Reworking of the resource system.

Resource indices (.ls2) now refer to string identifiers which are mapped 
to files by a global resource map (uqm.rmp).

This meets Milestone 3 of the Resource System Phase 2 plan.



git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2868 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
mcmartin
2007-11-28 08:09:57 +00:00
parent 73f89d6bfc
commit 25b4267902
59 changed files with 1951 additions and 7 deletions
+2 -2
View File
@@ -67,8 +67,8 @@ extern long LengthResFile (uio_Stream *fp);
extern BOOLEAN res_CloseResFile (uio_Stream *fp);
extern BOOLEAN DeleteResFile (uio_DirHandle *dir, const char *filename);
extern MEM_HANDLE InitResourceSystem (const char *resfile, RES_TYPE resType,
BOOLEAN (*FileErrorFun) (const char *filename));
extern MEM_HANDLE InitResourceSystem (const char *mapfile, const char *resfile,
RES_TYPE resType, BOOLEAN (*FileErrorFun) (const char *filename));
extern void UninitResourceSystem (void);
extern BOOLEAN InstallResTypeVectors (RES_TYPE res_type,
ResourceLoadFun *loadFun, ResourceFreeFun *freeFun);
+1
View File
@@ -25,6 +25,7 @@ typedef struct
{
RESOURCE res;
char *path;
char *res_id;
MEM_HANDLE handle;
//COUNT ref;
} ResourceDesc;
+18 -3
View File
@@ -83,16 +83,28 @@ lookupResourceIndex (const char *path)
#endif
static ResourceDesc *
newResourceDesc (RESOURCE res, char *path)
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;
return result;
@@ -305,8 +317,8 @@ _ReleaseResFileData (MEM_HANDLE handle)
}
MEM_HANDLE
InitResourceSystem (const char *resfile, RES_TYPE resType, BOOLEAN
(*FileErrorFun) (const char *filename))
InitResourceSystem (const char *mapfile, const char *resfile, RES_TYPE resType,
BOOLEAN (*FileErrorFun) (const char *filename))
{
MEM_HANDLE handle;
ResourceIndex *ndx;
@@ -317,6 +329,8 @@ InitResourceSystem (const char *resfile, RES_TYPE resType, BOOLEAN
handlers.loadFun = _GetResFileData;
handlers.freeFun = _ReleaseResFileData;
res_LoadFilename (contentDir, mapfile);
SetResourceIndex (NULL_HANDLE);
handle = loadResource (resfile, handlers.loadFun);
if (handle == NULL_HANDLE)
@@ -329,6 +343,7 @@ InitResourceSystem (const char *resfile, RES_TYPE resType, BOOLEAN
SetResourceIndex (handle);
(void) FileErrorFun;
(void) mapfile;
return handle;
}
+1 -1
View File
@@ -111,7 +111,7 @@ LoadKernel (int argc, char *argv[])
SetContextFGFrame (Screen);
SetFrameHot (Screen, MAKE_HOT_SPOT (0, 0));
hResIndex = InitResourceSystem ("starcon.lst", RES_INDEX, NULL);
hResIndex = InitResourceSystem ("uqm.rmp", "starcon.ls2", RES_INDEX, NULL);
if (hResIndex == 0)
return FALSE;
INIT_INSTANCES ();