Sad Penguin
03-17-2005, 09:37 PM
For some reason when this gets to the PNTS chunk, it returns a HUGE number.
byte_4 is a 4 dimension char array
ChunkToUInt takes a chuck, converts it to the correct endian, and returns a number.
This works fine for TAGS and LAYR, but when it gets to PNTS, the length (here pos) of the chunk is returned as many times greater than even the filesize.
What am I doing wrong? (This is with LW8, just using save then loading a saved file...) :confused:
// if ( CompareChunk( "LWO2", byte_4 ) == false ){return false;}
do {
//get chunk stream
fread( byte_4, 4, 1, mdl );
foundchunk = false;
//loading chunk data will be here
if (foundchunk == false) {
fread( byte_4, 4, 1, mdl );
pos = ChunkToUInt( byte_4 );
for (int add_cnt = 1; add_cnt <= pos; add_cnt++)
fread( &ch, 1, 1, mdl );
if (pos%2 == 1) { fread( &ch, 1, 1, mdl );}
}
} while ( ftell( mdl ) != datasize + 8);
byte_4 is a 4 dimension char array
ChunkToUInt takes a chuck, converts it to the correct endian, and returns a number.
This works fine for TAGS and LAYR, but when it gets to PNTS, the length (here pos) of the chunk is returned as many times greater than even the filesize.
What am I doing wrong? (This is with LW8, just using save then loading a saved file...) :confused:
// if ( CompareChunk( "LWO2", byte_4 ) == false ){return false;}
do {
//get chunk stream
fread( byte_4, 4, 1, mdl );
foundchunk = false;
//loading chunk data will be here
if (foundchunk == false) {
fread( byte_4, 4, 1, mdl );
pos = ChunkToUInt( byte_4 );
for (int add_cnt = 1; add_cnt <= pos; add_cnt++)
fread( &ch, 1, 1, mdl );
if (pos%2 == 1) { fread( &ch, 1, 1, mdl );}
}
} while ( ftell( mdl ) != datasize + 8);