summaryrefslogtreecommitdiff
path: root/src/renderer
diff options
context:
space:
mode:
Diffstat (limited to 'src/renderer')
-rw-r--r--src/renderer/tr_bsp.c13
-rw-r--r--src/renderer/tr_image.c14
-rw-r--r--src/renderer/tr_image_bmp.c19
-rw-r--r--src/renderer/tr_image_jpg.c13
-rw-r--r--src/renderer/tr_image_pcx.c27
-rw-r--r--src/renderer/tr_image_png.c7
-rw-r--r--src/renderer/tr_image_tga.c15
-rw-r--r--src/renderer/tr_model.c27
8 files changed, 81 insertions, 54 deletions
diff --git a/src/renderer/tr_bsp.c b/src/renderer/tr_bsp.c
index fd1b64b6..83633c00 100644
--- a/src/renderer/tr_bsp.c
+++ b/src/renderer/tr_bsp.c
@@ -1796,7 +1796,10 @@ Called directly from cgame
void RE_LoadWorldMap( const char *name ) {
int i;
dheader_t *header;
- byte *buffer;
+ union {
+ byte *b;
+ void *v;
+ } buffer;
byte *startMarker;
if ( tr.worldMapLoaded ) {
@@ -1814,8 +1817,8 @@ void RE_LoadWorldMap( const char *name ) {
tr.worldMapLoaded = qtrue;
// load it
- ri.FS_ReadFile( name, (void **)&buffer );
- if ( !buffer ) {
+ ri.FS_ReadFile( name, &buffer.v );
+ if ( !buffer.b ) {
ri.Error (ERR_DROP, "RE_LoadWorldMap: %s not found", name);
}
@@ -1832,7 +1835,7 @@ void RE_LoadWorldMap( const char *name ) {
startMarker = ri.Hunk_Alloc(0, h_low);
c_gridVerts = 0;
- header = (dheader_t *)buffer;
+ header = (dheader_t *)buffer.b;
fileBase = (byte *)header;
i = LittleLong (header->version);
@@ -1864,6 +1867,6 @@ void RE_LoadWorldMap( const char *name ) {
// only set tr.world now that we know the entire level has loaded properly
tr.world = &s_worldData;
- ri.FS_FreeFile( buffer );
+ ri.FS_FreeFile( buffer.v );
}
diff --git a/src/renderer/tr_image.c b/src/renderer/tr_image.c
index 836433b5..5ed98450 100644
--- a/src/renderer/tr_image.c
+++ b/src/renderer/tr_image.c
@@ -1432,7 +1432,11 @@ qhandle_t RE_RegisterSkin( const char *name ) {
qhandle_t hSkin;
skin_t *skin;
skinSurface_t *surf;
- char *text, *text_p;
+ union {
+ char *c;
+ void *v;
+ } text;
+ char *text_p;
char *token;
char surfName[MAX_QPATH];
@@ -1481,12 +1485,12 @@ qhandle_t RE_RegisterSkin( const char *name ) {
}
// load and parse the skin file
- ri.FS_ReadFile( name, (void **)&text );
- if ( !text ) {
+ ri.FS_ReadFile( name, &text.v );
+ if ( !text.c ) {
return 0;
}
- text_p = text;
+ text_p = text.c;
while ( text_p && *text_p ) {
// get surface name
token = CommaParse( &text_p );
@@ -1515,7 +1519,7 @@ qhandle_t RE_RegisterSkin( const char *name ) {
skin->numSurfaces++;
}
- ri.FS_FreeFile( text );
+ ri.FS_FreeFile( text.v );
// never let a skin have 0 shaders
diff --git a/src/renderer/tr_image_bmp.c b/src/renderer/tr_image_bmp.c
index 190b878f..0b78abb8 100644
--- a/src/renderer/tr_image_bmp.c
+++ b/src/renderer/tr_image_bmp.c
@@ -50,7 +50,10 @@ void R_LoadBMP( const char *name, byte **pic, int *width, int *height )
int row, column;
byte *buf_p;
byte *end;
- byte *buffer = NULL;
+ union {
+ byte *b;
+ void *v;
+ } buffer;
int length;
BMPHeader_t bmpHeader;
byte *bmpRGBA;
@@ -66,8 +69,8 @@ void R_LoadBMP( const char *name, byte **pic, int *width, int *height )
//
// load the file
//
- length = ri.FS_ReadFile( ( char * ) name, (void **)&buffer);
- if (!buffer || length < 0) {
+ length = ri.FS_ReadFile( ( char * ) name, &buffer.v);
+ if (!buffer.b || length < 0) {
return;
}
@@ -76,8 +79,8 @@ void R_LoadBMP( const char *name, byte **pic, int *width, int *height )
ri.Error( ERR_DROP, "LoadBMP: header too short (%s)\n", name );
}
- buf_p = buffer;
- end = buffer + length;
+ buf_p = buffer.b;
+ end = buffer.b + length;
bmpHeader.id[0] = *buf_p++;
bmpHeader.id[1] = *buf_p++;
@@ -119,12 +122,12 @@ void R_LoadBMP( const char *name, byte **pic, int *width, int *height )
buf_p += sizeof(bmpHeader.palette);
}
- if (buffer + bmpHeader.bitmapDataOffset > end)
+ if (buffer.b + bmpHeader.bitmapDataOffset > end)
{
ri.Error( ERR_DROP, "LoadBMP: invalid offset value in header (%s)\n", name );
}
- buf_p = buffer + bmpHeader.bitmapDataOffset;
+ buf_p = buffer.b + bmpHeader.bitmapDataOffset;
if ( bmpHeader.id[0] != 'B' && bmpHeader.id[1] != 'M' )
{
@@ -231,6 +234,6 @@ void R_LoadBMP( const char *name, byte **pic, int *width, int *height )
}
}
- ri.FS_FreeFile( buffer );
+ ri.FS_FreeFile( buffer.v );
}
diff --git a/src/renderer/tr_image_jpg.c b/src/renderer/tr_image_jpg.c
index fb4f2121..2e1a52a7 100644
--- a/src/renderer/tr_image_jpg.c
+++ b/src/renderer/tr_image_jpg.c
@@ -57,7 +57,10 @@ void R_LoadJPG( const char *filename, unsigned char **pic, int *width, int *heig
unsigned pixelcount, memcount;
unsigned char *out;
int len;
- byte *fbuffer;
+ union {
+ byte *b;
+ void *v;
+ } fbuffer;
byte *buf;
/* In this example we want to open the input file before doing anything else,
@@ -66,8 +69,8 @@ void R_LoadJPG( const char *filename, unsigned char **pic, int *width, int *heig
* requires it in order to read binary files.
*/
- len = ri.FS_ReadFile ( ( char * ) filename, (void **)&fbuffer);
- if (!fbuffer || len < 0) {
+ len = ri.FS_ReadFile ( ( char * ) filename, &fbuffer.v);
+ if (!fbuffer.b || len < 0) {
return;
}
@@ -85,7 +88,7 @@ void R_LoadJPG( const char *filename, unsigned char **pic, int *width, int *heig
/* Step 2: specify data source (eg, a file) */
- jpeg_mem_src(&cinfo, fbuffer, len);
+ jpeg_mem_src(&cinfo, fbuffer.b, len);
/* Step 3: read file parameters with jpeg_read_header() */
@@ -203,7 +206,7 @@ void R_LoadJPG( const char *filename, unsigned char **pic, int *width, int *heig
* so as to simplify the setjmp error logic above. (Actually, I don't
* think that jpeg_destroy can do an error exit, but why assume anything...)
*/
- ri.FS_FreeFile (fbuffer);
+ ri.FS_FreeFile (fbuffer.v);
/* At this point you may want to check to see whether any corrupt-data
* warnings occurred (test whether jerr.pub.num_warnings is nonzero).
diff --git a/src/renderer/tr_image_pcx.c b/src/renderer/tr_image_pcx.c
index db407dea..d1b1a5ee 100644
--- a/src/renderer/tr_image_pcx.c
+++ b/src/renderer/tr_image_pcx.c
@@ -50,7 +50,10 @@ typedef struct {
void R_LoadPCX ( const char *filename, byte **pic, int *width, int *height)
{
- byte *raw;
+ union {
+ byte *b;
+ void *v;
+ } raw;
byte *end;
pcx_t *pcx;
int len;
@@ -71,23 +74,23 @@ void R_LoadPCX ( const char *filename, byte **pic, int *width, int *height)
//
// load the file
//
- len = ri.FS_ReadFile( ( char * ) filename, (void **)&raw);
- if (!raw || len < 0) {
+ len = ri.FS_ReadFile( ( char * ) filename, &raw.v);
+ if (!raw.b || len < 0) {
return;
}
if((unsigned)len < sizeof(pcx_t))
{
ri.Printf (PRINT_ALL, "PCX truncated: %s\n", filename);
- ri.FS_FreeFile (raw);
+ ri.FS_FreeFile (raw.v);
return;
}
//
// parse the PCX file
//
- pcx = (pcx_t *)raw;
- end = raw+len;
+ pcx = (pcx_t *)raw.b;
+ end = raw.b+len;
w = LittleShort(pcx->xmax)+1;
h = LittleShort(pcx->ymax)+1;
@@ -107,7 +110,7 @@ void R_LoadPCX ( const char *filename, byte **pic, int *width, int *height)
pix = pic8 = ri.Malloc ( size );
- raw = pcx->data;
+ raw.b = pcx->data;
// FIXME: should use bytes_per_line but original q3 didn't do that either
while(pix < pic8+size)
{
@@ -117,16 +120,16 @@ void R_LoadPCX ( const char *filename, byte **pic, int *width, int *height)
continue;
}
- if(raw+1 > end)
+ if(raw.b+1 > end)
break;
- dataByte = *raw++;
+ dataByte = *raw.b++;
if((dataByte & 0xC0) == 0xC0)
{
- if(raw+1 > end)
+ if(raw.b+1 > end)
break;
runLength = dataByte & 0x3F;
- dataByte = *raw++;
+ dataByte = *raw.b++;
}
else
runLength = 1;
@@ -139,7 +142,7 @@ void R_LoadPCX ( const char *filename, byte **pic, int *width, int *height)
ri.Free (pic8);
}
- if (raw-(byte*)pcx >= end - (byte*)769 || end[-769] != 0x0c)
+ if (raw.b-(byte*)pcx >= end - (byte*)769 || end[-769] != 0x0c)
{
ri.Printf (PRINT_ALL, "PCX missing palette: %s\n", filename);
ri.FS_FreeFile (pcx);
diff --git a/src/renderer/tr_image_png.c b/src/renderer/tr_image_png.c
index e33ffffa..ef44c165 100644
--- a/src/renderer/tr_image_png.c
+++ b/src/renderer/tr_image_png.c
@@ -215,6 +215,10 @@ struct BufferedFile
static struct BufferedFile *ReadBufferedFile(const char *name)
{
struct BufferedFile *BF;
+ union {
+ byte *b;
+ void *v;
+ } buffer;
/*
* input verification
@@ -248,7 +252,8 @@ static struct BufferedFile *ReadBufferedFile(const char *name)
* Read the file.
*/
- BF->Length = ri.FS_ReadFile((char *) name, (void **) &BF->Buffer);
+ BF->Length = ri.FS_ReadFile((char *) name, &buffer.v);
+ BF->Buffer = buffer.b;
/*
* Did we get it? Is it big enough?
diff --git a/src/renderer/tr_image_tga.c b/src/renderer/tr_image_tga.c
index 2147acdc..e66e60de 100644
--- a/src/renderer/tr_image_tga.c
+++ b/src/renderer/tr_image_tga.c
@@ -45,7 +45,10 @@ void R_LoadTGA ( const char *name, byte **pic, int *width, int *height)
int row, column;
byte *buf_p;
byte *end;
- byte *buffer = NULL;
+ union {
+ byte *b;
+ void *v;
+ } buffer;
TargaHeader targa_header;
byte *targa_rgba;
int length;
@@ -60,8 +63,8 @@ void R_LoadTGA ( const char *name, byte **pic, int *width, int *height)
//
// load the file
//
- length = ri.FS_ReadFile ( ( char * ) name, (void **)&buffer);
- if (!buffer || length < 0) {
+ length = ri.FS_ReadFile ( ( char * ) name, &buffer.v);
+ if (!buffer.b || length < 0) {
return;
}
@@ -70,8 +73,8 @@ void R_LoadTGA ( const char *name, byte **pic, int *width, int *height)
ri.Error( ERR_DROP, "LoadTGA: header too short (%s)\n", name );
}
- buf_p = buffer;
- end = buffer + length;
+ buf_p = buffer.b;
+ end = buffer.b + length;
targa_header.id_length = buf_p[0];
targa_header.colormap_type = buf_p[1];
@@ -313,5 +316,5 @@ void R_LoadTGA ( const char *name, byte **pic, int *width, int *height)
*pic = targa_rgba;
- ri.FS_FreeFile (buffer);
+ ri.FS_FreeFile (buffer.v);
}
diff --git a/src/renderer/tr_model.c b/src/renderer/tr_model.c
index b4ca744f..8707d8a7 100644
--- a/src/renderer/tr_model.c
+++ b/src/renderer/tr_model.c
@@ -84,7 +84,10 @@ asked for again.
*/
qhandle_t RE_RegisterModel( const char *name ) {
model_t *mod;
- unsigned *buf;
+ union {
+ unsigned *u;
+ void *v;
+ } buf;
int lod;
int ident;
qboolean loaded = qfalse;
@@ -152,19 +155,19 @@ qhandle_t RE_RegisterModel( const char *name ) {
{
int filesize;
- filesize = ri.FS_ReadFile(name, (void **) &buf);
- if(!buf)
+ filesize = ri.FS_ReadFile(name, (void **) &buf.v);
+ if(!buf.u)
{
ri.Printf (PRINT_WARNING,"RE_RegisterModel: couldn't load %s\n", name);
mod->type = MOD_BAD;
return 0;
}
- ident = LittleLong(*(unsigned *)buf);
+ ident = LittleLong(*(unsigned *)buf.u);
if(ident == MDR_IDENT)
- loaded = R_LoadMDR(mod, buf, filesize, name);
+ loaded = R_LoadMDR(mod, buf.u, filesize, name);
- ri.FS_FreeFile (buf);
+ ri.FS_FreeFile (buf.v);
if(!loaded)
{
@@ -185,26 +188,26 @@ qhandle_t RE_RegisterModel( const char *name ) {
else
Com_sprintf(namebuf, sizeof(namebuf), "%s.%s", filename, fext);
- ri.FS_ReadFile( namebuf, (void **)&buf );
- if ( !buf ) {
+ ri.FS_ReadFile( namebuf, &buf.v );
+ if ( !buf.u ) {
continue;
}
loadmodel = mod;
- ident = LittleLong(*(unsigned *)buf);
+ ident = LittleLong(*(unsigned *)buf.u);
if ( ident == MD4_IDENT ) {
- loaded = R_LoadMD4( mod, buf, name );
+ loaded = R_LoadMD4( mod, buf.u, name );
} else {
if ( ident != MD3_IDENT ) {
ri.Printf (PRINT_WARNING,"RE_RegisterModel: unknown fileid for %s\n", name);
goto fail;
}
- loaded = R_LoadMD3( mod, lod, buf, name );
+ loaded = R_LoadMD3( mod, lod, buf.u, name );
}
- ri.FS_FreeFile (buf);
+ ri.FS_FreeFile (buf.v);
if ( !loaded ) {
if ( lod == 0 ) {