X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=dpvsimpledecode.c;h=bd0047050e683e98c09840dae609ca89ebc69a90;hb=d6852834938f79734277cd4fe3f2a34d85e55b83;hp=bdfcf319b0dfaf96aeb592e4af9083e15fe6c634;hpb=b0671fcac8564a24ec6d499c0a574d71d937ea7d;p=xonotic%2Fdarkplaces.git diff --git a/dpvsimpledecode.c b/dpvsimpledecode.c index bdfcf319..bd004705 100644 --- a/dpvsimpledecode.c +++ b/dpvsimpledecode.c @@ -20,7 +20,7 @@ typedef struct { - FILE *file; + qfile_t *file; int endoffile; } hz_bitstream_read_t; @@ -45,9 +45,9 @@ hz_bitstream_readblocks_t; hz_bitstream_read_t *hz_bitstream_read_open(char *filename) { - FILE *file; + qfile_t *file; hz_bitstream_read_t *stream; - if ((file = fopen(filename, "rb"))) + if ((file = FS_Open (filename, "rb", false))) { stream = malloc(sizeof(hz_bitstream_read_t)); memset(stream, 0, sizeof(*stream)); @@ -62,22 +62,11 @@ void hz_bitstream_read_close(hz_bitstream_read_t *stream) { if (stream) { - fclose(stream->file); + FS_Close(stream->file); free(stream); } } -unsigned int hz_bitstream_read_currentbyte(hz_bitstream_read_t *stream) -{ - return ftell(stream->file); -} - -int hz_bitstream_read_seek(hz_bitstream_read_t *stream, unsigned int position) -{ - stream->endoffile = 0; - return fseek(stream->file, position, SEEK_SET) != 0; -} - hz_bitstream_readblocks_t *hz_bitstream_read_blocks_new(void) { hz_bitstream_readblocks_t *blocks; @@ -133,7 +122,7 @@ int hz_bitstream_read_blocks_read(hz_bitstream_readblocks_t *blocks, hz_bitstrea else b->size = s; s -= b->size; - if (fread(b->data, 1, b->size, stream->file) != b->size) + if (FS_Read(stream->file, b->data, b->size) != b->size) { stream->endoffile = 1; break; @@ -178,7 +167,7 @@ int hz_bitstream_read_bit(hz_bitstream_readblocks_t *blocks) return (blocks->store >> blocks->count) & 1; } -unsigned int hz_bitstream_read_bits(hz_bitstream_readblocks_t *blocks, unsigned int size) +unsigned int hz_bitstream_read_bits(hz_bitstream_readblocks_t *blocks, int size) { unsigned int num = 0; // we can only handle about 24 bits at a time safely