From 5333f6adc151332f32b447e6c9a648328ed76059 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 21 Oct 2019 00:13:17 +0200 Subject: [PATCH] - refactored a few more - simple stuff but lots of lines. --- source/blood/src/sound.cpp | 10 ++--- source/blood/src/tile.cpp | 21 +++++----- source/build/src/mdsprite.cpp | 58 +++++++++++++------------- source/build/src/osd.cpp | 26 +++++------- source/build/src/palette.cpp | 64 +++++++++++++++-------------- source/build/src/sdlayer.cpp | 12 ++---- source/build/src/voxmodel.cpp | 76 +++++++++++++++++------------------ 7 files changed, 125 insertions(+), 142 deletions(-) diff --git a/source/blood/src/sound.cpp b/source/blood/src/sound.cpp index 1a9f77348..d6e68685f 100644 --- a/source/blood/src/sound.cpp +++ b/source/blood/src/sound.cpp @@ -365,18 +365,16 @@ void sndStartWavDisk(const char *pzFile, int nVolume, int nChannel) pChannel = &Channel[nChannel]; if (pChannel->at0 > 0) sndKillSound(pChannel); - int hFile = kopen4loadfrommod(pzFile, 0); - if (hFile == -1) + auto hFile = kopenFileReader(pzFile, 0); + if (!hFile.isOpen()) return; - int nLength = kfilelength(hFile); + int nLength = hFile.GetLength(); char *pData = (char*)gSoundRes.Alloc(nLength); if (!pData) { - kclose(hFile); return; } - kread(hFile, pData, kfilelength(hFile)); - kclose(hFile); + hFile.Read(pData, nLength); pChannel->at5 = (DICTNODE*)pData; pChannel->at4 |= 2; pChannel->at0 = FX_Play(pData, nLength, 0, -1, 0, nVolume, nVolume, nVolume, nVolume, 1.f, (intptr_t)&pChannel->at0); diff --git a/source/blood/src/tile.cpp b/source/blood/src/tile.cpp index 769cf2e4a..0ccb10607 100644 --- a/source/blood/src/tile.cpp +++ b/source/blood/src/tile.cpp @@ -88,27 +88,24 @@ int tileInit(char a1, const char *a2) for (int i = 0; i < kMaxTiles; i++) voxelIndex[i] = 0; - int hFile = kopen4loadfrommod("SURFACE.DAT", 0); - if (hFile != -1) + auto hFile = kopenFileReader("SURFACE.DAT", 0); + if (hFile.isOpen()) { - kread(hFile, surfType, sizeof(surfType)); - kclose(hFile); + hFile.Read(surfType, sizeof(surfType)); } - hFile = kopen4loadfrommod("VOXEL.DAT", 0); - if (hFile != -1) + hFile = kopenFileReader("VOXEL.DAT", 0); + if (hFile.isOpen()) { - kread(hFile, voxelIndex, sizeof(voxelIndex)); + hFile.Read(voxelIndex, sizeof(voxelIndex)); #if B_BIG_ENDIAN == 1 for (int i = 0; i < kMaxTiles; i++) voxelIndex[i] = B_LITTLE16(voxelIndex[i]); #endif - kclose(hFile); } - hFile = kopen4loadfrommod("SHADE.DAT", 0); - if (hFile != -1) + hFile = kopenFileReader("SHADE.DAT", 0); + if (hFile.isOpen()) { - kread(hFile, tileShade, sizeof(tileShade)); - kclose(hFile); + hFile.Read(tileShade, sizeof(tileShade)); } for (int i = 0; i < kMaxTiles; i++) { diff --git a/source/build/src/mdsprite.cpp b/source/build/src/mdsprite.cpp index 0ae9b30b4..7fb6c378c 100644 --- a/source/build/src/mdsprite.cpp +++ b/source/build/src/mdsprite.cpp @@ -683,7 +683,7 @@ prep_return: } //--------------------------------------- MD2 LIBRARY BEGINS --------------------------------------- -static md2model_t *md2load(buildvfs_kfd fil, const char *filnam) +static md2model_t *md2load(FileReader & fil, const char *filnam) { md2model_t *m; md3model_t *m3; @@ -698,7 +698,7 @@ static md2model_t *md2load(buildvfs_kfd fil, const char *filnam) m = (md2model_t *)Xcalloc(1,sizeof(md2model_t)); m->mdnum = 2; m->scale = .01f; - kread(fil,(char *)&head,sizeof(md2head_t)); + fil.Read((char *)&head,sizeof(md2head_t)); #if B_BIG_ENDIAN != 0 head.id = B_LITTLE32(head.id); head.vers = B_LITTLE32(head.vers); head.skinxsiz = B_LITTLE32(head.skinxsiz); head.skinysiz = B_LITTLE32(head.skinysiz); @@ -727,23 +727,23 @@ static md2model_t *md2load(buildvfs_kfd fil, const char *filnam) m->tris = (md2tri_t *)Xmalloc(head.numtris*sizeof(md2tri_t)); m->uv = (md2uv_t *)Xmalloc(head.numuv*sizeof(md2uv_t)); - klseek(fil,head.ofsframes,SEEK_SET); - if (kread(fil,(char *)m->frames,m->numframes*m->framebytes) != m->numframes*m->framebytes) + fil.Seek(head.ofsframes,FileReader::SeekSet); + if (fil.Read((char *)m->frames,m->numframes*m->framebytes) != m->numframes*m->framebytes) { Xfree(m->uv); Xfree(m->tris); Xfree(m->glcmds); Xfree(m->frames); Xfree(m); return 0; } if (m->numglcmds > 0) { - klseek(fil,head.ofsglcmds,SEEK_SET); - if (kread(fil,(char *)m->glcmds,m->numglcmds*sizeof(int32_t)) != (int32_t)(m->numglcmds*sizeof(int32_t))) + fil.Seek(head.ofsglcmds,FileReader::SeekSet); + if (fil.Read((char *)m->glcmds,m->numglcmds*sizeof(int32_t)) != (int32_t)(m->numglcmds*sizeof(int32_t))) { Xfree(m->uv); Xfree(m->tris); Xfree(m->glcmds); Xfree(m->frames); Xfree(m); return 0; } } - klseek(fil,head.ofstris,SEEK_SET); - if (kread(fil,(char *)m->tris,head.numtris*sizeof(md2tri_t)) != (int32_t)(head.numtris*sizeof(md2tri_t))) + fil.Seek(head.ofstris,FileReader::SeekSet); + if (fil.Read((char *)m->tris,head.numtris*sizeof(md2tri_t)) != (int32_t)(head.numtris*sizeof(md2tri_t))) { Xfree(m->uv); Xfree(m->tris); Xfree(m->glcmds); Xfree(m->frames); Xfree(m); return 0; } - klseek(fil,head.ofsuv,SEEK_SET); - if (kread(fil,(char *)m->uv,head.numuv*sizeof(md2uv_t)) != (int32_t)(head.numuv*sizeof(md2uv_t))) + fil.Seek(head.ofsuv,FileReader::SeekSet); + if (fil.Read((char *)m->uv,head.numuv*sizeof(md2uv_t)) != (int32_t)(head.numuv*sizeof(md2uv_t))) { Xfree(m->uv); Xfree(m->tris); Xfree(m->glcmds); Xfree(m->frames); Xfree(m); return 0; } #if B_BIG_ENDIAN != 0 @@ -792,8 +792,8 @@ static md2model_t *md2load(buildvfs_kfd fil, const char *filnam) m->skinfn = (char *)Xmalloc(ournumskins*64); if (m->numskins > 0) { - klseek(fil,head.ofsskins,SEEK_SET); - if (kread(fil,m->skinfn,64*m->numskins) != 64*m->numskins) + fil.Seek(head.ofsskins,FileReader::SeekSet); + if (fil.Read(m->skinfn,64*m->numskins) != 64*m->numskins) { Xfree(m->glcmds); Xfree(m->frames); Xfree(m); return 0; } } @@ -967,7 +967,7 @@ static inline void quicksort(uint16_t *indexes, float *depths, int32_t first, in //--------------------------------------- MD3 LIBRARY BEGINS --------------------------------------- -static md3model_t *md3load(buildvfs_kfd fil) +static md3model_t *md3load(FileReader & fil) { int32_t i, surfi, ofsurf, offs[4], leng[4]; int32_t maxtrispersurf; @@ -979,7 +979,7 @@ static md3model_t *md3load(buildvfs_kfd fil) m->muladdframes = NULL; - kread(fil,&m->head,SIZEOF_MD3HEAD_T); + fil.Read(&m->head,SIZEOF_MD3HEAD_T); #if B_BIG_ENDIAN != 0 m->head.id = B_LITTLE32(m->head.id); m->head.vers = B_LITTLE32(m->head.vers); @@ -997,19 +997,19 @@ static md3model_t *md3load(buildvfs_kfd fil) ofsurf = m->head.ofssurfs; - klseek(fil,m->head.ofsframes,SEEK_SET); i = m->head.numframes*sizeof(md3frame_t); + fil.Seek(m->head.ofsframes,FileReader::SeekSet); i = m->head.numframes*sizeof(md3frame_t); m->head.frames = (md3frame_t *)Xmalloc(i); - kread(fil,m->head.frames,i); + fil.Read(m->head.frames,i); if (m->head.numtags == 0) m->head.tags = NULL; else { - klseek(fil,m->head.ofstags,SEEK_SET); i = m->head.numtags*sizeof(md3tag_t); + fil.Seek(m->head.ofstags,FileReader::SeekSet); i = m->head.numtags*sizeof(md3tag_t); m->head.tags = (md3tag_t *)Xmalloc(i); - kread(fil,m->head.tags,i); + fil.Read(m->head.tags,i); } - klseek(fil,m->head.ofssurfs,SEEK_SET); + fil.Seek(m->head.ofssurfs,FileReader::SeekSet); m->head.surfs = (md3surf_t *)Xcalloc(m->head.numsurfs, sizeof(md3surf_t)); // NOTE: We assume that NULL is represented by all-zeros. // surfs[0].geometry is for POLYMER_MD_PROCESS_CHECK (else: crashes). @@ -1039,7 +1039,7 @@ static md3model_t *md3load(buildvfs_kfd fil) for (surfi=0; surfihead.numsurfs; surfi++) { s = &m->head.surfs[surfi]; - klseek(fil,ofsurf,SEEK_SET); kread(fil,s,SIZEOF_MD3SURF_T); + fil.Seek(ofsurf,FileReader::SeekSet); fil.Read(s,SIZEOF_MD3SURF_T); #if B_BIG_ENDIAN != 0 { @@ -1069,10 +1069,10 @@ static md3model_t *md3load(buildvfs_kfd fil) s->uv = (md3uv_t *)(((intptr_t)s->shaders)+leng[1]); s->xyzn = (md3xyzn_t *)(((intptr_t)s->uv)+leng[2]); - klseek(fil,offs[0],SEEK_SET); kread(fil,s->tris ,leng[0]); - klseek(fil,offs[1],SEEK_SET); kread(fil,s->shaders,leng[1]); - klseek(fil,offs[2],SEEK_SET); kread(fil,s->uv ,leng[2]); - klseek(fil,offs[3],SEEK_SET); kread(fil,s->xyzn ,leng[3]); + fil.Seek(offs[0],FileReader::SeekSet); fil.Read(s->tris ,leng[0]); + fil.Seek(offs[1],FileReader::SeekSet); fil.Read(s->shaders,leng[1]); + fil.Seek(offs[2],FileReader::SeekSet); fil.Read(s->uv ,leng[2]); + fil.Seek(offs[3],FileReader::SeekSet); fil.Read(s->xyzn ,leng[3]); #if B_BIG_ENDIAN != 0 { @@ -1880,13 +1880,13 @@ mdmodel_t *mdload(const char *filnam) vm = (mdmodel_t *)voxload(filnam); if (vm) return vm; - buildvfs_kfd fil = kopen4load(filnam,0); + auto fil = kopenFileReader(filnam,0); - if (fil == buildvfs_kfd_invalid) + if (!fil.isOpen()) return NULL; - kread(fil,&i,4); - klseek(fil,0,SEEK_SET); + fil.Read(&i,4); + fil.Seek(0,FileReader::SeekSet); switch (B_LITTLE32(i)) { @@ -1902,8 +1902,6 @@ mdmodel_t *mdload(const char *filnam) break; } - kclose(fil); - if (vm) { md3model_t *vm3 = (md3model_t *)vm; diff --git a/source/build/src/osd.cpp b/source/build/src/osd.cpp index 15fa93ce7..2bc01d60b 100644 --- a/source/build/src/osd.cpp +++ b/source/build/src/osd.cpp @@ -166,11 +166,11 @@ int OSD_Exec(const char *szScript) { int err = 0; int32_t len = 0; - buildvfs_kfd handle; + FileReader handle; - if ((handle = kopen4load(szScript, 0)) == buildvfs_kfd_invalid) + if (!(handle = fopenFileReader(szScript, 0)).isOpen()) err = 1; - else if ((len = kfilelength(handle)) <= 0) + else if ((len = handle.GetLength()) <= 0) err = 2; // blank file if (!err) @@ -178,19 +178,15 @@ int OSD_Exec(const char *szScript) auto buf = (char *) Xmalloc(len + 1); - if (err || kread(handle, buf, len) != len) + if (err || handle.Read(buf, len) != len) { if (!err) // no error message for blank file OSD_Printf("Error executing \"%s\"!\n", szScript); - if (handle != buildvfs_kfd_invalid) - kclose(handle); - Xfree(buf); return 1; } - kclose(handle); buf[len] = '\0'; char const *cp = strtok(buf, "\r\n"); @@ -274,9 +270,9 @@ static int osdfunc_fileinfo(osdcmdptr_t parm) { if (parm->numparms != 1) return OSDCMD_SHOWHELP; - buildvfs_kfd h; + FileReader h; - if ((h = kopen4load(parm->parms[0],0)) == buildvfs_kfd_invalid) + if (!(h = kopenFileReader(parm->parms[0],0)).isOpen()) { OSD_Printf("fileinfo: File \"%s\" not found.\n", parm->parms[0]); return OSDCMD_OK; @@ -291,14 +287,14 @@ static int osdfunc_fileinfo(osdcmdptr_t parm) do { - siz = kread(h, buf, ReadSize); + siz = h.Read(buf, ReadSize); crcval = Bcrc32((uint8_t *)buf, siz, crcval); } while (siz == ReadSize); crctime = timerGetHiTicks() - crctime; - klseek(h, 0, BSEEK_SET); + h.Seek(0, FileReader::SeekSet); double xxhtime = timerGetHiTicks(); @@ -307,7 +303,7 @@ static int osdfunc_fileinfo(osdcmdptr_t parm) do { - siz = kread(h, buf, ReadSize); + siz = h.Read(buf, ReadSize); XXH32_update(&xxh, (uint8_t *)buf, siz); } while (siz == ReadSize); @@ -321,12 +317,10 @@ static int osdfunc_fileinfo(osdcmdptr_t parm) " File size: %d bytes\n" " CRC-32: %08X (%.1fms)\n" " xxHash: %08X (%.1fms)\n", - parm->parms[0], kfilelength(h), + parm->parms[0], (int)h.GetLength(), crcval, crctime, xxhash, xxhtime); - kclose(h); - return OSDCMD_OK; } diff --git a/source/build/src/palette.cpp b/source/build/src/palette.cpp index ff357042a..2db4f3b37 100644 --- a/source/build/src/palette.cpp +++ b/source/build/src/palette.cpp @@ -187,6 +187,11 @@ static void maybe_alloc_palookup(int32_t palnum); void (*paletteLoadFromDisk_replace)(void) = NULL; +inline bool read_and_test(FileReader& handle, void* buffer, int32_t leng) +{ + return handle.Read(buffer, leng) != leng; +}; + // // loadpalette (internal) // @@ -206,15 +211,15 @@ void paletteLoadFromDisk(void) return; } - buildvfs_kfd fil; - if ((fil = kopen4load("palette.dat", 0)) == buildvfs_kfd_invalid) + auto fil = kopenFileReader("palette.dat", 0); + if (!fil.isOpen()) return; // PALETTE_MAIN - if (kread_and_test(fil, palette, 768)) - return kclose(fil); + if (768 != fil.Read(palette, 768)) + return; for (unsigned char & k : palette) k <<= 2; @@ -226,15 +231,16 @@ void paletteLoadFromDisk(void) // PALETTE_SHADES - if (kread_and_test(fil, &numshades, 2)) - return kclose(fil); + if (2 != fil.Read(&numshades, 2)) + return; + numshades = B_LITTLE16(numshades); if (numshades <= 1) { initprintf("Warning: Invalid number of shades in \"palette.dat\"!\n"); numshades = 0; - return kclose(fil); + return; } // Auto-detect LameDuke. Its PALETTE.DAT doesn't have a 'numshades' 16-bit @@ -247,15 +253,15 @@ void paletteLoadFromDisk(void) static char const * const seekfail = "Warning: klseek() failed in loadpalette()!\n"; uint16_t temp; - if (kread_and_test(fil, &temp, 2)) - return kclose(fil); + if (read_and_test(fil, &temp, 2)) + return; temp = B_LITTLE16(temp); if (temp == 770 || numshades > 256) // 02 03 { - if (klseek(fil, -4, BSEEK_CUR) < 0) + if (fil.Seek(-4, FileReader::SeekCur) < 0) { initputs(seekfail); - return kclose(fil); + return; } numshades = 32; @@ -263,18 +269,18 @@ void paletteLoadFromDisk(void) } else { - if (klseek(fil, -2, BSEEK_CUR) < 0) + if (fil.Seek(-2, FileReader::SeekCur) < 0) { initputs(seekfail); - return kclose(fil); + return; } } } // Read base shade table (palookup 0). maybe_alloc_palookup(0); - if (kread_and_test(fil, palookup[0], numshades<<8)) - return kclose(fil); + if (read_and_test(fil, palookup[0], numshades<<8)) + return; paletteloaded |= PALETTE_SHADE; @@ -292,8 +298,8 @@ void paletteLoadFromDisk(void) // Read the entries above and on the diagonal, if the table is // thought as being row-major. - if (kread_and_test(fil, &transluc[256*i + i], 256-i-1)) - return kclose(fil); + if (read_and_test(fil, &transluc[256*i + i], 256-i-1)) + return; // Duplicate the entries below the diagonal. for (bssize_t j=0; j= 1 && lognumalphatabs <= 7)) initprintf("invalid lognumalphatabs value, must be in [1 .. 7]\n"); @@ -356,8 +362,6 @@ void paletteLoadFromDisk(void) numalphatabs = 1<: kopen4load file handle +// : open file handle // // Returns: // - on success, 0 diff --git a/source/build/src/sdlayer.cpp b/source/build/src/sdlayer.cpp index e4fce5ffb..848736bf3 100644 --- a/source/build/src/sdlayer.cpp +++ b/source/build/src/sdlayer.cpp @@ -820,33 +820,29 @@ static SDL_GameController *controller = NULL; static void LoadSDLControllerDB() { - buildvfs_kfd fh = kopen4load("gamecontrollerdb.txt", 0); - if (fh == buildvfs_kfd_invalid) + auto fh = fopenFileReader("gamecontrollerdb.txt", 0); + if (!fh.isOpen()) return; - int flen = kfilelength(fh); + int flen = fh.GetLength(); if (flen <= 0) { - kclose(fh); return; } char * dbuf = (char *)malloc(flen + 1); if (!dbuf) { - kclose(fh); return; } - if (kread_and_test(fh, dbuf, flen)) + if (fh.Read(dbuf, flen) != flen) { free(dbuf); - kclose(fh); return; } dbuf[flen] = '\0'; - kclose(fh); SDL_RWops * rwops = SDL_RWFromConstMem(dbuf, flen); if (!rwops) diff --git a/source/build/src/voxmodel.cpp b/source/build/src/voxmodel.cpp index 55ffcbec3..fbe9d3588 100644 --- a/source/build/src/voxmodel.cpp +++ b/source/build/src/voxmodel.cpp @@ -594,14 +594,14 @@ static void alloc_vbit(void) memset(vbit, 0, i); } -static void read_pal(buildvfs_kfd fil, int32_t pal[256]) +static void read_pal(FileReader &fil, int32_t pal[256]) { - klseek(fil, -768, SEEK_END); + fil.Seek(-768, FileReader::SeekEnd); for (bssize_t i=0; i<256; i++) { char c[3]; - kread(fil, c, 3); + fil.Read(c, 3); //#if B_BIG_ENDIAN != 0 pal[i] = B_LITTLE32((c[0]<<18) + (c[1]<<10) + (c[2]<<2) + (i<<24)); //#endif @@ -610,11 +610,11 @@ static void read_pal(buildvfs_kfd fil, int32_t pal[256]) static int32_t loadvox(const char *filnam) { - const buildvfs_kfd fil = kopen4load(filnam, 0); - if (fil == buildvfs_kfd_invalid) - return -1; + auto fil = kopenFileReader(filnam, 0); + if (!fil.isOpen()) + return -1; - kread(fil, &voxsiz, sizeof(vec3_t)); + fil.Read(&voxsiz, sizeof(vec3_t)); #if B_BIG_ENDIAN != 0 voxsiz.x = B_LITTLE32(voxsiz.x); voxsiz.y = B_LITTLE32(voxsiz.y); @@ -634,11 +634,11 @@ static int32_t loadvox(const char *filnam) char *const tbuf = (char *)Xmalloc(voxsiz.z*sizeof(uint8_t)); - klseek(fil, 12, SEEK_SET); + fil.Seek(12, FileReader::SeekSet); for (bssize_t x=0; x=0; z--) if (tbuf[z] != 255) @@ -648,11 +648,11 @@ static int32_t loadvox(const char *filnam) } } - klseek(fil, 12, SEEK_SET); + fil.Seek(12, FileReader::SeekSet); for (bssize_t x=0; x=0; i--) xyoffs[i] = B_LITTLE16(xyoffs[i]); @@ -724,13 +723,12 @@ static int32_t loadkvx(const char *filnam) vcolhashsizm1--; //approx to numvoxs! alloc_vcolhashead(); - klseek(fil, 28+((voxsiz.x+1)<<2)+((ysizp1*voxsiz.x)<<1), SEEK_SET); + fil.Seek(28+((voxsiz.x+1)<<2)+((ysizp1*voxsiz.x)<<1), FileReader::SeekSet); - i = kfilelength(fil)-ktell(fil); + i = fil.GetLength() - fil.Tell(); char *const tbuf = (char *)Xmalloc(i); - kread(fil, tbuf, i); - kclose(fil); + fil.Read(tbuf, i); char *cptr = tbuf; @@ -772,38 +770,37 @@ static int32_t loadkv6(const char *filnam) { int32_t i; - const buildvfs_kfd fil = kopen4load(filnam, 0); - if (fil == buildvfs_kfd_invalid) + auto fil = kopenFileReader(filnam, 0); + if (!fil.isOpen()) return -1; - kread(fil, &i, 4); + fil.Read(&i, 4); if (B_LITTLE32(i) != 0x6c78764b) { - kclose(fil); return -1; } //Kvxl - kread(fil, &voxsiz, sizeof(vec3_t)); + fil.Read(&voxsiz, sizeof(vec3_t)); #if B_BIG_ENDIAN != 0 voxsiz.x = B_LITTLE32(voxsiz.x); voxsiz.y = B_LITTLE32(voxsiz.y); voxsiz.z = B_LITTLE32(voxsiz.z); #endif - kread(fil, &i, 4); voxpiv.x = (float)B_LITTLE32(i); - kread(fil, &i, 4); voxpiv.y = (float)B_LITTLE32(i); - kread(fil, &i, 4); voxpiv.z = (float)B_LITTLE32(i); + fil.Read(&i, 4); voxpiv.x = (float)B_LITTLE32(i); + fil.Read(&i, 4); voxpiv.y = (float)B_LITTLE32(i); + fil.Read(&i, 4); voxpiv.z = (float)B_LITTLE32(i); int32_t numvoxs; - kread(fil, &numvoxs, 4); numvoxs = B_LITTLE32(numvoxs); + fil.Read(&numvoxs, 4); numvoxs = B_LITTLE32(numvoxs); uint16_t *const ylen = (uint16_t *)Xmalloc(voxsiz.x*voxsiz.y*sizeof(int16_t)); - klseek(fil, 32+(numvoxs<<3)+(voxsiz.x<<2), SEEK_SET); - kread(fil, ylen, voxsiz.x*voxsiz.y*sizeof(int16_t)); + fil.Seek(32+(numvoxs<<3)+(voxsiz.x<<2), FileReader::SeekSet); + fil.Read(ylen, voxsiz.x*voxsiz.y*sizeof(int16_t)); for (i=voxsiz.x*voxsiz.y-1; i>=0; i--) ylen[i] = B_LITTLE16(ylen[i]); - klseek(fil, 32, SEEK_SET); + fil.Seek(32, FileReader::SeekSet); alloc_vbit(); @@ -822,7 +819,7 @@ static int32_t loadkv6(const char *filnam) for (i=ylen[x*voxsiz.y+y]; i>0; i--) { char c[8]; - kread(fil, c, 8); //b,g,r,a,z_lo,z_hi,vis,dir + fil.Read(c, 8); //b,g,r,a,z_lo,z_hi,vis,dir const int32_t z0 = B_LITTLE16(B_UNBUF16(&c[4])); @@ -837,7 +834,6 @@ static int32_t loadkv6(const char *filnam) } Xfree(ylen); - kclose(fil); return 0; }