mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-31 13:10:34 +00:00
Merge branch 'master' into wip-rua_scene
This commit is contained in:
commit
fddff1c24d
254 changed files with 8600 additions and 4441 deletions
|
@ -55,7 +55,15 @@ typedef struct server_s {
|
|||
double timeout;
|
||||
} server_t;
|
||||
|
||||
static cvar_t *sv_console_plugin;
|
||||
static char *sv_console_plugin;
|
||||
static cvar_t sv_console_plugin_cvar = {
|
||||
.name = "sv_console_plugin",
|
||||
.description =
|
||||
"Plugin used for the console",
|
||||
.default_value = "server",
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = 0, .value = &sv_console_plugin },
|
||||
};
|
||||
SERVER_PLUGIN_PROTOS
|
||||
static plugin_list_t server_plugin_list[] = {
|
||||
SERVER_PLUGIN_LIST
|
||||
|
@ -535,10 +543,9 @@ main (int argc, const char **argv)
|
|||
|
||||
PI_Init ();
|
||||
|
||||
sv_console_plugin = Cvar_Get ("sv_console_plugin", "server",
|
||||
CVAR_ROM, 0, "Plugin used for the console");
|
||||
Cvar_Register (&sv_console_plugin_cvar, 0, 0);
|
||||
PI_RegisterPlugins (server_plugin_list);
|
||||
Con_Init (sv_console_plugin->string);
|
||||
Con_Init (sv_console_plugin);
|
||||
if (con_module)
|
||||
con_module->data->console->cbuf = mst_cbuf;
|
||||
con_list_print = Sys_Printf;
|
||||
|
|
|
@ -38,7 +38,7 @@ extern int c_brush_polys, c_alias_polys;
|
|||
extern float gl_modelalpha;
|
||||
//extern vec3_t shadecolor;
|
||||
|
||||
extern void gl_multitexture_f (struct cvar_s *var);
|
||||
extern void gl_multitexture_f (void *data, const struct cvar_s *var);
|
||||
|
||||
void glrmain_init (void);
|
||||
void gl_R_RotateForEntity (struct entity_s *e);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef __QF_Vulkan_cvars_h
|
||||
#define __QF_Vulkan_cvars_h
|
||||
|
||||
extern struct cvar_s *vulkan_use_validation;
|
||||
extern struct cvar_s *vulkan_presentation_mode;
|
||||
extern struct cvar_s *vulkan_frame_count;
|
||||
extern int vulkan_use_validation;
|
||||
extern int vulkan_presentation_mode;
|
||||
extern int vulkan_frame_count;
|
||||
|
||||
#endif//__QF_Vulkan_cvars_h
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
struct exprval_s;
|
||||
struct exprctx_s;
|
||||
struct va_ctx_s;
|
||||
|
||||
typedef struct binop_s {
|
||||
int op;
|
||||
|
@ -52,10 +53,11 @@ typedef struct unop_s {
|
|||
typedef struct exprtype_s {
|
||||
const char *name;
|
||||
size_t size;
|
||||
const char *(*get_string) (const struct exprval_s *val, struct va_ctx_s *va_ctx);
|
||||
binop_t *binops;
|
||||
unop_t *unops;
|
||||
void *data;
|
||||
} exprtype_t;
|
||||
} __attribute__((designated_init)) exprtype_t;
|
||||
|
||||
typedef struct exprval_s {
|
||||
exprtype_t *type;
|
||||
|
@ -97,6 +99,7 @@ typedef struct exprctx_s {
|
|||
exprval_t *result;
|
||||
exprtab_t *symtab; // directly accessible symbols
|
||||
exprtab_t *external_variables; // accessible via $id
|
||||
const char *msg_prefix; // optional prefix for error messages
|
||||
struct memsuper_s *memsuper;
|
||||
const struct plitem_s *item;
|
||||
struct plitem_s *messages;
|
||||
|
@ -109,11 +112,15 @@ typedef struct exprenum_s {
|
|||
exprtab_t *symtab;
|
||||
} exprenum_t;
|
||||
|
||||
exprval_t *cexpr_assign_value (exprval_t *dst, const exprval_t *src,
|
||||
exprctx_t *context);
|
||||
int cexpr_parse_enum (exprenum_t *enm, const char *str,
|
||||
const exprctx_t *context, void *data);
|
||||
binop_t *cexpr_find_cast (exprtype_t *dst_type, exprtype_t *src_type) __attribute__((pure));
|
||||
exprval_t *cexpr_value (exprtype_t *type, exprctx_t *ctx);
|
||||
exprval_t *cexpr_value_reference (exprtype_t *type, void *data, exprctx_t *ctx);
|
||||
const char *cexpr_enum_get_string (const exprval_t *val, struct va_ctx_s *va_ctx) __attribute__((pure));
|
||||
const char *cexpr_flags_get_string (const exprval_t *val, struct va_ctx_s *va_ctx) __attribute__((pure));
|
||||
int cexpr_eval_string (const char *str, exprctx_t *context);
|
||||
void cexpr_error(exprctx_t *ctx, const char *fmt, ...) __attribute__((format(PRINTF,2,3)));
|
||||
|
||||
|
@ -148,6 +155,8 @@ extern exprtype_t cexpr_plitem;
|
|||
extern binop_t cexpr_array_binops[];
|
||||
extern binop_t cexpr_struct_binops[];
|
||||
extern binop_t cexpr_struct_pointer_binops[];
|
||||
extern binop_t cexpr_flag_binops[];
|
||||
extern unop_t cexpr_flag_unops[];
|
||||
|
||||
extern exprsym_t cexpr_lib_symbols[];
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ struct cbuf_interpreter_s *Cmd_GetProvider(const char *name);
|
|||
|
||||
|
||||
extern struct cbuf_args_s *cmd_args;
|
||||
extern struct cvar_s *cmd_warncmd;
|
||||
extern int cmd_warncmd;
|
||||
|
||||
///@}
|
||||
|
||||
|
|
|
@ -33,41 +33,30 @@
|
|||
*/
|
||||
///@{
|
||||
|
||||
#include "QF/cexpr.h"
|
||||
#include "QF/listener.h"
|
||||
#include "QF/qtypes.h"
|
||||
#include "QF/quakeio.h"
|
||||
|
||||
typedef struct cvar_s {
|
||||
const char *name; ///< The name of the cvar.
|
||||
const char *string; ///< The current cvar value as a string.
|
||||
const char *default_string; ///< The default value of the cvar.
|
||||
int flags; ///< Cvar flags
|
||||
/** Callback for when the cvar value changes.
|
||||
|
||||
This allows for more flexibility in what happens when a cvar is
|
||||
nodifed than can be achieved with flags alone. While a similar could
|
||||
be done using commands, a cvar with a callback and CVAR_ARCHIVE set
|
||||
allows the setting to be saved automatically.
|
||||
|
||||
\param var This cvar.
|
||||
*/
|
||||
void (*callback)(struct cvar_s *var);
|
||||
const char *name;
|
||||
const char *description;
|
||||
const char *default_value;
|
||||
unsigned flags;
|
||||
exprval_t value;
|
||||
int (*validator) (const struct cvar_s *var);
|
||||
struct cvar_listener_set_s *listeners;
|
||||
const char *description; ///< for "help" command
|
||||
float value; ///< The current cvar value as a float
|
||||
int int_val; ///< The current cvar value as an integer
|
||||
vec3_t vec; ///< The current cvar value as a vector
|
||||
struct cvar_s *next; ///< \internal Linked list of cvars.
|
||||
} cvar_t;
|
||||
|
||||
typedef struct cvar_listener_set_s LISTENER_SET_TYPE (cvar_t)
|
||||
cvar_listener_set_t;
|
||||
typedef void (*cvar_listener_t) (void *data, const cvar_t *cvar);
|
||||
|
||||
typedef int (*cvar_select_t) (const cvar_t *cvar, void *data);
|
||||
|
||||
typedef struct cvar_alias_s {
|
||||
char *name; ///< The name of the alias.
|
||||
cvar_t *cvar; ///< The cvar to which this alias refers
|
||||
struct cvar_alias_s *next; ///< \internal LInked list of aliases.
|
||||
} cvar_alias_t;
|
||||
|
||||
/** \name cvar_flags
|
||||
|
@ -88,16 +77,14 @@ typedef struct cvar_alias_s {
|
|||
///< (not implemented)
|
||||
#define CVAR_ROM 64 ///< display only, cannot be set
|
||||
#define CVAR_USER_CREATED 128 ///< created by a set command
|
||||
#define CVAR_REGISTERED 256 ///< var has been registered
|
||||
#define CVAR_LATCH 2048 ///< will change only when C code next does
|
||||
///< a Cvar_Get(), so it can't be changed
|
||||
///< (not implemented)
|
||||
///@}
|
||||
|
||||
|
||||
// Returns the Cvar if found, creates it with value if not. Description and
|
||||
// flags are always updated.
|
||||
cvar_t *Cvar_Get (const char *name, const char *value, int cvarflags,
|
||||
void (*callback)(cvar_t*), const char *description);
|
||||
void Cvar_Register (cvar_t *var, cvar_listener_t listener, void *data);
|
||||
|
||||
cvar_t *Cvar_FindAlias (const char *alias_name);
|
||||
|
||||
|
@ -107,17 +94,18 @@ void Cvar_AddListener (cvar_t *cvar, cvar_listener_t listener, void *data);
|
|||
void Cvar_RemoveListener (cvar_t *cvar, cvar_listener_t listener, void *data);
|
||||
|
||||
// equivelants to "<name> <variable>" typed at the console
|
||||
void Cvar_Set (cvar_t *var, const char *value);
|
||||
void Cvar_SetValue (cvar_t *var, float value);
|
||||
void Cvar_Set (const char *var, const char *value);
|
||||
void Cvar_SetVar (cvar_t *var, const char *value);
|
||||
|
||||
// allows you to change a Cvar's flags without a full Cvar_Get
|
||||
void Cvar_SetFlags (cvar_t *var, int cvarflags);
|
||||
|
||||
// returns 0 if not defined or non numeric
|
||||
float Cvar_VariableValue (const char *var_name);
|
||||
float Cvar_Value (const char *var_name);
|
||||
|
||||
// returns an empty string if not defined
|
||||
const char *Cvar_VariableString (const char *var_name);
|
||||
const char *Cvar_String (const char *var_name);
|
||||
const char *Cvar_VarString (const cvar_t *var);
|
||||
|
||||
// called by Cmd_ExecuteString when Cmd_Argv(0) doesn't match a known
|
||||
// command. Returns true if the command was a variable reference that
|
||||
|
@ -145,11 +133,11 @@ const char **Cvar_CompleteBuildList (const char *partial);
|
|||
// Returns a pointer to the Cvar, NULL if not found
|
||||
cvar_t *Cvar_FindVar (const char *var_name);
|
||||
|
||||
const cvar_t **Cvar_Select (cvar_select_t select, void *data);
|
||||
|
||||
void Cvar_Init_Hash (void);
|
||||
void Cvar_Init (void);
|
||||
|
||||
extern cvar_t *cvar_vars;
|
||||
|
||||
///@}
|
||||
|
||||
#endif//__QF_cvar_h
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
|
||||
typedef struct hashtab_s hashtab_t;
|
||||
typedef struct hashlink_s hashlink_t;
|
||||
typedef int (*hash_select_t) (void *ele, void *data);
|
||||
typedef void (*hash_action_t) (void *ele, void *data);
|
||||
|
||||
/** create a new hash table.
|
||||
\param tsize table size. larger values will give better distribution, but
|
||||
|
@ -213,6 +215,32 @@ size_t Hash_NumElements (hashtab_t *tab) __attribute__((pure));
|
|||
*/
|
||||
void **Hash_GetList (hashtab_t *tab);
|
||||
|
||||
/** list of all matching elements in the table.
|
||||
\param tab the table to search
|
||||
\param select function that tests for a match. The expected return value
|
||||
is 0 for no match, non-zero for a match.
|
||||
\param data context data passed to the \a select function
|
||||
\return a null terminated list of element pointers for all matchin
|
||||
elements in the table
|
||||
\note it is the caller's responsibilty to free() the list.
|
||||
|
||||
returned list is guaranteed to be in reverse order of insertion for
|
||||
elements with the same key. ie, deleting items from the list in list order
|
||||
will delete the correct items.
|
||||
*/
|
||||
void **Hash_Select (hashtab_t *tab, hash_select_t select, void *data);
|
||||
|
||||
|
||||
/** call a function for all elements in the table.
|
||||
\param tab the table to search
|
||||
\param action function to call for each elelemnt
|
||||
\param data context data passed to the \a action function
|
||||
|
||||
call order is guaranteed to be in reverse order of insertion for
|
||||
elements with the same key
|
||||
*/
|
||||
void Hash_ForEach (hashtab_t *tab, hash_action_t action, void *data);
|
||||
|
||||
/** dump statistics about the hash table
|
||||
\param tab the table to dump
|
||||
*/
|
||||
|
|
|
@ -125,16 +125,16 @@ int IN_GetButtonInfo (int devid, int button_num, in_buttoninfo_t *info);
|
|||
|
||||
void IN_ProcessEvents (void);
|
||||
|
||||
void IN_UpdateGrab (struct cvar_s *);
|
||||
void IN_UpdateGrab (int grab);
|
||||
|
||||
void IN_ClearStates (void);
|
||||
|
||||
extern struct cvar_s *in_grab;
|
||||
extern struct cvar_s *in_amp;
|
||||
extern struct cvar_s *in_pre_amp;
|
||||
extern struct cvar_s *in_mouse_accel;
|
||||
extern struct cvar_s *in_freelook;
|
||||
extern struct cvar_s *lookstrafe;
|
||||
extern int in_grab;
|
||||
extern float in_amp;
|
||||
extern float in_pre_amp;
|
||||
extern int in_mouse_accel;
|
||||
extern int in_freelook;
|
||||
extern int lookstrafe;
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -34,8 +34,8 @@
|
|||
#define JOY_MAX_AXES 32
|
||||
#define JOY_MAX_BUTTONS 64
|
||||
|
||||
extern struct cvar_s *joy_device; // Joystick device name
|
||||
extern struct cvar_s *joy_enable; // Joystick enabling flag
|
||||
extern char *joy_device;
|
||||
extern int joy_enable;
|
||||
|
||||
struct joy_axis_button {
|
||||
float threshold;
|
||||
|
@ -92,7 +92,7 @@ extern struct joy_button joy_buttons[JOY_MAX_BUTTONS];
|
|||
frame.
|
||||
|
||||
You should exit this function immediately if either joy_active or
|
||||
joy_enable->int_val are zero.
|
||||
joy_enable are zero.
|
||||
*/
|
||||
void JOY_Command (void);
|
||||
void joy_clear_axis (int i);
|
||||
|
@ -103,7 +103,7 @@ void joy_clear_axis (int i);
|
|||
Use this function to process joystick movements to move the player around.
|
||||
|
||||
You should exit this function immediately if either joy_active or
|
||||
joy_enable->int_val are zero.
|
||||
joy_enable are zero.
|
||||
*/
|
||||
void JOY_Move (void);
|
||||
|
||||
|
|
|
@ -449,10 +449,11 @@ void Mod_LeafPVS_mix (const mleaf_t *leaf, const model_t *model, byte defvis,
|
|||
|
||||
void Mod_Print (void);
|
||||
|
||||
extern struct cvar_s *gl_mesh_cache;
|
||||
extern struct cvar_s *gl_subdivide_size;
|
||||
extern struct cvar_s *gl_alias_render_tri;
|
||||
extern struct cvar_s *gl_textures_external;
|
||||
extern int gl_mesh_cache;
|
||||
extern float gl_subdivide_size;
|
||||
extern int gl_alias_render_tri;
|
||||
extern int gl_textures_external;
|
||||
extern int mod_sky_divide;
|
||||
extern int mod_lightmap_bytes;
|
||||
|
||||
#endif//__QF_model_h
|
||||
|
|
|
@ -98,7 +98,7 @@ typedef struct plugin_list_s {
|
|||
/*
|
||||
Plugin system variables
|
||||
*/
|
||||
extern struct cvar_s *fs_pluginpath;
|
||||
extern char *fs_pluginpath;
|
||||
|
||||
/*
|
||||
Function prototypes
|
||||
|
|
|
@ -136,9 +136,9 @@ typedef struct vid_render_data_s {
|
|||
int scr_copytop;
|
||||
int scr_copyeverything;
|
||||
int scr_fullupdate; // set to 0 to force full redraw
|
||||
void (*viewsize_callback) (struct cvar_s *);
|
||||
struct cvar_s *scr_viewsize;
|
||||
struct cvar_s *graphheight;
|
||||
void (*viewsize_callback) (int view_size);
|
||||
int *scr_viewsize;
|
||||
int *graphheight;
|
||||
float min_wateralpha;
|
||||
qboolean force_fullscreen;
|
||||
qboolean inhibit_viewmodel;
|
||||
|
|
|
@ -1829,11 +1829,12 @@ void PR_DumpState (progs_t *pr);
|
|||
void PR_StackTrace (progs_t *pr);
|
||||
void PR_Profile (progs_t *pr);
|
||||
|
||||
extern struct cvar_s *pr_debug;
|
||||
extern struct cvar_s *pr_deadbeef_ents;
|
||||
extern struct cvar_s *pr_deadbeef_locals;
|
||||
extern struct cvar_s *pr_boundscheck;
|
||||
extern struct cvar_s *pr_faultchecks;
|
||||
extern int pr_debug;
|
||||
extern char *pr_source_path;
|
||||
extern int pr_deadbeef_ents;
|
||||
extern int pr_deadbeef_locals;
|
||||
extern int pr_boundscheck;
|
||||
extern int pr_faultchecks;
|
||||
|
||||
///@}
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@
|
|||
extern int com_argc;
|
||||
extern const char **com_argv;
|
||||
extern const char *com_cmdline;
|
||||
extern struct cvar_s *fs_globalcfg;
|
||||
extern struct cvar_s *fs_usercfg;
|
||||
extern char *fs_globalcfg;
|
||||
extern char *fs_usercfg;
|
||||
|
||||
int COM_CheckParm (const char *parm) __attribute__((pure));
|
||||
void COM_AddParm (const char *parm);
|
||||
|
|
|
@ -181,7 +181,6 @@ struct progs_s;
|
|||
void R_Progs_Init (struct progs_s *pr);
|
||||
|
||||
dlight_t *R_AllocDlight (int key);
|
||||
void R_MaxDlightsCheck (struct cvar_s *var);
|
||||
void R_DecayLights (double frametime);
|
||||
void Fog_Update (float density, float red, float green, float blue,
|
||||
float time);
|
||||
|
|
|
@ -47,7 +47,10 @@ void SCR_SetFOV (float fov);
|
|||
void SCR_SetFullscreen (qboolean fullscreen);
|
||||
void SCR_SetBottomMargin (int lines);
|
||||
|
||||
extern struct cvar_s *hud_fps, *hud_time, *r_timegraph, *r_zgraph;
|
||||
extern int hud_fps;
|
||||
extern int hud_time;
|
||||
extern int r_timegraph;
|
||||
extern int r_zgraph;
|
||||
extern int scr_copytop;
|
||||
extern qboolean scr_skipupdate;
|
||||
|
||||
|
|
|
@ -40,12 +40,12 @@
|
|||
|
||||
struct dstring_s;
|
||||
|
||||
extern struct cvar_s *sys_nostdout;
|
||||
extern struct cvar_s *sys_extrasleep;
|
||||
extern struct cvar_s *sys_dead_sleep;
|
||||
extern struct cvar_s *sys_sleep;
|
||||
extern int sys_nostdout;
|
||||
extern int sys_extrasleep;
|
||||
extern int sys_dead_sleep;
|
||||
extern int sys_sleep;
|
||||
|
||||
extern struct cvar_s *developer;
|
||||
extern int developer;
|
||||
|
||||
|
||||
extern const char sys_char_map[256];
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
#ifndef __QF_teamplay_h
|
||||
#define __QF_teamplay_h
|
||||
|
||||
extern struct cvar_s *cl_parsesay;
|
||||
extern struct cvar_s *cl_nofake;
|
||||
extern struct cvar_s *cl_freply;
|
||||
extern int cl_parsesay;
|
||||
extern int cl_nofake;
|
||||
extern float cl_freply;
|
||||
|
||||
typedef const char *(*ffunc_t) (char *args);
|
||||
typedef struct freply_s {
|
||||
|
|
|
@ -66,6 +66,8 @@ typedef enum {
|
|||
grav_northwest, ///< +ve X right, +ve Y down, -X left, -ve Y up
|
||||
} grav_t;
|
||||
|
||||
extern struct exprtype_s grav_t_type;
|
||||
|
||||
/** The view object.
|
||||
*/
|
||||
typedef struct view_s view_t;
|
||||
|
|
|
@ -40,7 +40,7 @@ typedef struct chasestate_s {
|
|||
vec3_t player_angles;
|
||||
} chasestate_t;
|
||||
|
||||
extern struct cvar_s *chase_active;
|
||||
extern int chase_active;
|
||||
|
||||
void Chase_Init_Cvars (void);
|
||||
void Chase_Reset (void);
|
||||
|
|
|
@ -25,11 +25,28 @@
|
|||
Boston, MA 02111-1307, USA
|
||||
|
||||
*/
|
||||
#ifndef __client_hud_h_
|
||||
#define __client_hud_h_
|
||||
#ifndef __client_hud_h
|
||||
#define __client_hud_h
|
||||
|
||||
extern struct cvar_s *hud_sbar;
|
||||
extern struct cvar_s *hud_scoreboard_gravity;
|
||||
extern struct cvar_s *hud_swap;
|
||||
extern int hud_sb_lines;
|
||||
|
||||
#endif // __client_hud_h_
|
||||
extern int hud_sbar;
|
||||
extern int hud_swap;
|
||||
|
||||
extern struct view_s *sbar_view;
|
||||
extern struct view_s *sbar_inventory_view;
|
||||
extern struct view_s *sbar_frags_view;
|
||||
|
||||
extern struct view_s *hud_view;
|
||||
extern struct view_s *hud_inventory_view;
|
||||
extern struct view_s *hud_armament_view;
|
||||
extern struct view_s *hud_frags_view;
|
||||
|
||||
extern struct view_s *hud_overlay_view;
|
||||
extern struct view_s *hud_stuff_view;
|
||||
extern struct view_s *hud_main_view;
|
||||
|
||||
void HUD_Init_Cvars (void);
|
||||
void HUD_Calc_sb_lines (int view_size);
|
||||
|
||||
#endif//__client_hud_h
|
||||
|
|
|
@ -33,22 +33,22 @@
|
|||
|
||||
struct cbuf_s;
|
||||
|
||||
extern struct cvar_s *cl_upspeed;
|
||||
extern struct cvar_s *cl_forwardspeed;
|
||||
extern struct cvar_s *cl_backspeed;
|
||||
extern struct cvar_s *cl_sidespeed;
|
||||
extern float cl_upspeed;
|
||||
extern float cl_forwardspeed;
|
||||
extern float cl_backspeed;
|
||||
extern float cl_sidespeed;
|
||||
|
||||
extern struct cvar_s *cl_movespeedkey;
|
||||
extern float cl_movespeedkey;
|
||||
|
||||
extern struct cvar_s *cl_yawspeed;
|
||||
extern struct cvar_s *cl_pitchspeed;
|
||||
extern float cl_yawspeed;
|
||||
extern float cl_pitchspeed;
|
||||
|
||||
extern struct cvar_s *cl_anglespeedkey;
|
||||
extern float cl_anglespeedkey;
|
||||
|
||||
extern struct cvar_s *m_pitch;
|
||||
extern struct cvar_s *m_yaw;
|
||||
extern struct cvar_s *m_forward;
|
||||
extern struct cvar_s *m_side;
|
||||
extern float m_pitch;
|
||||
extern float m_yaw;
|
||||
extern float m_forward;
|
||||
extern float m_side;
|
||||
|
||||
#define FORWARD 0
|
||||
#define SIDE 1
|
||||
|
@ -59,7 +59,7 @@ typedef struct movestate_s {
|
|||
vec4f_t angles;
|
||||
} movestate_t;
|
||||
|
||||
#define freelook (in_mlook.state & 1 || in_freelook->int_val)
|
||||
#define freelook (in_mlook.state & 1 || in_freelook)
|
||||
|
||||
struct viewstate_s;
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ extern int win_canalttab;
|
|||
extern DEVMODE win_gdevmode;
|
||||
extern struct sw_ctx_s *win_sw_context;
|
||||
extern int win_minimized;
|
||||
extern struct cvar_s *vid_ddraw;
|
||||
extern int vid_ddraw;
|
||||
extern int win_center_x, win_center_y;
|
||||
extern RECT win_rect;
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ void X11_CloseDisplay (void);
|
|||
void X11_CreateNullCursor (void);
|
||||
void X11_CreateWindow (int, int);
|
||||
void X11_ForceViewPort (void);
|
||||
void X11_UpdateFullscreen (int fullscreen);
|
||||
void X11_Init_Cvars (void);
|
||||
void X11_OpenDisplay (void);
|
||||
void X11_ProcessEvent (void);
|
||||
|
|
|
@ -112,8 +112,8 @@ typedef struct
|
|||
int color;
|
||||
} zpointdesc_t;
|
||||
|
||||
extern struct cvar_s *r_drawflat;
|
||||
extern int r_framecount; // sequence # of current frame since Quake
|
||||
extern int r_drawflat;
|
||||
extern int r_framecount; // sequence # of current frame since Quake
|
||||
// started
|
||||
extern qboolean r_drawpolys; // 1 if driver wants clipped polygons
|
||||
// rather than a span list
|
||||
|
|
|
@ -62,7 +62,7 @@ extern netadr_t net_loopback_adr;
|
|||
extern netadr_t net_from; // address of who sent the packet
|
||||
extern struct msg_s *net_message;
|
||||
|
||||
extern struct cvar_s *qport;
|
||||
extern int qport;
|
||||
|
||||
int Net_Log_Init (const char **sound_precache, int server);
|
||||
void Net_LogPrintf (const char *fmt, ...) __attribute__ ((format (PRINTF, 1, 2)));
|
||||
|
@ -72,7 +72,7 @@ void Net_LogStop (void *data);
|
|||
void Analyze_Client_Packet (const byte * data, int len, int has_sequence);
|
||||
void Analyze_Server_Packet (const byte * data, int len, int has_sequence);
|
||||
|
||||
extern struct cvar_s *net_packetlog;
|
||||
extern int net_packetlog;
|
||||
///@}
|
||||
|
||||
/** \defgroup qw-udp QuakeWorld udp support.
|
||||
|
|
|
@ -385,7 +385,7 @@ extern qboolean slistInProgress;
|
|||
extern qboolean slistSilent;
|
||||
extern qboolean slistLocal;
|
||||
|
||||
extern struct cvar_s *hostname;
|
||||
extern char *hostname;
|
||||
|
||||
extern QFile *vcrFile;
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ typedef struct {
|
|||
float entgravity;
|
||||
} movevars_t;
|
||||
|
||||
extern struct cvar_s *no_pogo_stick;
|
||||
extern int no_pogo_stick;
|
||||
extern movevars_t movevars;
|
||||
extern playermove_t pmove;
|
||||
extern int onground;
|
||||
|
|
169
include/r_cvar.h
169
include/r_cvar.h
|
@ -1,93 +1,92 @@
|
|||
#include "QF/mathlib.h"
|
||||
|
||||
extern void gl_overbright_f (struct cvar_s *cvar);
|
||||
extern void gl_overbright_f (void *data, const struct cvar_s *cvar);
|
||||
|
||||
extern struct cvar_s *cl_crossx;
|
||||
extern struct cvar_s *cl_crossy;
|
||||
extern struct cvar_s *cl_verstring;
|
||||
extern struct cvar_s *crosshair;
|
||||
extern struct cvar_s *crosshaircolor;
|
||||
extern int cl_crossx;
|
||||
extern int cl_crossy;
|
||||
extern char *cl_verstring;
|
||||
extern int crosshair;
|
||||
extern int crosshaircolor;
|
||||
extern quat_t crosshair_color;
|
||||
|
||||
extern struct cvar_s *d_mipcap;
|
||||
extern struct cvar_s *d_mipscale;
|
||||
extern float d_mipcap;
|
||||
extern float d_mipscale;
|
||||
|
||||
extern struct cvar_s *gl_affinemodels;
|
||||
extern struct cvar_s *gl_anisotropy;
|
||||
extern struct cvar_s *gl_clear;
|
||||
extern struct cvar_s *gl_conspin;
|
||||
extern struct cvar_s *gl_constretch;
|
||||
extern struct cvar_s *gl_dlight_polyblend;
|
||||
extern struct cvar_s *gl_dlight_smooth;
|
||||
extern struct cvar_s *gl_fb_bmodels;
|
||||
extern struct cvar_s *gl_fb_models;
|
||||
extern struct cvar_s *gl_finish;
|
||||
extern struct cvar_s *gl_keeptjunctions;
|
||||
extern struct cvar_s *gl_lerp_anim;
|
||||
extern struct cvar_s *gl_lightmap_align;
|
||||
extern struct cvar_s *gl_lightmap_subimage;
|
||||
extern struct cvar_s *gl_max_size;
|
||||
extern struct cvar_s *gl_multitexture;
|
||||
extern struct cvar_s *gl_nocolors;
|
||||
extern struct cvar_s *gl_overbright;
|
||||
extern struct cvar_s *gl_particle_mip;
|
||||
extern struct cvar_s *gl_particle_size;
|
||||
extern struct cvar_s *gl_picmip;
|
||||
extern struct cvar_s *gl_playermip;
|
||||
extern struct cvar_s *gl_reporttjunctions;
|
||||
extern struct cvar_s *gl_sky_clip;
|
||||
extern struct cvar_s *gl_sky_debug;
|
||||
extern struct cvar_s *gl_sky_divide;
|
||||
extern struct cvar_s *gl_sky_multipass;
|
||||
extern struct cvar_s *gl_tessellate;
|
||||
extern struct cvar_s *gl_texsort;
|
||||
extern struct cvar_s *gl_textures_bgra;
|
||||
extern struct cvar_s *gl_triplebuffer;
|
||||
extern struct cvar_s *gl_vector_light;
|
||||
extern int gl_affinemodels;
|
||||
extern float gl_anisotropy;
|
||||
extern int gl_clear;
|
||||
extern float gl_conspin;
|
||||
extern int gl_constretch;
|
||||
extern int gl_dlight_polyblend;
|
||||
extern int gl_dlight_smooth;
|
||||
extern int gl_fb_bmodels;
|
||||
extern int gl_fb_models;
|
||||
extern int gl_finish;
|
||||
extern int gl_keeptjunctions;
|
||||
extern int gl_lerp_anim;
|
||||
extern int gl_lightmap_align;
|
||||
extern int gl_lightmap_subimage;
|
||||
extern int gl_max_size;
|
||||
extern int gl_multitexture;
|
||||
extern int gl_nocolors;
|
||||
extern int gl_overbright;
|
||||
extern int gl_particle_mip;
|
||||
extern int gl_particle_size;
|
||||
extern int gl_picmip;
|
||||
extern int gl_playermip;
|
||||
extern int gl_reporttjunctions;
|
||||
extern int gl_sky_clip;
|
||||
extern int gl_sky_debug;
|
||||
extern int gl_sky_multipass;
|
||||
extern int gl_tessellate;
|
||||
extern int gl_texsort;
|
||||
extern int gl_textures_bgra;
|
||||
extern int gl_triplebuffer;
|
||||
extern int gl_vector_light;
|
||||
|
||||
extern struct cvar_s *r_aliasstats;
|
||||
extern struct cvar_s *r_aliastransadj;
|
||||
extern struct cvar_s *r_aliastransbase;
|
||||
extern struct cvar_s *r_clearcolor;
|
||||
extern struct cvar_s *r_dlight_lightmap;
|
||||
extern struct cvar_s *r_drawentities;
|
||||
extern struct cvar_s *r_drawexplosions;
|
||||
extern struct cvar_s *r_drawviewmodel;
|
||||
extern struct cvar_s *r_dspeeds;
|
||||
extern struct cvar_s *r_dynamic;
|
||||
extern struct cvar_s *r_explosionclip;
|
||||
extern struct cvar_s *r_farclip;
|
||||
extern struct cvar_s *r_firecolor;
|
||||
extern struct cvar_s *r_flatlightstyles;
|
||||
extern struct cvar_s *r_graphheight;
|
||||
extern struct cvar_s *r_lightmap_components;
|
||||
extern struct cvar_s *r_maxedges;
|
||||
extern struct cvar_s *r_maxsurfs;
|
||||
extern struct cvar_s *r_mirroralpha;
|
||||
extern struct cvar_s *r_nearclip;
|
||||
extern struct cvar_s *r_norefresh;
|
||||
extern struct cvar_s *r_novis;
|
||||
extern struct cvar_s *r_numedges;
|
||||
extern struct cvar_s *r_numsurfs;
|
||||
extern struct cvar_s *r_particles;
|
||||
extern struct cvar_s *r_particles_max;
|
||||
extern struct cvar_s *r_particles_nearclip;
|
||||
extern struct cvar_s *r_reportedgeout;
|
||||
extern struct cvar_s *r_reportsurfout;
|
||||
extern struct cvar_s *r_shadows;
|
||||
extern struct cvar_s *r_skyname;
|
||||
extern struct cvar_s *r_speeds;
|
||||
extern struct cvar_s *r_timegraph;
|
||||
extern struct cvar_s *r_wateralpha;
|
||||
extern struct cvar_s *r_waterripple;
|
||||
extern struct cvar_s *r_waterwarp;
|
||||
extern struct cvar_s *r_zgraph;
|
||||
extern int r_aliasstats;
|
||||
extern float r_aliastransadj;
|
||||
extern float r_aliastransbase;
|
||||
extern int r_clearcolor;
|
||||
extern int r_dlight_lightmap;
|
||||
extern int r_drawentities;
|
||||
extern int r_drawexplosions;
|
||||
extern int r_drawviewmodel;
|
||||
extern int r_dspeeds;
|
||||
extern int r_dynamic;
|
||||
extern int r_explosionclip;
|
||||
extern float r_farclip;
|
||||
extern vec4f_t r_firecolor;
|
||||
extern int r_flatlightstyles;
|
||||
extern int r_graphheight;
|
||||
extern int r_lightmap_components;
|
||||
extern int r_maxedges;
|
||||
extern int r_maxsurfs;
|
||||
extern float r_mirroralpha;
|
||||
extern float r_nearclip;
|
||||
extern int r_norefresh;
|
||||
extern int r_novis;
|
||||
extern int r_numedges;
|
||||
extern int r_numsurfs;
|
||||
extern int r_particles;
|
||||
extern int r_particles_max;
|
||||
extern float r_particles_nearclip;
|
||||
extern int r_reportedgeout;
|
||||
extern int r_reportsurfout;
|
||||
extern int r_shadows;
|
||||
extern char *r_skyname;
|
||||
extern int r_speeds;
|
||||
extern int r_timegraph;
|
||||
extern float r_wateralpha;
|
||||
extern float r_waterripple;
|
||||
extern int r_waterwarp;
|
||||
extern int r_zgraph;
|
||||
|
||||
extern struct cvar_s *scr_fov;
|
||||
extern struct cvar_s *scr_fisheye;
|
||||
extern struct cvar_s *scr_fviews;
|
||||
extern struct cvar_s *scr_ffov;
|
||||
extern struct cvar_s *scr_showpause;
|
||||
extern struct cvar_s *scr_showram;
|
||||
extern struct cvar_s *scr_showturtle;
|
||||
extern struct cvar_s *scr_viewsize;
|
||||
extern float scr_fov;
|
||||
extern int scr_fisheye;
|
||||
extern int scr_fviews;
|
||||
extern float scr_ffov;
|
||||
extern int scr_showpause;
|
||||
extern int scr_showram;
|
||||
extern int scr_showturtle;
|
||||
extern int scr_viewsize;
|
||||
|
|
|
@ -46,16 +46,12 @@ typedef enum {
|
|||
struct entity_s;
|
||||
|
||||
void R_PushDlights (const vec3_t entorigin);
|
||||
struct cvar_s;
|
||||
void R_MaxDlightsCheck (struct cvar_s *var);
|
||||
void R_MaxDlightsCheck (int max_dlights);
|
||||
void R_Particles_Init_Cvars (void);
|
||||
void R_InitBubble (void);
|
||||
|
||||
void R_InitParticles (void);
|
||||
void R_ClearParticles (void);
|
||||
struct cvar_s;
|
||||
void R_MaxParticlesCheck (struct cvar_s *r_particles,
|
||||
struct cvar_s *r_particles_max);
|
||||
void R_InitSprites (void);
|
||||
|
||||
#endif // _R_DYNAMIC_H
|
||||
|
|
|
@ -66,22 +66,22 @@ typedef struct {
|
|||
|
||||
//===========================================================================
|
||||
|
||||
extern struct cvar_s *r_speeds;
|
||||
extern struct cvar_s *r_timegraph;
|
||||
extern struct cvar_s *r_graphheight;
|
||||
extern struct cvar_s *r_clearcolor;
|
||||
extern struct cvar_s *r_waterwarp;
|
||||
extern struct cvar_s *r_drawentities;
|
||||
extern struct cvar_s *r_aliasstats;
|
||||
extern struct cvar_s *r_dspeeds;
|
||||
extern struct cvar_s *r_drawflat;
|
||||
extern struct cvar_s *r_ambient;
|
||||
extern struct cvar_s *r_reportsurfout;
|
||||
extern struct cvar_s *r_maxsurfs;
|
||||
extern struct cvar_s *r_numsurfs;
|
||||
extern struct cvar_s *r_reportedgeout;
|
||||
extern struct cvar_s *r_maxedges;
|
||||
extern struct cvar_s *r_numedges;
|
||||
extern int r_speeds;
|
||||
extern int r_timegraph;
|
||||
extern int r_graphheight;
|
||||
extern int r_clearcolor;
|
||||
extern int r_waterwarp;
|
||||
extern int r_drawentities;
|
||||
extern int r_aliasstats;
|
||||
extern int r_dspeeds;
|
||||
extern int r_drawflat;
|
||||
extern int r_ambient;
|
||||
extern int r_reportsurfout;
|
||||
extern int r_maxsurfs;
|
||||
extern int r_numsurfs;
|
||||
extern int r_reportedgeout;
|
||||
extern int r_maxedges;
|
||||
extern int r_numedges;
|
||||
|
||||
extern float cl_wateralpha;
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ extern float pixelAspect;
|
|||
|
||||
extern int r_drawnpolycount;
|
||||
|
||||
extern struct cvar_s *r_clearcolor;
|
||||
extern int r_clearcolor;
|
||||
|
||||
extern int sintable[SIN_BUFFER_SIZE];
|
||||
extern int intsintable[SIN_BUFFER_SIZE];
|
||||
|
|
|
@ -38,7 +38,7 @@ extern int sb_lines; // scan lines to draw
|
|||
void Sbar_Init (void);
|
||||
|
||||
struct cvar_s;
|
||||
void Sbar_DMO_Init_f (struct cvar_s *var);
|
||||
void Sbar_DMO_Init_f (void *data, const struct cvar_s *var);
|
||||
|
||||
void Sbar_Changed (void);
|
||||
// call whenever any of the client stats represented on the sbar changes
|
||||
|
|
|
@ -229,7 +229,7 @@ struct channel_s {
|
|||
//@}
|
||||
};
|
||||
|
||||
extern struct cvar_s *snd_volume;
|
||||
extern float snd_volume;
|
||||
|
||||
extern snd_render_data_t snd_render_data;
|
||||
#define PAINTBUFFER_SIZE 512
|
||||
|
|
|
@ -4,6 +4,14 @@
|
|||
#include "QF/vid.h"
|
||||
#include "QF/plugin/vid_render.h"
|
||||
|
||||
typedef struct vid_system_s {
|
||||
void (*init) (byte *palette, byte *colormap);
|
||||
void (*init_cvars) (void);
|
||||
void (*update_fullscreen) (int fullscreen);
|
||||
} vid_system_t;
|
||||
|
||||
extern vid_system_t vid_system;
|
||||
|
||||
typedef struct vid_internal_s {
|
||||
void (*flush_caches) (void *data);
|
||||
void (*init_buffers) (void *data);
|
||||
|
@ -20,15 +28,15 @@ typedef struct vid_internal_s {
|
|||
struct vulkan_ctx_s *(*vulkan_context) (void);
|
||||
} vid_internal_t;
|
||||
|
||||
extern struct cvar_s *vid_fullscreen;
|
||||
extern struct cvar_s *vid_system_gamma;
|
||||
extern struct cvar_s *vid_gamma;
|
||||
extern int vid_fullscreen;
|
||||
extern int vid_system_gamma;
|
||||
extern float vid_gamma;
|
||||
|
||||
void VID_GetWindowSize (int def_w, int def_h);
|
||||
|
||||
void VID_InitGamma (const byte *);
|
||||
qboolean VID_SetGamma (double);
|
||||
void VID_UpdateGamma (struct cvar_s *);
|
||||
void VID_UpdateGamma (void);
|
||||
|
||||
void VID_MakeColormaps (void);
|
||||
|
||||
|
|
|
@ -106,13 +106,13 @@ typedef struct vulkan_ctx_s {
|
|||
|
||||
#define qfvPushDebug(ctx, x) \
|
||||
do { \
|
||||
if (developer->int_val & SYS_vulkan) { \
|
||||
if (developer & SYS_vulkan) { \
|
||||
DARRAY_APPEND(&(ctx)->instance->debug_stack, (x)); \
|
||||
} \
|
||||
} while (0)
|
||||
#define qfvPopDebug(ctx) \
|
||||
do { \
|
||||
if (developer->int_val & SYS_vulkan) { \
|
||||
if (developer & SYS_vulkan) { \
|
||||
__auto_type ds = &(ctx)->instance->debug_stack; \
|
||||
DARRAY_REMOVE_AT(ds, ds->size - 1); \
|
||||
} \
|
||||
|
|
|
@ -40,7 +40,15 @@
|
|||
#include "QF/plugin/general.h"
|
||||
#include "QF/plugin/cd.h"
|
||||
|
||||
cvar_t *cd_plugin;
|
||||
char *cd_plugin;
|
||||
static cvar_t cd_plugin_cvar = {
|
||||
.name = "cd_plugin",
|
||||
.description =
|
||||
"CD Plugin to use",
|
||||
.default_value = CD_DEFAULT,
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = 0, .value = &cd_plugin },
|
||||
};
|
||||
plugin_t *cdmodule = NULL;
|
||||
|
||||
CD_PLUGIN_PROTOS
|
||||
|
@ -96,19 +104,18 @@ CDAudio_Init (void)
|
|||
Sys_RegisterShutdown (CDAudio_shutdown, 0);
|
||||
|
||||
PI_RegisterPlugins (cd_plugin_list);
|
||||
cd_plugin = Cvar_Get ("cd_plugin", CD_DEFAULT, CVAR_ROM, NULL,
|
||||
"CD Plugin to use");
|
||||
Cvar_Register (&cd_plugin_cvar, 0, 0);
|
||||
|
||||
if (COM_CheckParm ("-nocdaudio"))
|
||||
return 0;
|
||||
|
||||
if (!*cd_plugin->string) {
|
||||
if (!*cd_plugin) {
|
||||
Sys_Printf ("Not loading CD due to no driver\n");
|
||||
return 0;
|
||||
}
|
||||
cdmodule = PI_LoadPlugin ("cd", cd_plugin->string);
|
||||
cdmodule = PI_LoadPlugin ("cd", cd_plugin);
|
||||
if (!cdmodule) {
|
||||
Sys_Printf ("Loading of cd module: %s failed!\n", cd_plugin->string);
|
||||
Sys_Printf ("Loading of cd module: %s failed!\n", cd_plugin);
|
||||
return -1;
|
||||
}
|
||||
Cmd_AddCommand (
|
||||
|
|
|
@ -84,15 +84,31 @@ static plitem_t *play_list; // string or array of strings
|
|||
static int play_pos = -1; // position in play_list (0 for string)
|
||||
// -1 = invalid (both)
|
||||
|
||||
static cvar_t *bgmvolume; // volume cvar
|
||||
static cvar_t *mus_ogglist; // tracklist cvar
|
||||
static float bgmvolume;
|
||||
static cvar_t bgmvolume_cvar = {
|
||||
.name = "bgmvolume",
|
||||
.description =
|
||||
"Volume of CD music",
|
||||
.default_value = "1",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_float, .value = &bgmvolume },
|
||||
};
|
||||
static char *mus_ogglist;
|
||||
static cvar_t mus_ogglist_cvar = {
|
||||
.name = "mus_ogglist",
|
||||
.description =
|
||||
"filename of track to music file map",
|
||||
.default_value = "tracklist.cfg",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = 0, .value = &mus_ogglist },
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
set_volume (void)
|
||||
{
|
||||
if (cd_channel && cd_channel->sfx) {
|
||||
int vol = bgmvolume->value * 255;
|
||||
int vol = bgmvolume * 255;
|
||||
|
||||
cd_channel->master_vol = vol;
|
||||
cd_channel->leftvol = cd_channel->rightvol = cd_channel->master_vol;
|
||||
|
@ -151,14 +167,14 @@ Load_Tracklist (void)
|
|||
ogglistvalid = false;
|
||||
mus_enabled = false;
|
||||
|
||||
if (!mus_ogglist || strequal (mus_ogglist->string, "none")) {
|
||||
if (!mus_ogglist || strequal (mus_ogglist, "none")) {
|
||||
return -1; // bail if we don't have a valid filename
|
||||
}
|
||||
|
||||
oggfile = QFS_FOpenFile (mus_ogglist->string);
|
||||
oggfile = QFS_FOpenFile (mus_ogglist);
|
||||
if (!oggfile) {
|
||||
Sys_Printf ("Mus_OggInit: open of file \"%s\" failed\n",
|
||||
mus_ogglist->string);
|
||||
mus_ogglist);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -324,7 +340,7 @@ I_OGGMus_Info (void)
|
|||
return;
|
||||
|
||||
Sys_Printf ("\n" "Tracklist loaded from file:\n%s\n"
|
||||
"---------------------------\n", mus_ogglist->string);
|
||||
"---------------------------\n", mus_ogglist);
|
||||
|
||||
/* loop, and count up the Highest key number. */
|
||||
for (iter = 1, count = 0; count < keycount && iter <= 99 ; iter++) {
|
||||
|
@ -439,15 +455,14 @@ I_OGGMus_Update (void)
|
|||
|
||||
/* called when the mus_ogglist cvar is changed */
|
||||
static void
|
||||
Mus_OggChange (cvar_t *ogglist)
|
||||
Mus_OggChange (void *data, const cvar_t *cvar)
|
||||
{
|
||||
mus_ogglist = ogglist;
|
||||
Load_Tracklist ();
|
||||
}
|
||||
|
||||
/* change volume on sound object */
|
||||
static void
|
||||
Mus_VolChange (cvar_t *bgmvolume)
|
||||
Mus_VolChange (void *data, const cvar_t *bgmvolume)
|
||||
{
|
||||
set_volume ();
|
||||
}
|
||||
|
@ -456,18 +471,15 @@ static void
|
|||
Mus_gamedir (int phase)
|
||||
{
|
||||
if (phase)
|
||||
Mus_OggChange (mus_ogglist);
|
||||
Load_Tracklist ();
|
||||
}
|
||||
|
||||
static void
|
||||
I_OGGMus_Init (void)
|
||||
{
|
||||
/* check list file cvar, open list file, create map, close file. */
|
||||
mus_ogglist = Cvar_Get ("mus_ogglist", "tracklist.cfg", CVAR_NONE,
|
||||
Mus_OggChange,
|
||||
"filename of track to music file map");
|
||||
bgmvolume = Cvar_Get ("bgmvolume", "1.0", CVAR_ARCHIVE, Mus_VolChange,
|
||||
"Volume of CD music");
|
||||
Cvar_Register (&mus_ogglist_cvar, Mus_OggChange, 0);
|
||||
Cvar_Register (&bgmvolume_cvar, Mus_VolChange, 0);
|
||||
QFS_GamedirCallback (Mus_gamedir);
|
||||
}
|
||||
|
||||
|
|
|
@ -77,8 +77,24 @@ static byte playTrack;
|
|||
static byte maxTrack;
|
||||
static int cdfile = -1;
|
||||
|
||||
static cvar_t *mus_cddevice;
|
||||
static cvar_t *bgmvolume;
|
||||
static char *mus_cddevice;
|
||||
static cvar_t mus_cddevice_cvar = {
|
||||
.name = "mus_cddevice",
|
||||
.description =
|
||||
"device to use for CD music",
|
||||
.default_value = "/dev/cdrom",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = 0, .value = &mus_cddevice },
|
||||
};
|
||||
static float bgmvolume;
|
||||
static cvar_t bgmvolume_cvar = {
|
||||
.name = "bgmvolume",
|
||||
.description =
|
||||
"Volume of CD music",
|
||||
.default_value = "1",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_float, .value = &bgmvolume },
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
|
@ -382,14 +398,14 @@ I_CDAudio_Update (void)
|
|||
if (!mus_enabled)
|
||||
return;
|
||||
|
||||
if (bgmvolume->value != cdvolume) {
|
||||
if (bgmvolume != cdvolume) {
|
||||
if (cdvolume) {
|
||||
Cvar_SetValue (bgmvolume, 0.0);
|
||||
cdvolume = bgmvolume->value;
|
||||
bgmvolume = 0.0;
|
||||
cdvolume = bgmvolume;
|
||||
I_CDAudio_Pause ();
|
||||
} else {
|
||||
Cvar_SetValue (bgmvolume, 1.0);
|
||||
cdvolume = bgmvolume->value;
|
||||
bgmvolume = 1.0;
|
||||
cdvolume = bgmvolume;
|
||||
I_CDAudio_Resume ();
|
||||
}
|
||||
}
|
||||
|
@ -412,20 +428,20 @@ I_CDAudio_Update (void)
|
|||
}
|
||||
|
||||
static void
|
||||
Mus_CDChange (cvar_t *mus_cdaudio)
|
||||
Mus_CDChange (void *data, const cvar_t *cvar)
|
||||
{
|
||||
int i;
|
||||
|
||||
I_CDAudio_Shutdown ();
|
||||
if (strequal (mus_cdaudio->string, "none")) {
|
||||
if (strequal (mus_cddevice, "none")) {
|
||||
return;
|
||||
}
|
||||
|
||||
cdfile = open (mus_cdaudio->string, O_RDONLY | O_NONBLOCK);
|
||||
cdfile = open (mus_cddevice, O_RDONLY | O_NONBLOCK);
|
||||
if (cdfile == -1) {
|
||||
Sys_MaskPrintf (SYS_snd,
|
||||
"Mus_CDInit: open device \"%s\" failed (error %i)\n",
|
||||
mus_cdaudio->string, errno);
|
||||
mus_cddevice, errno);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -443,10 +459,8 @@ Mus_CDChange (cvar_t *mus_cdaudio)
|
|||
static void
|
||||
I_CDAudio_Init (void)
|
||||
{
|
||||
mus_cddevice = Cvar_Get ("mus_cddevice", "/dev/cdrom", CVAR_NONE,
|
||||
Mus_CDChange, "device to use for CD music");
|
||||
bgmvolume = Cvar_Get ("bgmvolume", "1", CVAR_ARCHIVE, NULL,
|
||||
"Volume of CD music");
|
||||
Cvar_Register (&mus_cddevice_cvar, Mus_CDChange, 0);
|
||||
Cvar_Register (&bgmvolume_cvar, 0, 0);
|
||||
}
|
||||
|
||||
static general_funcs_t plugin_info_general_funcs = {
|
||||
|
|
|
@ -64,7 +64,15 @@ static qboolean playLooping = false;
|
|||
static SDL_CD *cd_id;
|
||||
static float cdvolume = 1.0;
|
||||
|
||||
static cvar_t *bgmvolume;
|
||||
static float bgmvolume;
|
||||
static cvar_t bgmvolume_cvar = {
|
||||
.name = "bgmvolume",
|
||||
.description =
|
||||
"Volume of CD music",
|
||||
.default_value = "1",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_float, .value = &bgmvolume },
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
|
@ -168,15 +176,15 @@ I_CDAudio_Update (void)
|
|||
{
|
||||
if (!cd_id || !enabled)
|
||||
return;
|
||||
if (bgmvolume->value != cdvolume) {
|
||||
if (bgmvolume != cdvolume) {
|
||||
if (cdvolume) {
|
||||
Cvar_SetValue (bgmvolume, 0.0);
|
||||
bgmvolume = 0.0;
|
||||
I_CDAudio_Pause ();
|
||||
} else {
|
||||
Cvar_SetValue (bgmvolume, 1.0);
|
||||
bgmvolume = 1.0;
|
||||
I_CDAudio_Resume ();
|
||||
}
|
||||
cdvolume = bgmvolume->value;
|
||||
cdvolume = bgmvolume;
|
||||
return;
|
||||
}
|
||||
if (playLooping && (SDL_CDStatus (cd_id) != CD_PLAYING)
|
||||
|
@ -276,8 +284,7 @@ I_CDAudio_Init (void)
|
|||
cdValid = false;
|
||||
}
|
||||
|
||||
bgmvolume = Cvar_Get ("bgmvolume", "1", CVAR_ARCHIVE, NULL,
|
||||
"Volume of CD music");
|
||||
Cvar_Register (&bgmvolume_cvar, 0, 0);
|
||||
|
||||
Sys_Printf ("CD Audio Initialized.\n");
|
||||
}
|
||||
|
|
|
@ -63,7 +63,15 @@ static byte playTrack;
|
|||
static char cd_dev[] = "/dev/cdrom";
|
||||
|
||||
static CDPLAYER *cdp = NULL;
|
||||
static cvar_t *bgmvolume;
|
||||
static float bgmvolume;
|
||||
static cvar_t bgmvolume_cvar = {
|
||||
.name = "bgmvolume",
|
||||
.description =
|
||||
"Volume of CD music",
|
||||
.default_value = "1",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_float, .value = &bgmvolume },
|
||||
};
|
||||
|
||||
static void
|
||||
I_SGI_Eject (void)
|
||||
|
@ -219,14 +227,14 @@ I_SGI_Update (void)
|
|||
if (!initialized || !enabled)
|
||||
return;
|
||||
|
||||
if (bgmvolume->value != cdvolume) {
|
||||
if (bgmvolume != cdvolume) {
|
||||
if (cdvolume) {
|
||||
Cvar_SetValue (bgmvolume, 0.0);
|
||||
cdvolume = bgmvolume->value;
|
||||
bgmvolume = 0.0;
|
||||
cdvolume = bgmvolume;
|
||||
CDAudio_Pause ();
|
||||
} else {
|
||||
Cvar_SetValue (bgmvolume, 1.0);
|
||||
cdvolume = bgmvolume->value;
|
||||
bgmvolume = 1.0;
|
||||
cdvolume = bgmvolume;
|
||||
CDAudio_Resume ();
|
||||
}
|
||||
}
|
||||
|
@ -334,8 +342,7 @@ I_SGI_Init (void)
|
|||
{
|
||||
int i;
|
||||
|
||||
bgmvolume = Cvar_Get ("bgmvolume", "1", CVAR_ARCHIVE, NULL,
|
||||
"Volume of CD music");
|
||||
Cvar_Register (&bgmvolume_cvar, 0, 0);
|
||||
if ((i = COM_CheckParm ("-cddev")) != 0 && i < com_argc - 1) {
|
||||
strncpy (cd_dev, com_argv[i + 1], sizeof (cd_dev));
|
||||
cd_dev[sizeof (cd_dev) - 1] = 0;
|
||||
|
|
|
@ -64,7 +64,15 @@ static UINT wDeviceID;
|
|||
static void I_CDAudio_Play (int track, qboolean looping);
|
||||
static void I_CDAudio_Stop (void);
|
||||
|
||||
static cvar_t *bgmvolume;
|
||||
static float bgmvolume;
|
||||
static cvar_t bgmvolume_cvar = {
|
||||
.name = "bgmvolume",
|
||||
.description =
|
||||
"Volume of CD music",
|
||||
.default_value = "1",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_float, .value = &bgmvolume },
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
|
@ -331,14 +339,14 @@ I_CDAudio_Update (void)
|
|||
if (!enabled)
|
||||
return;
|
||||
|
||||
if (bgmvolume->value != cdvolume) {
|
||||
if (bgmvolume != cdvolume) {
|
||||
if (cdvolume) {
|
||||
Cvar_SetValue (bgmvolume, 0.0);
|
||||
cdvolume = bgmvolume->value;
|
||||
bgmvolume = 0.0;
|
||||
cdvolume = bgmvolume;
|
||||
I_CDAudio_Pause ();
|
||||
} else {
|
||||
Cvar_SetValue (bgmvolume, 1.0);
|
||||
cdvolume = bgmvolume->value;
|
||||
bgmvolume = 1.0;
|
||||
cdvolume = bgmvolume;
|
||||
I_CDAudio_Resume ();
|
||||
}
|
||||
}
|
||||
|
@ -483,8 +491,7 @@ I_CDAudio_Init (void)
|
|||
initialized = true;
|
||||
enabled = true;
|
||||
|
||||
bgmvolume = Cvar_Get ("bgmvolume", "1", CVAR_ARCHIVE, NULL,
|
||||
"Volume of CD music");
|
||||
Cvar_Register (&bgmvolume_cvar, 0, 0);
|
||||
|
||||
if (I_CDAudio_GetAudioDiskInfo ()) {
|
||||
Sys_Printf ("CDAudio_Init: No CD in player.\n");
|
||||
|
|
|
@ -2,39 +2,57 @@ plugin_LTLIBRARIES += @snd_render_plugins@
|
|||
noinst_LTLIBRARIES += @snd_render_static_plugins@
|
||||
EXTRA_LTLIBRARIES += libs/audio/renderer/snd_render_default.la
|
||||
|
||||
flac_src=libs/audio/renderer/flac.c
|
||||
midi_src=libs/audio/renderer/midi.c
|
||||
vorbis_src=libs/audio/renderer/vorbis.c
|
||||
wav_src=libs/audio/renderer/wav.c
|
||||
flac_src = libs/audio/renderer/flac.c
|
||||
midi_src = libs/audio/renderer/midi.c
|
||||
vorbis_src = libs/audio/renderer/vorbis.c
|
||||
wav_src = libs/audio/renderer/wav.c
|
||||
|
||||
if HAVE_FLAC
|
||||
have_flac_src=$(flac_src)
|
||||
have_flac_src = $(flac_src)
|
||||
else
|
||||
have_flac_src=
|
||||
have_flac_src =
|
||||
endif
|
||||
if HAVE_MIDI
|
||||
have_midi_src=$(midi_src)
|
||||
have_midi_src = $(midi_src)
|
||||
else
|
||||
have_midi_src=
|
||||
have_midi_src =
|
||||
endif
|
||||
if HAVE_VORBIS
|
||||
have_vorbis_src=$(vorbis_src)
|
||||
have_vorbis_src = $(vorbis_src)
|
||||
else
|
||||
have_vorbis_src=
|
||||
have_vorbis_src =
|
||||
endif
|
||||
have_wav_src=$(wav_src)
|
||||
have_wav_src = $(wav_src)
|
||||
|
||||
format_src=$(have_flac_src) $(have_midi_src) $(have_vorbis_src) $(have_wav_src)
|
||||
format_libs= \
|
||||
$(SAMPLERATE_LIBS) $(VORBISFILE_LIBS) $(VORBIS_LIBS) $(FLAC_LIBS) \
|
||||
$(OGG_LIBS) $(WM_LIBS)
|
||||
extra_format_src=libs/audio/renderer/flac.c libs/audio/renderer/midi.c libs/audio/renderer/vorbis.c libs/audio/renderer/wav.c
|
||||
snd_common=libs/audio/renderer/snd_channels.c libs/audio/renderer/snd_mem.c libs/audio/renderer/snd_mix.c libs/audio/renderer/snd_resample.c libs/audio/renderer/snd_sfx.c
|
||||
snd_libs= \
|
||||
$(SAMPLERATE_LIBS) \
|
||||
$(VORBISFILE_LIBS) \
|
||||
$(VORBIS_LIBS) \
|
||||
$(FLAC_LIBS) \
|
||||
$(OGG_LIBS) \
|
||||
$(WM_LIBS)
|
||||
extra_format_src = \
|
||||
libs/audio/renderer/flac.c \
|
||||
libs/audio/renderer/midi.c \
|
||||
libs/audio/renderer/vorbis.c \
|
||||
libs/audio/renderer/wav.c
|
||||
snd_common = \
|
||||
libs/audio/renderer/snd_channels.c \
|
||||
libs/audio/renderer/snd_mem.c \
|
||||
libs/audio/renderer/snd_mix.c \
|
||||
libs/audio/renderer/snd_resample.c \
|
||||
libs/audio/renderer/snd_sfx.c
|
||||
snd_libs = \
|
||||
libs/util/libQFutil.la
|
||||
|
||||
libs_audio_renderer_snd_render_default_la_LDFLAGS= $(plugin_ldflags)
|
||||
libs_audio_renderer_snd_render_default_la_SOURCES= libs/audio/renderer/snd_dma.c $(snd_common) $(format_src)
|
||||
libs_audio_renderer_snd_render_default_la_LIBADD= $(snd_libs) $(format_libs)
|
||||
libs_audio_renderer_snd_render_default_la_DEPENDENCIES= $(snd_libs)
|
||||
EXTRA_libs_audio_renderer_snd_render_default_la_SOURCES=$(extra_format_src)
|
||||
libs_audio_renderer_snd_render_default_la_LDFLAGS = $(plugin_ldflags)
|
||||
libs_audio_renderer_snd_render_default_la_SOURCES = \
|
||||
libs/audio/renderer/snd_dma.c \
|
||||
$(snd_common) \
|
||||
$(format_src)
|
||||
libs_audio_renderer_snd_render_default_la_LIBADD = \
|
||||
$(snd_libs) \
|
||||
$(format_libs)
|
||||
libs_audio_renderer_snd_render_default_la_DEPENDENCIES = $(snd_libs)
|
||||
EXTRA_libs_audio_renderer_snd_render_default_la_SOURCES = $(extra_format_src)
|
||||
|
|
|
@ -57,19 +57,32 @@ typedef struct {
|
|||
|
||||
static int midi_intiialized = 0;
|
||||
|
||||
static cvar_t *wildmidi_volume;
|
||||
static cvar_t *wildmidi_config;
|
||||
static float wildmidi_volume;
|
||||
static cvar_t wildmidi_volume_cvar = {
|
||||
.name = "wildmidi_volume",
|
||||
.description =
|
||||
"Set the Master Volume",
|
||||
.default_value = "100",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_float, .value = &wildmidi_volume },
|
||||
};
|
||||
static char *wildmidi_config;
|
||||
static cvar_t wildmidi_config_cvar = {
|
||||
.name = "wildmidi_config",
|
||||
.description =
|
||||
"path/filename of timidity.cfg",
|
||||
.default_value = "/etc/timidity.cfg",
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = 0, .value = &wildmidi_config },
|
||||
};
|
||||
|
||||
static int
|
||||
midi_init (snd_t *snd)
|
||||
{
|
||||
wildmidi_volume = Cvar_Get ("wildmidi_volume", "100", CVAR_ARCHIVE, NULL,
|
||||
"Set the Master Volume");
|
||||
wildmidi_config = Cvar_Get ("wildmidi_config", "/etc/timidity.cfg",
|
||||
CVAR_ROM, NULL,
|
||||
"path/filename of timidity.cfg");
|
||||
Cvar_Register (&wildmidi_volume_cvar, 0, 0);
|
||||
Cvar_Register (&wildmidi_config_cvar, 0, 0);
|
||||
|
||||
if (WildMidi_Init (wildmidi_config->string, snd->speed, 0) == -1)
|
||||
if (WildMidi_Init (wildmidi_config, snd->speed, 0) == -1)
|
||||
return 1;
|
||||
midi_intiialized = 1;
|
||||
return 0;
|
||||
|
|
|
@ -71,11 +71,51 @@ static vec4f_t listener_forward;
|
|||
static vec4f_t listener_right;
|
||||
static vec4f_t listener_up;
|
||||
|
||||
static cvar_t *snd_phasesep;
|
||||
static cvar_t *snd_volumesep;
|
||||
static cvar_t *snd_swapchannelside;
|
||||
static cvar_t *ambient_fade;
|
||||
static cvar_t *ambient_level;
|
||||
static float snd_phasesep;
|
||||
static cvar_t snd_phasesep_cvar = {
|
||||
.name = "snd_phasesep",
|
||||
.description =
|
||||
"max stereo phase separation in ms. 0.6 is for 20cm head",
|
||||
.default_value = "0.0",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_float, .value = &snd_phasesep },
|
||||
};
|
||||
static float snd_volumesep;
|
||||
static cvar_t snd_volumesep_cvar = {
|
||||
.name = "snd_volumesep",
|
||||
.description =
|
||||
"max stereo volume separation. 1.0 is max",
|
||||
.default_value = "1.0",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_float, .value = &snd_volumesep },
|
||||
};
|
||||
static int snd_swapchannelside;
|
||||
static cvar_t snd_swapchannelside_cvar = {
|
||||
.name = "snd_swapchannelside",
|
||||
.description =
|
||||
"Toggle swapping of left and right channels",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_int, .value = &snd_swapchannelside },
|
||||
};
|
||||
static float ambient_fade;
|
||||
static cvar_t ambient_fade_cvar = {
|
||||
.name = "ambient_fade",
|
||||
.description =
|
||||
"How quickly ambient sounds fade in or out",
|
||||
.default_value = "100",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &ambient_fade },
|
||||
};
|
||||
static float ambient_level;
|
||||
static cvar_t ambient_level_cvar = {
|
||||
.name = "ambient_level",
|
||||
.description =
|
||||
"Ambient sounds' volume",
|
||||
.default_value = "0.3",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &ambient_level },
|
||||
};
|
||||
|
||||
static inline channel_t *
|
||||
unlink_channel (channel_t **_ch)
|
||||
|
@ -320,18 +360,11 @@ SND_Channels_Init (snd_t *snd)
|
|||
{
|
||||
int i;
|
||||
|
||||
snd_phasesep = Cvar_Get ("snd_phasesep", "0.0", CVAR_ARCHIVE, NULL,
|
||||
"max stereo phase separation in ms. 0.6 is for "
|
||||
"20cm head");
|
||||
snd_volumesep = Cvar_Get ("snd_volumesep", "1.0", CVAR_ARCHIVE, NULL,
|
||||
"max stereo volume separation. 1.0 is max");
|
||||
snd_swapchannelside = Cvar_Get ("snd_swapchannelside", "0", CVAR_ARCHIVE,
|
||||
NULL, "Toggle swapping of left and right "
|
||||
"channels");
|
||||
ambient_fade = Cvar_Get ("ambient_fade", "100", CVAR_NONE, NULL,
|
||||
"How quickly ambient sounds fade in or out");
|
||||
ambient_level = Cvar_Get ("ambient_level", "0.3", CVAR_NONE, NULL,
|
||||
"Ambient sounds' volume");
|
||||
Cvar_Register (&snd_phasesep_cvar, 0, 0);
|
||||
Cvar_Register (&snd_volumesep_cvar, 0, 0);
|
||||
Cvar_Register (&snd_swapchannelside_cvar, 0, 0);
|
||||
Cvar_Register (&ambient_fade_cvar, 0, 0);
|
||||
Cvar_Register (&ambient_level_cvar, 0, 0);
|
||||
|
||||
Cmd_AddDataCommand ("play", s_play_f, snd,
|
||||
"Play selected sound effect (play pathto/sound.wav)");
|
||||
|
@ -408,7 +441,7 @@ s_updateAmbientSounds (snd_t *snd, const byte *ambient_sound_level)
|
|||
if (!snd_ambient)
|
||||
return;
|
||||
// calc ambient sound levels
|
||||
if (!ambient_sound_level || !ambient_level->value) {
|
||||
if (!ambient_sound_level || !ambient_level) {
|
||||
// if we're not in a leaf (huh?) or ambients have been turned off,
|
||||
// stop all ambient channels.
|
||||
for (ambient_channel = 0; ambient_channel < NUM_AMBIENTS;
|
||||
|
@ -447,19 +480,19 @@ s_updateAmbientSounds (snd_t *snd, const byte *ambient_sound_level)
|
|||
// sfx will be written to chan->sfx later to ensure mixer doesn't use
|
||||
// channel prematurely.
|
||||
|
||||
vol = ambient_level->value * ambient_sound_level[ambient_channel];
|
||||
vol = ambient_level * ambient_sound_level[ambient_channel];
|
||||
if (vol < 8)
|
||||
vol = 0;
|
||||
|
||||
// don't adjust volume too fast
|
||||
if (chan->master_vol < vol) {
|
||||
chan->master_vol += *snd_render_data.host_frametime
|
||||
* ambient_fade->value;
|
||||
* ambient_fade;
|
||||
if (chan->master_vol > vol)
|
||||
chan->master_vol = vol;
|
||||
} else if (chan->master_vol > vol) {
|
||||
chan->master_vol -= *snd_render_data.host_frametime
|
||||
* ambient_fade->value;
|
||||
* ambient_fade;
|
||||
if (chan->master_vol < vol)
|
||||
chan->master_vol = vol;
|
||||
}
|
||||
|
@ -494,7 +527,7 @@ s_spatialize (snd_t *snd, channel_t *ch)
|
|||
dist = VectorNormalize (source_vec) * ch->dist_mult;
|
||||
|
||||
dot = DotProduct (listener_right, source_vec);
|
||||
if (snd_swapchannelside->int_val)
|
||||
if (snd_swapchannelside)
|
||||
dot = -dot;
|
||||
|
||||
if (snd->channels == 1) {
|
||||
|
@ -502,9 +535,9 @@ s_spatialize (snd_t *snd, channel_t *ch)
|
|||
lscale = 1.0;
|
||||
phase = 0;
|
||||
} else {
|
||||
rscale = 1.0 + dot * snd_volumesep->value;
|
||||
lscale = 1.0 - dot * snd_volumesep->value;
|
||||
phase = snd_phasesep->value * 0.001 * snd->speed * dot;
|
||||
rscale = 1.0 + dot * snd_volumesep;
|
||||
lscale = 1.0 - dot * snd_volumesep;
|
||||
phase = snd_phasesep * 0.001 * snd->speed * dot;
|
||||
}
|
||||
|
||||
// add in distance effect
|
||||
|
|
|
@ -60,10 +60,52 @@ static unsigned soundtime; // sample PAIRS
|
|||
static int sound_started = 0;
|
||||
|
||||
|
||||
static cvar_t *nosound;
|
||||
static cvar_t *snd_mixahead;
|
||||
static cvar_t *snd_noextraupdate;
|
||||
static cvar_t *snd_show;
|
||||
float snd_volume;
|
||||
static cvar_t snd_volume_cvar = {
|
||||
.name = "volume",
|
||||
.description =
|
||||
"Set the volume for sound playback",
|
||||
.default_value = "0.7",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_float, .value = &snd_volume },
|
||||
};
|
||||
static int nosound;
|
||||
static cvar_t nosound_cvar = {
|
||||
.name = "nosound",
|
||||
.description =
|
||||
"Set to turn sound off",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_int, .value = &nosound },
|
||||
};
|
||||
static float snd_mixahead;
|
||||
static cvar_t snd_mixahead_cvar = {
|
||||
.name = "snd_mixahead",
|
||||
.description =
|
||||
"Delay time for sounds",
|
||||
.default_value = "0.1",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_float, .value = &snd_mixahead },
|
||||
};
|
||||
static int snd_noextraupdate;
|
||||
static cvar_t snd_noextraupdate_cvar = {
|
||||
.name = "snd_noextraupdate",
|
||||
.description =
|
||||
"Toggles the correct value display in host_speeds. Usually messes up "
|
||||
"sound playback when in effect",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_int, .value = &snd_noextraupdate },
|
||||
};
|
||||
static int snd_show;
|
||||
static cvar_t snd_show_cvar = {
|
||||
.name = "snd_show",
|
||||
.description =
|
||||
"Toggles display of sounds currently being played",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_int, .value = &snd_show },
|
||||
};
|
||||
|
||||
static general_data_t plugin_info_general_data;
|
||||
|
||||
|
@ -196,7 +238,7 @@ s_update_ (void)
|
|||
snd.paintedtime = soundtime;
|
||||
}
|
||||
// mix ahead of current position
|
||||
endtime = soundtime + snd_mixahead->value * snd.speed;
|
||||
endtime = soundtime + snd_mixahead * snd.speed;
|
||||
samps = snd.frames;
|
||||
if (endtime - soundtime > samps)
|
||||
endtime = soundtime + samps;
|
||||
|
@ -233,7 +275,7 @@ static void
|
|||
s_extra_update (void)
|
||||
{
|
||||
if (snd_output_data->model == som_push) {
|
||||
if (!sound_started || snd_noextraupdate->int_val)
|
||||
if (!sound_started || snd_noextraupdate)
|
||||
return; // don't pollute timings
|
||||
s_update_ ();
|
||||
}
|
||||
|
@ -315,18 +357,11 @@ s_snd_force_unblock (void)
|
|||
static void
|
||||
s_init_cvars (void)
|
||||
{
|
||||
nosound = Cvar_Get ("nosound", "0", CVAR_NONE, NULL,
|
||||
"Set to turn sound off");
|
||||
snd_volume = Cvar_Get ("volume", "0.7", CVAR_ARCHIVE, NULL,
|
||||
"Set the volume for sound playback");
|
||||
snd_mixahead = Cvar_Get ("snd_mixahead", "0.1", CVAR_ARCHIVE, NULL,
|
||||
"Delay time for sounds");
|
||||
snd_noextraupdate = Cvar_Get ("snd_noextraupdate", "0", CVAR_NONE, NULL,
|
||||
"Toggles the correct value display in "
|
||||
"host_speeds. Usually messes up sound "
|
||||
"playback when in effect");
|
||||
snd_show = Cvar_Get ("snd_show", "0", CVAR_NONE, NULL,
|
||||
"Toggles display of sounds currently being played");
|
||||
Cvar_Register (&nosound_cvar, 0, 0);
|
||||
Cvar_Register (&snd_volume_cvar, 0, 0);
|
||||
Cvar_Register (&snd_mixahead_cvar, 0, 0);
|
||||
Cvar_Register (&snd_noextraupdate_cvar, 0, 0);
|
||||
Cvar_Register (&snd_show_cvar, 0, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -344,13 +379,6 @@ s_init (void)
|
|||
Cmd_AddCommand ("snd_force_unblock", s_snd_force_unblock,
|
||||
"fix permanently blocked sound");
|
||||
|
||||
// FIXME
|
||||
//extern struct cvar_s *snd_loadas8bit;
|
||||
// if (host_parms.memsize < 0x800000) {
|
||||
// Cvar_Set (snd_loadas8bit, "1");
|
||||
// Sys_Printf ("loading all sounds as 8bit\n");
|
||||
// }
|
||||
|
||||
snd_initialized = true;
|
||||
|
||||
s_startup ();
|
||||
|
|
|
@ -48,8 +48,6 @@
|
|||
// note: must be >= 255 due to the channel
|
||||
// volumes being 0-255.
|
||||
|
||||
cvar_t *snd_volume;
|
||||
|
||||
portable_samplepair_t snd_paintbuffer[PAINTBUFFER_SIZE * 2];
|
||||
static int max_overpaint; // number of extra samples painted
|
||||
// due to phase shift
|
||||
|
@ -170,7 +168,7 @@ SND_PaintChannels (snd_t *snd, unsigned endtime)
|
|||
|
||||
// transfer out according to DMA format
|
||||
snd->xfer (snd, snd_paintbuffer, end - snd->paintedtime,
|
||||
snd_volume->value);
|
||||
snd_volume);
|
||||
|
||||
memmove (snd_paintbuffer, snd_paintbuffer + end - snd->paintedtime,
|
||||
max_overpaint * sizeof (snd_paintbuffer[0]));
|
||||
|
|
|
@ -53,7 +53,15 @@ static sfx_t snd_sfx[MAX_SFX];
|
|||
static int snd_num_sfx;
|
||||
static hashtab_t *snd_sfx_hash;
|
||||
|
||||
static cvar_t *precache;
|
||||
static int precache;
|
||||
static cvar_t precache_cvar = {
|
||||
.name = "precache",
|
||||
.description =
|
||||
"Toggle the use of a precache",
|
||||
.default_value = "1",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_int, .value = &precache },
|
||||
};
|
||||
|
||||
static const char *
|
||||
snd_sfx_getkey (const void *sfx, void *unused)
|
||||
|
@ -203,7 +211,7 @@ SND_PrecacheSound (snd_t *snd, const char *name)
|
|||
Sys_Error ("SND_PrecacheSound: NULL");
|
||||
|
||||
sfx = SND_LoadSound (snd, va (0, "sound/%s", name));
|
||||
if (sfx && precache->int_val) {
|
||||
if (sfx && precache) {
|
||||
if (sfx->retain (sfx))
|
||||
sfx->release (sfx);
|
||||
}
|
||||
|
@ -249,8 +257,7 @@ void
|
|||
SND_SFX_Init (snd_t *snd)
|
||||
{
|
||||
snd_sfx_hash = Hash_NewTable (511, snd_sfx_getkey, snd_sfx_free, 0, 0);
|
||||
precache = Cvar_Get ("precache", "1", CVAR_NONE, NULL,
|
||||
"Toggle the use of a precache");
|
||||
Cvar_Register (&precache_cvar, 0, 0);
|
||||
|
||||
QFS_GamedirCallback (s_gamedir);
|
||||
|
||||
|
|
|
@ -37,8 +37,24 @@
|
|||
|
||||
#include "snd_internal.h"
|
||||
|
||||
static cvar_t *snd_output;
|
||||
static cvar_t *snd_render;
|
||||
static char *snd_output;
|
||||
static cvar_t snd_output_cvar = {
|
||||
.name = "snd_output",
|
||||
.description =
|
||||
"Sound Output Plugin to use",
|
||||
.default_value = SND_OUTPUT_DEFAULT,
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = 0, .value = &snd_output },
|
||||
};
|
||||
static char *snd_render;
|
||||
static cvar_t snd_render_cvar = {
|
||||
.name = "snd_render",
|
||||
.description =
|
||||
"Sound Renderer Plugin to use",
|
||||
.default_value = "default",
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = 0, .value = &snd_render },
|
||||
};
|
||||
static plugin_t *snd_render_module = NULL;
|
||||
static plugin_t *snd_output_module = NULL;
|
||||
static snd_render_funcs_t *snd_render_funcs = NULL;
|
||||
|
@ -73,7 +89,7 @@ S_Init (int *viewentity, double *host_frametime)
|
|||
if (COM_CheckParm ("-nosound"))
|
||||
return;
|
||||
|
||||
if (!*snd_output->string || !*snd_render->string) {
|
||||
if (!*snd_output || !*snd_render) {
|
||||
Sys_Printf ("Not loading sound due to no renderer/output\n");
|
||||
return;
|
||||
}
|
||||
|
@ -82,15 +98,15 @@ S_Init (int *viewentity, double *host_frametime)
|
|||
|
||||
PI_RegisterPlugins (snd_output_list);
|
||||
PI_RegisterPlugins (snd_render_list);
|
||||
snd_output_module = PI_LoadPlugin ("snd_output", snd_output->string);
|
||||
snd_output_module = PI_LoadPlugin ("snd_output", snd_output);
|
||||
if (!snd_output_module) {
|
||||
Sys_Printf ("Loading of sound output module: %s failed!\n",
|
||||
snd_output->string);
|
||||
snd_output);
|
||||
} else {
|
||||
snd_render_module = PI_LoadPlugin ("snd_render", snd_render->string);
|
||||
snd_render_module = PI_LoadPlugin ("snd_render", snd_render);
|
||||
if (!snd_render_module) {
|
||||
Sys_Printf ("Loading of sound render module: %s failed!\n",
|
||||
snd_render->string);
|
||||
snd_render);
|
||||
PI_UnloadPlugin (snd_output_module);
|
||||
snd_output_module = NULL;
|
||||
} else {
|
||||
|
@ -114,10 +130,8 @@ S_Init (int *viewentity, double *host_frametime)
|
|||
VISIBLE void
|
||||
S_Init_Cvars (void)
|
||||
{
|
||||
snd_output = Cvar_Get ("snd_output", SND_OUTPUT_DEFAULT, CVAR_ROM, NULL,
|
||||
"Sound Output Plugin to use");
|
||||
snd_render = Cvar_Get ("snd_render", "default", CVAR_ROM, NULL,
|
||||
"Sound Renderer Plugin to use");
|
||||
Cvar_Register (&snd_output_cvar, 0, 0);
|
||||
Cvar_Register (&snd_render_cvar, 0, 0);
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
|
|
|
@ -53,10 +53,42 @@ static void *alsa_handle;
|
|||
static snd_pcm_t *pcm;
|
||||
static snd_async_handler_t *async_handler;
|
||||
|
||||
static cvar_t *snd_bits;
|
||||
static cvar_t *snd_device;
|
||||
static cvar_t *snd_rate;
|
||||
static cvar_t *snd_stereo;
|
||||
static int snd_bits;
|
||||
static cvar_t snd_bits_cvar = {
|
||||
.name = "snd_bits",
|
||||
.description =
|
||||
"sound sample depth. 0 is system default",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = &cexpr_int, .value = &snd_bits },
|
||||
};
|
||||
static char *snd_device;
|
||||
static cvar_t snd_device_cvar = {
|
||||
.name = "snd_device",
|
||||
.description =
|
||||
"sound device. \"\" is system default",
|
||||
.default_value = "",
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = 0, .value = &snd_device },
|
||||
};
|
||||
static int snd_rate;
|
||||
static cvar_t snd_rate_cvar = {
|
||||
.name = "snd_rate",
|
||||
.description =
|
||||
"sound playback rate. 0 is system default",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = &cexpr_int, .value = &snd_rate },
|
||||
};
|
||||
static int snd_stereo;
|
||||
static cvar_t snd_stereo_cvar = {
|
||||
.name = "snd_stereo",
|
||||
.description =
|
||||
"sound stereo output",
|
||||
.default_value = "1",
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = &cexpr_int, .value = &snd_stereo },
|
||||
};
|
||||
|
||||
//FIXME xfer probably should not be touching this (such data should probably
|
||||
//come through snd_t)
|
||||
|
@ -92,14 +124,10 @@ load_libasound (void)
|
|||
static void
|
||||
SNDDMA_Init_Cvars (void)
|
||||
{
|
||||
snd_stereo = Cvar_Get ("snd_stereo", "1", CVAR_ROM, NULL,
|
||||
"sound stereo output");
|
||||
snd_rate = Cvar_Get ("snd_rate", "0", CVAR_ROM, NULL,
|
||||
"sound playback rate. 0 is system default");
|
||||
snd_device = Cvar_Get ("snd_device", "", CVAR_ROM, NULL,
|
||||
"sound device. \"\" is system default");
|
||||
snd_bits = Cvar_Get ("snd_bits", "0", CVAR_ROM, NULL,
|
||||
"sound sample depth. 0 is system default");
|
||||
Cvar_Register (&snd_stereo_cvar, 0, 0);
|
||||
Cvar_Register (&snd_rate_cvar, 0, 0);
|
||||
Cvar_Register (&snd_device_cvar, 0, 0);
|
||||
Cvar_Register (&snd_bits_cvar, 0, 0);
|
||||
}
|
||||
|
||||
static __attribute__((const)) snd_pcm_uframes_t
|
||||
|
@ -415,13 +443,13 @@ alsa_playback_set_bps (snd_t *snd, snd_pcm_hw_params_t *hw)
|
|||
int res;
|
||||
int bps = 0;
|
||||
|
||||
if (snd_bits->int_val == 16) {
|
||||
if (snd_bits == 16) {
|
||||
bps = SND_PCM_FORMAT_S16_LE;
|
||||
snd->samplebits = 16;
|
||||
} else if (snd_bits->int_val == 8) {
|
||||
} else if (snd_bits == 8) {
|
||||
bps = SND_PCM_FORMAT_U8;
|
||||
snd->samplebits = 8;
|
||||
} else if (snd_bits->int_val) {
|
||||
} else if (snd_bits) {
|
||||
Sys_Printf ("snd_alsa: invalid sample bits: %d\n", bps);
|
||||
return 0;
|
||||
}
|
||||
|
@ -454,7 +482,7 @@ alsa_playback_set_channels (snd_t *snd, snd_pcm_hw_params_t *hw)
|
|||
int res;
|
||||
int channels = 1;
|
||||
|
||||
if (snd_stereo->int_val) {
|
||||
if (snd_stereo) {
|
||||
channels = 2;
|
||||
}
|
||||
if ((res = qfsnd_pcm_hw_params_set_channels (pcm, hw, channels)) == 0) {
|
||||
|
@ -473,8 +501,8 @@ alsa_playback_set_rate (snd_t *snd, snd_pcm_hw_params_t *hw)
|
|||
unsigned rate = 0;
|
||||
static int default_rates[] = { 48000, 44100, 22050, 11025, 0 };
|
||||
|
||||
if (snd_rate->int_val) {
|
||||
rate = snd_rate->int_val;
|
||||
if (snd_rate) {
|
||||
rate = snd_rate;
|
||||
}
|
||||
|
||||
if (rate) {
|
||||
|
@ -531,7 +559,7 @@ static int
|
|||
SNDDMA_Init (snd_t *snd)
|
||||
{
|
||||
int res;
|
||||
const char *device = snd_device->string;
|
||||
const char *device = snd_device;
|
||||
|
||||
snd_pcm_hw_params_t *hw;
|
||||
snd_pcm_sw_params_t *sw;
|
||||
|
|
|
@ -83,21 +83,42 @@ static HINSTANCE hInstDS;
|
|||
|
||||
static sndinitstat SNDDMA_InitDirect (snd_t *snd);
|
||||
|
||||
static cvar_t *snd_stereo;
|
||||
static cvar_t *snd_rate;
|
||||
static cvar_t *snd_bits;
|
||||
static int snd_stereo;
|
||||
static cvar_t snd_stereo_cvar = {
|
||||
.name = "snd_stereo",
|
||||
.description =
|
||||
"sound stereo output",
|
||||
.default_value = "1",
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = &cexpr_int, .value = &snd_stereo },
|
||||
};
|
||||
static int snd_rate;
|
||||
static cvar_t snd_rate_cvar = {
|
||||
.name = "snd_rate",
|
||||
.description =
|
||||
"sound playback rate. 0 is system default",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = &cexpr_int, .value = &snd_rate },
|
||||
};
|
||||
static int snd_bits;
|
||||
static cvar_t snd_bits_cvar = {
|
||||
.name = "snd_bits",
|
||||
.description =
|
||||
"sound sample depth. 0 is system default",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = &cexpr_int, .value = &snd_bits },
|
||||
};
|
||||
|
||||
static DWORD *DSOUND_LockBuffer (snd_t *snd, qboolean lockit);
|
||||
|
||||
static void
|
||||
SNDDMA_Init_Cvars (void)
|
||||
{
|
||||
snd_stereo = Cvar_Get ("snd_stereo", "1", CVAR_ROM, NULL,
|
||||
"sound stereo output");
|
||||
snd_rate = Cvar_Get ("snd_rate", "11025", CVAR_ROM, NULL,
|
||||
"sound playback rate. 0 is system default");
|
||||
snd_bits = Cvar_Get ("snd_bits", "16", CVAR_ROM, NULL,
|
||||
"sound sample depth. 0 is system default");
|
||||
Cvar_Register (&snd_stereo_cvar, 0, 0);
|
||||
Cvar_Register (&snd_rate_cvar, 0, 0);
|
||||
Cvar_Register (&snd_bits_cvar, 0, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -152,14 +173,14 @@ SNDDMA_InitDirect (snd_t *snd)
|
|||
HRESULT hresult;
|
||||
WAVEFORMATEX format, pformat;
|
||||
|
||||
if (!snd_stereo->int_val) {
|
||||
if (!snd_stereo) {
|
||||
snd->channels = 1;
|
||||
} else {
|
||||
snd->channels = 2;
|
||||
}
|
||||
|
||||
snd->samplebits = snd_bits->int_val;
|
||||
snd->speed = snd_rate->int_val;
|
||||
snd->samplebits = snd_bits;
|
||||
snd->speed = snd_rate;
|
||||
|
||||
memset (&format, 0, sizeof (format));
|
||||
format.wFormatTag = WAVE_FORMAT_PCM;
|
||||
|
|
|
@ -55,8 +55,25 @@ static double snd_alive_time = 0;
|
|||
static jack_client_t *jack_handle;
|
||||
static jack_port_t *jack_out[2];
|
||||
static float *output[2];
|
||||
static cvar_t *snd_jack_server;
|
||||
static cvar_t *snd_jack_ports;
|
||||
static char *snd_jack_server;
|
||||
static cvar_t snd_jack_server_cvar = {
|
||||
.name = "snd_jack_server",
|
||||
.description =
|
||||
"The name of the JACK server to connect to",
|
||||
.default_value = "default",
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = 0, .value = &snd_jack_server },
|
||||
};
|
||||
static char *snd_jack_ports;
|
||||
static cvar_t snd_jack_ports_cvar = {
|
||||
.name = "snd_jack_ports",
|
||||
.description =
|
||||
"; separated list of port names to which QF will connect. Defaults to "
|
||||
"the first two physical ports. Currently only two ports are supported.",
|
||||
.default_value = "",
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = 0, .value = &snd_jack_ports },
|
||||
};
|
||||
|
||||
static int s_jack_connect (snd_t *snd);
|
||||
|
||||
|
@ -126,13 +143,13 @@ s_jack_activate (void)
|
|||
int i;
|
||||
|
||||
snd_shutdown = 0;
|
||||
if (!*snd_jack_ports->string) {
|
||||
if (!*snd_jack_ports) {
|
||||
ports = jack_get_ports (jack_handle, 0, 0,
|
||||
JackPortIsPhysical | JackPortIsInput);
|
||||
} else {
|
||||
ports = s_jack_parse_ports (snd_jack_ports->string);
|
||||
ports = s_jack_parse_ports (snd_jack_ports);
|
||||
}
|
||||
if (developer->int_val & SYS_snd) {
|
||||
if (developer & SYS_snd) {
|
||||
for (i = 0; ports[i]; i++) {
|
||||
Sys_Printf ("%s\n", ports[i]);
|
||||
}
|
||||
|
@ -222,7 +239,7 @@ snd_jack_error (const char *desc)
|
|||
static int
|
||||
snd_jack_xrun (void *arg)
|
||||
{
|
||||
if (developer->int_val & SYS_snd) {
|
||||
if (developer & SYS_snd) {
|
||||
fprintf (stderr, "snd_jack: xrun\n");
|
||||
}
|
||||
return 0;
|
||||
|
@ -236,7 +253,7 @@ s_jack_connect (snd_t *snd)
|
|||
jack_set_error_function (snd_jack_error);
|
||||
if ((jack_handle = jack_client_open ("QuakeForge",
|
||||
JackServerName | JackNoStartServer, 0,
|
||||
snd_jack_server->string)) == 0) {
|
||||
snd_jack_server)) == 0) {
|
||||
Sys_Printf ("Could not connect to JACK\n");
|
||||
return 0;
|
||||
}
|
||||
|
@ -280,13 +297,8 @@ s_shutdown (snd_t *snd)
|
|||
static void
|
||||
s_init_cvars (void)
|
||||
{
|
||||
snd_jack_server = Cvar_Get ("snd_jack_server", "default", CVAR_ROM, NULL,
|
||||
"The name of the JACK server to connect to");
|
||||
snd_jack_ports = Cvar_Get ("snd_jack_ports", "", CVAR_ROM, NULL,
|
||||
"; separated list of port names to which QF "
|
||||
"will connect. Defaults to the first two "
|
||||
"physical ports. Currently only two ports "
|
||||
"are supported.");
|
||||
Cvar_Register (&snd_jack_server_cvar, 0, 0);
|
||||
Cvar_Register (&snd_jack_ports_cvar, 0, 0);
|
||||
}
|
||||
|
||||
static general_funcs_t plugin_info_general_funcs = {
|
||||
|
|
|
@ -81,11 +81,51 @@ static const char *snd_dev = "/dev/dsp";
|
|||
|
||||
static int tryrates[] = { 44100, 48000, 11025, 22050, 22051, 44100, 8000 };
|
||||
|
||||
static cvar_t *snd_stereo;
|
||||
static cvar_t *snd_rate;
|
||||
static cvar_t *snd_device;
|
||||
static cvar_t *snd_bits;
|
||||
static cvar_t *snd_oss_mmaped;
|
||||
static int snd_stereo;
|
||||
static cvar_t snd_stereo_cvar = {
|
||||
.name = "snd_stereo",
|
||||
.description =
|
||||
"sound stereo output",
|
||||
.default_value = "1",
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = &cexpr_int, .value = &snd_stereo },
|
||||
};
|
||||
static int snd_rate;
|
||||
static cvar_t snd_rate_cvar = {
|
||||
.name = "snd_rate",
|
||||
.description =
|
||||
"sound playback rate. 0 is system default",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = &cexpr_int, .value = &snd_rate },
|
||||
};
|
||||
static char *snd_device;
|
||||
static cvar_t snd_device_cvar = {
|
||||
.name = "snd_device",
|
||||
.description =
|
||||
"sound device. \"\" is system default",
|
||||
.default_value = "",
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = 0, .value = &snd_device },
|
||||
};
|
||||
static int snd_bits;
|
||||
static cvar_t snd_bits_cvar = {
|
||||
.name = "snd_bits",
|
||||
.description =
|
||||
"sound sample depth. 0 is system default",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = &cexpr_int, .value = &snd_bits },
|
||||
};
|
||||
static int snd_oss_mmaped;
|
||||
static cvar_t snd_oss_mmaped_cvar = {
|
||||
.name = "snd_oss_mmaped",
|
||||
.description =
|
||||
"mmaped io",
|
||||
.default_value = "1",
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = &cexpr_int, .value = &snd_oss_mmaped },
|
||||
};
|
||||
|
||||
static plugin_t plugin_info;
|
||||
static plugin_data_t plugin_info_data;
|
||||
|
@ -99,16 +139,11 @@ static snd_output_funcs_t plugin_info_snd_output_funcs;
|
|||
static void
|
||||
SNDDMA_Init_Cvars (void)
|
||||
{
|
||||
snd_stereo = Cvar_Get ("snd_stereo", "1", CVAR_ROM, NULL,
|
||||
"sound stereo output");
|
||||
snd_rate = Cvar_Get ("snd_rate", "0", CVAR_ROM, NULL,
|
||||
"sound playback rate. 0 is system default");
|
||||
snd_device = Cvar_Get ("snd_device", "", CVAR_ROM, NULL,
|
||||
"sound device. \"\" is system default");
|
||||
snd_bits = Cvar_Get ("snd_bits", "0", CVAR_ROM, NULL,
|
||||
"sound sample depth. 0 is system default");
|
||||
snd_oss_mmaped = Cvar_Get ("snd_oss_mmaped", "1", CVAR_ROM, NULL,
|
||||
"mmaped io");
|
||||
Cvar_Register (&snd_stereo_cvar, 0, 0);
|
||||
Cvar_Register (&snd_rate_cvar, 0, 0);
|
||||
Cvar_Register (&snd_device_cvar, 0, 0);
|
||||
Cvar_Register (&snd_bits_cvar, 0, 0);
|
||||
Cvar_Register (&snd_oss_mmaped_cvar, 0, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -122,11 +157,11 @@ try_open (snd_t *snd, int rw)
|
|||
struct audio_buf_info info;
|
||||
|
||||
snd_inited = 0;
|
||||
mmaped_io = snd_oss_mmaped->int_val;
|
||||
mmaped_io = snd_oss_mmaped;
|
||||
|
||||
// open snd_dev, confirm capability to mmap, and get size of dma buffer
|
||||
if (snd_device->string[0])
|
||||
snd_dev = snd_device->string;
|
||||
if (snd_device[0])
|
||||
snd_dev = snd_device;
|
||||
|
||||
if (rw) {
|
||||
omode = O_RDWR;
|
||||
|
@ -168,7 +203,7 @@ try_open (snd_t *snd, int rw)
|
|||
}
|
||||
|
||||
// set sample bits & speed
|
||||
snd->samplebits = snd_bits->int_val;
|
||||
snd->samplebits = snd_bits;
|
||||
|
||||
if (snd->samplebits != 16 && snd->samplebits != 8) {
|
||||
ioctl (audio_fd, SNDCTL_DSP_GETFMTS, &fmt);
|
||||
|
@ -216,8 +251,8 @@ try_open (snd_t *snd, int rw)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (snd_rate->int_val) {
|
||||
snd->speed = snd_rate->int_val;
|
||||
if (snd_rate) {
|
||||
snd->speed = snd_rate;
|
||||
} else {
|
||||
for (i = 0; i < ((int) sizeof (tryrates) / 4); i++)
|
||||
if (!ioctl (audio_fd, SNDCTL_DSP_SPEED, &tryrates[i]))
|
||||
|
@ -225,7 +260,7 @@ try_open (snd_t *snd, int rw)
|
|||
snd->speed = tryrates[i];
|
||||
}
|
||||
|
||||
if (!snd_stereo->int_val) {
|
||||
if (!snd_stereo) {
|
||||
snd->channels = 1;
|
||||
} else {
|
||||
snd->channels = 2;
|
||||
|
|
|
@ -55,9 +55,33 @@ static unsigned shm_rpos;
|
|||
|
||||
static unsigned wpos;
|
||||
|
||||
static cvar_t *snd_bits;
|
||||
static cvar_t *snd_rate;
|
||||
static cvar_t *snd_stereo;
|
||||
static int snd_bits;
|
||||
static cvar_t snd_bits_cvar = {
|
||||
.name = "snd_bits",
|
||||
.description =
|
||||
"sound sample depth. 0 is system default",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = &cexpr_int, .value = &snd_bits },
|
||||
};
|
||||
static int snd_rate;
|
||||
static cvar_t snd_rate_cvar = {
|
||||
.name = "snd_rate",
|
||||
.description =
|
||||
"sound playback rate. 0 is system default",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = &cexpr_int, .value = &snd_rate },
|
||||
};
|
||||
static int snd_stereo;
|
||||
static cvar_t snd_stereo_cvar = {
|
||||
.name = "snd_stereo",
|
||||
.description =
|
||||
"sound stereo output",
|
||||
.default_value = "1",
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = &cexpr_int, .value = &snd_stereo },
|
||||
};
|
||||
|
||||
static plugin_t plugin_info;
|
||||
static plugin_data_t plugin_info_data;
|
||||
|
@ -86,12 +110,9 @@ paint_audio (void *unused, Uint8 * stream, int len)
|
|||
static void
|
||||
SNDDMA_Init_Cvars (void)
|
||||
{
|
||||
snd_stereo = Cvar_Get ("snd_stereo", "1", CVAR_ROM, NULL,
|
||||
"sound stereo output");
|
||||
snd_rate = Cvar_Get ("snd_rate", "0", CVAR_ROM, NULL,
|
||||
"sound playback rate. 0 is system default");
|
||||
snd_bits = Cvar_Get ("snd_bits", "0", CVAR_ROM, NULL,
|
||||
"sound sample depth. 0 is system default");
|
||||
Cvar_Register (&snd_stereo_cvar, 0, 0);
|
||||
Cvar_Register (&snd_rate_cvar, 0, 0);
|
||||
Cvar_Register (&snd_bits_cvar, 0, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -109,9 +130,9 @@ SNDDMA_Init (snd_t *snd)
|
|||
|
||||
/* Set up the desired format */
|
||||
desired.freq = 22050;
|
||||
if (snd_rate->int_val)
|
||||
desired.freq = snd_rate->int_val;
|
||||
switch (snd_bits->int_val) {
|
||||
if (snd_rate)
|
||||
desired.freq = snd_rate;
|
||||
switch (snd_bits) {
|
||||
case 8:
|
||||
desired.format = AUDIO_U8;
|
||||
break;
|
||||
|
@ -124,10 +145,10 @@ SNDDMA_Init (snd_t *snd)
|
|||
break;
|
||||
default:
|
||||
Sys_Printf ("Unknown number of audio bits: %d\n",
|
||||
snd_bits->int_val);
|
||||
snd_bits);
|
||||
return 0;
|
||||
}
|
||||
desired.channels = snd_stereo->int_val ? 2 : 1;
|
||||
desired.channels = snd_stereo ? 2 : 1;
|
||||
desired.samples = 1024;
|
||||
desired.callback = paint_audio;
|
||||
|
||||
|
|
|
@ -70,20 +70,41 @@ static DWORD gSndBufSize;
|
|||
|
||||
static qboolean SNDDMA_InitWav (snd_t *snd);
|
||||
|
||||
static cvar_t *snd_stereo;
|
||||
static cvar_t *snd_rate;
|
||||
static cvar_t *snd_bits;
|
||||
static int snd_stereo;
|
||||
static cvar_t snd_stereo_cvar = {
|
||||
.name = "snd_stereo",
|
||||
.description =
|
||||
"sound stereo output",
|
||||
.default_value = "1",
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = &cexpr_int, .value = &snd_stereo },
|
||||
};
|
||||
static int snd_rate;
|
||||
static cvar_t snd_rate_cvar = {
|
||||
.name = "snd_rate",
|
||||
.description =
|
||||
"sound playback rate. 0 is system default",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = &cexpr_int, .value = &snd_rate },
|
||||
};
|
||||
static int snd_bits;
|
||||
static cvar_t snd_bits_cvar = {
|
||||
.name = "snd_bits",
|
||||
.description =
|
||||
"sound sample depth. 0 is system default",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = &cexpr_int, .value = &snd_bits },
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
SNDDMA_Init_Cvars (void)
|
||||
{
|
||||
snd_stereo = Cvar_Get ("snd_stereo", "1", CVAR_ROM, NULL,
|
||||
"sound stereo output");
|
||||
snd_rate = Cvar_Get ("snd_rate", "11025", CVAR_ROM, NULL,
|
||||
"sound playback rate. 0 is system default");
|
||||
snd_bits = Cvar_Get ("snd_bits", "16", CVAR_ROM, NULL,
|
||||
"sound sample depth. 0 is system default");
|
||||
Cvar_Register (&snd_stereo_cvar, 0, 0);
|
||||
Cvar_Register (&snd_rate_cvar, 0, 0);
|
||||
Cvar_Register (&snd_bits_cvar, 0, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -150,14 +171,14 @@ SNDDMA_InitWav (snd_t *snd)
|
|||
snd_sent = 0;
|
||||
snd_completed = 0;
|
||||
|
||||
if (!snd_stereo->int_val) {
|
||||
if (!snd_stereo) {
|
||||
snd->channels = 1;
|
||||
} else {
|
||||
snd->channels = 2;
|
||||
}
|
||||
|
||||
snd->samplebits = snd_bits->int_val;
|
||||
snd->speed = snd_rate->int_val;
|
||||
snd->samplebits = snd_bits;
|
||||
snd->speed = snd_rate;
|
||||
|
||||
memset (&format, 0, sizeof (format));
|
||||
format.wFormatTag = WAVE_FORMAT_PCM;
|
||||
|
|
|
@ -66,7 +66,7 @@ init (void)
|
|||
|
||||
Sys_Init ();
|
||||
COM_ParseConfig (testsound_cbuf);
|
||||
Cvar_Get ("cmd_warncmd", "1", CVAR_NONE, NULL, NULL);
|
||||
cmd_warncmd = 1;
|
||||
|
||||
memhunk_t *hunk = Memory_Init (Sys_Alloc (MEMSIZE), MEMSIZE);
|
||||
|
||||
|
|
|
@ -50,19 +50,51 @@
|
|||
#include "client/view.h"
|
||||
|
||||
|
||||
cvar_t *chase_back;
|
||||
cvar_t *chase_up;
|
||||
cvar_t *chase_right;
|
||||
cvar_t *chase_active;
|
||||
float chase_back;
|
||||
static cvar_t chase_back_cvar = {
|
||||
.name = "chase_back",
|
||||
.description =
|
||||
"None",
|
||||
.default_value = "100",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &chase_back },
|
||||
};
|
||||
float chase_up;
|
||||
static cvar_t chase_up_cvar = {
|
||||
.name = "chase_up",
|
||||
.description =
|
||||
"None",
|
||||
.default_value = "16",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &chase_up },
|
||||
};
|
||||
float chase_right;
|
||||
static cvar_t chase_right_cvar = {
|
||||
.name = "chase_right",
|
||||
.description =
|
||||
"None",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &chase_right },
|
||||
};
|
||||
int chase_active;
|
||||
static cvar_t chase_active_cvar = {
|
||||
.name = "chase_active",
|
||||
.description =
|
||||
"None",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_int, .value = &chase_active },
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
Chase_Init_Cvars (void)
|
||||
{
|
||||
chase_back = Cvar_Get ("chase_back", "100", CVAR_NONE, NULL, "None");
|
||||
chase_up = Cvar_Get ("chase_up", "16", CVAR_NONE, NULL, "None");
|
||||
chase_right = Cvar_Get ("chase_right", "0", CVAR_NONE, NULL, "None");
|
||||
chase_active = Cvar_Get ("chase_active", "0", CVAR_NONE, NULL, "None");
|
||||
Cvar_Register (&chase_back_cvar, 0, 0);
|
||||
Cvar_Register (&chase_up_cvar, 0, 0);
|
||||
Cvar_Register (&chase_right_cvar, 0, 0);
|
||||
Cvar_Register (&chase_active_cvar, 0, 0);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -104,8 +136,8 @@ limit_distance (chasestate_t *cs)
|
|||
vec4f_t dir = cs->camera_origin - cs->player_origin;
|
||||
vec4f_t forward = normalf (dir);
|
||||
|
||||
if (magnitudef (dir)[0] > chase_back->value) {
|
||||
cs->camera_origin = cs->player_origin + forward * chase_back->value;
|
||||
if (magnitudef (dir)[0] > chase_back) {
|
||||
cs->camera_origin = cs->player_origin + forward * chase_back;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,26 +164,26 @@ cam_controls (chasestate_t *cs, viewstate_t *vs)
|
|||
vec4f_t dir = { };
|
||||
|
||||
if (in_strafe.state & 1) {
|
||||
move[SIDE] += cl_sidespeed->value * IN_ButtonState (&in_right);
|
||||
move[SIDE] -= cl_sidespeed->value * IN_ButtonState (&in_left);
|
||||
move[SIDE] += cl_sidespeed * IN_ButtonState (&in_right);
|
||||
move[SIDE] -= cl_sidespeed * IN_ButtonState (&in_left);
|
||||
}
|
||||
move[SIDE] += cl_sidespeed->value * IN_ButtonState (&in_moveright);
|
||||
move[SIDE] -= cl_sidespeed->value * IN_ButtonState (&in_moveleft);
|
||||
move[SIDE] += cl_sidespeed * IN_ButtonState (&in_moveright);
|
||||
move[SIDE] -= cl_sidespeed * IN_ButtonState (&in_moveleft);
|
||||
|
||||
if (!(in_klook.state & 1)) {
|
||||
move[FORWARD] += cl_forwardspeed->value
|
||||
move[FORWARD] += cl_forwardspeed
|
||||
* IN_ButtonState (&in_forward);
|
||||
move[FORWARD] -= cl_backspeed->value * IN_ButtonState (&in_back);
|
||||
move[FORWARD] -= cl_backspeed * IN_ButtonState (&in_back);
|
||||
}
|
||||
if (in_speed.state & 1) {
|
||||
move *= cl_movespeedkey->value;
|
||||
move *= cl_movespeedkey;
|
||||
}
|
||||
|
||||
// mouse and joystick controllers add to movement
|
||||
VectorSet (0, vs->player_angles[1] - cs->camera_angles[1], 0, dir);
|
||||
AngleVectors ((vec_t*)&dir, (vec_t*)&forward, (vec_t*)&right, (vec_t*)&up); //FIXME
|
||||
forward *= IN_UpdateAxis (&in_cam_forward) * m_forward->value;
|
||||
right *= IN_UpdateAxis (&in_cam_side) * m_side->value;
|
||||
forward *= IN_UpdateAxis (&in_cam_forward) * m_forward;
|
||||
right *= IN_UpdateAxis (&in_cam_side) * m_side;
|
||||
dir = forward + right;
|
||||
move[FORWARD] += dir[0];
|
||||
move[SIDE] -= dir[1];
|
||||
|
@ -191,9 +223,9 @@ chase_mode_1 (chasestate_t *cs)
|
|||
|
||||
// calc exact destination
|
||||
cs->camera_origin = vs->player_origin
|
||||
- forward * chase_back->value - right * chase_right->value;
|
||||
- forward * chase_back - right * chase_right;
|
||||
// chase_up is world up
|
||||
cs->camera_origin[2] += chase_up->value;
|
||||
cs->camera_origin[2] += chase_up;
|
||||
|
||||
// check for walls between player and camera
|
||||
stop = TraceLine (cs, vs->player_origin, cs->camera_origin);
|
||||
|
@ -219,13 +251,13 @@ chase_mode_2 (chasestate_t *cs)
|
|||
// move camera, it's not enough to just change the angles because
|
||||
// the angles are automatically changed to look toward the player
|
||||
AngleVectors (cs->camera_angles, (vec_t*)&forward, (vec_t*)&right, (vec_t*)&up);//FIXME
|
||||
cs->camera_origin = cs->player_origin - chase_back->value * forward;
|
||||
cs->camera_origin = cs->player_origin - chase_back * forward;
|
||||
|
||||
cs->player_origin = vs->player_origin;
|
||||
|
||||
// don't let camera get too low
|
||||
if (cs->camera_origin[2] < cs->player_origin[2] + chase_up->value) {
|
||||
cs->camera_origin[2] = cs->player_origin[2] + chase_up->value;
|
||||
if (cs->camera_origin[2] < cs->player_origin[2] + chase_up) {
|
||||
cs->camera_origin[2] = cs->player_origin[2] + chase_up;
|
||||
}
|
||||
|
||||
limit_distance (cs);
|
||||
|
@ -267,7 +299,7 @@ chase_mode_3 (chasestate_t *cs)
|
|||
|
||||
cs->player_origin = vs->player_origin;
|
||||
AngleVectors (cs->camera_angles, (vec_t*)&forward, (vec_t*)&right, (vec_t*)&up);//FIXME
|
||||
cs->camera_origin = cs->player_origin - chase_back->value * forward;
|
||||
cs->camera_origin = cs->player_origin - chase_back * forward;
|
||||
limit_distance (cs);
|
||||
check_for_walls (cs, forward);
|
||||
set_camera (cs, vs);
|
||||
|
@ -277,7 +309,7 @@ chase_mode_3 (chasestate_t *cs)
|
|||
void
|
||||
Chase_Update (chasestate_t *cs)
|
||||
{
|
||||
switch (chase_active->int_val) {
|
||||
switch (chase_active) {
|
||||
case 1:
|
||||
chase_mode_1 (cs);
|
||||
return;
|
||||
|
|
|
@ -129,7 +129,7 @@ CL_ModelEffects (entity_t *ent, int num, int glow_color, double time)
|
|||
VectorCopy (ent_origin, dl->origin);
|
||||
dl->radius = 200.0;
|
||||
dl->die = time + 0.1;
|
||||
//FIXME VectorCopy (r_firecolor->vec, dl->color);
|
||||
//FIXME VectorCopy (r_firecolor, dl->color);
|
||||
VectorSet (0.9, 0.7, 0.0, dl->color);
|
||||
dl->color[3] = 0.7;
|
||||
}
|
||||
|
|
|
@ -214,20 +214,124 @@ static in_button_t *cl_in_buttons[] = {
|
|||
0
|
||||
};
|
||||
|
||||
cvar_t *cl_anglespeedkey;
|
||||
cvar_t *cl_backspeed;
|
||||
cvar_t *cl_forwardspeed;
|
||||
cvar_t *cl_movespeedkey;
|
||||
cvar_t *cl_pitchspeed;
|
||||
cvar_t *cl_sidespeed;
|
||||
cvar_t *cl_upspeed;
|
||||
cvar_t *cl_yawspeed;
|
||||
float cl_anglespeedkey;
|
||||
static cvar_t cl_anglespeedkey_cvar = {
|
||||
.name = "cl_anglespeedkey",
|
||||
.description =
|
||||
"turn `run' speed multiplier",
|
||||
.default_value = "1.5",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &cl_anglespeedkey },
|
||||
};
|
||||
float cl_backspeed;
|
||||
static cvar_t cl_backspeed_cvar = {
|
||||
.name = "cl_backspeed",
|
||||
.description =
|
||||
"backward speed",
|
||||
.default_value = "200",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_float, .value = &cl_backspeed },
|
||||
};
|
||||
float cl_forwardspeed;
|
||||
static cvar_t cl_forwardspeed_cvar = {
|
||||
.name = "cl_forwardspeed",
|
||||
.description =
|
||||
"forward speed",
|
||||
.default_value = "200",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_float, .value = &cl_forwardspeed },
|
||||
};
|
||||
float cl_movespeedkey;
|
||||
static cvar_t cl_movespeedkey_cvar = {
|
||||
.name = "cl_movespeedkey",
|
||||
.description =
|
||||
"move `run' speed multiplier",
|
||||
.default_value = "2.0",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &cl_movespeedkey },
|
||||
};
|
||||
float cl_pitchspeed;
|
||||
static cvar_t cl_pitchspeed_cvar = {
|
||||
.name = "cl_pitchspeed",
|
||||
.description =
|
||||
"look up/down speed",
|
||||
.default_value = "150",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &cl_pitchspeed },
|
||||
};
|
||||
float cl_sidespeed;
|
||||
static cvar_t cl_sidespeed_cvar = {
|
||||
.name = "cl_sidespeed",
|
||||
.description =
|
||||
"strafe speed",
|
||||
.default_value = "350",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &cl_sidespeed },
|
||||
};
|
||||
float cl_upspeed;
|
||||
static cvar_t cl_upspeed_cvar = {
|
||||
.name = "cl_upspeed",
|
||||
.description =
|
||||
"swim/fly up/down speed",
|
||||
.default_value = "200",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &cl_upspeed },
|
||||
};
|
||||
float cl_yawspeed;
|
||||
static cvar_t cl_yawspeed_cvar = {
|
||||
.name = "cl_yawspeed",
|
||||
.description =
|
||||
"turning speed",
|
||||
.default_value = "140",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &cl_yawspeed },
|
||||
};
|
||||
|
||||
cvar_t *lookspring;
|
||||
cvar_t *m_pitch;
|
||||
cvar_t *m_yaw;
|
||||
cvar_t *m_forward;
|
||||
cvar_t *m_side;
|
||||
int lookspring;
|
||||
static cvar_t lookspring_cvar = {
|
||||
.name = "lookspring",
|
||||
.description =
|
||||
"Snap view to center when moving and no mlook/klook",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_int, .value = &lookspring },
|
||||
};
|
||||
float m_pitch;
|
||||
static cvar_t m_pitch_cvar = {
|
||||
.name = "m_pitch",
|
||||
.description =
|
||||
"mouse pitch (up/down) multipier",
|
||||
.default_value = "0.022",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_float, .value = &m_pitch },
|
||||
};
|
||||
float m_yaw;
|
||||
static cvar_t m_yaw_cvar = {
|
||||
.name = "m_yaw",
|
||||
.description =
|
||||
"mouse yaw (left/right) multipiler",
|
||||
.default_value = "0.022",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_float, .value = &m_yaw },
|
||||
};
|
||||
float m_forward;
|
||||
static cvar_t m_forward_cvar = {
|
||||
.name = "m_forward",
|
||||
.description =
|
||||
"mouse forward/back speed",
|
||||
.default_value = "1",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_float, .value = &m_forward },
|
||||
};
|
||||
float m_side;
|
||||
static cvar_t m_side_cvar = {
|
||||
.name = "m_side",
|
||||
.description =
|
||||
"mouse strafe speed",
|
||||
.default_value = "0.8",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_float, .value = &m_side },
|
||||
};
|
||||
|
||||
static void
|
||||
CL_AdjustAngles (float frametime, movestate_t *ms, viewstate_t *vs)
|
||||
|
@ -236,12 +340,12 @@ CL_AdjustAngles (float frametime, movestate_t *ms, viewstate_t *vs)
|
|||
float pitchspeed, yawspeed;
|
||||
vec4f_t delta = {};
|
||||
|
||||
pitchspeed = cl_pitchspeed->value;
|
||||
yawspeed = cl_yawspeed->value;
|
||||
pitchspeed = cl_pitchspeed;
|
||||
yawspeed = cl_yawspeed;
|
||||
|
||||
if (in_speed.state & inb_down) {
|
||||
pitchspeed *= cl_anglespeedkey->value;
|
||||
yawspeed *= cl_anglespeedkey->value;
|
||||
pitchspeed *= cl_anglespeedkey;
|
||||
yawspeed *= cl_anglespeedkey;
|
||||
}
|
||||
|
||||
pitchspeed *= frametime;
|
||||
|
@ -263,9 +367,9 @@ CL_AdjustAngles (float frametime, movestate_t *ms, viewstate_t *vs)
|
|||
delta[PITCH] -= pitchspeed * up;
|
||||
delta[PITCH] += pitchspeed * down;
|
||||
|
||||
delta[PITCH] -= IN_UpdateAxis (&in_move_pitch) * m_pitch->value;
|
||||
delta[YAW] -= IN_UpdateAxis (&in_move_yaw) * m_yaw->value;
|
||||
delta[ROLL] -= IN_UpdateAxis (&in_move_roll) * m_pitch->value;
|
||||
delta[PITCH] -= IN_UpdateAxis (&in_move_pitch) * m_pitch;
|
||||
delta[YAW] -= IN_UpdateAxis (&in_move_yaw) * m_yaw;
|
||||
delta[ROLL] -= IN_UpdateAxis (&in_move_roll) * m_pitch;
|
||||
|
||||
ms->angles += delta;
|
||||
|
||||
|
@ -359,7 +463,7 @@ CL_Legacy_Init (void)
|
|||
void
|
||||
CL_Input_BuildMove (float frametime, movestate_t *state, viewstate_t *vs)
|
||||
{
|
||||
if (IN_ButtonReleased (&in_mlook) && !freelook && lookspring->int_val) {
|
||||
if (IN_ButtonReleased (&in_mlook) && !freelook && lookspring) {
|
||||
V_StartPitchDrift (vs);
|
||||
}
|
||||
|
||||
|
@ -368,35 +472,35 @@ CL_Input_BuildMove (float frametime, movestate_t *state, viewstate_t *vs)
|
|||
vec4f_t move = {};
|
||||
|
||||
if (in_strafe.state & inb_down) {
|
||||
move[SIDE] += cl_sidespeed->value * IN_ButtonState (&in_right);
|
||||
move[SIDE] -= cl_sidespeed->value * IN_ButtonState (&in_left);
|
||||
move[SIDE] += cl_sidespeed * IN_ButtonState (&in_right);
|
||||
move[SIDE] -= cl_sidespeed * IN_ButtonState (&in_left);
|
||||
}
|
||||
|
||||
move[SIDE] += cl_sidespeed->value * IN_ButtonState (&in_moveright);
|
||||
move[SIDE] -= cl_sidespeed->value * IN_ButtonState (&in_moveleft);
|
||||
move[SIDE] += cl_sidespeed * IN_ButtonState (&in_moveright);
|
||||
move[SIDE] -= cl_sidespeed * IN_ButtonState (&in_moveleft);
|
||||
|
||||
move[UP] += cl_upspeed->value * IN_ButtonState (&in_up);
|
||||
move[UP] -= cl_upspeed->value * IN_ButtonState (&in_down);
|
||||
move[UP] += cl_upspeed * IN_ButtonState (&in_up);
|
||||
move[UP] -= cl_upspeed * IN_ButtonState (&in_down);
|
||||
|
||||
if (!(in_klook.state & inb_down)) {
|
||||
move[FORWARD] += cl_forwardspeed->value * IN_ButtonState (&in_forward);
|
||||
move[FORWARD] -= cl_backspeed->value * IN_ButtonState (&in_back);
|
||||
move[FORWARD] += cl_forwardspeed * IN_ButtonState (&in_forward);
|
||||
move[FORWARD] -= cl_backspeed * IN_ButtonState (&in_back);
|
||||
}
|
||||
|
||||
// adjust for speed key
|
||||
if (in_speed.state & inb_down) {
|
||||
move *= cl_movespeedkey->value;
|
||||
move *= cl_movespeedkey;
|
||||
}
|
||||
|
||||
move[FORWARD] -= IN_UpdateAxis (&in_move_forward) * m_forward->value;
|
||||
move[SIDE] += IN_UpdateAxis (&in_move_side) * m_side->value;
|
||||
move[FORWARD] -= IN_UpdateAxis (&in_move_forward) * m_forward;
|
||||
move[SIDE] += IN_UpdateAxis (&in_move_side) * m_side;
|
||||
move[UP] -= IN_UpdateAxis (&in_move_up);
|
||||
|
||||
if (freelook)
|
||||
V_StopPitchDrift (vs);
|
||||
|
||||
if (vs->chase
|
||||
&& (chase_active->int_val == 2 || chase_active->int_val == 3)) {
|
||||
&& (chase_active == 2 || chase_active == 3)) {
|
||||
/* adjust for chase camera angles
|
||||
* makes the player move relative to the chase camera frame rather
|
||||
* than the player's frame
|
||||
|
@ -481,32 +585,19 @@ CL_Input_Init (cbuf_t *cbuf)
|
|||
void
|
||||
CL_Input_Init_Cvars (void)
|
||||
{
|
||||
lookspring = Cvar_Get ("lookspring", "0", CVAR_ARCHIVE, NULL, "Snap view "
|
||||
"to center when moving and no mlook/klook");
|
||||
m_pitch = Cvar_Get ("m_pitch", "0.022", CVAR_ARCHIVE, NULL,
|
||||
"mouse pitch (up/down) multipier");
|
||||
m_yaw = Cvar_Get ("m_yaw", "0.022", CVAR_ARCHIVE, NULL,
|
||||
"mouse yaw (left/right) multipiler");
|
||||
m_forward = Cvar_Get ("m_forward", "1", CVAR_ARCHIVE, NULL,
|
||||
"mouse forward/back speed");
|
||||
m_side = Cvar_Get ("m_side", "0.8", CVAR_ARCHIVE, NULL,
|
||||
"mouse strafe speed");
|
||||
cl_anglespeedkey = Cvar_Get ("cl_anglespeedkey", "1.5", CVAR_NONE, NULL,
|
||||
"turn `run' speed multiplier");
|
||||
cl_backspeed = Cvar_Get ("cl_backspeed", "200", CVAR_ARCHIVE, NULL,
|
||||
"backward speed");
|
||||
cl_forwardspeed = Cvar_Get ("cl_forwardspeed", "200", CVAR_ARCHIVE, NULL,
|
||||
"forward speed");
|
||||
cl_movespeedkey = Cvar_Get ("cl_movespeedkey", "2.0", CVAR_NONE, NULL,
|
||||
"move `run' speed multiplier");
|
||||
cl_pitchspeed = Cvar_Get ("cl_pitchspeed", "150", CVAR_NONE, NULL,
|
||||
"look up/down speed");
|
||||
cl_sidespeed = Cvar_Get ("cl_sidespeed", "350", CVAR_NONE, NULL,
|
||||
"strafe speed");
|
||||
cl_upspeed = Cvar_Get ("cl_upspeed", "200", CVAR_NONE, NULL,
|
||||
"swim/fly up/down speed");
|
||||
cl_yawspeed = Cvar_Get ("cl_yawspeed", "140", CVAR_NONE, NULL,
|
||||
"turning speed");
|
||||
Cvar_Register (&lookspring_cvar, 0, 0);
|
||||
Cvar_Register (&m_pitch_cvar, 0, 0);
|
||||
Cvar_Register (&m_yaw_cvar, 0, 0);
|
||||
Cvar_Register (&m_forward_cvar, 0, 0);
|
||||
Cvar_Register (&m_side_cvar, 0, 0);
|
||||
Cvar_Register (&cl_anglespeedkey_cvar, 0, 0);
|
||||
Cvar_Register (&cl_backspeed_cvar, 0, 0);
|
||||
Cvar_Register (&cl_forwardspeed_cvar, 0, 0);
|
||||
Cvar_Register (&cl_movespeedkey_cvar, 0, 0);
|
||||
Cvar_Register (&cl_pitchspeed_cvar, 0, 0);
|
||||
Cvar_Register (&cl_sidespeed_cvar, 0, 0);
|
||||
Cvar_Register (&cl_upspeed_cvar, 0, 0);
|
||||
Cvar_Register (&cl_yawspeed_cvar, 0, 0);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -60,8 +60,24 @@ cl_particle_funcs_t *clp_funcs;
|
|||
static mtstate_t mt; // private PRNG state
|
||||
static psystem_t *cl_psystem;
|
||||
|
||||
static cvar_t *easter_eggs;
|
||||
static cvar_t *particles_style;
|
||||
static int easter_eggs;
|
||||
static cvar_t easter_eggs_cvar = {
|
||||
.name = "easter_eggs",
|
||||
.description =
|
||||
"Enables easter eggs.",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_int, .value = &easter_eggs },
|
||||
};
|
||||
static int particles_style;
|
||||
static cvar_t particles_style_cvar = {
|
||||
.name = "particles_style",
|
||||
.description =
|
||||
"Sets particle style. 0 for Id, 1 for QF.",
|
||||
.default_value = "1",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_int, .value = &particles_style },
|
||||
};
|
||||
|
||||
static int ramp[] = {
|
||||
/*ramp1*/ 0x6f, 0x6d, 0x6b, 0x69, 0x67, 0x65, 0x63, 0x61,
|
||||
|
@ -1238,37 +1254,34 @@ static cl_particle_funcs_t particles_ID_egg = {
|
|||
};
|
||||
|
||||
static void
|
||||
easter_eggs_f (cvar_t *var)
|
||||
set_particle_funcs (void)
|
||||
{
|
||||
if (easter_eggs) {
|
||||
if (easter_eggs->int_val) {
|
||||
if (particles_style->int_val) {
|
||||
clp_funcs = &particles_QF_egg;
|
||||
} else {
|
||||
clp_funcs = &particles_ID_egg;
|
||||
}
|
||||
} else if (particles_style) {
|
||||
if (particles_style->int_val) {
|
||||
clp_funcs = &particles_QF;
|
||||
} else {
|
||||
clp_funcs = &particles_ID;
|
||||
}
|
||||
if (particles_style) {
|
||||
clp_funcs = &particles_QF_egg;
|
||||
} else {
|
||||
clp_funcs = &particles_ID_egg;
|
||||
}
|
||||
} else {
|
||||
if (particles_style) {
|
||||
clp_funcs = &particles_QF;
|
||||
} else {
|
||||
clp_funcs = &particles_ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
particles_style_f (cvar_t *var)
|
||||
easter_eggs_f (void *data, const cvar_t *cvar)
|
||||
{
|
||||
easter_eggs_f (easter_eggs);
|
||||
cl_psystem->points_only = !var->int_val;
|
||||
set_particle_funcs ();
|
||||
}
|
||||
|
||||
static void
|
||||
CL_ParticleFunctionInit (void)
|
||||
particles_style_f (void *data, const cvar_t *cvar)
|
||||
{
|
||||
particles_style_f (particles_style);
|
||||
easter_eggs_f (easter_eggs);
|
||||
set_particle_funcs ();
|
||||
cl_psystem->points_only = !particles_style;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1276,12 +1289,9 @@ CL_Particles_Init (void)
|
|||
{
|
||||
mtwist_seed (&mt, 0xdeadbeef);
|
||||
cl_psystem = r_funcs->ParticleSystem ();
|
||||
easter_eggs = Cvar_Get ("easter_eggs", "0", CVAR_NONE, easter_eggs_f,
|
||||
"Enables easter eggs.");
|
||||
particles_style = Cvar_Get ("particles_style", "1", CVAR_ARCHIVE,
|
||||
particles_style_f,
|
||||
"Sets particle style. 0 for Id, 1 for QF.");
|
||||
CL_ParticleFunctionInit ();
|
||||
Cvar_Register (&easter_eggs_cvar, easter_eggs_f, 0);
|
||||
Cvar_Register (&particles_style_cvar, particles_style_f, 0);
|
||||
set_particle_funcs ();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -54,37 +54,230 @@
|
|||
especially when crossing a water boudnary.
|
||||
*/
|
||||
|
||||
cvar_t *scr_ofsx;
|
||||
cvar_t *scr_ofsy;
|
||||
cvar_t *scr_ofsz;
|
||||
float scr_ofsx;
|
||||
static cvar_t scr_ofsx_cvar = {
|
||||
.name = "scr_ofsx",
|
||||
.description =
|
||||
"None",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &scr_ofsx },
|
||||
};
|
||||
float scr_ofsy;
|
||||
static cvar_t scr_ofsy_cvar = {
|
||||
.name = "scr_ofsy",
|
||||
.description =
|
||||
"None",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &scr_ofsy },
|
||||
};
|
||||
float scr_ofsz;
|
||||
static cvar_t scr_ofsz_cvar = {
|
||||
.name = "scr_ofsz",
|
||||
.description =
|
||||
"None",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &scr_ofsz },
|
||||
};
|
||||
|
||||
cvar_t *cl_rollspeed;
|
||||
cvar_t *cl_rollangle;
|
||||
float cl_rollspeed;
|
||||
static cvar_t cl_rollspeed_cvar = {
|
||||
.name = "cl_rollspeed",
|
||||
.description =
|
||||
"How quickly you straighten out after strafing",
|
||||
.default_value = "200",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &cl_rollspeed },
|
||||
};
|
||||
float cl_rollangle;
|
||||
static cvar_t cl_rollangle_cvar = {
|
||||
.name = "cl_rollangle",
|
||||
.description =
|
||||
"How much your screen tilts when strafing",
|
||||
.default_value = "2.0",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &cl_rollangle },
|
||||
};
|
||||
|
||||
cvar_t *cl_bob;
|
||||
cvar_t *cl_bobcycle;
|
||||
cvar_t *cl_bobup;
|
||||
float cl_bob;
|
||||
static cvar_t cl_bob_cvar = {
|
||||
.name = "cl_bob",
|
||||
.description =
|
||||
"How much your weapon moves up and down when walking",
|
||||
.default_value = "0.02",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &cl_bob },
|
||||
};
|
||||
float cl_bobcycle;
|
||||
static cvar_t cl_bobcycle_cvar = {
|
||||
.name = "cl_bobcycle",
|
||||
.description =
|
||||
"How quickly your weapon moves up and down when walking",
|
||||
.default_value = "0.6",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &cl_bobcycle },
|
||||
};
|
||||
float cl_bobup;
|
||||
static cvar_t cl_bobup_cvar = {
|
||||
.name = "cl_bobup",
|
||||
.description =
|
||||
"How long your weapon stays up before cycling when walking",
|
||||
.default_value = "0.5",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &cl_bobup },
|
||||
};
|
||||
|
||||
cvar_t *v_centermove;
|
||||
cvar_t *v_centerspeed;
|
||||
float v_centermove;
|
||||
static cvar_t v_centermove_cvar = {
|
||||
.name = "v_centermove",
|
||||
.description =
|
||||
"How far the player must move forward before the view re-centers",
|
||||
.default_value = "0.15",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &v_centermove },
|
||||
};
|
||||
float v_centerspeed;
|
||||
static cvar_t v_centerspeed_cvar = {
|
||||
.name = "v_centerspeed",
|
||||
.description =
|
||||
"How quickly you return to a center view after a lookup or lookdown",
|
||||
.default_value = "500",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &v_centerspeed },
|
||||
};
|
||||
|
||||
cvar_t *v_kicktime;
|
||||
cvar_t *v_kickroll;
|
||||
cvar_t *v_kickpitch;
|
||||
float v_kicktime;
|
||||
static cvar_t v_kicktime_cvar = {
|
||||
.name = "v_kicktime",
|
||||
.description =
|
||||
"How long the kick from an attack lasts",
|
||||
.default_value = "0.5",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &v_kicktime },
|
||||
};
|
||||
float v_kickroll;
|
||||
static cvar_t v_kickroll_cvar = {
|
||||
.name = "v_kickroll",
|
||||
.description =
|
||||
"How much you lean when hit",
|
||||
.default_value = "0.6",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &v_kickroll },
|
||||
};
|
||||
float v_kickpitch;
|
||||
static cvar_t v_kickpitch_cvar = {
|
||||
.name = "v_kickpitch",
|
||||
.description =
|
||||
"How much you look up when hit",
|
||||
.default_value = "0.6",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &v_kickpitch },
|
||||
};
|
||||
|
||||
cvar_t *cl_cshift_bonus;
|
||||
cvar_t *cl_cshift_contents;
|
||||
cvar_t *cl_cshift_damage;
|
||||
cvar_t *cl_cshift_powerup;
|
||||
int cl_cshift_bonus;
|
||||
static cvar_t cl_cshift_bonus_cvar = {
|
||||
.name = "cl_cshift_bonus",
|
||||
.description =
|
||||
"Show bonus flash on item pickup",
|
||||
.default_value = "1",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_int, .value = &cl_cshift_bonus },
|
||||
};
|
||||
int cl_cshift_contents;
|
||||
static cvar_t cl_cshift_contents_cvar = {
|
||||
.name = "cl_cshift_content",
|
||||
.description =
|
||||
"Shift view colors for contents (water, slime, etc)",
|
||||
.default_value = "1",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_int, .value = &cl_cshift_contents },
|
||||
};
|
||||
int cl_cshift_damage;
|
||||
static cvar_t cl_cshift_damage_cvar = {
|
||||
.name = "cl_cshift_damage",
|
||||
.description =
|
||||
"Shift view colors on damage",
|
||||
.default_value = "1",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_int, .value = &cl_cshift_damage },
|
||||
};
|
||||
int cl_cshift_powerup;
|
||||
static cvar_t cl_cshift_powerup_cvar = {
|
||||
.name = "cl_cshift_powerup",
|
||||
.description =
|
||||
"Shift view colors for powerups",
|
||||
.default_value = "1",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_int, .value = &cl_cshift_powerup },
|
||||
};
|
||||
|
||||
cvar_t *v_iyaw_cycle;
|
||||
cvar_t *v_iroll_cycle;
|
||||
cvar_t *v_ipitch_cycle;
|
||||
cvar_t *v_iyaw_level;
|
||||
cvar_t *v_iroll_level;
|
||||
cvar_t *v_ipitch_level;
|
||||
float v_iyaw_cycle;
|
||||
static cvar_t v_iyaw_cycle_cvar = {
|
||||
.name = "v_iyaw_cycle",
|
||||
.description =
|
||||
"How far you tilt right and left when v_idlescale is enabled",
|
||||
.default_value = "2",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &v_iyaw_cycle },
|
||||
};
|
||||
float v_iroll_cycle;
|
||||
static cvar_t v_iroll_cycle_cvar = {
|
||||
.name = "v_iroll_cycle",
|
||||
.description =
|
||||
"How quickly you tilt right and left when v_idlescale is enabled",
|
||||
.default_value = "0.5",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &v_iroll_cycle },
|
||||
};
|
||||
float v_ipitch_cycle;
|
||||
static cvar_t v_ipitch_cycle_cvar = {
|
||||
.name = "v_ipitch_cycle",
|
||||
.description =
|
||||
"How quickly you lean forwards and backwards when v_idlescale is "
|
||||
"enabled",
|
||||
.default_value = "1",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &v_ipitch_cycle },
|
||||
};
|
||||
float v_iyaw_level;
|
||||
static cvar_t v_iyaw_level_cvar = {
|
||||
.name = "v_iyaw_level",
|
||||
.description =
|
||||
"How far you tilt right and left when v_idlescale is enabled",
|
||||
.default_value = "0.3",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &v_iyaw_level },
|
||||
};
|
||||
float v_iroll_level;
|
||||
static cvar_t v_iroll_level_cvar = {
|
||||
.name = "v_iroll_level",
|
||||
.description =
|
||||
"How far you tilt right and left when v_idlescale is enabled",
|
||||
.default_value = "0.1",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &v_iroll_level },
|
||||
};
|
||||
float v_ipitch_level;
|
||||
static cvar_t v_ipitch_level_cvar = {
|
||||
.name = "v_ipitch_level",
|
||||
.description =
|
||||
"How far you lean forwards and backwards when v_idlescale is enabled",
|
||||
.default_value = "0.3",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &v_ipitch_level },
|
||||
};
|
||||
|
||||
cvar_t *v_idlescale;
|
||||
float v_idlescale;
|
||||
static cvar_t v_idlescale_cvar = {
|
||||
.name = "v_idlescale",
|
||||
.description =
|
||||
"Toggles whether the view remains idle",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &v_idlescale },
|
||||
};
|
||||
|
||||
float v_dmg_time, v_dmg_roll, v_dmg_pitch;
|
||||
|
||||
|
@ -137,10 +330,10 @@ V_CalcRoll (const vec3_t angles, vec4f_t velocity)
|
|||
sign = side < 0 ? -1 : 1;
|
||||
side = fabs (side);
|
||||
|
||||
value = cl_rollangle->value;
|
||||
value = cl_rollangle;
|
||||
|
||||
if (side < cl_rollspeed->value)
|
||||
side = side * value / cl_rollspeed->value;
|
||||
if (side < cl_rollspeed)
|
||||
side = side * value / cl_rollspeed;
|
||||
else
|
||||
side = value;
|
||||
|
||||
|
@ -162,18 +355,18 @@ V_CalcBob (viewstate_t *vs)
|
|||
return bob; // just use old value
|
||||
|
||||
bobtime += vs->frametime;
|
||||
cycle = bobtime - (int) (bobtime / cl_bobcycle->value) *
|
||||
cl_bobcycle->value;
|
||||
cycle /= cl_bobcycle->value;
|
||||
if (cycle < cl_bobup->value)
|
||||
cycle = cycle / cl_bobup->value;
|
||||
cycle = bobtime - (int) (bobtime / cl_bobcycle) *
|
||||
cl_bobcycle;
|
||||
cycle /= cl_bobcycle;
|
||||
if (cycle < cl_bobup)
|
||||
cycle = cycle / cl_bobup;
|
||||
else
|
||||
cycle = 1 + (cycle - cl_bobup->value) / (1.0 - cl_bobup->value);
|
||||
cycle = 1 + (cycle - cl_bobup) / (1.0 - cl_bobup);
|
||||
|
||||
// bob is proportional to velocity in the xy plane
|
||||
// (don't count Z, or jumping messes it up)
|
||||
velocity[2] = 0;
|
||||
bob = sqrt (dotf (velocity, velocity)[0]) * cl_bob->value;
|
||||
bob = sqrt (dotf (velocity, velocity)[0]) * cl_bob;
|
||||
bob = bob * 0.3 + bob * 0.7 * sin (cycle * M_PI);
|
||||
if (bob > 4)
|
||||
bob = 4;
|
||||
|
@ -190,7 +383,7 @@ V_StartPitchDrift (viewstate_t *vs)
|
|||
}
|
||||
|
||||
if (vs->nodrift || !vs->pitchvel) {
|
||||
vs->pitchvel = v_centerspeed->value;
|
||||
vs->pitchvel = v_centerspeed;
|
||||
vs->nodrift = false;
|
||||
vs->driftmove = 0;
|
||||
}
|
||||
|
@ -236,12 +429,12 @@ V_DriftPitch (viewstate_t *vs)
|
|||
|
||||
// don't count small mouse motion
|
||||
if (vs->nodrift) {
|
||||
if (fabs (forwardmove) < cl_forwardspeed->value)
|
||||
if (fabs (forwardmove) < cl_forwardspeed)
|
||||
vs->driftmove = 0;
|
||||
else
|
||||
vs->driftmove += vs->frametime;
|
||||
|
||||
if (vs->driftmove > v_centermove->value) {
|
||||
if (vs->driftmove > v_centermove) {
|
||||
V_StartPitchDrift (vs);
|
||||
}
|
||||
return;
|
||||
|
@ -255,7 +448,7 @@ V_DriftPitch (viewstate_t *vs)
|
|||
}
|
||||
|
||||
move = vs->frametime * vs->pitchvel;
|
||||
vs->pitchvel += vs->frametime * v_centerspeed->value;
|
||||
vs->pitchvel += vs->frametime * v_centerspeed;
|
||||
|
||||
if (delta > 0) {
|
||||
if (move > delta) {
|
||||
|
@ -291,7 +484,7 @@ V_ParseDamage (qmsg_t *net_message, viewstate_t *vs)
|
|||
if (count < 10)
|
||||
count = 10;
|
||||
|
||||
if (cl_cshift_damage->int_val
|
||||
if (cl_cshift_damage
|
||||
|| (vs->force_cshifts & INFO_CSHIFT_DAMAGE)) {
|
||||
cshift_t *cshift = &vs->cshifts[CSHIFT_DAMAGE];
|
||||
int percent = cshift->percent;
|
||||
|
@ -309,12 +502,12 @@ V_ParseDamage (qmsg_t *net_message, viewstate_t *vs)
|
|||
AngleVectors (angles, forward, right, up);
|
||||
|
||||
side = DotProduct (from, right);
|
||||
v_dmg_roll = count * side * v_kickroll->value;
|
||||
v_dmg_roll = count * side * v_kickroll;
|
||||
|
||||
side = DotProduct (from, forward);
|
||||
v_dmg_pitch = count * side * v_kickpitch->value;
|
||||
v_dmg_pitch = count * side * v_kickpitch;
|
||||
|
||||
v_dmg_time = v_kicktime->value;
|
||||
v_dmg_time = v_kicktime;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -335,7 +528,7 @@ static void
|
|||
V_BonusFlash_f (void *data)
|
||||
{
|
||||
viewstate_t *vs = data;
|
||||
if (!cl_cshift_bonus->int_val
|
||||
if (!cl_cshift_bonus
|
||||
&& !(vs->force_cshifts & INFO_CSHIFT_BONUS))
|
||||
return;
|
||||
|
||||
|
@ -352,7 +545,7 @@ V_BonusFlash_f (void *data)
|
|||
void
|
||||
V_SetContentsColor (viewstate_t *vs, int contents)
|
||||
{
|
||||
if (!cl_cshift_contents->int_val
|
||||
if (!cl_cshift_contents
|
||||
&& !(vs->force_cshifts & INFO_CSHIFT_CONTENTS)) {
|
||||
vs->cshifts[CSHIFT_CONTENTS] = cshift_empty;
|
||||
return;
|
||||
|
@ -441,7 +634,7 @@ V_PrepBlend (viewstate_t *vs)
|
|||
{
|
||||
int i, j;
|
||||
|
||||
if (cl_cshift_powerup->int_val
|
||||
if (cl_cshift_powerup
|
||||
|| (vs->force_cshifts & INFO_CSHIFT_POWERUP))
|
||||
V_CalcPowerupCshift (vs);
|
||||
|
||||
|
@ -499,14 +692,14 @@ V_BoundOffsets (viewstate_t *vs)
|
|||
}
|
||||
|
||||
static vec4f_t
|
||||
idle_quat (vec4f_t axis, cvar_t *cycle, cvar_t *level, double time)
|
||||
idle_quat (vec4f_t axis, float cycle, float level, double time)
|
||||
{
|
||||
vec4f_t identity = { 0, 0, 0, 1 };
|
||||
if (!level || !cycle) {
|
||||
return identity;
|
||||
}
|
||||
float scale = sin (time * cycle->value);
|
||||
float ang = scale * level->value * v_idlescale->value;
|
||||
float scale = sin (time * cycle);
|
||||
float ang = scale * level * v_idlescale;
|
||||
float c = cos (ang * M_PI / 360);
|
||||
float s = sin (ang * M_PI / 360);
|
||||
return axis * s + identity * c;
|
||||
|
@ -553,8 +746,8 @@ V_CalcViewRoll (viewstate_t *vs)
|
|||
ang[ROLL] = V_CalcRoll (angles, velocity);
|
||||
|
||||
if (v_dmg_time > 0) {
|
||||
ang[ROLL] += v_dmg_time / v_kicktime->value * v_dmg_roll;
|
||||
ang[PITCH] += v_dmg_time / v_kicktime->value * v_dmg_pitch;
|
||||
ang[ROLL] += v_dmg_time / v_kicktime * v_dmg_roll;
|
||||
ang[PITCH] += v_dmg_time / v_kicktime * v_dmg_pitch;
|
||||
v_dmg_time -= vs->frametime;
|
||||
}
|
||||
|
||||
|
@ -586,10 +779,10 @@ V_CalcIntermissionRefdef (viewstate_t *vs)
|
|||
view->renderer.model = NULL;
|
||||
|
||||
// always idle in intermission
|
||||
old = v_idlescale->value;
|
||||
Cvar_SetValue (v_idlescale, 1);
|
||||
old = v_idlescale;
|
||||
v_idlescale = 1;
|
||||
V_AddIdle (vs);
|
||||
Cvar_SetValue (v_idlescale, old);
|
||||
v_idlescale = old;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -628,9 +821,7 @@ V_CalcRefdef (viewstate_t *vs)
|
|||
// don't allow cheats in multiplayer
|
||||
// FIXME check for dead
|
||||
if (vs->voffs_enabled) {
|
||||
origin += scr_ofsx->value * forward
|
||||
+ scr_ofsy->value * right
|
||||
+ scr_ofsz->value * up;
|
||||
origin += scr_ofsx * forward + scr_ofsy * right + scr_ofsz * up;
|
||||
}
|
||||
|
||||
V_BoundOffsets (vs);
|
||||
|
@ -644,15 +835,15 @@ V_CalcRefdef (viewstate_t *vs)
|
|||
|
||||
// fudge position around to keep amount of weapon visible
|
||||
// roughly equal with different FOV
|
||||
if (hud_sbar->int_val == 0 && r_data->scr_viewsize->int_val >= 100) {
|
||||
if (hud_sbar == 0 && *r_data->scr_viewsize >= 100) {
|
||||
;
|
||||
} else if (r_data->scr_viewsize->int_val == 110) {
|
||||
} else if (*r_data->scr_viewsize == 110) {
|
||||
gun_origin += (vec4f_t) { 0, 0, 1, 0};
|
||||
} else if (r_data->scr_viewsize->int_val == 100) {
|
||||
} else if (*r_data->scr_viewsize == 100) {
|
||||
gun_origin += (vec4f_t) { 0, 0, 2, 0};
|
||||
} else if (r_data->scr_viewsize->int_val == 90) {
|
||||
} else if (*r_data->scr_viewsize == 90) {
|
||||
gun_origin += (vec4f_t) { 0, 0, 1, 0};
|
||||
} else if (r_data->scr_viewsize->int_val == 80) {
|
||||
} else if (*r_data->scr_viewsize == 80) {
|
||||
gun_origin += (vec4f_t) { 0, 0, 0.5, 0};
|
||||
}
|
||||
|
||||
|
@ -741,7 +932,7 @@ V_RenderView (viewstate_t *vs)
|
|||
if (vs->intermission) { // intermission / finale rendering
|
||||
V_CalcIntermissionRefdef (vs);
|
||||
} else {
|
||||
if (vs->chase && chase_active->int_val) {
|
||||
if (vs->chase && chase_active) {
|
||||
Chase_Update (vs->chasestate);
|
||||
} else {
|
||||
V_CalcRefdef (vs);
|
||||
|
@ -769,61 +960,29 @@ V_Init (viewstate_t *viewstate)
|
|||
void
|
||||
V_Init_Cvars (void)
|
||||
{
|
||||
v_centermove = Cvar_Get ("v_centermove", "0.15", CVAR_NONE, NULL,
|
||||
"How far the player must move forward before the "
|
||||
"view re-centers");
|
||||
v_centerspeed = Cvar_Get ("v_centerspeed", "500", CVAR_NONE, NULL,
|
||||
"How quickly you return to a center view after "
|
||||
"a lookup or lookdown");
|
||||
v_iyaw_cycle = Cvar_Get ("v_iyaw_cycle", "2", CVAR_NONE, NULL,
|
||||
"How far you tilt right and left when "
|
||||
"v_idlescale is enabled");
|
||||
v_iroll_cycle = Cvar_Get ("v_iroll_cycle", "0.5", CVAR_NONE, NULL,
|
||||
"How quickly you tilt right and left when "
|
||||
"v_idlescale is enabled");
|
||||
v_ipitch_cycle = Cvar_Get ("v_ipitch_cycle", "1", CVAR_NONE, NULL,
|
||||
"How quickly you lean forwards and backwards "
|
||||
"when v_idlescale is enabled");
|
||||
v_iyaw_level = Cvar_Get ("v_iyaw_level", "0.3", CVAR_NONE, NULL,
|
||||
"How far you tilt right and left when "
|
||||
"v_idlescale is enabled");
|
||||
v_iroll_level = Cvar_Get ("v_iroll_level", "0.1", CVAR_NONE, NULL,
|
||||
"How far you tilt right and left when "
|
||||
"v_idlescale is enabled");
|
||||
v_ipitch_level = Cvar_Get ("v_ipitch_level", "0.3", CVAR_NONE, NULL,
|
||||
"How far you lean forwards and backwards when "
|
||||
"v_idlescale is enabled");
|
||||
v_idlescale = Cvar_Get ("v_idlescale", "0", CVAR_NONE, NULL,
|
||||
"Toggles whether the view remains idle");
|
||||
Cvar_Register (&v_centermove_cvar, 0, 0);
|
||||
Cvar_Register (&v_centerspeed_cvar, 0, 0);
|
||||
Cvar_Register (&v_iyaw_cycle_cvar, 0, 0);
|
||||
Cvar_Register (&v_iroll_cycle_cvar, 0, 0);
|
||||
Cvar_Register (&v_ipitch_cycle_cvar, 0, 0);
|
||||
Cvar_Register (&v_iyaw_level_cvar, 0, 0);
|
||||
Cvar_Register (&v_iroll_level_cvar, 0, 0);
|
||||
Cvar_Register (&v_ipitch_level_cvar, 0, 0);
|
||||
Cvar_Register (&v_idlescale_cvar, 0, 0);
|
||||
|
||||
scr_ofsx = Cvar_Get ("scr_ofsx", "0", CVAR_NONE, NULL, "None");
|
||||
scr_ofsy = Cvar_Get ("scr_ofsy", "0", CVAR_NONE, NULL, "None");
|
||||
scr_ofsz = Cvar_Get ("scr_ofsz", "0", CVAR_NONE, NULL, "None");
|
||||
cl_rollspeed = Cvar_Get ("cl_rollspeed", "200", CVAR_NONE, NULL,
|
||||
"How quickly you straighten out after strafing");
|
||||
cl_rollangle = Cvar_Get ("cl_rollangle", "2.0", CVAR_NONE, NULL,
|
||||
"How much your screen tilts when strafing");
|
||||
cl_bob = Cvar_Get ("cl_bob", "0.02", CVAR_NONE, NULL,
|
||||
"How much your weapon moves up and down when walking");
|
||||
cl_bobcycle = Cvar_Get ("cl_bobcycle", "0.6", CVAR_NONE, NULL,
|
||||
"How quickly your weapon moves up and down when "
|
||||
"walking");
|
||||
cl_bobup = Cvar_Get ("cl_bobup", "0.5", CVAR_NONE, NULL,
|
||||
"How long your weapon stays up before cycling when "
|
||||
"walking");
|
||||
v_kicktime = Cvar_Get ("v_kicktime", "0.5", CVAR_NONE, NULL,
|
||||
"How long the kick from an attack lasts");
|
||||
v_kickroll = Cvar_Get ("v_kickroll", "0.6", CVAR_NONE, NULL,
|
||||
"How much you lean when hit");
|
||||
v_kickpitch = Cvar_Get ("v_kickpitch", "0.6", CVAR_NONE, NULL,
|
||||
"How much you look up when hit");
|
||||
cl_cshift_bonus = Cvar_Get ("cl_cshift_bonus", "1", CVAR_ARCHIVE, NULL,
|
||||
"Show bonus flash on item pickup");
|
||||
cl_cshift_contents = Cvar_Get ("cl_cshift_content", "1", CVAR_ARCHIVE,
|
||||
NULL, "Shift view colors for contents "
|
||||
"(water, slime, etc)");
|
||||
cl_cshift_damage = Cvar_Get ("cl_cshift_damage", "1", CVAR_ARCHIVE, NULL,
|
||||
"Shift view colors on damage");
|
||||
cl_cshift_powerup = Cvar_Get ("cl_cshift_powerup", "1", CVAR_ARCHIVE, NULL,
|
||||
"Shift view colors for powerups");
|
||||
Cvar_Register (&scr_ofsx_cvar, 0, 0);
|
||||
Cvar_Register (&scr_ofsy_cvar, 0, 0);
|
||||
Cvar_Register (&scr_ofsz_cvar, 0, 0);
|
||||
Cvar_Register (&cl_rollspeed_cvar, 0, 0);
|
||||
Cvar_Register (&cl_rollangle_cvar, 0, 0);
|
||||
Cvar_Register (&cl_bob_cvar, 0, 0);
|
||||
Cvar_Register (&cl_bobcycle_cvar, 0, 0);
|
||||
Cvar_Register (&cl_bobup_cvar, 0, 0);
|
||||
Cvar_Register (&v_kicktime_cvar, 0, 0);
|
||||
Cvar_Register (&v_kickroll_cvar, 0, 0);
|
||||
Cvar_Register (&v_kickpitch_cvar, 0, 0);
|
||||
Cvar_Register (&cl_cshift_bonus_cvar, 0, 0);
|
||||
Cvar_Register (&cl_cshift_contents_cvar, 0, 0);
|
||||
Cvar_Register (&cl_cshift_damage_cvar, 0, 0);
|
||||
Cvar_Register (&cl_cshift_powerup_cvar, 0, 0);
|
||||
}
|
||||
|
|
|
@ -29,8 +29,140 @@
|
|||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include "QF/cvar.h"
|
||||
#include <string.h>
|
||||
|
||||
cvar_t *hud_sbar;
|
||||
cvar_t *hud_scoreboard_gravity;
|
||||
cvar_t *hud_swap;
|
||||
#include "QF/cvar.h"
|
||||
#include "QF/screen.h"
|
||||
#include "QF/render.h"
|
||||
#include "QF/plugin/vid_render.h"
|
||||
#include "QF/ui/view.h"
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
#include "client/hud.h"
|
||||
|
||||
int hud_sb_lines;
|
||||
|
||||
int hud_sbar;
|
||||
static cvar_t hud_sbar_cvar = {
|
||||
.name = "hud_sbar",
|
||||
.description =
|
||||
"status bar mode: 0 = hud, 1 = oldstyle",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_int, .value = &hud_sbar },
|
||||
};
|
||||
grav_t hud_scoreboard_gravity;
|
||||
static cvar_t hud_scoreboard_gravity_cvar = {
|
||||
.name = "hud_scoreboard_gravity",
|
||||
.description =
|
||||
"control placement of scoreboard overlay: center, northwest, north, "
|
||||
"northeast, west, east, southwest, south, southeast",
|
||||
.default_value = "center",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &grav_t_type, .value = &hud_scoreboard_gravity },
|
||||
};
|
||||
int hud_swap;
|
||||
static cvar_t hud_swap_cvar = {
|
||||
.name = "hud_swap",
|
||||
.description =
|
||||
"new HUD on left side?",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_int, .value = &hud_swap },
|
||||
};
|
||||
|
||||
view_t *sbar_view;
|
||||
view_t *sbar_inventory_view;
|
||||
view_t *sbar_frags_view;
|
||||
|
||||
view_t *hud_view;
|
||||
view_t *hud_inventory_view;
|
||||
view_t *hud_armament_view;
|
||||
view_t *hud_frags_view;
|
||||
|
||||
view_t *hud_overlay_view;
|
||||
view_t *hud_stuff_view;
|
||||
view_t *hud_main_view;
|
||||
|
||||
static void
|
||||
hud_sbar_f (void *data, const cvar_t *cvar)
|
||||
{
|
||||
HUD_Calc_sb_lines (*r_data->scr_viewsize);
|
||||
SCR_SetBottomMargin (hud_sbar ? hud_sb_lines : 0);
|
||||
if (hud_sbar) {
|
||||
view_remove (hud_main_view, hud_main_view->children[0]);
|
||||
view_insert (hud_main_view, sbar_view, 0);
|
||||
} else {
|
||||
view_remove (hud_main_view, hud_main_view->children[0]);
|
||||
view_insert (hud_main_view, hud_view, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
hud_swap_f (void *data, const cvar_t *cvar)
|
||||
{
|
||||
if (hud_swap) {
|
||||
//FIXME why is this needed for nq but not for qw?
|
||||
hud_armament_view->children[0]->gravity = grav_northwest;
|
||||
hud_armament_view->children[1]->gravity = grav_southeast;
|
||||
view_setgravity (hud_armament_view, grav_southwest);
|
||||
view_setgravity (hud_stuff_view, grav_southeast);
|
||||
} else {
|
||||
//FIXME why is this needed for nq but not for qw?
|
||||
hud_armament_view->children[0]->gravity = grav_northeast;
|
||||
hud_armament_view->children[1]->gravity = grav_southwest;
|
||||
view_setgravity (hud_armament_view, grav_southeast);
|
||||
view_setgravity (hud_stuff_view, grav_southwest);
|
||||
}
|
||||
view_move (hud_armament_view, hud_armament_view->xpos,
|
||||
hud_armament_view->ypos);
|
||||
view_move (hud_stuff_view, hud_stuff_view->xpos, hud_stuff_view->ypos);
|
||||
}
|
||||
|
||||
static void
|
||||
hud_scoreboard_gravity_f (void *data, const cvar_t *cvar)
|
||||
{
|
||||
view_setgravity (hud_overlay_view, hud_scoreboard_gravity);
|
||||
}
|
||||
|
||||
void
|
||||
HUD_Init_Cvars (void)
|
||||
{
|
||||
Cvar_Register (&hud_sbar_cvar, hud_sbar_f, 0);
|
||||
Cvar_Register (&hud_swap_cvar, hud_swap_f, 0);
|
||||
Cvar_Register (&hud_scoreboard_gravity_cvar, hud_scoreboard_gravity_f, 0);
|
||||
}
|
||||
|
||||
void
|
||||
HUD_Calc_sb_lines (int view_size)
|
||||
{
|
||||
int stuff_y;
|
||||
|
||||
if (view_size >= 120) {
|
||||
hud_sb_lines = 0;
|
||||
stuff_y = 0;
|
||||
} else if (view_size >= 110) {
|
||||
hud_sb_lines = 24;
|
||||
sbar_inventory_view->visible = 0;
|
||||
hud_inventory_view->visible = 0;
|
||||
hud_armament_view->visible = 0;
|
||||
stuff_y = 32;
|
||||
} else {
|
||||
hud_sb_lines = 48;
|
||||
sbar_inventory_view->visible = 1;
|
||||
hud_inventory_view->visible = 1;
|
||||
hud_armament_view->visible = 1;
|
||||
stuff_y = 48;
|
||||
}
|
||||
if (hud_sb_lines) {
|
||||
sbar_view->visible = 1;
|
||||
hud_view->visible = 1;
|
||||
view_resize (sbar_view, sbar_view->xlen, hud_sb_lines);
|
||||
view_resize (hud_view, hud_view->xlen, hud_sb_lines);
|
||||
} else {
|
||||
sbar_view->visible = 0;
|
||||
hud_view->visible = 0;
|
||||
}
|
||||
view_move (hud_stuff_view, hud_stuff_view->xpos, stuff_y);
|
||||
}
|
||||
|
|
|
@ -80,11 +80,78 @@ static old_console_t *con;
|
|||
|
||||
static float con_cursorspeed = 4;
|
||||
|
||||
static cvar_t *con_notifytime; // seconds
|
||||
static cvar_t *con_alpha;
|
||||
static cvar_t *con_size;
|
||||
static cvar_t *con_speed;
|
||||
static cvar_t *cl_conmode;
|
||||
static float con_notifytime;
|
||||
static cvar_t con_notifytime_cvar = {
|
||||
.name = "con_notifytime",
|
||||
.description =
|
||||
"How long in seconds messages are displayed on screen",
|
||||
.default_value = "3",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &con_notifytime },
|
||||
};
|
||||
static float con_alpha;
|
||||
static cvar_t con_alpha_cvar = {
|
||||
.name = "con_alpha",
|
||||
.description =
|
||||
"alpha value for the console background",
|
||||
.default_value = "0.6",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_float, .value = &con_alpha },
|
||||
};
|
||||
static float con_size;
|
||||
static cvar_t con_size_cvar = {
|
||||
.name = "con_size",
|
||||
.description =
|
||||
"Fraction of the screen the console covers when down",
|
||||
.default_value = "0.5",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_float, .value = &con_size },
|
||||
};
|
||||
static float con_speed;
|
||||
static cvar_t con_speed_cvar = {
|
||||
.name = "con_speed",
|
||||
.description =
|
||||
"How quickly the console scrolls up or down",
|
||||
.default_value = "300",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_float, .value = &con_speed },
|
||||
};
|
||||
static exprenum_t cl_conmode_enum;
|
||||
static exprtype_t cl_conmode_type = {
|
||||
.name = "cl_conmode",
|
||||
.size = sizeof (con_data.exec_line),
|
||||
.data = &cl_conmode_enum,
|
||||
.get_string = cexpr_enum_get_string,
|
||||
};
|
||||
static int cl_exec_line_command (void *data, const char *line);
|
||||
static int cl_exec_line_chat (void *data, const char *line);
|
||||
static int cl_exec_line_rcon (void *data, const char *line);
|
||||
static int (*cl_conmode_values[])(void *, const char *) = {
|
||||
cl_exec_line_command,
|
||||
cl_exec_line_chat,
|
||||
cl_exec_line_rcon,
|
||||
};
|
||||
static exprsym_t cl_conmode_symbols[] = {
|
||||
{"command", &cl_conmode_type, cl_conmode_values + 0},
|
||||
{"chat", &cl_conmode_type, cl_conmode_values + 1},
|
||||
{"rcon", &cl_conmode_type, cl_conmode_values + 1},
|
||||
{}
|
||||
};
|
||||
static exprtab_t cl_conmode_symtab = {
|
||||
cl_conmode_symbols,
|
||||
};
|
||||
static exprenum_t cl_conmode_enum = {
|
||||
&cl_conmode_type,
|
||||
&cl_conmode_symtab,
|
||||
};
|
||||
static cvar_t cl_conmode_cvar = {
|
||||
.name = "cl_conmode",
|
||||
.description =
|
||||
"Set the console input mode (command, chat, rcon)",
|
||||
.default_value = "command",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cl_conmode_type, .value = &con_data.exec_line },
|
||||
};
|
||||
|
||||
#define NUM_CON_TIMES 4
|
||||
static float con_times[NUM_CON_TIMES]; // realtime time the line was generated
|
||||
|
@ -313,22 +380,6 @@ cl_exec_line_rcon (void *data, const char *line)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
cl_conmode_f (cvar_t *var)
|
||||
{
|
||||
if (!strcmp (var->string, "command")) {
|
||||
con_data.exec_line = cl_exec_line_command;
|
||||
} else if (!strcmp (var->string, "chat")) {
|
||||
con_data.exec_line = cl_exec_line_chat;
|
||||
} else if (!strcmp (var->string, "rcon")) {
|
||||
con_data.exec_line = cl_exec_line_rcon;
|
||||
} else {
|
||||
Sys_Printf ("mode must be one of \"command\", \"chat\" or \"rcon\"\n");
|
||||
Sys_Printf (" forcing \"command\"\n");
|
||||
Cvar_Set (var, "command");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
con_end_message (inputline_t *line)
|
||||
{
|
||||
|
@ -588,8 +639,8 @@ draw_console (view_t *view)
|
|||
if (con_state == con_fullscreen) {
|
||||
alpha = 255;
|
||||
} else {
|
||||
float y = r_data->vid->conview->ylen * con_size->value;
|
||||
alpha = 255 * con_alpha->value * view->ylen / y;
|
||||
float y = r_data->vid->conview->ylen * con_size;
|
||||
alpha = 255 * con_alpha * view->ylen / y;
|
||||
alpha = min (alpha, 255);
|
||||
}
|
||||
// draw the background
|
||||
|
@ -632,7 +683,7 @@ draw_notify (view_t *view)
|
|||
if (time == 0)
|
||||
continue;
|
||||
time = *con_data.realtime - time;
|
||||
if (time > con_notifytime->value)
|
||||
if (time > con_notifytime)
|
||||
continue;
|
||||
text = con->text + (i % con_totallines) * con_linewidth;
|
||||
|
||||
|
@ -655,7 +706,7 @@ setup_console (void)
|
|||
lines = 0;
|
||||
break;
|
||||
case con_active:
|
||||
lines = r_data->vid->conview->ylen * bound (0.2, con_size->value,
|
||||
lines = r_data->vid->conview->ylen * bound (0.2, con_size,
|
||||
1);
|
||||
break;
|
||||
case con_fullscreen:
|
||||
|
@ -663,12 +714,12 @@ setup_console (void)
|
|||
break;
|
||||
}
|
||||
|
||||
if (con_speed->value) {
|
||||
if (con_speed) {
|
||||
if (lines < con_data.lines) {
|
||||
con_data.lines -= max (0.2, con_speed->value) * *con_data.frametime;
|
||||
con_data.lines -= max (0.2, con_speed) * *con_data.frametime;
|
||||
con_data.lines = max (con_data.lines, lines);
|
||||
} else if (lines > con_data.lines) {
|
||||
con_data.lines += max (0.2, con_speed->value) * *con_data.frametime;
|
||||
con_data.lines += max (0.2, con_speed) * *con_data.frametime;
|
||||
con_data.lines = min (con_data.lines, lines);
|
||||
}
|
||||
} else {
|
||||
|
@ -843,19 +894,12 @@ C_Init (void)
|
|||
|
||||
Menu_Init ();
|
||||
|
||||
con_notifytime = Cvar_Get ("con_notifytime", "3", CVAR_NONE, NULL,
|
||||
"How long in seconds messages are displayed "
|
||||
"on screen");
|
||||
Cvar_Register (&con_notifytime_cvar, 0, 0);
|
||||
|
||||
con_alpha = Cvar_Get ("con_alpha", "0.6", CVAR_ARCHIVE, NULL,
|
||||
"alpha value for the console background");
|
||||
con_size = Cvar_Get ("con_size", "0.5", CVAR_ARCHIVE, NULL,
|
||||
"Fraction of the screen the console covers when "
|
||||
"down");
|
||||
con_speed = Cvar_Get ("con_speed", "300", CVAR_ARCHIVE, NULL,
|
||||
"How quickly the console scrolls up or down");
|
||||
cl_conmode = Cvar_Get ("cl_conmode", "command", CVAR_ARCHIVE, cl_conmode_f,
|
||||
"Set the console input mode (command, chat, rcon)");
|
||||
Cvar_Register (&con_alpha_cvar, 0, 0);
|
||||
Cvar_Register (&con_size_cvar, 0, 0);
|
||||
Cvar_Register (&con_speed_cvar, 0, 0);
|
||||
Cvar_Register (&cl_conmode_cvar, 0, 0);
|
||||
|
||||
con_debuglog = COM_CheckParm ("-condebug");
|
||||
|
||||
|
|
|
@ -56,23 +56,31 @@ static U inputline_t *(*const create)(int, int, char) = Con_CreateInputLine;
|
|||
static U void (*const display)(const char **, int) = Con_DisplayList;
|
||||
#undef U
|
||||
|
||||
static cvar_t *con_interpreter;
|
||||
static char *con_interpreter;
|
||||
static cvar_t con_interpreter_cvar = {
|
||||
.name = "con_interpreter",
|
||||
.description =
|
||||
"Interpreter for the interactive console",
|
||||
.default_value = "id",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = 0, .value = &con_interpreter },
|
||||
};
|
||||
static sys_printf_t saved_sys_printf;
|
||||
|
||||
static void
|
||||
Con_Interp_f (cvar_t *var)
|
||||
Con_Interp_f (void *data, const cvar_t *cvar)
|
||||
{
|
||||
cbuf_interpreter_t *interp;
|
||||
|
||||
if (!con_module)
|
||||
return;
|
||||
|
||||
interp = Cmd_GetProvider(var->string);
|
||||
interp = Cmd_GetProvider(con_interpreter);
|
||||
|
||||
if (interp) {
|
||||
cbuf_t *new;
|
||||
|
||||
Sys_Printf ("Switching to interpreter '%s'\n", var->string);
|
||||
Sys_Printf ("Switching to interpreter '%s'\n", con_interpreter);
|
||||
|
||||
new = Cbuf_New (interp);
|
||||
|
||||
|
@ -83,7 +91,7 @@ Con_Interp_f (cvar_t *var)
|
|||
}
|
||||
con_module->data->console->cbuf = new;
|
||||
} else {
|
||||
Sys_Printf ("Unknown interpreter '%s'\n", var->string);
|
||||
Sys_Printf ("Unknown interpreter '%s'\n", con_interpreter);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,9 +119,7 @@ Con_Init (const char *plugin_name)
|
|||
} else {
|
||||
setvbuf (stdout, 0, _IOLBF, BUFSIZ);
|
||||
}
|
||||
con_interpreter =
|
||||
Cvar_Get("con_interpreter", "id", CVAR_NONE, Con_Interp_f,
|
||||
"Interpreter for the interactive console");
|
||||
Cvar_Register (&con_interpreter_cvar, Con_Interp_f, 0);
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
|
|
|
@ -79,7 +79,15 @@ typedef struct menu_item_s {
|
|||
menu_pic_t *pics;
|
||||
} menu_item_t;
|
||||
|
||||
static cvar_t *confirm_quit;
|
||||
static int confirm_quit;
|
||||
static cvar_t confirm_quit_cvar = {
|
||||
.name = "confirm_quit",
|
||||
.description =
|
||||
"confirm quit command",
|
||||
.default_value = "1",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_int, .value = &confirm_quit },
|
||||
};
|
||||
|
||||
static progs_t menu_pr_state;
|
||||
static menu_item_t *menu;
|
||||
|
@ -482,7 +490,7 @@ quit_f (void)
|
|||
{
|
||||
int ret;
|
||||
|
||||
if (confirm_quit->int_val && menu_quit) {
|
||||
if (confirm_quit && menu_quit) {
|
||||
run_menu_pre ();
|
||||
PR_ExecuteProgram (&menu_pr_state, menu_quit);
|
||||
ret = R_INT (&menu_pr_state);
|
||||
|
@ -611,8 +619,7 @@ Menu_Init (void)
|
|||
R_Progs_Init (&menu_pr_state);
|
||||
S_Progs_Init (&menu_pr_state);
|
||||
|
||||
confirm_quit = Cvar_Get ("confirm_quit", "1", CVAR_ARCHIVE, NULL,
|
||||
"confirm quit command");
|
||||
Cvar_Register (&confirm_quit_cvar, 0, 0);
|
||||
|
||||
Cmd_AddCommand ("togglemenu", togglemenu_f,
|
||||
"Toggle the display of the menu");
|
||||
|
|
|
@ -82,8 +82,58 @@
|
|||
static console_data_t sv_con_data;
|
||||
|
||||
static QFile *log_file;
|
||||
static cvar_t *sv_logfile;
|
||||
static cvar_t *sv_conmode;
|
||||
static char *sv_logfile;
|
||||
static cvar_t sv_logfile_cvar = {
|
||||
.name = "sv_logfile",
|
||||
.description =
|
||||
"Control server console logging. \"none\" for off, or "
|
||||
"\"filename:gzflags\"",
|
||||
.default_value = "none",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = 0, .value = &sv_logfile },
|
||||
};
|
||||
static exprenum_t sv_conmode_enum;
|
||||
static exprtype_t sv_conmode_type = {
|
||||
.name = "sv_conmode",
|
||||
.size = sizeof (sv_con_data.exec_line),
|
||||
.data = &sv_conmode_enum,
|
||||
.get_string = cexpr_enum_get_string,
|
||||
};
|
||||
static int sv_exec_line_command (void *data, const char *line);
|
||||
static int sv_exec_line_chat (void *data, const char *line);
|
||||
static int (*sv_conmode_values[])(void *, const char *) = {
|
||||
sv_exec_line_command,
|
||||
sv_exec_line_chat,
|
||||
};
|
||||
static exprsym_t sv_conmode_symbols[] = {
|
||||
{"command", &sv_conmode_type, sv_conmode_values + 0},
|
||||
{"chat", &sv_conmode_type, sv_conmode_values + 1},
|
||||
{}
|
||||
};
|
||||
static exprtab_t sv_conmode_symtab = {
|
||||
sv_conmode_symbols,
|
||||
};
|
||||
static exprenum_t sv_conmode_enum = {
|
||||
&sv_conmode_type,
|
||||
&sv_conmode_symtab,
|
||||
};
|
||||
static cvar_t sv_conmode_cvar = {
|
||||
.name = "sv_conmode",
|
||||
.description =
|
||||
"Set the console input mode (command, chat)",
|
||||
.default_value = "command",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &sv_conmode_type, .value = &sv_con_data.exec_line },
|
||||
};
|
||||
static int sv_use_curses;
|
||||
static cvar_t sv_use_curses_cvar = {
|
||||
.name = "sv_use_curses",
|
||||
.description =
|
||||
"Set to 1 to enable curses server console.",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = &cexpr_int, .value = &sv_use_curses },
|
||||
};
|
||||
|
||||
#ifdef HAVE_NCURSES
|
||||
|
||||
|
@ -631,14 +681,14 @@ init (void)
|
|||
#endif
|
||||
|
||||
static void
|
||||
sv_logfile_f (cvar_t *var)
|
||||
sv_logfile_f (void *data, const cvar_t *cvar)
|
||||
{
|
||||
if (!var->string[0] || strequal (var->string, "none")) {
|
||||
if (!sv_logfile[0] || strequal (sv_logfile, "none")) {
|
||||
if (log_file)
|
||||
Qclose (log_file);
|
||||
log_file = 0;
|
||||
} else {
|
||||
char *fname = strdup (var->string);
|
||||
char *fname = strdup (sv_logfile);
|
||||
char *flags = strrchr (fname, ':');
|
||||
|
||||
if (flags) {
|
||||
|
@ -670,37 +720,19 @@ sv_exec_line_chat (void *data, const char *line)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
sv_conmode_f (cvar_t *var)
|
||||
{
|
||||
if (!strcmp (var->string, "command")) {
|
||||
sv_con_data.exec_line = sv_exec_line_command;
|
||||
} else if (!strcmp (var->string, "chat")) {
|
||||
sv_con_data.exec_line = sv_exec_line_chat;
|
||||
} else {
|
||||
Sys_Printf ("mode must be one of \"command\" or \"chat\"\n");
|
||||
Sys_Printf (" forcing \"command\"\n");
|
||||
Cvar_Set (var, "command");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
C_Init (void)
|
||||
{
|
||||
Cvar_Register (&sv_use_curses_cvar, 0, 0);
|
||||
#ifdef HAVE_NCURSES
|
||||
cvar_t *curses = Cvar_Get ("sv_use_curses", "0", CVAR_ROM, NULL,
|
||||
"Set to 1 to enable curses server console.");
|
||||
use_curses = curses->int_val;
|
||||
use_curses = sv_use_curses;
|
||||
if (use_curses) {
|
||||
init ();
|
||||
} else
|
||||
#endif
|
||||
setvbuf (stdout, 0, _IOLBF, BUFSIZ);
|
||||
sv_logfile = Cvar_Get ("sv_logfile", "none", CVAR_NONE, sv_logfile_f,
|
||||
"Control server console logging. \"none\" for off, "
|
||||
"or \"filename:gzflags\"");
|
||||
sv_conmode = Cvar_Get ("sv_conmode", "command", CVAR_NONE, sv_conmode_f,
|
||||
"Set the console input mode (command, chat)");
|
||||
Cvar_Register (&sv_logfile_cvar, sv_logfile_f, 0);
|
||||
Cvar_Register (&sv_conmode_cvar, 0, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -117,8 +117,24 @@ typedef struct {
|
|||
dstring_t *dstr;
|
||||
} pr_debug_data_t;
|
||||
|
||||
cvar_t *pr_debug;
|
||||
cvar_t *pr_source_path;
|
||||
int pr_debug;
|
||||
static cvar_t pr_debug_cvar = {
|
||||
.name = "pr_debug",
|
||||
.description =
|
||||
"enable progs debugging",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_int, .value = &pr_debug },
|
||||
};
|
||||
char *pr_source_path;
|
||||
static cvar_t pr_source_path_cvar = {
|
||||
.name = "pr_source_path",
|
||||
.description =
|
||||
"where to look (within gamedir) for source files",
|
||||
.default_value = ".",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = 0, .value = &pr_source_path },
|
||||
};
|
||||
static char *source_path_string;
|
||||
static char **source_paths;
|
||||
|
||||
|
@ -182,7 +198,7 @@ compunit_get_key (const void *cu, void *p)
|
|||
}
|
||||
|
||||
static void
|
||||
source_path_f (cvar_t *var)
|
||||
source_path_f (void *data, const cvar_t *cvar)
|
||||
{
|
||||
int i;
|
||||
char *s;
|
||||
|
@ -190,7 +206,7 @@ source_path_f (cvar_t *var)
|
|||
if (source_path_string) {
|
||||
free (source_path_string);
|
||||
}
|
||||
source_path_string = strdup (var->string);
|
||||
source_path_string = strdup (pr_source_path);
|
||||
if (source_paths) {
|
||||
free (source_paths);
|
||||
}
|
||||
|
@ -587,7 +603,7 @@ PR_LoadDebug (progs_t *pr)
|
|||
|
||||
res->debug = 0;
|
||||
|
||||
if (!pr_debug->int_val)
|
||||
if (!pr_debug)
|
||||
return 1;
|
||||
|
||||
def = PR_FindGlobal (pr, ".debug_file");
|
||||
|
@ -976,7 +992,7 @@ PR_DumpState (progs_t *pr)
|
|||
{
|
||||
prdeb_resources_t *res = pr->pr_debug_resources;
|
||||
if (pr->pr_xfunction) {
|
||||
if (pr_debug->int_val && res->debug) {
|
||||
if (pr_debug && res->debug) {
|
||||
pr_lineno_t *lineno;
|
||||
pr_auxfunction_t *func = 0;
|
||||
dfunction_t *descriptor = pr->pr_xfunction->descriptor;
|
||||
|
@ -1045,7 +1061,7 @@ pr_debug_find_def (progs_t *pr, pr_ptr_t *ofs)
|
|||
prdeb_resources_t *res = pr->pr_debug_resources;
|
||||
pr_def_t *def = 0;
|
||||
|
||||
if (pr_debug->int_val && res->debug) {
|
||||
if (pr_debug && res->debug) {
|
||||
def = PR_Get_Local_Def (pr, ofs);
|
||||
}
|
||||
if (*ofs >= pr->progs->globals.count) {
|
||||
|
@ -1486,10 +1502,10 @@ PR_PrintStatement (progs_t *pr, dstatement_t *s, int contents)
|
|||
data.pr = pr;
|
||||
data.dstr = res->dstr;
|
||||
|
||||
if (pr_debug->int_val > 1)
|
||||
if (pr_debug > 1)
|
||||
dump_code = 1;
|
||||
|
||||
if (pr_debug->int_val && res->debug) {
|
||||
if (pr_debug && res->debug) {
|
||||
const char *source_line = PR_Get_Source_Line (pr, addr);
|
||||
|
||||
if (source_line) {
|
||||
|
@ -1528,7 +1544,7 @@ PR_PrintStatement (progs_t *pr, dstatement_t *s, int contents)
|
|||
}
|
||||
|
||||
dasprintf (res->line, "%04x ", addr);
|
||||
if (pr_debug->int_val > 2) {
|
||||
if (pr_debug > 2) {
|
||||
if (pr->progs->version < PROG_VERSION) {
|
||||
dasprintf (res->line,
|
||||
"%03x %04x(%8s) %04x(%8s) %04x(%8s)\t",
|
||||
|
@ -1741,7 +1757,7 @@ dump_frame (progs_t *pr, prstack_t *frame)
|
|||
Sys_Printf ("<NO FUNCTION>\n");
|
||||
return;
|
||||
}
|
||||
if (pr_debug->int_val && res->debug) {
|
||||
if (pr_debug && res->debug) {
|
||||
pr_lineno_t *lineno = PR_Find_Lineno (pr, frame->staddr);
|
||||
pr_auxfunction_t *func = PR_Get_Lineno_Func (pr, lineno);
|
||||
pr_uint_t line = PR_Get_Lineno_Line (pr, lineno);
|
||||
|
@ -1932,9 +1948,6 @@ PR_Debug_Init (progs_t *pr)
|
|||
void
|
||||
PR_Debug_Init_Cvars (void)
|
||||
{
|
||||
pr_debug = Cvar_Get ("pr_debug", "0", CVAR_NONE, NULL,
|
||||
"enable progs debugging");
|
||||
pr_source_path = Cvar_Get ("pr_source_path", ".", CVAR_NONE, source_path_f,
|
||||
"where to look (within gamedir) for source "
|
||||
"files");
|
||||
Cvar_Register (&pr_debug_cvar, 0, 0);
|
||||
Cvar_Register (&pr_source_path_cvar, source_path_f, 0);
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ ED_Free (progs_t *pr, edict_t *ed)
|
|||
if (pr->unlink)
|
||||
pr->unlink (ed); // unlink from world bsp
|
||||
|
||||
if (pr_deadbeef_ents->int_val) {
|
||||
if (pr_deadbeef_ents) {
|
||||
ED_ClearEdict (pr, ed, 0xdeadbeef);
|
||||
} else {
|
||||
if (pr->free_edict)
|
||||
|
|
|
@ -284,7 +284,7 @@ PR_EnterFunction (progs_t *pr, bfunction_t *f)
|
|||
sizeof (pr_type_t) * f->locals);
|
||||
pr->localstack_used += f->locals;
|
||||
|
||||
if (pr_deadbeef_locals->int_val) {
|
||||
if (pr_deadbeef_locals) {
|
||||
for (pr_uint_t i = f->params_start;
|
||||
i < f->params_start + f->locals; i++) {
|
||||
pr->pr_globals[i].int_var = 0xdeadbeef;
|
||||
|
@ -357,7 +357,7 @@ PR_BoundsCheckSize (progs_t *pr, pr_ptr_t addr, unsigned size)
|
|||
|| size > (unsigned) (pr->globals_size - addr))
|
||||
PR_RunError (pr, "invalid memory access: %d (0 to %d-%d)", addr,
|
||||
pr->globals_size, size);
|
||||
if (pr_boundscheck->int_val >= 2
|
||||
if (pr_boundscheck >= 2
|
||||
&& PR_GetPointer (pr, addr + size) > (pr_type_t *) pr->zone) {
|
||||
void *mem = (void *) PR_GetPointer (pr, addr);
|
||||
Z_CheckPointer (pr->zone, mem, size * sizeof (pr_type_t));
|
||||
|
@ -385,7 +385,7 @@ signal_hook (int sig, void *data)
|
|||
{
|
||||
progs_t *pr = (progs_t *) data;
|
||||
|
||||
if (sig == SIGFPE && pr_faultchecks->int_val) {
|
||||
if (sig == SIGFPE && pr_faultchecks) {
|
||||
dstatement_t *st;
|
||||
pr_type_t *op_a, *op_b, *op_c;
|
||||
|
||||
|
@ -501,7 +501,7 @@ PR_SetupParams (progs_t *pr, int num_params, int min_alignment)
|
|||
}
|
||||
pr_ptr_t mask = ~(min_alignment - 1);
|
||||
pr_ptr_t stack = (*pr->globals.stack - offset) & mask;
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
check_stack_pointer (pr, stack, 0);
|
||||
}
|
||||
*pr->globals.stack = stack;
|
||||
|
@ -835,7 +835,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
case OP_STOREP_I_v6p:
|
||||
case OP_STOREP_P_v6p:
|
||||
pointer = OPB(ptr);
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -843,7 +843,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
break;
|
||||
case OP_STOREP_V_v6p:
|
||||
pointer = OPB(ptr);
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheck (pr, pointer, ev_vector);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -851,7 +851,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
break;
|
||||
case OP_STOREP_Q_v6p:
|
||||
pointer = OPB(ptr);
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheck (pr, pointer, ev_quaternion);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -859,7 +859,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
break;
|
||||
case OP_STOREP_D_v6p:
|
||||
pointer = OPB(ptr);
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheck (pr, pointer, ev_double);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -867,7 +867,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
break;
|
||||
|
||||
case OP_ADDRESS_v6p:
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
if (OPA(entity) >= pr->pr_edict_area_size)
|
||||
PR_RunError (pr, "Progs attempted to address an out "
|
||||
"of bounds edict");
|
||||
|
@ -901,7 +901,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
case OP_LOAD_FN_v6p:
|
||||
case OP_LOAD_I_v6p:
|
||||
case OP_LOAD_P_v6p:
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
if (OPA(entity) >= pr->pr_edict_area_size)
|
||||
PR_RunError (pr, "Progs attempted to read an out of "
|
||||
"bounds edict number");
|
||||
|
@ -913,7 +913,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
OPC(int) = pr->pr_edict_area[fldofs].int_var;
|
||||
break;
|
||||
case OP_LOAD_V_v6p:
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
if (OPA(entity) >= pr->pr_edict_area_size)
|
||||
PR_RunError (pr, "Progs attempted to read an out of "
|
||||
"bounds edict number");
|
||||
|
@ -925,7 +925,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
memcpy (op_c, &pr->pr_edict_area[fldofs], 3 * sizeof (*op_c));
|
||||
break;
|
||||
case OP_LOAD_Q_v6p:
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
if (OPA(entity) >= pr->pr_edict_area_size)
|
||||
PR_RunError (pr, "Progs attempted to read an out of "
|
||||
"bounds edict number");
|
||||
|
@ -937,7 +937,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
memcpy (op_c, &pr->pr_edict_area[fldofs], 4 * sizeof (*op_c));
|
||||
break;
|
||||
case OP_LOAD_D_v6p:
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
if (OPA(entity) >= pr->pr_edict_area_size)
|
||||
PR_RunError (pr, "Progs attempted to read an out of "
|
||||
"bounds edict number");
|
||||
|
@ -957,7 +957,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
case OP_LOADB_I_v6p:
|
||||
case OP_LOADB_P_v6p:
|
||||
pointer = OPA(entity) + OPB(field);
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -965,7 +965,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
break;
|
||||
case OP_LOADB_V_v6p:
|
||||
pointer = OPA(entity) + OPB(field);
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheck (pr, pointer, ev_vector);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -973,7 +973,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
break;
|
||||
case OP_LOADB_Q_v6p:
|
||||
pointer = OPA(entity) + OPB(field);
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheck (pr, pointer, ev_quaternion);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -981,7 +981,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
break;
|
||||
case OP_LOADB_D_v6p:
|
||||
pointer = OPA(entity) + OPB(field);
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheck (pr, pointer, ev_double);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -996,7 +996,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
case OP_LOADBI_I_v6p:
|
||||
case OP_LOADBI_P_v6p:
|
||||
pointer = OPA(ptr) + (short) st->b;
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -1004,7 +1004,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
break;
|
||||
case OP_LOADBI_V_v6p:
|
||||
pointer = OPA(ptr) + (short) st->b;
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheck (pr, pointer, ev_vector);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -1012,7 +1012,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
break;
|
||||
case OP_LOADBI_Q_v6p:
|
||||
pointer = OPA(ptr) + (short) st->b;
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheck (pr, pointer, ev_quaternion);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -1020,7 +1020,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
break;
|
||||
case OP_LOADBI_D_v6p:
|
||||
pointer = OPA(ptr) + (short) st->b;
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheck (pr, pointer, ev_quaternion);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -1045,7 +1045,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
case OP_STOREB_I_v6p:
|
||||
case OP_STOREB_P_v6p:
|
||||
pointer = OPB(ptr) + OPC(int);
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -1053,7 +1053,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
break;
|
||||
case OP_STOREB_V_v6p:
|
||||
pointer = OPB(ptr) + OPC(int);
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheck (pr, pointer, ev_vector);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -1061,7 +1061,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
break;
|
||||
case OP_STOREB_Q_v6p:
|
||||
pointer = OPB(ptr) + OPC(int);
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheck (pr, pointer, ev_quaternion);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -1069,7 +1069,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
break;
|
||||
case OP_STOREB_D_v6p:
|
||||
pointer = OPB(ptr) + OPC(int);
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheck (pr, pointer, ev_quaternion);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -1084,7 +1084,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
case OP_STOREBI_I_v6p:
|
||||
case OP_STOREBI_P_v6p:
|
||||
pointer = OPB(ptr) + (short) st->c;
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -1092,7 +1092,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
break;
|
||||
case OP_STOREBI_V_v6p:
|
||||
pointer = OPB(ptr) + (short) st->c;
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheck (pr, pointer, ev_vector);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -1100,7 +1100,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
break;
|
||||
case OP_STOREBI_Q_v6p:
|
||||
pointer = OPB(ptr) + (short) st->c;
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheck (pr, pointer, ev_quaternion);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -1108,7 +1108,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
break;
|
||||
case OP_STOREBI_D_v6p:
|
||||
pointer = OPB(ptr) + (short) st->c;
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheck (pr, pointer, ev_quaternion);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
@ -1125,7 +1125,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
{
|
||||
pr_ptr_t stack = *pr->globals.stack - 1;
|
||||
pr_type_t *stk = pr->pr_globals + stack;
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
check_stack_pointer (pr, stack, 1);
|
||||
}
|
||||
stk->int_var = OPA(int);
|
||||
|
@ -1136,7 +1136,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
{
|
||||
pr_ptr_t stack = *pr->globals.stack - 3;
|
||||
pr_type_t *stk = pr->pr_globals + stack;
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
check_stack_pointer (pr, stack, 3);
|
||||
}
|
||||
memcpy (stk, op_a, 3 * sizeof (*op_c));
|
||||
|
@ -1147,7 +1147,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
{
|
||||
pr_ptr_t stack = *pr->globals.stack - 4;
|
||||
pr_type_t *stk = pr->pr_globals + stack;
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
check_stack_pointer (pr, stack, 4);
|
||||
}
|
||||
memcpy (stk, op_a, 4 * sizeof (*op_c));
|
||||
|
@ -1169,7 +1169,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
pointer = OPA(ptr) + OPB(int);
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
check_stack_pointer (pr, stack, 1);
|
||||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
|
@ -1186,7 +1186,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
pointer = OPA(ptr) + OPB(int);
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
check_stack_pointer (pr, stack, 3);
|
||||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
|
@ -1203,7 +1203,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
pointer = OPA(ptr) + OPB(int);
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
check_stack_pointer (pr, stack, 4);
|
||||
PR_BoundsCheck (pr, pointer, ev_quaternion);
|
||||
}
|
||||
|
@ -1227,7 +1227,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
pointer = OPA(ptr) + st->b;
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
check_stack_pointer (pr, stack, 1);
|
||||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
|
@ -1244,7 +1244,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
pointer = OPA(ptr) + st->b;
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
check_stack_pointer (pr, stack, 3);
|
||||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
|
@ -1261,7 +1261,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
pointer = OPA(ptr) + st->b;
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
check_stack_pointer (pr, stack, 4);
|
||||
PR_BoundsCheck (pr, pointer, ev_quaternion);
|
||||
}
|
||||
|
@ -1281,7 +1281,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
{
|
||||
pr_ptr_t stack = *pr->globals.stack;
|
||||
pr_type_t *stk = pr->pr_globals + stack;
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
check_stack_pointer (pr, stack, 1);
|
||||
}
|
||||
OPA(int) = stk->int_var;
|
||||
|
@ -1292,7 +1292,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
{
|
||||
pr_ptr_t stack = *pr->globals.stack;
|
||||
pr_type_t *stk = pr->pr_globals + stack;
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
check_stack_pointer (pr, stack, 3);
|
||||
}
|
||||
memcpy (op_a, stk, 3 * sizeof (*op_c));
|
||||
|
@ -1303,7 +1303,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
{
|
||||
pr_ptr_t stack = *pr->globals.stack;
|
||||
pr_type_t *stk = pr->pr_globals + stack;
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
check_stack_pointer (pr, stack, 4);
|
||||
}
|
||||
memcpy (op_a, stk, 4 * sizeof (*op_c));
|
||||
|
@ -1325,7 +1325,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
pointer = OPA(ptr) + OPB(int);
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
check_stack_pointer (pr, stack, 1);
|
||||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
|
@ -1342,7 +1342,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
pointer = OPA(ptr) + OPB(int);
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
check_stack_pointer (pr, stack, 3);
|
||||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
|
@ -1359,7 +1359,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
pointer = OPA(ptr) + OPB(int);
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
check_stack_pointer (pr, stack, 4);
|
||||
PR_BoundsCheck (pr, pointer, ev_quaternion);
|
||||
}
|
||||
|
@ -1383,7 +1383,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
pointer = OPA(ptr) + st->b;
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
check_stack_pointer (pr, stack, 1);
|
||||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
|
@ -1400,7 +1400,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
pointer = OPA(ptr) + st->b;
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
check_stack_pointer (pr, stack, 3);
|
||||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
|
@ -1417,7 +1417,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
pointer = OPA(ptr) + st->b;
|
||||
ptr = pr->pr_globals + pointer;
|
||||
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
check_stack_pointer (pr, stack, 4);
|
||||
PR_BoundsCheck (pr, pointer, ev_quaternion);
|
||||
}
|
||||
|
@ -1469,7 +1469,7 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
st = pr->pr_statements + pr->pr_xstatement;
|
||||
break;
|
||||
case OP_JUMP_v6p:
|
||||
if (pr_boundscheck->int_val
|
||||
if (pr_boundscheck
|
||||
&& (OPA(uint) >= pr->progs->statements.count)) {
|
||||
PR_RunError (pr, "Invalid jump destination");
|
||||
}
|
||||
|
@ -1478,12 +1478,12 @@ pr_exec_quakec (progs_t *pr, int exitdepth)
|
|||
break;
|
||||
case OP_JUMPB_v6p:
|
||||
pointer = st->a + OPB(int);
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheck (pr, pointer, ev_int);
|
||||
}
|
||||
ptr = pr->pr_globals + pointer;
|
||||
pointer = ptr->int_var;
|
||||
if (pr_boundscheck->int_val
|
||||
if (pr_boundscheck
|
||||
&& (pointer >= pr->progs->statements.count)) {
|
||||
PR_RunError (pr, "Invalid jump destination");
|
||||
}
|
||||
|
@ -1701,7 +1701,7 @@ op_call:
|
|||
memmove (op_c, op_a, st->b * 4);
|
||||
break;
|
||||
case OP_MOVEP_v6p:
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheckSize (pr, OPC(ptr), OPB(uint));
|
||||
PR_BoundsCheckSize (pr, OPA(ptr), OPB(uint));
|
||||
}
|
||||
|
@ -1710,7 +1710,7 @@ op_call:
|
|||
OPB(uint) * 4);
|
||||
break;
|
||||
case OP_MOVEPI_v6p:
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheckSize (pr, OPC(ptr), st->b);
|
||||
PR_BoundsCheckSize (pr, OPA(ptr), st->b);
|
||||
}
|
||||
|
@ -1722,14 +1722,14 @@ op_call:
|
|||
pr_memset (op_c, OPA(ptr), st->b);
|
||||
break;
|
||||
case OP_MEMSETP_v6p:
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheckSize (pr, OPC(ptr), OPB(uint));
|
||||
}
|
||||
pr_memset (pr->pr_globals + OPC(ptr), OPA(int),
|
||||
OPB(uint));
|
||||
break;
|
||||
case OP_MEMSETPI_v6p:
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheckSize (pr, OPC(ptr), st->b);
|
||||
}
|
||||
pr_memset (pr->pr_globals + OPC(ptr), OPA(int),
|
||||
|
@ -1888,7 +1888,7 @@ pr_jump_mode (progs_t *pr, const dstatement_t *st, int jump_ind)
|
|||
jump_offs = OPA(ptr) + OPB(int);
|
||||
break;
|
||||
}
|
||||
if (pr_boundscheck->int_val && jump_offs >= pr->progs->statements.count) {
|
||||
if (pr_boundscheck && jump_offs >= pr->progs->statements.count) {
|
||||
PR_RunError (pr, "out of bounds: %x", jump_offs);
|
||||
}
|
||||
return jump_offs - 1; // for st++
|
||||
|
@ -1900,7 +1900,7 @@ pr_stack_push (progs_t *pr)
|
|||
// keep the stack 16-byte aligned
|
||||
pr_ptr_t stack = *pr->globals.stack - 4;
|
||||
pr_type_t *stk = pr->pr_globals + stack;
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
check_stack_pointer (pr, stack, 4);
|
||||
}
|
||||
*pr->globals.stack = stack;
|
||||
|
@ -1912,7 +1912,7 @@ pr_stack_pop (progs_t *pr)
|
|||
{
|
||||
pr_ptr_t stack = *pr->globals.stack;
|
||||
pr_type_t *stk = pr->pr_globals + stack;
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
check_stack_pointer (pr, stack, 4);
|
||||
}
|
||||
// keep the stack 16-byte aligned
|
||||
|
@ -1929,7 +1929,7 @@ pr_stack_adjust (progs_t *pr, int mode, int offset)
|
|||
}
|
||||
|
||||
pr_ptr_t stack = *pr->globals.stack;
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
check_stack_pointer (pr, stack + offset, 0);
|
||||
}
|
||||
*pr->globals.stack = stack + offset;
|
||||
|
|
|
@ -50,10 +50,42 @@
|
|||
|
||||
#include "compat.h"
|
||||
|
||||
VISIBLE cvar_t *pr_boundscheck;
|
||||
cvar_t *pr_deadbeef_ents;
|
||||
cvar_t *pr_deadbeef_locals;
|
||||
cvar_t *pr_faultchecks;
|
||||
VISIBLE int pr_boundscheck;
|
||||
static cvar_t pr_boundscheck_cvar = {
|
||||
.name = "pr_boundscheck",
|
||||
.description =
|
||||
"Server progs bounds checking",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_int, .value = &pr_boundscheck },
|
||||
};
|
||||
int pr_deadbeef_ents;
|
||||
static cvar_t pr_deadbeef_ents_cvar = {
|
||||
.name = "pr_deadbeef_ents",
|
||||
.description =
|
||||
"set to clear unallocated memory to 0xdeadbeef",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_int, .value = &pr_deadbeef_ents },
|
||||
};
|
||||
int pr_deadbeef_locals;
|
||||
static cvar_t pr_deadbeef_locals_cvar = {
|
||||
.name = "pr_deadbeef_locals",
|
||||
.description =
|
||||
"set to clear uninitialized local vars to 0xdeadbeef",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_int, .value = &pr_deadbeef_locals },
|
||||
};
|
||||
int pr_faultchecks;
|
||||
static cvar_t pr_faultchecks_cvar = {
|
||||
.name = "pr_faultchecks",
|
||||
.description =
|
||||
"capture and handle division by 0 in progs",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_int, .value = &pr_faultchecks },
|
||||
};
|
||||
|
||||
static const char *
|
||||
function_get_key (const void *f, void *_pr)
|
||||
|
@ -498,16 +530,10 @@ PR_LoadProgs (progs_t *pr, const char *progsname)
|
|||
VISIBLE void
|
||||
PR_Init_Cvars (void)
|
||||
{
|
||||
pr_boundscheck =
|
||||
Cvar_Get ("pr_boundscheck", "0", CVAR_NONE, NULL,
|
||||
"Server progs bounds checking");
|
||||
pr_deadbeef_ents = Cvar_Get ("pr_deadbeef_ents", "0", CVAR_NONE, NULL,
|
||||
"set to clear unallocated memory to 0xdeadbeef");
|
||||
pr_deadbeef_locals = Cvar_Get ("pr_deadbeef_locals", "0", CVAR_NONE, NULL,
|
||||
"set to clear uninitialized local vars to "
|
||||
"0xdeadbeef");
|
||||
pr_faultchecks = Cvar_Get ("pr_faultchecks", "0", CVAR_NONE, NULL,
|
||||
"capture and handle division by 0 in progs");
|
||||
Cvar_Register (&pr_boundscheck_cvar, 0, 0);
|
||||
Cvar_Register (&pr_deadbeef_ents_cvar, 0, 0);
|
||||
Cvar_Register (&pr_deadbeef_locals_cvar, 0, 0);
|
||||
Cvar_Register (&pr_faultchecks_cvar, 0, 0);
|
||||
PR_Debug_Init_Cvars ();
|
||||
}
|
||||
|
||||
|
|
|
@ -1562,7 +1562,7 @@ check_global (progs_t *pr, dstatement_t *st, const v6p_opcode_t *op, etype_t typ
|
|||
}
|
||||
if (!pr->denorm_found) {
|
||||
pr->denorm_found = 1;
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
Sys_Printf ("DENORMAL floats detected, these progs might "
|
||||
"not work. Good luck.\n");
|
||||
return;
|
||||
|
@ -1619,7 +1619,7 @@ PR_Check_v6p_Opcodes (progs_t *pr)
|
|||
//FIXME need to decide if I really want to always do static bounds checking
|
||||
// the only problem is that it slows progs load a little, but it's the only
|
||||
// way to check for qccx' evil
|
||||
if (0 && !pr_boundscheck->int_val) {
|
||||
if (0 && !pr_boundscheck) {
|
||||
for (i = 0, st = pr->pr_statements; i < pr->progs->statements.count;
|
||||
st++, i++) {
|
||||
pr_opcode_v6p_e st_op = (pr_opcode_v6p_e) st->op;
|
||||
|
|
|
@ -201,7 +201,7 @@ main (int argc, char **argv)
|
|||
Cmd_Init ();
|
||||
Cvar_Init ();
|
||||
PR_Init_Cvars ();
|
||||
pr_boundscheck->int_val = 1;
|
||||
pr_boundscheck = 1;
|
||||
|
||||
while ((c = getopt (argc, argv, "qvt:")) != EOF) {
|
||||
switch (c) {
|
||||
|
|
|
@ -76,8 +76,8 @@ GIB_Exec_Override_f (void)
|
|||
return;
|
||||
}
|
||||
if (!Cvar_Command ()
|
||||
&& (cmd_warncmd->int_val
|
||||
|| (developer && developer->int_val & SYS_dev)))
|
||||
&& (cmd_warncmd
|
||||
|| (developer && developer & SYS_dev)))
|
||||
Sys_Printf ("execing %s\n", Cmd_Argv (1));
|
||||
if ((strlen (Cmd_Argv (1)) >= 4
|
||||
&& !strcmp (Cmd_Argv (1) + strlen (Cmd_Argv (1)) - 4, ".gib"))
|
||||
|
|
|
@ -114,7 +114,8 @@ GIB_Process_Embedded (gib_tree_t * node, cbuf_args_t * args)
|
|||
} else if (cur->delim == '#')
|
||||
dstring_appendstr (args->argv[args->argc - 1], "0");
|
||||
else if (cvar)
|
||||
dstring_appendstr (args->argv[args->argc - 1], cvar->string);
|
||||
dstring_appendstr (args->argv[args->argc - 1],
|
||||
Cvar_VarString (cvar));
|
||||
} else if ((var = GIB_Var_Get_Complex (&GIB_DATA (cbuf_active)->locals,
|
||||
&GIB_DATA (cbuf_active)->globals,
|
||||
(char *) cur->str, &index, false))) {
|
||||
|
@ -126,7 +127,8 @@ GIB_Process_Embedded (gib_tree_t * node, cbuf_args_t * args)
|
|||
} else if (cur->delim == '#')
|
||||
dstring_appendstr (args->argv[args->argc - 1], "0");
|
||||
else if ((cvar = Cvar_FindVar (cur->str)))
|
||||
dstring_appendstr (args->argv[args->argc - 1], cvar->string);
|
||||
dstring_appendstr (args->argv[args->argc - 1],
|
||||
Cvar_VarString (cvar));
|
||||
}
|
||||
if (str[prev])
|
||||
dstring_appendstr (args->argv[args->argc - 1], str + prev);
|
||||
|
|
|
@ -222,9 +222,11 @@ GIB_Var_Get_Very_Complex (hashtab_t ** first, hashtab_t ** second, dstring_t *ke
|
|||
dstring_replace (key, n, i-n+varstartskip, "0", 1);
|
||||
protect = n+1;
|
||||
} else if ((cvar = Cvar_FindVar (key->str+n+1+varstartskip))) {
|
||||
const char *cvar_str = Cvar_VarString (cvar);
|
||||
key->str[i] = c;
|
||||
dstring_replace (key, n, i-n+varstartskip, cvar->string, strlen (cvar->string));
|
||||
protect = n+strlen(cvar->string);
|
||||
dstring_replace (key, n, i-n+varstartskip, cvar_str,
|
||||
strlen (cvar_str));
|
||||
protect = n+strlen(cvar_str);
|
||||
} else {
|
||||
key->str[i] = c;
|
||||
dstring_snip (key, n, n-i+varstartskip);
|
||||
|
|
|
@ -70,14 +70,79 @@ typedef struct {
|
|||
static struct DARRAY_TYPE (in_regdriver_t) in_drivers = { .grow = 8 };
|
||||
static struct DARRAY_TYPE (in_device_t) in_devices = { .grow = 8 };
|
||||
|
||||
cvar_t *in_grab;
|
||||
VISIBLE cvar_t *in_amp;
|
||||
VISIBLE cvar_t *in_pre_amp;
|
||||
cvar_t *in_freelook;
|
||||
cvar_t *in_mouse_filter;
|
||||
cvar_t *in_mouse_amp;
|
||||
cvar_t *in_mouse_pre_amp;
|
||||
cvar_t *lookstrafe;
|
||||
int in_grab;
|
||||
static cvar_t in_grab_cvar = {
|
||||
.name = "in_grab",
|
||||
.description =
|
||||
"With this set to 1, quake will grab the mouse, preventing loss of "
|
||||
"input focus.",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_int, .value = &in_grab },
|
||||
};
|
||||
VISIBLE float in_amp;
|
||||
static cvar_t in_amp_cvar = {
|
||||
.name = "in_amp",
|
||||
.description =
|
||||
"global in_amp multiplier",
|
||||
.default_value = "1",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_float, .value = &in_amp },
|
||||
};
|
||||
VISIBLE float in_pre_amp;
|
||||
static cvar_t in_pre_amp_cvar = {
|
||||
.name = "in_pre_amp",
|
||||
.description =
|
||||
"global in_pre_amp multiplier",
|
||||
.default_value = "1",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_float, .value = &in_pre_amp },
|
||||
};
|
||||
int in_freelook;
|
||||
static cvar_t in_freelook_cvar = {
|
||||
.name = "freelook",
|
||||
.description =
|
||||
"force +mlook",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_int, .value = &in_freelook },
|
||||
};
|
||||
int in_mouse_filter;
|
||||
static cvar_t in_mouse_filter_cvar = {
|
||||
.name = "in_mouse_filter",
|
||||
.description =
|
||||
"Toggle mouse input filtering.",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_int, .value = &in_mouse_filter },
|
||||
};
|
||||
float in_mouse_amp;
|
||||
static cvar_t in_mouse_amp_cvar = {
|
||||
.name = "in_mouse_amp",
|
||||
.description =
|
||||
"mouse in_mouse_amp multiplier",
|
||||
.default_value = "15",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_float, .value = &in_mouse_amp },
|
||||
};
|
||||
float in_mouse_pre_amp;
|
||||
static cvar_t in_mouse_pre_amp_cvar = {
|
||||
.name = "in_mouse_pre_amp",
|
||||
.description =
|
||||
"mouse in_mouse_pre_amp multiplier",
|
||||
.default_value = "1",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_float, .value = &in_mouse_pre_amp },
|
||||
};
|
||||
int lookstrafe;
|
||||
static cvar_t lookstrafe_cvar = {
|
||||
.name = "lookstrafe",
|
||||
.description =
|
||||
"when mlook/klook on player will strafe",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_int, .value = &lookstrafe },
|
||||
};
|
||||
|
||||
int64_t in_timeout = 10000;//10ms default timeout
|
||||
|
||||
|
@ -395,18 +460,22 @@ IN_GetButtonInfo (int devid, int button_num, in_buttoninfo_t *info)
|
|||
}
|
||||
|
||||
void
|
||||
IN_UpdateGrab (cvar_t *var) // called from context_*.c
|
||||
IN_UpdateGrab (int grab)
|
||||
{
|
||||
if (var) {
|
||||
for (size_t i = 0; i < in_drivers.size; i++) {
|
||||
in_regdriver_t *rd = &in_drivers.a[i];
|
||||
if (rd->driver.grab_input) {
|
||||
rd->driver.grab_input (rd->data, var->int_val);
|
||||
}
|
||||
for (size_t i = 0; i < in_drivers.size; i++) {
|
||||
in_regdriver_t *rd = &in_drivers.a[i];
|
||||
if (rd->driver.grab_input) {
|
||||
rd->driver.grab_input (rd->data, grab);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
in_grab_f (void *data, const cvar_t *cvar)
|
||||
{
|
||||
IN_UpdateGrab (in_grab);
|
||||
}
|
||||
|
||||
void
|
||||
IN_ProcessEvents (void)
|
||||
{
|
||||
|
@ -488,23 +557,14 @@ IN_Init (void)
|
|||
void
|
||||
IN_Init_Cvars (void)
|
||||
{
|
||||
in_grab = Cvar_Get ("in_grab", "0", CVAR_ARCHIVE, IN_UpdateGrab,
|
||||
"With this set to 1, quake will grab the mouse, "
|
||||
"preventing loss of input focus.");
|
||||
in_amp = Cvar_Get ("in_amp", "1", CVAR_ARCHIVE, NULL,
|
||||
"global in_amp multiplier");
|
||||
in_pre_amp = Cvar_Get ("in_pre_amp", "1", CVAR_ARCHIVE, NULL,
|
||||
"global in_pre_amp multiplier");
|
||||
in_freelook = Cvar_Get ("freelook", "0", CVAR_ARCHIVE, NULL,
|
||||
"force +mlook");
|
||||
in_mouse_filter = Cvar_Get ("in_mouse_filter", "0", CVAR_ARCHIVE, NULL,
|
||||
"Toggle mouse input filtering.");
|
||||
in_mouse_amp = Cvar_Get ("in_mouse_amp", "15", CVAR_ARCHIVE, NULL,
|
||||
"mouse in_mouse_amp multiplier");
|
||||
in_mouse_pre_amp = Cvar_Get ("in_mouse_pre_amp", "1", CVAR_ARCHIVE, NULL,
|
||||
"mouse in_mouse_pre_amp multiplier");
|
||||
lookstrafe = Cvar_Get ("lookstrafe", "0", CVAR_ARCHIVE, NULL,
|
||||
"when mlook/klook on player will strafe");
|
||||
Cvar_Register (&in_grab_cvar, in_grab_f, 0);
|
||||
Cvar_Register (&in_amp_cvar, 0, 0);
|
||||
Cvar_Register (&in_pre_amp_cvar, 0, 0);
|
||||
Cvar_Register (&in_freelook_cvar, 0, 0);
|
||||
Cvar_Register (&in_mouse_filter_cvar, 0, 0);
|
||||
Cvar_Register (&in_mouse_amp_cvar, 0, 0);
|
||||
Cvar_Register (&in_mouse_pre_amp_cvar, 0, 0);
|
||||
Cvar_Register (&lookstrafe_cvar, 0, 0);
|
||||
for (size_t i = 0; i < in_drivers.size; i++) {
|
||||
in_regdriver_t *rd = &in_drivers.a[i];
|
||||
if (rd->driver.init_cvars) {
|
||||
|
|
|
@ -267,7 +267,8 @@ imt_switcher_update (imt_switcher_t *switcher)
|
|||
val = !!(input->button->state & inb_down);
|
||||
break;
|
||||
case imti_cvar:
|
||||
val = !!input->cvar->int_val;
|
||||
//FIXME check cvar type
|
||||
val = !!*(int *) input->cvar->value.value;
|
||||
break;
|
||||
}
|
||||
state |= val << i;
|
||||
|
@ -497,6 +498,7 @@ IMT_CreateSwitcher (const char *switcher_name, int context, imt_t *default_imt,
|
|||
switcher);
|
||||
} else {
|
||||
input->type = imti_cvar;
|
||||
//FIXME check cvar type
|
||||
input->cvar = Cvar_FindVar (input_name);
|
||||
Cvar_AddListener (input->cvar, imt_switcher_cvar_update, switcher);
|
||||
}
|
||||
|
|
|
@ -350,10 +350,9 @@ gl_Mod_MakeAliasModelDisplayLists (mod_alias_ctx_t *alias_ctx, void *_m,
|
|||
cache = dstring_new ();
|
||||
fullpath = dstring_new ();
|
||||
|
||||
if (!gl_alias_render_tri->int_val) {
|
||||
if (!gl_alias_render_tri) {
|
||||
|
||||
if (gl_mesh_cache->int_val
|
||||
&& gl_mesh_cache->int_val <= header->mdl.numtris) {
|
||||
if (gl_mesh_cache && gl_mesh_cache <= header->mdl.numtris) {
|
||||
do_cache = true;
|
||||
|
||||
mdfour (model_digest, (unsigned char *) _m, _s);
|
||||
|
|
|
@ -125,7 +125,7 @@ gl_Mod_ProcessTexture (model_t *mod, texture_t *tx)
|
|||
r_notexture_mip->render = &gl_notexture;
|
||||
return;
|
||||
}
|
||||
if (gl_textures_external && gl_textures_external->int_val) {
|
||||
if (gl_textures_external) {
|
||||
if (Mod_LoadExternalTextures (mod, tx)) {
|
||||
return;
|
||||
}
|
||||
|
@ -239,8 +239,7 @@ SubdividePolygon (int numverts, float *verts)
|
|||
|
||||
for (i = 0; i < 3; i++) {
|
||||
m = (mins[i] + maxs[i]) * 0.5;
|
||||
m = gl_subdivide_size->value * floor (m / gl_subdivide_size->value +
|
||||
0.5);
|
||||
m = gl_subdivide_size * floor (m / gl_subdivide_size + 0.5);
|
||||
if (maxs[i] - m < 8)
|
||||
continue;
|
||||
if (m - mins[i] < 8)
|
||||
|
|
|
@ -56,8 +56,8 @@
|
|||
#include "compat.h"
|
||||
#include "mod_internal.h"
|
||||
|
||||
VISIBLE cvar_t *gl_sky_divide; //FIXME visibility?
|
||||
VISIBLE int mod_lightmap_bytes = 1; //FIXME should this be visible?
|
||||
VISIBLE int mod_sky_divide; //FIXME visibility?
|
||||
VISIBLE int mod_lightmap_bytes = 1; //FIXME should this be visible?
|
||||
|
||||
VISIBLE mleaf_t *
|
||||
Mod_PointInLeaf (const vec3_t p, model_t *model)
|
||||
|
@ -640,9 +640,11 @@ Mod_LoadFaces (model_t *mod, bsp_t *bsp)
|
|||
|
||||
if (!strncmp (out->texinfo->texture->name, "sky", 3)) { // sky
|
||||
out->flags |= (SURF_DRAWSKY | SURF_DRAWTILED);
|
||||
if (gl_sky_divide && gl_sky_divide->int_val)
|
||||
if (mod_funcs && mod_funcs->Mod_SubdivideSurface)
|
||||
if (mod_sky_divide) {
|
||||
if (mod_funcs && mod_funcs->Mod_SubdivideSurface) {
|
||||
mod_funcs->Mod_SubdivideSurface (mod, out);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -174,12 +174,12 @@ build_skin (skin_t *skin, int cmap)
|
|||
int texnum, fb_texnum;
|
||||
|
||||
// FIXME deek: This 512x256 limit sucks!
|
||||
scaled_width = min (gl_max_size->int_val, 512);
|
||||
scaled_height = min (gl_max_size->int_val, 256);
|
||||
scaled_width = min (gl_max_size, 512);
|
||||
scaled_height = min (gl_max_size, 256);
|
||||
|
||||
// allow users to crunch sizes down even more if they want
|
||||
scaled_width >>= gl_playermip->int_val;
|
||||
scaled_height >>= gl_playermip->int_val;
|
||||
scaled_width >>= gl_playermip;
|
||||
scaled_height >>= gl_playermip;
|
||||
scaled_width = max (scaled_width, 1);
|
||||
scaled_height = max (scaled_height, 1);
|
||||
|
||||
|
|
|
@ -59,10 +59,43 @@ static size_t mod_numknown;
|
|||
|
||||
VISIBLE texture_t *r_notexture_mip;
|
||||
|
||||
cvar_t *gl_mesh_cache;
|
||||
cvar_t *gl_subdivide_size;
|
||||
cvar_t *gl_alias_render_tri;
|
||||
cvar_t *gl_textures_external;
|
||||
int gl_mesh_cache;
|
||||
static cvar_t gl_mesh_cache_cvar = {
|
||||
.name = "gl_mesh_cache",
|
||||
.description =
|
||||
"minimum triangle count in a model for its mesh to be cached. 0 to "
|
||||
"disable caching",
|
||||
.default_value = "256",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_int, .value = &gl_mesh_cache },
|
||||
};
|
||||
float gl_subdivide_size;
|
||||
static cvar_t gl_subdivide_size_cvar = {
|
||||
.name = "gl_subdivide_size",
|
||||
.description =
|
||||
"Sets the division value for the sky brushes.",
|
||||
.default_value = "128",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_float, .value = &gl_subdivide_size },
|
||||
};
|
||||
int gl_alias_render_tri;
|
||||
static cvar_t gl_alias_render_tri_cvar = {
|
||||
.name = "gl_alias_render_tri",
|
||||
.description =
|
||||
"When loading alias models mesh for pure triangle rendering",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_int, .value = &gl_alias_render_tri },
|
||||
};
|
||||
int gl_textures_external;
|
||||
static cvar_t gl_textures_external_cvar = {
|
||||
.name = "gl_textures_external",
|
||||
.description =
|
||||
"Use external textures to replace BSP textures",
|
||||
.default_value = "1",
|
||||
.flags = CVAR_ARCHIVE,
|
||||
.value = { .type = &cexpr_int, .value = &gl_textures_external },
|
||||
};
|
||||
|
||||
static void Mod_CallbackLoad (void *object, cache_allocator_t allocator);
|
||||
|
||||
|
@ -99,18 +132,10 @@ Mod_Init (void)
|
|||
VISIBLE void
|
||||
Mod_Init_Cvars (void)
|
||||
{
|
||||
gl_subdivide_size =
|
||||
Cvar_Get ("gl_subdivide_size", "128", CVAR_ARCHIVE, NULL,
|
||||
"Sets the division value for the sky brushes.");
|
||||
gl_mesh_cache = Cvar_Get ("gl_mesh_cache", "256", CVAR_ARCHIVE, NULL,
|
||||
"minimum triangle count in a model for its mesh"
|
||||
" to be cached. 0 to disable caching");
|
||||
gl_alias_render_tri =
|
||||
Cvar_Get ("gl_alias_render_tri", "0", CVAR_ARCHIVE, NULL, "When "
|
||||
"loading alias models mesh for pure triangle rendering");
|
||||
gl_textures_external =
|
||||
Cvar_Get ("gl_textures_external", "1", CVAR_ARCHIVE, NULL,
|
||||
"Use external textures to replace BSP textures");
|
||||
Cvar_Register (&gl_subdivide_size_cvar, 0, 0);
|
||||
Cvar_Register (&gl_mesh_cache_cvar, 0, 0);
|
||||
Cvar_Register (&gl_alias_render_tri_cvar, 0, 0);
|
||||
Cvar_Register (&gl_textures_external_cvar, 0, 0);
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
|
|
|
@ -114,7 +114,15 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
static cvar_t *net_family;
|
||||
static char *net_family;
|
||||
static cvar_t net_family_cvar = {
|
||||
.name = "net_family",
|
||||
.description =
|
||||
"Set the address family to ipv4, ipv6 or unspecified",
|
||||
.default_value = "unspecified",
|
||||
.flags = CVAR_ROM,
|
||||
.value = { .type = 0, .value = &net_family },
|
||||
};
|
||||
|
||||
netadr_t net_from;
|
||||
netadr_t net_local_adr;
|
||||
|
@ -330,9 +338,9 @@ NET_StringToAdr (const char *s, netadr_t *a)
|
|||
|
||||
memset (&hints, 0, sizeof (hints));
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
if (strchr (net_family->string, '6')) {
|
||||
if (strchr (net_family, '6')) {
|
||||
hints.ai_family = AF_INET6;
|
||||
} else if (strchr (net_family->string, '4')) {
|
||||
} else if (strchr (net_family, '4')) {
|
||||
hints.ai_family = AF_INET;
|
||||
} else {
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
|
@ -492,9 +500,9 @@ UDP_OpenSocket (int port)
|
|||
address.sin6_family = AF_INET6;
|
||||
|
||||
memset (&hints, 0, sizeof (hints));
|
||||
if (strchr (net_family->string, '6')) {
|
||||
if (strchr (net_family, '6')) {
|
||||
hints.ai_family = AF_INET6;
|
||||
} else if (strchr (net_family->string, '4')) {
|
||||
} else if (strchr (net_family, '4')) {
|
||||
hints.ai_family = AF_INET;
|
||||
} else {
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
|
@ -581,9 +589,7 @@ NET_Init (int port)
|
|||
if (r)
|
||||
Sys_Error ("Winsock initialization failed.");
|
||||
#endif /* _WIN32 */
|
||||
net_family = Cvar_Get ("net_family", "unspecified", CVAR_ROM, 0,
|
||||
"Set the address family to ipv4, ipv6 or"
|
||||
" unspecified");
|
||||
Cvar_Register (&net_family_cvar, 0, 0);
|
||||
|
||||
// open the single socket to be used for all communications
|
||||
net_socket = UDP_OpenSocket (port);
|
||||
|
|
|
@ -54,9 +54,35 @@
|
|||
int net_nochoke;
|
||||
int net_blocksend;
|
||||
double *net_realtime;
|
||||
cvar_t *showpackets;
|
||||
cvar_t *showdrop;
|
||||
cvar_t *qport;
|
||||
int showpackets;
|
||||
static cvar_t showpackets_cvar = {
|
||||
.name = "showpackets",
|
||||
.description =
|
||||
"Show all network packets",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_int, .value = &showpackets },
|
||||
};
|
||||
int showdrop;
|
||||
static cvar_t showdrop_cvar = {
|
||||
.name = "showdrop",
|
||||
.description =
|
||||
"Toggle the display of how many packets you are dropping",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_int, .value = &showdrop },
|
||||
};
|
||||
int qport;
|
||||
static cvar_t qport_cvar = {
|
||||
.name = "qport",
|
||||
.description =
|
||||
"The internal port number for the game networking code. Useful for "
|
||||
"clients who use multiple connections through one IP address (NAT/IP-"
|
||||
"MASQ) because default port is random.",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_int, .value = &qport },
|
||||
};
|
||||
void (*net_log_packet) (int length, const void *data, netadr_t to);
|
||||
|
||||
|
||||
|
@ -68,21 +94,15 @@ Netchan_Init (void)
|
|||
// pick a port value that should be nice and random
|
||||
port = Sys_TimeID ();
|
||||
|
||||
Cvar_SetValue (qport, port);
|
||||
qport = port;
|
||||
}
|
||||
|
||||
void
|
||||
Netchan_Init_Cvars (void)
|
||||
{
|
||||
showpackets = Cvar_Get ("showpackets", "0", CVAR_NONE, NULL,
|
||||
"Show all network packets");
|
||||
showdrop = Cvar_Get ("showdrop", "0", CVAR_NONE, NULL, "Toggle the "
|
||||
"display of how many packets you are dropping");
|
||||
qport = Cvar_Get ("qport", "0", CVAR_NONE, NULL, "The internal port "
|
||||
"number for the game networking code. Useful for "
|
||||
"clients who use multiple connections through one "
|
||||
"IP address (NAT/IP-MASQ) because default port is "
|
||||
"random.");
|
||||
Cvar_Register (&showpackets_cvar, 0, 0);
|
||||
Cvar_Register (&showdrop_cvar, 0, 0);
|
||||
Cvar_Register (&qport_cvar, 0, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -256,13 +276,13 @@ Netchan_Transmit (netchan_t *chan, unsigned length, byte *data)
|
|||
if (net_nochoke)
|
||||
chan->cleartime = *net_realtime;
|
||||
|
||||
if (showpackets->int_val & 1) {
|
||||
if (showpackets & 1) {
|
||||
Sys_Printf ("--> s=%i(%i) a=%i(%i) %-4i %i\n",
|
||||
chan->outgoing_sequence, send_reliable,
|
||||
chan->incoming_sequence, chan->incoming_reliable_sequence,
|
||||
send.cursize,
|
||||
chan->outgoing_sequence - chan->incoming_sequence);
|
||||
if (showpackets->int_val & 4) {
|
||||
if (showpackets & 4) {
|
||||
SZ_Dump (&send);
|
||||
}
|
||||
}
|
||||
|
@ -292,10 +312,10 @@ Netchan_Process (netchan_t *chan)
|
|||
sequence &= ~(1 << 31);
|
||||
sequence_ack &= ~(1 << 31);
|
||||
|
||||
if (showpackets->int_val & 2) {
|
||||
if (showpackets & 2) {
|
||||
Sys_Printf ("<-- s=%i(%i) a=%i(%i) %i\n", sequence, reliable_message,
|
||||
sequence_ack, reliable_ack, net_message->message->cursize);
|
||||
if (showpackets->int_val & 8) {
|
||||
if (showpackets & 8) {
|
||||
SZ_Dump (net_message->message);
|
||||
}
|
||||
}
|
||||
|
@ -329,7 +349,7 @@ Netchan_Process (netchan_t *chan)
|
|||
|
||||
/// Discard stale or duplicated packets.
|
||||
if (sequence < (unsigned int) chan->incoming_sequence + 1) {
|
||||
if (showdrop->int_val)
|
||||
if (showdrop)
|
||||
Sys_Printf ("%s:Out of order packet %i at %i\n",
|
||||
NET_AdrToString (chan->remote_address), sequence,
|
||||
chan->incoming_sequence);
|
||||
|
@ -341,7 +361,7 @@ Netchan_Process (netchan_t *chan)
|
|||
if (chan->net_drop > 0) {
|
||||
chan->drop_count += 1;
|
||||
|
||||
if (showdrop->int_val)
|
||||
if (showdrop)
|
||||
Sys_Printf ("%s:Dropped %i packets at %i\n",
|
||||
NET_AdrToString (chan->remote_address),
|
||||
sequence - (chan->incoming_sequence + 1), sequence);
|
||||
|
|
|
@ -86,8 +86,24 @@ int messagesReceived = 0;
|
|||
int unreliableMessagesSent = 0;
|
||||
int unreliableMessagesReceived = 0;
|
||||
|
||||
cvar_t *net_messagetimeout;
|
||||
cvar_t *hostname;
|
||||
float net_messagetimeout;
|
||||
static cvar_t net_messagetimeout_cvar = {
|
||||
.name = "net_messagetimeout",
|
||||
.description =
|
||||
"None",
|
||||
.default_value = "300",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &net_messagetimeout },
|
||||
};
|
||||
char *hostname;
|
||||
static cvar_t hostname_cvar = {
|
||||
.name = "hostname",
|
||||
.description =
|
||||
"None",
|
||||
.default_value = "UNNAMED",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = 0, .value = &hostname },
|
||||
};
|
||||
|
||||
QFile *vcrFile;
|
||||
qboolean recording = false;
|
||||
|
@ -229,9 +245,9 @@ MaxPlayers_f (void)
|
|||
|
||||
svs.maxclients = n;
|
||||
if (n == 1)
|
||||
Cvar_Set (deathmatch, "0");
|
||||
Cvar_Set ("deathmatch", "0");
|
||||
else
|
||||
Cvar_Set (deathmatch, "1");
|
||||
Cvar_Set ("deathmatch", "1");
|
||||
}
|
||||
|
||||
|
||||
|
@ -574,7 +590,7 @@ NET_GetMessage (qsocket_t *sock)
|
|||
|
||||
// see if this connection has timed out
|
||||
if (ret == 0 && sock->driver) {
|
||||
if (net_time - sock->lastMessageTime > net_messagetimeout->value) {
|
||||
if (net_time - sock->lastMessageTime > net_messagetimeout) {
|
||||
Sys_MaskPrintf (SYS_net, "socket timed out\n");
|
||||
NET_Close (sock);
|
||||
return -1;
|
||||
|
@ -849,9 +865,8 @@ NET_Init (cbuf_t *cbuf)
|
|||
// allocate space for network message buffer
|
||||
SZ_Alloc (&_net_message_message, NET_MAXMESSAGE);
|
||||
|
||||
net_messagetimeout =
|
||||
Cvar_Get ("net_messagetimeout", "300", CVAR_NONE, NULL, "None");
|
||||
hostname = Cvar_Get ("hostname", "UNNAMED", CVAR_NONE, NULL, "None");
|
||||
Cvar_Register (&net_messagetimeout_cvar, 0, 0);
|
||||
Cvar_Register (&hostname_cvar, 0, 0);
|
||||
|
||||
Cmd_AddCommand ("slist", NET_Slist_f, "No Description");
|
||||
Cmd_AddCommand ("listen", NET_Listen_f, "No Description");
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "QF/cmd.h"
|
||||
#include "QF/cvar.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/heapsort.h"
|
||||
#include "QF/keys.h"
|
||||
#include "QF/qendian.h"
|
||||
#include "QF/msg.h"
|
||||
|
@ -580,6 +581,26 @@ Datagram_Listen (qboolean state)
|
|||
}
|
||||
}
|
||||
|
||||
static const cvar_t **cvar_list;
|
||||
static int num_cvars;
|
||||
|
||||
static int
|
||||
dg_cvar_cmp (const void *_a, const void *_b)
|
||||
{
|
||||
const cvar_t * const *a = _a;
|
||||
const cvar_t * const *b = _b;
|
||||
return strcmp ((*a)->name, (*b)->name);
|
||||
}
|
||||
|
||||
static int
|
||||
dg_cvar_select (const cvar_t *cvar, void *data)
|
||||
{
|
||||
if (cvar->flags & CVAR_SERVERINFO) {
|
||||
*(int *)data += 1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static qsocket_t *
|
||||
_Datagram_CheckNewConnections (void)
|
||||
|
@ -634,7 +655,7 @@ _Datagram_CheckNewConnections (void)
|
|||
MSG_WriteByte (net_message->message, CCREP_SERVER_INFO);
|
||||
dfunc.GetSocketAddr (acceptsock, &newaddr);
|
||||
MSG_WriteString (net_message->message, dfunc.AddrToString (&newaddr));
|
||||
MSG_WriteString (net_message->message, hostname->string);
|
||||
MSG_WriteString (net_message->message, hostname);
|
||||
MSG_WriteString (net_message->message, sv.name);
|
||||
MSG_WriteByte (net_message->message, net_activeconnections);
|
||||
MSG_WriteByte (net_message->message, svs.maxclients);
|
||||
|
@ -690,25 +711,25 @@ _Datagram_CheckNewConnections (void)
|
|||
|
||||
if (command == CCREQ_RULE_INFO) {
|
||||
const char *prevCvarName;
|
||||
cvar_t *var;
|
||||
const cvar_t *var;
|
||||
|
||||
// find the search start location
|
||||
prevCvarName = MSG_ReadString (net_message);
|
||||
if (*prevCvarName) {
|
||||
var = Cvar_FindVar (prevCvarName);
|
||||
cvar_t key = { .name = prevCvarName };
|
||||
var = bsearch (&key, cvar_list, num_cvars, sizeof (cvar_t *),
|
||||
dg_cvar_cmp);
|
||||
if (!var)
|
||||
return NULL;
|
||||
var = var->next;
|
||||
return 0;
|
||||
var++;
|
||||
} else {
|
||||
var = cvar_vars;
|
||||
}
|
||||
|
||||
// search for the next server cvar
|
||||
while (var) {
|
||||
if (var->flags & CVAR_SERVERINFO) {
|
||||
break;
|
||||
if (cvar_list) {
|
||||
free (cvar_list);
|
||||
}
|
||||
var = var->next;
|
||||
num_cvars = 0;
|
||||
cvar_list = Cvar_Select (dg_cvar_select, &num_cvars);
|
||||
heapsort (cvar_list, num_cvars, sizeof (cvar_t *), dg_cvar_cmp);
|
||||
var = cvar_list[0];
|
||||
}
|
||||
|
||||
// send the response
|
||||
|
@ -719,7 +740,7 @@ _Datagram_CheckNewConnections (void)
|
|||
MSG_WriteByte (net_message->message, CCREP_RULE_INFO);
|
||||
if (var) {
|
||||
MSG_WriteString (net_message->message, var->name);
|
||||
MSG_WriteString (net_message->message, var->string);
|
||||
MSG_WriteString (net_message->message, Cvar_VarString (var));
|
||||
}
|
||||
MSG_PokeLongBE (net_message->message, 0,
|
||||
NETFLAG_CTL | net_message->message->cursize);
|
||||
|
|
|
@ -69,8 +69,8 @@ Loop_SearchForHosts (qboolean xmit)
|
|||
return;
|
||||
|
||||
const char *name = "local";
|
||||
if (strcmp (hostname->string, "UNNAMED") != 0) {
|
||||
name = hostname->string;
|
||||
if (strcmp (hostname, "UNNAMED") != 0) {
|
||||
name = hostname;
|
||||
}
|
||||
const char *map = sv.name;
|
||||
int users = net_activeconnections;
|
||||
|
|
|
@ -259,9 +259,9 @@ UDP_Init (void)
|
|||
myAddr = 0;
|
||||
|
||||
// if the quake hostname isn't set, set it to the machine name
|
||||
if (strcmp (hostname->string, "UNNAMED") == 0) {
|
||||
if (strcmp (hostname, "UNNAMED") == 0) {
|
||||
buff[15] = 0;
|
||||
Cvar_Set (hostname, buff);
|
||||
Cvar_Set ("hostname", buff);
|
||||
}
|
||||
|
||||
if ((net_controlsocket = UDP_OpenSocket (0)) == -1)
|
||||
|
@ -552,7 +552,7 @@ UDP_Read (int socket, byte *buf, int len, netadr_t *from)
|
|||
UDP_AddrToString (from));
|
||||
last_iface = default_iface;
|
||||
#endif
|
||||
if (developer->int_val & SYS_net) {
|
||||
if (developer & SYS_net) {
|
||||
hex_dump_buf (buf, ret);
|
||||
}
|
||||
return ret;
|
||||
|
@ -603,7 +603,7 @@ UDP_Write (int socket, byte *buf, int len, netadr_t *to)
|
|||
return 0;
|
||||
Sys_MaskPrintf (SYS_net, "sent %d bytes to %s\n", ret,
|
||||
UDP_AddrToString (to));
|
||||
if (developer->int_val & SYS_net) {
|
||||
if (developer & SYS_net) {
|
||||
hex_dump_buf (buf, len);
|
||||
}
|
||||
return ret;
|
||||
|
|
|
@ -252,7 +252,7 @@ WINS_Init (void)
|
|||
return -1;
|
||||
}
|
||||
// if the quake hostname isn't set, set it to the machine name
|
||||
if (strcmp (hostname->string, "UNNAMED") == 0) {
|
||||
if (strcmp (hostname, "UNNAMED") == 0) {
|
||||
// see if it's a text IP address (well, close enough)
|
||||
for (p = buff; *p; p++)
|
||||
if ((*p < '0' || *p > '9') && *p != '.')
|
||||
|
@ -265,7 +265,7 @@ WINS_Init (void)
|
|||
break;
|
||||
buff[i] = 0;
|
||||
}
|
||||
Cvar_Set (hostname, buff);
|
||||
Cvar_Set ("hostname", buff);
|
||||
}
|
||||
|
||||
i = COM_CheckParm ("-ip");
|
||||
|
|
|
@ -209,7 +209,7 @@ PF_cvar (progs_t *pr, void *data)
|
|||
|
||||
str = P_GSTRING (pr, 0);
|
||||
|
||||
R_FLOAT (pr) = Cvar_VariableValue (str);
|
||||
R_FLOAT (pr) = Cvar_Value (str);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -231,7 +231,7 @@ PF_cvar_set (progs_t *pr, void *data)
|
|||
return;
|
||||
}
|
||||
|
||||
Cvar_Set (var, val);
|
||||
Cvar_SetVar (var, val);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
#include "QF/progs.h"
|
||||
#include "QF/va.h"
|
||||
|
||||
#include "QF/simd/types.h"
|
||||
|
||||
#include "rua_internal.h"
|
||||
|
||||
typedef struct bi_alias_s {
|
||||
|
@ -127,7 +129,7 @@ bi_Cvar_SetString (progs_t *pr, void *_res)
|
|||
if (!var)
|
||||
var = Cvar_FindAlias (varname);
|
||||
if (var)
|
||||
Cvar_Set (var, val);
|
||||
Cvar_SetVar (var, val);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -140,7 +142,7 @@ bi_Cvar_SetInteger (progs_t *pr, void *_res)
|
|||
if (!var)
|
||||
var = Cvar_FindAlias (varname);
|
||||
if (var)
|
||||
Cvar_Set (var, va (0, "%d", val));
|
||||
Cvar_SetVar (var, va (0, "%d", val));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -153,7 +155,7 @@ bi_Cvar_SetFloat (progs_t *pr, void *_res)
|
|||
if (!var)
|
||||
var = Cvar_FindAlias (varname);
|
||||
if (var)
|
||||
Cvar_Set (var, va (0, "%g", val));
|
||||
Cvar_SetVar (var, va (0, "%g", val));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -166,7 +168,7 @@ bi_Cvar_SetVector (progs_t *pr, void *_res)
|
|||
if (!var)
|
||||
var = Cvar_FindAlias (varname);
|
||||
if (var)
|
||||
Cvar_Set (var, va (0, "%g %g %g", val[0], val[1], val[2]));
|
||||
Cvar_SetVar (var, va (0, "%g %g %g", val[0], val[1], val[2]));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -178,7 +180,7 @@ bi_Cvar_GetString (progs_t *pr, void *_res)
|
|||
if (!var)
|
||||
var = Cvar_FindAlias (varname);
|
||||
if (var)
|
||||
RETURN_STRING (pr, var->string);
|
||||
RETURN_STRING (pr, Cvar_VarString (var));
|
||||
else
|
||||
RETURN_STRING (pr, "");
|
||||
}
|
||||
|
@ -189,9 +191,13 @@ bi_Cvar_GetInteger (progs_t *pr, void *_res)
|
|||
const char *varname = P_GSTRING (pr, 0);
|
||||
cvar_t *var = Cvar_FindVar (varname);
|
||||
|
||||
R_INT (pr) = 0;
|
||||
if (!var)
|
||||
var = Cvar_FindAlias (varname);
|
||||
R_INT (pr) = var ? var->int_val : 0;
|
||||
if (!var || var->value.type != &cexpr_int)
|
||||
return;
|
||||
|
||||
R_INT (pr) = *(int *) var->value.value;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -200,9 +206,12 @@ bi_Cvar_GetFloat (progs_t *pr, void *_res)
|
|||
const char *varname = P_GSTRING (pr, 0);
|
||||
cvar_t *var = Cvar_FindVar (varname);
|
||||
|
||||
R_FLOAT (pr) = 0;
|
||||
if (!var)
|
||||
var = Cvar_FindAlias (varname);
|
||||
R_FLOAT (pr) = var ? var->value : 0;
|
||||
if (!var || var->value.type != &cexpr_float)
|
||||
return;
|
||||
R_INT (pr) = *(float *) var->value.value;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -213,8 +222,8 @@ bi_Cvar_GetVector (progs_t *pr, void *_res)
|
|||
|
||||
if (!var)
|
||||
var = Cvar_FindAlias (varname);
|
||||
if (var)
|
||||
RETURN_VECTOR (pr, var->vec);
|
||||
if (var && var->value.type == &cexpr_vector)
|
||||
RETURN_VECTOR (pr, *(vec4f_t *) var->value.value);
|
||||
else
|
||||
VectorZero (R_VECTOR (pr));
|
||||
}
|
||||
|
@ -228,8 +237,9 @@ bi_Cvar_Toggle (progs_t *pr, void *_res)
|
|||
var = Cvar_FindVar (varname);
|
||||
if (!var)
|
||||
var = Cvar_FindAlias (varname);
|
||||
if (var)
|
||||
Cvar_Set (var, var->int_val ? "0" : "1");
|
||||
if (var && var->value.type == &cexpr_int) {
|
||||
*(int *) var->value.value = !*(int *) var->value.value;
|
||||
}
|
||||
}
|
||||
|
||||
#define bi(x,np,params...) {#x, bi_##x, -1, np, {params}}
|
||||
|
|
|
@ -860,7 +860,7 @@ obj_find_message (probj_t *probj, pr_class_t *class, pr_sel_t *selector)
|
|||
pr_method_t *method;
|
||||
pr_sel_t *sel;
|
||||
int i;
|
||||
int dev = developer->int_val;
|
||||
int dev = developer;
|
||||
pr_string_t *names;
|
||||
|
||||
if (dev & SYS_rua_msg) {
|
||||
|
@ -882,7 +882,7 @@ obj_find_message (probj_t *probj, pr_class_t *class, pr_sel_t *selector)
|
|||
for (i = 0, method = method_list->method_list;
|
||||
i < method_list->method_count; i++, method++) {
|
||||
sel = &G_STRUCT (pr, pr_sel_t, method->method_name);
|
||||
if (developer->int_val & SYS_rua_msg) {
|
||||
if (developer & SYS_rua_msg) {
|
||||
names = probj->selector_names;
|
||||
Sys_Printf (" %s\n",
|
||||
PR_GetString (pr, names[sel->sel_id]));
|
||||
|
@ -1214,7 +1214,7 @@ rua___obj_exec_class (progs_t *pr, void *data)
|
|||
Sys_MaskPrintf (SYS_rua_obj, " instance variables: %d @ %x\n",
|
||||
class->instance_size,
|
||||
class->ivars);
|
||||
if (developer->int_val & SYS_rua_obj)
|
||||
if (developer & SYS_rua_obj)
|
||||
dump_ivars (probj, class->ivars);
|
||||
Sys_MaskPrintf (SYS_rua_obj, " instance methods: %x\n",
|
||||
class->methods);
|
||||
|
@ -1224,7 +1224,7 @@ rua___obj_exec_class (progs_t *pr, void *data)
|
|||
Sys_MaskPrintf (SYS_rua_obj, " instance variables: %d @ %x\n",
|
||||
meta->instance_size,
|
||||
meta->ivars);
|
||||
if (developer->int_val & SYS_rua_obj)
|
||||
if (developer & SYS_rua_obj)
|
||||
dump_ivars (probj, meta->ivars);
|
||||
|
||||
class->subclass_list = 0;
|
||||
|
@ -1482,7 +1482,7 @@ rua_obj_msg_sendv (progs_t *pr, void *data)
|
|||
if (count < 2 || count > PR_MAX_PARAMS) {
|
||||
PR_RunError (pr, "bad args count in obj_msg_sendv: %d", count);
|
||||
}
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (pr_boundscheck) {
|
||||
PR_BoundsCheckSize (pr, args->list, count * pr->pr_param_size);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,8 +39,47 @@
|
|||
#endif
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "QF/cexpr.h"
|
||||
#include "QF/ui/view.h"
|
||||
|
||||
static exprenum_t grav_t_enum;
|
||||
exprtype_t grav_t_type = {
|
||||
.name = "grav_t",
|
||||
.size = sizeof (grav_t),
|
||||
.data = &grav_t_enum,
|
||||
.get_string = cexpr_enum_get_string,
|
||||
};
|
||||
static grav_t grav_t_values[] = {
|
||||
grav_center,
|
||||
grav_north,
|
||||
grav_northeast,
|
||||
grav_east,
|
||||
grav_southeast,
|
||||
grav_south,
|
||||
grav_southwest,
|
||||
grav_west,
|
||||
grav_northwest,
|
||||
};
|
||||
static exprsym_t grav_t_symbols[] = {
|
||||
{ "center", &grav_t_type, grav_t_values + grav_center },
|
||||
{ "north", &grav_t_type, grav_t_values + grav_north },
|
||||
{ "northeast", &grav_t_type, grav_t_values + grav_northeast },
|
||||
{ "east", &grav_t_type, grav_t_values + grav_east },
|
||||
{ "southeast", &grav_t_type, grav_t_values + grav_southeast },
|
||||
{ "south", &grav_t_type, grav_t_values + grav_south },
|
||||
{ "southwest", &grav_t_type, grav_t_values + grav_southwest },
|
||||
{ "west", &grav_t_type, grav_t_values + grav_west },
|
||||
{ "northwest", &grav_t_type, grav_t_values + grav_northwest },
|
||||
{}
|
||||
};
|
||||
static exprtab_t grav_t_symtab = {
|
||||
grav_t_symbols,
|
||||
};
|
||||
static exprenum_t grav_t_enum = {
|
||||
&grav_t_type,
|
||||
&grav_t_symtab,
|
||||
};
|
||||
|
||||
static void
|
||||
setgeometry (view_t *view)
|
||||
{
|
||||
|
|
|
@ -94,9 +94,18 @@ cexpr_error(exprctx_t *ctx, const char *fmt, ...)
|
|||
va_end (args);
|
||||
|
||||
if (ctx->messages) {
|
||||
PL_Message (ctx->messages, ctx->item, "%s", string->str);
|
||||
if (ctx->msg_prefix) {
|
||||
PL_Message (ctx->messages, ctx->item, "%s:%s",
|
||||
ctx->msg_prefix, string->str);
|
||||
} else {
|
||||
PL_Message (ctx->messages, ctx->item, "%s", string->str);
|
||||
}
|
||||
} else {
|
||||
Sys_Printf ("%s\n", string->str);
|
||||
if (ctx->msg_prefix) {
|
||||
Sys_Printf ("%s:%s\n", ctx->msg_prefix, string->str);
|
||||
} else {
|
||||
Sys_Printf ("%s\n", string->str);
|
||||
}
|
||||
}
|
||||
dstring_delete (string);
|
||||
}
|
||||
|
|
|
@ -51,8 +51,6 @@
|
|||
|
||||
#include "QF/cexpr.h"
|
||||
|
||||
static exprval_t *assign_expr (exprval_t *dst, const exprval_t *src,
|
||||
exprctx_t *context);
|
||||
static exprval_t *binary_expr (int op, const exprval_t *a, const exprval_t *b,
|
||||
exprctx_t *context);
|
||||
static exprval_t *field_expr (const exprval_t *a, const exprval_t *b,
|
||||
|
@ -109,7 +107,7 @@ yyerror (void *scanner, exprctx_t *context, const char *s)
|
|||
%%
|
||||
|
||||
start
|
||||
: expr { assign_expr (context->result, $1, context); }
|
||||
: expr { cexpr_assign_value (context->result, $1, context); }
|
||||
;
|
||||
|
||||
uexpr
|
||||
|
@ -138,7 +136,7 @@ uexpr
|
|||
|
||||
expr
|
||||
: uexpr
|
||||
| expr '=' expr { $$ = assign_expr ($1, $3, context); }
|
||||
| expr '=' expr { $$ = cexpr_assign_value ($1, $3, context); }
|
||||
| expr SHL expr { $$ = binary_expr (SHL, $1, $3, context); }
|
||||
| expr SHR expr { $$ = binary_expr (SHR, $1, $3, context); }
|
||||
| expr '+' expr { $$ = binary_expr ('+', $1, $3, context); }
|
||||
|
@ -185,8 +183,8 @@ arg_expr
|
|||
|
||||
%%
|
||||
|
||||
static exprval_t *
|
||||
assign_expr (exprval_t *dst, const exprval_t *src, exprctx_t *context)
|
||||
exprval_t *
|
||||
cexpr_assign_value (exprval_t *dst, const exprval_t *src, exprctx_t *context)
|
||||
{
|
||||
binop_t *binop;
|
||||
if (!dst || !src) {
|
||||
|
|
|
@ -28,11 +28,14 @@
|
|||
# include "config.h"
|
||||
#endif
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "QF/cexpr.h"
|
||||
#include "QF/cmem.h"
|
||||
#include "QF/mathlib.h"
|
||||
#include "QF/plist.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/va.h"
|
||||
#include "QF/simd/vec4f.h"
|
||||
|
||||
#include "libs/util/cexpr-parse.h"
|
||||
|
@ -99,6 +102,12 @@ int_mod (const exprval_t *val1, const exprval_t *val2, exprval_t *result,
|
|||
*(int *) result->value = c + (mask & b);
|
||||
}
|
||||
|
||||
static const char *
|
||||
int_get_string (const exprval_t *val, va_ctx_t *va_ctx)
|
||||
{
|
||||
return va (va_ctx, "%d", *(int *) val->value);
|
||||
}
|
||||
|
||||
binop_t int_binops[] = {
|
||||
{ SHL, &cexpr_int, &cexpr_int, int_shl },
|
||||
{ SHR, &cexpr_int, &cexpr_int, int_shr },
|
||||
|
@ -124,10 +133,11 @@ unop_t int_unops[] = {
|
|||
};
|
||||
|
||||
exprtype_t cexpr_int = {
|
||||
"int",
|
||||
sizeof (int),
|
||||
int_binops,
|
||||
int_unops,
|
||||
.name = "int",
|
||||
.size = sizeof (int),
|
||||
.binops = int_binops,
|
||||
.unops = int_unops,
|
||||
.get_string = int_get_string,
|
||||
};
|
||||
|
||||
BINOP(uint, shl, unsigned, <<)
|
||||
|
@ -153,6 +163,12 @@ UNOP(uint, neg, unsigned, -)
|
|||
UNOP(uint, tnot, unsigned, !)
|
||||
UNOP(uint, bnot, unsigned, ~)
|
||||
|
||||
static const char *
|
||||
uint_get_string (const exprval_t *val, va_ctx_t *va_ctx)
|
||||
{
|
||||
return va (va_ctx, "%u", *(unsigned *) val->value);
|
||||
}
|
||||
|
||||
binop_t uint_binops[] = {
|
||||
{ SHL, &cexpr_uint, &cexpr_uint, uint_shl },
|
||||
{ SHR, &cexpr_uint, &cexpr_uint, uint_shr },
|
||||
|
@ -179,10 +195,11 @@ unop_t uint_unops[] = {
|
|||
};
|
||||
|
||||
exprtype_t cexpr_uint = {
|
||||
"uint",
|
||||
sizeof (unsigned),
|
||||
uint_binops,
|
||||
uint_unops,
|
||||
.name = "uint",
|
||||
.size = sizeof (unsigned),
|
||||
.binops = uint_binops,
|
||||
.unops = uint_unops,
|
||||
.get_string = uint_get_string,
|
||||
};
|
||||
|
||||
BINOP(size_t, shl, unsigned, <<)
|
||||
|
@ -221,6 +238,12 @@ UNOP(size_t, neg, unsigned, -)
|
|||
UNOP(size_t, tnot, unsigned, !)
|
||||
UNOP(size_t, bnot, unsigned, ~)
|
||||
|
||||
static const char *
|
||||
size_t_get_string (const exprval_t *val, va_ctx_t *va_ctx)
|
||||
{
|
||||
return va (va_ctx, "%zd", *(size_t *) val->value);
|
||||
}
|
||||
|
||||
binop_t size_t_binops[] = {
|
||||
{ SHL, &cexpr_size_t, &cexpr_size_t, size_t_shl },
|
||||
{ SHR, &cexpr_size_t, &cexpr_size_t, size_t_shr },
|
||||
|
@ -248,10 +271,11 @@ unop_t size_t_unops[] = {
|
|||
};
|
||||
|
||||
exprtype_t cexpr_size_t = {
|
||||
"size_t",
|
||||
sizeof (size_t),
|
||||
size_t_binops,
|
||||
size_t_unops,
|
||||
.name = "size_t",
|
||||
.size = sizeof (size_t),
|
||||
.binops = size_t_binops,
|
||||
.unops = size_t_unops,
|
||||
.get_string = size_t_get_string,
|
||||
};
|
||||
|
||||
BINOP(float, add, float, +)
|
||||
|
@ -304,11 +328,18 @@ float_div_quat (const exprval_t *val1, const exprval_t *val2,
|
|||
|
||||
CASTOP (float, int)
|
||||
CASTOP (float, uint)
|
||||
CASTOP (float, double)
|
||||
|
||||
UNOP(float, pos, float, +)
|
||||
UNOP(float, neg, float, -)
|
||||
UNOP(float, tnot, float, !)
|
||||
|
||||
static const char *
|
||||
float_get_string (const exprval_t *val, va_ctx_t *va_ctx)
|
||||
{
|
||||
return va (va_ctx, "%.9g", *(float *) val->value);
|
||||
}
|
||||
|
||||
binop_t float_binops[] = {
|
||||
{ '+', &cexpr_float, &cexpr_float, float_add },
|
||||
{ '-', &cexpr_float, &cexpr_float, float_sub },
|
||||
|
@ -321,6 +352,7 @@ binop_t float_binops[] = {
|
|||
{ MOD, &cexpr_float, &cexpr_float, float_mod },
|
||||
{ '=', &cexpr_int, &cexpr_float, float_cast_int },
|
||||
{ '=', &cexpr_uint, &cexpr_float, float_cast_uint },
|
||||
{ '=', &cexpr_double, &cexpr_float, float_cast_double },
|
||||
{ '=', &cexpr_plitem, &cexpr_float, cexpr_cast_plitem },
|
||||
{}
|
||||
};
|
||||
|
@ -333,10 +365,11 @@ unop_t float_unops[] = {
|
|||
};
|
||||
|
||||
exprtype_t cexpr_float = {
|
||||
"float",
|
||||
sizeof (float),
|
||||
float_binops,
|
||||
float_unops,
|
||||
.name = "float",
|
||||
.size = sizeof (float),
|
||||
.binops = float_binops,
|
||||
.unops = float_unops,
|
||||
.get_string = float_get_string,
|
||||
};
|
||||
|
||||
BINOP(double, add, double, +)
|
||||
|
@ -375,6 +408,12 @@ UNOP(double, pos, double, +)
|
|||
UNOP(double, neg, double, -)
|
||||
UNOP(double, tnot, double, !)
|
||||
|
||||
static const char *
|
||||
double_get_string (const exprval_t *val, va_ctx_t *va_ctx)
|
||||
{
|
||||
return va (va_ctx, "%.17g", *(double *) val->value);
|
||||
}
|
||||
|
||||
binop_t double_binops[] = {
|
||||
{ '+', &cexpr_double, &cexpr_double, double_add },
|
||||
{ '-', &cexpr_double, &cexpr_double, double_sub },
|
||||
|
@ -397,10 +436,11 @@ unop_t double_unops[] = {
|
|||
};
|
||||
|
||||
exprtype_t cexpr_double = {
|
||||
"double",
|
||||
sizeof (double),
|
||||
double_binops,
|
||||
double_unops,
|
||||
.name = "double",
|
||||
.size = sizeof (double),
|
||||
.binops = double_binops,
|
||||
.unops = double_unops,
|
||||
.get_string = double_get_string,
|
||||
};
|
||||
|
||||
BINOP(vector, add, vec4f_t, +)
|
||||
|
@ -518,6 +558,13 @@ vector_swizzle (const exprval_t *val1, const exprval_t *val2,
|
|||
UNOP(vector, pos, vec4f_t, +)
|
||||
UNOP(vector, neg, vec4f_t, -)
|
||||
|
||||
static const char *
|
||||
vector_get_string (const exprval_t *val, va_ctx_t *va_ctx)
|
||||
{
|
||||
vec4f_t vec = *(vec4f_t *) val->value;
|
||||
return va (va_ctx, VEC4F_FMT, VEC4_EXP (vec));
|
||||
}
|
||||
|
||||
static void
|
||||
vector_tnot (const exprval_t *val, exprval_t *result, exprctx_t *ctx)
|
||||
{
|
||||
|
@ -546,10 +593,11 @@ unop_t vector_unops[] = {
|
|||
};
|
||||
|
||||
exprtype_t cexpr_vector = {
|
||||
"vector",
|
||||
sizeof (vec4f_t),
|
||||
vector_binops,
|
||||
vector_unops,
|
||||
.name = "vector",
|
||||
.size = sizeof (vec4f_t),
|
||||
.binops = vector_binops,
|
||||
.unops = vector_unops,
|
||||
.get_string = vector_get_string,
|
||||
};
|
||||
|
||||
static void
|
||||
|
@ -572,6 +620,13 @@ quaternion_vector_mul (const exprval_t *val1, const exprval_t *val2,
|
|||
*c = qvmulf (a, b);
|
||||
}
|
||||
|
||||
static const char *
|
||||
quaternion_get_string (const exprval_t *val, va_ctx_t *va_ctx)
|
||||
{
|
||||
vec4f_t vec = *(vec4f_t *) val->value;
|
||||
return va (va_ctx, VEC4F_FMT, VEC4_EXP (vec));
|
||||
}
|
||||
|
||||
binop_t quaternion_binops[] = {
|
||||
{ '+', &cexpr_quaternion, &cexpr_quaternion, vector_add },
|
||||
{ '-', &cexpr_quaternion, &cexpr_quaternion, vector_sub },
|
||||
|
@ -588,31 +643,32 @@ unop_t quaternion_unops[] = {
|
|||
};
|
||||
|
||||
exprtype_t cexpr_quaternion = {
|
||||
"quaterion",
|
||||
sizeof (vec4f_t),
|
||||
quaternion_binops,
|
||||
quaternion_unops,
|
||||
.name = "quaterion",
|
||||
.size = sizeof (vec4f_t),
|
||||
.binops = quaternion_binops,
|
||||
.unops = quaternion_unops,
|
||||
.get_string = quaternion_get_string,
|
||||
};
|
||||
|
||||
exprtype_t cexpr_exprval = {
|
||||
"exprval",
|
||||
sizeof (exprval_t *),
|
||||
0, // can't actually do anything with an exprval
|
||||
0,
|
||||
.name = "exprval",
|
||||
.size = sizeof (exprval_t *),
|
||||
.binops = 0, // can't actually do anything with an exprval
|
||||
.unops = 0,
|
||||
};
|
||||
|
||||
exprtype_t cexpr_field = {
|
||||
"field",
|
||||
0, // has no size of its own, rather, it's the length of the name
|
||||
0, // can't actually do anything with a field
|
||||
0,
|
||||
.name = "field",
|
||||
.size = 0, // has no size of its own, rather, it's the length of the name
|
||||
.binops = 0, // can't actually do anything with a field
|
||||
.unops = 0,
|
||||
};
|
||||
|
||||
exprtype_t cexpr_function = {
|
||||
"function",
|
||||
0, // has no size of its own
|
||||
0, // can't actually do anything with a function other than call
|
||||
0,
|
||||
.name = "function",
|
||||
.size = 0, // has no size of its own
|
||||
.binops = 0,// can't actually do anything with a function other than call
|
||||
.unops = 0,
|
||||
};
|
||||
|
||||
void
|
||||
|
@ -711,10 +767,10 @@ binop_t plitem_binops[] = {
|
|||
};
|
||||
|
||||
exprtype_t cexpr_plitem = {
|
||||
"plitem",
|
||||
sizeof (plitem_t *),
|
||||
plitem_binops,
|
||||
0,
|
||||
.name = "plitem",
|
||||
.size = sizeof (plitem_t *),
|
||||
.binops = plitem_binops,
|
||||
.unops = 0,
|
||||
};
|
||||
|
||||
VISIBLE binop_t *
|
||||
|
@ -743,3 +799,71 @@ cexpr_parse_enum (exprenum_t *enm, const char *str, const exprctx_t *ctx,
|
|||
context.result = &result;
|
||||
return cexpr_eval_string (str, &context);
|
||||
}
|
||||
|
||||
VISIBLE const char *
|
||||
cexpr_enum_get_string (const exprval_t *val, va_ctx_t *va_ctx)
|
||||
{
|
||||
exprenum_t *enm = val->type->data;
|
||||
exprsym_t *symbols = enm->symtab->symbols;
|
||||
for (exprsym_t *sym = symbols; sym->name; sym++) {
|
||||
// if there are duplicate values, choose the *later* value
|
||||
if (sym[1].name
|
||||
&& memcmp (sym->value, sym[1].value, val->type->size) == 0) {
|
||||
continue;
|
||||
}
|
||||
if (memcmp (sym->value, val->value, val->type->size) == 0) {
|
||||
return sym->name;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
BINOP(flag, and, int, &)
|
||||
BINOP(flag, or, int, |)
|
||||
BINOP(flag, xor, int, ^)
|
||||
|
||||
UNOP(flag, not, int, ~)
|
||||
|
||||
binop_t cexpr_flag_binops[] = {
|
||||
{ '&', 0, 0, flag_and },
|
||||
{ '|', 0, 0, flag_or },
|
||||
{ '^', 0, 0, flag_xor },
|
||||
{ '=', &cexpr_int, 0, uint_cast_int },
|
||||
{}
|
||||
};
|
||||
|
||||
unop_t cexpr_flag_unops[] = {
|
||||
{ '~', 0, flag_not },
|
||||
{}
|
||||
};
|
||||
|
||||
VISIBLE const char *
|
||||
cexpr_flags_get_string (const exprval_t *val, va_ctx_t *va_ctx)
|
||||
{
|
||||
exprenum_t *enm = val->type->data;
|
||||
exprsym_t *symbols = enm->symtab->symbols;
|
||||
const char *val_str = 0;
|
||||
|
||||
if (val->type->size != 4) {
|
||||
Sys_Error ("cexpr_flags_get_string: only 32-bit values supported");
|
||||
}
|
||||
uint32_t flags = *(uint32_t *) val->value;
|
||||
for (exprsym_t *sym = symbols; sym->name; sym++) {
|
||||
uint32_t sym_flags = *(uint32_t *) sym->value;
|
||||
// if there are duplicate values, choose the *later* value
|
||||
if (sym[1].name && sym_flags == *(uint32_t *) sym[1].value) {
|
||||
continue;
|
||||
}
|
||||
if ((flags & sym_flags) && !(sym_flags & ~flags)) {
|
||||
if (val_str) {
|
||||
val_str = va (va_ctx, "%s | %s", val_str, sym->name);
|
||||
} else {
|
||||
val_str = sym->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!val_str) {
|
||||
val_str = "0";
|
||||
}
|
||||
return val_str;
|
||||
}
|
||||
|
|
|
@ -114,10 +114,10 @@ static binop_t cvar_binops[] = {
|
|||
};
|
||||
|
||||
static exprtype_t cvar_type = {
|
||||
"cvar",
|
||||
sizeof (void *), // ref to struct (will always be 0)
|
||||
cvar_binops,
|
||||
0,
|
||||
.name = "cvar",
|
||||
.size = sizeof (void *), // ref to struct (will always be 0)
|
||||
.binops = cvar_binops,
|
||||
.unops = 0,
|
||||
};
|
||||
|
||||
VISIBLE exprval_t *
|
||||
|
@ -132,21 +132,13 @@ cexpr_cvar (const char *name, exprctx_t *ctx)
|
|||
}
|
||||
|
||||
exprtype_t *type = ctx->result->type;
|
||||
binop_t *cast = cexpr_find_cast (type, &cexpr_int);
|
||||
|
||||
exprval_t *val = 0;
|
||||
if (cast || val->type == &cexpr_int || val->type == &cexpr_uint) {
|
||||
val = cexpr_value (type, ctx);
|
||||
*(int *) val->value = var->int_val;
|
||||
} else if (val->type == &cexpr_float) {
|
||||
val = cexpr_value (type, ctx);
|
||||
*(float *) val->value = var->value;
|
||||
} else if (val->type == &cexpr_double) {
|
||||
val = cexpr_value (type, ctx);
|
||||
//FIXME cvars need to support double values
|
||||
*(double *) val->value = var->value;
|
||||
if (var->value.type) {
|
||||
exprval_t *val = cexpr_value (type, ctx);
|
||||
cexpr_assign_value (val, &var->value, ctx);
|
||||
return val;
|
||||
}
|
||||
return val;
|
||||
cexpr_error (ctx, "cvar %s has unknown type", var->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
VISIBLE exprval_t *
|
||||
|
|
|
@ -65,7 +65,15 @@ typedef struct cmd_provider_s
|
|||
|
||||
static cmdalias_t *cmd_alias;
|
||||
|
||||
VISIBLE cvar_t *cmd_warncmd;
|
||||
VISIBLE int cmd_warncmd;
|
||||
static cvar_t cmd_warncmd_cvar = {
|
||||
.name = "cmd_warncmd",
|
||||
.description =
|
||||
"Toggles the display of error messages for unknown commands",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_int, .value = &cmd_warncmd },
|
||||
};
|
||||
|
||||
static hashtab_t *cmd_alias_hash;
|
||||
static hashtab_t *cmd_hash;
|
||||
|
@ -130,7 +138,7 @@ Cmd_Command (cbuf_args_t *args)
|
|||
return 0;
|
||||
if (cbuf_active->strict)
|
||||
return -1;
|
||||
else if (cmd_warncmd->int_val || developer->int_val & SYS_dev)
|
||||
else if (cmd_warncmd || developer & SYS_dev)
|
||||
Sys_Printf ("Unknown command \"%s\"\n", Cmd_Argv (0));
|
||||
return 0;
|
||||
}
|
||||
|
@ -515,9 +523,7 @@ Cmd_Exec_f (void)
|
|||
Sys_Printf ("couldn't exec %s\n", Cmd_Argv (1));
|
||||
return;
|
||||
}
|
||||
if (!Cvar_Command ()
|
||||
&& (cmd_warncmd->int_val
|
||||
|| (developer && developer->int_val & SYS_dev)))
|
||||
if (!Cvar_Command () && (cmd_warncmd || (developer & SYS_dev)))
|
||||
Sys_Printf ("execing %s\n", Cmd_Argv (1));
|
||||
Cbuf_InsertText (cbuf_active, f);
|
||||
Hunk_FreeToLowMark (0, mark);
|
||||
|
@ -629,8 +635,7 @@ Cmd_Init (void)
|
|||
Cmd_AddCommand ("echo", Cmd_Echo_f, "Print text to console");
|
||||
Cmd_AddCommand ("wait", Cmd_Wait_f, "Wait a game tic");
|
||||
Cmd_AddCommand ("sleep", Cmd_Sleep_f, "Wait for a certain number of seconds.");
|
||||
cmd_warncmd = Cvar_Get ("cmd_warncmd", "0", CVAR_NONE, NULL, "Toggles the "
|
||||
"display of error messages for unknown commands");
|
||||
Cvar_Register (&cmd_warncmd_cvar, 0, 0);
|
||||
cmd_cbuf = Cbuf_New (&id_interp);
|
||||
|
||||
Cmd_AddProvider("id", &id_interp);
|
||||
|
|
665
libs/util/cvar.c
665
libs/util/cvar.c
|
@ -43,7 +43,9 @@
|
|||
|
||||
#include "QF/cmd.h"
|
||||
#include "QF/cvar.h"
|
||||
#include "QF/cmem.h"
|
||||
#include "QF/hash.h"
|
||||
#include "QF/heapsort.h"
|
||||
#include "QF/mathlib.h"
|
||||
#include "QF/plist.h"
|
||||
#include "QF/qargs.h"
|
||||
|
@ -56,13 +58,77 @@
|
|||
#define USER_RO_CVAR "User-created READ-ONLY Cvar"
|
||||
#define USER_CVAR "User-created cvar"
|
||||
|
||||
VISIBLE cvar_t *developer;
|
||||
VISIBLE cvar_t *cvar_vars;
|
||||
static exprenum_t developer_enum;
|
||||
static exprtype_t developer_type = {
|
||||
.name = "developer",
|
||||
.size = sizeof (int),
|
||||
.binops = cexpr_flag_binops,
|
||||
.unops = cexpr_flag_unops,
|
||||
.data = &developer_enum,
|
||||
.get_string = cexpr_enum_get_string,
|
||||
};
|
||||
|
||||
#define SYS_DEVELOPER(dev) (SYS_##dev & ~SYS_dev),
|
||||
static int developer_values[] = {
|
||||
SYS_dev,
|
||||
#include "QF/sys_developer.h"
|
||||
};
|
||||
#undef SYS_DEVELOPER
|
||||
#define SYS_DEVELOPER(dev) {#dev, &developer_type, developer_values + __LINE__ - 31},
|
||||
static exprsym_t developer_symbols[] = {
|
||||
{"dev", &developer_type, developer_values + 0},
|
||||
#include "QF/sys_developer.h"
|
||||
{}
|
||||
};
|
||||
#undef SYS_DEVELOPER
|
||||
static exprtab_t developer_symtab = {
|
||||
developer_symbols,
|
||||
};
|
||||
static exprenum_t developer_enum = {
|
||||
&developer_type,
|
||||
&developer_symtab,
|
||||
};
|
||||
|
||||
VISIBLE int developer;
|
||||
static cvar_t developer_cvar = {
|
||||
.name = "developer",
|
||||
.description =
|
||||
"set to enable extra debugging information",
|
||||
.default_value = "0",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &developer_type, .value = &developer },
|
||||
};
|
||||
static const char *cvar_null_string = "";
|
||||
static cvar_alias_t *calias_vars;
|
||||
static hashtab_t *cvar_hash;
|
||||
static hashtab_t *user_cvar_hash;
|
||||
static hashtab_t *calias_hash;
|
||||
|
||||
static cvar_t *
|
||||
cvar_create (const char *name, const char *value)
|
||||
{
|
||||
cvar_t *var = calloc (1, sizeof (cvar_t) + sizeof (char *));
|
||||
var->name = strdup (name);
|
||||
var->description = cvar_null_string;
|
||||
var->default_value = cvar_null_string;
|
||||
var->flags = CVAR_USER_CREATED;
|
||||
var->value.value = var + 1;
|
||||
*(char **)var->value.value = strdup (value);
|
||||
|
||||
Hash_Add (user_cvar_hash, var);
|
||||
return var;
|
||||
}
|
||||
|
||||
static void
|
||||
cvar_destroy (cvar_t *var)
|
||||
{
|
||||
if (!(var->flags & CVAR_USER_CREATED)) {
|
||||
Sys_Error ("Attempt to destroy non-user cvar");
|
||||
}
|
||||
Hash_Del (user_cvar_hash, var->name);
|
||||
free (*(char **) var->value.value);
|
||||
free ((char *) var->name);
|
||||
free (var);
|
||||
}
|
||||
|
||||
VISIBLE cvar_t *
|
||||
Cvar_FindVar (const char *var_name)
|
||||
|
@ -105,8 +171,6 @@ Cvar_MakeAlias (const char *name, cvar_t *cvar)
|
|||
if (!var) {
|
||||
alias = (cvar_alias_t *) calloc (1, sizeof (cvar_alias_t));
|
||||
|
||||
alias->next = calias_vars;
|
||||
calias_vars = alias;
|
||||
alias->name = strdup (name);
|
||||
alias->cvar = cvar;
|
||||
Hash_Add (calias_hash, alias);
|
||||
|
@ -130,8 +194,21 @@ Cvar_RemoveAlias (const char *name)
|
|||
return var;
|
||||
}
|
||||
|
||||
static float
|
||||
cvar_value (cvar_t *var)
|
||||
{
|
||||
if (!var->value.type) {
|
||||
return atof (*(char **)var->value.value);
|
||||
} else if (var->value.type == &cexpr_int) {
|
||||
return *(int *)var->value.value;
|
||||
} else if (var->value.type == &cexpr_float) {
|
||||
return *(float *)var->value.value;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
VISIBLE float
|
||||
Cvar_VariableValue (const char *var_name)
|
||||
Cvar_Value (const char *var_name)
|
||||
{
|
||||
cvar_t *var;
|
||||
|
||||
|
@ -140,11 +217,22 @@ Cvar_VariableValue (const char *var_name)
|
|||
var = Cvar_FindAlias (var_name);
|
||||
if (!var)
|
||||
return 0;
|
||||
return atof (var->string);
|
||||
return cvar_value (var);
|
||||
}
|
||||
|
||||
static const char *
|
||||
cvar_string (const cvar_t *var)
|
||||
{
|
||||
if (!var->value.type) {
|
||||
return *(char **)var->value.value;
|
||||
} else if (var->value.type->get_string) {
|
||||
return var->value.type->get_string (&var->value, 0);
|
||||
}
|
||||
return cvar_null_string;
|
||||
}
|
||||
|
||||
VISIBLE const char *
|
||||
Cvar_VariableString (const char *var_name)
|
||||
Cvar_String (const char *var_name)
|
||||
{
|
||||
cvar_t *var;
|
||||
|
||||
|
@ -153,100 +241,99 @@ Cvar_VariableString (const char *var_name)
|
|||
var = Cvar_FindAlias (var_name);
|
||||
if (!var)
|
||||
return cvar_null_string;
|
||||
return var->string;
|
||||
return cvar_string (var);
|
||||
}
|
||||
|
||||
VISIBLE const char *
|
||||
Cvar_CompleteVariable (const char *partial)
|
||||
Cvar_VarString (const cvar_t *var)
|
||||
{
|
||||
cvar_t *cvar;
|
||||
cvar_alias_t *alias;
|
||||
int len;
|
||||
|
||||
len = strlen (partial);
|
||||
|
||||
if (!len)
|
||||
return NULL;
|
||||
|
||||
// check exact match
|
||||
for (cvar = cvar_vars; cvar; cvar = cvar->next)
|
||||
if (!strcmp (partial, cvar->name))
|
||||
return cvar->name;
|
||||
|
||||
// check aliases too :)
|
||||
for (alias = calias_vars; alias; alias = alias->next)
|
||||
if (!strcmp (partial, alias->name))
|
||||
return alias->name;
|
||||
|
||||
// check partial match
|
||||
for (cvar = cvar_vars; cvar; cvar = cvar->next)
|
||||
if (!strncmp (partial, cvar->name, len))
|
||||
return cvar->name;
|
||||
|
||||
// check aliases too :)
|
||||
for (alias = calias_vars; alias; alias = alias->next)
|
||||
if (!strncmp (partial, alias->name, len))
|
||||
return alias->name;
|
||||
|
||||
return NULL;
|
||||
return cvar_string (var);
|
||||
}
|
||||
|
||||
/*
|
||||
CVar_CompleteCountPossible
|
||||
typedef struct {
|
||||
const char *match;
|
||||
size_t match_len;
|
||||
int num_matches;
|
||||
} cvar_count_ctx_t;
|
||||
|
||||
static void
|
||||
cvar_match_count (void *ele, void *data)
|
||||
{
|
||||
cvar_count_ctx_t *ctx = data;
|
||||
const cvar_t *cvar = ele;
|
||||
|
||||
if (strncmp (cvar->name, ctx->match, ctx->match_len) == 0) {
|
||||
ctx->num_matches++;
|
||||
}
|
||||
}
|
||||
|
||||
New function for tab-completion system
|
||||
Added by EvilTypeGuy
|
||||
Thanks to Fett erich@heintz.com
|
||||
*/
|
||||
VISIBLE int
|
||||
Cvar_CompleteCountPossible (const char *partial)
|
||||
{
|
||||
cvar_t *cvar;
|
||||
int len;
|
||||
int h;
|
||||
cvar_count_ctx_t ctx = {
|
||||
.match = partial,
|
||||
.match_len = strlen (partial),
|
||||
.num_matches = 0,
|
||||
};
|
||||
|
||||
h = 0;
|
||||
len = strlen(partial);
|
||||
Hash_ForEach (cvar_hash, cvar_match_count, &ctx);
|
||||
Hash_ForEach (user_cvar_hash, cvar_match_count, &ctx);
|
||||
// this is a bit of a hack, but both cvar_alias_t and cvar_t have
|
||||
// name in the first file, so it will work out as that's the only
|
||||
// criteron for a match
|
||||
Hash_ForEach (calias_hash, cvar_match_count, &ctx);
|
||||
|
||||
if (!len)
|
||||
return 0;
|
||||
|
||||
// Loop through the cvars and count all possible matches
|
||||
for (cvar = cvar_vars; cvar; cvar = cvar->next)
|
||||
if (!strncmp(partial, cvar->name, len))
|
||||
h++;
|
||||
|
||||
return h;
|
||||
return ctx.num_matches;
|
||||
}
|
||||
|
||||
/*
|
||||
CVar_CompleteBuildList
|
||||
typedef struct {
|
||||
const char *match;
|
||||
size_t match_len;
|
||||
const char **list;
|
||||
int index;
|
||||
} cvar_copy_ctx_t;
|
||||
|
||||
New function for tab-completion system
|
||||
Added by EvilTypeGuy
|
||||
Thanks to Fett erich@heintz.com
|
||||
Thanks to taniwha
|
||||
*/
|
||||
VISIBLE const char **
|
||||
static void
|
||||
cvar_match_copy (void *ele, void *data)
|
||||
{
|
||||
cvar_copy_ctx_t *ctx = data;
|
||||
const cvar_t *cvar = ele;
|
||||
|
||||
if (strncmp (cvar->name, ctx->match, ctx->match_len) == 0) {
|
||||
ctx->list[ctx->index++] = cvar->name;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
cvar_cmp_name (const void *_a, const void *_b)
|
||||
{
|
||||
const char * const *a = _a;
|
||||
const char * const *b = _b;
|
||||
return strcmp (*a, *b);
|
||||
}
|
||||
|
||||
VISIBLE const char **
|
||||
Cvar_CompleteBuildList (const char *partial)
|
||||
{
|
||||
cvar_t *cvar;
|
||||
int len = 0;
|
||||
int bpos = 0;
|
||||
int sizeofbuf = (Cvar_CompleteCountPossible (partial) + 1) *
|
||||
sizeof (char *);
|
||||
const char **buf;
|
||||
int num_matches = Cvar_CompleteCountPossible (partial);
|
||||
|
||||
len = strlen(partial);
|
||||
buf = malloc(sizeofbuf + sizeof (char *));
|
||||
SYS_CHECKMEM (buf);
|
||||
// Loop through the alias list and print all matches
|
||||
for (cvar = cvar_vars; cvar; cvar = cvar->next)
|
||||
if (!strncmp(partial, cvar->name, len))
|
||||
buf[bpos++] = cvar->name;
|
||||
cvar_copy_ctx_t ctx = {
|
||||
.match = partial,
|
||||
.match_len = strlen (partial),
|
||||
.list = malloc((num_matches + 1) * sizeof (char *)),
|
||||
.index = 0,
|
||||
};
|
||||
|
||||
buf[bpos] = NULL;
|
||||
return buf;
|
||||
Hash_ForEach (cvar_hash, cvar_match_copy, &ctx);
|
||||
Hash_ForEach (user_cvar_hash, cvar_match_copy, &ctx);
|
||||
// this is a bit of a hack, but both cvar_alias_t and cvar_t have
|
||||
// name in the first file, so it will work out as that's the only
|
||||
// criteron for a match
|
||||
Hash_ForEach (calias_hash, cvar_match_copy, &ctx);
|
||||
ctx.list[ctx.index] = 0;
|
||||
fprintf (stderr, "%d %d\n", num_matches, ctx.index);
|
||||
heapsort (ctx.list, ctx.index, sizeof (char *), cvar_cmp_name);
|
||||
return ctx.list;
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
|
@ -267,47 +354,74 @@ Cvar_RemoveListener (cvar_t *cvar, cvar_listener_t listener, void *data)
|
|||
}
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
Cvar_Set (cvar_t *var, const char *value)
|
||||
static int
|
||||
cvar_setvar (cvar_t *var, const char *value)
|
||||
{
|
||||
int changed;
|
||||
int vals;
|
||||
int changed = 0;
|
||||
|
||||
if (!var)
|
||||
return;
|
||||
if (!var->value.type) {
|
||||
char **str_value = var->value.value;
|
||||
changed = !*str_value || !strequal (*str_value, value);
|
||||
if (var->validator) {
|
||||
changed = changed && var->validator (var);
|
||||
}
|
||||
if (changed) {
|
||||
free (*str_value);
|
||||
*str_value = strdup (value);
|
||||
}
|
||||
} else {
|
||||
exprenum_t *enm = var->value.type->data;
|
||||
exprctx_t context = {
|
||||
.memsuper = new_memsuper (),
|
||||
.symtab = enm ? enm->symtab : 0,
|
||||
.msg_prefix = var->name,
|
||||
};
|
||||
if (context.symtab && !context.symtab->tab) {
|
||||
cexpr_init_symtab (context.symtab, &context);
|
||||
}
|
||||
context.result = cexpr_value (var->value.type, &context);
|
||||
if (!cexpr_eval_string (value, &context)) {
|
||||
changed = memcmp (context.result->value, var->value.value,
|
||||
var->value.type->size) != 0;
|
||||
if (var->validator) {
|
||||
changed = changed && var->validator (var);
|
||||
}
|
||||
if (changed) {
|
||||
memcpy (var->value.value, context.result->value,
|
||||
var->value.type->size);
|
||||
}
|
||||
}
|
||||
delete_memsuper (context.memsuper);
|
||||
}
|
||||
|
||||
if (changed && var->listeners) {
|
||||
LISTENER_INVOKE (var->listeners, var);
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
Cvar_SetVar (cvar_t *var, const char *value)
|
||||
{
|
||||
if (var->flags & CVAR_ROM) {
|
||||
Sys_MaskPrintf (SYS_dev, "Cvar \"%s\" is read-only, cannot modify\n",
|
||||
var->name);
|
||||
return;
|
||||
}
|
||||
|
||||
changed = !strequal (var->string, value);
|
||||
if (changed) {
|
||||
free ((char*)var->string); // free the old value string
|
||||
|
||||
var->string = strdup (value);
|
||||
var->value = atof (var->string);
|
||||
var->int_val = atoi (var->string);
|
||||
VectorZero (var->vec);
|
||||
vals = sscanf (var->string, "%f %f %f",
|
||||
&var->vec[0], &var->vec[1], &var->vec[2]);
|
||||
if (vals == 1)
|
||||
var->vec[2] = var->vec[1] = var->vec[0];
|
||||
|
||||
if (var->callback)
|
||||
var->callback (var);
|
||||
|
||||
if (var->listeners) {
|
||||
LISTENER_INVOKE (var->listeners, var);
|
||||
}
|
||||
}
|
||||
cvar_setvar (var, value);
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
Cvar_SetValue (cvar_t *var, float value)
|
||||
Cvar_Set (const char *var_name, const char *value)
|
||||
{
|
||||
Cvar_Set (var, va (0, "%.9g", value));
|
||||
cvar_t *var;
|
||||
|
||||
var = Cvar_FindVar (var_name);
|
||||
|
||||
if (!var)
|
||||
return;
|
||||
|
||||
Cvar_SetVar (var, value);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -329,14 +443,25 @@ Cvar_Command (void)
|
|||
|
||||
// perform a variable print or set
|
||||
if (Cmd_Argc () == 1) {
|
||||
Sys_Printf ("\"%s\" is \"%s\"\n", v->name, v->string);
|
||||
Sys_Printf ("\"%s\" is \"%s\"\n", v->name, cvar_string (v));
|
||||
return true;
|
||||
}
|
||||
|
||||
Cvar_Set (v, Cmd_Argv (1));
|
||||
Cvar_SetVar (v, Cmd_Argv (1));
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
cvar_write_variable (void *ele, void *data)
|
||||
{
|
||||
cvar_t *cvar = ele;
|
||||
QFile *f = data;
|
||||
|
||||
if (cvar->flags & CVAR_ARCHIVE) {
|
||||
Qprintf (f, "seta %s \"%s\"\n", cvar->name, cvar_string (cvar));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Cvar_WriteVariables
|
||||
|
||||
|
@ -346,11 +471,19 @@ Cvar_Command (void)
|
|||
VISIBLE void
|
||||
Cvar_WriteVariables (QFile *f)
|
||||
{
|
||||
cvar_t *var;
|
||||
Hash_ForEach (cvar_hash, cvar_write_variable, f);
|
||||
Hash_ForEach (user_cvar_hash, cvar_write_variable, f);
|
||||
}
|
||||
|
||||
for (var = cvar_vars; var; var = var->next)
|
||||
if (var->flags & CVAR_ARCHIVE)
|
||||
Qprintf (f, "seta %s \"%s\"\n", var->name, var->string);
|
||||
static void
|
||||
cvar_write_config (void *ele, void *data)
|
||||
{
|
||||
cvar_t *cvar = ele;
|
||||
plitem_t *cfg = data;
|
||||
|
||||
if (cvar->flags & CVAR_ARCHIVE) {
|
||||
PL_D_AddObject (cfg, cvar->name, PL_NewString (cvar_string (cvar)));
|
||||
}
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
|
@ -358,11 +491,8 @@ Cvar_SaveConfig (plitem_t *config)
|
|||
{
|
||||
plitem_t *cvars = PL_NewDictionary (0); //FIXME hashlinks
|
||||
PL_D_AddObject (config, "cvars", cvars);
|
||||
for (cvar_t *var = cvar_vars; var; var = var->next) {
|
||||
if (var->flags & CVAR_ARCHIVE) {
|
||||
PL_D_AddObject (cvars, var->name, PL_NewString (var->string));
|
||||
}
|
||||
}
|
||||
Hash_ForEach (cvar_hash, cvar_write_config, cvars);
|
||||
Hash_ForEach (user_cvar_hash, cvar_write_config, cvars);
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
|
@ -379,79 +509,16 @@ Cvar_LoadConfig (plitem_t *config)
|
|||
if (value) {
|
||||
cvar_t *var = Cvar_FindVar (cvar_name);
|
||||
if (var) {
|
||||
Cvar_Set (var, value);
|
||||
Cvar_SetFlags (var, var->flags | CVAR_ARCHIVE);
|
||||
Cvar_SetVar (var, value);
|
||||
var->flags |= CVAR_ARCHIVE;
|
||||
} else {
|
||||
Cvar_Get (cvar_name, value, CVAR_USER_CREATED | CVAR_ARCHIVE,
|
||||
0, USER_CVAR);
|
||||
var = cvar_create (cvar_name, value);
|
||||
var->flags |= CVAR_ARCHIVE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define SYS_DEVELOPER(developer) #developer,
|
||||
static const char *developer_flags[] = {
|
||||
"dev",
|
||||
#include "QF/sys_developer.h"
|
||||
0
|
||||
};
|
||||
|
||||
static int
|
||||
parse_developer_flag (const char *flag)
|
||||
{
|
||||
const char **devflag;
|
||||
char *end;
|
||||
int val;
|
||||
|
||||
val = strtol (flag, &end, 0);
|
||||
if (!*end) {
|
||||
return val;
|
||||
}
|
||||
for (devflag = developer_flags; *devflag; devflag++) {
|
||||
if (!strcmp (*devflag, flag)) {
|
||||
return 1 << (devflag - developer_flags);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
developer_f (cvar_t *var)
|
||||
{
|
||||
char *buf = alloca (strlen (var->string) + 1);
|
||||
const char *s;
|
||||
char *b;
|
||||
char c;
|
||||
int parse = 0;
|
||||
|
||||
for (s = var->string; *s; s++) {
|
||||
if (isalpha (*s) || *s == '|') {
|
||||
parse = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!parse) {
|
||||
return;
|
||||
}
|
||||
var->int_val = 0;
|
||||
for (s = var->string, b = buf; (c = *s++); ) {
|
||||
if (isspace (c)) {
|
||||
continue;
|
||||
}
|
||||
if (c == '|') {
|
||||
*b = 0;
|
||||
var->int_val |= parse_developer_flag (buf);
|
||||
b = buf;
|
||||
continue;
|
||||
}
|
||||
*b++ = c;
|
||||
}
|
||||
if (b != buf) {
|
||||
*b = 0;
|
||||
var->int_val |= parse_developer_flag (buf);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_cvar (const char *cmd, int orflags)
|
||||
{
|
||||
|
@ -477,12 +544,12 @@ set_cvar (const char *cmd, int orflags)
|
|||
"Cvar \"%s\" is read-only, cannot modify\n",
|
||||
var_name);
|
||||
} else {
|
||||
Cvar_Set (var, value);
|
||||
Cvar_SetFlags (var, var->flags | orflags);
|
||||
Cvar_SetVar (var, value);
|
||||
var->flags |= orflags;
|
||||
}
|
||||
} else {
|
||||
Cvar_Get (var_name, value, CVAR_USER_CREATED | orflags, NULL,
|
||||
USER_CVAR);
|
||||
var = cvar_create (var_name, value);
|
||||
var->flags |= orflags;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -523,11 +590,23 @@ Cvar_Inc_f (void)
|
|||
var = Cvar_FindVar (name);
|
||||
if (!var)
|
||||
var = Cvar_FindAlias (name);
|
||||
if (!var)
|
||||
if (!var) {
|
||||
Sys_Printf ("Unknown variable \"%s\"\n", name);
|
||||
return;
|
||||
}
|
||||
if (var->flags & CVAR_ROM) {
|
||||
Sys_Printf ("Variable \"%s\" is read-only\n", name);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
Cvar_SetValue (var, var->value + inc);
|
||||
if (var->value.type == &cexpr_float) {
|
||||
*(float *) var->value.value += inc;
|
||||
} else if (var->value.type == &cexpr_int) {
|
||||
*(int *) var->value.value += inc;
|
||||
} else {
|
||||
Sys_Printf ("Variable \"%s\" cannot be incremented\n", name);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -547,8 +626,12 @@ Cvar_Toggle_f (void)
|
|||
Sys_Printf ("Unknown variable \"%s\"\n", Cmd_Argv (1));
|
||||
return;
|
||||
}
|
||||
if ((var->flags & CVAR_ROM) || var->value.type != &cexpr_int) {
|
||||
Sys_Printf ("Variable \"%s\" cannot be toggled\n", Cmd_Argv (1));
|
||||
return;
|
||||
}
|
||||
|
||||
Cvar_Set (var, var->int_val ? "0" : "1");
|
||||
*(int *) var->value.value = !*(int *) var->value.value;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -569,8 +652,7 @@ Cvar_Cycle_f (void)
|
|||
if (!var)
|
||||
var = Cvar_FindAlias (name);
|
||||
if (!var) {
|
||||
var = Cvar_Get (name, Cmd_Argv (Cmd_Argc () - 1), CVAR_USER_CREATED,
|
||||
0, USER_CVAR);
|
||||
var = cvar_create (name, Cmd_Argv (Cmd_Argc () - 1));
|
||||
}
|
||||
|
||||
// loop through the args until you find one that matches the current cvar
|
||||
|
@ -583,27 +665,22 @@ Cvar_Cycle_f (void)
|
|||
// it won't match on zero when it should, but after that, it will be
|
||||
// comparing string that all had the same source (the user) so it will
|
||||
// work.
|
||||
if (atof (Cmd_Argv (i)) == 0) {
|
||||
if (!strcmp (Cmd_Argv (i), var->string))
|
||||
break;
|
||||
} else {
|
||||
if (atof (Cmd_Argv (i)) == var->value)
|
||||
break;
|
||||
}
|
||||
if (!strcmp (Cmd_Argv (i), cvar_string (var)))
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == Cmd_Argc ())
|
||||
Cvar_Set (var, Cmd_Argv (2)); // no match
|
||||
Cvar_SetVar (var, Cmd_Argv (2)); // no match
|
||||
else if (i + 1 == Cmd_Argc ())
|
||||
Cvar_Set (var, Cmd_Argv (2)); // matched last value in list
|
||||
Cvar_SetVar (var, Cmd_Argv (2)); // matched last value in list
|
||||
else
|
||||
Cvar_Set (var, Cmd_Argv (i + 1)); // matched earlier in list
|
||||
Cvar_SetVar (var, Cmd_Argv (i + 1)); // matched earlier in list
|
||||
}
|
||||
|
||||
static void
|
||||
Cvar_Reset (cvar_t *var)
|
||||
{
|
||||
Cvar_Set (var, var->default_string);
|
||||
Cvar_SetVar (var, var->default_value);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -630,54 +707,59 @@ Cvar_Reset_f (void)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cvar_reset_var (void *ele, void *data)
|
||||
{
|
||||
cvar_t *var = ele;
|
||||
if (!(var->flags & CVAR_ROM))
|
||||
Cvar_Reset (var);
|
||||
}
|
||||
|
||||
static void
|
||||
Cvar_ResetAll_f (void)
|
||||
{
|
||||
cvar_t *var;
|
||||
Hash_ForEach (cvar_hash, cvar_reset_var, 0);
|
||||
}
|
||||
|
||||
for (var = cvar_vars; var; var = var->next)
|
||||
if (!(var->flags & CVAR_ROM))
|
||||
Cvar_Reset (var);
|
||||
static int
|
||||
cvar_cmp (const void *_a, const void *_b)
|
||||
{
|
||||
const cvar_t * const *a = _a;
|
||||
const cvar_t * const *b = _b;
|
||||
return strcmp ((*a)->name, (*b)->name);
|
||||
}
|
||||
|
||||
static void
|
||||
Cvar_CvarList_f (void)
|
||||
{
|
||||
cvar_t *var;
|
||||
int i;
|
||||
int showhelp = 0;
|
||||
const char *flags;
|
||||
|
||||
if (Cmd_Argc () > 1) {
|
||||
showhelp = 1;
|
||||
if (strequal (Cmd_Argv (1), "cfg"))
|
||||
showhelp++;
|
||||
}
|
||||
for (var = cvar_vars, i = 0; var; var = var->next, i++) {
|
||||
flags = va (0, "%c%c%c%c",
|
||||
var->flags & CVAR_ROM ? 'r' : ' ',
|
||||
var->flags & CVAR_ARCHIVE ? '*' : ' ',
|
||||
var->flags & CVAR_USERINFO ? 'u' : ' ',
|
||||
var->flags & CVAR_SERVERINFO ? 's' : ' ');
|
||||
|
||||
void **cvar_list = Hash_GetList (cvar_hash);
|
||||
int num_vars = Hash_NumElements (cvar_hash);
|
||||
heapsort (cvar_list, num_vars, sizeof (void *), cvar_cmp);
|
||||
|
||||
for (cvar_t **cvar = (cvar_t **) cvar_list; *cvar; cvar++) {
|
||||
cvar_t *var = *cvar;
|
||||
const char *flags = va (0, "%c%c%c%c",
|
||||
var->flags & CVAR_ROM ? 'r' : ' ',
|
||||
var->flags & CVAR_ARCHIVE ? '*' : ' ',
|
||||
var->flags & CVAR_USERINFO ? 'u' : ' ',
|
||||
var->flags & CVAR_SERVERINFO ? 's' : ' ');
|
||||
if (showhelp == 2)
|
||||
Sys_Printf ("//%s %s\n%s \"%s\"\n\n", flags, var->description,
|
||||
var->name, var->string);
|
||||
var->name, cvar_string (var));
|
||||
else if (showhelp)
|
||||
Sys_Printf ("%s %-20s : %s\n", flags, var->name, var->description);
|
||||
else
|
||||
Sys_Printf ("%s %s\n", flags, var->name);
|
||||
}
|
||||
|
||||
Sys_Printf ("------------\n%d variables\n", i);
|
||||
}
|
||||
|
||||
static void
|
||||
cvar_free (void *c, void *unused)
|
||||
{
|
||||
cvar_t *cvar = (cvar_t*)c;
|
||||
free ((char*)cvar->name);
|
||||
free ((char*)cvar->string);
|
||||
free (cvar);
|
||||
Sys_Printf ("------------\n%d variables\n", num_vars);
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
@ -705,15 +787,15 @@ calias_get_key (const void *c, void *unused)
|
|||
VISIBLE void
|
||||
Cvar_Init_Hash (void)
|
||||
{
|
||||
cvar_hash = Hash_NewTable (1021, cvar_get_key, cvar_free, 0, 0);
|
||||
cvar_hash = Hash_NewTable (1021, cvar_get_key, 0, 0, 0);
|
||||
user_cvar_hash = Hash_NewTable (1021, cvar_get_key, 0, 0, 0);
|
||||
calias_hash = Hash_NewTable (1021, calias_get_key, calias_free, 0, 0);
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
Cvar_Init (void)
|
||||
{
|
||||
developer = Cvar_Get ("developer", "0", CVAR_NONE, developer_f,
|
||||
"set to enable extra debugging information");
|
||||
Cvar_Register (&developer_cvar, 0, 0);
|
||||
|
||||
Cmd_AddCommand ("set", Cvar_Set_f, "Set the selected variable, useful on "
|
||||
"the command line (+set variablename setting)");
|
||||
|
@ -732,66 +814,36 @@ Cvar_Init (void)
|
|||
Cmd_AddCommand ("resetall", Cvar_ResetAll_f, "Reset all cvars");
|
||||
}
|
||||
|
||||
VISIBLE cvar_t *
|
||||
Cvar_Get (const char *name, const char *string, int cvarflags,
|
||||
void (*callback)(cvar_t*), const char *description)
|
||||
VISIBLE void
|
||||
Cvar_Register (cvar_t *var, cvar_listener_t listener, void *data)
|
||||
{
|
||||
int changed = 0;
|
||||
cvar_t *var;
|
||||
cvar_t *user_var;
|
||||
|
||||
if (Cmd_Exists (name)) {
|
||||
Sys_Printf ("Cvar_Get: %s is a command\n", name);
|
||||
return NULL;
|
||||
if (Cmd_Exists (var->name)) {
|
||||
Sys_Printf ("Cvar_Get: %s is a command\n", var->name);
|
||||
return;
|
||||
}
|
||||
if (var->flags & CVAR_REGISTERED) {
|
||||
Sys_Error ("Cvar %s already registered", var->name);
|
||||
}
|
||||
var = Cvar_FindVar (name);
|
||||
if (!var) {
|
||||
cvar_t **v;
|
||||
var = (cvar_t *) calloc (1, sizeof (cvar_t));
|
||||
|
||||
// Cvar doesn't exist, so we create it
|
||||
var->name = strdup (name);
|
||||
var->string = strdup (string);
|
||||
var->default_string = strdup (string);
|
||||
var->flags = cvarflags;
|
||||
var->callback = callback;
|
||||
var->description = description;
|
||||
var->value = atof (var->string);
|
||||
var->int_val = atoi (var->string);
|
||||
sscanf (var->string, "%f %f %f",
|
||||
&var->vec[0], &var->vec[1], &var->vec[2]);
|
||||
Hash_Add (cvar_hash, var);
|
||||
|
||||
for (v = &cvar_vars; *v; v = &(*v)->next)
|
||||
if (strcmp ((*v)->name, var->name) >= 0)
|
||||
break;
|
||||
var->next = *v;
|
||||
*v = var;
|
||||
|
||||
changed = 1;
|
||||
if ((user_var = Hash_Find (user_cvar_hash, var->name))) {
|
||||
cvar_setvar (var, cvar_string (user_var));
|
||||
cvar_destroy (user_var);
|
||||
} else {
|
||||
// Cvar does exist, so we update the flags and return.
|
||||
var->flags &= ~CVAR_USER_CREATED;
|
||||
var->flags |= cvarflags;
|
||||
changed = !strequal (var->string, string) || var->callback != callback;
|
||||
if (!var->callback)
|
||||
var->callback = callback;
|
||||
if (!var->description
|
||||
|| strequal (var->description, USER_RO_CVAR)
|
||||
|| strequal (var->description, USER_CVAR))
|
||||
var->description = description;
|
||||
if (!var->default_string)
|
||||
var->default_string = strdup (string);
|
||||
cvar_setvar (var, var->default_value);
|
||||
}
|
||||
if (changed) {
|
||||
if (var->callback)
|
||||
var->callback (var);
|
||||
var->flags |= CVAR_REGISTERED;
|
||||
|
||||
if (var->listeners) {
|
||||
LISTENER_INVOKE (var->listeners, var);
|
||||
}
|
||||
if (listener) {
|
||||
Cvar_AddListener (var, listener, data);
|
||||
}
|
||||
|
||||
return var;
|
||||
Hash_Add (cvar_hash, var);
|
||||
|
||||
if (var->listeners) {
|
||||
LISTENER_INVOKE (var->listeners, var);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -807,3 +859,38 @@ Cvar_SetFlags (cvar_t *var, int cvarflags)
|
|||
|
||||
var->flags = cvarflags;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
cvar_select_t select;
|
||||
void *data;
|
||||
const cvar_t **list;
|
||||
int index;
|
||||
} cvar_select_ctx_t;
|
||||
|
||||
static void
|
||||
cvar_select (void *ele, void *data)
|
||||
{
|
||||
const cvar_t *cvar = ele;
|
||||
cvar_select_ctx_t *ctx = data;
|
||||
|
||||
if (ctx->select (cvar, ctx->data)) {
|
||||
ctx->list[ctx->index++] = cvar;
|
||||
}
|
||||
}
|
||||
|
||||
VISIBLE const cvar_t **
|
||||
Cvar_Select (cvar_select_t select, void *data)
|
||||
{
|
||||
int num_cvars = Hash_NumElements (cvar_hash)
|
||||
+ Hash_NumElements (user_cvar_hash);
|
||||
cvar_select_ctx_t ctx = {
|
||||
.select = select,
|
||||
.data = data,
|
||||
.list = malloc ((num_cvars + 1) * sizeof (cvar_t *)),
|
||||
.index = 0,
|
||||
};
|
||||
Hash_ForEach (cvar_hash, cvar_select, &ctx);
|
||||
Hash_ForEach (user_cvar_hash, cvar_select, &ctx);
|
||||
ctx.list[num_cvars] = 0;
|
||||
return ctx.list;
|
||||
}
|
||||
|
|
|
@ -447,6 +447,43 @@ Hash_GetList (hashtab_t *tab)
|
|||
return list;
|
||||
}
|
||||
|
||||
VISIBLE void **
|
||||
Hash_Select (hashtab_t *tab, hash_select_t select, void *data)
|
||||
{
|
||||
void **list;
|
||||
void **l;
|
||||
size_t ind;
|
||||
|
||||
l = list = malloc ((tab->num_ele + 1) * sizeof (void *));
|
||||
if (!list)
|
||||
return 0;
|
||||
for (ind = 0; ind < tab->tab_size; ind++) {
|
||||
hashlink_t *lnk;
|
||||
|
||||
for (lnk = tab->tab[ind]; lnk; lnk = lnk->next) {
|
||||
if (select (lnk->data, data)) {
|
||||
*l++ = lnk->data;
|
||||
}
|
||||
}
|
||||
}
|
||||
*l++ = 0;
|
||||
return list;
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
Hash_ForEach (hashtab_t *tab, hash_action_t action, void *data)
|
||||
{
|
||||
size_t ind;
|
||||
|
||||
for (ind = 0; ind < tab->tab_size; ind++) {
|
||||
hashlink_t *lnk;
|
||||
|
||||
for (lnk = tab->tab[ind]; lnk; lnk = lnk->next) {
|
||||
action (lnk->data, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline double
|
||||
sqr (double x)
|
||||
{
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue