int VorbisStreamSeek(void* datasource, ogg_int64_t offset, int whence) { CFileHandler* buffer = static_cast<CFileHandler*>(datasource); if (whence == SEEK_SET) { buffer->Seek(offset, std::ios_base::beg); } else if (whence == SEEK_CUR) { buffer->Seek(offset, std::ios_base::cur); } else if (whence == SEEK_END) { buffer->Seek(offset, std::ios_base::end); } return 0; }
CBFGroundTextures::CBFGroundTextures(CSmfReadMap *rm) { CFileHandler *ifs = rm->ifs; map = rm; numBigTexX=gs->mapx/128; numBigTexY=gs->mapy/128; MapHeader* header=&map->header; ifs->Seek(header->tilesPtr); tileSize = header->tilesize; MapTileHeader tileHeader; READPTR_MAPTILEHEADER(tileHeader,ifs); tileMap = SAFE_NEW int[(header->mapx*header->mapy)/16]; tiles = SAFE_NEW char[tileHeader.numTiles*SMALL_TILE_SIZE]; int curTile=0; for(int a=0;a<tileHeader.numTileFiles;++a){ PrintLoadMsg("Loading tile file"); int size; ifs->Read(&size,4); size = swabdword(size); string name; while(true){ char ch; ifs->Read(&ch,1); /* char, no swab */ if(ch==0) break; name+=ch; } name=string("maps/")+name; CFileHandler tileFile(name); if(!tileFile.FileExists()){ logOutput.Print("Couldnt find tile file %s",name.c_str()); memset(&tiles[curTile*SMALL_TILE_SIZE],0xaa,size*SMALL_TILE_SIZE); curTile+=size; continue; } PrintLoadMsg("Reading tiles"); TileFileHeader tfh; READ_TILEFILEHEADER(tfh,tileFile); if(strcmp(tfh.magic,"spring tilefile")!=0 || tfh.version!=1 || tfh.tileSize!=32 || tfh.compressionType!=1){ char t[500]; sprintf(t,"Error couldnt open tile file %s",name.c_str()); handleerror(0,t,"Error when reading tile file",0); exit(0); } for(int b=0;b<size;++b){ tileFile.Read(&tiles[curTile*SMALL_TILE_SIZE],SMALL_TILE_SIZE); curTile++; } } PrintLoadMsg("Reading tile map"); int count = (header->mapx*header->mapy)/16; ifs->Read(tileMap, count*sizeof(int)); for (int i = 0; i < count; i++) { tileMap[i] = swabdword(tileMap[i]); } tileMapXSize = header->mapx/4; tileMapYSize = header->mapy/4; squares=SAFE_NEW GroundSquare[numBigTexX*numBigTexY]; for(int y=0;y<numBigTexY;++y){ for(int x=0;x<numBigTexX;++x){ GroundSquare* square=&squares[y*numBigTexX+x]; square->texLevel=1; square->lastUsed=-100; LoadSquare(x,y,2); } } inRead=false; }