mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-07-03 06:24:32 +00:00
Fix problems with loading saves after saving over them.
This was caused by the VFS caching file sizes, and not noticing that the file size had changed, which confused zlib because the data stream ended too early.
This commit is contained in:
parent
6d92cd24c8
commit
8f2279e28a
4 changed files with 27 additions and 29 deletions
|
@ -458,9 +458,9 @@ char *readFile(const std::string& path, unsigned long *size_ret)
|
|||
VFILE *vf = vfs.GetFile(path.c_str());
|
||||
if (!vf)
|
||||
return NULL;
|
||||
fileSize = vf->size();
|
||||
char *buffer = (char*)vf->getBuf(NULL, NULL);
|
||||
vf->dropBuf(false);
|
||||
fileSize = vf->size();
|
||||
vf->dropBuf(false); // unlink buffer from file
|
||||
#else
|
||||
FILE *f = fopen(path.c_str(), "rb");
|
||||
if (!f)
|
||||
|
@ -1128,6 +1128,8 @@ char *readCompressedFile(std::string path, unsigned long *size_ret)
|
|||
{
|
||||
unsigned long size = 0;
|
||||
char *buf = readFile(path, &size);
|
||||
if(!buf)
|
||||
return NULL;
|
||||
ZlibCompressor z; // allocates with new[] by default
|
||||
z.init(buf, size, ByteBuffer::TAKE_OVER);
|
||||
z.Compressed(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue