#define qfalse 0
#ifdef _DEBUG
-void WinPrint(char *str, ...)
+void WinPrint(const char *str, ...)
{
va_list argptr;
char text[4096];
printf(text);
}
#else
-void WinPrint(char *str, ...)
+void WinPrint(const char *str, ...)
{
}
#endif
// Returns: -
// Changes Globals: -
//===========================================================================
-void Net_StringToAddress(char *string, address_t *address)
+void Net_StringToAddress(const char *string, address_t *address)
{
strcpy(address->ip, string);
} //end of the function Net_StringToAddress
if (c == 0) break;
string[l] = c;
l++;
- } while (l < sizeof(string)-1);
+ } while ((size_t) l < sizeof(string)-1);
string[l] = 0;
return string;
} //end of the function NMSG_ReadString
struct socket_s *prev, *next; //prev and next socket in a list
} socket_t;
+void WinPrint(const char *format, ...);
+
//compare addresses
int Net_AddressCompare(address_t *addr1, address_t *addr2);
//gives the address of a socket
void Net_SocketToAddress(socket_t *sock, address_t *address);
//converts a string to an address
-void Net_StringToAddress(char *string, address_t *address);
+void Net_StringToAddress(const char *string, address_t *address);
//set the address ip port
void Net_SetAddressPort(address_t *address, int port);
//send a message to the given socket
char *NMSG_ReadString(netmessage_t *msg);
//++timo FIXME: the WINS_ things are not necessary, they can be made portable arther easily
-char *WINS_ErrorMessage(int error);
+const char *WINS_ErrorMessage(int error);
#ifdef __cplusplus
}
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
+#include <arpa/inet.h>
#include <errno.h>
#include <netdb.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <stdio.h>
#define SOCKET_ERROR -1
#define INVALID_SOCKET -1
// Returns: -
// Changes Globals: -
//===========================================================================
-char *WINS_ErrorMessage(int error)
+const char *WINS_ErrorMessage(int error)
{
int search = 0;
for (search = 0; errlist[search].errstr; search++)
{
if (error == errlist[search].errnum)
- return (char *)errlist[search].errstr;
+ return errlist[search].errstr;
} //end for
return "Unknown error";
char buff[MAXHOSTNAMELEN];
struct sockaddr_s addr;
char *p;
- int r;
/*
linux doesn't have anything to initialize for the net
"Windows .. built for the internet .. the internet .. built with unix"
//===========================================================================
int WINS_Accept(int socket, struct sockaddr_s *addr)
{
- int addrlen = sizeof (struct sockaddr_s);
+ socklen_t addrlen = sizeof (struct sockaddr_s);
int newsocket;
qboolean _true = 1;
//===========================================================================
int WINS_Read(int socket, byte *buf, int len, struct sockaddr_s *addr)
{
- int addrlen = sizeof (struct sockaddr_s);
+ socklen_t addrlen = sizeof (struct sockaddr_s);
int ret;
if (addr)
int WINS_Write(int socket, byte *buf, int len, struct sockaddr_s *addr)
{
int ret, written;
+ ret = 0;
if (addr)
{
//===========================================================================
int WINS_GetSocketAddr(int socket, struct sockaddr_s *addr)
{
- int addrlen = sizeof(struct sockaddr_s);
+ socklen_t addrlen = sizeof(struct sockaddr_s);
unsigned int a;
memset(addr, 0, sizeof(struct sockaddr_s));
{-1, NULL}
};
-#ifdef _DEBUG
-void WinPrint(char *str, ...);
-#else
-void WinPrint(char *str, ...);
-#endif
-
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
-char *WINS_ErrorMessage(int error)
+const char *WINS_ErrorMessage(int error)
{
int search = 0;
{
if ( ti < i )
idst = ti;
+ else if ( ti > i )
+ idst = ti-1;
else
- if ( ti > i )
- idst = ti-1;
+ continue;
for ( tj = 0; tj < 4; tj++ )
{
if ( tj < j )
jdst = tj;
+ else if ( tj > j )
+ jdst = tj-1;
else
- if ( tj > j )
- jdst = tj-1;
+ continue;
- if ( ti != i && tj != j )
- mb[idst*3 + jdst] = mr[ti*4 + tj ];
+ mb[idst*3 + jdst] = mr[ti*4 + tj ];
}
}
}
/* convenience (makes it easy to add new params to the callbacks) */
#define PM_PARAMS_CANLOAD \
- char *fileName, const void *buffer, int bufSize
+ const char *fileName, const void *buffer, int bufSize
#define PM_PARAMS_LOAD \
- char *fileName, int frameNum, const void *buffer, int bufSize
+ const char *fileName, int frameNum, const void *buffer, int bufSize
#define PM_PARAMS_CANSAVE \
void
#define PM_PARAMS_SAVE \
- char *fileName, picoModel_t *model
+ const char *fileName, picoModel_t *model
/* pico file format module structure */
struct picoModule_s
void PicoSetMallocFunc( void *(*func)( size_t ) );
void PicoSetFreeFunc( void (*func)( void* ) );
-void PicoSetLoadFileFunc( void (*func)( char*, unsigned char**, int* ) );
+void PicoSetLoadFileFunc( void (*func)( const char*, unsigned char**, int* ) );
void PicoSetFreeFileFunc( void (*func)( void* ) );
void PicoSetPrintFunc( void (*func)( int, const char* ) );
const picoModule_t **PicoModuleList( int *numModules );
-picoModel_t *PicoLoadModel( char *name, int frameNum );
+picoModel_t *PicoLoadModel( const char *name, int frameNum );
typedef size_t (*PicoInputStreamReadFunc)(void* inputStream, unsigned char* buffer, size_t length);
picoModel_t* PicoModuleLoadModelStream( const picoModule_t* module, void* inputStream, PicoInputStreamReadFunc inputStreamRead, size_t streamLength, int frameNum, const char *fileName );
/* setter functions */
-void PicoSetModelName( picoModel_t *model, char *name );
-void PicoSetModelFileName( picoModel_t *model, char *fileName );
+void PicoSetModelName( picoModel_t *model, const char *name );
+void PicoSetModelFileName( picoModel_t *model, const char *fileName );
void PicoSetModelFrameNum( picoModel_t *model, int frameNum );
void PicoSetModelNumFrames( picoModel_t *model, int numFrames );
void PicoSetModelData( picoModel_t *model, void *data );
lwEnvelope *lwGetEnvelope( picoMemStream_t *fp, int cksize )
{
lwEnvelope *env;
- lwKey *key;
+ lwKey *key = NULL;
lwPlugin *plug;
unsigned int id;
unsigned short sz;
i = **bp;
if ( i > 127 ) i -= 256;
flen += 1;
- *bp++;
+ (*bp)++;
return i;
}
if ( flen == FLEN_ERROR ) return 0;
c = **bp;
flen += 1;
- *bp++;
+ (*bp)++;
return c;
}
if ( flen == FLEN_ERROR ) return NULL;
- len = strlen( buf ) + 1;
+ len = strlen( (const char *) buf ) + 1;
if ( len == 1 ) {
flen += 2;
*bp += 2;
If you don't need this information, failID and failpos can be NULL.
====================================================================== */
-lwObject *lwGetObject( char *filename, picoMemStream_t *fp, unsigned int *failID, int *failpos )
+lwObject *lwGetObject( const char *filename, picoMemStream_t *fp, unsigned int *failID, int *failpos )
{
lwObject *object;
lwLayer *layer;
lwNode *node;
- unsigned int id, formsize, type, cksize;
- int i, rlen;
+ unsigned int id, formsize, type;
+ int i, rlen, cksize;
/* open the file */
/* end of the file? */
- if ( formsize <= _pico_memstream_tell( fp ) - 8 ) break;
+ if ( formsize <= (unsigned int) (_pico_memstream_tell( fp ) - 8) ) break;
/* get the next chunk header */
return NULL;
}
-int lwValidateObject( char *filename, picoMemStream_t *fp, unsigned int *failID, int *failpos )
+int lwValidateObject( const char *filename, picoMemStream_t *fp, unsigned int *failID, int *failpos )
{
unsigned int id, formsize, type;
void lwFreeLayer( lwLayer *layer );
void lwFreeObject( lwObject *object );
-lwObject *lwGetObject( char *filename, picoMemStream_t *fp, unsigned int *failID, int *failpos );
-int lwValidateObject( char *filename, picoMemStream_t *fp, unsigned int *failID, int *failpos );
+lwObject *lwGetObject( const char *filename, picoMemStream_t *fp, unsigned int *failID, int *failpos );
+int lwValidateObject( const char *filename, picoMemStream_t *fp, unsigned int *failID, int *failpos );
/* pntspols.c */
lwSurface *lwGetSurface5( picoMemStream_t *fp, int cksize, lwObject *obj );
int lwGetPolygons5( picoMemStream_t *fp, int cksize, lwPolygonList *plist, int ptoffset );
-lwObject *lwGetObject5( char *filename, picoMemStream_t *fp, unsigned int *failID, int *failpos );
-int lwValidateObject5( char *filename, picoMemStream_t *fp, unsigned int *failID, int *failpos );
+lwObject *lwGetObject5( const char *filename, picoMemStream_t *fp, unsigned int *failID, int *failpos );
+int lwValidateObject5( const char *filename, picoMemStream_t *fp, unsigned int *failID, int *failpos );
/* list.c */
clip->saturation.val = 1.0f;
clip->gamma.val = 1.0f;
- if ( p = strstr( s, "(sequence)" )) {
+ if ((p = strstr( s, "(sequence)" ))) {
p[ -1 ] = 0;
clip->type = ID_ISEQ;
clip->source.seq.prefix = s;
clip->source.still.name = s;
}
- *nclips++;
+ (*nclips)++;
clip->index = *nclips;
lwListAdd( (void *) clist, clip );
lwSurface *lwGetSurface5( picoMemStream_t *fp, int cksize, lwObject *obj )
{
lwSurface *surf;
- lwTexture *tex;
- lwPlugin *shdr;
+ lwTexture *tex = NULL;
+ lwPlugin *shdr = NULL;
char *s;
float v[ 3 ];
unsigned int id, flags;
break;
case ID_TFLG:
+ if(!tex) goto Fail;
flags = getU2( fp );
+ i = -1;
if ( flags & 1 ) i = 0;
if ( flags & 2 ) i = 1;
if ( flags & 4 ) i = 2;
+ if(i < 0) goto Fail;
tex->axis = i;
if ( tex->type == ID_IMAP )
tex->param.imap.axis = i;
break;
case ID_TSIZ:
+ if(!tex) goto Fail;
for ( i = 0; i < 3; i++ )
tex->tmap.size.val[ i ] = getF4( fp );
break;
case ID_TCTR:
+ if(!tex) goto Fail;
for ( i = 0; i < 3; i++ )
tex->tmap.center.val[ i ] = getF4( fp );
break;
case ID_TFAL:
+ if(!tex) goto Fail;
for ( i = 0; i < 3; i++ )
tex->tmap.falloff.val[ i ] = getF4( fp );
break;
case ID_TVEL:
+ if(!tex) goto Fail;
for ( i = 0; i < 3; i++ )
v[ i ] = getF4( fp );
tex->tmap.center.eindex = add_tvel( tex->tmap.center.val, v,
break;
case ID_TCLR:
+ if(!tex) goto Fail;
if ( tex->type == ID_PROC )
for ( i = 0; i < 3; i++ )
tex->param.proc.value[ i ] = getU1( fp ) / 255.0f;
break;
case ID_TVAL:
+ if(!tex) goto Fail;
tex->param.proc.value[ 0 ] = getI2( fp ) / 256.0f;
break;
case ID_TAMP:
+ if(!tex) goto Fail;
if ( tex->type == ID_IMAP )
tex->param.imap.amplitude.val = getF4( fp );
break;
case ID_TIMG:
+ if(!tex) goto Fail;
s = getS0( fp );
tex->param.imap.cindex = add_clip( s, &obj->clip, &obj->nclips );
break;
case ID_TAAS:
+ if(!tex) goto Fail;
tex->param.imap.aa_strength = getF4( fp );
tex->param.imap.aas_flags = 1;
break;
case ID_TREF:
+ if(!tex) goto Fail;
tex->tmap.ref_object = getbytes( fp, sz );
break;
case ID_TOPC:
+ if(!tex) goto Fail;
tex->opacity.val = getF4( fp );
break;
case ID_TFP0:
+ if(!tex) goto Fail;
if ( tex->type == ID_IMAP )
tex->param.imap.wrapw.val = getF4( fp );
break;
case ID_TFP1:
+ if(!tex) goto Fail;
if ( tex->type == ID_IMAP )
tex->param.imap.wraph.val = getF4( fp );
break;
break;
case ID_SDAT:
+ if(!shdr) goto Fail;
shdr->data = getbytes( fp, sz );
break;
If you don't need this information, failID and failpos can be NULL.
====================================================================== */
-lwObject *lwGetObject5( char *filename, picoMemStream_t *fp, unsigned int *failID, int *failpos )
+lwObject *lwGetObject5( const char *filename, picoMemStream_t *fp, unsigned int *failID, int *failpos )
{
lwObject *object;
lwLayer *layer;
/* end of the file? */
- if ( formsize <= _pico_memstream_tell( fp ) - 8 ) break;
+ if ( formsize <= (unsigned int) (_pico_memstream_tell( fp ) - 8) ) break;
/* get the next chunk header */
return NULL;
}
-int lwValidateObject5( char *filename, picoMemStream_t *fp, unsigned int *failID, int *failpos )
+int lwValidateObject5( const char *filename, picoMemStream_t *fp, unsigned int *failID, int *failpos )
{
unsigned int id, formsize, type;
/* function pointers */
void *(*_pico_ptr_malloc )( size_t ) = malloc;
void (*_pico_ptr_free )( void* ) = free;
-void (*_pico_ptr_load_file )( char*, unsigned char**, int* ) = NULL;
+void (*_pico_ptr_load_file )( const char*, unsigned char**, int* ) = NULL;
void (*_pico_ptr_free_file )( void* ) = NULL;
void (*_pico_ptr_print )( int, const char* ) = NULL;
/* _pico_load_file:
* wrapper around the loadfile function pointer
*/
-void _pico_load_file( char *name, unsigned char **buffer, int *bufSize )
+void _pico_load_file( const char *name, unsigned char **buffer, int *bufSize )
{
/* sanity checks */
if( name == NULL )
if( !str || !*str )
return;
while( *str && !isspace( *str ) )
- *str++;
+ str++;
*str = '\0';
}
/* _pico_stristr:
* case-insensitive strstr. -sea
*/
-char *_pico_stristr( char *str, const char *substr )
+const char *_pico_stristr( const char *str, const char *substr )
{
const size_t sublen = strlen(substr);
while (*str)
/* _pico_new_parser:
* allocates a new ascii parser object.
*/
-picoParser_t *_pico_new_parser( picoByte_t *buffer, int bufSize )
+picoParser_t *_pico_new_parser( const picoByte_t *buffer, int bufSize )
{
picoParser_t *p;
return NULL;
}
/* setup */
- p->buffer = buffer;
- p->cursor = buffer;
+ p->buffer = (const char *) buffer;
+ p->cursor = (const char *) buffer;
p->bufSize = bufSize;
p->max = p->buffer + bufSize;
p->curLine = 1; /* sea: new */
int _pico_parse_ex( picoParser_t *p, int allowLFs, int handleQuoted )
{
int hasLFs = 0;
- char *old;
+ const char *old;
/* sanity checks */
if( p == NULL || p->buffer == NULL ||
/* _pico_new_memstream:
* allocates a new memorystream object.
*/
-picoMemStream_t *_pico_new_memstream( picoByte_t *buffer, int bufSize )
+picoMemStream_t *_pico_new_memstream( const picoByte_t *buffer, int bufSize )
{
picoMemStream_t *s;
/* types */
typedef struct picoParser_s
{
- char *buffer;
+ const char *buffer;
int bufSize;
char *token;
int tokenSize;
int tokenMax;
- char *cursor;
- char *max;
+ const char *cursor;
+ const char *max;
int curLine;
}
picoParser_t;
typedef struct picoMemStream_s
{
- picoByte_t *buffer;
+ const picoByte_t *buffer;
int bufSize;
- picoByte_t *curPos;
+ const picoByte_t *curPos;
int flag;
}
picoMemStream_t;
extern void *(*_pico_ptr_malloc)( size_t );
extern void (*_pico_ptr_free)( void* );
-extern void (*_pico_ptr_load_file)( char*, unsigned char**, int* );
+extern void (*_pico_ptr_load_file)( const char*, unsigned char**, int* );
extern void (*_pico_ptr_free_file)( void* );
extern void (*_pico_ptr_print)( int, const char* );
void _pico_free( void *ptr );
/* files */
-void _pico_load_file( char *name, unsigned char **buffer, int *bufSize );
+void _pico_load_file( const char *name, unsigned char **buffer, int *bufSize );
void _pico_free_file( void *buffer );
/* strings */
char *_pico_strrtrim( char *str );
int _pico_strchcount( char *str, int ch );
void _pico_printf( int level, const char *format, ... );
-char *_pico_stristr( char *str, const char *substr );
+const char *_pico_stristr( const char *str, const char *substr );
void _pico_unixify( char *path );
int _pico_nofname( const char *path, char *dest, int destSize );
const char *_pico_nopath( const char *path );
float _pico_little_float( float src );
/* pico ascii parser */
-picoParser_t *_pico_new_parser( picoByte_t *buffer, int bufSize );
+picoParser_t *_pico_new_parser( const picoByte_t *buffer, int bufSize );
void _pico_free_parser( picoParser_t *p );
int _pico_parse_ex( picoParser_t *p, int allowLFs, int handleQuoted );
char *_pico_parse_first( picoParser_t *p );
int _pico_parse_vec4_def( picoParser_t *p, picoVec4_t out, picoVec4_t def);
/* pico memory stream */
-picoMemStream_t *_pico_new_memstream( picoByte_t *buffer, int bufSize );
+picoMemStream_t *_pico_new_memstream( const picoByte_t *buffer, int bufSize );
void _pico_free_memstream( picoMemStream_t *s );
int _pico_memstream_read( picoMemStream_t *s, void *buffer, int len );
int _pico_memstream_getc( picoMemStream_t *s );
sets the ptr to the file load function
*/
-void PicoSetLoadFileFunc( void (*func)( char*, unsigned char**, int* ) )
+void PicoSetLoadFileFunc( void (*func)( const char*, unsigned char**, int* ) )
{
if( func != NULL )
_pico_ptr_load_file = func;
-picoModel_t *PicoModuleLoadModel( const picoModule_t* pm, char* fileName, picoByte_t* buffer, int bufSize, int frameNum )
+picoModel_t *PicoModuleLoadModel( const picoModule_t* pm, const char* fileName, picoByte_t* buffer, int bufSize, int frameNum )
{
char *modelFileName, *remapFileName;
the meat and potatoes function
*/
-picoModel_t *PicoLoadModel( char *fileName, int frameNum )
+picoModel_t *PicoLoadModel( const char *fileName, int frameNum )
{
const picoModule_t **modules, *pm;
picoModel_t *model;
PicoSet*() Setter Functions
----------------------------------------------------------------------------*/
-void PicoSetModelName( picoModel_t *model, char *name )
+void PicoSetModelName( picoModel_t *model, const char *name )
{
if( model == NULL || name == NULL )
return;
-void PicoSetModelFileName( picoModel_t *model, char *fileName )
+void PicoSetModelFileName( picoModel_t *model, const char *fileName )
{
if( model == NULL || fileName == NULL )
return;
*/
static int _3ds_canload( PM_PARAMS_CANLOAD )
{
- T3dsChunk *chunk;
-
- /* to keep the compiler happy */
- *fileName = *fileName;
+ const T3dsChunk *chunk;
/* sanity check */
- if (bufSize < sizeof(T3dsChunk))
+ if (bufSize < (int) sizeof(T3dsChunk))
return PICO_PMV_ERROR_SIZE;
/* get pointer to 3ds header chunk */
- chunk = (T3dsChunk *)buffer;
+ chunk = (const T3dsChunk *)buffer;
/* check data length */
- if (bufSize < _pico_little_long(chunk->len))
+ if (bufSize < (int) _pico_little_long(chunk->len))
return PICO_PMV_ERROR_SIZE;
/* check 3ds magic */
/* initialize persistant vars (formerly static) */
pers.model = model;
- pers.bufptr = (picoByte_t *)buffer;
+ pers.bufptr = (picoByte_t *)_pico_alloc(bufSize);
+ memcpy(pers.bufptr, buffer, bufSize);
pers.basename = (char *)basename;
pers.maxofs = bufSize;
pers.cofs = 0L;
if( bufSize < 80 )
return PICO_PMV_ERROR_SIZE;
- /* keep the friggin compiler happy */
- *fileName = *fileName;
-
/* create pico parser */
- p = _pico_new_parser( (picoByte_t*) buffer, bufSize );
+ p = _pico_new_parser( (const picoByte_t*) buffer, bufSize );
if( p == NULL )
return PICO_PMV_ERROR_MEMORY;
return NULL; \
}
/* create a new pico parser */
- p = _pico_new_parser( (picoByte_t *)buffer,bufSize );
+ p = _pico_new_parser( (const picoByte_t *)buffer,bufSize );
if (p == NULL) return NULL;
/* create a new pico model */
else if( !_pico_stricmp( p->token, "*material" ) )
{
aseSubMaterial_t* subMaterial = NULL;
- picoShader_t *shader;
+ picoShader_t *shader = NULL;
int level = 1, index;
char materialName[ 1024 ];
float transValue = 0.0f, shineValue = 1.0f;
static int _fm_canload( PM_PARAMS_CANLOAD )
{
fm_t fm;
- unsigned char *bb;
+ unsigned char *bb, *bb0;
int fm_file_pos;
- bb = (unsigned char *) buffer;
+ bb0 = bb = (picoByte_t*) _pico_alloc(bufSize);
+ memcpy(bb, buffer, bufSize);
// Header
fm.fm_header_hdr = (fm_chunk_header_t *) bb;
#ifdef FM_DBG
_pico_printf( PICO_WARNING, "FM Header Ident incorrect\n");
#endif
+ _pico_free(bb0);
return PICO_PMV_ERROR_IDENT;
}
#ifdef FM_DBG
_pico_printf( PICO_WARNING, "FM Header Version incorrect\n");
#endif
+ _pico_free(bb0);
return PICO_PMV_ERROR_VERSION;
}
#ifdef FM_DBG
_pico_printf( PICO_WARNING, "FM Skin Ident incorrect\n");
#endif
+ _pico_free(bb0);
return PICO_PMV_ERROR_IDENT;
}
#ifdef FM_DBG
_pico_printf( PICO_WARNING, "FM Skin Version incorrect\n");
#endif
+ _pico_free(bb0);
return PICO_PMV_ERROR_VERSION;
}
#ifdef FM_DBG
_pico_printf( PICO_WARNING, "FM ST Ident incorrect\n");
#endif
+ _pico_free(bb0);
return PICO_PMV_ERROR_IDENT;
}
#ifdef FM_DBG
_pico_printf( PICO_WARNING, "FM ST Version incorrect\n");
#endif
+ _pico_free(bb0);
return PICO_PMV_ERROR_VERSION;
}
#ifdef FM_DBG
_pico_printf( PICO_WARNING, "FM Tri Ident incorrect\n");
#endif
+ _pico_free(bb0);
return PICO_PMV_ERROR_IDENT;
}
#ifdef FM_DBG
_pico_printf( PICO_WARNING, "FM Tri Version incorrect\n");
#endif
+ _pico_free(bb0);
return PICO_PMV_ERROR_VERSION;
}
#ifdef FM_DBG
_pico_printf( PICO_WARNING, "FM Frame Ident incorrect\n");
#endif
+ _pico_free(bb0);
return PICO_PMV_ERROR_IDENT;
}
#ifdef FM_DBG
_pico_printf( PICO_WARNING, "FM Frame Version incorrect\n");
#endif
+ _pico_free(bb0);
return PICO_PMV_ERROR_VERSION;
}
fm_xyz_st_t *triangle;
fm_frame_t *frame;
- picoByte_t *bb;
+ picoByte_t *bb, *bb0;
picoModel_t *picoModel;
picoSurface_t *picoSurface;
picoShader_t *picoShader;
picoColor_t color;
- bb = (picoByte_t*) buffer;
+ bb0 = bb = (picoByte_t*) _pico_alloc(bufSize);
+ memcpy(bb, buffer, bufSize);
// Header Header
fm.fm_header_hdr = (fm_chunk_header_t *) bb;
if( (strcmp(fm.fm_header_hdr->ident, FM_HEADERCHUNKNAME)) )
{
_pico_printf( PICO_WARNING, "FM Header Ident incorrect\n");
+ _pico_free(bb0);
return NULL;
}
if( _pico_little_long( fm.fm_header_hdr->version ) != FM_HEADERCHUNKVER )
{
_pico_printf( PICO_WARNING, "FM Header Version incorrect\n");
+ _pico_free(bb0);
return NULL;
}
if( (strcmp(fm.fm_skin_hdr->ident, FM_SKINCHUNKNAME)) )
{
_pico_printf( PICO_WARNING, "FM Skin Ident incorrect\n");
+ _pico_free(bb0);
return NULL;
}
if( _pico_little_long( fm.fm_skin_hdr->version ) != FM_SKINCHUNKVER )
{
_pico_printf( PICO_WARNING, "FM Skin Version incorrect\n");
+ _pico_free(bb0);
return NULL;
}
if( (strcmp(fm.fm_st_hdr->ident, FM_STCOORDCHUNKNAME)) )
{
_pico_printf( PICO_WARNING, "FM ST Ident incorrect\n");
+ _pico_free(bb0);
return NULL;
}
if( _pico_little_long( fm.fm_st_hdr->version ) != FM_STCOORDCHUNKVER )
{
_pico_printf( PICO_WARNING, "FM ST Version incorrect\n");
+ _pico_free(bb0);
return NULL;
}
if( (strcmp(fm.fm_tri_hdr->ident, FM_TRISCHUNKNAME)) )
{
_pico_printf( PICO_WARNING, "FM Tri Ident incorrect\n");
+ _pico_free(bb0);
return NULL;
}
if( _pico_little_long( fm.fm_tri_hdr->version ) != FM_TRISCHUNKVER )
{
_pico_printf( PICO_WARNING, "FM Tri Version incorrect\n");
+ _pico_free(bb0);
return NULL;
}
if( (strcmp(fm.fm_frame_hdr->ident, FM_FRAMESCHUNKNAME)) )
{
_pico_printf( PICO_WARNING, "FM Frame Ident incorrect\n");
+ _pico_free(bb0);
return NULL;
}
if( _pico_little_long( fm.fm_frame_hdr->version ) != FM_FRAMESCHUNKVER )
{
_pico_printf( PICO_WARNING, "FM Frame Version incorrect\n");
+ _pico_free(bb0);
return NULL;
}
if( fm_head->numFrames < 1 )
{
_pico_printf( PICO_ERROR, "%s has 0 frames!", fileName );
+ _pico_free(bb0);
return NULL;
}
if( frameNum < 0 || frameNum >= fm_head->numFrames )
{
_pico_printf( PICO_ERROR, "Invalid or out-of-range FM frame specified" );
+ _pico_free(bb0);
return NULL;
}
texCoord->t = _pico_little_short( texCoord[i].t );
}
// set Skin Name
- strncpy(skinname, (unsigned char *) fm.fm_skin, FM_SKINPATHSIZE );
+ strncpy(skinname, (const char *) fm.fm_skin, FM_SKINPATHSIZE );
#ifdef FM_VERBOSE_DBG
// Print out md2 values
if( picoModel == NULL )
{
_pico_printf( PICO_ERROR, "Unable to allocate a new model" );
+ _pico_free(bb0);
return NULL;
}
{
_pico_printf( PICO_ERROR, "Unable to allocate a new model surface" );
PicoFreeModel( picoModel );
+ _pico_free(bb0);
return NULL;
}
{
_pico_printf( PICO_ERROR, "Unable to allocate a new model shader" );
PicoFreeModel( picoModel );
+ _pico_free(bb0);
return NULL;
}
_pico_free(p_index_LUT_DUPS);
/* return the new pico model */
+ _pico_free(bb0);
return picoModel;
}
int ret;
/* create a new pico memorystream */
- s = _pico_new_memstream( (picoByte_t *)buffer, bufSize );
+ s = _pico_new_memstream( (const picoByte_t *)buffer, bufSize );
if (s == NULL)
{
return PICO_PMV_ERROR_MEMORY;
}
/* create a new pico memorystream */
- s = _pico_new_memstream( (picoByte_t *)buffer, bufSize );
+ s = _pico_new_memstream( (const picoByte_t *)buffer, bufSize );
if (s == NULL)
{
return NULL;
static int _md2_canload( PM_PARAMS_CANLOAD )
{
- md2_t *md2;
-
- /* to keep the compiler happy */
- *fileName = *fileName;
+ const md2_t *md2;
/* sanity check */
- if( bufSize < ( sizeof( *md2 ) * 2) )
+ if( (size_t) bufSize < ( sizeof( *md2 ) * 2) )
return PICO_PMV_ERROR_SIZE;
/* set as md2 */
- md2 = (md2_t*) buffer;
+ md2 = (const md2_t*) buffer;
/* check md2 magic */
- if( *((int*) md2->magic) != *((int*) MD2_MAGIC) )
+ if( *((const int*) md2->magic) != *((const int*) MD2_MAGIC) )
return PICO_PMV_ERROR_IDENT;
/* check md2 version */
md2Triangle_t *triangle;
md2XyzNormal_t *vertex;
- picoByte_t *bb;
+ picoByte_t *bb, *bb0;
picoModel_t *picoModel;
picoSurface_t *picoSurface;
picoShader_t *picoShader;
/* set as md2 */
- bb = (picoByte_t*) buffer;
- md2 = (md2_t*) buffer;
+ bb0 = bb = (picoByte_t*) _pico_alloc(bufSize);
+ memcpy(bb, buffer, bufSize);
+ md2 = (md2_t*) bb;
/* check ident and version */
- if( *((int*) md2->magic) != *((int*) MD2_MAGIC) || _pico_little_long( md2->version ) != MD2_VERSION )
+ if( *((const int*) md2->magic) != *((const int*) MD2_MAGIC) || _pico_little_long( md2->version ) != MD2_VERSION )
{
/* not an md2 file (todo: set error) */
_pico_printf( PICO_ERROR, "%s is not an MD2 File!", fileName );
+ _pico_free(bb0);
return NULL;
}
if( md2->numFrames < 1 )
{
_pico_printf( PICO_ERROR, "%s has 0 frames!", fileName );
+ _pico_free(bb0);
return NULL;
}
if( frameNum < 0 || frameNum >= md2->numFrames )
{
_pico_printf( PICO_ERROR, "Invalid or out-of-range MD2 frame specified" );
+ _pico_free(bb0);
return NULL;
}
}
// set Skin Name
- strncpy(skinname, (bb + md2->ofsSkins), MD2_MAX_SKINNAME );
+ strncpy(skinname, (const char *) (bb + md2->ofsSkins), MD2_MAX_SKINNAME );
// Print out md2 values
_pico_printf(PICO_VERBOSE,"Skins: %d Verts: %d STs: %d Triangles: %d Frames: %d\nSkin Name \"%s\"\n", md2->numSkins, md2->numXYZ, md2->numST, md2->numTris, md2->numFrames, &skinname );
if( picoModel == NULL )
{
_pico_printf( PICO_ERROR, "Unable to allocate a new model" );
+ _pico_free(bb0);
return NULL;
}
{
_pico_printf( PICO_ERROR, "Unable to allocate a new model surface" );
PicoFreeModel( picoModel );
+ _pico_free(bb0);
return NULL;
}
{
_pico_printf( PICO_ERROR, "Unable to allocate a new model shader" );
PicoFreeModel( picoModel );
+ _pico_free(bb0);
return NULL;
}
_pico_free(p_index_LUT_DUPS);
/* return the new pico model */
+ _pico_free(bb0);
return picoModel;
}
static int _md3_canload( PM_PARAMS_CANLOAD )
{
- md3_t *md3;
+ const md3_t *md3;
- /* to keep the compiler happy */
- *fileName = *fileName;
-
/* sanity check */
- if( bufSize < ( sizeof( *md3 ) * 2) )
+ if( (size_t) bufSize < ( sizeof( *md3 ) * 2) )
return PICO_PMV_ERROR_SIZE;
/* set as md3 */
- md3 = (md3_t*) buffer;
+ md3 = (const md3_t*) buffer;
/* check md3 magic */
- if( *((int*) md3->magic) != *((int*) MD3_MAGIC) )
+ if( *((const int*) md3->magic) != *((const int*) MD3_MAGIC) )
return PICO_PMV_ERROR_IDENT;
/* check md3 version */
static picoModel_t *_md3_load( PM_PARAMS_LOAD )
{
int i, j;
- picoByte_t *bb;
+ picoByte_t *bb, *bb0;
md3_t *md3;
md3Surface_t *surface;
md3Shader_t *shader;
/* set as md3 */
- bb = (picoByte_t*) buffer;
- md3 = (md3_t*) buffer;
+ bb0 = bb = (picoByte_t*) _pico_alloc(bufSize);
+ memcpy(bb, buffer, bufSize);
+ md3 = (md3_t*) bb;
/* check ident and version */
if( *((int*) md3->magic) != *((int*) MD3_MAGIC) || _pico_little_long( md3->version ) != MD3_VERSION )
{
/* not an md3 file (todo: set error) */
+ _pico_free(bb0);
return NULL;
}
if( md3->numFrames < 1 )
{
_pico_printf( PICO_ERROR, "MD3 with 0 frames" );
+ _pico_free(bb0);
return NULL;
}
if( frameNum < 0 || frameNum >= md3->numFrames )
{
_pico_printf( PICO_ERROR, "Invalid or out-of-range MD3 frame specified" );
+ _pico_free(bb0);
return NULL;
}
if( picoModel == NULL )
{
_pico_printf( PICO_ERROR, "Unable to allocate a new model" );
+ _pico_free(bb0);
return NULL;
}
{
_pico_printf( PICO_ERROR, "Unable to allocate a new model surface" );
PicoFreeModel( picoModel ); /* sea */
+ _pico_free(bb0);
return NULL;
}
{
_pico_printf( PICO_ERROR, "Unable to allocate a new model shader" );
PicoFreeModel( picoModel );
+ _pico_free(bb0);
return NULL;
}
}
/* return the new pico model */
+ _pico_free(bb0);
return picoModel;
}
static int _mdc_canload( PM_PARAMS_CANLOAD )
{
- mdc_t *mdc;
+ const mdc_t *mdc;
-
- /* to keep the compiler happy */
- *fileName = *fileName;
/* sanity check */
- if( bufSize < ( sizeof( *mdc ) * 2) )
+ if( (size_t) bufSize < ( sizeof( *mdc ) * 2) )
return PICO_PMV_ERROR_SIZE;
/* set as mdc */
- mdc = (mdc_t*) buffer;
+ mdc = (const mdc_t*) buffer;
/* check mdc magic */
- if( *((int*) mdc->magic) != *((int*) MDC_MAGIC) )
+ if( *((const int*) mdc->magic) != *((const int*) MDC_MAGIC) )
return PICO_PMV_ERROR_IDENT;
/* check mdc version */
static picoModel_t *_mdc_load( PM_PARAMS_LOAD )
{
int i, j;
- picoByte_t *bb;
+ picoByte_t *bb, *bb0;
mdc_t *mdc;
mdcSurface_t *surface;
mdcShader_t *shader;
mdcFrame_t *frame;
mdcTriangle_t *triangle;
mdcVertex_t *vertex;
- mdcXyzCompressed_t *vertexComp;
- short *mdcShort, *mdcCompVert;
+ mdcXyzCompressed_t *vertexComp = NULL;
+ short *mdcShort, *mdcCompVert = NULL;
double lat, lng;
picoModel_t *picoModel;
/* set as mdc */
- bb = (picoByte_t*) buffer;
- mdc = (mdc_t*) buffer;
+ bb0 = bb = (picoByte_t*) _pico_alloc(bufSize);
+ memcpy(bb, buffer, bufSize);
+ mdc = (mdc_t*) bb;
/* check ident and version */
if( *((int*) mdc->magic) != *((int*) MDC_MAGIC) || _pico_little_long( mdc->version ) != MDC_VERSION )
{
/* not an mdc file (todo: set error) */
+ _pico_free(bb0);
return NULL;
}
if( mdc->numFrames < 1 )
{
_pico_printf( PICO_ERROR, "MDC with 0 frames" );
+ _pico_free(bb0);
return NULL;
}
if( frameNum < 0 || frameNum >= mdc->numFrames )
{
_pico_printf( PICO_ERROR, "Invalid or out-of-range MDC frame specified" );
+ _pico_free(bb0);
return NULL;
}
if( picoModel == NULL )
{
_pico_printf( PICO_ERROR, "Unable to allocate a new model" );
+ _pico_free(bb0);
return NULL;
}
{
_pico_printf( PICO_ERROR, "Unable to allocate a new model surface" );
PicoFreeModel( picoModel ); /* sea */
+ _pico_free(bb0);
return NULL;
}
{
_pico_printf( PICO_ERROR, "Unable to allocate a new model shader" );
PicoFreeModel( picoModel );
+ _pico_free(bb0);
return NULL;
}
}
/* return the new pico model */
+ _pico_free(bb0);
return picoModel;
}
*/
static int _ms3d_canload( PM_PARAMS_CANLOAD )
{
- TMsHeader *hdr;
+ const TMsHeader *hdr;
- /* to keep the compiler happy */
- *fileName = *fileName;
-
/* sanity check */
- if (bufSize < sizeof(TMsHeader))
+ if ((size_t) bufSize < sizeof(TMsHeader))
return PICO_PMV_ERROR_SIZE;
/* get ms3d header */
- hdr = (TMsHeader *)buffer;
+ hdr = (const TMsHeader *)buffer;
/* check ms3d magic */
if (strncmp(hdr->magic,"MS3D000000",10) != 0)
static picoModel_t *_ms3d_load( PM_PARAMS_LOAD )
{
picoModel_t *model;
- unsigned char *bufptr;
+ unsigned char *bufptr, *bufptr0;
int shaderRefs[ MS3D_MAX_GROUPS ];
int numGroups;
int numMaterials;
PicoSetModelName( model, fileName );
PicoSetModelFileName( model, fileName );
+ bufptr0 = bufptr = (picoByte_t*) _pico_alloc(bufSize);
+ memcpy(bufptr, buffer, bufSize);
/* skip header */
- bufptr = (unsigned char *)buffer + sizeof(TMsHeader);
+ bufptr += sizeof(TMsHeader);
/* get number of vertices */
bufptr = GetWord( bufptr,&numVerts );
{
_pico_printf( PICO_ERROR,"Vertex %d index %d out of range (%d, max %d)",i,k,triangle->vertexIndices[k],numVerts-1);
PicoFreeModel( model );
+ _pico_free(bufptr0);
return NULL; /* yuck */
}
}
if (surface == NULL)
{
PicoFreeModel( model );
+ _pico_free(bufptr0);
return NULL;
}
/* do surface setup */
if (shader == NULL)
{
PicoFreeModel( model );
+ _pico_free(bufptr0);
return NULL;
}
/* scale shader colors */
#endif
}
/* return allocated pico model */
+ _pico_free(bufptr0);
return model;
// return NULL;
}
/* appearing at the beginning of wavefront objects */
/* alllocate a new pico parser */
- p = _pico_new_parser( (picoByte_t *)buffer,bufSize );
+ p = _pico_new_parser( (const picoByte_t *)buffer,bufSize );
if (p == NULL)
return PICO_PMV_ERROR_MEMORY;
return NULL; \
}
/* alllocate a new pico parser */
- p = _pico_new_parser( (picoByte_t *)buffer,bufSize );
+ p = _pico_new_parser( (const picoByte_t *)buffer,bufSize );
if (p == NULL) return NULL;
/* create a new pico model */
int ivt[ 4 ], has_vt = 0;
int ivn[ 4 ], has_vn = 0;
int have_quad = 0;
- int slashcount;
- int doubleslash;
+ int slashcount = 0;
+ int doubleslash = 0;
int i;
if(curSurface == NULL)
picoParser_t *p;
- /* keep the friggin compiler happy */
- *fileName = *fileName;
-
/* create pico parser */
- p = _pico_new_parser( (picoByte_t*) buffer, bufSize );
+ p = _pico_new_parser( (const picoByte_t*) buffer, bufSize );
if( p == NULL )
return PICO_PMV_ERROR_MEMORY;
picoColor_t color;
- /* keep the friggin compiler happy */
- *fileName = *fileName;
-
/* create pico parser */
- p = _pico_new_parser( (picoByte_t*) buffer, bufSize );
+ p = _pico_new_parser( (const picoByte_t*) buffer, bufSize );
if( p == NULL )
return NULL;
}
strncpy (qdir, path, c+len+count-path);
Sys_Printf ("qdir: %s\n", qdir);
- for ( i = 0; i < strlen( qdir ); i++ )
+ for ( i = 0; i < (int) strlen( qdir ); i++ )
{
if ( qdir[i] == '\\' )
qdir[i] = '/';
{
strncpy (gamedir, path, c+1-path);
- for ( i = 0; i < strlen( gamedir ); i++ )
+ for ( i = 0; i < (int) strlen( gamedir ); i++ )
{
if ( gamedir[i] == '\\' )
gamedir[i] = '/';
char *ExpandPath (const char *path)
{
static char full[1024];
- if (!qdir)
+ if (!*qdir)
Error ("ExpandPath called without qdir set");
if (path[0] == '/' || path[0] == '\\' || path[1] == ':') {
strcpy( full, path );
char *ExpandGamePath (const char *path)
{
static char full[1024];
- if (!qdir)
+ if (!*qdir)
Error ("ExpandGamePath called without qdir set");
if (path[0] == '/' || path[0] == '\\' || path[1] == ':') {
strcpy( full, path );
double I_FloatTime( void );
-void Error( const char *error, ... );
+void Error( const char *error, ... )
+#ifdef __GNUC__
+__attribute__((noreturn))
+#endif
+;
int CheckParm( const char *check );
FILE *SafeOpenWrite( const char *filename );
for( y = 0; y <= pcx->ymax; y++, pix += pcx->xmax + 1 )
{
/* do a scanline */
+ runLength = 0;
for( x=0; x <= pcx->xmax; )
{
/* RR2DO2 */
//
// load the file
//
- nLen = vfsLoadFile ( ( char * ) name, (void **)&buffer, 0);
+ nLen = vfsLoadFile ( name, (void **)&buffer, 0);
if (nLen == -1)
{
Error ("Couldn't read %s", name);
void WriteTGAGray (const char *filename, byte *data, int width, int height) {
byte buffer[18];
- int i;
- int c;
FILE *f;
memset (buffer, 0, 18);
char buf[1024];
sprintf (buf, "%f %f %f", v[0], v[1], v[2]);
- ret = xmlNewNode (NULL, "point");
- xmlNodeSetContent (ret, buf);
+ ret = xmlNewNode (NULL, (xmlChar*)"point");
+ xmlNodeSetContent (ret, (xmlChar*)buf);
return ret;
}
// l_net library defines an upper limit of MAX_NETMESSAGE
// there are some size check errors, so we use MAX_NETMESSAGE-10 to be safe
// if the size of the buffer exceeds MAX_NETMESSAGE-10 we'll send in several network messages
- while (pos < xml_buf->use)
+ while (pos < (int)xml_buf->use)
{
// what size are we gonna send now?
(xml_buf->use - pos < MAX_NETMESSAGE - 10) ? (size = xml_buf->use - pos) : (size = MAX_NETMESSAGE - 10);
// now build a proper "select" XML node
sprintf (buf, "Entity %i, Brush %i: %s", entitynum, brushnum, msg);
- node = xmlNewNode (NULL, "select");
- xmlNodeSetContent (node, buf);
+ node = xmlNewNode (NULL, (xmlChar*)"select");
+ xmlNodeSetContent (node, (xmlChar*)buf);
level[0] = (int)'0' + (bError ? SYS_ERR : SYS_WRN) ;
level[1] = 0;
- xmlSetProp (node, "level", (char *)&level);
+ xmlSetProp (node, (xmlChar*)"level", (xmlChar *)&level);
// a 'select' information
sprintf (buf, "%i %i", entitynum, brushnum);
- select = xmlNewNode (NULL, "brush");
- xmlNodeSetContent (select, buf);
+ select = xmlNewNode (NULL, (xmlChar*)"brush");
+ xmlNodeSetContent (select, (xmlChar*)buf);
xmlAddChild (node, select);
xml_SendNode (node);
char buf[1024];
char level[2];
- node = xmlNewNode (NULL, "pointmsg");
- xmlNodeSetContent (node, msg);
+ node = xmlNewNode (NULL, (xmlChar*)"pointmsg");
+ xmlNodeSetContent (node, (xmlChar*)msg);
level[0] = (int)'0' + SYS_ERR;
level[1] = 0;
- xmlSetProp (node, "level", (char *)&level);
+ xmlSetProp (node, (xmlChar*)"level", (xmlChar *)&level);
// a 'point' node
sprintf (buf, "%g %g %g", pt[0], pt[1], pt[2]);
- point = xmlNewNode (NULL, "point");
- xmlNodeSetContent (point, buf);
+ point = xmlNewNode (NULL, (xmlChar*)"point");
+ xmlNodeSetContent (point, (xmlChar*)buf);
xmlAddChild (node, point);
xml_SendNode (node);
char level[2];
int i;
- node = xmlNewNode (NULL, "windingmsg");
- xmlNodeSetContent (node, msg);
+ node = xmlNewNode (NULL, (xmlChar*)"windingmsg");
+ xmlNodeSetContent (node, (xmlChar*)msg);
level[0] = (int)'0' + SYS_ERR;
level[1] = 0;
- xmlSetProp (node, "level", (char *)&level);
+ xmlSetProp (node, (xmlChar*)"level", (xmlChar *)&level);
// a 'winding' node
sprintf( buf, "%i ", numpoints);
for(i = 0; i < numpoints; i++)
strcat( buf, smlbuf);
}
- winding = xmlNewNode (NULL, "winding");
- xmlNodeSetContent (winding, buf);
+ winding = xmlNewNode (NULL, (xmlChar*)"winding");
+ xmlNodeSetContent (winding, (xmlChar*)buf);
xmlAddChild (node, winding);
xml_SendNode (node);
char sMsg[1024];
Net_Setup();
- Net_StringToAddress((char *)dest, &address);
+ Net_StringToAddress(dest, &address);
brdcst_socket = Net_Connect(&address, 0);
if (brdcst_socket)
{
if (!bGotXML)
{
// initialize
- doc = xmlNewDoc("1.0");
- doc->children = xmlNewDocRawNode(doc, NULL, "q3map_feedback", NULL);
+ doc = xmlNewDoc((xmlChar*)"1.0");
+ doc->children = xmlNewDocRawNode(doc, NULL, (xmlChar*)"q3map_feedback", NULL);
bGotXML = qtrue;
}
- node = xmlNewNode (NULL, "message");
+ node = xmlNewNode (NULL, (xmlChar*)"message");
{
gchar* utf8 = g_locale_to_utf8(buf, -1, NULL, NULL, NULL);
- xmlNodeSetContent(node, utf8);
+ xmlNodeSetContent(node, (xmlChar*)utf8);
g_free(utf8);
}
level[0] = (int)'0' + flag;
level[1] = 0;
- xmlSetProp (node, "level", (char *)&level );
+ xmlSetProp (node, (xmlChar*)"level", (xmlChar *)&level );
xml_SendNode (node);
}
/* we check the magic */
if (err==UNZ_OK)
+ {
if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
err=UNZ_ERRNO;
else if (uMagic!=0x02014b50)
err=UNZ_BADZIPFILE;
+ }
if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK)
err=UNZ_ERRNO;
uSizeRead = extraFieldBufferSize;
if (lSeek!=0)
+ {
if (fseek(s->file,lSeek,SEEK_CUR)==0)
lSeek=0;
else
err=UNZ_ERRNO;
+ }
if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1)
err=UNZ_ERRNO;
uSizeRead = commentBufferSize;
if (lSeek!=0)
+ {
if (fseek(s->file,lSeek,SEEK_CUR)==0)
lSeek=0;
else
err=UNZ_ERRNO;
+ }
if ((file_info.size_file_comment>0) && (commentBufferSize>0))
if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1)
err=UNZ_ERRNO;
if (err==UNZ_OK)
+ {
if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
err=UNZ_ERRNO;
else if (uMagic!=0x04034b50)
err=UNZ_BADZIPFILE;
+ }
if (unzlocal_getShort(s->file,&uData) != UNZ_OK)
err=UNZ_ERRNO;
/* compute minimum size table less than or equal to l bits */
z = g - w;
- z = z > (uInt)l ? l : z; /* table size upper limit */
+ z = z > (uInt)l ? (uInt)l : z; /* table size upper limit */
if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */
{ /* too few codes for k-w bit table */
f -= a + 1; /* deduct codes from patterns left */
/* set up table entry in r */
r.bits = (Byte)(k - w);
if (p >= v + n)
+ {
r.exop = 128 + 64; /* out of values--invalid code */
+ r.base = 0;
+ }
else if (*p < s)
{
r.exop = (Byte)(*p < 256 ? 0 : 32 + 64); /* 256 is end-of-block */
Sys_FPrintf( SYS_NOXML, "******* leaked *******\n" );
Sys_FPrintf( SYS_NOXML, "**********************\n" );
polyline = LeakFile( tree );
- leaknode = xmlNewNode( NULL, "message" );
- xmlNodeSetContent( leaknode, "MAP LEAKED\n" );
+ leaknode = xmlNewNode( NULL, (xmlChar*)"message" );
+ xmlNodeSetContent( leaknode, (xmlChar*)"MAP LEAKED\n" );
xmlAddChild( leaknode, polyline );
level[0] = (int) '0' + SYS_ERR;
level[1] = 0;
- xmlSetProp( leaknode, "level", (char*) &level );
+ xmlSetProp( leaknode, (xmlChar*)"level", (xmlChar*) &level );
xml_SendNode( leaknode );
if( leaktest )
{
VectorSet( normal, 0, 0, -1 );
/* create the flare surface (note shader defaults automatically) */
- DrawSurfaceForFlare( mapEntityNum, origin, normal, color, (char*) flareShader, lightStyle );
+ DrawSurfaceForFlare( mapEntityNum, origin, normal, color, flareShader, lightStyle );
}
}
}
--- /dev/null
+/* -------------------------------------------------------------------------------
+
+Copyright (C) 1999-2007 id Software, Inc. and contributors.
+For a list of contributors, see the accompanying CONTRIBUTORS file.
+
+This file is part of GtkRadiant.
+
+GtkRadiant 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.
+
+GtkRadiant 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 GtkRadiant; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+----------------------------------------------------------------------------------
+
+This code has been altered significantly from its original form, to support
+several games based on the Quake III Arena engine, in the form of "Q3Map2."
+
+------------------------------------------------------------------------------- */
+
+
+
+/* marker */
+#ifndef GAME__NULL_H
+#define GAME__NULL_H
+
+
+
+/* -------------------------------------------------------------------------------
+
+content and surface flags
+are in game_quake3.h
+
+------------------------------------------------------------------------------- */
+
+
+
+/* -------------------------------------------------------------------------------
+
+game_t struct
+
+------------------------------------------------------------------------------- */
+
+{
+ NULL, /* -game x */
+ NULL, /* default base game data dir */
+ NULL, /* unix home sub-dir */
+ NULL, /* magic path word */
+ NULL, /* shader directory */
+ 0, /* max lightmapped surface verts */
+ 0, /* max surface verts */
+ 0, /* max surface indexes */
+ qfalse, /* flares */
+ NULL, /* default flare shader */
+ qfalse, /* wolf lighting model? */
+ 0, /* lightmap width/height */
+ 0, /* lightmap gamma */
+ 0, /* lightmap exposure */
+ 0, /* lightmap compensate */
+ 0, /* lightgrid scale */
+ 0, /* lightgrid ambient scale */
+ qfalse, /* light angle attenuation uses half-lambert curve */
+ qfalse, /* disable shader lightstyles hack */
+ qfalse, /* keep light entities on bsp */
+ 0, /* default patchMeta subdivisions tolerance */
+ qfalse, /* patch casting enabled */
+ qfalse, /* compile deluxemaps */
+ 0, /* deluxemaps default mode */
+ 0, /* minimap size */
+ 0, /* minimap sharpener */
+ 0, /* minimap border */
+ qfalse, /* minimap keep aspect */
+ MINIMAP_MODE_GRAY, /* minimap mode */
+ NULL, /* minimap name format */
+ NULL, /* bsp file prefix */
+ 0, /* bsp file version */
+ qfalse, /* cod-style lump len/ofs order */
+ NULL, /* bsp load function */
+ NULL, /* bsp write function */
+
+ {
+ { NULL, 0, 0, 0, 0, 0, 0 }
+ }
+}
+
+
+
+/* end marker */
+#endif
+
typedef struct pngBuffer_s
{
byte *buffer;
- int size, offset;
+ png_size_t size, offset;
}
pngBuffer_t;
png_struct *png;
png_info *info, *end;
pngBuffer_t pb;
- int i, bitDepth, colorType, channels;
- png_uint_32 w, h;
+ int bitDepth, colorType, channels;
+ png_uint_32 w, h, i;
byte **rowPointers;
if (!linefile)
Error ("Couldn't open %s\n", filename);
- xml_node = xmlNewNode (NULL, "polyline");
+ xml_node = xmlNewNode (NULL, (xmlChar*)"polyline");
count = 0;
node = &tree->outside_node;
while (node->occupied > 1)
{
int next;
- portal_t *p, *nextportal;
- node_t *nextnode;
+ portal_t *p, *nextportal = NULL;
+ node_t *nextnode = NULL;
int s;
// find the best portal exit
/* return to sender */
return 1;
}
+ else
+ Error("Light of undefined type!");
/* VorteX: set noShadow color */
VectorScale(light->color, add, trace->colorNoShadow);
vec3_t color;
float f;
int b, bt;
- qboolean minVertex, minGrid, ps;
+ qboolean minVertex, minGrid;
const char *value;
static void RadSubdivideDiffuseLight( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm, shaderInfo_t *si,
float scale, float subdivide, qboolean original, radWinding_t *rw, clipWork_t *cw )
{
- int i, style;
+ int i, style = 0;
float dist, area, value;
vec3_t mins, maxs, normal, d1, d2, cross, color, gradient;
light_t *light, *splash;
light->falloffTolerance = falloffTolerance;
/* bouncing light? */
- if( bouncing == qfalse )
+ if( !bouncing )
{
/* handle first-pass lights in normal q3a style */
value = si->value;
mid.xyz[ k ] = -plane[ 3 ];
else
mid.xyz[ k ] = a->xyz[ k ] + frac * (b->xyz[ k ] - a->xyz[ k ]);
-
- /* set texture coordinates */
- if( k > 1 )
- continue;
- mid.st[ 0 ] = a->st[ 0 ] + frac * (b->st[ 0 ] - a->st[ 0 ]);
- mid.st[ 1 ] = a->st[ 1 ] + frac * (b->st[ 1 ] - a->st[ 1 ]);
}
+ /* set texture coordinates */
+ mid.st[ 0 ] = a->st[ 0 ] + frac * (b->st[ 0 ] - a->st[ 0 ]);
+ mid.st[ 1 ] = a->st[ 1 ] + frac * (b->st[ 1 ] - a->st[ 1 ]);
/* copy midpoint to front and back polygons */
front->v[ front->numVerts++ ] = mid;
-/*
-FilterPointToTraceNodes_r() - ydnar
-debugging tool
-*/
-
-static int FilterPointToTraceNodes_r( vec3_t pt, int nodeNum )
-{
- float dot;
- traceNode_t *node;
-
-
- if( nodeNum < 0 || nodeNum >= numTraceNodes )
- return -1;
-
- node = &traceNodes[ nodeNum ];
-
- if( node->type >= 0 )
- {
- dot = DotProduct( pt, node->plane ) - node->plane[ 3 ];
- if( dot > -0.001f )
- FilterPointToTraceNodes_r( pt, node->children[ 0 ] );
- if( dot < 0.001f )
- FilterPointToTraceNodes_r( pt, node->children[ 1 ] );
- return -1;
- }
-
- Sys_Printf( "%d ", nodeNum );
-
- return nodeNum;
-}
-
-
-
/*
FilterTraceWindingIntoNodes_r() - ydnar
filters a trace winding into the raytracing tree
/* external model */
default:
frame = IntForKey( e, "_frame" );
- model = LoadModel( (char*) value, frame );
+ model = LoadModel( value, frame );
if( model == NULL )
continue;
PopulateWithPicoModel( castShadows, model, transform );
/* external model */
default:
frame = IntForKey( e, "_frame2" );
- model = LoadModel( (char*) value, frame );
+ model = LoadModel( value, frame );
if( model == NULL )
continue;
PopulateWithPicoModel( castShadows, model, transform );
if( MapQuad( lm, info, dv ) )
continue;
- /* get drawverts and map first triangle */
- MapTriangle( lm, info, dv, mapNonAxial );
-
- /* get drawverts and map second triangle */
- dv[ 1 ] = &verts[ pw[ r + 2 ] ];
- dv[ 2 ] = &verts[ pw[ r + 3 ] ];
- MapTriangle( lm, info, dv, mapNonAxial );
+ for( mapNonAxial = 0; mapNonAxial < 2; mapNonAxial++ )
+ {
+ /* get drawverts and map first triangle */
+ MapTriangle( lm, info, dv, mapNonAxial );
+
+ /* get drawverts and map second triangle */
+ dv[ 1 ] = &verts[ pw[ r + 2 ] ];
+ dv[ 2 ] = &verts[ pw[ r + 3 ] ];
+ MapTriangle( lm, info, dv, mapNonAxial );
+ }
}
}
//% normal2 = SUPER_NORMAL( x, y );
}
else
- Sys_Printf( "WARNING: Spurious lightmap S vector\n" );
+ {
+ Error( "Spurious lightmap S vector\n" );
+ }
VectorSubtract( origin2, origin, originVecs[ 0 ] );
//% VectorSubtract( normal2, normal, normalVecs[ 0 ] );
void IlluminateRawLightmap( int rawLightmapNum )
{
- int i, t, x, y, sx, sy, size, llSize, ldSize, luxelFilterRadius, lightmapNum;
+ int i, t, x, y, sx, sy, size, luxelFilterRadius, lightmapNum;
int *cluster, *cluster2, mapped, lighted, totalLighted;
+ size_t llSize, ldSize;
rawLightmap_t *lm;
surfaceInfo_t *info;
qboolean filterColor, filterDir;
radVertLuxel[ 2 ] <= ambientColor[ 2 ] )
{
/* nudge the sample point around a bit */
- for( x = 0; x < 4; x++ )
+ for( x = 0; x < 5; x++ )
{
/* two's complement 0, 1, -1, 2, -2, etc */
x1 = ((x >> 1) ^ (x & 1 ? -1 : 0)) + (x & 1);
- for( y = 0; y < 4; y++ )
+ for( y = 0; y < 5; y++ )
{
y1 = ((y >> 1) ^ (y & 1 ? -1 : 0)) + (y & 1);
- for( z = 0; z < 4; z++ )
+ for( z = 0; z < 5; z++ )
{
z1 = ((z >> 1) ^ (z & 1 ? -1 : 0)) + (z & 1);
trace.cluster = ClusterForPointExtFilter( origin, VERTEX_EPSILON, info->numSurfaceClusters, &surfaceClusters[ info->firstSurfaceCluster ] );
if( trace.cluster < 0 )
continue;
+
+ /* r7 dirt */
+ if( dirty && !bouncing )
+ dirt = DirtForSample( &trace );
+ else
+ dirt = 1.0f;
+
+ /* jal: floodlight */
+ floodLightAmount = 0.0f;
+ VectorClear( floodColor );
+ if( floodlighty && !bouncing )
+ {
+ floodLightAmount = floodlightIntensity * FloodLightForSample( &trace, floodlightDistance, floodlight_lowquality );
+ VectorScale( floodlightRGB, floodLightAmount, floodColor );
+ }
/* trace */
LightingAtSample( &trace, ds->vertexStyles, colors );
int i, x, y, z, x1, y1, z1;
light_t *light, *light2, **owner;
bspLeaf_t *leaf;
- vec3_t origin, dir, mins, maxs, nullVector = { 0, 0, 0 };
+ vec3_t origin, dir, mins, maxs;
float radius, intensity;
light_t *buckets[ 256 ];
/* check for fast mode */
if( !(light->flags & LIGHT_FAST) && !(light->flags & LIGHT_FAST_TEMP) )
light->envelope = MAX_WORLD_COORD * 8.0f;
+ intensity = light->photons; /* hopefully not used */
}
else
{
/* get shaders */
- asi = surfaceInfos[ *((int*) a) ].si;
- bsi = surfaceInfos[ *((int*) b) ].si;
+ asi = surfaceInfos[ *((const int*) a) ].si;
+ bsi = surfaceInfos[ *((const int*) b) ].si;
/* dummy check */
if( asi == NULL )
/* get surface info */
- aInfo = &surfaceInfos[ *((int*) a) ];
- bInfo = &surfaceInfos[ *((int*) b) ];
+ aInfo = &surfaceInfos[ *((const int*) a) ];
+ bInfo = &surfaceInfos[ *((const int*) b) ];
/* model first */
if( aInfo->modelindex < bInfo->modelindex )
/* get lightmaps */
- alm = &rawLightmaps[ *((int*) a) ];
- blm = &rawLightmaps[ *((int*) b) ];
+ alm = &rawLightmaps[ *((const int*) a) ];
+ blm = &rawLightmaps[ *((const int*) b) ];
/* get min number of surfaces */
min = (alm->numLightSurfaces < blm->numLightSurfaces ? alm->numLightSurfaces : blm->numLightSurfaces);
char dirname[ 1024 ], filename[ 1024 ];
shaderInfo_t *csi;
char lightmapName[ 128 ];
- char *rgbGenValues[ 256 ];
- char *alphaGenValues[ 256 ];
+ const char *rgbGenValues[ 256 ];
+ const char *alphaGenValues[ 256 ];
/* note it */
if( rgbGenValues[ style ] == NULL )
{
sprintf( key, "_style%drgbgen", style );
- rgbGenValues[ style ] = (char*) ValueForKey( &entities[ 0 ], key );
+ rgbGenValues[ style ] = ValueForKey( &entities[ 0 ], key );
if( rgbGenValues[ style ][ 0 ] == '\0' )
rgbGenValues[ style ] = "wave noise 0.5 1 0 5.37";
}
if( alphaGenValues[ style ] == NULL )
{
sprintf( key, "_style%dalphagen", style );
- alphaGenValues[ style ] = (char*) ValueForKey( &entities[ 0 ], key );
+ alphaGenValues[ style ] = ValueForKey( &entities[ 0 ], key );
}
if( alphaGenValues[ style ][ 0 ] != '\0' )
sprintf( alphaGen, "\t\talphaGen %s // style %d\n", alphaGenValues[ style ], style );
int planenum;
shaderInfo_t *si;
vec_t shift[ 2 ];
- vec_t rotate;
+ vec_t rotate = 0;
vec_t scale[ 2 ];
char name[ MAX_QPATH ];
char shader[ MAX_QPATH ];
{
FILE *file;
brush_t *b;
- int oldNumEntities, numMapBrushes;
+ int oldNumEntities = 0, numMapBrushes;
/* note it */
callback for picomodel.lib
*/
-void PicoLoadFileFunc( char *name, byte **buffer, int *bufSize )
+void PicoLoadFileFunc( const char *name, byte **buffer, int *bufSize )
{
- *bufSize = vfsLoadFile( (const char*) name, (void**) buffer, 0 );
+ *bufSize = vfsLoadFile( name, (void**) buffer, 0 );
}
Error( "MAX_MODELS (%d) exceeded, there are too many model files referenced by the map.", MAX_MODELS );
/* attempt to parse model */
- *pm = PicoLoadModel( (char*) name, frame );
+ *pm = PicoLoadModel( name, frame );
/* if loading failed, make a bogus model to silence the rest of the warnings */
if( *pm == NULL )
return NULL;
/* set data */
- PicoSetModelName( *pm, (char*) name );
+ PicoSetModelName( *pm, name );
PicoSetModelFrameNum( *pm, frame );
}
strcpy( installPath, "../" );
#else
char temp[ MAX_OS_PATH ];
+ char last0[ 2 ];
char *home;
char *path;
char *last;
/* do some path divining */
strcpy( temp, argv0 );
- if( strrchr( temp, '/' ) )
+ if( strrchr( argv0, '/' ) )
argv0 = strrchr( argv0, '/' ) + 1;
else
{
path = getenv( "PATH" );
/* minor setup */
+ last = last0;
last[ 0 ] = path[ 0 ];
last[ 1 ] = '\0';
found = qfalse;
------------------------------------------------------------------------------- */
/* ydnar: for smaller structs */
-typedef char qb_t;
+typedef unsigned char qb_t;
/* ydnar: for q3map_tcMod */
/* model.c */
void PicoPrintFunc( int level, const char *str );
-void PicoLoadFileFunc( char *name, byte **buffer, int *bufSize );
+void PicoLoadFileFunc( const char *name, byte **buffer, int *bufSize );
picoModel_t *FindModel( const char *name, int frame );
picoModel_t *LoadModel( const char *name, int frame );
void InsertModel( const char *name, int skin, int frame, m4x4_t transform, remap_t *remap, shaderInfo_t *celShader, int eNum, int castShadows, int recvShadows, int spawnFlags, float lightmapScale, int lightmapSampleSize, float shadeAngle );
mapDrawSurface_t *AllocDrawSurface( surfaceType_t type );
void FinishSurface( mapDrawSurface_t *ds );
void StripFaceSurface( mapDrawSurface_t *ds );
+void MaxAreaFaceSurface( mapDrawSurface_t *ds );
qboolean CalcSurfaceTextureRange( mapDrawSurface_t *ds );
qboolean CalcLightmapAxis( vec3_t normal, vec3_t axis );
void ClassifySurfaces( int numSurfs, mapDrawSurface_t *ds );
void AddEntitySurfaceModels( entity_t *e );
mapDrawSurface_t *DrawSurfaceForSide( entity_t *e, brush_t *b, side_t *s, winding_t *w );
mapDrawSurface_t *DrawSurfaceForMesh( entity_t *e, parseMesh_t *p, mesh_t *mesh );
-mapDrawSurface_t *DrawSurfaceForFlare( int entNum, vec3_t origin, vec3_t normal, vec3_t color, char *flareShader, int lightStyle );
+mapDrawSurface_t *DrawSurfaceForFlare( int entNum, vec3_t origin, vec3_t normal, vec3_t color, const char *flareShader, int lightStyle );
mapDrawSurface_t *DrawSurfaceForShader( char *shader );
void ClipSidesIntoTree( entity_t *e, tree_t *tree );
void MakeDebugPortalSurfs( tree_t *tree );
,
#include "game_prophecy.h" /* vortex: prophecy game ( darkplaces q1 engine) */
,
- { NULL } /* null game */
+ #include "game__null.h" /* null game (must be last item) */
};
#endif
Q_EXTERN game_t *game Q_ASSIGN( &games[ 0 ] );
creates a flare draw surface
*/
-mapDrawSurface_t *DrawSurfaceForFlare( int entNum, vec3_t origin, vec3_t normal, vec3_t color, char *flareShader, int lightStyle )
+mapDrawSurface_t *DrawSurfaceForFlare( int entNum, vec3_t origin, vec3_t normal, vec3_t color, const char *flareShader, int lightStyle )
{
mapDrawSurface_t *ds;
}
/* parse the file */
- ParseFromMemory( buffer, size );
+ ParseFromMemory( (char *) buffer, size );
/* tokenize it */
while( 1 )
Error( "MAX_INDEXES exceeded for surface (%d > %d) (%d verts)", numIndexes, MAX_INDEXES, ds->numVerts );
/* try all possible orderings of the points looking for a non-degenerate strip order */
+ ni = 0;
for( r = 0; r < ds->numVerts; r++ )
{
/* set rotation */
-/*
-PointTriangleIntersect()
-assuming that all points lie in plane, determine if pt
-is inside the triangle abc
-code originally (c) 2001 softSurfer (www.softsurfer.com)
-*/
-
-#define MIN_OUTSIDE_EPSILON -0.01f
-#define MAX_OUTSIDE_EPSILON 1.01f
-
-static qboolean PointTriangleIntersect( vec3_t pt, vec4_t plane, vec3_t a, vec3_t b, vec3_t c, vec3_t bary )
-{
- vec3_t u, v, w;
- float uu, uv, vv, wu, wv, d;
-
-
- /* make vectors */
- VectorSubtract( b, a, u );
- VectorSubtract( c, a, v );
- VectorSubtract( pt, a, w );
-
- /* more setup */
- uu = DotProduct( u, u );
- uv = DotProduct( u, v );
- vv = DotProduct( v, v );
- wu = DotProduct( w, u );
- wv = DotProduct( w, v );
- d = uv * uv - uu * vv;
-
- /* calculate barycentric coordinates */
- bary[ 1 ] = (uv * wv - vv * wu) / d;
- if( bary[ 1 ] < MIN_OUTSIDE_EPSILON || bary[ 1 ] > MAX_OUTSIDE_EPSILON )
- return qfalse;
- bary[ 2 ] = (uv * wv - uu * wv) / d;
- if( bary[ 2 ] < MIN_OUTSIDE_EPSILON || bary[ 2 ] > MAX_OUTSIDE_EPSILON )
- return qfalse;
- bary[ 0 ] = 1.0f - (bary[ 1 ] + bary[ 2 ]);
-
- /* point is in triangle */
- return qtrue;
-}
-
-
-
/*
CreateEdge()
sets up an edge structure from a plane and 2 points that the edge ab falls lies in
{
int i, score, coincident, ai, bi, ci, oldTexRange[ 2 ];
float lmMax;
- vec3_t mins, maxs, p;
+ vec3_t mins, maxs;
qboolean inTexRange, es, et;
mapDrawSurface_t old;
/* shader first */
- if( ((metaTriangle_t*) a)->si < ((metaTriangle_t*) b)->si )
+ if( ((const metaTriangle_t*) a)->si < ((const metaTriangle_t*) b)->si )
return 1;
- else if( ((metaTriangle_t*) a)->si > ((metaTriangle_t*) b)->si )
+ else if( ((const metaTriangle_t*) a)->si > ((const metaTriangle_t*) b)->si )
return -1;
/* then fog */
- else if( ((metaTriangle_t*) a)->fogNum < ((metaTriangle_t*) b)->fogNum )
+ else if( ((const metaTriangle_t*) a)->fogNum < ((const metaTriangle_t*) b)->fogNum )
return 1;
- else if( ((metaTriangle_t*) a)->fogNum > ((metaTriangle_t*) b)->fogNum )
+ else if( ((const metaTriangle_t*) a)->fogNum > ((const metaTriangle_t*) b)->fogNum )
return -1;
/* then plane */
#if 0
- else if( npDegrees == 0.0f && ((metaTriangle_t*) a)->si->nonplanar == qfalse &&
- ((metaTriangle_t*) a)->planeNum >= 0 && ((metaTriangle_t*) a)->planeNum >= 0 )
+ else if( npDegrees == 0.0f && ((const metaTriangle_t*) a)->si->nonplanar == qfalse &&
+ ((const metaTriangle_t*) a)->planeNum >= 0 && ((const metaTriangle_t*) a)->planeNum >= 0 )
{
- if( ((metaTriangle_t*) a)->plane[ 3 ] < ((metaTriangle_t*) b)->plane[ 3 ] )
+ if( ((const metaTriangle_t*) a)->plane[ 3 ] < ((const metaTriangle_t*) b)->plane[ 3 ] )
return 1;
- else if( ((metaTriangle_t*) a)->plane[ 3 ] > ((metaTriangle_t*) b)->plane[ 3 ] )
+ else if( ((const metaTriangle_t*) a)->plane[ 3 ] > ((const metaTriangle_t*) b)->plane[ 3 ] )
return -1;
- else if( ((metaTriangle_t*) a)->plane[ 0 ] < ((metaTriangle_t*) b)->plane[ 0 ] )
+ else if( ((const metaTriangle_t*) a)->plane[ 0 ] < ((const metaTriangle_t*) b)->plane[ 0 ] )
return 1;
- else if( ((metaTriangle_t*) a)->plane[ 0 ] > ((metaTriangle_t*) b)->plane[ 0 ] )
+ else if( ((const metaTriangle_t*) a)->plane[ 0 ] > ((const metaTriangle_t*) b)->plane[ 0 ] )
return -1;
- else if( ((metaTriangle_t*) a)->plane[ 1 ] < ((metaTriangle_t*) b)->plane[ 1 ] )
+ else if( ((const metaTriangle_t*) a)->plane[ 1 ] < ((const metaTriangle_t*) b)->plane[ 1 ] )
return 1;
- else if( ((metaTriangle_t*) a)->plane[ 1 ] > ((metaTriangle_t*) b)->plane[ 1 ] )
+ else if( ((const metaTriangle_t*) a)->plane[ 1 ] > ((const metaTriangle_t*) b)->plane[ 1 ] )
return -1;
- else if( ((metaTriangle_t*) a)->plane[ 2 ] < ((metaTriangle_t*) b)->plane[ 2 ] )
+ else if( ((const metaTriangle_t*) a)->plane[ 2 ] < ((const metaTriangle_t*) b)->plane[ 2 ] )
return 1;
- else if( ((metaTriangle_t*) a)->plane[ 2 ] > ((metaTriangle_t*) b)->plane[ 2 ] )
+ else if( ((const metaTriangle_t*) a)->plane[ 2 ] > ((const metaTriangle_t*) b)->plane[ 2 ] )
return -1;
}
#endif
VectorSet( bMins, 999999, 999999, 999999 );
for( i = 0; i < 3; i++ )
{
- av = ((metaTriangle_t*) a)->indexes[ i ];
- bv = ((metaTriangle_t*) b)->indexes[ i ];
+ av = ((const metaTriangle_t*) a)->indexes[ i ];
+ bv = ((const metaTriangle_t*) b)->indexes[ i ];
for( j = 0; j < 3; j++ )
{
if( metaVerts[ av ].xyz[ j ] < aMins[ j ] )
int EdgeCompare( const void *elem1, const void *elem2 ) {
float d1, d2;
- d1 = ((originalEdge_t *)elem1)->length;
- d2 = ((originalEdge_t *)elem2)->length;
+ d1 = ((const originalEdge_t *)elem1)->length;
+ d2 = ((const originalEdge_t *)elem2)->length;
if ( d1 < d2 ) {
return -1;
*/
int PComp (const void *a, const void *b)
{
- if ( (*(vportal_t **)a)->nummightsee == (*(vportal_t **)b)->nummightsee)
+ if ( (*(const vportal_t *const *)a)->nummightsee == (*(const vportal_t *const *)b)->nummightsee)
return 0;
- if ( (*(vportal_t **)a)->nummightsee < (*(vportal_t **)b)->nummightsee)
+ if ( (*(const vportal_t *const *)a)->nummightsee < (*(const vportal_t *const *)b)->nummightsee)
return -1;
return 1;
}
Error ("LoadPortals: reading portal %i", i);
if (numpoints > MAX_POINTS_ON_WINDING)
Error ("LoadPortals: portal %i has too many points", i);
- if ( (unsigned)leafnums[0] > portalclusters
- || (unsigned)leafnums[1] > portalclusters)
+ if (leafnums[0] > portalclusters
+ || leafnums[1] > portalclusters)
Error ("LoadPortals: reading portal %i", i);
if (fscanf (f, "%i ", &hint) != 1)
Error ("LoadPortals: reading hint state");