q3map2/picomodel: remove some warnings

imported from netradiant, initial commit message:

> q3map2 is now waring free
This commit is contained in:
rpolzer 2010-10-05 10:57:07 +02:00 committed by Thomas Debesse
parent 5a40208a05
commit 58f0f9e557
39 changed files with 374 additions and 331 deletions

View File

@ -173,16 +173,16 @@ enum
/* convenience (makes it easy to add new params to the callbacks) */ /* convenience (makes it easy to add new params to the callbacks) */
#define PM_PARAMS_CANLOAD \ #define PM_PARAMS_CANLOAD \
char *fileName, const void *buffer, int bufSize const char *fileName, const void *buffer, int bufSize
#define PM_PARAMS_LOAD \ #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 \ #define PM_PARAMS_CANSAVE \
void void
#define PM_PARAMS_SAVE \ #define PM_PARAMS_SAVE \
char *fileName, picoModel_t * model const char *fileName, picoModel_t * model
/* pico file format module structure */ /* pico file format module structure */
struct picoModule_s struct picoModule_s
@ -209,13 +209,13 @@ int PicoError( void );
void PicoSetMallocFunc( void *( *func )( size_t ) ); void PicoSetMallocFunc( void *( *func )( size_t ) );
void PicoSetFreeFunc( void ( *func )( void* ) ); 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 PicoSetFreeFileFunc( void ( *func )( void* ) );
void PicoSetPrintFunc( void ( *func )( int, const char* ) ); void PicoSetPrintFunc( void ( *func )( int, const char* ) );
const picoModule_t **PicoModuleList( int *numModules ); 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); 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); picoModel_t* PicoModuleLoadModelStream(const picoModule_t* module, void* inputStream, PicoInputStreamReadFunc inputStreamRead, size_t streamLength, int frameNum);
@ -241,8 +241,8 @@ int PicoAdjustSurface( picoSurface_t *surface, int numVe
/* setter functions */ /* setter functions */
void PicoSetModelName( picoModel_t *model, char *name ); void PicoSetModelName( picoModel_t *model, const char *name );
void PicoSetModelFileName( picoModel_t *model, char *fileName ); void PicoSetModelFileName( picoModel_t *model, const char *fileName );
void PicoSetModelFrameNum( picoModel_t *model, int frameNum ); void PicoSetModelFrameNum( picoModel_t *model, int frameNum );
void PicoSetModelNumFrames( picoModel_t *model, int numFrames ); void PicoSetModelNumFrames( picoModel_t *model, int numFrames );
void PicoSetModelData( picoModel_t *model, void *data ); void PicoSetModelData( picoModel_t *model, void *data );

View File

@ -43,7 +43,7 @@ static int compare_keys( lwKey *k1, lwKey *k2 ){
lwEnvelope *lwGetEnvelope( picoMemStream_t *fp, int cksize ){ lwEnvelope *lwGetEnvelope( picoMemStream_t *fp, int cksize ){
lwEnvelope *env; lwEnvelope *env;
lwKey *key; lwKey *key = NULL;
lwPlugin *plug; lwPlugin *plug;
unsigned int id; unsigned int id;
unsigned short sz; unsigned short sz;

View File

@ -450,7 +450,7 @@ char *sgetS0( unsigned char **bp ){
return NULL; return NULL;
} }
len = strlen( (char *) buf ) + 1; len = strlen( (const char *) buf ) + 1;
if ( len == 1 ) { if ( len == 1 ) {
flen += 2; flen += 2;
*bp += 2; *bp += 2;

View File

@ -76,12 +76,12 @@ void lwFreeObject( lwObject *object ){
If you don't need this information, failID and failpos can be NULL. 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; lwObject *object;
lwLayer *layer; lwLayer *layer;
lwNode *node; lwNode *node;
unsigned int id, formsize, type, cksize; unsigned int id, formsize, type;
int i, rlen; int i, rlen, cksize;
/* open the file */ /* open the file */
@ -266,7 +266,7 @@ lwObject *lwGetObject( char *filename, picoMemStream_t *fp, unsigned int *failID
/* end of the file? */ /* end of the file? */
if ( formsize <= _pico_memstream_tell( fp ) - 8 ) { if ( formsize <= (unsigned int) ( _pico_memstream_tell( fp ) - 8 ) ) {
break; break;
} }
@ -320,7 +320,7 @@ Fail:
return NULL; 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; unsigned int id, formsize, type;
/* open the file */ /* open the file */

View File

@ -539,8 +539,8 @@ typedef struct st_lwObject {
void lwFreeLayer( lwLayer *layer ); void lwFreeLayer( lwLayer *layer );
void lwFreeObject( lwObject *object ); void lwFreeObject( lwObject *object );
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 );
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 );
/* pntspols.c */ /* pntspols.c */
@ -600,8 +600,8 @@ lwSurface *lwDefaultSurface( void );
lwSurface *lwGetSurface5( picoMemStream_t *fp, int cksize, lwObject *obj ); lwSurface *lwGetSurface5( picoMemStream_t *fp, int cksize, lwObject *obj );
int lwGetPolygons5( picoMemStream_t *fp, int cksize, lwPolygonList *plist, int ptoffset ); int lwGetPolygons5( picoMemStream_t *fp, int cksize, lwPolygonList *plist, int ptoffset );
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 );
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 );
/* list.c */ /* list.c */

View File

@ -202,8 +202,8 @@ static lwTexture *get_texture( char *s ){
lwSurface *lwGetSurface5( picoMemStream_t *fp, int cksize, lwObject *obj ){ lwSurface *lwGetSurface5( picoMemStream_t *fp, int cksize, lwObject *obj ){
lwSurface *surf; lwSurface *surf;
lwTexture *tex; lwTexture *tex = NULL;
lwPlugin *shdr; lwPlugin *shdr = NULL;
char *s; char *s;
float v[ 3 ]; float v[ 3 ];
unsigned int id, flags; unsigned int id, flags;
@ -246,9 +246,6 @@ lwSurface *lwGetSurface5( picoMemStream_t *fp, int cksize, lwObject *obj ){
goto Fail; goto Fail;
} }
tex = NULL;
shdr = NULL;
/* process subchunks as they're encountered */ /* process subchunks as they're encountered */
while ( 1 ) { while ( 1 ) {
@ -385,11 +382,14 @@ lwSurface *lwGetSurface5( picoMemStream_t *fp, int cksize, lwObject *obj ){
break; break;
case ID_TFLG: case ID_TFLG:
if( tex == NULL ) {
goto Fail;
}
flags = getU2( fp ); flags = getU2( fp );
if( tex == NULL ) { i = -1;
break;
}
//only one of the three axis bits should be set //only one of the three axis bits should be set
if ( flags & 1 ) { if ( flags & 1 ) {
tex->axis = 0; tex->axis = 0;
@ -401,6 +401,9 @@ lwSurface *lwGetSurface5( picoMemStream_t *fp, int cksize, lwObject *obj ){
assert( flags & 4 ); assert( flags & 4 );
tex->axis = 2; tex->axis = 2;
} }
if ( !tex ) {
goto Fail;
}
if ( tex->type == ID_IMAP ) { if ( tex->type == ID_IMAP ) {
tex->param.imap.axis = i; tex->param.imap.axis = i;
@ -425,32 +428,32 @@ lwSurface *lwGetSurface5( picoMemStream_t *fp, int cksize, lwObject *obj ){
break; break;
case ID_TSIZ: case ID_TSIZ:
if( tex == NULL ) { if ( !tex ) {
break; goto Fail;
} }
for ( i = 0; i < 3; i++ ) for ( i = 0; i < 3; i++ )
tex->tmap.size.val[ i ] = getF4( fp ); tex->tmap.size.val[ i ] = getF4( fp );
break; break;
case ID_TCTR: case ID_TCTR:
if( tex == NULL ) { if ( !tex ) {
break; goto Fail;
} }
for ( i = 0; i < 3; i++ ) for ( i = 0; i < 3; i++ )
tex->tmap.center.val[ i ] = getF4( fp ); tex->tmap.center.val[ i ] = getF4( fp );
break; break;
case ID_TFAL: case ID_TFAL:
if( tex == NULL ) { if ( !tex ) {
break; goto Fail;
} }
for ( i = 0; i < 3; i++ ) for ( i = 0; i < 3; i++ )
tex->tmap.falloff.val[ i ] = getF4( fp ); tex->tmap.falloff.val[ i ] = getF4( fp );
break; break;
case ID_TVEL: case ID_TVEL:
if( tex == NULL ) { if ( !tex ) {
break; goto Fail;
} }
for ( i = 0; i < 3; i++ ) for ( i = 0; i < 3; i++ )
v[ i ] = getF4( fp ); v[ i ] = getF4( fp );
@ -459,8 +462,8 @@ lwSurface *lwGetSurface5( picoMemStream_t *fp, int cksize, lwObject *obj ){
break; break;
case ID_TCLR: case ID_TCLR:
if( tex == NULL ) { if ( !tex ) {
break; goto Fail;
} }
if ( tex->type == ID_PROC ) { if ( tex->type == ID_PROC ) {
for ( i = 0; i < 3; i++ ) for ( i = 0; i < 3; i++ )
@ -469,15 +472,15 @@ lwSurface *lwGetSurface5( picoMemStream_t *fp, int cksize, lwObject *obj ){
break; break;
case ID_TVAL: case ID_TVAL:
if( tex == NULL ) { if ( !tex ) {
break; goto Fail;
} }
tex->param.proc.value[ 0 ] = getI2( fp ) / 256.0f; tex->param.proc.value[ 0 ] = getI2( fp ) / 256.0f;
break; break;
case ID_TAMP: case ID_TAMP:
if( tex == NULL ) { if ( !tex ) {
break; goto Fail;
} }
if ( tex->type == ID_IMAP ) { if ( tex->type == ID_IMAP ) {
tex->param.imap.amplitude.val = getF4( fp ); tex->param.imap.amplitude.val = getF4( fp );
@ -485,38 +488,38 @@ lwSurface *lwGetSurface5( picoMemStream_t *fp, int cksize, lwObject *obj ){
break; break;
case ID_TIMG: case ID_TIMG:
if( tex == NULL ) { if ( !tex ) {
break; goto Fail;
} }
s = getS0( fp ); s = getS0( fp );
tex->param.imap.cindex = add_clip( s, &obj->clip, &obj->nclips ); tex->param.imap.cindex = add_clip( s, &obj->clip, &obj->nclips );
break; break;
case ID_TAAS: case ID_TAAS:
if( tex == NULL ) { if ( !tex ) {
break; goto Fail;
} }
tex->param.imap.aa_strength = getF4( fp ); tex->param.imap.aa_strength = getF4( fp );
tex->param.imap.aas_flags = 1; tex->param.imap.aas_flags = 1;
break; break;
case ID_TREF: case ID_TREF:
if( tex == NULL ) { if ( !tex ) {
break; goto Fail;
} }
tex->tmap.ref_object = getbytes( fp, sz ); tex->tmap.ref_object = getbytes( fp, sz );
break; break;
case ID_TOPC: case ID_TOPC:
if( tex == NULL ) { if ( !tex ) {
break; goto Fail;
} }
tex->opacity.val = getF4( fp ); tex->opacity.val = getF4( fp );
break; break;
case ID_TFP0: case ID_TFP0:
if( tex == NULL ) { if ( !tex ) {
break; goto Fail;
} }
if ( tex->type == ID_IMAP ) { if ( tex->type == ID_IMAP ) {
tex->param.imap.wrapw.val = getF4( fp ); tex->param.imap.wrapw.val = getF4( fp );
@ -524,8 +527,8 @@ lwSurface *lwGetSurface5( picoMemStream_t *fp, int cksize, lwObject *obj ){
break; break;
case ID_TFP1: case ID_TFP1:
if( tex == NULL ) { if ( !tex ) {
break; goto Fail;
} }
if ( tex->type == ID_IMAP ) { if ( tex->type == ID_IMAP ) {
tex->param.imap.wraph.val = getF4( fp ); tex->param.imap.wraph.val = getF4( fp );
@ -701,7 +704,7 @@ Fail:
If you don't need this information, failID and failpos can be NULL. 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; lwObject *object;
lwLayer *layer; lwLayer *layer;
lwNode *node; lwNode *node;
@ -837,7 +840,7 @@ Fail:
return NULL; 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; unsigned int id, formsize, type;

View File

@ -52,7 +52,7 @@
/* function pointers */ /* function pointers */
void *( *_pico_ptr_malloc )( size_t ) = malloc; void *( *_pico_ptr_malloc )( size_t ) = malloc;
void ( *_pico_ptr_free )( void* ) = free; 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_free_file )( void* ) = NULL;
void ( *_pico_ptr_print )( int, const char* ) = NULL; void ( *_pico_ptr_print )( int, const char* ) = NULL;
@ -201,7 +201,7 @@ void _pico_free( void *ptr ){
/* _pico_load_file: /* _pico_load_file:
* wrapper around the loadfile function pointer * 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 */ /* sanity checks */
if ( name == NULL ) { if ( name == NULL ) {
*bufSize = -1; *bufSize = -1;
@ -542,7 +542,7 @@ float _pico_big_float( float src ){
/* _pico_stristr: /* _pico_stristr:
* case-insensitive strstr. -sea * 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 ); const size_t sublen = strlen( substr );
while ( *str ) while ( *str )
{ {
@ -738,7 +738,7 @@ void _pico_parse_skip_white( picoParser_t *p, int *hasLFs ){
/* _pico_new_parser: /* _pico_new_parser:
* allocates a new ascii parser object. * 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; picoParser_t *p;
/* sanity check */ /* sanity check */
@ -762,7 +762,7 @@ picoParser_t *_pico_new_parser( picoByte_t *buffer, int bufSize ){
return NULL; return NULL;
} }
/* setup */ /* setup */
p->buffer = (char *)buffer; p->buffer = (const char *)buffer;
p->cursor = p->buffer; p->cursor = p->buffer;
p->bufSize = bufSize; p->bufSize = bufSize;
p->max = p->buffer + bufSize; p->max = p->buffer + bufSize;
@ -798,7 +798,7 @@ void _pico_free_parser( picoParser_t *p ){
*/ */
int _pico_parse_ex( picoParser_t *p, int allowLFs, int handleQuoted ){ int _pico_parse_ex( picoParser_t *p, int allowLFs, int handleQuoted ){
int hasLFs = 0; int hasLFs = 0;
char *old; const char *old;
/* sanity checks */ /* sanity checks */
if ( p == NULL || p->buffer == NULL || if ( p == NULL || p->buffer == NULL ||
@ -1220,7 +1220,7 @@ int _pico_parse_vec4_def( picoParser_t *p, picoVec4_t out, picoVec4_t def ){
/* _pico_new_memstream: /* _pico_new_memstream:
* allocates a new memorystream object. * 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; picoMemStream_t *s;
/* sanity check */ /* sanity check */

View File

@ -79,22 +79,22 @@ extern "C"
/* types */ /* types */
typedef struct picoParser_s typedef struct picoParser_s
{ {
char *buffer; const char *buffer;
int bufSize; int bufSize;
char *token; char *token;
int tokenSize; int tokenSize;
int tokenMax; int tokenMax;
char *cursor; const char *cursor;
char *max; const char *max;
int curLine; int curLine;
} }
picoParser_t; picoParser_t;
typedef struct picoMemStream_s typedef struct picoMemStream_s
{ {
picoByte_t *buffer; const picoByte_t *buffer;
int bufSize; int bufSize;
picoByte_t *curPos; picoByte_t *curPos;
int flag; int flag;
} }
picoMemStream_t; picoMemStream_t;
@ -105,7 +105,7 @@ extern const picoModule_t *picoModules[];
extern void *( *_pico_ptr_malloc )( size_t ); extern void *( *_pico_ptr_malloc )( size_t );
extern void ( *_pico_ptr_free )( void* ); 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_free_file )( void* );
extern void ( *_pico_ptr_print )( int, const char* ); extern void ( *_pico_ptr_print )( int, const char* );
@ -121,7 +121,7 @@ char *_pico_clone_alloc( const char *str );
void _pico_free( void *ptr ); void _pico_free( void *ptr );
/* files */ /* 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 ); void _pico_free_file( void *buffer );
/* strings */ /* strings */
@ -130,7 +130,7 @@ char *_pico_strltrim( char *str );
char *_pico_strrtrim( char *str ); char *_pico_strrtrim( char *str );
int _pico_strchcount( char *str, int ch ); int _pico_strchcount( char *str, int ch );
void _pico_printf( int level, const char *format, ... ); 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 ); void _pico_unixify( char *path );
int _pico_nofname( const char *path, char *dest, int destSize ); int _pico_nofname( const char *path, char *dest, int destSize );
const char *_pico_nopath( const char *path ); const char *_pico_nopath( const char *path );
@ -169,7 +169,7 @@ short _pico_little_short( short src );
float _pico_little_float( float src ); float _pico_little_float( float src );
/* pico ascii parser */ /* 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 ); void _pico_free_parser( picoParser_t *p );
int _pico_parse_ex( picoParser_t *p, int allowLFs, int handleQuoted ); int _pico_parse_ex( picoParser_t *p, int allowLFs, int handleQuoted );
char *_pico_parse_first( picoParser_t *p ); char *_pico_parse_first( picoParser_t *p );
@ -190,7 +190,7 @@ int _pico_parse_vec4( picoParser_t *p, picoVec4_t out );
int _pico_parse_vec4_def( picoParser_t *p, picoVec4_t out, picoVec4_t def ); int _pico_parse_vec4_def( picoParser_t *p, picoVec4_t out, picoVec4_t def );
/* pico memory stream */ /* 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 ); void _pico_free_memstream( picoMemStream_t *s );
int _pico_memstream_read( picoMemStream_t *s, void *buffer, int len ); int _pico_memstream_read( picoMemStream_t *s, void *buffer, int len );
int _pico_memstream_getc( picoMemStream_t *s ); int _pico_memstream_getc( picoMemStream_t *s );

View File

@ -111,7 +111,7 @@ void PicoSetFreeFunc( void ( *func )( void* ) ){
sets the ptr to the file load function 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 ) { if ( func != NULL ) {
_pico_ptr_load_file = func; _pico_ptr_load_file = func;
} }
@ -143,7 +143,7 @@ void PicoSetPrintFunc( void ( *func )( int, const char* ) ){
} }
} }
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; char *modelFileName, *remapFileName;
/* see whether this module can load the model file or not */ /* see whether this module can load the model file or not */
@ -188,7 +188,7 @@ picoModel_t *PicoModuleLoadModel( const picoModule_t* pm, char* fileName, picoBy
the meat and potatoes function 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; const picoModule_t **modules, *pm;
picoModel_t *model; picoModel_t *model;
picoByte_t *buffer; picoByte_t *buffer;
@ -761,7 +761,7 @@ picoSurface_t *PicoFindSurface(
PicoSet*() Setter Functions PicoSet*() Setter Functions
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
void PicoSetModelName( picoModel_t *model, char *name ){ void PicoSetModelName( picoModel_t *model, const char *name ){
if ( model == NULL || name == NULL ) { if ( model == NULL || name == NULL ) {
return; return;
} }
@ -774,7 +774,7 @@ void PicoSetModelName( picoModel_t *model, char *name ){
void PicoSetModelFileName( picoModel_t *model, char *fileName ){ void PicoSetModelFileName( picoModel_t *model, const char *fileName ){
if ( model == NULL || fileName == NULL ) { if ( model == NULL || fileName == NULL ) {
return; return;
} }

View File

@ -163,21 +163,18 @@ T3dsChunk;
* validates an autodesk 3ds model file. * validates an autodesk 3ds model file.
*/ */
static int _3ds_canload( PM_PARAMS_CANLOAD ){ static int _3ds_canload( PM_PARAMS_CANLOAD ){
T3dsChunk *chunk; const T3dsChunk *chunk;
/* to keep the compiler happy */
*fileName = *fileName;
/* sanity check */ /* sanity check */
if ( bufSize < sizeof( T3dsChunk ) ) { if ( bufSize < (int) sizeof( T3dsChunk ) ) {
return PICO_PMV_ERROR_SIZE; return PICO_PMV_ERROR_SIZE;
} }
/* get pointer to 3ds header chunk */ /* get pointer to 3ds header chunk */
chunk = (T3dsChunk *)buffer; chunk = (const T3dsChunk *)buffer;
/* check data length */ /* check data length */
if ( bufSize < _pico_little_long( chunk->len ) ) { if ( bufSize < (int) _pico_little_long( chunk->len ) ) {
return PICO_PMV_ERROR_SIZE; return PICO_PMV_ERROR_SIZE;
} }
@ -741,7 +738,8 @@ static picoModel_t *_3ds_load( PM_PARAMS_LOAD ){
/* initialize persistant vars (formerly static) */ /* initialize persistant vars (formerly static) */
pers.model = model; 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.basename = (char *)basename;
pers.maxofs = bufSize; pers.maxofs = bufSize;
pers.cofs = 0L; pers.cofs = 0L;

View File

@ -208,11 +208,8 @@ static int _ase_canload( PM_PARAMS_CANLOAD ){
return PICO_PMV_ERROR_SIZE; return PICO_PMV_ERROR_SIZE;
} }
/* keep the friggin compiler happy */
*fileName = *fileName;
/* create pico parser */ /* create pico parser */
p = _pico_new_parser( (picoByte_t*) buffer, bufSize ); p = _pico_new_parser( (const picoByte_t*) buffer, bufSize );
if ( p == NULL ) { if ( p == NULL ) {
return PICO_PMV_ERROR_MEMORY; return PICO_PMV_ERROR_MEMORY;
} }
@ -515,7 +512,7 @@ static picoModel_t *_ase_load( PM_PARAMS_LOAD ){
return NULL; \ return NULL; \
} }
/* create a new pico parser */ /* 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 ) { if ( p == NULL ) {
return NULL; return NULL;
} }
@ -851,7 +848,7 @@ static picoModel_t *_ase_load( PM_PARAMS_LOAD ){
/* model material */ /* model material */
else if ( !_pico_stricmp( p->token, "*material" ) ) { else if ( !_pico_stricmp( p->token, "*material" ) ) {
aseSubMaterial_t* subMaterial = NULL; aseSubMaterial_t* subMaterial = NULL;
picoShader_t *shader; picoShader_t *shader = NULL;
int level = 1, index; int level = 1, index;
char materialName[ 1024 ]; char materialName[ 1024 ];
float transValue = 0.0f, shineValue = 1.0f; float transValue = 0.0f, shineValue = 1.0f;

View File

@ -65,10 +65,11 @@ typedef struct index_DUP_LUT_s
// _fm_canload() // _fm_canload()
static int _fm_canload( PM_PARAMS_CANLOAD ){ static int _fm_canload( PM_PARAMS_CANLOAD ){
fm_t fm; fm_t fm;
unsigned char *bb; unsigned char *bb, *bb0;
int fm_file_pos; int fm_file_pos;
bb = (unsigned char *) buffer; bb0 = bb = (picoByte_t*) _pico_alloc( bufSize );
memcpy( bb, buffer, bufSize );
// Header // Header
fm.fm_header_hdr = (fm_chunk_header_t *) bb; fm.fm_header_hdr = (fm_chunk_header_t *) bb;
@ -80,6 +81,7 @@ static int _fm_canload( PM_PARAMS_CANLOAD ){
#ifdef FM_DBG #ifdef FM_DBG
_pico_printf( PICO_WARNING, "FM Header Ident incorrect\n" ); _pico_printf( PICO_WARNING, "FM Header Ident incorrect\n" );
#endif #endif
_pico_free( bb0 );
return PICO_PMV_ERROR_IDENT; return PICO_PMV_ERROR_IDENT;
} }
@ -88,6 +90,7 @@ static int _fm_canload( PM_PARAMS_CANLOAD ){
#ifdef FM_DBG #ifdef FM_DBG
_pico_printf( PICO_WARNING, "FM Header Version incorrect\n" ); _pico_printf( PICO_WARNING, "FM Header Version incorrect\n" );
#endif #endif
_pico_free( bb0 );
return PICO_PMV_ERROR_VERSION; return PICO_PMV_ERROR_VERSION;
} }
@ -101,6 +104,7 @@ static int _fm_canload( PM_PARAMS_CANLOAD ){
#ifdef FM_DBG #ifdef FM_DBG
_pico_printf( PICO_WARNING, "FM Skin Ident incorrect\n" ); _pico_printf( PICO_WARNING, "FM Skin Ident incorrect\n" );
#endif #endif
_pico_free( bb0 );
return PICO_PMV_ERROR_IDENT; return PICO_PMV_ERROR_IDENT;
} }
@ -109,6 +113,7 @@ static int _fm_canload( PM_PARAMS_CANLOAD ){
#ifdef FM_DBG #ifdef FM_DBG
_pico_printf( PICO_WARNING, "FM Skin Version incorrect\n" ); _pico_printf( PICO_WARNING, "FM Skin Version incorrect\n" );
#endif #endif
_pico_free( bb0 );
return PICO_PMV_ERROR_VERSION; return PICO_PMV_ERROR_VERSION;
} }
@ -122,6 +127,7 @@ static int _fm_canload( PM_PARAMS_CANLOAD ){
#ifdef FM_DBG #ifdef FM_DBG
_pico_printf( PICO_WARNING, "FM ST Ident incorrect\n" ); _pico_printf( PICO_WARNING, "FM ST Ident incorrect\n" );
#endif #endif
_pico_free( bb0 );
return PICO_PMV_ERROR_IDENT; return PICO_PMV_ERROR_IDENT;
} }
@ -130,6 +136,7 @@ static int _fm_canload( PM_PARAMS_CANLOAD ){
#ifdef FM_DBG #ifdef FM_DBG
_pico_printf( PICO_WARNING, "FM ST Version incorrect\n" ); _pico_printf( PICO_WARNING, "FM ST Version incorrect\n" );
#endif #endif
_pico_free( bb0 );
return PICO_PMV_ERROR_VERSION; return PICO_PMV_ERROR_VERSION;
} }
@ -143,6 +150,7 @@ static int _fm_canload( PM_PARAMS_CANLOAD ){
#ifdef FM_DBG #ifdef FM_DBG
_pico_printf( PICO_WARNING, "FM Tri Ident incorrect\n" ); _pico_printf( PICO_WARNING, "FM Tri Ident incorrect\n" );
#endif #endif
_pico_free( bb0 );
return PICO_PMV_ERROR_IDENT; return PICO_PMV_ERROR_IDENT;
} }
@ -151,6 +159,7 @@ static int _fm_canload( PM_PARAMS_CANLOAD ){
#ifdef FM_DBG #ifdef FM_DBG
_pico_printf( PICO_WARNING, "FM Tri Version incorrect\n" ); _pico_printf( PICO_WARNING, "FM Tri Version incorrect\n" );
#endif #endif
_pico_free( bb0 );
return PICO_PMV_ERROR_VERSION; return PICO_PMV_ERROR_VERSION;
} }
@ -164,6 +173,7 @@ static int _fm_canload( PM_PARAMS_CANLOAD ){
#ifdef FM_DBG #ifdef FM_DBG
_pico_printf( PICO_WARNING, "FM Frame Ident incorrect\n" ); _pico_printf( PICO_WARNING, "FM Frame Ident incorrect\n" );
#endif #endif
_pico_free( bb0 );
return PICO_PMV_ERROR_IDENT; return PICO_PMV_ERROR_IDENT;
} }
@ -172,6 +182,7 @@ static int _fm_canload( PM_PARAMS_CANLOAD ){
#ifdef FM_DBG #ifdef FM_DBG
_pico_printf( PICO_WARNING, "FM Frame Version incorrect\n" ); _pico_printf( PICO_WARNING, "FM Frame Version incorrect\n" );
#endif #endif
_pico_free( bb0 );
return PICO_PMV_ERROR_VERSION; return PICO_PMV_ERROR_VERSION;
} }
@ -199,7 +210,7 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD ){
fm_xyz_st_t *triangle; fm_xyz_st_t *triangle;
fm_frame_t *frame; fm_frame_t *frame;
picoByte_t *bb; picoByte_t *bb, bb0;
picoModel_t *picoModel; picoModel_t *picoModel;
picoSurface_t *picoSurface; picoSurface_t *picoSurface;
picoShader_t *picoShader; picoShader_t *picoShader;
@ -211,18 +222,22 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD ){
// fm loading // fm loading
_pico_printf( PICO_NORMAL, "Loading \"%s\"", fileName ); _pico_printf( PICO_NORMAL, "Loading \"%s\"", fileName );
bb = (picoByte_t*) buffer; bb0 = bb = (picoByte_t*) _pico_alloc( bufSize );
memcpy( bb, buffer, bufSize );
// Header Header // Header Header
fm.fm_header_hdr = (fm_chunk_header_t *) bb; fm.fm_header_hdr = (fm_chunk_header_t *) bb;
fm_file_pos = sizeof( fm_chunk_header_t ) + fm.fm_header_hdr->size; fm_file_pos = sizeof( fm_chunk_header_t ) + fm.fm_header_hdr->size;
if ( ( strcmp( fm.fm_header_hdr->ident, FM_HEADERCHUNKNAME ) ) ) { if ( ( strcmp( fm.fm_header_hdr->ident, FM_HEADERCHUNKNAME ) ) ) {
_pico_printf( PICO_WARNING, "FM Header Ident incorrect\n" ); _pico_printf( PICO_WARNING, "FM Header Ident incorrect\n" );
_pico_free(bb0);
return NULL; return NULL;
} }
if ( _pico_little_long( fm.fm_header_hdr->version ) != FM_HEADERCHUNKVER ) { if ( _pico_little_long( fm.fm_header_hdr->version ) != FM_HEADERCHUNKVER ) {
_pico_printf( PICO_WARNING, "FM Header Version incorrect\n" ); _pico_printf( PICO_WARNING, "FM Header Version incorrect\n" );
_pico_free(bb0);
return NULL; return NULL;
} }
@ -231,11 +246,13 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD ){
fm_file_pos += sizeof( fm_chunk_header_t ) + fm.fm_skin_hdr->size; fm_file_pos += sizeof( fm_chunk_header_t ) + fm.fm_skin_hdr->size;
if ( ( strcmp( fm.fm_skin_hdr->ident, FM_SKINCHUNKNAME ) ) ) { if ( ( strcmp( fm.fm_skin_hdr->ident, FM_SKINCHUNKNAME ) ) ) {
_pico_printf( PICO_WARNING, "FM Skin Ident incorrect\n" ); _pico_printf( PICO_WARNING, "FM Skin Ident incorrect\n" );
_pico_free(bb0);
return NULL; return NULL;
} }
if ( _pico_little_long( fm.fm_skin_hdr->version ) != FM_SKINCHUNKVER ) { if ( _pico_little_long( fm.fm_skin_hdr->version ) != FM_SKINCHUNKVER ) {
_pico_printf( PICO_WARNING, "FM Skin Version incorrect\n" ); _pico_printf( PICO_WARNING, "FM Skin Version incorrect\n" );
_pico_free(bb0);
return NULL; return NULL;
} }
@ -244,11 +261,13 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD ){
fm_file_pos += sizeof( fm_chunk_header_t ) + fm.fm_st_hdr->size; fm_file_pos += sizeof( fm_chunk_header_t ) + fm.fm_st_hdr->size;
if ( ( strcmp( fm.fm_st_hdr->ident, FM_STCOORDCHUNKNAME ) ) ) { if ( ( strcmp( fm.fm_st_hdr->ident, FM_STCOORDCHUNKNAME ) ) ) {
_pico_printf( PICO_WARNING, "FM ST Ident incorrect\n" ); _pico_printf( PICO_WARNING, "FM ST Ident incorrect\n" );
_pico_free(bb0);
return NULL; return NULL;
} }
if ( _pico_little_long( fm.fm_st_hdr->version ) != FM_STCOORDCHUNKVER ) { if ( _pico_little_long( fm.fm_st_hdr->version ) != FM_STCOORDCHUNKVER ) {
_pico_printf( PICO_WARNING, "FM ST Version incorrect\n" ); _pico_printf( PICO_WARNING, "FM ST Version incorrect\n" );
_pico_free(bb0);
return NULL; return NULL;
} }
@ -258,10 +277,12 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD ){
if ( ( strcmp( fm.fm_tri_hdr->ident, FM_TRISCHUNKNAME ) ) ) { if ( ( strcmp( fm.fm_tri_hdr->ident, FM_TRISCHUNKNAME ) ) ) {
_pico_printf( PICO_WARNING, "FM Tri Ident incorrect\n" ); _pico_printf( PICO_WARNING, "FM Tri Ident incorrect\n" );
return NULL; return NULL;
_pico_free(bb0);
} }
if ( _pico_little_long( fm.fm_tri_hdr->version ) != FM_TRISCHUNKVER ) { if ( _pico_little_long( fm.fm_tri_hdr->version ) != FM_TRISCHUNKVER ) {
_pico_printf( PICO_WARNING, "FM Tri Version incorrect\n" ); _pico_printf( PICO_WARNING, "FM Tri Version incorrect\n" );
_pico_free(bb0);
return NULL; return NULL;
} }
@ -270,11 +291,13 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD ){
fm_file_pos += sizeof( fm_chunk_header_t ); fm_file_pos += sizeof( fm_chunk_header_t );
if ( ( strcmp( fm.fm_frame_hdr->ident, FM_FRAMESCHUNKNAME ) ) ) { if ( ( strcmp( fm.fm_frame_hdr->ident, FM_FRAMESCHUNKNAME ) ) ) {
_pico_printf( PICO_WARNING, "FM Frame Ident incorrect\n" ); _pico_printf( PICO_WARNING, "FM Frame Ident incorrect\n" );
_pico_free(bb0);
return NULL; return NULL;
} }
if ( _pico_little_long( fm.fm_frame_hdr->version ) != FM_FRAMESCHUNKVER ) { if ( _pico_little_long( fm.fm_frame_hdr->version ) != FM_FRAMESCHUNKVER ) {
_pico_printf( PICO_WARNING, "FM Frame Version incorrect\n" ); _pico_printf( PICO_WARNING, "FM Frame Version incorrect\n" );
_pico_free(bb0);
return NULL; return NULL;
} }
@ -305,11 +328,13 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD ){
// do frame check // do frame check
if ( fm_head->numFrames < 1 ) { if ( fm_head->numFrames < 1 ) {
_pico_printf( PICO_ERROR, "%s has 0 frames!", fileName ); _pico_printf( PICO_ERROR, "%s has 0 frames!", fileName );
_pico_free(bb0);
return NULL; return NULL;
} }
if ( frameNum < 0 || frameNum >= fm_head->numFrames ) { if ( frameNum < 0 || frameNum >= fm_head->numFrames ) {
_pico_printf( PICO_ERROR, "Invalid or out-of-range FM frame specified" ); _pico_printf( PICO_ERROR, "Invalid or out-of-range FM frame specified" );
_pico_free(bb0);
return NULL; return NULL;
} }
@ -365,6 +390,7 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD ){
picoModel = PicoNewModel(); picoModel = PicoNewModel();
if ( picoModel == NULL ) { if ( picoModel == NULL ) {
_pico_printf( PICO_ERROR, "Unable to allocate a new model" ); _pico_printf( PICO_ERROR, "Unable to allocate a new model" );
_pico_free(bb0);
return NULL; return NULL;
} }
@ -379,6 +405,7 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD ){
if ( picoSurface == NULL ) { if ( picoSurface == NULL ) {
_pico_printf( PICO_ERROR, "Unable to allocate a new model surface" ); _pico_printf( PICO_ERROR, "Unable to allocate a new model surface" );
PicoFreeModel( picoModel ); PicoFreeModel( picoModel );
_pico_free(bb0);
return NULL; return NULL;
} }
@ -389,6 +416,7 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD ){
if ( picoShader == NULL ) { if ( picoShader == NULL ) {
_pico_printf( PICO_ERROR, "Unable to allocate a new model shader" ); _pico_printf( PICO_ERROR, "Unable to allocate a new model shader" );
PicoFreeModel( picoModel ); PicoFreeModel( picoModel );
_pico_free(bb0);
return NULL; return NULL;
} }
@ -619,6 +647,7 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD ){
_pico_free( p_index_LUT_DUPS ); _pico_free( p_index_LUT_DUPS );
/* return the new pico model */ /* return the new pico model */
_pico_free(bb0);
return picoModel; return picoModel;
} }

View File

@ -76,7 +76,7 @@ static int _lwo_canload( PM_PARAMS_CANLOAD ){
int ret; int ret;
/* create a new pico memorystream */ /* 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 ) { if ( s == NULL ) {
return PICO_PMV_ERROR_MEMORY; return PICO_PMV_ERROR_MEMORY;
} }
@ -133,7 +133,7 @@ static picoModel_t *_lwo_load( PM_PARAMS_LOAD ){
} }
/* create a new pico memorystream */ /* 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 ) { if ( s == NULL ) {
return NULL; return NULL;
} }

View File

@ -299,21 +299,18 @@ float md2_normals[ MD2_NUMVERTEXNORMALS ][ 3 ] =
// _md2_canload() // _md2_canload()
static int _md2_canload( PM_PARAMS_CANLOAD ){ static int _md2_canload( PM_PARAMS_CANLOAD ){
md2_t *md2; const md2_t *md2;
/* to keep the compiler happy */
*fileName = *fileName;
/* sanity check */ /* sanity check */
if ( bufSize < ( sizeof( *md2 ) * 2 ) ) { if ( (size_t) bufSize < ( sizeof( *md2 ) * 2 ) ) {
return PICO_PMV_ERROR_SIZE; return PICO_PMV_ERROR_SIZE;
} }
/* set as md2 */ /* set as md2 */
md2 = (md2_t*) buffer; md2 = (const md2_t*) buffer;
/* check md2 magic */ /* check md2 magic */
if ( *( (int*) md2->magic ) != *( (int*) MD2_MAGIC ) ) { if ( *( (const int*) md2->magic ) != *( (const int*) MD2_MAGIC ) ) {
return PICO_PMV_ERROR_IDENT; return PICO_PMV_ERROR_IDENT;
} }
@ -346,7 +343,7 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD ){
md2Triangle_t *triangle; md2Triangle_t *triangle;
md2XyzNormal_t *vertex; md2XyzNormal_t *vertex;
picoByte_t *bb; picoByte_t *bb, *bb0;
picoModel_t *picoModel; picoModel_t *picoModel;
picoSurface_t *picoSurface; picoSurface_t *picoSurface;
picoShader_t *picoShader; picoShader_t *picoShader;
@ -359,13 +356,15 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD ){
_pico_printf( PICO_NORMAL, "Loading \"%s\"", fileName ); _pico_printf( PICO_NORMAL, "Loading \"%s\"", fileName );
/* set as md2 */ /* set as md2 */
bb = (picoByte_t*) buffer; bb0 = bb = (picoByte_t*) _pico_alloc( bufSize );
md2 = (md2_t*) buffer; memcpy( bb, buffer, bufSize );
md2 = (md2_t*) bb;
/* check ident and version */ /* 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) */ /* not an md2 file (todo: set error) */
_pico_printf( PICO_ERROR, "%s is not an MD2 File!", fileName ); _pico_printf( PICO_ERROR, "%s is not an MD2 File!", fileName );
_pico_free(bb0);
return NULL; return NULL;
} }
@ -393,11 +392,13 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD ){
// do frame check // do frame check
if ( md2->numFrames < 1 ) { if ( md2->numFrames < 1 ) {
_pico_printf( PICO_ERROR, "%s has 0 frames!", fileName ); _pico_printf( PICO_ERROR, "%s has 0 frames!", fileName );
_pico_free(bb0);
return NULL; return NULL;
} }
if ( frameNum < 0 || frameNum >= md2->numFrames ) { if ( frameNum < 0 || frameNum >= md2->numFrames ) {
_pico_printf( PICO_ERROR, "Invalid or out-of-range MD2 frame specified" ); _pico_printf( PICO_ERROR, "Invalid or out-of-range MD2 frame specified" );
_pico_free(bb0);
return NULL; return NULL;
} }
@ -431,7 +432,7 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD ){
} }
// set Skin Name // set Skin Name
strncpy( skinname, (char *) ( bb + md2->ofsSkins ), MD2_MAX_SKINNAME ); strncpy( skinname, (const char *) ( bb + md2->ofsSkins ), MD2_MAX_SKINNAME );
// Print out md2 values // 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 ); _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 );
@ -462,6 +463,7 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD ){
picoModel = PicoNewModel(); picoModel = PicoNewModel();
if ( picoModel == NULL ) { if ( picoModel == NULL ) {
_pico_printf( PICO_ERROR, "Unable to allocate a new model" ); _pico_printf( PICO_ERROR, "Unable to allocate a new model" );
_pico_free(bb0);
return NULL; return NULL;
} }
@ -476,6 +478,7 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD ){
if ( picoSurface == NULL ) { if ( picoSurface == NULL ) {
_pico_printf( PICO_ERROR, "Unable to allocate a new model surface" ); _pico_printf( PICO_ERROR, "Unable to allocate a new model surface" );
PicoFreeModel( picoModel ); PicoFreeModel( picoModel );
_pico_free(bb0);
return NULL; return NULL;
} }
@ -486,6 +489,7 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD ){
if ( picoShader == NULL ) { if ( picoShader == NULL ) {
_pico_printf( PICO_ERROR, "Unable to allocate a new model shader" ); _pico_printf( PICO_ERROR, "Unable to allocate a new model shader" );
PicoFreeModel( picoModel ); PicoFreeModel( picoModel );
_pico_free(bb0);
return NULL; return NULL;
} }
@ -663,6 +667,7 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD ){
_pico_free( p_index_LUT_DUPS ); _pico_free( p_index_LUT_DUPS );
/* return the new pico model */ /* return the new pico model */
_pico_free(bb0);
return picoModel; return picoModel;
} }

View File

@ -144,22 +144,18 @@ md3_t;
*/ */
static int _md3_canload( PM_PARAMS_CANLOAD ){ static int _md3_canload( PM_PARAMS_CANLOAD ){
md3_t *md3; const md3_t *md3;
/* to keep the compiler happy */
*fileName = *fileName;
/* sanity check */ /* sanity check */
if ( bufSize < ( sizeof( *md3 ) * 2 ) ) { if ( (size_t) bufSize < ( sizeof( *md3 ) * 2 ) ) {
return PICO_PMV_ERROR_SIZE; return PICO_PMV_ERROR_SIZE;
} }
/* set as md3 */ /* set as md3 */
md3 = (md3_t*) buffer; md3 = (const md3_t*) buffer;
/* check md3 magic */ /* check md3 magic */
if ( *( (int*) md3->magic ) != *( (int*) MD3_MAGIC ) ) { if ( *( (const int*) md3->magic ) != *( (const int*) MD3_MAGIC ) ) {
return PICO_PMV_ERROR_IDENT; return PICO_PMV_ERROR_IDENT;
} }
@ -181,7 +177,7 @@ static int _md3_canload( PM_PARAMS_CANLOAD ){
static picoModel_t *_md3_load( PM_PARAMS_LOAD ){ static picoModel_t *_md3_load( PM_PARAMS_LOAD ){
int i, j; int i, j;
picoByte_t *bb; picoByte_t *bb, *bb0;
md3_t *md3; md3_t *md3;
md3Surface_t *surface; md3Surface_t *surface;
md3Shader_t *shader; md3Shader_t *shader;
@ -205,12 +201,14 @@ static picoModel_t *_md3_load( PM_PARAMS_LOAD ){
/* set as md3 */ /* set as md3 */
bb = (picoByte_t*) buffer; bb0 = bb = (picoByte_t*) _pico_alloc( bufSize );
md3 = (md3_t*) buffer; memcpy( bb, buffer, bufSize );
md3 = (md3_t*) bb;
/* check ident and version */ /* check ident and version */
if ( *( (int*) md3->magic ) != *( (int*) MD3_MAGIC ) || _pico_little_long( md3->version ) != MD3_VERSION ) { if ( *( (int*) md3->magic ) != *( (int*) MD3_MAGIC ) || _pico_little_long( md3->version ) != MD3_VERSION ) {
/* not an md3 file (todo: set error) */ /* not an md3 file (todo: set error) */
_pico_free(bb0);
return NULL; return NULL;
} }
@ -228,11 +226,13 @@ static picoModel_t *_md3_load( PM_PARAMS_LOAD ){
/* do frame check */ /* do frame check */
if ( md3->numFrames < 1 ) { if ( md3->numFrames < 1 ) {
_pico_printf( PICO_ERROR, "MD3 with 0 frames" ); _pico_printf( PICO_ERROR, "MD3 with 0 frames" );
_pico_free(bb0);
return NULL; return NULL;
} }
if ( frameNum < 0 || frameNum >= md3->numFrames ) { if ( frameNum < 0 || frameNum >= md3->numFrames ) {
_pico_printf( PICO_ERROR, "Invalid or out-of-range MD3 frame specified" ); _pico_printf( PICO_ERROR, "Invalid or out-of-range MD3 frame specified" );
_pico_free(bb0);
return NULL; return NULL;
} }
@ -305,6 +305,7 @@ static picoModel_t *_md3_load( PM_PARAMS_LOAD ){
picoModel = PicoNewModel(); picoModel = PicoNewModel();
if ( picoModel == NULL ) { if ( picoModel == NULL ) {
_pico_printf( PICO_ERROR, "Unable to allocate a new model" ); _pico_printf( PICO_ERROR, "Unable to allocate a new model" );
_pico_free(bb0);
return NULL; return NULL;
} }
@ -325,6 +326,7 @@ static picoModel_t *_md3_load( PM_PARAMS_LOAD ){
if ( picoSurface == NULL ) { if ( picoSurface == NULL ) {
_pico_printf( PICO_ERROR, "Unable to allocate a new model surface" ); _pico_printf( PICO_ERROR, "Unable to allocate a new model surface" );
PicoFreeModel( picoModel ); /* sea */ PicoFreeModel( picoModel ); /* sea */
_pico_free(bb0);
return NULL; return NULL;
} }
@ -340,6 +342,7 @@ static picoModel_t *_md3_load( PM_PARAMS_LOAD ){
_pico_printf( PICO_ERROR, "Unable to allocate a new model shader" ); _pico_printf( PICO_ERROR, "Unable to allocate a new model shader" );
PicoFreeModel( picoModel ); PicoFreeModel( picoModel );
return NULL; return NULL;
_pico_free(bb0);
} }
/* detox and set shader name */ /* detox and set shader name */
@ -398,6 +401,7 @@ static picoModel_t *_md3_load( PM_PARAMS_LOAD ){
} }
/* return the new pico model */ /* return the new pico model */
_pico_free(bb0);
return picoModel; return picoModel;
} }

View File

@ -416,22 +416,19 @@ mdc_t;
*/ */
static int _mdc_canload( PM_PARAMS_CANLOAD ){ static int _mdc_canload( PM_PARAMS_CANLOAD ){
mdc_t *mdc; const mdc_t *mdc;
/* to keep the compiler happy */
*fileName = *fileName;
/* sanity check */ /* sanity check */
if ( bufSize < ( sizeof( *mdc ) * 2 ) ) { if ( (size_t) bufSize < ( sizeof( *mdc ) * 2 ) ) {
return PICO_PMV_ERROR_SIZE; return PICO_PMV_ERROR_SIZE;
} }
/* set as mdc */ /* set as mdc */
mdc = (mdc_t*) buffer; mdc = (const mdc_t*) buffer;
/* check mdc magic */ /* check mdc magic */
if ( *( (int*) mdc->magic ) != *( (int*) MDC_MAGIC ) ) { if ( *( (const int*) mdc->magic ) != *( (const int*) MDC_MAGIC ) ) {
return PICO_PMV_ERROR_IDENT; return PICO_PMV_ERROR_IDENT;
} }
@ -453,7 +450,7 @@ static int _mdc_canload( PM_PARAMS_CANLOAD ){
static picoModel_t *_mdc_load( PM_PARAMS_LOAD ){ static picoModel_t *_mdc_load( PM_PARAMS_LOAD ){
int i, j; int i, j;
picoByte_t *bb; picoByte_t *bb, *bb0;
mdc_t *mdc; mdc_t *mdc;
mdcSurface_t *surface; mdcSurface_t *surface;
mdcShader_t *shader; mdcShader_t *shader;
@ -461,8 +458,8 @@ static picoModel_t *_mdc_load( PM_PARAMS_LOAD ){
mdcFrame_t *frame; mdcFrame_t *frame;
mdcTriangle_t *triangle; mdcTriangle_t *triangle;
mdcVertex_t *vertex; mdcVertex_t *vertex;
mdcXyzCompressed_t *vertexComp; mdcXyzCompressed_t *vertexComp = NULL;
short *mdcShort, *mdcCompVert; short *mdcShort, *mdcCompVert = NULL;
double lat, lng; double lat, lng;
picoModel_t *picoModel; picoModel_t *picoModel;
@ -479,12 +476,14 @@ static picoModel_t *_mdc_load( PM_PARAMS_LOAD ){
/* set as mdc */ /* set as mdc */
bb = (picoByte_t*) buffer; bb0 = bb = (picoByte_t*) _pico_alloc( bufSize );
mdc = (mdc_t*) buffer; memcpy( bb, buffer, bufSize );
mdc = (mdc_t*) bb;
/* check ident and version */ /* check ident and version */
if ( *( (int*) mdc->magic ) != *( (int*) MDC_MAGIC ) || _pico_little_long( mdc->version ) != MDC_VERSION ) { if ( *( (int*) mdc->magic ) != *( (int*) MDC_MAGIC ) || _pico_little_long( mdc->version ) != MDC_VERSION ) {
/* not an mdc file (todo: set error) */ /* not an mdc file (todo: set error) */
_pico_free( bb0 );
return NULL; return NULL;
} }
@ -503,11 +502,13 @@ static picoModel_t *_mdc_load( PM_PARAMS_LOAD ){
/* do frame check */ /* do frame check */
if ( mdc->numFrames < 1 ) { if ( mdc->numFrames < 1 ) {
_pico_printf( PICO_ERROR, "MDC with 0 frames" ); _pico_printf( PICO_ERROR, "MDC with 0 frames" );
_pico_free( bb0 );
return NULL; return NULL;
} }
if ( frameNum < 0 || frameNum >= mdc->numFrames ) { if ( frameNum < 0 || frameNum >= mdc->numFrames ) {
_pico_printf( PICO_ERROR, "Invalid or out-of-range MDC frame specified" ); _pico_printf( PICO_ERROR, "Invalid or out-of-range MDC frame specified" );
_pico_free( bb0 );
return NULL; return NULL;
} }
@ -605,6 +606,7 @@ static picoModel_t *_mdc_load( PM_PARAMS_LOAD ){
picoModel = PicoNewModel(); picoModel = PicoNewModel();
if ( picoModel == NULL ) { if ( picoModel == NULL ) {
_pico_printf( PICO_ERROR, "Unable to allocate a new model" ); _pico_printf( PICO_ERROR, "Unable to allocate a new model" );
_pico_free( bb0 );
return NULL; return NULL;
} }
@ -625,6 +627,7 @@ static picoModel_t *_mdc_load( PM_PARAMS_LOAD ){
if ( picoSurface == NULL ) { if ( picoSurface == NULL ) {
_pico_printf( PICO_ERROR, "Unable to allocate a new model surface" ); _pico_printf( PICO_ERROR, "Unable to allocate a new model surface" );
PicoFreeModel( picoModel ); /* sea */ PicoFreeModel( picoModel ); /* sea */
_pico_free( bb0 );
return NULL; return NULL;
} }
@ -639,6 +642,7 @@ static picoModel_t *_mdc_load( PM_PARAMS_LOAD ){
if ( picoShader == NULL ) { if ( picoShader == NULL ) {
_pico_printf( PICO_ERROR, "Unable to allocate a new model shader" ); _pico_printf( PICO_ERROR, "Unable to allocate a new model shader" );
PicoFreeModel( picoModel ); PicoFreeModel( picoModel );
_pico_free( bb0 );
return NULL; return NULL;
} }
@ -722,6 +726,7 @@ static picoModel_t *_mdc_load( PM_PARAMS_LOAD ){
} }
/* return the new pico model */ /* return the new pico model */
_pico_free( bb0 );
return picoModel; return picoModel;
} }

View File

@ -164,19 +164,16 @@ TMsKeyframe;
* validates a milkshape3d model file. * validates a milkshape3d model file.
*/ */
static int _ms3d_canload( PM_PARAMS_CANLOAD ){ static int _ms3d_canload( PM_PARAMS_CANLOAD ){
TMsHeader *hdr; const TMsHeader *hdr;
/* to keep the compiler happy */
*fileName = *fileName;
/* sanity check */ /* sanity check */
if ( bufSize < sizeof( TMsHeader ) ) { if ( (size_t) bufSize < sizeof( TMsHeader ) ) {
return PICO_PMV_ERROR_SIZE; return PICO_PMV_ERROR_SIZE;
} }
/* get ms3d header */ /* get ms3d header */
hdr = (TMsHeader *)buffer; hdr = (const TMsHeader *)buffer;
/* check ms3d magic */ /* check ms3d magic */
if ( strncmp( hdr->magic,"MS3D000000",10 ) != 0 ) { if ( strncmp( hdr->magic,"MS3D000000",10 ) != 0 ) {
@ -206,7 +203,7 @@ static unsigned char *GetWord( unsigned char *bufptr, int *out ){
*/ */
static picoModel_t *_ms3d_load( PM_PARAMS_LOAD ){ static picoModel_t *_ms3d_load( PM_PARAMS_LOAD ){
picoModel_t *model; picoModel_t *model;
unsigned char *bufptr; unsigned char *bufptr, *bufptr0;
int shaderRefs[ MS3D_MAX_GROUPS ]; int shaderRefs[ MS3D_MAX_GROUPS ];
int numGroups; int numGroups;
int numMaterials; int numMaterials;
@ -228,8 +225,10 @@ static picoModel_t *_ms3d_load( PM_PARAMS_LOAD ){
PicoSetModelName( model, fileName ); PicoSetModelName( model, fileName );
PicoSetModelFileName( model, fileName ); PicoSetModelFileName( model, fileName );
bufptr0 = bufptr = (picoByte_t*) _pico_alloc( bufSize );
memcpy( bufptr, buffer, bufSize );
/* skip header */ /* skip header */
bufptr = (unsigned char *)buffer + sizeof( TMsHeader ); bufptr += sizeof( TMsHeader );
/* get number of vertices */ /* get number of vertices */
bufptr = GetWord( bufptr,&numVerts ); bufptr = GetWord( bufptr,&numVerts );
@ -289,6 +288,7 @@ static picoModel_t *_ms3d_load( PM_PARAMS_LOAD ){
if ( triangle->vertexIndices[ k ] >= numVerts ) { if ( triangle->vertexIndices[ k ] >= numVerts ) {
_pico_printf( PICO_ERROR,"Vertex %d index %d out of range (%d, max %d)",i,k,triangle->vertexIndices[k],numVerts - 1 ); _pico_printf( PICO_ERROR,"Vertex %d index %d out of range (%d, max %d)",i,k,triangle->vertexIndices[k],numVerts - 1 );
PicoFreeModel( model ); PicoFreeModel( model );
_pico_free( bufptr0 );
return NULL; /* yuck */ return NULL; /* yuck */
} }
} }
@ -321,6 +321,7 @@ static picoModel_t *_ms3d_load( PM_PARAMS_LOAD ){
surface = PicoNewSurface( model ); surface = PicoNewSurface( model );
if ( surface == NULL ) { if ( surface == NULL ) {
PicoFreeModel( model ); PicoFreeModel( model );
_pico_free( bufptr0 );
return NULL; return NULL;
} }
/* do surface setup */ /* do surface setup */
@ -413,6 +414,7 @@ static picoModel_t *_ms3d_load( PM_PARAMS_LOAD ){
shader = PicoNewShader( model ); shader = PicoNewShader( model );
if ( shader == NULL ) { if ( shader == NULL ) {
PicoFreeModel( model ); PicoFreeModel( model );
_pico_free( bufptr0 );
return NULL; return NULL;
} }
/* scale shader colors */ /* scale shader colors */
@ -476,6 +478,7 @@ static picoModel_t *_ms3d_load( PM_PARAMS_LOAD ){
#endif #endif
} }
/* return allocated pico model */ /* return allocated pico model */
_pico_free( bufptr0 );
return model; return model;
// return NULL; // return NULL;
} }

View File

@ -85,7 +85,7 @@ static int _obj_canload( PM_PARAMS_CANLOAD ){
/* appearing at the beginning of wavefront objects */ /* appearing at the beginning of wavefront objects */
/* alllocate a new pico parser */ /* 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 ) { if ( p == NULL ) {
return PICO_PMV_ERROR_MEMORY; return PICO_PMV_ERROR_MEMORY;
} }
@ -521,7 +521,7 @@ static picoModel_t *_obj_load( PM_PARAMS_LOAD ){
return NULL; \ return NULL; \
} }
/* alllocate a new pico parser */ /* 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 ) { if ( p == NULL ) {
return NULL; return NULL;
} }
@ -685,8 +685,8 @@ static picoModel_t *_obj_load( PM_PARAMS_LOAD ){
int ivt[ 4 ], has_vt = 0; int ivt[ 4 ], has_vt = 0;
int ivn[ 4 ], has_vn = 0; int ivn[ 4 ], has_vn = 0;
int have_quad = 0; int have_quad = 0;
int slashcount; int slashcount = 0;
int doubleslash; int doubleslash = 0;
int i; int i;
/* group defs *must* come before faces */ /* group defs *must* come before faces */

View File

@ -302,11 +302,8 @@ static int _terrain_canload( PM_PARAMS_CANLOAD ) {
picoParser_t *p; picoParser_t *p;
/* keep the friggin compiler happy */
/**fileName = *fileName*/;
/* create pico parser */ /* create pico parser */
p = _pico_new_parser( (picoByte_t*) buffer, bufSize ); p = _pico_new_parser( (const picoByte_t*) buffer, bufSize );
if ( p == NULL ) { if ( p == NULL ) {
return PICO_PMV_ERROR_MEMORY; return PICO_PMV_ERROR_MEMORY;
} }
@ -355,11 +352,8 @@ static picoModel_t *_terrain_load( PM_PARAMS_LOAD ) {
picoColor_t color; picoColor_t color;
/* keep the friggin compiler happy */
/**fileName = *fileName*/;
/* create pico parser */ /* create pico parser */
p = _pico_new_parser( (picoByte_t*) buffer, bufSize ); p = _pico_new_parser( (const picoByte_t*) buffer, bufSize );
if ( p == NULL ) { if ( p == NULL ) {
return NULL; return NULL;
} }
@ -596,7 +590,7 @@ const picoModule_t picoModuleTerrain =
"1.3", /* module version string */ "1.3", /* module version string */
"PicoTerrain", /* module display name */ "PicoTerrain", /* module display name */
"Randy Reddig", /* author's name */ "Randy Reddig", /* author's name */
"2003 Randy Reddig", /* module copyright */ "2003 Randy Reddig", /* module copyright */
{ {
"picoterrain", NULL, NULL, NULL /* default extensions to use */ "picoterrain", NULL, NULL, NULL /* default extensions to use */
}, },

View File

@ -188,7 +188,7 @@ void SetQdirFromPath( const char *path ){
} }
strncpy( qdir, path, c + len + count - path ); strncpy( qdir, path, c + len + count - path );
Sys_Printf( "qdir: %s\n", qdir ); Sys_Printf( "qdir: %s\n", qdir );
for ( i = 0; i < strlen( qdir ); i++ ) for ( i = 0; i < (int) strlen( qdir ); i++ )
{ {
if ( qdir[i] == '\\' ) { if ( qdir[i] == '\\' ) {
qdir[i] = '/'; qdir[i] = '/';
@ -201,7 +201,7 @@ void SetQdirFromPath( const char *path ){
if ( *c == '/' || *c == '\\' ) { if ( *c == '/' || *c == '\\' ) {
strncpy( gamedir, path, c + 1 - path ); strncpy( gamedir, path, c + 1 - path );
for ( i = 0; i < strlen( gamedir ); i++ ) for ( i = 0; i < (int) strlen( gamedir ); i++ )
{ {
if ( gamedir[i] == '\\' ) { if ( gamedir[i] == '\\' ) {
gamedir[i] = '/'; gamedir[i] = '/';

View File

@ -532,6 +532,7 @@ void LoadPCX( const char *filename, byte **pic, byte **palette, int *width, int
for ( y = 0; y <= pcx->ymax; y++, pix += pcx->xmax + 1 ) for ( y = 0; y <= pcx->ymax; y++, pix += pcx->xmax + 1 )
{ {
/* do a scanline */ /* do a scanline */
runLength = 0;
for ( x = 0; x <= pcx->xmax; ) for ( x = 0; x <= pcx->xmax; )
{ {
/* RR2DO2 */ /* RR2DO2 */
@ -1123,7 +1124,7 @@ void LoadTGA( const char *name, byte **pixels, int *width, int *height ){
// //
// load the file // load the file
// //
nLen = vfsLoadFile( ( char * ) name, (void **)&buffer, 0 ); nLen = vfsLoadFile( name, (void **)&buffer, 0 );
if ( nLen == -1 ) { if ( nLen == -1 ) {
Error( "Couldn't read %s", name ); Error( "Couldn't read %s", name );
} }

View File

@ -73,8 +73,8 @@ xmlNodePtr xml_NodeForVec( vec3_t v ){
char buf[1024]; char buf[1024];
sprintf( buf, "%f %f %f", v[0], v[1], v[2] ); sprintf( buf, "%f %f %f", v[0], v[1], v[2] );
ret = xmlNewNode( NULL, BAD_CAST "point" ); ret = xmlNewNode( NULL, (xmlChar*)"point" );
xmlNodeSetContent( ret, BAD_CAST buf ); xmlNodeSetContent( ret, (xmlChar*)buf );
return ret; return ret;
} }
@ -96,7 +96,7 @@ void xml_SendNode( xmlNodePtr node ){
// l_net library defines an upper limit of MAX_NETMESSAGE // 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 // 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 // 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? // what size are we gonna send now?
( xml_buf->use - pos < MAX_NETMESSAGE - 10 ) ? ( size = xml_buf->use - pos ) : ( size = MAX_NETMESSAGE - 10 ); ( xml_buf->use - pos < MAX_NETMESSAGE - 10 ) ? ( size = xml_buf->use - pos ) : ( size = MAX_NETMESSAGE - 10 );
@ -151,15 +151,15 @@ void xml_Select( char *msg, int entitynum, int brushnum, qboolean bError ){
// now build a proper "select" XML node // now build a proper "select" XML node
sprintf( buf, "Entity %i, Brush %i: %s", entitynum, brushnum, msg ); sprintf( buf, "Entity %i, Brush %i: %s", entitynum, brushnum, msg );
node = xmlNewNode( NULL, BAD_CAST "select" ); node = xmlNewNode( NULL, (xmlChar*)"select" );
xmlNodeSetContent( node, BAD_CAST buf ); xmlNodeSetContent( node, (xmlChar*)buf );
level[0] = (int)'0' + ( bError ? SYS_ERR : SYS_WRN ) ; level[0] = (int)'0' + ( bError ? SYS_ERR : SYS_WRN ) ;
level[1] = 0; level[1] = 0;
xmlSetProp( node, BAD_CAST "level", BAD_CAST (char *)&level ); xmlSetProp( node, (xmlChar*)"level", (xmlChar*)&level );
// a 'select' information // a 'select' information
sprintf( buf, "%i %i", entitynum, brushnum ); sprintf( buf, "%i %i", entitynum, brushnum );
select = xmlNewNode( NULL, BAD_CAST "brush" ); select = xmlNewNode( NULL, (xmlChar*)"brush" );
xmlNodeSetContent( select, BAD_CAST buf ); xmlNodeSetContent( select, (xmlChar*)buf );
xmlAddChild( node, select ); xmlAddChild( node, select );
xml_SendNode( node ); xml_SendNode( node );
@ -178,15 +178,15 @@ void xml_Point( char *msg, vec3_t pt ){
char buf[1024]; char buf[1024];
char level[2]; char level[2];
node = xmlNewNode( NULL, BAD_CAST "pointmsg" ); node = xmlNewNode( NULL, (xmlChar*)"pointmsg" );
xmlNodeSetContent( node, BAD_CAST msg ); xmlNodeSetContent( node, (xmlChar*)msg );
level[0] = (int)'0' + SYS_ERR; level[0] = (int)'0' + SYS_ERR;
level[1] = 0; level[1] = 0;
xmlSetProp( node, BAD_CAST "level", BAD_CAST (char *)&level ); xmlSetProp( node, (xmlChar*)"level", (xmlChar *)&level );
// a 'point' node // a 'point' node
sprintf( buf, "%g %g %g", pt[0], pt[1], pt[2] ); sprintf( buf, "%g %g %g", pt[0], pt[1], pt[2] );
point = xmlNewNode( NULL, BAD_CAST "point" ); point = xmlNewNode( NULL, (xmlChar*)"point" );
xmlNodeSetContent( point, BAD_CAST buf ); xmlNodeSetContent( point, (xmlChar*)buf );
xmlAddChild( node, point ); xmlAddChild( node, point );
xml_SendNode( node ); xml_SendNode( node );
@ -202,11 +202,11 @@ void xml_Winding( char *msg, vec3_t p[], int numpoints, qboolean die ){
char level[2]; char level[2];
int i; int i;
node = xmlNewNode( NULL, BAD_CAST "windingmsg" ); node = xmlNewNode( NULL, (xmlChar*)"windingmsg" );
xmlNodeSetContent( node, BAD_CAST msg ); xmlNodeSetContent( node, (xmlChar*)msg );
level[0] = (int)'0' + SYS_ERR; level[0] = (int)'0' + SYS_ERR;
level[1] = 0; level[1] = 0;
xmlSetProp( node, BAD_CAST "level", BAD_CAST (char *)&level ); xmlSetProp( node, (xmlChar*)"level", (xmlChar *)&level );
// a 'winding' node // a 'winding' node
sprintf( buf, "%i ", numpoints ); sprintf( buf, "%i ", numpoints );
for ( i = 0; i < numpoints; i++ ) for ( i = 0; i < numpoints; i++ )
@ -219,8 +219,8 @@ void xml_Winding( char *msg, vec3_t p[], int numpoints, qboolean die ){
strcat( buf, smlbuf ); strcat( buf, smlbuf );
} }
winding = xmlNewNode( NULL, BAD_CAST "winding" ); winding = xmlNewNode( NULL, (xmlChar*)"winding" );
xmlNodeSetContent( winding, BAD_CAST buf ); xmlNodeSetContent( winding, (xmlChar*)buf );
xmlAddChild( node, winding ); xmlAddChild( node, winding );
xml_SendNode( node ); xml_SendNode( node );
@ -284,19 +284,19 @@ void FPrintf( int flag, char *buf ){
*/ */
if ( !bGotXML ) { if ( !bGotXML ) {
// initialize // initialize
doc = xmlNewDoc( BAD_CAST "1.0" ); doc = xmlNewDoc( (xmlChar*)"1.0" );
doc->children = xmlNewDocRawNode( doc, NULL, BAD_CAST "q3map_feedback", NULL ); doc->children = xmlNewDocRawNode( doc, NULL, (xmlChar*)"q3map_feedback", NULL );
bGotXML = qtrue; bGotXML = qtrue;
} }
node = xmlNewNode( NULL, BAD_CAST "message" ); node = xmlNewNode( NULL, (xmlChar*)"message" );
{ {
gchar* utf8 = g_locale_to_utf8( buf, -1, NULL, NULL, NULL ); gchar* utf8 = g_locale_to_utf8( buf, -1, NULL, NULL, NULL );
xmlNodeSetContent( node, BAD_CAST utf8 ); xmlNodeSetContent( node, (xmlChar*)utf8 );
g_free( utf8 ); g_free( utf8 );
} }
level[0] = (int)'0' + flag; level[0] = (int)'0' + flag;
level[1] = 0; level[1] = 0;
xmlSetProp( node, BAD_CAST "level", BAD_CAST (char *)&level ); xmlSetProp( node, (xmlChar*)"level", (xmlChar *)&level );
xml_SendNode( node ); xml_SendNode( node );
} }

View File

@ -347,12 +347,12 @@ void ProcessWorldModel( void ){
Sys_FPrintf( SYS_NOXML, "******* leaked *******\n" ); Sys_FPrintf( SYS_NOXML, "******* leaked *******\n" );
Sys_FPrintf( SYS_NOXML, "**********************\n" ); Sys_FPrintf( SYS_NOXML, "**********************\n" );
polyline = LeakFile( tree ); polyline = LeakFile( tree );
leaknode = xmlNewNode( NULL, BAD_CAST "message" ); leaknode = xmlNewNode( NULL, (xmlChar*)"message" );
xmlNodeSetContent( leaknode, BAD_CAST "MAP LEAKED\n" ); xmlNodeSetContent( leaknode, (xmlChar*)"MAP LEAKED\n" );
xmlAddChild( leaknode, polyline ); xmlAddChild( leaknode, polyline );
level[0] = (int) '0' + SYS_ERR; level[0] = (int) '0' + SYS_ERR;
level[1] = 0; level[1] = 0;
xmlSetProp( leaknode, BAD_CAST "level", BAD_CAST (char*) &level ); xmlSetProp( leaknode, (xmlChar*)"level", (xmlChar*)(char*) &level );
xml_SendNode( leaknode ); xml_SendNode( leaknode );
if ( leaktest ) { if ( leaktest ) {
Sys_Printf( "--- MAP LEAKED, ABORTING LEAKTEST ---\n" ); Sys_Printf( "--- MAP LEAKED, ABORTING LEAKTEST ---\n" );
@ -466,7 +466,7 @@ void ProcessWorldModel( void ){
} }
/* create the flare surface (note shader defaults automatically) */ /* create the flare surface (note shader defaults automatically) */
DrawSurfaceForFlare( mapEntityNum, origin, normal, color, (char*) flareShader, lightStyle ); DrawSurfaceForFlare( mapEntityNum, origin, normal, color, flareShader, lightStyle );
} }
} }
} }

View File

@ -0,0 +1,81 @@
/* -------------------------------------------------------------------------------
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 compensate */
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

View File

@ -97,7 +97,7 @@ static void LoadDDSBuffer( byte *buffer, int size, byte **pixels, int *width, in
typedef struct pngBuffer_s typedef struct pngBuffer_s
{ {
byte *buffer; byte *buffer;
int size, offset; png_size_t size, offset;
} pngBuffer_t; } pngBuffer_t;
void PNGReadData( png_struct *png, png_byte *buffer, png_size_t size ){ void PNGReadData( png_struct *png, png_byte *buffer, png_size_t size ){
@ -123,8 +123,8 @@ static void LoadPNGBuffer( byte *buffer, int size, byte **pixels, int *width, in
png_struct *png; png_struct *png;
png_info *info, *end; png_info *info, *end;
pngBuffer_t pb; pngBuffer_t pb;
int i, bitDepth, colorType, channels; int bitDepth, colorType, channels;
png_uint_32 w, h; png_uint_32 w, h, i;
byte **rowPointers; byte **rowPointers;
/* dummy check */ /* dummy check */

View File

@ -82,15 +82,15 @@ xmlNodePtr LeakFile( tree_t *tree ){
Error( "Couldn't open %s\n", filename ); Error( "Couldn't open %s\n", filename );
} }
xml_node = xmlNewNode( NULL, BAD_CAST "polyline" ); xml_node = xmlNewNode( NULL, (xmlChar*)"polyline" );
count = 0; count = 0;
node = &tree->outside_node; node = &tree->outside_node;
while ( node->occupied > 1 ) while ( node->occupied > 1 )
{ {
int next; int next;
portal_t *p, *nextportal; portal_t *p, *nextportal = NULL;
node_t *nextnode; node_t *nextnode = NULL;
int s; int s;
// find the best portal exit // find the best portal exit

View File

@ -981,10 +981,8 @@ int LightContributionToSample( trace_t *trace ){
/* return to sender */ /* return to sender */
return 1; return 1;
} }
/* unknown light type */
else { else {
return -1; Error( "Light of undefined type!" );
} }
/* ydnar: changed to a variable number */ /* ydnar: changed to a variable number */

View File

@ -417,7 +417,7 @@ static void RadSample( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm,
static void RadSubdivideDiffuseLight( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm, shaderInfo_t *si, 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 ){ float scale, float subdivide, qboolean original, radWinding_t *rw, clipWork_t *cw ){
int i, style; int i, style = 0;
float dist, area, value; float dist, area, value;
vec3_t mins, maxs, normal, d1, d2, cross, color, gradient; vec3_t mins, maxs, normal, d1, d2, cross, color, gradient;
light_t *light, *splash; light_t *light, *splash;
@ -543,7 +543,7 @@ static void RadSubdivideDiffuseLight( int lightmapNum, bspDrawSurface_t *ds, raw
light->falloffTolerance = falloffTolerance; light->falloffTolerance = falloffTolerance;
/* bouncing light? */ /* bouncing light? */
if ( bouncing == qfalse ) { if ( !bouncing ) {
/* handle first-pass lights in normal q3a style */ /* handle first-pass lights in normal q3a style */
value = si->value; value = si->value;
light->photons = value * area * areaScale; light->photons = value * area * areaScale;

View File

@ -514,13 +514,10 @@ void ClipTraceWinding( traceWinding_t *tw, vec4_t plane, traceWinding_t *front,
mid.xyz[ k ] = a->xyz[ k ] + frac * ( b->xyz[ k ] - a->xyz[ k ] ); 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 */ /* copy midpoint to front and back polygons */
front->v[ front->numVerts++ ] = mid; front->v[ front->numVerts++ ] = mid;
@ -531,40 +528,6 @@ void ClipTraceWinding( traceWinding_t *tw, vec4_t plane, traceWinding_t *front,
/*
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 FilterTraceWindingIntoNodes_r() - ydnar
filters a trace winding into the raytracing tree filters a trace winding into the raytracing tree
@ -1264,7 +1227,7 @@ static void PopulateTraceNodes( void ){
/* external model */ /* external model */
default: default:
frame = IntForKey( e, "_frame" ); frame = IntForKey( e, "_frame" );
model = LoadModel( (char*) value, frame ); model = LoadModel( value, frame );
if ( model == NULL ) { if ( model == NULL ) {
continue; continue;
} }
@ -1294,7 +1257,7 @@ static void PopulateTraceNodes( void ){
/* external model */ /* external model */
default: default:
frame = IntForKey( e, "_frame2" ); frame = IntForKey( e, "_frame2" );
model = LoadModel( (char*) value, frame ); model = LoadModel( value, frame );
if ( model == NULL ) { if ( model == NULL ) {
continue; continue;
} }

View File

@ -1063,13 +1063,18 @@ void MapRawLightmap( int rawLightmapNum ){
continue; continue;
} }
/* get drawverts and map first triangle */ for ( mapNonAxial = 0; mapNonAxial < 2; mapNonAxial++ )
MapTriangle( lm, info, dv, mapNonAxial ); {
/* get drawverts and map first triangle */
dv[ 1 ] = &verts[ pw[ r + 1 ] ];
dv[ 2 ] = &verts[ pw[ r + 2 ] ];
MapTriangle( lm, info, dv, mapNonAxial );
/* get drawverts and map second triangle */ /* get drawverts and map second triangle */
dv[ 1 ] = &verts[ pw[ r + 2 ] ]; dv[ 1 ] = &verts[ pw[ r + 2 ] ];
dv[ 2 ] = &verts[ pw[ r + 3 ] ]; dv[ 2 ] = &verts[ pw[ r + 3 ] ];
MapTriangle( lm, info, dv, mapNonAxial ); MapTriangle( lm, info, dv, mapNonAxial );
}
} }
} }
@ -1765,8 +1770,9 @@ static void SubsampleRawLuxel_r( rawLightmap_t *lm, trace_t *trace, vec3_t sampl
#define LIGHT_LUXEL( x, y ) ( lightLuxels + ( ( ( ( y ) * lm->sw ) + ( x ) ) * SUPER_LUXEL_SIZE ) ) #define LIGHT_LUXEL( x, y ) ( lightLuxels + ( ( ( ( y ) * lm->sw ) + ( x ) ) * SUPER_LUXEL_SIZE ) )
void IlluminateRawLightmap( int rawLightmapNum ){ void IlluminateRawLightmap( int rawLightmapNum ){
int i, t, x, y, sx, sy, size, llSize, luxelFilterRadius, lightmapNum; int i, t, x, y, sx, sy, size, luxelFilterRadius, lightmapNum;
int *cluster, *cluster2, mapped, lighted, totalLighted; int *cluster, *cluster2, mapped, lighted, totalLighted;
size_t llSize;
rawLightmap_t *lm; rawLightmap_t *lm;
surfaceInfo_t *info; surfaceInfo_t *info;
qboolean filterColor, filterDir; qboolean filterColor, filterDir;

View File

@ -284,8 +284,8 @@ static int CompareLightSurface( const void *a, const void *b ){
/* get shaders */ /* get shaders */
asi = surfaceInfos[ *( (int*) a ) ].si; asi = surfaceInfos[ *( (const int*) a ) ].si;
bsi = surfaceInfos[ *( (int*) b ) ].si; bsi = surfaceInfos[ *( (const int*) b ) ].si;
/* dummy check */ /* dummy check */
if ( asi == NULL ) { if ( asi == NULL ) {
@ -847,8 +847,8 @@ static int CompareSurfaceInfo( const void *a, const void *b ){
/* get surface info */ /* get surface info */
aInfo = &surfaceInfos[ *( (int*) a ) ]; aInfo = &surfaceInfos[ *( (const int*) a ) ];
bInfo = &surfaceInfos[ *( (int*) b ) ]; bInfo = &surfaceInfos[ *( (const int*) b ) ];
/* model first */ /* model first */
if ( aInfo->model < bInfo->model ) { if ( aInfo->model < bInfo->model ) {
@ -2262,8 +2262,8 @@ static int CompareRawLightmap( const void *a, const void *b ){
/* get lightmaps */ /* get lightmaps */
alm = &rawLightmaps[ *( (int*) a ) ]; alm = &rawLightmaps[ *( (const int*) a ) ];
blm = &rawLightmaps[ *( (int*) b ) ]; blm = &rawLightmaps[ *( (const int*) b ) ];
/* get min number of surfaces */ /* get min number of surfaces */
min = ( alm->numLightSurfaces < blm->numLightSurfaces ? alm->numLightSurfaces : blm->numLightSurfaces ); min = ( alm->numLightSurfaces < blm->numLightSurfaces ? alm->numLightSurfaces : blm->numLightSurfaces );
@ -2325,8 +2325,8 @@ void StoreSurfaceLightmaps( void ){
char dirname[ 1024 ], filename[ 1024 ]; char dirname[ 1024 ], filename[ 1024 ];
shaderInfo_t *csi; shaderInfo_t *csi;
char lightmapName[ 128 ]; char lightmapName[ 128 ];
char *rgbGenValues[ 256 ]; const char *rgbGenValues[ 256 ];
char *alphaGenValues[ 256 ]; const char *alphaGenValues[ 256 ];
/* note it */ /* note it */
@ -3080,7 +3080,7 @@ void StoreSurfaceLightmaps( void ){
/* get rgbgen string */ /* get rgbgen string */
if ( rgbGenValues[ style ] == NULL ) { if ( rgbGenValues[ style ] == NULL ) {
sprintf( key, "_style%drgbgen", style ); sprintf( key, "_style%drgbgen", style );
rgbGenValues[ style ] = (char*) ValueForKey( &entities[ 0 ], key ); rgbGenValues[ style ] = ValueForKey( &entities[ 0 ], key );
if ( rgbGenValues[ style ][ 0 ] == '\0' ) { if ( rgbGenValues[ style ][ 0 ] == '\0' ) {
rgbGenValues[ style ] = "wave noise 0.5 1 0 5.37"; rgbGenValues[ style ] = "wave noise 0.5 1 0 5.37";
} }
@ -3096,7 +3096,7 @@ void StoreSurfaceLightmaps( void ){
/* get alphagen string */ /* get alphagen string */
if ( alphaGenValues[ style ] == NULL ) { if ( alphaGenValues[ style ] == NULL ) {
sprintf( key, "_style%dalphagen", style ); sprintf( key, "_style%dalphagen", style );
alphaGenValues[ style ] = (char*) ValueForKey( &entities[ 0 ], key ); alphaGenValues[ style ] = ValueForKey( &entities[ 0 ], key );
} }
if ( alphaGenValues[ style ][ 0 ] != '\0' ) { if ( alphaGenValues[ style ][ 0 ] != '\0' ) {
sprintf( alphaGen, "\t\talphaGen %s // style %d\n", alphaGenValues[ style ], style ); sprintf( alphaGen, "\t\talphaGen %s // style %d\n", alphaGenValues[ style ], style );

View File

@ -956,7 +956,7 @@ static void ParseRawBrush( qboolean onlyLights ){
int planenum; int planenum;
shaderInfo_t *si; shaderInfo_t *si;
vec_t shift[ 2 ]; vec_t shift[ 2 ];
vec_t rotate; vec_t rotate = 0;
vec_t scale[ 2 ]; vec_t scale[ 2 ];
char name[ MAX_QPATH ]; char name[ MAX_QPATH ];
char shader[ MAX_QPATH ]; char shader[ MAX_QPATH ];
@ -1770,7 +1770,7 @@ static qboolean ParseMapEntity( qboolean onlyLights ){
void LoadMapFile( char *filename, qboolean onlyLights ){ void LoadMapFile( char *filename, qboolean onlyLights ){
FILE *file; FILE *file;
brush_t *b; brush_t *b;
int oldNumEntities, numMapBrushes; int oldNumEntities = 0, numMapBrushes;
/* note it */ /* note it */

View File

@ -78,8 +78,8 @@ void PicoPrintFunc( int level, const char *str ){
callback for picomodel.lib 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 );
} }
@ -161,7 +161,7 @@ picoModel_t *LoadModel( char *name, int frame ){
} }
/* attempt to parse model */ /* 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 loading failed, make a bogus model to silence the rest of the warnings */
if ( *pm == NULL ) { if ( *pm == NULL ) {

View File

@ -531,7 +531,7 @@ typedef struct {
------------------------------------------------------------------------------- */ ------------------------------------------------------------------------------- */
/* ydnar: for smaller structs */ /* ydnar: for smaller structs */
typedef char qb_t; typedef unsigned char qb_t;
/* ydnar: for q3map_tcMod */ /* ydnar: for q3map_tcMod */
@ -1618,7 +1618,7 @@ tree_t *FaceBSP( face_t *list );
/* model.c */ /* model.c */
void PicoPrintFunc( int level, const char *str ); 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( char *name, int frame ); picoModel_t *FindModel( char *name, int frame );
picoModel_t *LoadModel( char *name, int frame ); picoModel_t *LoadModel( char *name, int frame );
void InsertModel( char *name, int frame, m4x4_t transform, remap_t *remap, shaderInfo_t *celShader, int eNum, int castShadows, int recvShadows, int spawnFlags, float lightmapScale ); void InsertModel( char *name, int frame, m4x4_t transform, remap_t *remap, shaderInfo_t *celShader, int eNum, int castShadows, int recvShadows, int spawnFlags, float lightmapScale );
@ -1641,7 +1641,7 @@ void ClearSurface( mapDrawSurface_t *ds );
void AddEntitySurfaceModels( entity_t *e ); void AddEntitySurfaceModels( entity_t *e );
mapDrawSurface_t *DrawSurfaceForSide( entity_t *e, brush_t *b, side_t *s, winding_t *w ); 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 *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 ); mapDrawSurface_t *DrawSurfaceForShader( char *shader );
void ClipSidesIntoTree( entity_t *e, tree_t *tree ); void ClipSidesIntoTree( entity_t *e, tree_t *tree );
void MakeDebugPortalSurfs( tree_t *tree ); void MakeDebugPortalSurfs( tree_t *tree );
@ -1898,7 +1898,7 @@ Q_EXTERN game_t games[]
, ,
#include "game_reaction.h" /* must be after game_quake3.h */ #include "game_reaction.h" /* must be after game_quake3.h */
, ,
{ NULL } /* null game */ #include "game__null.h" /* null game (must be last item) */
}; };
#endif #endif
Q_EXTERN game_t *game Q_ASSIGN( &games[ 0 ] ); Q_EXTERN game_t *game Q_ASSIGN( &games[ 0 ] );

View File

@ -1228,7 +1228,7 @@ mapDrawSurface_t *DrawSurfaceForMesh( entity_t *e, parseMesh_t *p, mesh_t *mesh
creates a flare draw surface 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; mapDrawSurface_t *ds;

View File

@ -345,7 +345,7 @@ void LoadSurfaceExtraFile( const char *path ){
} }
/* parse the file */ /* parse the file */
ParseFromMemory( buffer, size ); ParseFromMemory( (char*) buffer, size );
/* tokenize it */ /* tokenize it */
while ( 1 ) while ( 1 )

View File

@ -535,6 +535,7 @@ void StripFaceSurface( mapDrawSurface_t *ds ){
} }
/* try all possible orderings of the points looking for a non-degenerate strip order */ /* try all possible orderings of the points looking for a non-degenerate strip order */
ni = 0;
for ( r = 0; r < ds->numVerts; r++ ) for ( r = 0; r < ds->numVerts; r++ )
{ {
/* set rotation */ /* set rotation */
@ -688,51 +689,6 @@ void MakeEntityMetaTriangles( entity_t *e ){
/*
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() CreateEdge()
sets up an edge structure from a plane and 2 points that the edge ab falls lies in sets up an edge structure from a plane and 2 points that the edge ab falls lies in
@ -1565,47 +1521,47 @@ static int CompareMetaTriangles( const void *a, const void *b ){
/* shader first */ /* shader first */
if ( ( (metaTriangle_t*) a )->si < ( (metaTriangle_t*) b )->si ) { if ( ( (metaTriangle_t*) a )->si < ( (const metaTriangle_t*) b )->si ) {
return 1; return 1;
} }
else if ( ( (metaTriangle_t*) a )->si > ( (metaTriangle_t*) b )->si ) { else if ( ( (metaTriangle_t*) a )->si > ( (const metaTriangle_t*) b )->si ) {
return -1; return -1;
} }
/* then fog */ /* then fog */
else if ( ( (metaTriangle_t*) a )->fogNum < ( (metaTriangle_t*) b )->fogNum ) { else if ( ( (metaTriangle_t*) a )->fogNum < ( (const metaTriangle_t*) b )->fogNum ) {
return 1; return 1;
} }
else if ( ( (metaTriangle_t*) a )->fogNum > ( (metaTriangle_t*) b )->fogNum ) { else if ( ( (metaTriangle_t*) a )->fogNum > ( (const metaTriangle_t*) b )->fogNum ) {
return -1; return -1;
} }
/* then plane */ /* then plane */
#if 0 #if 0
else if ( npDegrees == 0.0f && ( (metaTriangle_t*) a )->si->nonplanar == qfalse && else if ( npDegrees == 0.0f && ( (const metaTriangle_t*) a )->si->nonplanar == qfalse &&
( (metaTriangle_t*) a )->planeNum >= 0 && ( (metaTriangle_t*) a )->planeNum >= 0 ) { ( (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; 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; 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; 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; 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; 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; 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; 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; return -1;
} }
} }
@ -1618,8 +1574,8 @@ static int CompareMetaTriangles( const void *a, const void *b ){
VectorSet( bMins, 999999, 999999, 999999 ); VectorSet( bMins, 999999, 999999, 999999 );
for ( i = 0; i < 3; i++ ) for ( i = 0; i < 3; i++ )
{ {
av = ( (metaTriangle_t*) a )->indexes[ i ]; av = ( (const metaTriangle_t*) a )->indexes[ i ];
bv = ( (metaTriangle_t*) b )->indexes[ i ]; bv = ( (const metaTriangle_t*) b )->indexes[ i ];
for ( j = 0; j < 3; j++ ) for ( j = 0; j < 3; j++ )
{ {
if ( metaVerts[ av ].xyz[ j ] < aMins[ j ] ) { if ( metaVerts[ av ].xyz[ j ] < aMins[ j ] ) {

View File

@ -610,8 +610,8 @@ qboolean FixBrokenSurface( mapDrawSurface_t *ds ){
int EdgeCompare( const void *elem1, const void *elem2 ) { int EdgeCompare( const void *elem1, const void *elem2 ) {
float d1, d2; float d1, d2;
d1 = ( (originalEdge_t *)elem1 )->length; d1 = ( (const originalEdge_t *)elem1 )->length;
d2 = ( (originalEdge_t *)elem2 )->length; d2 = ( (const originalEdge_t *)elem2 )->length;
if ( d1 < d2 ) { if ( d1 < d2 ) {
return -1; return -1;

View File

@ -99,10 +99,10 @@ void prl( leaf_t *l ){
============= =============
*/ */
int PComp( const void *a, const void *b ){ int PComp( const void *a, const void *b ){
if ( ( *(vportal_t **)a )->nummightsee == ( *(vportal_t **)b )->nummightsee ) { if ( ( *(const vportal_t **)a )->nummightsee == ( *(const vportal_t **)b )->nummightsee ) {
return 0; return 0;
} }
if ( ( *(vportal_t **)a )->nummightsee < ( *(vportal_t **)b )->nummightsee ) { if ( ( *(const vportal_t **)a )->nummightsee < ( *(const vportal_t **)b )->nummightsee ) {
return -1; return -1;
} }
return 1; return 1;
@ -929,8 +929,8 @@ void LoadPortals( char *name ){
if ( numpoints > MAX_POINTS_ON_WINDING ) { if ( numpoints > MAX_POINTS_ON_WINDING ) {
Error( "LoadPortals: portal %i has too many points", i ); Error( "LoadPortals: portal %i has too many points", i );
} }
if ( (unsigned)leafnums[0] > portalclusters if ( leafnums[0] > portalclusters
|| (unsigned)leafnums[1] > portalclusters ) { || leafnums[1] > portalclusters ) {
Error( "LoadPortals: reading portal %i", i ); Error( "LoadPortals: reading portal %i", i );
} }
if ( fscanf( f, "%i ", &hint ) != 1 ) { if ( fscanf( f, "%i ", &hint ) != 1 ) {