X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=tools%2Fquake3%2Fq3map2%2Fmodel.c;h=05213cf1ae545ab0efb29ec2d6801f11ee95e291;hb=05b62ff70fbb4edb73e2280793cac30407e203d5;hp=00ff693eb47a3bf1600a5fac154a3097396ddeb6;hpb=43b05f81bc0b6781ac24d57070b188eecc81e00c;p=xonotic%2Fnetradiant.git diff --git a/tools/quake3/q3map2/model.c b/tools/quake3/q3map2/model.c index 00ff693e..05213cf1 100644 --- a/tools/quake3/q3map2/model.c +++ b/tools/quake3/q3map2/model.c @@ -78,9 +78,9 @@ PicoLoadFileFunc() 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 ); /* attempt to parse model */ - *pm = PicoLoadModel( (char*) name, frame ); + *pm = PicoLoadModel( name, frame ); /* if loading failed, make a bogus model to silence the rest of the warnings */ if( *pm == NULL ) @@ -169,7 +169,7 @@ picoModel_t *LoadModel( const char *name, int frame ) return NULL; /* set data */ - PicoSetModelName( *pm, (char*) name ); + PicoSetModelName( *pm, name ); PicoSetModelFrameNum( *pm, frame ); } @@ -242,17 +242,17 @@ void InsertModel( const char *name, int skin, int frame, m4x4_t transform, remap skinfilename[sizeof(skinfilename)-1] = 0; skinfilehandle = fopen(skinfilename, "r"); skinfilesize = vfsLoadFile(skinfilename, (void**) &skinfilecontent, 0); - if(skinfilesize < 0) + if(skinfilesize < 0 && skin != 0) { /* fallback to skin 0 if invalid */ snprintf(skinfilename, sizeof(skinfilename), "%s_0.skin", name); skinfilename[sizeof(skinfilename)-1] = 0; skinfilesize = vfsLoadFile(skinfilename, (void**) &skinfilecontent, 0); - if(skinfilesize < 0) + if(skinfilesize >= 0) Sys_Printf( "Skin %d of %s does not exist, using 0 instead\n", skin, name ); } sf = NULL; - if(skinfilesize) + if(skinfilesize >= 0) { Sys_Printf( "Using skin %d of %s\n", skin, name ); int pos; @@ -280,16 +280,15 @@ void InsertModel( const char *name, int skin, int frame, m4x4_t transform, remap sf = safe_malloc( sizeof( *sf ) ); sf->next = sf2; - sprintf(format, "replace %%%ds %%%ds%%n", (int)sizeof(sf->name)-1, (int)sizeof(sf->to)-1); - pos = 0; - if(sscanf(skinfileptr, format, &sf->name, &sf->to, &pos) > 0 && pos > 0) + sprintf(format, "replace %%%ds %%%ds", (int)sizeof(sf->name)-1, (int)sizeof(sf->to)-1); + if(sscanf(skinfileptr, format, sf->name, sf->to) == 2) continue; - sprintf(format, "%%%ds,%%%ds%%n", (int)sizeof(sf->name)-1, (int)sizeof(sf->to)-1); - pos = 0; - if(sscanf(skinfileptr, format, &sf->name, &sf->to, &pos) > 0 && pos > 0) + sprintf(format, " %%%d[^, ] ,%%%ds", (int)sizeof(sf->name)-1, (int)sizeof(sf->to)-1); + if((pos = sscanf(skinfileptr, format, sf->name, sf->to)) == 2) continue; /* invalid input line -> discard sf struct */ + Sys_Printf( "Discarding skin directive in %s: %s\n", skinfilename, skinfileptr ); free(sf); sf = sf2; }