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:
+34
-15
@@ -110,7 +110,7 @@ readIndex(const uint8 *buf) {
|
|||||||
h.package_list[i].num_instances = GET_INSTANCE(temp);
|
h.package_list[i].num_instances = GET_INSTANCE(temp);
|
||||||
h.package_list[i].file_index = GET_PACKAGE(temp);
|
h.package_list[i].file_index = GET_PACKAGE(temp);
|
||||||
fprintf(stderr, "0x%08x #%d, %d types, %d instances, "
|
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_types,
|
||||||
h.package_list[i].num_instances,
|
h.package_list[i].num_instances,
|
||||||
h.package_list[i].file_index);
|
h.package_list[i].file_index);
|
||||||
@@ -165,30 +165,44 @@ readIndex(const uint8 *buf) {
|
|||||||
if (filename == NULL)
|
if (filename == NULL)
|
||||||
filename = "<UNNAMED>";
|
filename = "<UNNAMED>";
|
||||||
fprintf(stderr, "0x%08x Package #%d (%s):\n",
|
fprintf(stderr, "0x%08x Package #%d (%s):\n",
|
||||||
bufptr - buf, i, filename);
|
bufptr - buf, i + 1, filename);
|
||||||
} else {
|
} else {
|
||||||
// not packaged
|
// 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;
|
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++) {
|
for (j = 0; j < num_types; j++) {
|
||||||
temp = MAKE_DWORD(bufptr[0], bufptr[1], bufptr[2], bufptr[3]);
|
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, "
|
fprintf(stderr, "0x%08x Type #%d: type %d, "
|
||||||
"%d instances, rest: %d\n",
|
"%d instances starting with #%d\n",
|
||||||
bufptr - buf, j,
|
bufptr - buf, j,
|
||||||
GET_TYPE(temp),
|
h.package_list[i].type_list[j].type,
|
||||||
GET_PACKAGE(temp), /* Yes, this is correct, the
|
h.package_list[i].type_list[j].num_instances,
|
||||||
package field contains the number of instances */
|
h.package_list[i].type_list[j].first_instance);
|
||||||
GET_INSTANCE(temp));
|
|
||||||
bufptr += 4;
|
bufptr += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
num_instances = h.package_list[i].num_instances;
|
for (j = 0; j < num_types; j++) {
|
||||||
for (j = 0; j < num_instances; j++) {
|
int k;
|
||||||
|
|
||||||
|
num_instances = h.package_list[i].type_list[j].num_instances;
|
||||||
|
for (k = 0; k < num_instances; k++) {
|
||||||
if (h.res_flags) {
|
if (h.res_flags) {
|
||||||
// packaged
|
// packaged
|
||||||
fprintf(stderr, "0x%08x Instance #%d: size %d "
|
fprintf(stderr, "0x%08x Instance #%d of "
|
||||||
"bytes\n", bufptr - buf, j,
|
"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]));
|
4 * MAKE_WORD(bufptr[0], bufptr[1]));
|
||||||
} else {
|
} else {
|
||||||
char *filename;
|
char *filename;
|
||||||
@@ -197,11 +211,16 @@ readIndex(const uint8 *buf) {
|
|||||||
MAKE_WORD(bufptr[0], bufptr[1]));
|
MAKE_WORD(bufptr[0], bufptr[1]));
|
||||||
if (filename == NULL)
|
if (filename == NULL)
|
||||||
filename = "<UNNAMED>";
|
filename = "<UNNAMED>";
|
||||||
fprintf(stderr, "0x%08x Instance #%d: %s\n",
|
fprintf(stderr, "0x%08x Instance #%d of "
|
||||||
bufptr - buf, j, filename);
|
"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;
|
bufptr += 2;
|
||||||
}
|
} // for k
|
||||||
|
} // for j
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-5
@@ -20,12 +20,15 @@ typedef unsigned int uint32;
|
|||||||
((uint16)((res) >> (TYPE_BITS + INSTANCE_BITS)) & \
|
((uint16)((res) >> (TYPE_BITS + INSTANCE_BITS)) & \
|
||||||
((1 << PACKAGE_BITS) - 1))
|
((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;
|
uint16 instance_count;
|
||||||
#if 0
|
|
||||||
RES_VECTORS func_vectors;
|
|
||||||
#endif
|
|
||||||
} type_desc;
|
} type_desc;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -40,6 +43,7 @@ typedef struct {
|
|||||||
uint16 file_index; // only low 11 bits used
|
uint16 file_index; // only low 11 bits used
|
||||||
uint8 flags;
|
uint8 flags;
|
||||||
uint32 data_loc; // only low 24 bits used
|
uint32 data_loc; // only low 24 bits used
|
||||||
|
packtype_desc *type_list;
|
||||||
} package_desc;
|
} package_desc;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user