Whitespace, dammit. Oh, and removal of several orphaned comments. Comments in front of functions suck.

This commit is contained in:
Ragnvald Maartmann-Moe IV 2001-08-22 22:03:16 +00:00
parent 62d0845528
commit edcf092b05
28 changed files with 350 additions and 555 deletions

View file

@ -115,6 +115,7 @@ static byte chktbl[1024 + 4] = {
0x00, 0x00, 0x00, 0x00 0x00, 0x00, 0x00, 0x00
}; };
/* /*
COM_BlockSequenceCRCByte COM_BlockSequenceCRCByte

View file

@ -38,10 +38,9 @@
#include <ctype.h> #include <ctype.h>
#include "QF/cvar.h"
#include "QF/cmd.h" #include "QF/cmd.h"
#include "compat.h"
#include "QF/console.h" #include "QF/console.h"
#include "QF/cvar.h"
#include "QF/hash.h" #include "QF/hash.h"
#include "QF/qargs.h" #include "QF/qargs.h"
#include "QF/qendian.h" #include "QF/qendian.h"
@ -50,6 +49,8 @@
#include "QF/vfs.h" #include "QF/vfs.h"
#include "QF/zone.h" #include "QF/zone.h"
#include "compat.h"
typedef struct cmdalias_s { typedef struct cmdalias_s {
struct cmdalias_s *next; struct cmdalias_s *next;
const char *name; const char *name;
@ -87,9 +88,6 @@ Cmd_Wait_f (void)
sizebuf_t cmd_text; sizebuf_t cmd_text;
byte cmd_text_buf[8192]; byte cmd_text_buf[8192];
/*
Cbuf_Init
*/
void void
Cbuf_Init (void) Cbuf_Init (void)
{ {
@ -116,7 +114,6 @@ Cbuf_AddText (const char *text)
SZ_Write (&cmd_text, text, strlen (text)); SZ_Write (&cmd_text, text, strlen (text));
} }
/* /*
Cbuf_InsertText Cbuf_InsertText
@ -149,7 +146,6 @@ Cbuf_InsertText (const char *text)
cmd_text.data[textlen] = '\n'; cmd_text.data[textlen] = '\n';
} }
static void static void
extract_line (char *line) extract_line (char *line)
{ {
@ -185,11 +181,6 @@ extract_line (char *line)
} }
} }
/*
Cbuf_Execute
*/
void void
Cbuf_Execute (void) Cbuf_Execute (void)
{ {
@ -210,11 +201,6 @@ Cbuf_Execute (void)
} }
} }
/*
Cbuf_Execute
*/
void void
Cbuf_Execute_Sets (void) Cbuf_Execute_Sets (void)
{ {
@ -256,7 +242,7 @@ Cmd_StuffCmds_f (void)
if (!s) if (!s)
return; return;
// pull out the commands // pull out the commands
build = malloc (s + 1); build = malloc (s + 1);
build[0] = 0; build[0] = 0;
@ -287,11 +273,6 @@ Cmd_StuffCmds_f (void)
free (build); free (build);
} }
/*
Cmd_Exec_File
*/
void void
Cmd_Exec_File (const char *path) Cmd_Exec_File (const char *path)
{ {
@ -313,9 +294,6 @@ Cmd_Exec_File (const char *path)
} }
} }
/*
Cmd_Exec_f
*/
void void
Cmd_Exec_f (void) Cmd_Exec_f (void)
{ {
@ -341,7 +319,6 @@ Cmd_Exec_f (void)
Hunk_FreeToLowMark (mark); Hunk_FreeToLowMark (mark);
} }
/* /*
Cmd_Echo_f Cmd_Echo_f
@ -362,7 +339,6 @@ Cmd_Echo_f (void)
Creates a new command that executes a command string (possibly ; seperated) Creates a new command that executes a command string (possibly ; seperated)
*/ */
char * char *
CopyString (char *in) CopyString (char *in)
{ {
@ -406,7 +382,7 @@ Cmd_Alias_f (void)
*a = alias; *a = alias;
} }
// copy the rest of the command line // copy the rest of the command line
cmd = malloc (strlen (Cmd_Args (1)) + 2);// can never be longer cmd = malloc (strlen (Cmd_Args (1)) + 2);// can never be longer
cmd[0] = 0; // start out with a null string cmd[0] = 0; // start out with a null string
c = Cmd_Argc (); c = Cmd_Argc ();
@ -469,22 +445,14 @@ static char *cmd_argv[MAX_ARGS];
static const char *cmd_null_string = ""; static const char *cmd_null_string = "";
static const char *cmd_args[MAX_ARGS]; static const char *cmd_args[MAX_ARGS];
static cmd_function_t *cmd_functions; // possible commands to execute static cmd_function_t *cmd_functions; // possible commands to execute
/*
Cmd_Argc
*/
int int
Cmd_Argc (void) Cmd_Argc (void)
{ {
return cmd_argc; return cmd_argc;
} }
/*
Cmd_Argv
*/
const char * const char *
Cmd_Argv (int arg) Cmd_Argv (int arg)
{ {
@ -506,7 +474,6 @@ Cmd_Args (int start)
return cmd_args[start]; return cmd_args[start];
} }
/* /*
Cmd_TokenizeString Cmd_TokenizeString
@ -524,7 +491,7 @@ Cmd_TokenizeString (const char *text)
memset (cmd_args, 0, sizeof (cmd_args)); memset (cmd_args, 0, sizeof (cmd_args));
while (1) { while (1) {
// skip whitespace up to a \n // skip whitespace up to a \n
while (*text && *(unsigned char *) text <= ' ' && *text != '\n') { while (*text && *(unsigned char *) text <= ' ' && *text != '\n') {
text++; text++;
} }
@ -557,13 +524,8 @@ Cmd_TokenizeString (const char *text)
cmd_argc++; cmd_argc++;
} }
} }
} }
/*
Cmd_AddCommand
*/
void void
Cmd_AddCommand (const char *cmd_name, xcommand_t function, const char *description) Cmd_AddCommand (const char *cmd_name, xcommand_t function, const char *description)
{ {
@ -594,9 +556,6 @@ Cmd_AddCommand (const char *cmd_name, xcommand_t function, const char *descripti
*c = cmd; *c = cmd;
} }
/*
Cmd_Exists
*/
qboolean qboolean
Cmd_Exists (const char *cmd_name) Cmd_Exists (const char *cmd_name)
{ {
@ -610,11 +569,6 @@ Cmd_Exists (const char *cmd_name)
return false; return false;
} }
/*
Cmd_CompleteCommand
*/
const char * const char *
Cmd_CompleteCommand (const char *partial) Cmd_CompleteCommand (const char *partial)
{ {
@ -627,7 +581,7 @@ Cmd_CompleteCommand (const char *partial)
if (!len) if (!len)
return NULL; return NULL;
// check for exact match // check for exact match
for (cmd = cmd_functions; cmd; cmd = cmd->next) for (cmd = cmd_functions; cmd; cmd = cmd->next)
if (!strcasecmp (partial, cmd->name)) if (!strcasecmp (partial, cmd->name))
return cmd->name; return cmd->name;
@ -635,7 +589,7 @@ Cmd_CompleteCommand (const char *partial)
if (!strcasecmp (partial, a->name)) if (!strcasecmp (partial, a->name))
return a->name; return a->name;
// check for partial match // check for partial match
for (cmd = cmd_functions; cmd; cmd = cmd->next) for (cmd = cmd_functions; cmd; cmd = cmd->next)
if (!strncasecmp (partial, cmd->name, len)) if (!strncasecmp (partial, cmd->name, len))
return cmd->name; return cmd->name;
@ -653,7 +607,6 @@ Cmd_CompleteCommand (const char *partial)
Added by EvilTypeGuy Added by EvilTypeGuy
Thanks to Fett erich@heintz.com Thanks to Fett erich@heintz.com
Thanks to taniwha Thanks to taniwha
*/ */
int int
Cmd_CompleteCountPossible (const char *partial) Cmd_CompleteCountPossible (const char *partial)
@ -683,7 +636,6 @@ Cmd_CompleteCountPossible (const char *partial)
Added by EvilTypeGuy Added by EvilTypeGuy
Thanks to Fett erich@heintz.com Thanks to Fett erich@heintz.com
Thanks to taniwha Thanks to taniwha
*/ */
const char ** const char **
Cmd_CompleteBuildList (const char *partial) Cmd_CompleteBuildList (const char *partial)
@ -712,7 +664,6 @@ Cmd_CompleteBuildList (const char *partial)
Added by EvilTypeGuy Added by EvilTypeGuy
Thanks to Fett erich@heintz.com Thanks to Fett erich@heintz.com
Thanks to taniwha Thanks to taniwha
*/ */
const char * const char *
Cmd_CompleteAlias (const char * partial) Cmd_CompleteAlias (const char * partial)
@ -740,7 +691,6 @@ Cmd_CompleteAlias (const char * partial)
Added by EvilTypeGuy Added by EvilTypeGuy
Thanks to Fett erich@heintz.com Thanks to Fett erich@heintz.com
Thanks to taniwha Thanks to taniwha
*/ */
int int
Cmd_CompleteAliasCountPossible (const char *partial) Cmd_CompleteAliasCountPossible (const char *partial)
@ -771,7 +721,6 @@ Cmd_CompleteAliasCountPossible (const char *partial)
Added by EvilTypeGuy Added by EvilTypeGuy
Thanks to Fett erich@heintz.com Thanks to Fett erich@heintz.com
Thanks to taniwha Thanks to taniwha
*/ */
const char ** const char **
Cmd_CompleteAliasBuildList (const char *partial) Cmd_CompleteAliasBuildList (const char *partial)
@ -779,7 +728,8 @@ Cmd_CompleteAliasBuildList (const char *partial)
cmdalias_t *alias; cmdalias_t *alias;
int len = 0; int len = 0;
int bpos = 0; int bpos = 0;
int sizeofbuf = (Cmd_CompleteAliasCountPossible (partial) + 1) * sizeof (char *); int sizeofbuf = (Cmd_CompleteAliasCountPossible (partial) + 1) *
sizeof (char *);
const char **buf; const char **buf;
len = strlen(partial); len = strlen(partial);
@ -811,7 +761,7 @@ Cmd_ExpandVariables (const char *data, char *dest)
len = 0; len = 0;
// parse a regular word // parse a regular word
while ((c = *data) != 0) { while ((c = *data) != 0) {
if (c == '"') if (c == '"')
quotes++; quotes++;
@ -886,11 +836,11 @@ Cmd_ExecuteString (const char *text, cmd_source_t src)
Cmd_TokenizeString (buf); Cmd_TokenizeString (buf);
#endif #endif
// execute the command line // execute the command line
if (!Cmd_Argc ()) if (!Cmd_Argc ())
return; // no tokens return; // no tokens
// check functions // check functions
cmd = (cmd_function_t*)Hash_Find (cmd_hash, cmd_argv[0]); cmd = (cmd_function_t*)Hash_Find (cmd_hash, cmd_argv[0]);
if (cmd) { if (cmd) {
if (cmd->function) if (cmd->function)
@ -898,11 +848,11 @@ Cmd_ExecuteString (const char *text, cmd_source_t src)
return; return;
} }
// Tonik: check cvars // Tonik: check cvars
if (Cvar_Command ()) if (Cvar_Command ())
return; return;
// check alias // check alias
a = (cmdalias_t*)Hash_Find (cmd_alias_hash, cmd_argv[0]); a = (cmdalias_t*)Hash_Find (cmd_alias_hash, cmd_argv[0]);
if (a) { if (a) {
Cbuf_InsertText (a->value); Cbuf_InsertText (a->value);
@ -913,8 +863,6 @@ Cmd_ExecuteString (const char *text, cmd_source_t src)
Con_Printf ("Unknown command \"%s\"\n", Cmd_Argv (0)); Con_Printf ("Unknown command \"%s\"\n", Cmd_Argv (0));
} }
/* /*
Cmd_CheckParm Cmd_CheckParm
@ -970,7 +918,8 @@ Cmd_Help_f (void)
name = Cmd_Argv (1); name = Cmd_Argv (1);
for (cmd = cmd_functions; cmd && strcasecmp (name, cmd->name); cmd = cmd->next) for (cmd = cmd_functions; cmd && strcasecmp (name, cmd->name);
cmd = cmd->next)
; ;
if (cmd) { if (cmd) {
Con_Printf ("%s\n", cmd->description); Con_Printf ("%s\n", cmd->description);
@ -1021,31 +970,31 @@ void
Cmd_Init_Hash (void) Cmd_Init_Hash (void)
{ {
cmd_hash = Hash_NewTable (1021, cmd_get_key, 0, 0); cmd_hash = Hash_NewTable (1021, cmd_get_key, 0, 0);
cmd_alias_hash = Hash_NewTable (1021, cmd_alias_get_key, cmd_alias_free, 0); cmd_alias_hash = Hash_NewTable (1021, cmd_alias_get_key, cmd_alias_free,
0);
} }
/*
Cmd_Init
*/
void void
Cmd_Init (void) Cmd_Init (void)
{ {
// // register our commands
// register our commands Cmd_AddCommand ("stuffcmds", Cmd_StuffCmds_f, "Execute the commands given "
// "at startup again");
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 ("exec", Cmd_Exec_f, "Execute a script file");
Cmd_AddCommand ("echo", Cmd_Echo_f, "Print text to console"); 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" Cmd_AddCommand ("alias", Cmd_Alias_f, "Used to create a reference to a "
"When used without parameters, displays all current aliases.\n" "command or list of commands.\n"
"Note: Enclose multiple commands within quotes and seperate each command with a semi-colon."); "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 ("unalias", Cmd_UnAlias_f, "Remove the selected alias");
Cmd_AddCommand ("wait", Cmd_Wait_f, "Wait a game tic"); Cmd_AddCommand ("wait", Cmd_Wait_f, "Wait a game tic");
Cmd_AddCommand ("cmdlist", Cmd_CmdList_f, "List all commands"); Cmd_AddCommand ("cmdlist", Cmd_CmdList_f, "List all commands");
Cmd_AddCommand ("help", Cmd_Help_f, "Display help for a command or variable"); Cmd_AddCommand ("help", Cmd_Help_f, "Display help for a command or "
"variable");
} }
char com_token[MAX_COM_TOKEN]; char com_token[MAX_COM_TOKEN];
/* /*
@ -1065,22 +1014,22 @@ COM_Parse (const char *data)
if (!data) if (!data)
return NULL; return NULL;
// skip whitespace // skip whitespace
skipwhite: skipwhite:
while ((c = *data) <= ' ') { while ((c = *data) <= ' ') {
if (c == 0) if (c == 0)
return NULL; // end of file; return NULL; // end of file;
data++; data++;
} }
// skip // comments // skip // comments
if (c == '/' && data[1] == '/') { if (c == '/' && data[1] == '/') {
while (*data && *data != '\n') while (*data && *data != '\n')
data++; data++;
goto skipwhite; goto skipwhite;
} }
// handle quoted strings specially // handle quoted strings specially
if (c == '\"') { if (c == '\"') {
data++; data++;
while (1) { while (1) {
@ -1093,7 +1042,7 @@ COM_Parse (const char *data)
len++; len++;
} }
} }
// parse a regular word // parse a regular word
do { do {
com_token[len] = c; com_token[len] = c;
data++; data++;

View file

@ -33,6 +33,7 @@
#include "QF/console.h" #include "QF/console.h"
#include "QF/sys.h" #include "QF/sys.h"
/* /*
Con_Print Con_Print

View file

@ -38,18 +38,20 @@
#include <stdarg.h> #include <stdarg.h>
#include "compat.h"
#include "QF/console.h" #include "QF/console.h"
#include "QF/cvar.h" #include "QF/cvar.h"
#include "QF/sys.h" #include "QF/sys.h"
#include "compat.h"
#define MAXPRINTMSG 4096
/* /*
Con_Printf Con_Printf
Handles cursor positioning, line wrapping, etc Handles cursor positioning, line wrapping, etc
*/ */
#define MAXPRINTMSG 4096
void void
Con_Printf (const char *fmt, ...) Con_Printf (const char *fmt, ...)
{ {
@ -130,4 +132,3 @@ Con_DisplayList(const char **list, int con_linewidth)
if (pos) if (pos)
Con_Printf("\n\n"); Con_Printf("\n\n");
} }

View file

@ -74,6 +74,7 @@ static unsigned short crctable[256] = {
0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
}; };
void void
CRC_Init (unsigned short *crcvalue) CRC_Init (unsigned short *crcvalue)
{ {

View file

@ -41,14 +41,15 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "compat.h"
#include "QF/console.h"
#include "QF/cmd.h" #include "QF/cmd.h"
#include "QF/console.h"
#include "QF/cvar.h" #include "QF/cvar.h"
#include "QF/hash.h" #include "QF/hash.h"
#include "QF/qargs.h" #include "QF/qargs.h"
#include "QF/vfs.h" #include "QF/vfs.h"
#include "compat.h"
#define USER_RO_CVAR "User-created READ-ONLY Cvar" #define USER_RO_CVAR "User-created READ-ONLY Cvar"
#define USER_CVAR "User-created cvar" #define USER_CVAR "User-created cvar"
@ -60,9 +61,7 @@ cvar_alias_t *calias_vars;
hashtab_t *cvar_hash; hashtab_t *cvar_hash;
hashtab_t *calias_hash; hashtab_t *calias_hash;
/*
Cvar_FindVar
*/
cvar_t * cvar_t *
Cvar_FindVar (const char *var_name) Cvar_FindVar (const char *var_name)
{ {
@ -106,9 +105,6 @@ Cvar_Alias_Get (const char *name, cvar_t *cvar)
} }
} }
/*
Cvar_VariableValue
*/
float float
Cvar_VariableValue (const char *var_name) Cvar_VariableValue (const char *var_name)
{ {
@ -122,10 +118,6 @@ Cvar_VariableValue (const char *var_name)
return atof (var->string); return atof (var->string);
} }
/*
Cvar_VariableString
*/
const char * const char *
Cvar_VariableString (const char *var_name) Cvar_VariableString (const char *var_name)
{ {
@ -139,10 +131,6 @@ Cvar_VariableString (const char *var_name)
return var->string; return var->string;
} }
/*
Cvar_CompleteVariable
*/
const char * const char *
Cvar_CompleteVariable (const char *partial) Cvar_CompleteVariable (const char *partial)
{ {
@ -184,7 +172,6 @@ Cvar_CompleteVariable (const char *partial)
New function for tab-completion system New function for tab-completion system
Added by EvilTypeGuy Added by EvilTypeGuy
Thanks to Fett erich@heintz.com Thanks to Fett erich@heintz.com
*/ */
int int
Cvar_CompleteCountPossible (const char *partial) Cvar_CompleteCountPossible (const char *partial)
@ -214,7 +201,6 @@ Cvar_CompleteCountPossible (const char *partial)
Added by EvilTypeGuy Added by EvilTypeGuy
Thanks to Fett erich@heintz.com Thanks to Fett erich@heintz.com
Thanks to taniwha Thanks to taniwha
*/ */
const char ** const char **
Cvar_CompleteBuildList (const char *partial) Cvar_CompleteBuildList (const char *partial)
@ -222,7 +208,8 @@ Cvar_CompleteBuildList (const char *partial)
cvar_t *cvar; cvar_t *cvar;
int len = 0; int len = 0;
int bpos = 0; int bpos = 0;
int sizeofbuf = (Cvar_CompleteCountPossible (partial) + 1) * sizeof (char *); int sizeofbuf = (Cvar_CompleteCountPossible (partial) + 1) *
sizeof (char *);
const char **buf; const char **buf;
len = strlen(partial); len = strlen(partial);
@ -236,9 +223,6 @@ Cvar_CompleteBuildList (const char *partial)
return buf; return buf;
} }
/*
Cvar_Set
*/
void void
Cvar_Set (cvar_t *var, const char *value) Cvar_Set (cvar_t *var, const char *value)
{ {
@ -264,7 +248,6 @@ Cvar_Set (cvar_t *var, const char *value)
var->callback (var); var->callback (var);
} }
/* /*
Cvar_SetROM Cvar_SetROM
@ -290,9 +273,6 @@ Cvar_SetROM (cvar_t *var, const char *value)
var->callback (var); var->callback (var);
} }
/*
Cvar_SetValue
*/
// 1999-09-07 weird cvar zeros fix by Maddes // 1999-09-07 weird cvar zeros fix by Maddes
void void
Cvar_SetValue (cvar_t *var, float value) Cvar_SetValue (cvar_t *var, float value)
@ -301,7 +281,8 @@ Cvar_SetValue (cvar_t *var, float value)
int i; int i;
snprintf (val, sizeof (val), "%f", value); snprintf (val, sizeof (val), "%f", value);
for (i = strlen (val) - 1; i > 0 && val[i] == '0' && val[i - 1] != '.'; i--) { for (i = strlen (val) - 1; i > 0 && val[i] == '0' && val[i - 1] != '.';
i--) {
val[i] = 0; val[i] = 0;
} }
Cvar_Set (var, val); Cvar_Set (var, val);
@ -324,7 +305,7 @@ Cvar_Command (void)
if (!v) if (!v)
return false; return false;
// perform a variable print or set // perform a variable print or set
if (Cmd_Argc () == 1) { if (Cmd_Argc () == 1) {
Con_Printf ("\"%s\" is \"%s\"\n", v->name, v->string); Con_Printf ("\"%s\" is \"%s\"\n", v->name, v->string);
return true; return true;
@ -334,7 +315,6 @@ Cvar_Command (void)
return true; return true;
} }
/* /*
Cvar_WriteVariables Cvar_WriteVariables
@ -371,7 +351,8 @@ Cvar_Set_f (void)
if (var) { if (var) {
if (var->flags & CVAR_ROM) { if (var->flags & CVAR_ROM) {
Con_DPrintf ("Cvar \"%s\" is read-only, cannot modify\n", var_name); Con_DPrintf ("Cvar \"%s\" is read-only, cannot modify\n",
var_name);
} else { } else {
Cvar_Set (var, value); Cvar_Set (var, value);
} }
@ -401,7 +382,8 @@ Cvar_Setrom_f (void)
if (var) { if (var) {
if (var->flags & CVAR_ROM) { if (var->flags & CVAR_ROM) {
Con_DPrintf ("Cvar \"%s\" is read-only, cannot modify\n", var_name); Con_DPrintf ("Cvar \"%s\" is read-only, cannot modify\n",
var_name);
} else { } else {
Cvar_Set (var, value); Cvar_Set (var, value);
Cvar_SetFlags (var, var->flags | CVAR_ROM); Cvar_SetFlags (var, var->flags | CVAR_ROM);
@ -501,9 +483,11 @@ Cvar_Init (void)
developer = Cvar_Get ("developer", "0", CVAR_NONE, NULL, developer = Cvar_Get ("developer", "0", CVAR_NONE, NULL,
"set to enable extra debugging information"); "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 ("set", Cvar_Set_f, "Set the selected variable, useful on "
Cmd_AddCommand ("setrom", Cvar_Setrom_f, "Set the selected variable and make it read only, useful on the command line.\n" "the command line (+set variablename setting)");
"(+setrom 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 ("toggle", Cvar_Toggle_f, "Toggle a cvar on or off");
Cmd_AddCommand ("cvarlist", Cvar_CvarList_f, "List all cvars"); Cmd_AddCommand ("cvarlist", Cvar_CvarList_f, "List all cvars");
} }
@ -533,7 +517,6 @@ Cvar_Shutdown (void)
} }
} }
cvar_t * cvar_t *
Cvar_Get (const char *name, const char *string, int cvarflags, Cvar_Get (const char *name, const char *string, int cvarflags,
void (*callback)(cvar_t*), const char *description) void (*callback)(cvar_t*), const char *description)

View file

@ -13,14 +13,13 @@
* *
*/ */
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <io.h>
#include <direct.h> #include <direct.h>
#include <sys/stat.h>
#include <dirent.h> #include <dirent.h>
#include <errno.h>
#include <io.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#define SUFFIX "*" #define SUFFIX "*"
#define SLASH "\\" #define SLASH "\\"
@ -29,12 +28,13 @@
#define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR) /* is a directory */ #define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR) /* is a directory */
#endif S_ISDIR #endif S_ISDIR
/* /*
* opendir opendir
*
* Returns a pointer to a DIR structure appropriately filled in to begin Returns a pointer to a DIR structure appropriately filled in to begin
* searching a directory. searching a directory.
*/ */
DIR * DIR *
opendir (const char *szPath) opendir (const char *szPath)
{ {
@ -107,13 +107,12 @@ opendir (const char *szPath)
return nd; return nd;
} }
/* /*
* readdir readdir
*
* Return a pointer to a dirent structure filled with the information on the Return a pointer to a dirent structure filled with the information on the
* next entry in the directory. next entry in the directory.
*/ */
struct dirent * struct dirent *
readdir (DIR * dirp) readdir (DIR * dirp)
{ {
@ -169,12 +168,11 @@ readdir (DIR * dirp)
return (struct dirent *) 0; return (struct dirent *) 0;
} }
/* /*
* closedir closedir
*
* Frees up resources allocated by opendir. Frees up resources allocated by opendir.
*/ */
int int
closedir (DIR * dirp) closedir (DIR * dirp)
{ {
@ -199,11 +197,11 @@ closedir (DIR * dirp)
} }
/* /*
* rewinddir rewinddir
*
* Return to the beginning of the directory "stream". We simply call findclose Return to the beginning of the directory "stream". We simply call findclose
* and then reset things like an opendir. and then reset things like an opendir.
*/ */
void void
rewinddir (DIR * dirp) rewinddir (DIR * dirp)
{ {
@ -223,11 +221,11 @@ rewinddir (DIR * dirp)
} }
/* /*
* telldir telldir
*
* Returns the "position" in the "directory stream" which can be used with Returns the "position" in the "directory stream" which can be used with
* seekdir to go back to an old entry. We simply return the value in stat. seekdir to go back to an old entry. We simply return the value in stat.
*/ */
long long
telldir (DIR * dirp) telldir (DIR * dirp)
{ {
@ -241,14 +239,14 @@ telldir (DIR * dirp)
} }
/* /*
* seekdir seekdir
*
* Seek to an entry previously returned by telldir. We rewind the directory Seek to an entry previously returned by telldir. We rewind the directory
* and call readdir repeatedly until either dd_stat is the position number and call readdir repeatedly until either dd_stat is the position number
* or -1 (off the end). This is not perfect, in that the directory may or -1 (off the end). This is not perfect, in that the directory may
* have changed while we weren't looking. But that is probably the case with have changed while we weren't looking. But that is probably the case with
* any such system. any such system.
*/ */
void void
seekdir (DIR * dirp, long lPos) seekdir (DIR * dirp, long lPos)
{ {

View file

@ -32,6 +32,7 @@
#include "QF/qendian.h" #include "QF/qendian.h"
#include "QF/vfile.h" #include "QF/vfile.h"
void void
WriteFloat (VFile *file, float f) WriteFloat (VFile *file, float f)
{ {

View file

@ -34,23 +34,22 @@
# define _GNU_SOURCE # define _GNU_SOURCE
#endif #endif
#include <errno.h>
#include <ctype.h> #include <ctype.h>
#include <errno.h>
#include "fnmatch.h" #include "fnmatch.h"
/* Comment out all this code if we are using the GNU C Library, and are not /* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C actually compiling the library itself. This code is part of the GNU C
Library, but also included in many other GNU distributions. Compiling Library, but also included in many other GNU distributions. Compiling
and linking in this code is a waste when using the GNU C library and linking in this code is a waste when using the GNU C library
(especially if it is a shared library). Rather than having every GNU (especially if it is a shared library). Rather than having every GNU
program understand `configure --with-gnu-libc' and omit the object files, program understand `configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */ it is simpler to just do this in the source for each such file.
*/
#if defined (_LIBC) || !defined (__GNU_LIBRARY__) #if defined (_LIBC) || !defined (__GNU_LIBRARY__)
#if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS) #if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS)
extern int errno; extern int errno;
#endif #endif

View file

@ -1,7 +1,7 @@
/* /*
info.c info.c
(description) Info strings.
Copyright (C) 1996-1997 Id Software, Inc. Copyright (C) 1996-1997 Id Software, Inc.
@ -39,13 +39,11 @@
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#include "compat.h"
#include "QF/console.h" #include "QF/console.h"
#include "QF/info.h" #include "QF/info.h"
/* #include "compat.h"
INFO STRINGS
*/
/* /*
Info_ValueForKey Info_ValueForKey
@ -180,7 +178,6 @@ Info_RemovePrefixedKeys (char *start, char prefix)
} }
void void
Info_SetValueForStarKey (char *s, const char *key, const char *value, size_t maxsize, int flags) Info_SetValueForStarKey (char *s, const char *key, const char *value, size_t maxsize, int flags)
{ {
@ -243,7 +240,8 @@ Info_SetValueForStarKey (char *s, const char *key, const char *value, size_t max
} }
void void
Info_SetValueForKey (char *s, const char *key, const char *value, size_t maxsize, int flags) Info_SetValueForKey (char *s, const char *key, const char *value,
size_t maxsize, int flags)
{ {
if (key[0] == '*') { if (key[0] == '*') {
Con_Printf ("Can't set * keys\n"); Con_Printf ("Can't set * keys\n");

View file

@ -32,6 +32,7 @@
#include "QF/link.h" #include "QF/link.h"
// ClearLink is used for new headnodes // ClearLink is used for new headnodes
void void
ClearLink (link_t *l) ClearLink (link_t *l)

View file

@ -72,9 +72,7 @@ ProjectPointOnPlane (vec3_t dst, const vec3_t p, const vec3_t normal)
dst[2] = p[2] - d * n[2]; dst[2] = p[2] - d * n[2];
} }
/* // assumes "src" is normalized
** assumes "src" is normalized
*/
void void
PerpendicularVector (vec3_t dst, const vec3_t src) PerpendicularVector (vec3_t dst, const vec3_t src)
{ {
@ -83,8 +81,7 @@ PerpendicularVector (vec3_t dst, const vec3_t src)
float minelem = 1.0F; float minelem = 1.0F;
vec3_t tempvec; vec3_t tempvec;
/* /* find the smallest magnitude axially aligned vector */
** find the smallest magnitude axially aligned vector */
for (pos = 0, i = 0; i < 3; i++) { for (pos = 0, i = 0; i < 3; i++) {
if (fabs (src[i]) < minelem) { if (fabs (src[i]) < minelem) {
pos = i; pos = i;
@ -94,17 +91,15 @@ PerpendicularVector (vec3_t dst, const vec3_t src)
tempvec[0] = tempvec[1] = tempvec[2] = 0.0F; tempvec[0] = tempvec[1] = tempvec[2] = 0.0F;
tempvec[pos] = 1.0F; tempvec[pos] = 1.0F;
/* /* project the point onto the plane defined by src */
** project the point onto the plane defined by src */
ProjectPointOnPlane (dst, tempvec, src); ProjectPointOnPlane (dst, tempvec, src);
/* /* normalize the result */
** normalize the result */
VectorNormalize (dst); VectorNormalize (dst);
} }
#if defined(_WIN32) && !defined(__GNUC__) #if defined(_WIN32) && !defined(__GNUC__)
#pragma optimize( "", off ) # pragma optimize( "", off )
#endif #endif
void VectorVectors(const vec3_t forward, vec3_t right, vec3_t up) void VectorVectors(const vec3_t forward, vec3_t right, vec3_t up)
@ -181,7 +176,7 @@ RotatePointAroundVector (vec3_t dst, const vec3_t dir, const vec3_t point,
} }
#if defined(_WIN32) && !defined(__GNUC__) #if defined(_WIN32) && !defined(__GNUC__)
#pragma optimize( "", on ) # pragma optimize( "", on )
#endif #endif
/*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/
@ -223,10 +218,11 @@ BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, mplane_t *p)
float dist1, dist2; float dist1, dist2;
int sides; int sides;
#if 0 // this is done by the BOX_ON_PLANE_SIDE macro before #if 0
// calling this function // this is done by the BOX_ON_PLANE_SIDE macro before
// calling this function
// fast axial cases // fast axial cases
if (p->type < 3) { if (p->type < 3) {
if (p->dist <= emins[p->type]) if (p->dist <= emins[p->type])
return 1; return 1;
@ -236,7 +232,7 @@ BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, mplane_t *p)
} }
#endif #endif
// general case // general case
switch (p->signbits) { switch (p->signbits) {
case 0: case 0:
dist1 = dist1 =
@ -328,7 +324,6 @@ BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, mplane_t *p)
sides = 1; sides = 1;
if (dist2 < 0) if (dist2 < 0)
sides |= 2; sides |= 2;
#endif #endif
sides = 0; sides = 0;
@ -344,10 +339,8 @@ BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, mplane_t *p)
return sides; return sides;
} }
#endif #endif
void void
AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up) AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
{ {
@ -395,7 +388,6 @@ _VectorMA (vec3_t veca, float scale, vec3_t vecb, vec3_t vecc)
vecc[2] = veca[2] + scale * vecb[2]; vecc[2] = veca[2] + scale * vecb[2];
} }
vec_t vec_t
_DotProduct (vec3_t v1, vec3_t v2) _DotProduct (vec3_t v1, vec3_t v2)
{ {
@ -485,7 +477,6 @@ VectorScale (vec3_t in, vec_t scale, vec3_t out)
out[2] = in[2] * scale; out[2] = in[2] * scale;
} }
int int
Q_log2 (int val) Q_log2 (int val)
{ {
@ -496,10 +487,6 @@ Q_log2 (int val)
return answer; return answer;
} }
/*
R_ConcatRotations
*/
void void
R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]) R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3])
{ {
@ -523,10 +510,6 @@ R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3])
in1[2][2] * in2[2][2]; in1[2][2] * in2[2][2];
} }
/*
R_ConcatTransforms
*/
void void
R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]) R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4])
{ {
@ -556,7 +539,6 @@ R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4])
in1[2][2] * in2[2][3] + in1[2][3]; in1[2][2] * in2[2][3] + in1[2][3];
} }
/* /*
FloorDivMod FloorDivMod
@ -564,7 +546,6 @@ R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4])
numer and denom, both of which should contain no fractional part. The numer and denom, both of which should contain no fractional part. The
quotient must fit in 32 bits. quotient must fit in 32 bits.
*/ */
void void
FloorDivMod (double numer, double denom, int *quotient, int *rem) FloorDivMod (double numer, double denom, int *quotient, int *rem)
{ {
@ -575,9 +556,9 @@ FloorDivMod (double numer, double denom, int *quotient, int *rem)
if (denom <= 0.0) if (denom <= 0.0)
Sys_Error ("FloorDivMod: bad denominator %f\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",
// numer, denom); // numer, denom);
#endif #endif
if (numer >= 0.0) { if (numer >= 0.0) {
@ -586,10 +567,8 @@ FloorDivMod (double numer, double denom, int *quotient, int *rem)
q = (int) x; q = (int) x;
r = (int) floor (numer - (x * denom)); r = (int) floor (numer - (x * denom));
} else { } else {
//
// perform operations with positive values, and fix mod to make // perform operations with positive values, and fix mod to make
// floor-based // floor-based
//
x = floor (-numer / denom); x = floor (-numer / denom);
q = -(int) x; q = -(int) x;
r = (int) floor (-numer - (x * denom)); r = (int) floor (-numer - (x * denom));
@ -603,10 +582,6 @@ FloorDivMod (double numer, double denom, int *quotient, int *rem)
*rem = r; *rem = r;
} }
/*
GreatestCommonDivisor
*/
int int
GreatestCommonDivisor (int i1, int i2) GreatestCommonDivisor (int i1, int i2)
{ {
@ -621,17 +596,13 @@ GreatestCommonDivisor (int i1, int i2)
} }
} }
#ifndef USE_INTEL_ASM #ifndef USE_INTEL_ASM
// TODO: move to nonintel.c
/* /*
Invert24To16 Invert24To16
Inverts an 8.24 value to a 16.16 value Inverts an 8.24 value to a 16.16 value
TODO: move to nonintel.c
*/ */
fixed16_t fixed16_t
Invert24To16 (fixed16_t val) Invert24To16 (fixed16_t val)
{ {
@ -641,5 +612,4 @@ Invert24To16 (fixed16_t val)
return (fixed16_t) return (fixed16_t)
(((double) 0x10000 * (double) 0x1000000 / (double) val) + 0.5); (((double) 0x10000 * (double) 0x1000000 / (double) val) + 0.5);
} }
#endif #endif

View file

@ -41,7 +41,6 @@
#include "QF/uint32.h" #include "QF/uint32.h"
/* NOTE: This code makes no attempt to be fast! /* NOTE: This code makes no attempt to be fast!
It assumes that a int is at least 32 bits long It assumes that a int is at least 32 bits long
*/ */
@ -61,6 +60,7 @@ static struct mdfour *m;
#define ROUND2(a,b,c,d,k,s) a = lshift(a + G(b,c,d) + X[k] + 0x5A827999,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) #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 */ /* this applies md4 to 64 byte chunks */
static void static void
mdfour64 (uint32 * M) mdfour64 (uint32 * M)
@ -183,7 +183,6 @@ mdfour_begin (struct mdfour *md)
md->totalN = 0; md->totalN = 0;
} }
static void static void
mdfour_tail (const unsigned char *in, int n) mdfour_tail (const unsigned char *in, int n)
{ {
@ -234,7 +233,6 @@ mdfour_update (struct mdfour *md, const unsigned char *in, int n)
mdfour_tail (in, n); mdfour_tail (in, n);
} }
void void
mdfour_result (struct mdfour *md, unsigned char *out) mdfour_result (struct mdfour *md, unsigned char *out)
{ {
@ -246,7 +244,6 @@ mdfour_result (struct mdfour *md, unsigned char *out)
copy4 (out + 12, m->D); copy4 (out + 12, m->D);
} }
void void
mdfour (unsigned char *out, const unsigned char *in, int n) mdfour (unsigned char *out, const unsigned char *in, int n)
{ {

View file

@ -40,15 +40,14 @@
#include "QF/qendian.h" #include "QF/qendian.h"
#include "QF/sys.h" #include "QF/sys.h"
/* /*
MESSAGE IO FUNCTIONS MESSAGE IO FUNCTIONS
Handles byte ordering and avoids alignment errors Handles byte ordering and avoids alignment errors
*/ */
//
// writing functions // writing functions
//
void void
MSG_WriteChar (sizebuf_t *sb, int c) MSG_WriteChar (sizebuf_t *sb, int c)
@ -113,7 +112,6 @@ MSG_WriteFloat (sizebuf_t *sb, float f)
int l; int l;
} dat; } dat;
dat.f = f; dat.f = f;
dat.l = LittleLong (dat.l); dat.l = LittleLong (dat.l);
@ -148,9 +146,7 @@ MSG_WriteAngle16 (sizebuf_t *sb, float f)
} }
//
// reading functions // reading functions
//
void void
MSG_BeginReading (msg_t *msg) MSG_BeginReading (msg_t *msg)

