mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2024-12-25 06:05:45 +00:00
ttvfs related cleanups
This commit is contained in:
parent
3cf3ac7659
commit
f69d88b656
7 changed files with 69 additions and 56 deletions
|
@ -45,6 +45,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#ifdef BBGE_BUILD_VFS
|
||||
#include "ttvfs.h"
|
||||
#endif
|
||||
|
||||
#ifdef BBGE_BUILD_UNIX
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -2124,14 +2128,20 @@ void DSQ::loadMods()
|
|||
{
|
||||
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
|
||||
forEachFile(mod.getBaseModPath(), ".aqmod", loadModPackagesCallback, 0);
|
||||
forEachFile(modpath, ".aqmod", loadModPackagesCallback, 0);
|
||||
#endif
|
||||
|
||||
forEachFile(mod.getBaseModPath(), ".xml", loadModsCallback, 0);
|
||||
forEachFile(modpath, ".xml", loadModsCallback, 0);
|
||||
selectedMod = 0;
|
||||
|
||||
std::ostringstream os;
|
||||
os << "loadMods done, " << modEntries.size() << " entries";
|
||||
debugLog(os.str());
|
||||
}
|
||||
|
||||
void DSQ::applyPatches()
|
||||
|
@ -2139,11 +2149,8 @@ void DSQ::applyPatches()
|
|||
#ifndef AQUARIA_DEMO
|
||||
#ifdef BBGE_BUILD_VFS
|
||||
|
||||
// This is to allow files in patches to override files in mods on non-win32 systems (theoretically)
|
||||
if(!vfs.GetDir("_mods"))
|
||||
{
|
||||
vfs.Mount(mod.getBaseModPath().c_str(), "_mods");
|
||||
}
|
||||
// This is to allow files in patches to override files in mods on non-win32 systems
|
||||
vfs.Mount(mod.getBaseModPath().c_str(), "_mods");
|
||||
|
||||
loadMods();
|
||||
|
||||
|
@ -2204,6 +2211,7 @@ void DSQ::refreshResourcesForPatch(const std::string& name)
|
|||
os << "refreshResourcesForPatch - " << files.size() << " to refresh";
|
||||
debugLog(os.str());
|
||||
|
||||
int reloaded = 0;
|
||||
if(files.size())
|
||||
{
|
||||
for(int i = 0; i < dsq->resources.size(); ++i)
|
||||
|
@ -2213,6 +2221,9 @@ void DSQ::refreshResourcesForPatch(const std::string& name)
|
|||
r->reload();
|
||||
}
|
||||
}
|
||||
os.str("");
|
||||
os << "refreshResourcesForPatch - " << reloaded << " textures reloaded";
|
||||
debugLog(os.str());
|
||||
}
|
||||
#else
|
||||
void DSQ::refreshResourcesForPatch(const std::string& name) {}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "ModSelector.h"
|
||||
#include "Network.h"
|
||||
#include "tinyxml.h"
|
||||
#include "ttvfs.h"
|
||||
|
||||
using Network::NetEvent;
|
||||
using Network::NE_ABORT;
|
||||
|
|
|
@ -44,6 +44,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include <assert.h>
|
||||
|
||||
#ifdef BBGE_BUILD_VFS
|
||||
#include "ttvfs.h"
|
||||
ttvfs::Root vfs; // extern
|
||||
#endif
|
||||
|
||||
|
|
|
@ -295,6 +295,7 @@ void triggerBreakpoint();
|
|||
bool createDir(const std::string& d);
|
||||
|
||||
#ifdef BBGE_BUILD_VFS
|
||||
namespace ttvfs { class Root; }
|
||||
extern ttvfs::Root vfs; // in Base.cpp
|
||||
#endif
|
||||
|
||||
|
|
|
@ -57,6 +57,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
Vector unchange;
|
||||
#endif
|
||||
|
||||
#ifdef BBGE_BUILD_VFS
|
||||
#include "ttvfs.h"
|
||||
#endif
|
||||
|
||||
Core *core = 0;
|
||||
|
||||
#ifdef BBGE_BUILD_WINDOWS
|
||||
|
|
|
@ -134,73 +134,68 @@ using namespace SoundCore;
|
|||
|
||||
FMOD_RESULT F_CALLBACK myopen(const char *name, int unicode, unsigned int *filesize, void **handle, void **userdata)
|
||||
{
|
||||
if (name)
|
||||
{
|
||||
VFILE *fp;
|
||||
if (name)
|
||||
{
|
||||
VFILE *fp = vfopen(name, "rb");
|
||||
if (!fp)
|
||||
return FMOD_ERR_FILE_NOTFOUND;
|
||||
size_t sz = 0;
|
||||
if(vfsize(fp, &sz) < 0)
|
||||
{
|
||||
vfclose(fp);
|
||||
return FMOD_ERR_FILE_NOTFOUND;
|
||||
}
|
||||
|
||||
fp = vfopen(name, "rb");
|
||||
if (!fp)
|
||||
{
|
||||
return FMOD_ERR_FILE_NOTFOUND;
|
||||
}
|
||||
*filesize = (unsigned int)sz;
|
||||
*userdata = (void *)0x12345678;
|
||||
*handle = fp;
|
||||
}
|
||||
|
||||
#ifdef BBGE_BUILD_VFS
|
||||
*filesize = fp->size();
|
||||
#else
|
||||
vfseek(fp, 0, SEEK_END);
|
||||
*filesize = ftell(fp);
|
||||
vfseek(fp, 0, SEEK_SET);
|
||||
#endif
|
||||
|
||||
*userdata = (void *)0x12345678;
|
||||
*handle = fp;
|
||||
}
|
||||
|
||||
return FMOD_OK;
|
||||
return FMOD_OK;
|
||||
}
|
||||
|
||||
FMOD_RESULT F_CALLBACK myclose(void *handle, void *userdata)
|
||||
{
|
||||
if (!handle)
|
||||
{
|
||||
return FMOD_ERR_INVALID_PARAM;
|
||||
}
|
||||
if (!handle)
|
||||
{
|
||||
return FMOD_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
vfclose((VFILE *)handle);
|
||||
vfclose((VFILE *)handle);
|
||||
|
||||
return FMOD_OK;
|
||||
return FMOD_OK;
|
||||
}
|
||||
|
||||
FMOD_RESULT F_CALLBACK myread(void *handle, void *buffer, unsigned int sizebytes, unsigned int *bytesread, void *userdata)
|
||||
{
|
||||
if (!handle)
|
||||
{
|
||||
return FMOD_ERR_INVALID_PARAM;
|
||||
}
|
||||
if (!handle)
|
||||
{
|
||||
return FMOD_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (bytesread)
|
||||
{
|
||||
*bytesread = (int)vfread(buffer, 1, sizebytes, (VFILE *)handle);
|
||||
|
||||
if (*bytesread < sizebytes)
|
||||
{
|
||||
return FMOD_ERR_FILE_EOF;
|
||||
}
|
||||
}
|
||||
if (bytesread)
|
||||
{
|
||||
*bytesread = (int)vfread(buffer, 1, sizebytes, (VFILE *)handle);
|
||||
|
||||
return FMOD_OK;
|
||||
if (*bytesread < sizebytes)
|
||||
{
|
||||
return FMOD_ERR_FILE_EOF;
|
||||
}
|
||||
}
|
||||
|
||||
return FMOD_OK;
|
||||
}
|
||||
|
||||
FMOD_RESULT F_CALLBACK myseek(void *handle, unsigned int pos, void *userdata)
|
||||
{
|
||||
if (!handle)
|
||||
{
|
||||
return FMOD_ERR_INVALID_PARAM;
|
||||
}
|
||||
if (!handle)
|
||||
{
|
||||
return FMOD_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
vfseek((VFILE *)handle, pos, SEEK_SET);
|
||||
vfseek((VFILE *)handle, pos, SEEK_SET);
|
||||
|
||||
return FMOD_OK;
|
||||
return FMOD_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ void Root::Clear()
|
|||
|
||||
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 */)
|
||||
|
|
Loading…
Reference in a new issue