diff --git a/.editorconfig b/.editorconfig index ebfe3d8..8686eed 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,3 +10,6 @@ end_of_line = lf [*.yml] indent_style = space indent_size = 2 + +[{CMakeLists.txt,*.cmake}] +indent_style = space diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..be9d7ad --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +*.c text eol=lf +*.h text eol=lf +*.cmake text eol=lf +*.txt text eol=lf diff --git a/.gitignore b/.gitignore index edce00f..c5700d6 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,11 @@ /OniProj/OniWin32Projs/TEVCProj/templateInfo.txt /OniProj/OniWin32Projs/TEVCProj/templatechangelog.txt /OniProj/OniWin32Projs/TEVCProj/TE.out +/OniProj/OniCMakeProjs/TEVCProj/TE.out +/OniProj/OniCMakeProjs/TEVCProj/TE_Errors.txt +/OniProj/OniCMakeProjs/TEVCProj/debugger.txt +/OniProj/OniCMakeProjs/TEVCProj/templateInfo.txt +/OniProj/OniCMakeProjs/TEVCProj/templateSwapCodes.txt +/OniProj/OniCMakeProjs/TEVCProj/templatechangelog.txt +/OniProj/OniCMakeProjs/TEVCProj/templatechecksum.c + diff --git a/BungieFrameWork/BFW_Source/BFW_FileManager/BFW_FileManager_Common.c b/BungieFrameWork/BFW_Source/BFW_FileManager/BFW_FileManager_Common.c index a0d0999..8823e43 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileManager/BFW_FileManager_Common.c +++ b/BungieFrameWork/BFW_Source/BFW_FileManager/BFW_FileManager_Common.c @@ -884,6 +884,8 @@ BFrFileRef_MakeFromName( UUtError error = UUcError_None; BFtFileRef *new_file_ref = UUrMemory_Block_New(sizeof(BFtFileRef)); + *outFileRef = NULL; + if (NULL == new_file_ref) { error = UUcError_OutOfMemory; goto exit; diff --git a/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TM_Common.c b/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TM_Common.c index f2246d6..55ae3a1 100644 --- a/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TM_Common.c +++ b/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TM_Common.c @@ -83,6 +83,7 @@ TMiSwapCode_Dump_Recursive( UUtBool stop; UUtUns8 count; UUtUns32 savedDataOffset; + UUtUns32 value; curSwapCode = *ioSwapCode; @@ -179,11 +180,12 @@ TMiSwapCode_Dump_Recursive( case TMcSwapCode_TemplatePtr: TMiSwapCode_Dump_Indent(inFile, inIndent, curDataOffset, curSwapCode - inSwapCodeBase - 1); + memcpy(&value, curSwapCode, sizeof(UUtUns32)); fprintf(inFile, "templatePtr(%02x): %c%c%c%c\n", TMcSwapCode_TemplatePtr, - (*(UUtUns32*)curSwapCode >> 24) & 0xFF, - (*(UUtUns32*)curSwapCode >> 16) & 0xFF, - (*(UUtUns32*)curSwapCode >> 8) & 0xFF, - (*(UUtUns32*)curSwapCode >> 0) & 0xFF); + (value >> 24) & 0xFF, + (value >> 16) & 0xFF, + (value >> 8) & 0xFF, + (value >> 0) & 0xFF); curSwapCode += 4; curDataOffset += 4; diff --git a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Extract.c b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Extract.c index f550abd..11273ea 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Extract.c +++ b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Extract.c @@ -158,11 +158,11 @@ TEiExtract_WriteSwapCodes_Recursive( if(inType->baseType != NULL) { UUmAssert(inType->baseType->kind == TEcTypeKind_Template); - *(UUtUns32*)curSwapCodePtr = inType->baseType->u.templateInfo.templateTag; + memcpy(curSwapCodePtr, &inType->baseType->u.templateInfo.templateTag, sizeof(UUtUns32)); } else { - *(UUtUns32*)curSwapCodePtr = 0; + memset(curSwapCodePtr, 0, sizeof(UUtUns32)); } curSwapCodePtr += 4; break; diff --git a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TemplateExtractor.c b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TemplateExtractor.c index 57eb471..3a36bde 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TemplateExtractor.c +++ b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TemplateExtractor.c @@ -27,9 +27,9 @@ #include "Oni_Platform.h" // For ONtPlatformData -#define TEcInputFileName "..\\..\\TemplateFileList.txt" -#define TEcTemplateDatFileName "..\\..\\GameDataFolder\\template.dat" -#define TEcTemplateNameDatFileName "..\\..\\GameDataFolder\\template.nam" +#define TEcInputFileName "../../TemplateFileList.txt" +#define TEcTemplateDatFileName "../../GameDataFolder/template.dat" +#define TEcTemplateNameDatFileName "../../GameDataFolder/template.nam" UUtBool TEgError = UUcFalse; diff --git a/CMakeLists.txt b/CMakeLists.txt index 502bbb2..c63d772 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,10 +85,13 @@ include_directories( ) if (Platform_SDL) - include_directories( - OniProj/OniGameSource/Platform_SDL/ - BungieFrameWork/BFW_Source/BFW_SoundSystem2/Platform_OpenAL/ - ) + find_package(OpenGL REQUIRED) + find_package(OpenAL REQUIRED) + find_package(SDL2 REQUIRED) + include_directories( + OniProj/OniGameSource/Platform_SDL/ + BungieFrameWork/BFW_Source/BFW_SoundSystem2/Platform_OpenAL/ + ) elseif(WIN32) include_directories( BungieFrameWork/BFW_Source/BFW_LocalInput/Platform_Win32/ diff --git a/OniProj/OniCMakeProjs/OniProj/CMakeLists.txt b/OniProj/OniCMakeProjs/OniProj/CMakeLists.txt index 5e71f97..6854bbd 100644 --- a/OniProj/OniCMakeProjs/OniProj/CMakeLists.txt +++ b/OniProj/OniCMakeProjs/OniProj/CMakeLists.txt @@ -479,9 +479,6 @@ set(SOURCE_FILES ../../OniGameSource/Oni_Weapon.h) if(Platform_SDL) - find_package(OpenGL REQUIRED) - find_package(OpenAL REQUIRED) - find_package(SDL2 REQUIRED) find_package(PkgConfig) if(PKG_CONFIG_FOUND) pkg_check_modules(LIBAV REQUIRED IMPORTED_TARGET libavcodec libavutil) diff --git a/OniProj/OniCMakeProjs/TEVCProj/CMakeLists.txt b/OniProj/OniCMakeProjs/TEVCProj/CMakeLists.txt index f453823..5a5dd49 100644 --- a/OniProj/OniCMakeProjs/TEVCProj/CMakeLists.txt +++ b/OniProj/OniCMakeProjs/TEVCProj/CMakeLists.txt @@ -1,6 +1,8 @@ project(TEVCProj) -set(BFW_SOURCE_FILES +set(templatechecksum_path "${OniAll_SOURCE_DIR}/OniProj/OniWin32Projs/ImpConsole/templatechecksum.c") + +add_executable(TEVCProj ../../../BungieFrameWork/BFW_Source/BFW_AppUtilities/BFW_AppUtilities.c ../../../BungieFrameWork/BFW_Source/BFW_FileManager/BFW_FileManager_Common.c ../../../BungieFrameWork/BFW_Source/BFW_Group/BFW_Group.c @@ -21,21 +23,36 @@ set(BFW_SOURCE_FILES ../../../BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Extract.c ../../../BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Parser.c ../../../BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Symbol.c + + # shoved here for now + ${templatechecksum_path} ) -if (WIN32) - add_executable(TEVCProj - ${BFW_SOURCE_FILES} - ../../../BungieFrameWork/BFW_Source/BFW_DebuggerSymbols/BFW_DebuggerSymbols_Win32.c - ../../../BungieFrameWork/BFW_Source/BFW_FileManager/Platform_Win32/BFW_FileManager_Win32.c - ../../../BungieFrameWork/BFW_Source/BFW_Utility/Platform_Win32/BFW_Platform_Win32.c +target_precompile_headers(TEVCProj PRIVATE ../../../BungieFrameWork/BFW_Headers/BFW_MasterHeader.h) - # shoved here for now - ../../OniWin32Projs/ImpConsole/templatechecksum.c +if (Platform_SDL) + target_sources(TEVCProj PRIVATE + ../../../BungieFrameWork/BFW_Source/BFW_Utility/Platform_SDL/BFW_Platform_SDL.c ) + target_compile_definitions(TEVCProj PRIVATE UUmSDL=1) + target_link_libraries(TEVCProj PRIVATE + SDL2::SDL2 + ) +endif() - target_precompile_headers(TEVCProj PRIVATE ../../../BungieFrameWork/BFW_Headers/BFW_MasterHeader.h) -endif () +if (LINUX) + target_sources(TEVCProj PRIVATE + ../../../BungieFrameWork/BFW_Source/BFW_FileManager/Platform_Linux/BFW_FileManager_Linux.c + ../../../BungieFrameWork/BFW_Source/BFW_DebuggerSymbols/BFW_DebuggerSymbols_Win32.c + ) + target_link_libraries(TEVCProj PRIVATE m) +elseif (WIN32) + target_sources(TEVCProj PRIVATE + ../../../BungieFrameWork/BFW_Source/BFW_DebuggerSymbols/BFW_DebuggerSymbols_Win32.c + ../../../BungieFrameWork/BFW_Source/BFW_FileManager/Platform_Win32/BFW_FileManager_Win32.c + ../../../BungieFrameWork/BFW_Source/BFW_Utility/Platform_Win32/BFW_Platform_Win32.c + ) +endif() if (MSVC) target_compile_options(TEVCProj @@ -44,31 +61,29 @@ if (MSVC) ) endif () -set(TEVCWorkingDirectory "${CMAKE_SOURCE_DIR}/OniProj/OniCMakeProjs/TEVCProj") - if (TARGET TEVCProj AND NOT CMAKE_CROSSCOMPILING) - message("Found TEVCProj under output directory, attempting to update templatechecksum.c") - execute_process( - COMMAND TEVCProj - WORKING_DIRECTORY "${TEVCWorkingDirectory}") + set(TEVCWorkingDirectory "${OniAll_SOURCE_DIR}/OniProj/OniCMakeProjs/TEVCProj") + set(intermediate_templatechecksum_path "${TEVCWorkingDirectory}/templatechecksum.c") + + # Create list of headers contributing to templates + set(path_template_file_list_txt "${OniAll_SOURCE_DIR}/OniProj/TemplateFileList.txt") + file(STRINGS "${path_template_file_list_txt}" header_paths) + list(TRANSFORM header_paths REPLACE "[\\]" "/") + list(TRANSFORM header_paths PREPEND "${TEVCWorkingDirectory}/") - # check if anything was spat out - if (EXISTS "${TEVCWorkingDirectory}/templatechecksum.c") - message("Overwriting templatechecksum.c with new copy...") - # remove it, overwrite is unreliable/unsupported with cmake? - file(REMOVE "${CMAKE_SOURCE_DIR}/OniProj/OniWin32Projs/ImpConsole/templatechecksum.c") - # and now copy the new file over - file(COPY_FILE - "${TEVCWorkingDirectory}/templatechecksum.c" - "${CMAKE_SOURCE_DIR}/OniProj/OniWin32Projs/ImpConsole/templatechecksum.c" - RESULT error - ) - if (NOT ${error} EQUAL 0) - message(FATAL_ERROR "Failed to copy templatechecksum.c to destination!") - endif () - else () - message("No output found, likely checksum match.") - endif () + # Automatically regenerate templatechecksum.c + add_custom_command( + OUTPUT "${intermediate_templatechecksum_path}" + COMMAND TEVCProj + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${intermediate_templatechecksum_path}" "${templatechecksum_path}" + DEPENDS TEVCProj "${path_template_file_list_txt}" ${header_paths} + WORKING_DIRECTORY "${TEVCWorkingDirectory}") + # Add manual regenerate-templatechecksum target to force regeneration + add_custom_target(regenerate-templatechecksum + COMMAND TEVCProj + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${intermediate_templatechecksum_path}" "${templatechecksum_path}" + DEPENDS TEVCProj + WORKING_DIRECTORY "${TEVCWorkingDirectory}") else () - message(" Failed to find TEVCProj under output directory (${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) !") + message(STATUS "TEVCProj not available: templatechecksum.c will not be regenerated") endif () diff --git a/OniProj/TemplateFileList.txt b/OniProj/TemplateFileList.txt index 742ce07..195a362 100644 --- a/OniProj/TemplateFileList.txt +++ b/OniProj/TemplateFileList.txt @@ -1,45 +1,45 @@ -..\..\..\BungieFrameWork\BFW_Headers\BFW_Image.h -..\..\..\BungieFrameWork\BFW_Headers\BFW_Collision.h -..\..\..\BungieFrameWork\BFW_Headers\BFW_TemplateManager.h -..\..\..\BungieFrameWork\BFW_Headers\BFW_Motoko.h -..\..\..\BungieFrameWork\BFW_Headers\BFW_Path.h -..\..\..\BungieFrameWork\BFW_Headers\BFW_Particle.h -..\..\..\BungieFrameWork\BFW_Headers\BFW_Particle2.h -..\..\..\BungieFrameWork\BFW_Headers\BFW_Effect.h -..\..\..\BungieFrameWork\BFW_Headers\BFW_EnvParticle.h -..\..\..\BungieFrameWork\BFW_Headers\BFW_Materials.h -..\..\..\BungieFrameWork\BFW_Headers\BFW_SoundSystem.h -..\..\..\BungieFrameWork\BFW_Headers\BFW_SoundSystem2.h -..\..\..\BungieFrameWork\BFW_Headers\BFW_Totoro.h -..\..\..\BungieFrameWork\BFW_Source\BFW_Totoro\BFW_Totoro_Private.h -..\..\..\BungieFrameWork\BFW_Headers\BFW_TextSystem.h -..\..\..\BungieFrameWork\BFW_Headers\BFW_ErrorCodes.h -..\..\..\BungieFrameWork\BFW_Headers\BFW_MathLib.h -..\..\..\BungieFrameWork\BFW_Source\BFW_Object\BFW_Object_Templates.h -..\..\..\BungieFrameWork\BFW_Headers\BFW_Doors.h -..\..\..\BungieFrameWork\BFW_Headers\BFW_BinaryData.h -..\..\..\BungieFrameWork\BFW_Source\BFW_WindowManager\WM_PartSpecification\WM_PartSpecification.h -..\..\..\BungieFrameWork\BFW_Source\BFW_WindowManager\WM_Cursor\WM_Cursor.h -..\..\..\BungieFrameWork\BFW_Source\BFW_WindowManager\WM_Dialog\WM_Dialog.h -..\..\..\BungieFrameWork\BFW_Source\BFW_WindowManager\WM_Windows\WM_Menu.h -..\..\..\BungieFrameWork\BFW_Source\BFW_WindowManager\WM_Windows\WM_MenuBar.h -..\..\..\OniProj\OniGameSource\Oni_Sky.h -..\..\..\OniProj\OniGameSource\Oni_Weapon.h -..\..\..\OniProj\OniGameSource\Oni_AI\Oni_AI.h -..\..\..\BungieFrameWork\BFW_Headers\BFW_Akira.h -..\..\..\OniProj\OniGameSource\Oni_AI\Oni_AI_Script.h -..\..\..\OniProj\OniGameSource\Oni_AI\Oni_AI2.h -..\..\..\OniProj\OniGameSource\Oni_AI\Oni_AI2_Targeting.h -..\..\..\OniProj\OniGameSource\Oni_AI\Oni_AI2_Combat.h -..\..\..\OniProj\OniGameSource\ONI_Character.h -..\..\..\OniProj\OniGameSource\Oni_AI\Oni_AI_Setup.h -..\..\..\OniProj\OniGameSource\Oni_GameState.h -..\..\..\OniProj\OniGameSource\Oni_Level.h -..\..\..\OniProj\OniGameSource\Oni_Film.h -..\..\..\OniProj\OniGameSource\Oni_UnitViewer.h -..\..\..\OniProj\OniGameSource\Oni_Object\Oni_Object.h -..\..\..\OniProj\OniGameSource\Oni.h -..\..\..\OniProj\OniGameSource\Oni_InGameUI.h -..\..\..\OniProj\OniGameSource\Oni_Sound2.h -..\..\..\OniProj\OniGameSource\Oni_GameSettings.h +../../../BungieFrameWork/BFW_Headers/BFW_Image.h +../../../BungieFrameWork/BFW_Headers/BFW_Collision.h +../../../BungieFrameWork/BFW_Headers/BFW_TemplateManager.h +../../../BungieFrameWork/BFW_Headers/BFW_Motoko.h +../../../BungieFrameWork/BFW_Headers/BFW_Path.h +../../../BungieFrameWork/BFW_Headers/BFW_Particle.h +../../../BungieFrameWork/BFW_Headers/BFW_Particle2.h +../../../BungieFrameWork/BFW_Headers/BFW_Effect.h +../../../BungieFrameWork/BFW_Headers/BFW_EnvParticle.h +../../../BungieFrameWork/BFW_Headers/BFW_Materials.h +../../../BungieFrameWork/BFW_Headers/BFW_SoundSystem.h +../../../BungieFrameWork/BFW_Headers/BFW_SoundSystem2.h +../../../BungieFrameWork/BFW_Headers/BFW_Totoro.h +../../../BungieFrameWork/BFW_Source/BFW_Totoro/BFW_Totoro_Private.h +../../../BungieFrameWork/BFW_Headers/BFW_TextSystem.h +../../../BungieFrameWork/BFW_Headers/BFW_ErrorCodes.h +../../../BungieFrameWork/BFW_Headers/BFW_MathLib.h +../../../BungieFrameWork/BFW_Source/BFW_Object/BFW_Object_Templates.h +../../../BungieFrameWork/BFW_Headers/BFW_Doors.h +../../../BungieFrameWork/BFW_Headers/BFW_BinaryData.h +../../../BungieFrameWork/BFW_Source/BFW_WindowManager/WM_PartSpecification/WM_PartSpecification.h +../../../BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Cursor/WM_Cursor.h +../../../BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Dialog/WM_Dialog.h +../../../BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Menu.h +../../../BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_MenuBar.h +../../../OniProj/OniGameSource/Oni_Sky.h +../../../OniProj/OniGameSource/Oni_Weapon.h +../../../OniProj/OniGameSource/Oni_AI/Oni_AI.h +../../../BungieFrameWork/BFW_Headers/BFW_Akira.h +../../../OniProj/OniGameSource/Oni_AI/Oni_AI_Script.h +../../../OniProj/OniGameSource/Oni_AI/Oni_AI2.h +../../../OniProj/OniGameSource/Oni_AI/Oni_AI2_Targeting.h +../../../OniProj/OniGameSource/Oni_AI/Oni_AI2_Combat.h +../../../OniProj/OniGameSource/Oni_Character.h +../../../OniProj/OniGameSource/Oni_AI/Oni_AI_Setup.h +../../../OniProj/OniGameSource/Oni_GameState.h +../../../OniProj/OniGameSource/Oni_Level.h +../../../OniProj/OniGameSource/Oni_Film.h +../../../OniProj/OniGameSource/Oni_UnitViewer.h +../../../OniProj/OniGameSource/Oni_Object/Oni_Object.h +../../../OniProj/OniGameSource/Oni.h +../../../OniProj/OniGameSource/Oni_InGameUI.h +../../../OniProj/OniGameSource/Oni_Sound2.h +../../../OniProj/OniGameSource/Oni_GameSettings.h