mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-05-30 16:30:43 +00:00
a slight oopsie on the location of WriteFloat and friends :P plus nq is now
endian/size clean.
This commit is contained in:
parent
39872aad5b
commit
c350bb2b1b
4 changed files with 106 additions and 102 deletions
|
@ -52,89 +52,6 @@
|
|||
void CL_FinishTimeDemo (void);
|
||||
int demotime_cached;
|
||||
|
||||
static void
|
||||
WriteFloat (VFile *file, float f)
|
||||
{
|
||||
// a float in C is /defined/ to be 32 bits. byte order, can, of course
|
||||
// still make a mess.
|
||||
union {
|
||||
float f;
|
||||
byte b[4];
|
||||
} dat;
|
||||
|
||||
dat.f = LittleFloat (f);
|
||||
Qwrite (file, dat.b, sizeof (dat.b));
|
||||
}
|
||||
|
||||
static void
|
||||
WriteByte (VFile *file, int b)
|
||||
{
|
||||
byte dat = b & 0xff;
|
||||
Qwrite (file, &dat, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
WriteShort (VFile *file, unsigned int s)
|
||||
{
|
||||
byte dat[2];
|
||||
|
||||
dat[0] = s & 0xff;
|
||||
dat[1] = (s >> 8) & 0xff;
|
||||
Qwrite (file, dat, sizeof (dat));
|
||||
}
|
||||
|
||||
static void
|
||||
WriteLong (VFile *file, unsigned int l)
|
||||
{
|
||||
byte dat[4];
|
||||
|
||||
dat[0] = l & 0xff;
|
||||
dat[1] = (l >> 8) & 0xff;
|
||||
dat[2] = (l >> 16) & 0xff;
|
||||
dat[3] = (l >> 24) & 0xff;
|
||||
Qwrite (file, dat, sizeof (dat));
|
||||
}
|
||||
|
||||
static float
|
||||
ReadFloat (VFile *file)
|
||||
{
|
||||
// a float in C is /defined/ to be 32 bits. byte order, can, of course
|
||||
// still make a mess.
|
||||
union {
|
||||
float f;
|
||||
byte b[4];
|
||||
} dat;
|
||||
|
||||
Qread (file, dat.b, sizeof (dat.b));
|
||||
return LittleFloat (dat.f);
|
||||
}
|
||||
|
||||
static byte
|
||||
ReadByte (VFile *file)
|
||||
{
|
||||
byte dat;
|
||||
Qread (file, &dat, 1);
|
||||
return dat;
|
||||
}
|
||||
|
||||
static unsigned short
|
||||
ReadShort (VFile *file)
|
||||
{
|
||||
byte dat[2];
|
||||
|
||||
Qread (file, dat, sizeof (dat));
|
||||
return (dat[1] << 8) | dat[0];
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
ReadLong (VFile *file)
|
||||
{
|
||||
byte dat[4];
|
||||
|
||||
Qread (file, dat, sizeof (dat));
|
||||
return (dat[3] << 24) | (dat[2] << 16) | (dat[1] << 8) | dat[0];
|
||||
}
|
||||
|
||||
/*
|
||||
DEMO CODE
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue