[wpdev-commits] wolfpack/muls maps.cpp,1.3,1.4
Brought to you by:
rip,
thiagocorrea
From: Sebastian H. <dar...@us...> - 2004-07-21 17:05:33
|
Update of /cvsroot/wpdev/wolfpack/muls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3015/muls Modified Files: maps.cpp Log Message: A stadif issue has been resolved. Index: maps.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/muls/maps.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** maps.cpp 21 Jul 2004 12:42:54 -0000 1.3 --- maps.cpp 21 Jul 2004 17:05:22 -0000 1.4 *************** *** 48,51 **** --- 48,59 ---- #include <math.h> + #pragma pack (1) + struct stIndexRecord { + unsigned int offset; + unsigned int blocklength; + unsigned int extra; + }; + #pragma pack() + class MapsPrivate { *************** *** 59,63 **** This maps block ids to offsets in the stadifiX.mul file. */ ! QMap<unsigned int, unsigned int> staticpatches; #pragma pack (1) --- 67,71 ---- This maps block ids to offsets in the stadifiX.mul file. */ ! QMap<unsigned int, stIndexRecord> staticpatches; #pragma pack (1) *************** *** 78,82 **** QFile staticsfile; QFile mapdifdata; - QFile stadifindex; QFile stadifdata; --- 86,89 ---- *************** *** 134,157 **** } - QFile stadiflist( basepath + QString( "stadifl%1.mul" ).arg( id ) ); stadifdata.setName( basepath + QString( "stadif%1.mul" ).arg( id ) ); stadifdata.open( IO_ReadOnly ); - stadifindex.setName( basepath + QString( "stadifi%1.mul" ).arg( id ) ); - stadifindex.open( IO_ReadOnly ); ! if ( stadifdata.isOpen() && stadifindex.isOpen() && stadiflist.open( IO_ReadOnly ) ) ! { ! QDataStream listinput( &stadiflist ); ! listinput.setByteOrder( QDataStream::LittleEndian ); ! unsigned int offset = 0; ! while ( !listinput.atEnd() ) ! { unsigned int id; listinput >> id; ! staticpatches.insert( id, offset ); ! offset += 12; // Size of a static index record ! } stadiflist.close(); } } --- 141,178 ---- } stadifdata.setName( basepath + QString( "stadif%1.mul" ).arg( id ) ); stadifdata.open( IO_ReadOnly ); ! QFile stadiflist( basepath + QString( "stadifl%1.mul" ).arg( id ) ); ! QFile stadifindex( basepath + QString( "stadifi%1.mul" ).arg( id ) ); ! ! if (stadifindex.open(IO_ReadOnly) && stadiflist.open(IO_ReadOnly)) { ! QDataStream listinput(&stadiflist); ! QDataStream indexinput(&stadifindex); ! listinput.setByteOrder(QDataStream::LittleEndian); ! indexinput.setByteOrder(QDataStream::LittleEndian); ! ! stIndexRecord record; ! while (!listinput.atEnd()) { unsigned int id; listinput >> id; ! ! indexinput >> record.offset; ! indexinput >> record.blocklength; ! indexinput >> record.extra; ! ! if (!staticpatches.contains(id)) { ! staticpatches.insert( id, record ); ! } ! } ! } ! ! if (stadiflist.isOpen()) { stadiflist.close(); } + + if (stadifindex.isOpen()) { + stadifindex.close(); + } } *************** *** 608,639 **** #endif { - // Well, unfortunally we will be forced to read the file :( - #pragma pack (1) - struct - { - Q_UINT32 offset; - Q_UINT32 blocklength; - } indexStructure; - #pragma pack() - QDataStream staticStream; staticStream.setByteOrder( QDataStream::LittleEndian ); // See if this particular block is patched. if ( mapRecord->staticpatches.contains( indexPos / 12 ) ) { ! indexPos = mapRecord->staticpatches[indexPos / 12]; ! ! mapRecord->stadifindex.at( indexPos ); ! mapRecord->stadifindex.readBlock( ( char * ) &indexStructure, sizeof( indexStructure ) ); ! if ( indexStructure.offset == 0xFFFFFFFF ) return; // No statics for this block ! mapRecord->stadifdata.at( indexStructure.offset ); staticStream.setDevice( &mapRecord->stadifdata ); } else { mapRecord->idxfile.at( indexPos ); mapRecord->idxfile.readBlock( ( char * ) &indexStructure, sizeof( indexStructure ) ); --- 629,651 ---- #endif { QDataStream staticStream; staticStream.setByteOrder( QDataStream::LittleEndian ); + unsigned int blockLength; // See if this particular block is patched. if ( mapRecord->staticpatches.contains( indexPos / 12 ) ) { ! const stIndexRecord& index = mapRecord->staticpatches[indexPos / 12]; ! if ( index.offset == 0xFFFFFFFF ) return; // No statics for this block ! mapRecord->stadifdata.at( index.offset ); staticStream.setDevice( &mapRecord->stadifdata ); + blockLength = index.blocklength; } else { + stIndexRecord indexStructure; mapRecord->idxfile.at( indexPos ); mapRecord->idxfile.readBlock( ( char * ) &indexStructure, sizeof( indexStructure ) ); *************** *** 644,652 **** mapRecord->staticsfile.at( indexStructure.offset ); staticStream.setDevice( &mapRecord->staticsfile ); } const uint remainX = x % 8; const uint remainY = y % 8; ! for ( Q_UINT32 i = 0; i < indexStructure.blocklength / 7; ++i ) { staticrecord r; --- 656,665 ---- mapRecord->staticsfile.at( indexStructure.offset ); staticStream.setDevice( &mapRecord->staticsfile ); + blockLength = indexStructure.blocklength; } const uint remainX = x % 8; const uint remainY = y % 8; ! for ( Q_UINT32 i = 0; i < blockLength / 7; ++i ) { staticrecord r; |