q3map2 is now waring free

This commit is contained in:
rpolzer 2010-10-05 10:57:07 +02:00
parent 5f1f257a1c
commit 5ec3a47e10
47 changed files with 454 additions and 341 deletions

View File

@ -43,7 +43,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define qfalse 0 #define qfalse 0
#ifdef _DEBUG #ifdef _DEBUG
void WinPrint(char *str, ...) void WinPrint(const char *str, ...)
{ {
va_list argptr; va_list argptr;
char text[4096]; char text[4096];
@ -55,7 +55,7 @@ void WinPrint(char *str, ...)
printf(text); printf(text);
} }
#else #else
void WinPrint(char *str, ...) void WinPrint(const char *str, ...)
{ {
} }
#endif #endif
@ -323,7 +323,7 @@ void Net_Disconnect(socket_t *sock)
// Returns: - // Returns: -
// Changes Globals: - // Changes Globals: -
//=========================================================================== //===========================================================================
void Net_StringToAddress(char *string, address_t *address) void Net_StringToAddress(const char *string, address_t *address)
{ {
strcpy(address->ip, string); strcpy(address->ip, string);
} //end of the function Net_StringToAddress } //end of the function Net_StringToAddress
@ -620,7 +620,7 @@ char *NMSG_ReadString(netmessage_t *msg)
if (c == 0) break; if (c == 0) break;
string[l] = c; string[l] = c;
l++; l++;
} while (l < sizeof(string)-1); } while ((size_t) l < sizeof(string)-1);
string[l] = 0; string[l] = 0;
return string; return string;
} //end of the function NMSG_ReadString } //end of the function NMSG_ReadString

View File

@ -73,12 +73,14 @@ typedef struct socket_s
struct socket_s *prev, *next; //prev and next socket in a list struct socket_s *prev, *next; //prev and next socket in a list
} socket_t; } socket_t;
void WinPrint(const char *format, ...);
//compare addresses //compare addresses
int Net_AddressCompare(address_t *addr1, address_t *addr2); int Net_AddressCompare(address_t *addr1, address_t *addr2);
//gives the address of a socket //gives the address of a socket
void Net_SocketToAddress(socket_t *sock, address_t *address); void Net_SocketToAddress(socket_t *sock, address_t *address);
//converts a string to an 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 //set the address ip port
void Net_SetAddressPort(address_t *address, int port); void Net_SetAddressPort(address_t *address, int port);
//send a message to the given socket //send a message to the given socket
@ -118,7 +120,7 @@ float NMSG_ReadFloat(netmessage_t *msg);
char *NMSG_ReadString(netmessage_t *msg); char *NMSG_ReadString(netmessage_t *msg);
//++timo FIXME: the WINS_ things are not necessary, they can be made portable arther easily //++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 #ifdef __cplusplus
} }

View File

@ -41,8 +41,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include <arpa/inet.h>
#include <errno.h> #include <errno.h>
#include <netdb.h> #include <netdb.h>
#include <unistd.h>
#include <stdarg.h>
#include <stdio.h>
#define SOCKET_ERROR -1 #define SOCKET_ERROR -1
#define INVALID_SOCKET -1 #define INVALID_SOCKET -1
@ -112,7 +116,7 @@ ERROR_STRUCT errlist[] = {
// Returns: - // Returns: -
// Changes Globals: - // Changes Globals: -
//=========================================================================== //===========================================================================
char *WINS_ErrorMessage(int error) const char *WINS_ErrorMessage(int error)
{ {
int search = 0; int search = 0;
@ -121,7 +125,7 @@ char *WINS_ErrorMessage(int error)
for (search = 0; errlist[search].errstr; search++) for (search = 0; errlist[search].errstr; search++)
{ {
if (error == errlist[search].errnum) if (error == errlist[search].errnum)
return (char *)errlist[search].errstr; return errlist[search].errstr;
} //end for } //end for
return "Unknown error"; return "Unknown error";
@ -139,7 +143,6 @@ int WINS_Init(void)
char buff[MAXHOSTNAMELEN]; char buff[MAXHOSTNAMELEN];
struct sockaddr_s addr; struct sockaddr_s addr;
char *p; char *p;
int r;
/* /*
linux doesn't have anything to initialize for the net linux doesn't have anything to initialize for the net
"Windows .. built for the internet .. the internet .. built with unix" "Windows .. built for the internet .. the internet .. built with unix"
@ -365,7 +368,7 @@ int WINS_Listen(int socket)
//=========================================================================== //===========================================================================
int WINS_Accept(int socket, struct sockaddr_s *addr) int WINS_Accept(int socket, struct sockaddr_s *addr)
{ {
int addrlen = sizeof (struct sockaddr_s); socklen_t addrlen = sizeof (struct sockaddr_s);
int newsocket; int newsocket;
qboolean _true = 1; qboolean _true = 1;
@ -496,7 +499,7 @@ int WINS_CheckNewConnections(void)
//=========================================================================== //===========================================================================
int WINS_Read(int socket, byte *buf, int len, struct sockaddr_s *addr) 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; int ret;
if (addr) if (addr)
@ -583,6 +586,7 @@ int WINS_Broadcast (int socket, byte *buf, int len)
int WINS_Write(int socket, byte *buf, int len, struct sockaddr_s *addr) int WINS_Write(int socket, byte *buf, int len, struct sockaddr_s *addr)
{ {
int ret, written; int ret, written;
ret = 0;
if (addr) if (addr)
{ {
@ -670,7 +674,7 @@ int WINS_StringToAddr(char *string, struct sockaddr_s *addr)
//=========================================================================== //===========================================================================
int WINS_GetSocketAddr(int socket, struct sockaddr_s *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; unsigned int a;
memset(addr, 0, sizeof(struct sockaddr_s)); memset(addr, 0, sizeof(struct sockaddr_s));

View File

@ -136,19 +136,13 @@ ERROR_STRUCT errlist[] = {
{-1, NULL} {-1, NULL}
}; };
#ifdef _DEBUG
void WinPrint(char *str, ...);
#else
void WinPrint(char *str, ...);
#endif
//=========================================================================== //===========================================================================
// //
// Parameter: - // Parameter: -
// Returns: - // Returns: -
// Changes Globals: - // Changes Globals: -
//=========================================================================== //===========================================================================
char *WINS_ErrorMessage(int error) const char *WINS_ErrorMessage(int error)
{ {
int search = 0; int search = 0;

View File

@ -1626,20 +1626,21 @@ void m4_submat( m4x4_t mr, m3x3_t mb, int i, int j )
{ {
if ( ti < i ) if ( ti < i )
idst = ti; idst = ti;
else if ( ti > i )
idst = ti-1;
else else
if ( ti > i ) continue;
idst = ti-1;
for ( tj = 0; tj < 4; tj++ ) for ( tj = 0; tj < 4; tj++ )
{ {
if ( tj < j ) if ( tj < j )
jdst = tj; jdst = tj;
else if ( tj > j )
jdst = tj-1;
else else
if ( tj > j ) continue;
jdst = tj-1;
if ( ti != i && tj != j ) mb[idst*3 + jdst] = mr[ti*4 + tj ];
mb[idst*3 + jdst] = mr[ti*4 + tj ];
} }
} }
} }

View File

@ -175,16 +175,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
@ -211,13 +211,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, const char *fileName ); picoModel_t* PicoModuleLoadModelStream( const picoModule_t* module, void* inputStream, PicoInputStreamReadFunc inputStreamRead, size_t streamLength, int frameNum, const char *fileName );
@ -242,8 +242,8 @@ int PicoAdjustSurface( picoSurface_t *surface, int numVertexes, int numSTA
/* 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

@ -44,7 +44,7 @@ Read an ENVL chunk from an LWO2 file.
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

@ -311,7 +311,7 @@ int sgetI1( unsigned char **bp )
i = **bp; i = **bp;
if ( i > 127 ) i -= 256; if ( i > 127 ) i -= 256;
flen += 1; flen += 1;
*bp++; (*bp)++;
return i; return i;
} }
@ -349,7 +349,7 @@ unsigned char sgetU1( unsigned char **bp )
if ( flen == FLEN_ERROR ) return 0; if ( flen == FLEN_ERROR ) return 0;
c = **bp; c = **bp;
flen += 1; flen += 1;
*bp++; (*bp)++;
return c; return c;
} }
@ -422,7 +422,7 @@ char *sgetS0( unsigned char **bp )
if ( flen == FLEN_ERROR ) return NULL; if ( flen == FLEN_ERROR ) return NULL;
len = strlen( 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,13 +76,13 @@ can be used to diagnose the cause.
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 */
@ -233,7 +233,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 ) break; if ( formsize <= (unsigned int) (_pico_memstream_tell( fp ) - 8) ) break;
/* get the next chunk header */ /* get the next chunk header */
@ -270,7 +270,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;

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

@ -70,7 +70,7 @@ static int add_clip( char *s, lwClip **clist, int *nclips )
clip->saturation.val = 1.0f; clip->saturation.val = 1.0f;
clip->gamma.val = 1.0f; clip->gamma.val = 1.0f;
if ( p = strstr( s, "(sequence)" )) { if ((p = strstr( s, "(sequence)" ))) {
p[ -1 ] = 0; p[ -1 ] = 0;
clip->type = ID_ISEQ; clip->type = ID_ISEQ;
clip->source.seq.prefix = s; clip->source.seq.prefix = s;
@ -81,7 +81,7 @@ static int add_clip( char *s, lwClip **clist, int *nclips )
clip->source.still.name = s; clip->source.still.name = s;
} }
*nclips++; (*nclips)++;
clip->index = *nclips; clip->index = *nclips;
lwListAdd( (void *) clist, clip ); lwListAdd( (void *) clist, clip );
@ -188,8 +188,8 @@ Read an lwSurface from an LWOB file.
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;
@ -352,11 +352,14 @@ lwSurface *lwGetSurface5( picoMemStream_t *fp, int cksize, lwObject *obj )
break; break;
case ID_TFLG: case ID_TFLG:
if(!tex) goto Fail;
flags = getU2( fp ); flags = getU2( fp );
i = -1;
if ( flags & 1 ) i = 0; if ( flags & 1 ) i = 0;
if ( flags & 2 ) i = 1; if ( flags & 2 ) i = 1;
if ( flags & 4 ) i = 2; if ( flags & 4 ) i = 2;
if(i < 0) goto Fail;
tex->axis = i; tex->axis = i;
if ( tex->type == ID_IMAP ) if ( tex->type == ID_IMAP )
tex->param.imap.axis = i; tex->param.imap.axis = i;
@ -373,21 +376,25 @@ lwSurface *lwGetSurface5( picoMemStream_t *fp, int cksize, lwObject *obj )
break; break;
case ID_TSIZ: case ID_TSIZ:
if(!tex) 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) 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) 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) goto Fail;
for ( i = 0; i < 3; i++ ) for ( i = 0; i < 3; i++ )
v[ i ] = getF4( fp ); v[ i ] = getF4( fp );
tex->tmap.center.eindex = add_tvel( tex->tmap.center.val, v, tex->tmap.center.eindex = add_tvel( tex->tmap.center.val, v,
@ -395,44 +402,53 @@ lwSurface *lwGetSurface5( picoMemStream_t *fp, int cksize, lwObject *obj )
break; break;
case ID_TCLR: case ID_TCLR:
if(!tex) goto Fail;
if ( tex->type == ID_PROC ) if ( tex->type == ID_PROC )
for ( i = 0; i < 3; i++ ) for ( i = 0; i < 3; i++ )
tex->param.proc.value[ i ] = getU1( fp ) / 255.0f; tex->param.proc.value[ i ] = getU1( fp ) / 255.0f;
break; break;
case ID_TVAL: case ID_TVAL:
if(!tex) 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) 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 );
break; break;
case ID_TIMG: case ID_TIMG:
if(!tex) 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) 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) 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) goto Fail;
tex->opacity.val = getF4( fp ); tex->opacity.val = getF4( fp );
break; break;
case ID_TFP0: case ID_TFP0:
if(!tex) 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 );
break; break;
case ID_TFP1: case ID_TFP1:
if(!tex) 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 );
break; break;
@ -446,6 +462,7 @@ lwSurface *lwGetSurface5( picoMemStream_t *fp, int cksize, lwObject *obj )
break; break;
case ID_SDAT: case ID_SDAT:
if(!shdr) goto Fail;
shdr->data = getbytes( fp, sz ); shdr->data = getbytes( fp, sz );
break; break;
@ -583,7 +600,7 @@ to diagnose the cause.
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;
@ -665,7 +682,7 @@ lwObject *lwGetObject5( char *filename, picoMemStream_t *fp, unsigned int *failI
/* end of 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 */ /* get the next chunk header */
@ -693,7 +710,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 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* 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;
@ -193,7 +193,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 )
@ -266,7 +266,7 @@ void _pico_first_token( char *str )
if( !str || !*str ) if( !str || !*str )
return; return;
while( *str && !isspace( *str ) ) while( *str && !isspace( *str ) )
*str++; str++;
*str = '\0'; *str = '\0';
} }
@ -555,7 +555,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;
@ -761,8 +761,8 @@ picoParser_t *_pico_new_parser( picoByte_t *buffer, int bufSize )
return NULL; return NULL;
} }
/* setup */ /* setup */
p->buffer = buffer; p->buffer = (const char *) buffer;
p->cursor = buffer; p->cursor = (const char *) buffer;
p->bufSize = bufSize; p->bufSize = bufSize;
p->max = p->buffer + bufSize; p->max = p->buffer + bufSize;
p->curLine = 1; /* sea: new */ p->curLine = 1; /* sea: new */
@ -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 ||
@ -1218,7 +1218,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;

