mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-07-03 22:44:32 +00:00
[vfs, #3] All file reading code goes through the VFS now, new mod downloader & mod selector in place. Also a bunch of other stuff. (...)
- HTTP networking support, mods can be downloaded via the builtin downloader. All network activity runs in a seperate thread, which is started as soon as any network activity is requested. - The master server is hard-coded to fg.wzff.de/aqmods/ if not specified otherwise; this setting can be overridden in the config file. - The mod selector screen is now a grid-view for much better navigation; also works with joystick. - VFS code is functionally similar to the old molebox-packed release for win32. The game could also have its data shipped in a Zip file or any other kind of archive. - It is still possible to build without VFS support, but then the mod downloader and soft-patching will not be available. The full commit history can be found here: https://github.com/fgenesis/Aquaria_clean/compare/master...vfs The most important commit messages follow: [...] This replaces all std::ifstream with InStream, and fopen(), ... with vfopen(), ... Some code is #ifdef'd for better performance and less memory-copying. VFILE is defined to whatever type of file is in use: - FILE if BBGE_BUILD_VFS is not defined - tttvfs::VFSFile if it is. Other changes: - [un]packFile() is now unused and obsolete. That code has not been adjusted to use VFILE. - glpng can now load from a memory buffer. - TinyXML uses the VFS for reading operations now. - The rather clunky binary stream loading of glfont2 got replaced with ByteBuffer, which gets its data in one block (necessary to use the VFS without implementing a somewhat STL-compliant std::ifstream replacement.) ------------- Implement loading mods from zip files. ------------- Implement soft-patching game data files. (Replacing textures/audio/... on the fly) ------------- Misc bits: - Extended GUI focus handling a bit - Fixed weirdness in texture loading... not sure but this seems more correct to me. Actually, considering that the texture will have its native size after restarting the game, the lines removed with this commit seem pretty useless.
This commit is contained in:
parent
1709503344
commit
6dc1c1e8d1
41 changed files with 2966 additions and 468 deletions
109
BBGE/Core.cpp
109
BBGE/Core.cpp
|
@ -1252,6 +1252,8 @@ bool Core::isShuttingDown()
|
|||
|
||||
void Core::init()
|
||||
{
|
||||
setupFileAccess();
|
||||
|
||||
flags.set(CF_CLEARBUFFERS);
|
||||
quitNestedMainFlag = false;
|
||||
#ifdef BBGE_BUILD_GLFW
|
||||
|
@ -2880,7 +2882,7 @@ void Core::main(float runTime)
|
|||
*/
|
||||
}
|
||||
|
||||
#if (!defined(_DEBUG) || defined(BBGE_BUILD_UNIX)) && defined(BBGE_BUILD_SDL)
|
||||
#if !defined(_DEBUG) && defined(BBGE_BUILD_SDL)
|
||||
if (verbose) debugLog("checking window active");
|
||||
|
||||
if (lib_graphics && (wasInactive || !settings.runInBackground))
|
||||
|
@ -4078,6 +4080,11 @@ void Core::shutdown()
|
|||
debugLog("OK");
|
||||
#endif
|
||||
|
||||
#ifdef BBGE_BUILD_VFS
|
||||
debugLog("Unload VFS...");
|
||||
vfs.Clear();
|
||||
debugLog("OK");
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
|
@ -4757,3 +4764,103 @@ int Core::tgaSaveSeries(char *filename,
|
|||
// ilutGLScreenie();
|
||||
}
|
||||
|
||||
|
||||
#include "DeflateCompressor.h"
|
||||
|
||||
// saves an array of pixels as a TGA image (frees the image data passed in)
|
||||
int Core::zgaSave( const char *filename,
|
||||
short int w,
|
||||
short int h,
|
||||
unsigned char depth,
|
||||
unsigned char *imageData) {
|
||||
|
||||
ByteBuffer::uint8 type,mode,aux, pixelDepth = depth;
|
||||
ByteBuffer::uint8 cGarbage = 0;
|
||||
ByteBuffer::uint16 iGarbage = 0;
|
||||
ByteBuffer::uint16 width = w, height = h;
|
||||
|
||||
// open file and check for errors
|
||||
FILE *file = fopen(adjustFilenameCase(filename).c_str(), "wb");
|
||||
if (file == NULL) {
|
||||
delete [] imageData;
|
||||
return (int)false;
|
||||
}
|
||||
|
||||
// compute image type: 2 for RGB(A), 3 for greyscale
|
||||
mode = pixelDepth / 8;
|
||||
if ((pixelDepth == 24) || (pixelDepth == 32))
|
||||
type = 2;
|
||||
else
|
||||
type = 3;
|
||||
|
||||
// convert the image data from RGB(A) to BGR(A)
|
||||
if (mode >= 3)
|
||||
for (int i=0; i < width * height * mode ; i+= mode) {
|
||||
aux = imageData[i];
|
||||
imageData[i] = imageData[i+2];
|
||||
imageData[i+2] = aux;
|
||||
}
|
||||
|
||||
ZlibCompressor z;
|
||||
z.SetForceCompression(true);
|
||||
z.reserve(width * height * mode + 30);
|
||||
z << cGarbage
|
||||
<< cGarbage
|
||||
<< type
|
||||
<< iGarbage
|
||||
<< iGarbage
|
||||
<< cGarbage
|
||||
<< iGarbage
|
||||
<< iGarbage
|
||||
<< width
|
||||
<< height
|
||||
<< pixelDepth
|
||||
<< cGarbage;
|
||||
|
||||
z.append(imageData, width * height * mode);
|
||||
z.Compress(3);
|
||||
|
||||
// save the image data
|
||||
if (fwrite(z.contents(), 1, z.size(), file) != z.size())
|
||||
{
|
||||
fclose(file);
|
||||
delete [] imageData;
|
||||
return (int)false;
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
delete [] imageData;
|
||||
|
||||
return (int)true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "ttvfs_zip/VFSZipArchiveLoader.h"
|
||||
|
||||
void Core::setupFileAccess()
|
||||
{
|
||||
#ifdef BBGE_BUILD_VFS
|
||||
debugLog("Init VFS...");
|
||||
|
||||
if(!ttvfs::checkCompat())
|
||||
exit(1);
|
||||
|
||||
vfs.AddArchiveLoader(new ttvfs::VFSZipArchiveLoader);
|
||||
|
||||
if(!vfs.LoadFileSysRoot(false))
|
||||
{
|
||||
errorLog("Failed to setup file access");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
vfs.Prepare();
|
||||
|
||||
// TODO: mount and other stuff
|
||||
|
||||
//vfs.AddArchive("aqfiles.zip", false, "");
|
||||
|
||||
|
||||
debugLog("Done");
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue