[Kstars-devel] KDE/kdeedu/kstars/kstars
Akarsh Simha
akarshsimha at gmail.com
Mon Jul 28 16:35:54 CEST 2008
SVN commit 838696 by asimha:
Updating default data files and the code in BinFileHelper and
StarBlockList to use the new format.
CCMAIL: kstars-devel at kde.org
M +13 -11 binfilehelper.cpp
M +1 -0 binfilehelper.h
M data/shallowstars.dat
M data/starnames.dat
M +1 -1 skycomponents/starblocklist.cpp
--- trunk/KDE/kdeedu/kstars/kstars/binfilehelper.cpp #838695:838696
@@ -94,6 +94,8 @@
else
byteswap = 0;
+ fread( &versionNumber, 1, 1, fileHandle );
+
preambleUpdated = true;
// Read the field descriptor table
fread(&nfields, 2, 1, fileHandle);
@@ -104,7 +106,7 @@
if(!fread(de, sizeof(dataElement), 1, fileHandle)) {
return ERR_FD_TRUNC;
}
- bswap_32( de->scale );
+ if( byteswap ) bswap_32( de->scale );
fields.append( de );
}
@@ -118,14 +120,14 @@
FDUpdated = true;
// Read the index table
- fread(&indexSize, 2, 1, fileHandle);
- bswap_16( indexSize );
+ fread(&indexSize, 4, 1, fileHandle);
+ if( byteswap ) bswap_32( indexSize );
- quint16 ID;
+ quint32 ID;
quint32 offset;
quint32 prev_offset;
- quint16 nrecs;
- quint16 prev_nrecs;
+ quint32 nrecs;
+ quint32 prev_nrecs;
itableOffset = KDE_ftell(fileHandle);
@@ -136,11 +138,11 @@
indexCount.clear();
indexOffset.clear();
for(i = 0; i < indexSize; ++i) {
- if(!fread(&ID, 2, 1, fileHandle)) {
+ if(!fread(&ID, 4, 1, fileHandle)) {
errorMessage.sprintf("Table truncated before expected! Read i = %d index entries so far", i);
return ERR_INDEX_TRUNC;
}
- bswap_16( ID );
+ if( byteswap ) bswap_32( ID );
if(ID >= indexSize) {
errorMessage.sprintf("ID %u is greater than the expected number of expected entries (%u)", ID, indexSize);
return ERR_INDEX_BADID;
@@ -153,12 +155,12 @@
errorMessage.sprintf("Table truncated before expected! Read i = %d index entries so far", i);
return ERR_BADSEEK;
}
- bswap_32( offset );
- if(!fread(&nrecs, 2, 1, fileHandle)) {
+ if( byteswap ) bswap_32( offset );
+ if(!fread(&nrecs, 4, 1, fileHandle)) {
errorMessage.sprintf("Table truncated before expected! Read i = %d index entries so far", i);
return ERR_BADSEEK;
}
- bswap_16( nrecs );
+ if( byteswap ) bswap_32( nrecs );
if(prev_offset != 0 && prev_nrecs != (-prev_offset + offset)/recordSize) {
errorMessage.sprintf("Expected %u = (%X - %x) / %x records, but found %u, in index entry %u",
(offset - prev_offset) / recordSize, offset, prev_offset, recordSize, prev_nrecs, i - 1);
--- trunk/KDE/kdeedu/kstars/kstars/binfilehelper.h #838695:838696
@@ -261,6 +261,7 @@
long dataOffset; // Stores the offset position of the start of data
QString errorMessage; // Stores the most recent 'unread' error message
unsigned long recordCount; // Stores the total number of records in the file
+ quint8 versionNumber; // Stores the version number of the file
};
#endif
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/starblocklist.cpp #838695:838696
@@ -94,7 +94,7 @@
return false;
}
- Trixel trixelId = ( ( trixel < 256 ) ? ( trixel + 256 ) : ( trixel - 256 ) ); // Trixel ID on datafile is assigned differently
+ Trixel trixelId = trixel; //( ( trixel < 256 ) ? ( trixel + 256 ) : ( trixel - 256 ) ); // Trixel ID on datafile is assigned differently
if( readOffset <= 0 )
readOffset = dSReader->getOffset( trixelId );
More information about the Kstars-devel
mailing list