Improved version (almost there...)
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@122 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
+45
-26
@@ -110,7 +110,7 @@ readIndex(const uint8 *buf) {
|
||||
h.package_list[i].num_instances = GET_INSTANCE(temp);
|
||||
h.package_list[i].file_index = GET_PACKAGE(temp);
|
||||
fprintf(stderr, "0x%08x #%d, %d types, %d instances, "
|
||||
"file index 0x%04x, ", bufptr - buf, i,
|
||||
"file index 0x%04x, ", bufptr - buf, i + 1,
|
||||
h.package_list[i].num_types,
|
||||
h.package_list[i].num_instances,
|
||||
h.package_list[i].file_index);
|
||||
@@ -165,43 +165,62 @@ readIndex(const uint8 *buf) {
|
||||
if (filename == NULL)
|
||||
filename = "<UNNAMED>";
|
||||
fprintf(stderr, "0x%08x Package #%d (%s):\n",
|
||||
bufptr - buf, i, filename);
|
||||
bufptr - buf, i + 1, filename);
|
||||
} else {
|
||||
// not packaged
|
||||
fprintf(stderr, "0x%08x Package #%d:\n", bufptr - buf, i);
|
||||
fprintf(stderr, "0x%08x Package #%d:\n",
|
||||
bufptr - buf, i + 1);
|
||||
}
|
||||
|
||||
num_types = h.package_list[i].num_types;
|
||||
h.package_list[i].type_list =
|
||||
malloc(num_types * sizeof (packtype_desc));
|
||||
for (j = 0; j < num_types; j++) {
|
||||
temp = MAKE_DWORD(bufptr[0], bufptr[1], bufptr[2], bufptr[3]);
|
||||
h.package_list[i].type_list[j].type = GET_TYPE(temp);
|
||||
h.package_list[i].type_list[j].first_instance =
|
||||
GET_INSTANCE(temp);
|
||||
h.package_list[i].type_list[j].num_instances =
|
||||
GET_PACKAGE(temp);
|
||||
fprintf(stderr, "0x%08x Type #%d: type %d, "
|
||||
"%d instances, rest: %d\n",
|
||||
"%d instances starting with #%d\n",
|
||||
bufptr - buf, j,
|
||||
GET_TYPE(temp),
|
||||
GET_PACKAGE(temp), /* Yes, this is correct, the
|
||||
package field contains the number of instances */
|
||||
GET_INSTANCE(temp));
|
||||
h.package_list[i].type_list[j].type,
|
||||
h.package_list[i].type_list[j].num_instances,
|
||||
h.package_list[i].type_list[j].first_instance);
|
||||
bufptr += 4;
|
||||
}
|
||||
|
||||
num_instances = h.package_list[i].num_instances;
|
||||
for (j = 0; j < num_instances; j++) {
|
||||
if (h.res_flags) {
|
||||
// packaged
|
||||
fprintf(stderr, "0x%08x Instance #%d: size %d "
|
||||
"bytes\n", bufptr - buf, j,
|
||||
4 * MAKE_WORD(bufptr[0], bufptr[1]));
|
||||
} else {
|
||||
char *filename;
|
||||
for (j = 0; j < num_types; j++) {
|
||||
int k;
|
||||
|
||||
filename = get_file_name(buf, &h,
|
||||
MAKE_WORD(bufptr[0], bufptr[1]));
|
||||
if (filename == NULL)
|
||||
filename = "<UNNAMED>";
|
||||
fprintf(stderr, "0x%08x Instance #%d: %s\n",
|
||||
bufptr - buf, j, filename);
|
||||
}
|
||||
bufptr += 2;
|
||||
}
|
||||
num_instances = h.package_list[i].type_list[j].num_instances;
|
||||
for (k = 0; k < num_instances; k++) {
|
||||
if (h.res_flags) {
|
||||
// packaged
|
||||
fprintf(stderr, "0x%08x Instance #%d of "
|
||||
"type %d: size %d bytes\n", bufptr - buf,
|
||||
k + h.package_list[i].type_list[j].
|
||||
first_instance,
|
||||
h.package_list[i].type_list[j].type,
|
||||
4 * MAKE_WORD(bufptr[0], bufptr[1]));
|
||||
} else {
|
||||
char *filename;
|
||||
|
||||
filename = get_file_name(buf, &h,
|
||||
MAKE_WORD(bufptr[0], bufptr[1]));
|
||||
if (filename == NULL)
|
||||
filename = "<UNNAMED>";
|
||||
fprintf(stderr, "0x%08x Instance #%d of "
|
||||
"type %d: %s\n", bufptr - buf,
|
||||
k + h.package_list[i].type_list[j].
|
||||
first_instance,
|
||||
h.package_list[i].type_list[j].type,
|
||||
filename);
|
||||
}
|
||||
bufptr += 2;
|
||||
} // for k
|
||||
} // for j
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-5
@@ -20,12 +20,15 @@ typedef unsigned int uint32;
|
||||
((uint16)((res) >> (TYPE_BITS + INSTANCE_BITS)) & \
|
||||
((1 << PACKAGE_BITS) - 1))
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
||||
typedef struct {
|
||||
uint8 type;
|
||||
uint16 first_instance; // only low 13 bits used
|
||||
uint16 num_instances; // only low 11 bits used
|
||||
} packtype_desc;
|
||||
|
||||
typedef struct {
|
||||
uint16 instance_count;
|
||||
#if 0
|
||||
RES_VECTORS func_vectors;
|
||||
#endif
|
||||
} type_desc;
|
||||
|
||||
typedef struct {
|
||||
@@ -40,6 +43,7 @@ typedef struct {
|
||||
uint16 file_index; // only low 11 bits used
|
||||
uint8 flags;
|
||||
uint32 data_loc; // only low 24 bits used
|
||||
packtype_desc *type_list;
|
||||
} package_desc;
|
||||
|
||||
typedef struct {
|
||||
|
||||
Reference in New Issue
Block a user