View File

@ -78,22 +78,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; const picoByte_t *curPos;
int flag; int flag;
} }
picoMemStream_t; picoMemStream_t;
@ -104,7 +104,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* );
@ -120,7 +120,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 */
@ -129,7 +129,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 );
@ -168,7 +168,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 );
@ -189,7 +189,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

@ -114,7 +114,7 @@ PicoSetLoadFileFunc()
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;
@ -148,7 +148,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;
@ -199,7 +199,7 @@ PicoLoadModel()
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;
@ -753,7 +753,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;
@ -765,7 +765,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

@ -166,20 +166,17 @@ T3dsChunk;
*/ */
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;
/* check 3ds magic */ /* check 3ds magic */
@ -736,7 +733,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

@ -221,11 +221,8 @@ static int _ase_canload( PM_PARAMS_CANLOAD )
if( bufSize < 80 ) if( bufSize < 80 )
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;
@ -552,7 +549,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) return NULL; if (p == NULL) return NULL;
/* create a new pico model */ /* create a new pico model */
@ -868,7 +865,7 @@ static picoModel_t *_ase_load( PM_PARAMS_LOAD )
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

@ -66,10 +66,11 @@ typedef struct index_DUP_LUT_s
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;
@ -82,6 +83,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;
} }
@ -91,6 +93,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;
} }
@ -105,6 +108,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;
} }
@ -114,6 +118,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;
} }
@ -128,6 +133,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;
} }
@ -137,6 +143,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;
} }
@ -151,6 +158,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;
} }
@ -160,6 +168,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;
} }
@ -174,6 +183,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;
} }
@ -183,6 +193,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;
} }
@ -211,7 +222,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;
@ -220,7 +231,8 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD )
picoColor_t color; picoColor_t color;
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;
@ -228,12 +240,14 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD )
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;
} }
@ -243,12 +257,14 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD )
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;
} }
@ -258,12 +274,14 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD )
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;
} }
@ -273,12 +291,14 @@ 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");
_pico_free(bb0);
return NULL; return NULL;
} }
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;
} }
@ -288,12 +308,14 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD )
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;
} }
@ -325,12 +347,14 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD )
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;
} }
@ -371,7 +395,7 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD )
texCoord->t = _pico_little_short( texCoord[i].t ); texCoord->t = _pico_little_short( texCoord[i].t );
} }
// set Skin Name // 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 #ifdef FM_VERBOSE_DBG
// Print out md2 values // Print out md2 values
@ -387,6 +411,7 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD )
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;
} }
@ -402,6 +427,7 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD )
{ {
_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;
} }
@ -413,6 +439,7 @@ static picoModel_t *_fm_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 );
_pico_free(bb0);
return NULL; return NULL;
} }
@ -644,6 +671,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

