mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-30 20:50:42 +00:00
start merging stuff into libs/util and fix the concequences in nq. nq doesn't
build yet though (keys.c, *screen.c and *view.c) due to console fun.
This commit is contained in:
parent
9a47e3c92c
commit
95f6db7775
85 changed files with 4016 additions and 1083 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
|
.vimrc
|
||||||
ChangeLog
|
ChangeLog
|
||||||
Makefile
|
Makefile
|
||||||
Makefile.in
|
Makefile.in
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
## Process this file with automake to produce Makefile.in
|
## Process this file with automake to produce Makefile.in
|
||||||
AUTOMAKE_OPTIONS= foreign
|
AUTOMAKE_OPTIONS= foreign
|
||||||
|
|
||||||
SUBDIRS= include qw nq
|
SUBDIRS= include libs qw nq
|
||||||
|
|
||||||
EXTRA_DIST= ChangeLog RPM/build_rpm.in \
|
EXTRA_DIST= ChangeLog RPM/build_rpm.in \
|
||||||
tools/gas2masm/Makefile tools/gas2masm/gas2masm.c \
|
tools/gas2masm/Makefile tools/gas2masm/gas2masm.c \
|
||||||
|
|
|
@ -1415,6 +1415,8 @@ AC_OUTPUT(
|
||||||
doc/texinfo/Makefile
|
doc/texinfo/Makefile
|
||||||
doc/man/Makefile
|
doc/man/Makefile
|
||||||
include/Makefile
|
include/Makefile
|
||||||
|
libs/Makefile
|
||||||
|
libs/util/Makefile
|
||||||
qw/include/Makefile
|
qw/include/Makefile
|
||||||
qw/include/win32/version.h
|
qw/include/win32/version.h
|
||||||
qw/source/Makefile
|
qw/source/Makefile
|
||||||
|
|
147
include/cmd.h
Normal file
147
include/cmd.h
Normal file
|
@ -0,0 +1,147 @@
|
||||||
|
/*
|
||||||
|
cmd.h
|
||||||
|
|
||||||
|
Command buffer and command execution
|
||||||
|
|
||||||
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __cmd_h
|
||||||
|
#define __cmd_h
|
||||||
|
|
||||||
|
#include "qtypes.h"
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Any number of commands can be added in a frame, from several different sources.
|
||||||
|
Most commands come from either keybindings or console line input, but remote
|
||||||
|
servers can also send across commands and entire text files can be execed.
|
||||||
|
|
||||||
|
The + command line options are also added to the command buffer.
|
||||||
|
|
||||||
|
The game starts with a Cbuf_AddText ("exec quake.rc\n"); Cbuf_Execute ();
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
void Cbuf_Init (void);
|
||||||
|
// allocates an initial text buffer that will grow as needed
|
||||||
|
|
||||||
|
void Cbuf_AddText (char *text);
|
||||||
|
// as new commands are generated from the console or keybindings,
|
||||||
|
// the text is added to the end of the command buffer.
|
||||||
|
|
||||||
|
void Cbuf_InsertText (char *text);
|
||||||
|
// when a command wants to issue other commands immediately, the text is
|
||||||
|
// inserted at the beginning of the buffer, before any remaining unexecuted
|
||||||
|
// commands.
|
||||||
|
|
||||||
|
void Cbuf_Execute (void);
|
||||||
|
// Pulls off \n terminated lines of text from the command buffer and sends
|
||||||
|
// them through Cmd_ExecuteString. Stops when the buffer is empty.
|
||||||
|
// Normally called once per frame, but may be explicitly invoked.
|
||||||
|
// Do not call inside a command function!
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Command execution takes a null terminated string, breaks it into tokens,
|
||||||
|
then searches for a command or variable that matches the first token.
|
||||||
|
|
||||||
|
Commands can come from three sources, but the handler functions may choose
|
||||||
|
to dissallow the action or forward it to a remote server if the source is
|
||||||
|
not apropriate.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef void (*xcommand_t) (void);
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
src_client, // came in over a net connection as a clc_stringcmd
|
||||||
|
// host_client will be valid during this state.
|
||||||
|
src_command, // from the command buffer
|
||||||
|
} cmd_source_t;
|
||||||
|
|
||||||
|
extern cmd_source_t cmd_source;
|
||||||
|
|
||||||
|
void Cmd_Init_Hash (void);
|
||||||
|
void Cmd_Init (void);
|
||||||
|
void cl_Cmd_Init (void);
|
||||||
|
|
||||||
|
void Cmd_AddCommand (char *cmd_name, xcommand_t function, char *description);
|
||||||
|
// called by the init functions of other parts of the program to
|
||||||
|
// register commands and functions to call for them.
|
||||||
|
// The cmd_name is referenced later, so it should not be in temp memory
|
||||||
|
// if function is NULL, the command will be forwarded to the server
|
||||||
|
// as a clc_stringcmd instead of executed locally
|
||||||
|
|
||||||
|
qboolean Cmd_Exists (char *cmd_name);
|
||||||
|
// used by the cvar code to check for cvar / command name overlap
|
||||||
|
|
||||||
|
char *Cmd_CompleteCommand (char *partial);
|
||||||
|
// attempts to match a partial command for automatic command line completion
|
||||||
|
// returns NULL if nothing fits
|
||||||
|
|
||||||
|
int Cmd_Argc (void);
|
||||||
|
char *Cmd_Argv (int arg);
|
||||||
|
char *Cmd_Args (void);
|
||||||
|
// The functions that execute commands get their parameters with these
|
||||||
|
// functions. Cmd_Argv () will return an empty string, not a NULL
|
||||||
|
// if arg > argc, so string operations are allways safe.
|
||||||
|
|
||||||
|
int Cmd_CheckParm (char *parm);
|
||||||
|
// Returns the position (1 to argc-1) in the command's argument list
|
||||||
|
// where the given parameter apears, or 0 if not present
|
||||||
|
|
||||||
|
void Cmd_TokenizeString (char *text);
|
||||||
|
// Takes a null terminated string. Does not need to be /n terminated.
|
||||||
|
// breaks the string up into arg tokens.
|
||||||
|
|
||||||
|
void Cmd_ExecuteString (char *text);
|
||||||
|
// Parses a single line of text into arguments and tries to execute it
|
||||||
|
// as if it was typed at the console
|
||||||
|
void Cmd_ExecuteString_src (char *text, cmd_source_t src);
|
||||||
|
// Parses a single line of text into arguments and tries to execute it.
|
||||||
|
// The text can come from the command buffer, a remote client, or stdin.
|
||||||
|
|
||||||
|
|
||||||
|
void Cmd_ForwardToServer (void);
|
||||||
|
// adds the current command line as a clc_stringcmd to the client message.
|
||||||
|
// things like godmode, noclip, etc, are commands directed to the server,
|
||||||
|
// so when they are typed in at the console, they will need to be forwarded.
|
||||||
|
|
||||||
|
void Cmd_StuffCmds_f (void);
|
||||||
|
|
||||||
|
void Cbuf_Execute_Sets (void);
|
||||||
|
void Cmd_Exec_File (char *path);
|
||||||
|
|
||||||
|
#define MAX_COM_TOKEN 1024
|
||||||
|
extern char com_token[MAX_COM_TOKEN];
|
||||||
|
char *COM_Parse (char *data);
|
||||||
|
|
||||||
|
extern struct cvar_s *cl_warncmd;
|
||||||
|
|
||||||
|
#endif // __cmd_h
|
91
include/compat.h
Normal file
91
include/compat.h
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
/*
|
||||||
|
compat.h
|
||||||
|
|
||||||
|
Miscellaneous compability stuff
|
||||||
|
|
||||||
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __compat_h
|
||||||
|
#define __compat_h
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STDARG_H
|
||||||
|
# include <stdarg.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
|
# include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#ifndef max
|
||||||
|
# define max(a,b) ((a) > (b) ? (a) : (b))
|
||||||
|
#endif
|
||||||
|
#ifndef min
|
||||||
|
# define min(a,b) ((a) < (b) ? (a) : (b))
|
||||||
|
#endif
|
||||||
|
#ifndef bound
|
||||||
|
# define bound(a,b,c) (max(a, min(b, c)))
|
||||||
|
#endif
|
||||||
|
/* This fixes warnings when compiling with -pedantic */
|
||||||
|
#if defined(__GNUC__) && !defined(inline)
|
||||||
|
# define inline __inline__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* These may be underscored... */
|
||||||
|
#if !defined(HAVE_SNPRINTF) && defined(HAVE__SNPRINTF)
|
||||||
|
# define snprintf _snprintf
|
||||||
|
#endif
|
||||||
|
#if !defined(HAVE_VSNPRINTF) && defined(HAVE__VSNPRINTF)
|
||||||
|
# define vsnprintf _vsnprintf
|
||||||
|
#endif
|
||||||
|
#if defined(_WIN32) && !defined(__BORLANDC__)
|
||||||
|
# define kbhit _kbhit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* If we don't have them in the C-library we declare them to avoid warnings */
|
||||||
|
#if ! (defined(HAVE_SNPRINTF) || defined(HAVE__SNPRINTF))
|
||||||
|
extern int snprintf(char * s, size_t maxlen, const char *format, ...);
|
||||||
|
#endif
|
||||||
|
#if ! (defined(HAVE_VSNPRINTF) || defined(HAVE__VSNPRINTF))
|
||||||
|
extern int vsnprintf(char *s, size_t maxlen, const char *format, va_list arg);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* String utility functions */
|
||||||
|
#if !defined(strequal)
|
||||||
|
# define strequal(a,b) (strcmp (a, b) == 0)
|
||||||
|
#endif
|
||||||
|
#if !defined(strcaseequal)
|
||||||
|
# define strcaseequal(a,b) (strcasecmp (a, b) == 0)
|
||||||
|
#endif
|
||||||
|
#if !defined(strnequal)
|
||||||
|
# define strnequal(a,b,c) (strncmp (a, b, c) == 0)
|
||||||
|
#endif
|
||||||
|
#if !defined(strncaseequal)
|
||||||
|
# define strncaseequal(a,b,c) (strncasecmp (a, b, c) == 0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // __compat_h
|
75
include/console.h
Normal file
75
include/console.h
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
console.h
|
||||||
|
|
||||||
|
Console definitions and prototypes
|
||||||
|
|
||||||
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __console_h
|
||||||
|
#define __console_h
|
||||||
|
//
|
||||||
|
// console
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "qtypes.h"
|
||||||
|
#include "gcc_attr.h"
|
||||||
|
|
||||||
|
#define CON_TEXTSIZE 16384
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
char text[CON_TEXTSIZE];
|
||||||
|
int current; // line where next message will be printed
|
||||||
|
int x; // offset in current line for next print
|
||||||
|
int display; // bottom of console displays this line
|
||||||
|
int numlines; // number of non-blank text lines, used for backscroling
|
||||||
|
} console_t;
|
||||||
|
|
||||||
|
extern console_t con_main;
|
||||||
|
extern console_t con_chat;
|
||||||
|
extern console_t *con; // point to either con_main or con_chat
|
||||||
|
|
||||||
|
extern int con_ormask;
|
||||||
|
|
||||||
|
extern int con_totallines;
|
||||||
|
extern qboolean con_initialized;
|
||||||
|
extern byte *con_chars;
|
||||||
|
extern int con_notifylines; // scan lines to clear for notify lines
|
||||||
|
|
||||||
|
void Con_DrawCharacter (int cx, int line, int num);
|
||||||
|
|
||||||
|
void Con_CheckResize (void);
|
||||||
|
void Con_Init (void);
|
||||||
|
void Con_Init_Cvars (void);
|
||||||
|
void Con_DrawConsole (int lines);
|
||||||
|
void Con_Print (char *txt);
|
||||||
|
void Con_Printf (char *fmt, ...) __attribute__((format(printf,1,2)));
|
||||||
|
void Con_DPrintf (char *fmt, ...) __attribute__((format(printf,1,2)));
|
||||||
|
void Con_Clear_f (void);
|
||||||
|
void Con_DrawNotify (void);
|
||||||
|
void Con_ClearNotify (void);
|
||||||
|
void Con_ToggleConsole_f (void);
|
||||||
|
|
||||||
|
extern struct cvar_s *developer;
|
||||||
|
|
||||||
|
#endif // __console_h
|
|
@ -26,8 +26,8 @@
|
||||||
$Id$
|
$Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _CVAR_H
|
#ifndef __cvar_h
|
||||||
#define _CVAR_H
|
#define __cvar_h
|
||||||
|
|
||||||
#include "qtypes.h"
|
#include "qtypes.h"
|
||||||
#include "quakeio.h"
|
#include "quakeio.h"
|
||||||
|
@ -118,4 +118,4 @@ void Cvar_Shutdown();
|
||||||
|
|
||||||
extern cvar_t *cvar_vars;
|
extern cvar_t *cvar_vars;
|
||||||
|
|
||||||
#endif // _CVAR_H
|
#endif // __cvar_h
|
36
include/gcc_attr.h
Normal file
36
include/gcc_attr.h
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
gcc_attr.h
|
||||||
|
|
||||||
|
GCC __attribute__ protection for lame compilers.
|
||||||
|
|
||||||
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __gcc_attr_h
|
||||||
|
#define __gcc_attr_h
|
||||||
|
|
||||||
|
#ifndef __GNUC__
|
||||||
|
# define __attribute__(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // __gcc_attr_h
|
54
include/hash.h
Normal file
54
include/hash.h
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
hash.h
|
||||||
|
|
||||||
|
hash tables
|
||||||
|
|
||||||
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
|
Copyright (C) 2000 Marcus Sundberg <mackan@stacken.kth.se>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __hash_h
|
||||||
|
#define __hash_h
|
||||||
|
|
||||||
|
#include <stdlib.h> // should be sys/types.h, but bc is stupid
|
||||||
|
|
||||||
|
typedef struct hashlink_s {
|
||||||
|
struct hashlink_s *next;
|
||||||
|
struct hashlink_s **prev;
|
||||||
|
void *data;
|
||||||
|
} hashlink_t;
|
||||||
|
|
||||||
|
typedef struct hashtab_s {
|
||||||
|
size_t tab_size;
|
||||||
|
char *(*get_key)(void*);
|
||||||
|
void (*free_ele)(void*);
|
||||||
|
hashlink_t *tab[ZERO_LENGTH_ARRAY];
|
||||||
|
} hashtab_t;
|
||||||
|
|
||||||
|
hashtab_t *Hash_NewTable (int tsize, char *(*gk)(void*), void (*f)(void*));
|
||||||
|
void Hash_DelTable (hashtab_t *tab);
|
||||||
|
int Hash_Add (hashtab_t *tab, void *ele);
|
||||||
|
void *Hash_Find (hashtab_t *tab, const char *key);
|
||||||
|
int Hash_Del (hashtab_t *tab, const char *key);
|
||||||
|
|
||||||
|
#endif // __hash_h
|
47
include/mdfour.h
Normal file
47
include/mdfour.h
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
mdfour.h
|
||||||
|
|
||||||
|
an implementation of MD4 designed for use in the SMB authentication
|
||||||
|
protocol
|
||||||
|
|
||||||
|
Copyright (C) Andrew Tridgell 1997-1998
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __mdfour_h
|
||||||
|
#define __mdfour_h
|
||||||
|
|
||||||
|
#include "uint32.h"
|
||||||
|
|
||||||
|
#define MDFOUR_DIGEST_BYTES 16
|
||||||
|
|
||||||
|
struct mdfour {
|
||||||
|
uint32 A, B, C, D;
|
||||||
|
uint32 totalN;
|
||||||
|
};
|
||||||
|
|
||||||
|
void mdfour_begin(struct mdfour *md); // old: MD4Init
|
||||||
|
void mdfour_update(struct mdfour *md, unsigned char *in, int n); //old: MD4Update
|
||||||
|
void mdfour_result(struct mdfour *md, unsigned char *out); // old: MD4Final
|
||||||
|
void mdfour(unsigned char *out, unsigned char *in, int n);
|
||||||
|
|
||||||
|
#endif // __mdfour_h
|
|
@ -28,8 +28,8 @@
|
||||||
$Id$
|
$Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _QARGS_H
|
#ifndef __qargs_h
|
||||||
#define _QARGS_H
|
#define __qargs_h
|
||||||
|
|
||||||
#include "qtypes.h"
|
#include "qtypes.h"
|
||||||
|
|
||||||
|
@ -44,4 +44,4 @@ void COM_Init (void);
|
||||||
void COM_Init_Cvars (void);
|
void COM_Init_Cvars (void);
|
||||||
void COM_InitArgv (int argc, char **argv);
|
void COM_InitArgv (int argc, char **argv);
|
||||||
|
|
||||||
#endif // _QARGS_H
|
#endif // __qargs_h
|
|
@ -28,15 +28,16 @@
|
||||||
$Id$
|
$Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _QDEFS_H
|
#ifndef __qdefs_h
|
||||||
#define _QDEFS_H
|
#define __qdefs_h
|
||||||
|
|
||||||
#define MAX_QPATH 64
|
#define MAX_QPATH 64
|
||||||
#define MAX_CL_STATS 32
|
#define MAX_CL_STATS 32
|
||||||
#define NUM_CSHIFTS 4
|
#define NUM_CSHIFTS 4
|
||||||
#define MAX_MODELS 256
|
#define MAX_MODELS 256
|
||||||
#define MAX_SOUNDS 256
|
#define MAX_SOUNDS 256
|
||||||
#define MAX_SCOREBOARDNAME 16
|
#define MAX_SCOREBOARD 16
|
||||||
|
#define MAX_SCOREBOARDNAME 32
|
||||||
#define MAX_STYLESTRING 64
|
#define MAX_STYLESTRING 64
|
||||||
#define MAX_EDICTS 768
|
#define MAX_EDICTS 768
|
||||||
#define MAX_LIGHTSTYLES 64
|
#define MAX_LIGHTSTYLES 64
|
||||||
|
@ -46,4 +47,4 @@
|
||||||
|
|
||||||
#define clc_stringcmd 4
|
#define clc_stringcmd 4
|
||||||
|
|
||||||
#endif // _QDEFS_H
|
#endif // __qdefs_h
|
71
include/qendian.h
Normal file
71
include/qendian.h
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
qendian.h
|
||||||
|
|
||||||
|
(description)
|
||||||
|
|
||||||
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
|
Copyright (C) 1999,2000 contributors of the QuakeForge project
|
||||||
|
Please see the file "AUTHORS" for a list of contributors
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __qendian_h
|
||||||
|
#define __qendian_h
|
||||||
|
|
||||||
|
#include "qtypes.h"
|
||||||
|
|
||||||
|
#ifndef NULL
|
||||||
|
# define NULL ((void *)0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define Q_MAXCHAR ((char)0x7f)
|
||||||
|
#define Q_MAXSHORT ((short)0x7fff)
|
||||||
|
#define Q_MAXINT ((int)0x7fffffff)
|
||||||
|
#define Q_MAXLONG ((int)0x7fffffff)
|
||||||
|
#define Q_MAXFLOAT ((int)0x7fffffff)
|
||||||
|
|
||||||
|
#define Q_MINCHAR ((char)0x80)
|
||||||
|
#define Q_MINSHORT ((short)0x8000)
|
||||||
|
#define Q_MININT ((int)0x80000000)
|
||||||
|
#define Q_MINLONG ((int)0x80000000)
|
||||||
|
#define Q_MINFLOAT ((int)0x7fffffff)
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
extern qboolean bigendien;
|
||||||
|
extern short (*BigShort) (short l);
|
||||||
|
extern short (*LittleShort) (short l);
|
||||||
|
extern int (*BigLong) (int l);
|
||||||
|
extern int (*LittleLong) (int l);
|
||||||
|
extern float (*BigFloat) (float l);
|
||||||
|
extern float (*LittleFloat) (float l);
|
||||||
|
|
||||||
|
short ShortSwap (short l);
|
||||||
|
short ShortNoSwap (short l);
|
||||||
|
int LongSwap (int l);
|
||||||
|
int LongNoSwap (int l);
|
||||||
|
float FloatSwap (float f);
|
||||||
|
float FloatNoSwap (float f);
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
#endif // __qendian_h
|
|
@ -28,8 +28,14 @@
|
||||||
$Id$
|
$Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __qtypes
|
#ifndef __qtypes_h
|
||||||
#define __qtypes
|
#define __qtypes_h
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "qdefs.h"
|
||||||
|
#include "compat.h"
|
||||||
|
|
||||||
#define MAX_QPATH 64
|
#define MAX_QPATH 64
|
||||||
|
|
||||||
|
@ -56,4 +62,4 @@ typedef int func_t;
|
||||||
typedef int string_t;
|
typedef int string_t;
|
||||||
typedef byte pixel_t;
|
typedef byte pixel_t;
|
||||||
|
|
||||||
#endif // __qtypes
|
#endif // __qtypes_h
|
77
include/quakefs.h
Normal file
77
include/quakefs.h
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
/*
|
||||||
|
quakefs.h
|
||||||
|
|
||||||
|
quake virtual filesystem definitions
|
||||||
|
|
||||||
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
|
Copyright (C) 1999,2000 contributors of the QuakeForge project
|
||||||
|
Please see the file "AUTHORS" for a list of contributors
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __quakefs_h
|
||||||
|
#define __quakefs_h
|
||||||
|
|
||||||
|
#include "qtypes.h"
|
||||||
|
#include "quakeio.h"
|
||||||
|
#include "cvar.h"
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
#define MAX_OSPATH 128 // max length of a filesystem pathname
|
||||||
|
|
||||||
|
extern cvar_t *fs_userpath;
|
||||||
|
extern cvar_t *fs_sharepath;
|
||||||
|
extern cvar_t *fs_skinbase;
|
||||||
|
|
||||||
|
extern int com_filesize;
|
||||||
|
struct cache_user_s;
|
||||||
|
|
||||||
|
extern char com_gamedir[MAX_OSPATH];
|
||||||
|
extern char gamedirfile[MAX_OSPATH];
|
||||||
|
|
||||||
|
void COM_WriteFile (char *filename, void *data, int len);
|
||||||
|
void COM_WriteBuffers (const char *filename, int count, ...);
|
||||||
|
|
||||||
|
int _COM_FOpenFile (char *filename, QFile **gzfile, char *foundname, int zip);
|
||||||
|
int COM_FOpenFile (char *filename, QFile **gzfile);
|
||||||
|
void COM_CloseFile (QFile *h);
|
||||||
|
int COM_filelength (QFile *f);
|
||||||
|
void COM_FileBase (char *in, char *out);
|
||||||
|
void COM_DefaultExtension (char *path, char *extension);
|
||||||
|
char *COM_SkipPath (char *pathname);
|
||||||
|
void COM_StripExtension (char *in, char *out);
|
||||||
|
int COM_NextFilename (char *filename, const char *prefix, const char *ext);
|
||||||
|
|
||||||
|
|
||||||
|
byte *COM_LoadStackFile (char *path, void *buffer, int bufsize);
|
||||||
|
byte *COM_LoadTempFile (char *path);
|
||||||
|
byte *COM_LoadHunkFile (char *path);
|
||||||
|
void COM_LoadCacheFile (char *path, struct cache_user_s *cu);
|
||||||
|
void COM_CreatePath (char *path);
|
||||||
|
void COM_Gamedir (char *dir);
|
||||||
|
void COM_Filesystem_Init (void);
|
||||||
|
void COM_Filesystem_Init_Cvars (void);
|
||||||
|
void COM_Path_f (void);
|
||||||
|
void COM_Maplist_f (void);
|
||||||
|
|
||||||
|
#endif // __quakefs_h
|
|
@ -27,16 +27,17 @@
|
||||||
|
|
||||||
$Id$
|
$Id$
|
||||||
*/
|
*/
|
||||||
#ifndef _QUAKEIO_H
|
#ifndef __quakeio_h
|
||||||
#define _QUAKEIO_H
|
#define __quakeio_h
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef HAVE_ZLIB
|
#ifdef HAVE_ZLIB
|
||||||
#include <zlib.h>
|
# include <zlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "gcc_attr.h"
|
#include "gcc_attr.h"
|
||||||
|
@ -63,8 +64,8 @@ int Qseek(QFile *file, long offset, int whence);
|
||||||
long Qtell(QFile *file);
|
long Qtell(QFile *file);
|
||||||
int Qflush(QFile *file);
|
int Qflush(QFile *file);
|
||||||
int Qeof(QFile *file);
|
int Qeof(QFile *file);
|
||||||
|
char *Qgetline(QFile *file);
|
||||||
int Qgetpos(QFile *file, fpos_t *pos);
|
int Qgetpos(QFile *file, fpos_t *pos);
|
||||||
int Qsetpos(QFile *file, fpos_t *pos);
|
int Qsetpos(QFile *file, fpos_t *pos);
|
||||||
|
|
||||||
#endif /*_QUAKEIO_H*/
|
#endif /*__quakeio_h*/
|
|
@ -25,8 +25,8 @@
|
||||||
|
|
||||||
$Id$
|
$Id$
|
||||||
*/
|
*/
|
||||||
#ifndef _SIZEBUF_H
|
#ifndef __sizebuf_h
|
||||||
#define _SIZEBUF_H
|
#define __sizebuf_h
|
||||||
|
|
||||||
#include "qtypes.h"
|
#include "qtypes.h"
|
||||||
|
|
||||||
|
@ -46,4 +46,4 @@ void *SZ_GetSpace (sizebuf_t *buf, int length);
|
||||||
void SZ_Write (sizebuf_t *buf, void *data, int length);
|
void SZ_Write (sizebuf_t *buf, void *data, int length);
|
||||||
void SZ_Print (sizebuf_t *buf, char *data); // strcats onto the sizebuf
|
void SZ_Print (sizebuf_t *buf, char *data); // strcats onto the sizebuf
|
||||||
|
|
||||||
#endif
|
#endif // __sizebuf_h
|
87
include/sys.h
Normal file
87
include/sys.h
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
sys.h
|
||||||
|
|
||||||
|
non-portable functions
|
||||||
|
|
||||||
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __sys_h
|
||||||
|
#define __sys_h
|
||||||
|
|
||||||
|
#include "gcc_attr.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// file IO
|
||||||
|
//
|
||||||
|
|
||||||
|
// returns the file size
|
||||||
|
// return -1 if file is not present
|
||||||
|
// the file should be in BINARY mode for stupid OSs that care
|
||||||
|
int Sys_FileOpenRead (char *path, int *hndl);
|
||||||
|
|
||||||
|
int Sys_FileOpenWrite (char *path);
|
||||||
|
void Sys_FileClose (int handle);
|
||||||
|
void Sys_FileSeek (int handle, int position);
|
||||||
|
int Sys_FileRead (int handle, void *dest, int count);
|
||||||
|
int Sys_FileWrite (int handle, void *data, int count);
|
||||||
|
int Sys_FileTime (char *path);
|
||||||
|
void Sys_mkdir (char *path);
|
||||||
|
|
||||||
|
//
|
||||||
|
// memory protection
|
||||||
|
//
|
||||||
|
void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length);
|
||||||
|
|
||||||
|
//
|
||||||
|
// system IO
|
||||||
|
//
|
||||||
|
void Sys_DebugLog(char *file, char *fmt, ...) __attribute__((format(printf,2,3)));
|
||||||
|
|
||||||
|
void Sys_Error (char *error, ...) __attribute__((format(printf,1,2)));
|
||||||
|
// an error will cause the entire program to exit
|
||||||
|
|
||||||
|
void Sys_Printf (char *fmt, ...) __attribute__((format(printf,1,2)));
|
||||||
|
// send text to the console
|
||||||
|
|
||||||
|
void Sys_Quit (void);
|
||||||
|
|
||||||
|
double Sys_DoubleTime (void);
|
||||||
|
|
||||||
|
char *Sys_ConsoleInput (void);
|
||||||
|
|
||||||
|
void Sys_Sleep (void);
|
||||||
|
// called to yield for a little bit so as
|
||||||
|
// not to hog cpu when paused or debugging
|
||||||
|
|
||||||
|
void Sys_LowFPPrecision (void);
|
||||||
|
void Sys_HighFPPrecision (void);
|
||||||
|
void Sys_SetFPCW (void);
|
||||||
|
|
||||||
|
void Sys_Printf (char *fmt, ...) __attribute__((format(printf,1,2)));
|
||||||
|
// send text to the console
|
||||||
|
|
||||||
|
void Sys_Init (void);
|
||||||
|
void Sys_Init_Cvars (void);
|
||||||
|
|
||||||
|
#endif // __sys_h
|
53
include/uint32.h
Normal file
53
include/uint32.h
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
uint32.h
|
||||||
|
|
||||||
|
Definitions for portable (?) unsigned int
|
||||||
|
|
||||||
|
Copyright (C) 2000 Jeff Teunissen <d2deek@pmail.net>
|
||||||
|
|
||||||
|
Author: Jeff Teunissen <d2deek@pmail.net>
|
||||||
|
Date: 01 Jan 2000
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __uint32_h
|
||||||
|
#define __uint32_h
|
||||||
|
|
||||||
|
#ifndef int32
|
||||||
|
# if (SIZEOF_INT == 4)
|
||||||
|
# define int32 int
|
||||||
|
# elif (SIZEOF_LONG == 4)
|
||||||
|
# define int32 long
|
||||||
|
# elif (SIZEOF_SHORT == 4)
|
||||||
|
# define int32 short
|
||||||
|
# else
|
||||||
|
/* I hope this works */
|
||||||
|
# define int32 int
|
||||||
|
# define LARGE_INT32
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef uint32
|
||||||
|
# define uint32 unsigned int32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // __uint32_h
|
|
@ -25,8 +25,8 @@
|
||||||
|
|
||||||
$Id$
|
$Id$
|
||||||
*/
|
*/
|
||||||
#ifndef _ZONE_H
|
#ifndef __zone_h
|
||||||
#define _ZONE_H
|
#define __zone_h
|
||||||
|
|
||||||
/*
|
/*
|
||||||
memory allocation
|
memory allocation
|
||||||
|
@ -130,4 +130,4 @@ void *Cache_Alloc (cache_user_t *c, int size, char *name);
|
||||||
|
|
||||||
void Cache_Report (void);
|
void Cache_Report (void);
|
||||||
|
|
||||||
#endif // _ZONE_H
|
#endif // __zone_h
|
2
libs/.gitignore
vendored
Normal file
2
libs/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
Makefile.in
|
||||||
|
Makefile
|
1
libs/Makefile.am
Normal file
1
libs/Makefile.am
Normal file
|
@ -0,0 +1 @@
|
||||||
|
SUBDIRS= util
|
3
libs/util/.gitignore
vendored
Normal file
3
libs/util/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
Makefile.in
|
||||||
|
Makefile
|
||||||
|
.deps
|
3
libs/util/Makefile.am
Normal file
3
libs/util/Makefile.am
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
noinst_LIBRARIES = libutil.a
|
||||||
|
|
||||||
|
libutil_a_SOURCES = cmd.c cvar.c hash.c mdfour.c sizebuf.c va.c zone.c
|
937
libs/util/cmd.c
Normal file
937
libs/util/cmd.c
Normal file
|
@ -0,0 +1,937 @@
|
||||||
|
/*
|
||||||
|
cmd.c
|
||||||
|
|
||||||
|
script command processing module
|
||||||
|
|
||||||
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
# include <string.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STRINGS_H
|
||||||
|
# include <strings.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include "cvar.h"
|
||||||
|
#include "cmd.h"
|
||||||
|
#include "console.h"
|
||||||
|
#include "hash.h"
|
||||||
|
#include "qargs.h"
|
||||||
|
#include "qendian.h"
|
||||||
|
#include "quakefs.h"
|
||||||
|
#include "sizebuf.h"
|
||||||
|
#include "sys.h"
|
||||||
|
#include "zone.h"
|
||||||
|
|
||||||
|
void Cmd_ForwardToServer (void);
|
||||||
|
|
||||||
|
#define MAX_ALIAS_NAME 32
|
||||||
|
|
||||||
|
typedef struct cmdalias_s {
|
||||||
|
struct cmdalias_s *next;
|
||||||
|
char name[MAX_ALIAS_NAME];
|
||||||
|
char *value;
|
||||||
|
} cmdalias_t;
|
||||||
|
|
||||||
|
cmdalias_t *cmd_alias;
|
||||||
|
|
||||||
|
qboolean cmd_wait;
|
||||||
|
|
||||||
|
cvar_t *cl_warncmd;
|
||||||
|
|
||||||
|
hashtab_t *cmd_alias_hash;
|
||||||
|
hashtab_t *cmd_hash;
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cmd_Wait_f
|
||||||
|
|
||||||
|
Causes execution of the remainder of the command buffer to be delayed until
|
||||||
|
next frame. This allows commands like:
|
||||||
|
bind g "impulse 5 ; +attack ; wait ; -attack ; impulse 2"
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cmd_Wait_f (void)
|
||||||
|
{
|
||||||
|
cmd_wait = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
COMMAND BUFFER
|
||||||
|
*/
|
||||||
|
|
||||||
|
sizebuf_t cmd_text;
|
||||||
|
byte cmd_text_buf[8192];
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cbuf_Init
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cbuf_Init (void)
|
||||||
|
{
|
||||||
|
cmd_text.data = cmd_text_buf;
|
||||||
|
cmd_text.maxsize = sizeof (cmd_text_buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cbuf_AddText
|
||||||
|
|
||||||
|
Adds command text at the end of the buffer
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cbuf_AddText (char *text)
|
||||||
|
{
|
||||||
|
int l;
|
||||||
|
|
||||||
|
l = strlen (text);
|
||||||
|
|
||||||
|
if (cmd_text.cursize + l >= cmd_text.maxsize) {
|
||||||
|
Con_Printf ("Cbuf_AddText: overflow\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SZ_Write (&cmd_text, text, strlen (text));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cbuf_InsertText
|
||||||
|
|
||||||
|
Adds command text immediately after the current command
|
||||||
|
Adds a \n to the text
|
||||||
|
TODO: Can we just read the buffer in the reverse order?
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cbuf_InsertText (char *text)
|
||||||
|
{
|
||||||
|
int textlen;
|
||||||
|
|
||||||
|
textlen = strlen (text);
|
||||||
|
if (cmd_text.cursize + 1 + textlen >= cmd_text.maxsize) {
|
||||||
|
Con_Printf ("Cbuf_InsertText: overflow\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!cmd_text.cursize) {
|
||||||
|
memcpy (cmd_text.data, text, textlen);
|
||||||
|
cmd_text.cursize = textlen;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Move up to make room for inserted text
|
||||||
|
memmove (cmd_text.data + textlen + 1, cmd_text.data, cmd_text.cursize);
|
||||||
|
cmd_text.cursize += textlen + 1;
|
||||||
|
|
||||||
|
// Insert new text
|
||||||
|
memcpy (cmd_text.data, text, textlen);
|
||||||
|
cmd_text.data[textlen] = '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
extract_line (char *line)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char *text;
|
||||||
|
int quotes;
|
||||||
|
|
||||||
|
// find a \n or ; line break
|
||||||
|
text = (char *) cmd_text.data;
|
||||||
|
quotes = 0;
|
||||||
|
for (i = 0; i < cmd_text.cursize; i++) {
|
||||||
|
if (text[i] == '"')
|
||||||
|
quotes++;
|
||||||
|
if (!(quotes & 1) && text[i] == ';')
|
||||||
|
break; // don't break if inside a quoted
|
||||||
|
// string
|
||||||
|
if (text[i] == '\n' || text[i] == '\r')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy (line, text, i);
|
||||||
|
line[i] = '\0';
|
||||||
|
// delete the text from the command buffer and move remaining commands
|
||||||
|
// down
|
||||||
|
// this is necessary because commands (exec, alias) can insert data at
|
||||||
|
// the
|
||||||
|
// beginning of the text buffer
|
||||||
|
|
||||||
|
if (i == cmd_text.cursize)
|
||||||
|
cmd_text.cursize = 0;
|
||||||
|
else {
|
||||||
|
i++;
|
||||||
|
cmd_text.cursize -= i;
|
||||||
|
memcpy (text, text + i, cmd_text.cursize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Cbuf_Execute
|
||||||
|
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cbuf_Execute (void)
|
||||||
|
{
|
||||||
|
char line[1024] = { 0 };
|
||||||
|
|
||||||
|
while (cmd_text.cursize) {
|
||||||
|
extract_line (line);
|
||||||
|
// execute the command line
|
||||||
|
// Con_DPrintf("+%s\n",line),
|
||||||
|
Cmd_ExecuteString (line);
|
||||||
|
|
||||||
|
if (cmd_wait) { // skip out while text still remains
|
||||||
|
// in buffer, leaving it
|
||||||
|
// for next frame
|
||||||
|
cmd_wait = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Cbuf_Execute
|
||||||
|
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cbuf_Execute_Sets (void)
|
||||||
|
{
|
||||||
|
char line[1024] = { 0 };
|
||||||
|
|
||||||
|
while (cmd_text.cursize) {
|
||||||
|
extract_line (line);
|
||||||
|
// execute the command line
|
||||||
|
if (strnequal (line, "set", 3) && isspace ((int) line[3])) {
|
||||||
|
// Con_DPrintf ("+%s\n",line);
|
||||||
|
Cmd_ExecuteString (line);
|
||||||
|
}
|
||||||
|
if (strnequal (line, "setrom", 6) && isspace ((int) line[6])) {
|
||||||
|
// Con_DPrintf ("+%s\n",line);
|
||||||
|
Cmd_ExecuteString (line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
SCRIPT COMMANDS
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cmd_StuffCmds_f
|
||||||
|
|
||||||
|
Adds command line parameters as script statements
|
||||||
|
Commands lead with a +, and continue until a - or another +
|
||||||
|
quake +prog jctest.qp +cmd amlev1
|
||||||
|
quake -nosound +cmd amlev1
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cmd_StuffCmds_f (void)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
int s;
|
||||||
|
char *build, c;
|
||||||
|
|
||||||
|
s = strlen (com_cmdline);
|
||||||
|
if (!s)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// pull out the commands
|
||||||
|
build = malloc (s + 1);
|
||||||
|
build[0] = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < s - 1; i++) {
|
||||||
|
if (com_cmdline[i] == '+') {
|
||||||
|
i++;
|
||||||
|
|
||||||
|
for (j = i; !((com_cmdline[j] == '+')
|
||||||
|
|| (com_cmdline[j] == '-'
|
||||||
|
&& (j==0 || com_cmdline[j - 1] == ' '))
|
||||||
|
|| (com_cmdline[j] == 0)); j++);
|
||||||
|
|
||||||
|
c = com_cmdline[j];
|
||||||
|
com_cmdline[j] = 0;
|
||||||
|
|
||||||
|
strncat (build, com_cmdline + i, s - strlen (build));
|
||||||
|
strncat (build, "\n", s - strlen (build));
|
||||||
|
com_cmdline[j] = c;
|
||||||
|
i = j - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Con_Printf("[\n%s]\n",build);
|
||||||
|
|
||||||
|
if (build[0])
|
||||||
|
Cbuf_InsertText (build);
|
||||||
|
|
||||||
|
free (build);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Cmd_Exec_File
|
||||||
|
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cmd_Exec_File (char *path)
|
||||||
|
{
|
||||||
|
char *f;
|
||||||
|
int len;
|
||||||
|
QFile *file;
|
||||||
|
|
||||||
|
if (!path || !*path)
|
||||||
|
return;
|
||||||
|
if ((file = Qopen (path, "r")) != NULL) {
|
||||||
|
len = COM_filelength (file);
|
||||||
|
f = (char *) Hunk_TempAlloc (len + 1);
|
||||||
|
if (f) {
|
||||||
|
f[len] = 0;
|
||||||
|
Qread (file, f, len);
|
||||||
|
Qclose (file);
|
||||||
|
Cbuf_InsertText (f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cmd_Exec_f
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cmd_Exec_f (void)
|
||||||
|
{
|
||||||
|
char *f;
|
||||||
|
int mark;
|
||||||
|
|
||||||
|
if (Cmd_Argc () != 2) {
|
||||||
|
Con_Printf ("exec <filename> : execute a script file\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// FIXME: is this safe freeing the hunk here?
|
||||||
|
mark = Hunk_LowMark ();
|
||||||
|
f = (char *) COM_LoadHunkFile (Cmd_Argv (1));
|
||||||
|
if (!f) {
|
||||||
|
Con_Printf ("couldn't exec %s\n", Cmd_Argv (1));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!Cvar_Command () && ((cl_warncmd && cl_warncmd->int_val)
|
||||||
|
|| (developer && developer->int_val)))
|
||||||
|
Con_Printf ("execing %s\n", Cmd_Argv (1));
|
||||||
|
|
||||||
|
Cbuf_InsertText (f);
|
||||||
|
Hunk_FreeToLowMark (mark);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cmd_Echo_f
|
||||||
|
|
||||||
|
Just prints the rest of the line to the console
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cmd_Echo_f (void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 1; i < Cmd_Argc (); i++)
|
||||||
|
Con_Printf ("%s ", Cmd_Argv (i));
|
||||||
|
Con_Printf ("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cmd_Alias_f
|
||||||
|
|
||||||
|
Creates a new command that executes a command string (possibly ; seperated)
|
||||||
|
*/
|
||||||
|
|
||||||
|
char *
|
||||||
|
CopyString (char *in)
|
||||||
|
{
|
||||||
|
char *out;
|
||||||
|
|
||||||
|
out = malloc (strlen (in) + 1);
|
||||||
|
strcpy (out, in);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Cmd_Alias_f (void)
|
||||||
|
{
|
||||||
|
cmdalias_t *a;
|
||||||
|
char cmd[1024];
|
||||||
|
int i, c;
|
||||||
|
char *s;
|
||||||
|
|
||||||
|
if (Cmd_Argc () == 1) {
|
||||||
|
Con_Printf ("Current alias commands:\n");
|
||||||
|
for (a = cmd_alias; a; a = a->next)
|
||||||
|
Con_Printf ("%s : %s\n", a->name, a->value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
s = Cmd_Argv (1);
|
||||||
|
if (strlen (s) >= MAX_ALIAS_NAME) {
|
||||||
|
Con_Printf ("Alias name is too long\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// if the alias allready exists, reuse it
|
||||||
|
a = (cmdalias_t*)Hash_Find (cmd_alias_hash, s);
|
||||||
|
if (a) {
|
||||||
|
free (a->value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!a) {
|
||||||
|
a = calloc (1, sizeof (cmdalias_t));
|
||||||
|
a->next = cmd_alias;
|
||||||
|
cmd_alias = a;
|
||||||
|
strcpy (a->name, s);
|
||||||
|
Hash_Add (cmd_alias_hash, a);
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy the rest of the command line
|
||||||
|
cmd[0] = 0; // start out with a null string
|
||||||
|
c = Cmd_Argc ();
|
||||||
|
for (i = 2; i < c; i++) {
|
||||||
|
strncat (cmd, Cmd_Argv (i), sizeof (cmd) - strlen (cmd));
|
||||||
|
if (i != c)
|
||||||
|
strncat (cmd, " ", sizeof (cmd) - strlen (cmd));
|
||||||
|
}
|
||||||
|
strncat (cmd, "\n", sizeof (cmd) - strlen (cmd));
|
||||||
|
|
||||||
|
a->value = CopyString (cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Cmd_UnAlias_f (void)
|
||||||
|
{
|
||||||
|
cmdalias_t *a, *prev;
|
||||||
|
char *s;
|
||||||
|
|
||||||
|
if (Cmd_Argc () != 2) {
|
||||||
|
Con_Printf ("unalias <alias>: erase an existing alias\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
s = Cmd_Argv (1);
|
||||||
|
if (strlen (s) >= MAX_ALIAS_NAME) {
|
||||||
|
Con_Printf ("Alias name is too long\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
prev = cmd_alias;
|
||||||
|
for (a = cmd_alias; a; a = a->next) {
|
||||||
|
if (!strcmp (s, a->name)) {
|
||||||
|
Hash_Del (cmd_alias_hash, s);
|
||||||
|
free (a->value);
|
||||||
|
prev->next = a->next;
|
||||||
|
if (a == cmd_alias)
|
||||||
|
cmd_alias = a->next;
|
||||||
|
free (a);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
prev = a;
|
||||||
|
}
|
||||||
|
Con_Printf ("Unknown alias \"%s\"\n", s);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
COMMAND EXECUTION
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct cmd_function_s {
|
||||||
|
struct cmd_function_s *next;
|
||||||
|
char *name;
|
||||||
|
xcommand_t function;
|
||||||
|
char *description;
|
||||||
|
} cmd_function_t;
|
||||||
|
|
||||||
|
|
||||||
|
#define MAX_ARGS 80
|
||||||
|
|
||||||
|
static int cmd_argc;
|
||||||
|
static char *cmd_argv[MAX_ARGS];
|
||||||
|
static char *cmd_null_string = "";
|
||||||
|
static char *cmd_args = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static cmd_function_t *cmd_functions; // possible commands to execute
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cmd_Argc
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
Cmd_Argc (void)
|
||||||
|
{
|
||||||
|
return cmd_argc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cmd_Argv
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
Cmd_Argv (int arg)
|
||||||
|
{
|
||||||
|
if (arg >= cmd_argc)
|
||||||
|
return cmd_null_string;
|
||||||
|
return cmd_argv[arg];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cmd_Args
|
||||||
|
|
||||||
|
Returns a single string containing argv(1) to argv(argc()-1)
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
Cmd_Args (void)
|
||||||
|
{
|
||||||
|
if (!cmd_args)
|
||||||
|
return "";
|
||||||
|
return cmd_args;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cmd_TokenizeString
|
||||||
|
|
||||||
|
Parses the given string into command line tokens.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cmd_TokenizeString (char *text)
|
||||||
|
{
|
||||||
|
static char argv_buf[1024];
|
||||||
|
int argv_idx;
|
||||||
|
|
||||||
|
argv_idx = 0;
|
||||||
|
|
||||||
|
cmd_argc = 0;
|
||||||
|
cmd_args = NULL;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
// skip whitespace up to a /n
|
||||||
|
while (*text && *(unsigned char *) text <= ' ' && *text != '\n') {
|
||||||
|
text++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*text == '\n') { // a newline seperates commands in
|
||||||
|
// the buffer
|
||||||
|
text++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!*text)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (cmd_argc == 1)
|
||||||
|
cmd_args = text;
|
||||||
|
|
||||||
|
text = COM_Parse (text);
|
||||||
|
if (!text)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (cmd_argc < MAX_ARGS) {
|
||||||
|
if (argv_idx + strlen (com_token) + 1 > 1024) {
|
||||||
|
Con_Printf ("Cmd_TokenizeString: overflow\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cmd_argv[cmd_argc] = argv_buf + argv_idx;
|
||||||
|
strcpy (cmd_argv[cmd_argc], com_token);
|
||||||
|
argv_idx += strlen (com_token) + 1;
|
||||||
|
|
||||||
|
cmd_argc++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cmd_AddCommand
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cmd_AddCommand (char *cmd_name, xcommand_t function, char *description)
|
||||||
|
{
|
||||||
|
cmd_function_t *cmd;
|
||||||
|
cmd_function_t **c;
|
||||||
|
|
||||||
|
// fail if the command is a variable name
|
||||||
|
if (Cvar_FindVar (cmd_name)) {
|
||||||
|
Con_Printf ("Cmd_AddCommand: %s already defined as a var\n", cmd_name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// fail if the command already exists
|
||||||
|
cmd = (cmd_function_t*)Hash_Find (cmd_hash, cmd_name);
|
||||||
|
if (cmd) {
|
||||||
|
Con_Printf ("Cmd_AddCommand: %s already defined\n", cmd_name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd = malloc (sizeof (cmd_function_t));
|
||||||
|
cmd->name = cmd_name;
|
||||||
|
cmd->function = function;
|
||||||
|
cmd->description = description;
|
||||||
|
Hash_Add (cmd_hash, cmd);
|
||||||
|
for (c = &cmd_functions; *c; c = &(*c)->next)
|
||||||
|
if (strcmp ((*c)->name, cmd->name) >=0)
|
||||||
|
break;
|
||||||
|
cmd->next = *c;
|
||||||
|
*c = cmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cmd_Exists
|
||||||
|
*/
|
||||||
|
qboolean
|
||||||
|
Cmd_Exists (char *cmd_name)
|
||||||
|
{
|
||||||
|
cmd_function_t *cmd;
|
||||||
|
|
||||||
|
cmd = (cmd_function_t*)Hash_Find (cmd_hash, cmd_name);
|
||||||
|
if (cmd) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cmd_CompleteCommand
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
Cmd_CompleteCommand (char *partial)
|
||||||
|
{
|
||||||
|
cmd_function_t *cmd;
|
||||||
|
int len;
|
||||||
|
cmdalias_t *a;
|
||||||
|
|
||||||
|
len = strlen (partial);
|
||||||
|
|
||||||
|
if (!len)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// check for exact match
|
||||||
|
for (cmd = cmd_functions; cmd; cmd = cmd->next)
|
||||||
|
if (!strcasecmp (partial, cmd->name))
|
||||||
|
return cmd->name;
|
||||||
|
for (a = cmd_alias; a; a = a->next)
|
||||||
|
if (!strcasecmp (partial, a->name))
|
||||||
|
return a->name;
|
||||||
|
|
||||||
|
// check for partial match
|
||||||
|
for (cmd = cmd_functions; cmd; cmd = cmd->next)
|
||||||
|
if (!strncasecmp (partial, cmd->name, len))
|
||||||
|
return cmd->name;
|
||||||
|
for (a = cmd_alias; a; a = a->next)
|
||||||
|
if (!strncasecmp (partial, a->name, len))
|
||||||
|
return a->name;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cmd_ExpandVariables
|
||||||
|
|
||||||
|
Expand $fov-like expressions
|
||||||
|
FIXME: better handling of buffer overflows?
|
||||||
|
*/
|
||||||
|
// dest must point to a 1024-byte buffer
|
||||||
|
void
|
||||||
|
Cmd_ExpandVariables (char *data, char *dest)
|
||||||
|
{
|
||||||
|
unsigned int c;
|
||||||
|
char buf[1024];
|
||||||
|
int i, len;
|
||||||
|
cvar_t *var, *bestvar;
|
||||||
|
int quotes = 0;
|
||||||
|
|
||||||
|
len = 0;
|
||||||
|
|
||||||
|
// parse a regular word
|
||||||
|
while ((c = *data) != 0) {
|
||||||
|
if (c == '"')
|
||||||
|
quotes++;
|
||||||
|
if (c == '$' && !(quotes & 1)) {
|
||||||
|
data++;
|
||||||
|
|
||||||
|
// Copy the text after '$' to a temp buffer
|
||||||
|
i = 0;
|
||||||
|
buf[0] = 0;
|
||||||
|
bestvar = NULL;
|
||||||
|
while ((c = *data) > 32) {
|
||||||
|
if (c == '$')
|
||||||
|
break;
|
||||||
|
data++;
|
||||||
|
buf[i++] = c;
|
||||||
|
buf[i] = 0;
|
||||||
|
if ((var = Cvar_FindVar (buf)) != 0)
|
||||||
|
bestvar = var;
|
||||||
|
if (i >= sizeof (buf) - 1)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bestvar) {
|
||||||
|
// check buffer size
|
||||||
|
if (len + strlen (bestvar->string) >= 1024 - 1)
|
||||||
|
break;
|
||||||
|
|
||||||
|
strcpy (&dest[len], bestvar->string);
|
||||||
|
len += strlen (bestvar->string);
|
||||||
|
i = strlen (bestvar->name);
|
||||||
|
while (buf[i])
|
||||||
|
dest[len++] = buf[i++];
|
||||||
|
} else {
|
||||||
|
// no matching cvar name was found
|
||||||
|
dest[len++] = '$';
|
||||||
|
if (len + strlen (buf) >= 1024 - 1)
|
||||||
|
break;
|
||||||
|
strcpy (&dest[len], buf);
|
||||||
|
len += strlen (buf);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dest[len] = c;
|
||||||
|
data++;
|
||||||
|
len++;
|
||||||
|
if (len >= 1024 - 1)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
dest[len] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cmd_ExecuteString
|
||||||
|
|
||||||
|
A complete command line has been parsed, so try to execute it
|
||||||
|
FIXME: lookupnoadd the token to speed search?
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cmd_ExecuteString (char *text)
|
||||||
|
{
|
||||||
|
cmd_function_t *cmd;
|
||||||
|
cmdalias_t *a;
|
||||||
|
char buf[1024];
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
Cmd_TokenizeString (text);
|
||||||
|
#else
|
||||||
|
Cmd_ExpandVariables (text, buf);
|
||||||
|
Cmd_TokenizeString (buf);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// execute the command line
|
||||||
|
if (!Cmd_Argc ())
|
||||||
|
return; // no tokens
|
||||||
|
|
||||||
|
// check functions
|
||||||
|
cmd = (cmd_function_t*)Hash_Find (cmd_hash, cmd_argv[0]);
|
||||||
|
if (cmd) {
|
||||||
|
if (!cmd->function)
|
||||||
|
Cmd_ForwardToServer ();
|
||||||
|
else
|
||||||
|
cmd->function ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tonik: check cvars
|
||||||
|
if (Cvar_Command ())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// check alias
|
||||||
|
a = (cmdalias_t*)Hash_Find (cmd_alias_hash, cmd_argv[0]);
|
||||||
|
if (a) {
|
||||||
|
Cbuf_InsertText (a->value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cl_warncmd->int_val || developer->int_val)
|
||||||
|
Con_Printf ("Unknown command \"%s\"\n", Cmd_Argv (0));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cmd_CheckParm
|
||||||
|
|
||||||
|
Returns the position (1 to argc-1) in the command's argument list
|
||||||
|
where the given parameter apears, or 0 if not present
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
Cmd_CheckParm (char *parm)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (!parm)
|
||||||
|
Sys_Error ("Cmd_CheckParm: NULL");
|
||||||
|
|
||||||
|
for (i = 1; i < Cmd_Argc (); i++)
|
||||||
|
if (!strcasecmp (parm, Cmd_Argv (i)))
|
||||||
|
return i;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Cmd_CmdList_f (void)
|
||||||
|
{
|
||||||
|
cmd_function_t *cmd;
|
||||||
|
int i;
|
||||||
|
int show_description = 0;
|
||||||
|
|
||||||
|
if (Cmd_Argc() > 1)
|
||||||
|
show_description = 1;
|
||||||
|
for (cmd = cmd_functions, i = 0; cmd; cmd = cmd->next, i++) {
|
||||||
|
if (show_description) {
|
||||||
|
Con_Printf ("%-20s :\n%s\n", cmd->name, cmd->description);
|
||||||
|
} else {
|
||||||
|
Con_Printf ("%s\n", cmd->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Con_Printf ("------------\n%d commands\n", i);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cmd_alias_free (void *_a)
|
||||||
|
{
|
||||||
|
cmdalias_t *a = (cmdalias_t*)_a;
|
||||||
|
free (a->value);
|
||||||
|
free (a);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
cmd_alias_get_key (void *_a)
|
||||||
|
{
|
||||||
|
cmdalias_t *a = (cmdalias_t*)_a;
|
||||||
|
return a->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
cmd_get_key (void *c)
|
||||||
|
{
|
||||||
|
cmd_function_t *cmd = (cmd_function_t*)c;
|
||||||
|
return cmd->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cmd_Init_Hash
|
||||||
|
|
||||||
|
initialise the command and alias hash tables
|
||||||
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
Cmd_Init_Hash (void)
|
||||||
|
{
|
||||||
|
cmd_hash = Hash_NewTable (1021, cmd_get_key, 0);
|
||||||
|
cmd_alias_hash = Hash_NewTable (1021, cmd_alias_get_key, cmd_alias_free);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cmd_Init
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cmd_Init (void)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// register our commands
|
||||||
|
//
|
||||||
|
Cmd_AddCommand ("stuffcmds", Cmd_StuffCmds_f, "Execute the commands given at startup again");
|
||||||
|
Cmd_AddCommand ("exec", Cmd_Exec_f, "Execute a script file");
|
||||||
|
Cmd_AddCommand ("echo", Cmd_Echo_f, "Print text to console");
|
||||||
|
Cmd_AddCommand ("alias", Cmd_Alias_f, "Used to create a reference to a command or list of commands.\n"
|
||||||
|
"When used without parameters, displays all current aliases.\n"
|
||||||
|
"Note: Enclose multiple commands within quotes and seperate each command with a semi-colon.");
|
||||||
|
Cmd_AddCommand ("unalias", Cmd_UnAlias_f, "Remove the selected alias");
|
||||||
|
Cmd_AddCommand ("wait", Cmd_Wait_f, "Wait a game tic");
|
||||||
|
Cmd_AddCommand ("cmdlist", Cmd_CmdList_f, "List all commands");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char com_token[MAX_COM_TOKEN];
|
||||||
|
|
||||||
|
/*
|
||||||
|
COM_Parse
|
||||||
|
|
||||||
|
Parse a token out of a string
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
COM_Parse (char *data)
|
||||||
|
{
|
||||||
|
unsigned int c;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
len = 0;
|
||||||
|
com_token[0] = 0;
|
||||||
|
|
||||||
|
if (!data)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// skip whitespace
|
||||||
|
skipwhite:
|
||||||
|
while ((c = *data) <= ' ') {
|
||||||
|
if (c == 0)
|
||||||
|
return NULL; // end of file;
|
||||||
|
data++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// skip // comments
|
||||||
|
if (c == '/' && data[1] == '/') {
|
||||||
|
while (*data && *data != '\n')
|
||||||
|
data++;
|
||||||
|
goto skipwhite;
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle quoted strings specially
|
||||||
|
if (c == '\"') {
|
||||||
|
data++;
|
||||||
|
while (1) {
|
||||||
|
c = *data++;
|
||||||
|
if (c == '\"' || !c) {
|
||||||
|
com_token[len] = 0;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
com_token[len] = c;
|
||||||
|
len++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// parse a regular word
|
||||||
|
do {
|
||||||
|
com_token[len] = c;
|
||||||
|
data++;
|
||||||
|
len++;
|
||||||
|
if (len >= MAX_COM_TOKEN - 1)
|
||||||
|
break;
|
||||||
|
|
||||||
|
c = *data;
|
||||||
|
} while (c > 32);
|
||||||
|
|
||||||
|
com_token[len] = 0;
|
||||||
|
return data;
|
||||||
|
}
|
545
libs/util/cvar.c
Normal file
545
libs/util/cvar.c
Normal file
|
@ -0,0 +1,545 @@
|
||||||
|
/*
|
||||||
|
cvar.c
|
||||||
|
|
||||||
|
dynamic variable tracking
|
||||||
|
|
||||||
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
|
Copyright (C) 1999,2000 Nelson Rush.
|
||||||
|
Copyright (C) 1999,2000 contributors of the QuakeForge project
|
||||||
|
Please see the file "AUTHORS" for a list of contributors
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
# include <string.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STRINGS_H
|
||||||
|
# include <strings.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "console.h"
|
||||||
|
#include "cmd.h"
|
||||||
|
#include "cvar.h"
|
||||||
|
#include "hash.h"
|
||||||
|
#include "qargs.h"
|
||||||
|
|
||||||
|
cvar_t *cvar_vars;
|
||||||
|
char *cvar_null_string = "";
|
||||||
|
extern cvar_t *developer;
|
||||||
|
cvar_alias_t *calias_vars;
|
||||||
|
hashtab_t *cvar_hash;
|
||||||
|
hashtab_t *calias_hash;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cvar_FindVar
|
||||||
|
*/
|
||||||
|
cvar_t *
|
||||||
|
Cvar_FindVar (char *var_name)
|
||||||
|
{
|
||||||
|
return (cvar_t*) Hash_Find (cvar_hash, var_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
cvar_t *
|
||||||
|
Cvar_FindAlias (char *alias_name)
|
||||||
|
{
|
||||||
|
cvar_alias_t *alias;
|
||||||
|
|
||||||
|
alias = (cvar_alias_t*) Hash_Find (calias_hash, alias_name);
|
||||||
|
if (alias)
|
||||||
|
return alias->cvar;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Cvar_Alias_Get (char *name, cvar_t *cvar)
|
||||||
|
{
|
||||||
|
cvar_alias_t *alias;
|
||||||
|
cvar_t *var;
|
||||||
|
|
||||||
|
if (Cmd_Exists (name)) {
|
||||||
|
Con_Printf ("CAlias_Get: %s is a command\n", name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Cvar_FindVar (name)) {
|
||||||
|
Con_Printf ("CAlias_Get: tried to alias used cvar name %s\n", name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var = Cvar_FindAlias (name);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cvar_VariableValue
|
||||||
|
*/
|
||||||
|
float
|
||||||
|
Cvar_VariableValue (char *var_name)
|
||||||
|
{
|
||||||
|
cvar_t *var;
|
||||||
|
|
||||||
|
var = Cvar_FindVar (var_name);
|
||||||
|
if (!var)
|
||||||
|
var = Cvar_FindAlias (var_name);
|
||||||
|
if (!var)
|
||||||
|
return 0;
|
||||||
|
return atof (var->string);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cvar_VariableString
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
Cvar_VariableString (char *var_name)
|
||||||
|
{
|
||||||
|
cvar_t *var;
|
||||||
|
|
||||||
|
var = Cvar_FindVar (var_name);
|
||||||
|
if (!var)
|
||||||
|
var = Cvar_FindAlias (var_name);
|
||||||
|
if (!var)
|
||||||
|
return cvar_null_string;
|
||||||
|
return var->string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cvar_CompleteVariable
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
Cvar_CompleteVariable (char *partial)
|
||||||
|
{
|
||||||
|
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 (!strcasecmp (partial, cvar->name))
|
||||||
|
return cvar->name;
|
||||||
|
|
||||||
|
// check aliases too :)
|
||||||
|
for (alias = calias_vars; alias; alias = alias->next)
|
||||||
|
if (!strcasecmp (partial, alias->name))
|
||||||
|
return alias->name;
|
||||||
|
|
||||||
|
// check partial match
|
||||||
|
for (cvar = cvar_vars; cvar; cvar = cvar->next)
|
||||||
|
if (!strncasecmp (partial, cvar->name, len))
|
||||||
|
return cvar->name;
|
||||||
|
|
||||||
|
// check aliases too :)
|
||||||
|
for (alias = calias_vars; alias; alias = alias->next)
|
||||||
|
if (!strncasecmp (partial, alias->name, len))
|
||||||
|
return alias->name;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Cvar_Info (cvar_t *var);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cvar_Set
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cvar_Set (cvar_t *var, char *value)
|
||||||
|
{
|
||||||
|
if (!var)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (var->flags & CVAR_ROM) {
|
||||||
|
Con_DPrintf ("Cvar \"%s\" is read-only, cannot modify\n", var->name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
free (var->string); // free the old value string
|
||||||
|
|
||||||
|
var->string = strdup (value);
|
||||||
|
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]);
|
||||||
|
|
||||||
|
Cvar_Info (var);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cvar_SetROM
|
||||||
|
|
||||||
|
doesn't check for CVAR_ROM flag
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cvar_SetROM (cvar_t *var, char *value)
|
||||||
|
{
|
||||||
|
if (!var)
|
||||||
|
return;
|
||||||
|
|
||||||
|
free (var->string); // free the old value string
|
||||||
|
|
||||||
|
var->string = strdup (value);
|
||||||
|
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]);
|
||||||
|
|
||||||
|
Cvar_Info (var);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cvar_SetValue
|
||||||
|
*/
|
||||||
|
// 1999-09-07 weird cvar zeros fix by Maddes
|
||||||
|
void
|
||||||
|
Cvar_SetValue (cvar_t *var, float value)
|
||||||
|
{
|
||||||
|
char val[32];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
snprintf (val, sizeof (val), "%f", value);
|
||||||
|
for (i = strlen (val) - 1; i > 0 && val[i] == '0' && val[i - 1] != '.'; i--) {
|
||||||
|
val[i] = 0;
|
||||||
|
}
|
||||||
|
Cvar_Set (var, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cvar_Command
|
||||||
|
|
||||||
|
Handles variable inspection and changing from the console
|
||||||
|
*/
|
||||||
|
qboolean
|
||||||
|
Cvar_Command (void)
|
||||||
|
{
|
||||||
|
cvar_t *v;
|
||||||
|
|
||||||
|
// check variables
|
||||||
|
v = Cvar_FindVar (Cmd_Argv (0));
|
||||||
|
if (!v)
|
||||||
|
v = Cvar_FindAlias (Cmd_Argv (0));
|
||||||
|
if (!v)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// perform a variable print or set
|
||||||
|
if (Cmd_Argc () == 1) {
|
||||||
|
Con_Printf ("\"%s\" is \"%s\"\n", v->name, v->string);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Cvar_Set (v, Cmd_Argv (1));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cvar_WriteVariables
|
||||||
|
|
||||||
|
Writes lines containing "set variable value" for all variables
|
||||||
|
with the archive flag set to true.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cvar_WriteVariables (QFile *f)
|
||||||
|
{
|
||||||
|
cvar_t *var;
|
||||||
|
|
||||||
|
for (var = cvar_vars; var; var = var->next)
|
||||||
|
if (var->flags & CVAR_ARCHIVE)
|
||||||
|
Qprintf (f, "%s \"%s\"\n", var->name, var->string);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Cvar_Set_f (void)
|
||||||
|
{
|
||||||
|
cvar_t *var;
|
||||||
|
char *value;
|
||||||
|
char *var_name;
|
||||||
|
|
||||||
|
if (Cmd_Argc () != 3) {
|
||||||
|
Con_Printf ("usage: set <cvar> <value>\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var_name = Cmd_Argv (1);
|
||||||
|
value = Cmd_Argv (2);
|
||||||
|
var = Cvar_FindVar (var_name);
|
||||||
|
|
||||||
|
if (!var)
|
||||||
|
var = Cvar_FindAlias (var_name);
|
||||||
|
|
||||||
|
if (var) {
|
||||||
|
if (var->flags & CVAR_ROM) {
|
||||||
|
Con_DPrintf ("Cvar \"%s\" is read-only, cannot modify\n", var_name);
|
||||||
|
} else {
|
||||||
|
Cvar_Set (var, value);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var = Cvar_Get (var_name, value, CVAR_USER_CREATED,
|
||||||
|
"User-created cvar");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Cvar_Setrom_f (void)
|
||||||
|
{
|
||||||
|
cvar_t *var;
|
||||||
|
char *value;
|
||||||
|
char *var_name;
|
||||||
|
|
||||||
|
if (Cmd_Argc () != 3) {
|
||||||
|
Con_Printf ("usage: setrom <cvar> <value>\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var_name = Cmd_Argv (1);
|
||||||
|
value = Cmd_Argv (2);
|
||||||
|
var = Cvar_FindVar (var_name);
|
||||||
|
|
||||||
|
if (!var)
|
||||||
|
var = Cvar_FindAlias (var_name);
|
||||||
|
|
||||||
|
if (var) {
|
||||||
|
if (var->flags & CVAR_ROM) {
|
||||||
|
Con_DPrintf ("Cvar \"%s\" is read-only, cannot modify\n", var_name);
|
||||||
|
} else {
|
||||||
|
Cvar_Set (var, value);
|
||||||
|
Cvar_SetFlags (var, var->flags | CVAR_ROM);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var = Cvar_Get (var_name, value, CVAR_USER_CREATED | CVAR_ROM,
|
||||||
|
"User-created READ-ONLY Cvar");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Cvar_Toggle_f (void)
|
||||||
|
{
|
||||||
|
cvar_t *var;
|
||||||
|
|
||||||
|
if (Cmd_Argc () != 2) {
|
||||||
|
Con_Printf ("toggle <cvar> : toggle a cvar on/off\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var = Cvar_FindVar (Cmd_Argv (1));
|
||||||
|
if (!var)
|
||||||
|
var = Cvar_FindAlias (Cmd_Argv (1));
|
||||||
|
if (!var) {
|
||||||
|
Con_Printf ("Unknown variable \"%s\"\n", Cmd_Argv (1));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Cvar_Set (var, var->int_val ? "0" : "1");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Cvar_Help_f (void)
|
||||||
|
{
|
||||||
|
char *var_name;
|
||||||
|
cvar_t *var;
|
||||||
|
|
||||||
|
if (Cmd_Argc () != 2) {
|
||||||
|
Con_Printf ("usage: help <cvar>\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var_name = Cmd_Argv (1);
|
||||||
|
var = Cvar_FindVar (var_name);
|
||||||
|
if (!var)
|
||||||
|
var = Cvar_FindAlias (var_name);
|
||||||
|
if (var) {
|
||||||
|
Con_Printf ("%s\n", var->description);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Con_Printf ("variable not found\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Cvar_CvarList_f (void)
|
||||||
|
{
|
||||||
|
cvar_t *var;
|
||||||
|
int i;
|
||||||
|
int showhelp = 0;
|
||||||
|
|
||||||
|
if (Cmd_Argc () > 1)
|
||||||
|
showhelp = 1;
|
||||||
|
for (var = cvar_vars, i = 0; var; var = var->next, i++) {
|
||||||
|
Con_Printf ("%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)
|
||||||
|
Con_Printf ("%-20s : %s\n", var->name, var->description);
|
||||||
|
else
|
||||||
|
Con_Printf ("%s\n", var->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
Con_Printf ("------------\n%d variables\n", i);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cvar_free (void *c)
|
||||||
|
{
|
||||||
|
cvar_t *cvar = (cvar_t*)c;
|
||||||
|
free (cvar->name);
|
||||||
|
free (cvar->string);
|
||||||
|
free (cvar);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
cvar_get_key (void *c)
|
||||||
|
{
|
||||||
|
cvar_t *cvar = (cvar_t*)c;
|
||||||
|
return cvar->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
calias_free (void *c)
|
||||||
|
{
|
||||||
|
cvar_alias_t *calias = (cvar_alias_t*)c;
|
||||||
|
free (calias->name);
|
||||||
|
free (calias);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
calias_get_key (void *c)
|
||||||
|
{
|
||||||
|
cvar_alias_t *calias = (cvar_alias_t*)c;
|
||||||
|
return calias->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Cvar_Init_Hash (void)
|
||||||
|
{
|
||||||
|
cvar_hash = Hash_NewTable (1021, cvar_get_key, cvar_free);
|
||||||
|
calias_hash = Hash_NewTable (1021, calias_get_key, calias_free);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Cvar_Init (void)
|
||||||
|
{
|
||||||
|
developer = Cvar_Get ("developer", "0", 0, "set to enable extra debugging information");
|
||||||
|
|
||||||
|
Cmd_AddCommand ("set", Cvar_Set_f, "Set the selected variable, useful on the command line (+set variablename setting)");
|
||||||
|
Cmd_AddCommand ("setrom", Cvar_Setrom_f, "Set the selected variable and make it read only, useful on the command line.\n"
|
||||||
|
"(+setrom variablename setting)");
|
||||||
|
Cmd_AddCommand ("toggle", Cvar_Toggle_f, "Toggle a cvar on or off");
|
||||||
|
Cmd_AddCommand ("help", Cvar_Help_f, "Display quake help");
|
||||||
|
Cmd_AddCommand ("cvarlist", Cvar_CvarList_f, "List all cvars");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Cvar_Shutdown (void)
|
||||||
|
{
|
||||||
|
cvar_t *var, *next;
|
||||||
|
cvar_alias_t *alias, *nextalias;
|
||||||
|
|
||||||
|
// Free cvars
|
||||||
|
var = cvar_vars;
|
||||||
|
while (var) {
|
||||||
|
next = var->next;
|
||||||
|
free (var->string);
|
||||||
|
free (var->name);
|
||||||
|
free (var);
|
||||||
|
var = next;
|
||||||
|
}
|
||||||
|
// Free aliases
|
||||||
|
alias = calias_vars;
|
||||||
|
while (alias) {
|
||||||
|
nextalias = alias->next;
|
||||||
|
free (alias->name);
|
||||||
|
free (alias);
|
||||||
|
alias = nextalias;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cvar_t *
|
||||||
|
Cvar_Get (char *name, char *string, int cvarflags, char *description)
|
||||||
|
{
|
||||||
|
|
||||||
|
cvar_t *var;
|
||||||
|
|
||||||
|
if (Cmd_Exists (name)) {
|
||||||
|
Con_Printf ("Cvar_Get: %s is a command\n", name);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
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->flags = cvarflags;
|
||||||
|
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;
|
||||||
|
} else {
|
||||||
|
// Cvar does exist, so we update the flags and return.
|
||||||
|
var->flags &= ~CVAR_USER_CREATED;
|
||||||
|
var->flags |= cvarflags;
|
||||||
|
var->description = description;
|
||||||
|
}
|
||||||
|
Cvar_Info (var);
|
||||||
|
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cvar_SetFlags
|
||||||
|
|
||||||
|
sets a Cvar's flags simply and easily
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cvar_SetFlags (cvar_t *var, int cvarflags)
|
||||||
|
{
|
||||||
|
if (var == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var->flags = cvarflags;
|
||||||
|
}
|
135
libs/util/hash.c
Normal file
135
libs/util/hash.c
Normal file
|
@ -0,0 +1,135 @@
|
||||||
|
/*
|
||||||
|
hash.h
|
||||||
|
|
||||||
|
hash tables
|
||||||
|
|
||||||
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
|
Copyright (C) 2000 Marcus Sundberg <mackan@stacken.kth.se>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
# include <string.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STRINGS_H
|
||||||
|
# include <strings.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "compat.h"
|
||||||
|
#include "hash.h"
|
||||||
|
|
||||||
|
static unsigned long
|
||||||
|
hash (const char *str)
|
||||||
|
{
|
||||||
|
unsigned long h = 0;
|
||||||
|
while (*str) {
|
||||||
|
h = (h << 4) + (unsigned char)*str++;
|
||||||
|
if (h&0xf0000000)
|
||||||
|
h = (h ^ (h >> 24)) & 0xfffffff;
|
||||||
|
}
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
|
hashtab_t *
|
||||||
|
Hash_NewTable (int tsize, char *(*gk)(void*), void (*f)(void*))
|
||||||
|
{
|
||||||
|
hashtab_t *tab = calloc (1, (size_t)&((hashtab_t*)0)->tab[tsize]);
|
||||||
|
if (!tab)
|
||||||
|
return 0;
|
||||||
|
tab->tab_size = tsize;
|
||||||
|
tab->get_key = gk;
|
||||||
|
tab->free_ele = f;
|
||||||
|
return tab;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Hash_DelTable (hashtab_t *tab)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < tab->tab_size; i++) {
|
||||||
|
while (tab->tab[i]) {
|
||||||
|
hashlink_t *t = tab->tab[i]->next;
|
||||||
|
if (tab->free_ele)
|
||||||
|
tab->free_ele (&tab->tab[i]->data);
|
||||||
|
free (tab->tab[i]);
|
||||||
|
tab->tab[i] = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free (tab);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Hash_Add (hashtab_t *tab, void *ele)
|
||||||
|
{
|
||||||
|
unsigned long h = hash (tab->get_key(ele));
|
||||||
|
size_t ind = h % tab->tab_size;
|
||||||
|
hashlink_t *lnk = malloc (sizeof (hashlink_t));
|
||||||
|
|
||||||
|
if (!lnk)
|
||||||
|
return -1;
|
||||||
|
if (tab->tab[ind])
|
||||||
|
tab->tab[ind]->prev = &lnk->next;
|
||||||
|
lnk->next = tab->tab[ind];
|
||||||
|
lnk->prev = &tab->tab[ind];
|
||||||
|
lnk->data = ele;
|
||||||
|
tab->tab[ind] = lnk;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
Hash_Find (hashtab_t *tab, const char *key)
|
||||||
|
{
|
||||||
|
unsigned long h = hash (key);
|
||||||
|
size_t ind = h % tab->tab_size;
|
||||||
|
hashlink_t *lnk = tab->tab[ind];
|
||||||
|
|
||||||
|
while (lnk) {
|
||||||
|
if (strequal (key, tab->get_key (lnk->data)))
|
||||||
|
return lnk->data;
|
||||||
|
lnk = lnk->next;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Hash_Del (hashtab_t *tab, const char *key)
|
||||||
|
{
|
||||||
|
unsigned long h = hash (key);
|
||||||
|
size_t ind = h % tab->tab_size;
|
||||||
|
hashlink_t *lnk = tab->tab[ind];
|
||||||
|
|
||||||
|
while (lnk) {
|
||||||
|
if (strequal (key, tab->get_key (lnk->data))) {
|
||||||
|
if (lnk->next)
|
||||||
|
lnk->next->prev = lnk->prev;
|
||||||
|
*lnk->prev = lnk->next;
|
||||||
|
free (lnk);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
lnk = lnk->next;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
258
libs/util/mdfour.c
Normal file
258
libs/util/mdfour.c
Normal file
|
@ -0,0 +1,258 @@
|
||||||
|
/*
|
||||||
|
mdfour.c
|
||||||
|
|
||||||
|
An implementation of MD4 designed for use in the samba SMB
|
||||||
|
authentication protocol
|
||||||
|
|
||||||
|
Copyright (C) 1997-1998 Andrew Tridgell
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
# include <string.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STRINGS_H
|
||||||
|
# include <strings.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "mdfour.h"
|
||||||
|
#include "uint32.h"
|
||||||
|
|
||||||
|
/* NOTE: This code makes no attempt to be fast!
|
||||||
|
|
||||||
|
It assumes that a int is at least 32 bits long
|
||||||
|
*/
|
||||||
|
|
||||||
|
static struct mdfour *m;
|
||||||
|
|
||||||
|
#define F(X,Y,Z) (((X)&(Y)) | ((~(X))&(Z)))
|
||||||
|
#define G(X,Y,Z) (((X)&(Y)) | ((X)&(Z)) | ((Y)&(Z)))
|
||||||
|
#define H(X,Y,Z) ((X)^(Y)^(Z))
|
||||||
|
|
||||||
|
#ifdef LARGE_INT32
|
||||||
|
# define lshift(x,s) ((((x)<<(s))&0xFFFFFFFF) | (((x)>>(32-(s)))&0xFFFFFFFF))
|
||||||
|
#else
|
||||||
|
# define lshift(x,s) (((x)<<(s)) | ((x)>>(32-(s))))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ROUND1(a,b,c,d,k,s) a = lshift(a + F(b,c,d) + X[k], s)
|
||||||
|
#define ROUND2(a,b,c,d,k,s) a = lshift(a + G(b,c,d) + X[k] + 0x5A827999,s)
|
||||||
|
#define ROUND3(a,b,c,d,k,s) a = lshift(a + H(b,c,d) + X[k] + 0x6ED9EBA1,s)
|
||||||
|
|
||||||
|
/* this applies md4 to 64 byte chunks */
|
||||||
|
static void
|
||||||
|
mdfour64 (uint32 * M)
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
uint32 AA, BB, CC, DD;
|
||||||
|
uint32 X[16];
|
||||||
|
uint32 A, B, C, D;
|
||||||
|
|
||||||
|
for (j = 0; j < 16; j++)
|
||||||
|
X[j] = M[j];
|
||||||
|
|
||||||
|
A = m->A;
|
||||||
|
B = m->B;
|
||||||
|
C = m->C;
|
||||||
|
D = m->D;
|
||||||
|
AA = A;
|
||||||
|
BB = B;
|
||||||
|
CC = C;
|
||||||
|
DD = D;
|
||||||
|
|
||||||
|
ROUND1 (A, B, C, D, 0, 3);
|
||||||
|
ROUND1 (D, A, B, C, 1, 7);
|
||||||
|
ROUND1 (C, D, A, B, 2, 11);
|
||||||
|
ROUND1 (B, C, D, A, 3, 19);
|
||||||
|
ROUND1 (A, B, C, D, 4, 3);
|
||||||
|
ROUND1 (D, A, B, C, 5, 7);
|
||||||
|
ROUND1 (C, D, A, B, 6, 11);
|
||||||
|
ROUND1 (B, C, D, A, 7, 19);
|
||||||
|
ROUND1 (A, B, C, D, 8, 3);
|
||||||
|
ROUND1 (D, A, B, C, 9, 7);
|
||||||
|
ROUND1 (C, D, A, B, 10, 11);
|
||||||
|
ROUND1 (B, C, D, A, 11, 19);
|
||||||
|
ROUND1 (A, B, C, D, 12, 3);
|
||||||
|
ROUND1 (D, A, B, C, 13, 7);
|
||||||
|
ROUND1 (C, D, A, B, 14, 11);
|
||||||
|
ROUND1 (B, C, D, A, 15, 19);
|
||||||
|
|
||||||
|
ROUND2 (A, B, C, D, 0, 3);
|
||||||
|
ROUND2 (D, A, B, C, 4, 5);
|
||||||
|
ROUND2 (C, D, A, B, 8, 9);
|
||||||
|
ROUND2 (B, C, D, A, 12, 13);
|
||||||
|
ROUND2 (A, B, C, D, 1, 3);
|
||||||
|
ROUND2 (D, A, B, C, 5, 5);
|
||||||
|
ROUND2 (C, D, A, B, 9, 9);
|
||||||
|
ROUND2 (B, C, D, A, 13, 13);
|
||||||
|
ROUND2 (A, B, C, D, 2, 3);
|
||||||
|
ROUND2 (D, A, B, C, 6, 5);
|
||||||
|
ROUND2 (C, D, A, B, 10, 9);
|
||||||
|
ROUND2 (B, C, D, A, 14, 13);
|
||||||
|
ROUND2 (A, B, C, D, 3, 3);
|
||||||
|
ROUND2 (D, A, B, C, 7, 5);
|
||||||
|
ROUND2 (C, D, A, B, 11, 9);
|
||||||
|
ROUND2 (B, C, D, A, 15, 13);
|
||||||
|
|
||||||
|
ROUND3 (A, B, C, D, 0, 3);
|
||||||
|
ROUND3 (D, A, B, C, 8, 9);
|
||||||
|
ROUND3 (C, D, A, B, 4, 11);
|
||||||
|
ROUND3 (B, C, D, A, 12, 15);
|
||||||
|
ROUND3 (A, B, C, D, 2, 3);
|
||||||
|
ROUND3 (D, A, B, C, 10, 9);
|
||||||
|
ROUND3 (C, D, A, B, 6, 11);
|
||||||
|
ROUND3 (B, C, D, A, 14, 15);
|
||||||
|
ROUND3 (A, B, C, D, 1, 3);
|
||||||
|
ROUND3 (D, A, B, C, 9, 9);
|
||||||
|
ROUND3 (C, D, A, B, 5, 11);
|
||||||
|
ROUND3 (B, C, D, A, 13, 15);
|
||||||
|
ROUND3 (A, B, C, D, 3, 3);
|
||||||
|
ROUND3 (D, A, B, C, 11, 9);
|
||||||
|
ROUND3 (C, D, A, B, 7, 11);
|
||||||
|
ROUND3 (B, C, D, A, 15, 15);
|
||||||
|
|
||||||
|
A += AA;
|
||||||
|
B += BB;
|
||||||
|
C += CC;
|
||||||
|
D += DD;
|
||||||
|
|
||||||
|
#ifdef LARGE_INT32
|
||||||
|
A &= 0xFFFFFFFF;
|
||||||
|
B &= 0xFFFFFFFF;
|
||||||
|
C &= 0xFFFFFFFF;
|
||||||
|
D &= 0xFFFFFFFF;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (j = 0; j < 16; j++)
|
||||||
|
X[j] = 0;
|
||||||
|
|
||||||
|
m->A = A;
|
||||||
|
m->B = B;
|
||||||
|
m->C = C;
|
||||||
|
m->D = D;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
copy64 (uint32 * M, unsigned char *in)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < 16; i++)
|
||||||
|
M[i] = (in[i * 4 + 3] << 24) | (in[i * 4 + 2] << 16) |
|
||||||
|
(in[i * 4 + 1] << 8) | (in[i * 4 + 0] << 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
copy4 (unsigned char *out, uint32 x)
|
||||||
|
{
|
||||||
|
out[0] = x & 0xFF;
|
||||||
|
out[1] = (x >> 8) & 0xFF;
|
||||||
|
out[2] = (x >> 16) & 0xFF;
|
||||||
|
out[3] = (x >> 24) & 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
mdfour_begin (struct mdfour *md)
|
||||||
|
{
|
||||||
|
md->A = 0x67452301;
|
||||||
|
md->B = 0xefcdab89;
|
||||||
|
md->C = 0x98badcfe;
|
||||||
|
md->D = 0x10325476;
|
||||||
|
md->totalN = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
mdfour_tail (unsigned char *in, int n)
|
||||||
|
{
|
||||||
|
unsigned char buf[128];
|
||||||
|
uint32 M[16];
|
||||||
|
uint32 b;
|
||||||
|
|
||||||
|
m->totalN += n;
|
||||||
|
|
||||||
|
b = m->totalN * 8;
|
||||||
|
|
||||||
|
memset (buf, 0, 128);
|
||||||
|
if (n)
|
||||||
|
memcpy (buf, in, n);
|
||||||
|
buf[n] = 0x80;
|
||||||
|
|
||||||
|
if (n <= 55) {
|
||||||
|
copy4 (buf + 56, b);
|
||||||
|
copy64 (M, buf);
|
||||||
|
mdfour64 (M);
|
||||||
|
} else {
|
||||||
|
copy4 (buf + 120, b);
|
||||||
|
copy64 (M, buf);
|
||||||
|
mdfour64 (M);
|
||||||
|
copy64 (M, buf + 64);
|
||||||
|
mdfour64 (M);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
mdfour_update (struct mdfour *md, unsigned char *in, int n)
|
||||||
|
{
|
||||||
|
uint32 M[16];
|
||||||
|
|
||||||
|
if (n == 0)
|
||||||
|
mdfour_tail (in, n);
|
||||||
|
|
||||||
|
m = md;
|
||||||
|
|
||||||
|
while (n >= 64) {
|
||||||
|
copy64 (M, in);
|
||||||
|
mdfour64 (M);
|
||||||
|
in += 64;
|
||||||
|
n -= 64;
|
||||||
|
m->totalN += 64;
|
||||||
|
}
|
||||||
|
|
||||||
|
mdfour_tail (in, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
mdfour_result (struct mdfour *md, unsigned char *out)
|
||||||
|
{
|
||||||
|
m = md;
|
||||||
|
|
||||||
|
copy4 (out, m->A);
|
||||||
|
copy4 (out + 4, m->B);
|
||||||
|
copy4 (out + 8, m->C);
|
||||||
|
copy4 (out + 12, m->D);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
mdfour (unsigned char *out, unsigned char *in, int n)
|
||||||
|
{
|
||||||
|
struct mdfour md;
|
||||||
|
|
||||||
|
mdfour_begin (&md);
|
||||||
|
mdfour_update (&md, in, n);
|
||||||
|
mdfour_result (&md, out);
|
||||||
|
}
|
95
libs/util/sizebuf.c
Normal file
95
libs/util/sizebuf.c
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
/*
|
||||||
|
sizebuf.c
|
||||||
|
|
||||||
|
(description)
|
||||||
|
|
||||||
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
# include <string.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STRINGS_H
|
||||||
|
# include <strings.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "console.h"
|
||||||
|
#include "sizebuf.h"
|
||||||
|
#include "sys.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
SZ_Clear (sizebuf_t *buf)
|
||||||
|
{
|
||||||
|
buf->cursize = 0;
|
||||||
|
buf->overflowed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
SZ_GetSpace (sizebuf_t *buf, int length)
|
||||||
|
{
|
||||||
|
void *data;
|
||||||
|
|
||||||
|
if (buf->cursize + length > buf->maxsize) {
|
||||||
|
if (!buf->allowoverflow)
|
||||||
|
Sys_Error ("SZ_GetSpace: overflow without allowoverflow set (%d)",
|
||||||
|
buf->maxsize);
|
||||||
|
|
||||||
|
if (length > buf->maxsize)
|
||||||
|
Sys_Error ("SZ_GetSpace: %i is > full buffer size", length);
|
||||||
|
|
||||||
|
Con_Printf ("SZ_GetSpace: overflow\n");
|
||||||
|
SZ_Clear (buf);
|
||||||
|
buf->overflowed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
data = buf->data + buf->cursize;
|
||||||
|
buf->cursize += length;
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SZ_Write (sizebuf_t *buf, void *data, int length)
|
||||||
|
{
|
||||||
|
memcpy (SZ_GetSpace (buf, length), data, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SZ_Print (sizebuf_t *buf, char *data)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
|
||||||
|
len = strlen (data) + 1;
|
||||||
|
|
||||||
|
if (!buf->cursize || buf->data[buf->cursize - 1])
|
||||||
|
memcpy ((byte *) SZ_GetSpace (buf, len), data, len); // no
|
||||||
|
// trailing 0
|
||||||
|
else
|
||||||
|
memcpy ((byte *) SZ_GetSpace (buf, len - 1) - 1, data, len); // write
|
||||||
|
// over
|
||||||
|
// trailing
|
||||||
|
// 0
|
||||||
|
}
|
56
libs/util/va.c
Normal file
56
libs/util/va.c
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
va.c
|
||||||
|
|
||||||
|
varargs printf function
|
||||||
|
|
||||||
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#include "qtypes.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
va
|
||||||
|
|
||||||
|
does a varargs printf into a temp buffer, so I don't need to have
|
||||||
|
varargs versions of all text functions.
|
||||||
|
FIXME: make this buffer size safe someday
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
va (char *format, ...)
|
||||||
|
{
|
||||||
|
va_list argptr;
|
||||||
|
static char string[1024];
|
||||||
|
|
||||||
|
va_start (argptr, format);
|
||||||
|
vsnprintf (string, sizeof (string), format, argptr);
|
||||||
|
va_end (argptr);
|
||||||
|
|
||||||
|
return string;
|
||||||
|
}
|
680
libs/util/zone.c
Normal file
680
libs/util/zone.c
Normal file
|
@ -0,0 +1,680 @@
|
||||||
|
/*
|
||||||
|
zone.c
|
||||||
|
|
||||||
|
(description)
|
||||||
|
|
||||||
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
# include <string.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STRINGS_H
|
||||||
|
# include <strings.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "cmd.h"
|
||||||
|
#include "console.h"
|
||||||
|
#include "qargs.h"
|
||||||
|
#include "sys.h"
|
||||||
|
#include "zone.h"
|
||||||
|
|
||||||
|
#define DYNAMIC_SIZE 0x20000
|
||||||
|
#define ZONEID 0x1d4a11
|
||||||
|
#define HUNK_SENTINAL 0x1df001ed
|
||||||
|
|
||||||
|
#define MINFRAGMENT 64
|
||||||
|
|
||||||
|
void Cache_FreeLow (int new_low_hunk);
|
||||||
|
void Cache_FreeHigh (int new_high_hunk);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
The zone calls are pretty much only used for small strings and structures,
|
||||||
|
all big things are allocated on the hunk.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int sentinal;
|
||||||
|
int size; // including sizeof(hunk_t), -1 = not
|
||||||
|
// allocated
|
||||||
|
char name[8];
|
||||||
|
} hunk_t;
|
||||||
|
|
||||||
|
byte *hunk_base;
|
||||||
|
int hunk_size;
|
||||||
|
|
||||||
|
int hunk_low_used;
|
||||||
|
int hunk_high_used;
|
||||||
|
|
||||||
|
qboolean hunk_tempactive;
|
||||||
|
int hunk_tempmark;
|
||||||
|
|
||||||
|
void R_FreeTextures (void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Hunk_Check
|
||||||
|
|
||||||
|
Run consistancy and sentinal trahing checks
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Hunk_Check (void)
|
||||||
|
{
|
||||||
|
hunk_t *h;
|
||||||
|
|
||||||
|
for (h = (hunk_t *) hunk_base; (byte *) h != hunk_base + hunk_low_used;) {
|
||||||
|
if (h->sentinal != HUNK_SENTINAL)
|
||||||
|
Sys_Error ("Hunk_Check: trashed sentinal");
|
||||||
|
if (h->size < 16 || h->size + (byte *) h - hunk_base > hunk_size)
|
||||||
|
Sys_Error ("Hunk_Check: bad size");
|
||||||
|
h = (hunk_t *) ((byte *) h + h->size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Hunk_Print
|
||||||
|
|
||||||
|
If "all" is specified, every single allocation is printed.
|
||||||
|
Otherwise, allocations with the same name will be totaled up before
|
||||||
|
printing.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Hunk_Print (qboolean all)
|
||||||
|
{
|
||||||
|
hunk_t *h, *next, *endlow, *starthigh, *endhigh;
|
||||||
|
int count, sum;
|
||||||
|
int totalblocks;
|
||||||
|
char name[9];
|
||||||
|
|
||||||
|
name[8] = 0;
|
||||||
|
count = 0;
|
||||||
|
sum = 0;
|
||||||
|
totalblocks = 0;
|
||||||
|
|
||||||
|
h = (hunk_t *) hunk_base;
|
||||||
|
endlow = (hunk_t *) (hunk_base + hunk_low_used);
|
||||||
|
starthigh = (hunk_t *) (hunk_base + hunk_size - hunk_high_used);
|
||||||
|
endhigh = (hunk_t *) (hunk_base + hunk_size);
|
||||||
|
|
||||||
|
Con_Printf (" :%8i total hunk size\n", hunk_size);
|
||||||
|
Con_Printf ("-------------------------\n");
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
//
|
||||||
|
// skip to the high hunk if done with low hunk
|
||||||
|
//
|
||||||
|
if (h == endlow) {
|
||||||
|
Con_Printf ("-------------------------\n");
|
||||||
|
Con_Printf (" :%8i REMAINING\n",
|
||||||
|
hunk_size - hunk_low_used - hunk_high_used);
|
||||||
|
Con_Printf ("-------------------------\n");
|
||||||
|
h = starthigh;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// if totally done, break
|
||||||
|
//
|
||||||
|
if (h == endhigh)
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// run consistancy checks
|
||||||
|
//
|
||||||
|
if (h->sentinal != HUNK_SENTINAL)
|
||||||
|
Sys_Error ("Hunk_Check: trahsed sentinal");
|
||||||
|
if (h->size < 16 || h->size + (byte *) h - hunk_base > hunk_size)
|
||||||
|
Sys_Error ("Hunk_Check: bad size");
|
||||||
|
|
||||||
|
next = (hunk_t *) ((byte *) h + h->size);
|
||||||
|
count++;
|
||||||
|
totalblocks++;
|
||||||
|
sum += h->size;
|
||||||
|
|
||||||
|
//
|
||||||
|
// print the single block
|
||||||
|
//
|
||||||
|
memcpy (name, h->name, 8);
|
||||||
|
if (all)
|
||||||
|
Con_Printf ("%8p :%8i %8s\n", h, h->size, name);
|
||||||
|
|
||||||
|
//
|
||||||
|
// print the total
|
||||||
|
//
|
||||||
|
if (next == endlow || next == endhigh ||
|
||||||
|
strncmp (h->name, next->name, 8)) {
|
||||||
|
if (!all)
|
||||||
|
Con_Printf (" :%8i %8s (TOTAL)\n", sum, name);
|
||||||
|
count = 0;
|
||||||
|
sum = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
h = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
Con_Printf ("-------------------------\n");
|
||||||
|
Con_Printf ("%8i total blocks\n", totalblocks);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Hunk_AllocName
|
||||||
|
*/
|
||||||
|
void *
|
||||||
|
Hunk_AllocName (int size, char *name)
|
||||||
|
{
|
||||||
|
hunk_t *h;
|
||||||
|
|
||||||
|
#ifdef PARANOID
|
||||||
|
Hunk_Check ();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (size < 0)
|
||||||
|
Sys_Error ("Hunk_Alloc: bad size: %i", size);
|
||||||
|
|
||||||
|
size = sizeof (hunk_t) + ((size + 15) & ~15);
|
||||||
|
|
||||||
|
if (hunk_size - hunk_low_used - hunk_high_used < size)
|
||||||
|
// Sys_Error ("Hunk_Alloc: failed on %i bytes",size);
|
||||||
|
#ifdef _WIN32
|
||||||
|
Sys_Error
|
||||||
|
("Not enough RAM allocated. Try starting using \"-heapsize 16000\" on the %s command line.",
|
||||||
|
PROGRAM);
|
||||||
|
#else
|
||||||
|
Sys_Error
|
||||||
|
("Not enough RAM allocated. Try starting using \"-mem 16\" on the %s command line.",
|
||||||
|
PROGRAM);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
h = (hunk_t *) (hunk_base + hunk_low_used);
|
||||||
|
hunk_low_used += size;
|
||||||
|
|
||||||
|
Cache_FreeLow (hunk_low_used);
|
||||||
|
|
||||||
|
memset (h, 0, size);
|
||||||
|
|
||||||
|
h->size = size;
|
||||||
|
h->sentinal = HUNK_SENTINAL;
|
||||||
|
strncpy (h->name, name, 8);
|
||||||
|
|
||||||
|
return (void *) (h + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Hunk_Alloc
|
||||||
|
*/
|
||||||
|
void *
|
||||||
|
Hunk_Alloc (int size)
|
||||||
|
{
|
||||||
|
return Hunk_AllocName (size, "unknown");
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Hunk_LowMark (void)
|
||||||
|
{
|
||||||
|
return hunk_low_used;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Hunk_FreeToLowMark (int mark)
|
||||||
|
{
|
||||||
|
if (mark < 0 || mark > hunk_low_used)
|
||||||
|
Sys_Error ("Hunk_FreeToLowMark: bad mark %i", mark);
|
||||||
|
memset (hunk_base + mark, 0, hunk_low_used - mark);
|
||||||
|
hunk_low_used = mark;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Hunk_HighMark (void)
|
||||||
|
{
|
||||||
|
if (hunk_tempactive) {
|
||||||
|
hunk_tempactive = false;
|
||||||
|
Hunk_FreeToHighMark (hunk_tempmark);
|
||||||
|
}
|
||||||
|
|
||||||
|
return hunk_high_used;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Hunk_FreeToHighMark (int mark)
|
||||||
|
{
|
||||||
|
if (hunk_tempactive) {
|
||||||
|
hunk_tempactive = false;
|
||||||
|
Hunk_FreeToHighMark (hunk_tempmark);
|
||||||
|
}
|
||||||
|
if (mark < 0 || mark > hunk_high_used)
|
||||||
|
Sys_Error ("Hunk_FreeToHighMark: bad mark %i", mark);
|
||||||
|
memset (hunk_base + hunk_size - hunk_high_used, 0, hunk_high_used - mark);
|
||||||
|
hunk_high_used = mark;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Hunk_HighAllocName
|
||||||
|
*/
|
||||||
|
void *
|
||||||
|
Hunk_HighAllocName (int size, char *name)
|
||||||
|
{
|
||||||
|
hunk_t *h;
|
||||||
|
|
||||||
|
if (size < 0)
|
||||||
|
Sys_Error ("Hunk_HighAllocName: bad size: %i", size);
|
||||||
|
|
||||||
|
if (hunk_tempactive) {
|
||||||
|
Hunk_FreeToHighMark (hunk_tempmark);
|
||||||
|
hunk_tempactive = false;
|
||||||
|
}
|
||||||
|
#ifdef PARANOID
|
||||||
|
Hunk_Check ();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
size = sizeof (hunk_t) + ((size + 15) & ~15);
|
||||||
|
|
||||||
|
if (hunk_size - hunk_low_used - hunk_high_used < size) {
|
||||||
|
Con_Printf ("Hunk_HighAlloc: failed on %i bytes\n", size);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
hunk_high_used += size;
|
||||||
|
Cache_FreeHigh (hunk_high_used);
|
||||||
|
|
||||||
|
h = (hunk_t *) (hunk_base + hunk_size - hunk_high_used);
|
||||||
|
|
||||||
|
memset (h, 0, size);
|
||||||
|
h->size = size;
|
||||||
|
h->sentinal = HUNK_SENTINAL;
|
||||||
|
strncpy (h->name, name, 8);
|
||||||
|
|
||||||
|
return (void *) (h + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Hunk_TempAlloc
|
||||||
|
|
||||||
|
Return space from the top of the hunk
|
||||||
|
*/
|
||||||
|
void *
|
||||||
|
Hunk_TempAlloc (int size)
|
||||||
|
{
|
||||||
|
void *buf;
|
||||||
|
|
||||||
|
size = (size + 15) & ~15;
|
||||||
|
|
||||||
|
if (hunk_tempactive) {
|
||||||
|
Hunk_FreeToHighMark (hunk_tempmark);
|
||||||
|
hunk_tempactive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
hunk_tempmark = Hunk_HighMark ();
|
||||||
|
|
||||||
|
buf = Hunk_HighAllocName (size, "temp");
|
||||||
|
|
||||||
|
hunk_tempactive = true;
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
CACHE MEMORY
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct cache_system_s {
|
||||||
|
int size; // including this header
|
||||||
|
cache_user_t *user;
|
||||||
|
char name[16];
|
||||||
|
struct cache_system_s *prev, *next;
|
||||||
|
struct cache_system_s *lru_prev, *lru_next; // for LRU flushing
|
||||||
|
} cache_system_t;
|
||||||
|
|
||||||
|
cache_system_t *Cache_TryAlloc (int size, qboolean nobottom);
|
||||||
|
|
||||||
|
cache_system_t cache_head;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cache_Move
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cache_Move (cache_system_t * c)
|
||||||
|
{
|
||||||
|
cache_system_t *new;
|
||||||
|
|
||||||
|
// we are clearing up space at the bottom, so only allocate it late
|
||||||
|
new = Cache_TryAlloc (c->size, true);
|
||||||
|
if (new) {
|
||||||
|
// Con_Printf ("cache_move ok\n");
|
||||||
|
|
||||||
|
memcpy (new + 1, c + 1, c->size - sizeof (cache_system_t));
|
||||||
|
new->user = c->user;
|
||||||
|
memcpy (new->name, c->name, sizeof (new->name));
|
||||||
|
Cache_Free (c->user);
|
||||||
|
new->user->data = (void *) (new + 1);
|
||||||
|
} else {
|
||||||
|
// Con_Printf ("cache_move failed\n");
|
||||||
|
|
||||||
|
Cache_Free (c->user); // tough luck...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cache_FreeLow
|
||||||
|
|
||||||
|
Throw things out until the hunk can be expanded to the given point
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cache_FreeLow (int new_low_hunk)
|
||||||
|
{
|
||||||
|
cache_system_t *c;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
c = cache_head.next;
|
||||||
|
if (c == &cache_head)
|
||||||
|
return; // nothing in cache at all
|
||||||
|
if ((byte *) c >= hunk_base + new_low_hunk)
|
||||||
|
return; // there is space to grow the hunk
|
||||||
|
Cache_Move (c); // reclaim the space
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cache_FreeHigh
|
||||||
|
|
||||||
|
Throw things out until the hunk can be expanded to the given point
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cache_FreeHigh (int new_high_hunk)
|
||||||
|
{
|
||||||
|
cache_system_t *c, *prev;
|
||||||
|
|
||||||
|
prev = NULL;
|
||||||
|
while (1) {
|
||||||
|
c = cache_head.prev;
|
||||||
|
if (c == &cache_head)
|
||||||
|
return; // nothing in cache at all
|
||||||
|
if ((byte *) c + c->size <= hunk_base + hunk_size - new_high_hunk)
|
||||||
|
return; // there is space to grow the hunk
|
||||||
|
if (c == prev)
|
||||||
|
Cache_Free (c->user); // didn't move out of the way
|
||||||
|
else {
|
||||||
|
Cache_Move (c); // try to move it
|
||||||
|
prev = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Cache_UnlinkLRU (cache_system_t * cs)
|
||||||
|
{
|
||||||
|
if (!cs->lru_next || !cs->lru_prev)
|
||||||
|
Sys_Error ("Cache_UnlinkLRU: NULL link");
|
||||||
|
|
||||||
|
cs->lru_next->lru_prev = cs->lru_prev;
|
||||||
|
cs->lru_prev->lru_next = cs->lru_next;
|
||||||
|
|
||||||
|
cs->lru_prev = cs->lru_next = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Cache_MakeLRU (cache_system_t * cs)
|
||||||
|
{
|
||||||
|
if (cs->lru_next || cs->lru_prev)
|
||||||
|
Sys_Error ("Cache_MakeLRU: active link");
|
||||||
|
|
||||||
|
cache_head.lru_next->lru_prev = cs;
|
||||||
|
cs->lru_next = cache_head.lru_next;
|
||||||
|
cs->lru_prev = &cache_head;
|
||||||
|
cache_head.lru_next = cs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cache_TryAlloc
|
||||||
|
|
||||||
|
Looks for a free block of memory between the high and low hunk marks
|
||||||
|
Size should already include the header and padding
|
||||||
|
*/
|
||||||
|
cache_system_t *
|
||||||
|
Cache_TryAlloc (int size, qboolean nobottom)
|
||||||
|
{
|
||||||
|
cache_system_t *cs, *new;
|
||||||
|
|
||||||
|
// is the cache completely empty?
|
||||||
|
|
||||||
|
if (!nobottom && cache_head.prev == &cache_head) {
|
||||||
|
if (hunk_size - hunk_high_used - hunk_low_used < size)
|
||||||
|
Sys_Error ("Cache_TryAlloc: %i is greater then free hunk", size);
|
||||||
|
|
||||||
|
new = (cache_system_t *) (hunk_base + hunk_low_used);
|
||||||
|
memset (new, 0, sizeof (*new));
|
||||||
|
new->size = size;
|
||||||
|
|
||||||
|
cache_head.prev = cache_head.next = new;
|
||||||
|
new->prev = new->next = &cache_head;
|
||||||
|
|
||||||
|
Cache_MakeLRU (new);
|
||||||
|
return new;
|
||||||
|
}
|
||||||
|
// search from the bottom up for space
|
||||||
|
|
||||||
|
new = (cache_system_t *) (hunk_base + hunk_low_used);
|
||||||
|
cs = cache_head.next;
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (!nobottom || cs != cache_head.next) {
|
||||||
|
if ((byte *) cs - (byte *) new >= size) { // found space
|
||||||
|
memset (new, 0, sizeof (*new));
|
||||||
|
new->size = size;
|
||||||
|
|
||||||
|
new->next = cs;
|
||||||
|
new->prev = cs->prev;
|
||||||
|
cs->prev->next = new;
|
||||||
|
cs->prev = new;
|
||||||
|
|
||||||
|
Cache_MakeLRU (new);
|
||||||
|
|
||||||
|
return new;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// continue looking
|
||||||
|
new = (cache_system_t *) ((byte *) cs + cs->size);
|
||||||
|
cs = cs->next;
|
||||||
|
|
||||||
|
} while (cs != &cache_head);
|
||||||
|
|
||||||
|
// try to allocate one at the very end
|
||||||
|
if (hunk_base + hunk_size - hunk_high_used - (byte *) new >= size) {
|
||||||
|
memset (new, 0, sizeof (*new));
|
||||||
|
new->size = size;
|
||||||
|
|
||||||
|
new->next = &cache_head;
|
||||||
|
new->prev = cache_head.prev;
|
||||||
|
cache_head.prev->next = new;
|
||||||
|
cache_head.prev = new;
|
||||||
|
|
||||||
|
Cache_MakeLRU (new);
|
||||||
|
|
||||||
|
return new;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL; // couldn't allocate
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cache_Flush
|
||||||
|
|
||||||
|
Throw everything out, so new data will be demand cached
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cache_Flush (void)
|
||||||
|
{
|
||||||
|
while (cache_head.next != &cache_head)
|
||||||
|
Cache_Free (cache_head.next->user); // reclaim the space
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cache_Print
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cache_Print (void)
|
||||||
|
{
|
||||||
|
cache_system_t *cd;
|
||||||
|
|
||||||
|
for (cd = cache_head.next; cd != &cache_head; cd = cd->next) {
|
||||||
|
Con_Printf ("%8i : %s\n", cd->size, cd->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cache_Report
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cache_Report (void)
|
||||||
|
{
|
||||||
|
Con_DPrintf ("%4.1f megabyte data cache\n",
|
||||||
|
(hunk_size - hunk_high_used -
|
||||||
|
hunk_low_used) / (float) (1024 * 1024));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cache_Compact
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cache_Compact (void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cache_Init
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cache_Init (void)
|
||||||
|
{
|
||||||
|
cache_head.next = cache_head.prev = &cache_head;
|
||||||
|
cache_head.lru_next = cache_head.lru_prev = &cache_head;
|
||||||
|
|
||||||
|
Cmd_AddCommand ("flush", Cache_Flush, "Clears the current game cache");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cache_Free
|
||||||
|
|
||||||
|
Frees the memory and removes it from the LRU list
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Cache_Free (cache_user_t *c)
|
||||||
|
{
|
||||||
|
cache_system_t *cs;
|
||||||
|
|
||||||
|
if (!c->data)
|
||||||
|
Sys_Error ("Cache_Free: not allocated");
|
||||||
|
|
||||||
|
cs = ((cache_system_t *) c->data) - 1;
|
||||||
|
|
||||||
|
cs->prev->next = cs->next;
|
||||||
|
cs->next->prev = cs->prev;
|
||||||
|
cs->next = cs->prev = NULL;
|
||||||
|
|
||||||
|
c->data = NULL;
|
||||||
|
|
||||||
|
Cache_UnlinkLRU (cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cache_Check
|
||||||
|
*/
|
||||||
|
void *
|
||||||
|
Cache_Check (cache_user_t *c)
|
||||||
|
{
|
||||||
|
cache_system_t *cs;
|
||||||
|
|
||||||
|
if (!c->data)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
cs = ((cache_system_t *) c->data) - 1;
|
||||||
|
|
||||||
|
// move to head of LRU
|
||||||
|
Cache_UnlinkLRU (cs);
|
||||||
|
Cache_MakeLRU (cs);
|
||||||
|
|
||||||
|
return c->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Cache_Alloc
|
||||||
|
*/
|
||||||
|
void *
|
||||||
|
Cache_Alloc (cache_user_t *c, int size, char *name)
|
||||||
|
{
|
||||||
|
cache_system_t *cs;
|
||||||
|
|
||||||
|
if (c->data)
|
||||||
|
Sys_Error ("Cache_Alloc: allready allocated");
|
||||||
|
|
||||||
|
if (size <= 0)
|
||||||
|
Sys_Error ("Cache_Alloc: size %i", size);
|
||||||
|
|
||||||
|
size = (size + sizeof (cache_system_t) + 15) & ~15;
|
||||||
|
|
||||||
|
// find memory for it
|
||||||
|
while (1) {
|
||||||
|
cs = Cache_TryAlloc (size, false);
|
||||||
|
if (cs) {
|
||||||
|
strncpy (cs->name, name, sizeof (cs->name) - 1);
|
||||||
|
c->data = (void *) (cs + 1);
|
||||||
|
cs->user = c;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// free the least recently used cahedat
|
||||||
|
if (cache_head.lru_prev == &cache_head)
|
||||||
|
Sys_Error ("Cache_Alloc: out of memory");
|
||||||
|
// not enough memory at all
|
||||||
|
Cache_Free (cache_head.lru_prev->user);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Cache_Check (c);
|
||||||
|
}
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Memory_Init
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Memory_Init (void *buf, int size)
|
||||||
|
{
|
||||||
|
hunk_base = buf;
|
||||||
|
hunk_size = size;
|
||||||
|
hunk_low_used = 0;
|
||||||
|
hunk_high_used = 0;
|
||||||
|
|
||||||
|
Cache_Init ();
|
||||||
|
}
|
|
@ -40,7 +40,7 @@
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "cvar.h"
|
#include "cvar.h"
|
||||||
#include "quakefs.h"
|
#include "quakefs.h"
|
||||||
#include "qdefs.h"
|
#include "game.h"
|
||||||
|
|
||||||
typedef struct usercmd_s
|
typedef struct usercmd_s
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,120 +0,0 @@
|
||||||
/*
|
|
||||||
cvar.h
|
|
||||||
|
|
||||||
Configuration variable definitions and prototypes
|
|
||||||
|
|
||||||
Copyright (C) 1996-1997 Id Software, Inc.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
|
|
||||||
See the GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to:
|
|
||||||
|
|
||||||
Free Software Foundation, Inc.
|
|
||||||
59 Temple Place - Suite 330
|
|
||||||
Boston, MA 02111-1307, USA
|
|
||||||
|
|
||||||
$Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _CVAR_H
|
|
||||||
#define _CVAR_H
|
|
||||||
|
|
||||||
//#include "qtypes.h"
|
|
||||||
#include "quakeio.h"
|
|
||||||
#include "cmd.h"
|
|
||||||
|
|
||||||
typedef struct cvar_s
|
|
||||||
{
|
|
||||||
char *name;
|
|
||||||
char *string;
|
|
||||||
int flags;
|
|
||||||
char *description; // for "help" command
|
|
||||||
float value;
|
|
||||||
int int_val;
|
|
||||||
struct cvar_s *next;
|
|
||||||
} cvar_t;
|
|
||||||
|
|
||||||
typedef struct cvar_alias_s
|
|
||||||
{
|
|
||||||
char *name;
|
|
||||||
cvar_t *cvar;
|
|
||||||
struct cvar_alias_s *next;
|
|
||||||
} cvar_alias_t;
|
|
||||||
|
|
||||||
#define CVAR_NONE 0
|
|
||||||
#define CVAR_ARCHIVE 1 // set to cause it to be saved to vars.rc
|
|
||||||
// used for system variables, not for player
|
|
||||||
// specific configurations
|
|
||||||
#define CVAR_USERINFO 2 // sent to server on connect or change
|
|
||||||
#define CVAR_SERVERINFO 4 // sent in response to front end requests
|
|
||||||
#define CVAR_NOTIFY 32 // Will notify players when changed.
|
|
||||||
#define CVAR_ROM 64 // display only, cannot be set by user at all
|
|
||||||
#define CVAR_USER_CREATED 128 // created by a set command
|
|
||||||
#define CVAR_LATCH 2048 // will only change when C code next does
|
|
||||||
// a Cvar_Get(), so it can't be changed
|
|
||||||
|
|
||||||
// Zoid| A good CVAR_ROM example is userpath. The code should read "cvar_t
|
|
||||||
// *fs_userpath = CvarGet("fs_userpath", ".", CVAR_ROM); The user can
|
|
||||||
// override that with +set fs_userpath <blah> since the command line +set gets
|
|
||||||
// created _before_ the C code for fs_basepath setup is called. The code goes
|
|
||||||
// "look, the user made fs_basepath already", uses the users value, but sets
|
|
||||||
// CVAR_ROM as per the call.
|
|
||||||
|
|
||||||
|
|
||||||
// Returns the Cvar if found, creates it with value if not. Description and
|
|
||||||
// flags are always updated.
|
|
||||||
cvar_t *Cvar_Get (char *name, char *value, int cvarflags, char *description);
|
|
||||||
|
|
||||||
cvar_t *Cvar_FindAlias (char *alias_name);
|
|
||||||
|
|
||||||
void Cvar_Alias_Get (char *name, cvar_t *cvar);
|
|
||||||
|
|
||||||
// equivelants to "<name> <variable>" typed at the console
|
|
||||||
void Cvar_Set (cvar_t *var, char *value);
|
|
||||||
void Cvar_SetValue (cvar_t *var, float value);
|
|
||||||
|
|
||||||
// sets a CVAR_ROM variable from within the engine
|
|
||||||
void Cvar_SetROM (cvar_t *var, 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 (char *var_name);
|
|
||||||
|
|
||||||
// returns an empty string if not defined
|
|
||||||
char *Cvar_VariableString (char *var_name);
|
|
||||||
|
|
||||||
// attempts to match a partial variable name for command line completion
|
|
||||||
// returns NULL if nothing fits
|
|
||||||
char *Cvar_CompleteVariable (char *partial);
|
|
||||||
|
|
||||||
// called by Cmd_ExecuteString when Cmd_Argv(0) doesn't match a known
|
|
||||||
// command. Returns true if the command was a variable reference that
|
|
||||||
// was handled. (print or change)
|
|
||||||
qboolean Cvar_Command (void);
|
|
||||||
|
|
||||||
// Writes lines containing "set variable value" for all variables
|
|
||||||
// with the archive flag set to true.
|
|
||||||
void Cvar_WriteVariables (QFile *f);
|
|
||||||
|
|
||||||
// Returns a pointer to the Cvar, NULL if not found
|
|
||||||
cvar_t *Cvar_FindVar (char *var_name);
|
|
||||||
|
|
||||||
void Cvar_Init();
|
|
||||||
|
|
||||||
void Cvar_Shutdown();
|
|
||||||
|
|
||||||
extern cvar_t *cvar_vars;
|
|
||||||
|
|
||||||
#endif // _CVAR_H
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
qdefs.h
|
game.h
|
||||||
|
|
||||||
(description)
|
(description)
|
||||||
|
|
||||||
|
@ -28,38 +28,21 @@
|
||||||
$Id$
|
$Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __qdefs_h
|
#ifndef __game_h
|
||||||
#define __qdefs_h
|
#define __game_h
|
||||||
|
|
||||||
#include "qtypes.h"
|
#include "qtypes.h"
|
||||||
#include "cvar.h"
|
#include "cvar.h"
|
||||||
|
#include "qdefs.h"
|
||||||
|
|
||||||
#define MAX_OSPATH 128 // max length of a filesystem pathname
|
#undef MAX_DATAGRAM
|
||||||
#define MAX_QPATH 64 // max length of a quake game pathname
|
|
||||||
#define MAX_CL_STATS 32
|
|
||||||
#define NUM_CSHIFTS 4
|
|
||||||
#define MAX_MODELS 256 // these are sent over the net as bytes
|
|
||||||
#define MAX_SOUNDS 256 // so they cannot be blindly increased
|
|
||||||
#define MAX_SCOREBOARD 16
|
|
||||||
#define MAX_SCOREBOARDNAME 32
|
|
||||||
#define MAX_STYLESTRING 64
|
|
||||||
#define MAX_EDICTS 600 // FIXME: ouch! ouch! ouch!
|
|
||||||
#define MAX_LIGHTSTYLES 64
|
|
||||||
#define MAX_DATAGRAM 1024 // max length of unreliable message
|
#define MAX_DATAGRAM 1024 // max length of unreliable message
|
||||||
|
|
||||||
|
#undef MAX_MSGLEN
|
||||||
#define MAX_MSGLEN 8000 // max length of a reliable message
|
#define MAX_MSGLEN 8000 // max length of a reliable message
|
||||||
#define clc_stringcmd 4
|
|
||||||
|
|
||||||
#define QUAKE_GAME // as opposed to utilities
|
#define QUAKE_GAME // as opposed to utilities
|
||||||
|
|
||||||
//define PARANOID // speed sapping error checking
|
|
||||||
|
|
||||||
#ifdef QUAKE2
|
|
||||||
#define GAMENAME "id1" // directory to look in by default
|
|
||||||
#else
|
|
||||||
#define GAMENAME "id1"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
@ -186,4 +169,4 @@ extern qboolean isDedicated;
|
||||||
extern qboolean abyss, rogue, hipnotic, standard_quake;
|
extern qboolean abyss, rogue, hipnotic, standard_quake;
|
||||||
extern cvar_t *registered;
|
extern cvar_t *registered;
|
||||||
|
|
||||||
#endif // __qdefs_h
|
#endif // __game_h
|
|
@ -877,7 +877,7 @@ int CDAudio_Init(void)
|
||||||
enabled = false;
|
enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cmd_AddCommand ("cd", CD_f);
|
Cmd_AddCommand ("cd", CD_f, "No Description");
|
||||||
|
|
||||||
Con_Printf("CD Audio Initialized\n");
|
Con_Printf("CD Audio Initialized\n");
|
||||||
|
|
||||||
|
|
|
@ -413,7 +413,7 @@ int CDAudio_Init(void)
|
||||||
cdValid = false;
|
cdValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cmd_AddCommand ("cd", CD_f);
|
Cmd_AddCommand ("cd", CD_f, "No Description");
|
||||||
|
|
||||||
Con_Printf("CD Audio Initialized\n");
|
Con_Printf("CD Audio Initialized\n");
|
||||||
|
|
||||||
|
|
|
@ -467,7 +467,7 @@ int CDAudio_Init(void)
|
||||||
cdValid = false;
|
cdValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cmd_AddCommand ("cd", CD_f);
|
Cmd_AddCommand ("cd", CD_f, "No Description");
|
||||||
|
|
||||||
Con_Printf("CD Audio Initialized\n");
|
Con_Printf("CD Audio Initialized\n");
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
|
#include "cmd.h"
|
||||||
|
|
||||||
void CL_FinishTimeDemo (void);
|
void CL_FinishTimeDemo (void);
|
||||||
|
|
||||||
|
@ -256,7 +257,7 @@ void CL_Record_f (void)
|
||||||
// start the map up
|
// start the map up
|
||||||
//
|
//
|
||||||
if (c > 2)
|
if (c > 2)
|
||||||
Cmd_ExecuteString ( va("map %s", Cmd_Argv(2)), src_command);
|
Cmd_ExecuteString_src ( va("map %s", Cmd_Argv(2)), src_command);
|
||||||
|
|
||||||
//
|
//
|
||||||
// open the demo file
|
// open the demo file
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "host.h"
|
#include "host.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
#include "cmd.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============================================================================
|
===============================================================================
|
||||||
|
@ -425,41 +426,41 @@ CL_InitInput
|
||||||
*/
|
*/
|
||||||
void CL_InitInput (void)
|
void CL_InitInput (void)
|
||||||
{
|
{
|
||||||
Cmd_AddCommand ("+moveup",IN_UpDown);
|
Cmd_AddCommand ("+moveup",IN_UpDown, "No Description");
|
||||||
Cmd_AddCommand ("-moveup",IN_UpUp);
|
Cmd_AddCommand ("-moveup",IN_UpUp, "No Description");
|
||||||
Cmd_AddCommand ("+movedown",IN_DownDown);
|
Cmd_AddCommand ("+movedown",IN_DownDown, "No Description");
|
||||||
Cmd_AddCommand ("-movedown",IN_DownUp);
|
Cmd_AddCommand ("-movedown",IN_DownUp, "No Description");
|
||||||
Cmd_AddCommand ("+left",IN_LeftDown);
|
Cmd_AddCommand ("+left",IN_LeftDown, "No Description");
|
||||||
Cmd_AddCommand ("-left",IN_LeftUp);
|
Cmd_AddCommand ("-left",IN_LeftUp, "No Description");
|
||||||
Cmd_AddCommand ("+right",IN_RightDown);
|
Cmd_AddCommand ("+right",IN_RightDown, "No Description");
|
||||||
Cmd_AddCommand ("-right",IN_RightUp);
|
Cmd_AddCommand ("-right",IN_RightUp, "No Description");
|
||||||
Cmd_AddCommand ("+forward",IN_ForwardDown);
|
Cmd_AddCommand ("+forward",IN_ForwardDown, "No Description");
|
||||||
Cmd_AddCommand ("-forward",IN_ForwardUp);
|
Cmd_AddCommand ("-forward",IN_ForwardUp, "No Description");
|
||||||
Cmd_AddCommand ("+back",IN_BackDown);
|
Cmd_AddCommand ("+back",IN_BackDown, "No Description");
|
||||||
Cmd_AddCommand ("-back",IN_BackUp);
|
Cmd_AddCommand ("-back",IN_BackUp, "No Description");
|
||||||
Cmd_AddCommand ("+lookup", IN_LookupDown);
|
Cmd_AddCommand ("+lookup", IN_LookupDown, "No Description");
|
||||||
Cmd_AddCommand ("-lookup", IN_LookupUp);
|
Cmd_AddCommand ("-lookup", IN_LookupUp, "No Description");
|
||||||
Cmd_AddCommand ("+lookdown", IN_LookdownDown);
|
Cmd_AddCommand ("+lookdown", IN_LookdownDown, "No Description");
|
||||||
Cmd_AddCommand ("-lookdown", IN_LookdownUp);
|
Cmd_AddCommand ("-lookdown", IN_LookdownUp, "No Description");
|
||||||
Cmd_AddCommand ("+strafe", IN_StrafeDown);
|
Cmd_AddCommand ("+strafe", IN_StrafeDown, "No Description");
|
||||||
Cmd_AddCommand ("-strafe", IN_StrafeUp);
|
Cmd_AddCommand ("-strafe", IN_StrafeUp, "No Description");
|
||||||
Cmd_AddCommand ("+moveleft", IN_MoveleftDown);
|
Cmd_AddCommand ("+moveleft", IN_MoveleftDown, "No Description");
|
||||||
Cmd_AddCommand ("-moveleft", IN_MoveleftUp);
|
Cmd_AddCommand ("-moveleft", IN_MoveleftUp, "No Description");
|
||||||
Cmd_AddCommand ("+moveright", IN_MoverightDown);
|
Cmd_AddCommand ("+moveright", IN_MoverightDown, "No Description");
|
||||||
Cmd_AddCommand ("-moveright", IN_MoverightUp);
|
Cmd_AddCommand ("-moveright", IN_MoverightUp, "No Description");
|
||||||
Cmd_AddCommand ("+speed", IN_SpeedDown);
|
Cmd_AddCommand ("+speed", IN_SpeedDown, "No Description");
|
||||||
Cmd_AddCommand ("-speed", IN_SpeedUp);
|
Cmd_AddCommand ("-speed", IN_SpeedUp, "No Description");
|
||||||
Cmd_AddCommand ("+attack", IN_AttackDown);
|
Cmd_AddCommand ("+attack", IN_AttackDown, "No Description");
|
||||||
Cmd_AddCommand ("-attack", IN_AttackUp);
|
Cmd_AddCommand ("-attack", IN_AttackUp, "No Description");
|
||||||
Cmd_AddCommand ("+use", IN_UseDown);
|
Cmd_AddCommand ("+use", IN_UseDown, "No Description");
|
||||||
Cmd_AddCommand ("-use", IN_UseUp);
|
Cmd_AddCommand ("-use", IN_UseUp, "No Description");
|
||||||
Cmd_AddCommand ("+jump", IN_JumpDown);
|
Cmd_AddCommand ("+jump", IN_JumpDown, "No Description");
|
||||||
Cmd_AddCommand ("-jump", IN_JumpUp);
|
Cmd_AddCommand ("-jump", IN_JumpUp, "No Description");
|
||||||
Cmd_AddCommand ("impulse", IN_Impulse);
|
Cmd_AddCommand ("impulse", IN_Impulse, "No Description");
|
||||||
Cmd_AddCommand ("+klook", IN_KLookDown);
|
Cmd_AddCommand ("+klook", IN_KLookDown, "No Description");
|
||||||
Cmd_AddCommand ("-klook", IN_KLookUp);
|
Cmd_AddCommand ("-klook", IN_KLookUp, "No Description");
|
||||||
Cmd_AddCommand ("+mlook", IN_MLookDown);
|
Cmd_AddCommand ("+mlook", IN_MLookDown, "No Description");
|
||||||
Cmd_AddCommand ("-mlook", IN_MLookUp);
|
Cmd_AddCommand ("-mlook", IN_MLookUp, "No Description");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
#include "cmd.h"
|
||||||
|
|
||||||
// we need to declare some mouse variables here, because the menu system
|
// we need to declare some mouse variables here, because the menu system
|
||||||
// references them even when on a unix system.
|
// references them even when on a unix system.
|
||||||
|
@ -824,13 +825,13 @@ void CL_Init (void)
|
||||||
CL_InitInput ();
|
CL_InitInput ();
|
||||||
CL_InitTEnts ();
|
CL_InitTEnts ();
|
||||||
|
|
||||||
Cmd_AddCommand ("entities", CL_PrintEntities_f);
|
Cmd_AddCommand ("entities", CL_PrintEntities_f, "No Description");
|
||||||
Cmd_AddCommand ("disconnect", CL_Disconnect_f);
|
Cmd_AddCommand ("disconnect", CL_Disconnect_f, "No Description");
|
||||||
Cmd_AddCommand ("record", CL_Record_f);
|
Cmd_AddCommand ("record", CL_Record_f, "No Description");
|
||||||
Cmd_AddCommand ("stop", CL_Stop_f);
|
Cmd_AddCommand ("stop", CL_Stop_f, "No Description");
|
||||||
Cmd_AddCommand ("playdemo", CL_PlayDemo_f);
|
Cmd_AddCommand ("playdemo", CL_PlayDemo_f, "No Description");
|
||||||
Cmd_AddCommand ("timedemo", CL_TimeDemo_f);
|
Cmd_AddCommand ("timedemo", CL_TimeDemo_f, "No Description");
|
||||||
Cmd_AddCommand ("maplist", COM_Maplist_f);
|
Cmd_AddCommand ("maplist", COM_Maplist_f, "No Description");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,9 @@
|
||||||
#include "sbar.h"
|
#include "sbar.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "qdefs.h"
|
#include "game.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
#include "cmd.h"
|
||||||
|
|
||||||
char *svc_strings[] =
|
char *svc_strings[] =
|
||||||
{
|
{
|
||||||
|
@ -963,7 +964,7 @@ void CL_ParseServerMessage (void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case svc_sellscreen:
|
case svc_sellscreen:
|
||||||
Cmd_ExecuteString ("help", src_command);
|
Cmd_ExecuteString_src ("help", src_command);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,7 +239,7 @@ Cbuf_Execute (void)
|
||||||
extract_line (line);
|
extract_line (line);
|
||||||
// execute the command line
|
// execute the command line
|
||||||
//Con_DPrintf("+%s\n",line),
|
//Con_DPrintf("+%s\n",line),
|
||||||
Cmd_ExecuteString (line, src_command);
|
Cmd_ExecuteString_src (line, src_command);
|
||||||
|
|
||||||
if (cmd_wait)
|
if (cmd_wait)
|
||||||
{ // skip out while text still remains in buffer, leaving it
|
{ // skip out while text still remains in buffer, leaving it
|
||||||
|
@ -265,7 +265,7 @@ Cbuf_Execute_Sets (void)
|
||||||
if (strncmp(line,"set",3)==0
|
if (strncmp(line,"set",3)==0
|
||||||
&& isspace((int) line[3]))
|
&& isspace((int) line[3]))
|
||||||
//Con_DPrintf("+%s\n",line),
|
//Con_DPrintf("+%s\n",line),
|
||||||
Cmd_ExecuteString (line, src_command);
|
Cmd_ExecuteString_src (line, src_command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -527,6 +527,7 @@ typedef struct cmd_function_s
|
||||||
struct cmd_function_s *next;
|
struct cmd_function_s *next;
|
||||||
char *name;
|
char *name;
|
||||||
xcommand_t function;
|
xcommand_t function;
|
||||||
|
char *description;
|
||||||
} cmd_function_t;
|
} cmd_function_t;
|
||||||
|
|
||||||
|
|
||||||
|
@ -642,7 +643,7 @@ void Cmd_TokenizeString (char *text)
|
||||||
Cmd_AddCommand
|
Cmd_AddCommand
|
||||||
============
|
============
|
||||||
*/
|
*/
|
||||||
void Cmd_AddCommand (char *cmd_name, xcommand_t function)
|
void Cmd_AddCommand (char *cmd_name, xcommand_t function, char *description)
|
||||||
{
|
{
|
||||||
cmd_function_t *cmd;
|
cmd_function_t *cmd;
|
||||||
|
|
||||||
|
@ -670,6 +671,7 @@ void Cmd_AddCommand (char *cmd_name, xcommand_t function)
|
||||||
cmd->name = cmd_name;
|
cmd->name = cmd_name;
|
||||||
cmd->function = function;
|
cmd->function = function;
|
||||||
cmd->next = cmd_functions;
|
cmd->next = cmd_functions;
|
||||||
|
cmd->description = description;
|
||||||
cmd_functions = cmd;
|
cmd_functions = cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -810,13 +812,13 @@ void Cmd_ExpandVariables (char *data, char *dest)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
============
|
============
|
||||||
Cmd_ExecuteString
|
Cmd_ExecuteString_src
|
||||||
|
|
||||||
A complete command line has been parsed, so try to execute it
|
A complete command line has been parsed, so try to execute it
|
||||||
FIXME: lookupnoadd the token to speed search?
|
FIXME: lookupnoadd the token to speed search?
|
||||||
============
|
============
|
||||||
*/
|
*/
|
||||||
void Cmd_ExecuteString (char *text, cmd_source_t src)
|
void Cmd_ExecuteString_src (char *text, cmd_source_t src)
|
||||||
{
|
{
|
||||||
cmd_function_t *cmd;
|
cmd_function_t *cmd;
|
||||||
cmdalias_t *a;
|
cmdalias_t *a;
|
||||||
|
@ -986,12 +988,12 @@ void Cmd_Init (void)
|
||||||
//
|
//
|
||||||
// register our commands
|
// register our commands
|
||||||
//
|
//
|
||||||
Cmd_AddCommand ("stuffcmds",Cmd_StuffCmds_f);
|
Cmd_AddCommand ("stuffcmds",Cmd_StuffCmds_f, "No Description");
|
||||||
Cmd_AddCommand ("exec",Cmd_Exec_f);
|
Cmd_AddCommand ("exec",Cmd_Exec_f, "No Description");
|
||||||
Cmd_AddCommand ("echo",Cmd_Echo_f);
|
Cmd_AddCommand ("echo",Cmd_Echo_f, "No Description");
|
||||||
Cmd_AddCommand ("alias",Cmd_Alias_f);
|
Cmd_AddCommand ("alias",Cmd_Alias_f, "No Description");
|
||||||
Cmd_AddCommand ("cmd", Cmd_ForwardToServer);
|
Cmd_AddCommand ("cmd", Cmd_ForwardToServer, "No Description");
|
||||||
Cmd_AddCommand ("wait", Cmd_Wait_f);
|
Cmd_AddCommand ("wait", Cmd_Wait_f, "No Description");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -35,7 +35,8 @@
|
||||||
#include "quakefs.h"
|
#include "quakefs.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "qargs.h"
|
#include "qargs.h"
|
||||||
#include "qdefs.h"
|
#include "game.h"
|
||||||
|
#include "cmd.h"
|
||||||
|
|
||||||
cvar_t *cmdline;
|
cvar_t *cmdline;
|
||||||
int static_registered = 1;
|
int static_registered = 1;
|
||||||
|
@ -97,8 +98,9 @@ void COM_Init ()
|
||||||
|
|
||||||
registered = Cvar_Get("registered", "0", CVAR_NONE, "None");
|
registered = Cvar_Get("registered", "0", CVAR_NONE, "None");
|
||||||
cmdline = Cvar_Get("cmdline", "0", CVAR_SERVERINFO, "None");
|
cmdline = Cvar_Get("cmdline", "0", CVAR_SERVERINFO, "None");
|
||||||
Cmd_AddCommand ("path", COM_Path_f);
|
Cmd_AddCommand ("path", COM_Path_f, "No Description");
|
||||||
|
|
||||||
COM_InitFilesystem ();
|
COM_Filesystem_Init_Cvars ();
|
||||||
|
COM_Filesystem_Init ();
|
||||||
COM_CheckRegistered ();
|
COM_CheckRegistered ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include "va.h"
|
#include "va.h"
|
||||||
|
#include "cmd.h"
|
||||||
#include "draw.h"
|
#include "draw.h"
|
||||||
#include "host.h"
|
#include "host.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
|
@ -258,10 +259,10 @@ void Con_Init (void)
|
||||||
//
|
//
|
||||||
con_notifytime = Cvar_Get("con_notifytime", "3", CVAR_NONE, "seconds");
|
con_notifytime = Cvar_Get("con_notifytime", "3", CVAR_NONE, "seconds");
|
||||||
|
|
||||||
Cmd_AddCommand ("toggleconsole", Con_ToggleConsole_f);
|
Cmd_AddCommand ("toggleconsole", Con_ToggleConsole_f, "No Description");
|
||||||
Cmd_AddCommand ("messagemode", Con_MessageMode_f);
|
Cmd_AddCommand ("messagemode", Con_MessageMode_f, "No Description");
|
||||||
Cmd_AddCommand ("messagemode2", Con_MessageMode2_f);
|
Cmd_AddCommand ("messagemode2", Con_MessageMode2_f, "No Description");
|
||||||
Cmd_AddCommand ("clear", Con_Clear_f);
|
Cmd_AddCommand ("clear", Con_Clear_f, "No Description");
|
||||||
con_initialized = true;
|
con_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -596,7 +597,7 @@ Draws the console with the solid background
|
||||||
The typing input line at the bottom should only be drawn if typing is allowed
|
The typing input line at the bottom should only be drawn if typing is allowed
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
void Con_DrawConsole (int lines, qboolean drawinput)
|
void Con_DrawConsole (int lines)//, qboolean drawinput)
|
||||||
{
|
{
|
||||||
int i, x, y;
|
int i, x, y;
|
||||||
int rows;
|
int rows;
|
||||||
|
@ -627,7 +628,7 @@ void Con_DrawConsole (int lines, qboolean drawinput)
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw the input prompt, user text, and cursor if desired
|
// draw the input prompt, user text, and cursor if desired
|
||||||
if (drawinput)
|
// if (drawinput)
|
||||||
Con_DrawInput ();
|
Con_DrawInput ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -413,11 +413,11 @@ void Cvar_Init()
|
||||||
{
|
{
|
||||||
developer = Cvar_Get ("developer","0",0,"None");
|
developer = Cvar_Get ("developer","0",0,"None");
|
||||||
|
|
||||||
Cmd_AddCommand ("set", Cvar_Set_f);
|
Cmd_AddCommand ("set", Cvar_Set_f, "No Description");
|
||||||
Cmd_AddCommand ("setrom", Cvar_Setrom_f);
|
Cmd_AddCommand ("setrom", Cvar_Setrom_f, "No Description");
|
||||||
Cmd_AddCommand ("toggle", Cvar_Toggle_f);
|
Cmd_AddCommand ("toggle", Cvar_Toggle_f, "No Description");
|
||||||
Cmd_AddCommand ("help",Cvar_Help_f);
|
Cmd_AddCommand ("help",Cvar_Help_f, "No Description");
|
||||||
Cmd_AddCommand ("cvarlist",Cvar_CvarList_f);
|
Cmd_AddCommand ("cvarlist",Cvar_CvarList_f, "No Description");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cvar_Shutdown (void)
|
void Cvar_Shutdown (void)
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "qdefs.h"
|
#include "game.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "qargs.h"
|
#include "qargs.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
|
|
|
@ -22,9 +22,9 @@
|
||||||
|
|
||||||
void GIB_Init (void)
|
void GIB_Init (void)
|
||||||
{
|
{
|
||||||
Cmd_AddCommand("gibload", GIB_Load_f);
|
Cmd_AddCommand("gibload", GIB_Load_f, "No Description");
|
||||||
Cmd_AddCommand("gibstats", GIB_Stats_f);
|
Cmd_AddCommand("gibstats", GIB_Stats_f, "No Description");
|
||||||
Cmd_AddCommand("gib", GIB_Gib_f);
|
Cmd_AddCommand("gib", GIB_Gib_f, "No Description");
|
||||||
GIB_Init_Instructions ();
|
GIB_Init_Instructions ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,7 @@ int GIB_Con_f (void)
|
||||||
if (GIB_Argc() != 1)
|
if (GIB_Argc() != 1)
|
||||||
return GIB_E_NUMARGS;
|
return GIB_E_NUMARGS;
|
||||||
|
|
||||||
Cmd_ExecuteString (GIB_Argv(1), src_command);
|
Cmd_ExecuteString_src (GIB_Argv(1), src_command);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -440,7 +440,7 @@ void Draw_Init (void)
|
||||||
Cvar_Set (gl_lightmode, "0");
|
Cvar_Set (gl_lightmode, "0");
|
||||||
lighthalf = gl_lightmode->int_val != 0; // to avoid re-rendering all lightmaps on first frame
|
lighthalf = gl_lightmode->int_val != 0; // to avoid re-rendering all lightmaps on first frame
|
||||||
|
|
||||||
Cmd_AddCommand ("gl_texturemode", &Draw_TextureMode_f);
|
Cmd_AddCommand ("gl_texturemode", &Draw_TextureMode_f, "No Description");
|
||||||
|
|
||||||
// load the console background and the charset
|
// load the console background and the charset
|
||||||
// by hand, because we need to write the version
|
// by hand, because we need to write the version
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "glquake.h"
|
#include "glquake.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
|
#include "cmd.h"
|
||||||
|
|
||||||
#define MAX_FIRES 128 // rocket flames
|
#define MAX_FIRES 128 // rocket flames
|
||||||
fire_t r_fires[MAX_FIRES];
|
fire_t r_fires[MAX_FIRES];
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "r_local.h"
|
#include "r_local.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
#include "qdefs.h"
|
#include "game.h"
|
||||||
#include "glquake.h"
|
#include "glquake.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "model.h"
|
#include "model.h"
|
||||||
|
|
|
@ -226,12 +226,12 @@ void R_Init (void)
|
||||||
{
|
{
|
||||||
allowskybox = false; // server will decide if this is allowed --KB
|
allowskybox = false; // server will decide if this is allowed --KB
|
||||||
|
|
||||||
Cmd_AddCommand ("timerefresh", R_TimeRefresh_f);
|
Cmd_AddCommand ("timerefresh", R_TimeRefresh_f, "No Description");
|
||||||
Cmd_AddCommand ("envmap", R_Envmap_f);
|
Cmd_AddCommand ("envmap", R_Envmap_f, "No Description");
|
||||||
Cmd_AddCommand ("pointfile", R_ReadPointFile_f);
|
Cmd_AddCommand ("pointfile", R_ReadPointFile_f, "No Description");
|
||||||
Cmd_AddCommand ("loadsky", R_LoadSky_f);
|
Cmd_AddCommand ("loadsky", R_LoadSky_f, "No Description");
|
||||||
|
|
||||||
Cmd_AddCommand ("r_firecolor", R_FireColor_f);
|
Cmd_AddCommand ("r_firecolor", R_FireColor_f, "No Description");
|
||||||
|
|
||||||
r_norefresh = Cvar_Get("r_norefresh", "0", CVAR_NONE, "None");
|
r_norefresh = Cvar_Get("r_norefresh", "0", CVAR_NONE, "None");
|
||||||
r_lightmap = Cvar_Get("r_lightmap", "0", CVAR_NONE, "None");
|
r_lightmap = Cvar_Get("r_lightmap", "0", CVAR_NONE, "None");
|
||||||
|
|
|
@ -429,9 +429,9 @@ SCR_Init (void)
|
||||||
//
|
//
|
||||||
// register our commands
|
// register our commands
|
||||||
//
|
//
|
||||||
Cmd_AddCommand ("screenshot",SCR_ScreenShot_f);
|
Cmd_AddCommand ("screenshot",SCR_ScreenShot_f, "No Description");
|
||||||
Cmd_AddCommand ("sizeup",SCR_SizeUp_f);
|
Cmd_AddCommand ("sizeup",SCR_SizeUp_f, "No Description");
|
||||||
Cmd_AddCommand ("sizedown",SCR_SizeDown_f);
|
Cmd_AddCommand ("sizedown",SCR_SizeDown_f, "No Description");
|
||||||
|
|
||||||
scr_ram = Draw_PicFromWad ("ram");
|
scr_ram = Draw_PicFromWad ("ram");
|
||||||
scr_net = Draw_PicFromWad ("net");
|
scr_net = Draw_PicFromWad ("net");
|
||||||
|
@ -655,7 +655,7 @@ void SCR_DrawConsole (void)
|
||||||
if (scr_con_current)
|
if (scr_con_current)
|
||||||
{
|
{
|
||||||
scr_copyeverything = 1;
|
scr_copyeverything = 1;
|
||||||
Con_DrawConsole (scr_con_current, true);
|
Con_DrawConsole (scr_con_current);//, true);
|
||||||
clearconsole = 0;
|
clearconsole = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "host.h"
|
#include "host.h"
|
||||||
|
#include "cmd.h"
|
||||||
#include "world.h"
|
#include "world.h"
|
||||||
#include "va.h"
|
#include "va.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
@ -318,7 +319,7 @@ void Host_Map_f (void)
|
||||||
strcat (cls.spawnparms, " ");
|
strcat (cls.spawnparms, " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
Cmd_ExecuteString ("connect local", src_command);
|
Cmd_ExecuteString_src ("connect local", src_command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -985,7 +986,7 @@ void Host_Name_f (void)
|
||||||
|
|
||||||
void Host_Version_f (void)
|
void Host_Version_f (void)
|
||||||
{
|
{
|
||||||
Con_Printf ("Version %4.2f\n", VERSION);
|
Con_Printf ("Version %s\n", VERSION);
|
||||||
Con_Printf ("Exe: "__TIME__" "__DATE__"\n");
|
Con_Printf ("Exe: "__TIME__" "__DATE__"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1862,45 +1863,45 @@ Host_InitCommands
|
||||||
*/
|
*/
|
||||||
void Host_InitCommands (void)
|
void Host_InitCommands (void)
|
||||||
{
|
{
|
||||||
Cmd_AddCommand ("status", Host_Status_f);
|
Cmd_AddCommand ("status", Host_Status_f, "No Description");
|
||||||
Cmd_AddCommand ("quit", Host_Quit_f);
|
Cmd_AddCommand ("quit", Host_Quit_f, "No Description");
|
||||||
Cmd_AddCommand ("god", Host_God_f);
|
Cmd_AddCommand ("god", Host_God_f, "No Description");
|
||||||
Cmd_AddCommand ("notarget", Host_Notarget_f);
|
Cmd_AddCommand ("notarget", Host_Notarget_f, "No Description");
|
||||||
Cmd_AddCommand ("fly", Host_Fly_f);
|
Cmd_AddCommand ("fly", Host_Fly_f, "No Description");
|
||||||
Cmd_AddCommand ("map", Host_Map_f);
|
Cmd_AddCommand ("map", Host_Map_f, "No Description");
|
||||||
Cmd_AddCommand ("restart", Host_Restart_f);
|
Cmd_AddCommand ("restart", Host_Restart_f, "No Description");
|
||||||
Cmd_AddCommand ("changelevel", Host_Changelevel_f);
|
Cmd_AddCommand ("changelevel", Host_Changelevel_f, "No Description");
|
||||||
#ifdef QUAKE2
|
#ifdef QUAKE2
|
||||||
Cmd_AddCommand ("changelevel2", Host_Changelevel2_f);
|
Cmd_AddCommand ("changelevel2", Host_Changelevel2_f, "No Description");
|
||||||
#endif
|
#endif
|
||||||
Cmd_AddCommand ("connect", Host_Connect_f);
|
Cmd_AddCommand ("connect", Host_Connect_f, "No Description");
|
||||||
Cmd_AddCommand ("reconnect", Host_Reconnect_f);
|
Cmd_AddCommand ("reconnect", Host_Reconnect_f, "No Description");
|
||||||
Cmd_AddCommand ("name", Host_Name_f);
|
Cmd_AddCommand ("name", Host_Name_f, "No Description");
|
||||||
Cmd_AddCommand ("noclip", Host_Noclip_f);
|
Cmd_AddCommand ("noclip", Host_Noclip_f, "No Description");
|
||||||
Cmd_AddCommand ("version", Host_Version_f);
|
Cmd_AddCommand ("version", Host_Version_f, "No Description");
|
||||||
Cmd_AddCommand ("say", Host_Say_f);
|
Cmd_AddCommand ("say", Host_Say_f, "No Description");
|
||||||
Cmd_AddCommand ("say_team", Host_Say_Team_f);
|
Cmd_AddCommand ("say_team", Host_Say_Team_f, "No Description");
|
||||||
Cmd_AddCommand ("tell", Host_Tell_f);
|
Cmd_AddCommand ("tell", Host_Tell_f, "No Description");
|
||||||
Cmd_AddCommand ("color", Host_Color_f);
|
Cmd_AddCommand ("color", Host_Color_f, "No Description");
|
||||||
Cmd_AddCommand ("kill", Host_Kill_f);
|
Cmd_AddCommand ("kill", Host_Kill_f, "No Description");
|
||||||
Cmd_AddCommand ("pause", Host_Pause_f);
|
Cmd_AddCommand ("pause", Host_Pause_f, "No Description");
|
||||||
Cmd_AddCommand ("spawn", Host_Spawn_f);
|
Cmd_AddCommand ("spawn", Host_Spawn_f, "No Description");
|
||||||
Cmd_AddCommand ("begin", Host_Begin_f);
|
Cmd_AddCommand ("begin", Host_Begin_f, "No Description");
|
||||||
Cmd_AddCommand ("prespawn", Host_PreSpawn_f);
|
Cmd_AddCommand ("prespawn", Host_PreSpawn_f, "No Description");
|
||||||
Cmd_AddCommand ("kick", Host_Kick_f);
|
Cmd_AddCommand ("kick", Host_Kick_f, "No Description");
|
||||||
Cmd_AddCommand ("ping", Host_Ping_f);
|
Cmd_AddCommand ("ping", Host_Ping_f, "No Description");
|
||||||
Cmd_AddCommand ("load", Host_Loadgame_f);
|
Cmd_AddCommand ("load", Host_Loadgame_f, "No Description");
|
||||||
Cmd_AddCommand ("save", Host_Savegame_f);
|
Cmd_AddCommand ("save", Host_Savegame_f, "No Description");
|
||||||
Cmd_AddCommand ("give", Host_Give_f);
|
Cmd_AddCommand ("give", Host_Give_f, "No Description");
|
||||||
|
|
||||||
Cmd_AddCommand ("startdemos", Host_Startdemos_f);
|
Cmd_AddCommand ("startdemos", Host_Startdemos_f, "No Description");
|
||||||
Cmd_AddCommand ("demos", Host_Demos_f);
|
Cmd_AddCommand ("demos", Host_Demos_f, "No Description");
|
||||||
Cmd_AddCommand ("stopdemo", Host_Stopdemo_f);
|
Cmd_AddCommand ("stopdemo", Host_Stopdemo_f, "No Description");
|
||||||
|
|
||||||
Cmd_AddCommand ("viewmodel", Host_Viewmodel_f);
|
Cmd_AddCommand ("viewmodel", Host_Viewmodel_f, "No Description");
|
||||||
Cmd_AddCommand ("viewframe", Host_Viewframe_f);
|
Cmd_AddCommand ("viewframe", Host_Viewframe_f, "No Description");
|
||||||
Cmd_AddCommand ("viewnext", Host_Viewnext_f);
|
Cmd_AddCommand ("viewnext", Host_Viewnext_f, "No Description");
|
||||||
Cmd_AddCommand ("viewprev", Host_Viewprev_f);
|
Cmd_AddCommand ("viewprev", Host_Viewprev_f, "No Description");
|
||||||
|
|
||||||
Cmd_AddCommand ("mcache", Mod_Print);
|
Cmd_AddCommand ("mcache", Mod_Print, "No Description");
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,8 +174,8 @@ void IN_Init (void)
|
||||||
in_joystick = Cvar_Get("joystick", "0", CVAR_ARCHIVE, "None");
|
in_joystick = Cvar_Get("joystick", "0", CVAR_ARCHIVE, "None");
|
||||||
joy_numbuttons = Cvar_Get("joybuttons", "4", CVAR_ARCHIVE, "None");
|
joy_numbuttons = Cvar_Get("joybuttons", "4", CVAR_ARCHIVE, "None");
|
||||||
aux_look = Cvar_Get("auxlook", "1", CVAR_ARCHIVE, "None");
|
aux_look = Cvar_Get("auxlook", "1", CVAR_ARCHIVE, "None");
|
||||||
Cmd_AddCommand ("toggle_auxlook", Toggle_AuxLook_f);
|
Cmd_AddCommand ("toggle_auxlook", Toggle_AuxLook_f, "No Description");
|
||||||
Cmd_AddCommand ("force_centerview", Force_CenterView_f);
|
Cmd_AddCommand ("force_centerview", Force_CenterView_f, "No Description");
|
||||||
|
|
||||||
IN_StartupMouse ();
|
IN_StartupMouse ();
|
||||||
IN_StartupJoystick ();
|
IN_StartupJoystick ();
|
||||||
|
|
|
@ -260,7 +260,7 @@ IN_init_mouse()
|
||||||
char *mousedev;
|
char *mousedev;
|
||||||
int mouserate = MOUSE_DEFAULTSAMPLERATE;
|
int mouserate = MOUSE_DEFAULTSAMPLERATE;
|
||||||
|
|
||||||
Cmd_AddCommand("force_centerview", Force_CenterView_f);
|
Cmd_AddCommand("force_centerview", Force_CenterView_f, "No Description");
|
||||||
|
|
||||||
mouse_buttons = 3;
|
mouse_buttons = 3;
|
||||||
|
|
||||||
|
|
|
@ -505,8 +505,8 @@ IN_Init
|
||||||
*/
|
*/
|
||||||
void IN_Init (void)
|
void IN_Init (void)
|
||||||
{
|
{
|
||||||
Cmd_AddCommand ("force_centerview", Force_CenterView_f);
|
Cmd_AddCommand ("force_centerview", Force_CenterView_f, "No Description");
|
||||||
Cmd_AddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f);
|
Cmd_AddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f, "No Description");
|
||||||
|
|
||||||
uiWheelMessage = RegisterWindowMessage ( "MSWHEEL_ROLLMSG" );
|
uiWheelMessage = RegisterWindowMessage ( "MSWHEEL_ROLLMSG" );
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
#include "vid.h"
|
#include "vid.h"
|
||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "zone.h"
|
|
||||||
#include "cvar.h"
|
#include "cvar.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
|
@ -468,7 +467,7 @@ void Key_SetBinding (int keynum, char *binding)
|
||||||
|
|
||||||
// allocate memory for new binding
|
// allocate memory for new binding
|
||||||
l = strlen (binding);
|
l = strlen (binding);
|
||||||
new = Z_Malloc (l+1);
|
new = malloc (l+1);
|
||||||
strcpy (new, binding);
|
strcpy (new, binding);
|
||||||
new[l] = 0;
|
new[l] = 0;
|
||||||
keybindings[keynum] = new;
|
keybindings[keynum] = new;
|
||||||
|
@ -641,9 +640,9 @@ void Key_Init (void)
|
||||||
//
|
//
|
||||||
// register our functions
|
// register our functions
|
||||||
//
|
//
|
||||||
Cmd_AddCommand ("bind",Key_Bind_f);
|
Cmd_AddCommand ("bind",Key_Bind_f, "No Description");
|
||||||
Cmd_AddCommand ("unbind",Key_Unbind_f);
|
Cmd_AddCommand ("unbind",Key_Unbind_f, "No Description");
|
||||||
Cmd_AddCommand ("unbindall",Key_Unbindall_f);
|
Cmd_AddCommand ("unbindall",Key_Unbindall_f, "No Description");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -517,7 +517,7 @@ void FloorDivMod (double numer, double denom, int *quotient,
|
||||||
|
|
||||||
#ifndef PARANOID
|
#ifndef PARANOID
|
||||||
if (denom <= 0.0)
|
if (denom <= 0.0)
|
||||||
Sys_Error ("FloorDivMod: bad denominator %d\n", denom);
|
Sys_Error ("FloorDivMod: bad denominator %f\n", denom);
|
||||||
|
|
||||||
// if ((floor(numer) != numer) || (floor(denom) != denom))
|
// if ((floor(numer) != numer) || (floor(denom) != denom))
|
||||||
// Sys_Error ("FloorDivMod: non-integer numer or denom %f %f\n",
|
// Sys_Error ("FloorDivMod: non-integer numer or denom %f %f\n",
|
||||||
|
|
|
@ -3039,19 +3039,19 @@ void M_ServerList_Key (int k)
|
||||||
|
|
||||||
void M_Init (void)
|
void M_Init (void)
|
||||||
{
|
{
|
||||||
Cmd_AddCommand ("togglemenu", M_ToggleMenu_f);
|
Cmd_AddCommand ("togglemenu", M_ToggleMenu_f, "No Description");
|
||||||
|
|
||||||
Cmd_AddCommand ("menu_main", M_Menu_Main_f);
|
Cmd_AddCommand ("menu_main", M_Menu_Main_f, "No Description");
|
||||||
Cmd_AddCommand ("menu_singleplayer", M_Menu_SinglePlayer_f);
|
Cmd_AddCommand ("menu_singleplayer", M_Menu_SinglePlayer_f, "No Description");
|
||||||
Cmd_AddCommand ("menu_load", M_Menu_Load_f);
|
Cmd_AddCommand ("menu_load", M_Menu_Load_f, "No Description");
|
||||||
Cmd_AddCommand ("menu_save", M_Menu_Save_f);
|
Cmd_AddCommand ("menu_save", M_Menu_Save_f, "No Description");
|
||||||
Cmd_AddCommand ("menu_multiplayer", M_Menu_MultiPlayer_f);
|
Cmd_AddCommand ("menu_multiplayer", M_Menu_MultiPlayer_f, "No Description");
|
||||||
Cmd_AddCommand ("menu_setup", M_Menu_Setup_f);
|
Cmd_AddCommand ("menu_setup", M_Menu_Setup_f, "No Description");
|
||||||
Cmd_AddCommand ("menu_options", M_Menu_Options_f);
|
Cmd_AddCommand ("menu_options", M_Menu_Options_f, "No Description");
|
||||||
Cmd_AddCommand ("menu_keys", M_Menu_Keys_f);
|
Cmd_AddCommand ("menu_keys", M_Menu_Keys_f, "No Description");
|
||||||
Cmd_AddCommand ("menu_video", M_Menu_Video_f);
|
Cmd_AddCommand ("menu_video", M_Menu_Video_f, "No Description");
|
||||||
Cmd_AddCommand ("menu_help", M_Menu_Help_f);
|
Cmd_AddCommand ("menu_help", M_Menu_Help_f, "No Description");
|
||||||
Cmd_AddCommand ("menu_quit", M_Menu_Quit_f);
|
Cmd_AddCommand ("menu_quit", M_Menu_Quit_f, "No Description");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,12 @@
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
#include "string.h"
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STRINGS_H
|
||||||
|
#include "strings.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "r_local.h"
|
#include "r_local.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
|
|
|
@ -1157,7 +1157,7 @@ int TTY_Init(void)
|
||||||
p->portNumber = n;
|
p->portNumber = n;
|
||||||
p->dialType = 'T';
|
p->dialType = 'T';
|
||||||
snprintf (p->name, sizeof(p->name), "com%u", n+1);
|
snprintf (p->name, sizeof(p->name), "com%u", n+1);
|
||||||
Cmd_AddCommand (p->name, Com_f);
|
Cmd_AddCommand (p->name, Com_f, "No Description");
|
||||||
ResetComPortConfig (p);
|
ResetComPortConfig (p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "cmd.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
@ -42,7 +43,7 @@
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "qdefs.h"
|
#include "game.h"
|
||||||
|
|
||||||
// This is enables a simple IP banning mechanism
|
// This is enables a simple IP banning mechanism
|
||||||
#define BAN_TEST
|
#define BAN_TEST
|
||||||
|
@ -793,7 +794,7 @@ int Datagram_Init (void)
|
||||||
int csock;
|
int csock;
|
||||||
|
|
||||||
myDriverLevel = net_driverlevel;
|
myDriverLevel = net_driverlevel;
|
||||||
Cmd_AddCommand ("net_stats", NET_Stats_f);
|
Cmd_AddCommand ("net_stats", NET_Stats_f, "No Description");
|
||||||
|
|
||||||
if (COM_CheckParm("-nolan"))
|
if (COM_CheckParm("-nolan"))
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -808,10 +809,10 @@ int Datagram_Init (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BAN_TEST
|
#ifdef BAN_TEST
|
||||||
Cmd_AddCommand ("ban", NET_Ban_f);
|
Cmd_AddCommand ("ban", NET_Ban_f, "No Description");
|
||||||
#endif
|
#endif
|
||||||
Cmd_AddCommand ("test", Test_f);
|
Cmd_AddCommand ("test", Test_f, "No Description");
|
||||||
Cmd_AddCommand ("test2", Test2_f);
|
Cmd_AddCommand ("test2", Test2_f, "No Description");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "cmd.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "net_vcr.h"
|
#include "net_vcr.h"
|
||||||
#include "qargs.h"
|
#include "qargs.h"
|
||||||
|
@ -875,10 +876,10 @@ void NET_Init (void)
|
||||||
config_modem_init = Cvar_Get("_config_modem_init", "", CVAR_ARCHIVE, "None");
|
config_modem_init = Cvar_Get("_config_modem_init", "", CVAR_ARCHIVE, "None");
|
||||||
config_modem_hangup = Cvar_Get("_config_modem_hangup", "AT H", CVAR_ARCHIVE, "None");
|
config_modem_hangup = Cvar_Get("_config_modem_hangup", "AT H", CVAR_ARCHIVE, "None");
|
||||||
|
|
||||||
Cmd_AddCommand ("slist", NET_Slist_f);
|
Cmd_AddCommand ("slist", NET_Slist_f, "No Description");
|
||||||
Cmd_AddCommand ("listen", NET_Listen_f);
|
Cmd_AddCommand ("listen", NET_Listen_f, "No Description");
|
||||||
Cmd_AddCommand ("maxplayers", MaxPlayers_f);
|
Cmd_AddCommand ("maxplayers", MaxPlayers_f, "No Description");
|
||||||
Cmd_AddCommand ("port", NET_Port_f);
|
Cmd_AddCommand ("port", NET_Port_f, "No Description");
|
||||||
|
|
||||||
// initialize all the drivers
|
// initialize all the drivers
|
||||||
for (net_driverlevel=0 ; net_driverlevel<net_numdrivers ; net_driverlevel++)
|
for (net_driverlevel=0 ; net_driverlevel<net_numdrivers ; net_driverlevel++)
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "progs.h"
|
#include "progs.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
|
#include "cmd.h"
|
||||||
#include "va.h"
|
#include "va.h"
|
||||||
#include "host.h"
|
#include "host.h"
|
||||||
#include "world.h"
|
#include "world.h"
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "host.h"
|
#include "host.h"
|
||||||
|
#include "cmd.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "qendian.h"
|
#include "qendian.h"
|
||||||
#include "crc.h"
|
#include "crc.h"
|
||||||
|
@ -1086,10 +1087,10 @@ PR_Init
|
||||||
*/
|
*/
|
||||||
void PR_Init (void)
|
void PR_Init (void)
|
||||||
{
|
{
|
||||||
Cmd_AddCommand ("edict", ED_PrintEdict_f);
|
Cmd_AddCommand ("edict", ED_PrintEdict_f, "No Description");
|
||||||
Cmd_AddCommand ("edicts", ED_PrintEdicts);
|
Cmd_AddCommand ("edicts", ED_PrintEdicts, "No Description");
|
||||||
Cmd_AddCommand ("edictcount", ED_Count);
|
Cmd_AddCommand ("edictcount", ED_Count, "No Description");
|
||||||
Cmd_AddCommand ("profile", PR_Profile_f);
|
Cmd_AddCommand ("profile", PR_Profile_f, "No Description");
|
||||||
nomonsters = Cvar_Get("nomonsters", "0", CVAR_NONE, "None");
|
nomonsters = Cvar_Get("nomonsters", "0", CVAR_NONE, "None");
|
||||||
gamecfg = Cvar_Get("gamecfg", "0", CVAR_NONE, "None");
|
gamecfg = Cvar_Get("gamecfg", "0", CVAR_NONE, "None");
|
||||||
scratch1 = Cvar_Get("scratch1", "0", CVAR_NONE, "None");
|
scratch1 = Cvar_Get("scratch1", "0", CVAR_NONE, "None");
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
|
#include "cmd.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "chase.h"
|
#include "chase.h"
|
||||||
|
|
||||||
|
@ -203,8 +204,8 @@ void R_Init (void)
|
||||||
|
|
||||||
R_InitTurb ();
|
R_InitTurb ();
|
||||||
|
|
||||||
Cmd_AddCommand ("timerefresh", R_TimeRefresh_f);
|
Cmd_AddCommand ("timerefresh", R_TimeRefresh_f, "No Description");
|
||||||
Cmd_AddCommand ("pointfile", R_ReadPointFile_f);
|
Cmd_AddCommand ("pointfile", R_ReadPointFile_f, "No Description");
|
||||||
|
|
||||||
gl_particles = Cvar_Get ("gl_particles", "1", CVAR_ARCHIVE|CVAR_ROM,
|
gl_particles = Cvar_Get ("gl_particles", "1", CVAR_ARCHIVE|CVAR_ROM,
|
||||||
"whether or not to draw particles");
|
"whether or not to draw particles");
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
#include "r_local.h"
|
#include "r_local.h"
|
||||||
#include "host.h"
|
#include "host.h"
|
||||||
|
#include "cmd.h"
|
||||||
#include "chase.h"
|
#include "chase.h"
|
||||||
#include "draw.h"
|
#include "draw.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
@ -755,9 +756,9 @@ V_Init
|
||||||
*/
|
*/
|
||||||
void V_Init (void)
|
void V_Init (void)
|
||||||
{
|
{
|
||||||
Cmd_AddCommand ("v_cshift", V_cshift_f);
|
Cmd_AddCommand ("v_cshift", V_cshift_f, "No Description");
|
||||||
Cmd_AddCommand ("bf", V_BonusFlash_f);
|
Cmd_AddCommand ("bf", V_BonusFlash_f, "No Description");
|
||||||
Cmd_AddCommand ("centerview", V_StartPitchDrift);
|
Cmd_AddCommand ("centerview", V_StartPitchDrift, "No Description");
|
||||||
|
|
||||||
v_centermove = Cvar_Get("v_centermove", "0.15", CVAR_NONE, "None");
|
v_centermove = Cvar_Get("v_centermove", "0.15", CVAR_NONE, "None");
|
||||||
v_centerspeed = Cvar_Get("v_centerspeed", "500", CVAR_NONE, "None");
|
v_centerspeed = Cvar_Get("v_centerspeed", "500", CVAR_NONE, "None");
|
||||||
|
|
|
@ -32,7 +32,8 @@
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "sbar.h"
|
#include "sbar.h"
|
||||||
#include "qdefs.h"
|
#include "game.h"
|
||||||
|
#include "cmd.h"
|
||||||
#include "vid.h"
|
#include "vid.h"
|
||||||
#include "va.h"
|
#include "va.h"
|
||||||
#include "draw.h"
|
#include "draw.h"
|
||||||
|
@ -1219,8 +1220,8 @@ Sbar_Init (void)
|
||||||
sb_face_invis_invuln = Draw_PicFromWad ("face_inv2");
|
sb_face_invis_invuln = Draw_PicFromWad ("face_inv2");
|
||||||
sb_face_quad = Draw_PicFromWad ("face_quad");
|
sb_face_quad = Draw_PicFromWad ("face_quad");
|
||||||
|
|
||||||
Cmd_AddCommand ("+showscores", Sbar_ShowScores);
|
Cmd_AddCommand ("+showscores", Sbar_ShowScores, "No Description");
|
||||||
Cmd_AddCommand ("-showscores", Sbar_DontShowScores);
|
Cmd_AddCommand ("-showscores", Sbar_DontShowScores, "No Description");
|
||||||
|
|
||||||
sb_sbar = Draw_PicFromWad ("sbar");
|
sb_sbar = Draw_PicFromWad ("sbar");
|
||||||
sb_ibar = Draw_PicFromWad ("ibar");
|
sb_ibar = Draw_PicFromWad ("ibar");
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "r_local.h"
|
#include "r_local.h"
|
||||||
|
#include "cmd.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "sbar.h"
|
#include "sbar.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
@ -355,9 +356,9 @@ void SCR_Init (void)
|
||||||
//
|
//
|
||||||
// register our commands
|
// register our commands
|
||||||
//
|
//
|
||||||
Cmd_AddCommand ("screenshot",SCR_ScreenShot_f);
|
Cmd_AddCommand ("screenshot",SCR_ScreenShot_f, "No Description");
|
||||||
Cmd_AddCommand ("sizeup",SCR_SizeUp_f);
|
Cmd_AddCommand ("sizeup",SCR_SizeUp_f, "No Description");
|
||||||
Cmd_AddCommand ("sizedown",SCR_SizeDown_f);
|
Cmd_AddCommand ("sizedown",SCR_SizeDown_f, "No Description");
|
||||||
|
|
||||||
scr_ram = Draw_PicFromWad ("ram");
|
scr_ram = Draw_PicFromWad ("ram");
|
||||||
scr_net = Draw_PicFromWad ("net");
|
scr_net = Draw_PicFromWad ("net");
|
||||||
|
@ -593,7 +594,7 @@ void SCR_DrawConsole (void)
|
||||||
if (scr_con_current)
|
if (scr_con_current)
|
||||||
{
|
{
|
||||||
scr_copyeverything = 1;
|
scr_copyeverything = 1;
|
||||||
Con_DrawConsole (scr_con_current, true);
|
Con_DrawConsole (scr_con_current);//, true);
|
||||||
clearconsole = 0;
|
clearconsole = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -146,7 +146,7 @@ void S_SoundInfo_f(void)
|
||||||
Con_Printf("%5d samplebits\n", shm->samplebits);
|
Con_Printf("%5d samplebits\n", shm->samplebits);
|
||||||
Con_Printf("%5d submission_chunk\n", shm->submission_chunk);
|
Con_Printf("%5d submission_chunk\n", shm->submission_chunk);
|
||||||
Con_Printf("%5d speed\n", shm->speed);
|
Con_Printf("%5d speed\n", shm->speed);
|
||||||
Con_Printf("0x%x dma buffer\n", shm->buffer);
|
Con_Printf("0x%x dma buffer\n", (int)shm->buffer);
|
||||||
Con_Printf("%5d total_channels\n", total_channels);
|
Con_Printf("%5d total_channels\n", total_channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,11 +192,11 @@ void S_Init (void)
|
||||||
|
|
||||||
Con_Printf("\nSound Initialization\n");
|
Con_Printf("\nSound Initialization\n");
|
||||||
|
|
||||||
Cmd_AddCommand("play", S_Play);
|
Cmd_AddCommand("play", S_Play, "No Description");
|
||||||
Cmd_AddCommand("playvol", S_PlayVol);
|
Cmd_AddCommand("playvol", S_PlayVol, "No Description");
|
||||||
Cmd_AddCommand("stopsound", S_StopAllSoundsC);
|
Cmd_AddCommand("stopsound", S_StopAllSoundsC, "No Description");
|
||||||
Cmd_AddCommand("soundlist", S_SoundList);
|
Cmd_AddCommand("soundlist", S_SoundList, "No Description");
|
||||||
Cmd_AddCommand("soundinfo", S_SoundInfo_f);
|
Cmd_AddCommand("soundinfo", S_SoundInfo_f, "No Description");
|
||||||
|
|
||||||
nosound = Cvar_Get("nosound", "0", CVAR_NONE, "None");
|
nosound = Cvar_Get("nosound", "0", CVAR_NONE, "None");
|
||||||
volume = Cvar_Get("volume", "0.7", CVAR_ARCHIVE, "None");
|
volume = Cvar_Get("volume", "0.7", CVAR_ARCHIVE, "None");
|
||||||
|
|
|
@ -445,7 +445,7 @@ qboolean BLASTER_Init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Cmd_AddCommand("sbinfo", SB_Info_f);
|
Cmd_AddCommand("sbinfo", SB_Info_f, "No Description");
|
||||||
size = 4096;
|
size = 4096;
|
||||||
|
|
||||||
// allocate 8k and get a 4k-aligned buffer from it
|
// allocate 8k and get a 4k-aligned buffer from it
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "msg.h"
|
#include "msg.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
|
#include "cmd.h"
|
||||||
#include "host.h"
|
#include "host.h"
|
||||||
#include "world.h"
|
#include "world.h"
|
||||||
|
|
||||||
|
@ -1001,7 +1002,7 @@ void SV_SendReconnect (void)
|
||||||
#ifdef QUAKE2
|
#ifdef QUAKE2
|
||||||
Cbuf_InsertText ("reconnect\n");
|
Cbuf_InsertText ("reconnect\n");
|
||||||
#else
|
#else
|
||||||
Cmd_ExecuteString ("reconnect\n", src_command);
|
Cmd_ExecuteString_src ("reconnect\n", src_command);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "world.h"
|
#include "world.h"
|
||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
|
#include "cmd.h"
|
||||||
#include "host.h"
|
#include "host.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
edict_t *sv_player;
|
edict_t *sv_player;
|
||||||
|
@ -588,7 +589,7 @@ nextmsg:
|
||||||
if (ret == 2)
|
if (ret == 2)
|
||||||
Cbuf_InsertText (s);
|
Cbuf_InsertText (s);
|
||||||
else if (ret == 1)
|
else if (ret == 1)
|
||||||
Cmd_ExecuteString (s, src_client);
|
Cmd_ExecuteString_src (s, src_client);
|
||||||
else
|
else
|
||||||
Con_DPrintf("%s tried to %s\n", host_client->name, s);
|
Con_DPrintf("%s tried to %s\n", host_client->name, s);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -116,11 +116,11 @@ void VID_Init (unsigned char *palette)
|
||||||
vid_windowed_mode = Cvar_Get("vid_windowed_mode", "0", CVAR_ARCHIVE, "None");
|
vid_windowed_mode = Cvar_Get("vid_windowed_mode", "0", CVAR_ARCHIVE, "None");
|
||||||
block_switch = Cvar_Get("block_switch", "0", CVAR_ARCHIVE, "None");
|
block_switch = Cvar_Get("block_switch", "0", CVAR_ARCHIVE, "None");
|
||||||
|
|
||||||
Cmd_AddCommand ("vid_testmode", VID_TestMode_f);
|
Cmd_AddCommand ("vid_testmode", VID_TestMode_f, "No Description");
|
||||||
Cmd_AddCommand ("vid_nummodes", VID_NumModes_f);
|
Cmd_AddCommand ("vid_nummodes", VID_NumModes_f, "No Description");
|
||||||
Cmd_AddCommand ("vid_describecurrentmode", VID_DescribeCurrentMode_f);
|
Cmd_AddCommand ("vid_describecurrentmode", VID_DescribeCurrentMode_f, "No Description");
|
||||||
Cmd_AddCommand ("vid_describemode", VID_DescribeMode_f);
|
Cmd_AddCommand ("vid_describemode", VID_DescribeMode_f, "No Description");
|
||||||
Cmd_AddCommand ("vid_describemodes", VID_DescribeModes_f);
|
Cmd_AddCommand ("vid_describemodes", VID_DescribeModes_f, "No Description");
|
||||||
|
|
||||||
// set up the mode list; note that later inits link in their modes ahead of
|
// set up the mode list; note that later inits link in their modes ahead of
|
||||||
// earlier ones, so the standard VGA modes are always first in the list. This
|
// earlier ones, so the standard VGA modes are always first in the list. This
|
||||||
|
|
|
@ -2095,15 +2095,15 @@ void VID_Init (unsigned char *palette)
|
||||||
int basenummodes;
|
int basenummodes;
|
||||||
byte *ptmp;
|
byte *ptmp;
|
||||||
|
|
||||||
Cmd_AddCommand ("vid_testmode", VID_TestMode_f);
|
Cmd_AddCommand ("vid_testmode", VID_TestMode_f, "No Description");
|
||||||
Cmd_AddCommand ("vid_nummodes", VID_NumModes_f);
|
Cmd_AddCommand ("vid_nummodes", VID_NumModes_f, "No Description");
|
||||||
Cmd_AddCommand ("vid_describecurrentmode", VID_DescribeCurrentMode_f);
|
Cmd_AddCommand ("vid_describecurrentmode", VID_DescribeCurrentMode_f, "No Description");
|
||||||
Cmd_AddCommand ("vid_describemode", VID_DescribeMode_f);
|
Cmd_AddCommand ("vid_describemode", VID_DescribeMode_f, "No Description");
|
||||||
Cmd_AddCommand ("vid_describemodes", VID_DescribeModes_f);
|
Cmd_AddCommand ("vid_describemodes", VID_DescribeModes_f, "No Description");
|
||||||
Cmd_AddCommand ("vid_forcemode", VID_ForceMode_f);
|
Cmd_AddCommand ("vid_forcemode", VID_ForceMode_f, "No Description");
|
||||||
Cmd_AddCommand ("vid_windowed", VID_Windowed_f);
|
Cmd_AddCommand ("vid_windowed", VID_Windowed_f, "No Description");
|
||||||
Cmd_AddCommand ("vid_fullscreen", VID_Fullscreen_f);
|
Cmd_AddCommand ("vid_fullscreen", VID_Fullscreen_f, "No Description");
|
||||||
Cmd_AddCommand ("vid_minimize", VID_Minimize_f);
|
Cmd_AddCommand ("vid_minimize", VID_Minimize_f, "No Description");
|
||||||
|
|
||||||
if (COM_CheckParm ("-dibonly"))
|
if (COM_CheckParm ("-dibonly"))
|
||||||
dibonly = true;
|
dibonly = true;
|
||||||
|
|
|
@ -587,7 +587,7 @@ void VID_Init (unsigned char *palette)
|
||||||
int num_visuals;
|
int num_visuals;
|
||||||
int template_mask;
|
int template_mask;
|
||||||
|
|
||||||
Cmd_AddCommand ("gamma", VID_Gamma_f);
|
Cmd_AddCommand ("gamma", VID_Gamma_f, "No Description");
|
||||||
for (i=0 ; i<256 ; i++)
|
for (i=0 ; i<256 ; i++)
|
||||||
vid_gamma[i] = i;
|
vid_gamma[i] = i;
|
||||||
|
|
||||||
|
|
|
@ -402,7 +402,7 @@ void VID_Init (unsigned char *palette)
|
||||||
|
|
||||||
int desired_width=320, desired_height=200;
|
int desired_width=320, desired_height=200;
|
||||||
|
|
||||||
Cmd_AddCommand ("gamma", VID_Gamma_f);
|
Cmd_AddCommand ("gamma", VID_Gamma_f, "No Description");
|
||||||
|
|
||||||
pixel_multiply = Cvar_Get("pixel_multiply", "2", CVAR_ARCHIVE, "None");
|
pixel_multiply = Cvar_Get("pixel_multiply", "2", CVAR_ARCHIVE, "None");
|
||||||
|
|
||||||
|
|
|
@ -545,7 +545,7 @@ VID_Init(unsigned char *palette)
|
||||||
if (svgalib_inited) return;
|
if (svgalib_inited) return;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
Cmd_AddCommand ("gamma", VID_Gamma_f);
|
Cmd_AddCommand ("gamma", VID_Gamma_f, "No Description");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (UseDisplay) {
|
if (UseDisplay) {
|
||||||
|
@ -555,10 +555,10 @@ VID_Init(unsigned char *palette)
|
||||||
|
|
||||||
VID_InitModes();
|
VID_InitModes();
|
||||||
|
|
||||||
Cmd_AddCommand("vid_nummodes", VID_NumModes_f);
|
Cmd_AddCommand("vid_nummodes", VID_NumModes_f, "No Description");
|
||||||
Cmd_AddCommand("vid_describemode", VID_DescribeMode_f);
|
Cmd_AddCommand("vid_describemode", VID_DescribeMode_f, "No Description");
|
||||||
Cmd_AddCommand("vid_describemodes", VID_DescribeModes_f);
|
Cmd_AddCommand("vid_describemodes", VID_DescribeModes_f, "No Description");
|
||||||
Cmd_AddCommand("vid_debug", VID_Debug_f);
|
Cmd_AddCommand("vid_debug", VID_Debug_f, "No Description");
|
||||||
|
|
||||||
/* Interpret command-line params */
|
/* Interpret command-line params */
|
||||||
w = h = d = 0;
|
w = h = d = 0;
|
||||||
|
|
|
@ -1575,10 +1575,10 @@ void VID_Init (unsigned char *palette)
|
||||||
|
|
||||||
memset(&devmode, 0, sizeof(devmode));
|
memset(&devmode, 0, sizeof(devmode));
|
||||||
|
|
||||||
Cmd_AddCommand ("vid_nummodes", VID_NumModes_f);
|
Cmd_AddCommand ("vid_nummodes", VID_NumModes_f, "No Description");
|
||||||
Cmd_AddCommand ("vid_describecurrentmode", VID_DescribeCurrentMode_f);
|
Cmd_AddCommand ("vid_describecurrentmode", VID_DescribeCurrentMode_f, "No Description");
|
||||||
Cmd_AddCommand ("vid_describemode", VID_DescribeMode_f);
|
Cmd_AddCommand ("vid_describemode", VID_DescribeMode_f, "No Description");
|
||||||
Cmd_AddCommand ("vid_describemodes", VID_DescribeModes_f);
|
Cmd_AddCommand ("vid_describemodes", VID_DescribeModes_f, "No Description");
|
||||||
|
|
||||||
hIcon = LoadIcon (global_hInstance, MAKEINTRESOURCE (IDI_ICON2));
|
hIcon = LoadIcon (global_hInstance, MAKEINTRESOURCE (IDI_ICON2));
|
||||||
|
|
||||||
|
|
|
@ -2089,15 +2089,15 @@ void VID_Init (unsigned char *palette)
|
||||||
vid_window_x = Cvar_Get("vid_window_x", "0", CVAR_ARCHIVE, "None");
|
vid_window_x = Cvar_Get("vid_window_x", "0", CVAR_ARCHIVE, "None");
|
||||||
vid_window_y = Cvar_Get("vid_window_y", "0", CVAR_ARCHIVE, "None");
|
vid_window_y = Cvar_Get("vid_window_y", "0", CVAR_ARCHIVE, "None");
|
||||||
|
|
||||||
Cmd_AddCommand ("vid_testmode", VID_TestMode_f);
|
Cmd_AddCommand ("vid_testmode", VID_TestMode_f, "No Description");
|
||||||
Cmd_AddCommand ("vid_nummodes", VID_NumModes_f);
|
Cmd_AddCommand ("vid_nummodes", VID_NumModes_f, "No Description");
|
||||||
Cmd_AddCommand ("vid_describecurrentmode", VID_DescribeCurrentMode_f);
|
Cmd_AddCommand ("vid_describecurrentmode", VID_DescribeCurrentMode_f, "No Description");
|
||||||
Cmd_AddCommand ("vid_describemode", VID_DescribeMode_f);
|
Cmd_AddCommand ("vid_describemode", VID_DescribeMode_f, "No Description");
|
||||||
Cmd_AddCommand ("vid_describemodes", VID_DescribeModes_f);
|
Cmd_AddCommand ("vid_describemodes", VID_DescribeModes_f, "No Description");
|
||||||
Cmd_AddCommand ("vid_forcemode", VID_ForceMode_f);
|
Cmd_AddCommand ("vid_forcemode", VID_ForceMode_f, "No Description");
|
||||||
Cmd_AddCommand ("vid_windowed", VID_Windowed_f);
|
Cmd_AddCommand ("vid_windowed", VID_Windowed_f, "No Description");
|
||||||
Cmd_AddCommand ("vid_fullscreen", VID_Fullscreen_f);
|
Cmd_AddCommand ("vid_fullscreen", VID_Fullscreen_f, "No Description");
|
||||||
Cmd_AddCommand ("vid_minimize", VID_Minimize_f);
|
Cmd_AddCommand ("vid_minimize", VID_Minimize_f, "No Description");
|
||||||
|
|
||||||
if (COM_CheckParm ("-dibonly"))
|
if (COM_CheckParm ("-dibonly"))
|
||||||
dibonly = true;
|
dibonly = true;
|
||||||
|
|
|
@ -472,7 +472,7 @@ void VID_Init (unsigned char *palette)
|
||||||
VID_GetWindowSize (320, 200);
|
VID_GetWindowSize (320, 200);
|
||||||
|
|
||||||
//plugin_load("in_x11.so");
|
//plugin_load("in_x11.so");
|
||||||
// Cmd_AddCommand("gamma", VID_Gamma_f);
|
// Cmd_AddCommand("gamma", VID_Gamma_f, "No Description");
|
||||||
for (i=0; i < 256; i++) vid_gamma[i] = i;
|
for (i=0; i < 256; i++) vid_gamma[i] = i;
|
||||||
|
|
||||||
vid.width = vid_width->int_val;
|
vid.width = vid_width->int_val;
|
||||||
|
|
749
nq/source/zone.c
749
nq/source/zone.c
File diff suppressed because it is too large
Load diff
|
@ -1,78 +0,0 @@
|
||||||
/*
|
|
||||||
qtypes.h
|
|
||||||
|
|
||||||
(description)
|
|
||||||
|
|
||||||
Copyright (C) 1996-1997 Id Software, Inc.
|
|
||||||
Copyright (C) 1999,2000 contributors of the QuakeForge project
|
|
||||||
Please see the file "AUTHORS" for a list of contributors
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
|
|
||||||
See the GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to:
|
|
||||||
|
|
||||||
Free Software Foundation, Inc.
|
|
||||||
59 Temple Place - Suite 330
|
|
||||||
Boston, MA 02111-1307, USA
|
|
||||||
|
|
||||||
$Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _QTYPES_H
|
|
||||||
#define _QTYPES_H
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include "qdefs.h"
|
|
||||||
#include "compat.h"
|
|
||||||
|
|
||||||
#define MAX_QPATH 64
|
|
||||||
|
|
||||||
#ifndef _DEF_BYTE_
|
|
||||||
# define _DEF_BYTE_
|
|
||||||
typedef unsigned char byte;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// KJB Undefined true and false defined in SciTech's DEBUG.H header
|
|
||||||
#undef true
|
|
||||||
#undef false
|
|
||||||
typedef enum {false, true} qboolean;
|
|
||||||
|
|
||||||
// From mathlib...
|
|
||||||
typedef float vec_t;
|
|
||||||
typedef vec_t vec3_t[3];
|
|
||||||
typedef vec_t vec5_t[5];
|
|
||||||
typedef int fixed4_t;
|
|
||||||
typedef int fixed8_t;
|
|
||||||
typedef int fixed16_t;
|
|
||||||
|
|
||||||
|
|
||||||
typedef int func_t;
|
|
||||||
typedef int string_t;
|
|
||||||
typedef byte pixel_t;
|
|
||||||
|
|
||||||
/*
|
|
||||||
typedef enum {key_game, key_console, key_message, key_menu} keydest_t;
|
|
||||||
typedef enum { ALIAS_SINGLE=0, ALIAS_GROUP } aliasframetype_t;
|
|
||||||
typedef enum { ALIAS_SKIN_SINGLE=0, ALIAS_SKIN_GROUP } aliasskintype_t;
|
|
||||||
typedef enum {ev_void, ev_string, ev_float, ev_vector, ev_entity, ev_field, ev_function, ev_pointer} etype_t;
|
|
||||||
typedef void (*builtin_t) (void);
|
|
||||||
typedef enum {touchessolid, drawnode, nodrawnode} solidstate_t;
|
|
||||||
typedef enum { ST_SYNC=0, ST_RAND } synctype_t;
|
|
||||||
typedef enum { SPR_SINGLE=0, SPR_GROUP } spriteframetype_t;
|
|
||||||
typedef enum {MS_WINDOWED, MS_FULLSCREEN, MS_FULLDIB, MS_UNINIT} modestate_t;
|
|
||||||
typedef enum {mod_brush, mod_sprite, mod_alias} modtype_t;
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif // _QTYPES_H
|
|
|
@ -1,69 +0,0 @@
|
||||||
/*
|
|
||||||
quakeio.h
|
|
||||||
|
|
||||||
(description)
|
|
||||||
|
|
||||||
Copyright (C) 1996-1997 Id Software, Inc.
|
|
||||||
Copyright (C) 1999,2000 contributors of the QuakeForge project
|
|
||||||
Please see the file "AUTHORS" for a list of contributors
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
|
|
||||||
See the GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to:
|
|
||||||
|
|
||||||
Free Software Foundation, Inc.
|
|
||||||
59 Temple Place - Suite 330
|
|
||||||
Boston, MA 02111-1307, USA
|
|
||||||
|
|
||||||
$Id$
|
|
||||||
*/
|
|
||||||
#ifndef _QUAKEIO_H
|
|
||||||
#define _QUAKEIO_H
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
# include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_ZLIB
|
|
||||||
# include <zlib.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "gcc_attr.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
FILE *file;
|
|
||||||
#ifdef HAVE_ZLIB
|
|
||||||
gzFile *gzfile;
|
|
||||||
#endif
|
|
||||||
} QFile;
|
|
||||||
|
|
||||||
void Qexpand_squiggle(const char *path, char *dest);
|
|
||||||
int Qrename(const char *old, const char *new);
|
|
||||||
QFile *Qopen(const char *path, const char *mode);
|
|
||||||
QFile *Qdopen(int fd, const char *mode);
|
|
||||||
void Qclose(QFile *file);
|
|
||||||
int Qread(QFile *file, void *buf, int count);
|
|
||||||
int Qwrite(QFile *file, void *buf, int count);
|
|
||||||
int Qprintf(QFile *file, const char *fmt, ...) __attribute__((format(printf,2,3)));
|
|
||||||
char *Qgets(QFile *file, char *buf, int count);
|
|
||||||
int Qgetc(QFile *file);
|
|
||||||
int Qputc(QFile *file, int c);
|
|
||||||
int Qseek(QFile *file, long offset, int whence);
|
|
||||||
long Qtell(QFile *file);
|
|
||||||
int Qflush(QFile *file);
|
|
||||||
int Qeof(QFile *file);
|
|
||||||
char *Qgetline(QFile *file);
|
|
||||||
|
|
||||||
#endif /*_QUAKEIO_H*/
|
|
Loading…
Reference in a new issue