components/prboom/d_deh.c
//
// deh_procBexSprites
//
// Supports sprite name substitutions without requiring use
// of the DeHackEd Text block
//
deh_procBexSprites
Supports sprite name substitutions without requiring use
of the DeHackEd Text block
deh_procBexSprites Supports sprite name substitutions without requiring use of the DeHackEd Text block
static void deh_procBexSprites(DEHFILE *fpin, FILE *fpout, char *line)
{
   char key[DEH_MAXKEYLEN];
   char inbuffer[DEH_BUFFERMAX];
   uint_64_t value;    
   char *strval;  
   char candidate[5];
   int  rover;
   if(fpout)
      fprintf(fpout,"Processing sprite name substitution\n");
   strncpy(inbuffer,line,DEH_BUFFERMAX);
   while(!dehfeof(fpin) && *inbuffer && (*inbuffer != ' '))
   {
      if(!dehfgets(inbuffer, sizeof(inbuffer), fpin))
        break;
      if(*inbuffer == '#')
        continue;  
      lfstrip(inbuffer);
      if(!*inbuffer) 
        break;  
      if(!deh_GetData(inbuffer,key,&value,&strval,fpout)) 
      {
        if(fpout)
          fprintf(fpout,"Bad data pair in '%s'\n",inbuffer);
        continue;
      }
      memset(candidate, 0, sizeof(candidate));
      strncpy(candidate, ptr_lstrip(strval), 4);
      if(strlen(candidate) != 4)
      {
	 if(fpout)
	    fprintf(fpout, "Bad length for sprite name '%s'\n",
	            candidate);
	 continue;
      }
      rover = 0;
      while(deh_spritenames[rover])
      {
	 if(!strncasecmp(deh_spritenames[rover], key, 4))
	 {
	    if(fpout)
	       fprintf(fpout, "Substituting '%s' for sprite '%s'\n",
	               candidate, deh_spritenames[rover]);
	    sprnames[rover] = strdup(candidate);
	    break;
	 }
	 rover++;
      }
   }
}
static void deh_procBexSprites ( DEHFILE * fpin , FILE * fpout , char * line ) { char key [ DEH_MAXKEYLEN ] ; char inbuffer [ DEH_BUFFERMAX ] ; uint_64_t value ; char * strval ; char candidate [ 5 ] ; int rover ; if ( fpout ) fprintf ( fpout , " \n " ) ; strncpy ( inbuffer , line , DEH_BUFFERMAX ) ; while ( ! dehfeof ( fpin ) && * inbuffer && ( * inbuffer != ' ' ) ) { if ( ! dehfgets ( inbuffer , sizeof ( inbuffer ) , fpin ) ) break ; if ( * inbuffer == ' ' ) continue ; lfstrip ( inbuffer ) ; if ( ! * inbuffer ) break ; if ( ! deh_GetData ( inbuffer , key , & value , & strval , fpout ) ) { if ( fpout ) fprintf ( fpout , " \n " , inbuffer ) ; continue ; } memset ( candidate , 0 , sizeof ( candidate ) ) ; strncpy ( candidate , ptr_lstrip ( strval ) , 4 ) ; if ( strlen ( candidate ) != 4 ) { if ( fpout ) fprintf ( fpout , " \n " , candidate ) ; continue ; } rover = 0 ; while ( deh_spritenames [ rover ] ) { if ( ! strncasecmp ( deh_spritenames [ rover ] , key , 4 ) ) { if ( fpout ) fprintf ( fpout , " \n " , candidate , deh_spritenames [ rover ] ) ; sprnames [ rover ] = strdup ( candidate ) ; break ; } rover ++ ; } } }
deh_procBexSprites
Supports sprite name substitutions without requiring use
of the DeHackEd Text block
deh_procBexSprites Supports sprite name substitutions without requiring use of the DeHackEd Text block
// All deh values are ints or longs // holds the string value of the line // skip comment lines // killough 11/98 // returns TRUE if ok // do it