diff --git a/H2Codez/H2Codez.vcxproj.user b/H2Codez/H2Codez.vcxproj.user index 76851d1..2a02be8 100644 --- a/H2Codez/H2Codez.vcxproj.user +++ b/H2Codez/H2Codez.vcxproj.user @@ -1,10 +1,10 @@  - C:\Program Files %28x86%29\Microsoft Games\Halo 2 Map Editor\h2sapien.exe + C:\Program Files %28x86%29\Microsoft Games\Halo 2 Map Editor\h2tool C:\Program Files (x86)\Microsoft Games\Halo 2 Map Editor WindowsLocalDebugger - structure-new-from-ass "c:\program files (x86)\microsoft games\halo 2 map editor\data\scenarios\multi\forge_world\structure\forge_world.ass" yes pause_after_run + build-cache-file "C:\Program Files (x86)\Microsoft Games\Halo 2 Map Editor\tags\scenarios\multi\preview\preview_1" C:\Program Files %28x86%29\Microsoft Games\Halo 2 Map Editor\h2sapien.exe diff --git a/H2Codez/H2Tool/H2ToolLibrary.inl b/H2Codez/H2Tool/H2ToolLibrary.inl index 199a472..cc0c5a3 100644 --- a/H2Codez/H2Tool/H2ToolLibrary.inl +++ b/H2Codez/H2Tool/H2ToolLibrary.inl @@ -17,13 +17,19 @@ static int __cdecl TAG_LOAD(int TAG_TYPE, cstring tags_directory, int a3) return TAG_LOAD(TAG_TYPE, tags_directory, a3); } -static int __cdecl TAG_GET(int TAG_TYPE, int TAG_INDEX) +static void *TAG_GET(int TAG_TYPE, int TAG_INDEX) { - typedef int(_cdecl* _TAG_GET)(int, int); + typedef void*(_cdecl* _TAG_GET)(int, int); static _TAG_GET TAG_GET = CAST_PTR(_TAG_GET, 0x52F150); return TAG_GET(TAG_TYPE, TAG_INDEX); } + +static void *TAG_GET(char TAG_GROUP, int TAG_INDEX) +{ + return TAG_GET(static_cast(TAG_GROUP), TAG_INDEX); +} + static DWORD TAG_NEW(int TAG_TYPE, char* TAG_PATH) { typedef DWORD(_cdecl* _TAG_NEW)(int, char*); @@ -107,6 +113,19 @@ static int GET_STRING_ID(const char *string) return get_string_id_impl(string); } +static bool TAG_RENAME(int tag_index, const char *new_name) +{ + typedef char (__cdecl *TAG_RENAME)(int tag_index, const char *new_name); + auto TAG_RENAME_IMPL = reinterpret_cast(0x0052F840); + + return TAG_RENAME_IMPL(tag_index, new_name); +} + +static bool TAG_RENAME(int tag_index, const std::string &new_name) +{ + return TAG_RENAME(tag_index, new_name.c_str()); +} + typedef bool (*find_tag_comparison)(void *element, void *find_data); static unsigned int FIND_TAG_BLOCK_ELEMENT(tag_block_ref *tag_block, size_t element_size, find_tag_comparison search_func, void *data) diff --git a/H2Codez/H2Tool/H2Tool_Commands.cpp b/H2Codez/H2Tool/H2Tool_Commands.cpp index 0c2aaf4..5f05e23 100644 --- a/H2Codez/H2Tool/H2Tool_Commands.cpp +++ b/H2Codez/H2Tool/H2Tool_Commands.cpp @@ -699,6 +699,35 @@ void H2ToolPatches::fix_command_line() PatchCall(0x00751F83, __crtGetCommandLineW_hook); } +void tag_dump(int tag_index) +{ + char old_name[0x200]; + strncpy_s(old_name, TAG_GET_NAME(tag_index), sizeof(old_name)); + + std::string new_name = "dump\\"; + new_name += old_name; + + printf("dumping tag '%s' as '%s' ***\n", old_name, new_name.c_str()); + + TAG_RENAME(tag_index, new_name); + TAG_SAVE(tag_index); + TAG_RENAME(tag_index, old_name); +} + +char __cdecl scenario_write_patch_file_hook(int TAG_INDEX, int a2) +{ + typedef char (__cdecl *scenario_write_patch_file)(int TAG_INDEX, int a2); + auto scenario_write_patch_file_impl = reinterpret_cast(0x0056A110); + + tag_dump(TAG_INDEX); + + scnr_tag *scenario = (scnr_tag*)TAG_GET('scnr', TAG_INDEX); + for (int i = 0; i < scenario->structureBSPs.size; i++) + tag_dump(scenario->structureBSPs.data[i].structureBSP.tag_index); + + return scenario_write_patch_file_impl(TAG_INDEX, a2); +} + void H2ToolPatches::Initialize() { H2PCTool.WriteLog("Dll Successfully Injected to H2Tool"); @@ -720,8 +749,9 @@ void H2ToolPatches::Initialize() std::string cmd = GetCommandLineA(); if (cmd.find("shared_tag_removal") != string::npos) apply_shared_tag_removal_scheme(); - + if (conf.getBoolean("dump_tags_packaging", false)) + PatchCall(0x00588A66, scenario_write_patch_file_hook); } diff --git a/H2Codez/H2Tool/H2Tool_extra_commands.inl b/H2Codez/H2Tool/H2Tool_extra_commands.inl index c968c6f..24da965 100644 --- a/H2Codez/H2Tool/H2Tool_extra_commands.inl +++ b/H2Codez/H2Tool/H2Tool_extra_commands.inl @@ -175,7 +175,7 @@ tag_data_struct** global_sbsp_data_list; static void _cdecl TAG_RENDER_MODEL_IMPORT_PROC(filo *sFILE_REF, char* _TAG_INDEX_) { DWORD TAG_INDEX = (DWORD)_TAG_INDEX_; - DWORD MODE_TAG = TAG_GET('mode', TAG_INDEX); + DWORD MODE_TAG = (DWORD)TAG_GET('mode', TAG_INDEX); DWORD import_info_block_offset = MODE_TAG + 0xC; if (MODE_TAG != -1) { @@ -288,7 +288,7 @@ static void *jms_collision_geometry_import_defination_ = CAST_PTR(void*, 0x97C35 static bool _cdecl h2pc_generate_render_model_(DWORD TAG_INDEX, filo& FILE_REF) { - DWORD mode_tag_file = TAG_GET('mode', TAG_INDEX); + DWORD mode_tag_file = (DWORD)TAG_GET('mode', TAG_INDEX); DWORD import_info_block_offset = mode_tag_file + 0xC; DWORD SBSP_FOLDER_LOAD_1 = 0x41C835; @@ -378,7 +378,7 @@ static bool _cdecl h2pc_import_render_model_proc(wcstring* arguments) DWORD TAG_INDEX = TAG_LOAD('mode', path.c_str(), 7); if (TAG_INDEX != -1) { - DWORD RENDER_MODEL_TAG = TAG_GET('mode', TAG_INDEX); + DWORD RENDER_MODEL_TAG = (DWORD)TAG_GET('mode', TAG_INDEX); DWORD import_info_field = RENDER_MODEL_TAG + 0xC; if (!load_model_object_definations_(import_info_field, jms_collision_geometry_import_defination_, 1, filo)) diff --git a/H2Codez/Tags/ScenarioTag.h b/H2Codez/Tags/ScenarioTag.h index 8e11015..6dea968 100644 --- a/H2Codez/Tags/ScenarioTag.h +++ b/H2Codez/Tags/ScenarioTag.h @@ -2,6 +2,33 @@ #pragma pack(1) #include "../Common/BasicTagTypes.h" +struct scenario_structure_bsp_reference_block +{ + BYTE padding26[16]; + // TagReference("sbsp") + tag_ref structureBSP; + // TagReference("ltmp") + tag_ref structureLightmap; + BYTE padding27[4]; + float uNUSEDRadianceEstSearchDistance; + BYTE padding28[4]; + float uNUSEDLuminelsPerWorldUnit; + float uNUSEDOutputWhiteReference; + BYTE padding29[8]; + + enum Flags : short + { + DefaultSkyEnabled = 0x1, + }; + Flags flags; + BYTE padding30[2]; + // BlockIndex1("scenario_sky_reference_block") + short defaultSky; + BYTE padding31[2]; +}; +CHECK_STRUCT_SIZE(scenario_structure_bsp_reference_block, 84); + + struct cs_point_block { char name[32]; @@ -118,7 +145,7 @@ struct scnr_tag tag_ref customObjectNames; tag_ref chapterTitleText; tag_ref hUDMessages; - tag_block_ref structureBSPs; + tag_block structureBSPs; tag_block_ref scenarioResources; tag_block_ref scenarioResources_unused; tag_block_ref hsUnitSeats;