Allow addons to override any content by placing zips into their 'shadow-content' dir.

Unzipped files in 'shadow-content' are not currently supported.

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3158 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2009-06-29 05:05:48 +00:00
parent 59288c1085
commit d4f68f3909
4 changed files with 51 additions and 9 deletions
+2
View File
@@ -1,4 +1,6 @@
Changes towards version 0.7:
- Allow addons to override any content by placing zips into their
'shadow-content' dir - Alex
- Content reorg: font chars now use hexadecimal numbering - Alex
- Content reorg: some race comm and ships renamed, ship files renamed,
many ani files renamed, new naming scheme for ani frames and voice - Alex
+46 -8
View File
@@ -77,8 +77,8 @@ static uio_MountHandle *mountContentDir (uio_Repository *repository,
static void mountAddonDir (uio_Repository *repository,
uio_MountHandle *contentMountHandle, const char *addonDirName);
static void mountDirZips (uio_MountHandle *contentHandle,
uio_DirHandle *dirHandle, const char *mountPoint);
static void mountDirZips (uio_DirHandle *dirHandle, const char *mountPoint,
int relativeFlags, uio_MountHandle *relativeHandle);
// Looks for a file 'file' in all 'numLocs' locations from 'locs'.
@@ -344,7 +344,7 @@ mountContentDir (uio_Repository *repository, const char *contentPath)
packagesDir = uio_openDir (repository, "/packages", 0);
if (packagesDir != NULL)
{
mountDirZips (contentMountHandle, packagesDir, "/");
mountDirZips (packagesDir, "/", uio_MOUNT_BELOW, contentMountHandle);
uio_closeDir (packagesDir);
}
@@ -390,7 +390,7 @@ mountAddonDir (uio_Repository *repository, uio_MountHandle *contentMountHandle,
return;
}
mountDirZips (mountHandle, addonsDir, "addons");
mountDirZips (addonsDir, "addons", uio_MOUNT_BELOW, mountHandle);
availableAddons = uio_getDirList (addonsDir, "", "", match_MATCH_PREFIX);
if (availableAddons != NULL)
@@ -423,7 +423,7 @@ mountAddonDir (uio_Repository *repository, uio_MountHandle *contentMountHandle,
"not found; addon skipped.", addon);
continue;
}
mountDirZips (mountHandle, addonDir, mountname);
mountDirZips (addonDir, mountname, uio_MOUNT_BELOW, mountHandle);
uio_closeDir (addonDir);
}
}
@@ -439,7 +439,8 @@ mountAddonDir (uio_Repository *repository, uio_MountHandle *contentMountHandle,
}
static void
mountDirZips (uio_MountHandle *contentHandle, uio_DirHandle *dirHandle, const char *mountPoint)
mountDirZips (uio_DirHandle *dirHandle, const char *mountPoint,
int relativeFlags, uio_MountHandle *relativeHandle)
{
static uio_AutoMount *autoMount[] = { NULL };
uio_DirList *dirList;
@@ -454,8 +455,8 @@ mountDirZips (uio_MountHandle *contentHandle, uio_DirHandle *dirHandle, const ch
{
if (uio_mountDir (repository, mountPoint, uio_FSTYPE_ZIP,
dirHandle, dirList->names[i], "/", autoMount,
uio_MOUNT_BELOW | uio_MOUNT_RDONLY,
contentHandle) == NULL)
relativeFlags | uio_MOUNT_RDONLY,
relativeHandle) == NULL)
{
log_add (log_Warning, "Warning: Could not mount '%s': %s.",
dirList->names[i], strerror (errno));
@@ -520,11 +521,48 @@ loadAddon (const char *addon)
return TRUE;
}
void
prepareShadowAddons (const char **addons)
{
uio_DirHandle *addonsDir;
const char *shadowDirName = "shadow-content";
addonsDir = uio_openDirRelative (contentDir, "addons", 0);
// If anything fails here, it will fail again later, so
// we'll just keep quiet about it for now
if (addonsDir == NULL)
return;
for (; *addons != NULL; addons++)
{
const char *addon = *addons;
uio_DirHandle *addonDir;
uio_DirHandle *shadowDir;
addonDir = uio_openDirRelative (addonsDir, addon, 0);
if (addonDir == NULL)
continue;
// Mount addon's "shadow-content" on top of "/"
shadowDir = uio_openDirRelative (addonDir, shadowDirName, 0);
if (shadowDir)
{
log_add (log_Debug, "Mounting shadow content of '%s' addon", addon);
mountDirZips (shadowDir, "/", uio_MOUNT_TOP, NULL);
uio_closeDir (shadowDir);
}
uio_closeDir (addonDir);
}
uio_closeDir (addonsDir);
}
void
prepareAddons (const char **addons)
{
for (; *addons != NULL; addons++)
{
log_add (log_Info, "Loading addon '%s'", *addons);
if (!loadAddon (*addons))
{
break;
+1
View File
@@ -71,6 +71,7 @@ void prepareConfigDir (const char *configDirName);
void prepareMeleeDir (void);
void prepareSaveDir (void);
void prepareAddons (const char **addons);
void prepareShadowAddons (const char **addons);
BOOLEAN loadAddon (const char *addon);
int loadIndices (uio_DirHandle *baseDir);
+1
View File
@@ -444,6 +444,7 @@ main (int argc, char *argv[])
prepareContentDir (options.contentDir, options.addonDir, argv[0]);
prepareMeleeDir ();
prepareSaveDir ();
prepareShadowAddons (options.addons);
#if 0
initTempDir ();
#endif