mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-21 03:11:57 +00:00
Zweite Stufe des Reformat
This commit is contained in:
parent
0811be484c
commit
b7e402c9a7
5 changed files with 1128 additions and 722 deletions
File diff suppressed because it is too large
Load diff
|
@ -1,30 +1,33 @@
|
|||
/*
|
||||
Copyright (C) 1997-2001 Id Software, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
/* crc.c */
|
||||
* Copyright (C) 1997-2001 Id Software, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
* =======================================================================
|
||||
*
|
||||
* 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"
|
||||
|
||||
/* 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_XOR_VALUE 0x0000
|
||||
|
||||
|
@ -84,9 +87,9 @@ unsigned short CRC_Block (byte *start, int count)
|
|||
unsigned short crc;
|
||||
|
||||
CRC_Init (&crc);
|
||||
|
||||
while (count--)
|
||||
crc = (crc << 8) ^ crctable[(crc >> 8) ^ *start++];
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,23 +1,28 @@
|
|||
/*
|
||||
Copyright (C) 1997-2001 Id Software, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
/* crc.h */
|
||||
* Copyright (C) 1997-2001 Id Software, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
* =======================================================================
|
||||
*
|
||||
* Corresponding header for crc.c
|
||||
*
|
||||
* =======================================================================
|
||||
*/
|
||||
|
||||
void CRC_Init(unsigned short *crcvalue);
|
||||
void CRC_ProcessByte(unsigned short *crcvalue, byte data);
|
||||
|
|
|
@ -1,23 +1,28 @@
|
|||
/*
|
||||
Copyright (C) 1997-2001 Id Software, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
// cvar.c -- dynamic variable tracking
|
||||
* Copyright (C) 1997-2001 Id Software, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
* =======================================================================
|
||||
*
|
||||
* The Quake II CVAR subsystem. Implements dynamic variable tracking.
|
||||
*
|
||||
* =======================================================================
|
||||
*/
|
||||
|
||||
#include "qcommon.h"
|
||||
|
||||
|
@ -27,17 +32,20 @@ static qboolean Cvar_InfoValidate (char *s)
|
|||
{
|
||||
if (strstr (s, "\\"))
|
||||
return false;
|
||||
|
||||
if (strstr (s, "\""))
|
||||
return false;
|
||||
|
||||
if (strstr (s, ";"))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static cvar_t *Cvar_FindVar (const char *var_name)
|
||||
{
|
||||
cvar_t *var;
|
||||
|
||||
|
||||
for (var=cvar_vars ; var ; var=var->next)
|
||||
if (!strcmp (var_name, var->name))
|
||||
return var;
|
||||
|
@ -48,20 +56,24 @@ static cvar_t *Cvar_FindVar (const char *var_name)
|
|||
float Cvar_VariableValue (char *var_name)
|
||||
{
|
||||
cvar_t *var;
|
||||
|
||||
|
||||
var = Cvar_FindVar (var_name);
|
||||
|
||||
if (!var)
|
||||
return 0;
|
||||
|
||||
return atof (var->string);
|
||||
}
|
||||
|
||||
const char *Cvar_VariableString (const char *var_name)
|
||||
{
|
||||
cvar_t *var;
|
||||
|
||||
|
||||
var = Cvar_FindVar (var_name);
|
||||
|
||||
if (!var)
|
||||
return "";
|
||||
|
||||
return var->string;
|
||||
}
|
||||
|
||||
|
@ -69,12 +81,12 @@ char *Cvar_CompleteVariable (char *partial)
|
|||
{
|
||||
cvar_t *cvar;
|
||||
int len;
|
||||
|
||||
|
||||
len = (int)strlen(partial);
|
||||
|
||||
|
||||
if (!len)
|
||||
return NULL;
|
||||
|
||||
|
||||
/* check exact match */
|
||||
for (cvar=cvar_vars ; cvar ; cvar=cvar->next)
|
||||
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 *var;
|
||||
|
||||
|
||||
if (flags & (CVAR_USERINFO | CVAR_SERVERINFO))
|
||||
{
|
||||
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);
|
||||
|
||||
if (var)
|
||||
{
|
||||
var->flags |= flags;
|
||||
|
@ -144,6 +157,7 @@ cvar_t *Cvar_Set2 (char *var_name, char *value, qboolean force)
|
|||
cvar_t *var;
|
||||
|
||||
var = Cvar_FindVar (var_name);
|
||||
|
||||
if (!var)
|
||||
{
|
||||
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)
|
||||
return var;
|
||||
|
||||
Z_Free (var->latched_string);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
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);
|
||||
var->latched_string = CopyString(value);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
var->string = CopyString(value);
|
||||
|
@ -196,9 +213,11 @@ cvar_t *Cvar_Set2 (char *var_name, char *value, qboolean force)
|
|||
FS_ExecAutoexec ();
|
||||
}
|
||||
}
|
||||
|
||||
return var;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (var->latched_string)
|
||||
|
@ -214,10 +233,10 @@ cvar_t *Cvar_Set2 (char *var_name, char *value, qboolean force)
|
|||
var->modified = true;
|
||||
|
||||
if (var->flags & CVAR_USERINFO)
|
||||
userinfo_modified = true;
|
||||
|
||||
userinfo_modified = true;
|
||||
|
||||
Z_Free (var->string);
|
||||
|
||||
|
||||
var->string = CopyString(value);
|
||||
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 *var;
|
||||
|
||||
|
||||
var = Cvar_FindVar (var_name);
|
||||
|
||||
if (!var)
|
||||
{
|
||||
{
|
||||
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)
|
||||
userinfo_modified = true;
|
||||
|
||||
|
||||
Z_Free (var->string);
|
||||
|
||||
|
||||
var->string = CopyString(value);
|
||||
var->value = (float)atof (var->string);
|
||||
|
||||
|
@ -265,12 +285,13 @@ void Cvar_SetValue (char *var_name, float value)
|
|||
|
||||
if (value == (int)value)
|
||||
Com_sprintf (val, sizeof(val), "%i",(int)value);
|
||||
|
||||
else
|
||||
Com_sprintf (val, sizeof(val), "%f",value);
|
||||
|
||||
Cvar_Set (var_name, val);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Any variables with latched values will now be updated
|
||||
*/
|
||||
|
@ -282,11 +303,12 @@ void Cvar_GetLatchedVars (void)
|
|||
{
|
||||
if (!var->latched_string)
|
||||
continue;
|
||||
|
||||
Z_Free (var->string);
|
||||
var->string = var->latched_string;
|
||||
var->latched_string = NULL;
|
||||
var->value = atof(var->string);
|
||||
|
||||
|
||||
if (!strcmp(var->name, "game"))
|
||||
{
|
||||
FS_SetGamedir (var->string);
|
||||
|
@ -304,9 +326,10 @@ qboolean Cvar_Command (void)
|
|||
|
||||
/* check variables */
|
||||
v = Cvar_FindVar (Cmd_Argv(0));
|
||||
|
||||
if (!v)
|
||||
return false;
|
||||
|
||||
|
||||
/* perform a variable print or set */
|
||||
if (Cmd_Argc() == 1)
|
||||
{
|
||||
|
@ -327,6 +350,7 @@ void Cvar_Set_f (void)
|
|||
int flags;
|
||||
|
||||
c = Cmd_Argc();
|
||||
|
||||
if (c != 3 && c != 4)
|
||||
{
|
||||
Com_Printf ("usage: set <variable> <value> [u / s]\n");
|
||||
|
@ -337,20 +361,23 @@ void Cvar_Set_f (void)
|
|||
{
|
||||
if (!strcmp(Cmd_Argv(3), "u"))
|
||||
flags = CVAR_USERINFO;
|
||||
|
||||
else if (!strcmp(Cmd_Argv(3), "s"))
|
||||
flags = CVAR_SERVERINFO;
|
||||
|
||||
else
|
||||
{
|
||||
Com_Printf ("flags can only be 'u' or 's'\n");
|
||||
return;
|
||||
}
|
||||
|
||||
Cvar_FullSet (Cmd_Argv(1), Cmd_Argv(2), flags);
|
||||
}
|
||||
|
||||
else
|
||||
Cvar_Set (Cmd_Argv(1), Cmd_Argv(2));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Appends lines containing "set variable value" for all variables
|
||||
* with the archive flag set to true.
|
||||
|
@ -362,6 +389,7 @@ void Cvar_WriteVariables (char *path)
|
|||
FILE *f;
|
||||
|
||||
f = fopen (path, "a");
|
||||
|
||||
for (var = cvar_vars ; var ; var = var->next)
|
||||
{
|
||||
if (var->flags & CVAR_ARCHIVE)
|
||||
|
@ -370,6 +398,7 @@ void Cvar_WriteVariables (char *path)
|
|||
fprintf (f, "%s", buffer);
|
||||
}
|
||||
}
|
||||
|
||||
fclose (f);
|
||||
}
|
||||
|
||||
|
@ -379,34 +408,45 @@ void Cvar_List_f (void)
|
|||
int i;
|
||||
|
||||
i = 0;
|
||||
|
||||
for (var = cvar_vars ; var ; var = var->next, i++)
|
||||
{
|
||||
if (var->flags & CVAR_ARCHIVE)
|
||||
Com_Printf ("*");
|
||||
|
||||
else
|
||||
Com_Printf (" ");
|
||||
|
||||
if (var->flags & CVAR_USERINFO)
|
||||
Com_Printf ("U");
|
||||
|
||||
else
|
||||
Com_Printf (" ");
|
||||
|
||||
if (var->flags & CVAR_SERVERINFO)
|
||||
Com_Printf ("S");
|
||||
|
||||
else
|
||||
Com_Printf (" ");
|
||||
|
||||
if (var->flags & CVAR_NOSET)
|
||||
Com_Printf ("-");
|
||||
|
||||
else if (var->flags & CVAR_LATCH)
|
||||
Com_Printf ("L");
|
||||
|
||||
else
|
||||
Com_Printf (" ");
|
||||
|
||||
Com_Printf (" %s \"%s\"\n", var->name, var->string);
|
||||
}
|
||||
|
||||
Com_Printf ("%i cvars\n", i);
|
||||
}
|
||||
|
||||
qboolean userinfo_modified;
|
||||
|
||||
char *Cvar_BitInfo (int bit)
|
||||
char *Cvar_BitInfo (int bit)
|
||||
{
|
||||
static char info[MAX_INFO_STRING];
|
||||
cvar_t *var;
|
||||
|
@ -418,20 +458,21 @@ char *Cvar_BitInfo (int bit)
|
|||
if (var->flags & bit)
|
||||
Info_SetValueForKey (info, var->name, var->string);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
/*
|
||||
* returns an info string containing
|
||||
/*
|
||||
* returns an info string containing
|
||||
* all the CVAR_USERINFO cvars
|
||||
*/
|
||||
char *Cvar_Userinfo (void)
|
||||
char *Cvar_Userinfo (void)
|
||||
{
|
||||
return Cvar_BitInfo (CVAR_USERINFO);
|
||||
}
|
||||
|
||||
/*
|
||||
* returns an info string containing
|
||||
/*
|
||||
* returns an info string containing
|
||||
* all the CVAR_SERVERINFO cvars
|
||||
*/
|
||||
char *Cvar_Serverinfo (void)
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue