Skip to content

Commit

Permalink
Restore original behavior for random id grouping
Browse files Browse the repository at this point in the history
  • Loading branch information
Morilli committed Dec 1, 2023
1 parent fcfa174 commit d19a35b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions bnk-extract/bin.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
struct string_hash {
char* string;
uint32_t hash;
uint32_t random_container_id;
uint32_t switch_id;
};
typedef LIST(struct string_hash) StringHashes;
Expand Down
6 changes: 5 additions & 1 deletion bnk-extract/extract.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ StringWithChildren* group_wems(AudioDataList* audio_data, StringHashes* string_h
current_root = try_insert(current_root, switch_id);
}
current_root = try_insert(current_root, current_event->string);

if (current_event->random_container_id) {
char random_container_id[11];
sprintf(random_container_id, "%u", current_event->random_container_id);
current_root = try_insert(current_root, random_container_id);
}
char wem_name[15];
sprintf(wem_name, "%u.wem", current_audio_data->id);
add_object(current_root, (&(StringWithChildren) {.string = strdup(wem_name), .wemData = current_audio_data}));
Expand Down
8 changes: 4 additions & 4 deletions bnk-extract/sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ WemInformation* bnk_extract(int argc, char* argv[])
if (sounds.objects[k].sound_object_id == event_action->sound_object_id || sounds.objects[k].self_id == event_action->sound_object_id) {
dprintf("Found one!\n");
v_printf(2, "Hash %u of string %s belongs to file \"%u.wem\".\n", hash, read_strings->objects[i].string, sounds.objects[k].file_id);
add_object(&string_files, (&(struct string_hash) {read_strings->objects[i].string, sounds.objects[k].file_id, 0}));
add_object(&string_files, (&(struct string_hash) {read_strings->objects[i].string, sounds.objects[k].file_id, 0, 0}));
}
}
for (uint32_t k = 0; k < music_segments.length; k++) {
Expand All @@ -594,7 +594,7 @@ WemInformation* bnk_extract(int argc, char* argv[])
dprintf("Found one 1!\n");
for (uint32_t m = 0; m < music_track->track_count; m++) {
v_printf(2, "Hash %u of string %s belongs to file \"%u.wem\".\n", hash, read_strings->objects[i].string, music_track->file_ids[m]);
add_object(&string_files, (&(struct string_hash) {read_strings->objects[i].string, music_track->file_ids[m], 0 /*music_segments.objects[k].self_id*/}));
add_object(&string_files, (&(struct string_hash) {read_strings->objects[i].string, music_track->file_ids[m], 0, 0 /*music_segments.objects[k].self_id*/}));
}
}
}
Expand Down Expand Up @@ -627,7 +627,7 @@ WemInformation* bnk_extract(int argc, char* argv[])
dprintf("sound id amount? %u\n", random_containers.objects[k].sound_id_amount);
dprintf("Found one precisely here.\n");
v_printf(2, "Hash %u of string %s belongs to file \"%u.wem\".\n", hash, read_strings->objects[i].string, sounds.objects[m].file_id);
add_object(&string_files, (&(struct string_hash) {read_strings->objects[i].string, sounds.objects[m].file_id, random_containers.objects[k].self_id}));
add_object(&string_files, (&(struct string_hash) {read_strings->objects[i].string, sounds.objects[m].file_id, random_containers.objects[k].self_id, 0}));
}
}
}
Expand All @@ -642,7 +642,7 @@ WemInformation* bnk_extract(int argc, char* argv[])
if (music_track->switch_ids[l] == event_action->switch_id) {
dprintf("Found one 3!\n");
v_printf(2, "Hash %u of string %s belongs to file \"%u.wem\".\n", hash, read_strings->objects[i].string, music_track->file_ids[l]);
add_object(&string_files, (&(struct string_hash) {read_strings->objects[i].string, music_track->file_ids[l], music_track->switch_group_id}));
add_object(&string_files, (&(struct string_hash) {read_strings->objects[i].string, music_track->file_ids[l], 0, music_track->switch_group_id}));
}
}
}
Expand Down

0 comments on commit d19a35b

Please sign in to comment.