Added --addondir commandline option.

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3092 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
gewlitys
2008-10-17 21:48:14 +00:00
parent a40a51cd71
commit 2f7bbc1d5f
4 changed files with 63 additions and 11 deletions
+1
View File
@@ -1,4 +1,5 @@
Changes towards version 0.7: Changes towards version 0.7:
- Added --addondir commandline option - Mika
- Case insensitive matching when looking for .zip/.uqm/.rmp files - SvdB - Case insensitive matching when looking for .zip/.uqm/.rmp files - SvdB
- Added read-ahead buffering when reading zip index files. - SvdB - Added read-ahead buffering when reading zip index files. - SvdB
- Added support for packed ani and font files - Mika - Added support for packed ani and font files - Mika
+52 -9
View File
@@ -72,8 +72,11 @@ INPUT_TEMPLATE input_templates[6];
static const char *findFileInDirs (const char *locs[], int numLocs, static const char *findFileInDirs (const char *locs[], int numLocs,
const char *file); const char *file);
static void mountContentDir (uio_Repository *repository, static uio_MountHandle *mountContentDir (uio_Repository *repository,
const char *contentPath); const char *contentPath);
static void mountAddonDir (uio_Repository *repository,
uio_MountHandle *contentMountHandle, const char *addonDirName);
static void mountDirZips (uio_MountHandle *contentHandle, static void mountDirZips (uio_MountHandle *contentHandle,
uio_DirHandle *dirHandle, const char *mountPoint); uio_DirHandle *dirHandle, const char *mountPoint);
@@ -126,10 +129,11 @@ findFileInDirs (const char *locs[], int numLocs, const char *file)
// execFile is the path to the uqm executable, as acquired through // execFile is the path to the uqm executable, as acquired through
// main()'s argv[0]. // main()'s argv[0].
void void
prepareContentDir (const char *contentDirName, const char *execFile) prepareContentDir (const char *contentDirName, const char* addonDirName, const char *execFile)
{ {
const char *testFile = "version"; const char *testFile = "version";
const char *loc; const char *loc;
uio_MountHandle* contentMountHandle;
if (contentDirName == NULL) if (contentDirName == NULL)
{ {
@@ -176,8 +180,11 @@ prepareContentDir (const char *contentDirName, const char *execFile)
} }
log_add (log_Debug, "Using '%s' as base content dir.", baseContentPath); log_add (log_Debug, "Using '%s' as base content dir.", baseContentPath);
contentMountHandle = mountContentDir (repository, baseContentPath);
mountContentDir (repository, baseContentPath); if (addonDirName)
log_add (log_Debug, "Using '%s' as addon dir.", addonDirName);
mountAddonDir (repository, contentMountHandle, addonDirName);
#ifndef __APPLE__ #ifndef __APPLE__
(void) execFile; (void) execFile;
@@ -309,15 +316,13 @@ prepareMeleeDir (void) {
} }
} }
static void static uio_MountHandle *
mountContentDir (uio_Repository *repository, const char *contentPath) mountContentDir (uio_Repository *repository, const char *contentPath)
{ {
uio_DirHandle *packagesDir, *addonsDir; uio_DirHandle *packagesDir;
static uio_AutoMount *autoMount[] = { NULL }; static uio_AutoMount *autoMount[] = { NULL };
uio_MountHandle *contentMountHandle; uio_MountHandle *contentMountHandle;
availableAddons = NULL;
contentMountHandle = uio_mountDir (repository, "/", contentMountHandle = uio_mountDir (repository, "/",
uio_FSTYPE_STDIO, NULL, NULL, contentPath, autoMount, uio_FSTYPE_STDIO, NULL, NULL, contentPath, autoMount,
uio_MOUNT_TOP | uio_MOUNT_RDONLY, NULL); uio_MOUNT_TOP | uio_MOUNT_RDONLY, NULL);
@@ -343,6 +348,44 @@ mountContentDir (uio_Repository *repository, const char *contentPath)
uio_closeDir (packagesDir); uio_closeDir (packagesDir);
} }
return contentMountHandle;
}
static void
mountAddonDir (uio_Repository *repository, uio_MountHandle *contentMountHandle,
const char *addonDirName)
{
uio_DirHandle *addonsDir;
static uio_AutoMount *autoMount[] = { NULL };
uio_MountHandle *mountHandle;
availableAddons = NULL;
if (addonDirName != NULL)
{
mountHandle = uio_mountDir (repository, "addons",
uio_FSTYPE_STDIO, NULL, NULL, addonDirName, autoMount,
uio_MOUNT_TOP | uio_MOUNT_RDONLY, NULL);
if (mountHandle == NULL)
{
log_add (log_Warning, "Warning: Could not mount addon directory: %s"
";\n\t'--addon' options are ignored.", strerror (errno));
return;
}
}
else
{
mountHandle = contentMountHandle;
}
contentDir = uio_openDir (repository, "/", 0);
if (contentDir == NULL)
{
log_add (log_Fatal, "Fatal error: Could not open content dir: %s",
strerror (errno));
exit (EXIT_FAILURE);
}
// NB: note the difference between addonsDir and addonDir. // NB: note the difference between addonsDir and addonDir.
// the former is the dir 'addons', the latter a directory // the former is the dir 'addons', the latter a directory
// in that dir. // in that dir.
@@ -355,7 +398,7 @@ mountContentDir (uio_Repository *repository, const char *contentPath)
return; return;
} }
mountDirZips (contentMountHandle, addonsDir, "addons"); mountDirZips (mountHandle, addonsDir, "addons");
availableAddons = uio_getDirList (addonsDir, "", "", match_MATCH_PREFIX); availableAddons = uio_getDirList (addonsDir, "", "", match_MATCH_PREFIX);
if (availableAddons != NULL) if (availableAddons != NULL)
@@ -388,7 +431,7 @@ mountContentDir (uio_Repository *repository, const char *contentPath)
"not found; addon skipped.", addon); "not found; addon skipped.", addon);
continue; continue;
} }
mountDirZips (contentMountHandle, addonDir, mountname); mountDirZips (mountHandle, addonDir, mountname);
uio_closeDir (addonDir); uio_closeDir (addonDir);
} }
} }
+1 -1
View File
@@ -66,7 +66,7 @@ typedef struct _input_template {
extern INPUT_TEMPLATE input_templates[6]; extern INPUT_TEMPLATE input_templates[6];
void prepareContentDir (const char *contentDirName, const char *execFile); void prepareContentDir (const char *contentDirName, const char *addonDirName, const char *execFile);
void prepareConfigDir (const char *configDirName); void prepareConfigDir (const char *configDirName);
void prepareMeleeDir (void); void prepareMeleeDir (void);
void prepareSaveDir (void); void prepareSaveDir (void);
+9 -1
View File
@@ -74,6 +74,7 @@ struct options_struct {
const char *configDir; const char *configDir;
const char *contentDir; const char *contentDir;
const char **addons; const char **addons;
const char *addonDir;
int numAddons; int numAddons;
int gammaSet; int gammaSet;
float gamma; float gamma;
@@ -124,6 +125,7 @@ main (int argc, char *argv[])
/* .configDir = */ NULL, /* .configDir = */ NULL,
/* .contentDir = */ NULL, /* .contentDir = */ NULL,
/* .addons = */ NULL, /* .addons = */ NULL,
/* .addonDir = */ NULL,
/* .numAddons = */ 0, /* .numAddons = */ 0,
/* .gammaSet = */ 0, /* .gammaSet = */ 0,
/* .gamma = */ 0.0f, /* .gamma = */ 0.0f,
@@ -437,7 +439,7 @@ main (int argc, char *argv[])
speechVolumeScale = options.speechVolumeScale; speechVolumeScale = options.speechVolumeScale;
optAddons = options.addons; optAddons = options.addons;
prepareContentDir (options.contentDir, argv[0]); prepareContentDir (options.contentDir, options.addonDir, argv[0]);
prepareMeleeDir (); prepareMeleeDir ();
prepareSaveDir (); prepareSaveDir ();
#if 0 #if 0
@@ -500,6 +502,7 @@ enum
SOUND_OPT, SOUND_OPT,
STEREOSFX_OPT, STEREOSFX_OPT,
ADDON_OPT, ADDON_OPT,
ADDONDIR_OPT,
ACCEL_OPT, ACCEL_OPT,
#ifdef NETPLAY #ifdef NETPLAY
NETHOST1_OPT, NETHOST1_OPT,
@@ -545,6 +548,7 @@ static struct option longOptions[] =
{"sound", 1, NULL, SOUND_OPT}, {"sound", 1, NULL, SOUND_OPT},
{"stereosfx", 0, NULL, STEREOSFX_OPT}, {"stereosfx", 0, NULL, STEREOSFX_OPT},
{"addon", 1, NULL, ADDON_OPT}, {"addon", 1, NULL, ADDON_OPT},
{"addondir", 1, NULL, ADDONDIR_OPT},
{"accel", 1, NULL, ACCEL_OPT}, {"accel", 1, NULL, ACCEL_OPT},
#ifdef NETPLAY #ifdef NETPLAY
{"nethost1", 1, NULL, NETHOST1_OPT}, {"nethost1", 1, NULL, NETHOST1_OPT},
@@ -822,6 +826,9 @@ parseOptions (int argc, char *argv[], struct options_struct *options)
options->addons[options->numAddons - 1] = optarg; options->addons[options->numAddons - 1] = optarg;
options->addons[options->numAddons] = NULL; options->addons[options->numAddons] = NULL;
break; break;
case ADDONDIR_OPT:
options->addonDir = optarg;
break;
case ACCEL_OPT: case ACCEL_OPT:
force_platform = PLATFORM_NULL; force_platform = PLATFORM_NULL;
if (!strcmp (optarg, "mmx")) if (!strcmp (optarg, "mmx"))
@@ -1012,6 +1019,7 @@ usage (FILE *out, const struct options_struct *defaultOptions)
"FILE)"); "FILE)");
log_add (log_User, " --addon ADDON (using a specific addon; " log_add (log_User, " --addon ADDON (using a specific addon; "
"may be specified multiple times)"); "may be specified multiple times)");
log_add (log_User, " --addondir=ADDONDIR (directory where addons reside)");
log_add (log_User, " --sound=DRIVER (openal, mixsdl, none; default " log_add (log_User, " --sound=DRIVER (openal, mixsdl, none; default "
"mixsdl)"); "mixsdl)");
log_add (log_User, " --stereosfx (enables positional sound effects, " log_add (log_User, " --stereosfx (enables positional sound effects, "