From edcf092b05d64fb69388fdce51d92dbb814b58c9 Mon Sep 17 00:00:00 2001 From: Ragnvald Maartmann-Moe IV Date: Wed, 22 Aug 2001 22:03:16 +0000 Subject: [PATCH] Whitespace, dammit. Oh, and removal of several orphaned comments. Comments in front of functions suck. --- libs/util/checksum.c | 1 + libs/util/cmd.c | 121 ++++++-------------- libs/util/con_print.c | 1 + libs/util/console.c | 9 +- libs/util/crc.c | 1 + libs/util/cvar.c | 53 +++------ libs/util/dirent.c | 78 +++++++------ libs/util/fendian.c | 1 + libs/util/fnmatch.c | 7 +- libs/util/info.c | 12 +- libs/util/link.c | 1 + libs/util/mathlib.c | 64 +++-------- libs/util/mdfour.c | 5 +- libs/util/msg.c | 6 +- libs/util/pcx.c | 4 +- libs/util/plugin.c | 15 +-- libs/util/qargs.c | 16 +-- libs/util/qendian.c | 2 +- libs/util/qfplist.c | 257 +++++++++++++++++++++--------------------- libs/util/quakefs.c | 96 +++++----------- libs/util/quakeio.c | 13 +-- libs/util/sys.c | 27 ++--- libs/util/sys_error.c | 7 +- libs/util/tga.c | 7 +- libs/util/va.c | 6 +- libs/util/ver_check.c | 3 +- libs/util/wad.c | 19 ++-- libs/util/zone.c | 73 +++--------- 28 files changed, 350 insertions(+), 555 deletions(-) diff --git a/libs/util/checksum.c b/libs/util/checksum.c index a2ef1e1e3..8b94cad7a 100644 --- a/libs/util/checksum.c +++ b/libs/util/checksum.c @@ -115,6 +115,7 @@ static byte chktbl[1024 + 4] = { 0x00, 0x00, 0x00, 0x00 }; + /* COM_BlockSequenceCRCByte diff --git a/libs/util/cmd.c b/libs/util/cmd.c index e5395f645..34524e344 100644 --- a/libs/util/cmd.c +++ b/libs/util/cmd.c @@ -38,10 +38,9 @@ #include -#include "QF/cvar.h" #include "QF/cmd.h" -#include "compat.h" #include "QF/console.h" +#include "QF/cvar.h" #include "QF/hash.h" #include "QF/qargs.h" #include "QF/qendian.h" @@ -50,6 +49,8 @@ #include "QF/vfs.h" #include "QF/zone.h" +#include "compat.h" + typedef struct cmdalias_s { struct cmdalias_s *next; const char *name; @@ -87,9 +88,6 @@ Cmd_Wait_f (void) sizebuf_t cmd_text; byte cmd_text_buf[8192]; -/* - Cbuf_Init -*/ void Cbuf_Init (void) { @@ -116,7 +114,6 @@ Cbuf_AddText (const char *text) SZ_Write (&cmd_text, text, strlen (text)); } - /* Cbuf_InsertText @@ -149,7 +146,6 @@ Cbuf_InsertText (const char *text) cmd_text.data[textlen] = '\n'; } - static void extract_line (char *line) { @@ -185,11 +181,6 @@ extract_line (char *line) } } -/* - - Cbuf_Execute - -*/ void Cbuf_Execute (void) { @@ -210,11 +201,6 @@ Cbuf_Execute (void) } } -/* - - Cbuf_Execute - -*/ void Cbuf_Execute_Sets (void) { @@ -256,7 +242,7 @@ Cmd_StuffCmds_f (void) if (!s) return; -// pull out the commands + // pull out the commands build = malloc (s + 1); build[0] = 0; @@ -287,11 +273,6 @@ Cmd_StuffCmds_f (void) free (build); } -/* - - Cmd_Exec_File - -*/ void Cmd_Exec_File (const char *path) { @@ -313,9 +294,6 @@ Cmd_Exec_File (const char *path) } } -/* - Cmd_Exec_f -*/ void Cmd_Exec_f (void) { @@ -341,7 +319,6 @@ Cmd_Exec_f (void) Hunk_FreeToLowMark (mark); } - /* Cmd_Echo_f @@ -362,7 +339,6 @@ Cmd_Echo_f (void) Creates a new command that executes a command string (possibly ; seperated) */ - char * CopyString (char *in) { @@ -406,7 +382,7 @@ Cmd_Alias_f (void) *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[0] = 0; // start out with a null string c = Cmd_Argc (); @@ -469,22 +445,14 @@ static char *cmd_argv[MAX_ARGS]; static const char *cmd_null_string = ""; static const char *cmd_args[MAX_ARGS]; - - static cmd_function_t *cmd_functions; // possible commands to execute -/* - Cmd_Argc -*/ int Cmd_Argc (void) { return cmd_argc; } -/* - Cmd_Argv -*/ const char * Cmd_Argv (int arg) { @@ -506,7 +474,6 @@ Cmd_Args (int start) return cmd_args[start]; } - /* Cmd_TokenizeString @@ -524,7 +491,7 @@ Cmd_TokenizeString (const char *text) memset (cmd_args, 0, sizeof (cmd_args)); while (1) { -// skip whitespace up to a \n + // skip whitespace up to a \n while (*text && *(unsigned char *) text <= ' ' && *text != '\n') { text++; } @@ -557,13 +524,8 @@ Cmd_TokenizeString (const char *text) cmd_argc++; } } - } - -/* - Cmd_AddCommand -*/ void 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; } -/* - Cmd_Exists -*/ qboolean Cmd_Exists (const char *cmd_name) { @@ -610,11 +569,6 @@ Cmd_Exists (const char *cmd_name) return false; } - - -/* - Cmd_CompleteCommand -*/ const char * Cmd_CompleteCommand (const char *partial) { @@ -627,7 +581,7 @@ Cmd_CompleteCommand (const char *partial) if (!len) return NULL; -// check for exact match + // check for exact match for (cmd = cmd_functions; cmd; cmd = cmd->next) if (!strcasecmp (partial, cmd->name)) return cmd->name; @@ -635,7 +589,7 @@ Cmd_CompleteCommand (const char *partial) if (!strcasecmp (partial, a->name)) return a->name; -// check for partial match + // check for partial match for (cmd = cmd_functions; cmd; cmd = cmd->next) if (!strncasecmp (partial, cmd->name, len)) return cmd->name; @@ -653,7 +607,6 @@ Cmd_CompleteCommand (const char *partial) Added by EvilTypeGuy Thanks to Fett erich@heintz.com Thanks to taniwha - */ int Cmd_CompleteCountPossible (const char *partial) @@ -683,7 +636,6 @@ Cmd_CompleteCountPossible (const char *partial) Added by EvilTypeGuy Thanks to Fett erich@heintz.com Thanks to taniwha - */ const char ** Cmd_CompleteBuildList (const char *partial) @@ -712,7 +664,6 @@ Cmd_CompleteBuildList (const char *partial) Added by EvilTypeGuy Thanks to Fett erich@heintz.com Thanks to taniwha - */ const char * Cmd_CompleteAlias (const char * partial) @@ -740,7 +691,6 @@ Cmd_CompleteAlias (const char * partial) Added by EvilTypeGuy Thanks to Fett erich@heintz.com Thanks to taniwha - */ int Cmd_CompleteAliasCountPossible (const char *partial) @@ -771,7 +721,6 @@ Cmd_CompleteAliasCountPossible (const char *partial) Added by EvilTypeGuy Thanks to Fett erich@heintz.com Thanks to taniwha - */ const char ** Cmd_CompleteAliasBuildList (const char *partial) @@ -779,7 +728,8 @@ Cmd_CompleteAliasBuildList (const char *partial) cmdalias_t *alias; int len = 0; int bpos = 0; - int sizeofbuf = (Cmd_CompleteAliasCountPossible (partial) + 1) * sizeof (char *); + int sizeofbuf = (Cmd_CompleteAliasCountPossible (partial) + 1) * + sizeof (char *); const char **buf; len = strlen(partial); @@ -811,7 +761,7 @@ Cmd_ExpandVariables (const char *data, char *dest) len = 0; -// parse a regular word + // parse a regular word while ((c = *data) != 0) { if (c == '"') quotes++; @@ -886,11 +836,11 @@ Cmd_ExecuteString (const char *text, cmd_source_t src) Cmd_TokenizeString (buf); #endif -// execute the command line + // execute the command line if (!Cmd_Argc ()) return; // no tokens -// check functions + // check functions cmd = (cmd_function_t*)Hash_Find (cmd_hash, cmd_argv[0]); if (cmd) { if (cmd->function) @@ -898,11 +848,11 @@ Cmd_ExecuteString (const char *text, cmd_source_t src) return; } -// Tonik: check cvars + // Tonik: check cvars if (Cvar_Command ()) return; -// check alias + // check alias a = (cmdalias_t*)Hash_Find (cmd_alias_hash, cmd_argv[0]); if (a) { 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)); } - - /* Cmd_CheckParm @@ -970,7 +918,8 @@ Cmd_Help_f (void) 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) { Con_Printf ("%s\n", cmd->description); @@ -1021,31 +970,31 @@ void Cmd_Init_Hash (void) { 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 Cmd_Init (void) { -// -// register our commands -// - Cmd_AddCommand ("stuffcmds", Cmd_StuffCmds_f, "Execute the commands given at startup again"); + // 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 ("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"); - 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]; /* @@ -1065,22 +1014,22 @@ COM_Parse (const char *data) if (!data) return NULL; -// skip whitespace - skipwhite: + // skip whitespace +skipwhite: while ((c = *data) <= ' ') { if (c == 0) return NULL; // end of file; data++; } -// skip // comments + // skip // comments if (c == '/' && data[1] == '/') { while (*data && *data != '\n') data++; goto skipwhite; } -// handle quoted strings specially + // handle quoted strings specially if (c == '\"') { data++; while (1) { @@ -1093,7 +1042,7 @@ COM_Parse (const char *data) len++; } } -// parse a regular word + // parse a regular word do { com_token[len] = c; data++; diff --git a/libs/util/con_print.c b/libs/util/con_print.c index 676e6f85f..d382a33a0 100644 --- a/libs/util/con_print.c +++ b/libs/util/con_print.c @@ -33,6 +33,7 @@ #include "QF/console.h" #include "QF/sys.h" + /* Con_Print diff --git a/libs/util/console.c b/libs/util/console.c index 5269122fc..89e8356d5 100644 --- a/libs/util/console.c +++ b/libs/util/console.c @@ -38,18 +38,20 @@ #include -#include "compat.h" #include "QF/console.h" #include "QF/cvar.h" #include "QF/sys.h" +#include "compat.h" + +#define MAXPRINTMSG 4096 + + /* Con_Printf Handles cursor positioning, line wrapping, etc */ -#define MAXPRINTMSG 4096 - void Con_Printf (const char *fmt, ...) { @@ -130,4 +132,3 @@ Con_DisplayList(const char **list, int con_linewidth) if (pos) Con_Printf("\n\n"); } - diff --git a/libs/util/crc.c b/libs/util/crc.c index 9ae8bcfeb..07347e85d 100644 --- a/libs/util/crc.c +++ b/libs/util/crc.c @@ -74,6 +74,7 @@ static unsigned short crctable[256] = { 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 }; + void CRC_Init (unsigned short *crcvalue) { diff --git a/libs/util/cvar.c b/libs/util/cvar.c index e37fb2dbe..670cc066d 100644 --- a/libs/util/cvar.c +++ b/libs/util/cvar.c @@ -41,14 +41,15 @@ #include #include -#include "compat.h" -#include "QF/console.h" #include "QF/cmd.h" +#include "QF/console.h" #include "QF/cvar.h" #include "QF/hash.h" #include "QF/qargs.h" #include "QF/vfs.h" +#include "compat.h" + #define USER_RO_CVAR "User-created READ-ONLY Cvar" #define USER_CVAR "User-created cvar" @@ -60,9 +61,7 @@ cvar_alias_t *calias_vars; hashtab_t *cvar_hash; hashtab_t *calias_hash; -/* - Cvar_FindVar -*/ + cvar_t * Cvar_FindVar (const char *var_name) { @@ -106,9 +105,6 @@ Cvar_Alias_Get (const char *name, cvar_t *cvar) } } -/* - Cvar_VariableValue -*/ float Cvar_VariableValue (const char *var_name) { @@ -122,10 +118,6 @@ Cvar_VariableValue (const char *var_name) return atof (var->string); } - -/* - Cvar_VariableString -*/ const char * Cvar_VariableString (const char *var_name) { @@ -139,10 +131,6 @@ Cvar_VariableString (const char *var_name) return var->string; } - -/* - Cvar_CompleteVariable -*/ const char * Cvar_CompleteVariable (const char *partial) { @@ -184,7 +172,6 @@ Cvar_CompleteVariable (const char *partial) New function for tab-completion system Added by EvilTypeGuy Thanks to Fett erich@heintz.com - */ int Cvar_CompleteCountPossible (const char *partial) @@ -214,7 +201,6 @@ Cvar_CompleteCountPossible (const char *partial) Added by EvilTypeGuy Thanks to Fett erich@heintz.com Thanks to taniwha - */ const char ** Cvar_CompleteBuildList (const char *partial) @@ -222,7 +208,8 @@ Cvar_CompleteBuildList (const char *partial) cvar_t *cvar; int len = 0; int bpos = 0; - int sizeofbuf = (Cvar_CompleteCountPossible (partial) + 1) * sizeof (char *); + int sizeofbuf = (Cvar_CompleteCountPossible (partial) + 1) * + sizeof (char *); const char **buf; len = strlen(partial); @@ -236,9 +223,6 @@ Cvar_CompleteBuildList (const char *partial) return buf; } -/* - Cvar_Set -*/ void Cvar_Set (cvar_t *var, const char *value) { @@ -264,7 +248,6 @@ Cvar_Set (cvar_t *var, const char *value) var->callback (var); } - /* Cvar_SetROM @@ -290,9 +273,6 @@ Cvar_SetROM (cvar_t *var, const char *value) var->callback (var); } -/* - Cvar_SetValue -*/ // 1999-09-07 weird cvar zeros fix by Maddes void Cvar_SetValue (cvar_t *var, float value) @@ -301,7 +281,8 @@ Cvar_SetValue (cvar_t *var, float value) int i; 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; } Cvar_Set (var, val); @@ -324,7 +305,7 @@ Cvar_Command (void) if (!v) return false; -// perform a variable print or set + // perform a variable print or set if (Cmd_Argc () == 1) { Con_Printf ("\"%s\" is \"%s\"\n", v->name, v->string); return true; @@ -334,7 +315,6 @@ Cvar_Command (void) return true; } - /* Cvar_WriteVariables @@ -371,7 +351,8 @@ Cvar_Set_f (void) if (var) { 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 { Cvar_Set (var, value); } @@ -401,7 +382,8 @@ Cvar_Setrom_f (void) if (var) { 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 { Cvar_Set (var, value); Cvar_SetFlags (var, var->flags | CVAR_ROM); @@ -501,9 +483,11 @@ Cvar_Init (void) developer = Cvar_Get ("developer", "0", CVAR_NONE, NULL, "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 ("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 ("cvarlist", Cvar_CvarList_f, "List all cvars"); } @@ -533,7 +517,6 @@ Cvar_Shutdown (void) } } - cvar_t * Cvar_Get (const char *name, const char *string, int cvarflags, void (*callback)(cvar_t*), const char *description) diff --git a/libs/util/dirent.c b/libs/util/dirent.c index 995ab7689..8c55b6aa7 100644 --- a/libs/util/dirent.c +++ b/libs/util/dirent.c @@ -13,14 +13,13 @@ * */ -#include -#include -#include -#include #include -#include - #include +#include +#include +#include +#include +#include #define SUFFIX "*" #define SLASH "\\" @@ -29,12 +28,13 @@ #define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR) /* is a directory */ #endif S_ISDIR + /* - * opendir - * - * Returns a pointer to a DIR structure appropriately filled in to begin - * searching a directory. - */ + opendir + + Returns a pointer to a DIR structure appropriately filled in to begin + searching a directory. +*/ DIR * opendir (const char *szPath) { @@ -107,13 +107,12 @@ opendir (const char *szPath) return nd; } - /* - * readdir - * - * Return a pointer to a dirent structure filled with the information on the - * next entry in the directory. - */ + readdir + + Return a pointer to a dirent structure filled with the information on the + next entry in the directory. +*/ struct dirent * readdir (DIR * dirp) { @@ -169,12 +168,11 @@ readdir (DIR * dirp) return (struct dirent *) 0; } - /* - * closedir - * - * Frees up resources allocated by opendir. - */ + closedir + + Frees up resources allocated by opendir. +*/ int closedir (DIR * dirp) { @@ -199,11 +197,11 @@ closedir (DIR * dirp) } /* - * rewinddir - * - * Return to the beginning of the directory "stream". We simply call findclose - * and then reset things like an opendir. - */ + rewinddir + + Return to the beginning of the directory "stream". We simply call findclose + and then reset things like an opendir. +*/ void rewinddir (DIR * dirp) { @@ -223,11 +221,11 @@ rewinddir (DIR * dirp) } /* - * telldir - * - * 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. - */ + telldir + + 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. +*/ long telldir (DIR * dirp) { @@ -241,14 +239,14 @@ telldir (DIR * dirp) } /* - * seekdir - * - * Seek to an entry previously returned by telldir. We rewind the directory - * 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 - * have changed while we weren't looking. But that is probably the case with - * any such system. - */ + seekdir + + Seek to an entry previously returned by telldir. We rewind the directory + 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 + have changed while we weren't looking. But that is probably the case with + any such system. +*/ void seekdir (DIR * dirp, long lPos) { diff --git a/libs/util/fendian.c b/libs/util/fendian.c index f702ecc18..193823b54 100644 --- a/libs/util/fendian.c +++ b/libs/util/fendian.c @@ -32,6 +32,7 @@ #include "QF/qendian.h" #include "QF/vfile.h" + void WriteFloat (VFile *file, float f) { diff --git a/libs/util/fnmatch.c b/libs/util/fnmatch.c index 2229c0152..fafbba111 100644 --- a/libs/util/fnmatch.c +++ b/libs/util/fnmatch.c @@ -34,23 +34,22 @@ # define _GNU_SOURCE #endif -#include #include +#include #include "fnmatch.h" - /* 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 Library, but also included in many other GNU distributions. Compiling 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 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(__GNU_LIBRARY__) && !defined(STDC_HEADERS) extern int errno; #endif diff --git a/libs/util/info.c b/libs/util/info.c index f425c64eb..7eccca04a 100644 --- a/libs/util/info.c +++ b/libs/util/info.c @@ -1,7 +1,7 @@ /* info.c - (description) + Info strings. Copyright (C) 1996-1997 Id Software, Inc. @@ -39,13 +39,11 @@ #include #include -#include "compat.h" #include "QF/console.h" #include "QF/info.h" -/* - INFO STRINGS -*/ +#include "compat.h" + /* Info_ValueForKey @@ -180,7 +178,6 @@ Info_RemovePrefixedKeys (char *start, char prefix) } - void 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 -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] == '*') { Con_Printf ("Can't set * keys\n"); diff --git a/libs/util/link.c b/libs/util/link.c index 95b89667c..b4ee49582 100644 --- a/libs/util/link.c +++ b/libs/util/link.c @@ -32,6 +32,7 @@ #include "QF/link.h" + // ClearLink is used for new headnodes void ClearLink (link_t *l) diff --git a/libs/util/mathlib.c b/libs/util/mathlib.c index a249ec41d..42dc29b6e 100644 --- a/libs/util/mathlib.c +++ b/libs/util/mathlib.c @@ -72,9 +72,7 @@ ProjectPointOnPlane (vec3_t dst, const vec3_t p, const vec3_t normal) dst[2] = p[2] - d * n[2]; } -/* -** assumes "src" is normalized -*/ +// assumes "src" is normalized void PerpendicularVector (vec3_t dst, const vec3_t src) { @@ -83,8 +81,7 @@ PerpendicularVector (vec3_t dst, const vec3_t src) float minelem = 1.0F; 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++) { if (fabs (src[i]) < minelem) { pos = i; @@ -94,17 +91,15 @@ PerpendicularVector (vec3_t dst, const vec3_t src) tempvec[0] = tempvec[1] = tempvec[2] = 0.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); - /* - ** normalize the result */ + /* normalize the result */ VectorNormalize (dst); } #if defined(_WIN32) && !defined(__GNUC__) -#pragma optimize( "", off ) +# pragma optimize( "", off ) #endif 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__) -#pragma optimize( "", on ) +# pragma optimize( "", on ) #endif /*-----------------------------------------------------------------*/ @@ -223,10 +218,11 @@ BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, mplane_t *p) float dist1, dist2; int sides; -#if 0 // this is done by the BOX_ON_PLANE_SIDE macro before - // calling this function +#if 0 + // 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->dist <= emins[p->type]) return 1; @@ -236,7 +232,7 @@ BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, mplane_t *p) } #endif -// general case + // general case switch (p->signbits) { case 0: dist1 = @@ -328,7 +324,6 @@ BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, mplane_t *p) sides = 1; if (dist2 < 0) sides |= 2; - #endif sides = 0; @@ -344,10 +339,8 @@ BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, mplane_t *p) return sides; } - #endif - void 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]; } - vec_t _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; } - int Q_log2 (int val) { @@ -496,10 +487,6 @@ Q_log2 (int val) return answer; } - -/* - R_ConcatRotations -*/ void 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]; } - -/* - R_ConcatTransforms -*/ void 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]; } - /* 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 quotient must fit in 32 bits. */ - void 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) Sys_Error ("FloorDivMod: bad denominator %f\n", denom); -// if ((floor(numer) != numer) || (floor(denom) != denom)) -// Sys_Error ("FloorDivMod: non-integer numer or denom %f %f\n", -// numer, denom); +// if ((floor(numer) != numer) || (floor(denom) != denom)) +// Sys_Error ("FloorDivMod: non-integer numer or denom %f %f\n", +// numer, denom); #endif if (numer >= 0.0) { @@ -586,10 +567,8 @@ FloorDivMod (double numer, double denom, int *quotient, int *rem) q = (int) x; r = (int) floor (numer - (x * denom)); } else { - // // perform operations with positive values, and fix mod to make // floor-based - // x = floor (-numer / denom); q = -(int) x; r = (int) floor (-numer - (x * denom)); @@ -603,10 +582,6 @@ FloorDivMod (double numer, double denom, int *quotient, int *rem) *rem = r; } - -/* - GreatestCommonDivisor -*/ int GreatestCommonDivisor (int i1, int i2) { @@ -621,17 +596,13 @@ GreatestCommonDivisor (int i1, int i2) } } - #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 Invert24To16 (fixed16_t val) { @@ -641,5 +612,4 @@ Invert24To16 (fixed16_t val) return (fixed16_t) (((double) 0x10000 * (double) 0x1000000 / (double) val) + 0.5); } - #endif diff --git a/libs/util/mdfour.c b/libs/util/mdfour.c index c50c092b7..07919f2fa 100644 --- a/libs/util/mdfour.c +++ b/libs/util/mdfour.c @@ -41,7 +41,6 @@ #include "QF/uint32.h" /* NOTE: This code makes no attempt to be fast! - 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 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) @@ -183,7 +183,6 @@ mdfour_begin (struct mdfour *md) md->totalN = 0; } - static void 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); } - void 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); } - void mdfour (unsigned char *out, const unsigned char *in, int n) { diff --git a/libs/util/msg.c b/libs/util/msg.c index 353e1c3a7..46dced74a 100644 --- a/libs/util/msg.c +++ b/libs/util/msg.c @@ -40,15 +40,14 @@ #include "QF/qendian.h" #include "QF/sys.h" + /* MESSAGE IO FUNCTIONS Handles byte ordering and avoids alignment errors */ -// // writing functions -// void MSG_WriteChar (sizebuf_t *sb, int c) @@ -113,7 +112,6 @@ MSG_WriteFloat (sizebuf_t *sb, float f) int l; } dat; - dat.f = f; dat.l = LittleLong (dat.l); @@ -148,9 +146,7 @@ MSG_WriteAngle16 (sizebuf_t *sb, float f) } -// // reading functions -// void MSG_BeginReading (msg_t *msg) diff --git a/libs/util/pcx.c b/libs/util/pcx.c index b46376c5a..4fbd80971 100644 --- a/libs/util/pcx.c +++ b/libs/util/pcx.c @@ -46,6 +46,7 @@ #include "compat.h" + tex_t * LoadPCX (VFile *f, int convert, byte *pal) { @@ -59,9 +60,7 @@ LoadPCX (VFile *f, int convert, byte *pal) int count; tex_t *tex; - // // parse the PCX file - // pcx_mark = Hunk_LowMark (); pcx = Hunk_AllocName (com_filesize, "PCX"); Qread (f, pcx, com_filesize); @@ -145,7 +144,6 @@ LoadPCX (VFile *f, int convert, byte *pal) return tex; } - pcx_t * EncodePCX (byte * data, int width, int height, int rowbytes, byte * palette, qboolean flip, int *length) diff --git a/libs/util/plugin.c b/libs/util/plugin.c index 4130056f4..58aaa8c17 100644 --- a/libs/util/plugin.c +++ b/libs/util/plugin.c @@ -29,19 +29,15 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif - #ifdef HAVE_STDIO_H # include #endif - #ifdef HAVE_STRING_H # include #endif - #ifdef HAVE_STRINGS_H # include #endif - #ifdef HAVE_WINDOWS_H # include #endif @@ -65,6 +61,7 @@ cvar_t *fs_pluginpath; + void PI_InitCvars (void) { @@ -117,7 +114,8 @@ PI_LoadPlugin (const char *type, const char *name) #if defined(HAVE_DLOPEN) 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; } #elif defined (_WIN32) @@ -128,13 +126,16 @@ PI_LoadPlugin (const char *type, const char *name) #endif #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); Con_Printf ("Plugin info function not found\n"); return NULL; } #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); Con_Printf ("Plugin info function not found\n"); return NULL; diff --git a/libs/util/qargs.c b/libs/util/qargs.c index 408cc92be..5b40f1c10 100644 --- a/libs/util/qargs.c +++ b/libs/util/qargs.c @@ -63,6 +63,7 @@ char *com_cmdline; qboolean nouse = false; // 1999-10-29 +USE fix by Maddes + /* COM_CheckParm @@ -85,9 +86,6 @@ COM_CheckParm (char *parm) return 0; } -/* - COM_InitArgv -*/ void COM_InitArgv (int argc, char **argv) { @@ -96,9 +94,8 @@ COM_InitArgv (int argc, char **argv) safe = false; - largv = - - (char **) calloc (1, (argc + NUM_SAFE_ARGVS + 1) * sizeof (char **)); + largv = (char **) calloc (1, (argc + NUM_SAFE_ARGVS + 1) * + sizeof (char **)); for (com_argc = 0, len = 0; com_argc < argc; com_argc++) { largv[com_argc] = argv[com_argc]; @@ -120,9 +117,8 @@ COM_InitArgv (int argc, char **argv) } if (safe) { - // force all the safe-mode switches. Note that we reserved extra - // space in - // case we need to add these, so we don't need an overflow check + // force all the safe-mode switches. Note that we reserved extra space + // in case we need to add these, so we don't need an overflow check for (i = 0; i < NUM_SAFE_ARGVS; i++) { largv[com_argc] = safeargvs[i]; com_argc++; @@ -132,11 +128,9 @@ COM_InitArgv (int argc, char **argv) largv[com_argc] = argvdummy; com_argv = largv; -// 1999-10-29 +USE fix by Maddes start if (COM_CheckParm ("-nouse")) { nouse = true; } -// 1999-10-29 +USE fix by Maddes end } /* diff --git a/libs/util/qendian.c b/libs/util/qendian.c index 21ced2ae4..cd983189d 100644 --- a/libs/util/qendian.c +++ b/libs/util/qendian.c @@ -60,6 +60,7 @@ float (*BigFloat) (float l) = FloatNoSwap; float (*LittleFloat) (float l) = FloatSwap; #endif + short ShortSwap (short l) { @@ -104,7 +105,6 @@ FloatSwap (float f) byte b[4]; } dat1 , dat2; - dat1.f = f; dat2.b[0] = dat1.b[3]; dat2.b[1] = dat1.b[2]; diff --git a/libs/util/qfplist.c b/libs/util/qfplist.c index 5907c5231..98906a6aa 100644 --- a/libs/util/qfplist.c +++ b/libs/util/qfplist.c @@ -44,6 +44,7 @@ static qboolean PL_SkipSpace (pldata_t *); static char *PL_ParseQuotedString (pldata_t *); static char *PL_ParseUnquotedString (pldata_t *); + void PL_FreeItem (plitem_t *item) { @@ -213,7 +214,6 @@ PL_ParseQuotedString (pldata_t *pl) if (pl->pos - start - shrink == 0) { str = ""; } else { - char chars[pl->pos - start - shrink]; unsigned int j; 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++; return str; @@ -303,7 +304,8 @@ PL_ParseUnquotedString (pldata_t *pl) break; 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; } @@ -316,154 +318,155 @@ PL_ParsePropertyListItem (pldata_t *pl) return NULL; switch (pl->ptr[pl->pos]) { - case '{': { - hashtab_t *dict = Hash_NewTable (1021, dict_get_key, dict_free, NULL); + case '{': + { + 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++; - while (PL_SkipSpace (pl) && pl->ptr[pl->pos] != '}') { - plitem_t *key; - plitem_t *value; + // If there is no value, lose the key + if (!(value = PL_ParsePropertyListItem (pl))) { + PL_FreeItem (key); + return NULL; + } - if (!(key = PL_ParsePropertyListItem (pl))) - return NULL; + if (!(PL_SkipSpace (pl))) { + PL_FreeItem (key); + PL_FreeItem (value); + 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; - } + if (pl->ptr[pl->pos] == ';') { pl->pos++; - - // If there is no value, lose the key - if (!(value = PL_ParsePropertyListItem (pl))) { - PL_FreeItem (key); - 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); + } else if (pl->ptr[pl->pos] != '}') { + pl->error = "Unexpected character (wanted ';' or '}')"; + PL_FreeItem (key); + PL_FreeItem (value); return NULL; } - pl->pos++; - item = calloc (1, sizeof (plitem_t)); - item->type = QFDictionary; - item->data = dict; - return item; - } + { // Add the key/value pair to the dictionary + dictkey_t *k = calloc (1, sizeof (dictkey_t)); - 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); + if (!k) { + 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 ')')"; - free (value); - return NULL; - } + k->key = (char *) key->data; + k->value = value; - if (a->numvals == MAX_ARRAY_INDEX) { - pl->error = "Unexpected character (too many items in array)"; - free (value); - return NULL; - } - a->values[a->numvals++] = value; + Hash_Add (dict, k); } - 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)"; + if (pl->pos >= pl->end) { // Catch the error + pl->error = "Unexpected end of string when parsing dictionary"; + Hash_DelTable (dict); 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: { - char *str = PL_ParseUnquotedString (pl); + item = calloc (1, sizeof (plitem_t)); + 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; - } 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 } diff --git a/libs/util/quakefs.c b/libs/util/quakefs.c index af92bd68d..37b232409 100644 --- a/libs/util/quakefs.c +++ b/libs/util/quakefs.c @@ -39,11 +39,11 @@ # include #endif +#include +#include +#include #include #include -#include -#include -#include #ifdef HAVE_FNMATCH_H # define model_t sunmodel_t @@ -62,7 +62,6 @@ #include #include "QF/cmd.h" -#include "compat.h" #include "QF/console.h" #include "QF/cvar.h" #include "QF/hash.h" @@ -70,16 +69,17 @@ #include "QF/qargs.h" #include "QF/qendian.h" #include "QF/qtypes.h" -#include "QF/vfs.h" #include "QF/sys.h" #include "QF/va.h" +#include "QF/vfs.h" #include "QF/zone.h" +#include "compat.h" + #ifndef HAVE_FNMATCH_PROTO int fnmatch (const char *__pattern, const char *__string, int __flags); #endif - /* 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 @@ -161,9 +161,7 @@ typedef struct searchpath_s { searchpath_t *com_searchpaths; searchpath_t *com_base_searchpaths; // without gamedirs -/* - COM_FileBase -*/ + void COM_FileBase (const char *in, char *out) { @@ -191,9 +189,7 @@ COM_FileBase (const char *in, char *out) } } -/* - COM_filelength -*/ + int COM_filelength (VFile *f) { @@ -208,9 +204,7 @@ COM_filelength (VFile *f) return end; } -/* - COM_FileOpenRead -*/ + int COM_FileOpenRead (char *path, VFile **hndl) { @@ -226,9 +220,7 @@ COM_FileOpenRead (char *path, VFile **hndl) return COM_filelength (f); } -/* - 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 { char **list; int count; @@ -329,6 +315,11 @@ maplist_print (struct maplist *maplist) } } +/* + COM_Maplist_f + + List map files in gamepaths. +*/ void COM_Maplist_f (void) { @@ -433,7 +424,6 @@ COM_WriteBuffers (const char *filename, int count, ...) va_end (args); } - /* COM_CreatePath @@ -456,7 +446,6 @@ COM_CreatePath (const char *path) } } - /* COM_CopyFile @@ -492,9 +481,6 @@ COM_CopyFile (char *netpath, char *cachepath) Qclose (out); } -/* - COM_OpenRead -*/ VFile * 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? 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+1] != '.') // second dot 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 0; @@ -589,15 +577,13 @@ _COM_FOpenFile (const char *filename, VFile **gzfile, char *foundname, int zip) 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)) { Con_Printf ("FindFile: %s: attempt to escape directory tree!\n", filename); 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) { // is the element a pak file? if (search->pack) { @@ -631,7 +617,8 @@ _COM_FOpenFile (const char *filename, VFile **gzfile, char *foundname, int zip) if (findtime == -1) { #ifdef HAVE_ZLIB 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); findtime = Sys_FileTime (netpath); if (findtime == -1) @@ -795,7 +782,6 @@ COM_LoadPackFile (char *packfile) Qseek (packhandle, header.dirofs, SEEK_SET); Qread (packhandle, info, header.dirlen); - // parse the directory for (i = 0; i < numpackfiles; i++) { strcpy (newfiles[i].name, info[i].name); @@ -819,7 +805,6 @@ COM_LoadPackFile (char *packfile) #define FNAME_SIZE MAX_OSPATH // Note, this is /NOT/ a work-alike strcmp, this groups numbers sanely. -//int qstrcmp(const char *val, const char *ref) int qstrcmp (char **os1, char **os2) { @@ -996,9 +981,7 @@ COM_Gamedir (const char *dir) return; // still the same strcpy (gamedirfile, dir); - // // free up any current game dir info - // while (com_searchpaths != com_base_searchpaths) { if (com_searchpaths->pack) { Qclose (com_searchpaths->pack->handle); @@ -1010,9 +993,7 @@ COM_Gamedir (const char *dir) com_searchpaths = next; } - // // flush all data, so it will be forced to reload - // Cache_Flush (); if (fs_skinbase && strcmp (dir, fs_skinbase->string) == 0) @@ -1021,9 +1002,6 @@ COM_Gamedir (const char *dir) COM_AddGameDirectory (dir); } -/* - COM_CreateGameDirectory -*/ void COM_CreateGameDirectory (const char *gamename) { @@ -1032,9 +1010,6 @@ COM_CreateGameDirectory (const char *gamename) COM_AddGameDirectory (gamename); } -/* - COM_InitFilesystem -*/ void COM_Filesystem_Init (void) { @@ -1081,16 +1056,14 @@ void COM_Filesystem_Init_Cvars (void) { 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, "location of your game directories"); fs_basegame = Cvar_Get ("fs_basegame", "id1", CVAR_ROM, NULL, "game to use by default"); } -/* - COM_SkipPath -*/ const char * COM_SkipPath (const char *pathname) { @@ -1105,9 +1078,6 @@ COM_SkipPath (const char *pathname) return last; } -/* - COM_StripExtension -*/ void COM_StripExtension (const char *in, char *out) { @@ -1116,9 +1086,6 @@ COM_StripExtension (const char *in, char *out) *out = 0; } -/* - COM_FileExtension -*/ char * COM_FileExtension (char *in) { @@ -1136,19 +1103,13 @@ COM_FileExtension (char *in) return exten; } - -/* - COM_DefaultExtension -*/ void COM_DefaultExtension (char *path, char *extension) { char *src; -// -// if path doesn't have a .EXT, append extension -// (extension should include the .) -// + // if path doesn't have a .EXT, append extension + // (extension should include the .) src = path + strlen (path) - 1; while (*src != '/' && src != path) { @@ -1160,9 +1121,6 @@ COM_DefaultExtension (char *path, char *extension) strncat (path, extension, MAX_OSPATH - strlen (path)); } -/* - COM_NextFileName -*/ int COM_NextFilename (char *filename, const char *prefix, const char *ext) { diff --git a/libs/util/quakeio.c b/libs/util/quakeio.c index 46dbf5eae..3685ebc2e 100644 --- a/libs/util/quakeio.c +++ b/libs/util/quakeio.c @@ -53,12 +53,12 @@ # define _POSIX_ #endif +#include #include #include -#include -#include "QF/vfs.h" #include "QF/vfile.h" +#include "QF/vfs.h" #ifdef WIN32 # ifndef __BORLANDC__ @@ -91,8 +91,7 @@ Qexpand_squiggle (const char *path, char *dest) #ifdef _WIN32 // LordHavoc: first check HOME to duplicate previous version behavior - // (also handy if someone wants it somewhere other than their - // windows directory) + // (also handy if someone wants it elsewhere than their windows directory) home = getenv ("HOME"); if (!home || !home[0]) home = getenv ("WINDIR"); @@ -105,8 +104,8 @@ Qexpand_squiggle (const char *path, char *dest) if (home) { strcpy (dest, home); - strncat (dest, path + 1, MAX_OSPATH - strlen (dest)); // skip - // leading ~ + strncat (dest, path + 1, MAX_OSPATH - strlen (dest)); + // skip leading ~ } else strcpy (dest, path); } @@ -372,11 +371,9 @@ Qeof (VFile *file) } /* - Qgetline Dynamic length version of Qgets. DO NOT free the buffer. - */ const char * Qgetline (VFile *file) diff --git a/libs/util/sys.c b/libs/util/sys.c index 6f4dd5e95..4c3b1e456 100644 --- a/libs/util/sys.c +++ b/libs/util/sys.c @@ -28,12 +28,6 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif -#include -#include -#include -#include -#include -#include #ifdef HAVE_STRING_H # include #endif @@ -56,10 +50,18 @@ # include #endif -#include "compat.h" +#include +#include +#include +#include +#include +#include + #include "QF/cvar.h" #include "QF/sys.h" +#include "compat.h" + static void Sys_StdPrintf (const char *fmt, va_list args); cvar_t *sys_nostdout; @@ -104,6 +106,7 @@ const char sys_char_map[256] = { #define MAXPRINTMSG 4096 + void Sys_mkdir (const char *path) { @@ -156,9 +159,6 @@ Sys_SetPrintf (sys_printf_t func) sys_printf_function = func; } -/* - Sys_Printf -*/ static void Sys_StdPrintf (const char *fmt, va_list args) { @@ -187,9 +187,6 @@ Sys_Printf (const char *fmt, ...) va_end (args); } -/* - Sys_DoubleTime -*/ double Sys_DoubleTime (void) { @@ -248,8 +245,8 @@ Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length) addr = (startaddr & ~(psize - 1)) - psize; -// fprintf(stderr, "writable code %lx(%lx)-%lx, length=%lx\n", startaddr, -// addr, startaddr+length, length); +// fprintf(stderr, "writable code %lx(%lx)-%lx, length=%lx\n", startaddr, +// addr, startaddr+length, length); r = mprotect ((char *) addr, length + startaddr - addr + psize, 7); diff --git a/libs/util/sys_error.c b/libs/util/sys_error.c index c4942546d..91ed1c9f4 100644 --- a/libs/util/sys_error.c +++ b/libs/util/sys_error.c @@ -28,11 +28,14 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif -#include + #include +#include + +#include "QF/sys.h" #include "compat.h" -#include "QF/sys.h" + void QFutil_Sys_Error (const char *error, ...) diff --git a/libs/util/tga.c b/libs/util/tga.c index 31748f58a..341aa0f5e 100644 --- a/libs/util/tga.c +++ b/libs/util/tga.c @@ -55,7 +55,6 @@ fgetLittleShort (VFile *f) return (short) (b1 + b2 * 256); } - /* static int fgetLittleLong (VFile *f) @@ -71,7 +70,6 @@ fgetLittleLong (VFile *f) } */ - byte * LoadTGA (VFile *fin) { @@ -102,8 +100,8 @@ LoadTGA (VFile *fin) if (targa_header.colormap_type != 0 || (targa_header.pixel_size != 32 && targa_header.pixel_size != 24)) - Sys_Error - ("Texture_LoadTGA: Only 32 or 24 bit images supported (no colormaps)\n"); + Sys_Error ("Texture_LoadTGA: Only 32 or 24 bit images supported " + "(no colormaps)\n"); columns = targa_header.width; rows = targa_header.height; @@ -227,7 +225,6 @@ LoadTGA (VFile *fin) return targa_rgba; } - void WriteTGAfile (const char *tganame, byte *data, int width, int height) { diff --git a/libs/util/va.c b/libs/util/va.c index 357af446a..8fa628711 100644 --- a/libs/util/va.c +++ b/libs/util/va.c @@ -30,13 +30,15 @@ # include "config.h" #endif -#include #include +#include -#include "compat.h" #include "QF/qtypes.h" #include "QF/va.h" +#include "compat.h" + + /* va diff --git a/libs/util/ver_check.c b/libs/util/ver_check.c index 2ea114b9e..53ea4e252 100644 --- a/libs/util/ver_check.c +++ b/libs/util/ver_check.c @@ -31,8 +31,9 @@ # include "config.h" #endif -#include #include +#include + /* ver_compare diff --git a/libs/util/wad.c b/libs/util/wad.c index a0a0fd6e9..e323c1225 100644 --- a/libs/util/wad.c +++ b/libs/util/wad.c @@ -77,7 +77,6 @@ W_CleanupName (const char *in, char *out) out[i] = 0; } - void W_LoadWadFile (const char *filename) { @@ -89,12 +88,13 @@ W_LoadWadFile (const char *filename) wad_base = COM_LoadHunkFile (filename); if (!wad_base) { - Sys_Printf ( -"\n The following error is somewhat misleading. Most likely you don't\n" -" have a file by that name on your system because it's stored in a pak\n" -" file. The real 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" -" subdirectory named %s.\n\n", fs_basegame->string); + Sys_Printf ("\n The following error is somewhat misleading. Most " + "likely you don't\n have a file by that name on your " + "system because it's stored in a pak\n file. The real " + "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 subdirectory named %s.\n\n", + fs_basegame->string); Sys_Printf (" fs_sharepath is %s\n", fs_sharepath->string); Sys_Printf (" fs_userpath is %s\n\n", fs_userpath->string); Sys_Error ("W_LoadWadFile: unable to load %s\n\n", filename); @@ -121,7 +121,6 @@ W_LoadWadFile (const char *filename) } } - lumpinfo_t * W_GetLumpinfo (const char *name) { @@ -140,7 +139,6 @@ W_GetLumpinfo (const char *name) return NULL; } - void * W_GetLumpName (const char *name) { @@ -151,7 +149,6 @@ W_GetLumpName (const char *name) return (void *) (wad_base + lump->filepos); } - void * W_GetLumpNum (int num) { @@ -165,12 +162,10 @@ W_GetLumpNum (int num) return (void *) (wad_base + lump->filepos); } - /* automatic byte swapping */ - void SwapPic (qpic_t *pic) { diff --git a/libs/util/zone.c b/libs/util/zone.c index b684351a6..b1df12354 100644 --- a/libs/util/zone.c +++ b/libs/util/zone.c @@ -53,7 +53,6 @@ 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. @@ -79,6 +78,7 @@ int hunk_tempmark; void R_FreeTextures (void); + /* Hunk_Check @@ -127,9 +127,7 @@ Hunk_Print (qboolean all) 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", @@ -137,15 +135,11 @@ Hunk_Print (qboolean all) 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) @@ -156,16 +150,12 @@ Hunk_Print (qboolean all) 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) @@ -182,9 +172,6 @@ Hunk_Print (qboolean all) } -/* - Hunk_AllocName -*/ void * 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); 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 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); #else 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); #endif @@ -225,9 +214,6 @@ Hunk_AllocName (int size, const char *name) return (void *) (h + 1); } -/* - Hunk_Alloc -*/ void * Hunk_Alloc (int size) { @@ -273,10 +259,6 @@ Hunk_FreeToHighMark (int mark) hunk_high_used = mark; } - -/* - Hunk_HighAllocName -*/ void * Hunk_HighAllocName (int size, const char *name) { @@ -312,7 +294,6 @@ Hunk_HighAllocName (int size, const char *name) return (void *) (h + 1); } - /* Hunk_TempAlloc @@ -355,15 +336,12 @@ 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 + // we are clearing up space at the bottom, so only allocate it late new = Cache_TryAlloc (c->size, true); if (new) { Con_DPrintf ("cache_move ok\n"); @@ -461,7 +439,7 @@ Cache_TryAlloc (int size, qboolean nobottom) { cache_system_t *cs, *new; -// is the cache completely empty? + // is the cache completely empty? if (!nobottom && cache_head.prev == &cache_head) { if (hunk_size - hunk_high_used - hunk_low_used < size) { @@ -479,7 +457,8 @@ Cache_TryAlloc (int size, qboolean nobottom) Cache_MakeLRU (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); cs = cache_head.next; @@ -506,7 +485,7 @@ Cache_TryAlloc (int size, qboolean nobottom) } 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) { memset (new, 0, sizeof (*new)); new->size = size; @@ -536,10 +515,6 @@ Cache_Flush (void) Cache_Free (cache_head.next->user); // reclaim the space } - -/* - Cache_Print -*/ void Cache_Print (void) { @@ -550,9 +525,6 @@ Cache_Print (void) } } -/* - Cache_Report -*/ void Cache_Report (void) { @@ -561,17 +533,11 @@ Cache_Report (void) hunk_low_used) / (float) (1024 * 1024)); } -/* - Cache_Compact -*/ void Cache_Compact (void) { } -/* - Cache_Init -*/ void Cache_Init (void) { @@ -605,11 +571,6 @@ Cache_Free (cache_user_t *c) Cache_UnlinkLRU (cs); } - - -/* - Cache_Check -*/ void * Cache_Check (cache_user_t *c) { @@ -620,17 +581,13 @@ Cache_Check (cache_user_t *c) cs = ((cache_system_t *) c->data) - 1; -// move to head of LRU + // 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, 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; -// find memory for it + // find memory for it while (1) { cs = Cache_TryAlloc (size, false); if (cs) { @@ -665,10 +622,6 @@ Cache_Alloc (cache_user_t *c, int size, const char *name) //============================================================================ - -/* - Memory_Init -*/ void Memory_Init (void *buf, int size) {