@ -79,7 +79,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;
@ -139,7 +139,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

@ -300,20 +300,17 @@ float md2_normals[ MD2_NUMVERTEXNORMALS ][ 3 ] =
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;
/* check md2 version */ /* check md2 version */
@ -344,7 +341,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;
@ -354,14 +351,16 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD )
/* 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;
} }
@ -390,12 +389,14 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD )
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;
} }
@ -429,7 +430,7 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD )
} }
// set Skin Name // 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 // 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 );
@ -443,6 +444,7 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD )
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;
} }
@ -458,6 +460,7 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD )
{ {
_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;
} }
@ -469,6 +472,7 @@ static picoModel_t *_md2_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 );
_pico_free(bb0);
return NULL; return NULL;
} }
@ -644,6 +648,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

@ -145,21 +145,18 @@ by one structure only.
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;
/* check md3 version */ /* check md3 version */
@ -180,7 +177,7 @@ loads a quake3 arena md3 model file.
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;
@ -204,13 +201,15 @@ 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;
} }
@ -229,12 +228,14 @@ static picoModel_t *_md3_load( PM_PARAMS_LOAD )
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;
} }
@ -308,6 +309,7 @@ static picoModel_t *_md3_load( PM_PARAMS_LOAD )
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;
} }
@ -329,6 +331,7 @@ static picoModel_t *_md3_load( PM_PARAMS_LOAD )
{ {
_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;
} }
@ -344,6 +347,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 );
_pico_free(bb0);
return NULL; return NULL;
} }
@ -403,6 +407,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

@ -417,21 +417,18 @@ by one structure only.
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;
/* check mdc version */ /* check mdc version */
@ -452,7 +449,7 @@ loads a Return to Castle Wolfenstein mdc model file.
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;
@ -460,8 +457,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;
@ -478,13 +475,15 @@ 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;
} }
@ -504,12 +503,14 @@ static picoModel_t *_mdc_load( PM_PARAMS_LOAD )
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;
} }
@ -608,6 +609,7 @@ static picoModel_t *_mdc_load( PM_PARAMS_LOAD )
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;
} }
@ -629,6 +631,7 @@ static picoModel_t *_mdc_load( PM_PARAMS_LOAD )
{ {
_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;
} }
@ -644,6 +647,7 @@ static picoModel_t *_mdc_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 );
_pico_free(bb0);
return NULL; return NULL;
} }
@ -728,6 +732,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

@ -165,18 +165,15 @@ TMsKeyframe;
*/ */
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;
@ -226,8 +223,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 );
@ -288,6 +287,7 @@ static picoModel_t *_ms3d_load( PM_PARAMS_LOAD )
{ {
_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 */
} }
} }
@ -322,6 +322,7 @@ static picoModel_t *_ms3d_load( PM_PARAMS_LOAD )
if (surface == NULL) if (surface == NULL)
{ {
PicoFreeModel( model ); PicoFreeModel( model );
_pico_free(bufptr0);
return NULL; return NULL;
} }
/* do surface setup */ /* do surface setup */
@ -415,6 +416,7 @@ static picoModel_t *_ms3d_load( PM_PARAMS_LOAD )
if (shader == NULL) if (shader == NULL)
{ {
PicoFreeModel( model ); PicoFreeModel( model );
_pico_free(bufptr0);
return NULL; return NULL;
} }
/* scale shader colors */ /* scale shader colors */
@ -473,6 +475,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

@ -87,7 +87,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;
@ -535,7 +535,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) return NULL; if (p == NULL) return NULL;
/* create a new pico model */ /* create a new pico model */
@ -688,8 +688,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;
if(curSurface == NULL) if(curSurface == NULL)

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;

View File

