New Paste :: Recent Pastes:: No Line Numbers
Doom .WAD Reading by baldurk
1
bool ReadWad() { // BEGIN READING WAD! FILE *fp = fopen("doom2.wad", "r"); if(!fp) { cout << "Holy cow! Can't open doom2.wad" << endl; return false; } char ID[5]; memset(ID, 0, 5); fread(ID, sizeof(char), 4, fp); if(strcmp(ID, "IWAD") && strcmp(ID, "PWAD")) { cout << "Holy cow! doom2.wad ain't a valid PWAD or IWAD. ID: " << ID << endl; return false; } long size, offset; fread(&size, sizeof(long), 1, fp); cerr << "Got " << size << " lumps." << endl; fread(&offset, sizeof(long), 1, fp); cerr << "Directory at: " << offset << endl; cerr << "Seeking.." << endl; int ret = fseek(fp, offset, SEEK_SET); if(ret) { cout << "Holy cow! error seeking to directory." << endl; return false; } return true; }