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:
@@ -1,4 +1,5 @@
|
||||
Changes towards version 0.7:
|
||||
- Added --addondir commandline option - Mika
|
||||
- Case insensitive matching when looking for .zip/.uqm/.rmp files - SvdB
|
||||
- Added read-ahead buffering when reading zip index files. - SvdB
|
||||
- Added support for packed ani and font files - Mika
|
||||
|
||||
+52
-9
@@ -72,8 +72,11 @@ INPUT_TEMPLATE input_templates[6];
|
||||
|
||||
static const char *findFileInDirs (const char *locs[], int numLocs,
|
||||
const char *file);
|
||||
static void mountContentDir (uio_Repository *repository,
|
||||
static uio_MountHandle *mountContentDir (uio_Repository *repository,
|
||||
const char *contentPath);
|
||||
static void mountAddonDir (uio_Repository *repository,
|
||||
uio_MountHandle *contentMountHandle, const char *addonDirName);
|
||||
|
||||
static void mountDirZips (uio_MountHandle *contentHandle,
|
||||
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
|
||||
// main()'s argv[0].
|
||||
void
|
||||
prepareContentDir (const char *contentDirName, const char *execFile)
|
||||
prepareContentDir (const char *contentDirName, const char* addonDirName, const char *execFile)
|
||||
{
|
||||
const char *testFile = "version";
|
||||
const char *loc;
|
||||
uio_MountHandle* contentMountHandle;
|
||||
|
||||
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);
|
||||
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__
|
||||
(void) execFile;
|
||||
@@ -309,15 +316,13 @@ prepareMeleeDir (void) {
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
static uio_MountHandle *
|
||||
mountContentDir (uio_Repository *repository, const char *contentPath)
|
||||
{
|
||||
uio_DirHandle *packagesDir, *addonsDir;
|
||||
uio_DirHandle *packagesDir;
|
||||
static uio_AutoMount *autoMount[] = { NULL };
|
||||
uio_MountHandle *contentMountHandle;
|
||||
|
||||
availableAddons = NULL;
|
||||
|
||||
contentMountHandle = uio_mountDir (repository, "/",
|
||||
uio_FSTYPE_STDIO, NULL, NULL, contentPath, autoMount,
|
||||
uio_MOUNT_TOP | uio_MOUNT_RDONLY, NULL);
|
||||
@@ -343,6 +348,44 @@ mountContentDir (uio_Repository *repository, const char *contentPath)
|
||||
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.
|
||||
// the former is the dir 'addons', the latter a directory
|
||||
// in that dir.
|
||||
@@ -355,7 +398,7 @@ mountContentDir (uio_Repository *repository, const char *contentPath)
|
||||
return;
|
||||
}
|
||||
|
||||
mountDirZips (contentMountHandle, addonsDir, "addons");
|
||||
mountDirZips (mountHandle, addonsDir, "addons");
|
||||
|
||||
availableAddons = uio_getDirList (addonsDir, "", "", match_MATCH_PREFIX);
|
||||
if (availableAddons != NULL)
|
||||
@@ -388,7 +431,7 @@ mountContentDir (uio_Repository *repository, const char *contentPath)
|
||||
"not found; addon skipped.", addon);
|
||||
continue;
|
||||
}
|
||||
mountDirZips (contentMountHandle, addonDir, mountname);
|
||||
mountDirZips (mountHandle, addonDir, mountname);
|
||||
uio_closeDir (addonDir);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ typedef struct _input_template {
|
||||
|
||||
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 prepareMeleeDir (void);
|
||||
void prepareSaveDir (void);
|
||||
|
||||
+9
-1
@@ -74,6 +74,7 @@ struct options_struct {
|
||||
const char *configDir;
|
||||
const char *contentDir;
|
||||
const char **addons;
|
||||
const char *addonDir;
|
||||
int numAddons;
|
||||
int gammaSet;
|
||||
float gamma;
|
||||
@@ -124,6 +125,7 @@ main (int argc, char *argv[])
|
||||
/* .configDir = */ NULL,
|
||||
/* .contentDir = */ NULL,
|
||||
/* .addons = */ NULL,
|
||||
/* .addonDir = */ NULL,
|
||||
/* .numAddons = */ 0,
|
||||
/* .gammaSet = */ 0,
|
||||
/* .gamma = */ 0.0f,
|
||||
@@ -437,7 +439,7 @@ main (int argc, char *argv[])
|
||||
speechVolumeScale = options.speechVolumeScale;
|
||||
optAddons = options.addons;
|
||||
|
||||
prepareContentDir (options.contentDir, argv[0]);
|
||||
prepareContentDir (options.contentDir, options.addonDir, argv[0]);
|
||||
prepareMeleeDir ();
|
||||
prepareSaveDir ();
|
||||
#if 0
|
||||
@@ -500,6 +502,7 @@ enum
|
||||
SOUND_OPT,
|
||||
STEREOSFX_OPT,
|
||||
ADDON_OPT,
|
||||
ADDONDIR_OPT,
|
||||
ACCEL_OPT,
|
||||
#ifdef NETPLAY
|
||||
NETHOST1_OPT,
|
||||
@@ -545,6 +548,7 @@ static struct option longOptions[] =
|
||||
{"sound", 1, NULL, SOUND_OPT},
|
||||
{"stereosfx", 0, NULL, STEREOSFX_OPT},
|
||||
{"addon", 1, NULL, ADDON_OPT},
|
||||
{"addondir", 1, NULL, ADDONDIR_OPT},
|
||||
{"accel", 1, NULL, ACCEL_OPT},
|
||||
#ifdef NETPLAY
|
||||
{"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] = NULL;
|
||||
break;
|
||||
case ADDONDIR_OPT:
|
||||
options->addonDir = optarg;
|
||||
break;
|
||||
case ACCEL_OPT:
|
||||
force_platform = PLATFORM_NULL;
|
||||
if (!strcmp (optarg, "mmx"))
|
||||
@@ -1012,6 +1019,7 @@ usage (FILE *out, const struct options_struct *defaultOptions)
|
||||
"FILE)");
|
||||
log_add (log_User, " --addon ADDON (using a specific addon; "
|
||||
"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 "
|
||||
"mixsdl)");
|
||||
log_add (log_User, " --stereosfx (enables positional sound effects, "
|
||||
|
||||
Reference in New Issue
Block a user