@ -193,7 +193,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] = '/';
@ -206,7 +206,7 @@ void SetQdirFromPath( const char *path )
{ {
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] = '/';
@ -250,7 +250,7 @@ char *ExpandArg (const char *path)
char *ExpandPath (const char *path) char *ExpandPath (const char *path)
{ {
static char full[1024]; static char full[1024];
if (!qdir) if (!*qdir)
Error ("ExpandPath called without qdir set"); Error ("ExpandPath called without qdir set");
if (path[0] == '/' || path[0] == '\\' || path[1] == ':') { if (path[0] == '/' || path[0] == '\\' || path[1] == ':') {
strcpy( full, path ); strcpy( full, path );
@ -263,7 +263,7 @@ char *ExpandPath (const char *path)
char *ExpandGamePath (const char *path) char *ExpandGamePath (const char *path)
{ {
static char full[1024]; static char full[1024];
if (!qdir) if (!*qdir)
Error ("ExpandGamePath called without qdir set"); Error ("ExpandGamePath called without qdir set");
if (path[0] == '/' || path[0] == '\\' || path[1] == ':') { if (path[0] == '/' || path[0] == '\\' || path[1] == ':') {
strcpy( full, path ); strcpy( full, path );

View File

@ -99,7 +99,11 @@ void ExpandWildcards( int *argc, char ***argv );
double I_FloatTime( void ); double I_FloatTime( void );
void Error( const char *error, ... ); void Error( const char *error, ... )
#ifdef __GNUC__
__attribute__((noreturn))
#endif
;
int CheckParm( const char *check ); int CheckParm( const char *check );
FILE *SafeOpenWrite( const char *filename ); FILE *SafeOpenWrite( const char *filename );

View File

@ -527,6 +527,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 */
@ -1133,7 +1134,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);
@ -1183,8 +1184,6 @@ void WriteTGA (const char *filename, byte *data, int width, int height) {
void WriteTGAGray (const char *filename, byte *data, int width, int height) { void WriteTGAGray (const char *filename, byte *data, int width, int height) {
byte buffer[18]; byte buffer[18];
int i;
int c;
FILE *f; FILE *f;
memset (buffer, 0, 18); memset (buffer, 0, 18);

View File

@ -71,8 +71,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, "point"); ret = xmlNewNode (NULL, (xmlChar*)"point");
xmlNodeSetContent (ret, 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);
@ -152,15 +152,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, "select"); node = xmlNewNode (NULL, (xmlChar*)"select");
xmlNodeSetContent (node, 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, "level", (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, "brush"); select = xmlNewNode (NULL, (xmlChar*)"brush");
xmlNodeSetContent (select, 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, "pointmsg"); node = xmlNewNode (NULL, (xmlChar*)"pointmsg");
xmlNodeSetContent (node, 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, "level", (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, "point"); point = xmlNewNode (NULL, (xmlChar*)"point");
xmlNodeSetContent (point, buf); xmlNodeSetContent (point, (xmlChar*)buf);
xmlAddChild (node, point); xmlAddChild (node, point);
xml_SendNode (node); xml_SendNode (node);
@ -203,11 +203,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, "windingmsg"); node = xmlNewNode (NULL, (xmlChar*)"windingmsg");
xmlNodeSetContent (node, 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, "level", (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, "winding"); winding = xmlNewNode (NULL, (xmlChar*)"winding");
xmlNodeSetContent (winding, buf); xmlNodeSetContent (winding, (xmlChar*)buf);
xmlAddChild (node, winding); xmlAddChild (node, winding);
xml_SendNode (node); xml_SendNode (node);
@ -242,7 +242,7 @@ void Broadcast_Setup( const char *dest )
char sMsg[1024]; char sMsg[1024];
Net_Setup(); Net_Setup();
Net_StringToAddress((char *)dest, &address); Net_StringToAddress(dest, &address);
brdcst_socket = Net_Connect(&address, 0); brdcst_socket = Net_Connect(&address, 0);
if (brdcst_socket) if (brdcst_socket)
{ {
@ -288,19 +288,19 @@ void FPrintf (int flag, char *buf)
if (!bGotXML) if (!bGotXML)
{ {
// initialize // initialize
doc = xmlNewDoc("1.0"); doc = xmlNewDoc((xmlChar*)"1.0");
doc->children = xmlNewDocRawNode(doc, NULL, "q3map_feedback", NULL); doc->children = xmlNewDocRawNode(doc, NULL, (xmlChar*)"q3map_feedback", NULL);
bGotXML = qtrue; bGotXML = qtrue;
} }
node = xmlNewNode (NULL, "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, 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, "level", (char *)&level ); xmlSetProp (node, (xmlChar*)"level", (xmlChar *)&level );
xml_SendNode (node); xml_SendNode (node);
} }

View File

@ -1635,10 +1635,12 @@ static int unzlocal_GetCurrentFileInfoInternal (unzFile file,
/* we check the magic */ /* we check the magic */
if (err==UNZ_OK) if (err==UNZ_OK)
{
if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
err=UNZ_ERRNO; err=UNZ_ERRNO;
else if (uMagic!=0x02014b50) else if (uMagic!=0x02014b50)
err=UNZ_BADZIPFILE; err=UNZ_BADZIPFILE;
}
if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK) if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK)
err=UNZ_ERRNO; err=UNZ_ERRNO;
@ -1715,10 +1717,12 @@ static int unzlocal_GetCurrentFileInfoInternal (unzFile file,
uSizeRead = extraFieldBufferSize; uSizeRead = extraFieldBufferSize;
if (lSeek!=0) if (lSeek!=0)
{
if (fseek(s->file,lSeek,SEEK_CUR)==0) if (fseek(s->file,lSeek,SEEK_CUR)==0)
lSeek=0; lSeek=0;
else else
err=UNZ_ERRNO; err=UNZ_ERRNO;
}
if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1) if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1)
err=UNZ_ERRNO; err=UNZ_ERRNO;
@ -1740,10 +1744,12 @@ static int unzlocal_GetCurrentFileInfoInternal (unzFile file,
uSizeRead = commentBufferSize; uSizeRead = commentBufferSize;
if (lSeek!=0) if (lSeek!=0)
{
if (fseek(s->file,lSeek,SEEK_CUR)==0) if (fseek(s->file,lSeek,SEEK_CUR)==0)
lSeek=0; lSeek=0;
else else
err=UNZ_ERRNO; err=UNZ_ERRNO;
}
if ((file_info.size_file_comment>0) && (commentBufferSize>0)) if ((file_info.size_file_comment>0) && (commentBufferSize>0))
if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1) if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1)
err=UNZ_ERRNO; err=UNZ_ERRNO;
@ -1906,10 +1912,12 @@ static int unzlocal_CheckCurrentFileCoherencyHeader (unz_s* s, uInt* piSizeVar,
if (err==UNZ_OK) if (err==UNZ_OK)
{
if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
err=UNZ_ERRNO; err=UNZ_ERRNO;
else if (uMagic!=0x04034b50) else if (uMagic!=0x04034b50)
err=UNZ_BADZIPFILE; err=UNZ_BADZIPFILE;
}
if (unzlocal_getShort(s->file,&uData) != UNZ_OK) if (unzlocal_getShort(s->file,&uData) != UNZ_OK)
err=UNZ_ERRNO; err=UNZ_ERRNO;
@ -3407,7 +3415,7 @@ static int huft_build(uInt *b, uInt n, uInt s, const uInt *d, const uInt *e, inf
/* compute minimum size table less than or equal to l bits */ /* compute minimum size table less than or equal to l bits */
z = g - w; 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 */ if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */
{ /* too few codes for k-w bit table */ { /* too few codes for k-w bit table */
f -= a + 1; /* deduct codes from patterns left */ f -= a + 1; /* deduct codes from patterns left */
@ -3445,7 +3453,10 @@ static int huft_build(uInt *b, uInt n, uInt s, const uInt *d, const uInt *e, inf
/* set up table entry in r */ /* set up table entry in r */
r.bits = (Byte)(k - w); r.bits = (Byte)(k - w);
if (p >= v + n) if (p >= v + n)
{
r.exop = 128 + 64; /* out of values--invalid code */ r.exop = 128 + 64; /* out of values--invalid code */
r.base = 0;
}
else if (*p < s) else if (*p < s)
{ {
r.exop = (Byte)(*p < 256 ? 0 : 32 + 64); /* 256 is end-of-block */ r.exop = (Byte)(*p < 256 ? 0 : 32 + 64); /* 256 is end-of-block */

View File

@ -340,12 +340,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, "message" ); leaknode = xmlNewNode( NULL, (xmlChar*)"message" );
xmlNodeSetContent( leaknode, "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, "level", (char*) &level ); xmlSetProp( leaknode, (xmlChar*)"level", (xmlChar*) &level );
xml_SendNode( leaknode ); xml_SendNode( leaknode );
if( leaktest ) if( leaktest )
{ {
@ -458,7 +458,7 @@ void ProcessWorldModel( void )
VectorSet( normal, 0, 0, -1 ); VectorSet( normal, 0, 0, -1 );
/* 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,98 @@
/* -------------------------------------------------------------------------------
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

View File

@ -99,7 +99,7 @@ note: this function is a total hack, as it reads/writes the png struct directly!
typedef struct pngBuffer_s typedef struct pngBuffer_s
{ {
byte *buffer; byte *buffer;
int size, offset; png_size_t size, offset;
} }
pngBuffer_t; pngBuffer_t;
@ -127,8 +127,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;

View File

@ -81,15 +81,15 @@ xmlNodePtr LeakFile (tree_t *tree)
if (!linefile) if (!linefile)
Error ("Couldn't open %s\n", filename); Error ("Couldn't open %s\n", filename);
xml_node = xmlNewNode (NULL, "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

@ -1116,6 +1116,8 @@ int LightContributionToSample( trace_t *trace )
/* return to sender */ /* return to sender */
return 1; return 1;
} }
else
Error("Light of undefined type!");
/* VorteX: set noShadow color */ /* VorteX: set noShadow color */
VectorScale(light->color, add, trace->colorNoShadow); VectorScale(light->color, add, trace->colorNoShadow);
@ -1830,7 +1832,7 @@ void LightWorld( void )
vec3_t color; vec3_t color;
float f; float f;
int b, bt; int b, bt;
qboolean minVertex, minGrid, ps; qboolean minVertex, minGrid;
const char *value; const char *value;

View File

@ -414,7 +414,7 @@ subdivides a radiosity winding until it is smaller than subdivide, then generate
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;
@ -539,7 +539,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;

View File

@ -521,13 +521,10 @@ void ClipTraceWinding( traceWinding_t *tw, vec4_t plane, traceWinding_t *front,
mid.xyz[ k ] = -plane[ 3 ]; mid.xyz[ k ] = -plane[ 3 ];
else else
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;
@ -538,39 +535,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
@ -1257,7 +1221,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;
PopulateWithPicoModel( castShadows, model, transform ); PopulateWithPicoModel( castShadows, model, transform );
@ -1285,7 +1249,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;
PopulateWithPicoModel( castShadows, model, transform ); PopulateWithPicoModel( castShadows, model, transform );

View File

@ -1154,13 +1154,16 @@ void MapRawLightmap( int rawLightmapNum )
if( MapQuad( lm, info, dv ) ) if( MapQuad( lm, info, dv ) )
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 */
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 );
}
} }
} }
@ -1714,7 +1717,9 @@ static qboolean SubmapRawLuxel( rawLightmap_t *lm, int x, int y, float bx, float
//% normal2 = SUPER_NORMAL( x, y ); //% normal2 = SUPER_NORMAL( x, y );
} }
else else
Sys_Printf( "WARNING: Spurious lightmap S vector\n" ); {
Error( "Spurious lightmap S vector\n" );
}
VectorSubtract( origin2, origin, originVecs[ 0 ] ); VectorSubtract( origin2, origin, originVecs[ 0 ] );
//% VectorSubtract( normal2, normal, normalVecs[ 0 ] ); //% VectorSubtract( normal2, normal, normalVecs[ 0 ] );
@ -1974,8 +1979,9 @@ illuminates the luxels
void IlluminateRawLightmap( int rawLightmapNum ) 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; int *cluster, *cluster2, mapped, lighted, totalLighted;
size_t llSize, ldSize;
rawLightmap_t *lm; rawLightmap_t *lm;
surfaceInfo_t *info; surfaceInfo_t *info;
qboolean filterColor, filterDir; qboolean filterColor, filterDir;
@ -2870,16 +2876,16 @@ void IlluminateVertexes( int num )
radVertLuxel[ 2 ] <= ambientColor[ 2 ] ) radVertLuxel[ 2 ] <= ambientColor[ 2 ] )
{ {
/* nudge the sample point around a bit */ /* 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 */ /* two's complement 0, 1, -1, 2, -2, etc */
x1 = ((x >> 1) ^ (x & 1 ? -1 : 0)) + (x & 1); 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); 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); z1 = ((z >> 1) ^ (z & 1 ? -1 : 0)) + (z & 1);
@ -2893,6 +2899,21 @@ void IlluminateVertexes( int num )
if( trace.cluster < 0 ) if( trace.cluster < 0 )
continue; 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 */ /* trace */
LightingAtSample( &trace, ds->vertexStyles, colors ); LightingAtSample( &trace, ds->vertexStyles, colors );
@ -3503,7 +3524,7 @@ void SetupEnvelopes( qboolean forGrid, qboolean fastFlag )
int i, x, y, z, x1, y1, z1; int i, x, y, z, x1, y1, z1;
light_t *light, *light2, **owner; light_t *light, *light2, **owner;
bspLeaf_t *leaf; bspLeaf_t *leaf;
vec3_t origin, dir, mins, maxs, nullVector = { 0, 0, 0 }; vec3_t origin, dir, mins, maxs;
float radius, intensity; float radius, intensity;
light_t *buckets[ 256 ]; light_t *buckets[ 256 ];
@ -3616,6 +3637,7 @@ void SetupEnvelopes( qboolean forGrid, qboolean fastFlag )
/* check for fast mode */ /* check for fast mode */
if( !(light->flags & LIGHT_FAST) && !(light->flags & LIGHT_FAST_TEMP) ) if( !(light->flags & LIGHT_FAST) && !(light->flags & LIGHT_FAST_TEMP) )
light->envelope = MAX_WORLD_COORD * 8.0f; light->envelope = MAX_WORLD_COORD * 8.0f;
intensity = light->photons; /* hopefully not used */
} }
else else
{ {

View File

@ -291,8 +291,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 )
@ -861,8 +861,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->modelindex < bInfo->modelindex ) if( aInfo->modelindex < bInfo->modelindex )
@ -2220,8 +2220,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);
@ -2281,8 +2281,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 */
@ -3170,7 +3170,7 @@ void StoreSurfaceLightmaps( void )
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";
} }
@ -3184,7 +3184,7 @@ void StoreSurfaceLightmaps( void )
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

@ -837,7 +837,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 ];
@ -1693,7 +1693,7 @@ 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,9 +78,9 @@ PicoLoadFileFunc()
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 );
} }
@ -158,7 +158,7 @@ picoModel_t *LoadModel( const char *name, int frame )
Error( "MAX_MODELS (%d) exceeded, there are too many model files referenced by the map.", MAX_MODELS ); Error( "MAX_MODELS (%d) exceeded, there are too many model files referenced by the map.", MAX_MODELS );
/* 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 )
@ -169,7 +169,7 @@ picoModel_t *LoadModel( const char *name, int frame )
return NULL; return NULL;
/* set data */ /* set data */
PicoSetModelName( *pm, (char*) name ); PicoSetModelName( *pm, name );
PicoSetModelFrameNum( *pm, frame ); PicoSetModelFrameNum( *pm, frame );
} }

