Zweite Stufe des Reformat

This commit is contained in:
Yamagi Burmeister 2010-08-31 08:20:43 +00:00
parent 0811be484c
commit b7e402c9a7
5 changed files with 1128 additions and 722 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,30 +1,33 @@
/* /*
Copyright (C) 1997-2001 Id Software, Inc. * Copyright (C) 1997-2001 Id Software, Inc.
*
This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or modify
modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
as published by the Free Software Foundation; either version 2 * the Free Software Foundation; either version 2 of the License, or (at
of the License, or (at your option) any later version. * your option) any later version.
*
This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful, but
but WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
See the GNU General Public License for more details. * See the GNU General Public License for more details.
*
You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/ *
/* crc.c */ * =======================================================================
*
* This is a 16 bit, non-reflected CRC using the polynomial 0x1021
* and the initial and final xor values shown below... In other words,
* the CCITT standard CRC used by XMODEM.
*
* =======================================================================
*/
#include "qcommon.h" #include "qcommon.h"
/* this is a 16 bit, non-reflected CRC using the polynomial 0x1021
and the initial and final xor values shown below... in other words, the
CCITT standard CRC used by XMODEM */
#define CRC_INIT_VALUE 0xffff #define CRC_INIT_VALUE 0xffff
#define CRC_XOR_VALUE 0x0000 #define CRC_XOR_VALUE 0x0000
@ -84,9 +87,9 @@ unsigned short CRC_Block (byte *start, int count)
unsigned short crc; unsigned short crc;
CRC_Init (&crc); CRC_Init (&crc);
while (count--) while (count--)
crc = (crc << 8) ^ crctable[(crc >> 8) ^ *start++]; crc = (crc << 8) ^ crctable[(crc >> 8) ^ *start++];
return crc; return crc;
} }

View File

@ -1,23 +1,28 @@
/* /*
Copyright (C) 1997-2001 Id Software, Inc. * Copyright (C) 1997-2001 Id Software, Inc.
*
This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or modify
modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
as published by the Free Software Foundation; either version 2 * the Free Software Foundation; either version 2 of the License, or (at
of the License, or (at your option) any later version. * your option) any later version.
*
This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful, but
but WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
See the GNU General Public License for more details. * See the GNU General Public License for more details.
*
You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/ *
/* crc.h */ * =======================================================================
*
* Corresponding header for crc.c
*
* =======================================================================
*/
void CRC_Init(unsigned short *crcvalue); void CRC_Init(unsigned short *crcvalue);
void CRC_ProcessByte(unsigned short *crcvalue, byte data); void CRC_ProcessByte(unsigned short *crcvalue, byte data);

View File

