diff options
| author | Joel de Vahl <joel@stalverk80.se> | 2008-10-06 16:44:34 +0000 |
|---|---|---|
| committer | Joel de Vahl <joel@stalverk80.se> | 2008-10-06 16:44:34 +0000 |
| commit | d1b55351ccc2252917ad494b74bb6ad562df34ce (patch) | |
| tree | c797ff1df77593bd8d36ddf41c235f65a5508b30 /src/engine/e_datafile.c | |
| parent | 78d129c0519166f8ab2e84acbccc3f604ed70b0b (diff) | |
| download | zcatch-d1b55351ccc2252917ad494b74bb6ad562df34ce.tar.gz zcatch-d1b55351ccc2252917ad494b74bb6ad562df34ce.zip | |
Big endian fix.
Diffstat (limited to 'src/engine/e_datafile.c')
| -rw-r--r-- | src/engine/e_datafile.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/engine/e_datafile.c b/src/engine/e_datafile.c index 8f684827..c0376088 100644 --- a/src/engine/e_datafile.c +++ b/src/engine/e_datafile.c @@ -137,11 +137,16 @@ DATAFILE *datafile_load(const char *filename) } #if defined(CONF_ARCH_ENDIAN_BIG) - swap_endian(df->data, sizeof(int), header.swaplen); + swap_endian(df->data, sizeof(int), header.swaplen / sizeof(int)); #endif - + if(DEBUG) + { + dbg_msg("datafile", "allocsize=%d", allocsize); + dbg_msg("datafile", "readsize=%d", readsize); + dbg_msg("datafile", "swaplen=%d", header.swaplen); dbg_msg("datafile", "item_size=%d", df->header.item_size); + } df->info.item_types = (DATAFILE_ITEM_TYPE *)df->data; df->info.item_offsets = (int *)&df->info.item_types[df->header.num_item_types]; @@ -224,17 +229,17 @@ void *datafile_get_data(DATAFILE *df, int index) unsigned long uncompressed_size = df->info.data_sizes[index]; unsigned long s; - dbg_msg("datafile", "loading data index=%d size=%d", index, datasize); + dbg_msg("datafile", "loading data index=%d size=%d uncompressed=%d", index, datasize, uncompressed_size); df->data_ptrs[index] = (char *)mem_alloc(uncompressed_size, 1); /* read the compressed data */ io_seek(df->file, df->data_start_offset+df->info.data_offsets[index], IOSEEK_START); io_read(df->file, temp, datasize); - + /* decompress the data, TODO: check for errors */ s = uncompressed_size; uncompress((Bytef*)df->data_ptrs[index], &s, (Bytef*)temp, datasize); - + /* clean up the temporary buffers */ mem_free(temp); } @@ -261,7 +266,7 @@ void *datafile_get_data_swapped(DATAFILE *df, int index) return ptr; #if defined(CONF_ARCH_ENDIAN_BIG) - swap_endian(ptr, sizeof(int), size); + swap_endian(ptr, sizeof(int), size / sizeof(int)); #endif return ptr; |