View file

@ -46,6 +46,7 @@
#include "compat.h" #include "compat.h"
tex_t * tex_t *
LoadPCX (VFile *f, int convert, byte *pal) LoadPCX (VFile *f, int convert, byte *pal)
{ {
@ -59,9 +60,7 @@ LoadPCX (VFile *f, int convert, byte *pal)
int count; int count;
tex_t *tex; tex_t *tex;
//
// parse the PCX file // parse the PCX file
//
pcx_mark = Hunk_LowMark (); pcx_mark = Hunk_LowMark ();
pcx = Hunk_AllocName (com_filesize, "PCX"); pcx = Hunk_AllocName (com_filesize, "PCX");
Qread (f, pcx, com_filesize); Qread (f, pcx, com_filesize);
@ -145,7 +144,6 @@ LoadPCX (VFile *f, int convert, byte *pal)
return tex; return tex;
} }
pcx_t * pcx_t *
EncodePCX (byte * data, int width, int height, EncodePCX (byte * data, int width, int height,
int rowbytes, byte * palette, qboolean flip, int *length) int rowbytes, byte * palette, qboolean flip, int *length)

View file

@ -29,19 +29,15 @@
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif
#ifdef HAVE_STDIO_H #ifdef HAVE_STDIO_H
# include <stdio.h> # include <stdio.h>
#endif #endif
#ifdef HAVE_STRING_H #ifdef HAVE_STRING_H
# include <string.h> # include <string.h>
#endif #endif
#ifdef HAVE_STRINGS_H #ifdef HAVE_STRINGS_H
# include <strings.h> # include <strings.h>
#endif #endif
#ifdef HAVE_WINDOWS_H #ifdef HAVE_WINDOWS_H
# include <windows.h> # include <windows.h>
#endif #endif
@ -65,6 +61,7 @@
cvar_t *fs_pluginpath; cvar_t *fs_pluginpath;
void void
PI_InitCvars (void) PI_InitCvars (void)
{ {
@ -117,7 +114,8 @@ PI_LoadPlugin (const char *type, const char *name)
#if defined(HAVE_DLOPEN) #if defined(HAVE_DLOPEN)
if (!(dlhand = dlopen (realname, RTLD_LAZY))) { // lib not found if (!(dlhand = dlopen (realname, RTLD_LAZY))) { // lib not found
Con_Printf ("Could not load plugin \"%s\": %s\n", realname, dlerror ()); Con_Printf ("Could not load plugin \"%s\": %s\n", realname,
dlerror ());
return NULL; return NULL;
} }
#elif defined (_WIN32) #elif defined (_WIN32)
@ -128,13 +126,16 @@ PI_LoadPlugin (const char *type, const char *name)
#endif #endif
#if defined(HAVE_DLOPEN) #if defined(HAVE_DLOPEN)
if (!(plugin_info = dlsym (dlhand, "PluginInfo"))) { // info function not found if (!(plugin_info = dlsym (dlhand, "PluginInfo"))) {
// info function not found
dlclose (dlhand); dlclose (dlhand);
Con_Printf ("Plugin info function not found\n"); Con_Printf ("Plugin info function not found\n");
return NULL; return NULL;
} }
#elif defined (_WIN32) #elif defined (_WIN32)
if (!(plugin_info = (P_PluginInfo) GetProcAddress (dlhand, "PluginInfo"))) { // info function not found if (!(plugin_info = (P_PluginInfo) GetProcAddress (dlhand,
"PluginInfo"))) {
// info function not found
FreeLibrary (dlhand); FreeLibrary (dlhand);
Con_Printf ("Plugin info function not found\n"); Con_Printf ("Plugin info function not found\n");
return NULL; return NULL;

View file

@ -63,6 +63,7 @@ char *com_cmdline;
qboolean nouse = false; // 1999-10-29 +USE fix by Maddes qboolean nouse = false; // 1999-10-29 +USE fix by Maddes
/* /*
COM_CheckParm COM_CheckParm
@ -85,9 +86,6 @@ COM_CheckParm (char *parm)
return 0; return 0;
} }
/*
COM_InitArgv
*/
void void
COM_InitArgv (int argc, char **argv) COM_InitArgv (int argc, char **argv)
{ {
@ -96,9 +94,8 @@ COM_InitArgv (int argc, char **argv)
safe = false; safe = false;
largv = largv = (char **) calloc (1, (argc + NUM_SAFE_ARGVS + 1) *
sizeof (char **));
(char **) calloc (1, (argc + NUM_SAFE_ARGVS + 1) * sizeof (char **));
for (com_argc = 0, len = 0; com_argc < argc; com_argc++) { for (com_argc = 0, len = 0; com_argc < argc; com_argc++) {
largv[com_argc] = argv[com_argc]; largv[com_argc] = argv[com_argc];
@ -120,9 +117,8 @@ COM_InitArgv (int argc, char **argv)
} }
if (safe) { if (safe) {
// force all the safe-mode switches. Note that we reserved extra // force all the safe-mode switches. Note that we reserved extra space
// space in // in case we need to add these, so we don't need an overflow check
// case we need to add these, so we don't need an overflow check
for (i = 0; i < NUM_SAFE_ARGVS; i++) { for (i = 0; i < NUM_SAFE_ARGVS; i++) {
largv[com_argc] = safeargvs[i]; largv[com_argc] = safeargvs[i];
com_argc++; com_argc++;
@ -132,11 +128,9 @@ COM_InitArgv (int argc, char **argv)
largv[com_argc] = argvdummy; largv[com_argc] = argvdummy;
com_argv = largv; com_argv = largv;
// 1999-10-29 +USE fix by Maddes start
if (COM_CheckParm ("-nouse")) { if (COM_CheckParm ("-nouse")) {
nouse = true; nouse = true;
} }
// 1999-10-29 +USE fix by Maddes end
} }
/* /*

View file

@ -60,6 +60,7 @@ float (*BigFloat) (float l) = FloatNoSwap;
float (*LittleFloat) (float l) = FloatSwap; float (*LittleFloat) (float l) = FloatSwap;
#endif #endif
short short
ShortSwap (short l) ShortSwap (short l)
{ {
@ -104,7 +105,6 @@ FloatSwap (float f)
byte b[4]; byte b[4];
} dat1 , dat2; } dat1 , dat2;
dat1.f = f; dat1.f = f;
dat2.b[0] = dat1.b[3]; dat2.b[0] = dat1.b[3];
dat2.b[1] = dat1.b[2]; dat2.b[1] = dat1.b[2];

View file

@ -44,6 +44,7 @@ static qboolean PL_SkipSpace (pldata_t *);
static char *PL_ParseQuotedString (pldata_t *); static char *PL_ParseQuotedString (pldata_t *);
static char *PL_ParseUnquotedString (pldata_t *); static char *PL_ParseUnquotedString (pldata_t *);
void void
PL_FreeItem (plitem_t *item) PL_FreeItem (plitem_t *item)
{ {
@ -213,7 +214,6 @@ PL_ParseQuotedString (pldata_t *pl)
if (pl->pos - start - shrink == 0) { if (pl->pos - start - shrink == 0) {
str = ""; str = "";
} else { } else {
char chars[pl->pos - start - shrink]; char chars[pl->pos - start - shrink];
unsigned int j; unsigned int j;
unsigned int k; unsigned int k;
@ -286,7 +286,8 @@ PL_ParseQuotedString (pldata_t *pl)
} }
} }
} }
str = strncat (calloc ((pl->pos - start - shrink) + 1, 1), chars, pl->pos - start - shrink); str = strncat (calloc ((pl->pos - start - shrink) + 1, 1), chars,
pl->pos - start - shrink);
} }
pl->pos++; pl->pos++;
return str; return str;
@ -303,7 +304,8 @@ PL_ParseUnquotedString (pldata_t *pl)
break; break;
pl->pos++; pl->pos++;
} }
str = strncat (calloc ((pl->pos - start) + 1, 1), &pl->ptr[start], pl->pos - start); str = strncat (calloc ((pl->pos - start) + 1, 1), &pl->ptr[start],
pl->pos - start);
return str; return str;
} }
@ -316,154 +318,155 @@ PL_ParsePropertyListItem (pldata_t *pl)
return NULL; return NULL;
switch (pl->ptr[pl->pos]) { switch (pl->ptr[pl->pos]) {
case '{': { case '{':
hashtab_t *dict = Hash_NewTable (1021, dict_get_key, dict_free, NULL); {
hashtab_t *dict = Hash_NewTable (1021, dict_get_key, dict_free, NULL);
pl->pos++;
while (PL_SkipSpace (pl) && pl->ptr[pl->pos] != '}') {
plitem_t *key;
plitem_t *value;
if (!(key = PL_ParsePropertyListItem (pl)))
return NULL;
if (!(PL_SkipSpace (pl))) {
PL_FreeItem (key);
return NULL;
}
if (key->type != QFString) {
pl->error = "Key is not a string";
PL_FreeItem (key);
return NULL;
}
if (pl->ptr[pl->pos] != '=') {
pl->error = "Unexpected character (expected '=')";
PL_FreeItem (key);
return NULL;
}
pl->pos++; pl->pos++;
while (PL_SkipSpace (pl) && pl->ptr[pl->pos] != '}') { // If there is no value, lose the key
plitem_t *key; if (!(value = PL_ParsePropertyListItem (pl))) {
plitem_t *value; PL_FreeItem (key);
return NULL;
}
if (!(key = PL_ParsePropertyListItem (pl))) if (!(PL_SkipSpace (pl))) {
return NULL; PL_FreeItem (key);
PL_FreeItem (value);
return NULL;
}
if (!(PL_SkipSpace (pl))) { if (pl->ptr[pl->pos] == ';') {
PL_FreeItem (key);
return NULL;
}
if (key->type != QFString) {
pl->error = "Key is not a string";
PL_FreeItem (key);
return NULL;
}
if (pl->ptr[pl->pos] != '=') {
pl->error = "Unexpected character (expected '=')";
PL_FreeItem (key);
return NULL;
}
pl->pos++; pl->pos++;
} else if (pl->ptr[pl->pos] != '}') {
// If there is no value, lose the key pl->error = "Unexpected character (wanted ';' or '}')";
if (!(value = PL_ParsePropertyListItem (pl))) { PL_FreeItem (key);
PL_FreeItem (key); PL_FreeItem (value);
return NULL;
}
if (!(PL_SkipSpace (pl))) {
PL_FreeItem (key);
PL_FreeItem (value);
return NULL;
}
if (pl->ptr[pl->pos] == ';') {
pl->pos++;
} else if (pl->ptr[pl->pos] != '}') {
pl->error = "Unexpected character (wanted ';' or '}')";
PL_FreeItem (key);
PL_FreeItem (value);
return NULL;
}
{ // Add the key/value pair to the dictionary
dictkey_t *k = calloc (1, sizeof (dictkey_t));
if (!k) {
PL_FreeItem (key);
PL_FreeItem (value);
return NULL;
}
k->key = (char *) key->data;
k->value = value;
Hash_Add (dict, k);
}
}
if (pl->pos >= pl->end) { // Catch the error
pl->error = "Unexpected end of string when parsing dictionary";
Hash_DelTable (dict);
return NULL; return NULL;
} }
pl->pos++;
item = calloc (1, sizeof (plitem_t)); { // Add the key/value pair to the dictionary
item->type = QFDictionary; dictkey_t *k = calloc (1, sizeof (dictkey_t));
item->data = dict;
return item;
}
case '(': { if (!k) {
plarray_t *a = calloc (1, sizeof (plarray_t)); PL_FreeItem (key);
PL_FreeItem (value);
pl->pos++;
while (PL_SkipSpace (pl) && pl->ptr[pl->pos] != ')') {
plitem_t *value;
if (!(value = PL_ParsePropertyListItem (pl)))
return NULL;
if (!(PL_SkipSpace (pl))) {
free (value);
return NULL; return NULL;
} }
if (pl->ptr[pl->pos] == ',') { k->key = (char *) key->data;
pl->pos++; k->value = value;
} else if (pl->ptr[pl->pos] != ')') {
pl->error = "Unexpected character (wanted ',' or ')')";
free (value);
return NULL;
}
if (a->numvals == MAX_ARRAY_INDEX) { Hash_Add (dict, k);
pl->error = "Unexpected character (too many items in array)";
free (value);
return NULL;
}
a->values[a->numvals++] = value;
} }
pl->pos++;
item = calloc (1, sizeof (plitem_t));
item->type = QFArray;
item->data = a;
return item;
} }
case '<': if (pl->pos >= pl->end) { // Catch the error
pl->error = "Unexpected character in string (binary data unsupported)"; pl->error = "Unexpected end of string when parsing dictionary";
Hash_DelTable (dict);
return NULL; return NULL;
case '"': {
char *str = PL_ParseQuotedString (pl);
if (!str) {
return NULL;
} else {
item = calloc (1, sizeof (plitem_t));
item->type = QFString;
item->data = str;
return item;
}
} }
pl->pos++;
default: { item = calloc (1, sizeof (plitem_t));
char *str = PL_ParseUnquotedString (pl); item->type = QFDictionary;
item->data = dict;
return item;
}
if (!str) { case '(': {
plarray_t *a = calloc (1, sizeof (plarray_t));
pl->pos++;
while (PL_SkipSpace (pl) && pl->ptr[pl->pos] != ')') {
plitem_t *value;
if (!(value = PL_ParsePropertyListItem (pl)))
return NULL;
if (!(PL_SkipSpace (pl))) {
free (value);
return NULL; return NULL;
} else {
item = calloc (1, sizeof (plitem_t));
item->type = QFString;
item->data = str;
return item;
} }
if (pl->ptr[pl->pos] == ',') {
pl->pos++;
} else if (pl->ptr[pl->pos] != ')') {
pl->error = "Unexpected character (wanted ',' or ')')";
free (value);
return NULL;
}
if (a->numvals == MAX_ARRAY_INDEX) {
pl->error = "Unexpected character (too many items in array)";
free (value);
return NULL;
}
a->values[a->numvals++] = value;
} }
pl->pos++;
item = calloc (1, sizeof (plitem_t));
item->type = QFArray;
item->data = a;
return item;
}
case '<':
pl->error = "Unexpected character in string (binary data unsupported)";
return NULL;
case '"': {
char *str = PL_ParseQuotedString (pl);
if (!str) {
return NULL;
} else {
item = calloc (1, sizeof (plitem_t));
item->type = QFString;
item->data = str;
return item;
}
}
default: {
char *str = PL_ParseUnquotedString (pl);
if (!str) {
return NULL;
} else {
item = calloc (1, sizeof (plitem_t));
item->type = QFString;
item->data = str;
return item;
}
}
} // switch } // switch
} }

View file

@ -39,11 +39,11 @@
# include <unistd.h> # include <unistd.h>
#endif #endif
#include <ctype.h>
#include <dirent.h>
#include <fcntl.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include <ctype.h>
#include <fcntl.h>
#include <dirent.h>
#ifdef HAVE_FNMATCH_H #ifdef HAVE_FNMATCH_H
# define model_t sunmodel_t # define model_t sunmodel_t
@ -62,7 +62,6 @@
#include <limits.h> #include <limits.h>
#include "QF/cmd.h" #include "QF/cmd.h"
#include "compat.h"
#include "QF/console.h" #include "QF/console.h"
#include "QF/cvar.h" #include "QF/cvar.h"
#include "QF/hash.h" #include "QF/hash.h"
@ -70,16 +69,17 @@
#include "QF/qargs.h" #include "QF/qargs.h"
#include "QF/qendian.h" #include "QF/qendian.h"
#include "QF/qtypes.h" #include "QF/qtypes.h"
#include "QF/vfs.h"
#include "QF/sys.h" #include "QF/sys.h"
#include "QF/va.h" #include "QF/va.h"
#include "QF/vfs.h"
#include "QF/zone.h" #include "QF/zone.h"
#include "compat.h"
#ifndef HAVE_FNMATCH_PROTO #ifndef HAVE_FNMATCH_PROTO
int fnmatch (const char *__pattern, const char *__string, int __flags); int fnmatch (const char *__pattern, const char *__string, int __flags);
#endif #endif
/* /*
All of Quake's data access is through a hierchical file system, but the All of Quake's data access is through a hierchical file system, but the
contents of the file system can be transparently merged from several contents of the file system can be transparently merged from several
@ -161,9 +161,7 @@ typedef struct searchpath_s {
searchpath_t *com_searchpaths; searchpath_t *com_searchpaths;
searchpath_t *com_base_searchpaths; // without gamedirs searchpath_t *com_base_searchpaths; // without gamedirs
/*
COM_FileBase
*/
void void
COM_FileBase (const char *in, char *out) COM_FileBase (const char *in, char *out)
{ {
@ -191,9 +189,7 @@ COM_FileBase (const char *in, char *out)
} }
} }
/*
COM_filelength
*/
int int
COM_filelength (VFile *f) COM_filelength (VFile *f)
{ {
@ -208,9 +204,7 @@ COM_filelength (VFile *f)
return end; return end;
} }
/*
COM_FileOpenRead
*/
int int
COM_FileOpenRead (char *path, VFile **hndl) COM_FileOpenRead (char *path, VFile **hndl)
{ {
@ -226,9 +220,7 @@ COM_FileOpenRead (char *path, VFile **hndl)
return COM_filelength (f); return COM_filelength (f);
} }
/*
COM_Path_f
*/
void void
COM_Path_f (void) COM_Path_f (void)
{ {
@ -246,12 +238,6 @@ COM_Path_f (void)
} }
} }
/*
COM_Maplist_f
List map files in gamepaths.
*/
struct maplist { struct maplist {
char **list; char **list;
int count; int count;
@ -329,6 +315,11 @@ maplist_print (struct maplist *maplist)
} }
} }
/*
COM_Maplist_f
List map files in gamepaths.
*/
void void
COM_Maplist_f (void) COM_Maplist_f (void)
{ {
@ -433,7 +424,6 @@ COM_WriteBuffers (const char *filename, int count, ...)
va_end (args); va_end (args);
} }
/* /*
COM_CreatePath COM_CreatePath
@ -456,7 +446,6 @@ COM_CreatePath (const char *path)
} }
} }
/* /*
COM_CopyFile COM_CopyFile
@ -492,9 +481,6 @@ COM_CopyFile (char *netpath, char *cachepath)
Qclose (out); Qclose (out);
} }
/*
COM_OpenRead
*/
VFile * VFile *
COM_OpenRead (const char *path, int offs, int len, int zip) COM_OpenRead (const char *path, int offs, int len, int zip)
{ {
@ -552,12 +538,14 @@ contains_updir (const char *filename)
// FIXME: maybe I should handle alternate seperators? // FIXME: maybe I should handle alternate seperators?
for (i = 0; filename[i+1]; i++) { for (i = 0; filename[i+1]; i++) {
if (!(i == 0 || filename[i-1] == '/') // beginning of string or first slash if (!(i == 0 || filename[i-1] == '/') // beginning of string
// or first slash
|| filename[i] != '.' // first dot || filename[i] != '.' // first dot
|| filename[i+1] != '.') // second dot || filename[i+1] != '.') // second dot
continue; continue;
if (filename[i+2] == 0 || filename[i+2] == '/') // end of string or second slash if (filename[i+2] == 0 || filename[i+2] == '/')
// end of string or second slash
return 1; return 1;
} }
return 0; return 0;
@ -589,15 +577,13 @@ _COM_FOpenFile (const char *filename, VFile **gzfile, char *foundname, int zip)
file_from_pak = 0; file_from_pak = 0;
// make sure they're not trying to do wierd stuff with our private files // make sure they're not trying to do wierd stuff with our private files
if (contains_updir(filename)) { if (contains_updir(filename)) {
Con_Printf ("FindFile: %s: attempt to escape directory tree!\n", filename); Con_Printf ("FindFile: %s: attempt to escape directory tree!\n", filename);
goto error; goto error;
} }
// // search through the path, one element at a time
// search through the path, one element at a time
//
for (search = com_searchpaths; search; search = search->next) { for (search = com_searchpaths; search; search = search->next) {
// is the element a pak file? // is the element a pak file?
if (search->pack) { if (search->pack) {
@ -631,7 +617,8 @@ _COM_FOpenFile (const char *filename, VFile **gzfile, char *foundname, int zip)
if (findtime == -1) { if (findtime == -1) {
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB
strncpy (foundname, gzfilename, MAX_OSPATH); strncpy (foundname, gzfilename, MAX_OSPATH);
snprintf (netpath, sizeof (netpath), "%s%s%s", search->filename, snprintf (netpath, sizeof (netpath), "%s%s%s",
search->filename,
search->filename[0] ? "/" : "", gzfilename); search->filename[0] ? "/" : "", gzfilename);
findtime = Sys_FileTime (netpath); findtime = Sys_FileTime (netpath);
if (findtime == -1) if (findtime == -1)
@ -795,7 +782,6 @@ COM_LoadPackFile (char *packfile)
Qseek (packhandle, header.dirofs, SEEK_SET); Qseek (packhandle, header.dirofs, SEEK_SET);
Qread (packhandle, info, header.dirlen); Qread (packhandle, info, header.dirlen);
// parse the directory // parse the directory
for (i = 0; i < numpackfiles; i++) { for (i = 0; i < numpackfiles; i++) {
strcpy (newfiles[i].name, info[i].name); strcpy (newfiles[i].name, info[i].name);
@ -819,7 +805,6 @@ COM_LoadPackFile (char *packfile)
#define FNAME_SIZE MAX_OSPATH #define FNAME_SIZE MAX_OSPATH
// Note, this is /NOT/ a work-alike strcmp, this groups numbers sanely. // Note, this is /NOT/ a work-alike strcmp, this groups numbers sanely.
//int qstrcmp(const char *val, const char *ref)
int int
qstrcmp (char **os1, char **os2) qstrcmp (char **os1, char **os2)
{ {
@ -996,9 +981,7 @@ COM_Gamedir (const char *dir)
return; // still the same return; // still the same
strcpy (gamedirfile, dir); strcpy (gamedirfile, dir);
//
// free up any current game dir info // free up any current game dir info
//
while (com_searchpaths != com_base_searchpaths) { while (com_searchpaths != com_base_searchpaths) {
if (com_searchpaths->pack) { if (com_searchpaths->pack) {
Qclose (com_searchpaths->pack->handle); Qclose (com_searchpaths->pack->handle);
@ -1010,9 +993,7 @@ COM_Gamedir (const char *dir)
com_searchpaths = next; com_searchpaths = next;
} }
//
// flush all data, so it will be forced to reload // flush all data, so it will be forced to reload
//
Cache_Flush (); Cache_Flush ();
if (fs_skinbase && strcmp (dir, fs_skinbase->string) == 0) if (fs_skinbase && strcmp (dir, fs_skinbase->string) == 0)
@ -1021,9 +1002,6 @@ COM_Gamedir (const char *dir)
COM_AddGameDirectory (dir); COM_AddGameDirectory (dir);
} }
/*
COM_CreateGameDirectory
*/
void void
COM_CreateGameDirectory (const char *gamename) COM_CreateGameDirectory (const char *gamename)
{ {
@ -1032,9 +1010,6 @@ COM_CreateGameDirectory (const char *gamename)
COM_AddGameDirectory (gamename); COM_AddGameDirectory (gamename);
} }
/*
COM_InitFilesystem
*/
void void
COM_Filesystem_Init (void) COM_Filesystem_Init (void)
{ {
@ -1081,16 +1056,14 @@ void
COM_Filesystem_Init_Cvars (void) COM_Filesystem_Init_Cvars (void)
{ {
fs_sharepath = Cvar_Get ("fs_sharepath", FS_SHAREPATH, CVAR_ROM, NULL, fs_sharepath = Cvar_Get ("fs_sharepath", FS_SHAREPATH, CVAR_ROM, NULL,
"location of shared (read only) game directories"); "location of shared (read only) game "
"directories");
fs_userpath = Cvar_Get ("fs_userpath", FS_USERPATH, CVAR_ROM, NULL, fs_userpath = Cvar_Get ("fs_userpath", FS_USERPATH, CVAR_ROM, NULL,
"location of your game directories"); "location of your game directories");
fs_basegame = Cvar_Get ("fs_basegame", "id1", CVAR_ROM, NULL, fs_basegame = Cvar_Get ("fs_basegame", "id1", CVAR_ROM, NULL,
"game to use by default"); "game to use by default");
} }
/*
COM_SkipPath
*/
const char * const char *
COM_SkipPath (const char *pathname) COM_SkipPath (const char *pathname)
{ {
@ -1105,9 +1078,6 @@ COM_SkipPath (const char *pathname)
return last; return last;
} }
/*
COM_StripExtension
*/
void void
COM_StripExtension (const char *in, char *out) COM_StripExtension (const char *in, char *out)
{ {
@ -1116,9 +1086,6 @@ COM_StripExtension (const char *in, char *out)
*out = 0; *out = 0;
} }
/*
COM_FileExtension
*/
char * char *
COM_FileExtension (char *in) COM_FileExtension (char *in)
{ {
@ -1136,19 +1103,13 @@ COM_FileExtension (char *in)
return exten; return exten;
} }
/*
COM_DefaultExtension
*/
void void
COM_DefaultExtension (char *path, char *extension) COM_DefaultExtension (char *path, char *extension)
{ {
char *src; char *src;
// // if path doesn't have a .EXT, append extension
// if path doesn't have a .EXT, append extension // (extension should include the .)
// (extension should include the .)
//
src = path + strlen (path) - 1; src = path + strlen (path) - 1;
while (*src != '/' && src != path) { while (*src != '/' && src != path) {
@ -1160,9 +1121,6 @@ COM_DefaultExtension (char *path, char *extension)
strncat (path, extension, MAX_OSPATH - strlen (path)); strncat (path, extension, MAX_OSPATH - strlen (path));
} }
/*
COM_NextFileName
*/
int int
COM_NextFilename (char *filename, const char *prefix, const char *ext) COM_NextFilename (char *filename, const char *prefix, const char *ext)
{ {

View file

@ -53,12 +53,12 @@
# define _POSIX_ # define _POSIX_
#endif #endif
#include <limits.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
#include <limits.h>
#include "QF/vfs.h"
#include "QF/vfile.h" #include "QF/vfile.h"
#include "QF/vfs.h"
#ifdef WIN32 #ifdef WIN32
# ifndef __BORLANDC__ # ifndef __BORLANDC__
@ -91,8 +91,7 @@ Qexpand_squiggle (const char *path, char *dest)
#ifdef _WIN32 #ifdef _WIN32
// LordHavoc: first check HOME to duplicate previous version behavior // LordHavoc: first check HOME to duplicate previous version behavior
// (also handy if someone wants it somewhere other than their // (also handy if someone wants it elsewhere than their windows directory)
// windows directory)
home = getenv ("HOME"); home = getenv ("HOME");
if (!home || !home[0]) if (!home || !home[0])
home = getenv ("WINDIR"); home = getenv ("WINDIR");
@ -105,8 +104,8 @@ Qexpand_squiggle (const char *path, char *dest)
if (home) { if (home) {
strcpy (dest, home); strcpy (dest, home);
strncat (dest, path + 1, MAX_OSPATH - strlen (dest)); // skip strncat (dest, path + 1, MAX_OSPATH - strlen (dest));
// leading ~ // skip leading ~
} else } else
strcpy (dest, path); strcpy (dest, path);
} }
@ -372,11 +371,9 @@ Qeof (VFile *file)
} }
/* /*
Qgetline Qgetline
Dynamic length version of Qgets. DO NOT free the buffer. Dynamic length version of Qgets. DO NOT free the buffer.
*/ */
const char * const char *
Qgetline (VFile *file) Qgetline (VFile *file)

View file

@ -28,12 +28,6 @@
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif
#include <errno.h>
#include <stdarg.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#ifdef HAVE_STRING_H #ifdef HAVE_STRING_H
# include <string.h> # include <string.h>
#endif #endif
@ -56,10 +50,18 @@
# include <sys/mman.h> # include <sys/mman.h>
#endif #endif
#include "compat.h" #include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include "QF/cvar.h" #include "QF/cvar.h"
#include "QF/sys.h" #include "QF/sys.h"
#include "compat.h"
static void Sys_StdPrintf (const char *fmt, va_list args); static void Sys_StdPrintf (const char *fmt, va_list args);
cvar_t *sys_nostdout; cvar_t *sys_nostdout;
@ -104,6 +106,7 @@ const char sys_char_map[256] = {
#define MAXPRINTMSG 4096 #define MAXPRINTMSG 4096
void void
Sys_mkdir (const char *path) Sys_mkdir (const char *path)
{ {
@ -156,9 +159,6 @@ Sys_SetPrintf (sys_printf_t func)
sys_printf_function = func; sys_printf_function = func;
} }
/*
Sys_Printf
*/
static void static void
Sys_StdPrintf (const char *fmt, va_list args) Sys_StdPrintf (const char *fmt, va_list args)
{ {
@ -187,9 +187,6 @@ Sys_Printf (const char *fmt, ...)
va_end (args); va_end (args);
} }
/*
Sys_DoubleTime
*/
double double
Sys_DoubleTime (void) Sys_DoubleTime (void)
{ {
@ -248,8 +245,8 @@ Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length)
addr = (startaddr & ~(psize - 1)) - psize; addr = (startaddr & ~(psize - 1)) - psize;
// fprintf(stderr, "writable code %lx(%lx)-%lx, length=%lx\n", startaddr, // fprintf(stderr, "writable code %lx(%lx)-%lx, length=%lx\n", startaddr,
// addr, startaddr+length, length); // addr, startaddr+length, length);
r = mprotect ((char *) addr, length + startaddr - addr + psize, 7); r = mprotect ((char *) addr, length + startaddr - addr + psize, 7);

View file

@ -28,11 +28,14 @@
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif
#include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h>
#include "QF/sys.h"
#include "compat.h" #include "compat.h"
#include "QF/sys.h"
void void
QFutil_Sys_Error (const char *error, ...) QFutil_Sys_Error (const char *error, ...)

View file

@ -55,7 +55,6 @@ fgetLittleShort (VFile *f)
return (short) (b1 + b2 * 256); return (short) (b1 + b2 * 256);
} }
/* /*
static int static int
fgetLittleLong (VFile *f) fgetLittleLong (VFile *f)
@ -71,7 +70,6 @@ fgetLittleLong (VFile *f)
} }
*/ */
byte * byte *
LoadTGA (VFile *fin) LoadTGA (VFile *fin)
{ {
@ -102,8 +100,8 @@ LoadTGA (VFile *fin)
if (targa_header.colormap_type != 0 if (targa_header.colormap_type != 0
|| (targa_header.pixel_size != 32 && targa_header.pixel_size != 24)) || (targa_header.pixel_size != 32 && targa_header.pixel_size != 24))
Sys_Error Sys_Error ("Texture_LoadTGA: Only 32 or 24 bit images supported "
("Texture_LoadTGA: Only 32 or 24 bit images supported (no colormaps)\n"); "(no colormaps)\n");
columns = targa_header.width; columns = targa_header.width;
rows = targa_header.height; rows = targa_header.height;
@ -227,7 +225,6 @@ LoadTGA (VFile *fin)
return targa_rgba; return targa_rgba;
} }
void void
WriteTGAfile (const char *tganame, byte *data, int width, int height) WriteTGAfile (const char *tganame, byte *data, int width, int height)
{ {

View file

@ -30,13 +30,15 @@
# include "config.h" # include "config.h"
#endif #endif
#include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h>
#include "compat.h"
#include "QF/qtypes.h" #include "QF/qtypes.h"
#include "QF/va.h" #include "QF/va.h"
#include "compat.h"
/* /*
va va

View file

@ -31,8 +31,9 @@
# include "config.h" # include "config.h"
#endif #endif
#include <stdlib.h>
#include <ctype.h> #include <ctype.h>
#include <stdlib.h>
/* /*
ver_compare ver_compare

View file

@ -77,7 +77,6 @@ W_CleanupName (const char *in, char *out)
out[i] = 0; out[i] = 0;
} }
void void
W_LoadWadFile (const char *filename) W_LoadWadFile (const char *filename)
{ {
@ -89,12 +88,13 @@ W_LoadWadFile (const char *filename)
wad_base = COM_LoadHunkFile (filename); wad_base = COM_LoadHunkFile (filename);
if (!wad_base) if (!wad_base)
{ {
Sys_Printf ( Sys_Printf ("\n The following error is somewhat misleading. Most "
"\n The following error is somewhat misleading. Most likely you don't\n" "likely you don't\n have a file by that name on your "
" have a file by that name on your system because it's stored in a pak\n" "system because it's stored in a pak\n file. The real "
" file. The real problem is that it's not where we expect it to be.\n\n" "problem is that it's not where we expect it to be.\n\n"
" Game data should be installed into fs_sharepath or fs_userpath, in a\n" " Game data should be installed into fs_sharepath or "
" subdirectory named %s.\n\n", fs_basegame->string); "fs_userpath, in a\n subdirectory named %s.\n\n",
fs_basegame->string);
Sys_Printf (" fs_sharepath is %s\n", fs_sharepath->string); Sys_Printf (" fs_sharepath is %s\n", fs_sharepath->string);
Sys_Printf (" fs_userpath is %s\n\n", fs_userpath->string); Sys_Printf (" fs_userpath is %s\n\n", fs_userpath->string);
Sys_Error ("W_LoadWadFile: unable to load %s\n\n", filename); Sys_Error ("W_LoadWadFile: unable to load %s\n\n", filename);
@ -121,7 +121,6 @@ W_LoadWadFile (const char *filename)
} }
} }
lumpinfo_t * lumpinfo_t *
W_GetLumpinfo (const char *name) W_GetLumpinfo (const char *name)
{ {
@ -140,7 +139,6 @@ W_GetLumpinfo (const char *name)
return NULL; return NULL;
} }
void * void *
W_GetLumpName (const char *name) W_GetLumpName (const char *name)
{ {
@ -151,7 +149,6 @@ W_GetLumpName (const char *name)
return (void *) (wad_base + lump->filepos); return (void *) (wad_base + lump->filepos);
} }
void * void *
W_GetLumpNum (int num) W_GetLumpNum (int num)
{ {
@ -165,12 +162,10 @@ W_GetLumpNum (int num)
return (void *) (wad_base + lump->filepos); return (void *) (wad_base + lump->filepos);
} }
/* /*
automatic byte swapping automatic byte swapping
*/ */
void void
SwapPic (qpic_t *pic) SwapPic (qpic_t *pic)
{ {

View file

@ -53,7 +53,6 @@
void Cache_FreeLow (int new_low_hunk); void Cache_FreeLow (int new_low_hunk);
void Cache_FreeHigh (int new_high_hunk); void Cache_FreeHigh (int new_high_hunk);
/* /*
The zone calls are pretty much only used for small strings and structures, The zone calls are pretty much only used for small strings and structures,
all big things are allocated on the hunk. all big things are allocated on the hunk.
@ -79,6 +78,7 @@ int hunk_tempmark;
void R_FreeTextures (void); void R_FreeTextures (void);
/* /*
Hunk_Check Hunk_Check
@ -127,9 +127,7 @@ Hunk_Print (qboolean all)
Con_Printf ("-------------------------\n"); Con_Printf ("-------------------------\n");
while (1) { while (1) {
//
// skip to the high hunk if done with low hunk // skip to the high hunk if done with low hunk
//
if (h == endlow) { if (h == endlow) {
Con_Printf ("-------------------------\n"); Con_Printf ("-------------------------\n");
Con_Printf (" :%8i REMAINING\n", Con_Printf (" :%8i REMAINING\n",
@ -137,15 +135,11 @@ Hunk_Print (qboolean all)
Con_Printf ("-------------------------\n"); Con_Printf ("-------------------------\n");
h = starthigh; h = starthigh;
} }
//
// if totally done, break // if totally done, break
//
if (h == endhigh) if (h == endhigh)
break; break;
//
// run consistancy checks // run consistancy checks
//
if (h->sentinal != HUNK_SENTINAL) if (h->sentinal != HUNK_SENTINAL)
Sys_Error ("Hunk_Check: trahsed sentinal"); Sys_Error ("Hunk_Check: trahsed sentinal");
if (h->size < 16 || h->size + (byte *) h - hunk_base > hunk_size) if (h->size < 16 || h->size + (byte *) h - hunk_base > hunk_size)
@ -156,16 +150,12 @@ Hunk_Print (qboolean all)
totalblocks++; totalblocks++;
sum += h->size; sum += h->size;
//
// print the single block // print the single block
//
memcpy (name, h->name, 8); memcpy (name, h->name, 8);
if (all) if (all)
Con_Printf ("%8p :%8i %8s\n", h, h->size, name); Con_Printf ("%8p :%8i %8s\n", h, h->size, name);
//
// print the total // print the total
//
if (next == endlow || next == endhigh || if (next == endlow || next == endhigh ||
strncmp (h->name, next->name, 8)) { strncmp (h->name, next->name, 8)) {
if (!all) if (!all)
@ -182,9 +172,6 @@ Hunk_Print (qboolean all)
} }
/*
Hunk_AllocName
*/
void * void *
Hunk_AllocName (int size, const char *name) Hunk_AllocName (int size, const char *name)
{ {
@ -200,14 +187,16 @@ Hunk_AllocName (int size, const char *name)
size = sizeof (hunk_t) + ((size + 15) & ~15); size = sizeof (hunk_t) + ((size + 15) & ~15);
if (hunk_size - hunk_low_used - hunk_high_used < size) if (hunk_size - hunk_low_used - hunk_high_used < size)
// Sys_Error ("Hunk_Alloc: failed on %i bytes",size); // Sys_Error ("Hunk_Alloc: failed on %i bytes",size);
#ifdef _WIN32 #ifdef _WIN32
Sys_Error Sys_Error
("Not enough RAM allocated. Try starting using \"-heapsize 16000\" on the %s command line.", ("Not enough RAM allocated. Try starting using "
"\"-heapsize 16000\" on the %s command line.",
PROGRAM); PROGRAM);
#else #else
Sys_Error Sys_Error
("Not enough RAM allocated. Try starting using \"-mem 16\" on the %s command line.", ("Not enough RAM allocated. Try starting using \"-mem 16\" on "
"the %s command line.",
PROGRAM); PROGRAM);
#endif #endif
@ -225,9 +214,6 @@ Hunk_AllocName (int size, const char *name)
return (void *) (h + 1); return (void *) (h + 1);
} }
/*
Hunk_Alloc
*/
void * void *
Hunk_Alloc (int size) Hunk_Alloc (int size)
{ {
@ -273,10 +259,6 @@ Hunk_FreeToHighMark (int mark)
hunk_high_used = mark; hunk_high_used = mark;
} }
/*
Hunk_HighAllocName
*/
void * void *
Hunk_HighAllocName (int size, const char *name) Hunk_HighAllocName (int size, const char *name)
{ {
@ -312,7 +294,6 @@ Hunk_HighAllocName (int size, const char *name)
return (void *) (h + 1); return (void *) (h + 1);
} }
/* /*
Hunk_TempAlloc Hunk_TempAlloc
@ -355,15 +336,12 @@ cache_system_t *Cache_TryAlloc (int size, qboolean nobottom);
cache_system_t cache_head; cache_system_t cache_head;
/*
Cache_Move
*/
void void
Cache_Move (cache_system_t * c) Cache_Move (cache_system_t * c)
{ {
cache_system_t *new; cache_system_t *new;
// we are clearing up space at the bottom, so only allocate it late // we are clearing up space at the bottom, so only allocate it late
new = Cache_TryAlloc (c->size, true); new = Cache_TryAlloc (c->size, true);
if (new) { if (new) {
Con_DPrintf ("cache_move ok\n"); Con_DPrintf ("cache_move ok\n");
@ -461,7 +439,7 @@ Cache_TryAlloc (int size, qboolean nobottom)
{ {
cache_system_t *cs, *new; cache_system_t *cs, *new;
// is the cache completely empty? // is the cache completely empty?
if (!nobottom && cache_head.prev == &cache_head) { if (!nobottom && cache_head.prev == &cache_head) {
if (hunk_size - hunk_high_used - hunk_low_used < size) { if (hunk_size - hunk_high_used - hunk_low_used < size) {
@ -479,7 +457,8 @@ Cache_TryAlloc (int size, qboolean nobottom)
Cache_MakeLRU (new); Cache_MakeLRU (new);
return new; return new;
} }
// search from the bottom up for space
// search from the bottom up for space
new = (cache_system_t *) (hunk_base + hunk_low_used); new = (cache_system_t *) (hunk_base + hunk_low_used);
cs = cache_head.next; cs = cache_head.next;
@ -506,7 +485,7 @@ Cache_TryAlloc (int size, qboolean nobottom)
} while (cs != &cache_head); } while (cs != &cache_head);
// try to allocate one at the very end // try to allocate one at the very end
if (hunk_base + hunk_size - hunk_high_used - (byte *) new >= size) { if (hunk_base + hunk_size - hunk_high_used - (byte *) new >= size) {
memset (new, 0, sizeof (*new)); memset (new, 0, sizeof (*new));
new->size = size; new->size = size;
@ -536,10 +515,6 @@ Cache_Flush (void)
Cache_Free (cache_head.next->user); // reclaim the space Cache_Free (cache_head.next->user); // reclaim the space
} }
/*
Cache_Print
*/
void void
Cache_Print (void) Cache_Print (void)
{ {
@ -550,9 +525,6 @@ Cache_Print (void)
} }
} }
/*
Cache_Report
*/
void void
Cache_Report (void) Cache_Report (void)
{ {
@ -561,17 +533,11 @@ Cache_Report (void)
hunk_low_used) / (float) (1024 * 1024)); hunk_low_used) / (float) (1024 * 1024));
} }
/*
Cache_Compact
*/
void void
Cache_Compact (void) Cache_Compact (void)
{ {
} }
/*
Cache_Init
*/
void void
Cache_Init (void) Cache_Init (void)
{ {
@ -605,11 +571,6 @@ Cache_Free (cache_user_t *c)
Cache_UnlinkLRU (cs); Cache_UnlinkLRU (cs);
} }
/*
Cache_Check
*/
void * void *
Cache_Check (cache_user_t *c) Cache_Check (cache_user_t *c)
{ {
@ -620,17 +581,13 @@ Cache_Check (cache_user_t *c)
cs = ((cache_system_t *) c->data) - 1; cs = ((cache_system_t *) c->data) - 1;
// move to head of LRU // move to head of LRU
Cache_UnlinkLRU (cs); Cache_UnlinkLRU (cs);
Cache_MakeLRU (cs); Cache_MakeLRU (cs);
return c->data; return c->data;
} }
/*
Cache_Alloc
*/
void * void *
Cache_Alloc (cache_user_t *c, int size, const char *name) Cache_Alloc (cache_user_t *c, int size, const char *name)
{ {
@ -644,7 +601,7 @@ Cache_Alloc (cache_user_t *c, int size, const char *name)
size = (size + sizeof (cache_system_t) + 15) & ~15; size = (size + sizeof (cache_system_t) + 15) & ~15;
// find memory for it // find memory for it
while (1) { while (1) {
cs = Cache_TryAlloc (size, false); cs = Cache_TryAlloc (size, false);
if (cs) { if (cs) {
@ -665,10 +622,6 @@ Cache_Alloc (cache_user_t *c, int size, const char *name)
//============================================================================ //============================================================================
/*
Memory_Init
*/
void void
Memory_Init (void *buf, int size) Memory_Init (void *buf, int size)
{ {