fix formatting

This commit is contained in:
Natsirt867
2026-01-05 10:28:51 -06:00
parent 987343376d
commit 681436ac68

View File

@@ -187,125 +187,125 @@ void init() {
switch (input) { switch (input) {
case 1: case 1:
{ {
HANDLE hMPQ = NULL; HANDLE hMPQ = NULL;
//DWORD dwError = 0; //DWORD dwError = 0;
HANDLE hMPQ_COMMON = NULL; HANDLE hMPQ_COMMON = NULL;
ArchiveManager manager; ArchiveManager manager;
//char mpqFilePath[MAX_PATH]; //char mpqFilePath[MAX_PATH];
// get_mpq_file_path(mpqFilePath, MAX_PATH); // get_mpq_file_path(mpqFilePath, MAX_PATH);
PathList list_container; PathList list_container;
char wowDataDir[MAX_PATH]; char wowDataDir[MAX_PATH];
get_data_dir(wowDataDir, MAX_PATH); get_data_dir(wowDataDir, MAX_PATH);
init_archive_manager(&manager, wowDataDir); init_archive_manager(&manager, wowDataDir);
init_path_list(&list_container); init_path_list(&list_container);
recursively_scan_directory(wowDataDir, &list_container); recursively_scan_directory(wowDataDir, &list_container);
for (int i = 0; i < list_container.count; i++) { for (int i = 0; i < list_container.count; i++) {
log_info("Found path: '%s'", list_container.entries[i].path); log_info("Found path: '%s'", list_container.entries[i].path);
} }
// free_path_list(&list_container); // free_path_list(&list_container);
qsort(list_container.entries, list_container.count, sizeof(ArchiveEntry), qsort(list_container.entries, list_container.count, sizeof(ArchiveEntry),
archive_comparator); archive_comparator);
for (int i = 0; i < list_container.count; i++) { for (int i = 0; i < list_container.count; i++) {
HANDLE hArchive; HANDLE hArchive;
const char *mpqFilePath = list_container.entries[i].path; const char *mpqFilePath = list_container.entries[i].path;
if (manager.count >= manager.capacity) { if (manager.count >= manager.capacity) {
expand_archive_manager(&manager); expand_archive_manager(&manager);
}
if (!SFileOpenArchive(
mpqFilePath,
0,
MPQ_OPEN_READ_ONLY,
&hArchive))
{
// Log error and continue to the next archive!
log_error("Error opening MPQ '%s'. Error code: %lu\n", mpqFilePath, GetLastError());
continue;
}
// Success: Store the handle in the ArchiveManager
manager.archives[manager.count++] = hArchive;
// TODO - honestly I should mount these as needed... check newest patch first -> oldest
// for files needed
log_info("Successfully mounted archive #%zu: %s", manager.count, mpqFilePath);
} }
/*
if (!SFileOpenArchive( if (!SFileOpenArchive(
mpqFilePath, mpqFilePath,
0, 0,
MPQ_OPEN_READ_ONLY, MPQ_OPEN_READ_ONLY,
&hMPQ)) { &hArchive))
{
// Log error and continue to the next archive!
log_error("Error opening MPQ '%s'. Error code: %lu\n", mpqFilePath, GetLastError()); log_error("Error opening MPQ '%s'. Error code: %lu\n", mpqFilePath, GetLastError());
return; continue;
}
if (!SFileOpenArchive("./common.MPQ", 0, MPQ_OPEN_READ_ONLY, &hMPQ_COMMON)) {
DWORD dwError = GetLastError();
log_error("Error opening `common.MPQ` at `%s`. Error code: %lu\n", "./common.MPQ", dwError);
return;
} }
log_info("Successfully opened MPQ file: '%s'\n", mpqFilePath); // Success: Store the handle in the ArchiveManager
getchar(); manager.archives[manager.count++] = hArchive;
// TODO - honestly I should mount these as needed... check newest patch first -> oldest
// for files needed
log_info("Successfully mounted archive #%zu: %s", manager.count, mpqFilePath);
}
log_info("Getting (listfile) for test run...\n"); /*
get_file_size_in_mpq(get_file_in_mpq(hMPQ, "(listfile)"), "(listfile)"); if (!SFileOpenArchive(
mpqFilePath,
log_info("Getting (CTFNightelf_A.wmo) for WMO data test"); 0,
//WMOData test_WMOdata = load_wmo_data(hMPQ, "World\\wmo\\PvP\\Buildings\\CTF\\CTFOrc_A.wmo");*/ MPQ_OPEN_READ_ONLY,
// "World\\wmo\\Dungeon\\MD_Caveden\\MD_VrykulDen.wmo" &hMPQ)) {
//char *wmoFileName = "World\\wmo\\PvP\\Buildings\\CTF\\CTFNightelf_A.wmo"; log_error("Error opening MPQ '%s'. Error code: %lu\n", mpqFilePath, GetLastError());
//char *wmoFileName = "World\\wmo\\Dungeon\\MD_Caveden\\MD_VrykulDen.wmo"; return;
//char *wmoFileName = "World\\wmo\\Test\\test_petes_wmo_rotation_test.wmo";
char *wmoFileName = "World\\wmo\\Dungeon\\Ulduar\\Ulduar_Raid.wmo";
WMOData test_WMOdata = load_wmo_data(&manager, wmoFileName);
const char *log_file_name = "wmo_geometry_export.obj.log";
char log_file_path[MAX_PATH];
snprintf(log_file_path, MAX_PATH, "%s.obj.log", log_file_name);
FILE *log_file = fopen(log_file_name, "w");
if (log_file == NULL) {
log_error("Failed to open log file: '%s'. Check permissions or dir", log_file_name);
} }
if (!SFileOpenArchive("./common.MPQ", 0, MPQ_OPEN_READ_ONLY, &hMPQ_COMMON)) {
DWORD dwError = GetLastError();
log_error("Error opening `common.MPQ` at `%s`. Error code: %lu\n", "./common.MPQ", dwError);
return;
}
WMORootData wmo_root_data = {0}; log_info("Successfully opened MPQ file: '%s'\n", mpqFilePath);
getchar();
// TODO - SOURCE OF ERROR FOR BYTE MISMATCH? log_info("Getting (listfile) for test run...\n");
parse_wmo_chunks(&manager, test_WMOdata.data, test_WMOdata.size, &wmo_root_data, wmoFileName); get_file_size_in_mpq(get_file_in_mpq(hMPQ, "(listfile)"), "(listfile)");
// extract_wmo_geometry(&wmo_root_data, log_file); log_info("Getting (CTFNightelf_A.wmo) for WMO data test");
if (log_file != NULL) { //WMOData test_WMOdata = load_wmo_data(hMPQ, "World\\wmo\\PvP\\Buildings\\CTF\\CTFOrc_A.wmo");*/
fclose(log_file); // "World\\wmo\\Dungeon\\MD_Caveden\\MD_VrykulDen.wmo"
} //char *wmoFileName = "World\\wmo\\PvP\\Buildings\\CTF\\CTFNightelf_A.wmo";
//char *wmoFileName = "World\\wmo\\Dungeon\\MD_Caveden\\MD_VrykulDen.wmo";
//char *wmoFileName = "World\\wmo\\Test\\test_petes_wmo_rotation_test.wmo";
char *wmoFileName = "World\\wmo\\Dungeon\\Ulduar\\Ulduar_Raid.wmo";
WMOData test_WMOdata = load_wmo_data(&manager, wmoFileName);
if (wmo_root_data.motx_data_ptr && wmo_root_data.momt_data_ptr) { const char *log_file_name = "wmo_geometry_export.obj.log";
log_info("Successfully located chunks."); char log_file_path[MAX_PATH];
// log_info("Located MVER chunk at offset %td", out_wmo_data.mver_data_ptr - wmo_buffer); snprintf(log_file_path, MAX_PATH, "%s.obj.log", log_file_name);
// pass by reference
parse_momt_and_extract_textures(&manager, &wmo_root_data);
} else { FILE *log_file = fopen(log_file_name, "w");
log_error("Failed to find required MOMT and MOTX chunks."); if (log_file == NULL) {
} log_error("Failed to open log file: '%s'. Check permissions or dir", log_file_name);
}
log_info("Testing struct data storage... MVER at %td, MOGN at %td",
wmo_root_data.mver_data_ptr - test_WMOdata.data,
wmo_root_data.mogn_data_ptr - test_WMOdata.data);
if (!restart_gl_log()) { WMORootData wmo_root_data = {0};
// TODO - SOURCE OF ERROR FOR BYTE MISMATCH?
parse_wmo_chunks(&manager, test_WMOdata.data, test_WMOdata.size, &wmo_root_data, wmoFileName);
// extract_wmo_geometry(&wmo_root_data, log_file);
if (log_file != NULL) {
fclose(log_file);
}
if (wmo_root_data.motx_data_ptr && wmo_root_data.momt_data_ptr) {
log_info("Successfully located chunks.");
// log_info("Located MVER chunk at offset %td", out_wmo_data.mver_data_ptr - wmo_buffer);
// pass by reference
parse_momt_and_extract_textures(&manager, &wmo_root_data);
} else {
log_error("Failed to find required MOMT and MOTX chunks.");
}
log_info("Testing struct data storage... MVER at %td, MOGN at %td",
wmo_root_data.mver_data_ptr - test_WMOdata.data,
wmo_root_data.mogn_data_ptr - test_WMOdata.data);
if (!restart_gl_log()) {
break; break;
} }
@@ -711,7 +711,7 @@ void init() {
free_group_mesh(meshes); free_group_mesh(meshes);
glfwTerminate(); glfwTerminate();
break; break;
} }
case 2: case 2:
printf("TODO!!"); printf("TODO!!");
break; break;