From 51657e10769faa2617d546a06c42e4c62a19bb50 Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 30 Jan 2022 17:41:24 +0100 Subject: Removed trailing whitespace all over the place --- Stars45/Archive.cpp | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'Stars45/Archive.cpp') diff --git a/Stars45/Archive.cpp b/Stars45/Archive.cpp index 4b6462a..5f96466 100644 --- a/Stars45/Archive.cpp +++ b/Stars45/Archive.cpp @@ -90,7 +90,7 @@ void DataArchive::WriteEntry(int index, BYTE* buf) } else { - err = compress(dirbuf, &header.dir_size_comp, + err = compress(dirbuf, &header.dir_size_comp, (BYTE*) directory, header.nfiles * sizeof(DataEntry)); CHECK_ERR(err, "compress"); @@ -100,11 +100,11 @@ void DataArchive::WriteEntry(int index, BYTE* buf) _write(f, &header, sizeof(DataHeader)); _lseek(f, sizeof(DataHeader) + header.dir_offset, SEEK_SET); _write(f, dirbuf, header.dir_blocks); - + delete [] dirbuf; dirbuf = 0; } - + if (buf && directory && directory[index].size_comp) { _lseek(f, sizeof(DataHeader) + directory[index].offset, SEEK_SET); _write(f, buf, directory[index].size_comp); @@ -169,16 +169,16 @@ void DataArchive::CreateBlockMap() else { ZeroMemory(block_map, nblocks*sizeof(DWORD)); - DWORD first_block = header.dir_offset/BLOCK_SIZE + + DWORD first_block = header.dir_offset/BLOCK_SIZE + (header.dir_offset%BLOCK_SIZE > 0); - + for (j = 0; j < DirBlocks(); j++) block_map[first_block+j] = 1; for (i = 0; i < header.nfiles; i++) { - DWORD first_block = directory[i].offset/BLOCK_SIZE + + DWORD first_block = directory[i].offset/BLOCK_SIZE + (directory[i].offset%BLOCK_SIZE > 0); - + for (j = 0; j < FileBlocks(i); j++) block_map[first_block+j] = i+2; } @@ -195,9 +195,9 @@ int DataArchive::FindDataBlocks(int need) for (start = 0; start < nblocks-need; start++) { for (i = 0; block_map[start+i] == 0 && i < need; i++); - + if (i == need) return start*BLOCK_SIZE; - + start += i; } } @@ -217,11 +217,11 @@ void DataArchive::LoadDatafile(const char* name) ZeroMemory(this, sizeof(DataArchive)); strncpy_s(datafile, name, NAMELEN-1); - FILE* f; + FILE* f; fopen_s(&f, datafile, "rb"); if (f) { fread(&header, sizeof(DataHeader), 1, f); - + if (header.version != VERSION) { Print("ERROR: datafile '%s' invalid version '%d'\n", datafile, header.version); @@ -251,7 +251,7 @@ void DataArchive::LoadDatafile(const char* name) dirbuf, header.dir_size_comp); if (err != Z_OK) ZeroMemory(directory, sizeof(DataEntry) * dirsize); - + delete [] dirbuf; dirbuf = 0; @@ -260,15 +260,15 @@ void DataArchive::LoadDatafile(const char* name) } else { Print("Creating Archive '%s'...\n", datafile); - + header.version = VERSION; header.nfiles = 0; header.dir_blocks = 0; header.dir_size_comp = 0; header.dir_offset = 0; - + nblocks = DirBlocks(); - + delete [] block_map; block_map = 0; } @@ -328,7 +328,7 @@ BYTE* DataArchive::CompressEntry(int i) fclose(f); directory[i].size_orig = len; - + directory[i].size_comp = (int) (len * 1.1); BYTE* cbuf = new(__FILE__,__LINE__) BYTE[directory[i].size_comp]; @@ -429,7 +429,7 @@ int DataArchive::InsertEntry(const char* name) strncpy_s(directory[i].name, path, NAMELEN); directory[i].name[NAMELEN-1] = '\0'; directory[i].size_orig = 1; - + return i; } } @@ -479,16 +479,16 @@ void DataArchive::Insert(const char* name) if (index < 0) { old_dir_blocks = DirBlocks(); old_dir_offset = header.dir_offset; - + index = InsertEntry(name); - + if (index >= (int) header.nfiles) { header.nfiles = index+1; added = 1; } new_dir_blocks = DirBlocks(); - + if (new_dir_blocks > old_dir_blocks) { header.dir_offset = FindDataBlocks(new_dir_blocks); CreateBlockMap(); @@ -501,11 +501,11 @@ void DataArchive::Insert(const char* name) if (index >= 0) { DataEntry& e = directory[index]; - + if (verbose) Print(" Inserting: %-16s ", e.name); BYTE* buf = CompressEntry(index); - + if (!buf) { // this is (almost) unrecoverable, // so we quit before screwing things up: @@ -514,7 +514,7 @@ void DataArchive::Insert(const char* name) } new_blocks = FileBlocks(index); - + // the file is new, or got bigger, // need to find room for the data: if (new_blocks > old_blocks) { @@ -524,7 +524,7 @@ void DataArchive::Insert(const char* name) WriteEntry(index, buf); delete [] buf; - + if (verbose) { int ratio = (int) (100.0 * (double) e.size_comp / (double) e.size_orig); Print("%9d => %9d (%2d%%)\n", e.size_orig, e.size_comp, ratio); @@ -597,9 +597,9 @@ void DataArchive::List() for (DWORD i = 0; i < header.nfiles; i++) { DataEntry& e = directory[i]; int ratio = (int) (100.0 * (double) e.size_comp / (double) e.size_orig); - + printf("%5d %9d %9d %2d%% %s\n", i+1, e.size_orig, e.size_comp, ratio, e.name); //-V576 - + total_orig += e.size_orig; total_comp += e.size_comp; } -- cgit v1.1