fix formatting
This commit is contained in:
184
src/main.c
184
src/main.c
@@ -187,125 +187,125 @@ void init() {
|
||||
|
||||
switch (input) {
|
||||
case 1:
|
||||
{
|
||||
HANDLE hMPQ = NULL;
|
||||
//DWORD dwError = 0;
|
||||
HANDLE hMPQ_COMMON = NULL;
|
||||
{
|
||||
HANDLE hMPQ = NULL;
|
||||
//DWORD dwError = 0;
|
||||
HANDLE hMPQ_COMMON = NULL;
|
||||
|
||||
ArchiveManager manager;
|
||||
//char mpqFilePath[MAX_PATH];
|
||||
// get_mpq_file_path(mpqFilePath, MAX_PATH);
|
||||
ArchiveManager manager;
|
||||
//char mpqFilePath[MAX_PATH];
|
||||
// get_mpq_file_path(mpqFilePath, MAX_PATH);
|
||||
|
||||
PathList list_container;
|
||||
char wowDataDir[MAX_PATH];
|
||||
get_data_dir(wowDataDir, MAX_PATH);
|
||||
PathList list_container;
|
||||
char 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);
|
||||
for (int i = 0; i < list_container.count; i++) {
|
||||
log_info("Found path: '%s'", list_container.entries[i].path);
|
||||
}
|
||||
// free_path_list(&list_container);
|
||||
recursively_scan_directory(wowDataDir, &list_container);
|
||||
for (int i = 0; i < list_container.count; i++) {
|
||||
log_info("Found path: '%s'", list_container.entries[i].path);
|
||||
}
|
||||
// free_path_list(&list_container);
|
||||
|
||||
qsort(list_container.entries, list_container.count, sizeof(ArchiveEntry),
|
||||
archive_comparator);
|
||||
qsort(list_container.entries, list_container.count, sizeof(ArchiveEntry),
|
||||
archive_comparator);
|
||||
|
||||
for (int i = 0; i < list_container.count; i++) {
|
||||
HANDLE hArchive;
|
||||
const char *mpqFilePath = list_container.entries[i].path;
|
||||
for (int i = 0; i < list_container.count; i++) {
|
||||
HANDLE hArchive;
|
||||
const char *mpqFilePath = list_container.entries[i].path;
|
||||
|
||||
if (manager.count >= manager.capacity) {
|
||||
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 (manager.count >= manager.capacity) {
|
||||
expand_archive_manager(&manager);
|
||||
}
|
||||
|
||||
/*
|
||||
if (!SFileOpenArchive(
|
||||
mpqFilePath,
|
||||
0,
|
||||
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());
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
continue;
|
||||
}
|
||||
|
||||
log_info("Successfully opened MPQ file: '%s'\n", mpqFilePath);
|
||||
getchar();
|
||||
// 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);
|
||||
}
|
||||
|
||||
log_info("Getting (listfile) for test run...\n");
|
||||
get_file_size_in_mpq(get_file_in_mpq(hMPQ, "(listfile)"), "(listfile)");
|
||||
|
||||
log_info("Getting (CTFNightelf_A.wmo) for WMO data test");
|
||||
//WMOData test_WMOdata = load_wmo_data(hMPQ, "World\\wmo\\PvP\\Buildings\\CTF\\CTFOrc_A.wmo");*/
|
||||
// "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);
|
||||
|
||||
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(
|
||||
mpqFilePath,
|
||||
0,
|
||||
MPQ_OPEN_READ_ONLY,
|
||||
&hMPQ)) {
|
||||
log_error("Error opening MPQ '%s'. Error code: %lu\n", mpqFilePath, GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
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?
|
||||
parse_wmo_chunks(&manager, test_WMOdata.data, test_WMOdata.size, &wmo_root_data, wmoFileName);
|
||||
log_info("Getting (listfile) for test run...\n");
|
||||
get_file_size_in_mpq(get_file_in_mpq(hMPQ, "(listfile)"), "(listfile)");
|
||||
|
||||
// extract_wmo_geometry(&wmo_root_data, log_file);
|
||||
if (log_file != NULL) {
|
||||
fclose(log_file);
|
||||
}
|
||||
log_info("Getting (CTFNightelf_A.wmo) for WMO data test");
|
||||
//WMOData test_WMOdata = load_wmo_data(hMPQ, "World\\wmo\\PvP\\Buildings\\CTF\\CTFOrc_A.wmo");*/
|
||||
// "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) {
|
||||
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);
|
||||
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);
|
||||
|
||||
} else {
|
||||
log_error("Failed to find required MOMT and MOTX chunks.");
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -711,7 +711,7 @@ void init() {
|
||||
free_group_mesh(meshes);
|
||||
glfwTerminate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
case 2:
|
||||
printf("TODO!!");
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user