mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-17 22:50:51 +00:00
various cleanups including TODOs and FIXMEs and rewrite va to use a dynamic
buffer.
This commit is contained in:
parent
4af4c69289
commit
630aa80dc4
6 changed files with 38 additions and 53 deletions
|
@ -315,7 +315,7 @@ C_Print (const char *fmt, va_list args)
|
|||
if (!buffer)
|
||||
Sys_Error ("console: could not allocate %d bytes\n",
|
||||
buffer_size);
|
||||
size = vsnprintf (buffer, buffer_size, fmt, args);
|
||||
size = vsnprintf (buffer, buffer_size, fmt, args) + 1;
|
||||
//printf ("size = %d\n", size);
|
||||
}
|
||||
|
||||
|
|
|
@ -118,9 +118,8 @@ Cbuf_AddText (const char *text)
|
|||
/*
|
||||
Cbuf_InsertText
|
||||
|
||||
Adds command text immediately after the current command
|
||||
Adds command text to the beginning of the buffer.
|
||||
Adds a \n to the text
|
||||
TODO: Can we just read the buffer in the reverse order?
|
||||
*/
|
||||
void
|
||||
Cbuf_InsertText (const char *text)
|
||||
|
@ -308,19 +307,19 @@ Cmd_Exec_f (void)
|
|||
Sys_Printf ("exec <filename> : execute a script file\n");
|
||||
return;
|
||||
}
|
||||
// FIXME: is this safe freeing the hunk here?
|
||||
|
||||
mark = Hunk_LowMark ();
|
||||
f = (char *) COM_LoadHunkFile (Cmd_Argv (1));
|
||||
if (!f) {
|
||||
Sys_Printf ("couldn't exec %s\n", Cmd_Argv (1));
|
||||
return;
|
||||
}
|
||||
Cbuf_InsertText (f);
|
||||
Hunk_FreeToLowMark (mark);
|
||||
|
||||
if (!Cvar_Command () && (cmd_warncmd->int_val
|
||||
|| (developer && developer->int_val)))
|
||||
Sys_Printf ("execing %s\n", Cmd_Argv (1));
|
||||
|
||||
Cbuf_InsertText (f);
|
||||
Hunk_FreeToLowMark (mark);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -829,7 +828,6 @@ Cmd_ExpandVariables (const char *data, char *dest)
|
|||
Cmd_ExecuteString
|
||||
|
||||
A complete command line has been parsed, so try to execute it
|
||||
FIXME: lookupnoadd the token to speed search?
|
||||
*/
|
||||
void
|
||||
Cmd_ExecuteString (const char *text, cmd_source_t src)
|
||||
|
|
|
@ -67,7 +67,6 @@ struct hashtab_s {
|
|||
unsigned long
|
||||
Hash_String (const char *str)
|
||||
{
|
||||
//FIXME not 64 bit clean
|
||||
#if 0
|
||||
unsigned long h = 0;
|
||||
while (*str) {
|
||||
|
@ -81,9 +80,8 @@ Hash_String (const char *str)
|
|||
// shamelessly stolen from Daniel Phillips <phillips@innominate.de>
|
||||
// from his post to lkml
|
||||
unsigned long hash0 = 0x12a3fe2d, hash1 = 0x37abe8f9;
|
||||
while (*str)
|
||||
{
|
||||
unsigned long hash = hash1 + (hash0 ^ (*str++ * 71523));
|
||||
while (*str) {
|
||||
unsigned long hash = hash1 + (hash0 ^ ((unsigned char)*str++ * 71523));
|
||||
if (hash < 0) hash -= 0x7fffffff;
|
||||
hash1 = hash0;
|
||||
hash0 = hash;
|
||||
|
|
|
@ -62,13 +62,9 @@ ProjectPointOnPlane (vec3_t dst, const vec3_t p, const vec3_t normal)
|
|||
|
||||
d = DotProduct (normal, p) * inv_denom;
|
||||
|
||||
n[0] = normal[0] * inv_denom;
|
||||
n[1] = normal[1] * inv_denom;
|
||||
n[2] = normal[2] * inv_denom;
|
||||
VectorScale (normal, inv_denom * d, n);
|
||||
|
||||
dst[0] = p[0] - d * n[0];
|
||||
dst[1] = p[1] - d * n[1];
|
||||
dst[2] = p[2] - d * n[2];
|
||||
VectorSubtract (p, n, dst);
|
||||
}
|
||||
|
||||
// assumes "src" is normalized
|
||||
|
@ -86,7 +82,7 @@ PerpendicularVector (vec3_t dst, const vec3_t src)
|
|||
minelem = fabs (src[i]);
|
||||
}
|
||||
}
|
||||
tempvec[0] = tempvec[1] = tempvec[2] = 0.0F;
|
||||
VectorZero (tempvec);
|
||||
tempvec[pos] = 1.0F;
|
||||
|
||||
/* project the point onto the plane defined by src */
|
||||
|
@ -109,10 +105,8 @@ VectorVectors(const vec3_t forward, vec3_t right, vec3_t up)
|
|||
right[1] = -forward[0];
|
||||
right[2] = forward[1];
|
||||
|
||||
d = DotProduct(forward, right);
|
||||
right[0] -= d * forward[0];
|
||||
right[1] -= d * forward[1];
|
||||
right[2] -= d * forward[2];
|
||||
d = -DotProduct(forward, right);
|
||||
VectorMA (right, d, forward, right);
|
||||
VectorNormalize (right);
|
||||
CrossProduct(right, forward, up);
|
||||
}
|
||||
|
@ -129,9 +123,7 @@ RotatePointAroundVector (vec3_t dst, const vec3_t dir, const vec3_t point,
|
|||
int i;
|
||||
vec3_t vr, vup, vf;
|
||||
|
||||
vf[0] = dir[0];
|
||||
vf[1] = dir[1];
|
||||
vf[2] = dir[2];
|
||||
VectorCopy (dir, vf);
|
||||
|
||||
PerpendicularVector (vr, dir);
|
||||
CrossProduct (vr, vf, vup);
|
||||
|
@ -169,8 +161,7 @@ RotatePointAroundVector (vec3_t dst, const vec3_t dir, const vec3_t point,
|
|||
R_ConcatRotations (tmpmat, im, rot);
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
dst[i] = rot[i][0] * point[0] + rot[i][1] * point[1] + rot[i][2] *
|
||||
point[2];
|
||||
dst[i] = DotProduct (rot[i], point);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,12 +172,6 @@ RotatePointAroundVector (vec3_t dst, const vec3_t dir, const vec3_t point,
|
|||
float
|
||||
anglemod (float a)
|
||||
{
|
||||
#if 0
|
||||
if (a >= 0)
|
||||
a -= 360 * (int) (a / 360);
|
||||
else
|
||||
a += 360 * (1 + (int) (-a / 360));
|
||||
#endif
|
||||
a = (360.0 / 65536) * ((int) (a * (65536 / 360.0)) & 65535);
|
||||
return a;
|
||||
}
|
||||
|
@ -196,7 +181,7 @@ anglemod (float a)
|
|||
|
||||
Split out like this for ASM to call.
|
||||
*/
|
||||
void
|
||||
void __attribute__ ((noreturn))
|
||||
BOPS_Error (void)
|
||||
{
|
||||
Sys_Error ("BoxOnPlaneSide: Bad signbits");
|
||||
|
@ -280,9 +265,7 @@ BoxOnPlaneSide (const vec3_t emins, const vec3_t emaxs, mplane_t *p)
|
|||
p->normal[2] * emaxs[2];
|
||||
break;
|
||||
default:
|
||||
dist1 = dist2 = 0; // shut up compiler
|
||||
BOPS_Error ();
|
||||
break;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -582,7 +565,6 @@ GreatestCommonDivisor (int i1, int i2)
|
|||
Invert24To16
|
||||
|
||||
Inverts an 8.24 value to a 16.16 value
|
||||
TODO: move to nonintel.c
|
||||
*/
|
||||
fixed16_t
|
||||
Invert24To16 (fixed16_t val)
|
||||
|
|
|
@ -798,14 +798,6 @@ COM_AddDirectory (const char *dir)
|
|||
COM_LoadGameDirectory (dir);
|
||||
}
|
||||
|
||||
/*
|
||||
COM_AddGameDirectory
|
||||
|
||||
FIXME: this is a wrapper for COM_AddDirectory (which used to be
|
||||
this function) to have it load share and base paths. Whenver
|
||||
someone goes through to clean up the fs code, this function should
|
||||
merge with COM_AddGameDirectory.
|
||||
*/
|
||||
void
|
||||
COM_AddGameDirectory (const char *dir)
|
||||
{
|
||||
|
|
|
@ -35,6 +35,7 @@ static const char rcsid[] =
|
|||
#include <stdio.h>
|
||||
|
||||
#include "QF/qtypes.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/va.h"
|
||||
|
||||
#include "compat.h"
|
||||
|
@ -45,17 +46,31 @@ static const char rcsid[] =
|
|||
|
||||
does a varargs printf into a temp buffer, so I don't need to have
|
||||
varargs versions of all text functions.
|
||||
FIXME: make this buffer size safe someday
|
||||
*/
|
||||
char *
|
||||
va (const char *format, ...)
|
||||
va (const char *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
static char string[1024];
|
||||
va_list args;
|
||||
static char *string;
|
||||
int size;
|
||||
static int string_size;
|
||||
|
||||
va_start (argptr, format);
|
||||
vsnprintf (string, sizeof (string), format, argptr);
|
||||
va_end (argptr);
|
||||
va_start (args, fmt);
|
||||
size = vsnprintf (string, string_size, fmt, args) + 1; // +1 for nul
|
||||
//printf ("size = %d\n", size);
|
||||
while (size <= 0 || size > string_size) {
|
||||
if (size > 0)
|
||||
string_size = (size + 1023) & ~1023; // 1k multiples
|
||||
else
|
||||
string_size += 1024;
|
||||
string = realloc (string, string_size);
|
||||
if (!string)
|
||||
Sys_Error ("console: could not allocate %d bytes\n",
|
||||
string_size);
|
||||
size = vsnprintf (string, string_size, fmt, args) + 1;
|
||||
//printf ("size = %d\n", size);
|
||||
}
|
||||
va_end (args);
|
||||
|
||||
return string;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue