Major reworking of how addon packs work.
Addon packs now provide additional files instead of overriding UIO. They must provide .rmp files to do the necessary overrides. The addons directory has also been moved outside of packages/ and into content/ directly. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2869 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
+79
-43
@@ -29,6 +29,7 @@
|
||||
#include "libs/uio.h"
|
||||
#include "libs/strlib.h"
|
||||
#include "libs/log.h"
|
||||
#include "libs/reslib.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@@ -45,6 +46,7 @@ int optWhichIntro;
|
||||
int optWhichShield;
|
||||
int optSmoothScroll;
|
||||
int optMeleeScale;
|
||||
const char **optAddons;
|
||||
|
||||
BOOLEAN optSubtitles;
|
||||
BOOLEAN optStereoSFX;
|
||||
@@ -66,9 +68,9 @@ INPUT_TEMPLATE input_templates[6];
|
||||
static const char *findFileInDirs (const char *locs[], int numLocs,
|
||||
const char *file);
|
||||
static void mountContentDir (uio_Repository *repository,
|
||||
const char *contentPath, const char **addons);
|
||||
const char *contentPath);
|
||||
static void mountDirZips (uio_MountHandle *contentHandle,
|
||||
uio_DirHandle *dirHandle);
|
||||
uio_DirHandle *dirHandle, const char *mountPoint);
|
||||
|
||||
|
||||
// Looks for a file 'file' in all 'numLocs' locations from 'locs'.
|
||||
@@ -115,7 +117,7 @@ findFileInDirs (const char *locs[], int numLocs, const char *file)
|
||||
}
|
||||
|
||||
void
|
||||
prepareContentDir (const char *contentDirName, const char **addons)
|
||||
prepareContentDir (const char *contentDirName)
|
||||
{
|
||||
const char *testFile = "version";
|
||||
const char *loc;
|
||||
@@ -151,7 +153,7 @@ prepareContentDir (const char *contentDirName, const char **addons)
|
||||
|
||||
log_add (log_Debug, "Using '%s' as base content dir.", baseContentPath);
|
||||
|
||||
mountContentDir (repository, baseContentPath, addons);
|
||||
mountContentDir (repository, baseContentPath);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -280,10 +282,10 @@ prepareMeleeDir (void) {
|
||||
}
|
||||
|
||||
static void
|
||||
mountContentDir (uio_Repository *repository, const char *contentPath,
|
||||
const char **addons) {
|
||||
mountContentDir (uio_Repository *repository, const char *contentPath)
|
||||
{
|
||||
uio_MountHandle *contentHandle;
|
||||
uio_DirHandle *packagesDir, *addonsDir, *addonDir;
|
||||
uio_DirHandle *packagesDir, *addonsDir;
|
||||
static uio_AutoMount *autoMount[] = { NULL };
|
||||
availableAddons = NULL;
|
||||
|
||||
@@ -306,35 +308,24 @@ mountContentDir (uio_Repository *repository, const char *contentPath,
|
||||
}
|
||||
|
||||
packagesDir = uio_openDir (repository, "/packages", 0);
|
||||
if (packagesDir == NULL)
|
||||
{ // No packages dir means no packages to load.
|
||||
if (addons[0] != NULL)
|
||||
{ // addons were specified, but there's no /packages dir,
|
||||
// let alone a /packages/addons dir.
|
||||
log_add (log_Warning, "Warning: There's no 'packages/addons' "
|
||||
"directory in the 'content' directory;\n\t'--addon' "
|
||||
"options are ignored.");
|
||||
}
|
||||
return;
|
||||
if (packagesDir != NULL)
|
||||
{
|
||||
mountDirZips (contentHandle, packagesDir, "/");
|
||||
uio_closeDir (packagesDir);
|
||||
}
|
||||
|
||||
mountDirZips (contentHandle, packagesDir);
|
||||
|
||||
// NB: note the difference between addonsDir and addonDir.
|
||||
// the former is the dir 'packages/addons', the latter a directory
|
||||
// the former is the dir 'addons', the latter a directory
|
||||
// in that dir.
|
||||
addonsDir = uio_openDirRelative (packagesDir, "addons", 0);
|
||||
addonsDir = uio_openDirRelative (contentDir, "addons", 0);
|
||||
if (addonsDir == NULL)
|
||||
{ // No addon dir found.
|
||||
log_add (log_Warning, "Warning: There's no 'packages/addons' "
|
||||
log_add (log_Warning, "Warning: There's no 'addons' "
|
||||
"directory in the 'content' directory;\n\t'--addon' "
|
||||
"options are ignored.");
|
||||
uio_closeDir (packagesDir);
|
||||
return;
|
||||
}
|
||||
|
||||
uio_closeDir (packagesDir);
|
||||
|
||||
availableAddons = uio_getDirList (addonsDir, "", "", match_MATCH_PREFIX);
|
||||
if (availableAddons != NULL)
|
||||
{
|
||||
@@ -351,8 +342,23 @@ mountContentDir (uio_Repository *repository, const char *contentPath,
|
||||
}
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
log_add (log_Info, " %d. %s", i+1,
|
||||
availableAddons->names[i]);
|
||||
static char mountname[128];
|
||||
uio_DirHandle *addonDir;
|
||||
const char *addon = availableAddons->names[i];
|
||||
log_add (log_Info, " %d. %s", i+1, addon);
|
||||
|
||||
snprintf(mountname, 128, "addons/%s", addon);
|
||||
mountname[127]=0;
|
||||
|
||||
addonDir = uio_openDirRelative (addonsDir, addon, 0);
|
||||
if (addonDir == NULL)
|
||||
{
|
||||
log_add (log_Warning, "Warning: directory 'addons/%s' "
|
||||
"not found; addon skipped.", addon);
|
||||
continue;
|
||||
}
|
||||
mountDirZips (contentHandle, addonDir, mountname);
|
||||
uio_closeDir (addonDir);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -360,26 +366,14 @@ mountContentDir (uio_Repository *repository, const char *contentPath,
|
||||
log_add (log_Info, "0 available addon packs.");
|
||||
}
|
||||
|
||||
for (; *addons != NULL; addons++)
|
||||
{
|
||||
addonDir = uio_openDirRelative (addonsDir, *addons, 0);
|
||||
if (addonDir == NULL)
|
||||
{
|
||||
log_add (log_Warning, "Warning: directory 'packages/addons/%s' "
|
||||
"not found; addon skipped.", *addons);
|
||||
continue;
|
||||
}
|
||||
|
||||
mountDirZips (contentHandle, addonDir);
|
||||
|
||||
uio_closeDir (addonDir);
|
||||
}
|
||||
uio_DirList_free (availableAddons);
|
||||
availableAddons = NULL;
|
||||
|
||||
uio_closeDir (addonsDir);
|
||||
}
|
||||
|
||||
static void
|
||||
mountDirZips (uio_MountHandle *contentHandle, uio_DirHandle *dirHandle)
|
||||
mountDirZips (uio_MountHandle *contentHandle, uio_DirHandle *dirHandle, const char *mountPoint)
|
||||
{
|
||||
static uio_AutoMount *autoMount[] = { NULL };
|
||||
uio_DirList *dirList;
|
||||
@@ -392,7 +386,7 @@ mountDirZips (uio_MountHandle *contentHandle, uio_DirHandle *dirHandle)
|
||||
|
||||
for (i = 0; i < dirList->numNames; i++)
|
||||
{
|
||||
if (uio_mountDir (repository, "/", uio_FSTYPE_ZIP,
|
||||
if (uio_mountDir (repository, mountPoint, uio_FSTYPE_ZIP,
|
||||
dirHandle, dirList->names[i], "/", autoMount,
|
||||
uio_MOUNT_BELOW | uio_MOUNT_RDONLY,
|
||||
contentHandle) == NULL)
|
||||
@@ -405,3 +399,45 @@ mountDirZips (uio_MountHandle *contentHandle, uio_DirHandle *dirHandle)
|
||||
uio_DirList_free (dirList);
|
||||
}
|
||||
|
||||
void
|
||||
prepareAddons (const char **addons)
|
||||
{
|
||||
uio_DirHandle *addonsDir;
|
||||
|
||||
addonsDir = uio_openDirRelative (contentDir, "addons", 0);
|
||||
if (addonsDir == NULL)
|
||||
{ // No addon dir found.
|
||||
log_add (log_Warning, "Warning: There's no 'addons' "
|
||||
"directory in the 'content' directory;\n\t'--addon' "
|
||||
"options are ignored.");
|
||||
return;
|
||||
}
|
||||
for (; *addons != NULL; addons++)
|
||||
{
|
||||
uio_DirList *indices;
|
||||
uio_DirHandle *addonDir;
|
||||
|
||||
addonDir = uio_openDirRelative (addonsDir, *addons, 0);
|
||||
if (addonDir == NULL)
|
||||
{
|
||||
log_add (log_Warning, "Warning: Addon '%s' not found", *addons);
|
||||
continue;
|
||||
}
|
||||
|
||||
indices = uio_getDirList (addonDir, "", ".rmp$",
|
||||
match_MATCH_REGEX);
|
||||
|
||||
if (indices != NULL)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < indices->numNames; i++)
|
||||
{
|
||||
res_LoadFilename (addonDir, indices->names[i]);
|
||||
}
|
||||
}
|
||||
uio_DirList_free (indices);
|
||||
uio_closeDir (addonDir);
|
||||
}
|
||||
uio_closeDir (addonsDir);
|
||||
}
|
||||
|
||||
+3
-1
@@ -50,6 +50,7 @@ extern uio_DirHandle *meleeDir;
|
||||
extern char baseContentPath[PATH_MAX];
|
||||
|
||||
extern uio_DirList *availableAddons;
|
||||
extern const char **optAddons;
|
||||
|
||||
/* These get edited by TEXTENTRY widgets, so they should have room to
|
||||
* hold as much as one of them allows by default. */
|
||||
@@ -64,10 +65,11 @@ typedef struct _input_template {
|
||||
|
||||
extern INPUT_TEMPLATE input_templates[6];
|
||||
|
||||
void prepareContentDir (const char *contentDirName, const char **addons);
|
||||
void prepareContentDir (const char *contentDirName);
|
||||
void prepareConfigDir (const char *configDirName);
|
||||
void prepareMeleeDir (void);
|
||||
void prepareSaveDir (void);
|
||||
void prepareAddons (const char **addons);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -72,16 +72,24 @@ MEM_HANDLE
|
||||
loadResourceDesc (ResourceIndex *idx, ResourceDesc *desc)
|
||||
{
|
||||
RES_TYPE resType = GET_TYPE (desc->res);
|
||||
|
||||
const char *path;
|
||||
|
||||
if (resType >= idx->typeInfo.numTypes ||
|
||||
idx->typeInfo.handlers[resType].loadFun == NULL)
|
||||
{
|
||||
log_add (log_Warning, "Warning: Unable to load '%s'; no handler "
|
||||
"for type %d defined.", desc->path, resType);
|
||||
"for type %d defined.", desc->res_id, resType);
|
||||
return NULL_HANDLE;
|
||||
}
|
||||
|
||||
desc->handle = loadResource (desc->path,
|
||||
path = res_GetString (desc->res_id);
|
||||
if (path == NULL)
|
||||
{
|
||||
log_add (log_Warning, "Could not decode resource '%s'", desc->res_id);
|
||||
return NULL_HANDLE;
|
||||
}
|
||||
|
||||
desc->handle = loadResource (path,
|
||||
idx->typeInfo.handlers[resType].loadFun);
|
||||
return desc->handle;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
typedef struct
|
||||
{
|
||||
RESOURCE res;
|
||||
char *path;
|
||||
char *res_id;
|
||||
MEM_HANDLE handle;
|
||||
//COUNT ref;
|
||||
|
||||
@@ -86,24 +86,14 @@ static ResourceDesc *
|
||||
newResourceDesc (RESOURCE res, char *res_id)
|
||||
{
|
||||
ResourceDesc *result;
|
||||
const char *path;
|
||||
|
||||
result = HMalloc (sizeof (ResourceDesc));
|
||||
if (result == NULL)
|
||||
return NULL;
|
||||
|
||||
path = res_GetString (res_id);
|
||||
if (path == NULL)
|
||||
{
|
||||
log_add (log_Warning, "Could not decode resource '%s'", res_id);
|
||||
HFree (result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// log_add (log_Info, " '%s' -> '%s'.", res_id, path);
|
||||
|
||||
result->res = res;
|
||||
result->path = path;
|
||||
result->res_id = res_id;
|
||||
result->handle = NULL_HANDLE;
|
||||
//result->ref = 0;
|
||||
|
||||
@@ -143,37 +143,8 @@ SetMusicVolume (COUNT Volume)
|
||||
char*
|
||||
CheckMusicResName (char* fileName)
|
||||
{
|
||||
char otherName[256];
|
||||
const char* otherExt;
|
||||
char* curExt;
|
||||
|
||||
if (strlen (fileName) < 4)
|
||||
return fileName;
|
||||
|
||||
strncpy (otherName, fileName, sizeof (otherName) - 1);
|
||||
otherName[sizeof (otherName) - 1] = '\0';
|
||||
|
||||
switch (optWhichMusic)
|
||||
{
|
||||
default:
|
||||
case OPT_3DO:
|
||||
otherExt = "ogg";
|
||||
break;
|
||||
case OPT_PC:
|
||||
otherExt = "mod";
|
||||
break;
|
||||
}
|
||||
|
||||
curExt = otherName + strlen (otherName) - strlen (otherExt);
|
||||
if (strcmp(curExt, otherExt) != 0)
|
||||
{
|
||||
strcpy (curExt, otherExt);
|
||||
if (fileExists2 (contentDir, otherName))
|
||||
strcpy (fileName, otherName);
|
||||
else
|
||||
log_add (log_Warning, "Requested track '%s' not found.", otherName);
|
||||
}
|
||||
|
||||
if (!fileExists2 (contentDir, fileName))
|
||||
log_add (log_Warning, "Requested track '%s' not found.", fileName);
|
||||
return fileName;
|
||||
}
|
||||
|
||||
|
||||
@@ -114,6 +114,17 @@ LoadKernel (int argc, char *argv[])
|
||||
hResIndex = InitResourceSystem ("uqm.rmp", "starcon.ls2", RES_INDEX, NULL);
|
||||
if (hResIndex == 0)
|
||||
return FALSE;
|
||||
|
||||
/* TODO: This code must die once 3domusic becomes an addon
|
||||
* pack in its own right. */
|
||||
if (optWhichMusic == OPT_3DO)
|
||||
{
|
||||
res_LoadFilename (contentDir, "3domusic.rmp");
|
||||
}
|
||||
|
||||
/* Now load the rest of the addons, in order. */
|
||||
prepareAddons (optAddons);
|
||||
|
||||
INIT_INSTANCES ();
|
||||
|
||||
{
|
||||
|
||||
+2
-2
@@ -419,9 +419,9 @@ main (int argc, char *argv[])
|
||||
musicVolumeScale = options.musicVolumeScale;
|
||||
sfxVolumeScale = options.sfxVolumeScale;
|
||||
speechVolumeScale = options.speechVolumeScale;
|
||||
optAddons = options.addons;
|
||||
|
||||
prepareContentDir (options.contentDir, options.addons);
|
||||
HFree ((void *) options.addons);
|
||||
prepareContentDir (options.contentDir);
|
||||
prepareMeleeDir ();
|
||||
prepareSaveDir ();
|
||||
#if 0
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
#define UQM_MAJOR_VERSION_S "0"
|
||||
#define UQM_MINOR_VERSION 6
|
||||
#define UQM_MINOR_VERSION_S "6"
|
||||
#define UQM_PATCH_VERSION 3
|
||||
#define UQM_PATCH_VERSION_S "3"
|
||||
#define UQM_PATCH_VERSION 4
|
||||
#define UQM_PATCH_VERSION_S "4"
|
||||
#define UQM_EXTRA_VERSION ""
|
||||
/* The final version is interpreted as:
|
||||
* printf ("%d.%d.%d%s", UQM_MAJOR_VERSION, UQM_MINOR_VERSION,
|
||||
|
||||
Reference in New Issue
Block a user