@ -1,23 +1,28 @@
/* /*
Copyright (C) 1997-2001 Id Software, Inc. * Copyright (C) 1997-2001 Id Software, Inc.
*
This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or modify
modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
as published by the Free Software Foundation; either version 2 * the Free Software Foundation; either version 2 of the License, or (at
of the License, or (at your option) any later version. * your option) any later version.
*
This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful, but
but WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
See the GNU General Public License for more details. * See the GNU General Public License for more details.
*
You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/ *
// cvar.c -- dynamic variable tracking * =======================================================================
*
* The Quake II CVAR subsystem. Implements dynamic variable tracking.
*
* =======================================================================
*/
#include "qcommon.h" #include "qcommon.h"
@ -27,17 +32,20 @@ static qboolean Cvar_InfoValidate (char *s)
{ {
if (strstr (s, "\\")) if (strstr (s, "\\"))
return false; return false;
if (strstr (s, "\"")) if (strstr (s, "\""))
return false; return false;
if (strstr (s, ";")) if (strstr (s, ";"))
return false; return false;
return true; return true;
} }
static cvar_t *Cvar_FindVar (const char *var_name) static cvar_t *Cvar_FindVar (const char *var_name)
{ {
cvar_t *var; cvar_t *var;
for (var=cvar_vars ; var ; var=var->next) for (var=cvar_vars ; var ; var=var->next)
if (!strcmp (var_name, var->name)) if (!strcmp (var_name, var->name))
return var; return var;
@ -48,20 +56,24 @@ static cvar_t *Cvar_FindVar (const char *var_name)
float Cvar_VariableValue (char *var_name) float Cvar_VariableValue (char *var_name)
{ {
cvar_t *var; cvar_t *var;
var = Cvar_FindVar (var_name); var = Cvar_FindVar (var_name);
if (!var) if (!var)
return 0; return 0;
return atof (var->string); return atof (var->string);
} }
const char *Cvar_VariableString (const char *var_name) const char *Cvar_VariableString (const char *var_name)
{ {
cvar_t *var; cvar_t *var;
var = Cvar_FindVar (var_name); var = Cvar_FindVar (var_name);
if (!var) if (!var)
return ""; return "";
return var->string; return var->string;
} }
@ -69,12 +81,12 @@ char *Cvar_CompleteVariable (char *partial)
{ {
cvar_t *cvar; cvar_t *cvar;
int len; int len;
len = (int)strlen(partial); len = (int)strlen(partial);
if (!len) if (!len)
return NULL; return NULL;
/* check exact match */ /* check exact match */
for (cvar=cvar_vars ; cvar ; cvar=cvar->next) for (cvar=cvar_vars ; cvar ; cvar=cvar->next)
if (!strcmp (partial,cvar->name)) if (!strcmp (partial,cvar->name))
@ -95,7 +107,7 @@ char *Cvar_CompleteVariable (char *partial)
cvar_t *Cvar_Get (char *var_name, char *var_value, int flags) cvar_t *Cvar_Get (char *var_name, char *var_value, int flags)
{ {
cvar_t *var; cvar_t *var;
if (flags & (CVAR_USERINFO | CVAR_SERVERINFO)) if (flags & (CVAR_USERINFO | CVAR_SERVERINFO))
{ {
if (!Cvar_InfoValidate (var_name)) if (!Cvar_InfoValidate (var_name))
@ -106,6 +118,7 @@ cvar_t *Cvar_Get (char *var_name, char *var_value, int flags)
} }
var = Cvar_FindVar (var_name); var = Cvar_FindVar (var_name);
if (var) if (var)
{ {
var->flags |= flags; var->flags |= flags;
@ -144,6 +157,7 @@ cvar_t *Cvar_Set2 (char *var_name, char *value, qboolean force)
cvar_t *var; cvar_t *var;
var = Cvar_FindVar (var_name); var = Cvar_FindVar (var_name);
if (!var) if (!var)
{ {
return Cvar_Get (var_name, value, 0); return Cvar_Get (var_name, value, 0);
@ -172,8 +186,10 @@ cvar_t *Cvar_Set2 (char *var_name, char *value, qboolean force)
{ {
if (strcmp(value, var->latched_string) == 0) if (strcmp(value, var->latched_string) == 0)
return var; return var;
Z_Free (var->latched_string); Z_Free (var->latched_string);
} }
else else
{ {
if (strcmp(value, var->string) == 0) if (strcmp(value, var->string) == 0)
@ -185,6 +201,7 @@ cvar_t *Cvar_Set2 (char *var_name, char *value, qboolean force)
Com_Printf ("%s will be changed for next game.\n", var_name); Com_Printf ("%s will be changed for next game.\n", var_name);
var->latched_string = CopyString(value); var->latched_string = CopyString(value);
} }
else else
{ {
var->string = CopyString(value); var->string = CopyString(value);
@ -196,9 +213,11 @@ cvar_t *Cvar_Set2 (char *var_name, char *value, qboolean force)
FS_ExecAutoexec (); FS_ExecAutoexec ();
} }
} }
return var; return var;
} }
} }
else else
{ {
if (var->latched_string) if (var->latched_string)
@ -214,10 +233,10 @@ cvar_t *Cvar_Set2 (char *var_name, char *value, qboolean force)
var->modified = true; var->modified = true;
if (var->flags & CVAR_USERINFO) if (var->flags & CVAR_USERINFO)
userinfo_modified = true; userinfo_modified = true;
Z_Free (var->string); Z_Free (var->string);
var->string = CopyString(value); var->string = CopyString(value);
var->value = atof (var->string); var->value = atof (var->string);
@ -237,10 +256,11 @@ cvar_t *Cvar_Set (char *var_name, char *value)
cvar_t *Cvar_FullSet (char *var_name, char *value, int flags) cvar_t *Cvar_FullSet (char *var_name, char *value, int flags)
{ {
cvar_t *var; cvar_t *var;
var = Cvar_FindVar (var_name); var = Cvar_FindVar (var_name);
if (!var) if (!var)
{ {
return Cvar_Get (var_name, value, flags); return Cvar_Get (var_name, value, flags);
} }
@ -248,9 +268,9 @@ cvar_t *Cvar_FullSet (char *var_name, char *value, int flags)
if (var->flags & CVAR_USERINFO) if (var->flags & CVAR_USERINFO)
userinfo_modified = true; userinfo_modified = true;
Z_Free (var->string); Z_Free (var->string);
var->string = CopyString(value); var->string = CopyString(value);
var->value = (float)atof (var->string); var->value = (float)atof (var->string);
@ -265,12 +285,13 @@ void Cvar_SetValue (char *var_name, float value)
if (value == (int)value) if (value == (int)value)
Com_sprintf (val, sizeof(val), "%i",(int)value); Com_sprintf (val, sizeof(val), "%i",(int)value);
else else
Com_sprintf (val, sizeof(val), "%f",value); Com_sprintf (val, sizeof(val), "%f",value);
Cvar_Set (var_name, val); Cvar_Set (var_name, val);
} }
/* /*
* Any variables with latched values will now be updated * Any variables with latched values will now be updated
*/ */
@ -282,11 +303,12 @@ void Cvar_GetLatchedVars (void)
{ {
if (!var->latched_string) if (!var->latched_string)
continue; continue;
Z_Free (var->string); Z_Free (var->string);
var->string = var->latched_string; var->string = var->latched_string;
var->latched_string = NULL; var->latched_string = NULL;
var->value = atof(var->string); var->value = atof(var->string);
if (!strcmp(var->name, "game")) if (!strcmp(var->name, "game"))
{ {
FS_SetGamedir (var->string); FS_SetGamedir (var->string);
@ -304,9 +326,10 @@ qboolean Cvar_Command (void)
/* check variables */ /* check variables */
v = Cvar_FindVar (Cmd_Argv(0)); v = Cvar_FindVar (Cmd_Argv(0));
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)
{ {
@ -327,6 +350,7 @@ void Cvar_Set_f (void)
int flags; int flags;
c = Cmd_Argc(); c = Cmd_Argc();
if (c != 3 && c != 4) if (c != 3 && c != 4)
{ {
Com_Printf ("usage: set <variable> <value> [u / s]\n"); Com_Printf ("usage: set <variable> <value> [u / s]\n");
@ -337,20 +361,23 @@ void Cvar_Set_f (void)
{ {
if (!strcmp(Cmd_Argv(3), "u")) if (!strcmp(Cmd_Argv(3), "u"))
flags = CVAR_USERINFO; flags = CVAR_USERINFO;
else if (!strcmp(Cmd_Argv(3), "s")) else if (!strcmp(Cmd_Argv(3), "s"))
flags = CVAR_SERVERINFO; flags = CVAR_SERVERINFO;
else else
{ {
Com_Printf ("flags can only be 'u' or 's'\n"); Com_Printf ("flags can only be 'u' or 's'\n");
return; return;
} }
Cvar_FullSet (Cmd_Argv(1), Cmd_Argv(2), flags); Cvar_FullSet (Cmd_Argv(1), Cmd_Argv(2), flags);
} }
else else
Cvar_Set (Cmd_Argv(1), Cmd_Argv(2)); Cvar_Set (Cmd_Argv(1), Cmd_Argv(2));
} }
/* /*
* Appends lines containing "set variable value" for all variables * Appends lines containing "set variable value" for all variables
* with the archive flag set to true. * with the archive flag set to true.
@ -362,6 +389,7 @@ void Cvar_WriteVariables (char *path)
FILE *f; FILE *f;
f = fopen (path, "a"); f = fopen (path, "a");
for (var = cvar_vars ; var ; var = var->next) for (var = cvar_vars ; var ; var = var->next)
{ {
if (var->flags & CVAR_ARCHIVE) if (var->flags & CVAR_ARCHIVE)
@ -370,6 +398,7 @@ void Cvar_WriteVariables (char *path)
fprintf (f, "%s", buffer); fprintf (f, "%s", buffer);
} }
} }
fclose (f); fclose (f);
} }
@ -379,34 +408,45 @@ void Cvar_List_f (void)
int i; int i;
i = 0; i = 0;
for (var = cvar_vars ; var ; var = var->next, i++) for (var = cvar_vars ; var ; var = var->next, i++)
{ {
if (var->flags & CVAR_ARCHIVE) if (var->flags & CVAR_ARCHIVE)
Com_Printf ("*"); Com_Printf ("*");
else else
Com_Printf (" "); Com_Printf (" ");
if (var->flags & CVAR_USERINFO) if (var->flags & CVAR_USERINFO)
Com_Printf ("U"); Com_Printf ("U");
else else
Com_Printf (" "); Com_Printf (" ");
if (var->flags & CVAR_SERVERINFO) if (var->flags & CVAR_SERVERINFO)
Com_Printf ("S"); Com_Printf ("S");
else else
Com_Printf (" "); Com_Printf (" ");
if (var->flags & CVAR_NOSET) if (var->flags & CVAR_NOSET)
Com_Printf ("-"); Com_Printf ("-");
else if (var->flags & CVAR_LATCH) else if (var->flags & CVAR_LATCH)
Com_Printf ("L"); Com_Printf ("L");
else else
Com_Printf (" "); Com_Printf (" ");
Com_Printf (" %s \"%s\"\n", var->name, var->string); Com_Printf (" %s \"%s\"\n", var->name, var->string);
} }
Com_Printf ("%i cvars\n", i); Com_Printf ("%i cvars\n", i);
} }
qboolean userinfo_modified; qboolean userinfo_modified;
char *Cvar_BitInfo (int bit) char *Cvar_BitInfo (int bit)
{ {
static char info[MAX_INFO_STRING]; static char info[MAX_INFO_STRING];
cvar_t *var; cvar_t *var;
@ -418,20 +458,21 @@ char *Cvar_BitInfo (int bit)
if (var->flags & bit) if (var->flags & bit)
Info_SetValueForKey (info, var->name, var->string); Info_SetValueForKey (info, var->name, var->string);
} }
return info; return info;
} }
/* /*
* returns an info string containing * returns an info string containing
* all the CVAR_USERINFO cvars * all the CVAR_USERINFO cvars
*/ */
char *Cvar_Userinfo (void) char *Cvar_Userinfo (void)
{ {
return Cvar_BitInfo (CVAR_USERINFO); return Cvar_BitInfo (CVAR_USERINFO);
} }
/* /*
* returns an info string containing * returns an info string containing
* all the CVAR_SERVERINFO cvars * all the CVAR_SERVERINFO cvars
*/ */
char *Cvar_Serverinfo (void) char *Cvar_Serverinfo (void)

File diff suppressed because it is too large Load Diff