#include "lwo2.h"
/* disable warnings */
-#ifdef _WIN32
+#ifdef WIN32
#pragma warning( disable:4018 ) /* signed/unsigned mismatch */
#endif
clip->saturation.val = 1.0f;
clip->gamma.val = 1.0f;
- if ( ( p = strstr( s, "(sequence)" ) ) != NULL ) {
+ if ( ( p = strstr( s, "(sequence)" ) ) ) {
p[ -1 ] = 0;
clip->type = ID_ISEQ;
clip->source.seq.prefix = s;
( *nclips )++;
clip->index = *nclips;
- lwListAdd( clist, clip );
+ lwListAdd( (void *) clist, clip );
return clip->index;
}
env->behavior[ 0 ] = BEH_LINEAR;
env->behavior[ 1 ] = BEH_LINEAR;
- lwListAdd( elist, env );
+ lwListAdd( (void *) elist, env );
}
*nenvs += 3;
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;
case ID_BTEX:
s = getbytes( fp, sz );
tex = get_texture( s );
- lwListAdd( &surf->bump.tex, tex );
+ lwListAdd( (void *) &surf->bump.tex, tex );
break;
case ID_CTEX:
s = getbytes( fp, sz );
tex = get_texture( s );
- lwListAdd( &surf->color.tex, tex );
+ lwListAdd( (void *) &surf->color.tex, tex );
break;
case ID_DTEX:
s = getbytes( fp, sz );
tex = get_texture( s );
- lwListAdd( &surf->diffuse.tex, tex );
+ lwListAdd( (void *) &surf->diffuse.tex, tex );
break;
case ID_LTEX:
s = getbytes( fp, sz );
tex = get_texture( s );
- lwListAdd( &surf->luminosity.tex, tex );
+ lwListAdd( (void *) &surf->luminosity.tex, tex );
break;
case ID_RTEX:
s = getbytes( fp, sz );
tex = get_texture( s );
- lwListAdd( &surf->reflection.val.tex, tex );
+ lwListAdd( (void *) &surf->reflection.val.tex, tex );
break;
case ID_STEX:
s = getbytes( fp, sz );
tex = get_texture( s );
- lwListAdd( &surf->specularity.tex, tex );
+ lwListAdd( (void *) &surf->specularity.tex, tex );
break;
case ID_TTEX:
s = getbytes( fp, sz );
tex = get_texture( s );
- lwListAdd( &surf->transparency.val.tex, tex );
+ lwListAdd( (void *) &surf->transparency.val.tex, tex );
break;
case ID_TFLG:
+ if ( !tex ) {
+ goto Fail;
+ }
flags = getU2( fp );
+ i = -1;
if ( flags & 1 ) {
i = 0;
}
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 );
}
goto Fail;
}
shdr->name = getbytes( fp, sz );
- lwListAdd( &surf->shader, shdr );
+ lwListAdd( (void *) &surf->shader, shdr );
surf->nshaders++;
break;
case ID_SDAT:
+ if ( !shdr ) {
+ goto Fail;
+ }
shdr->data = getbytes( fp, sz );
break;
bp += 2;
}
j -= 1;
- pp->surf = ( lwSurface * ) ( (size_t)j );
+ pp->surf = ( lwSurface * ) (size_t) j;
pp++;
pv += nv;
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;
lwNode *node;
if ( !node ) {
goto Fail;
}
- lwListAdd( &object->surf, node );
+ lwListAdd( (void *) &object->surf, node );
object->nsurfs++;
break;
/* end of the file? */
- if ( formsize <= _pico_memstream_tell( fp ) - 8 ) {
+ if ( formsize <= (unsigned int) ( _pico_memstream_tell( fp ) - 8 ) ) {
break;
}
return NULL;
}
-int lwValidateObject5( char *filename, picoMemStream_t *fp, unsigned int *failID, int *failpos ){
- unsigned int id, formsize, type;
+int lwValidateObject5( const char *filename, picoMemStream_t *fp, unsigned int *failID, int *failpos ){
+ unsigned int id, type;
/* open the file */
set_flen( 0 );
id = getU4( fp );
- formsize = getU4( fp );
+ /* formsize = */ getU4( fp );
type = getU4( fp );
if ( 12 != get_flen() ) {
return PICO_PMV_ERROR_SIZE;