From aabf57f230fd40c401da0e685f08a9a63a3c10b0 Mon Sep 17 00:00:00 2001 From: Supermario1313 Date: Tue, 27 Sep 2022 16:36:00 +0200 Subject: [PATCH] Make the beta 4 patch 4 hotfix LunaLua build compilable with Clang --- .gitignore | 24 +- .gitmodules | 3 + CMakeLists.txt | 16 +- CrossCompilation/LICENSE | 21 ++ CrossCompilation/Makefile | 26 ++ CrossCompilation/clang-cl-msvc.cmake | 316 ++++++++++++++++++ CrossCompilation/dumpbin | 3 + CrossCompilation/llvm-mt-wrapper | 28 ++ CrossCompilation/llvm-rc-wrapper | 77 +++++ CrossCompilation/msvc/include/.gitkeep | 0 CrossCompilation/msvc/lib/x86/.gitkeep | 0 CrossCompilation/powershell | 3 + .../winsdk/Include/v7.1A/ucrt/.gitkeep | 0 .../winsdk/Include/v7.1A/um/.gitkeep | 0 .../winsdk/Lib/v7.1A/ucrt/x86/.gitkeep | 0 .../winsdk/Lib/v7.1A/um/x86/.gitkeep | 0 LunaDll/CMakeLists.txt | 47 ++- LunaDll/Defines.h | 5 +- LunaDll/FileManager/config_manager.cpp | 30 +- LunaDll/GameConfig/GameConfiguration.cpp | 6 +- LunaDll/GameConfig/GameConfiguration.h | 2 +- LunaDll/GlobalFuncs.h | 15 + LunaDll/Globals.cpp | 2 +- LunaDll/Globals.h | 2 +- LunaDll/Input/LunaGameController.cpp | 4 +- LunaDll/LuaMain/LuaHelper.cpp | 14 +- LunaDll/LuaMain/LuaHelper.h | 29 +- LunaDll/LuaMain/LuaProxy.h | 38 +-- .../LuaProxyGlobalFunctions.cpp | 17 +- .../LuaProxyComponent/LuaProxyShader.cpp | 2 +- LunaDll/LuaMain/LuaProxyFFI.cpp | 2 +- LunaDll/LuaMain/LunaLuaMain.cpp | 4 +- LunaDll/LunaDll.rc | Bin 12068 -> 5816 bytes LunaDll/LunaDll.vcxproj | 43 ++- LunaDll/LunaDll.vcxproj.filters | 69 +++- LunaDll/Misc/AsyncHTTPClient.cpp | 4 +- LunaDll/Misc/ErrorReporter.cpp | 3 + LunaDll/Misc/LoadScreen.cpp | 2 +- LunaDll/Misc/ResourceFileMapper.cpp | 6 +- LunaDll/Misc/ResourceFileMapper.h | 6 +- LunaDll/Misc/RuntimeHook.h | 104 ++++++ .../RuntimeHookHooks.cpp | 26 +- LunaDll/Misc/RuntimeHookUtils/APIHook.cpp | 6 +- LunaDll/Rendering/BitBltEmulation.cpp | 2 +- LunaDll/Rendering/GL/GLCompat.h | 2 +- LunaDll/Rendering/GL/GLContextManager.cpp | 2 +- LunaDll/Rendering/GL/GLContextManager.h | 2 +- LunaDll/Rendering/GL/GLDraw.cpp | 2 +- LunaDll/Rendering/GL/GLDraw.h | 2 +- LunaDll/Rendering/GL/GLEngine.cpp | 2 +- LunaDll/Rendering/GL/GLEngine.h | 2 +- LunaDll/Rendering/GL/GLEngineProxy.h | 2 +- LunaDll/Rendering/GL/GLFramebuffer.h | 2 +- LunaDll/Rendering/GL/GLInitTest.cpp | 2 +- LunaDll/Rendering/GL/GLSplitSprite.h | 2 +- LunaDll/Rendering/GL/GLSprite.h | 2 +- LunaDll/Rendering/GL/GLTextureStore.cpp | 4 +- LunaDll/Rendering/GL/GLTextureStore.h | 2 +- LunaDll/Rendering/LunaImage.cpp | 6 +- LunaDll/Rendering/Rendering.cpp | 2 +- LunaDll/Rendering/SMBXImageCategories.h | 34 +- .../Rendering/Shaders/GLShaderVariableEntry.h | 2 +- .../Rendering/Shaders/GLShaderVariableInfo.h | 2 +- LunaDll/SMBXInternal/Animation.h | 2 +- LunaDll/SMBXInternal/BGOs.h | 2 +- LunaDll/SMBXInternal/BaseItemArray.h | 17 +- LunaDll/SMBXInternal/Blocks.h | 2 +- LunaDll/SMBXInternal/CollectedStarRecord.h | 2 +- LunaDll/SMBXInternal/Layer.h | 2 +- LunaDll/SMBXInternal/Menu.h | 2 +- LunaDll/SMBXInternal/Musicbox.h | 2 +- LunaDll/SMBXInternal/Path.h | 2 +- LunaDll/SMBXInternal/PlayerMOB.h | 9 +- LunaDll/SMBXInternal/SMBXEvents.h | 2 +- LunaDll/SMBXInternal/Scenery.h | 2 +- LunaDll/SMBXInternal/Sound.cpp | 2 +- LunaDll/SMBXInternal/Tile.h | 2 +- LunaDll/SMBXInternal/Warp.h | 2 +- LunaDll/SMBXInternal/Water.h | 2 +- LunaDll/SMBXInternal/WorldLevel.h | 2 +- LunaDll/SdlMusic/SdlMusPlayer.cpp | 4 +- LunaDll/libs/luabind-deboostified | 1 + LunaDll/resource.h | Bin 2186 -> 1062 bytes README.md | 20 +- 84 files changed, 938 insertions(+), 226 deletions(-) create mode 100644 CrossCompilation/LICENSE create mode 100644 CrossCompilation/Makefile create mode 100644 CrossCompilation/clang-cl-msvc.cmake create mode 100755 CrossCompilation/dumpbin create mode 100755 CrossCompilation/llvm-mt-wrapper create mode 100755 CrossCompilation/llvm-rc-wrapper create mode 100644 CrossCompilation/msvc/include/.gitkeep create mode 100644 CrossCompilation/msvc/lib/x86/.gitkeep create mode 100755 CrossCompilation/powershell create mode 100644 CrossCompilation/winsdk/Include/v7.1A/ucrt/.gitkeep create mode 100644 CrossCompilation/winsdk/Include/v7.1A/um/.gitkeep create mode 100644 CrossCompilation/winsdk/Lib/v7.1A/ucrt/x86/.gitkeep create mode 100644 CrossCompilation/winsdk/Lib/v7.1A/um/x86/.gitkeep create mode 160000 LunaDll/libs/luabind-deboostified diff --git a/.gitignore b/.gitignore index b8a886fd9..31bc0396c 100644 --- a/.gitignore +++ b/.gitignore @@ -258,4 +258,26 @@ HardcodedGraphicsData /LunaLoader-bin.zip /SMBX-Launcher.zip -*.bak \ No newline at end of file +*.bak + +# clangd +compile_commands.json +.cache + +# cmake +/CrossCompilation/build/ + +# Windows SDK +/CrossCompilation/msvc/include/** +/CrossCompilation/msvc/lib/x86/** +/CrossCompilation/winsdk/Include/v7.1A/ucrt/** +/CrossCompilation/winsdk/Include/v7.1A/um/** +/CrossCompilation/winsdk/Lib/v7.1A/ucrt/x86/** +/CrossCompilation/winsdk/Lib/v7.1A/um/x86/** + +!/CrossCompilation/msvc/include/.gitkeep +!/CrossCompilation/msvc/lib/x86/.gitkeep +!/CrossCompilation/winsdk/Include/v7.1A/ucrt/.gitkeep +!/CrossCompilation/winsdk/Include/v7.1A/um/.gitkeep +!/CrossCompilation/winsdk/Lib/v7.1A/ucrt/x86/.gitkeep +!/CrossCompilation/winsdk/Lib/v7.1A/um/x86/.gitkeep diff --git a/.gitmodules b/.gitmodules index dee567e15..4a7880687 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "LunaDll/libs/PGE_File_Formats"] path = LunaDll/libs/PGE_File_Formats url = https://github.com/WohlSoft/PGE-File-Library-STL +[submodule "LunaDll/libs/luabind-deboostified"] + path = LunaDll/libs/luabind-deboostified + url = https://github.com/WohlSoft/luabind-deboostified diff --git a/CMakeLists.txt b/CMakeLists.txt index 82e1d7237..6bbf275a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required (VERSION 3.7.2) project(LunaLua C CXX) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${LunaLua_BINARY_DIR}") +#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${LunaLua_BINARY_DIR}") if(NOT MSVC) message(FATAL_ERROR "NON-Microsoft Compilers are not supported right now") @@ -12,8 +12,8 @@ if(NOT CMAKE_BUILD_TYPE) endif() # /Fd\"Release\\vc140.pdb\" -set(CMAKE_CXX_FLAGS "" CACHE - STRING "compiler flags" FORCE) +#set(CMAKE_CXX_FLAGS "" CACHE +# STRING "compiler flags" FORCE) set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/Zi /Gm- /O2 /Zc:inline /fp:precise /errorReport:prompt /WX- /Zc:forScope /Gd /Oy- /Oi /MT /EHsc /nologo /FAcs /Ot" CACHE STRING "compiler flags" FORCE) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" CACHE @@ -23,8 +23,8 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" CACHE set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" CACHE STRING "compiler flags" FORCE) -set(CMAKE_C_FLAGS "" CACHE - STRING "compiler flags" FORCE) +#set(CMAKE_C_FLAGS "" CACHE +# STRING "compiler flags" FORCE) set(CMAKE_C_FLAGS_RELWITHDEBINFO "/Zi /Gm- /O2 /Zc:inline /fp:precise /errorReport:prompt /WX- /Zc:forScope /Gd /Oy- /Oi /MT /EHsc /nologo /FAcs /Ot" CACHE STRING "compiler flags" FORCE) set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_RELWITHDEBINFO}" CACHE @@ -35,9 +35,9 @@ set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_RELWITHDEBINFO}" CACHE STRING "compiler flags" FORCE) # /PDB:"C:\Repos\LunaLUA\Release\LunaDll.pdb" -set(CMAKE_SHARED_LINKER_FLAGS "" CACHE - STRING "compiler flags" FORCE) -set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "/NXCOMPAT /DYNAMICBASE /MAPINFO:EXPORTS /DEBUG /DLL /MACHINE:X86 /OPT:REF /SAFESEH:NO /INCREMENTAL:NO /SUBSYSTEM:WINDOWS\",5.01\" /MANIFESTUAC:\"level='asInvoker' uiAccess='false'\" /MAP /OPT:ICF /ERRORREPORT:PROMPT /NOLOGO /TLBID:1" CACHE +#set(CMAKE_SHARED_LINKER_FLAGS "" CACHE +# STRING "compiler flags" FORCE) +set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "/VERBOSE /NXCOMPAT /DYNAMICBASE /MAPINFO:EXPORTS /DEBUG /DLL /MACHINE:X86 /OPT:REF /SAFESEH:NO /INCREMENTAL:NO /SUBSYSTEM:WINDOWS\",5.01\" /MANIFESTUAC:\"level='asInvoker' uiAccess='false'\" /MAP /OPT:ICF /ERRORREPORT:PROMPT /NOLOGO /TLBID:1" CACHE STRING "compiler flags" FORCE) set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO}" CACHE STRING "compiler flags" FORCE) diff --git a/CrossCompilation/LICENSE b/CrossCompilation/LICENSE new file mode 100644 index 000000000..491495a21 --- /dev/null +++ b/CrossCompilation/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Roy van Dam + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/CrossCompilation/Makefile b/CrossCompilation/Makefile new file mode 100644 index 000000000..91f6b20a5 --- /dev/null +++ b/CrossCompilation/Makefile @@ -0,0 +1,26 @@ +.PHONY: all clean + +.EXPORT_ALL_VARIABLES: + +MSVC_BASE = $(shell pwd)/msvc +WINSDK_BASE = $(shell pwd)/winsdk +WINSDK_VER = v7.1A +HOST_ARCH = x86 +MSVC_VER = 1900 + +all: LunaDLL.dll + +LunaDLL.dll: build/build.ninja + cmake --build build + +compile_commands.json: build/build.ninja + cp build/compile_commands.json .. + +build/build.ninja: + mkdir -p build + cd build && cmake ../.. -G Ninja \ + -DCMAKE_TOOLCHAIN_FILE=$(shell pwd)/clang-cl-msvc.cmake \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=1 + +clean: + rm -rf build diff --git a/CrossCompilation/clang-cl-msvc.cmake b/CrossCompilation/clang-cl-msvc.cmake new file mode 100644 index 000000000..3c0c8609d --- /dev/null +++ b/CrossCompilation/clang-cl-msvc.cmake @@ -0,0 +1,316 @@ +## When configuring CMake with a toolchain file against a top-level CMakeLists.txt, +# it will actually run CMake many times, once for each small test program used to +# determine what features a compiler supports. Unfortunately, none of these +# invocations share a CMakeCache.txt with the top-level invocation, meaning they +# won't see the value of any arguments the user passed via -D. Since these are +# necessary to properly configure MSVC in both the top-level configuration as well as +# all feature-test invocations, we set environment variables with the values so that +# these environments get inherited by child invocations. +function(init_user_prop prop) + if(${prop}) + set(ENV{_${prop}} "${${prop}}") + else() + set(${prop} "$ENV{_${prop}}" PARENT_SCOPE) + endif() +endfunction() + +macro(cmake_getconf VAR) + if(NOT ${VAR}) + set(${VAR} "$ENV{${VAR}}") + if(${VAR}) + set(${VAR} "${${VAR}}" CACHE STRING "${VAR}") + message(STATUS "Found ${VAR}: ${${VAR}}") + else() + message(FATAL_ERROR "Cannot determine \"${VAR}\"") + endif() + endif() +endmacro() + +function(generate_winsdk_vfs_overlay winsdk_include_dir output_path) + set(include_dirs) + file(GLOB_RECURSE entries LIST_DIRECTORIES true "${winsdk_include_dir}/*") + foreach(entry ${entries}) + if(IS_DIRECTORY "${entry}") + list(APPEND include_dirs "${entry}") + endif() + endforeach() + + file(WRITE "${output_path}" "version: 0\n") + file(APPEND "${output_path}" "case-sensitive: false\n") + file(APPEND "${output_path}" "roots:\n") + + foreach(dir ${include_dirs}) + file(GLOB headers RELATIVE "${dir}" "${dir}/*.h" "${dir}/*.rh") + if(NOT headers) + continue() + endif() + + file(APPEND "${output_path}" " - name: \"${dir}\"\n") + file(APPEND "${output_path}" " type: directory\n") + file(APPEND "${output_path}" " contents:\n") + + foreach(header ${headers}) + file(APPEND "${output_path}" " - name: \"${header}\"\n") + file(APPEND "${output_path}" " type: file\n") + file(APPEND "${output_path}" " external-contents: \"${dir}/${header}\"\n") + endforeach() + endforeach() +endfunction() + +function(generate_winsdk_lib_symlinks winsdk_um_lib_dir output_dir) + execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${output_dir}") + file(GLOB libraries RELATIVE "${winsdk_um_lib_dir}" "${winsdk_um_lib_dir}/*") + foreach(library ${libraries}) + string(TOLOWER "${library}" symlink_name) + execute_process(COMMAND "${CMAKE_COMMAND}" + -E create_symlink + "${winsdk_um_lib_dir}/${library}" + "${output_dir}/${symlink_name}") + endforeach() +endfunction() + +function(generate_defaultlib_symlinks msvc_lib_dir output_dir) + execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${output_dir}") + set(libraries "libcmt" "libcmtd" "msvcrt" "msvcrtd" "oldnames") + foreach(library ${libraries}) + string(TOUPPER "${library}" symlink_name) + execute_process(COMMAND "${CMAKE_COMMAND}" + -E create_symlink + "${msvc_lib_dir}/${library}.lib" + "${output_dir}/${symlink_name}.lib") + endforeach() +endfunction() + +set(CMAKE_SYSTEM_NAME Windows) +set(CMAKE_SYSTEM_VERSION 10.0) +set(CMAKE_SYSTEM_PROCESSOR AMD64) + +cmake_getconf(HOST_ARCH) +cmake_getconf(MSVC_VER) +cmake_getconf(MSVC_BASE) +cmake_getconf(WINSDK_BASE) +cmake_getconf(WINSDK_VER) + +if(NOT HOST_ARCH) + set(HOST_ARCH x86_64) +endif() +if(HOST_ARCH STREQUAL "aarch64" OR HOST_ARCH STREQUAL "arm64") + set(TRIPLE_ARCH "aarch64") + set(WINSDK_ARCH "arm64") +elseif(HOST_ARCH STREQUAL "armv7" OR HOST_ARCH STREQUAL "arm") + set(TRIPLE_ARCH "armv7") + set(WINSDK_ARCH "arm") +elseif(HOST_ARCH STREQUAL "i686" OR HOST_ARCH STREQUAL "x86") + set(TRIPLE_ARCH "i686") + set(WINSDK_ARCH "x86") +elseif(HOST_ARCH STREQUAL "x86_64" OR HOST_ARCH STREQUAL "x64") + set(TRIPLE_ARCH "x86_64") + set(WINSDK_ARCH "x64") +else() + message(SEND_ERROR "Unknown host architecture ${HOST_ARCH}. Must be aarch64 (or arm64), armv7 (or arm), i686 (or x86), or x86_64 (or x64).") +endif() +if(NOT MSVC_VER) + set(MSVC_VER 19.11) +endif() + +set(MSVC_INCLUDE "${MSVC_BASE}/include") +set(MSVC_LIB "${MSVC_BASE}/lib") +set(WINSDK_INCLUDE "${WINSDK_BASE}/Include/${WINSDK_VER}") +set(WINSDK_LIB "${WINSDK_BASE}/Lib/${WINSDK_VER}") + +if(NOT EXISTS "${MSVC_BASE}" OR + NOT EXISTS "${MSVC_INCLUDE}" OR + NOT EXISTS "${MSVC_LIB}") + message(SEND_ERROR + "CMake variable MSVC_BASE must point to a folder containing MSVC " + "system headers and libraries") +endif() + +if(NOT EXISTS "${WINSDK_BASE}" OR + NOT EXISTS "${WINSDK_INCLUDE}" OR + NOT EXISTS "${WINSDK_LIB}") + message(SEND_ERROR + "CMake variable WINSDK_BASE and WINSDK_VER must resolve to a valid " + "Windows SDK installation") +endif() + +if(NOT EXISTS "${WINSDK_INCLUDE}/um/Windows.h") + message(SEND_ERROR "Cannot find Windows.h") +endif() +if(NOT EXISTS "${WINSDK_INCLUDE}/um/WINDOWS.H") + set(case_sensitive_filesystem TRUE) +endif() + +# Attempt to find the clang-cl binary +find_program(CLANG_CL_PATH NAMES clang-cl) +if(${CLANG_CL_PATH} STREQUAL "CLANG_CL_PATH-NOTFOUND") + message(SEND_ERROR "Unable to find clang-cl") +endif() + +# Attempt to find the llvm-link binary +find_program(LLD_LINK_PATH NAMES lld-link) +if(${LLD_LINK_PATH} STREQUAL "LLD_LINK_PATH-NOTFOUND") + message(SEND_ERROR "Unable to find lld-link") +endif() + +# Attempt to find the lld-lib binary +find_program(LLVM_LIB_PATH NAMES llvm-lib) +if(${LLVM_LIB_PATH} STREQUAL "LLVM_LIB_PATH-NOTFOUND") + message(SEND_ERROR "Unable to find llvm-lib") +endif() + +# Attempt to find the llvm-nm binary +find_program(LLVM_NM_PATH NAMES llvm-nm) +if(${LLVM_NM_PATH} STREQUAL "LLVM_NM_PATH-NOTFOUND") + message(SEND_ERROR "Unable to find llvm-nm") +endif() + +# Attempt to find the llvm-mt binary +#find_program(LLVM_MT_PATH NAMES llvm-mt) +set(LLVM_MT_PATH "${CMAKE_CURRENT_LIST_DIR}/llvm-mt-wrapper") +if(${LLVM_MT_PATH} STREQUAL "LLVM_MT_PATH-NOTFOUND") + message(SEND_ERROR "Unable to find llvm-mt") +endif() + +# Attempt to find the native clang binary +find_program(CLANG_C_PATH NAMES clang) +if(${CLANG_C_PATH} STREQUAL "CLANG_C_PATH-NOTFOUND") + message(SEND_ERROR "Unable to find clang") +endif() + +# Attempt to find the native clang++ binary +find_program(CLANG_CXX_PATH NAMES clang++) +if(${CLANG_CXX_PATH} STREQUAL "CLANG_CXX_PATH-NOTFOUND") + message(SEND_ERROR "Unable to find clang++") +endif() + +# Attempt to find the llvm-rc binary +find_program(LLVM_RC_PATH NAMES llvm-rc) +if(${LLVM_RC_PATH} STREQUAL "LLVM_RC_PATH-NOTFOUND") + message(SEND_ERROR "Unable to find rc") +endif() + + +set(CMAKE_C_COMPILER "${CLANG_CL_PATH}" CACHE FILEPATH "") +set(CMAKE_CXX_COMPILER "${CLANG_CL_PATH}" CACHE FILEPATH "") +#set(CMAKE_RC_COMPILER "${LLVM_RC_PATH}" CACHE FILEPATH "") +# Workaround until llvm-rc parses the .rc files like Microsoft's rc.exe +set(CMAKE_RC_COMPILER "${CMAKE_CURRENT_LIST_DIR}/llvm-rc-wrapper" CACHE FILEPATH "") +set(CMAKE_LINKER "${LLD_LINK_PATH}" CACHE FILEPATH "") +set(CMAKE_AR "${LLVM_LIB_PATH}" CACHE FILEPATH "") +set(CMAKE_NM "${LLVM_NM_PATH}" CACHE FILEPATH "") +set(CMAKE_MT "${LLVM_MT_PATH}" CACHE FILEPATH "") + +# Even though we're cross-compiling, we need some native tools (e.g. llvm-tblgen), and those +# native tools have to be built before we can start doing the cross-build. LLVM supports +# a CROSS_TOOLCHAIN_FLAGS_NATIVE argument which consists of a list of flags to pass to CMake +# when configuring the NATIVE portion of the cross-build. By default we construct this so +# that it points to the tools in the same location as the native clang-cl that we're using. +list(APPEND _CTF_NATIVE_DEFAULT "-DCMAKE_ASM_COMPILER=${CLANG_C_PATH}") +list(APPEND _CTF_NATIVE_DEFAULT "-DCMAKE_C_COMPILER=${CLANG_C_PATH}") +list(APPEND _CTF_NATIVE_DEFAULT "-DCMAKE_CXX_COMPILER=${CLANG_CXX_PATH}") + +set(CROSS_TOOLCHAIN_FLAGS_NATIVE "${_CTF_NATIVE_DEFAULT}" CACHE STRING "") + +set(COMPILE_FLAGS + -Xclang -fexceptions -Xclang -fcxx-exceptions -Xclang + -D_CRT_SECURE_NO_WARNINGS + --target=${TRIPLE_ARCH}-windows-msvc + -fms-compatibility-version=${MSVC_VER} + -fms-extensions + -fms-compatibility + -fdelayed-template-parsing + -Wno-unused-command-line-argument # Needed to accept projects pushing both -Werror and /MP + -Wno-nonportable-include-path + -Wno-microsoft + -imsvc "${MSVC_INCLUDE}" + -imsvc "${WINSDK_INCLUDE}/ucrt" + -imsvc "${WINSDK_INCLUDE}/shared" + -imsvc "${WINSDK_INCLUDE}/um" + -imsvc "${WINSDK_INCLUDE}/winrt") + +if(case_sensitive_filesystem) + # Ensure all sub-configures use the top-level VFS overlay instead of generating their own. + init_user_prop(winsdk_vfs_overlay_path) + if(NOT winsdk_vfs_overlay_path) + set(winsdk_vfs_overlay_path "${CMAKE_BINARY_DIR}/winsdk_vfs_overlay.yaml") + generate_winsdk_vfs_overlay("${WINSDK_BASE}/Include/${WINSDK_VER}" "${winsdk_vfs_overlay_path}") + init_user_prop(winsdk_vfs_overlay_path) + endif() + list(APPEND COMPILE_FLAGS + -Xclang -ivfsoverlay -Xclang "${winsdk_vfs_overlay_path}") + + set(CMAKE_CLANG_VFS_OVERLAY "${winsdk_vfs_overlay_path}") +endif() + +string(REPLACE ";" " " COMPILE_FLAGS "${COMPILE_FLAGS}") + +# We need to preserve any flags that were passed in by the user. However, we +# can't append to CMAKE_C_FLAGS and friends directly, because toolchain files +# will be re-invoked on each reconfigure and therefore need to be idempotent. +# The assignments to the _INITIAL cache variables don't use FORCE, so they'll +# only be populated on the initial configure, and their values won't change +# afterward. +set(_CMAKE_RC_FLAGS_INITIAL -I "${MSVC_INCLUDE}" + -I "${WINSDK_INCLUDE}/ucrt" + -I "${WINSDK_INCLUDE}/shared" + -I "${WINSDK_INCLUDE}/um" + -I "${WINSDK_INCLUDE}/winrt") +string(REPLACE ";" " " _CMAKE_RC_FLAGS_INITIAL "${_CMAKE_RC_FLAGS_INITIAL}") +set(CMAKE_RC_FLAGS "${_CMAKE_RC_FLAGS_INITIAL}" CACHE STRING "" FORCE) + +set(_CMAKE_C_FLAGS_INITIAL "${CMAKE_C_FLAGS}" CACHE STRING "") +set(CMAKE_C_FLAGS "${_CMAKE_C_FLAGS_INITIAL} ${COMPILE_FLAGS}" CACHE STRING "" FORCE) + +set(_CMAKE_CXX_FLAGS_INITIAL "${CMAKE_CXX_FLAGS}" CACHE STRING "") +set(CMAKE_CXX_FLAGS "${_CMAKE_CXX_FLAGS_INITIAL} ${COMPILE_FLAGS}" CACHE STRING "" FORCE) + +set(LINK_FLAGS + # Prevent CMake from attempting to invoke mt.exe. It only recognizes the slashed form and not the dashed form. + #/manifest:no + + -libpath:"${MSVC_LIB}/${WINSDK_ARCH}" + -libpath:"${WINSDK_LIB}/ucrt/${WINSDK_ARCH}" + -libpath:"${WINSDK_LIB}/um/${WINSDK_ARCH}") + +if(case_sensitive_filesystem) + # Ensure all sub-configures use the top-level symlinks dir instead of generating their own. + init_user_prop(winsdk_lib_symlinks_dir) + if(NOT winsdk_lib_symlinks_dir) + set(winsdk_lib_symlinks_dir "${CMAKE_BINARY_DIR}/winsdk_lib_symlinks") + generate_winsdk_lib_symlinks("${WINSDK_BASE}/Lib/${WINSDK_VER}/um/${WINSDK_ARCH}" "${winsdk_lib_symlinks_dir}") + init_user_prop(winsdk_lib_symlinks_dir) + endif() + init_user_prop(defaultlib_symlinks_dir) + if(NOT defaultlib_symlinks_dir) + set(defaultlib_symlinks_dir "${CMAKE_BINARY_DIR}/defaultlib_symlinks") + generate_defaultlib_symlinks("${MSVC_BASE}/lib/${WINSDK_ARCH}" "${defaultlib_symlinks_dir}") + init_user_prop(defaultlib_symlinks_dir) + endif() + list(APPEND LINK_FLAGS + -libpath:"${winsdk_lib_symlinks_dir}" + -libpath:"${defaultlib_symlinks_dir}") +endif() + +string(REPLACE ";" " " LINK_FLAGS "${LINK_FLAGS}") + +# See explanation for compiler flags above for the _INITIAL variables. +set(_CMAKE_EXE_LINKER_FLAGS_INITIAL "${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "") +set(CMAKE_EXE_LINKER_FLAGS "${_CMAKE_EXE_LINKER_FLAGS_INITIAL} ${LINK_FLAGS}" CACHE STRING "" FORCE) + +set(_CMAKE_MODULE_LINKER_FLAGS_INITIAL "${CMAKE_MODULE_LINKER_FLAGS}" CACHE STRING "") +set(CMAKE_MODULE_LINKER_FLAGS "${_CMAKE_MODULE_LINKER_FLAGS_INITIAL} ${LINK_FLAGS}" CACHE STRING "" FORCE) + +set(_CMAKE_SHARED_LINKER_FLAGS_INITIAL "${CMAKE_SHARED_LINKER_FLAGS}" CACHE STRING "") +set(CMAKE_SHARED_LINKER_FLAGS "${_CMAKE_SHARED_LINKER_FLAGS_INITIAL} ${LINK_FLAGS}" CACHE STRING "" FORCE) + +# CMake populates these with a bunch of unnecessary libraries, which requires +# extra case-correcting symlinks and what not. Instead, let projects explicitly +# control which libraries they require. +set(CMAKE_C_STANDARD_LIBRARIES "" CACHE STRING "" FORCE) +set(CMAKE_CXX_STANDARD_LIBRARIES "" CACHE STRING "" FORCE) + +if(NOT $ENV{VCPKG_TOOLCHAIN} STREQUAL "") + message(STATUS "Included VCPKG: $ENV{VCPKG_TOOLCHAIN}") + include($ENV{VCPKG_TOOLCHAIN}) +endif() diff --git a/CrossCompilation/dumpbin b/CrossCompilation/dumpbin new file mode 100755 index 000000000..e2acbbbd6 --- /dev/null +++ b/CrossCompilation/dumpbin @@ -0,0 +1,3 @@ +#! /bin/bash + +echo "${0}: ${@}" diff --git a/CrossCompilation/llvm-mt-wrapper b/CrossCompilation/llvm-mt-wrapper new file mode 100755 index 000000000..310352056 --- /dev/null +++ b/CrossCompilation/llvm-mt-wrapper @@ -0,0 +1,28 @@ +#! /bin/bash + +#dummy_manifest=" +# +# +# +# +# +# +# +# +#" + +echo "${0}: ${@}" + +output="$("llvm-mt" "${@}" 2>&1)" +res=$? + +if [ "$res" -ne 0 ]; then + if echo "$output" | grep -q "no libxml2"; then + echo "llvm-mt not compiled with libxml2, skipping manifest." + exit 0 + fi + echo "$output" +fi + +exit "$res" diff --git a/CrossCompilation/llvm-rc-wrapper b/CrossCompilation/llvm-rc-wrapper new file mode 100755 index 000000000..59bd0f673 --- /dev/null +++ b/CrossCompilation/llvm-rc-wrapper @@ -0,0 +1,77 @@ +#! /bin/bash + +shopt -s nocasematch + +llvm_rc_args=() +while [ $# -gt 1 ]; do + param=$1 + shift + case "$param" in + -c*|/c*) + if [ "${#param}" -eq 2 ]; then + llvm_rc_args+=("/C" "$1") + shift + else + llvm_rc_args+=("/C" "${param:2}") + fi + ;; + -d*|/d*) + if [ "${#param}" -eq 2 ]; then + llvm_rc_args+=("/D" "$1") + shift + else + llvm_rc_args+=("/D" "${param:2}") + fi + ;; + -fo*|/fo*) + if [ "${#param}" -eq 3 ]; then + llvm_rc_args+=("/FO" "$1") + shift + else + llvm_rc_args+=("/FO" "${param:3}") + fi + ;; + -i*|/i*) + if [ "${#param}" -eq 2 ]; then + llvm_rc_args+=("/I" "$1") + shift + else + llvm_rc_args+=("/I" "${param:2}") + fi + ;; + -ln*|/ln*) + if [ "${#param}" -eq 3 ]; then + llvm_rc_args+=("/LN" "$1") + shift + else + llvm_rc_args+=("/LN" "${param:3}") + fi + ;; + -l*|/l*) + if [ "${#param}" -eq 2 ]; then + llvm_rc_args+=("/l" "$1") + shift + else + llvm_rc_args+=("/l" "${param:2}") + fi + ;; + -u*|/u*) + if [ "${#param}" -eq 2 ]; then + llvm_rc_args+=("/U" "$1") + shift + else + llvm_rc_args+=("/U" "${param:2}") + fi + ;; + *) llvm_rc_args+=("$param");; + esac +done + +rc_file=$1 +# Fix: llvm-rc: Error in VERSIONINFO statement (ID 1): +# Non-ASCII 8-bit codepoint (169) can't occur in a non-Unicode string +sed -i "s/\xa9/(C)/g;s/\\\\xa9/(C)/g" "$rc_file" + +llvm_rc_args+=("$rc_file") +echo llvm-rc "${llvm_rc_args[@]}" +llvm-rc "${llvm_rc_args[@]}" diff --git a/CrossCompilation/msvc/include/.gitkeep b/CrossCompilation/msvc/include/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/CrossCompilation/msvc/lib/x86/.gitkeep b/CrossCompilation/msvc/lib/x86/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/CrossCompilation/powershell b/CrossCompilation/powershell new file mode 100755 index 000000000..e2acbbbd6 --- /dev/null +++ b/CrossCompilation/powershell @@ -0,0 +1,3 @@ +#! /bin/bash + +echo "${0}: ${@}" diff --git a/CrossCompilation/winsdk/Include/v7.1A/ucrt/.gitkeep b/CrossCompilation/winsdk/Include/v7.1A/ucrt/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/CrossCompilation/winsdk/Include/v7.1A/um/.gitkeep b/CrossCompilation/winsdk/Include/v7.1A/um/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/CrossCompilation/winsdk/Lib/v7.1A/ucrt/x86/.gitkeep b/CrossCompilation/winsdk/Lib/v7.1A/ucrt/x86/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/CrossCompilation/winsdk/Lib/v7.1A/um/x86/.gitkeep b/CrossCompilation/winsdk/Lib/v7.1A/um/x86/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/LunaDll/CMakeLists.txt b/LunaDll/CMakeLists.txt index f5924a792..86a992cc7 100644 --- a/LunaDll/CMakeLists.txt +++ b/LunaDll/CMakeLists.txt @@ -14,8 +14,7 @@ include(libs/PGE_File_Formats/pge_file_library.cmake) include_directories( ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/libs/boost - ${CMAKE_CURRENT_SOURCE_DIR}/libs/luabind-include + ${CMAKE_CURRENT_SOURCE_DIR}/libs/luabind-deboostified ${CMAKE_CURRENT_SOURCE_DIR}/libs/lua/include ${CMAKE_CURRENT_SOURCE_DIR}/libs/sdl/include ${CMAKE_CURRENT_SOURCE_DIR}/libs/glew/include @@ -23,7 +22,6 @@ include_directories( ) link_directories( - ${CMAKE_CURRENT_SOURCE_DIR}/libs/luabind-lib ${CMAKE_CURRENT_SOURCE_DIR}/libs/lua/lib ${CMAKE_CURRENT_SOURCE_DIR}/libs/sdl/lib ${CMAKE_CURRENT_SOURCE_DIR}/libs/glew/lib/Release/Win32 @@ -37,6 +35,7 @@ set(LunaLua_LibsSources libs/DirManager/dirman_winapi.cpp libs/Utils/files.cpp + libs/Utils/strings.cpp libs/fmt/fmt_format.cpp libs/fmt/fmt_ostream.cpp @@ -59,6 +58,31 @@ set(LunaLua_LibsSources libs/luasocket/timeout.c libs/luasocket/udp.c libs/luasocket/wsocket.c + + libs/luabind-deboostified/src/class.cpp + libs/luabind-deboostified/src/class_info.cpp + libs/luabind-deboostified/src/class_registry.cpp + libs/luabind-deboostified/src/class_rep.cpp + libs/luabind-deboostified/src/CMakeLists.txt + libs/luabind-deboostified/src/create_class.cpp + libs/luabind-deboostified/src/error.cpp + libs/luabind-deboostified/src/exception_handler.cpp + libs/luabind-deboostified/src/function.cpp + libs/luabind-deboostified/src/function_introspection.cpp + libs/luabind-deboostified/src/headertest.cpp + libs/luabind-deboostified/src/inheritance.cpp + libs/luabind-deboostified/src/link_compatibility.cpp + libs/luabind-deboostified/src/object_rep.cpp + libs/luabind-deboostified/src/open.cpp + libs/luabind-deboostified/src/operator.cpp + libs/luabind-deboostified/src/pcall.cpp + libs/luabind-deboostified/src/scope.cpp + libs/luabind-deboostified/src/set_package_preload.cpp + libs/luabind-deboostified/src/stack_content_by_name.cpp + libs/luabind-deboostified/src/weak_ref.cpp + libs/luabind-deboostified/src/wrapper_base.cpp + + ../LunaLoader/LunaLoaderPatch.cpp ) set(LunaLua_Sources @@ -88,6 +112,7 @@ set(LunaLua_Sources HardcodedGraphics/HardcodedGraphicsManager.cpp HardcodedGraphics/HardocodeGFXMap.cpp Input/Input.cpp + Input/LunaGameController.cpp IPC/IPCPipeServer.cpp LevelCodes/dlltestlvlCode.cpp LevelCodes/Docopoper-AbstractAssault.lvl.cpp @@ -101,6 +126,7 @@ set(LunaLua_Sources LevelCodes/SAJewers-Snowboardin.cpp LevelCodes/Talkhaus-Science_Final_Battle.cpp LuaMain/LuaHelper.cpp + LuaMain/LunaPathValidator.cpp LuaMain/LuaProxyComponent/LuaProxyAnimation.cpp LuaMain/LuaProxyComponent/LuaProxyAsyncHTTPRequest.cpp LuaMain/LuaProxyComponent/LuaProxyAudio.cpp @@ -231,10 +257,10 @@ add_library(LunaLuaLibShared MODULE set_target_properties(LunaLuaLibShared PROPERTIES OUTPUT_NAME LunaDll MSVC_RUNTIME_LIBRARY "MultiThreaded" - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/$<$:>" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/$<$:>" - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/$<$:>" - PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/$<$:>" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/out/lib/$<$:>" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/out/bin/$<$:>" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/out/bin/$<$:>" + PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/out/pdb/$<$:>" ) target_compile_definitions(LunaLuaLibShared PRIVATE @@ -270,11 +296,12 @@ target_link_libraries(LunaLuaLibShared odbccp32 winmm shlwapi - libluabind + #libluabind lua51 - Dbghelp - Ws2_32 + dbghelp + ws2_32 setupapi comsuppw opengl32 + delayimp ) diff --git a/LunaDll/Defines.h b/LunaDll/Defines.h index 4ac55c3c8..97eb6962c 100644 --- a/LunaDll/Defines.h +++ b/LunaDll/Defines.h @@ -182,8 +182,9 @@ enum CollidersType : short { #define GM_PLAYER_KEY_STR 9 #define DEFMEM(name, type, addr) static auto& name = *(type*)(addr); \ - static constexpr auto name ## _CONSTPTR = (type*)(addr) -#define DEFMEM_PTR(name, type, addr) static constexpr auto name = (const type*)(addr) + static constexpr std::uintptr_t name ## _ADDR = addr; \ + static auto name ## _POINTER = (type*)(addr); +#define DEFMEM_PTR(name, type, addr) static auto name = (const type*)(addr) // General DEFMEM(GM_SCRN_HDC, HDC, 0x00B25028); diff --git a/LunaDll/FileManager/config_manager.cpp b/LunaDll/FileManager/config_manager.cpp index bbeb22f65..18a643ede 100644 --- a/LunaDll/FileManager/config_manager.cpp +++ b/LunaDll/FileManager/config_manager.cpp @@ -226,19 +226,19 @@ void ConfigPackMiniManager::loadStore(EntryType type, // idx 0=setup, 1=episode, 2=custom ResourceFileInfo iniFiles[3]; - auto& setup_files_it = dst.setup_files.find(wfname); + auto&& setup_files_it = dst.setup_files.find(wfname); if (setup_files_it != dst.setup_files.end()) { iniFiles[0] = setup_files_it->second; } - auto& episode_files_it = m_episode_files.find(wfname); + auto&& episode_files_it = m_episode_files.find(wfname); if (episode_files_it != m_episode_files.end()) { iniFiles[1] = episode_files_it->second; } - auto& custom_files_it = m_custom_files.find(wfname); + auto&& custom_files_it = m_custom_files.find(wfname); if (custom_files_it != m_custom_files.end()) { iniFiles[2] = custom_files_it->second; @@ -524,15 +524,15 @@ ResourceFileInfo ConfigPackMiniManager::findFile(const std::string &filename, co { std::wstring wFilename = Str2WStr(filename); - auto& custom_it = m_custom_files.find(wFilename); + auto&& custom_it = m_custom_files.find(wFilename); if (custom_it != m_custom_files.end()) return custom_it->second; - auto& episode_it = m_episode_files.find(wFilename); + auto&& episode_it = m_episode_files.find(wFilename); if (episode_it != m_episode_files.end()) return episode_it->second; - auto& cp_it = root_files.find(wFilename); + auto&& cp_it = root_files.find(wFilename); if (cp_it != root_files.end()) return cp_it->second; @@ -580,12 +580,12 @@ static void read_layout_branches(nlohmann::json &typetree, if(entry.find("control") == entry.end()) control = "invalid"; else - control = entry["control"]; + control = entry["control"].get(); if(entry.find("name") == entry.end()) name = control; else - name = entry["name"]; + name = entry["name"].get(); if(SDL_strncasecmp(control.c_str(), "group", 6) == 0) { @@ -608,7 +608,7 @@ static void read_layout_branches(nlohmann::json &typetree, { std::string type = "int"; if(entry.find("type") != entry.end()) - type = entry["type"]; + type = entry["type"].get(); if(type == "int") { @@ -688,14 +688,14 @@ static void read_layout_branches(nlohmann::json &typetree, { std::string v; if(entry.find("value-default") != entry.end()) - v = entry["value-default"]; + v = entry["value-default"].get(); dst[name] = v; } else if(SDL_strncasecmp(control.c_str(), "multilineedit", 14) == 0) { std::string v; if(entry.find("value-default") != entry.end()) - v = entry["value-default"]; + v = entry["value-default"].get(); dst[name] = v; } else if(SDL_strncasecmp(control.c_str(), "file", 5) == 0 || @@ -705,7 +705,7 @@ static void read_layout_branches(nlohmann::json &typetree, { std::string v; if(entry.find("value-default") != entry.end()) - v = entry["value-default"]; + v = entry["value-default"].get(); dst[name] = v; } else if(SDL_strncasecmp(control.c_str(), "itemselect", 11) == 0) @@ -724,7 +724,7 @@ static void read_layout_branches(nlohmann::json &typetree, std::string type = "int"; if(entry.find("type") != entry.end()) - type = entry["type"]; + type = entry["type"].get(); nlohmann::json v = entry["value-default"]; if(v.find("w") != v.end() && v.find("h") != v.end()) @@ -763,7 +763,7 @@ static void read_layout_branches(nlohmann::json &typetree, std::string type = "int"; if(entry.find("type") != entry.end()) - type = entry["type"]; + type = entry["type"].get(); nlohmann::json v = entry["value-default"]; if(v.find("x") != v.end() && v.find("y") != v.end()) @@ -802,7 +802,7 @@ static void read_layout_branches(nlohmann::json &typetree, std::string type = "int"; if(entry.find("type") != entry.end()) - type = entry["type"]; + type = entry["type"].get(); nlohmann::json v = entry["value-default"]; if(v.find("x") != v.end() && v.find("y") != v.end() && diff --git a/LunaDll/GameConfig/GameConfiguration.cpp b/LunaDll/GameConfig/GameConfiguration.cpp index 73223aa99..784d6e915 100644 --- a/LunaDll/GameConfig/GameConfiguration.cpp +++ b/LunaDll/GameConfig/GameConfiguration.cpp @@ -33,7 +33,7 @@ namespace general { VB6StrPtr& gameTitle_3 = *(VB6StrPtr*)0x96AF26; } -void GameConfiguration::runPatchByIni(IniProcessing &reader) +void GameConfiguration::runPatchByIni(IniProcessing &&reader) { if (!reader.isOpened()) return; @@ -69,6 +69,10 @@ void GameConfiguration::runPatchByIni(IniProcessing &reader) gameTitleSuffix = " (Software Renderer)"; } +#ifdef __clang__ + gameTitleSuffix += " (Clang)"; +#endif + // References the same string memory, so do not destruct those. reader.beginGroup("general"); general::gameTitle_1.assignNoDestruct(reader.value("game-title", std::string(general::gameTitle_1)).toString() + gameTitleSuffix); diff --git a/LunaDll/GameConfig/GameConfiguration.h b/LunaDll/GameConfig/GameConfiguration.h index b30ab07eb..40aabe3f4 100644 --- a/LunaDll/GameConfig/GameConfiguration.h +++ b/LunaDll/GameConfig/GameConfiguration.h @@ -7,7 +7,7 @@ class GameConfiguration { public: - static void runPatchByIni(IniProcessing& reader); + static void runPatchByIni(IniProcessing&& reader); }; #endif diff --git a/LunaDll/GlobalFuncs.h b/LunaDll/GlobalFuncs.h index 3adf649c9..5e1567e69 100644 --- a/LunaDll/GlobalFuncs.h +++ b/LunaDll/GlobalFuncs.h @@ -233,4 +233,19 @@ void ShowAndFocusWindow(HWND hWindow); // Handle WIN32 events when loading void HandleEventsWhileLoading(); +// Float/double manipulation +#ifdef __clang__ +constexpr std::uint32_t FloatToDWord(float f) { + return __builtin_bit_cast(std::uint32_t, f); +} + +constexpr std::uint32_t DoubleLeastSignificantDWord(double d) { + return static_cast(__builtin_bit_cast(std::uint64_t, d) & 0xFFFFFFFFL); +} + +constexpr std::uint32_t DoubleMostSignificantDWord(double d) { + return static_cast(__builtin_bit_cast(std::uint64_t, d) >> 32); +} +#endif + #endif diff --git a/LunaDll/Globals.cpp b/LunaDll/Globals.cpp index 53cee9794..61710cd9e 100644 --- a/LunaDll/Globals.cpp +++ b/LunaDll/Globals.cpp @@ -28,7 +28,7 @@ SMBXHUDSettings gSMBXHUDSettings = { bool gRenderBGOFlag = true; bool gRenderSizableFlag = true; bool gRenderBackgroundFlag = true; -std::atomic gMainWindowSize = 0; // Low word is width, height word is height +std::atomic gMainWindowSize(0); // Low word is width, height word is height // Settings for glitch fixes bool gDisablePlayerFilterBounceFix = false; diff --git a/LunaDll/Globals.h b/LunaDll/Globals.h index b9e88b365..97ee61edb 100644 --- a/LunaDll/Globals.h +++ b/LunaDll/Globals.h @@ -31,7 +31,7 @@ class RenderOverrideManager; #include "Defines.h" #ifndef __MINGW32__ -#pragma comment (lib, "Msimg32.lib") +#pragma comment (lib, "msimg32.lib") #endif struct StartupEpisodeSettings diff --git a/LunaDll/Input/LunaGameController.cpp b/LunaDll/Input/LunaGameController.cpp index 61432a081..f28aee31f 100644 --- a/LunaDll/Input/LunaGameController.cpp +++ b/LunaDll/Input/LunaGameController.cpp @@ -149,7 +149,7 @@ void LunaGameControllerManager::handleInputs() // Get selected controller and whether it was active LunaGameController* selectedController = getController(1); - bool wasSelectedActive = (selectedController != nullptr) ? selectedController->isActive() : selectedController; + bool wasSelectedActive = (selectedController != nullptr) ? selectedController->isActive() : false; // Get active controller and clear flags LunaGameController* activeController = nullptr; @@ -273,7 +273,7 @@ void LunaGameControllerManager::handleInputs() SDL_JoystickID joyId = press.first; int which = press.second; - auto& it = controllerMap.find(joyId); + auto&& it = controllerMap.find(joyId); if (it != controllerMap.end()) { if (gLunaLua.isValid()) { diff --git a/LunaDll/LuaMain/LuaHelper.cpp b/LunaDll/LuaMain/LuaHelper.cpp index f0b06d1c3..f03e19c03 100644 --- a/LunaDll/LuaMain/LuaHelper.cpp +++ b/LunaDll/LuaMain/LuaHelper.cpp @@ -2,6 +2,7 @@ #include "LunaLuaMain.h" #include "../Misc/VB6StrPtr.h" #include "LuaProxy.h" +#include bool LuaHelper::is_function(lua_State *luaState, const char *fname) { @@ -18,14 +19,11 @@ bool LuaHelper::is_function(lua_State *luaState, const char *fname) void LuaHelper::assignVB6StrPtr(VB6StrPtr* ptr, const luabind::object &value, lua_State* L) { // Copy from native Lua string - boost::optional opt_str = luabind::object_cast_nothrow(value); - if (opt_str != boost::none) - { - *ptr = *opt_str; - return; - } - - luaL_error(L, "Cannot cast to string"); + try { + *ptr = luabind::object_cast(value); + } catch (luabind::cast_failed) { + luaL_error(L, "Cannot cast to string"); + } } bool* LuaHelper::generateFilterTable(lua_State* L, luabind::object theFilter, int maxVal, int minVal /*= 1*/) diff --git a/LunaDll/LuaMain/LuaHelper.h b/LunaDll/LuaMain/LuaHelper.h index 9cbe1a590..a30bd1f56 100644 --- a/LunaDll/LuaMain/LuaHelper.h +++ b/LunaDll/LuaMain/LuaHelper.h @@ -78,33 +78,6 @@ namespace LuaHelper { }; -// Original Posting: http://stackoverflow.com/questions/15037955/luabind-cant-return-shared-ptr -// We need to add this, in order to use std::shared_ptr -#include -#if BOOST_VERSION >= 105300 -#include -namespace luabind { - namespace detail { - namespace has_get_pointer_ { - template - T * get_pointer(std::shared_ptr const& p) { return p.get(); } - } - } -} -#else // if BOOST_VERSION < 105300 -#include -// Not standard conforming: add function to ::std(::tr1) -namespace std { -#if defined(_MSC_VER) && _MSC_VER < 1700 - namespace tr1 { -#endif - template - T * get_pointer(shared_ptr const& p) { return p.get(); } -#if defined(_MSC_VER) && _MSC_VER < 1700 - } // namespace tr1 -#endif -} // namespace std -#endif // if BOOST_VERSION < 105300 @@ -126,7 +99,7 @@ namespace std { .property("__type", & LUAHELPER_HELPCLASS_NAME(name) ::getName) #define LUAHELPER_DEF_CLASS_SMART_PTR_SHARED(name, smartPtrClass) \ - luabind::class_< LUAHELPER_HELPCLASS_NAME(name) ::cls, smartPtrClass ## < LUAHELPER_HELPCLASS_NAME(name) ::cls > >( LUAHELPER_HELPCLASS_NAME(name) ::getRawName()) \ + luabind::class_< LUAHELPER_HELPCLASS_NAME(name) ::cls, luabind::no_bases, smartPtrClass < LUAHELPER_HELPCLASS_NAME(name) ::cls > >( LUAHELPER_HELPCLASS_NAME(name) ::getRawName()) \ .property("__type", & LUAHELPER_HELPCLASS_NAME(name) ::getName) #define LUAHELPER_GET_NAMED_ARG_OR_RETURN_VOID(tableObj, elemKey) \ diff --git a/LunaDll/LuaMain/LuaProxy.h b/LunaDll/LuaMain/LuaProxy.h index 6a09dfd36..b502f95a0 100644 --- a/LunaDll/LuaMain/LuaProxy.h +++ b/LunaDll/LuaMain/LuaProxy.h @@ -30,25 +30,15 @@ namespace LuaProxy { template bool luaUserdataCompare(const luabind::object& arg1, const luabind::object& arg2, lua_State* L) { - boost::optional arg1Casted = luabind::object_cast_nothrow(arg1); - boost::optional arg2Casted = luabind::object_cast_nothrow(arg2); + T* rawArg1 = luabind::object_cast_nothrow(arg1, static_cast(nullptr)); + T* rawArg2 = luabind::object_cast_nothrow(arg2, static_cast(nullptr)); - T* rawArg1 = nullptr; - T* rawArg2 = nullptr; - if (arg1Casted != boost::none) - { - rawArg1 = arg1Casted.get(); - } - else + if (rawArg1 == nullptr) { luaL_error(L, "Failed to compare %s == %s:\nLeft compare argument is not %s", typeid(T).name(), typeid(T).name(), typeid(T).name()); return false; } - if (arg2Casted != boost::none) - { - rawArg2 = arg2Casted.get(); - } - else + if (rawArg2 == nullptr) { luaL_error(L, "Failed to compare %s == %s:\nRight compare argument is not %s", typeid(T).name(), typeid(T).name(), typeid(T).name()); return false; @@ -61,25 +51,15 @@ namespace LuaProxy { bool luaUserdataIndexCompare(const luabind::object& arg1, const luabind::object& arg2, lua_State* L){ static_assert(std::is_integral::value, "Data member type must be integral!"); - boost::optional arg1Casted = luabind::object_cast_nothrow(arg1); - boost::optional arg2Casted = luabind::object_cast_nothrow(arg2); + C* rawArg1 = luabind::object_cast_nothrow(arg1, static_cast(nullptr)); + C* rawArg2 = luabind::object_cast_nothrow(arg2, static_cast(nullptr)); - C* rawArg1 = nullptr; - C* rawArg2 = nullptr; - if (arg1Casted != boost::none) - { - rawArg1 = arg1Casted.get(); - } - else + if (rawArg1 == nullptr) { luaL_error(L, "Failed to compare %s == %s:\nLeft compare argument is not %s", typeid(C).name(), typeid(C).name(), typeid(C).name()); return false; } - if (arg2Casted != boost::none) - { - rawArg2 = arg2Casted.get(); - } - else + if (rawArg2 == nullptr) { luaL_error(L, "Failed to compare %s == %s:\nRight compare argument is not %s", typeid(C).name(), typeid(C).name(), typeid(C).name()); return false; @@ -88,7 +68,7 @@ namespace LuaProxy { return rawArg1->*Index == rawArg2->*Index; }; -#define LUAPROXY_DEFUSERDATAINEDXCOMPARE(def_class, def_datamember) &LuaProxy::luaUserdataIndexCompare +#define LUAPROXY_DEFUSERDATAINEDXCOMPARE(def_class, def_datamember) &LuaProxy::luaUserdataIndexCompare template diff --git a/LunaDll/LuaMain/LuaProxyComponent/LuaProxyGlobalFunctions.cpp b/LunaDll/LuaMain/LuaProxyComponent/LuaProxyGlobalFunctions.cpp index 16e0f3ba6..a85eb3624 100644 --- a/LunaDll/LuaMain/LuaProxyComponent/LuaProxyGlobalFunctions.cpp +++ b/LunaDll/LuaMain/LuaProxyComponent/LuaProxyGlobalFunctions.cpp @@ -21,7 +21,6 @@ #include #include "../../Misc/SafeFPUControl.h" - //type - Player's state/powerup //ini_file - path to INI-file which contains the hitbox redefinations void LuaProxy::loadHitboxes(int _character, int _powerup, const std::string& ini_file, lua_State* L) @@ -178,12 +177,12 @@ void LuaProxy::mem(int mem, LuaProxy::L_FIELDTYPE ftype, const luabind::object & case LFT_FLOAT: case LFT_DFLOAT: { - boost::optional opt_obj = luabind::object_cast_nothrow(value); - if (opt_obj == boost::none) { + try { + MemAssign((int)ptr, luabind::object_cast(value), OP_Assign, (FIELDTYPE)ftype); + } + catch (luabind::cast_failed) { luaL_error(L, "Cannot interpret field as number"); - break; } - MemAssign((int)ptr, *opt_obj, OP_Assign, (FIELDTYPE)ftype); break; } case LFT_STRING: @@ -193,13 +192,15 @@ void LuaProxy::mem(int mem, LuaProxy::L_FIELDTYPE ftype, const luabind::object & } case LFT_BOOL: { - boost::optional opt_obj = luabind::object_cast_nothrow(value); - if (opt_obj == boost::none) { + bool obj; + try { + obj = luabind::object_cast(value); + } catch (luabind::cast_failed) { luaL_error(L, "Cannot interpret field as boolean"); break; } void* ptr = ((&(*(byte*)mem))); - *((short*)ptr) = COMBOOL(*opt_obj); + *((short*)ptr) = COMBOOL(obj); break; } default: diff --git a/LunaDll/LuaMain/LuaProxyComponent/LuaProxyShader.cpp b/LunaDll/LuaMain/LuaProxyComponent/LuaProxyShader.cpp index c4ff03599..8111d9b37 100644 --- a/LunaDll/LuaMain/LuaProxyComponent/LuaProxyShader.cpp +++ b/LunaDll/LuaMain/LuaProxyComponent/LuaProxyShader.cpp @@ -17,7 +17,7 @@ void LuaProxy::Shader::compileFromSource(const std::string& vertexSource, const m_internalShader = g_GLEngine.CreateNewShader(vertexSource, fragmentSource); if (!m_internalShader->isValid()) { - luaL_error(L, "Failed to compile shader: \n%s", m_internalShader->getLastErrorMsg()); + luaL_error(L, "Failed to compile shader: \n%s", m_internalShader->getLastErrorMsg().c_str()); return; } diff --git a/LunaDll/LuaMain/LuaProxyFFI.cpp b/LunaDll/LuaMain/LuaProxyFFI.cpp index 2586350af..a92ef8ebc 100644 --- a/LunaDll/LuaMain/LuaProxyFFI.cpp +++ b/LunaDll/LuaMain/LuaProxyFFI.cpp @@ -136,7 +136,7 @@ extern "C" { return nullptr; } - tmp = *((VB6StrPtr*)ptr); + tmp = static_cast(*((VB6StrPtr*)ptr)); return tmp.c_str(); } diff --git a/LunaDll/LuaMain/LunaLuaMain.cpp b/LunaDll/LuaMain/LunaLuaMain.cpp index c4311b5fc..52fec2de3 100644 --- a/LunaDll/LuaMain/LunaLuaMain.cpp +++ b/LunaDll/LuaMain/LunaLuaMain.cpp @@ -609,7 +609,7 @@ void CLunaLua::bindAll() .def("captureAt", &CaptureBuffer::CaptureAt), def("loadImage", (bool(*)(const std::string&, int, int))&LuaProxy::Graphics::loadImage), def("loadImage", (std::shared_ptr(*)(const std::string&, lua_State*))&LuaProxy::Graphics::loadImage), - def("loadAnimatedImage", &LuaProxy::Graphics::loadAnimatedImage, pure_out_value(_2)), + def("loadAnimatedImage", &LuaProxy::Graphics::loadAnimatedImage, pure_out_value<2>()), def("placeSprite", (void(*)(int, int, int, int, const std::string&, int))&LuaProxy::Graphics::placeSprite), def("placeSprite", (void(*)(int, int, int, int, const std::string&))&LuaProxy::Graphics::placeSprite), def("placeSprite", (void(*)(int, int, int, int))&LuaProxy::Graphics::placeSprite), @@ -618,7 +618,7 @@ void CLunaLua::bindAll() def("placeSprite", (void(*)(int, const std::shared_ptr& img, int, int))&LuaProxy::Graphics::placeSprite), def("unplaceSprites", (void(*)(const std::shared_ptr& img))&LuaProxy::Graphics::unplaceSprites), def("unplaceSprites", (void(*)(const std::shared_ptr& img, int, int))&LuaProxy::Graphics::unplaceSprites), - def("getPixelData", &LuaProxy::Graphics::getPixelData, pure_out_value(_2) + pure_out_value(_3)), + def("getPixelData", &LuaProxy::Graphics::getPixelData, meta::join, pure_out_value<3>>::type()), def("drawImage", (void(*)(const std::shared_ptr& , double, double, lua_State*))&LuaProxy::Graphics::drawImage), def("drawImage", (void(*)(const std::shared_ptr& , double, double, float, lua_State*))&LuaProxy::Graphics::drawImage), def("drawImage", (void(*)(const std::shared_ptr& , double, double, double, double, double, double, lua_State*))&LuaProxy::Graphics::drawImage), diff --git a/LunaDll/LunaDll.rc b/LunaDll/LunaDll.rc index 7185aefe229846065736a71512c222c3947401b9..b7753b1e59168498c5c1fc97f6389909c7d65b89 100644 GIT binary patch literal 5816 zcmdT|TW_OA6n^JdOxcGfTIzr=al9`ThOte9!D7Hk)U7PmCNV082yl}~`{R2K0~jaH zrCRSpNo1Haw{x5CoHJ)Q+(j1XfRM|EL?YyCy zqw9vy_$~^wH97I(5G~1aFlcsK>mvh;g}3AvZnf2kI=TjnG23%Ay3kGYlzjhAnw_rd zj2G1MP6bo7#-2K+1V4Z@HVrnB2=j(b!op+1(ZxcO>!BYdckm?$hORF(M`aV;P)&PG z_={c>S;GIGtVpCI_XOtNn3U*j!Kgd3Eth=9#?;nTbL6N~%G)F3n(FL^LFixrS}=1`L>j8ia}{vgz=eto@8EQ$JgSs`W3TQ0#Ic5pl{0TL)1@^yp5MNLS{p z$&a!yq+`Pp2s|^7O@^N9!XCvVvLIfOJRvMd!7D|{(6zv^>!)eX0~DXPDsH76-;sXI_4r6)@i{K+$2!!#^(CupLCbEbhl%^hJ<6TroGz0fFo z4oiHKY{}A($vSxmz##~D)O{i13Yt-JzX{@;B)7!e#=ag!XZSX^K7kYd1XH;upv6!b z;8y_ZKt$jA@MwHu z{l8x5;F%=KpabslAsvA5js=hc@+*BVztTbZ(H-8iaZ0vemDt||#0LO?bGF@(hu~WV z5dKmK_(j zz`Y!lgo^qE2nt6C9*8@2VpB=7-~E2TJ#J2Md?P|Km2LoJPSkCdr=kC&$%0PR=gGpD zI#U(QRpko24QGS7j-gt|m+3&l;27Ej!ToT~(2*f(E4_=Kn=`m@premu2}&bN(CKI| zQ4sA*1TOm$unB@tr!N6Sl_|lCNX{Xyk{!FLgRZ2s`~MF}sU+uC{~)UDaAFTtIG9!+C?7x-%*ziV z=W+3a*H3s5%3`TNZKYX0HGHp8>wT3)Zu0hPV|OK$Sl3zN*Ys;F7HSh4{kxj0IiTL6 z^V$}T)#}0Tpf$*M#0RwnL1E5o#zJ><$mpoUpi)?16eMM%h=^oln6xB7Y0{SlH(wTY=sn%7T5Wj8u$YoNO}~3FU{} zH95h(nNc9M%O*f_Nr8#GKsz*T?UINL0z!N@3ZuY?Zxe3E-5`vRz4M!HRV>n)oHa44mEI5$S3!Bj{wn;&FU$|G=n=o(vth9 zG`w5qxN_YfC)z1#%S!h*_~{*-ZNsb(c0!>sF|4JHqSoq_9cL+szs&cTYbaJr(%|4; z<-E6afcS;-RqxX3b3c8{H%d*osUK&NkEu9_f!;WPSlgC)nODK%&q)ICeuHEG!c-wM zc8ep6$>x4!ATI~*99ZVSw+A$DBuz(z8@%lRj*s{tdeu3r=Ewf(hZ8<(Y0neBS8s>3 zpOx*60zcoT!5_@FN)tPa5mlj%q)1b$)7cnTk&3t2=y1yG&sP4J;}vJK9C$-_N3>F5 ncf|hv3&g4fIqpt8q`h;c+NrM)i!0S*d*z;v<0L;&b_xFi=3Jic literal 12068 zcmdU#`%fE35XblDO8pJY@ENu>VmZNHx# zkMGXD1DnwHBI~?+yR);i^V-?j`}?m4;Xz2kdN>aI;VgUz=X#F9h1#~&b{;OnUKr@D z5q{7w32(z;IMH*a_6wBlB$LU5a9~?npeknI5^69B;Ksr!J8uoXA!OlG3>( zl!Uv|j}yJQ&2Fk@7JMG=6==+P#{P~YzrM@a;ejwNhqg4(>~B-Hwk1n!Xy#pM;+lTo z{ZqfBbYx#RdeZk@joQ%odvVq^wQi_&OXX_RX>T#ORpIW)uAhbb!o4ZD6}8xyafn^@ zng?*+R7+w`jZ^1kA|4(`-}^yw^j1oqj(VHoT0`7hj-0?3E{h8<#4*OEZ+M9$%tv0? z|B~M7@qJOXrHB!a`by*RAWdP!hqlz#j$XB|R^(_s>uPJp+1hdb^*Ac+Z)^6KY6JR} z9viz8v351KE17h2tqo!8Mqh>x&%zr9W*qpPr4D4Xp>gFnSh5(ZeyC77J)ex$+Cgk?Jp!Ot# zJ=wsC>UU%RAbeK+NcA(7?1OkWTgAC*wjvG%{EFKjtMNcOoo)titoQuXh>3q8oe(k~@`dVBcs3QGKFS5drOq^LV-kqj%c()Nece=i#hb@8GuP+F`!S zVt%tg_hES2)Qc5si~A6)f_hJ<4gTFe9!HJA!y&^bIcpu)hw1fZM|O(lqIXU0Ohhc4 z8hqCI=*?V%DE|xnF&*3yW%zr}GMsICddvEee@DM|MqcAUvS&|n*&j#;e%AY4@rP5K z`Bu(?M0LMPv-Y$T;!Cizd6oMS7yItM;O&g?+Z4KRwN&bo0(%Nxr!4D9$}4GDf^v81-8Fksx^`CJ(M42XM>~DNTdFR(kSE0 zqsSNH#Z(Fw2jJ2C@o2VsB@{xHm&Am~wWGaiBkl=AhTiMz;rx3vJiQd17}-ms=M3-fA6~~Z_FOTktO0)4jw7L&0#^=36_icHXb?H2(F6aZBod6ul z%bxmIu_Z06$FJAv5o)30njA>^r_LQFV4GWttdd{EEZ45b{ zCo$e(WjqUU$76j9dPgSdF2tMby4ygtN~g}t@^}QgeLeqg>@%(lS$}Z*5m0f20u99x z5FW=Y%A*-CZz}@AljUbfH7>1{$1jt&8%_Ute{mxS3I__oJJ(>4A59;z4zW2bX z?2Q^Q#h$bH?((&?!#sB?DR6Kzcau4aZsBS=8)+G2ffVT0FwBw>1Yhcx0q4?+*MY zVLwt2*zE8#Rv z`DWyq9M;RLF*?+?@SrBT`6A&oX0AR*=z0RiOa0M`e084Lz3Ox`E#6{}ZJf^YwLEg-OS79~ z)v|o4R^2)6QmPhpPK{Gn^qp2CTGpOCS~c>T=n|eCn*A%Q+xaq!FL}PsjAmPQgWuze z*Te9OA~&LMmntO>*4|T0-d4QCy)(DEtr0XQ&itdH0zM3Ea`#7vtZ`v>C0tSkTk diff --git a/LunaDll/LunaDll.vcxproj b/LunaDll/LunaDll.vcxproj index 123d5f05b..76cde13e6 100644 --- a/LunaDll/LunaDll.vcxproj +++ b/LunaDll/LunaDll.vcxproj @@ -56,18 +56,18 @@ true - $(MSBuildProjectDirectory)\libs;$(MSBuildProjectDirectory)\libs\luabind-include;$(MSBuildProjectDirectory)\libs\lua\include;$(MSBuildProjectDirectory)\libs\sdl\include;$(MSBuildProjectDirectory)\libs\boost;$(MSBuildProjectDirectory)\libs\glew\include;$(MSBuildProjectDirectory)\libs\freeimage;$(IncludePath) - $(MSBuildProjectDirectory)\libs\luabind-lib;$(MSBuildProjectDirectory)\libs\lua\lib;$(MSBuildProjectDirectory)\libs\sdl\lib;$(MSBuildProjectDirectory)\libs\glew\lib\Release\Win32;$(MSBuildProjectDirectory)\libs\freeimage;$(LibraryPath) + $(MSBuildProjectDirectory)\libs;$(MSBuildProjectDirectory)\libs\luabind-deboostified;$(MSBuildProjectDirectory)\libs\lua\include;$(MSBuildProjectDirectory)\libs\sdl\include;$(MSBuildProjectDirectory)\libs\glew\include;$(MSBuildProjectDirectory)\libs\freeimage;$(IncludePath) + $(MSBuildProjectDirectory)\libs\lua\lib;$(MSBuildProjectDirectory)\libs\sdl\lib;$(MSBuildProjectDirectory)\libs\glew\lib\Release\Win32;$(MSBuildProjectDirectory)\libs\freeimage;$(LibraryPath) false - $(MSBuildProjectDirectory)\libs;$(MSBuildProjectDirectory)\libs\luabind-include;$(MSBuildProjectDirectory)\libs\lua\include;$(MSBuildProjectDirectory)\libs\sdl\include;$(MSBuildProjectDirectory)\libs\boost;$(MSBuildProjectDirectory)\libs\glew\include;$(MSBuildProjectDirectory)\libs\freeimage;$(IncludePath) - $(MSBuildProjectDirectory)\libs\luabind-lib;$(MSBuildProjectDirectory)\libs\lua\lib;$(MSBuildProjectDirectory)\libs\sdl\lib;$(MSBuildProjectDirectory)\libs\glew\lib\Release\Win32;$(MSBuildProjectDirectory)\libs\freeimage;$(LibraryPath) + $(MSBuildProjectDirectory)\libs;$(MSBuildProjectDirectory)\libs\luabind-deboostified;$(MSBuildProjectDirectory)\libs\lua\include;$(MSBuildProjectDirectory)\libs\sdl\include;$(MSBuildProjectDirectory)\libs\glew\include;$(MSBuildProjectDirectory)\libs\freeimage;$(IncludePath) + $(MSBuildProjectDirectory)\libs\lua\lib;$(MSBuildProjectDirectory)\libs\sdl\lib;$(MSBuildProjectDirectory)\libs\glew\lib\Release\Win32;$(MSBuildProjectDirectory)\libs\freeimage;$(LibraryPath) false - $(MSBuildProjectDirectory)\libs\luabind-include;$(ProgramFiles)\Lua\5.1\include;$(MSBuildProjectDirectory)\libs\sdl\include;$(IncludePath) - $(MSBuildProjectDirectory)\libs\luabind-lib;$(ProgramFiles)\Lua\5.1\lib;$(MSBuildProjectDirectory)\libs\sdl\lib;$(LibraryPath) + $(MSBuildProjectDirectory)\libs\luabind-deboostified;$(ProgramFiles)\Lua\5.1\include;$(MSBuildProjectDirectory)\libs\sdl\include;$(IncludePath) + $(ProgramFiles)\Lua\5.1\lib;$(MSBuildProjectDirectory)\libs\sdl\lib;$(LibraryPath) @@ -76,14 +76,14 @@ Level3 Disabled WIN32;_DEBUG;_WINDOWS;_USRDLL;LUNADLL_EXPORTS;NDEBUG;_CRT_SECURE_NO_WARNINGS;GLEW_STATIC;%(PreprocessorDefinitions) - $(LUA_DEV);$(MSBuildProjectDirectory)\libs\boost + $(LUA_DEV) false MultiThreaded Windows true - kernel32.lib;user32.lib;gdi32.lib;gdiplus.lib;FreeImageLite.lib;version.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;winmm.lib;shlwapi.lib;libluabind.lib;lua51.lib;Dbghelp.lib;Ws2_32.lib;SDL2.lib;SDL2main.lib;SDL2_mixer_ext.lib;setupapi.lib;comsuppw.lib;opengl32.lib;glew32s.lib;%(AdditionalDependencies) + kernel32.lib;user32.lib;gdi32.lib;gdiplus.lib;FreeImageLite.lib;version.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;winmm.lib;shlwapi.lib;lua51.lib;Dbghelp.lib;Ws2_32.lib;SDL2.lib;SDL2main.lib;SDL2_mixer_ext.lib;setupapi.lib;comsuppw.lib;opengl32.lib;glew32s.lib;%(AdditionalDependencies) @@ -101,7 +101,7 @@ Sync false false - $(MSBuildProjectDirectory)\libs\boost;$(LUA_DEV) + $(LUA_DEV) true Speed MultiThreaded @@ -111,7 +111,7 @@ true true true - kernel32.lib;user32.lib;gdi32.lib;gdiplus.lib;FreeImageLite.lib;version.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;winmm.lib;shlwapi.lib;libluabind.lib;lua51.lib;Dbghelp.lib;Ws2_32.lib;SDL2.lib;SDL2main.lib;SDL2_mixer_ext.lib;setupapi.lib;comsuppw.lib;opengl32.lib;glew32s.lib;%(AdditionalDependencies) + kernel32.lib;user32.lib;gdi32.lib;gdiplus.lib;FreeImageLite.lib;version.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;winmm.lib;shlwapi.lib;lua51.lib;Dbghelp.lib;Ws2_32.lib;SDL2.lib;SDL2main.lib;SDL2_mixer_ext.lib;setupapi.lib;comsuppw.lib;opengl32.lib;glew32s.lib;%(AdditionalDependencies) true @@ -370,6 +370,27 @@ + + + + + + + + + + + + + + + + + + + + + @@ -544,4 +565,4 @@ - \ No newline at end of file + diff --git a/LunaDll/LunaDll.vcxproj.filters b/LunaDll/LunaDll.vcxproj.filters index 65d968618..1d2a79805 100644 --- a/LunaDll/LunaDll.vcxproj.filters +++ b/LunaDll/LunaDll.vcxproj.filters @@ -134,6 +134,10 @@ {35f2e9ba-fba0-48ac-ae82-40ba81b273f4} + + + + {bfb6190e-4738-4465-8020-4a003075249a} @@ -1313,6 +1317,69 @@ LuaMain + + libs\luabind-deboostified + + + libs\luabind-deboostified + + + libs\luabind-deboostified + + + libs\luabind-deboostified + + + libs\luabind-deboostified + + + libs\luabind-deboostified + + + libs\luabind-deboostified + + + libs\luabind-deboostified + + + libs\luabind-deboostified + + + libs\luabind-deboostified + + + libs\luabind-deboostified + + + libs\luabind-deboostified + + + libs\luabind-deboostified + + + libs\luabind-deboostified + + + libs\luabind-deboostified + + + libs\luabind-deboostified + + + libs\luabind-deboostified + + + libs\luabind-deboostified + + + libs\luabind-deboostified + + + libs\luabind-deboostified + + + libs\luabind-deboostified + @@ -1335,4 +1402,4 @@ - \ No newline at end of file + diff --git a/LunaDll/Misc/AsyncHTTPClient.cpp b/LunaDll/Misc/AsyncHTTPClient.cpp index b306b9905..eb8ab00e1 100644 --- a/LunaDll/Misc/AsyncHTTPClient.cpp +++ b/LunaDll/Misc/AsyncHTTPClient.cpp @@ -76,7 +76,7 @@ void AsyncHTTPClient::asyncSendWorker() } if (SUCCEEDED(hr)) { - _bstr_t method(method.c_str()); + _bstr_t method_bstr(method.c_str()); _bstr_t url; if (m_method == HTTP_GET) { url = ((m_url + (fullArgList.empty() ? "" : "?") + fullArgList).c_str()); @@ -85,7 +85,7 @@ void AsyncHTTPClient::asyncSendWorker() { url = m_url.c_str(); } - hr = pIWinHttpRequest->Open(method, url, varFalse); + hr = pIWinHttpRequest->Open(method_bstr, url, varFalse); } if (m_method == HTTP_POST) { diff --git a/LunaDll/Misc/ErrorReporter.cpp b/LunaDll/Misc/ErrorReporter.cpp index 81b6736db..12197392d 100644 --- a/LunaDll/Misc/ErrorReporter.cpp +++ b/LunaDll/Misc/ErrorReporter.cpp @@ -102,6 +102,9 @@ void ErrorReport::SnapshotError(EXCEPTION_RECORD* exception, CONTEXT* context) fullErrorDescription << "== Crash Summary ==\n"; fullErrorDescription << "LunaLua Version: " + std::string(LUNALUA_VERSION) + "\n"; +#ifdef __clang__ + fullErrorDescription << "This LunaLua build has been compiled with Clang. Clang support is still experimental so errors might happen.\n"; +#endif fullErrorDescription << "Exception Code: 0x" << std::hex << exception->ExceptionCode; switch (exception->ExceptionCode) diff --git a/LunaDll/Misc/LoadScreen.cpp b/LunaDll/Misc/LoadScreen.cpp index 78a6e5beb..481256020 100644 --- a/LunaDll/Misc/LoadScreen.cpp +++ b/LunaDll/Misc/LoadScreen.cpp @@ -13,7 +13,7 @@ static bool lunaLoadScreenEnabled = false; static std::thread* loadThread = nullptr; -static std::atomic killThreadFlag = false; +static std::atomic killThreadFlag(false); static void luasetconst(lua_State* L, const char* name, lua_Number number) { diff --git a/LunaDll/Misc/ResourceFileMapper.cpp b/LunaDll/Misc/ResourceFileMapper.cpp index 1adbc6203..36c4e34b5 100644 --- a/LunaDll/Misc/ResourceFileMapper.cpp +++ b/LunaDll/Misc/ResourceFileMapper.cpp @@ -94,7 +94,7 @@ const ResourceFileInfo CachedFileMetadata::getResourceFileInfo(const std::wstrin std::transform(lfile.begin(), lfile.end(), lfile.begin(), ::towlower); std::unique_lock lck(mMutex); - auto& it = mSearchPaths.find(lpath); + auto&& it = mSearchPaths.find(lpath); if (it == mSearchPaths.end()) { @@ -133,7 +133,7 @@ const ResourceFileInfo CachedFileMetadata::getResourceFileInfo(const std::wstrin } const ResourceFileMap& fileMap = it->second.map; - auto& fileIt = fileMap.find(lfile); + auto&& fileIt = fileMap.find(lfile); if (fileIt == fileMap.end()) { @@ -155,7 +155,7 @@ ResourceFileMap CachedFileMetadata::listResourceFilesFromDir(const NormalizedPat std::transform(lpath.begin(), lpath.end(), lpath.begin(), ::towlower); std::unique_lock lck(mMutex); - auto& it = mSearchPaths.find(lpath); + auto&& it = mSearchPaths.find(lpath); if (it == mSearchPaths.end()) { diff --git a/LunaDll/Misc/ResourceFileMapper.h b/LunaDll/Misc/ResourceFileMapper.h index 48faeef16..d6f0e3502 100644 --- a/LunaDll/Misc/ResourceFileMapper.h +++ b/LunaDll/Misc/ResourceFileMapper.h @@ -100,7 +100,7 @@ class CachedFileDataWeakPtr { std::vector>* pCacheHolder = isWorld ? &mWorldCacheHolder : &mCacheHolder; pCacheHolder->clear(); - for (auto& cacheEntry = mCache.begin(); cacheEntry != mCache.end();) + for (auto&& cacheEntry = mCache.begin(); cacheEntry != mCache.end();) { std::shared_ptr cachePtr = cacheEntry->second.data.lock(); if (cachePtr) @@ -123,7 +123,7 @@ class CachedFileDataWeakPtr { std::vector>* pCacheHolder = isWorld ? &mWorldCacheHolder : &mCacheHolder; pCacheHolder->clear(); - for (auto& cacheEntry = mCache.begin(); cacheEntry != mCache.end();) + for (auto&& cacheEntry = mCache.begin(); cacheEntry != mCache.end();) { std::shared_ptr cachePtr = cacheEntry->second.data.lock(); if (!cachePtr) @@ -139,7 +139,7 @@ class CachedFileDataWeakPtr Entry* CachedFileDataWeakPtr::get(const NormalizedPath& filePath) { - auto& it = mCache.find(filePath); + auto&& it = mCache.find(filePath); if (it == mCache.end()) { diff --git a/LunaDll/Misc/RuntimeHook.h b/LunaDll/Misc/RuntimeHook.h index f603cdf49..86496c0f0 100644 --- a/LunaDll/Misc/RuntimeHook.h +++ b/LunaDll/Misc/RuntimeHook.h @@ -5,6 +5,7 @@ #include #include "../Defines.h" #include "AsmPatch.h" +#include "../GlobalFuncs.h" struct SMBX_Warp; @@ -171,8 +172,56 @@ void fixup_RenderPlayerJiterX(); /************************************************************************/ /* Render Priority Hooks */ /************************************************************************/ + template _declspec(naked) static void __stdcall _RenderBelowPriorityHookImpl() { +#ifdef __clang__ + // NB: I'm using %c modifiers for PriorityMostSignificantDWord and PriorityLeastSignificantDWord because of a clang bug: https://bugs.llvm.org/show_bug.cgi?id=24232 + __asm__ volatile ( + ".intel_syntax\n" + "pushfd\n" + "push eax\n" + "push ecx\n" + "push edx\n" + + "call %P[getRenderer]\n" // Pointer to the renderer is put in eax + "mov ecx, eax\n" // The pointer to this is stored in ecx in the __thiscall convention + + /* + ".if %c[priorityAbove100]\n" + "push 0x7FEFFFFF\n" // Push most significant dword of DBL_MAX + "push 0xFFFFFFFF\n" // Push least significant dword of DBL_MAX + ".else\n" + "push eax\n" // Allocate the first 4 bytes on the stack for the priority argument of Renderer::RenderBelowPriority, the next four bytes will be allocated by push priority. + + // The following 3 instructions are for converting priority to a dfloat. + "push %c[priorityValue]\n" + "fild dword ptr [esp]\n" + "fstp qword ptr [esp]\n" + ".endif\n" + */ + + "push %c[PriorityMostSignificantDWord]\n" // Push most significant dword of priority + "push %c[PriorityLeastSignificantDWord]\n" // Push least significant dword of priority + + "call %P[RenderBelowPriority]\n" + + "pop edx\n" + "pop ecx\n" + "pop eax\n" + "popfd\n" + "ret\n" + ".att_syntax\n" + : + : //[priorityAbove100] "i" (priority >= 100), + //[priorityValue] "i" (priority), + [PriorityMostSignificantDWord] "i" (DoubleMostSignificantDWord(priority >= 100 ? DBL_MAX : priority)), + [PriorityLeastSignificantDWord] "i" (DoubleLeastSignificantDWord(priority >= 100 ? DBL_MAX : priority)), + [getRenderer] "i" (&Renderer::Get), + [RenderBelowPriority] "i" (&Renderer::RenderBelowPriority) + + ); +#else __asm { pushfd push eax @@ -187,6 +236,7 @@ _declspec(naked) static void __stdcall _RenderBelowPriorityHookImpl() { popfd ret } +#endif } template static inline constexpr void* GetRenderBelowPriorityHook(void) { @@ -195,6 +245,59 @@ static inline constexpr void* GetRenderBelowPriorityHook(void) { template _declspec(naked) static void __stdcall _RenderBelowPriorityHookWithSkipImpl() { +#ifdef __clang__ + // NB: I'm using %c modifiers for PriorityMostSignificantDWord, PriorityLeastSignificantDWord, skipTargetAddrValue and skipTargetAddrValue because of a clang bug: https://bugs.llvm.org/show_bug.cgi?id=24232 + __asm__ volatile ( + ".intel_syntax\n" + "pushfd\n" + "push eax\n" + "push ecx\n" + "push edx\n" + + "call %P[getRenderer]\n" // Pointer to the renderer is put in eax + "mov ecx, eax\n" // The pointer to this is stored in ecx in the __thiscall convention + + /* + ".if %c[priorityAbove100]\n" + "push 0x7FEFFFFF\n" // Push most significant dword of DBL_MAX + "push 0xFFFFFFFF\n" // Push least significant dword of DBL_MAX + ".else\n" + "push eax\n" // Allocate the first 4 bytes on the stack for the priority argument of Renderer::RenderBelowPriority, the next four bytes will be allocated by push priority. + + // The following 3 instructions are for converting priority to a dfloat. + "push %c[priorityValue]\n" + "fild dword ptr [esp]\n" + "fstp qword ptr [esp]\n" + ".endif\n" + */ + + "push %c[PriorityMostSignificantDWord]\n" // Push most significant dword of priority + "push %c[PriorityLeastSignificantDWord]\n" // Push least significant dword of priority + + "call %P[RenderBelowPriority]\n" + + "mov al, byte ptr [%c[skipAddrValue]]\n" + "test al, al\n" + "jnz 1f\n" + "mov dword ptr [esp + 16], %c[skipTargetAddrValue]\n" + "1:\n" + "pop edx\n" + "pop ecx\n" + "pop eax\n" + "popfd\n" + "ret\n" + ".att_syntax\n" + : + : //[priorityAbove100] "i" (priority >= 100), + //[priorityValue] "i" (priority), + [PriorityMostSignificantDWord] "i" (DoubleMostSignificantDWord(priority >= 100 ? DBL_MAX : priority)), + [PriorityLeastSignificantDWord] "i" (DoubleLeastSignificantDWord(priority >= 100 ? DBL_MAX : priority)), + [skipTargetAddrValue] "i" (skipTargetAddr), + [skipAddrValue] "i" (skipAddr), + [getRenderer] "i" (&Renderer::Get), + [RenderBelowPriority] "i" (&Renderer::RenderBelowPriority) + ); +#else __asm { pushfd push eax @@ -225,6 +328,7 @@ _declspec(naked) static void __stdcall _RenderBelowPriorityHookWithSkipImpl() { ret } } +#endif } template static inline constexpr void* GetRenderBelowPriorityHookWithSkip(void) { diff --git a/LunaDll/Misc/RuntimeHookComponents/RuntimeHookHooks.cpp b/LunaDll/Misc/RuntimeHookComponents/RuntimeHookHooks.cpp index cd638b376..581bdebe9 100644 --- a/LunaDll/Misc/RuntimeHookComponents/RuntimeHookHooks.cpp +++ b/LunaDll/Misc/RuntimeHookComponents/RuntimeHookHooks.cpp @@ -1701,19 +1701,17 @@ __declspec(naked) void __stdcall runtimeHookSmbxChangeModeHookRaw(void) { __asm { pushfd - push eax - push ecx - push edx - } - runtimeHookSmbxChangeModeHook(); - __asm { + push eax + push ecx + push edx + call runtimeHookSmbxChangeModeHook pop edx - pop ecx - pop eax - popfd - or ebx, 0xFFFFFFFF - cmp word ptr ds : [0xB2C620], bx - ret + pop ecx + pop eax + popfd + or ebx, 0xFFFFFFFF + cmp word ptr ds : [0xB2C620], bx + ret } } @@ -1819,9 +1817,7 @@ __declspec(naked) void __stdcall runtimeHookSmbxCheckWindowedRaw(void) push eax push ecx push edx - } - runtimeHookSmbxCheckWindowed(); - __asm { + call runtimeHookSmbxCheckWindowed pop edx pop ecx pop eax diff --git a/LunaDll/Misc/RuntimeHookUtils/APIHook.cpp b/LunaDll/Misc/RuntimeHookUtils/APIHook.cpp index eb7e474d6..33bf9f362 100644 --- a/LunaDll/Misc/RuntimeHookUtils/APIHook.cpp +++ b/LunaDll/Misc/RuntimeHookUtils/APIHook.cpp @@ -4,7 +4,7 @@ #include "CmnHdr.h" #include "ImageHlp.h" -#pragma comment(lib, "ImageHlp") +#pragma comment(lib, "imagehlp") #include "APIHook.h" #include "Toolhelp.h" @@ -40,7 +40,7 @@ CAPIHook::CAPIHook(PSTR pszCalleeModName, PSTR pszFuncName, PROC pfnHook, GetModuleHandleA(pszCalleeModName), m_pszFuncName); chASSERT(m_pfnOrig != NULL); // Function doesn't exist - if (m_pfnOrig > sm_pvMaxAppAddr) { + if (static_cast(m_pfnOrig) > sm_pvMaxAppAddr) { // The address is in a shared DLL; the address needs fixing up PBYTE pb = (PBYTE)m_pfnOrig; if (pb[0] == cPushOpCode) { @@ -151,7 +151,7 @@ void CAPIHook::ReplaceIATEntryInOneMod(PCSTR pszCalleeModName, // Is this the function we're looking for? BOOL fFound = (*ppfn == pfnCurrent); - if (!fFound && (*ppfn > sm_pvMaxAppAddr)) { + if (!fFound && (static_cast(*ppfn) > sm_pvMaxAppAddr)) { // If this is not the function and the address is in a shared DLL, // then maybe we're running under a debugger on Windows 98. In this diff --git a/LunaDll/Rendering/BitBltEmulation.cpp b/LunaDll/Rendering/BitBltEmulation.cpp index 2d941a5de..0b705cbf2 100644 --- a/LunaDll/Rendering/BitBltEmulation.cpp +++ b/LunaDll/Rendering/BitBltEmulation.cpp @@ -2,7 +2,7 @@ #include "../Globals.h" #include "../Rendering/GL/GLEngineProxy.h" #include "LunaImage.h" -#include "Imageloader.h" +#include "ImageLoader.h" #include "BitBltEmulation.h" #include "../Rendering/Rendering.h" diff --git a/LunaDll/Rendering/GL/GLCompat.h b/LunaDll/Rendering/GL/GLCompat.h index d9f3e5a17..8fef25176 100644 --- a/LunaDll/Rendering/GL/GLCompat.h +++ b/LunaDll/Rendering/GL/GLCompat.h @@ -1,7 +1,7 @@ #ifndef GLCompat_hhhh #define GLCompat_hhhh -#include +#include #include "../../Defines.h" #include #include diff --git a/LunaDll/Rendering/GL/GLContextManager.cpp b/LunaDll/Rendering/GL/GLContextManager.cpp index e7599cdcd..5ea49dec6 100644 --- a/LunaDll/Rendering/GL/GLContextManager.cpp +++ b/LunaDll/Rendering/GL/GLContextManager.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "../../Defines.h" #include "../../Globals.h" #include "GLContextManager.h" diff --git a/LunaDll/Rendering/GL/GLContextManager.h b/LunaDll/Rendering/GL/GLContextManager.h index f7b2433ff..b2b6ca861 100644 --- a/LunaDll/Rendering/GL/GLContextManager.h +++ b/LunaDll/Rendering/GL/GLContextManager.h @@ -2,7 +2,7 @@ #define GLContextManager_hhhh #include -#include +#include #include "GLTextureStore.h" #include "GLFramebuffer.h" diff --git a/LunaDll/Rendering/GL/GLDraw.cpp b/LunaDll/Rendering/GL/GLDraw.cpp index e9d132f0c..0c170e36a 100644 --- a/LunaDll/Rendering/GL/GLDraw.cpp +++ b/LunaDll/Rendering/GL/GLDraw.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "../../Defines.h" #include "GLDraw.h" #include "GLCompat.h" diff --git a/LunaDll/Rendering/GL/GLDraw.h b/LunaDll/Rendering/GL/GLDraw.h index 08df3068d..85f163e4c 100644 --- a/LunaDll/Rendering/GL/GLDraw.h +++ b/LunaDll/Rendering/GL/GLDraw.h @@ -2,7 +2,7 @@ #define GLDraw_hhhh #include -#include +#include #include #include "GLCompat.h" #include "../../Misc/SRect.h" diff --git a/LunaDll/Rendering/GL/GLEngine.cpp b/LunaDll/Rendering/GL/GLEngine.cpp index f02b2d1c5..add10d617 100644 --- a/LunaDll/Rendering/GL/GLEngine.cpp +++ b/LunaDll/Rendering/GL/GLEngine.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "../../Defines.h" #include "../../Globals.h" #include "../RenderUtils.h" diff --git a/LunaDll/Rendering/GL/GLEngine.h b/LunaDll/Rendering/GL/GLEngine.h index 147f5cb4f..2d7f8c8eb 100644 --- a/LunaDll/Rendering/GL/GLEngine.h +++ b/LunaDll/Rendering/GL/GLEngine.h @@ -2,7 +2,7 @@ #define GLEngine_hhhh #include -#include +#include #include #include #include "GLDraw.h" diff --git a/LunaDll/Rendering/GL/GLEngineProxy.h b/LunaDll/Rendering/GL/GLEngineProxy.h index 09e2e84e5..f957069a7 100644 --- a/LunaDll/Rendering/GL/GLEngineProxy.h +++ b/LunaDll/Rendering/GL/GLEngineProxy.h @@ -1,7 +1,7 @@ #ifndef GLEngineProxy__hhhh #define GLEngineProxy__hhhh -#include +#include #include #include #include diff --git a/LunaDll/Rendering/GL/GLFramebuffer.h b/LunaDll/Rendering/GL/GLFramebuffer.h index c3cf80395..54be55be7 100644 --- a/LunaDll/Rendering/GL/GLFramebuffer.h +++ b/LunaDll/Rendering/GL/GLFramebuffer.h @@ -2,7 +2,7 @@ #define GLFramebuffer_hhhh #include -#include +#include #include "GLTextureStore.h" class GLFramebuffer { diff --git a/LunaDll/Rendering/GL/GLInitTest.cpp b/LunaDll/Rendering/GL/GLInitTest.cpp index 1723b9c4e..f6f9d25b3 100644 --- a/LunaDll/Rendering/GL/GLInitTest.cpp +++ b/LunaDll/Rendering/GL/GLInitTest.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "../../Defines.h" diff --git a/LunaDll/Rendering/GL/GLSplitSprite.h b/LunaDll/Rendering/GL/GLSplitSprite.h index 912b028d2..72490f9e9 100644 --- a/LunaDll/Rendering/GL/GLSplitSprite.h +++ b/LunaDll/Rendering/GL/GLSplitSprite.h @@ -2,7 +2,7 @@ #define GLSplitSprite_hhhh #include -#include +#include #include #include #include "GLDraw.h" diff --git a/LunaDll/Rendering/GL/GLSprite.h b/LunaDll/Rendering/GL/GLSprite.h index 2eb50a4bf..029e65374 100644 --- a/LunaDll/Rendering/GL/GLSprite.h +++ b/LunaDll/Rendering/GL/GLSprite.h @@ -2,7 +2,7 @@ #define GLSprite_hhhh #include -#include +#include #include #include "GLDraw.h" diff --git a/LunaDll/Rendering/GL/GLTextureStore.cpp b/LunaDll/Rendering/GL/GLTextureStore.cpp index 5e8b8ddd3..188239793 100644 --- a/LunaDll/Rendering/GL/GLTextureStore.cpp +++ b/LunaDll/Rendering/GL/GLTextureStore.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "../../Defines.h" #include "../RenderUtils.h" #include "GLTextureStore.h" @@ -8,7 +8,7 @@ // Instance GLTextureStore g_GLTextureStore; -std::atomic GLTextureStore::totalMem = 0; +std::atomic GLTextureStore::totalMem(0); // Constructor GLTextureStore::GLTextureStore() { diff --git a/LunaDll/Rendering/GL/GLTextureStore.h b/LunaDll/Rendering/GL/GLTextureStore.h index f68752a23..64b8b46b6 100644 --- a/LunaDll/Rendering/GL/GLTextureStore.h +++ b/LunaDll/Rendering/GL/GLTextureStore.h @@ -2,7 +2,7 @@ #define GLTextureStore_hhhh #include -#include +#include #include #include #include diff --git a/LunaDll/Rendering/LunaImage.cpp b/LunaDll/Rendering/LunaImage.cpp index 6d35bfa41..8201f8459 100644 --- a/LunaDll/Rendering/LunaImage.cpp +++ b/LunaDll/Rendering/LunaImage.cpp @@ -12,8 +12,8 @@ static CachedFileDataWeakPtr g_lunaImageCache; static std::mutex g_lunaImageCacheMutex; -std::atomic LunaImage::totalRawMem = 0; -std::atomic LunaImage::totalCompMem = 0; +std::atomic LunaImage::totalRawMem(0); +std::atomic LunaImage::totalCompMem(0); void LunaImage::holdCachedImages(bool isWorld) { @@ -29,7 +29,7 @@ void LunaImage::releaseCachedImages(bool isWorld) uint64_t LunaImage::getNewUID() { - static std::atomic uidCounter = 1; + static std::atomic uidCounter(1); return uidCounter.fetch_add(1, std::memory_order_relaxed); } diff --git a/LunaDll/Rendering/Rendering.cpp b/LunaDll/Rendering/Rendering.cpp index 4184650c9..062278c0d 100644 --- a/LunaDll/Rendering/Rendering.cpp +++ b/LunaDll/Rendering/Rendering.cpp @@ -24,7 +24,7 @@ using namespace std; static Renderer sLunaRender; static Renderer sAltLunaRender; static DWORD altLunaRenderThread = 0; -static std::atomic altLunaRenderThreadValid = false; +static std::atomic altLunaRenderThreadValid(false); Renderer& Renderer::Get() { diff --git a/LunaDll/Rendering/SMBXImageCategories.h b/LunaDll/Rendering/SMBXImageCategories.h index a9a861535..4fc0c51f4 100644 --- a/LunaDll/Rendering/SMBXImageCategories.h +++ b/LunaDll/Rendering/SMBXImageCategories.h @@ -81,22 +81,22 @@ struct SMBXImageCategory } }; -static const SMBXImageCategory smbxImageCategoryBlock = { L"block", Block::MAX_ID, GM_GFX_BLOCKS_PTR_CONSTPTR, GM_GFX_BLOCKS_MASK_PTR_CONSTPTR, nullptr, nullptr, nullptr, 1 }; -static const SMBXImageCategory smbxImageCategoryBackground2 = { L"background2", 100, GM_GFX_BACKGROUND2_PTR_CONSTPTR, nullptr, GM_GFX_BACKGROUND2_W_PTR_CONSTPTR, GM_GFX_BACKGROUND2_H_PTR_CONSTPTR, nullptr, 1 }; -static const SMBXImageCategory smbxImageCategoryNpc = { L"npc", NPC::MAX_ID, GM_GFX_NPC_PTR_CONSTPTR, GM_GFX_NPC_MASK_PTR_CONSTPTR, GM_GFX_NPC_W_PTR_CONSTPTR, GM_GFX_NPC_H_PTR_CONSTPTR, nullptr, 1 }; -static const SMBXImageCategory smbxImageCategoryEffect = { L"effect", SMBXAnimation::MAX_ID, GM_GFX_EFFECTS_PTR_CONSTPTR, GM_GFX_EFFECTS_MASK_PTR_CONSTPTR, GM_GFX_EFFECTS_W_PTR_CONSTPTR, GM_GFX_EFFECTS_H_PTR_CONSTPTR, nullptr, 1 }; -static const SMBXImageCategory smbxImageCategoryBackground = { L"background", SMBX_BGO::MAX_ID, GM_GFX_BACKGROUND_PTR_CONSTPTR, GM_GFX_BACKGROUND_MASK_PTR_CONSTPTR, GM_GFX_BACKGROUND_W_PTR_CONSTPTR, GM_GFX_BACKGROUND_H_PTR_CONSTPTR, nullptr, 1 }; -static const SMBXImageCategory smbxImageCategoryMario = { L"mario", 10, GM_GFX_MARIO_PTR_CONSTPTR, GM_GFX_MARIO_MASK_PTR_CONSTPTR, GM_GFX_MARIO_W_PTR_CONSTPTR, GM_GFX_MARIO_H_PTR_CONSTPTR, nullptr, 1 }; -static const SMBXImageCategory smbxImageCategoryLuigi = { L"luigi", 10, GM_GFX_LUIGI_PTR_CONSTPTR, GM_GFX_LUIGI_MASK_PTR_CONSTPTR, GM_GFX_LUIGI_W_PTR_CONSTPTR, GM_GFX_LUIGI_H_PTR_CONSTPTR, nullptr, 1 }; -static const SMBXImageCategory smbxImageCategoryPeach = { L"peach", 10, GM_GFX_PEACH_PTR_CONSTPTR, GM_GFX_PEACH_MASK_PTR_CONSTPTR, GM_GFX_PEACH_W_PTR_CONSTPTR, GM_GFX_PEACH_H_PTR_CONSTPTR, nullptr, 1 }; -static const SMBXImageCategory smbxImageCategoryToad = { L"toad", 10, GM_GFX_TOAD_PTR_CONSTPTR, GM_GFX_TOAD_MASK_PTR_CONSTPTR, GM_GFX_TOAD_W_PTR_CONSTPTR, GM_GFX_TOAD_H_PTR_CONSTPTR, nullptr, 1 }; -static const SMBXImageCategory smbxImageCategoryLink = { L"link", 10, GM_GFX_LINK_PTR_CONSTPTR, GM_GFX_LINK_MASK_PTR_CONSTPTR, GM_GFX_LINK_W_PTR_CONSTPTR, GM_GFX_LINK_H_PTR_CONSTPTR, nullptr, 1 }; -static const SMBXImageCategory smbxImageCategoryYoshiB = { L"yoshib", 10, GM_GFX_YOSHIB_PTR_CONSTPTR, GM_GFX_YOSHIB_MASK_PTR_CONSTPTR, nullptr, nullptr, L"yoshi", 1 }; -static const SMBXImageCategory smbxImageCategoryYoshiT = { L"yoshit", 10, GM_GFX_YOSHIT_PTR_CONSTPTR, GM_GFX_YOSHIT_MASK_PTR_CONSTPTR, nullptr, nullptr, L"yoshi", 1 }; -static const SMBXImageCategory smbxImageCategoryTile = { L"tile", SMBXTile::MAX_ID, GM_GFX_TILES_PTR_CONSTPTR, nullptr, GM_GFX_TILES_W_PTR_CONSTPTR, GM_GFX_TILES_H_PTR_CONSTPTR, nullptr, 1 }; -static const SMBXImageCategory smbxImageCategoryLevel = { L"level", WorldLevel::MAX_ID+1, GM_GFX_LEVEL_PTR_CONSTPTR, GM_GFX_LEVEL_MASK_PTR_CONSTPTR, GM_GFX_LEVEL_W_PTR_CONSTPTR, GM_GFX_LEVEL_H_PTR_CONSTPTR, nullptr, 0 }; -static const SMBXImageCategory smbxImageCategoryScene = { L"scene", SMBXScenery::MAX_ID, GM_GFX_SCENE_PTR_CONSTPTR, GM_GFX_SCENE_MASK_PTR_CONSTPTR, GM_GFX_SCENE_W_PTR_CONSTPTR, GM_GFX_SCENE_H_PTR_CONSTPTR, nullptr, 1 }; -static const SMBXImageCategory smbxImageCategoryPath = { L"path", SMBXPath::MAX_ID, GM_GFX_PATH_PTR_CONSTPTR, GM_GFX_PATH_MASK_PTR_CONSTPTR, GM_GFX_PATH_W_PTR_CONSTPTR, GM_GFX_PATH_H_PTR_CONSTPTR, nullptr, 1 }; -static const SMBXImageCategory smbxImageCategoryPlayer = { L"player", 5, GM_GFX_PLAYER_PTR_CONSTPTR, GM_GFX_PLAYER_MASK_PTR_CONSTPTR, GM_GFX_PLAYER_W_PTR_CONSTPTR, GM_GFX_PLAYER_H_PTR_CONSTPTR, nullptr, 1 }; +static const SMBXImageCategory smbxImageCategoryBlock = { L"block", Block::MAX_ID, GM_GFX_BLOCKS_PTR_POINTER, GM_GFX_BLOCKS_MASK_PTR_POINTER, nullptr, nullptr, nullptr, 1 }; +static const SMBXImageCategory smbxImageCategoryBackground2 = { L"background2", 100, GM_GFX_BACKGROUND2_PTR_POINTER, nullptr, GM_GFX_BACKGROUND2_W_PTR_POINTER, GM_GFX_BACKGROUND2_H_PTR_POINTER, nullptr, 1 }; +static const SMBXImageCategory smbxImageCategoryNpc = { L"npc", NPC::MAX_ID, GM_GFX_NPC_PTR_POINTER, GM_GFX_NPC_MASK_PTR_POINTER, GM_GFX_NPC_W_PTR_POINTER, GM_GFX_NPC_H_PTR_POINTER, nullptr, 1 }; +static const SMBXImageCategory smbxImageCategoryEffect = { L"effect", SMBXAnimation::MAX_ID, GM_GFX_EFFECTS_PTR_POINTER, GM_GFX_EFFECTS_MASK_PTR_POINTER, GM_GFX_EFFECTS_W_PTR_POINTER, GM_GFX_EFFECTS_H_PTR_POINTER, nullptr, 1 }; +static const SMBXImageCategory smbxImageCategoryBackground = { L"background", SMBX_BGO::MAX_ID, GM_GFX_BACKGROUND_PTR_POINTER, GM_GFX_BACKGROUND_MASK_PTR_POINTER, GM_GFX_BACKGROUND_W_PTR_POINTER, GM_GFX_BACKGROUND_H_PTR_POINTER, nullptr, 1 }; +static const SMBXImageCategory smbxImageCategoryMario = { L"mario", 10, GM_GFX_MARIO_PTR_POINTER, GM_GFX_MARIO_MASK_PTR_POINTER, GM_GFX_MARIO_W_PTR_POINTER, GM_GFX_MARIO_H_PTR_POINTER, nullptr, 1 }; +static const SMBXImageCategory smbxImageCategoryLuigi = { L"luigi", 10, GM_GFX_LUIGI_PTR_POINTER, GM_GFX_LUIGI_MASK_PTR_POINTER, GM_GFX_LUIGI_W_PTR_POINTER, GM_GFX_LUIGI_H_PTR_POINTER, nullptr, 1 }; +static const SMBXImageCategory smbxImageCategoryPeach = { L"peach", 10, GM_GFX_PEACH_PTR_POINTER, GM_GFX_PEACH_MASK_PTR_POINTER, GM_GFX_PEACH_W_PTR_POINTER, GM_GFX_PEACH_H_PTR_POINTER, nullptr, 1 }; +static const SMBXImageCategory smbxImageCategoryToad = { L"toad", 10, GM_GFX_TOAD_PTR_POINTER, GM_GFX_TOAD_MASK_PTR_POINTER, GM_GFX_TOAD_W_PTR_POINTER, GM_GFX_TOAD_H_PTR_POINTER, nullptr, 1 }; +static const SMBXImageCategory smbxImageCategoryLink = { L"link", 10, GM_GFX_LINK_PTR_POINTER, GM_GFX_LINK_MASK_PTR_POINTER, GM_GFX_LINK_W_PTR_POINTER, GM_GFX_LINK_H_PTR_POINTER, nullptr, 1 }; +static const SMBXImageCategory smbxImageCategoryYoshiB = { L"yoshib", 10, GM_GFX_YOSHIB_PTR_POINTER, GM_GFX_YOSHIB_MASK_PTR_POINTER, nullptr, nullptr, L"yoshi", 1 }; +static const SMBXImageCategory smbxImageCategoryYoshiT = { L"yoshit", 10, GM_GFX_YOSHIT_PTR_POINTER, GM_GFX_YOSHIT_MASK_PTR_POINTER, nullptr, nullptr, L"yoshi", 1 }; +static const SMBXImageCategory smbxImageCategoryTile = { L"tile", SMBXTile::MAX_ID, GM_GFX_TILES_PTR_POINTER, nullptr, GM_GFX_TILES_W_PTR_POINTER, GM_GFX_TILES_H_PTR_POINTER, nullptr, 1 }; +static const SMBXImageCategory smbxImageCategoryLevel = { L"level", WorldLevel::MAX_ID+1, GM_GFX_LEVEL_PTR_POINTER, GM_GFX_LEVEL_MASK_PTR_POINTER, GM_GFX_LEVEL_W_PTR_POINTER, GM_GFX_LEVEL_H_PTR_POINTER, nullptr, 0 }; +static const SMBXImageCategory smbxImageCategoryScene = { L"scene", SMBXScenery::MAX_ID, GM_GFX_SCENE_PTR_POINTER, GM_GFX_SCENE_MASK_PTR_POINTER, GM_GFX_SCENE_W_PTR_POINTER, GM_GFX_SCENE_H_PTR_POINTER, nullptr, 1 }; +static const SMBXImageCategory smbxImageCategoryPath = { L"path", SMBXPath::MAX_ID, GM_GFX_PATH_PTR_POINTER, GM_GFX_PATH_MASK_PTR_POINTER, GM_GFX_PATH_W_PTR_POINTER, GM_GFX_PATH_H_PTR_POINTER, nullptr, 1 }; +static const SMBXImageCategory smbxImageCategoryPlayer = { L"player", 5, GM_GFX_PLAYER_PTR_POINTER, GM_GFX_PLAYER_MASK_PTR_POINTER, GM_GFX_PLAYER_W_PTR_POINTER, GM_GFX_PLAYER_H_PTR_POINTER, nullptr, 1 }; #endif diff --git a/LunaDll/Rendering/Shaders/GLShaderVariableEntry.h b/LunaDll/Rendering/Shaders/GLShaderVariableEntry.h index 40c6f95c4..e884e4c76 100644 --- a/LunaDll/Rendering/Shaders/GLShaderVariableEntry.h +++ b/LunaDll/Rendering/Shaders/GLShaderVariableEntry.h @@ -2,7 +2,7 @@ #include #include -#include +#include #include "GLShaderVariableType.h" diff --git a/LunaDll/Rendering/Shaders/GLShaderVariableInfo.h b/LunaDll/Rendering/Shaders/GLShaderVariableInfo.h index cd604bc2d..b7c3201d8 100644 --- a/LunaDll/Rendering/Shaders/GLShaderVariableInfo.h +++ b/LunaDll/Rendering/Shaders/GLShaderVariableInfo.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include "GLShaderVariableType.h" diff --git a/LunaDll/SMBXInternal/Animation.h b/LunaDll/SMBXInternal/Animation.h index 242a700f8..e79f1f2d9 100644 --- a/LunaDll/SMBXInternal/Animation.h +++ b/LunaDll/SMBXInternal/Animation.h @@ -158,7 +158,7 @@ enum EffectID : short #pragma pack(push, 4) -struct SMBXAnimation : SMBX_FullBaseItemArray { +struct SMBXAnimation : SMBX_FullBaseItemArray { EffectID AnimationID; short unknown02; Momentum momentum; diff --git a/LunaDll/SMBXInternal/BGOs.h b/LunaDll/SMBXInternal/BGOs.h index 87c1a6d4f..3ce06957f 100644 --- a/LunaDll/SMBXInternal/BGOs.h +++ b/LunaDll/SMBXInternal/BGOs.h @@ -7,7 +7,7 @@ #include "BaseItemArray.h" #pragma pack(push, 4) -struct SMBX_BGO : SMBX_FullBaseItemArray { // Length should be 0x38 +struct SMBX_BGO : SMBX_FullBaseItemArray { // Length should be 0x38 VB6StrPtr ptLayerName; // +0x00 short isHidden; // +0x04 short id; // +0x06 diff --git a/LunaDll/SMBXInternal/BaseItemArray.h b/LunaDll/SMBXInternal/BaseItemArray.h index c5b929115..19a6b23c2 100644 --- a/LunaDll/SMBXInternal/BaseItemArray.h +++ b/LunaDll/SMBXInternal/BaseItemArray.h @@ -1,40 +1,43 @@ #ifndef BaseItemArray_hhhhh #define BaseItemArray_hhhhh +#include +#include + template< class T, // The internal class int MAX_SIZE_VAL, // The maximum size of the array - void** const ARRAY_VAL_PTR, // The ptr of the actual array + const std::uintptr_t ARRAY_VAL_PTR, // The ptr of the actual array const int OFFSET_VAL = 0 // (Optional) Offset added to the index > struct SMBX_StaticBaseItemArray { static inline T* Get(unsigned short index) { if (index >= MAX_SIZE_VAL) return NULL; - return &((T*)*ARRAY_VAL_PTR)[index + OFFSET_VAL]; + return &(*(T**)ARRAY_VAL_PTR)[index + OFFSET_VAL]; } }; template< class T, // The internal class const short MAX_ID_VAL, // The ptr to the max id - const unsigned short* COUNT_VAL_PTR, // The ptr to the count value (how many objects of type T are in that array) - void** const ARRAY_VAL_PTR, // The ptr of the actual array + const std::uintptr_t COUNT_VAL_PTR, // The ptr to the count value (how many objects of type T are in that array) + const std::uintptr_t ARRAY_VAL_PTR, // The ptr of the actual array const int OFFSET_VAL = 0 // (Optional) Offset added to the index > struct SMBX_FullBaseItemArray { static inline T* Get(unsigned short index) { if (index > Count()) return NULL; - return &((T*)*ARRAY_VAL_PTR)[index + OFFSET_VAL]; + return &(*(T**)ARRAY_VAL_PTR)[index + OFFSET_VAL]; } static inline T* GetRaw(unsigned short index) { - return &((T*)*ARRAY_VAL_PTR)[index + OFFSET_VAL]; + return &(*(T**)ARRAY_VAL_PTR)[index + OFFSET_VAL]; } static inline unsigned short Count() { - return *COUNT_VAL_PTR; + return *(unsigned short*)COUNT_VAL_PTR; } static const short MAX_ID = MAX_ID_VAL; diff --git a/LunaDll/SMBXInternal/Blocks.h b/LunaDll/SMBXInternal/Blocks.h index 92a03d722..93949b535 100644 --- a/LunaDll/SMBXInternal/Blocks.h +++ b/LunaDll/SMBXInternal/Blocks.h @@ -7,7 +7,7 @@ struct PlayerMOB; #pragma pack(push, 4) -struct Block : SMBX_FullBaseItemArray { +struct Block : SMBX_FullBaseItemArray { short Slippery; // 0x00 0xFFFF = yes short Unknown02; // 0x02 diff --git a/LunaDll/SMBXInternal/CollectedStarRecord.h b/LunaDll/SMBXInternal/CollectedStarRecord.h index 3d98b3e6c..9318abd9e 100644 --- a/LunaDll/SMBXInternal/CollectedStarRecord.h +++ b/LunaDll/SMBXInternal/CollectedStarRecord.h @@ -7,7 +7,7 @@ #include "BaseItemArray.h" #pragma pack(push, 1) -struct SMBX_CollectedStarRecord : SMBX_FullBaseItemArray +struct SMBX_CollectedStarRecord : SMBX_FullBaseItemArray { VB6StrPtr levelFileName; //0x00 short section; //0x04 diff --git a/LunaDll/SMBXInternal/Layer.h b/LunaDll/SMBXInternal/Layer.h index 8d198cc19..86eced32d 100644 --- a/LunaDll/SMBXInternal/Layer.h +++ b/LunaDll/SMBXInternal/Layer.h @@ -7,7 +7,7 @@ #include "BaseItemArray.h" #pragma pack(push, 4) -struct LayerControl : SMBX_StaticBaseItemArray { +struct LayerControl : SMBX_StaticBaseItemArray { short IsStopped; // 0x00 0xFFFF when moving, event ended? short Unknown1; // 0x02 VB6StrPtr ptLayerName; // 0x04 ptr to double zero terminated 2byte wide char string diff --git a/LunaDll/SMBXInternal/Menu.h b/LunaDll/SMBXInternal/Menu.h index 1c75a3c20..f2f725bab 100644 --- a/LunaDll/SMBXInternal/Menu.h +++ b/LunaDll/SMBXInternal/Menu.h @@ -5,7 +5,7 @@ #include "../Defines.h" #include "BaseItemArray.h" -struct EpisodeListItem : SMBX_FullBaseItemArray +struct EpisodeListItem : SMBX_FullBaseItemArray { VB6StrPtr episodeName; VB6StrPtr episodePath; diff --git a/LunaDll/SMBXInternal/Musicbox.h b/LunaDll/SMBXInternal/Musicbox.h index b149f1761..92b88b7a3 100644 --- a/LunaDll/SMBXInternal/Musicbox.h +++ b/LunaDll/SMBXInternal/Musicbox.h @@ -5,7 +5,7 @@ #include "BaseItemArray.h" #pragma pack(push, 1) -struct SMBXMusicbox : SMBX_FullBaseItemArray +struct SMBXMusicbox : SMBX_FullBaseItemArray { Momentum momentum; short id; diff --git a/LunaDll/SMBXInternal/Path.h b/LunaDll/SMBXInternal/Path.h index d277bffb7..86d595615 100644 --- a/LunaDll/SMBXInternal/Path.h +++ b/LunaDll/SMBXInternal/Path.h @@ -4,7 +4,7 @@ #include "../Defines.h" #pragma pack(push, 1) -struct SMBXPath : SMBX_FullBaseItemArray +struct SMBXPath : SMBX_FullBaseItemArray { Momentum momentum; short visible; diff --git a/LunaDll/SMBXInternal/PlayerMOB.h b/LunaDll/SMBXInternal/PlayerMOB.h index dcdb49730..25b218358 100644 --- a/LunaDll/SMBXInternal/PlayerMOB.h +++ b/LunaDll/SMBXInternal/PlayerMOB.h @@ -3,6 +3,7 @@ #define PlayerMob_hhhhh #include "../Defines.h" #include "BaseItemArray.h" +#include #ifndef __MINGW32__ #pragma region Lookup @@ -378,10 +379,10 @@ struct PlayerMOB { /* Verify struct is correctly sized, and also verify that a sampling of fields * that errors in would indicate a problem */ #ifndef __INTELLISENSE__ -static_assert(&((PlayerMOB*)0x0)->ItemPullupTimer == (void*)0x26, "ItemPullupTimer must be at at 0x26"); -static_assert(&((PlayerMOB*)0x0)->HasJumped == (void*)0x60, "HasJumped must be at at 0x60"); -static_assert(&((PlayerMOB*)0x0)->momentum.x == (void*)0xC0, "momentum.x must be at at 0xC0"); -static_assert(&((PlayerMOB*)0x0)->Unknown166 == (void*)0x166, "Unknown166 must be at at 0x166"); +static_assert(offsetof(PlayerMOB, ItemPullupTimer) == 0x26, "ItemPullupTimer must be at at 0x26"); +static_assert(offsetof(PlayerMOB, HasJumped) == 0x60, "HasJumped must be at at 0x60"); +static_assert(offsetof(PlayerMOB, momentum.x) == 0xC0, "momentum.x must be at at 0xC0"); +static_assert(offsetof(PlayerMOB, Unknown166) == 0x166, "Unknown166 must be at at 0x166"); static_assert(sizeof(PlayerMOB) == 0x184, "sizeof(PlayerMOB) must be 0x184"); #endif diff --git a/LunaDll/SMBXInternal/SMBXEvents.h b/LunaDll/SMBXInternal/SMBXEvents.h index 7bd9af51d..901ce1faa 100644 --- a/LunaDll/SMBXInternal/SMBXEvents.h +++ b/LunaDll/SMBXInternal/SMBXEvents.h @@ -109,7 +109,7 @@ //+0x588 w = Auto start #pragma pack(push, 1) -struct SMBXEvent : SMBX_StaticBaseItemArray +struct SMBXEvent : SMBX_StaticBaseItemArray { short NoSmoke; // 0x00 (0xFFFF == no smoke, 0 == smoke) short SoundID; // 0x02 diff --git a/LunaDll/SMBXInternal/Scenery.h b/LunaDll/SMBXInternal/Scenery.h index c395abffe..d812421fd 100644 --- a/LunaDll/SMBXInternal/Scenery.h +++ b/LunaDll/SMBXInternal/Scenery.h @@ -5,7 +5,7 @@ #include "BaseItemArray.h" #pragma pack(push, 1) -struct SMBXScenery : SMBX_FullBaseItemArray +struct SMBXScenery : SMBX_FullBaseItemArray { Momentum momentum; short id; diff --git a/LunaDll/SMBXInternal/Sound.cpp b/LunaDll/SMBXInternal/Sound.cpp index 35e5ac7f3..dfb1ad050 100644 --- a/LunaDll/SMBXInternal/Sound.cpp +++ b/LunaDll/SMBXInternal/Sound.cpp @@ -53,7 +53,7 @@ static std::wstring g_LastActiveCustomMusicPath = L""; void SMBXSound::StoreActiveCustomMusicPath(unsigned int section) { - g_LastActiveCustomMusicPath = GM_MUSIC_PATHS_PTR[section]; + g_LastActiveCustomMusicPath = static_cast(GM_MUSIC_PATHS_PTR[section]); } std::wstring SMBXSound::GetActiveCustomMusicPath() diff --git a/LunaDll/SMBXInternal/Tile.h b/LunaDll/SMBXInternal/Tile.h index a6af770fa..e06f1ad4d 100644 --- a/LunaDll/SMBXInternal/Tile.h +++ b/LunaDll/SMBXInternal/Tile.h @@ -5,7 +5,7 @@ #include "BaseItemArray.h" #pragma pack(push, 1) -struct SMBXTile : SMBX_FullBaseItemArray +struct SMBXTile : SMBX_FullBaseItemArray { Momentum momentum; short id; diff --git a/LunaDll/SMBXInternal/Warp.h b/LunaDll/SMBXInternal/Warp.h index bed695d51..1723c22af 100644 --- a/LunaDll/SMBXInternal/Warp.h +++ b/LunaDll/SMBXInternal/Warp.h @@ -27,7 +27,7 @@ enum SMBX_WarpType : short { }; #pragma pack(push, 1) -struct SMBX_Warp : SMBX_FullBaseItemArray +struct SMBX_Warp : SMBX_FullBaseItemArray { short isLocked; //0x00 short allowCarryNPC; //0x02 diff --git a/LunaDll/SMBXInternal/Water.h b/LunaDll/SMBXInternal/Water.h index d00b5fabd..b601b1690 100644 --- a/LunaDll/SMBXInternal/Water.h +++ b/LunaDll/SMBXInternal/Water.h @@ -7,7 +7,7 @@ #include "BaseItemArray.h" #pragma pack(push, 4) -struct SMBX_Water : SMBX_FullBaseItemArray // Length should be 0x40 +struct SMBX_Water : SMBX_FullBaseItemArray // Length should be 0x40 { VB6StrPtr ptLayerName; // +0x00 short isHidden; // +0x04 // boolean diff --git a/LunaDll/SMBXInternal/WorldLevel.h b/LunaDll/SMBXInternal/WorldLevel.h index 1e573a580..4ad0972fd 100644 --- a/LunaDll/SMBXInternal/WorldLevel.h +++ b/LunaDll/SMBXInternal/WorldLevel.h @@ -6,7 +6,7 @@ #include "BaseItemArray.h" #pragma pack(push, 1) -struct WorldLevel : SMBX_FullBaseItemArray +struct WorldLevel : SMBX_FullBaseItemArray { Momentum momentum; short id; diff --git a/LunaDll/SdlMusic/SdlMusPlayer.cpp b/LunaDll/SdlMusic/SdlMusPlayer.cpp index 3fd3837f8..797ec5bfe 100644 --- a/LunaDll/SdlMusic/SdlMusPlayer.cpp +++ b/LunaDll/SdlMusic/SdlMusPlayer.cpp @@ -112,8 +112,8 @@ std::string PGE_MusPlayer::currentTrack=""; int PGE_MusPlayer::sRate=44100; bool PGE_MusPlayer::showMsg=true; std::string PGE_MusPlayer::showMsg_for=""; -std::atomic PGE_MusPlayer::sCount = 0; -std::atomic PGE_MusPlayer::musSCount = 0; +std::atomic PGE_MusPlayer::sCount(0); +std::atomic PGE_MusPlayer::musSCount(0); Mix_Music *PGE_MusPlayer::currentMusic() { diff --git a/LunaDll/libs/luabind-deboostified b/LunaDll/libs/luabind-deboostified new file mode 160000 index 000000000..b6e468e61 --- /dev/null +++ b/LunaDll/libs/luabind-deboostified @@ -0,0 +1 @@ +Subproject commit b6e468e610c8f4051081b1abb3dc3fbf9597bf6c diff --git a/LunaDll/resource.h b/LunaDll/resource.h index 11d9dbf6b7e68564267a120f808b953f9f80212f..6a00933b7b8c32bc49b8f1861cdd1e28bf34de9a 100644 GIT binary patch literal 1062 zcmZ|OQE!_t5C`ygK82+`R%-Ctb=#wBdy5;eE8AqtlSLCVF(D!aXg5{;?mN($*h$7q z1o?6L`|g;}Utgtij6ZV8xTJ!cx3^?IM|r*3@48*pqgCAvWrOI|75eF0zb|{gMRmJr zhOI|c-T3R#7acr(`h&8eEm_lC?>F!?nQeVlw;l<`oECIp`47tk$<#L#T{!&^S*nRy zT!QcxPHzIM-B(U*q4|SR5=TWRdmC8l?xl4GPI~Ibdz_~D3`=#H0}c~YM;Dwfom9ju z&x!*MBU8tjuwyISbk5v_-2nVCieW6Vf?no;@BW9!;1=TR71vWFz@H*~i1B?vU@UB{ z3a0+02mCq0L5wpF_)CNjm7%1TBh@u&3qF^ys;42H&A-w@0miLA$44e$#i;D%TYtL>`STm{3m0m0EI^ z%<8I*{?ME-C9}0N>-=72=5SUA?>ae-U2_9{q1>%VRvdbRgTWsyRe4S%iz&KI!)*<< ev|42+8qRwB4vrWC^3%do7n7N9w{`XYll%n{!4ob3 literal 2186 zcmbW3TW`}q5Ju-2iT_}UMT#2(Wk`)m_i@GM!sroUuu#>yC}HM0rxDJyeEPj)m6U^(dv`+-aw z=>?1w$vKis2$enRAC)YTq%Fegls2-QQDP_7XBQuNr_5t$J$r|gzcua1o|YPX=*yRt~}r0L?P!~X6$DhPse^4Wbgar0};?pbbeAhhd!Y1?Qo^Rv0nw* z^**_u@7S+{?0vhPr8!v>Q?;@?_EugITTdvz>+Qau@7Uq9bGJ$*cvdG>r?l^}x$<{2 zP^XmN%07|W0Z!$I-QL;l&Q4WnBkY;j_p;urc2B9uYwEG;|JSneuUTC&n{qEK=~a!t z(O=nxePKLCc2)Y>-6YQAGvpmFB2H(VI#oaAn(m}iv