Example #1
0
  WadArchive(const char* name)
    : m_name(name), m_wadfile(name)
  {
    if(!m_wadfile.failed())
    {
      wadinfo_t wadinfo;
      istream_read_wadinfo(m_wadfile, wadinfo);

      EWadVersion version = wad_version(wadinfo.identification);
      int miptexType = miptex_type_for_version(version);

      if(version != eNotValid)
      {
        m_wadfile.seek(wadinfo.infotableofs);

        for(int i = 0; i < wadinfo.numlumps; ++i)
        {
          char buffer[32];
          lumpinfo_t lumpinfo;
          istream_read_lumpinfo(m_wadfile, lumpinfo);
          if(lumpinfo.type == miptexType)
          {
            strcpy(buffer, "textures/");
            strcat(buffer, lumpinfo.name);
            strcat(buffer, type_for_version(version));
            m_files.insert(files_t::value_type(buffer, wad_record_t(lumpinfo.filepos, lumpinfo.disksize, lumpinfo.size)));
          }
        }
      }
    }
  }
Example #2
0
 // if file doesn't exist in project, add it and return reference to it
 // otherwise return a reference to the existing file.
 file& add_file(std::string const& file_path) {
     return files_.insert(
         files_t::value_type(file_path, file())).first->second;
 }