1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-07-03 14:34:34 +00:00

ttvfs related cleanups

This commit is contained in:
fgenesis 2014-04-15 19:48:06 +02:00
parent 3cf3ac7659
commit f69d88b656
7 changed files with 69 additions and 56 deletions

View file

@ -45,6 +45,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <sys/stat.h> #include <sys/stat.h>
#endif #endif
#ifdef BBGE_BUILD_VFS
#include "ttvfs.h"
#endif
#ifdef BBGE_BUILD_UNIX #ifdef BBGE_BUILD_UNIX
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -2124,14 +2128,20 @@ void DSQ::loadMods()
{ {
modEntries.clear(); modEntries.clear();
#ifdef BBGE_BUILD_VFS std::string modpath = mod.getBaseModPath();
debugLog("loadMods: " + modpath);
#ifdef BBGE_BUILD_VFS
// first load the packages, then enumerate XMLs // first load the packages, then enumerate XMLs
forEachFile(mod.getBaseModPath(), ".aqmod", loadModPackagesCallback, 0); forEachFile(modpath, ".aqmod", loadModPackagesCallback, 0);
#endif #endif
forEachFile(mod.getBaseModPath(), ".xml", loadModsCallback, 0); forEachFile(modpath, ".xml", loadModsCallback, 0);
selectedMod = 0; selectedMod = 0;
std::ostringstream os;
os << "loadMods done, " << modEntries.size() << " entries";
debugLog(os.str());
} }
void DSQ::applyPatches() void DSQ::applyPatches()
@ -2139,11 +2149,8 @@ void DSQ::applyPatches()
#ifndef AQUARIA_DEMO #ifndef AQUARIA_DEMO
#ifdef BBGE_BUILD_VFS #ifdef BBGE_BUILD_VFS
// This is to allow files in patches to override files in mods on non-win32 systems (theoretically) // This is to allow files in patches to override files in mods on non-win32 systems
if(!vfs.GetDir("_mods"))
{
vfs.Mount(mod.getBaseModPath().c_str(), "_mods"); vfs.Mount(mod.getBaseModPath().c_str(), "_mods");
}
loadMods(); loadMods();
@ -2204,6 +2211,7 @@ void DSQ::refreshResourcesForPatch(const std::string& name)
os << "refreshResourcesForPatch - " << files.size() << " to refresh"; os << "refreshResourcesForPatch - " << files.size() << " to refresh";
debugLog(os.str()); debugLog(os.str());
int reloaded = 0;
if(files.size()) if(files.size())
{ {
for(int i = 0; i < dsq->resources.size(); ++i) for(int i = 0; i < dsq->resources.size(); ++i)
@ -2213,6 +2221,9 @@ void DSQ::refreshResourcesForPatch(const std::string& name)
r->reload(); r->reload();
} }
} }
os.str("");
os << "refreshResourcesForPatch - " << reloaded << " textures reloaded";
debugLog(os.str());
} }
#else #else
void DSQ::refreshResourcesForPatch(const std::string& name) {} void DSQ::refreshResourcesForPatch(const std::string& name) {}

View file

@ -7,6 +7,7 @@
#include "ModSelector.h" #include "ModSelector.h"
#include "Network.h" #include "Network.h"
#include "tinyxml.h" #include "tinyxml.h"
#include "ttvfs.h"
using Network::NetEvent; using Network::NetEvent;
using Network::NE_ABORT; using Network::NE_ABORT;

View file

@ -44,6 +44,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <assert.h> #include <assert.h>
#ifdef BBGE_BUILD_VFS #ifdef BBGE_BUILD_VFS
#include "ttvfs.h"
ttvfs::Root vfs; // extern ttvfs::Root vfs; // extern
#endif #endif

View file

@ -295,6 +295,7 @@ void triggerBreakpoint();
bool createDir(const std::string& d); bool createDir(const std::string& d);
#ifdef BBGE_BUILD_VFS #ifdef BBGE_BUILD_VFS
namespace ttvfs { class Root; }
extern ttvfs::Root vfs; // in Base.cpp extern ttvfs::Root vfs; // in Base.cpp
#endif #endif

View file

@ -57,6 +57,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Vector unchange; Vector unchange;
#endif #endif
#ifdef BBGE_BUILD_VFS
#include "ttvfs.h"
#endif
Core *core = 0; Core *core = 0;
#ifdef BBGE_BUILD_WINDOWS #ifdef BBGE_BUILD_WINDOWS

View file

@ -136,22 +136,17 @@ FMOD_RESULT F_CALLBACK myopen(const char *name, int unicode, unsigned int *files
{ {
if (name) if (name)
{ {
VFILE *fp; VFILE *fp = vfopen(name, "rb");
fp = vfopen(name, "rb");
if (!fp) if (!fp)
return FMOD_ERR_FILE_NOTFOUND;
size_t sz = 0;
if(vfsize(fp, &sz) < 0)
{ {
vfclose(fp);
return FMOD_ERR_FILE_NOTFOUND; return FMOD_ERR_FILE_NOTFOUND;
} }
#ifdef BBGE_BUILD_VFS *filesize = (unsigned int)sz;
*filesize = fp->size();
#else
vfseek(fp, 0, SEEK_END);
*filesize = ftell(fp);
vfseek(fp, 0, SEEK_SET);
#endif
*userdata = (void *)0x12345678; *userdata = (void *)0x12345678;
*handle = fp; *handle = fp;
} }

View file

@ -67,7 +67,7 @@ void Root::Clear()
void Root::Mount(const char *src, const char *dest) void Root::Mount(const char *src, const char *dest)
{ {
return AddVFSDir(GetDir(src, true), dest); AddVFSDir(GetDir(src, true), dest);
} }
void Root::AddVFSDir(DirBase *dir, const char *subdir /* = NULL */) void Root::AddVFSDir(DirBase *dir, const char *subdir /* = NULL */)