View File

@ -109,6 +109,7 @@ void LokiInitPaths( char *argv0 )
strcpy( installPath, "../" ); strcpy( installPath, "../" );
#else #else
char temp[ MAX_OS_PATH ]; char temp[ MAX_OS_PATH ];
char last0[ 2 ];
char *home; char *home;
char *path; char *path;
char *last; char *last;
@ -122,7 +123,7 @@ void LokiInitPaths( char *argv0 )
/* do some path divining */ /* do some path divining */
strcpy( temp, argv0 ); strcpy( temp, argv0 );
if( strrchr( temp, '/' ) ) if( strrchr( argv0, '/' ) )
argv0 = strrchr( argv0, '/' ) + 1; argv0 = strrchr( argv0, '/' ) + 1;
else else
{ {
@ -130,6 +131,7 @@ void LokiInitPaths( char *argv0 )
path = getenv( "PATH" ); path = getenv( "PATH" );
/* minor setup */ /* minor setup */
last = last0;
last[ 0 ] = path[ 0 ]; last[ 0 ] = path[ 0 ];
last[ 1 ] = '\0'; last[ 1 ] = '\0';
found = qfalse; found = qfalse;

View File

@ -522,7 +522,7 @@ general types
------------------------------------------------------------------------------- */ ------------------------------------------------------------------------------- */
/* 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 */
@ -1656,7 +1656,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( const char *name, int frame ); picoModel_t *FindModel( const char *name, int frame );
picoModel_t *LoadModel( 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 ); 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 );
@ -1667,6 +1667,7 @@ void AddTriangleModels( entity_t *e );
mapDrawSurface_t *AllocDrawSurface( surfaceType_t type ); mapDrawSurface_t *AllocDrawSurface( surfaceType_t type );
void FinishSurface( mapDrawSurface_t *ds ); void FinishSurface( mapDrawSurface_t *ds );
void StripFaceSurface( mapDrawSurface_t *ds ); void StripFaceSurface( mapDrawSurface_t *ds );
void MaxAreaFaceSurface( mapDrawSurface_t *ds );
qboolean CalcSurfaceTextureRange( mapDrawSurface_t *ds ); qboolean CalcSurfaceTextureRange( mapDrawSurface_t *ds );
qboolean CalcLightmapAxis( vec3_t normal, vec3_t axis ); qboolean CalcLightmapAxis( vec3_t normal, vec3_t axis );
void ClassifySurfaces( int numSurfs, mapDrawSurface_t *ds ); void ClassifySurfaces( int numSurfs, mapDrawSurface_t *ds );
@ -1679,7 +1680,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 );
@ -1949,7 +1950,7 @@ Q_EXTERN game_t games[]
, ,
#include "game_prophecy.h" /* vortex: prophecy game ( darkplaces q1 engine) */ #include "game_prophecy.h" /* vortex: prophecy game ( darkplaces q1 engine) */
, ,
{ 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

@ -1207,7 +1207,7 @@ DrawSurfaceForFlare() - ydnar
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

@ -346,7 +346,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

@ -771,6 +771,7 @@ void StripFaceSurface( mapDrawSurface_t *ds )
Error( "MAX_INDEXES exceeded for surface (%d > %d) (%d verts)", numIndexes, MAX_INDEXES, ds->numVerts ); 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 */ /* 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 */
@ -941,50 +942,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
@ -1444,7 +1401,7 @@ static int AddMetaTriangleToSurface( mapDrawSurface_t *ds, metaTriangle_t *tri,
{ {
int i, score, coincident, ai, bi, ci, oldTexRange[ 2 ]; int i, score, coincident, ai, bi, ci, oldTexRange[ 2 ];
float lmMax; float lmMax;
vec3_t mins, maxs, p; vec3_t mins, maxs;
qboolean inTexRange, es, et; qboolean inTexRange, es, et;
mapDrawSurface_t old; mapDrawSurface_t old;
@ -1807,37 +1764,37 @@ static int CompareMetaTriangles( const void *a, const void *b )
/* shader first */ /* shader first */
if( ((metaTriangle_t*) a)->si < ((metaTriangle_t*) b)->si ) if( ((const 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( ((const 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( ((const 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( ((const 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;
} }
#endif #endif
@ -1849,8 +1806,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

@ -600,8 +600,8 @@ EdgeCompare
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

@ -102,9 +102,9 @@ the earlier information.
*/ */
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 *const *)a)->nummightsee == (*(const vportal_t *const *)b)->nummightsee)
return 0; 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;
return 1; return 1;
} }
@ -932,8 +932,8 @@ void LoadPortals (char *name)
Error ("LoadPortals: reading portal %i", i); Error ("LoadPortals: reading portal %i", i);
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)
Error ("LoadPortals: reading hint state"); Error ("LoadPortals: reading hint state");