1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-08-10 16:19:59 +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:
fgenesis 2012-06-01 17:52:19 +02:00
parent 1709503344
commit 6dc1c1e8d1
41 changed files with 2966 additions and 468 deletions

View file

@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "ScriptedEntity.h"
#include "AutoMap.h"
#include "GridRender.h"
#include "DeflateCompressor.h"
#include "../ExternalLibs/tinyxml.h"
@ -870,7 +871,7 @@ void Continuity::loadTreasureData()
std::string line, gfx;
int num, use;
float sz;
std::ifstream in2("data/treasures.txt");
InStream in2("data/treasures.txt");
while (std::getline(in2, line))
{
std::istringstream is(line);
@ -903,7 +904,7 @@ void Continuity::loadIngredientData(const std::string &file)
/*
int num;
std::ifstream in2("data/ingredientdescriptions.txt");
InStream in2("data/ingredientdescriptions.txt");
while (std::getline(in2, line))
{
IngredientDescription desc;
@ -916,7 +917,7 @@ void Continuity::loadIngredientData(const std::string &file)
clearIngredientData();
recipes.clear();
std::ifstream in(file.c_str());
InStream in(file.c_str());
bool recipes = false;
while (std::getline(in, line))
@ -1241,7 +1242,7 @@ void Continuity::loadEatBank()
{
eats.clear();
std::ifstream inf("data/eats.txt");
InStream inf("data/eats.txt");
EatData curData;
std::string read;
@ -2183,7 +2184,7 @@ void Continuity::setActivePet(int flag)
void Continuity::loadPetData()
{
petData.clear();
std::ifstream in("data/pets.txt");
InStream in("data/pets.txt");
std::string read;
while (std::getline(in, read))
{
@ -2469,12 +2470,30 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
doc.InsertEndChild(startData);
// FIXME: Patch TinyXML to write out a string and compress in-memory
std::string fn = core->adjustFilenameCase(getSaveFileName(slot, "aqs"));
FILE *fh = fopen(fn.c_str(), "wb");
if(!fh)
{
debugLog("FAILED TO SAVE GAME");
return;
}
doc.SaveFile(dsq->getSaveDirectory() + "/poot.tmp");
packFile(dsq->getSaveDirectory() + "/poot.tmp", getSaveFileName(slot, "aqs"), 9);
remove((dsq->getSaveDirectory() + "/poot.tmp").c_str());
TiXmlPrinter printer;
doc.Accept( &printer );
const char* xmlstr = printer.CStr();
ZlibCompressor z;
z.init((void*)xmlstr, printer.Size(), ZlibCompressor::REUSE);
z.SetForceCompression(true);
z.Compress(3);
std::ostringstream os;
os << "Writing " << z.size() << " bytes to save file " << fn;
debugLog(os.str());
size_t written = fwrite(z.contents(), 1, z.size(), fh);
if (written != z.size())
{
debugLog("FAILED TO WRITE SAVE FILE COMPLETELY");
}
fclose(fh);
}
std::string Continuity::getSaveFileName(int slot, const std::string &pfix)
@ -2491,7 +2510,7 @@ void Continuity::loadFileData(int slot, TiXmlDocument &doc)
{
unsigned long size = 0;
char *buf = readCompressedFile(teh_file, &size);
if (!doc.LoadMem(buf, size))
if (!buf || !doc.LoadMem(buf, size))
errorLog("Failed to load save data: " + teh_file);
return;
}
@ -3267,7 +3286,7 @@ void Continuity::reset()
health = maxHealth;
speedTypes.clear();
std::ifstream inFile("data/speedtypes.txt");
InStream inFile("data/speedtypes.txt");
int n, spd;
while (inFile >> n)
{