From: <av...@us...> - 2009-06-29 05:05:49
|
Revision: 3158 http://sc2.svn.sourceforge.net/sc2/?rev=3158&view=rev Author: avolkov Date: 2009-06-29 05:05:48 +0000 (Mon, 29 Jun 2009) Log Message: ----------- Allow addons to override any content by placing zips into their 'shadow-content' dir. Unzipped files in 'shadow-content' are not currently supported. Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/options.c trunk/sc2/src/options.h trunk/sc2/src/starcon2.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2009-06-28 23:43:08 UTC (rev 3157) +++ trunk/sc2/ChangeLog 2009-06-29 05:05:48 UTC (rev 3158) @@ -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 Modified: trunk/sc2/src/options.c =================================================================== --- trunk/sc2/src/options.c 2009-06-28 23:43:08 UTC (rev 3157) +++ trunk/sc2/src/options.c 2009-06-29 05:05:48 UTC (rev 3158) @@ -77,8 +77,8 @@ 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 @@ 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 @@ 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 @@ "not found; addon skipped.", addon); continue; } - mountDirZips (mountHandle, addonDir, mountname); + mountDirZips (addonDir, mountname, uio_MOUNT_BELOW, mountHandle); uio_closeDir (addonDir); } } @@ -439,7 +439,8 @@ } 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 @@ { 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)); @@ -513,7 +514,7 @@ return FALSE; } - loadIndices (addonDir); + loadIndices (addonDir); uio_closeDir (addonDir); uio_closeDir (addonsDir); @@ -521,10 +522,47 @@ } 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; Modified: trunk/sc2/src/options.h =================================================================== --- trunk/sc2/src/options.h 2009-06-28 23:43:08 UTC (rev 3157) +++ trunk/sc2/src/options.h 2009-06-29 05:05:48 UTC (rev 3158) @@ -71,6 +71,7 @@ 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); Modified: trunk/sc2/src/starcon2.c =================================================================== --- trunk/sc2/src/starcon2.c 2009-06-28 23:43:08 UTC (rev 3157) +++ trunk/sc2/src/starcon2.c 2009-06-29 05:05:48 UTC (rev 3158) @@ -444,6 +444,7 @@ prepareContentDir (options.contentDir, options.addonDir, argv[0]); prepareMeleeDir (); prepareSaveDir (); + prepareShadowAddons (options.addons); #if 0 initTempDir (); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |