Shifted type information from .ls2 to .rmp files
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2909 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
Changes towards version 0.7:
|
Changes towards version 0.7:
|
||||||
|
- .rmp files now carry the types of the targets - Michael
|
||||||
- Joystick threshold defaults to 10,000, not 0 (Bug #1046) - Michael
|
- Joystick threshold defaults to 10,000, not 0 (Bug #1046) - Michael
|
||||||
- Remove MEM_HANDLEs from everywhere outside of memlib - Michael
|
- Remove MEM_HANDLEs from everywhere outside of memlib - Michael
|
||||||
- Split out RESOURCEs from the loaded data in RACE_DESC and LOCDATA
|
- Split out RESOURCEs from the loaded data in RACE_DESC and LOCDATA
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
music.arispace = addons/3domusic/arispace.ogg
|
music.arispace = MUSICRES:addons/3domusic/arispace.ogg
|
||||||
music.battle = addons/3domusic/battle.ogg
|
music.battle = MUSICRES:addons/3domusic/battle.ogg
|
||||||
music.hyper = addons/3domusic/hyper.ogg
|
music.hyper = MUSICRES:addons/3domusic/hyper.ogg
|
||||||
music.orbit1 = addons/3domusic/orbit1.ogg
|
music.orbit1 = MUSICRES:addons/3domusic/orbit1.ogg
|
||||||
music.orbit2 = addons/3domusic/orbit2.ogg
|
music.orbit2 = MUSICRES:addons/3domusic/orbit2.ogg
|
||||||
music.orbit3 = addons/3domusic/orbit3.ogg
|
music.orbit3 = MUSICRES:addons/3domusic/orbit3.ogg
|
||||||
music.orbit4 = addons/3domusic/orbit4.ogg
|
music.orbit4 = MUSICRES:addons/3domusic/orbit4.ogg
|
||||||
music.orbit5 = addons/3domusic/orbit5.ogg
|
music.orbit5 = MUSICRES:addons/3domusic/orbit5.ogg
|
||||||
music.outfit = addons/3domusic/outfit.ogg
|
music.outfit = MUSICRES:addons/3domusic/outfit.ogg
|
||||||
music.shipyard = addons/3domusic/shipyard.ogg
|
music.shipyard = MUSICRES:addons/3domusic/shipyard.ogg
|
||||||
music.space = addons/3domusic/space.ogg
|
music.space = MUSICRES:addons/3domusic/space.ogg
|
||||||
music.starbase = addons/3domusic/starbase.ogg
|
music.starbase = MUSICRES:addons/3domusic/starbase.ogg
|
||||||
music.credits = addons/3domusic/credits.ogg
|
music.credits = MUSICRES:addons/3domusic/credits.ogg
|
||||||
|
|||||||
+951
-951
File diff suppressed because it is too large
Load Diff
@@ -29,7 +29,19 @@
|
|||||||
typedef struct resource_index *RESOURCE_INDEX;
|
typedef struct resource_index *RESOURCE_INDEX;
|
||||||
typedef DWORD RESOURCE;
|
typedef DWORD RESOURCE;
|
||||||
|
|
||||||
typedef BYTE RES_TYPE;
|
typedef enum
|
||||||
|
{
|
||||||
|
UNKNOWNRES = 0,
|
||||||
|
KEY_CONFIG,
|
||||||
|
GFXRES,
|
||||||
|
FONTRES,
|
||||||
|
STRTAB,
|
||||||
|
SNDRES,
|
||||||
|
MUSICRES,
|
||||||
|
RES_INDEX,
|
||||||
|
CODE
|
||||||
|
} RES_TYPE;
|
||||||
|
|
||||||
typedef COUNT RES_INSTANCE;
|
typedef COUNT RES_INSTANCE;
|
||||||
typedef COUNT RES_PACKAGE;
|
typedef COUNT RES_PACKAGE;
|
||||||
|
|
||||||
@@ -41,6 +53,7 @@ typedef COUNT RES_PACKAGE;
|
|||||||
|
|
||||||
#define GET_TYPE(res) \
|
#define GET_TYPE(res) \
|
||||||
((RES_TYPE)(res) & (RES_TYPE)((1 << TYPE_BITS) - 1))
|
((RES_TYPE)(res) & (RES_TYPE)((1 << TYPE_BITS) - 1))
|
||||||
|
|
||||||
#define GET_INSTANCE(res) \
|
#define GET_INSTANCE(res) \
|
||||||
((RES_INSTANCE)((res) >> TYPE_BITS) & ((1 << INSTANCE_BITS) - 1))
|
((RES_INSTANCE)((res) >> TYPE_BITS) & ((1 << INSTANCE_BITS) - 1))
|
||||||
#define GET_PACKAGE(res) \
|
#define GET_PACKAGE(res) \
|
||||||
|
|||||||
@@ -22,6 +22,22 @@
|
|||||||
#include "libs/misc.h"
|
#include "libs/misc.h"
|
||||||
#include "libs/log.h"
|
#include "libs/log.h"
|
||||||
|
|
||||||
|
#define TYPESIZ 32
|
||||||
|
/* These MUST COME in the SAME ORDER as the enums in reslib.h!!!
|
||||||
|
They also must be no more than TYPESIZ-1 characters long, but that's
|
||||||
|
unlikely to be a problem. */
|
||||||
|
static const char *res_type_strings[] = {
|
||||||
|
"UNKNOWNRES",
|
||||||
|
"KEY_CONFIG",
|
||||||
|
"GFXRES",
|
||||||
|
"FONTRES",
|
||||||
|
"STRTAB",
|
||||||
|
"SNDRES",
|
||||||
|
"MUSICRES",
|
||||||
|
"RES_INDEX",
|
||||||
|
"CODE",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
const char *_cur_resfile_name;
|
const char *_cur_resfile_name;
|
||||||
// When a file is being loaded, _cur_resfile_name is set to its name.
|
// When a file is being loaded, _cur_resfile_name is set to its name.
|
||||||
@@ -71,8 +87,56 @@ loadPackage (ResourceIndex *idx, RES_PACKAGE pkg) {
|
|||||||
void *
|
void *
|
||||||
loadResourceDesc (ResourceIndex *idx, ResourceDesc *desc)
|
loadResourceDesc (ResourceIndex *idx, ResourceDesc *desc)
|
||||||
{
|
{
|
||||||
RES_TYPE resType = GET_TYPE (desc->res);
|
RES_TYPE resType, expectedType;
|
||||||
const char *path;
|
const char *resval;
|
||||||
|
char *path;
|
||||||
|
|
||||||
|
expectedType = GET_TYPE (desc->res);
|
||||||
|
|
||||||
|
resval = res_GetString (desc->res_id);
|
||||||
|
if (resval == NULL)
|
||||||
|
{
|
||||||
|
log_add (log_Warning, "Could not decode resource '%s'", desc->res_id);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
path = strchr (resval, ':');
|
||||||
|
if (path == NULL)
|
||||||
|
{
|
||||||
|
log_add (log_Warning, "Could not find type information for resource '%s'", desc->res_id);
|
||||||
|
resType = GET_TYPE (desc->res);
|
||||||
|
path = (char *)resval;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char typestr[TYPESIZ];
|
||||||
|
int n = path - resval;
|
||||||
|
|
||||||
|
if (n >= TYPESIZ)
|
||||||
|
{
|
||||||
|
n = TYPESIZ - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
strncpy (typestr, resval, n);
|
||||||
|
typestr[n] = '\0';
|
||||||
|
|
||||||
|
path++;
|
||||||
|
|
||||||
|
resType = UNKNOWNRES;
|
||||||
|
while (res_type_strings[resType])
|
||||||
|
{
|
||||||
|
if (!strcmp (typestr, res_type_strings[resType]))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
resType++;
|
||||||
|
}
|
||||||
|
if (!res_type_strings[resType])
|
||||||
|
{
|
||||||
|
log_add (log_Warning, "Illegal type '%s' for resource '%s'", typestr, desc->res_id);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (resType >= idx->typeInfo.numTypes ||
|
if (resType >= idx->typeInfo.numTypes ||
|
||||||
idx->typeInfo.handlers[resType].loadFun == NULL)
|
idx->typeInfo.handlers[resType].loadFun == NULL)
|
||||||
@@ -82,13 +146,17 @@ loadResourceDesc (ResourceIndex *idx, ResourceDesc *desc)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
path = res_GetString (desc->res_id);
|
if ((expectedType != UNKNOWNRES) && (resType != expectedType))
|
||||||
if (path == NULL)
|
|
||||||
{
|
{
|
||||||
log_add (log_Warning, "Could not decode resource '%s'", desc->res_id);
|
log_add (log_Warning, "Warning: Expected type '%s' for"
|
||||||
|
"resource '%s', but got '%s'.",
|
||||||
|
res_type_strings[expectedType],
|
||||||
|
desc->res_id,
|
||||||
|
res_type_strings[resType]);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
desc->restype = resType;
|
||||||
desc->resdata = loadResource (path,
|
desc->resdata = loadResource (path,
|
||||||
idx->typeInfo.handlers[resType].loadFun);
|
idx->typeInfo.handlers[resType].loadFun);
|
||||||
return desc->resdata;
|
return desc->resdata;
|
||||||
@@ -187,6 +255,7 @@ res_FreeResource (RESOURCE res)
|
|||||||
idx = _get_current_index_header ();
|
idx = _get_current_index_header ();
|
||||||
freeFun = idx->typeInfo.handlers[GET_TYPE (res)].freeFun;
|
freeFun = idx->typeInfo.handlers[GET_TYPE (res)].freeFun;
|
||||||
(*freeFun) (desc->resdata);
|
(*freeFun) (desc->resdata);
|
||||||
|
desc->restype = UNKNOWNRES;
|
||||||
desc->resdata = NULL;
|
desc->resdata = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
RESOURCE res;
|
RESOURCE res;
|
||||||
|
RES_TYPE restype;
|
||||||
char *res_id;
|
char *res_id;
|
||||||
void *resdata;
|
void *resdata;
|
||||||
//COUNT ref;
|
//COUNT ref;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
#ifndef _NAMEREF_H
|
#ifndef _NAMEREF_H
|
||||||
#define _NAMEREF_H
|
#define _NAMEREF_H
|
||||||
|
|
||||||
#include "restypes.h"
|
#include "reslib.h"
|
||||||
|
|
||||||
#define LoadCodeRes LoadCodeResInstance
|
#define LoadCodeRes LoadCodeResInstance
|
||||||
#define LoadGraphic (DRAWABLE)LoadGraphicInstance
|
#define LoadGraphic (DRAWABLE)LoadGraphicInstance
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
//Copyright Paul Reiche, Fred Ford. 1992-2002
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _RESTYPES_H
|
|
||||||
#define _RESTYPES_H
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
KEY_CONFIG = 1,
|
|
||||||
GFXRES,
|
|
||||||
FONTRES,
|
|
||||||
STRTAB,
|
|
||||||
SNDRES,
|
|
||||||
MUSICRES,
|
|
||||||
RES_INDEX,
|
|
||||||
CODE
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* _RESTYPES_H */
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user