mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
Zweite Stufe des Reformat
This commit is contained in:
parent
0811be484c
commit
b7e402c9a7
5 changed files with 1128 additions and 722 deletions
|
@ -29,7 +29,6 @@ char *com_argv[MAX_NUM_ARGVS+1];
|
|||
int realtime;
|
||||
jmp_buf abortframe; /* an ERR_DROP occured, exit the entire frame */
|
||||
|
||||
|
||||
FILE *log_stats_file;
|
||||
|
||||
cvar_t *host_speeds;
|
||||
|
@ -71,6 +70,7 @@ void Com_BeginRedirect (int target, char *buffer, int buffersize, void (*flush))
|
|||
{
|
||||
if (!target || !buffer || !buffersize || !flush)
|
||||
return;
|
||||
|
||||
rd_target = target;
|
||||
rd_buffer = buffer;
|
||||
rd_buffersize = buffersize;
|
||||
|
@ -109,6 +109,7 @@ void Com_Printf (char *fmt, ...)
|
|||
rd_flush(rd_target, rd_buffer);
|
||||
*rd_buffer = 0;
|
||||
}
|
||||
|
||||
strcat (rd_buffer, msg);
|
||||
return;
|
||||
}
|
||||
|
@ -128,13 +129,17 @@ void Com_Printf (char *fmt, ...)
|
|||
if (!logfile)
|
||||
{
|
||||
Com_sprintf (name, sizeof(name), "%s/qconsole.log", FS_Gamedir ());
|
||||
|
||||
if (logfile_active->value > 2)
|
||||
logfile = fopen (name, "a");
|
||||
|
||||
else
|
||||
logfile = fopen (name, "w");
|
||||
}
|
||||
|
||||
if (logfile)
|
||||
fprintf (logfile, "%s", msg);
|
||||
|
||||
if (logfile_active->value > 1)
|
||||
fflush (logfile); /* force it to save every time */
|
||||
}
|
||||
|
@ -189,6 +194,7 @@ void Com_Error (int code, char *fmt, ...)
|
|||
|
||||
if (recursive)
|
||||
Sys_Error ("recursive error after: %s", msg);
|
||||
|
||||
recursive = true;
|
||||
|
||||
va_start (argptr,fmt);
|
||||
|
@ -203,6 +209,7 @@ void Com_Error (int code, char *fmt, ...)
|
|||
recursive = false;
|
||||
longjmp (abortframe, -1);
|
||||
}
|
||||
|
||||
else if (code == ERR_DROP)
|
||||
{
|
||||
Com_Printf ("********************\nERROR: %s\n********************\n", msg);
|
||||
|
@ -213,6 +220,7 @@ void Com_Error (int code, char *fmt, ...)
|
|||
recursive = false;
|
||||
longjmp (abortframe, -1);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
SV_Shutdown (va("Server fatal crashed: %s\n", msg), false);
|
||||
|
@ -241,6 +249,7 @@ void Com_Quit (void)
|
|||
#ifndef DEDICATED_ONLY
|
||||
CL_Shutdown ();
|
||||
#endif
|
||||
|
||||
if (logfile)
|
||||
{
|
||||
fclose (logfile);
|
||||
|
@ -491,6 +500,7 @@ void MSG_WriteString (sizebuf_t *sb, char *s)
|
|||
{
|
||||
if (!s)
|
||||
SZ_Write (sb, "", 1);
|
||||
|
||||
else
|
||||
SZ_Write (sb, s, (int)strlen(s)+1);
|
||||
}
|
||||
|
@ -517,27 +527,34 @@ void MSG_WriteAngle16 (sizebuf_t *sb, float f)
|
|||
MSG_WriteShort (sb, ANGLE2SHORT(f));
|
||||
}
|
||||
|
||||
|
||||
void MSG_WriteDeltaUsercmd (sizebuf_t *buf, usercmd_t *from, usercmd_t *cmd)
|
||||
{
|
||||
int bits;
|
||||
|
||||
/* Movement messages */
|
||||
bits = 0;
|
||||
|
||||
if (cmd->angles[0] != from->angles[0])
|
||||
bits |= CM_ANGLE1;
|
||||
|
||||
if (cmd->angles[1] != from->angles[1])
|
||||
bits |= CM_ANGLE2;
|
||||
|
||||
if (cmd->angles[2] != from->angles[2])
|
||||
bits |= CM_ANGLE3;
|
||||
|
||||
if (cmd->forwardmove != from->forwardmove)
|
||||
bits |= CM_FORWARD;
|
||||
|
||||
if (cmd->sidemove != from->sidemove)
|
||||
bits |= CM_SIDE;
|
||||
|
||||
if (cmd->upmove != from->upmove)
|
||||
bits |= CM_UP;
|
||||
|
||||
if (cmd->buttons != from->buttons)
|
||||
bits |= CM_BUTTONS;
|
||||
|
||||
if (cmd->impulse != from->impulse)
|
||||
bits |= CM_IMPULSE;
|
||||
|
||||
|
@ -545,20 +562,25 @@ void MSG_WriteDeltaUsercmd (sizebuf_t *buf, usercmd_t *from, usercmd_t *cmd)
|
|||
|
||||
if (bits & CM_ANGLE1)
|
||||
MSG_WriteShort (buf, cmd->angles[0]);
|
||||
|
||||
if (bits & CM_ANGLE2)
|
||||
MSG_WriteShort (buf, cmd->angles[1]);
|
||||
|
||||
if (bits & CM_ANGLE3)
|
||||
MSG_WriteShort (buf, cmd->angles[2]);
|
||||
|
||||
if (bits & CM_FORWARD)
|
||||
MSG_WriteShort (buf, cmd->forwardmove);
|
||||
|
||||
if (bits & CM_SIDE)
|
||||
MSG_WriteShort (buf, cmd->sidemove);
|
||||
|
||||
if (bits & CM_UP)
|
||||
MSG_WriteShort (buf, cmd->upmove);
|
||||
|
||||
if (bits & CM_BUTTONS)
|
||||
MSG_WriteByte (buf, cmd->buttons);
|
||||
|
||||
if (bits & CM_IMPULSE)
|
||||
MSG_WriteByte (buf, cmd->impulse);
|
||||
|
||||
|
@ -579,15 +601,18 @@ void MSG_WriteDir (sizebuf_t *sb, vec3_t dir)
|
|||
|
||||
bestd = 0;
|
||||
best = 0;
|
||||
|
||||
for (i=0 ; i<NUMVERTEXNORMALS ; i++)
|
||||
{
|
||||
d = DotProduct (dir, bytedirs[i]);
|
||||
|
||||
if (d > bestd)
|
||||
{
|
||||
bestd = d;
|
||||
best = i;
|
||||
}
|
||||
}
|
||||
|
||||
MSG_WriteByte (sb, best);
|
||||
}
|
||||
|
||||
|
@ -596,12 +621,13 @@ void MSG_ReadDir (sizebuf_t *sb, vec3_t dir)
|
|||
int b;
|
||||
|
||||
b = MSG_ReadByte (sb);
|
||||
|
||||
if (b >= NUMVERTEXNORMALS)
|
||||
Com_Error (ERR_DROP, "MSF_ReadDir: out of range");
|
||||
|
||||
VectorCopy (bytedirs[b], dir);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Writes part of a packetentities message.
|
||||
* Can delta from either a baseline or a previous packet_entity
|
||||
|
@ -612,6 +638,7 @@ void MSG_WriteDeltaEntity (entity_state_t *from, entity_state_t *to, sizebuf_t *
|
|||
|
||||
if (!to->number)
|
||||
Com_Error (ERR_FATAL, "Unset entity number");
|
||||
|
||||
if (to->number >= MAX_EDICTS)
|
||||
Com_Error (ERR_FATAL, "Entity number >= MAX_EDICTS");
|
||||
|
||||
|
@ -623,15 +650,19 @@ void MSG_WriteDeltaEntity (entity_state_t *from, entity_state_t *to, sizebuf_t *
|
|||
|
||||
if (to->origin[0] != from->origin[0])
|
||||
bits |= U_ORIGIN1;
|
||||
|
||||
if (to->origin[1] != from->origin[1])
|
||||
bits |= U_ORIGIN2;
|
||||
|
||||
if (to->origin[2] != from->origin[2])
|
||||
bits |= U_ORIGIN3;
|
||||
|
||||
if ( to->angles[0] != from->angles[0] )
|
||||
bits |= U_ANGLE1;
|
||||
|
||||
if ( to->angles[1] != from->angles[1] )
|
||||
bits |= U_ANGLE2;
|
||||
|
||||
if ( to->angles[2] != from->angles[2] )
|
||||
bits |= U_ANGLE3;
|
||||
|
||||
|
@ -639,8 +670,10 @@ void MSG_WriteDeltaEntity (entity_state_t *from, entity_state_t *to, sizebuf_t *
|
|||
{
|
||||
if ((unsigned)to->skinnum < 256)
|
||||
bits |= U_SKIN8;
|
||||
|
||||
else if ((unsigned)to->skinnum < 0x10000)
|
||||
bits |= U_SKIN16;
|
||||
|
||||
else
|
||||
bits |= (U_SKIN8|U_SKIN16);
|
||||
}
|
||||
|
@ -649,6 +682,7 @@ void MSG_WriteDeltaEntity (entity_state_t *from, entity_state_t *to, sizebuf_t *
|
|||
{
|
||||
if (to->frame < 256)
|
||||
bits |= U_FRAME8;
|
||||
|
||||
else
|
||||
bits |= U_FRAME16;
|
||||
}
|
||||
|
@ -657,8 +691,10 @@ void MSG_WriteDeltaEntity (entity_state_t *from, entity_state_t *to, sizebuf_t *
|
|||
{
|
||||
if (to->effects < 256)
|
||||
bits |= U_EFFECTS8;
|
||||
|
||||
else if (to->effects < 0x8000)
|
||||
bits |= U_EFFECTS16;
|
||||
|
||||
else
|
||||
bits |= U_EFFECTS8|U_EFFECTS16;
|
||||
}
|
||||
|
@ -667,8 +703,10 @@ void MSG_WriteDeltaEntity (entity_state_t *from, entity_state_t *to, sizebuf_t *
|
|||
{
|
||||
if (to->renderfx < 256)
|
||||
bits |= U_RENDERFX8;
|
||||
|
||||
else if (to->renderfx < 0x8000)
|
||||
bits |= U_RENDERFX16;
|
||||
|
||||
else
|
||||
bits |= U_RENDERFX8|U_RENDERFX16;
|
||||
}
|
||||
|
@ -682,10 +720,13 @@ void MSG_WriteDeltaEntity (entity_state_t *from, entity_state_t *to, sizebuf_t *
|
|||
|
||||
if ( to->modelindex != from->modelindex )
|
||||
bits |= U_MODEL;
|
||||
|
||||
if ( to->modelindex2 != from->modelindex2 )
|
||||
bits |= U_MODEL2;
|
||||
|
||||
if ( to->modelindex3 != from->modelindex3 )
|
||||
bits |= U_MODEL3;
|
||||
|
||||
if ( to->modelindex4 != from->modelindex4 )
|
||||
bits |= U_MODEL4;
|
||||
|
||||
|
@ -701,8 +742,10 @@ void MSG_WriteDeltaEntity (entity_state_t *from, entity_state_t *to, sizebuf_t *
|
|||
|
||||
if (bits & 0xff000000)
|
||||
bits |= U_MOREBITS3 | U_MOREBITS2 | U_MOREBITS1;
|
||||
|
||||
else if (bits & 0x00ff0000)
|
||||
bits |= U_MOREBITS2 | U_MOREBITS1;
|
||||
|
||||
else if (bits & 0x0000ff00)
|
||||
bits |= U_MOREBITS1;
|
||||
|
||||
|
@ -714,11 +757,13 @@ void MSG_WriteDeltaEntity (entity_state_t *from, entity_state_t *to, sizebuf_t *
|
|||
MSG_WriteByte (msg, (bits>>16)&255 );
|
||||
MSG_WriteByte (msg, (bits>>24)&255 );
|
||||
}
|
||||
|
||||
else if (bits & 0x00ff0000)
|
||||
{
|
||||
MSG_WriteByte (msg, (bits>>8)&255 );
|
||||
MSG_WriteByte (msg, (bits>>16)&255 );
|
||||
}
|
||||
|
||||
else if (bits & 0x0000ff00)
|
||||
{
|
||||
MSG_WriteByte (msg, (bits>>8)&255 );
|
||||
|
@ -726,55 +771,70 @@ void MSG_WriteDeltaEntity (entity_state_t *from, entity_state_t *to, sizebuf_t *
|
|||
|
||||
if (bits & U_NUMBER16)
|
||||
MSG_WriteShort (msg, to->number);
|
||||
|
||||
else
|
||||
MSG_WriteByte (msg, to->number);
|
||||
|
||||
if (bits & U_MODEL)
|
||||
MSG_WriteByte (msg, to->modelindex);
|
||||
|
||||
if (bits & U_MODEL2)
|
||||
MSG_WriteByte (msg, to->modelindex2);
|
||||
|
||||
if (bits & U_MODEL3)
|
||||
MSG_WriteByte (msg, to->modelindex3);
|
||||
|
||||
if (bits & U_MODEL4)
|
||||
MSG_WriteByte (msg, to->modelindex4);
|
||||
|
||||
if (bits & U_FRAME8)
|
||||
MSG_WriteByte (msg, to->frame);
|
||||
|
||||
if (bits & U_FRAME16)
|
||||
MSG_WriteShort (msg, to->frame);
|
||||
|
||||
if ((bits & U_SKIN8) && (bits & U_SKIN16)) /*used for laser colors */
|
||||
MSG_WriteLong (msg, to->skinnum);
|
||||
|
||||
else if (bits & U_SKIN8)
|
||||
MSG_WriteByte (msg, to->skinnum);
|
||||
|
||||
else if (bits & U_SKIN16)
|
||||
MSG_WriteShort (msg, to->skinnum);
|
||||
|
||||
if ( (bits & (U_EFFECTS8|U_EFFECTS16)) == (U_EFFECTS8|U_EFFECTS16) )
|
||||
MSG_WriteLong (msg, to->effects);
|
||||
|
||||
else if (bits & U_EFFECTS8)
|
||||
MSG_WriteByte (msg, to->effects);
|
||||
|
||||
else if (bits & U_EFFECTS16)
|
||||
MSG_WriteShort (msg, to->effects);
|
||||
|
||||
if ( (bits & (U_RENDERFX8|U_RENDERFX16)) == (U_RENDERFX8|U_RENDERFX16) )
|
||||
MSG_WriteLong (msg, to->renderfx);
|
||||
|
||||
else if (bits & U_RENDERFX8)
|
||||
MSG_WriteByte (msg, to->renderfx);
|
||||
|
||||
else if (bits & U_RENDERFX16)
|
||||
MSG_WriteShort (msg, to->renderfx);
|
||||
|
||||
if (bits & U_ORIGIN1)
|
||||
MSG_WriteCoord (msg, to->origin[0]);
|
||||
|
||||
if (bits & U_ORIGIN2)
|
||||
MSG_WriteCoord (msg, to->origin[1]);
|
||||
|
||||
if (bits & U_ORIGIN3)
|
||||
MSG_WriteCoord (msg, to->origin[2]);
|
||||
|
||||
if (bits & U_ANGLE1)
|
||||
MSG_WriteAngle(msg, to->angles[0]);
|
||||
|
||||
if (bits & U_ANGLE2)
|
||||
MSG_WriteAngle(msg, to->angles[1]);
|
||||
|
||||
if (bits & U_ANGLE3)
|
||||
MSG_WriteAngle(msg, to->angles[2]);
|
||||
|
||||
|
@ -787,8 +847,10 @@ void MSG_WriteDeltaEntity (entity_state_t *from, entity_state_t *to, sizebuf_t *
|
|||
|
||||
if (bits & U_SOUND)
|
||||
MSG_WriteByte (msg, to->sound);
|
||||
|
||||
if (bits & U_EVENT)
|
||||
MSG_WriteByte (msg, to->event);
|
||||
|
||||
if (bits & U_SOLID)
|
||||
MSG_WriteShort (msg, to->solid);
|
||||
}
|
||||
|
@ -810,8 +872,10 @@ int MSG_ReadChar (sizebuf_t *msg_read)
|
|||
|
||||
if (msg_read->readcount+1 > msg_read->cursize)
|
||||
c = -1;
|
||||
|
||||
else
|
||||
c = (signed char)msg_read->data[msg_read->readcount];
|
||||
|
||||
msg_read->readcount++;
|
||||
|
||||
return c;
|
||||
|
@ -823,8 +887,10 @@ int MSG_ReadByte (sizebuf_t *msg_read)
|
|||
|
||||
if (msg_read->readcount+1 > msg_read->cursize)
|
||||
c = -1;
|
||||
|
||||
else
|
||||
c = (unsigned char)msg_read->data[msg_read->readcount];
|
||||
|
||||
msg_read->readcount++;
|
||||
|
||||
return c;
|
||||
|
@ -836,6 +902,7 @@ int MSG_ReadShort (sizebuf_t *msg_read)
|
|||
|
||||
if (msg_read->readcount+2 > msg_read->cursize)
|
||||
c = -1;
|
||||
|
||||
else
|
||||
c = (short)(msg_read->data[msg_read->readcount]
|
||||
+ (msg_read->data[msg_read->readcount+1]<<8));
|
||||
|
@ -851,6 +918,7 @@ int MSG_ReadLong (sizebuf_t *msg_read)
|
|||
|
||||
if (msg_read->readcount+4 > msg_read->cursize)
|
||||
c = -1;
|
||||
|
||||
else
|
||||
c = msg_read->data[msg_read->readcount]
|
||||
+ (msg_read->data[msg_read->readcount+1]<<8)
|
||||
|
@ -873,6 +941,7 @@ float MSG_ReadFloat (sizebuf_t *msg_read)
|
|||
|
||||
if (msg_read->readcount+4 > msg_read->cursize)
|
||||
dat.f = -1;
|
||||
|
||||
else
|
||||
{
|
||||
dat.b[0] = msg_read->data[msg_read->readcount];
|
||||
|
@ -880,6 +949,7 @@ float MSG_ReadFloat (sizebuf_t *msg_read)
|
|||
dat.b[2] = msg_read->data[msg_read->readcount+2];
|
||||
dat.b[3] = msg_read->data[msg_read->readcount+3];
|
||||
}
|
||||
|
||||
msg_read->readcount += 4;
|
||||
|
||||
dat.l = LittleLong (dat.l);
|
||||
|
@ -893,14 +963,18 @@ char *MSG_ReadString (sizebuf_t *msg_read)
|
|||
int l,c;
|
||||
|
||||
l = 0;
|
||||
|
||||
do
|
||||
{
|
||||
c = MSG_ReadChar (msg_read);
|
||||
|
||||
if (c == -1 || c == 0)
|
||||
break;
|
||||
|
||||
string[l] = c;
|
||||
l++;
|
||||
} while (l < sizeof(string)-1);
|
||||
}
|
||||
while (l < sizeof(string)-1);
|
||||
|
||||
string[l] = 0;
|
||||
|
||||
|
@ -913,14 +987,18 @@ char *MSG_ReadStringLine (sizebuf_t *msg_read)
|
|||
int l,c;
|
||||
|
||||
l = 0;
|
||||
|
||||
do
|
||||
{
|
||||
c = MSG_ReadChar (msg_read);
|
||||
|
||||
if (c == -1 || c == 0 || c == '\n')
|
||||
break;
|
||||
|
||||
string[l] = c;
|
||||
l++;
|
||||
} while (l < sizeof(string)-1);
|
||||
}
|
||||
while (l < sizeof(string)-1);
|
||||
|
||||
string[l] = 0;
|
||||
|
||||
|
@ -960,16 +1038,20 @@ void MSG_ReadDeltaUsercmd (sizebuf_t *msg_read, usercmd_t *from, usercmd_t *move
|
|||
/* read current angles */
|
||||
if (bits & CM_ANGLE1)
|
||||
move->angles[0] = MSG_ReadShort (msg_read);
|
||||
|
||||
if (bits & CM_ANGLE2)
|
||||
move->angles[1] = MSG_ReadShort (msg_read);
|
||||
|
||||
if (bits & CM_ANGLE3)
|
||||
move->angles[2] = MSG_ReadShort (msg_read);
|
||||
|
||||
/* read movement */
|
||||
if (bits & CM_FORWARD)
|
||||
move->forwardmove = MSG_ReadShort (msg_read);
|
||||
|
||||
if (bits & CM_SIDE)
|
||||
move->sidemove = MSG_ReadShort (msg_read);
|
||||
|
||||
if (bits & CM_UP)
|
||||
move->upmove = MSG_ReadShort (msg_read);
|
||||
|
||||
|
@ -1049,9 +1131,11 @@ void SZ_Print (sizebuf_t *buf, char *data)
|
|||
{
|
||||
if (buf->data[buf->cursize-1])
|
||||
memcpy ((byte *)SZ_GetSpace(buf, len),data,len); /* no trailing 0 */
|
||||
|
||||
else
|
||||
memcpy ((byte *)SZ_GetSpace(buf, len-1)-1,data,len); /* write over trailing 0 */
|
||||
}
|
||||
|
||||
else
|
||||
memcpy ((byte *)SZ_GetSpace(buf, len),data,len);
|
||||
}
|
||||
|
@ -1086,6 +1170,7 @@ char *COM_Argv (int arg)
|
|||
{
|
||||
if (arg < 0 || arg >= com_argc || !com_argv[arg])
|
||||
return "";
|
||||
|
||||
return com_argv[arg];
|
||||
}
|
||||
|
||||
|
@ -1093,6 +1178,7 @@ void COM_ClearArgv (int arg)
|
|||
{
|
||||
if (arg < 0 || arg >= com_argc || !com_argv[arg])
|
||||
return;
|
||||
|
||||
com_argv[arg] = "";
|
||||
}
|
||||
|
||||
|
@ -1102,11 +1188,14 @@ void COM_InitArgv (int argc, char **argv)
|
|||
|
||||
if (argc > MAX_NUM_ARGVS)
|
||||
Com_Error (ERR_FATAL, "argc > MAX_NUM_ARGVS");
|
||||
|
||||
com_argc = argc;
|
||||
|
||||
for (i=0 ; i<argc ; i++)
|
||||
{
|
||||
if (!argv[i] || strlen(argv[i]) >= MAX_TOKEN_CHARS )
|
||||
com_argv[i] = "";
|
||||
|
||||
else
|
||||
com_argv[i] = argv[i];
|
||||
}
|
||||
|
@ -1119,6 +1208,7 @@ void COM_AddParm (char *parm)
|
|||
{
|
||||
if (com_argc == MAX_NUM_ARGVS)
|
||||
Com_Error (ERR_FATAL, "COM_AddParm: MAX_NUM)ARGS");
|
||||
|
||||
com_argv[com_argc++] = parm;
|
||||
}
|
||||
|
||||
|
@ -1129,10 +1219,10 @@ int memsearch (byte *start, int count, int search)
|
|||
for (i=0 ; i<count ; i++)
|
||||
if (start[i] == search)
|
||||
return i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
char *CopyString (char *in)
|
||||
{
|
||||
char *out;
|
||||
|
@ -1151,20 +1241,25 @@ void Info_Print (char *s)
|
|||
|
||||
if (*s == '\\')
|
||||
s++;
|
||||
|
||||
while (*s)
|
||||
{
|
||||
o = key;
|
||||
|
||||
while (*s && *s != '\\')
|
||||
*o++ = *s++;
|
||||
|
||||
l = o - key;
|
||||
|
||||
if (l < 20)
|
||||
{
|
||||
memset (o, ' ', 20-l);
|
||||
key[20] = 0;
|
||||
}
|
||||
|
||||
else
|
||||
*o = 0;
|
||||
|
||||
Com_Printf ("%s", key);
|
||||
|
||||
if (!*s)
|
||||
|
@ -1175,12 +1270,15 @@ void Info_Print (char *s)
|
|||
|
||||
o = value;
|
||||
s++;
|
||||
|
||||
while (*s && *s != '\\')
|
||||
*o++ = *s++;
|
||||
|
||||
*o = 0;
|
||||
|
||||
if (*s)
|
||||
s++;
|
||||
|
||||
Com_Printf ("%s\n", value);
|
||||
}
|
||||
}
|
||||
|
@ -1198,7 +1296,6 @@ just cleared malloc with counters now...
|
|||
|
||||
#define Z_MAGIC 0x1d1d
|
||||
|
||||
|
||||
typedef struct zhead_s
|
||||
{
|
||||
struct zhead_s *prev, *next;
|
||||
|
@ -1216,7 +1313,8 @@ void Z_Free (void *ptr)
|
|||
|
||||
z = ((zhead_t *)ptr) - 1;
|
||||
|
||||
if (z->magic != Z_MAGIC) {
|
||||
if (z->magic != Z_MAGIC)
|
||||
{
|
||||
printf( "free: %p failed\n", ptr );
|
||||
abort();
|
||||
Com_Error (ERR_FATAL, "Z_Free: bad magic");
|
||||
|
@ -1242,6 +1340,7 @@ void Z_FreeTags (int tag)
|
|||
for (z=z_chain.next ; z != &z_chain ; z=next)
|
||||
{
|
||||
next = z->next;
|
||||
|
||||
if (z->tag == tag)
|
||||
Z_Free ((void *)(z+1));
|
||||
}
|
||||
|
@ -1253,8 +1352,10 @@ void *Z_TagMalloc (int size, int tag)
|
|||
|
||||
size = size + sizeof(zhead_t);
|
||||
z = malloc(size);
|
||||
|
||||
if (!z)
|
||||
Com_Error (ERR_FATAL, "Z_Malloc: failed on allocation of %i bytes",size);
|
||||
|
||||
memset (z, 0, size);
|
||||
z_count++;
|
||||
z_bytes += size;
|
||||
|
@ -1275,7 +1376,8 @@ void *Z_Malloc (int size)
|
|||
return Z_TagMalloc (size, 0);
|
||||
}
|
||||
|
||||
static byte chktbl[1024] = {
|
||||
static byte chktbl[1024] =
|
||||
{
|
||||
0x84, 0x47, 0x51, 0xc1, 0x93, 0x22, 0x21, 0x24, 0x2f, 0x66, 0x60, 0x4d, 0xb0, 0x7c, 0xda,
|
||||
0x88, 0x54, 0x15, 0x2b, 0xc6, 0x6c, 0x89, 0xc5, 0x9d, 0x48, 0xee, 0xe6, 0x8a, 0xb5, 0xf4,
|
||||
0xcb, 0xfb, 0xf1, 0x0c, 0x2e, 0xa0, 0xd7, 0xc9, 0x1f, 0xd6, 0x06, 0x9a, 0x09, 0x41, 0x54,
|
||||
|
@ -1361,6 +1463,7 @@ byte COM_BlockSequenceCRCByte (byte *base, int length, int sequence)
|
|||
|
||||
if (length > 60)
|
||||
length = 60;
|
||||
|
||||
memcpy (chkb, base, length);
|
||||
|
||||
chkb[length] = p[0];
|
||||
|
@ -1465,7 +1568,6 @@ void Qcommon_Init (int argc, char **argv)
|
|||
s = va("%4.2f %s %s %s", VERSION, CPUSTRING, __DATE__, BUILDSTRING);
|
||||
Cvar_Get ("version", s, CVAR_SERVERINFO|CVAR_NOSET);
|
||||
|
||||
|
||||
if (dedicated->value)
|
||||
Cmd_AddCommand ("quit", Com_Quit);
|
||||
|
||||
|
@ -1481,19 +1583,26 @@ void Qcommon_Init (int argc, char **argv)
|
|||
|
||||
/* add + commands from command line */
|
||||
if (!Cbuf_AddLateCommands ())
|
||||
{ /* if the user didn't give any commands, run default action */
|
||||
{
|
||||
/* if the user didn't give any commands, run default action */
|
||||
if (!dedicated->value)
|
||||
Cbuf_AddText ("d1\n");
|
||||
|
||||
else
|
||||
Cbuf_AddText ("dedicated_start\n");
|
||||
|
||||
Cbuf_Execute ();
|
||||
}
|
||||
|
||||
#ifndef DEDICATED_ONLY
|
||||
|
||||
else
|
||||
{ /* the user asked for something explicit
|
||||
{
|
||||
/* the user asked for something explicit
|
||||
so drop the loading plaque */
|
||||
SCR_EndLoadingPlaque ();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Com_Printf ("====== Quake2 Initialized ======\n\n");
|
||||
|
@ -1515,6 +1624,7 @@ void Qcommon_Frame (int msec)
|
|||
if ( log_stats->modified )
|
||||
{
|
||||
log_stats->modified = false;
|
||||
|
||||
if ( log_stats->value )
|
||||
{
|
||||
if ( log_stats_file )
|
||||
|
@ -1522,10 +1632,13 @@ void Qcommon_Frame (int msec)
|
|||
fclose( log_stats_file );
|
||||
log_stats_file = 0;
|
||||
}
|
||||
|
||||
log_stats_file = fopen( "stats.log", "w" );
|
||||
|
||||
if ( log_stats_file )
|
||||
fprintf( log_stats_file, "entities,dlights,parts,frame time\n" );
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if ( log_stats_file )
|
||||
|
@ -1538,14 +1651,17 @@ void Qcommon_Frame (int msec)
|
|||
|
||||
if (fixedtime->value)
|
||||
msec = fixedtime->value;
|
||||
|
||||
else if (timescale->value)
|
||||
{
|
||||
msec *= timescale->value;
|
||||
|
||||
if (msec < 1)
|
||||
msec = 1;
|
||||
}
|
||||
|
||||
#ifndef DEDICATED_ONLY
|
||||
|
||||
if (showtrace->value)
|
||||
{
|
||||
extern int c_traces, c_brush_traces;
|
||||
|
@ -1556,24 +1672,31 @@ void Qcommon_Frame (int msec)
|
|||
c_brush_traces = 0;
|
||||
c_pointcontents = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
do
|
||||
{
|
||||
s = Sys_ConsoleInput ();
|
||||
|
||||
if (s)
|
||||
Cbuf_AddText (va("%s\n",s));
|
||||
} while (s);
|
||||
}
|
||||
while (s);
|
||||
|
||||
Cbuf_Execute ();
|
||||
|
||||
#ifndef DEDICATED_ONLY
|
||||
|
||||
if (host_speeds->value)
|
||||
time_before = Sys_Milliseconds ();
|
||||
|
||||
#endif
|
||||
|
||||
SV_Frame (msec);
|
||||
|
||||
#ifndef DEDICATED_ONLY
|
||||
|
||||
if (host_speeds->value)
|
||||
time_between = Sys_Milliseconds ();
|
||||
|
||||
|
@ -1597,6 +1720,7 @@ void Qcommon_Frame (int msec)
|
|||
Com_Printf ("all:%3i sv:%3i gm:%3i cl:%3i rf:%3i\n",
|
||||
all, sv, gm, cl, rf);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
||||
* 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.
|
||||
*
|
||||
* =======================================================================
|
||||
*/
|
||||
/* crc.c */
|
||||
|
||||
#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.
|
||||
|
||||
* 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
|
||||
*
|
||||
* =======================================================================
|
||||
*/
|
||||
/* crc.h */
|
||||
|
||||
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.
|
||||
|
||||
* 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.
|
||||
*
|
||||
* =======================================================================
|
||||
*/
|
||||
// cvar.c -- dynamic variable tracking
|
||||
|
||||
#include "qcommon.h"
|
||||
|
||||
|
@ -27,10 +32,13 @@ static qboolean Cvar_InfoValidate (char *s)
|
|||
{
|
||||
if (strstr (s, "\\"))
|
||||
return false;
|
||||
|
||||
if (strstr (s, "\""))
|
||||
return false;
|
||||
|
||||
if (strstr (s, ";"))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -50,8 +58,10 @@ float Cvar_VariableValue (char *var_name)
|
|||
cvar_t *var;
|
||||
|
||||
var = Cvar_FindVar (var_name);
|
||||
|
||||
if (!var)
|
||||
return 0;
|
||||
|
||||
return atof (var->string);
|
||||
}
|
||||
|
||||
|
@ -60,8 +70,10 @@ const char *Cvar_VariableString (const char *var_name)
|
|||
cvar_t *var;
|
||||
|
||||
var = Cvar_FindVar (var_name);
|
||||
|
||||
if (!var)
|
||||
return "";
|
||||
|
||||
return var->string;
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -239,6 +258,7 @@ 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);
|
||||
|
@ -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,6 +303,7 @@ void Cvar_GetLatchedVars (void)
|
|||
{
|
||||
if (!var->latched_string)
|
||||
continue;
|
||||
|
||||
Z_Free (var->string);
|
||||
var->string = var->latched_string;
|
||||
var->latched_string = NULL;
|
||||
|
@ -304,6 +326,7 @@ qboolean Cvar_Command (void)
|
|||
|
||||
/* check variables */
|
||||
v = Cvar_FindVar (Cmd_Argv(0));
|
||||
|
||||
if (!v)
|
||||
return false;
|
||||
|
||||
|
@ -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,28 +408,39 @@ 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);
|
||||
}
|
||||
|
||||
|
@ -418,6 +458,7 @@ char *Cvar_BitInfo (int bit)
|
|||
if (var->flags & bit)
|
||||
Info_SetValueForKey (info, var->name, var->string);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue