Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion thstd/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,6 @@ add_executable(thstd
thstd.c
thstd.h
)
add_definitions( -g )
target_link_libraries(thstd util)
link_setargv(thstd)
install(TARGETS thstd DESTINATION bin)
Expand Down
58 changes: 47 additions & 11 deletions thstd/thstd.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -45,10 +45,10 @@ unsigned int option_version;
/* Some of the S's here are actually colors. */
static const id_format_pair_t formats_v0[] = {
{ 0, "Sff" },
{ 1, "Sff" },
{ 1, "Cff" },
{ 2, "Sff" },
{ 3, "Sff" },
{ 4, "Sff" },
{ 4, "SSS" },
{ 5, "Sff" },
{ 6, "SSf" },
{ 7, "fff" },
Expand All@@ -58,6 +58,27 @@ static const id_format_pair_t formats_v0[] = {
{ 11, "fff" },
{ 12, "Sff" },
{ 13, "Sff" },
{ 14, "Sff" },
{ 15, "Sff" },
{ 16, "Sff" },
{ 17, "Sff" },
{ 18, "Sff" },
{ 19, "Sff" },
{ 20, "Sff" },
{ 21, "Sff" },
{ 22, "Sff" },
{ 23, "SSS" },
{ 24, "SSS" },
{ 25, "SSS" },
{ 26, "SSS" },
{ 27, "SSS" },
{ 28, "SSS" },
{ 29, "SSS" },
{ 30, "SSS" },
{ 31, "SSS" },
{ 32, "SSS" },
{ 33, "SSS" },
{ 34, "SSS" },
{ 0, NULL }
};

Expand DownExpand Up@@ -161,13 +182,12 @@ std_read_file(

for(;;) {
quad_type = (unsigned int*)map;
if (*quad_type == 0x0004FFFF) {
if (*quad_type == 0x4FFFF) {
break;
}

list_append_new(&entry->quads, (std_object_t*)map);

map = map + sizeof(std_object_t);
map = map + ((std_object_t*)map)->size;
}
}

Expand DownExpand Up@@ -262,6 +282,10 @@ std_dump(
fprintf(stream, " Padding: %i\n", object->_padding);
fprintf(stream, " Width: %g\n", object->width);
fprintf(stream, " Height: %g\n", object->height);
if(object->size == 36) {
fprintf(stream, " Unknown_ex1: %g\n", object->unknown_ex1);
fprintf(stream, " Unknown_ex2: %g\n", object->unknown_ex2);
}
}
fprintf(stream, "\n");

Expand DownExpand Up@@ -381,7 +405,7 @@ std_create(

const id_format_pair_t *formats =
option_version == 0 ? formats_v0 :
formats_v1;
option_version == 1 ? formats_v1 : formats_v2;

f = fopen(spec, "r");
if (!f) {
Expand DownExpand Up@@ -519,6 +543,7 @@ std_create(
} else if (util_strcmp_ref(line, stringref("QUAD:")) == 0) {
std->header->nb_faces++;
quad = malloc(sizeof(*quad));
quad->size = 0x1c;
list_append_new(&entry->quads, quad);
set_object = 0;
} else if (util_strcmp_ref(line, stringref("FACE: ")) == 0) {
Expand DownExpand Up@@ -613,25 +638,37 @@ std_create(
sscanf(line, "Padding: %hu", &quad->_padding);
sscanf(line, "Width: %g", &quad->width);
sscanf(line, "Height: %g", &quad->height);
if(1 == sscanf(line, "Unknown_ex1: %g", &quad->unknown_ex1)) {
quad->size = 36;
}
if(1 == sscanf(line, "Unknown_ex2: %g", &quad->unknown_ex2)) {
quad->size = 36;
}
}
}
sscanf(line, "%u", &instr_time);
}
}
fclose(f);

size_t total_entry_size = 0;
list_for_each(&std->entries, entry) {
list_for_each(&entry->quads, quad) {
total_entry_size += quad->size;
}
}
if (option_version == 0)
std->header_06->faces_offset = (sizeof(std_header_06_t) +
sizeof(int32_t) * std->header->nb_objects +
sizeof(std_entry_header_t) * std->header->nb_objects +
sizeof(int32_t) * std->header->nb_objects +
sizeof(std_object_t) * std->header->nb_faces);
total_entry_size);
else
std->header_10->faces_offset = (sizeof(std_header_10_t) +
sizeof(int32_t) * std->header->nb_objects +
sizeof(std_entry_header_t) * std->header->nb_objects +
sizeof(int32_t) * std->header->nb_objects +
sizeof(std_object_t) * std->header->nb_faces);
total_entry_size);

int inst_test = 0;
list_for_each(&std->instances, instance) {
Expand DownExpand Up@@ -694,9 +731,8 @@ std_write(
entry_offset += sizeof(std_entry_header_t);

list_for_each(&entry->quads, quad) {
quad->size = 0x1c;
file_write(stream, quad, sizeof(std_object_t));
entry_offset += sizeof(std_object_t);
file_write(stream, quad, quad->size);
entry_offset += quad->size;
}

endcode = 0x0004FFFF;
Expand Down
5 changes: 4 additions & 1 deletion thstd/thstd.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -107,7 +107,10 @@ PACK_BEGIN
float z;
float width;
float height;
PACK_END

float unknown_ex1;
float unknown_ex2;
PACK_END
} std_object_t;

typedef struct {
Expand Down