}
read (file, &hdr, sizeof ( hdr));
if (Istrnicmp ( hdr.sign, HIWAD", 4 ) && Istrnicmp ( hdr.sign, "PWAD", 4 ))
{
printf ("\nNot a valid WAD file"); exit ( 1 );
}
directory = new DirEntry [hdr.dirEntries];
if ( directory == NULL ) {
printf (M\nlnsufficint memory to load directory.M); exit (1 );
}
Iseek (file, hdr.dirOffset, SEEK_SET );
read (file, directory, hdr.dirEntries * sizeof ( DirEntry ));
}
WadFile :: -WadFile () {
close (file );
if ( directory != NULL ) delete directory;
}
void WadFile :: loadLevel (int episode, int level) {
char levelName [5] = {*E\ '0' + episode, *M\ 'CT + level, W};
for (int i = 0; i < hdr.dirEntries; i++ )
if (Istrcmp ( directory [i].name, levelName )) break;
if (i >= hdr.dirEntries ) return;
for (i++; i < hdr.dirEntries; i++ ) {
if (Istrnicmp ( directory [i].name, "VERTEXES", 8 )) {
if ( vertices != NULL ) delete vertices;
numVertices = directory [ij.size / sizeof ( Vertex ); vertices = new Vertex [numVertices];
Iseek (file, directory [ij.offset, SEEK_SET );

Компьютерная графика. Полигональные модели

read (file, vertices, directory [ij.size );
}
else
if (Istrnicmp ( directory [i].name, "LINEDEFS", 8 )) {
if (lines != NULL ) delete lines;
numLines = directory [i].size / sizeof ( LineDef); lines = new LineDef [numLines];
Iseek ( file, directory [i].offset, SEEK^SET ); read (file, lines, directory [ij.size );
}
else
if (istrnicmp ( directory [i].name, "SIDEDEFS", 8 )) {
if (sides != NULL ) delete sides;
numSides = directory [ij.size / sizeof ( SideDef); sides = new SideDef [numSides];
Iseek (file, directory [ij.offset, SEEK_SET ); read (file, sides, directory [ij.size );
}
else
if (Istrnicmp ( directory [ij.name, "SEGS", 8 )) {
if (segs != NULL ) delete segs;
numSegs = directory [ij.size / sizeof ( Segment); segs = new Segment [numSegs];
Iseek (file, directory [ij.offset, SEEK_SET ); read (file, segs, directory [ij.size );
}
else
if (Istrnicmp ( directory [ij.name, "SECTORS", 8 )) {

⇐ Предыдущая| |Следующая ⇒