home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / RAYCAST.ZIP / LOADWOR.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-07  |  1.2 KB  |  49 lines

  1. #include <string.h>
  2. #include "ray.h"
  3. #include "globals.h"
  4. #include "loadwor.h"
  5. #include "resnames.h"
  6.  
  7. #define F_EXT_LENGTH 4
  8.  
  9. const char F_EXT_MARKER='.';
  10. const char WAD_EXT [F_EXT_LENGTH]="WAD";
  11.  
  12. void File_Extension(PCHAR file_name, PCHAR file_ext)
  13. {
  14. BOOL found_ext;
  15. SHORT cur_char;
  16.  
  17.  
  18. strncpy(file_ext,"\0",F_EXT_LENGTH);
  19. found_ext=FALSE;
  20. cur_char=0;
  21.  
  22. // look for a '.' to mark the beginning of a file's extension
  23. while ( (file_name[cur_char]!='\0') && (cur_char<F_NAME_LENGTH) ) {
  24.    if (file_name[cur_char]==F_EXT_MARKER) {
  25.      found_ext=TRUE;
  26.      break;
  27.      }
  28.    cur_char++;
  29.    }
  30. // if we find an extension, copy it
  31. if (found_ext)
  32.   strncpy(file_ext, file_name+cur_char+1, F_EXT_LENGTH);
  33.  
  34. }
  35.  
  36. void Load_World(PCHAR filename) {
  37.    CHAR file_ext[F_EXT_LENGTH];
  38.       // is the user specifying a doom level or a normal level?
  39.       File_Extension(filename, file_ext);
  40.       if (!strnicmp(file_ext, WAD_EXT, F_EXT_LENGTH))
  41.       {
  42.          //yes, so load textures from standard file, and then world from wad
  43.          F_Doom_Load(filename);
  44.       } else {
  45.           //no, so load everything from a 4 horseman file
  46.          F_Scan_Load(filename);
  47.       }
  48. }
  49.