----------------------------------------------------------------------------- */
-
-
-/* marker */
-#define PM_3DS_C
-
/* dependencies */
#include "picointernal.h"
* validates an autodesk 3ds model file.
*/
static int _3ds_canload( PM_PARAMS_CANLOAD ){
- T3dsChunk *chunk;
-
- /* to keep the compiler happy */
- *fileName = *fileName;
+ const T3dsChunk *chunk;
/* sanity check */
- if ( bufSize < sizeof( T3dsChunk ) ) {
+ if ( bufSize < (int) sizeof( T3dsChunk ) ) {
return PICO_PMV_ERROR_SIZE;
}
/* get pointer to 3ds header chunk */
- chunk = (T3dsChunk *)buffer;
+ chunk = (const T3dsChunk *)buffer;
/* check data length */
- if ( bufSize < _pico_little_long( chunk->len ) ) {
+ if ( bufSize < (int) _pico_little_long( chunk->len ) ) {
return PICO_PMV_ERROR_SIZE;
}
return 0;
}
+ /* ydnar: trim to first whitespace */
+ _pico_first_token( shaderName );
+
/* now that we have the shader name we need to go through all of */
/* the shaders and check the name against each shader. when we */
/* find a shader in our shader list that matches this name we */
/* we have a valid map name ptr */
if ( mapNamePtr != NULL ) {
char temp[128];
- char *name;
+ const char *name;
/* copy map name to local buffer */
strcpy( mapName,mapNamePtr );
/* is used by the mesh. new material names are set HERE. */
/* but for now we skip the new material's name ... */
if ( pers->shader ) {
- char *name = (char *)( pers->bufptr + pers->cofs );
- PicoSetShaderName( pers->shader,name );
+ char *name = (char*) ( pers->bufptr + pers->cofs );
+ char *cleanedName = _pico_clone_alloc( name );
+ _pico_first_token( cleanedName );
+ PicoSetShaderName( pers->shader, cleanedName );
#ifdef DEBUG_PM_3DS
- printf( "NewShader: '%s'\n",name );
+ printf( "NewShader: '%s'\n", cleanedName );
#endif
+ _pico_free( cleanedName );
}
}
if ( chunk->id == CHUNK_MATDIFFUSE ) {
/* initialize persistant vars (formerly static) */
pers.model = model;
- pers.bufptr = (picoByte_t *)buffer;
+ pers.bufptr = (picoByte_t *)_pico_alloc( bufSize );
+ memcpy( pers.bufptr, buffer, bufSize );
pers.basename = (char *)basename;
pers.maxofs = bufSize;
pers.cofs = 0L;