diff --git a/.gitignore b/.gitignore index 3119a09b0..791b6f575 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ Win32_LIB_ASM_Release /assets/debian /make /bin +/build diff --git a/CMakeLists.txt b/CMakeLists.txt index ad49f3ac5..0c2f8e4b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,17 +1,15 @@ -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.14 FATAL_ERROR) -# Enable CCache early -set(SRB2_USE_CCACHE OFF CACHE BOOL "Use CCache") -if (${SRB2_USE_CCACHE}) - find_program(CCACHE_PROGRAM ccache) - if(CCACHE_PROGRAM) - message(STATUS "Found CCache: ${CCACHE_PROGRAM}") - set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}") - else() - message(WARNING "You have specified to use CCACHE but it was not found. Object files will not be cached.") - endif() +if("${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") + message(FATAL_ERROR "In-source builds are blocked. Please build from a separate directory.") endif() +# Set up CMAKE path +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") + +include(CMakeDependentOption) +include(cmake/CPM.cmake) + file(STRINGS src/version.h SRB2_VERSION) string(REGEX MATCH "[0-9]+\\.[0-9.]+" SRB2_VERSION ${SRB2_VERSION}) @@ -19,121 +17,23 @@ string(REGEX MATCH "[0-9]+\\.[0-9.]+" SRB2_VERSION ${SRB2_VERSION}) # Version change is fine. project(SRB2 VERSION ${SRB2_VERSION} - LANGUAGES C) + LANGUAGES C CXX) -if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) - message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.") +if(APPLE) + # DiscordRPC needs but does not properly specify ObjC + enable_language(OBJC) endif() -if ((${SRB2_USE_CCACHE}) AND (${CMAKE_C_COMPILER} MATCHES "clang")) - message(WARNING "Using clang and CCache: You may want to set environment variable CCACHE_CPP2=yes to prevent include errors during compile.") -endif() - -# Set up CMAKE path -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") - -### Useful functions - -# Add sources from Sourcefile -function(target_sourcefile type) - file(STRINGS Sourcefile list - REGEX "[-0-9A-Za-z_]+\.${type}") - target_sources(SRB2SDL2 PRIVATE ${list}) -endfunction() - -# Macro to add OSX framework -macro(add_framework fwname appname) - find_library(FRAMEWORK_${fwname} - NAMES ${fwname} - PATHS ${CMAKE_OSX_SYSROOT}/System/Library - ${CMAKE_OSX_SYSROOT}/Library - /System/Library - /Library - ATH_SUFFIXES Frameworks - NO_DEFAULT_PATH) - if( ${FRAMEWORK_${fwname}} STREQUAL FRAMEWORK_${fwname}-NOTFOUND) - MESSAGE(ERROR ": Framework ${fwname} not found") - else() - TARGET_LINK_LIBRARIES(${appname} PRIVATE "${FRAMEWORK_${fwname}}/${fwname}") - MESSAGE(STATUS "Framework ${fwname} found at ${FRAMEWORK_${fwname}}") - endif() -endmacro() - -# Macro to copy Windows DLLs to Debug/Release folder for easy debugging -# Note: this is general purpose, we could copy anything. Just using for DLLs on MSVC though -macro(copy_files_to_build_dir target dlllist_var) - if(MSVC) - # http://stackoverflow.com/a/26983405/3064195 - foreach(dlllist_item ${${dlllist_var}}) - get_filename_component(dllname ${dlllist_item} NAME) - add_custom_command(TARGET ${target} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${dlllist_item} - $/${dllname} - ) - endforeach() - endif() -endmacro() - -# bitness check -set(SRB2_SYSTEM_BITS 0) -if(CMAKE_SIZEOF_VOID_P EQUAL 8) - message(STATUS "Target is 64-bit") - set(SRB2_SYSTEM_BITS 64) -endif() -if(CMAKE_SIZEOF_VOID_P EQUAL 4) - message(STATUS "Target is 32-bit") - set(SRB2_SYSTEM_BITS 32) -endif() -if(${SRB2_SYSTEM_BITS} EQUAL 0) - message(STATUS "Target bitness is unknown") -endif() - -# OS macros -if (UNIX) - add_definitions(-DUNIXCOMMON) -endif() - -if(CMAKE_COMPILER_IS_GNUCC) - find_program(OBJCOPY objcopy) -endif() - -if(${CMAKE_SYSTEM} MATCHES "Linux") - add_definitions(-DLINUX) - if(${SRB2_SYSTEM_BITS} EQUAL 64) - add_definitions(-DLINUX64) - endif() -endif() - -if(${CMAKE_SYSTEM} MATCHES "Darwin") - add_definitions(-DMACOSX) -endif() - -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") -set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") - -# Set EXE names so the assets CMakeLists can refer to its target -set(SRB2_SDL2_EXE_NAME srb2kart-v2 CACHE STRING "Executable binary output name") - -include_directories(${CMAKE_CURRENT_BINARY_DIR}/src) - -add_subdirectory(src) - -# Shut Up please lmao -#if(NOT ${SRB2_CONFIG_DEV_BUILD}) -# add_subdirectory(assets) -#endif() - ##### PACKAGE CONFIGURATION ##### set(SRB2_CPACK_GENERATOR "" CACHE STRING "Generator to use for making a package. E.g., ZIP, TGZ, DragNDrop (OSX only). Leave blank for default generator.") if("${SRB2_CPACK_GENERATOR}" STREQUAL "") - if(${CMAKE_SYSTEM} MATCHES "Windows") + if("${CMAKE_SYSTEM_NAME}" MATCHES "Windows") set(SRB2_CPACK_GENERATOR "ZIP") - elseif(${CMAKE_SYSTEM} MATCHES "Linux") + elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") set(SRB2_CPACK_GENERATOR "TGZ") - elseif(${CMAKE_SYSTEM} MATCHES "Darwin") + elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") set(SRB2_CPACK_GENERATOR "TGZ") endif() endif() @@ -149,3 +49,158 @@ set(CPACK_PACKAGE_VERSION_PATCH ${SRB2_VERSION_PATCH}) set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}") SET(CPACK_OUTPUT_FILE_PREFIX package) include(CPack) + +# Options + +if("${CMAKE_SYSTEM_NAME}" MATCHES Linux) + set(SRB2_CONFIG_SYSTEM_LIBRARIES_DEFAULT ON) +else() + set(SRB2_CONFIG_SYSTEM_LIBRARIES_DEFAULT OFF) +endif() + +option( + SRB2_CONFIG_SYSTEM_LIBRARIES + "Link dependencies using CMake's find_package and do not use internal builds" + ${SRB2_CONFIG_SYSTEM_LIBRARIES_DEFAULT} +) +option(SRB2_CONFIG_ENABLE_TESTS "Build the test suite" OFF) +# This option isn't recommended for distribution builds and probably won't work (yet). +cmake_dependent_option( + SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES + "Use dynamic libraries when compiling internal dependencies" + OFF "NOT SRB2_CONFIG_SYSTEM_LIBRARIES" + OFF +) +option(SRB2_CONFIG_HWRENDER "Enable hardware render (OpenGL) support" ON) +option(SRB2_CONFIG_STATIC_OPENGL "Enable static linking GL (do not do this)" OFF) +option(SRB2_CONFIG_ERRORMODE "Compile C code with warnings treated as errors." OFF) +option(SRB2_CONFIG_DEBUGMODE "Compile with PARANOIA, ZDEBUG, RANGECHECK and PACKETDROP defined." OFF) +option(SRB2_CONFIG_MOBJCONSISTANCY "Compile with MOBJCONSISTANCY defined." OFF) +option(SRB2_CONFIG_PACKETDROP "Compile with PACKETDROP defined." OFF) +option(SRB2_CONFIG_ZDEBUG "Compile with ZDEBUG defined." OFF) +# SRB2_CONFIG_PROFILEMODE is probably superceded by some CMake setting. +option(SRB2_CONFIG_PROFILEMODE "Compile for profiling (GCC only)." OFF) +set(SRB2_CONFIG_ASSET_DIRECTORY "" CACHE PATH "Path to directory that contains all asset files for the installer. If set, assets will be part of installation and cpack.") + +if(SRB2_CONFIG_ENABLE_TESTS) + # https://github.com/catchorg/Catch2 + CPMAddPackage( + NAME Catch2 + VERSION 3.1.1 + GITHUB_REPOSITORY catchorg/Catch2 + OPTIONS + "CATCH_INSTALL_DOCS OFF" + ) + list(APPEND CMAKE_MODULE_PATH "${Catch2_SOURCE_DIR}/extras") + include(CTest) + include(Catch) + add_executable(srb2tests) + # To add tests, use target_sources to add individual test files to the target in subdirs. + target_link_libraries(srb2tests PRIVATE Catch2::Catch2 Catch2::Catch2WithMain) + target_compile_features(srb2tests PRIVATE c_std_11 cxx_std_17) + catch_discover_tests(srb2tests) +endif() + +# Enable CCache +# (Set USE_CCACHE=ON to use, CCACHE_OPTIONS for options) +if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL Windows) + option(USE_CCACHE "Enable ccache support" OFF) + + if(USE_CCACHE) + find_program(CCACHE_TOOL_PATH ccache) + if(CCACHE_TOOL_PATH) + set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_TOOL_PATH} CACHE STRING "" FORCE) + set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_TOOL_PATH} CACHE STRING "" FORCE) + else() + message(WARNING "USE_CCACHE was set but ccache is not found (set CCACHE_TOOL_PATH)") + endif() + endif() +else() + CPMAddPackage( + NAME Ccache.cmake + GITHUB_REPOSITORY TheLartians/Ccache.cmake + VERSION 1.2 + ) +endif() + +# Dependencies +add_subdirectory(thirdparty) + +if("${SRB2_CONFIG_SYSTEM_LIBRARIES}") + find_package(ZLIB REQUIRED) + find_package(PNG REQUIRED) + find_package(SDL2 REQUIRED) + find_package(SDL2_mixer REQUIRED) + find_package(CURL REQUIRED) + find_package(OPENMPT REQUIRED) + find_package(GME REQUIRED) + find_package(DiscordRPC REQUIRED) +endif() + +if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) + message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.") +endif() + +if ((${SRB2_USE_CCACHE}) AND (${CMAKE_C_COMPILER} MATCHES "clang")) + message(WARNING "Using clang and CCache: You may want to set environment variable CCACHE_CPP2=yes to prevent include errors during compile.") +endif() + +# Add sources from Sourcefile +function(target_sourcefile type) + file(STRINGS Sourcefile list + REGEX "[-0-9A-Za-z_]+\.${type}") + target_sources(SRB2SDL2 PRIVATE ${list}) +endfunction() + +# bitness check +set(SRB2_SYSTEM_BITS 0) +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + message(STATUS "Target is 64-bit") + set(SRB2_SYSTEM_BITS 64) +endif() +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + message(STATUS "Target is 32-bit") + set(SRB2_SYSTEM_BITS 32) +endif() +if(${SRB2_SYSTEM_BITS} EQUAL 0) + message(STATUS "Target bitness is unknown") +endif() + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") +set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") + +# Set EXE names so the assets CMakeLists can refer to its target +set(SRB2_SDL2_EXE_NAME "" CACHE STRING "Override executable binary output name") +set(SRB2_SDL2_EXE_SUFFIX "" CACHE STRING "Optional executable suffix, separated by an underscore") + +include_directories(${CMAKE_CURRENT_BINARY_DIR}/src) + +add_subdirectory(src) +add_subdirectory(assets) + + +## config.h generation +set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary") +include(GitUtilities) +git_latest_commit(SRB2_COMP_COMMIT "${CMAKE_SOURCE_DIR}") +git_current_branch(SRB2_GIT_BRANCH "${CMAKE_SOURCE_DIR}") +git_working_tree_dirty(SRB2_COMP_UNCOMMITTED "${CMAKE_SOURCE_DIR}") +set(SRB2_COMP_BRANCH "${SRB2_GIT_BRANCH}") +set(SRB2_COMP_REVISION "${SRB2_COMP_COMMIT}") +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/config.h) + + +if("${SRB2_SDL2_EXE_NAME}" STREQUAL "") + list(APPEND EXE_NAME_PARTS "ringracers") + + if(NOT "${SRB2_GIT_BRANCH}" STREQUAL "master") + list(APPEND EXE_NAME_PARTS ${SRB2_GIT_BRANCH}) + endif() +else() + list(APPEND EXE_NAME_PARTS ${SRB2_SDL2_EXE_NAME}) +endif() + +list(APPEND EXE_NAME_PARTS ${SRB2_SDL2_EXE_SUFFIX}) + +list(JOIN EXE_NAME_PARTS "_" EXE_NAME) +set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME ${EXE_NAME}) diff --git a/assets/CMakeLists.txt b/assets/CMakeLists.txt index d0ffef2fc..cc34efce6 100644 --- a/assets/CMakeLists.txt +++ b/assets/CMakeLists.txt @@ -1,75 +1,53 @@ ## Assets Target Configuration ## -# For prepending the current source path, later -FUNCTION(PREPEND var prefix) - SET(listVar "") - FOREACH(f ${ARGN}) - LIST(APPEND listVar "${prefix}/${f}") - ENDFOREACH(f) - SET(${var} "${listVar}" PARENT_SCOPE) -ENDFUNCTION(PREPEND) +if(${CMAKE_SYSTEM} MATCHES Linux) + # Asset installation isn't part of the Linux target + return() +endif() -set(SRB2_ASSET_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/installer" - CACHE STRING "Path to directory that contains all asset files for the installer.") +if("${SRB2_CONFIG_ASSET_DIRECTORY}" STREQUAL "") + message(WARNING "SRB2_CONFIG_ASSET_DIRECTORY is not set, so installation will not contain data files.") + return() +endif() -set(SRB2_ASSET_INSTALL ON - CACHE BOOL "Insert asset files into the install directory or package.") +get_filename_component(SRB2_ASSET_DIRECTORY_ABSOLUTE "${SRB2_CONFIG_ASSET_DIRECTORY}" ABSOLUTE) + +set(SRB2_ASSETS_DOCS + "README.txt" + "HISTORY.txt" + "README-SDL.txt" + "LICENSE.txt" + "LICENSE-3RD-PARTY.txt" +) +list(TRANSFORM SRB2_ASSETS_DOCS PREPEND "/") +list(TRANSFORM SRB2_ASSETS_DOCS PREPEND "${SRB2_ASSET_DIRECTORY_ABSOLUTE}") #################### # POST-V2.2 NOTE: Do not forget to add patch.pk3 to the end of this list! #################### -set(SRB2_ASSET_HASHED -"main.pk3;\ -gfx.pk3;\ -textures.pk3;\ -chars.pk3;\ -maps.pk3;\ -patch.pk3" - CACHE STRING "Asset filenames to apply MD5 checks. No spaces between entries!" +set(SRB2_ASSETS_GAME + "main.pk3" + "gfx.pk3" + "textures.pk3" + "chars.pk3" + "maps.pk3" + "followers.pk3" + "patch.pk3" ) +list(TRANSFORM SRB2_ASSETS_GAME PREPEND "/") +list(TRANSFORM SRB2_ASSETS_GAME PREPEND "${SRB2_ASSET_DIRECTORY_ABSOLUTE}") -set(SRB2_ASSET_DOCS -"README.txt;\ -HISTORY.txt;\ -LICENSE.txt;\ -LICENSE-3RD-PARTY.txt;\ -README-SDL.txt" - CACHE STRING "Documentation filenames. In OS X, these are packaged separately from other assets. No spaces between entries!" -) - -PREPEND(SRB2_ASSET_DOCS ${SRB2_ASSET_DIRECTORY} ${SRB2_ASSET_DOCS}) - -foreach(SRB2_ASSET ${SRB2_ASSET_HASHED}) - file(MD5 ${SRB2_ASSET_DIRECTORY}/${SRB2_ASSET} "SRB2_ASSET_${SRB2_ASSET}_HASH") - set(SRB2_ASSET_${SRB2_ASSET}_HASH ${SRB2_ASSET_${SRB2_ASSET}_HASH} PARENT_SCOPE) -endforeach() +set(SRB2_ASSETS ${SRB2_ASSET_DOCS} ${SRB2_ASSETS_GAME}) # Installation if(${CMAKE_SYSTEM} MATCHES Darwin) get_target_property(outname SRB2SDL2 OUTPUT_NAME) - if(${SRB2_ASSET_INSTALL}) - install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/" - DESTINATION "${outname}.app/Contents/Resources" - ) - endif() - # Always install the doc files, even in non-asset packages. - install(FILES ${SRB2_ASSET_DOCS} - DESTINATION . - OPTIONAL - ) + install(FILES ${SRB2_ASSETS} DESTINATION "${outname}.app/Contents/Resources") + install(DIRECTORY "${SRB2_ASSET_DIRECTORY_ABSOLUTE}/models" DESTINATION "${outname}.app/Contents/Resources") + install(FILES ${SRB2_ASSETS_DOCS} DESTINATION .) else() - if(${SRB2_ASSET_INSTALL}) - install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/" - DESTINATION . - ) - # Docs are assumed to be located in SRB2_ASSET_DIRECTORY, so don't install them in their own call. - else() - # Always install the doc files, even in non-asset packages. - install(FILES ${SRB2_ASSET_DOCS} - DESTINATION . - OPTIONAL - ) - endif() + install(FILES ${SRB2_ASSETS} DESTINATION .) + install(DIRECTORY "${SRB2_ASSET_DIRECTORY_ABSOLUTE}/models" DESTINATION .) endif() diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake new file mode 100644 index 000000000..772103fc3 --- /dev/null +++ b/cmake/CPM.cmake @@ -0,0 +1,21 @@ +set(CPM_DOWNLOAD_VERSION 0.36.0) + +if(CPM_SOURCE_CACHE) + set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +elseif(DEFINED ENV{CPM_SOURCE_CACHE}) + set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +else() + set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +endif() + +# Expand relative path. This is important if the provided path contains a tilde (~) +get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE) +if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION})) + message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}") + file(DOWNLOAD + https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake + ${CPM_DOWNLOAD_LOCATION} + ) +endif() + +include(${CPM_DOWNLOAD_LOCATION}) diff --git a/cmake/Modules/FindDiscordRPC.cmake b/cmake/Modules/FindDiscordRPC.cmake index e71762767..2d3c987c1 100644 --- a/cmake/Modules/FindDiscordRPC.cmake +++ b/cmake/Modules/FindDiscordRPC.cmake @@ -21,3 +21,13 @@ find_library(DISCORDRPC_LIBRARY set(DISCORDRPC_PROCESS_INCLUDES DISCORDRPC_INCLUDE_DIR) set(DISCORDRPC_PROCESS_LIBS DISCORDRPC_LIBRARY) libfind_process(DISCORDRPC) + +if(DISCORDRPC_FOUND AND NOT TARGET DiscordRPC::DiscordRPC) + add_library(DiscordRPC::DiscordRPC UNKNOWN IMPORTED) + set_target_properties( + DiscordRPC::DiscordRPC + PROPERTIES + IMPORTED_LOCATION "${DISCORDRPC_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${DISCORDRPC_INCLUDE_DIR}" + ) +endif() diff --git a/cmake/Modules/FindGME.cmake b/cmake/Modules/FindGME.cmake index ea80af454..3af0a94be 100644 --- a/cmake/Modules/FindGME.cmake +++ b/cmake/Modules/FindGME.cmake @@ -20,4 +20,14 @@ find_library(GME_LIBRARY set(GME_PROCESS_INCLUDES GME_INCLUDE_DIR) set(GME_PROCESS_LIBS GME_LIBRARY) -libfind_process(GME) \ No newline at end of file +libfind_process(GME) + +if(GME_FOUND AND NOT TARGET gme) + add_library(gme UNKNOWN IMPORTED) + set_target_properties( + gme + PROPERTIES + IMPORTED_LOCATION "${GME_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${GME_INCLUDE_DIR}" + ) +endif() diff --git a/cmake/Modules/FindOPENMPT.cmake b/cmake/Modules/FindOPENMPT.cmake index 2d334b6f0..7e5b2d5a3 100644 --- a/cmake/Modules/FindOPENMPT.cmake +++ b/cmake/Modules/FindOPENMPT.cmake @@ -20,4 +20,14 @@ find_library(OPENMPT_LIBRARY set(OPENMPT_PROCESS_INCLUDES OPENMPT_INCLUDE_DIR) set(OPENMPT_PROCESS_LIBS OPENMPT_LIBRARY) -libfind_process(OPENMPT) \ No newline at end of file +libfind_process(OPENMPT) + +if(OPENMPT_FOUND AND NOT TARGET openmpt) + add_library(openmpt UNKNOWN IMPORTED) + set_target_properties( + openmpt + PROPERTIES + IMPORTED_LOCATION "${OPENMPT_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${OPENMPT_INCLUDE_DIR}" + ) +endif() diff --git a/cmake/Modules/FindSDL2.cmake b/cmake/Modules/FindSDL2.cmake index 2fc833cef..2d625f84c 100644 --- a/cmake/Modules/FindSDL2.cmake +++ b/cmake/Modules/FindSDL2.cmake @@ -31,3 +31,13 @@ find_library(SDL2_LIBRARY set(SDL2_PROCESS_INCLUDES SDL2_INCLUDE_DIR) set(SDL2_PROCESS_LIBS SDL2_LIBRARY) libfind_process(SDL2) + +if(SDL2_FOUND AND NOT TARGET SDL2::SDL2) + add_library(SDL2::SDL2 UNKNOWN IMPORTED) + set_target_properties( + SDL2::SDL2 + PROPERTIES + IMPORTED_LOCATION "${SDL2_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}" + ) +endif() diff --git a/cmake/Modules/FindSDL2_mixer.cmake b/cmake/Modules/FindSDL2_mixer.cmake index 9af3e26dd..637498e53 100644 --- a/cmake/Modules/FindSDL2_mixer.cmake +++ b/cmake/Modules/FindSDL2_mixer.cmake @@ -32,3 +32,13 @@ find_library(SDL2_MIXER_LIBRARY set(SDL2_MIXER_PROCESS_INCLUDES SDL2_MIXER_INCLUDE_DIR) set(SDL2_MIXER_PROCESS_LIBS SDL2_MIXER_LIBRARY) libfind_process(SDL2_MIXER) + +if(SDL2_MIXER_FOUND AND NOT TARGET SDL2_mixer::SDL2_mixer) + add_library(SDL2_mixer::SDL2_mixer UNKNOWN IMPORTED) + set_target_properties( + SDL2_mixer::SDL2_mixer + PROPERTIES + IMPORTED_LOCATION "${SDL2_MIXER_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${SDL2_MIXER_INCLUDE_DIR}" + ) +endif() diff --git a/cmake/launch-c.in b/cmake/launch-c.in deleted file mode 100644 index c60558232..000000000 --- a/cmake/launch-c.in +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -export CCACHE_CPP2=true -exec "${RULE_LAUNCH_COMPILE}" "${CMAKE_C_COMPILER}" "$@" diff --git a/cmake/launch-cxx.in b/cmake/launch-cxx.in deleted file mode 100644 index c60558232..000000000 --- a/cmake/launch-cxx.in +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -export CCACHE_CPP2=true -exec "${RULE_LAUNCH_COMPILE}" "${CMAKE_C_COMPILER}" "$@" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ea89576fa..f3ee5a215 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,12 @@ -# SRB2 Core - add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32) +if("${CMAKE_COMPILER_IS_GNUCC}" AND "${CMAKE_SYSTEM_NAME}" MATCHES "Windows" AND NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}" AND NOT "${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}") + # On MinGW with internal libraries, link the standard library statically + target_link_options(SRB2SDL2 PRIVATE "-static") +endif() + +target_compile_features(SRB2SDL2 PRIVATE c_std_11 cxx_std_17) + # Core sources target_sourcefile(c) target_sources(SRB2SDL2 PRIVATE comptime.c md5.c config.h.in) @@ -11,147 +16,59 @@ set(SRB2_ASM_SOURCES vid_copy.s) set(SRB2_NASM_SOURCES tmap_mmx.nas tmap.nas) ### Configuration -set(SRB2_CONFIG_HAVE_PNG ON CACHE BOOL - "Enable PNG support. Depends on zlib, so will be disabled if you don't enable that too.") -set(SRB2_CONFIG_HAVE_ZLIB ON CACHE BOOL - "Enable zlib support.") -set(SRB2_CONFIG_HAVE_GME ON CACHE BOOL - "Enable GME support.") -set(SRB2_CONFIG_HAVE_DISCORDRPC OFF CACHE BOOL - "Enable Discord rich presence support.") -set(SRB2_CONFIG_HAVE_CURL ON CACHE BOOL - "Enable cURL support, used for downloading files via HTTP.") -set(SRB2_CONFIG_HAVE_OPENMPT ON CACHE BOOL - "Enable OpenMPT support.") -set(SRB2_CONFIG_HAVE_CURL ON CACHE BOOL - "Enable curl support.") -set(SRB2_CONFIG_HAVE_THREADS ON CACHE BOOL - "Enable multithreading support.") -if(${CMAKE_SYSTEM} MATCHES Windows) - set(SRB2_CONFIG_HAVE_MIXERX ON CACHE BOOL - "Enable SDL Mixer X support.") -else() - set(SRB2_CONFIG_HAVE_MIXERX OFF) -endif() -set(SRB2_CONFIG_HWRENDER ON CACHE BOOL - "Enable hardware rendering through OpenGL.") set(SRB2_CONFIG_USEASM OFF CACHE BOOL "Enable NASM tmap implementation for software mode speedup.") set(SRB2_CONFIG_YASM OFF CACHE BOOL "Use YASM in place of NASM.") -set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL - "Use statically linked OpenGL. NOT RECOMMENDED.") set(SRB2_CONFIG_DEV_BUILD OFF CACHE BOOL "Compile a development build of SRB2Kart.") set(SRB2_CONFIG_SKIP_COMPTIME OFF CACHE BOOL "Skip Comptime rebuild.") - -if(NOT SRB2_CONFIG_SKIP_COMPTIME) - # This updates the modification time for comptime.c at the - # end of building so when the build system is ran next time, - # that file gets flagged. comptime.c will always be rebuilt. - # - # This begs the question, why always rebuild comptime.c? - # Some things like the git commit must be checked each time - # the program is built. But the build system determines which - # files should be rebuilt before anything else. So - # comptime.c, which only needs to be rebuilt based on - # information known at build time, must be told to rebuild - # before that information can be ascertained. - add_custom_command( - TARGET SRB2SDL2 - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E touch_nocreate ${CMAKE_CURRENT_SOURCE_DIR}/comptime.c - ) -endif() - -# config.h is generated by this command. It should be done at -# build time for accurate git information and before anything -# that needs it, obviously. -set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary") -add_custom_target(_SRB2_reconf ALL - COMMAND ${CMAKE_COMMAND} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DBINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/.. -P ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/Comptime.cmake - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.." -) -add_dependencies(SRB2SDL2 _SRB2_reconf) -### use internal libraries? -if(${CMAKE_SYSTEM} MATCHES "Windows") ###set on Windows only - set(SRB2_CONFIG_USE_INTERNAL_LIBRARIES ON CACHE BOOL - "Use SRB2Kart's internal copies of required dependencies (SDL2, PNG, zlib, GME, OpenMPT, cURL).") -endif() - -set(ACSVM_NOFLAGS ON) -set(ACSVM_SHARED ON) -add_subdirectory(ACS) - add_subdirectory(blua) add_subdirectory(blan) -add_subdirectory(objects) -if(${SRB2_CONFIG_HAVE_GME}) - if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) - set(GME_FOUND ON) - set(GME_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/gme/include) - if(${SRB2_SYSTEM_BITS} EQUAL 64) - set(GME_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/gme/win64 -lgme") - else() # 32-bit - set(GME_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/gme/win32 -lgme") - endif() - else() - find_package(GME) - endif() - if(${GME_FOUND}) - set(SRB2_HAVE_GME ON) - target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_GME) - else() - message(WARNING "You have specified that GME is available but it was not found.") +# OS macros +if (UNIX) + target_compile_definitions(SRB2SDL2 PRIVATE -DUNIXCOMMON) +endif() + +if(CMAKE_COMPILER_IS_GNUCC) + find_program(OBJCOPY objcopy) +endif() + +if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") + target_compile_definitions(SRB2SDL2 PRIVATE -DLINUX) + if(${SRB2_SYSTEM_BITS} EQUAL 64) + target_compile_definitions(SRB2SDL2 PRIVATE -DLINUX64) endif() endif() -if(${SRB2_CONFIG_HAVE_OPENMPT}) - if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) - set(OPENMPT_FOUND ON) - set(OPENMPT_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/inc) - if(${SRB2_SYSTEM_BITS} EQUAL 64) - set(OPENMPT_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/libopenmpt/lib/x86_64/mingw -lopenmpt") - else() # 32-bit - set(OPENMPT_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/libopenmpt/lib/x86/mingw -lopenmpt") - endif() - else() - find_package(OPENMPT) - endif() - if(${OPENMPT_FOUND}) - set(SRB2_HAVE_OPENMPT ON) - target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_OPENMPT) - else() - message(WARNING "You have specified that OpenMPT is available but it was not found.") - endif() +if("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") + target_compile_definitions(SRB2SDL2 PRIVATE -DMACOSX) endif() -if(${SRB2_CONFIG_HAVE_MIXERX}) - if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) - set(MIXERX_FOUND ON) - set(MIXERX_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/SDLMixerX/i686-w64-mingw32/include/SDL2) - if(${SRB2_SYSTEM_BITS} EQUAL 64) - set(MIXERX_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDLMixerX/x86_64-w64-mingw32/lib -lSDL2_mixer_ext") - else() # 32-bit - set(MIXERX_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDLMixerX/i686-w64-mingw32/lib -lSDL2_mixer_ext") - endif() - else() - # No support for non-Windows (yet?) - #find_package(MIXERX) - message(WARNING "SDL Mixer X is not supported as an external library.") - set(MIXERX_FOUND OFF) - endif() - if(${MIXERX_FOUND}) - set(SRB2_HAVE_MIXERX ON) - target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MIXERX) - else() - message(WARNING "You have specified that SDL Mixer X is available but it was not found.") - endif() +target_link_libraries(SRB2SDL2 PRIVATE gme) +target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_GME) +if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}") + # this sucks but gme doesn't use modern cmake to delineate public headers + target_include_directories(SRB2SDL2 PRIVATE "${libgme_SOURCE_DIR}") endif() +target_link_libraries(SRB2SDL2 PRIVATE openmpt) +target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_OPENMPT) + +target_link_libraries(SRB2SDL2 PRIVATE ZLIB::ZLIB PNG::PNG CURL::libcurl) +target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_ZLIB -DHAVE_PNG -DHAVE_CURL -D_LARGEFILE64_SOURCE) +target_sources(SRB2SDL2 PRIVATE apng.c) + +target_link_libraries(SRB2SDL2 PRIVATE DiscordRPC::DiscordRPC) +target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_DISCORDRPC -DUSE_STUN) +target_sources(SRB2SDL2 PRIVATE discord.c stun.c) + +set(SRB2_HAVE_THREADS ON) +target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_THREADS) + if(${SRB2_CONFIG_HAVE_DISCORDRPC}) if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) set(DISCORDRPC_FOUND ON) @@ -219,49 +136,32 @@ if(${SRB2_CONFIG_HAVE_PNG} AND ${SRB2_CONFIG_HAVE_ZLIB}) endif() endif() -if(${SRB2_CONFIG_HAVE_CURL}) - if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) - set(CURL_FOUND ON) - set(CURL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/curl/include) - if(${SRB2_SYSTEM_BITS} EQUAL 64) - set(CURL_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/curl/lib64 -lcurl") - else() # 32-bit - set(CURL_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/curl/lib32 -lcurl") - endif() - else() - find_package(CURL) - endif() - if(${CURL_FOUND}) - set(SRB2_HAVE_CURL ON) - target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_CURL) - else() - message(WARNING "You have specified that CURL is available but it was not found. SRB2Kart may not compile correctly.") - endif() -endif() - -if(${SRB2_CONFIG_HAVE_THREADS}) - set(SRB2_HAVE_THREADS ON) - target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_THREADS) -endif() - -if(${SRB2_CONFIG_HWRENDER}) +if("${SRB2_CONFIG_HWRENDER}") target_compile_definitions(SRB2SDL2 PRIVATE -DHWRENDER) add_subdirectory(hardware) + + if("${SRB2_CONFIG_STATIC_OPENGL}") + find_package(OpenGL) + if(${OPENGL_FOUND}) + target_compile_definitions(SRB2SDL2 PRIVATE -DSTATIC_OPENGL) + else() + message(WARNING "You have specified static opengl but opengl was not found. Not setting HWRENDER.") + endif() + endif() endif() -if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL}) - find_package(OpenGL) - if(${OPENGL_FOUND}) - target_compile_definitions(SRB2SDL2 PRIVATE -DHWRENDER) - target_compile_definitions(SRB2SDL2 PRIVATE -DSTATIC_OPENGL) - else() - message(WARNING "You have specified static opengl but opengl was not found. Not setting HWRENDER.") - endif() +# TODO: build this with the game +if(${CMAKE_SYSTEM} MATCHES Windows AND ${CMAKE_C_COMPILER_ID} MATCHES "GNU" AND ${SRB2_SYSTEM_BITS} EQUAL 32) + target_link_libraries(SRB2SDL2 PRIVATE + "${CMAKE_CURRENT_SOURCE_DIR}/../libs/drmingw/lib/win32/libexchndl.a" + "${CMAKE_CURRENT_SOURCE_DIR}/../libs/drmingw/lib/win32/libmgwhelp.a" + ) + target_include_directories(SRB2SDL2 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../libs/drmingw/include") endif() if(${SRB2_CONFIG_USEASM}) #SRB2_ASM_FLAGS can be used to pass flags to either nasm or yasm. - if(${CMAKE_SYSTEM} MATCHES "Linux") + if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") set(SRB2_ASM_FLAGS "-DLINUX ${SRB2_ASM_FLAGS}") endif() @@ -277,7 +177,7 @@ if(${SRB2_CONFIG_USEASM}) set(SRB2_USEASM ON) target_compile_definitions(SRB2SDL2 PRIVATE -DUSEASM) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse3 -mfpmath=sse") + target_compile_options(SRB2SDL2 PRIVATE -msse3 -mfpmath=sse) target_sources(SRB2SDL2 PRIVATE ${SRB2_ASM_SOURCES} ${SRB2_NASM_SOURCES}) @@ -290,7 +190,7 @@ endif() # If using CCACHE, then force it. # https://github.com/Cockatrice/Cockatrice/pull/3052/files -if (${CMAKE_SYSTEM} MATCHES "Darwin") +if ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") get_property(RULE_LAUNCH_COMPILE GLOBAL PROPERTY RULE_LAUNCH_COMPILE) if(RULE_LAUNCH_COMPILE) MESSAGE(STATUS "Force enabling CCache usage under macOS") @@ -312,35 +212,171 @@ endif() # Compatibility flag with later versions of GCC # We should really fix our code to not need this if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -mno-ms-bitfields) + target_compile_options(SRB2SDL2 PRIVATE -mno-ms-bitfields) endif() -if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-absolute-value) +# Compiler warnings configuration +target_compile_options(SRB2SDL2 PRIVATE + # Using generator expressions to handle per-language compile options + + # C, GNU + # This is a direct translation from versions.mk + $<$,$>: + -Wall + -Wno-trigraphs + -W # Was controlled by RELAXWARNINGS + -Wfloat-equal + -Wundef + -Wpointer-arith + -Wbad-function-cast + -Wcast-qual + -Wcast-align # Was controlled by NOCASTALIGNWARN + -Wwrite-strings + -Wsign-compare + -Wno-comment + -Wmissing-prototypes + -Wmissing-declarations + -Wmissing-noreturn + -Wnested-externs + -Winline + -Wformat-y2k + -Wformat-security + + $<$,2.9.5>: + -Wno-div-by-zero + -Wendif-labels + -Wdisabled-optimization + > + + $<$,4.0.0>: + -Wold-style-definition + -Wmissing-field-initializers + > + + $<$,4.1.0>: + -Wshadow + > + + $<$,4.3.0>: + -funit-at-a-time + -Wlogical-op + > + + $<$,4.5.0>: + -Wlogical-op + -Wno-error=array-bounds + > + + $<$,4.6.0>: + -Wno-suggest-attribute=noreturn + -Wno-error=suggest-attribute=noreturn + > + + $<$,5.4.0>: + -Wno-logical-op + -Wno-error=logical-op + > + + $<$,6.1.0>: + -Wno-tautological-compare + -Wno-error=tautological-compare + > + + $<$,7.1.0>: + -Wno-error=format-overflow=2 + -Wimplicit-fallthrough=4 + > + + $<$,8.1.0>: + -Wno-error=format-overflow + -Wno-error=stringop-truncation + -Wno-error=stringop-overflow + -Wno-format-overflow + -Wno-stringop-truncation + -Wno-stringop-overflow + -Wno-error=multistatement-macros + > + + $<$,9.1.0>: + -Wno-error=address-of-packed-member + > + > + + # C, Clang and Apple Clang + $<$,$,$>>: + -Wall + -Wno-absolute-value + -Wno-trigraphs + -Wno-error=non-literal-null-conversion + -Wno-error=constant-conversion + -Wno-error=unused-but-set-variable + > + + # C, MSVC + $<$,$>: + # All warnings at and before Visual Studio 2019 RTM + # https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warnings-by-compiler-version?view=msvc-170 + /Wv:19.20.27004.0 + > + + # C++, GNU, Clang and Apple Clang + $<$,$,$,$>>: + -Wall + > + + # C++, MSVC + $<$,$>: + /Wv:19.20.27004.0 + > +) +if(SRB2_CONFIG_ERRORMODE) + target_compile_options(SRB2SDL2 PRIVATE + $<$,$,$>: + -Werror + > + + $<$: + /WX + > + ) endif() +# Link warnings configuration +target_link_options(SRB2SDL2 PRIVATE + $<$: + # -Wl,--as-needed - Was controlled by NOLDWARNING + > +) + if(${SRB2_CONFIG_DEV_BUILD}) target_compile_definitions(SRB2SDL2 PRIVATE -DDEVELOP) endif() - -set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-trigraphs) - target_compile_definitions(SRB2SDL2 PRIVATE -DCMAKECONFIG) -#add_library(SRB2Core STATIC -# ${SRB2_CORE_SOURCES} -# ${SRB2_CORE_HEADERS} -# ${SRB2_CORE_RENDER_SOURCES} -# ${SRB2_CORE_GAME_SOURCES} -# ${SRB2_LUA_SOURCES} -# ${SRB2_LUA_HEADERS} -# ${SRB2_BLUA_SOURCES} -# ${SRB2_BLUA_HEADERS} -#) +# Misc. build options from Makefiles +if(SRB2_CONFIG_DEBUGMODE) + target_compile_definitions(SRB2SDL2 PRIVATE -DZDEBUG -DPARANOIA -DRANGECHECK -DPACKETDROP) +endif() +if(SRB2_CONFIG_MOBJCONSISTANCY) + target_compile_definitions(SRB2SDL2 PRIVATE -DMOBJCONSISTANCY) +endif() +if(SRB2_CONFIG_PACKETDROP) + target_compile_definitions(SRB2SDL2 PRIVATE -DPACKETDROP) +endif() +if(SRB2_CONFIG_ZDEBUG) + target_compile_definitions(SRB2SDL2 PRIVATE -DZDEBUG) +endif() +if(SRB2_CONFIG_PROFILEMODE AND "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") + target_compile_options(SRB2SDL2 PRIVATE -pg) + target_link_options(SRB2SDL2 PRIVATE -pg) +endif() -## strip debug symbols into separate file when using gcc. -## to be consistent with Makefile, don't generate for OS X. -if((CMAKE_COMPILER_IS_GNUCC) AND NOT (${CMAKE_SYSTEM} MATCHES Darwin)) +add_subdirectory(sdl) +add_subdirectory(objects) + +# strip debug symbols into separate file when using gcc. +# to be consistent with Makefile, don't generate for OS X. +if((CMAKE_COMPILER_IS_GNUCC) AND NOT ("${CMAKE_SYSTEM_NAME}" MATCHES Darwin)) if((${CMAKE_BUILD_TYPE} MATCHES Debug) OR (${CMAKE_BUILD_TYPE} MATCHES RelWithDebInfo)) if(${CMAKE_BUILD_TYPE} MATCHES Debug) set(OBJCOPY_ONLY_KEEP_DEBUG "--only-keep-debug") @@ -354,9 +390,27 @@ if((CMAKE_COMPILER_IS_GNUCC) AND NOT (${CMAKE_SYSTEM} MATCHES Darwin)) endif() endif() -add_subdirectory(sdl) +# copy DLLs to bin/ directory if building internal shared on windows +if("${CMAKE_SYSTEM_NAME}" STREQUAL Windows AND NOT "${SRB2_CONFIG_INTERNAL_LIBRARIES}" AND "${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}") + set(ADDITIONAL_DLLS "") + if("${CMAKE_C_COMPILER_ID}" STREQUAL GNU) + # also copy implicitly linked system libraries + get_filename_component(MINGW_BIN_PATH ${CMAKE_CXX_COMPILER} PATH) + list(APPEND ADDITIONAL_DLLS + "libgcc_s_dw2-1.dll" + "libstdc++-6.dll" + "libwinpthread-1.dll" + ) + list(TRANSFORM ADDITIONAL_DLLS PREPEND "${MINGW_BIN_PATH}/") + endif() + add_custom_command(TARGET SRB2SDL2 POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + ${ADDITIONAL_DLLS} -if(NOT ${SRB2_SDL2_AVAILABLE}) - message(FATAL_ERROR "There are no targets available to build an SRB2Kart executable. :(") + $ + COMMAND_EXPAND_LISTS + COMMENT "Copying runtime DLLs" + ) endif() diff --git a/src/Makefile.d/versions.mk b/src/Makefile.d/versions.mk index 195899129..36321042d 100644 --- a/src/Makefile.d/versions.mk +++ b/src/Makefile.d/versions.mk @@ -17,7 +17,7 @@ $(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\ $(eval $(call _predecessor,$(subst =, ,$(v)))))) # -W -Wno-unused -WFLAGS:=-Wall -Wno-trigraphs +WFLAGS:=-Wall -Wno-trigraphs -Wno-comment ifndef GCC295 #WFLAGS+=-Wno-packed endif diff --git a/src/am_map.h b/src/am_map.h index 1c8fa70e4..596a17d46 100644 --- a/src/am_map.h +++ b/src/am_map.h @@ -16,15 +16,15 @@ #include "d_event.h" -typedef struct +struct fpoint_t { INT32 x, y; -} fpoint_t; +}; -typedef struct +struct fline_t { fpoint_t a, b; -} fline_t; +}; extern boolean am_recalc; // true if screen size changes extern boolean automapactive; // In AutoMap mode? diff --git a/src/command.h b/src/command.h index a9558626b..9ceb2f102 100644 --- a/src/command.h +++ b/src/command.h @@ -79,14 +79,14 @@ void COM_Init(void); // Variable sized buffers // ====================== -typedef struct vsbuf_s +struct vsbuf_t { boolean allowoverflow; // if false, do a I_Error boolean overflowed; // set to true if the buffer size failed UINT8 *data; size_t maxsize; size_t cursize; -} vsbuf_t; +}; void VS_Alloc(vsbuf_t *buf, size_t initsize); void VS_Free(vsbuf_t *buf); @@ -127,13 +127,13 @@ typedef enum CV_NOLUA = 4096,/* don't let this be called from Lua */ } cvflags_t; -typedef struct CV_PossibleValue_s +struct CV_PossibleValue_t { INT32 value; const char *strvalue; -} CV_PossibleValue_t; +}; -typedef struct consvar_s //NULL, NULL, 0, NULL, NULL |, 0, NULL, NULL, 0, 0, NULL +struct consvar_t //NULL, NULL, 0, NULL, NULL |, 0, NULL, NULL, 0, 0, NULL { const char *name; const char *defaultvalue; @@ -157,8 +157,8 @@ typedef struct consvar_s //NULL, NULL, 0, NULL, NULL |, 0, NULL, NULL, 0, 0, NUL UINT16 netid; // used internaly : netid for send end receive // used only with CV_NETVAR char changed; // has variable been changed by the user? 0 = no, 1 = yes - struct consvar_s *next; -} consvar_t; + consvar_t *next; +}; /* name, defaultvalue, flags, PossibleValue, func */ #define CVAR_INIT( ... ) \ diff --git a/src/config.h.in b/src/config.h.in index 9c7dc2770..bcd28add7 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -11,18 +11,9 @@ #ifdef CMAKECONFIG -#define ASSET_HASH_MAIN_PK3 "${SRB2_ASSET_main.pk3_HASH}" -#define ASSET_HASH_GFX_PK3 "${SRB2_ASSET_gfx.pk3_HASH}" -#define ASSET_HASH_TEXTURES_PK3 "${SRB2_ASSET_textures.pk3_HASH}" -#define ASSET_HASH_CHARS_PK3 "${SRB2_ASSET_chars.pk3_HASH}" -#define ASSET_HASH_MAPS_PK3 "${SRB2_ASSET_maps.pk3_HASH}" -#define ASSET_HASH_FOLLOWERS_PK3 "${SRB2_ASSET_followers.pk3_HASH}" -#ifdef USE_PATCH_FILE -#define ASSET_HASH_PATCH_PK3 "${SRB2_ASSET_patch.pk3_HASH}" -#endif - #define SRB2_COMP_REVISION "${SRB2_COMP_REVISION}" #define SRB2_COMP_BRANCH "${SRB2_COMP_BRANCH}" +#define SRB2_COMP_LASTCOMMIT "${SRB2_COMP_LASTCOMMIT}" // This is done with configure_file instead of defines in order to avoid // recompiling the whole target whenever the working directory state changes #cmakedefine SRB2_COMP_UNCOMMITTED @@ -30,11 +21,8 @@ #define COMPVERSION_UNCOMMITTED #endif -#define SRB2_COMP_LASTCOMMIT "${SRB2_COMP_LASTCOMMIT}" +#endif -#define CMAKE_ASSETS_DIR "${CMAKE_SOURCE_DIR}/assets" - -#else /* Manually defined asset hashes for non-CMake builds * Last updated 2019 / 01 / 18 - Kart v1.0.2 - Main assets diff --git a/src/cxxutil.hpp b/src/cxxutil.hpp new file mode 100644 index 000000000..befe9c20b --- /dev/null +++ b/src/cxxutil.hpp @@ -0,0 +1,37 @@ +#ifndef __SRB2_CXXUTIL_HPP__ +#define __SRB2_CXXUTIL_HPP__ + +#include +#include + +namespace srb2 { + +template +class Finally { +public: + explicit Finally(const F& f) noexcept : f_(f) {} + explicit Finally(F&& f) noexcept : f_(f) {} + + Finally(Finally&& from) noexcept : f_(std::move(from.f_)), call_(std::exchange(from.call_, false)) {} + + Finally(const Finally& from) = delete; + void operator=(const Finally& from) = delete; + void operator=(Finally&& from) = delete; + + ~Finally() noexcept { + f_(); + } + +private: + F f_; + bool call_ = true; +}; + +template +Finally> finally(F&& f) noexcept { + return Finally {std::forward(f)}; +} + +} + +#endif // __SRB2_CXXUTIL_HPP__ diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 3f20c6154..a7285c396 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -130,43 +130,43 @@ void Command_Numnodes(void); #endif // Client to server packet -typedef struct +struct clientcmd_pak { UINT8 client_tic; UINT8 resendfrom; INT16 consistancy; ticcmd_t cmd; -} ATTRPACK clientcmd_pak; +} ATTRPACK; // Splitscreen packet // WARNING: must have the same format of clientcmd_pak, for more easy use -typedef struct +struct client2cmd_pak { UINT8 client_tic; UINT8 resendfrom; INT16 consistancy; ticcmd_t cmd, cmd2; -} ATTRPACK client2cmd_pak; +} ATTRPACK; // 3P Splitscreen packet // WARNING: must have the same format of clientcmd_pak, for more easy use -typedef struct +struct client3cmd_pak { UINT8 client_tic; UINT8 resendfrom; INT16 consistancy; ticcmd_t cmd, cmd2, cmd3; -} ATTRPACK client3cmd_pak; +} ATTRPACK; // 4P Splitscreen packet // WARNING: must have the same format of clientcmd_pak, for more easy use -typedef struct +struct client4cmd_pak { UINT8 client_tic; UINT8 resendfrom; INT16 consistancy; ticcmd_t cmd, cmd2, cmd3, cmd4; -} ATTRPACK client4cmd_pak; +} ATTRPACK; #ifdef _MSC_VER #pragma warning(disable : 4200) @@ -174,15 +174,15 @@ typedef struct // Server to client packet // this packet is too large -typedef struct +struct servertics_pak { UINT8 starttic; UINT8 numtics; UINT8 numslots; // "Slots filled": Highest player number in use plus one. ticcmd_t cmds[45]; // Normally [BACKUPTIC][MAXPLAYERS] but too large -} ATTRPACK servertics_pak; +} ATTRPACK; -typedef struct +struct serverconfig_pak { UINT8 version; // Different versions don't work UINT8 subversion; // Contains build version @@ -204,9 +204,9 @@ typedef struct UINT8 maxplayer; boolean allownewplayer; boolean discordinvites; -} ATTRPACK serverconfig_pak; +} ATTRPACK; -typedef struct +struct filetx_pak { UINT8 fileid; UINT32 filesize; @@ -214,21 +214,21 @@ typedef struct UINT32 position; UINT16 size; UINT8 data[]; // Size is variable using hardware_MAXPACKETLENGTH -} ATTRPACK filetx_pak; +} ATTRPACK; -typedef struct +struct fileacksegment_t { UINT32 start; UINT32 acks; -} ATTRPACK fileacksegment_t; +} ATTRPACK; -typedef struct +struct fileack_pak { UINT8 fileid; UINT8 iteration; UINT8 numsegments; fileacksegment_t segments[]; -} ATTRPACK fileack_pak; +} ATTRPACK; #ifdef _MSC_VER #pragma warning(default : 4200) @@ -236,7 +236,7 @@ typedef struct #define MAXAPPLICATION 16 -typedef struct +struct clientconfig_pak { UINT8 _255;/* see serverinfo_pak */ UINT8 packetversion; @@ -246,7 +246,7 @@ typedef struct UINT8 localplayers; // number of splitscreen players UINT8 mode; char names[MAXSPLITSCREENPLAYERS][MAXPLAYERNAME]; -} ATTRPACK clientconfig_pak; +} ATTRPACK; #define SV_SPEEDMASK 0x03 // used to send kartspeed #define SV_DEDICATED 0x40 // server is dedicated @@ -256,7 +256,7 @@ typedef struct #define MAXFILENEEDED 915 #define MAX_MIRROR_LENGTH 256 // This packet is too large -typedef struct +struct serverinfo_pak { /* In the old packet, 'version' is the first field. Now that field is set @@ -287,27 +287,27 @@ typedef struct char httpsource[MAX_MIRROR_LENGTH]; // HTTP URL to download from, always defined for compatibility INT16 avgpwrlv; // Kart avg power level UINT8 fileneeded[MAXFILENEEDED]; // is filled with writexxx (byteptr.h) -} ATTRPACK serverinfo_pak; +} ATTRPACK; -typedef struct +struct serverrefuse_pak { char reason[255]; -} ATTRPACK serverrefuse_pak; +} ATTRPACK; -typedef struct +struct askinfo_pak { UINT8 version; tic_t time; // used for ping evaluation -} ATTRPACK askinfo_pak; +} ATTRPACK; -typedef struct +struct msaskinfo_pak { char clientaddr[22]; tic_t time; // used for ping evaluation -} ATTRPACK msaskinfo_pak; +} ATTRPACK; // Shorter player information for external use. -typedef struct +struct plrinfo { UINT8 num; char name[MAXPLAYERNAME+1]; @@ -317,10 +317,10 @@ typedef struct UINT8 data; // Color is first four bits, hasflag, isit and issuper have one bit each, the last is unused. UINT32 score; UINT16 timeinserver; // In seconds. -} ATTRPACK plrinfo; +} ATTRPACK; // Shortest player information for join during intermission. -typedef struct +struct plrconfig { char name[MAXPLAYERNAME+1]; UINT8 skin; @@ -328,20 +328,20 @@ typedef struct UINT32 pflags; UINT32 score; UINT8 ctfteam; -} ATTRPACK plrconfig; +} ATTRPACK; -typedef struct +struct filesneededconfig_pak { INT32 first; UINT8 num; UINT8 more; UINT8 files[MAXFILENEEDED]; // is filled with writexxx (byteptr.h) -} ATTRPACK filesneededconfig_pak; +} ATTRPACK; // // Network packet data // -typedef struct +struct doomdata_t { UINT32 checksum; UINT8 ack; // If not zero the node asks for acknowledgement, the receiver must resend the ack @@ -373,18 +373,18 @@ typedef struct filesneededconfig_pak filesneededcfg; // ??? bytes UINT32 pingtable[MAXPLAYERS+1]; // 68 bytes } u; // This is needed to pack diff packet types data together -} ATTRPACK doomdata_t; +} ATTRPACK; #if defined(_MSC_VER) #pragma pack() #endif #define MAXSERVERLIST (MAXNETNODES-1) -typedef struct +struct serverelem_t { SINT8 node; serverinfo_pak info; -} serverelem_t; +}; extern serverelem_t serverlist[MAXSERVERLIST]; extern UINT32 serverlistcount; @@ -528,7 +528,7 @@ extern boolean hu_stopped; // SRB2Kart // -typedef struct rewind_s { +struct rewind_t { UINT8 savebuffer[(768*1024)]; tic_t leveltime; size_t demopos; @@ -536,8 +536,8 @@ typedef struct rewind_s { ticcmd_t oldcmd[MAXPLAYERS]; mobj_t oldghost[MAXPLAYERS]; - struct rewind_s *next; -} rewind_t; + rewind_t *next; +}; void CL_ClearRewinds(void); rewind_t *CL_SaveRewindPoint(size_t demopos); diff --git a/src/d_event.h b/src/d_event.h index c69796573..5fc963b6c 100644 --- a/src/d_event.h +++ b/src/d_event.h @@ -31,13 +31,14 @@ typedef enum } evtype_t; // Event structure. -typedef struct +struct event_t { evtype_t type; INT32 data1; // keys / mouse/joystick buttons INT32 data2; // mouse/joystick x move INT32 data3; // mouse/joystick y move -} event_t; + INT32 device; // which player's device it belongs to +}; // // GLOBAL VARIABLES diff --git a/src/d_net.c b/src/d_net.c index b91ecc5bf..d2c481d87 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -200,9 +200,9 @@ typedef struct UINT8 nextacknum; UINT8 flags; -} node_t; +} netnode_t; -static node_t nodes[MAXNETNODES]; +static netnode_t nodes[MAXNETNODES]; #define NODETIMEOUT 14 #ifndef NONET @@ -227,7 +227,7 @@ FUNCMATH static INT32 cmpack(UINT8 a, UINT8 b) */ static boolean GetFreeAcknum(UINT8 *freeack, boolean lowtimer) { - node_t *node = &nodes[doomcom->remotenode]; + netnode_t *node = &nodes[doomcom->remotenode]; INT32 i, numfreeslot = 0; if (cmpack((UINT8)((node->remotefirstack + MAXACKTOSEND) % 256), node->nextacknum) < 0) @@ -334,7 +334,7 @@ static boolean Processackpak(void) { INT32 i; boolean goodpacket = true; - node_t *node = &nodes[doomcom->remotenode]; + netnode_t *node = &nodes[doomcom->remotenode]; // Received an ack return, so remove the ack in the list if (netbuffer->ackreturn && cmpack(node->remotefirstack, netbuffer->ackreturn) < 0) @@ -509,7 +509,7 @@ void Net_AckTicker(void) for (i = 0; i < MAXACKPACKETS; i++) { const INT32 nodei = ackpak[i].destinationnode; - node_t *node = &nodes[nodei]; + netnode_t *node = &nodes[nodei]; if (ackpak[i].acknum && ackpak[i].senttime + NODETIMEOUT < I_GetTime()) { if (ackpak[i].resentnum > 20 && (node->flags & NF_CLOSE)) @@ -640,7 +640,7 @@ void Net_WaitAllAckReceived(UINT32 timeout) #endif } -static void InitNode(node_t *node) +static void InitNode(netnode_t *node) { node->acktosend_head = node->acktosend_tail = 0; node->firstacktosend = 0; diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 34e2bac31..847fe0ead 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -184,22 +184,22 @@ extern const char *netxcmdnames[MAXNETXCMD - 1]; //Packet composition for Command_TeamChange_f() ServerTeamChange, etc. //bitwise structs make packing bits a little easier, but byte alignment harder? //todo: decide whether to make the other netcommands conform, or just get rid of this experiment. -typedef struct { +struct changeteam_packet_t { UINT32 playernum : 5; // value 0 to 31 UINT32 newteam : 5; // value 0 to 31 UINT32 verification : 1; // value 0 to 1 UINT32 autobalance : 1; // value 0 to 1 UINT32 scrambled : 1; // value 0 to 1 -} ATTRPACK changeteam_packet_t; +} ATTRPACK; #ifdef _MSC_VER #pragma warning(default : 4214) #endif -typedef struct { +struct changeteam_value_t { UINT16 l; // liitle endian UINT16 b; // big enian -} ATTRPACK changeteam_value_t; +} ATTRPACK; //Since we do not want other files/modules to know about this data buffer we union it here with a Short Int. //Other files/modules will hand the INT16 back to us and we will decode it here. @@ -237,12 +237,12 @@ void RemoveAdminPlayer(INT32 playernum); void ItemFinder_OnChange(void); void D_SetPassword(const char *pw); -typedef struct +struct scheduleTask_t { UINT16 basetime; UINT16 timer; char *command; -} scheduleTask_t; +}; extern scheduleTask_t **schedule; extern size_t schedule_size; diff --git a/src/d_netfil.h b/src/d_netfil.h index e5922b1de..8d8d5dda5 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -37,7 +37,7 @@ typedef enum FS_FALLBACK, // HTTP failed } filestatus_t; -typedef struct +struct fileneeded_t { UINT8 willsend; // Is the server willing to send it? char filename[MAX_WADPATH]; @@ -54,7 +54,7 @@ typedef struct UINT32 currentsize; UINT32 totalsize; UINT32 ackresendposition; // Used when resuming downloads -} fileneeded_t; +}; extern INT32 fileneedednum; extern fileneeded_t fileneeded[MAX_WADFILES]; @@ -73,8 +73,6 @@ extern boolean curl_failedwebdownload; extern boolean curl_running; extern INT32 curl_transfers; -typedef struct HTTP_login HTTP_login; - extern struct HTTP_login { char * url; @@ -114,7 +112,7 @@ typedef enum LFTNS_SENT // The node already has the file } luafiletransfernodestatus_t; -typedef struct luafiletransfer_s +struct luafiletransfer_t { char *filename; char *realfilename; @@ -123,8 +121,8 @@ typedef struct luafiletransfer_s boolean ongoing; luafiletransfernodestatus_t nodestatus[MAXNETNODES]; tic_t nodetimeouts[MAXNETNODES]; - struct luafiletransfer_s *next; -} luafiletransfer_t; + luafiletransfer_t *next; +}; extern luafiletransfer_t *luafiletransfers; extern boolean waitingforluafiletransfer; diff --git a/src/d_player.h b/src/d_player.h index 44d0e59e3..d2171e656 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -262,7 +262,7 @@ typedef enum #define ACCEL_KICKSTART (TICRATE) // player_t struct for all bot variables -typedef struct botvars_s +struct botvars_t { UINT8 difficulty; // Bot's difficulty setting UINT8 diffincrease; // In GP: bot difficulty will increase this much next round @@ -276,19 +276,21 @@ typedef struct botvars_s SINT8 turnconfirm; // Confirm turn direction -} botvars_t; +}; -typedef struct { +struct sonicloopcamvars_t +{ tic_t enter_tic, exit_tic; tic_t zoom_in_speed, zoom_out_speed; fixed_t dist; angle_t pan; fixed_t pan_speed; // in degrees tic_t pan_accel, pan_back; -} sonicloopcamvars_t; +}; // player_t struct for loop state -typedef struct { +struct sonicloopvars_t +{ fixed_t radius; fixed_t revolution, min_revolution, max_revolution; angle_t yaw; @@ -296,12 +298,12 @@ typedef struct { vector2_t shift; boolean flip; sonicloopcamvars_t camera; -} sonicloopvars_t; +}; // ======================================================================== // PLAYER STRUCTURE // ======================================================================== -typedef struct player_s +struct player_t { mobj_t *mo; @@ -569,7 +571,7 @@ typedef struct player_s #ifdef HWRENDER fixed_t fovadd; // adjust FOV for hw rendering #endif -} player_t; +}; // Value for infinite lives #define INFLIVES 0x7F diff --git a/src/d_think.h b/src/d_think.h index dbe3781a4..e06896962 100644 --- a/src/d_think.h +++ b/src/d_think.h @@ -40,17 +40,16 @@ typedef union typedef actionf_t think_t; // Doubly linked list of actors. -typedef struct thinker_s +struct thinker_t { - struct thinker_s *prev; - struct thinker_s *next; + thinker_t *prev; + thinker_t *next; think_t function; // killough 11/98: count of how many other objects reference // this one using pointers. Used for garbage collection. INT32 references; boolean cachable; -} thinker_t; - +}; #endif diff --git a/src/d_ticcmd.h b/src/d_ticcmd.h index 20c3f0122..f653c53b0 100644 --- a/src/d_ticcmd.h +++ b/src/d_ticcmd.h @@ -60,7 +60,7 @@ typedef enum #pragma pack(1) #endif -typedef struct +struct ticcmd_t { SINT8 forwardmove; // -MAXPLMOVE to MAXPLMOVE (50) SINT8 sidemove; // -MAXPLMOVE to MAXPLMOVE (50) @@ -71,7 +71,7 @@ typedef struct UINT16 buttons; UINT8 latency; // Netgames: how many tics ago was this ticcmd generated from this player's end? UINT8 flags; -} ATTRPACK ticcmd_t; +} ATTRPACK; #if defined(_MSC_VER) #pragma pack() diff --git a/src/deh_tables.h b/src/deh_tables.h index 8e48b069c..0654e1b73 100644 --- a/src/deh_tables.h +++ b/src/deh_tables.h @@ -41,11 +41,11 @@ struct flickytypes_s { /** Action pointer for reading actions from Dehacked lumps. */ -typedef struct +struct actionpointer_t { actionf_t action; ///< Function pointer corresponding to the actual action. const char *name; ///< Name of the action in ALL CAPS. -} actionpointer_t; +}; struct int_const_s { const char *n; diff --git a/src/dehacked.h b/src/dehacked.h index 88d303b33..63cf9cedd 100644 --- a/src/dehacked.h +++ b/src/dehacked.h @@ -57,13 +57,13 @@ extern UINT8 superstack; // the code was first write for a file // converted to use memory with this functions -typedef struct +struct MYFILE { char *data; char *curpos; size_t size; UINT16 wad; -} MYFILE; +}; #define myfeof(a) (a->data + a->size <= a->curpos) char *myfgets(char *buf, size_t bufsize, MYFILE *f); char *myhashfgets(char *buf, size_t bufsize, MYFILE *f); diff --git a/src/discord.h b/src/discord.h index a6bb1134a..82d955d01 100644 --- a/src/discord.h +++ b/src/discord.h @@ -15,7 +15,7 @@ #ifdef HAVE_DISCORDRPC -#include "discord_rpc.h" +#include extern consvar_t cv_discordrp; extern consvar_t cv_discordstreamer; @@ -27,7 +27,7 @@ extern struct discordInfo_s { boolean everyoneCanInvite; } discordInfo; -typedef struct discordRequest_s { +struct discordRequest_t { char *username; // Discord user name. char *discriminator; // Discord discriminator (The little hashtag thing after the username). Separated for a "hide discriminators" cvar. char *userID; // The ID of the Discord user, gets used with Discord_Respond() @@ -38,9 +38,9 @@ typedef struct discordRequest_s { // Hey, wanna add ImageMagick as a dependency? :dying: //patch_t *avatar; - struct discordRequest_s *next; // Next request in the list. - struct discordRequest_s *prev; // Previous request in the list. Not used normally, but just in case something funky happens, this should repair the list. -} discordRequest_t; + discordRequest_t *next; // Next request in the list. + discordRequest_t *prev; // Previous request in the list. Not used normally, but just in case something funky happens, this should repair the list. +}; extern discordRequest_t *discordRequestList; diff --git a/src/doomdata.h b/src/doomdata.h index 467aaa56b..050398b29 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -68,24 +68,24 @@ enum #endif // A single Vertex. -typedef struct +struct mapvertex_t { INT16 x, y; -}ATTRPACK mapvertex_t; +}ATTRPACK; // A SideDef, defining the visual appearance of a wall, // by setting textures and offsets. -typedef struct +struct mapsidedef_t { INT16 textureoffset, rowoffset; char toptexture[8], bottomtexture[8], midtexture[8]; // Front sector, towards viewer. INT16 sector; -} ATTRPACK mapsidedef_t; +} ATTRPACK; // A LineDef, as used for editing, and as input // to the BSP builder. -typedef struct +struct maplinedef_t { INT16 v1, v2; INT16 flags; @@ -93,7 +93,7 @@ typedef struct INT16 tag; // sidenum[1] will be 0xffff if one sided UINT16 sidenum[2]; -} ATTRPACK maplinedef_t; +} ATTRPACK; // // LineDef attributes. @@ -177,7 +177,7 @@ enum }; // Sector definition, from editing. -typedef struct +struct mapsector_t { INT16 floorheight; INT16 ceilingheight; @@ -186,34 +186,34 @@ typedef struct INT16 lightlevel; INT16 special; INT16 tag; -} ATTRPACK mapsector_t; +} ATTRPACK; // SubSector, as generated by BSP. -typedef struct +struct mapsubsector_t { UINT16 numsegs; // Index of first one, segs are stored sequentially. UINT16 firstseg; -} ATTRPACK mapsubsector_t; +} ATTRPACK; // LineSeg, generated by splitting LineDefs // using partition lines selected by BSP builder. -typedef struct +struct mapseg_t { INT16 v1, v2; INT16 angle; INT16 linedef; INT16 side; INT16 offset; -} ATTRPACK mapseg_t; +} ATTRPACK; // BSP node structure. // Indicate a leaf. #define NF_SUBSECTOR 0x8000 -typedef struct +struct mapnode_t { // Partition line from (x,y) to x+dx,y+dy) INT16 x, y; @@ -224,7 +224,7 @@ typedef struct // If NF_SUBSECTOR it's a subsector, else it's a node of another subtree. UINT16 children[2]; -} ATTRPACK mapnode_t; +} ATTRPACK; #if defined(_MSC_VER) #pragma pack() @@ -235,7 +235,7 @@ typedef struct // Thing definition, position, orientation and type, // plus visibility flags and attributes. -typedef struct +struct mapthing_t { INT16 x, y; INT16 angle, pitch, roll; @@ -249,8 +249,8 @@ typedef struct INT32 args[NUMMAPTHINGARGS]; char *stringargs[NUMMAPTHINGSTRINGARGS]; UINT8 layer; // FOF layer to spawn on, see P_GetMobjSpawnHeight - struct mobj_s *mobj; -} mapthing_t; + mobj_t *mobj; +}; #define ZSHIFT 4 diff --git a/src/doomdef.h b/src/doomdef.h index b5f23360f..7b7575db3 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -133,10 +133,10 @@ extern char logfilename[1024]; // VERSIONSTRING_RC is for the resource-definition script used by windows builds #else #ifdef BETAVERSION -#define VERSIONSTRING "v"SRB2VERSION" "BETAVERSION +#define VERSIONSTRING "v" SRB2VERSION " " BETAVERSION #define VERSIONSTRING_RC SRB2VERSION " " BETAVERSION "\0" #else -#define VERSIONSTRING "v"SRB2VERSION +#define VERSIONSTRING "v" SRB2VERSION #define VERSIONSTRING_RC SRB2VERSION "\0" #endif // Hey! If you change this, add 1 to the MODVERSION below! @@ -216,7 +216,7 @@ extern char logfilename[1024]; // Master Server compatibility ONLY #define MSCOMPAT_MAXPLAYERS (32) -typedef struct skincolor_s +struct skincolor_t { char name[MAXCOLORNAME+1]; // Skincolor name UINT8 ramp[COLORRAMPSIZE]; // Colormap ramp @@ -224,7 +224,7 @@ typedef struct skincolor_s UINT8 invshade; // Signpost color shade UINT16 chatcolor; // Chat color boolean accessible; // Accessible by the color command + setup menu -} skincolor_t; +}; typedef enum { @@ -580,12 +580,14 @@ UINT32 quickncasehash (const char *p, size_t n) return x; } +#ifndef __cplusplus #ifndef min // Double-Check with WATTCP-32's cdefs.h #define min(x, y) (((x) < (y)) ? (x) : (y)) #endif #ifndef max // Double-Check with WATTCP-32's cdefs.h #define max(x, y) (((x) > (y)) ? (x) : (y)) #endif +#endif #ifndef CLAMP #define CLAMP(x, min_val, max_val) ((x) < (min_val) ? (min_val) : ((x) > (max_val) ? (max_val) : (x))) diff --git a/src/doomstat.h b/src/doomstat.h index 1a981b840..4561545d4 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -90,12 +90,12 @@ typedef enum PRECIPFX_WATERPARTICLES = 1<<2 } precipeffect_t; -typedef struct +struct precipprops_t { const char *name; mobjtype_t type; precipeffect_t effects; -} precipprops_t; +}; extern precipprops_t precipprops[MAXPRECIP]; extern preciptype_t precip_freeslot; @@ -207,7 +207,7 @@ extern tic_t countdowntimer; extern boolean countdowntimeup; extern boolean exitfadestarted; -typedef struct +struct scene_t { UINT8 numpics; char picname[8][8]; @@ -227,13 +227,13 @@ typedef struct UINT8 fadecolor; // Color number for fade, 0 means don't do the first fade UINT8 fadeinid; // ID of the first fade, to a color -- ignored if fadecolor is 0 UINT8 fadeoutid; // ID of the second fade, to the new screen -} scene_t; // TODO: It would probably behoove us to implement subsong/track selection here, too, but I'm lazy -SH +}; // TODO: It would probably behoove us to implement subsong/track selection here, too, but I'm lazy -SH -typedef struct +struct cutscene_t { scene_t scene[128]; // 128 scenes per cutscene. INT32 numscenes; // Number of scenes in this cutscene -} cutscene_t; +}; extern cutscene_t *cutscenes[128]; @@ -248,7 +248,7 @@ extern cutscene_t *cutscenes[128]; #define PROMPT_PIC_LOOP 1 #define PROMPT_PIC_DESTROY 2 #define MAX_PROMPT_PICS 8 -typedef struct +struct textpage_t { UINT8 numpics; UINT8 picmode; // sequence mode after displaying last pic, 0 = persist, 1 = loop, 2 = destroy @@ -281,13 +281,13 @@ typedef struct char nexttag[33]; // next tag to jump to. If set, this overrides nextprompt and nextpage. INT32 timetonext; // time in tics to jump to next page automatically. 0 = don't jump automatically char *text; -} textpage_t; +}; -typedef struct +struct textprompt_t { textpage_t page[MAX_PAGES]; INT32 numpages; // Number of pages in this prompt -} textprompt_t; +}; extern textprompt_t *textprompts[MAX_PROMPTS]; @@ -305,10 +305,10 @@ extern mapthing_t *rflagpoint, *bflagpoint; // Pointers to the flag spawn locati #define GF_BLUEFLAG 2 // A single point in space. -typedef struct +struct mappoint_t { fixed_t x, y, z; -} mappoint_t; +}; extern struct quake { @@ -328,26 +328,25 @@ typedef struct } nightsgrades_t; // Custom Lua values -// (This is not ifdeffed so the map header structure can stay identical, just in case.) -typedef struct +struct customoption_t { char option[32]; // 31 usable characters char value[256]; // 255 usable characters. If this seriously isn't enough then wtf. -} customoption_t; +}; -typedef struct +struct mapheader_lighting_t { UINT8 light_contrast; ///< Range of wall lighting. 0 is no lighting. SINT8 sprite_backlight; ///< Subtract from wall lighting for sprites only. boolean use_light_angle; ///< When false, wall lighting is evenly distributed. When true, wall lighting is directional. angle_t light_angle; ///< Angle of directional wall lighting. -} mapheader_lighting_t; +}; #define MAXMUSNAMES 3 // maximum definable music tracks per level /** Map header information. */ -typedef struct +struct mapheader_t { // The original eight, plus one. char lvlttl[22]; ///< Level name without "Zone". (21 character limit instead of 32, 21 characters can display on screen max anyway) @@ -435,7 +434,8 @@ typedef struct // (This is not ifdeffed so the map header structure can stay identical, just in case.) UINT8 numCustomOptions; ///< Internal. For Lua custom value support. customoption_t *customopts; ///< Custom options. Allocated dynamically for space reasons. Be careful. -} mapheader_t; +}; + // level flags #define LF_SCRIPTISFILE (1<<0) ///< True if the script is a file, not a lump. @@ -454,7 +454,7 @@ extern mapheader_t* mapheaderinfo[NUMMAPS]; // Keep in mind that it may encourage people making overly long cups just because they "can", and would be a waste of memory. #define MAXLEVELLIST 5 -typedef struct cupheader_s +struct cupheader_t { UINT16 id; ///< Cup ID char name[15]; ///< Cup title (14 chars) @@ -465,8 +465,8 @@ typedef struct cupheader_s INT16 specialstage; ///< Map number to use for special stage UINT8 emeraldnum; ///< ID of Emerald to use for special stage (1-7 for Chaos Emeralds, 8-14 for Super Emeralds, 0 for no emerald) SINT8 unlockrequired; ///< An unlockable is required to select this cup. -1 for no unlocking required. - struct cupheader_s *next; ///< Next cup in linked list -} cupheader_t; + cupheader_t *next; ///< Next cup in linked list +}; extern cupheader_t *kartcupheaders; // Start of cup linked list extern UINT16 numkartcupheaders; @@ -546,11 +546,11 @@ enum TypeOfLevel #define NUMBASETOLNAMES (4) #define NUMTOLNAMES (NUMBASETOLNAMES + NUMGAMETYPEFREESLOTS) -typedef struct +struct tolinfo_t { const char *name; UINT32 flag; -} tolinfo_t; +}; extern tolinfo_t TYPEOFLEVEL[NUMTOLNAMES]; extern UINT32 lastcustomtol; @@ -596,13 +596,13 @@ extern INT32 nummaprings; //keep track of spawned rings/coins /** Time attack information, currently a very small structure. */ -typedef struct +struct recorddata_t { tic_t time; ///< Time in which the level was finished. tic_t lap; ///< Best lap time for this level. //UINT32 score; ///< Score when the level was finished. //UINT16 rings; ///< Rings when the level was finished. -} recorddata_t; +}; /** Setup for one NiGHTS map. * These are dynamically allocated because I am insane diff --git a/src/doomtype.h b/src/doomtype.h index d415d2aff..a578e63b0 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -17,6 +17,10 @@ #ifndef __DOOMTYPE__ #define __DOOMTYPE__ +#ifdef __cplusplus +extern "C" { +#endif + #ifdef _WIN32 //#define WIN32_LEAN_AND_MEAN #define RPC_NO_WINDOWS_H @@ -99,7 +103,9 @@ typedef long ssize_t; #endif #define strncasecmp strnicmp #define strcasecmp stricmp +#ifndef __cplusplus #define inline __inline +#endif #elif defined (__WATCOMC__) #include #include @@ -118,24 +124,6 @@ typedef long ssize_t; char *strcasestr(const char *in, const char *what); #define stristr strcasestr -#if defined (macintosh) //|| defined (__APPLE__) //skip all boolean/Boolean crap - #define true 1 - #define false 0 - #define min(x,y) (((x)<(y)) ? (x) : (y)) - #define max(x,y) (((x)>(y)) ? (x) : (y)) - -#ifdef macintosh - #define stricmp strcmp - #define strnicmp strncmp -#endif - - #define boolean INT32 - - #ifndef O_BINARY - #define O_BINARY 0 - #endif -#endif //macintosh - #if defined (PC_DOS) || defined (_WIN32) || defined (__HAIKU__) #define HAVE_DOSSTR_FUNCS #endif @@ -162,22 +150,24 @@ size_t strlcpy(char *dst, const char *src, size_t siz); /* Boolean type definition */ -// \note __BYTEBOOL__ used to be set above if "macintosh" was defined, -// if macintosh's version of boolean type isn't needed anymore, then isn't this macro pointless now? -#ifndef __BYTEBOOL__ - #define __BYTEBOOL__ +// Note: C++ bool and C99/C11 _Bool are NOT compatible. +// Historically, boolean was win32 BOOL on Windows. For equivalence, it's now +// int32_t. "true" and "false" are only declared for C code; in C++, conversion +// between "bool" and "int32_t" takes over. +#ifndef _WIN32 +typedef int32_t boolean; +#else +#define BOOL boolean +#endif - //faB: clean that up !! - #if defined( _MSC_VER) && (_MSC_VER >= 1800) // MSVC 2013 and forward - #include "stdbool.h" - #elif defined (_WIN32) - #define false FALSE // use windows types - #define true TRUE - #define boolean BOOL - #else - typedef enum {false, true} boolean; - #endif -#endif // __BYTEBOOL__ +#ifndef __cplusplus +#ifndef _WIN32 +enum {false = 0, true = 1}; +#else +#define false FALSE +#define true TRUE +#endif +#endif /* 7.18.2.1 Limits of exact-width integer types */ @@ -418,4 +408,10 @@ typedef UINT64 precise_t; #define FUNCPTRCAST(p) ((union{void(*f)(void);void*v;})\ {(void(*)(void))p}).v +#include "typedef.h" + +#ifdef __cplusplus +} // extern "C" +#endif + #endif //__DOOMTYPE__ diff --git a/src/font.h b/src/font.h index 88bedb44f..0cc6610d0 100644 --- a/src/font.h +++ b/src/font.h @@ -15,9 +15,7 @@ #define MAX_FONTS 32 -typedef struct font font_t; - -struct font +struct font_t { patch_t **font; diff --git a/src/g_demo.h b/src/g_demo.h index 53f49be4d..174a4139e 100644 --- a/src/g_demo.h +++ b/src/g_demo.h @@ -66,7 +66,7 @@ typedef enum { MD_INVALID } menudemotype_e; -typedef struct menudemo_s { +struct menudemo_t { char filepath[256]; menudemotype_e type; @@ -83,7 +83,7 @@ typedef struct menudemo_s { UINT8 skin, color; UINT32 timeorscore; } standings[MAXPLAYERS]; -} menudemo_t; +}; extern mobj_t *metalplayback; @@ -150,14 +150,14 @@ void G_LoadMetal(UINT8 **buffer); // Your naming conventions are stupid and useless. // There is no conflict here. -typedef struct demoghost { +struct demoghost { UINT8 checksum[16]; UINT8 *buffer, *p, color; UINT8 fadein; UINT16 version; mobj_t oldmo, *mo; struct demoghost *next; -} demoghost; +}; extern demoghost *ghosts; // G_CheckDemoExtraFiles: checks if our loaded WAD list matches the demo's. diff --git a/src/g_game.h b/src/g_game.h index 59b35eddc..259a70491 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -142,7 +142,7 @@ struct searchdim UINT8 siz; }; -typedef struct +struct mapsearchfreq_t { INT16 mapnum; UINT8 matchc; @@ -150,8 +150,7 @@ typedef struct UINT8 keywhc; struct searchdim *keywhd;/* ...in KEYWORD */ UINT8 total;/* total hits */ -} -mapsearchfreq_t; +}; INT32 G_FindMap(const char *query, char **foundmapnamep, mapsearchfreq_t **freqp, INT32 *freqc); diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index bfeda823f..02df2e294 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -398,7 +398,6 @@ typedef void (APIENTRY * PFNglCopyTexSubImage2D) (GLenum target, GLint level, GL static PFNglCopyTexSubImage2D pglCopyTexSubImage2D; #endif - /* 1.3 functions for multitexturing */ typedef void (APIENTRY *PFNglActiveTexture) (GLenum); static PFNglActiveTexture pglActiveTexture; @@ -973,7 +972,6 @@ void SetupGLFunc4(void) *(void**)&pglUniform3fv = GetGLFunc("glUniform3fv"); *(void**)&pglGetUniformLocation = GetGLFunc("glGetUniformLocation"); #endif - } EXPORT boolean HWRAPI(CompileShaders) (void) @@ -1995,7 +1993,7 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo) { pglTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); pglTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex); - + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0); if (pTexInfo->flags & TF_TRANSPARENT) pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 0); // No mippmaps on transparent stuff else diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 4df7fc578..9ff90ba32 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -70,12 +70,12 @@ extern char english_shiftxform[]; // sorted player lines //------------------------------------ -typedef struct +struct playersort_t { UINT32 count; INT32 num; const char *name; -} playersort_t; +}; //------------------------------------ // chat stuff diff --git a/src/i_joy.h b/src/i_joy.h index b10f4c55d..eb83a6649 100644 --- a/src/i_joy.h +++ b/src/i_joy.h @@ -38,7 +38,7 @@ actually, we need to know if it is a gamepad or analog controls */ -struct JoyType_s +struct JoyType_t { /*! if true, we MUST Poll() to get new joystick data, that is: we NEED the DIRECTINPUTDEVICE2 ! (watchout NT compatibility) */ @@ -48,7 +48,6 @@ struct JoyType_s INT32 bGamepadStyle; }; -typedef struct JoyType_s JoyType_t; /** \brief Joystick info for palyer[sic] 1-4's joystick/gamepad */ diff --git a/src/i_net.h b/src/i_net.h index 8ad08e08c..bc98dca8e 100644 --- a/src/i_net.h +++ b/src/i_net.h @@ -40,7 +40,7 @@ extern INT32 net_bandwidth; // in byte/s #pragma pack(1) #endif -typedef struct +struct doomcom_t { /// Supposed to be DOOMCOM_ID INT32 id; @@ -77,14 +77,14 @@ typedef struct /// The packet data to be sent. char data[MAXPACKETLENGTH]; -} ATTRPACK doomcom_t; +} ATTRPACK; -typedef struct +struct holepunch_t { INT32 magic; INT32 addr; INT16 port; -} ATTRPACK holepunch_t; +} ATTRPACK; #if defined(_MSC_VER) #pragma pack() @@ -172,11 +172,11 @@ extern boolean (*I_SetBanUsername) (const char *username); extern boolean (*I_SetBanReason) (const char *reason); extern boolean (*I_SetUnbanTime) (time_t timestamp); -typedef struct +struct bannednode_t { size_t banid; time_t timeleft; -} bannednode_t; +}; extern bannednode_t *bannednode; /// \brief Called by D_SRB2Main to be defined by extern network driver diff --git a/src/i_system.h b/src/i_system.h index 128a3d86a..ef652bfaa 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -131,7 +131,7 @@ typedef enum NumberofForces, } FFType; -typedef struct JoyFF_s +struct JoyFF_t { INT32 ForceX; ///< The X of the Force's Vel INT32 ForceY; ///< The Y of the Force's Vel @@ -147,7 +147,7 @@ typedef struct JoyFF_s INT32 Offset; ///< Offset of the effect. UINT32 Phase; ///< Position in the cycle of the periodic effect at which playback begins, in the range from 0 through 35,999 UINT32 Period; ///< Period of the effect, in microseconds. -} JoyFF_t; +}; /** \brief Forcefeedback for the first joystick @@ -301,7 +301,7 @@ char *I_GetUserName(void); */ INT32 I_mkdir(const char *dirname, INT32 unixright); -typedef struct { +struct CPUInfoFlags { int FPU : 1; ///< FPU availabile int CPUID : 1; ///< CPUID instruction int RDTSC : 1; ///< RDTSC instruction @@ -327,7 +327,7 @@ typedef struct { int ALPHAbyte : 1; ///< ? int PAE : 1; ///< Physical Address Extension int CPUs : 8; -} CPUInfoFlags; +}; /** \brief Info about CPU diff --git a/src/i_time.h b/src/i_time.h index cab36133b..8d90c3d09 100644 --- a/src/i_time.h +++ b/src/i_time.h @@ -22,10 +22,10 @@ extern "C" { #endif -typedef struct timestate_s { +struct timestate_t { tic_t time; fixed_t timefrac; -} timestate_t; +}; extern timestate_t g_time; extern consvar_t cv_timescale; diff --git a/src/info.h b/src/info.h index cda76d62b..eb9b6c159 100644 --- a/src/info.h +++ b/src/info.h @@ -5380,7 +5380,7 @@ typedef enum state NUMSTATES } statenum_t; -typedef struct +struct state_t { spritenum_t sprite; UINT32 frame; // we use the upper 16 bits for translucency and other shade effects @@ -5389,7 +5389,7 @@ typedef struct INT32 var1; INT32 var2; statenum_t nextstate; -} state_t; +}; extern state_t states[NUMSTATES]; extern char sprnames[NUMSPRITES + 1][5]; @@ -6457,7 +6457,7 @@ typedef enum mobj_type NUMMOBJTYPES } mobjtype_t; -typedef struct +struct mobjinfo_t { INT32 doomednum; statenum_t spawnstate; @@ -6483,7 +6483,7 @@ typedef struct sfxenum_t activesound; UINT32 flags; statenum_t raisestate; -} mobjinfo_t; +}; extern mobjinfo_t mobjinfo[NUMMOBJTYPES]; diff --git a/src/k_bheap.h b/src/k_bheap.h index 04e37492c..be07b40df 100644 --- a/src/k_bheap.h +++ b/src/k_bheap.h @@ -17,21 +17,21 @@ typedef void(*updateindexfunc)(void *const, const size_t); -typedef struct bheapitem_s +struct bheapitem_t { size_t heapindex; // The index in the heap this item is updateindexfunc indexchanged; // A callback function that is called when this item changes index to alert data - struct bheap_s *owner; // The heap that owns this item + bheap_t *owner; // The heap that owns this item void *data; // data for this heap item UINT32 value; // The value of this item, the lowest value item is first in the array -} bheapitem_t; +}; -typedef struct bheap_s +struct bheap_t { size_t capacity; // capacity of the heap size_t count; // number of items in the heap bheapitem_t *array; // pointer to the heap items array -} bheap_t; +}; /*-------------------------------------------------- diff --git a/src/k_boss.h b/src/k_boss.h index db335bb07..f24365b29 100644 --- a/src/k_boss.h +++ b/src/k_boss.h @@ -26,14 +26,14 @@ typedef enum #define NUMWEAKSPOTS 8 #define WEAKSPOTANIMTIME (3*TICRATE) -typedef struct weakspot_t +struct weakspot_t { mobj_t *spot; spottype_t type; tic_t time; UINT16 color; boolean minimap; -} weakspot_t; +}; #define BOSSHEALTHBARLEN 110 diff --git a/src/k_bot.h b/src/k_bot.h index 7207741a6..dc78dcfaf 100644 --- a/src/k_bot.h +++ b/src/k_bot.h @@ -28,10 +28,10 @@ #define BOTTURNCONFIRM 4 // Point for bots to aim for -typedef struct botprediction_s { +struct botprediction_t { fixed_t x, y; fixed_t radius; -} botprediction_t; +}; // AVAILABLE FOR LUA diff --git a/src/k_brightmap.h b/src/k_brightmap.h index 9ed86b125..2c22a171f 100644 --- a/src/k_brightmap.h +++ b/src/k_brightmap.h @@ -17,7 +17,7 @@ #include "doomdef.h" #include "doomtype.h" -typedef struct brightmapStorage_s +struct brightmapStorage_t { // Brightmap storage struct. // Stores data for brightmap definitions, @@ -28,7 +28,7 @@ typedef struct brightmapStorage_s char brightmapName[9]; // The brightmap's name. UINT32 brightmapHash; // The brightmap name's hash. -} brightmapStorage_t; +}; /*-------------------------------------------------- void K_InitBrightmapsPwad(INT32 wadNum); diff --git a/src/k_collide.c b/src/k_collide.c index 252121111..21b12f095 100644 --- a/src/k_collide.c +++ b/src/k_collide.c @@ -841,7 +841,6 @@ boolean K_PvPTouchDamage(mobj_t *t1, mobj_t *t2) if ((t1Condition == true || flameT1 == true) && (t2Condition == true || flameT2 == true)) { - K_DoPowerClash(t1->player, t2->player); return false; } else if (t1Condition == true && t2Condition == false) @@ -860,7 +859,6 @@ boolean K_PvPTouchDamage(mobj_t *t1, mobj_t *t2) if ((t1Condition == true || flameT1 == true) && (t2Condition == true || flameT2 == true)) { - K_DoPowerClash(t1->player, t2->player); return false; } else if (t1Condition == true && t2Condition == false) diff --git a/src/k_follower.h b/src/k_follower.h index 77f1c9377..d30bf62db 100644 --- a/src/k_follower.h +++ b/src/k_follower.h @@ -45,7 +45,7 @@ typedef enum // // We'll define these here because they're really just a mobj that'll follow some rules behind a player // -typedef struct follower_s +struct follower_t { char skinname[SKINNAMESIZE+1]; // Skin Name. This is what to refer to when asking the commands anything. char name[SKINNAMESIZE+1]; // Name. This is used for the menus. We'll just follow the same rules as skins for this. @@ -81,7 +81,7 @@ typedef struct follower_s statenum_t losestate; // state when the player has lost statenum_t hitconfirmstate; // state for hit confirm tic_t hitconfirmtime; // time to keep the above playing for -} follower_t; +}; extern INT32 numfollowers; extern follower_t followers[MAXSKINS]; diff --git a/src/k_hud.h b/src/k_hud.h index f07d0001c..511900b2e 100644 --- a/src/k_hud.h +++ b/src/k_hud.h @@ -23,12 +23,12 @@ extern consvar_t cv_newspeedometer; void K_AdjustXYWithSnap(INT32 *x, INT32 *y, UINT32 options, INT32 dupx, INT32 dupy); -typedef struct trackingResult_s +struct trackingResult_t { fixed_t x, y; fixed_t scale; boolean onScreen; -} trackingResult_t; +}; void K_ObjectTracking(trackingResult_t *result, vector3_t *point, boolean reverse); diff --git a/src/k_kart.c b/src/k_kart.c index 8f1bda7a4..6292e6bc0 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3170,26 +3170,6 @@ void K_DoInstashield(player_t *player) P_SetTarget(&layerb->target, player->mo); } -void K_DoPowerClash(player_t *t1, player_t *t2) { - mobj_t *clash; - - // short-circuit instashield for vfx visibility - t1->instashield = 1; - t2->instashield = 1; - - S_StartSound(t1->mo, sfx_parry); - - clash = P_SpawnMobj((t1->mo->x/2) + (t2->mo->x/2), (t1->mo->y/2) + (t2->mo->y/2), (t1->mo->z/2) + (t2->mo->z/2), MT_POWERCLASH); - - // needs to handle mixed scale collisions (t1 grow t2 invinc)... - clash->z = clash->z + (t1->mo->height/4) + (t2->mo->height/4); - clash->angle = R_PointToAngle2(clash->x, clash->y, t1->mo->x, t1->mo->y) + ANGLE_90; - - // Shrink over time (accidental behavior that looked good) - clash->destscale = (t1->mo->scale/2) + (t2->mo->scale/2); - P_SetScale(clash, 3*clash->destscale/2); -} - void K_BattleAwardHit(player_t *player, player_t *victim, mobj_t *inflictor, UINT8 bumpersRemoved) { UINT8 points = 1; diff --git a/src/k_kart.h b/src/k_kart.h index e9de53f4b..bd999859b 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -58,7 +58,6 @@ void K_KartPlayerAfterThink(player_t *player); angle_t K_MomentumAngle(mobj_t *mo); void K_AwardPlayerRings(player_t *player, INT32 rings, boolean overload); void K_DoInstashield(player_t *player); -void K_DoPowerClash(player_t *t1, player_t *t2); void K_BattleAwardHit(player_t *player, player_t *victim, mobj_t *inflictor, UINT8 bumpersRemoved); void K_SpinPlayer(player_t *player, mobj_t *inflictor, mobj_t *source, INT32 type); INT32 K_ExplodePlayer(player_t *player, mobj_t *inflictor, mobj_t *source); diff --git a/src/k_pathfind.h b/src/k_pathfind.h index 3d08d87e7..38b0b207f 100644 --- a/src/k_pathfind.h +++ b/src/k_pathfind.h @@ -35,27 +35,27 @@ typedef boolean(*getpathfindfinishedfunc)(void*, void*); // A pathfindnode contains information about a node from the pathfinding // heapindex is only used within the pathfinding algorithm itself, and is always 0 after it is completed -typedef struct pathfindnode_s { +struct pathfindnode_t { size_t heapindex; // The index in the openset binary heap. Only valid while the node is in the openset. void *nodedata; - struct pathfindnode_s *camefrom; // should eventually be the most efficient predecessor node + pathfindnode_t *camefrom; // should eventually be the most efficient predecessor node UINT32 gscore; // The accumulated distance from the start to this node UINT32 hscore; // The heuristic from this node to the goal -} pathfindnode_t; +}; // Contains the final created path after pathfinding is completed -typedef struct path_s { +struct path_t { size_t numnodes; - struct pathfindnode_s *array; + pathfindnode_t *array; UINT32 totaldist; -} path_t; +}; // Contains info about the pathfinding used to setup the algorithm // (e.g. the base capacities of the dynamically allocated arrays) // should be setup by the caller before starting pathfinding // base capacities will be 8 if they aren't setup, missing callback functions will cause an error. // Can be accessed after the pathfinding is complete to get the final capacities of them -typedef struct pathfindsetup_s { +struct pathfindsetup_t { size_t opensetcapacity; size_t closedsetcapacity; size_t nodesarraycapacity; @@ -67,7 +67,7 @@ typedef struct pathfindsetup_s { getnodeheuristicfunc getheuristic; getnodetraversablefunc gettraversable; getpathfindfinishedfunc getfinished; -} pathfindsetup_t; +}; /*-------------------------------------------------- diff --git a/src/k_terrain.h b/src/k_terrain.h index b93531cb2..4de19754d 100644 --- a/src/k_terrain.h +++ b/src/k_terrain.h @@ -22,7 +22,7 @@ #define TERRAIN_NAME_LEN 32 -typedef struct t_splash_s +struct t_splash_t { // Splash definition. // These are particles spawned when hitting the floor. @@ -41,9 +41,9 @@ typedef struct t_splash_s angle_t cone; // Randomized angle of the push-out. UINT8 numParticles; // Number of particles to spawn. -} t_splash_t; +}; -typedef struct t_footstep_s +struct t_footstep_t { // Footstep definition. // These are particles spawned when moving fast enough on a floor. @@ -64,7 +64,7 @@ typedef struct t_footstep_s tic_t sfxFreq; // How frequently to play the sound. tic_t frequency; // How frequently to spawn the particles. fixed_t requiredSpeed; // Speed percentage you need to be at to trigger the particles. -} t_footstep_t; +}; typedef enum { @@ -75,7 +75,7 @@ typedef enum TOV__MAX } t_overlay_action_t; -typedef struct t_overlay_s +struct t_overlay_t { // Overlay definition. // These are sprites displayed on top of the base object. @@ -87,7 +87,7 @@ typedef struct t_overlay_s fixed_t scale; // Thing scale multiplier. UINT16 color; // Colorize effect. SKINCOLOR_NONE has no colorize. fixed_t speed; // Speed-up based on object speed. 0 plays the animation at a constant rate. -} t_overlay_t; +}; typedef enum { @@ -100,7 +100,7 @@ typedef enum TRF_BYPASSBOOST = 1<<5 // Texture bypasses boost friction resistence } terrain_flags_t; -typedef struct terrain_s +struct terrain_t { // Terrain definition. // These are all of the properties that the floor gets. @@ -124,9 +124,9 @@ typedef struct terrain_s fixed_t outrun; // Raise top speed by this amount, for super fast road. fixed_t floorClip; // Offset for sprites on this ground UINT32 flags; // Flag values (see: terrain_flags_t) -} terrain_t; +}; -typedef struct t_floor_s +struct t_floor_t { // Terrain floor definition. // Ties a texture name to a terrain definition. @@ -134,7 +134,7 @@ typedef struct t_floor_s char textureName[9]; // Floor texture name. UINT32 textureHash; // Floor texture hash. size_t terrainID; // Terrain definition ID. -} t_floor_t; +}; /*-------------------------------------------------- diff --git a/src/k_waypoint.h b/src/k_waypoint.h index fb6f0fa81..1f0f81e28 100644 --- a/src/k_waypoint.h +++ b/src/k_waypoint.h @@ -20,17 +20,17 @@ #define DEFAULT_WAYPOINT_RADIUS (384) -typedef struct waypoint_s +struct waypoint_t { mobj_t *mobj; boolean onaline; - struct waypoint_s **nextwaypoints; - struct waypoint_s **prevwaypoints; + waypoint_t **nextwaypoints; + waypoint_t **prevwaypoints; UINT32 *nextwaypointdistances; UINT32 *prevwaypointdistances; size_t numnextwaypoints; size_t numprevwaypoints; -} waypoint_t; +}; // AVAILABLE FOR LUA diff --git a/src/lua_hudlib_drawlist.h b/src/lua_hudlib_drawlist.h index 398293602..15249e4f9 100644 --- a/src/lua_hudlib_drawlist.h +++ b/src/lua_hudlib_drawlist.h @@ -24,8 +24,6 @@ extern "C" { #endif -typedef struct huddrawlist_s *huddrawlist_h; - // Create a new drawlist. Returns a handle to it. huddrawlist_h LUA_HUD_CreateDrawList(void); // Clears the draw list. diff --git a/src/m_aatree.c b/src/m_aatree.c index 2ca7120d9..6456aad96 100644 --- a/src/m_aatree.c +++ b/src/m_aatree.c @@ -32,7 +32,7 @@ typedef struct aatree_node_s struct aatree_node_s *left, *right; } aatree_node_t; -struct aatree_s +struct aatree_t { aatree_node_t *root; UINT32 flags; diff --git a/src/m_aatree.h b/src/m_aatree.h index ed52a14d3..aa26da4c7 100644 --- a/src/m_aatree.h +++ b/src/m_aatree.h @@ -19,7 +19,6 @@ // Flags for AA trees. #define AATREE_ZUSER 1 // Treat values as z_zone-allocated blocks and set their user fields -typedef struct aatree_s aatree_t; typedef void (*aatree_iter_t)(INT32 key, void *value); typedef struct aatree_iterator_s aatree_iterator_t; diff --git a/src/m_cond.h b/src/m_cond.h index ed29fe326..aad12b98e 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -37,7 +37,7 @@ typedef enum } conditiontype_t; // Condition Set information -typedef struct +struct condition_t { UINT32 id; /// <- The ID of this condition. /// In an unlock condition, all conditions with the same ID @@ -47,14 +47,14 @@ typedef struct INT32 requirement; /// <- The requirement for this variable. INT16 extrainfo1; /// <- Extra information for the condition when needed. INT16 extrainfo2; /// <- Extra information for the condition when needed. -} condition_t; -typedef struct +}; +struct conditionset_t { UINT32 numconditions; /// <- number of conditions. condition_t *condition; /// <- All conditionals to be checked. UINT8 achieved; /// <- Whether this conditional has been achieved already or not. /// (Conditional checking is skipped if true -- it's assumed you can't relock an unlockable) -} conditionset_t; +}; // Emblem information #define ET_GLOBAL 0 // Emblem with a position in space @@ -69,7 +69,7 @@ typedef struct // Map emblem flags #define ME_ENCORE 1 -typedef struct +struct emblem_t { UINT8 type; ///< Emblem type INT16 tag; ///< Tag of emblem mapthing @@ -79,8 +79,8 @@ typedef struct INT32 var; ///< If needed, specifies information on the target amount to achieve (or target skin) char hint[110]; ///< Hint for emblem hints menu UINT8 collected; ///< Do you have this emblem? -} emblem_t; -typedef struct +}; +struct extraemblem_t { char name[20]; ///< Name of the goal (used in the "emblem awarded" cecho) char description[40]; ///< Description of goal (used in statistics) @@ -89,10 +89,10 @@ typedef struct UINT8 sprite; ///< emblem sprite to use, 0 - 25 UINT16 color; ///< skincolor to use UINT8 collected; ///< Do you have this emblem? -} extraemblem_t; +}; // Unlockable information -typedef struct +struct unlockable_t { char name[64]; char objective[64]; @@ -103,7 +103,7 @@ typedef struct UINT8 nocecho; UINT8 nochecklist; UINT8 unlocked; -} unlockable_t; +}; #define SECRET_NONE 0 // Does nil. Use with levels locked by UnlockRequired #define SECRET_HEADER 1 // Does nothing on its own, just serves as a header for the menu diff --git a/src/m_dllist.h b/src/m_dllist.h index 680c2cd80..1a1f0a6ea 100644 --- a/src/m_dllist.h +++ b/src/m_dllist.h @@ -29,11 +29,11 @@ #pragma warning(disable : 4706) #endif -typedef struct mdllistitem_s +struct mdllistitem_t { - struct mdllistitem_s *next; - struct mdllistitem_s **prev; -} mdllistitem_t; + mdllistitem_t *next; + mdllistitem_t **prev; +}; FUNCINLINE static ATTRINLINE void M_DLListInsert(mdllistitem_t *item, mdllistitem_t **head) { diff --git a/src/m_fixed.h b/src/m_fixed.h index 021f84d89..c558353cc 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -333,11 +333,11 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedRound(fixed_t x) return INT32_MAX; } -typedef struct +struct vector2_t { fixed_t x; fixed_t y; -} vector2_t; +}; vector2_t *FV2_Load(vector2_t *vec, fixed_t x, fixed_t y); vector2_t *FV2_UnLoad(vector2_t *vec, fixed_t *x, fixed_t *y); @@ -361,10 +361,10 @@ boolean FV2_Equal(const vector2_t *a_1, const vector2_t *a_2); fixed_t FV2_Dot(const vector2_t *a_1, const vector2_t *a_2); vector2_t *FV2_Point2Vec (const vector2_t *point1, const vector2_t *point2, vector2_t *a_o); -typedef struct +struct vector3_t { fixed_t x, y, z; -} vector3_t; +}; vector3_t *FV3_Load(vector3_t *vec, fixed_t x, fixed_t y, fixed_t z); vector3_t *FV3_UnLoad(vector3_t *vec, fixed_t *x, fixed_t *y, fixed_t *z); @@ -401,10 +401,10 @@ vector3_t *FV3_IntersectionPoint(const vector3_t *vNormal, const vector3_t *vLin UINT8 FV3_PointOnLineSide(const vector3_t *point, const vector3_t *line); boolean FV3_PointInsideBox(const vector3_t *point, const vector3_t *box); -typedef struct +struct matrix_t { fixed_t m[16]; -} matrix_t; +}; void FM_LoadIdentity(matrix_t* matrix); void FM_CreateObjectMatrix(matrix_t *matrix, fixed_t x, fixed_t y, fixed_t z, fixed_t anglex, fixed_t angley, fixed_t anglez, fixed_t upx, fixed_t upy, fixed_t upz, fixed_t radius); diff --git a/src/m_menu.h b/src/m_menu.h index 52fe05896..0007bd1cf 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -312,7 +312,7 @@ boolean M_CanShowLevelInList(INT32 mapnum, INT32 gt); typedef union { - struct menu_s *submenu; // IT_SUBMENU + menu_t *submenu; // IT_SUBMENU consvar_t *cvar; // IT_CVAR void (*routine)(INT32 choice); // IT_CALL, IT_KEYHANDLER, IT_ARROWS void (*eventhandler)(event_t *ev); // MM_EVENTHANDLER @@ -321,7 +321,7 @@ typedef union // // MENU TYPEDEFS // -typedef struct menuitem_s +struct menuitem_t { // show IT_xxx UINT16 status; @@ -333,20 +333,20 @@ typedef struct menuitem_s // hotkey in menu or y of the item UINT16 alphaKey; -} menuitem_t; +}; -typedef struct menu_s +struct menu_t { UINT32 menuid; // ID to encode menu type and hierarchy const char *menutitlepic; INT16 numitems; // # of menu items - struct menu_s *prevMenu; // previous menu + menu_t *prevMenu; // previous menu menuitem_t *menuitems; // menu items void (*drawroutine)(void); // draw routine INT16 x, y; // x, y of menu INT16 lastOn; // last item user was on in menu boolean (*quitroutine)(void); // called before quit a menu return true if we can -} menu_t; +}; void M_SetupNextMenu(menu_t *menudef); void M_ClearMenus(boolean callexitmenufunc); @@ -413,12 +413,12 @@ typedef struct extern gtdesc_t gametypedesc[NUMGAMETYPES];*/ // mode descriptions for video mode menu -typedef struct +struct modedesc_t { INT32 modenum; // video mode number in the vidmodes list const char *desc; // XXXxYYY UINT8 goodratio; // aspect correct if 1 -} modedesc_t; +}; // savegame struct for save game menu typedef struct @@ -479,11 +479,11 @@ INT32 HU_GetHighlightColor(void); void Moviemode_option_Onchange(void); // Player Setup menu colors linked list -typedef struct menucolor_s { - struct menucolor_s *next; - struct menucolor_s *prev; +struct menucolor_t { + menucolor_t *next; + menucolor_t *prev; UINT16 color; -} menucolor_t; +}; extern menucolor_t *menucolorhead, *menucolortail; diff --git a/src/m_perfstats.h b/src/m_perfstats.h index 8371e1da7..186447827 100644 --- a/src/m_perfstats.h +++ b/src/m_perfstats.h @@ -39,22 +39,22 @@ extern int ps_checkposition_calls; extern precise_t ps_lua_thinkframe_time; extern int ps_lua_mobjhooks; -typedef struct +struct ps_hookinfo_t { precise_t time_taken; char short_src[LUA_IDSIZE]; -} ps_hookinfo_t; +}; void PS_SetThinkFrameHookInfo(int index, precise_t time_taken, char* short_src); -typedef struct +struct ps_botinfo_t { boolean isBot; precise_t total; precise_t prediction; // K_CreateBotPrediction precise_t nudge; // K_NudgePredictionTowardsObjects precise_t item; // K_BotItemUsage -} ps_botinfo_t; +}; extern ps_botinfo_t ps_bots[MAXPLAYERS]; diff --git a/src/m_queue.h b/src/m_queue.h index 3e9579e11..8e0c02797 100644 --- a/src/m_queue.h +++ b/src/m_queue.h @@ -13,17 +13,17 @@ #ifndef M_QUEUE_H #define M_QUEUE_H -typedef struct mqueueitem_s +struct mqueueitem_t { - struct mqueueitem_s *next; -} mqueueitem_t; + mqueueitem_t *next; +}; -typedef struct mqueue_s +struct mqueue_t { mqueueitem_t head; mqueueitem_t *tail; mqueueitem_t *rover; -} mqueue_t; +}; void M_QueueInit(mqueue_t *queue); void M_QueueInsert(mqueueitem_t *item, mqueue_t *queue); diff --git a/src/mserv.h b/src/mserv.h index eb1152876..b47bf2c25 100644 --- a/src/mserv.h +++ b/src/mserv.h @@ -27,16 +27,16 @@ typedef union } ATTRPACK msg_header_t; // Keep this structure 8 bytes aligned (current size is 80) -typedef struct +struct msg_server_t { msg_header_t header; char ip[16]; char port[8]; char contact[32]; char version[8]; // format is: x.yy.z (like 1.30.2 or 1.31) -} ATTRPACK msg_server_t; +} ATTRPACK; -typedef struct +struct msg_ban_t { msg_header_t header; char ipstart[16]; @@ -44,7 +44,7 @@ typedef struct char endstamp[32]; char reason[255]; INT32 hostonly; -} ATTRPACK msg_ban_t; +} ATTRPACK; #if defined(_MSC_VER) #pragma pack() diff --git a/src/p_local.h b/src/p_local.h index 52677632e..82e787e9f 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -86,7 +86,7 @@ void P_UnlinkThinker(thinker_t *thinker); // // P_USER // -typedef struct camera_s +struct camera_t { boolean chase; angle_t aiming; @@ -102,7 +102,7 @@ typedef struct camera_s //More drawing info: to determine current sprite. angle_t angle; // orientation - struct subsector_s *subsector; + subsector_t *subsector; // The closest interval over all contacted Sectors (or Things). fixed_t floorz; @@ -125,7 +125,7 @@ typedef struct camera_s // Interpolation data fixed_t old_x, old_y, old_z; angle_t old_angle, old_aiming; -} camera_t; +}; // demo freecam or something before i commit die struct demofreecam_s { @@ -254,11 +254,11 @@ typedef enum NUMJINGLES } jingletype_t; -typedef struct +struct jingle_t { char musname[7]; boolean looping; -} jingle_t; +}; extern jingle_t jingleinfo[NUMJINGLES]; @@ -390,7 +390,7 @@ void P_InternalFlickyHop(mobj_t *actor, fixed_t momz, fixed_t momh, angle_t angl // P_MAP // -typedef struct tm_s +struct tm_t { mobj_t *thing; fixed_t x, y; @@ -420,7 +420,7 @@ typedef struct tm_s // set by PIT_CheckLine() for any line that stopped the PIT_CheckLine() // that is, for any line which is 'solid' line_t *blockingline; -} tm_t; +}; extern tm_t tm; @@ -440,12 +440,12 @@ void P_UnsetThingPosition(mobj_t *thing); void P_SetThingPosition(mobj_t *thing); void P_SetUnderlayPosition(mobj_t *thing); -typedef struct TryMoveResult_s +struct TryMoveResult_t { boolean success; line_t *line; mobj_t *mo; -} TryMoveResult_t; +}; boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y, TryMoveResult_t *result); boolean P_CheckMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff, TryMoveResult_t *result); @@ -507,7 +507,7 @@ extern precipmobj_t **precipblocklinks; // special blockmap for precip rendering // // P_INTER // -typedef struct BasicFF_s +struct BasicFF_t { INT32 ForceX; ///< The X of the Force's Vel INT32 ForceY; ///< The Y of the Force's Vel @@ -517,7 +517,7 @@ typedef struct BasicFF_s INT32 Gain; ///< /The gain to be applied to the effect, in the range from 0 through 10,000. //All, CONSTANTFORCE �10,000 to 10,000 INT32 Magnitude; ///< Magnitude of the effect, in the range from 0 through 10,000. -} BasicFF_t; +}; /* Damage/death types, for P_DamageMobj and related */ //// Damage types @@ -585,9 +585,4 @@ fixed_t P_GetMobjFeet(const mobj_t *); fixed_t P_GetMobjGround(const mobj_t *); fixed_t P_GetMobjZMovement(mobj_t *mo); -void P_InitTIDHash(void); -void P_SetThingTID(mobj_t *mo, mtag_t tid); -void P_RemoveThingTID(mobj_t *mo); -mobj_t *P_FindMobjFromTID(mtag_t tid, mobj_t *i, mobj_t *activator); - #endif // __P_LOCAL__ diff --git a/src/p_map.c b/src/p_map.c index c9e454244..ab0d57e72 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1160,10 +1160,8 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) P_DamageMobj(tm.thing, thing, thing, 1, DMG_WIPEOUT|DMG_STEAL); } - if (K_PvPTouchDamage(tm.thing, thing) == true) - K_KartBouncing(tm.thing, thing); - else - K_KartBouncing(tm.thing, thing); + K_PvPTouchDamage(tm.thing, thing); + K_KartBouncing(tm.thing, thing); return BMIT_CONTINUE; } diff --git a/src/p_maputl.h b/src/p_maputl.h index 1037df52b..ea9478a6e 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -20,12 +20,12 @@ // // P_MAPUTL // -typedef struct +struct divline_t { fixed_t x, y, dx, dy; -} divline_t; +}; -typedef struct +struct intercept_t { fixed_t frac; // along trace line boolean isaline; @@ -34,7 +34,7 @@ typedef struct mobj_t *thing; line_t *line; } d; -} intercept_t; +}; typedef boolean (*traverser_t)(intercept_t *in); diff --git a/src/p_mobj.c b/src/p_mobj.c index c0b24c609..e0c4f329d 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10155,7 +10155,6 @@ void P_RemoveMobj(mobj_t *mobj) memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); #endif - P_RemoveThingTID(mobj); R_RemoveMobjInterpolator(mobj); // free block @@ -12444,8 +12443,6 @@ static mobj_t *P_SpawnMobjFromMapThing(mapthing_t *mthing, fixed_t x, fixed_t y, mobj->pitch = FixedAngle(mthing->pitch << FRACBITS); mobj->roll = FixedAngle(mthing->roll << FRACBITS); - P_SetThingTID(mobj, Tag_FGet(&mthing->tags)); - mthing->mobj = mobj; // Generic reverse gravity for individual objects flag. @@ -13424,109 +13421,3 @@ fixed_t P_GetMobjZMovement(mobj_t *mo) return P_ReturnThrustY(mo, slope->zangle, P_ReturnThrustX(mo, angDiff, speed)); } - -// -// Thing IDs / tags -// -// TODO: Replace this system with taglist_t instead. -// The issue is that those require a static numbered ID -// to determine which struct it belongs to, which mobjs -// don't really have. -// - -#define TID_HASH_CHAINS (131) -static mobj_t *TID_Hash[TID_HASH_CHAINS]; - -// -// P_InitTIDHash -// Initializes mobj tag hash array -// -void P_InitTIDHash(void) -{ - memset(TID_Hash, 0, TID_HASH_CHAINS * sizeof(mobj_t *)); -} - -// -// P_SetThingTID -// Adds a mobj to the hash array -// -void P_SetThingTID(mobj_t *mo, mtag_t tid) -{ - INT32 key = 0; - - if (tid == 0) - { - if (mo->tid != 0) - { - P_RemoveThingTID(mo); - } - - return; - } - - mo->tid = tid; - - // Insert at the head of this chain - key = tid % TID_HASH_CHAINS; - - mo->tid_next = TID_Hash[key]; - mo->tid_prev = &TID_Hash[key]; - TID_Hash[key] = mo; - - // Connect to any existing things in chain - if (mo->tid_next != NULL) - { - mo->tid_next->tid_prev = &(mo->tid_next); - } -} - -// -// P_RemoveThingTID -// Removes a mobj from the hash array -// -void P_RemoveThingTID(mobj_t *mo) -{ - if (mo->tid != 0 && mo->tid_prev != NULL) - { - // Fix the gap this would leave. - *(mo->tid_prev) = mo->tid_next; - - if (mo->tid_next != NULL) - { - mo->tid_next->tid_prev = mo->tid_prev; - } - } - - // Remove TID. - mo->tid = 0; -} - -// -// P_FindMobjFromTID -// Mobj tag search function. -// -mobj_t *P_FindMobjFromTID(mtag_t tid, mobj_t *i, mobj_t *activator) -{ - if (tid == 0) - { - // 0 grabs the activator, if applicable, - // for some ACS functions. - - if (i != NULL) - { - // Don't do more than once. - return NULL; - } - - return activator; - } - - i = (i != NULL) ? i->tid_next : TID_Hash[tid % TID_HASH_CHAINS]; - - while (i != NULL && i->tid != tid) - { - i = i->tid_next; - } - - return i; -} diff --git a/src/p_mobj.h b/src/p_mobj.h index 650bfde07..817e5b3cc 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -269,7 +269,7 @@ typedef enum { } precipflag_t; // Map Object definition. -typedef struct mobj_s +struct mobj_t { // List: thinker links. thinker_t thinker; @@ -284,8 +284,8 @@ typedef struct mobj_s // Interaction info, by BLOCKMAP. // Links in blocks (if needed). - struct mobj_s *bnext; - struct mobj_s **bprev; // killough 8/11/98: change to ptr-to-ptr + mobj_t *bnext; + mobj_t **bprev; // killough 8/11/98: change to ptr-to-ptr // More drawing info: to determine current sprite. angle_t angle, pitch, roll; // orientation @@ -302,18 +302,19 @@ typedef struct mobj_s fixed_t spritexoffset, spriteyoffset; fixed_t old_spritexscale, old_spriteyscale; fixed_t old_spritexoffset, old_spriteyoffset; - struct pslope_s *floorspriteslope; // The slope that the floorsprite is rotated by + + pslope_t *floorspriteslope; // The slope that the floorsprite is rotated by INT16 lightlevel; // Add to sector lightlevel, -255 - 255 - struct msecnode_s *touching_sectorlist; // a linked list of sectors where this object appears + msecnode_t *touching_sectorlist; // a linked list of sectors where this object appears - struct subsector_s *subsector; // Subsector the mobj resides in. + subsector_t *subsector; // Subsector the mobj resides in. // The closest interval over all contacted sectors (or things). fixed_t floorz; // Nearest floor below. fixed_t ceilingz; // Nearest ceiling above. - struct ffloor_s *floorrover; // FOF referred by floorz - struct ffloor_s *ceilingrover; // FOF referred by ceilingz + ffloor_t *floorrover; // FOF referred by floorz + ffloor_t *ceilingrover; // FOF referred by ceilingz fixed_t floordrop; fixed_t ceilingdrop; @@ -331,25 +332,21 @@ typedef struct mobj_s UINT32 flags2; // MF2_ flags UINT16 eflags; // extra flags - mtag_t tid; - struct mobj_s *tid_next; - struct mobj_s **tid_prev; // killough 8/11/98: change to ptr-to-ptr - void *skin; // overrides 'sprite' when non-NULL (for player bodies to 'remember' the skin) // Player and mobj sprites in multiplayer modes are modified // using an internal color lookup table for re-indexing. UINT16 color; // This replaces MF_TRANSLATION. Use 0 for default (no translation). // More list: links in sector (if needed) - struct mobj_s *snext; - struct mobj_s **sprev; // killough 8/11/98: change to ptr-to-ptr + mobj_t *snext; + mobj_t **sprev; // killough 8/11/98: change to ptr-to-ptr // Additional pointers for NiGHTS hoops - struct mobj_s *hnext; - struct mobj_s *hprev; + mobj_t *hnext; + mobj_t *hprev; // One last pointer for kart item lists - struct mobj_s *itnext; + mobj_t *itnext; INT32 health; // for player this is rings + 1 -- no it isn't, not any more!! @@ -357,7 +354,7 @@ typedef struct mobj_s angle_t movedir; // dirtype_t 0-7; also used by Deton for up/down angle INT32 movecount; // when 0, select a new dir - struct mobj_s *target; // Thing being chased/attacked (or NULL), and originator for missiles. + mobj_t *target; // Thing being chased/attacked (or NULL), and originator for missiles. INT32 reactiontime; // If not 0, don't attack yet. @@ -365,13 +362,13 @@ typedef struct mobj_s // Additional info record for player avatars only. // Only valid if type == MT_PLAYER - struct player_s *player; + player_t *player; INT32 lastlook; // Player number last looked for. mapthing_t *spawnpoint; // Used for CTF flags, objectplace, and a handful other applications. - struct mobj_s *tracer; // Thing being chased/attacked for tracers. + mobj_t *tracer; // Thing being chased/attacked for tracers. fixed_t friction; fixed_t movefactor; @@ -398,7 +395,7 @@ typedef struct mobj_s INT32 cusval; INT32 cvmem; - struct pslope_s *standingslope; // The slope that the object is standing on (shouldn't need synced in savegames, right?) + pslope_t *standingslope; // The slope that the object is standing on (shouldn't need synced in savegames, right?) boolean resetinterp; // if true, some fields should not be interpolated (see R_InterpolateMobjState implementation) boolean colorized; // Whether the mobj uses the rainbow colormap @@ -409,13 +406,13 @@ typedef struct mobj_s fixed_t sprxoff, spryoff, sprzoff; // Sprite offsets in real space, does NOT affect position or collision - struct terrain_s *terrain; // Terrain definition of the floor this object last hit. NULL when in the air. - struct mobj_s *terrainOverlay; // Overlay sprite object for terrain + terrain_t *terrain; // Terrain definition of the floor this object last hit. NULL when in the air. + mobj_t *terrainOverlay; // Overlay sprite object for terrain INT32 dispoffset; // WARNING: New fields must be added separately to savegame and Lua. -} mobj_t; +}; // // For precipitation @@ -424,7 +421,7 @@ typedef struct mobj_s // so please keep the start of the // structure the same. // -typedef struct precipmobj_s +struct precipmobj_t { // List: thinker links. thinker_t thinker; @@ -442,8 +439,8 @@ typedef struct precipmobj_s // Links in blocks (if needed). // The blockmap is only used by precip to render. - struct precipmobj_s *bnext; - struct precipmobj_s **bprev; // killough 8/11/98: change to ptr-to-ptr + precipmobj_t *bnext; + precipmobj_t **bprev; // killough 8/11/98: change to ptr-to-ptr // More drawing info: to determine current sprite. angle_t angle, pitch, roll; // orientation @@ -460,18 +457,18 @@ typedef struct precipmobj_s fixed_t spritexoffset, spriteyoffset; fixed_t old_spritexscale, old_spriteyscale; fixed_t old_spritexoffset, old_spriteyoffset; - struct pslope_s *floorspriteslope; // The slope that the floorsprite is rotated by + pslope_t *floorspriteslope; // The slope that the floorsprite is rotated by INT16 lightlevel; // Add to sector lightlevel, -255 - 255 - struct mprecipsecnode_s *touching_sectorlist; // a linked list of sectors where this object appears + mprecipsecnode_t *touching_sectorlist; // a linked list of sectors where this object appears - struct subsector_s *subsector; // Subsector the mobj resides in. + subsector_t *subsector; // Subsector the mobj resides in. // The closest interval over all contacted sectors (or things). fixed_t floorz; // Nearest floor below. fixed_t ceilingz; // Nearest ceiling above. - struct ffloor_s *floorrover; // FOF referred by floorz - struct ffloor_s *ceilingrover; // FOF referred by ceilingz + ffloor_t *floorrover; // FOF referred by floorz + ffloor_t *ceilingrover; // FOF referred by ceilingz fixed_t floordrop; fixed_t ceilingdrop; @@ -488,15 +485,15 @@ typedef struct precipmobj_s UINT32 flags; // flags from mobjinfo tables tic_t lastThink; -} precipmobj_t; +}; -typedef struct actioncache_s +struct actioncache_t { - struct actioncache_s *next; - struct actioncache_s *prev; - struct mobj_s *mobj; + actioncache_t *next; + actioncache_t *prev; + mobj_t *mobj; INT32 statenum; -} actioncache_t; +}; extern actioncache_t actioncachehead; diff --git a/src/p_polyobj.h b/src/p_polyobj.h index 1cf1cbb16..91f8079d3 100644 --- a/src/p_polyobj.h +++ b/src/p_polyobj.h @@ -66,7 +66,7 @@ typedef enum // Polyobject Structure // -typedef struct polyobj_s +struct polyobj_t { mdllistitem_t link; // for subsector links; must be first @@ -78,7 +78,7 @@ typedef struct polyobj_s size_t segCount; // number of segs in polyobject size_t numSegsAlloc; // number of segs allocated - struct seg_s **segs; // the segs, a reallocating array. + seg_t **segs; // the segs, a reallocating array. size_t numVertices; // number of vertices (generally == segCount) size_t numVerticesAlloc; // number of vertices allocated @@ -88,7 +88,7 @@ typedef struct polyobj_s size_t numLines; // number of linedefs (generally <= segCount) size_t numLinesAlloc; // number of linedefs allocated - struct line_s **lines; // linedefs this polyobject must move + line_t **lines; // linedefs this polyobject must move degenmobj_t spawnSpot; // location of spawn spot vertex_t centerPt; // center point @@ -109,28 +109,28 @@ typedef struct polyobj_s INT32 translucency; // index to translucency tables INT16 triggertag; // Tag of linedef executor to trigger on touch - struct visplane_s *visplane; // polyobject's visplane, for ease of putting into the list later + visplane_t *visplane; // polyobject's visplane, for ease of putting into the list later // these are saved for netgames, so do not let Lua touch these! INT32 spawnflags; // Flags the polyobject originally spawned with INT32 spawntrans; // Translucency the polyobject originally spawned with -} polyobj_t; +}; // // Polyobject Blockmap Link Structure // -typedef struct polymaplink_s +struct polymaplink_t { mdllistitem_t link; // for blockmap links polyobj_t *po; // pointer to polyobject -} polymaplink_t; +}; // // Polyobject Special Thinkers // -typedef struct polyrotate_s +struct polyrotate_t { thinker_t thinker; // must be first @@ -138,9 +138,9 @@ typedef struct polyrotate_s INT32 speed; // speed of movement per frame INT32 distance; // distance to move UINT8 turnobjs; // turn objects? PTF_ flags -} polyrotate_t; +}; -typedef struct polymove_s +struct polymove_t { thinker_t thinker; // must be first @@ -150,7 +150,7 @@ typedef struct polymove_s fixed_t momy; // y component of speed along angle INT32 distance; // total distance to move UINT32 angle; // angle along which to move -} polymove_t; +}; // PolyObject waypoint movement return behavior typedef enum @@ -160,7 +160,7 @@ typedef enum PWR_COMEBACK, // Repeat sequence in reverse } polywaypointreturn_e; -typedef struct polywaypoint_s +struct polywaypoint_t { thinker_t thinker; // must be first @@ -172,9 +172,9 @@ typedef struct polywaypoint_s UINT8 returnbehavior; // behavior after reaching the last waypoint UINT8 continuous; // continuously move - used with PWR_WRAP or PWR_COMEBACK UINT8 stophere; // Will stop after it reaches the next waypoint -} polywaypoint_t; +}; -typedef struct polyslidedoor_s +struct polyslidedoor_t { thinker_t thinker; // must be first @@ -191,9 +191,9 @@ typedef struct polyslidedoor_s fixed_t momx; // x component of speed along angle fixed_t momy; // y component of speed along angle UINT8 closing; // if true, is closing -} polyslidedoor_t; +}; -typedef struct polyswingdoor_s +struct polyswingdoor_t { thinker_t thinker; // must be first @@ -205,31 +205,31 @@ typedef struct polyswingdoor_s INT32 initDistance; // initial distance to travel INT32 distance; // current distance to travel UINT8 closing; // if true, is closing -} polyswingdoor_t; +}; -typedef struct polydisplace_s +struct polydisplace_t { thinker_t thinker; // must be first INT32 polyObjNum; - struct sector_s *controlSector; + sector_t *controlSector; fixed_t dx; fixed_t dy; fixed_t oldHeights; -} polydisplace_t; +}; -typedef struct polyrotdisplace_s +struct polyrotdisplace_t { thinker_t thinker; // must be first INT32 polyObjNum; - struct sector_s *controlSector; + sector_t *controlSector; fixed_t rotscale; UINT8 turnobjs; fixed_t oldHeights; -} polyrotdisplace_t; +}; -typedef struct polyfade_s +struct polyfade_t { thinker_t thinker; // must be first @@ -241,7 +241,7 @@ typedef struct polyfade_s boolean ticbased; INT32 duration; INT32 timer; -} polyfade_t; +}; // // Line Activation Data Structures @@ -261,23 +261,23 @@ typedef enum PTF_OTHERS = 1<<1, // Turn other mobjs with movement } polyturnflags_e; -typedef struct polyrotdata_s +struct polyrotdata_t { INT32 polyObjNum; // numeric id of polyobject to affect INT32 direction; // direction of rotation INT32 speed; // angular speed INT32 distance; // distance to move UINT8 flags; // TMPR_ flags -} polyrotdata_t; +}; -typedef struct polymovedata_s +struct polymovedata_t { INT32 polyObjNum; // numeric id of polyobject to affect fixed_t distance; // distance to move fixed_t speed; // linear speed angle_t angle; // angle of movement UINT8 overRide; // if true, will override any action on the object -} polymovedata_t; +}; typedef enum { @@ -285,14 +285,14 @@ typedef enum PWF_LOOP = 1<<1, // Loop movement (used with PWR_WRAP or PWR_COMEBACK) } polywaypointflags_e; -typedef struct polywaypointdata_s +struct polywaypointdata_t { INT32 polyObjNum; // numeric id of polyobject to affect INT32 sequence; // waypoint sequence # fixed_t speed; // linear speed UINT8 returnbehavior; // behavior after reaching the last waypoint UINT8 flags; // PWF_ flags -} polywaypointdata_t; +}; // polyobject door types typedef enum @@ -301,7 +301,7 @@ typedef enum POLY_DOOR_SWING, } polydoor_e; -typedef struct polydoordata_s +struct polydoordata_t { INT32 polyObjNum; // numeric id of polyobject to affect INT32 doorType; // polyobj door type @@ -309,31 +309,31 @@ typedef struct polydoordata_s angle_t angle; // for slide door only, angle of motion INT32 distance; // distance to move INT32 delay; // delay time after opening -} polydoordata_t; +}; -typedef struct polydisplacedata_s +struct polydisplacedata_t { INT32 polyObjNum; - struct sector_s *controlSector; + sector_t *controlSector; fixed_t dx; fixed_t dy; -} polydisplacedata_t; +}; -typedef struct polyrotdisplacedata_s +struct polyrotdisplacedata_t { INT32 polyObjNum; - struct sector_s *controlSector; + sector_t *controlSector; fixed_t rotscale; UINT8 turnobjs; -} polyrotdisplacedata_t; +}; -typedef struct polyflagdata_s +struct polyflagdata_t { INT32 polyObjNum; INT32 speed; UINT32 angle; fixed_t momx; -} polyflagdata_t; +}; typedef enum { @@ -344,7 +344,7 @@ typedef enum TMPF_GHOSTFADE = 1<<4, } textmappolyfade_t; -typedef struct polyfadedata_s +struct polyfadedata_t { INT32 polyObjNum; INT32 destvalue; @@ -352,7 +352,7 @@ typedef struct polyfadedata_s boolean doghostfade; boolean ticbased; INT32 speed; -} polyfadedata_t; +}; // // Functions diff --git a/src/p_saveg.c b/src/p_saveg.c index 260899a93..e79244f42 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2009,8 +2009,6 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) diff2 |= MD2_SHADOWSCALE; if (mobj->renderflags) diff2 |= MD2_RENDERFLAGS; - if (mobj->tid != 0) - diff2 |= MD2_TID; if (mobj->spritexscale != FRACUNIT) diff2 |= MD2_SPRITEXSCALE; if (mobj->spriteyscale != FRACUNIT) @@ -2212,8 +2210,6 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEUINT32(save_p, rf); } - if (diff2 & MD2_TID) - WRITEINT16(save_p, mobj->tid); if (diff2 & MD2_SPRITEXSCALE) WRITEFIXED(save_p, mobj->spritexscale); if (diff2 & MD2_SPRITEYSCALE) @@ -3369,8 +3365,6 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) } if (diff2 & MD2_RENDERFLAGS) mobj->renderflags = READUINT32(save_p); - if (diff2 & MD2_TID) - P_SetThingTID(mobj, READINT16(save_p)); if (diff2 & MD2_SPRITEXSCALE) mobj->spritexscale = READFIXED(save_p); else diff --git a/src/p_saveg.h b/src/p_saveg.h index 27865bf50..b7ca6527f 100644 --- a/src/p_saveg.h +++ b/src/p_saveg.h @@ -28,14 +28,14 @@ boolean P_LoadNetGame(boolean reloading); mobj_t *P_FindNewPosition(UINT32 oldposition); -typedef struct +struct savedata_t { UINT8 skin; INT32 score; INT32 lives; UINT16 emeralds; UINT8 numgameovers; -} savedata_t; +}; extern savedata_t savedata; extern UINT8 *save_p; diff --git a/src/p_setup.c b/src/p_setup.c index 5999854a1..04c315995 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -8029,7 +8029,6 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) R_InitializeLevelInterpolators(); P_InitThinkers(); - P_InitTIDHash(); R_InitMobjInterpolators(); P_InitCachedActions(); diff --git a/src/p_setup.h b/src/p_setup.h index 615d2c34d..c11d79802 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -45,7 +45,7 @@ enum // // MAP used flats lookup table // -typedef struct +struct levelflat_t { char name[9]; // resource name from wad @@ -85,7 +85,7 @@ typedef struct void *mipmap; void *mippic; #endif -} levelflat_t; +}; extern size_t numlevelflats; extern levelflat_t *levelflats; diff --git a/src/p_slopes.h b/src/p_slopes.h index f8f360b71..eeb490d0d 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -116,16 +116,16 @@ typedef enum { } dynplanetype_t; /// Permit slopes to be dynamically altered through a thinker. -typedef struct +struct dynlineplanethink_t { thinker_t thinker; pslope_t *slope; dynplanetype_t type; line_t *sourceline; fixed_t extent; -} dynlineplanethink_t; +}; -typedef struct +struct dynvertexplanethink_t { thinker_t thinker; pslope_t *slope; @@ -134,7 +134,7 @@ typedef struct fixed_t origsecheights[3]; fixed_t origvecheights[3]; UINT8 relative; -} dynvertexplanethink_t; +}; void T_DynamicSlopeLine (dynlineplanethink_t* th); void T_DynamicSlopeVert (dynvertexplanethink_t* th); diff --git a/src/p_spec.c b/src/p_spec.c index 5cf76fcd0..1278d4f3a 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -369,10 +369,7 @@ void P_ParseAnimationDefintion(SINT8 istexture) Z_Free(animdefsToken); // set texture type - if (istexture) - animdefs[i].istexture = 1; - else - animdefs[i].istexture = (animdeftempflats ? 2 : 0); + animdefs[i].istexture = istexture; // "RANGE" animdefsToken = M_GetToken(NULL); diff --git a/src/p_spec.h b/src/p_spec.h index 5a2974ada..b5d70e3a7 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -606,17 +606,17 @@ UINT16 P_GetFFloorID(ffloor_t *fflr); ffloor_t *P_GetFFloorByID(sector_t *sec, UINT16 id); // Use this when you don't know the type of your thinker data struct but need to access its thinker. -typedef struct +struct thinkerdata_t { thinker_t thinker; -} thinkerdata_t; +}; // // P_LIGHTS // /** Fire flicker action structure. */ -typedef struct +struct fireflicker_t { thinker_t thinker; ///< The thinker in use for the effect. sector_t *sector; ///< The sector where action is taking place. @@ -624,29 +624,29 @@ typedef struct INT32 resetcount; INT16 maxlight; ///< The brightest light level to use. INT16 minlight; ///< The darkest light level to use. -} fireflicker_t; +}; -typedef struct +struct lightflash_t { thinker_t thinker; sector_t *sector; INT32 maxlight; INT32 minlight; -} lightflash_t; +}; /** Laser block thinker. */ -typedef struct +struct laserthink_t { thinker_t thinker; ///< Thinker structure for laser. INT16 tag; line_t *sourceline; UINT8 nobosses; -} laserthink_t; +}; /** Strobe light action structure.. */ -typedef struct +struct strobe_t { thinker_t thinker; ///< The thinker in use for the effect. sector_t *sector; ///< The sector where the action is taking place. @@ -655,9 +655,9 @@ typedef struct INT16 maxlight; ///< The maximum light level to use. INT32 darktime; ///< How INT32 to use minlight. INT32 brighttime; ///< How INT32 to use maxlight. -} strobe_t; +}; -typedef struct +struct glow_t { thinker_t thinker; sector_t *sector; @@ -665,11 +665,11 @@ typedef struct INT16 maxlight; INT16 direction; INT16 speed; -} glow_t; +}; /** Thinker struct for fading lights. */ -typedef struct +struct lightlevel_t { thinker_t thinker; ///< Thinker in use for the effect. sector_t *sector; ///< Sector where action is taking place. @@ -680,7 +680,7 @@ typedef struct fixed_t fixedpertic; ///< Fixed point for increment per tic. // The reason for those two above to be fixed point is to deal with decimal values that would otherwise get trimmed away. INT32 timer; ///< Internal timer. -} lightlevel_t; +}; #define GLOWSPEED 8 #define STROBEBRIGHT 5 @@ -737,7 +737,7 @@ typedef enum /** Ceiling movement structure. */ -typedef struct +struct ceiling_t { thinker_t thinker; ///< Thinker for the type of movement. ceiling_e type; ///< Type of movement. @@ -761,7 +761,7 @@ typedef struct fixed_t crushSpeed; ///< Crusher speed fixed_t returnHeight; ///< Crusher return height fixed_t returnSpeed; ///< Crusher return speed -} ceiling_t; +}; #define CEILSPEED (FRACUNIT) @@ -817,7 +817,7 @@ typedef enum bridgeFall, } elevator_e; -typedef struct +struct floormove_t { thinker_t thinker; floor_e type; @@ -836,9 +836,9 @@ typedef struct fixed_t crushSpeed; fixed_t returnHeight; fixed_t returnSpeed; -} floormove_t; +}; -typedef struct +struct elevator_t { thinker_t thinker; elevator_e type; @@ -857,7 +857,7 @@ typedef struct fixed_t floorwasheight; // Height the floor WAS at fixed_t ceilingwasheight; // Height the ceiling WAS at line_t *sourceline; -} elevator_t; +}; typedef enum { @@ -866,7 +866,7 @@ typedef enum CF_REVERSE = 1<<2, // Reverse gravity } crumbleflag_t; -typedef struct +struct crumble_t { thinker_t thinker; line_t *sourceline; @@ -880,15 +880,15 @@ typedef struct fixed_t floorwasheight; // Height the floor WAS at fixed_t ceilingwasheight; // Height the ceiling WAS at UINT8 flags; -} crumble_t; +}; -typedef struct +struct noenemies_t { thinker_t thinker; line_t *sourceline; // Source line of the thinker -} noenemies_t; +}; -typedef struct +struct continuousfall_t { thinker_t thinker; sector_t *sector; @@ -897,9 +897,9 @@ typedef struct fixed_t floorstartheight; fixed_t ceilingstartheight; fixed_t destheight; -} continuousfall_t; +}; -typedef struct +struct bouncecheese_t { thinker_t thinker; line_t *sourceline; @@ -909,9 +909,9 @@ typedef struct fixed_t floorwasheight; fixed_t ceilingwasheight; boolean low; -} bouncecheese_t; +}; -typedef struct +struct mariothink_t { thinker_t thinker; sector_t *sector; @@ -920,16 +920,16 @@ typedef struct fixed_t floorstartheight; fixed_t ceilingstartheight; INT16 tag; -} mariothink_t; +}; -typedef struct +struct mariocheck_t { thinker_t thinker; line_t *sourceline; sector_t *sector; -} mariocheck_t; +}; -typedef struct +struct thwomp_t { thinker_t thinker; line_t *sourceline; @@ -943,23 +943,23 @@ typedef struct INT16 tag; UINT16 sound; INT32 initDelay; -} thwomp_t; +}; -typedef struct +struct floatthink_t { thinker_t thinker; line_t *sourceline; sector_t *sector; INT16 tag; -} floatthink_t; +}; -typedef struct +struct eachtime_t { thinker_t thinker; line_t *sourceline; // Source line of the thinker boolean playersInArea[MAXPLAYERS]; boolean triggerOnExit; -} eachtime_t; +}; typedef enum { @@ -968,7 +968,7 @@ typedef enum RF_DYNAMIC = 1<<2, //Dynamically sinking platform } raiseflag_t; -typedef struct +struct raise_t { thinker_t thinker; INT16 tag; @@ -979,7 +979,7 @@ typedef struct fixed_t extraspeed; //For dynamically sinking platform UINT8 shaketimer; //For dynamically sinking platform UINT8 flags; -} raise_t; +}; #define ELEVATORSPEED (FRACUNIT*4) #define FLOORSPEED (FRACUNIT) @@ -1031,20 +1031,20 @@ void T_EachTimeThinker(eachtime_t *eachtime); void T_CameraScanner(elevator_t *elevator); void T_RaiseSector(raise_t *raise); -typedef struct +struct executor_t { thinker_t thinker; // Thinker for linedef executor delay line_t *line; // Pointer to line that is waiting. mobj_t *caller; // Pointer to calling mobj sector_t *sector; // Pointer to triggering sector INT32 timer; // Delay timer -} executor_t; +}; void T_ExecutorDelay(executor_t *e); /** Generalized scroller. */ -typedef struct +struct scroll_t { thinker_t thinker; ///< Thinker structure for scrolling. fixed_t dx, dy; ///< (dx,dy) scroll speeds. @@ -1064,14 +1064,14 @@ typedef struct sc_carry, ///< Carry objects on floor. sc_carry_ceiling,///< Carry objects on ceiling (for 3Dfloor conveyors). } type; -} scroll_t; +}; void T_Scroll(scroll_t *s); void T_LaserFlash(laserthink_t *flash); /** Friction for ice/sludge effects. */ -typedef struct +struct friction_t { thinker_t thinker; ///< Thinker structure for friction. INT32 friction; ///< Friction value, 0xe800 = normal. @@ -1079,7 +1079,7 @@ typedef struct INT32 affectee; ///< Number of affected sector. INT32 referrer; ///< If roverfriction == true, then this will contain the sector # of the control sector where the effect was applied. UINT8 roverfriction; ///< flag for whether friction originated from a FOF or not -} friction_t; +}; // Friction defines. #define ORIG_FRICTION (62914) ///< Original value. @@ -1093,7 +1093,7 @@ typedef enum } pushertype_e; // Model for pushers for push/pull effects -typedef struct +struct pusher_t { thinker_t thinker; ///< Thinker structure for pusher effect. pushertype_e type; ///< Type of pusher effect. @@ -1105,10 +1105,10 @@ typedef struct INT32 referrer; ///< If roverpusher == true, then this will contain the sector # of the control sector where the effect was applied. INT32 exclusive; /// < Once this affect has been applied to a mobj, no other pushers may affect it. INT32 slider; /// < Should the player go into an uncontrollable slide? -} pusher_t; +}; // Model for disappearing/reappearing FOFs -typedef struct +struct disappear_t { thinker_t thinker; ///< Thinker structure for effect. tic_t appeartime; ///< Tics to be appeared for @@ -1118,12 +1118,12 @@ typedef struct INT32 affectee; ///< Number of affected line INT32 sourceline; ///< Number of source line INT32 exists; ///< Exists toggle -} disappear_t; +}; void T_Disappear(disappear_t *d); // Model for fading FOFs -typedef struct +struct fade_t { thinker_t thinker; ///< Thinker structure for effect. ffloor_t *rover; ///< Target ffloor @@ -1144,13 +1144,13 @@ typedef struct boolean docollision; ///< Handle interactive flags boolean doghostfade; ///< No interactive flags during fading boolean exactalpha; ///< Use exact alpha values (opengl) -} fade_t; +}; void T_Fade(fade_t *d); // Model for fading colormaps -typedef struct +struct fadecolormap_t { thinker_t thinker; ///< Thinker structure for effect. sector_t *sector; ///< Sector where action is taking place. @@ -1159,7 +1159,7 @@ typedef struct boolean ticbased; ///< Tic-based timing INT32 duration; ///< Total duration for tic-based logic (OR: speed increment) INT32 timer; ///< Timer for tic-based logic (OR: internal speed counter) -} fadecolormap_t; +}; void T_FadeColormap(fadecolormap_t *d); @@ -1167,7 +1167,7 @@ void T_FadeColormap(fadecolormap_t *d); void T_Pusher(pusher_t *p); // Plane displacement -typedef struct +struct planedisplace_t { thinker_t thinker; ///< Thinker structure for plane displacement effect. INT32 affectee; ///< Number of affected sector. @@ -1183,7 +1183,7 @@ typedef struct pd_ceiling, ///< Displace ceiling. pd_both, ///< Displace both floor AND ceiling. } type; -} planedisplace_t; +}; void T_PlaneDisplace(planedisplace_t *pd); diff --git a/src/r_data.h b/src/r_data.h index 3c8908a59..4ce797e66 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -23,12 +23,12 @@ #endif // Store lists of lumps for F_START/F_END etc. -typedef struct +struct lumplist_t { UINT16 wadfile; UINT16 firstlump; size_t numlumps; -} lumplist_t; +}; UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha); UINT32 ASTBlendTexturePixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha); diff --git a/src/r_defs.h b/src/r_defs.h index d2d6355f0..8d451c464 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -35,11 +35,11 @@ // Clips the given range of columns // and includes it in the new clip list. // -typedef struct +struct cliprange_t { INT32 first; INT32 last; -} cliprange_t; +}; // Silhouette, needed for clipping segs (mainly) and sprites representing things. #define SIL_NONE 0 @@ -57,7 +57,7 @@ typedef UINT8 lighttable_t; #define CMF_FOG (udmf ? 4 : 1) // ExtraColormap type. Use for extra_colormaps from now on. -typedef struct extracolormap_s +struct extracolormap_t { UINT8 fadestart, fadeend; UINT8 flags; @@ -74,9 +74,9 @@ typedef struct extracolormap_s char lumpname[9]; // for netsyncing #endif - struct extracolormap_s *next; - struct extracolormap_s *prev; -} extracolormap_t; + extracolormap_t *next; + extracolormap_t *prev; +}; // // INTERNAL MAP TYPES used by play and refresh @@ -84,28 +84,25 @@ typedef struct extracolormap_s /** Your plain vanilla vertex. */ -typedef struct +struct vertex_t { fixed_t x, y; boolean floorzset, ceilingzset; fixed_t floorz, ceilingz; -} vertex_t; - -// Forward of linedefs, for sectors. -struct line_s; +}; /** Degenerate version of ::mobj_t, storing only a location. * Used for sound origins in sectors, hoop centers, and the like. Does not * handle sound from moving objects (doppler), because position is probably * just buffered, not updated. */ -typedef struct +struct degenmobj_t { thinker_t thinker; ///< Not used for anything. fixed_t x; ///< X coordinate. fixed_t y; ///< Y coordinate. fixed_t z; ///< Z coordinate. -} degenmobj_t; +}; #include "p_polyobj.h" @@ -208,7 +205,7 @@ typedef enum BT_STRONG, } busttype_e; -typedef struct ffloor_s +struct ffloor_t { fixed_t *topheight; INT32 *toppic; @@ -224,17 +221,17 @@ typedef struct ffloor_s angle_t *bottomangle; // Pointers to pointers. Yup. - struct pslope_s **t_slope; - struct pslope_s **b_slope; + pslope_t **t_slope; + pslope_t **b_slope; size_t secnum; ffloortype_e fofflags; - struct line_s *master; + line_t *master; - struct sector_s *target; + sector_t *target; - struct ffloor_s *next; - struct ffloor_s *prev; + ffloor_t *next; + ffloor_t *prev; INT32 lastlight; INT32 alpha; @@ -258,25 +255,25 @@ typedef struct ffloor_s INT32 spawnalpha; // alpha the 3D floor spawned with void *fadingdata; // fading FOF thinker -} ffloor_t; +}; // This struct holds information for shadows casted by 3D floors. // This information is contained inside the sector_t and is used as the base // information for casted shadows. -typedef struct lightlist_s +struct lightlist_t { fixed_t height; INT16 *lightlevel; extracolormap_t **extra_colormap; // pointer-to-a-pointer, so we can react to colormap changes INT32 flags; ffloor_t *caster; - struct pslope_s *slope; // FOF_DOUBLESHADOW makes me have to store this pointer here. Bluh bluh. -} lightlist_t; + pslope_t *slope; // FOF_DOUBLESHADOW makes me have to store this pointer here. Bluh bluh. +}; // This struct is used for rendering walls with shadows casted on them... -typedef struct r_lightlist_s +struct r_lightlist_t { fixed_t height; fixed_t heightstep; @@ -288,7 +285,7 @@ typedef struct r_lightlist_s lighttable_t *rcolormap; ffloortype_e flags; INT32 lightnum; -} r_lightlist_t; +}; // Slopes typedef enum { @@ -296,10 +293,10 @@ typedef enum { SL_DYNAMIC = 1<<1, /// This plane slope will be assigned a thinker to make it dynamic. } slopeflags_t; -typedef struct pslope_s +struct pslope_t { UINT16 id; // The number of the slope, mostly used for netgame syncing purposes - struct pslope_s *next; // Make a linked list of dynamic slopes, for easy reference later + pslope_t *next; // Make a linked list of dynamic slopes, for easy reference later // The plane's definition. vector3_t o; /// Plane origin. @@ -326,7 +323,7 @@ typedef struct pslope_s #ifdef HWRENDER INT16 hwLightOffset; #endif -} pslope_t; +}; typedef enum { @@ -442,7 +439,7 @@ typedef enum // The SECTORS record, at runtime. // Stores things/mobjs. // -typedef struct sector_s +struct sector_t { fixed_t floorheight; fixed_t ceilingheight; @@ -488,10 +485,10 @@ typedef struct sector_s // list of mobjs that are at least partially in the sector // thinglist is a subset of touching_thinglist - struct msecnode_s *touching_thinglist; + msecnode_t *touching_thinglist; size_t linecount; - struct line_s **lines; // [linecount] size + line_t **lines; // [linecount] size // Improved fake floor hack ffloor_t *ffloors; @@ -523,13 +520,13 @@ typedef struct sector_s fixed_t friction; // Sprite culling feature - struct line_s *cullheight; + line_t *cullheight; // Current speed of ceiling/floor. For Knuckles to hold onto stuff. fixed_t floorspeed, ceilspeed; // list of precipitation mobjs in sector - struct mprecipsecnode_s *touching_preciplist; + mprecipsecnode_t *touching_preciplist; // Eternity engine slope pslope_t *f_slope; // floor slope @@ -541,13 +538,13 @@ typedef struct sector_s // colormap structure extracolormap_t *spawn_extra_colormap; - + // Action specials INT16 action; INT32 args[NUMSECTORARGS]; char *stringargs[NUMSECTORSTRINGARGS]; sectoractionflags_t activation; -} sector_t; +}; // // Move clipping aid for linedefs. @@ -565,7 +562,7 @@ typedef enum #define NUMLINEARGS 10 #define NUMLINESTRINGARGS 2 -typedef struct line_s +struct line_t { // Vertices, from v1 to v2. vertex_t *v1; @@ -605,9 +602,9 @@ typedef struct line_s char *text; // a concatenation of all front and back texture names, for linedef specials that require a string. INT16 callcount; // no. of calls left before triggering, for the "X calls" linedef specials, defaults to 0 -} line_t; +}; -typedef struct +struct side_t { // add this to the calculated texture column fixed_t textureoffset; @@ -631,7 +628,7 @@ typedef struct char *text; // a concatenation of all top, bottom, and mid texture names, for linedef specials that require a string. extracolormap_t *colormap_data; // storage for colormaps; not applied to sectors. -} side_t; +}; // // A subsector. @@ -639,14 +636,14 @@ typedef struct // Basically, this is a list of linesegs, indicating the visible walls that define // (all or some) sides of a convex BSP leaf. // -typedef struct subsector_s +struct subsector_t { sector_t *sector; INT16 numlines; UINT32 firstline; - struct polyobj_s *polyList; // haleyjd 02/19/06: list of polyobjects + polyobj_t *polyList; // haleyjd 02/19/06: list of polyobjects size_t validcount; -} subsector_t; +}; // Sector list node showing all sectors an object appears in. // @@ -662,32 +659,32 @@ typedef struct subsector_s // // For the links, NULL means top or end of list. -typedef struct msecnode_s +struct msecnode_t { sector_t *m_sector; // a sector containing this object - struct mobj_s *m_thing; // this object - struct msecnode_s *m_sectorlist_prev; // prev msecnode_t for this thing - struct msecnode_s *m_sectorlist_next; // next msecnode_t for this thing - struct msecnode_s *m_thinglist_prev; // prev msecnode_t for this sector - struct msecnode_s *m_thinglist_next; // next msecnode_t for this sector + mobj_t *m_thing; // this object + msecnode_t *m_sectorlist_prev; // prev msecnode_t for this thing + msecnode_t *m_sectorlist_next; // next msecnode_t for this thing + msecnode_t *m_thinglist_prev; // prev msecnode_t for this sector + msecnode_t *m_thinglist_next; // next msecnode_t for this sector boolean visited; // used in search algorithms -} msecnode_t; +}; -typedef struct mprecipsecnode_s +struct mprecipsecnode_t { sector_t *m_sector; // a sector containing this object - struct precipmobj_s *m_thing; // this object - struct mprecipsecnode_s *m_sectorlist_prev; // prev msecnode_t for this thing - struct mprecipsecnode_s *m_sectorlist_next; // next msecnode_t for this thing - struct mprecipsecnode_s *m_thinglist_prev; // prev msecnode_t for this sector - struct mprecipsecnode_s *m_thinglist_next; // next msecnode_t for this sector + precipmobj_t *m_thing; // this object + mprecipsecnode_t *m_sectorlist_prev; // prev msecnode_t for this thing + mprecipsecnode_t *m_sectorlist_next; // next msecnode_t for this thing + mprecipsecnode_t *m_thinglist_prev; // prev msecnode_t for this sector + mprecipsecnode_t *m_thinglist_next; // next msecnode_t for this sector boolean visited; // used in search algorithms -} mprecipsecnode_t; +}; // for now, only used in hardware mode // maybe later for software as well? // that's why it's moved here -typedef struct light_s +struct light_t { UINT16 type; // light,... (cfr #define in hwr_light.c) @@ -700,19 +697,19 @@ typedef struct light_s UINT32 dynamic_color; // color of the light for dynamic lighting float dynamic_radius; // radius of the light ball float dynamic_sqrradius; // radius^2 of the light ball -} light_t; +}; -typedef struct lightmap_s +struct lightmap_t { float s[2], t[2]; light_t *light; - struct lightmap_s *next; -} lightmap_t; + lightmap_t *next; +}; // // The lineseg. // -typedef struct seg_s +struct seg_t { vertex_t *v1; vertex_t *v2; @@ -753,12 +750,12 @@ typedef struct seg_s #ifdef HWRENDER INT16 hwLightOffset; #endif -} seg_t; +}; // // BSP node. // -typedef struct +struct node_t { // Partition line. fixed_t x, y; @@ -769,18 +766,18 @@ typedef struct // If NF_SUBSECTOR its a subsector. UINT16 children[2]; -} node_t; +}; #if defined(_MSC_VER) #pragma pack(1) #endif // posts are runs of non masked source pixels -typedef struct +struct post_t { UINT8 topdelta; // -1 is the last post in a column UINT8 length; // length data bytes follows -} ATTRPACK post_t; +} ATTRPACK; #if defined(_MSC_VER) #pragma pack() @@ -800,7 +797,7 @@ typedef post_t column_t; // // ? // -typedef struct drawseg_s +struct drawseg_t { seg_t *curline; INT32 x1; @@ -820,9 +817,9 @@ typedef struct drawseg_s INT16 *sprbottomclip; INT16 *maskedtexturecol; - struct visplane_s *ffloorplanes[MAXFFLOORS]; + visplane_t *ffloorplanes[MAXFFLOORS]; INT32 numffloorplanes; - struct ffloor_s *thicksides[MAXFFLOORS]; + ffloor_t *thicksides[MAXFFLOORS]; INT16 *thicksidecol; INT32 numthicksides; fixed_t frontscale[MAXVIDWIDTH]; @@ -832,7 +829,7 @@ typedef struct drawseg_s fixed_t maskedtextureheight[MAXVIDWIDTH]; // For handling sloped midtextures vertex_t leftpos, rightpos; // Used for rendering FOF walls with slopes -} drawseg_t; +}; typedef enum { @@ -844,11 +841,11 @@ typedef enum } pic_mode_t; #ifdef ROTSPRITE -typedef struct +struct rotsprite_t { INT32 angles; void **patches; -} rotsprite_t; +}; #endif // Patches. @@ -856,7 +853,7 @@ typedef struct // Patches are used for sprites and all masked pictures, and we compose // textures from the TEXTURES list of patches. // -typedef struct +struct patch_t { INT16 width, height; INT16 leftoffset, topoffset; @@ -870,7 +867,7 @@ typedef struct #ifdef ROTSPRITE rotsprite_t *rotated; // Rotated patches #endif -} patch_t; +}; extern patch_t *missingpat; @@ -878,7 +875,7 @@ extern patch_t *missingpat; #pragma pack(1) #endif -typedef struct +struct softwarepatch_t { INT16 width; // bounding box size INT16 height; @@ -886,14 +883,14 @@ typedef struct INT16 topoffset; // pixels below the origin INT32 columnofs[8]; // only [width] used // the [0] is &columnofs[width] -} ATTRPACK softwarepatch_t; +} ATTRPACK; #ifdef _MSC_VER #pragma warning(disable : 4200) #endif // a pic is an unmasked block of pixels, stored in horizontal way -typedef struct +struct pic_t { INT16 width; UINT8 zero; // set to 0 allow autodetection of pic_t @@ -902,7 +899,7 @@ typedef struct INT16 height; INT16 reserved1; // set to 0 UINT8 data[]; -} ATTRPACK pic_t; +} ATTRPACK; #ifdef _MSC_VER #pragma warning(default : 4200) @@ -1002,7 +999,7 @@ typedef enum // Or the right side: NNNNFR // Or both, mirrored: NNNNFLFR // -typedef struct +struct spriteframe_t { // If false use 0 for any position. // Note: as eight entries are available, we might as well insert the same @@ -1019,15 +1016,15 @@ typedef struct #ifdef ROTSPRITE rotsprite_t *rotated[2][16]; // Rotated patches #endif -} spriteframe_t; +}; // // A sprite definition: a number of animation frames. // -typedef struct +struct spritedef_t { size_t numframes; spriteframe_t *spriteframes; -} spritedef_t; +}; #endif diff --git a/src/r_draw.c b/src/r_draw.c index cbf673e9e..c50d5cbea 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -103,7 +103,7 @@ UINT8 *dc_transmap; // one of the translucency tables */ UINT8 *dc_translation; -struct r_lightlist_s *dc_lightlist = NULL; +struct r_lightlist_t *dc_lightlist = NULL; INT32 dc_numlights = 0, dc_maxlights, dc_texheight; // ========================================================================= diff --git a/src/r_draw.h b/src/r_draw.h index f99ea5aed..45b0a1ce1 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -47,7 +47,7 @@ extern UINT8 *dc_transmap; extern UINT8 *dc_translation; -extern struct r_lightlist_s *dc_lightlist; +extern struct r_lightlist_t *dc_lightlist; extern INT32 dc_numlights, dc_maxlights; //Fix TUTIFRUTI @@ -72,9 +72,9 @@ extern UINT8 *ds_source; extern UINT8 *ds_brightmap; extern UINT8 *ds_transmap; -typedef struct { +struct floatv3_t { float x, y, z; -} floatv3_t; +}; // Vectors for Software's tilted slope drawers extern floatv3_t *ds_su, *ds_sv, *ds_sz; diff --git a/src/r_fps.h b/src/r_fps.h index 41fc65af0..8f2bad0d2 100644 --- a/src/r_fps.h +++ b/src/r_fps.h @@ -40,7 +40,7 @@ extern enum viewcontext_e viewcontext; #define R_GetViewNumber() ((viewcontext - VIEWCONTEXT_PLAYER1) & 3) -typedef struct { +struct viewvars_t { fixed_t x; fixed_t y; fixed_t z; @@ -54,11 +54,11 @@ typedef struct { fixed_t cos; fixed_t sin; mobj_t *mobj; -} viewvars_t; +}; extern viewvars_t *newview; -typedef struct { +struct interpmobjstate_t { fixed_t x; fixed_t y; fixed_t z; @@ -69,7 +69,7 @@ typedef struct { fixed_t spriteyscale; fixed_t spritexoffset; fixed_t spriteyoffset; -} interpmobjstate_t; +}; // Level interpolators @@ -83,7 +83,7 @@ typedef enum { } levelinterpolator_type_e; // Tagged union of a level interpolator -typedef struct levelinterpolator_s { +struct levelinterpolator_t { levelinterpolator_type_e type; thinker_t *thinker; union { @@ -116,7 +116,7 @@ typedef struct levelinterpolator_s { fixed_t oldzdelta, bakzdelta; } dynslope; }; -} levelinterpolator_t; +}; // Interpolates the current view variables (r_state.h) against the selected view context in R_SetViewContext void R_InterpolateView(fixed_t frac); diff --git a/src/r_picformats.h b/src/r_picformats.h index 9596aae6e..3ab520f5f 100644 --- a/src/r_picformats.h +++ b/src/r_picformats.h @@ -92,19 +92,19 @@ typedef enum ROTAXIS_Z // Yaw } rotaxis_t; -typedef struct +struct spriteframepivot_t { INT32 x, y; rotaxis_t rotaxis; -} spriteframepivot_t; +}; -typedef struct +struct spriteinfo_t { spriteframepivot_t pivot[64 + 1]; #define SPRINFO_DEFAULT_PIVOT (64) UINT8 available[BIT_ARRAY_SIZE(64 + 1)]; // 1 extra for default_pivot char *bright[64 + 1]; // brightmap lump name -} spriteinfo_t; +}; // Portable Network Graphics #define PNG_HEADER_SIZE (8) diff --git a/src/r_plane.h b/src/r_plane.h index a552521c6..7d5f2cafc 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -28,9 +28,9 @@ // Now what is a visplane, anyway? // Simple: kinda floor/ceiling polygon optimised for SRB2 rendering. // -typedef struct visplane_s +struct visplane_t { - struct visplane_s *next; + visplane_t *next; fixed_t height; fixed_t viewx, viewy, viewz; @@ -50,13 +50,13 @@ typedef struct visplane_s fixed_t xoffs, yoffs; // Scrolling flats. - struct ffloor_s *ffloor; + ffloor_t *ffloor; polyobj_t *polyobj; pslope_t *slope; boolean noencore; boolean ripple; -} visplane_t; +}; extern visplane_t *visplanes[MAXVISPLANES]; extern visplane_t *floorplane; @@ -104,7 +104,7 @@ void R_CalculateSlopeVectors(void); // Sets the slope vector pointers for the current tilted span. void R_SetTiltedSpan(INT32 span); -typedef struct planemgr_s +struct visffloor_t { visplane_t *plane; fixed_t height; @@ -119,11 +119,11 @@ typedef struct planemgr_s fixed_t f_pos_slope; fixed_t b_pos_slope; - struct pslope_s *slope; + pslope_t *slope; - struct ffloor_s *ffloor; + ffloor_t *ffloor; polyobj_t *polyobj; -} visffloor_t; +}; extern visffloor_t ffloor[MAXFFLOORS]; extern INT32 numffloors; diff --git a/src/r_portal.h b/src/r_portal.h index e665a26e6..d716f5808 100644 --- a/src/r_portal.h +++ b/src/r_portal.h @@ -20,9 +20,9 @@ /** Portal structure for the software renderer. */ -typedef struct portal_s +struct portal_t { - struct portal_s *next; + portal_t *next; // Viewport. fixed_t viewx; @@ -39,7 +39,7 @@ typedef struct portal_s INT16 *ceilingclip; /**< Temporary screen top clipping array. */ INT16 *floorclip; /**< Temporary screen bottom clipping array. */ fixed_t *frontscale;/**< Temporary screen bottom clipping array. */ -} portal_t; +}; extern portal_t* portal_base; extern portal_t* portal_cap; diff --git a/src/r_skins.h b/src/r_skins.h index 2785c5546..2aec39679 100644 --- a/src/r_skins.h +++ b/src/r_skins.h @@ -31,7 +31,7 @@ #define DEFAULTSKIN4 "eggman" // fourth player /// The skin_t struct -typedef struct +struct skin_t { char name[SKINNAMESIZE+1]; // INT16 descriptive name of the skin UINT16 wadnum; @@ -62,7 +62,7 @@ typedef struct // contains super versions too spritedef_t sprites[NUMPLAYERSPRITES*2]; spriteinfo_t sprinfo[NUMPLAYERSPRITES*2]; -} skin_t; +}; enum facepatches { FACE_RANK = 0, diff --git a/src/r_splats.h b/src/r_splats.h index a26661e03..23e475c06 100644 --- a/src/r_splats.h +++ b/src/r_splats.h @@ -28,7 +28,7 @@ struct rastery_s }; extern struct rastery_s *prastertab; // for ASM code -typedef struct floorsplat_s +struct floorsplat_t { UINT16 *pic; INT32 width, height; @@ -39,7 +39,7 @@ typedef struct floorsplat_s vector3_t verts[4]; // (x,y,z) as viewed from above on map fixed_t x, y, z; // position mobj_t *mobj; // Mobj it is tied to -} floorsplat_t; +}; void R_DrawFloorSplat(vissprite_t *spr); diff --git a/src/r_state.h b/src/r_state.h index 5398bcc20..920ce08fd 100644 --- a/src/r_state.h +++ b/src/r_state.h @@ -28,13 +28,13 @@ // // needed for pre rendering (fracs) -typedef struct +struct sprcache_t { fixed_t width; fixed_t offset; fixed_t topoffset; fixed_t height; -} sprcache_t; +}; extern sprcache_t *spritecachedinfo; diff --git a/src/r_textures.h b/src/r_textures.h index d3e3940f9..a29bf71e0 100644 --- a/src/r_textures.h +++ b/src/r_textures.h @@ -28,7 +28,7 @@ // A single patch from a texture definition, // basically a rectangular area within // the texture rectangle. -typedef struct +struct texpatch_t { // Block origin (always UL), which has already accounted for the internal origin of the patch. INT16 originx, originy; @@ -36,7 +36,7 @@ typedef struct UINT8 flip; // 1 = flipx, 2 = flipy, 3 = both UINT8 alpha; // Translucency value patchalphastyle_t style; -} texpatch_t; +}; // texture type enum @@ -52,7 +52,7 @@ enum // A texture_t describes a rectangular texture, // which is composed of one or more texpatch_t structures // that arrange graphic patches. -typedef struct +struct texture_t { // Keep name for switch changing, etc. char name[8]; @@ -67,7 +67,7 @@ typedef struct // All the patches[patchcount] are drawn back to front into the cached texture. INT16 patchcount; texpatch_t patches[]; -} texture_t; +}; // all loaded and prepared textures from the start of the game extern texture_t **textures; diff --git a/src/r_things.h b/src/r_things.h index 4b0da28a3..3087dc752 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -99,13 +99,13 @@ INT32 R_ThingLightLevel(mobj_t *thing); * per portal to later group them in separate * drawnode lists. */ -typedef struct +struct maskcount_t { size_t drawsegs[2]; size_t vissprites[2]; fixed_t viewx, viewy, viewz; /**< View z stored at the time of the BSP traversal for the view/portal. Masked sorting/drawing needs it. */ sector_t* viewsector; -} maskcount_t; +}; void R_DrawMasked(maskcount_t* masks, INT32 nummasks); @@ -149,14 +149,14 @@ typedef enum // A vissprite_t is a thing that will be drawn during a refresh, // i.e. a sprite object that is partly visible. -typedef struct vissprite_s +struct vissprite_t { // Doubly linked list. - struct vissprite_s *prev; - struct vissprite_s *next; + vissprite_t *prev; + vissprite_t *next; // Bonus linkdraw pointer. - struct vissprite_s *linkdraw; + vissprite_t *linkdraw; mobj_t *mobj; // for easy access @@ -225,7 +225,7 @@ typedef struct vissprite_s INT32 dispoffset; // copy of info->dispoffset, affects ordering but not drawing fixed_t floorclip; // Cut off your tires in tall grass -} vissprite_t; +}; extern UINT32 visspritecount; @@ -242,7 +242,7 @@ UINT8 *R_GetSpriteTranslation(vissprite_t *vis); // A drawnode is something that points to a 3D floor, 3D side, or masked // middle texture. This is used for sorting with sprites. -typedef struct drawnode_s +struct drawnode_t { visplane_t *plane; drawseg_t *seg; @@ -250,9 +250,9 @@ typedef struct drawnode_s ffloor_t *ffloor; vissprite_t *sprite; - struct drawnode_s *next; - struct drawnode_s *prev; -} drawnode_t; + drawnode_t *next; + drawnode_t *prev; +}; void R_InitDrawNodes(void); diff --git a/src/s_sound.h b/src/s_sound.h index 4f2f3d4f0..9c9b585f1 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -67,12 +67,12 @@ typedef enum SF_X2AWAYSOUND = 64, // Hear it from 2x the distance away } soundflags_t; -typedef struct { +struct listener_t { fixed_t x, y, z; angle_t angle; -} listener_t; +}; -typedef struct +struct channel_t { // sound information (if null, channel avail.) sfxinfo_t *sfxinfo; @@ -86,14 +86,14 @@ typedef struct // handle of the sound being played INT32 handle; -} channel_t; +}; -typedef struct { +struct caption_t { channel_t *c; sfxinfo_t *s; UINT16 t; UINT8 b; -} caption_t; +}; #define NUMCAPTIONS 8 #define MAXCAPTIONTICS (2*TICRATE) @@ -168,7 +168,7 @@ boolean S_SpeedMusic(float speed); #define MAXDEFTRACKS 3 // Music credits -typedef struct musicdef_s +struct musicdef_t { char name[MAXDEFTRACKS][7]; UINT32 hash[MAXDEFTRACKS]; @@ -179,8 +179,8 @@ typedef struct musicdef_s char *composers; int volume; boolean contentidunsafe; - struct musicdef_s *next; -} musicdef_t; + musicdef_t *next; +}; extern struct cursongcredit { @@ -223,7 +223,7 @@ UINT32 S_GetMusicPosition(void); // Music Stacking (Jingles) // -typedef struct musicstack_s +struct musicstack_t { char musname[7]; UINT16 musflags; @@ -234,9 +234,9 @@ typedef struct musicstack_s lumpnum_t mlumpnum; boolean noposition; // force music stack resuming from zero (like music_stack_noposition) - struct musicstack_s *prev; - struct musicstack_s *next; -} musicstack_t; + musicstack_t *prev; + musicstack_t *next; +}; extern char music_stack_nextmusname[7]; extern boolean music_stack_noposition; diff --git a/src/screen.h b/src/screen.h index 8abf77224..d49f4aee2 100644 --- a/src/screen.h +++ b/src/screen.h @@ -45,7 +45,7 @@ #define BASEVIDHEIGHT 200 // resolution of the graphics. // global video state -typedef struct viddef_s +struct viddef_t { INT32 modenum; // vidmode num indexes videomodes list @@ -74,7 +74,7 @@ typedef struct viddef_s INT32/*fixed_t*/ fmeddupx, fmeddupy; INT32 glstate; #endif -} viddef_t; +}; enum { @@ -84,16 +84,16 @@ enum }; // internal additional info for vesa modes only -typedef struct +struct vesa_extra_t { INT32 vesamode; // vesa mode number plus LINEAR_MODE bit void *plinearmem; // linear address of start of frame buffer -} vesa_extra_t; +}; // a video modes from the video modes list, // note: video mode 0 is always standard VGA320x200. -typedef struct vmode_s +struct vmode_t { - struct vmode_s *pnext; + vmode_t *pnext; char *name; UINT32 width, height; UINT32 rowbytes; // bytes per scanline @@ -102,12 +102,12 @@ typedef struct vmode_s INT32 numpages; vesa_extra_t *pextradata; // vesa mode extra data #ifdef _WIN32 - INT32 (WINAPI *setmode)(viddef_t *lvid, struct vmode_s *pcurrentmode); + INT32 (WINAPI *setmode)(viddef_t *lvid, vmode_t *pcurrentmode); #else - INT32 (*setmode)(viddef_t *lvid, struct vmode_s *pcurrentmode); + INT32 (*setmode)(viddef_t *lvid, vmode_t *pcurrentmode); #endif INT32 misc; // misc for display driver (r_opengl.dll etc) -} vmode_t; +}; #define NUMSPECIALMODES 4 extern vmode_t specialmodes[NUMSPECIALMODES]; diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index deb4c0a14..dd8d304a4 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -1,311 +1,129 @@ # Declare SDL2 interface sources -if(NOT ${SRB2_CONFIG_HAVE_MIXERX}) - set(SRB2_CONFIG_SDL2_USEMIXER ON CACHE BOOL "Use SDL2_mixer or regular sdl sound") -else() - set(SRB2_CONFIG_SDL2_USEMIXER OFF) -endif() - -if(${SRB2_CONFIG_SDL2_USEMIXER}) - if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) - set(SDL2_MIXER_FOUND ON) - if(${SRB2_SYSTEM_BITS} EQUAL 64) - set(SDL2_MIXER_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/x86_64-w64-mingw32/include/SDL2) - set(SDL2_MIXER_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/x86_64-w64-mingw32/lib -lSDL2_mixer") - else() # 32-bit - set(SDL2_MIXER_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/i686-w64-mingw32/include/SDL2) - set(SDL2_MIXER_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/i686-w64-mingw32/lib -lSDL2_mixer") - endif() - else() - find_package(SDL2_mixer) - endif() - if(${SDL2_MIXER_FOUND}) - set(SRB2_HAVE_MIXER ON) - target_sources(SRB2SDL2 PRIVATE mixer_sound.c) - else() - message(WARNING "You specified that SDL2_mixer is available, but it was not found. Falling back to sdl sound.") - target_sources(SRB2SDL2 PRIVATE sdl_sound.c) - endif() -elseif(${MIXERX_FOUND}) - target_sources(SRB2SDL2 PRIVATE mixer_sound.c) -else() - target_sources(SRB2SDL2 PRIVATE sdl_sound.c) -endif() +target_sources(SRB2SDL2 PRIVATE mixer_sound.c) target_sourcefile(c) target_sources(SRB2SDL2 PRIVATE ogl_sdl.c) -if(${SRB2_CONFIG_HAVE_THREADS}) - target_sources(SRB2SDL2 PRIVATE i_threads.c) +target_sources(SRB2SDL2 PRIVATE i_threads.c) + +if(${SRB2_USEASM}) + set_source_files_properties(${SRB2_ASM_SOURCES} PROPERTIES LANGUAGE C) + set_source_files_properties(${SRB2_ASM_SOURCES} PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp") endif() -# Dependency -if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) - set(SDL2_FOUND ON) - if(${SRB2_SYSTEM_BITS} EQUAL 64) - set(SDL2_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/SDL2/x86_64-w64-mingw32/include/SDL2) - set(SDL2_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDL2/x86_64-w64-mingw32/lib -lSDL2") - else() # 32-bit - set(SDL2_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/SDL2/i686-w64-mingw32/include/SDL2) - set(SDL2_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDL2/i686-w64-mingw32/lib -lSDL2") - endif() +if("${CMAKE_SYSTEM_NAME}" MATCHES Windows) + target_sources(SRB2SDL2 PRIVATE + ../win32/win_dbg.c + ../win32/Srb2win.rc) +endif() + +if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin) + set(MACOSX_BUNDLE_ICON_FILE Srb2mac.icns) + set_source_files_properties(macosx/Srb2mac.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") + target_sources(SRB2SDL2 PRIVATE + macosx/mac_alert.c + macosx/mac_alert.h + macosx/mac_resources.c + macosx/mac_resources.h + macosx/Srb2mac.icns + ) +endif() + +if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin) + find_library(CORE_FOUNDATION_LIBRARY "CoreFoundation") + target_link_libraries(SRB2SDL2 PRIVATE + ${CORE_FOUNDATION_LIBRARY} + ) + + #target_link_libraries(SRB2SDL2 PRIVATE SRB2Core) + set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}") + + # Configure the app bundle icon and plist properties + target_sources(SRB2SDL2 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/macosx/Srb2mac.icns") + set_target_properties(SRB2SDL2 PROPERTIES + MACOSX_BUNDLE_ICON_FILE "Srb2mac" + MACOSX_BUNDLE_BUNDLE_NAME "Dr. Robotnik's Ring Racers" + MACOSX_BUNDLE_BUNDLE_VERSION ${SRB2_VERSION} + + RESOURCE "${CMAKE_CURRENT_SOURCE_DIR}/macosx/Srb2mac.icns" + ) +endif() + +if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}" AND NOT "${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}") + target_link_libraries(SRB2SDL2 PRIVATE SDL2::SDL2-static SDL2_mixer::SDL2_mixer-static) else() - find_package(SDL2) + target_link_libraries(SRB2SDL2 PRIVATE SDL2::SDL2 SDL2_mixer::SDL2_mixer) endif() -if(${SDL2_FOUND}) - if(${SRB2_USEASM}) - set_source_files_properties(${SRB2_ASM_SOURCES} PROPERTIES LANGUAGE C) - set_source_files_properties(${SRB2_ASM_SOURCES} PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp") - endif() +if("${CMAKE_SYSTEM_NAME}" MATCHES Linux) + target_link_libraries(SRB2SDL2 PRIVATE m rt) +endif() - if(${CMAKE_SYSTEM} MATCHES Windows) - target_sources(SRB2SDL2 PRIVATE - ../win32/win_dbg.c - ../win32/Srb2win.rc) - endif() - - if(${CMAKE_SYSTEM} MATCHES Darwin) - set(MACOSX_BUNDLE_ICON_FILE Srb2mac.icns) - set_source_files_properties(macosx/Srb2mac.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") - target_sources(SRB2SDL2 PRIVATE - macosx/mac_alert.c - macosx/mac_alert.h - macosx/mac_resources.c - macosx/mac_resources.h - macosx/Srb2mac.icns - ) - endif() - - if(${CMAKE_SYSTEM} MATCHES Windows) - set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2kart) - elseif(${CMAKE_SYSTEM} MATCHES Linux) - set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME lsdlsrb2kart) +if(${SRB2_USEASM}) + if(${SRB2_CONFIG_YASM}) + set(ASM_ASSEMBLER_TEMP ${CMAKE_ASM_YASM_COMPILER}) + set(ASM_ASSEMBLER_OBJFORMAT ${CMAKE_ASM_YASM_OBJECT_FORMAT}) + set_source_files_properties(${SRB2_NASM_SOURCES} LANGUAGE ASM_YASM) else() - set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2kart) + set(ASM_ASSEMBLER_TEMP ${CMAKE_ASM_NASM_COMPILER}) + set(ASM_ASSEMBLER_OBJFORMAT ${CMAKE_ASM_NASM_OBJECT_FORMAT}) + set_source_files_properties(${SRB2_NASM_SOURCES} LANGUAGE ASM_NASM) endif() +endif() - if(${CMAKE_SYSTEM} MATCHES Darwin) - find_library(CORE_LIB CoreFoundation) - target_link_libraries(SRB2SDL2 PRIVATE - ${CORE_LIB} - SDL2 - SDL2_mixer - ${GME_LIBRARIES} - ${OPENMPT_LIBRARIES} - ${MIXERX_LIBRARIES} - ${PNG_LIBRARIES} - ${ZLIB_LIBRARIES} - ${OPENGL_LIBRARIES} - ${CURL_LIBRARIES} - ${DISCORDRPC_LIBRARIES} - ) - set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}") - else() - target_link_libraries(SRB2SDL2 PRIVATE - ${SDL2_LIBRARIES} - ${SDL2_MIXER_LIBRARIES} - ${GME_LIBRARIES} - ${OPENMPT_LIBRARIES} - ${MIXERX_LIBRARIES} - ${PNG_LIBRARIES} - ${ZLIB_LIBRARIES} - ${OPENGL_LIBRARIES} - ${CURL_LIBRARIES} - ${DISCORDRPC_LIBRARIES} - ) +if("${CMAKE_SYSTEM_NAME}" MATCHES Windows) + target_link_libraries(SRB2SDL2 PRIVATE + ws2_32 + ) + target_compile_options(SRB2SDL2 PRIVATE + -U_WINDOWS + ) +endif() - if(${CMAKE_SYSTEM} MATCHES Linux) - target_link_libraries(SRB2SDL2 PRIVATE - m - rt +target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MIXER -DSOUND=SOUND_MIXER) +target_compile_definitions(SRB2SDL2 PRIVATE -DDIRECTFULLSCREEN -DHAVE_SDL) + +#### Installation #### +if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin) + install(TARGETS SRB2SDL2 + BUNDLE DESTINATION . + ) + set_property(TARGET SRB2SDL2 PROPERTY INSTALL_RPATH_USE_LINK_PATH ON) +else() + install(TARGETS SRB2SDL2 SRB2SDL2 + RUNTIME DESTINATION . + ) + if ((${CMAKE_BUILD_TYPE} MATCHES Debug) OR (${CMAKE_BUILD_TYPE} MATCHES RelWithDebInfo)) + set(SRB2_DEBUG_INSTALL OFF CACHE BOOL "Insert *.debug file into the install directory or package.") + if (${SRB2_DEBUG_INSTALL}) + install(FILES $.debug + DESTINATION . + OPTIONAL ) endif() endif() - - if(${CMAKE_SYSTEM} MATCHES Windows AND ${CMAKE_C_COMPILER_ID} MATCHES "GNU" AND ${SRB2_SYSTEM_BITS} EQUAL 32) - target_link_libraries(SRB2SDL2 PRIVATE - "${CMAKE_CURRENT_SOURCE_DIR}/../../libs/drmingw/lib/win32/libexchndl.a" - "${CMAKE_CURRENT_SOURCE_DIR}/../../libs/drmingw/lib/win32/libmgwhelp.a" - ) - target_include_directories(SRB2SDL2 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../libs/drmingw/include") - endif() - - #target_link_libraries(SRB2SDL2 PRIVATE SRB2Core) - - if(${SRB2_USEASM}) - if(${SRB2_CONFIG_YASM}) - set(ASM_ASSEMBLER_TEMP ${CMAKE_ASM_YASM_COMPILER}) - set(ASM_ASSEMBLER_OBJFORMAT ${CMAKE_ASM_YASM_OBJECT_FORMAT}) - set_source_files_properties(${SRB2_NASM_SOURCES} LANGUAGE ASM_YASM) - else() - set(ASM_ASSEMBLER_TEMP ${CMAKE_ASM_NASM_COMPILER}) - set(ASM_ASSEMBLER_OBJFORMAT ${CMAKE_ASM_NASM_OBJECT_FORMAT}) - set_source_files_properties(${SRB2_NASM_SOURCES} LANGUAGE ASM_NASM) - endif() - endif() - - set_target_properties(SRB2SDL2 PROPERTIES VERSION ${SRB2_VERSION}) - - if(${CMAKE_SYSTEM} MATCHES Windows) - target_link_libraries(SRB2SDL2 PRIVATE - ws2_32 - ) - target_compile_options(SRB2SDL2 PRIVATE - -U_WINDOWS - ) - endif() - - target_link_libraries(SRB2SDL2 PRIVATE acsvm acsvm-capi) - - target_include_directories(SRB2SDL2 PRIVATE - ${SDL2_INCLUDE_DIRS} - ${SDL2_MIXER_INCLUDE_DIRS} - ${GME_INCLUDE_DIRS} - ${OPENMPT_INCLUDE_DIRS} - ${MIXERX_INCLUDE_DIRS} - ${PNG_INCLUDE_DIRS} - ${ZLIB_INCLUDE_DIRS} - ${OPENGL_INCLUDE_DIRS} - ${CURL_INCLUDE_DIRS} - ${DISCORDRPC_INCLUDE_DIRS} - ) - - if((${SRB2_HAVE_MIXER}) OR (${SRB2_HAVE_MIXERX})) - target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MIXER -DSOUND=SOUND_MIXER) - endif() - - target_compile_definitions(SRB2SDL2 PRIVATE - -DDIRECTFULLSCREEN -DHAVE_SDL - -DHAVE_THREADS - ) - - #### Installation #### - if(${CMAKE_SYSTEM} MATCHES Darwin) - install(TARGETS SRB2SDL2 - BUNDLE DESTINATION . - ) - else() - install(TARGETS SRB2SDL2 SRB2SDL2 - RUNTIME DESTINATION . - ) - if ((${CMAKE_BUILD_TYPE} MATCHES Debug) OR (${CMAKE_BUILD_TYPE} MATCHES RelWithDebInfo)) - set(SRB2_DEBUG_INSTALL OFF CACHE BOOL "Insert *.debug file into the install directory or package.") - if (${SRB2_DEBUG_INSTALL}) - install(FILES $.debug - DESTINATION . - OPTIONAL - ) - endif() - endif() - endif() - - if(${CMAKE_SYSTEM} MATCHES Windows) - set(win_extra_dll_list "") - macro(getwinlib dllname defaultname) - if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) - if (${CMAKE_GENERATOR} STREQUAL "MinGW Makefiles") - if(${SRB2_SYSTEM_BITS} EQUAL 64) - find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}" - HINTS ${CMAKE_SOURCE_DIR}/libs/dll-binaries/x86_64 - HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/x86_64-w64-mingw32/bin - HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/x86_64-w64-mingw32/bin - HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86_64/mingw - HINTS ${CMAKE_SOURCE_DIR}/libs/SDLMixerX/x86_64-w64-mingw32/bin - ) - else() - find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}" - HINTS ${CMAKE_SOURCE_DIR}/libs/dll-binaries/i686 - HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/i686-w64-mingw32/bin - HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/i686-w64-mingw32/bin - HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86/mingw - HINTS ${CMAKE_SOURCE_DIR}/libs/SDLMixerX/i686-w64-mingw32/bin - ) - endif() - else() - if(${SRB2_SYSTEM_BITS} EQUAL 64) - find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}" - HINTS ${CMAKE_SOURCE_DIR}/libs/dll-binaries/x86_64 - HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/lib/x64 - HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/lib/x64 - HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86_64/mingw - HINTS ${CMAKE_SOURCE_DIR}/libs/SDLMixerX/x86_64-w64-mingw32/bin - ) - else() - find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}" - HINTS ${CMAKE_SOURCE_DIR}/libs/dll-binaries/i686 - HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/lib/x86 - HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/lib/x86 - HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86/mingw - HINTS ${CMAKE_SOURCE_DIR}/libs/SDLMixerX/i686-w64-mingw32/bin - ) - endif() - endif() - - list(APPEND win_extra_dll_list ${SRB2_SDL2_DLL_${dllname}}) - else() - find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}") - list(APPEND win_extra_dll_list ${SRB2_SDL2_DLL_${dllname}}) - endif() - endmacro() - getwinlib(SDL2 "SDL2.dll") - if(${SRB2_CONFIG_SDL2_USEMIXER}) - getwinlib(SDL2_mixer "SDL2_mixer.dll") - getwinlib(libogg_0 "libogg-0.dll") - getwinlib(libvorbis_0 "libvorbis-0.dll") - getwinlib(libvorbisfile_3 "libvorbisfile-3.dll") - endif() - if(${SRB2_CONFIG_HAVE_GME}) - getwinlib(libgme "libgme.dll") - endif() - if(${SRB2_CONFIG_HAVE_OPENMPT}) - getwinlib(libopenmpt "libopenmpt.dll") - endif() - if(${SRB2_CONFIG_HAVE_MIXERX}) - getwinlib(SDL2_mixer_ext "SDL2_mixer_ext.dll") - getwinlib(libfluidsynth-2 "libfluidsynth-2.dll") - getwinlib(libgcc_s_sjlj-1 "libgcc_s_sjlj-1.dll") - getwinlib(libstdc++-6 "libstdc++-6.dll") - endif() - - if(${SRB2_CONFIG_HAVE_DISCORDRPC}) - getwinlib(discord-rpc "discord-rpc.dll") - endif() - - install(PROGRAMS - ${win_extra_dll_list} - DESTINATION . - ) - - # We also want to copy those DLLs to build directories on MSVC. - # So we'll add a post_build step. - copy_files_to_build_dir(SRB2SDL2 win_extra_dll_list) - endif() - - - # Mac bundle fixup - # HACK: THIS IS IMPORTANT! See the escaped \${CMAKE_INSTALL_PREFIX}? This - # makes it so that var is evaluated LATER during cpack, not right now! - # This fixes the quirk where the bundled libraries don't land in the final package - # https://cmake.org/pipermail/cmake/2011-March/043532.html - # - # HOWEVER: ${CPACK_PACKAGE_DESCRIPTION_SUMMARY} is NOT escaped, because that var - # is only available to us at this step. Read the link: ${CMAKE_INSTALL_PREFIX} at - # this current step points to the CMAKE build folder, NOT the folder that CPACK uses. - # Therefore, it makes sense to escape that var, but not the other. - if(${CMAKE_SYSTEM} MATCHES Darwin) - install(CODE " - include(BundleUtilities) - fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${CPACK_PACKAGE_DESCRIPTION_SUMMARY}.app\" - \"\" - /Library/Frameworks - )" - ) - endif() - - set(SRB2_SDL2_AVAILABLE YES PARENT_SCOPE) -else() - message(WARNING "SDL2 was not found, so the SDL2 target will not be available.") - set(SRB2_SDL2_AVAILABLE NO PARENT_SCOPE) endif() + +# Mac bundle fixup +# HACK: THIS IS IMPORTANT! See the escaped \${CMAKE_INSTALL_PREFIX}? This +# makes it so that var is evaluated LATER during cpack, not right now! +# This fixes the quirk where the bundled libraries don't land in the final package +# https://cmake.org/pipermail/cmake/2011-March/043532.html +# +# HOWEVER: ${CPACK_PACKAGE_DESCRIPTION_SUMMARY} is NOT escaped, because that var +# is only available to us at this step. Read the link: ${CMAKE_INSTALL_PREFIX} at +# this current step points to the CMAKE build folder, NOT the folder that CPACK uses. +# Therefore, it makes sense to escape that var, but not the other. +if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin) + install(CODE " + include(BundleUtilities) + fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${CPACK_PACKAGE_DESCRIPTION_SUMMARY}.app\" + \"\" + /Library/Frameworks + )" + ) +endif() + +set(SRB2_SDL2_AVAILABLE YES PARENT_SCOPE) diff --git a/src/sdl/i_main.c b/src/sdl/i_main.c index eaaad76fa..b171b30e8 100644 --- a/src/sdl/i_main.c +++ b/src/sdl/i_main.c @@ -66,7 +66,7 @@ char logfilename[1024]; #endif #if defined (_WIN32) -#include "exchndl.h" +#include #endif #if defined (_WIN32) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index e03bf6993..ef059d90c 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2466,18 +2466,6 @@ static const char *locateWad(void) } #endif - -#ifdef CMAKECONFIG -#ifndef NDEBUG - I_OutputMsg(","CMAKE_ASSETS_DIR); - strcpy(returnWadPath, CMAKE_ASSETS_DIR); - if (isWadPathOk(returnWadPath)) - { - return returnWadPath; - } -#endif -#endif - #ifdef __APPLE__ OSX_GetResourcesPath(returnWadPath); I_OutputMsg(",%s", returnWadPath); diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 46fc20416..43a771df1 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -80,7 +80,7 @@ write netcode into the sound code, OKAY? #endif #ifdef HAVE_GME -#include "gme/gme.h" +#include #define GME_TREBLE 5.0f #define GME_BASS 1.0f #endif // HAVE_GME diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index 5e088073f..8c1e79352 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -94,7 +94,6 @@ boolean LoadGL(void) CONS_Printf("If you know what is the OpenGL library's name, use -OGLlib\n"); return 0; } - #endif return SetupGLfunc(); } @@ -152,6 +151,12 @@ boolean OglSdlSurface(INT32 w, INT32 h) else supportMipMap = false; + if (sscanf((const char*)gl_version, "%d.%d", &majorGL, &minorGL) + && (!(majorGL == 1 && minorGL <= 3))) + supportMipMap = true; + else + supportMipMap = false; + SetupGLFunc4(); glanisotropicmode_cons_t[1].value = maximumAnisotropy; diff --git a/src/sounds.c b/src/sounds.c index bd8d66856..bf89f3a9d 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -1091,7 +1091,6 @@ sfxinfo_t S_sfx[NUMSFX] = {"gemhit", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "/"}, // Opulence gem/coin tumbling {"bhurry", false, 255, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Hurry up!"}, // v1.0.2 Battle overtime {"bsnipe", false, 96, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Sniped"}, // Banana sniping - {"sploss", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // Down to yellow sparks {"join", false, 96, 8, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // Player joined server {"leave", false, 96, 8, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // Player left server {"requst", false, 96, 8, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // Got a Discord join request @@ -1107,11 +1106,6 @@ sfxinfo_t S_sfx[NUMSFX] = {"kdtrg2", false, 64, 16, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // Medium energy, SF_X8AWAYSOUND {"kdtrg3", false, 64, 80, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // High energy, SF_X2AWAYSOUND|SF_X8AWAYSOUND - // SRB2kart - Grow/invinc clash - {"parry", false, 64, 16, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // SF_X8AWAYSOUND - - {"ffbonc", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, - // Shout message sound effect {"sysmsg", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Server notification"}, diff --git a/src/sounds.h b/src/sounds.h index 64985a7f8..c1cf9fdcb 100644 --- a/src/sounds.h +++ b/src/sounds.h @@ -62,9 +62,8 @@ typedef enum // // SoundFX struct. // -typedef struct sfxinfo_struct sfxinfo_t; -struct sfxinfo_struct +struct sfxinfo_t { // up to 6-character name const char *name; @@ -1155,7 +1154,6 @@ typedef enum sfx_gemhit, sfx_bhurry, sfx_bsnipe, - sfx_sploss, sfx_join, sfx_leave, sfx_requst, @@ -1171,12 +1169,6 @@ typedef enum sfx_kdtrg2, sfx_kdtrg3, - // SRB2Kart - Powerup clash SFX - sfx_parry, - - // Fast fall bounce - sfx_ffbonc, - // Shout message sound effect sfx_sysmsg, diff --git a/src/st_stuff.c b/src/st_stuff.c index 5542c8e6a..d7b7f4cb2 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -487,57 +487,6 @@ static void ST_drawDebugInfo(void) tic_t lt_ticker = 0, lt_lasttic = 0; tic_t lt_exitticker = 0, lt_endtime = 0; -// SRB2KART: HUD shit for new titlecards: -static patch_t *tcchev1; -static patch_t *tcchev2; - -static patch_t *tcol1; -static patch_t *tcol2; - -static patch_t *tcroundbar; -static patch_t *tcround; -static patch_t *tcbonus; - -static patch_t *tccircletop; -static patch_t *tccirclebottom; -static patch_t *tccirclebg; - -static patch_t *tcbanner; -static patch_t *tcbanner2; - -static patch_t *tcroundnum[10]; -static patch_t *tcroundbonus; - -static patch_t *tcactnum[10]; -static patch_t *tcact; - -static patch_t *twarn; -static patch_t *twarn2; - -// some coordinates define to make my life easier.... -#define FINAL_ROUNDX (24) -#define FINAL_EGGY (160) -#define FINAL_ROUNDY (16) -#define FINAL_BANNERY (160) - -INT32 chev1x, chev1y, chev2x, chev2y, chevtflag; -INT32 roundx, roundy; -INT32 bannerx, bannery; - -INT32 roundnumx, roundnumy; -INT32 eggx1, eggx2, eggy1, eggy2; - -// These are all arbitrary values found by trial and error trying to align the hud lmao. -// But they'll work. -#define BASE_CHEV1X (252) -#define BASE_CHEV1Y (60) -#define BASE_CHEV2X (65) -#define BASE_CHEV2Y (135) - -#define TTANIMTHRESHOLD (TICRATE) -#define TTANIMSTART (TTANIMTHRESHOLD-16) -#define TTANIMENDTHRESHOLD (TICRATE*3) -#define TTANIMEND (TICRATE*4) // // Load the graphics for the title card. @@ -548,44 +497,6 @@ static void ST_cacheLevelTitle(void) UINT8 i; char buf[9]; - // SRB2KART - tcchev1 = (patch_t *)W_CachePatchName("TCCHEV1W", PU_HUDGFX); - tcchev2 = (patch_t *)W_CachePatchName("TCCHEV2W", PU_HUDGFX); - - tcol1 = (patch_t *)W_CachePatchName("TCCHOL1", PU_HUDGFX); - tcol2 = (patch_t *)W_CachePatchName("TCCHOL2", PU_HUDGFX); - - tcroundbar = (patch_t *)W_CachePatchName("TCBB0", PU_HUDGFX); - tcround = (patch_t *)W_CachePatchName("TCROUND", PU_HUDGFX); - tcbonus = (patch_t *)W_CachePatchName("TCBONUS", PU_HUDGFX); - - tccircletop = (patch_t *)W_CachePatchName("TCSN1", PU_HUDGFX); - tccirclebottom =(patch_t *)W_CachePatchName("TCSN2", PU_HUDGFX); - tccirclebg = (patch_t *)W_CachePatchName("TCEG3", PU_HUDGFX); - - tcbanner = (patch_t *)W_CachePatchName("TCBSKA0", PU_HUDGFX); - tcbanner2 = (patch_t *)W_CachePatchName("TCBC0", PU_HUDGFX); - - tcact = (patch_t *)W_CachePatchName("TT_ACT", PU_HUDGFX); - - twarn = (patch_t *)W_CachePatchName("K_BOSW01", PU_HUDGFX); - twarn2 = (patch_t *)W_CachePatchName("K_BOSW02", PU_HUDGFX); - - // Cache round # - for (i=1; i < 11; i++) - { - sprintf(buf, "TT_RND%d", i); - tcroundnum[i-1] = (patch_t *)W_CachePatchName(buf, PU_HUDGFX); - } - tcroundbonus = (patch_t *)W_CachePatchName("TT_RNDB", PU_HUDGFX); - - // Cache act # - for (i=0; i < 10; i++) - { - sprintf(buf, "TT_ACT%d", i); - tcactnum[i] = (patch_t *)W_CachePatchName(buf, PU_HUDGFX); - } - } // @@ -594,26 +505,7 @@ static void ST_cacheLevelTitle(void) void ST_startTitleCard(void) { // cache every HUD patch used - ST_cacheLevelTitle(); - - // Set most elements to start off-screen, ST_runTitleCard will have them slide in afterwards - chev1x = BASE_CHEV1X +350; // start off-screen - chev1y = BASE_CHEV1Y; - chev2x = BASE_CHEV2X -350; // start off-screen - chev2y = BASE_CHEV2Y; - chevtflag = 0; - - roundx = -999; - roundy = -999; - - roundnumx = -999; - roundnumy = -999; - eggx1 = -999; - eggx2 = -999; - eggy1 = -999; - eggy2 = -999; - - bannery = 300; + ST_cacheLevelTitle(); // Nothing // initialize HUD variables lt_ticker = lt_exitticker = lt_lasttic = 0; @@ -642,7 +534,6 @@ void ST_preDrawTitleCard(void) void ST_runTitleCard(void) { boolean run = !(paused || P_AutoPause()); - INT32 auxticker; boolean gp = (marathonmode || (grandprixinfo.gp && grandprixinfo.roundnum)); if (!G_IsTitleCardAvailable()) @@ -656,163 +547,6 @@ void ST_runTitleCard(void) // tick lt_ticker++; - // SRB2KART - // side Zig-Zag positions... - if (bossinfo.boss == true) - { - // Handle name info... - if (bossinfo.enemyname) - { - UINT32 len = strlen(bossinfo.enemyname)+1; - if (len > 1 && bossinfo.titleshow < len) - { - len = (lt_endtime-(TICRATE/2))/len; - if (lt_ticker % len == 0) - { - char c = toupper(bossinfo.enemyname[bossinfo.titleshow]); - bossinfo.titleshow++; - c -= LT_FONTSTART; - if (c < 0 || c >= LT_FONTSIZE || !fontv[GTFN_FONT].font[(INT32)c] || !bossinfo.titlesound) - { - ; - } - else - { - S_StartSound(NULL, bossinfo.titlesound); - } - } - } - } - // No matter the circumstances, scroll the WARN... - bannerx = -((lt_ticker*2)%((encoremode ? twarn2 : twarn)->width)); - } - else - { - // TITLECARD START - if (lt_ticker < TTANIMSTART) - { - chev1x = max(BASE_CHEV1X, (BASE_CHEV1X +350) - (INT32)(lt_ticker)*50); - chev2x = min(BASE_CHEV2X, (BASE_CHEV2X -350) + (INT32)(lt_ticker)*50); - } - - // OPEN ZIG-ZAGS 1 SECOND IN - if (lt_ticker > TTANIMTHRESHOLD) - { - auxticker = (INT32)(lt_ticker) - TTANIMTHRESHOLD; - - chev1x = min(320, BASE_CHEV1X + auxticker*16); - chev1y = max(0, BASE_CHEV1Y - auxticker*16); - - chev2x = max(0, BASE_CHEV2X - auxticker*16); - chev2y = min(200, BASE_CHEV2Y + auxticker*16); - - // translucent fade after opening up. - chevtflag = min(5, ((auxticker)/5)) << V_ALPHASHIFT; - - - // OPEN ZIG-ZAG: END OF ANIMATION (they leave the screen borders) - if (lt_ticker > TTANIMENDTHRESHOLD) - { - auxticker = (INT32)lt_ticker - TTANIMENDTHRESHOLD; - - chev1x += auxticker*16; - chev1y -= auxticker*16; - - chev2x -= auxticker*16; - chev2y += auxticker*16; - } - } - - // ROUND BAR + EGG - - eggy1 = FINAL_EGGY; // Make sure to reset that each call so that Y position doesn't go bonkers - - // SLIDE BAR IN, SLIDE "ROUND" DOWNWARDS - if (lt_ticker <= TTANIMTHRESHOLD) - { - INT32 interptimer = (INT32)lt_ticker - TTANIMSTART; - // INT32 because tic_t is unsigned and we want this to be potentially negative - - if (interptimer >= 0) - { - INT32 interpdiff = ((TTANIMTHRESHOLD-TTANIMSTART) - interptimer); - interpdiff *= interpdiff; // interpdiff^2 - - roundx = FINAL_ROUNDX - interpdiff; - roundy = FINAL_ROUNDY - interpdiff; - eggy1 = FINAL_EGGY + interpdiff; - - } - } - // SLIDE BAR OUT, SLIDE "ROUND" DOWNWARDS FASTER - else if (lt_ticker >= TTANIMENDTHRESHOLD) - { - auxticker = (INT32)lt_ticker - TTANIMENDTHRESHOLD; - - roundx = FINAL_ROUNDX - auxticker*24; - roundy = FINAL_ROUNDY + auxticker*48; - eggy1 = FINAL_EGGY + auxticker*48; - } - - // follow the round bar. - eggx1 = roundx + tcroundbar->width/2; - - // initially, both halves are on the same coordinates. - eggx2 = eggx1; - eggy2 = eggy1; - // same for the background (duh) - roundnumx = eggx1; - roundnumy = eggy1; - - // split both halves of the egg, but only do that in grand prix! - if (gp && lt_ticker > TTANIMTHRESHOLD + TICRATE/2) - { - auxticker = (INT32)lt_ticker - (TTANIMTHRESHOLD + TICRATE/2); - - eggx1 -= auxticker*12; - eggy1 -= auxticker*12; - - eggx2 += auxticker*12; - eggy2 += auxticker*12; - - } - - - // SCROLLING BOTTOM BANNER - - // SLIDE BANNER UPWARDS WITH A FUNNY BOUNCE (this requires trig :death:) - if (lt_ticker < TTANIMTHRESHOLD) - { - INT32 costimer = (INT32)lt_ticker - TTANIMSTART; - // INT32 because tic_t is unsigned and we want this to be potentially negative - - if (costimer > 0) - { - // For this animation, we're going to do a tiny bit of stupid trigonometry. - // Admittedly all of this is going to look like magic numbers, and honestly? They are. - - // start at angle 355 (where y = ~230 with our params) - // and go to angle 131 (where y = ~160 with our params) - - UINT8 basey = 190; - UINT8 amplitude = 45; - fixed_t ang = (355 - costimer*14)*FRACUNIT; - - bannery = basey + (amplitude * FINECOSINE(FixedAngle(ang)>>ANGLETOFINESHIFT)) / FRACUNIT; - } - } - // SLIDE BANNER DOWNWARDS OUT OF THE SCREEN AT THE END - else if (lt_ticker >= TTANIMENDTHRESHOLD) - { - auxticker = (INT32)lt_ticker - TTANIMENDTHRESHOLD; - bannery = FINAL_BANNERY + auxticker*16; - } - - // No matter the circumstances, scroll the banner... - bannerx = -((lt_ticker*2)%(tcbanner->width)); - } - - // used for hud slidein if (lt_ticker >= lt_endtime) lt_exitticker++; @@ -886,8 +620,6 @@ void ST_drawTitleCard(void) if (subttl[0]) V_DrawRightAlignedString(sub + zonexpos - 8, bary+1, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, subttl); - //else - //V_DrawRightAlignedString(sub + zonexpos - 8, bary+1, V_ALLOWLOWERCASE, va("%s Mode", gametype_cons_t[gametype].strvalue)); } ttlnumxpos += sub; @@ -913,21 +645,6 @@ luahook: LUA_HUD_DrawList(luahuddrawlist_titlecard); } -// Clear defined coordinates, we don't need them anymore -#undef FINAL_ROUNDX -#undef FINAL_EGGY -#undef FINAL_ROUNDY -#undef FINAL_BANNERY - -#undef BASE_CHEV1X -#undef BASE_CHEV1Y -#undef BASE_CHEV2X -#undef BASE_CHEV2Y - -#undef TTANIMTHRESHOLD -#undef TTANIMSTART -#undef TTANIMENDTHRESHOLD -#undef TTANIMEND // // Drawer for G_PreLevelTitleCard. @@ -1112,7 +829,6 @@ void ST_Drawer(void) if (rendermode != render_none) ST_doPaletteStuff(); { -//#if 0 const tic_t length = TICRATE/2; if (lt_exitticker) @@ -1123,9 +839,6 @@ void ST_Drawer(void) } else st_translucency = 0; -//#else -// st_translucency = cv_translucenthud.value; -//#endif } // Check for a valid level title diff --git a/src/taglist.h b/src/taglist.h index a66312425..8db78b880 100644 --- a/src/taglist.h +++ b/src/taglist.h @@ -21,11 +21,11 @@ typedef INT16 mtag_t; #define MTAG_GLOBAL -1 /// Multitag list. Each taggable element will have its own taglist. -typedef struct +struct taglist_t { mtag_t* tags; UINT16 count; -} taglist_t; +}; void Tag_Add (taglist_t* list, const mtag_t tag); void Tag_Remove (taglist_t* list, const mtag_t tag); @@ -40,12 +40,12 @@ void Tag_SectorRemove (const size_t id, const mtag_t tag); void Tag_SectorFSet (const size_t id, const mtag_t tag); /// Taggroup list. It is essentially just an element id list. -typedef struct +struct taggroup_t { size_t *elements; size_t count; size_t capacity; -} taggroup_t; +}; extern bitarray_t tags_available[]; diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt new file mode 100644 index 000000000..28c4ce492 --- /dev/null +++ b/src/tests/CMakeLists.txt @@ -0,0 +1,3 @@ +target_sources(srb2tests PRIVATE + boolcompat.cpp +) diff --git a/src/tests/boolcompat.cpp b/src/tests/boolcompat.cpp new file mode 100644 index 000000000..fee40cd36 --- /dev/null +++ b/src/tests/boolcompat.cpp @@ -0,0 +1,8 @@ +#include + +#include "../doomtype.h" + +TEST_CASE("C++ bool is convertible to doomtype.h boolean") { + REQUIRE(static_cast(true) == 1); + REQUIRE(static_cast(false) == 0); +} diff --git a/src/typedef.h b/src/typedef.h new file mode 100644 index 000000000..2237c0f1b --- /dev/null +++ b/src/typedef.h @@ -0,0 +1,398 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 2022 by Kart Krew. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file typedef.h +/// \brief Universally accessible type definitions. This +/// file exists so these types can be used anywhere +/// without needing to include specific headers. + +#define TYPEDEF2(struct_id, new_type) \ + typedef struct struct_id new_type + +#define TYPEDEF(id) TYPEDEF2 (id, id) + +// am_map.h +TYPEDEF (fpoint_t); +TYPEDEF (fline_t); + +// command.h +TYPEDEF (vsbuf_t); +TYPEDEF (CV_PossibleValue_t); +TYPEDEF (consvar_t); + +// d_netcmd.h +TYPEDEF (changeteam_packet_t); +TYPEDEF (changeteam_value_t); +TYPEDEF (scheduleTask_t); + +// discord.h +TYPEDEF (discordRequest_t); + +// d_player.h +TYPEDEF (botvars_t); +TYPEDEF (player_t); +TYPEDEF (sonicloopcamvars_t); +TYPEDEF (sonicloopvars_t); + +// d_clisrv.h +TYPEDEF (clientcmd_pak); +TYPEDEF (client2cmd_pak); +TYPEDEF (client3cmd_pak); +TYPEDEF (client4cmd_pak); +TYPEDEF (servertics_pak); +TYPEDEF (serverconfig_pak); +TYPEDEF (filetx_pak); +TYPEDEF (fileacksegment_t); +TYPEDEF (fileack_pak); +TYPEDEF (clientconfig_pak); +TYPEDEF (serverinfo_pak); +TYPEDEF (serverrefuse_pak); +TYPEDEF (askinfo_pak); +TYPEDEF (msaskinfo_pak); +TYPEDEF (plrinfo); +TYPEDEF (plrconfig); +TYPEDEF (filesneededconfig_pak); +TYPEDEF (doomdata_t); +TYPEDEF (serverelem_t); +TYPEDEF (rewind_t); + +// d_event.h +TYPEDEF (event_t); + +// d_netfil.h +TYPEDEF (fileneeded_t); +TYPEDEF (HTTP_login); +TYPEDEF (luafiletransfer_t); + +// d_think.h +TYPEDEF (thinker_t); + +// d_ticcmd.h +TYPEDEF (ticcmd_t); + +// deh_tables.h +TYPEDEF (actionpointer_t); + +// dehacked.h +TYPEDEF (MYFILE); + +// domdata.h +TYPEDEF (mapvertex_t); +TYPEDEF (mapsidedef_t); +TYPEDEF (maplinedef_t); +TYPEDEF (mapsector_t); +TYPEDEF (mapsubsector_t); +TYPEDEF (mapseg_t); +TYPEDEF (mapnode_t); +TYPEDEF (mapthing_t); + +// doomdef.h +TYPEDEF (skincolor_t); + +// doomstat.h +TYPEDEF (precipprops_t); +TYPEDEF (recorddata_t); +TYPEDEF (scene_t); +TYPEDEF (cutscene_t); +TYPEDEF (textpage_t); +TYPEDEF (textprompt_t); +TYPEDEF (mappoint_t); +TYPEDEF (customoption_t); +TYPEDEF (mapheader_t); +TYPEDEF (tolinfo_t); +TYPEDEF (cupheader_t); +TYPEDEF (mapheader_lighting_t); + +// font.h +TYPEDEF (font_t); + +// g_demo.h +TYPEDEF (democharlist_t); +TYPEDEF (menudemo_t); +TYPEDEF (demoghost); + +// g_game.h +TYPEDEF (mapsearchfreq_t); + +// hu_stuff.h +TYPEDEF (playersort_t); + +// i_joy.h +TYPEDEF (JoyType_t); + +// i_net.h +TYPEDEF (doomcom_t); +TYPEDEF (holepunch_t); +TYPEDEF (bannednode_t); + +// i_system.h +TYPEDEF (JoyFF_t); +TYPEDEF (CPUInfoFlags); + +// i_time.h +TYPEDEF (timestate_t); + +// info.h +TYPEDEF (state_t); +TYPEDEF (mobjinfo_t); + +// k_bheap.h +TYPEDEF (bheapitem_t); +TYPEDEF (bheap_t); + +// k_boss.h +TYPEDEF (weakspot_t); + +// k_bot.h +TYPEDEF (botprediction_t); + +// k_brightmap.h +TYPEDEF (brightmapStorage_t); + +// k_follower.h +TYPEDEF (follower_t); +TYPEDEF (followercategory_t); + +// k_hud.h +TYPEDEF (trackingResult_t); + +// k_menu.h +TYPEDEF (menucolor_t); +TYPEDEF (menuitem_t); +TYPEDEF (menu_t); +TYPEDEF (menucmd_t); +TYPEDEF (setup_player_t); +TYPEDEF (modedesc_t); + +// k_pathfind.h +TYPEDEF (pathfindnode_t); +TYPEDEF (path_t); +TYPEDEF (pathfindsetup_t); + +// k_profiles.h +TYPEDEF (profile_t); + +// k_terrain.h +TYPEDEF (t_splash_t); +TYPEDEF (t_footstep_t); +TYPEDEF (t_overlay_t); +TYPEDEF (terrain_t); +TYPEDEF (t_floor_t); + +// k_waypoint.h +TYPEDEF (waypoint_t); + +// lua_hudlib_drawlist.h +typedef struct huddrawlist_s *huddrawlist_h; + +// m_aatree.h +TYPEDEF (aatree_t); + +// m_cond.h +TYPEDEF (condition_t); +TYPEDEF (conditionset_t); +TYPEDEF (emblem_t); +TYPEDEF (extraemblem_t); +TYPEDEF (unlockable_t); + +// m_dllist.h +TYPEDEF (mdllistitem_t); + +// m_fixed.h +TYPEDEF (vector2_t); +TYPEDEF (vector3_t); +TYPEDEF (matrix_t); + +// m_perfstats.h +TYPEDEF (ps_hookinfo_t); +TYPEDEF (ps_botinfo_t); + +// m_queue.h +TYPEDEF (mqueueitem_t); +TYPEDEF (mqueue_t); + +// mserv.h +TYPEDEF (msg_server_t); +TYPEDEF (msg_ban_t); + +// p_local.h +TYPEDEF (camera_t); +TYPEDEF (jingle_t); +TYPEDEF (tm_t); +TYPEDEF (TryMoveResult_t); +TYPEDEF (BasicFF_t); + +// p_maputl.h +TYPEDEF (divline_t); +TYPEDEF (intercept_t); + +// p_mobj.h +TYPEDEF (mobj_t); +TYPEDEF (precipmobj_t); +TYPEDEF (actioncache_t); + +// p_polyobj.h +TYPEDEF (polyobj_t); +TYPEDEF (polymaplink_t); +TYPEDEF (polyrotate_t); +TYPEDEF (polymove_t); +TYPEDEF (polywaypoint_t); +TYPEDEF (polyslidedoor_t); +TYPEDEF (polyswingdoor_t); +TYPEDEF (polydisplace_t); +TYPEDEF (polyrotdisplace_t); +TYPEDEF (polyfade_t); +TYPEDEF (polyrotdata_t); +TYPEDEF (polymovedata_t); +TYPEDEF (polywaypointdata_t); +TYPEDEF (polydoordata_t); +TYPEDEF (polydisplacedata_t); +TYPEDEF (polyrotdisplacedata_t); +TYPEDEF (polyflagdata_t); +TYPEDEF (polyfadedata_t); + +// p_saveg.h +TYPEDEF (savedata_t); + +// p_setup.h +TYPEDEF (levelflat_t); + +// p_slopes.h +TYPEDEF (dynlineplanethink_t); +TYPEDEF (dynvertexplanethink_t); + +// p_spec.h +TYPEDEF (thinkerdata_t); +TYPEDEF (fireflicker_t); +TYPEDEF (lightflash_t); +TYPEDEF (laserthink_t); +TYPEDEF (strobe_t); +TYPEDEF (glow_t); +TYPEDEF (lightlevel_t); +TYPEDEF (ceiling_t); +TYPEDEF (floormove_t); +TYPEDEF (elevator_t); +TYPEDEF (crumble_t); +TYPEDEF (noenemies_t); +TYPEDEF (continuousfall_t); +TYPEDEF (bouncecheese_t); +TYPEDEF (mariothink_t); +TYPEDEF (mariocheck_t); +TYPEDEF (thwomp_t); +TYPEDEF (floatthink_t); +TYPEDEF (eachtime_t); +TYPEDEF (raise_t); +TYPEDEF (executor_t); +TYPEDEF (scroll_t); +TYPEDEF (friction_t); +TYPEDEF (pusher_t); +TYPEDEF (disappear_t); +TYPEDEF (fade_t); +TYPEDEF (fadecolormap_t); +TYPEDEF (planedisplace_t); + +// r_data.h +TYPEDEF (lumplist_t); + +// r_defs.h +TYPEDEF (cliprange_t); +TYPEDEF (vertex_t); +TYPEDEF (degenmobj_t); +TYPEDEF (light_t); +TYPEDEF (node_t); +TYPEDEF (post_t); +TYPEDEF (drawseg_t); +TYPEDEF (rotsprite_t); +TYPEDEF (patch_t); +TYPEDEF (softwarepatch_t); +TYPEDEF (pic_t); +TYPEDEF (spriteframe_t); +TYPEDEF (spritedef_t); +TYPEDEF (extracolormap_t); +TYPEDEF (ffloor_t); +TYPEDEF (lightlist_t); +TYPEDEF (r_lightlist_t); +TYPEDEF (pslope_t); +TYPEDEF (sector_t); +TYPEDEF (line_t); +TYPEDEF (side_t); +TYPEDEF (subsector_t); +TYPEDEF (msecnode_t); +TYPEDEF (mprecipsecnode_t); +TYPEDEF (lightmap_t); +TYPEDEF (seg_t); + +// r_draw.h +TYPEDEF (floatv3_t); + +// r_fps.h +TYPEDEF (viewvars_t); +TYPEDEF (interpmobjstate_t); +TYPEDEF (levelinterpolator_t); + +// r_picformats.h +TYPEDEF (spriteframepivot_t); +TYPEDEF (spriteinfo_t); + +// r_plane.h +TYPEDEF (visplane_t); +TYPEDEF (visffloor_t); + +// r_portal.h +TYPEDEF (portal_t); + +// r_skins.h +TYPEDEF (skin_t); + +// r_splats.h +TYPEDEF (floorsplat_t); + +// r_state.h +TYPEDEF (sprcache_t); + +// r_textures.h +TYPEDEF (texpatch_t); +TYPEDEF (texture_t); + +// r_things.h +TYPEDEF (maskcount_t); +TYPEDEF (vissprite_t); +TYPEDEF (drawnode_t); + +// s_sound.h +TYPEDEF (listener_t); +TYPEDEF (channel_t); +TYPEDEF (caption_t); +TYPEDEF (musicdef_t); +TYPEDEF (musicstack_t); + +// screen.h +TYPEDEF (viddef_t); +TYPEDEF (vesa_extra_t); +TYPEDEF (vmode_t); + +// sounds.h +TYPEDEF (sfxinfo_t); + +// taglist.h +TYPEDEF (taglist_t); +TYPEDEF (taggroup_t); + +// v_video.h +TYPEDEF (colorlookup_t); + +// w_wad.h +TYPEDEF (filelump_t); +TYPEDEF (wadinfo_t); +TYPEDEF (lumpinfo_t); +TYPEDEF (virtlump_t); +TYPEDEF (virtres_t); +TYPEDEF (wadfile_t); + +#undef TYPEDEF +#undef TYPEDEF2 diff --git a/src/v_video.h b/src/v_video.h index 938837249..36bfd8917 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -45,12 +45,12 @@ void V_Recalc(void); // Color look-up table #define CLUTINDEX(r, g, b) (((r) >> 3) << 11) | (((g) >> 2) << 5) | ((b) >> 3) -typedef struct +struct colorlookup_t { boolean init; RGBA_t palette[256]; UINT16 table[0xFFFF]; -} colorlookup_t; +}; void InitColorLUT(colorlookup_t *lut, RGBA_t *palette, boolean makecolors); UINT8 GetColorLUT(colorlookup_t *lut, UINT8 r, UINT8 g, UINT8 b); diff --git a/src/w_wad.h b/src/w_wad.h index 55e3e0072..e3f442d50 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -27,12 +27,12 @@ #if defined(_MSC_VER) #pragma pack(1) #endif -typedef struct +struct filelump_t { UINT32 filepos; // file offset of the resource UINT32 size; // size of the resource char name[8]; // name of the resource -} ATTRPACK filelump_t; +} ATTRPACK; #if defined(_MSC_VER) #pragma pack() #endif @@ -43,12 +43,12 @@ typedef struct // ============================================================== // header of a wad file -typedef struct +struct wadinfo_t { char identification[4]; // should be "IWAD" or "PWAD" UINT32 numlumps; // how many resources UINT32 infotableofs; // the 'directory' of resources -} wadinfo_t; +}; // Available compression methods for lumps. typedef enum @@ -62,7 +62,7 @@ typedef enum } compmethod; // a memory entry of the wad directory -typedef struct +struct lumpinfo_t { unsigned long position; // filelump_t filepos unsigned long disksize; // filelump_t size @@ -72,22 +72,22 @@ typedef struct char *fullname; // e.g. "Folder/Subfolder/LongEntryName.extension" size_t size; // real (uncompressed) size compmethod compression; // lump compression method -} lumpinfo_t; +}; // ========================================================================= // 'VIRTUAL' RESOURCES // ========================================================================= -typedef struct { +struct virtlump_t { char name[9]; UINT8* data; size_t size; -} virtlump_t; +}; -typedef struct { +struct virtres_t { size_t numlumps; virtlump_t* vlumps; -} virtres_t; +}; virtres_t* vres_GetMap(lumpnum_t); void vres_Free(virtres_t*); @@ -114,7 +114,7 @@ typedef enum restype RET_UNKNOWN, } restype_t; -typedef struct wadfile_s +struct wadfile_t { char *filename; restype_t type; @@ -127,7 +127,7 @@ typedef struct wadfile_s UINT8 md5sum[16]; boolean important; // also network - !W_VerifyNMUSlumps -} wadfile_t; +}; #define WADFILENUM(lumpnum) (UINT16)((lumpnum)>>16) // wad flumpnum>>16) // wad file number in upper word #define LUMPNUM(lumpnum) (UINT16)((lumpnum)&0xFFFF) // lump number for this pwad diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt new file mode 100644 index 000000000..8e9793ee7 --- /dev/null +++ b/thirdparty/CMakeLists.txt @@ -0,0 +1,542 @@ +macro(export) +endmacro() + +if(SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES) + set(SRB2_INTERNAL_LIBRARY_TYPE SHARED) + set(NOT_SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES OFF) +else() + set(SRB2_INTERNAL_LIBRARY_TYPE STATIC) + set(NOT_SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES ON) +endif() + + +if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}") + CPMAddPackage( + NAME SDL2 + VERSION 2.24.2 + URL "https://github.com/libsdl-org/SDL/archive/refs/tags/release-2.24.2.zip" + EXCLUDE_FROM_ALL ON + OPTIONS + "BUILD_SHARED_LIBS ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}" + "SDL_SHARED ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}" + "SDL_STATIC ${NOT_SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}" + "SDL_TEST OFF" + "SDL2_DISABLE_SDL2MAIN ON" + "SDL2_DISABLE_INSTALL ON" + ) +endif() + +if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}") + CPMAddPackage( + NAME SDL2_mixer + VERSION 2.6.2 + URL "https://github.com/libsdl-org/SDL_mixer/archive/refs/tags/release-2.6.2.zip" + EXCLUDE_FROM_ALL ON + OPTIONS + "BUILD_SHARED_LIBS ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}" + "SDL2MIXER_INSTALL OFF" + "SDL2MIXER_DEPS_SHARED OFF" + "SDL2MIXER_SAMPLES OFF" + "SDL2MIXER_VENDORED ON" + "SDL2MIXER_FLAC ON" + "SDL2MIXER_FLAC_LIBFLAC OFF" + "SDL2MIXER_FLAC_DRFLAC ON" + "SDL2MIXER_MOD OFF" + "SDL2MIXER_MP3 ON" + "SDL2MIXER_MP3_DRMP3 ON" + "SDL2MIXER_MIDI ON" + "SDL2MIXER_OPUS OFF" + "SDL2MIXER_VORBIS STB" + "SDL2MIXER_WAVE ON" + ) +endif() + +if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}") + CPMAddPackage( + NAME ZLIB + VERSION 1.2.13 + URL "https://github.com/madler/zlib/archive/refs/tags/v1.2.13.zip" + EXCLUDE_FROM_ALL + DOWNLOAD_ONLY YES + ) + if(ZLIB_ADDED) + set(ZLIB_SRCS + crc32.h + deflate.h + gzguts.h + inffast.h + inffixed.h + inflate.h + inftrees.h + trees.h + zutil.h + + adler32.c + compress.c + crc32.c + deflate.c + gzclose.c + gzlib.c + gzread.c + gzwrite.c + inflate.c + infback.c + inftrees.c + inffast.c + trees.c + uncompr.c + zutil.c + ) + list(TRANSFORM ZLIB_SRCS PREPEND "${ZLIB_SOURCE_DIR}/") + + configure_file("${ZLIB_SOURCE_DIR}/zlib.pc.cmakein" "${ZLIB_BINARY_DIR}/zlib.pc" @ONLY) + configure_file("${ZLIB_SOURCE_DIR}/zconf.h.cmakein" "${ZLIB_BINARY_DIR}/include/zconf.h" @ONLY) + configure_file("${ZLIB_SOURCE_DIR}/zlib.h" "${ZLIB_BINARY_DIR}/include/zlib.h" @ONLY) + + add_library(ZLIB ${SRB2_INTERNAL_LIBRARY_TYPE} ${ZLIB_SRCS}) + set_target_properties(ZLIB PROPERTIES + VERSION 1.2.13 + OUTPUT_NAME "z" + ) + target_include_directories(ZLIB PRIVATE "${ZLIB_SOURCE_DIR}") + target_include_directories(ZLIB PUBLIC "${ZLIB_BINARY_DIR}/include") + if(MSVC) + target_compile_definitions(ZLIB PRIVATE -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) + endif() + add_library(ZLIB::ZLIB ALIAS ZLIB) + endif() +endif() + +if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}") + CPMAddPackage( + NAME png + VERSION 1.6.38 + URL "https://github.com/glennrp/libpng/archive/refs/tags/v1.6.38.zip" + # png cmake build is broken on msys/mingw32 + DOWNLOAD_ONLY YES + ) + + if(png_ADDED) + # Since png's cmake build is broken, we're going to create a target manually + set( + PNG_SOURCES + + png.h + pngconf.h + + pngpriv.h + pngdebug.h + pnginfo.h + pngstruct.h + + png.c + pngerror.c + pngget.c + pngmem.c + pngpread.c + pngread.c + pngrio.c + pngrtran.c + pngrutil.c + pngset.c + pngtrans.c + pngwio.c + pngwrite.c + pngwtran.c + pngwutil.c + ) + list(TRANSFORM PNG_SOURCES PREPEND "${png_SOURCE_DIR}/") + + add_custom_command( + OUTPUT "${png_BINARY_DIR}/include/png.h" "${png_BINARY_DIR}/include/pngconf.h" + COMMAND ${CMAKE_COMMAND} -E copy "${png_SOURCE_DIR}/png.h" "${png_SOURCE_DIR}/pngconf.h" "${png_BINARY_DIR}/include" + DEPENDS "${png_SOURCE_DIR}/png.h" "${png_SOURCE_DIR}/pngconf.h" + VERBATIM + ) + add_custom_command( + OUTPUT "${png_BINARY_DIR}/include/pnglibconf.h" + COMMAND ${CMAKE_COMMAND} -E copy "${png_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt" "${png_BINARY_DIR}/include/pnglibconf.h" + DEPENDS "${png_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt" + VERBATIM + ) + list( + APPEND PNG_SOURCES + "${png_BINARY_DIR}/include/png.h" + "${png_BINARY_DIR}/include/pngconf.h" + "${png_BINARY_DIR}/include/pnglibconf.h" + ) + add_library(png "${SRB2_INTERNAL_LIBRARY_TYPE}" ${PNG_SOURCES}) + + # Disable ARM NEON since having it automatic breaks libpng external build on clang for some reason + target_compile_definitions(png PRIVATE -DPNG_ARM_NEON_OPT=0) + + # The png includes need to be available to consumers + target_include_directories(png PUBLIC "${png_BINARY_DIR}/include") + + # ... and these also need to be present only for png build + target_include_directories(png PRIVATE "${ZLIB_SOURCE_DIR}") + target_include_directories(png PRIVATE "${ZLIB_BINARY_DIR}") + target_include_directories(png PRIVATE "${png_BINARY_DIR}") + + target_link_libraries(png PRIVATE ZLIB::ZLIB) + add_library(PNG::PNG ALIAS png) + endif() +endif() + +if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}") + set( + internal_curl_options + + "BUILD_CURL_EXE OFF" + "BUILD_SHARED_LIBS ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}" + "CURL_DISABLE_TESTS ON" + "HTTP_ONLY ON" + "CURL_DISABLE_CRYPTO_AUTH ON" + "CURL_DISABLE_NTLM ON" + "ENABLE_MANUAL OFF" + "ENABLE_THREADED_RESOLVER OFF" + "CURL_USE_LIBPSL OFF" + "CURL_USE_LIBSSH2 OFF" + "USE_LIBIDN2 OFF" + "CURL_ENABLE_EXPORT_TARGET OFF" + ) + if(${CMAKE_SYSTEM} MATCHES Windows) + list(APPEND internal_curl_options "CURL_USE_OPENSSL OFF") + list(APPEND internal_curl_options "CURL_USE_SCHANNEL ON") + endif() + if(${CMAKE_SYSTEM} MATCHES Darwin) + list(APPEND internal_curl_options "CURL_USE_OPENSSL OFF") + list(APPEND internal_curl_options "CURL_USE_SECTRANSP ON") + endif() + if(${CMAKE_SYSTEM} MATCHES Linux) + list(APPEND internal_curl_options "CURL_USE_OPENSSL ON") + endif() + + CPMAddPackage( + NAME curl + VERSION 7.86.0 + URL "https://github.com/curl/curl/archive/refs/tags/curl-7_86_0.zip" + EXCLUDE_FROM_ALL ON + OPTIONS ${internal_curl_options} + ) +endif() + +if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}") + CPMAddPackage( + NAME openmpt + VERSION 0.4.30 + URL "https://github.com/OpenMPT/openmpt/archive/refs/tags/libopenmpt-0.4.30.zip" + DOWNLOAD_ONLY ON + ) + + if(openmpt_ADDED) + set( + openmpt_SOURCES + + # minimp3 + # -DMPT_WITH_MINIMP3 + include/minimp3/minimp3.c + + common/mptStringParse.cpp + common/mptLibrary.cpp + common/Logging.cpp + common/Profiler.cpp + common/version.cpp + common/mptCPU.cpp + common/ComponentManager.cpp + common/mptOS.cpp + common/serialization_utils.cpp + common/mptStringFormat.cpp + common/FileReader.cpp + common/mptWine.cpp + common/mptPathString.cpp + common/mptAlloc.cpp + common/mptUUID.cpp + common/mptTime.cpp + common/mptString.cpp + common/mptFileIO.cpp + common/mptStringBuffer.cpp + common/mptRandom.cpp + common/mptIO.cpp + common/misc_util.cpp + + common/mptCRC.h + common/mptLibrary.h + common/mptIO.h + common/version.h + common/stdafx.h + common/ComponentManager.h + common/Endianness.h + common/mptStringFormat.h + common/mptMutex.h + common/mptUUID.h + common/mptExceptionText.h + common/BuildSettings.h + common/mptAlloc.h + common/mptTime.h + common/FileReaderFwd.h + common/Logging.h + common/mptException.h + common/mptWine.h + common/mptStringBuffer.h + common/misc_util.h + common/mptBaseMacros.h + common/mptMemory.h + common/mptFileIO.h + common/serialization_utils.h + common/mptSpan.h + common/mptThread.h + common/FlagSet.h + common/mptString.h + common/mptStringParse.h + common/mptBaseUtils.h + common/mptRandom.h + common/CompilerDetect.h + common/FileReader.h + common/mptAssert.h + common/mptPathString.h + common/Profiler.h + common/mptOS.h + common/mptBaseTypes.h + common/mptCPU.h + common/mptBufferIO.h + common/versionNumber.h + + soundlib/WAVTools.cpp + soundlib/ITTools.cpp + soundlib/AudioCriticalSection.cpp + soundlib/Load_stm.cpp + soundlib/MixerLoops.cpp + soundlib/Load_dbm.cpp + soundlib/ModChannel.cpp + soundlib/Load_gdm.cpp + soundlib/Snd_fx.cpp + soundlib/Load_mid.cpp + soundlib/mod_specifications.cpp + soundlib/Snd_flt.cpp + soundlib/Load_psm.cpp + soundlib/Load_far.cpp + soundlib/patternContainer.cpp + soundlib/Load_med.cpp + soundlib/Load_dmf.cpp + soundlib/Paula.cpp + soundlib/modcommand.cpp + soundlib/Message.cpp + soundlib/SoundFilePlayConfig.cpp + soundlib/Load_uax.cpp + soundlib/plugins/PlugInterface.cpp + soundlib/plugins/LFOPlugin.cpp + soundlib/plugins/PluginManager.cpp + soundlib/plugins/DigiBoosterEcho.cpp + soundlib/plugins/dmo/DMOPlugin.cpp + soundlib/plugins/dmo/Flanger.cpp + soundlib/plugins/dmo/Distortion.cpp + soundlib/plugins/dmo/ParamEq.cpp + soundlib/plugins/dmo/Gargle.cpp + soundlib/plugins/dmo/I3DL2Reverb.cpp + soundlib/plugins/dmo/Compressor.cpp + soundlib/plugins/dmo/WavesReverb.cpp + soundlib/plugins/dmo/Echo.cpp + soundlib/plugins/dmo/Chorus.cpp + soundlib/Load_ams.cpp + soundlib/tuningbase.cpp + soundlib/ContainerUMX.cpp + soundlib/Load_ptm.cpp + soundlib/ContainerXPK.cpp + soundlib/SampleFormatMP3.cpp + soundlib/tuning.cpp + soundlib/Sndfile.cpp + soundlib/ContainerMMCMP.cpp + soundlib/Load_amf.cpp + soundlib/Load_669.cpp + soundlib/modsmp_ctrl.cpp + soundlib/Load_mtm.cpp + soundlib/OggStream.cpp + soundlib/Load_plm.cpp + soundlib/Tables.cpp + soundlib/Load_c67.cpp + soundlib/Load_mod.cpp + soundlib/Load_sfx.cpp + soundlib/Sndmix.cpp + soundlib/load_j2b.cpp + soundlib/ModSequence.cpp + soundlib/SampleFormatFLAC.cpp + soundlib/ModInstrument.cpp + soundlib/Load_mo3.cpp + soundlib/ModSample.cpp + soundlib/Dlsbank.cpp + soundlib/Load_itp.cpp + soundlib/UpgradeModule.cpp + soundlib/MIDIMacros.cpp + soundlib/ContainerPP20.cpp + soundlib/RowVisitor.cpp + soundlib/Load_imf.cpp + soundlib/SampleFormatVorbis.cpp + soundlib/Load_dsm.cpp + soundlib/Load_mt2.cpp + soundlib/MixerSettings.cpp + soundlib/S3MTools.cpp + soundlib/Load_xm.cpp + soundlib/MIDIEvents.cpp + soundlib/pattern.cpp + soundlib/Load_digi.cpp + soundlib/Load_s3m.cpp + soundlib/tuningCollection.cpp + soundlib/SampleIO.cpp + soundlib/Dither.cpp + soundlib/Load_mdl.cpp + soundlib/OPL.cpp + soundlib/WindowedFIR.cpp + soundlib/SampleFormats.cpp + soundlib/Load_wav.cpp + soundlib/Load_it.cpp + soundlib/UMXTools.cpp + soundlib/Load_stp.cpp + soundlib/Load_okt.cpp + soundlib/Load_ult.cpp + soundlib/MixFuncTable.cpp + soundlib/SampleFormatOpus.cpp + soundlib/Fastmix.cpp + soundlib/Tagging.cpp + soundlib/ITCompression.cpp + soundlib/Load_dtm.cpp + soundlib/MPEGFrame.cpp + soundlib/XMTools.cpp + soundlib/SampleFormatMediaFoundation.cpp + soundlib/InstrumentExtensions.cpp + + soundlib/MixerInterface.h + soundlib/SoundFilePlayConfig.h + soundlib/ModSample.h + soundlib/MIDIEvents.h + soundlib/ModSampleCopy.h + soundlib/patternContainer.h + soundlib/ChunkReader.h + soundlib/ITCompression.h + soundlib/Dither.h + soundlib/S3MTools.h + soundlib/MPEGFrame.h + soundlib/WAVTools.h + soundlib/mod_specifications.h + soundlib/ITTools.h + soundlib/RowVisitor.h + soundlib/plugins/PluginMixBuffer.h + soundlib/plugins/PluginStructs.h + soundlib/plugins/LFOPlugin.h + soundlib/plugins/PlugInterface.h + soundlib/plugins/DigiBoosterEcho.h + soundlib/plugins/OpCodes.h + soundlib/plugins/dmo/Echo.h + soundlib/plugins/dmo/I3DL2Reverb.h + soundlib/plugins/dmo/WavesReverb.h + soundlib/plugins/dmo/ParamEq.h + soundlib/plugins/dmo/Gargle.h + soundlib/plugins/dmo/DMOPlugin.h + soundlib/plugins/dmo/Chorus.h + soundlib/plugins/dmo/Compressor.h + soundlib/plugins/dmo/Distortion.h + soundlib/plugins/dmo/Flanger.h + soundlib/plugins/PluginManager.h + soundlib/SampleIO.h + soundlib/Container.h + soundlib/ModSequence.h + soundlib/UMXTools.h + soundlib/Message.h + soundlib/modcommand.h + soundlib/XMTools.h + soundlib/Snd_defs.h + soundlib/MixFuncTable.h + soundlib/pattern.h + soundlib/modsmp_ctrl.h + soundlib/Tagging.h + soundlib/tuningcollection.h + soundlib/Mixer.h + soundlib/FloatMixer.h + soundlib/AudioCriticalSection.h + soundlib/Tables.h + soundlib/tuningbase.h + soundlib/WindowedFIR.h + soundlib/Sndfile.h + soundlib/Paula.h + soundlib/ModInstrument.h + soundlib/Dlsbank.h + soundlib/IntMixer.h + soundlib/OPL.h + soundlib/Resampler.h + soundlib/ModChannel.h + soundlib/MixerSettings.h + soundlib/AudioReadTarget.h + soundlib/MixerLoops.h + soundlib/tuning.h + soundlib/MIDIMacros.h + soundlib/OggStream.h + soundlib/Loaders.h + soundlib/BitReader.h + soundlib/opal.h + + sounddsp/AGC.cpp + sounddsp/EQ.cpp + sounddsp/DSP.cpp + sounddsp/Reverb.cpp + sounddsp/Reverb.h + sounddsp/EQ.h + sounddsp/DSP.h + sounddsp/AGC.h + + libopenmpt/libopenmpt_c.cpp + libopenmpt/libopenmpt_cxx.cpp + libopenmpt/libopenmpt_impl.cpp + libopenmpt/libopenmpt_ext_impl.cpp + ) + list(TRANSFORM openmpt_SOURCES PREPEND "${openmpt_SOURCE_DIR}/") + + # -DLIBOPENMPT_BUILD + configure_file("openmpt_svn_version.h" "svn_version.h") + add_library(openmpt "${SRB2_INTERNAL_LIBRARY_TYPE}" ${openmpt_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/svn_version.h) + if("${CMAKE_C_COMPILER_ID}" STREQUAL GNU OR "${CMAKE_C_COMPILER_ID}" STREQUAL Clang OR "${CMAKE_C_COMPILER_ID}" STREQUAL AppleClang) + target_compile_options(openmpt PRIVATE "-g0") + endif() + if("${CMAKE_SYSTEM_NAME}" STREQUAL Windows AND "${CMAKE_C_COMPILER_ID}" STREQUAL MSVC) + target_link_libraries(openmpt PRIVATE Rpcrt4) + endif() + target_compile_features(openmpt PRIVATE cxx_std_11) + target_compile_definitions(openmpt PRIVATE -DLIBOPENMPT_BUILD) + + target_include_directories(openmpt PRIVATE "${openmpt_SOURCE_DIR}/common") + target_include_directories(openmpt PRIVATE "${openmpt_SOURCE_DIR}/src") + target_include_directories(openmpt PRIVATE "${openmpt_SOURCE_DIR}/include") + target_include_directories(openmpt PRIVATE "${openmpt_SOURCE_DIR}") + target_include_directories(openmpt PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") + + # I wish this wasn't necessary, but it is + target_include_directories(openmpt PUBLIC "${openmpt_SOURCE_DIR}") + endif() +endif() + +if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}") + CPMAddPackage( + NAME libgme + VERSION 0.6.3 + URL "https://bitbucket.org/mpyne/game-music-emu/get/e76bdc0cb916e79aa540290e6edd0c445879d3ba.zip" + EXCLUDE_FROM_ALL ON + OPTIONS + "BUILD_SHARED_LIBS ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}" + "ENABLE_UBSAN OFF" + "GME_YM2612_EMU MAME" + ) + target_compile_features(gme PRIVATE cxx_std_11) + target_link_libraries(gme PRIVATE ZLIB::ZLIB) +endif() + +if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}") + CPMAddPackage( + NAME DiscordRPC + VERSION 3.4.0 + URL "https://github.com/discord/discord-rpc/archive/refs/tags/v3.4.0.zip" + EXCLUDE_FROM_ALL ON + OPTIONS + "BUILD_EXAMPLES OFF" + ) + target_include_directories(discord-rpc INTERFACE "${DiscordRPC_SOURCE_DIR}/include") + add_library(DiscordRPC::DiscordRPC ALIAS discord-rpc) +endif() diff --git a/thirdparty/openmpt_svn_version.h b/thirdparty/openmpt_svn_version.h new file mode 100644 index 000000000..a45ed9f22 --- /dev/null +++ b/thirdparty/openmpt_svn_version.h @@ -0,0 +1,10 @@ + +#pragma once +#define OPENMPT_VERSION_SVNVERSION "17963" +#define OPENMPT_VERSION_REVISION 17963 +#define OPENMPT_VERSION_DIRTY 0 +#define OPENMPT_VERSION_MIXEDREVISIONS 0 +#define OPENMPT_VERSION_URL "https://source.openmpt.org/svn/openmpt/tags/libopenmpt-0.4.32" +#define OPENMPT_VERSION_DATE "2022-09-25T14:19:05.052596Z" +#define OPENMPT_VERSION_IS_PACKAGE 1 +