#include #include using namespace std; void readsection(RwChunkHeaderInfo *rwh, RwUInt32 vers, RwUInt32 level, RwStream *file) { RwChunkHeaderInfo newheader; RwUInt32 end; RwInt32 i; RwChar const *name; for (i = 0; i < level; i++) cout << " "; name = RwChunkHeaderInfoGetChunkName(rwh->type); cout << name << " (" << hex << rwh->length << " bytes @ 0x" << hex << RwStreamTell(file)-12 << "/0x" << hex << RwStreamTell(file) << ") - [0x" << hex << rwh->type << "] " << rwh->version << endl; end = RwStreamTell(file) + rwh->length; while (RwStreamTell(file) < end) { RwStreamReadChunkHeaderInfo(file, &newheader); if (newheader.version == vers) { readsection(&newheader, vers, level+1, file); /* Native Data PLG has the wrong length */ if (rwh->type == 0x510) RwStreamSeek(file, end); } else { RwStreamSkip(file, rwh->length-12); break; } } } int main(int argc, char *argv[]) { RwStream *file; RwChunkHeaderInfo rwh; RwUInt32 vers; if (argc < 2) { cerr << "Usage: " << argv[0] << " rw\n"; return 1; } file = RwStreamOpen(rwSTREAMFILENAME, rwSTREAMREAD, argv[1]); if (file == NULL) { cerr << "Coudn't open file: " << argv[1] << "\n"; return 1; } RwStreamReadChunkHeaderInfo(file, &rwh); vers = rwh.version; readsection(&rwh, vers, 0, file); cout << "RW version: " << hex << vers << " " << argv[1] << endl; // cout << "RW version: " << hex << vers << endl; return 0; }