1
0
forked from mirrors/0ad

improvements and fixes:

- properly differentiate between buffer/offset alignment and length
alignment (relevant since block size has been increased to 256k)
- use VfsPath for most game paths instead of CStr
- clean up timer interface and implementation
- self-tests no longer crash
- file_cache.cpp: fix for the case where allocation fails (prevent
deleter from seeing a null pointer)
- allocators: move all shared_ptr-related stuff to its own component;
add DummySharedPtr
- codec: disable checksums (important for performance at work)
- File: made into an interface class to avoid export problems. not
entirely sure about this..
- vfs_path.h, path.h, os_path.h: proper fix for using
fs::change_extension and similar utility functions with derivatives of
basic_path
- lib_api: automatically link against import lib if building lib/ as a
DLL
- path_util: remove unused functions (this component is deprecated)
- compiler.h: add INLINE
- Xeromyces.cpp: pass PIVFS so that GetXMBPath works in self-test
(should do this mostly everywhere rather than have one singleton g_VFS)

This was SVN commit r5537.
This commit is contained in:
janwas
2008-01-07 20:03:19 +00:00
parent 3273a8425c
commit a859562ea7
95 changed files with 950 additions and 1030 deletions
+12 -15
View File
@@ -50,7 +50,7 @@ public:
set_logger(NULL); // unregister the log handler
}
bool Convert(const CStr& daeFilename, const CStr& pmdFilename, CColladaManager::FileType type)
bool Convert(const VfsPath& daeFilename, const VfsPath& pmdFilename, CColladaManager::FileType type)
{
// To avoid always loading the DLL when it's usually not going to be
// used (and to do the same on Linux where delay-loading won't help),
@@ -137,7 +137,7 @@ CColladaManager::~CColladaManager()
delete m;
}
CStr CColladaManager::GetLoadableFilename(const CStr& sourceName, FileType type)
VfsPath CColladaManager::GetLoadableFilename(const CStr& sourceName, FileType type)
{
const char* extn = NULL;
switch (type)
@@ -175,11 +175,11 @@ CStr CColladaManager::GetLoadableFilename(const CStr& sourceName, FileType type)
// (TODO: the comments and variable names say "pmd" but actually they can
// be "psa" too.)
CStr dae = sourceName + ".dae";
VfsPath dae(sourceName + ".dae");
if (! FileExists(dae))
{
// No .dae - got to use the .pmd, assuming there is one
return sourceName + extn;
return VfsPath(sourceName + extn);
}
// There is a .dae - see if there's an up-to-date cached copy
@@ -188,8 +188,8 @@ CStr CColladaManager::GetLoadableFilename(const CStr& sourceName, FileType type)
if (g_VFS->GetFileInfo(dae, &fileInfo) < 0)
{
// This shouldn't occur for any sensible reasons
LOG(CLogger::Error, "collada", "Failed to stat DAE file '%s'", dae.c_str());
return "";
LOG(CLogger::Error, "collada", "Failed to stat DAE file '%s'", dae.string().c_str());
return VfsPath();
}
// Build a struct of all the data we want to hash.
@@ -205,20 +205,17 @@ CStr CColladaManager::GetLoadableFilename(const CStr& sourceName, FileType type)
u32 hash = fnv_hash(static_cast<void*>(&hashSource), sizeof(hashSource));
char hashString[9];
sprintf(hashString, "%08x", hash);
std::string extension("_");
extension += hashString;
extension += extn;
// realDaePath is "mods/whatever/art/meshes/whatever.dae"
char realDaePath[PATH_MAX];
Path realDaePath;
g_VFS->GetRealPath(dae, realDaePath);
// cachedPmdVfsPath is "cache/mods/whatever/art/meshes/whatever_{hash}.pmd"
CStr cachedPmdVfsPath = "cache/";
cachedPmdVfsPath += realDaePath;
// Remove the .dae extension (which will certainly be there)
cachedPmdVfsPath = cachedPmdVfsPath.substr(0, cachedPmdVfsPath.length()-4);
// Add a _hash.pmd extension
cachedPmdVfsPath += "_";
cachedPmdVfsPath += hashString;
cachedPmdVfsPath += extn;
VfsPath cachedPmdVfsPath = VfsPath("cache/") / realDaePath.string();
cachedPmdVfsPath = change_extension(cachedPmdVfsPath, extension);
// If it's not in the cache, we'll have to create it first
if (! FileExists(cachedPmdVfsPath))