Compare commits
37
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
467ecf8224 | ||
|
|
2077315f24 | ||
|
|
67e74b5874 | ||
|
|
9bea6eddbd | ||
|
|
f4e5f7249c | ||
|
|
9639ace28a | ||
|
|
a2616778cc | ||
|
|
495c34dd40 | ||
|
|
b0bf588c27 | ||
|
|
35e4f35f6e | ||
|
|
7866b769cc | ||
|
|
1af1e42dab | ||
|
|
40bd3e5e19 | ||
|
|
a05413d925 | ||
|
|
8a8cbffd12 | ||
|
|
1fb6c63097 | ||
|
|
c312380944 | ||
|
|
b5bb2b42bf | ||
|
|
d074f375ca | ||
|
|
6fd14f0a80 | ||
|
|
d6bbb2c1b3 | ||
|
|
fa66b87965 | ||
|
|
c59d5db03e | ||
|
|
b6edc90553 | ||
|
|
23735121ff | ||
|
|
20950b698f | ||
|
|
44df85d6a4 | ||
|
|
42d53f1f6f | ||
|
|
48f2d0ff83 | ||
|
|
517723f9c1 | ||
|
|
6915077e0f | ||
|
|
406dbf333d | ||
|
|
a730dfd212 | ||
|
|
3058d365f3 | ||
|
|
ccc453e0b0 | ||
|
|
c3d02090e4 | ||
|
|
20cd7621c3 |
No files matched your search
+87
-168
@@ -1,169 +1,61 @@
|
||||
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
|
||||
|
||||
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)
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
# DO NOT CHANGE THIS SRB2 STRING! Some variable names depend on this string.
|
||||
# Version change is fine.
|
||||
project(SRB2
|
||||
VERSION 1.6
|
||||
LANGUAGES C CXX)
|
||||
|
||||
if(APPLE)
|
||||
# DiscordRPC needs but does not properly specify ObjC
|
||||
enable_language(OBJC)
|
||||
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_NAME}" MATCHES "Windows")
|
||||
set(SRB2_CPACK_GENERATOR "ZIP")
|
||||
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
|
||||
set(SRB2_CPACK_GENERATOR "TGZ")
|
||||
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
|
||||
set(SRB2_CPACK_GENERATOR "TGZ")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CPACK_GENERATOR ${SRB2_CPACK_GENERATOR})
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "SRB2Kart" CACHE STRING "Program name for display purposes")
|
||||
set(CPACK_PACKAGE_VENDOR "Kart Krew" CACHE STRING "Vendor name for display purposes")
|
||||
#set(CPACK_PACKAGE_DESCRIPTION_FILE )
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${SRB2_VERSION_MAJOR})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${SRB2_VERSION_MINOR})
|
||||
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_ENABLE_DISCORDRPC "Enable Discord RPC features" ON)
|
||||
option(SRB2_CONFIG_STATIC_STDLIB "Link static version of standard library. All dependencies must also be static" ON)
|
||||
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)
|
||||
option(SRB2_CONFIG_TRACY "Compile with Tracy profiling enabled" OFF)
|
||||
option(SRB2_CONFIG_ASAN "Compile with AddressSanitizer (libasan)." OFF)
|
||||
option(SRB2_CONFIG_UBSAN "Compile with UndefinedBehaviorSanitizer (libubsan)." 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.")
|
||||
option(SRB2_CONFIG_LTO "Enable link time optimizations, improves performance at the cost of longer link times." ON)
|
||||
option(SRB2_CONFIG_TIDY "Enable clang tiny, checks compiled code for issues at the cost of longer compile times." OFF)
|
||||
|
||||
# man i suck at explaining lmao
|
||||
option(SRB2_CONFIG_SATURNPAK "Enable Saturn specific special packet. Required for using the newer resynch system" ON)
|
||||
option(SRB2_CONFIG_SATURNJOIN "Enable Saturn specific allowjoin toggle." ON)
|
||||
option(SRB2_CONFIG_SCREENFBO "Enable hardware render (OpenGL) FBO downsampling support" ON)
|
||||
option(SRB2_CONFIG_LIBBACKTRACE "Enable using libbacktrace for crashlogs" ON)
|
||||
|
||||
#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()
|
||||
# TODO: fix windoze crap, i dont want cpm lol
|
||||
#CPMAddPackage(
|
||||
# NAME Ccache.cmake
|
||||
# GITHUB_REPOSITORY TheLartians/Ccache.cmake
|
||||
# VERSION 1.2.5
|
||||
#)
|
||||
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 OPTIONAL)
|
||||
find_package(GME REQUIRED)
|
||||
find_package(DiscordRPC OPTIONAL)
|
||||
find_package(libbacktrace OPTIONAL)
|
||||
endif()
|
||||
LANGUAGES C)
|
||||
|
||||
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()
|
||||
# Set up CMAKE path
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
|
||||
|
||||
# Add sources from Sourcefile
|
||||
function(target_sourcefile type)
|
||||
file(STRINGS Sourcefile list
|
||||
REGEX "[-0-9A-Za-z_]+\.${type}")
|
||||
target_sources(SRB2SDL2 PRIVATE ${list})
|
||||
### Useful functions
|
||||
|
||||
# Prepend sources with current source directory
|
||||
function(prepend_sources SOURCE_FILES)
|
||||
foreach(SOURCE_FILE ${${SOURCE_FILES}})
|
||||
set(MODIFIED ${MODIFIED} ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_FILE})
|
||||
endforeach()
|
||||
set(${SOURCE_FILES} ${MODIFIED} PARENT_SCOPE)
|
||||
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}
|
||||
$<TARGET_FILE_DIR:${target}>/${dllname}
|
||||
)
|
||||
endforeach()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# bitness check
|
||||
set(SRB2_SYSTEM_BITS 0)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
@@ -178,39 +70,66 @@ 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 "" CACHE STRING "Override executable binary output name")
|
||||
set(SRB2_SDL2_EXE_SUFFIX "" CACHE STRING "Optional executable suffix, separated by an underscore")
|
||||
set(SRB2_SDL2_EXE_NAME srb2kart CACHE STRING "Executable binary output name")
|
||||
set(SRB2_WIN_EXE_NAME srb2kartdd CACHE STRING "Executable binary output name for DirectDraw build")
|
||||
|
||||
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}") #TODO: fix this
|
||||
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 "srb2kart-saturn")
|
||||
##### PACKAGE CONFIGURATION #####
|
||||
|
||||
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})
|
||||
if(${CMAKE_SYSTEM} MATCHES "Windows")
|
||||
set(CPACK_GENERATOR "ZIP")
|
||||
endif()
|
||||
if(${CMAKE_SYSTEM} MATCHES "Linux")
|
||||
set(CPACK_GENERATOR "TGZ")
|
||||
endif()
|
||||
if(${CMAKE_SYSTEM} MATCHES "Darwin")
|
||||
set(CPACK_GENERATOR "DragNDrop")
|
||||
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})
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Sonic Robo Blast 2 Kart" CACHE STRING "Program name for display purposes")
|
||||
set(CPACK_PACKAGE_VENDOR "Kart Krew" CACHE STRING "Vendor name for display purposes")
|
||||
#set(CPACK_PACKAGE_DESCRIPTION_FILE )
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${SRB2_VERSION_MAJOR})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${SRB2_VERSION_MINOR})
|
||||
set(CPACK_PACKAGE_VERSION_PATCH ${SRB2_VERSION_PATCH})
|
||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}")
|
||||
include(CPack)
|
||||
+44
-37
@@ -1,52 +1,59 @@
|
||||
## Assets Target Configuration ##
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES Linux)
|
||||
# Asset installation isn't part of the Linux target
|
||||
return()
|
||||
endif()
|
||||
# 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("${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_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/installer"
|
||||
CACHE STRING "Path to directory that contains all asset files for the installer.")
|
||||
|
||||
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"
|
||||
set(SRB2_ASSET_HASHED
|
||||
"srb2.srb;\
|
||||
gfx.kart;\
|
||||
textures.kart;\
|
||||
chars.kart;\
|
||||
maps.kart"
|
||||
CACHE STRING "Asset filenames to apply MD5 checks. No spaces between entries!"
|
||||
)
|
||||
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_ASSETS_GAME
|
||||
"srb2.srb"
|
||||
"gfx.kart"
|
||||
"textures.kart"
|
||||
"chars.kart"
|
||||
"maps.kart"
|
||||
set(SRB2_ASSET_DOCS
|
||||
"README.txt;\
|
||||
HISTORY.txt;\
|
||||
LICENSE.txt;\
|
||||
LICENSE-3RD-PARTY.txt"
|
||||
CACHE STRING "Documentation filenames. In OS X, these are packaged separately from other assets. No spaces between entries!"
|
||||
)
|
||||
list(TRANSFORM SRB2_ASSETS_GAME PREPEND "/")
|
||||
list(TRANSFORM SRB2_ASSETS_GAME PREPEND "${SRB2_ASSET_DIRECTORY_ABSOLUTE}")
|
||||
|
||||
set(SRB2_ASSETS ${SRB2_ASSET_DOCS} ${SRB2_ASSETS_GAME})
|
||||
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()
|
||||
|
||||
# Installation
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES Darwin)
|
||||
get_target_property(outname SRB2SDL2 OUTPUT_NAME)
|
||||
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 .)
|
||||
install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/"
|
||||
DESTINATION "${outname}.app/Contents/Resources"
|
||||
)
|
||||
install(FILES ${SRB2_ASSET_DOCS}
|
||||
DESTINATION .
|
||||
OPTIONAL
|
||||
)
|
||||
else()
|
||||
install(FILES ${SRB2_ASSETS} DESTINATION .)
|
||||
install(DIRECTORY "${SRB2_ASSET_DIRECTORY_ABSOLUTE}/models" DESTINATION .)
|
||||
install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/"
|
||||
DESTINATION .
|
||||
)
|
||||
# Docs are assumed to be located in SRB2_ASSET_DIRECTORY, so don't install again
|
||||
#install(FILES ${SRB2_ASSET_DOCS}
|
||||
# DESTINATION .
|
||||
# OPTIONAL
|
||||
#)
|
||||
endif()
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
|
||||
|
||||
set(CMAKE_BINARY_DIR "${BINARY_DIR}")
|
||||
set(CMAKE_CURRENT_BINARY_DIR "${BINARY_DIR}")
|
||||
|
||||
# Set up CMAKE path
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
|
||||
|
||||
include(GitUtilities)
|
||||
|
||||
git_current_branch(SRB2_COMP_BRANCH)
|
||||
git_working_tree_dirty(SRB2_COMP_UNCOMMITTED)
|
||||
|
||||
git_latest_commit(SRB2_COMP_REVISION)
|
||||
git_subject(subject)
|
||||
string(REGEX REPLACE "([\"\\])" "\\\\\\1" SRB2_COMP_LASTCOMMIT "${subject}")
|
||||
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in" "${CMAKE_CURRENT_SOURCE_DIR}/src/config.h")
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in" "${CMAKE_CURRENT_SOURCE_DIR}/build/src/config.h")
|
||||
@@ -21,13 +21,3 @@ 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()
|
||||
@@ -20,14 +20,4 @@ find_library(GME_LIBRARY
|
||||
|
||||
set(GME_PROCESS_INCLUDES GME_INCLUDE_DIR)
|
||||
set(GME_PROCESS_LIBS GME_LIBRARY)
|
||||
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()
|
||||
libfind_process(GME)
|
||||
@@ -20,14 +20,4 @@ find_library(OPENMPT_LIBRARY
|
||||
|
||||
set(OPENMPT_PROCESS_INCLUDES OPENMPT_INCLUDE_DIR)
|
||||
set(OPENMPT_PROCESS_LIBS OPENMPT_LIBRARY)
|
||||
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()
|
||||
libfind_process(OPENMPT)
|
||||
@@ -31,13 +31,3 @@ 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()
|
||||
@@ -32,13 +32,3 @@ 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()
|
||||
@@ -1,33 +0,0 @@
|
||||
include(LibFindMacros)
|
||||
|
||||
libfind_pkg_check_modules(LIBBACKTRACE_PKGCONF LIBBACKTRACE)
|
||||
|
||||
find_path(LIBBACKTRACE_INCLUDE_DIR
|
||||
NAMES backtrace.h
|
||||
PATHS
|
||||
${LIBBACKTRACE_PKGCONF_INCLUDE_DIRS}
|
||||
"/usr/include"
|
||||
"/usr/local/include"
|
||||
)
|
||||
|
||||
find_library(LIBBACKTRACE_LIBRARY
|
||||
NAMES backtrace
|
||||
PATHS
|
||||
${LIBBACKTRACE_PKGCONF_LIBRARY_DIRS}
|
||||
"/usr/lib"
|
||||
"/usr/local/lib"
|
||||
)
|
||||
|
||||
set(LIBBACKTRACE_PROCESS_INCLUDES LIBBACKTRACE_INCLUDE_DIR)
|
||||
set(LIBBACKTRACE_PROCESS_LIBS LIBBACKTRACE_LIBRARY)
|
||||
libfind_process(LIBBACKTRACE)
|
||||
|
||||
if(LIBBACKTRACE_FOUND AND NOT TARGET libbacktrace)
|
||||
add_library(libbacktrace UNKNOWN IMPORTED)
|
||||
set_target_properties(
|
||||
libbacktrace
|
||||
PROPERTIES
|
||||
IMPORTED_LOCATION "${LIBBACKTRACE_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${LIBBACKTRACE_INCLUDE_DIR}"
|
||||
)
|
||||
endif()
|
||||
@@ -6,54 +6,38 @@ endif()
|
||||
|
||||
set(__GitUtilities ON)
|
||||
|
||||
macro(_git_command)
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" ${ARGN}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
function(git_describe variable path)
|
||||
execute_process(COMMAND "${GIT_EXECUTABLE}" "describe"
|
||||
WORKING_DIRECTORY "${path}"
|
||||
RESULT_VARIABLE result
|
||||
OUTPUT_VARIABLE output
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
endmacro()
|
||||
|
||||
macro(_git_easy_command)
|
||||
_git_command(${ARGN})
|
||||
set(${variable} "${output}" PARENT_SCOPE)
|
||||
endmacro()
|
||||
|
||||
function(git_current_branch variable)
|
||||
_git_command(symbolic-ref -q --short HEAD)
|
||||
|
||||
# If a detached head, a ref could still be resolved.
|
||||
if("${output}" STREQUAL "")
|
||||
_git_command(describe --all --exact-match)
|
||||
|
||||
# Get the ref, in the form heads/master or
|
||||
# remotes/origin/master so isolate the final part.
|
||||
string(REGEX REPLACE ".*/" "" output "${output}")
|
||||
endif()
|
||||
|
||||
set(${variable} "${output}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_latest_commit variable)
|
||||
_git_easy_command(rev-parse --short HEAD)
|
||||
function(git_current_branch variable path)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} "symbolic-ref" "--short" "HEAD"
|
||||
WORKING_DIRECTORY "${path}"
|
||||
RESULT_VARIABLE result
|
||||
OUTPUT_VARIABLE output
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
set(${variable} "${output}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_working_tree_dirty variable)
|
||||
_git_command(status --porcelain -uno)
|
||||
function(git_latest_commit variable path)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} "rev-parse" "--short" "HEAD"
|
||||
WORKING_DIRECTORY "${path}"
|
||||
RESULT_VARIABLE result
|
||||
OUTPUT_VARIABLE output
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
if(output STREQUAL "")
|
||||
set(${variable} FALSE PARENT_SCOPE)
|
||||
else()
|
||||
set(${variable} TRUE PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(git_subject variable)
|
||||
_git_easy_command(log -1 "--format=%h %s")
|
||||
endfunction()
|
||||
|
||||
function(get_git_dir variable)
|
||||
_git_easy_command(rev-parse --git-dir)
|
||||
endfunction()
|
||||
set(${variable} "${output}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
@@ -1,5 +1,4 @@
|
||||
/cscope.out
|
||||
*.json
|
||||
*.idx
|
||||
config.h
|
||||
*.gdb_history
|
||||
+495
-391
@@ -1,146 +1,413 @@
|
||||
add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32)
|
||||
|
||||
if(("${CMAKE_COMPILER_IS_GNUCC}" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND "${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
|
||||
target_link_options(SRB2SDL2 PRIVATE "-Wl,--disable-dynamicbase")
|
||||
if("${SRB2_CONFIG_STATIC_STDLIB}")
|
||||
# On MinGW with internal libraries, link the standard library statically
|
||||
if(CMAKE_LINKER_TYPE STREQUAL "LLD")
|
||||
target_link_options(SRB2SDL2 PRIVATE -Wl, -static-libgcc -static-libstdc++ -static -lpthread)
|
||||
else()
|
||||
target_link_options(SRB2SDL2 PRIVATE -Wl,--add-stdcall-alias -static-libgcc -static-libstdc++ -static -lpthread)
|
||||
endif()
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(SRB2SDL2 PRIVATE Threads::Threads)
|
||||
endif()
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
target_link_options(SRB2SDL2 PRIVATE "-Wl,--large-address-aware")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(SRB2_CONFIG_STD23 OFF CACHE BOOL
|
||||
"Compiles the game under c23 and cxx23 instead c11 and cxx17.")
|
||||
|
||||
if(SRB2_CONFIG_STD23)
|
||||
message("-- Compiling game with C23 and CXX23.")
|
||||
target_compile_features(SRB2SDL2 PRIVATE c_std_23 cxx_std_23)
|
||||
set_property(TARGET SRB2SDL2 PROPERTY C_STANDARD 23)
|
||||
set_property(TARGET SRB2SDL2 PROPERTY CXX_STANDARD 23)
|
||||
else()
|
||||
message("-- Compiling game with C11 and CXX17.")
|
||||
target_compile_features(SRB2SDL2 PRIVATE c_std_11 cxx_std_17)
|
||||
set_property(TARGET SRB2SDL2 PROPERTY C_STANDARD 11)
|
||||
set_property(TARGET SRB2SDL2 PROPERTY CXX_STANDARD 17)
|
||||
endif()
|
||||
# SRB2 Core
|
||||
|
||||
# Core sources
|
||||
target_sourcefile(c)
|
||||
target_sources(SRB2SDL2 PRIVATE comptime.c config.h.in)
|
||||
set(SRB2_CORE_SOURCES
|
||||
am_map.c
|
||||
b_bot.c
|
||||
command.c
|
||||
comptime.c
|
||||
console.c
|
||||
d_clisrv.c
|
||||
d_main.c
|
||||
d_net.c
|
||||
d_netcmd.c
|
||||
d_netfil.c
|
||||
d_protocol.c
|
||||
dehacked.c
|
||||
f_finale.c
|
||||
f_wipe.c
|
||||
filesrch.c
|
||||
g_game.c
|
||||
g_input.c
|
||||
hu_stuff.c
|
||||
i_tcp.c
|
||||
info.c
|
||||
lzf.c
|
||||
m_aatree.c
|
||||
m_anigif.c
|
||||
m_argv.c
|
||||
m_bbox.c
|
||||
m_cheat.c
|
||||
m_cond.c
|
||||
m_fixed.c
|
||||
m_menu.c
|
||||
m_textinput.c
|
||||
m_misc.c
|
||||
m_perfstats.c
|
||||
m_queue.c
|
||||
m_random.c
|
||||
md5.c
|
||||
mserv.c
|
||||
http-mserv.c
|
||||
qs22j.c
|
||||
s_sound.c
|
||||
screen.c
|
||||
sounds.c
|
||||
st_stuff.c
|
||||
#string.c
|
||||
tables.c
|
||||
v_video.c
|
||||
w_wad.c
|
||||
y_inter.c
|
||||
z_zone.c
|
||||
)
|
||||
|
||||
target_sources(SRB2SDL2 PRIVATE md5.c md5.h)
|
||||
set(SRB2_CORE_HEADERS
|
||||
am_map.h
|
||||
b_bot.h
|
||||
byteptr.h
|
||||
command.h
|
||||
console.h
|
||||
d_clisrv.h
|
||||
d_event.h
|
||||
d_main.h
|
||||
d_net.h
|
||||
d_netcmd.h
|
||||
d_netfil.h
|
||||
d_player.h
|
||||
d_protocol.h
|
||||
d_think.h
|
||||
d_ticcmd.h
|
||||
dehacked.h
|
||||
doomdata.h
|
||||
doomdef.h
|
||||
doomstat.h
|
||||
doomtype.h
|
||||
endian.h
|
||||
f_finale.h
|
||||
fastcmp.h
|
||||
filesrch.h
|
||||
g_game.h
|
||||
g_input.h
|
||||
g_state.h
|
||||
hu_stuff.h
|
||||
i_joy.h
|
||||
i_net.h
|
||||
i_sound.h
|
||||
i_system.h
|
||||
i_tcp.h
|
||||
i_time.h
|
||||
i_video.h
|
||||
info.h
|
||||
keys.h
|
||||
lzf.h
|
||||
m_aatree.h
|
||||
m_anigif.h
|
||||
m_argv.h
|
||||
m_bbox.h
|
||||
m_cheat.h
|
||||
m_cond.h
|
||||
m_dllist.h
|
||||
m_fixed.h
|
||||
m_menu.h
|
||||
m_textinput.h
|
||||
m_misc.h
|
||||
m_queue.h
|
||||
m_perfstats.h
|
||||
m_random.h
|
||||
m_swap.h
|
||||
md5.h
|
||||
mserv.h
|
||||
qs22j.h
|
||||
s_sound.h
|
||||
screen.h
|
||||
sounds.h
|
||||
st_stuff.h
|
||||
tables.h
|
||||
v_video.h
|
||||
w_wad.h
|
||||
y_inter.h
|
||||
z_zone.h
|
||||
|
||||
config.h.in
|
||||
)
|
||||
|
||||
set(SRB2_CORE_RENDER_SOURCES
|
||||
r_bsp.c
|
||||
r_data.c
|
||||
r_draw.c
|
||||
r_fps.c
|
||||
r_main.c
|
||||
r_patch.c
|
||||
r_patchrotation.c
|
||||
r_plane.c
|
||||
r_segs.c
|
||||
r_sky.c
|
||||
r_splats.c
|
||||
r_things.c
|
||||
r_portal.c
|
||||
|
||||
r_bsp.h
|
||||
r_data.h
|
||||
r_defs.h
|
||||
r_draw.h
|
||||
r_fps.h
|
||||
r_local.h
|
||||
r_main.h
|
||||
r_patch.h
|
||||
r_patchrotation.h
|
||||
r_plane.h
|
||||
r_segs.h
|
||||
r_sky.h
|
||||
r_splats.h
|
||||
r_state.h
|
||||
r_things.h
|
||||
r_portal.h
|
||||
)
|
||||
|
||||
set(SRB2_CORE_GAME_SOURCES
|
||||
p_ceilng.c
|
||||
p_enemy.c
|
||||
p_floor.c
|
||||
p_inter.c
|
||||
p_lights.c
|
||||
p_map.c
|
||||
p_maputl.c
|
||||
p_mobj.c
|
||||
p_polyobj.c
|
||||
p_saveg.c
|
||||
p_setup.c
|
||||
p_sight.c
|
||||
p_slopes.c
|
||||
p_spec.c
|
||||
p_telept.c
|
||||
p_tick.c
|
||||
p_user.c
|
||||
k_director.c
|
||||
k_kart.c
|
||||
k_stats.c
|
||||
i_time.c
|
||||
|
||||
p_local.h
|
||||
p_maputl.h
|
||||
p_mobj.h
|
||||
p_polyobj.h
|
||||
p_pspr.h
|
||||
p_saveg.h
|
||||
p_setup.h
|
||||
p_slopes.h
|
||||
p_spec.h
|
||||
p_tick.h
|
||||
k_director.h
|
||||
k_kart.h
|
||||
k_stats.h
|
||||
)
|
||||
|
||||
if(NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
|
||||
set(SRB2_CORE_SOURCES ${SRB2_CORE_SOURCES} string.c)
|
||||
endif()
|
||||
|
||||
prepend_sources(SRB2_CORE_SOURCES)
|
||||
prepend_sources(SRB2_CORE_HEADERS)
|
||||
prepend_sources(SRB2_CORE_RENDER_SOURCES)
|
||||
prepend_sources(SRB2_CORE_GAME_SOURCES)
|
||||
|
||||
set(SRB2_CORE_HEADERS ${SRB2_CORE_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS})
|
||||
source_group("Renderer" FILES ${SRB2_CORE_RENDER_SOURCES})
|
||||
source_group("Game" FILES ${SRB2_CORE_GAME_SOURCES})
|
||||
|
||||
### Configuration
|
||||
set(SRB2_CONFIG_DEV_BUILD OFF CACHE BOOL
|
||||
"Compile a development build of SRB2Kart.")
|
||||
set(SRB2_CONFIG_HAVE_BLUA ON CACHE BOOL
|
||||
"Enable Lua interpreter support")
|
||||
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_OPENMPT ON CACHE BOOL
|
||||
"Enable OpenMPT 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_HWRENDER ON CACHE BOOL
|
||||
"Enable hardware rendering through OpenGL.")
|
||||
set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL
|
||||
"Use statically linked OpenGL. NOT RECOMMENDED.")
|
||||
set(SRB2_CONFIG_USE_FBO_OGL ON CACHE BOOL
|
||||
"Enable OpenGL FBO Downsampling support.")
|
||||
set(SRB2_CONFIG_DEDICATED OFF CACHE BOOL
|
||||
"Build a dedicated server.")
|
||||
|
||||
set(SRB2_CONFIG_SKIP_COMPTIME OFF CACHE BOOL
|
||||
"Skip Comptime rebuild.")
|
||||
if(${SRB2_CONFIG_DEDICATED})
|
||||
set(SRB2_CONFIG_HAVE_GME NO)
|
||||
set(SRB2_CONFIG_HAVE_OPENMPT NO)
|
||||
set(SRB2_CONFIG_HWRENDER NO)
|
||||
endif()
|
||||
|
||||
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
|
||||
### use internal libraries?
|
||||
if(${CMAKE_SYSTEM} MATCHES "Windows") ###set on Windows only
|
||||
set(SRB2_CONFIG_USE_INTERNAL_LIBRARIES OFF CACHE BOOL
|
||||
"Use SRB2Kart's internal copies of required dependencies (SDL2, PNG, zlib, GME, OpenMPT).")
|
||||
endif()
|
||||
|
||||
if(${SRB2_CONFIG_HAVE_BLUA})
|
||||
add_definitions(-DHAVE_BLUA)
|
||||
set(SRB2_LUA_SOURCES
|
||||
lua_baselib.c
|
||||
lua_blockmaplib.c
|
||||
lua_consolelib.c
|
||||
lua_hooklib.c
|
||||
lua_hudlib.c
|
||||
lua_hudlib_drawlist.c
|
||||
lua_infolib.c
|
||||
lua_maplib.c
|
||||
lua_mathlib.c
|
||||
lua_mobjlib.c
|
||||
lua_playerlib.c
|
||||
lua_script.c
|
||||
lua_skinlib.c
|
||||
lua_thinkerlib.c
|
||||
lua_udatalib.c
|
||||
lua_glib.c
|
||||
)
|
||||
set(SRB2_LUA_HEADERS
|
||||
lua_hook.h
|
||||
lua_hud.h
|
||||
lua_hudlib_drawlist.h
|
||||
lua_libs.h
|
||||
lua_script.h
|
||||
lua_udatalib.h
|
||||
lua_glib.h
|
||||
)
|
||||
|
||||
prepend_sources(SRB2_LUA_SOURCES)
|
||||
prepend_sources(SRB2_LUA_HEADERS)
|
||||
|
||||
source_group("LUA" FILES ${SRB2_LUA_SOURCES} ${SRB2_LUA_HEADERS})
|
||||
|
||||
set(SRB2_BLUA_SOURCES
|
||||
blua/lapi.c
|
||||
blua/lauxlib.c
|
||||
blua/lbaselib.c
|
||||
blua/ldblib.c
|
||||
blua/lcode.c
|
||||
blua/ldebug.c
|
||||
blua/ldo.c
|
||||
blua/ldump.c
|
||||
blua/lfunc.c
|
||||
blua/lgc.c
|
||||
blua/linit.c
|
||||
blua/liolib.c
|
||||
blua/llex.c
|
||||
blua/lmem.c
|
||||
blua/lobject.c
|
||||
blua/lopcodes.c
|
||||
blua/lparser.c
|
||||
blua/lstate.c
|
||||
blua/lstring.c
|
||||
blua/lstrlib.c
|
||||
blua/ltable.c
|
||||
blua/ltablib.c
|
||||
blua/ltm.c
|
||||
blua/lundump.c
|
||||
blua/lvm.c
|
||||
blua/lzio.c
|
||||
)
|
||||
set(SRB2_BLUA_HEADERS
|
||||
blua/lapi.h
|
||||
blua/lauxlib.h
|
||||
blua/lcode.h
|
||||
blua/ldebug.h
|
||||
blua/ldo.h
|
||||
blua/lfunc.h
|
||||
blua/lgc.h
|
||||
blua/llex.h
|
||||
blua/llimits.h
|
||||
blua/lmem.h
|
||||
blua/lobject.h
|
||||
blua/lopcodes.h
|
||||
blua/lparser.h
|
||||
blua/lstate.h
|
||||
blua/lstring.h
|
||||
blua/ltable.h
|
||||
blua/ltm.h
|
||||
blua/lua.h
|
||||
blua/luaconf.h
|
||||
blua/lualib.h
|
||||
blua/lundump.h
|
||||
blua/lvm.h
|
||||
blua/lzio.h
|
||||
)
|
||||
|
||||
prepend_sources(SRB2_BLUA_SOURCES)
|
||||
prepend_sources(SRB2_BLUA_HEADERS)
|
||||
|
||||
source_group("LUA\\Interpreter" FILES ${SRB2_BLUA_SOURCES} ${SRB2_BLUA_HEADERS})
|
||||
endif()
|
||||
|
||||
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)
|
||||
|
||||
if(SRB2_CONFIG_ASAN)
|
||||
target_compile_options(SRB2SDL2 PRIVATE -fsanitize=address)
|
||||
target_link_options(SRB2SDL2 PRIVATE -fsanitize=address)
|
||||
endif()
|
||||
|
||||
if(SRB2_CONFIG_UBSAN)
|
||||
target_compile_options(SRB2SDL2 PRIVATE -fsanitize=undefined)
|
||||
target_link_options(SRB2SDL2 PRIVATE -fsanitize=undefined)
|
||||
endif()
|
||||
|
||||
if(SRB2_CONFIG_TIDY)
|
||||
set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-checks=*")
|
||||
endif()
|
||||
|
||||
add_subdirectory(blua)
|
||||
add_subdirectory(sdl)
|
||||
add_subdirectory(core)
|
||||
|
||||
# OS macros
|
||||
if (UNIX)
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DUNIXCOMMON)
|
||||
target_link_libraries(SRB2SDL2 PRIVATE -rdynamic) # Use -rdynamic so a backtrace log shows function names
|
||||
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)
|
||||
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)
|
||||
add_definitions(-DHAVE_LIBGME)
|
||||
else()
|
||||
message(WARNING "You have specified that GME is available but it was not found.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DMACOSX)
|
||||
if(${SRB2_CONFIG_HAVE_DISCORDRPC})
|
||||
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
|
||||
set(DISCORDRPC_FOUND ON)
|
||||
if(${SRB2_SYSTEM_BITS} EQUAL 64)
|
||||
set(DISCORDRPC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/discord-rpc/win64-dynamic/include)
|
||||
set(DISCORDRPC_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/discord-rpc/win64-dynamic/lib -ldiscord-rpc")
|
||||
else() # 32-bit
|
||||
set(DISCORDRPC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/discord-rpc/win32-dynamic/include)
|
||||
set(DISCORDRPC_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/discord-rpc/win32-dynamic/lib -ldiscord-rpc")
|
||||
endif()
|
||||
else()
|
||||
find_package(DiscordRPC)
|
||||
endif()
|
||||
if(${DISCORDRPC_FOUND})
|
||||
set(SRB2_HAVE_DISCORDRPC ON)
|
||||
add_definitions(-DHAVE_DISCORDRPC)
|
||||
add_definitions(-DUSE_STUN)
|
||||
set(SRB2_DISCORDRPC_SOURCES discord.c stun.c)
|
||||
set(SRB2_DISCORDRPC_HEADERS discord.h stun.h)
|
||||
prepend_sources(SRB2_DISCORDRPC_SOURCES)
|
||||
prepend_sources(SRB2_DISCORDRPC_HEADERS)
|
||||
source_group("Discord Rich Presence" FILES ${SRB2_DISCORDRPC_SOURCES} ${SRB2_DISCORDRPC_HEADERS})
|
||||
else()
|
||||
message(WARNING "You have specified that Discord Rich Presence is available but it was not found.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# add toggle for this
|
||||
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_compile_definitions(SRB2SDL2 PRIVATE -DUSE_STUN)
|
||||
if(SRB2_CONFIG_ENABLE_DISCORDRPC)
|
||||
target_link_libraries(SRB2SDL2 PRIVATE DiscordRPC::DiscordRPC)
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_DISCORDRPC)
|
||||
target_sources(SRB2SDL2 PRIVATE discord.c)
|
||||
endif()
|
||||
|
||||
if(${SRB2_CONFIG_LIBBACKTRACE})
|
||||
target_link_libraries(SRB2SDL2 PRIVATE libbacktrace)
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_LIBBACKTRACE)
|
||||
endif()
|
||||
|
||||
# FIXME macOS does not support C11 threads.h
|
||||
if(NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
|
||||
set(SRB2_HAVE_THREADS ON)
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_THREADS)
|
||||
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)
|
||||
add_definitions(-DHAVE_OPENMPT)
|
||||
else()
|
||||
message(WARNING "You have specified that OpenMPT is available but it was not found.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(${SRB2_CONFIG_HAVE_ZLIB})
|
||||
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
|
||||
set(ZLIB_FOUND ON)
|
||||
set(ZLIB_COMPAT ON)
|
||||
set(WITH_GTEST OFF)
|
||||
set(ZLIB_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/zlib)
|
||||
if(${SRB2_SYSTEM_BITS} EQUAL 64)
|
||||
set(ZLIB_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/zlib/win32 -lz64")
|
||||
@@ -152,9 +419,9 @@ if(${SRB2_CONFIG_HAVE_ZLIB})
|
||||
endif()
|
||||
if(${ZLIB_FOUND})
|
||||
set(SRB2_HAVE_ZLIB ON)
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_ZLIB)
|
||||
add_definitions(-DHAVE_ZLIB)
|
||||
else()
|
||||
message(WARNING "You have specified that ZLIB is available but it was not found. SRB2Kart-Saturn may not compile correctly.")
|
||||
message(WARNING "You have specified that ZLIB is available but it was not found. SRB2Kart may not compile correctly.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -173,292 +440,129 @@ if(${SRB2_CONFIG_HAVE_PNG} AND ${SRB2_CONFIG_HAVE_ZLIB})
|
||||
endif()
|
||||
if(${PNG_FOUND})
|
||||
set(SRB2_HAVE_PNG ON)
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_PNG)
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -D_LARGEFILE64_SOURCE)
|
||||
add_definitions(-DHAVE_PNG)
|
||||
add_definitions(-D_LARGEFILE64_SOURCE)
|
||||
source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS})
|
||||
else()
|
||||
message(WARNING "You have specified that PNG is available but it was not found. SRB2Kart-Saturn may not compile correctly.")
|
||||
message(WARNING "You have specified that PNG is available but it was not found. SRB2Kart may not compile correctly.")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
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.")
|
||||
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)
|
||||
add_definitions(-DHAVE_CURL)
|
||||
else()
|
||||
message(WARNING "You have specified that CURL is available but it was not found. SRB2Kart may not compile correctly.")
|
||||
endif()
|
||||
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"
|
||||
if(${SRB2_CONFIG_HWRENDER})
|
||||
add_definitions(-DHWRENDER)
|
||||
set(SRB2_HWRENDER_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_batching.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_shaders.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_bsp.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_cache.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_draw.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_portal.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md3load.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_model.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/u_list.c
|
||||
)
|
||||
target_include_directories(SRB2SDL2 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../libs/drmingw/include")
|
||||
|
||||
set (SRB2_HWRENDER_HEADERS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_batching.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_shaders.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_data.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_defs.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_dll.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_gl.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_glob.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_portal.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md3load.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_model.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/u_list.h
|
||||
)
|
||||
|
||||
set(SRB2_R_OPENGL_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/r_opengl/r_opengl.c
|
||||
)
|
||||
|
||||
set(SRB2_R_OPENGL_HEADERS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/r_opengl/r_opengl.h
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL})
|
||||
find_package(OpenGL)
|
||||
if(${OPENGL_FOUND})
|
||||
add_definitions(-DHWRENDER)
|
||||
add_definitions(-DSTATIC_OPENGL)
|
||||
else()
|
||||
message(WARNING "You have specified static opengl but opengl was not found. Not setting HWRENDER.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(${SRB2_CONFIG_HWRENDER})
|
||||
if(${SRB2_CONFIG_USE_FBO_OGL})
|
||||
set(SRB2_USE_FBO_OGL ON)
|
||||
add_definitions(-DUSE_FBO_OGL)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Targets
|
||||
|
||||
# If using CCACHE, then force it.
|
||||
# https://github.com/Cockatrice/Cockatrice/pull/3052/files
|
||||
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")
|
||||
# Set up wrapper scripts
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/launch-c.in ${CMAKE_BINARY_DIR}/launch-c)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/launch-cxx.in ${CMAKE_BINARY_DIR}/launch-cxx)
|
||||
execute_process(COMMAND chmod a+rx
|
||||
"${CMAKE_BINARY_DIR}/launch-c"
|
||||
"${CMAKE_BINARY_DIR}/launch-cxx")
|
||||
|
||||
# Set Xcode project attributes to route compilation through our scripts
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/launch-c")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/launch-cxx")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR}/launch-c")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR}/launch-cxx")
|
||||
endif()
|
||||
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" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|x64|amd64|AMD64|em64t|EM64T)")
|
||||
target_compile_options(SRB2SDL2 PRIVATE -mno-ms-bitfields)
|
||||
endif()
|
||||
target_compile_options(SRB2SDL2 PRIVATE -Wno-trigraphs)
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -mno-ms-bitfields)
|
||||
endif()
|
||||
|
||||
# TODO: fix prng and P_CreateBlockmap overflow at some point
|
||||
target_compile_options(SRB2SDL2 PRIVATE -fwrapv)
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-absolute-value)
|
||||
endif()
|
||||
|
||||
if (${CMAKE_BUILD_TYPE} MATCHES Debug)
|
||||
target_compile_options(SRB2SDL2 PRIVATE -O0)
|
||||
target_compile_options(SRB2SDL2 PRIVATE -g)
|
||||
add_definitions(-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}
|
||||
#)
|
||||
|
||||
if(${SRB2_CONFIG_DEDICATED})
|
||||
add_subdirectory(dedicated)
|
||||
else()
|
||||
target_compile_options(SRB2SDL2 PRIVATE -O3)
|
||||
target_compile_options(SRB2SDL2 PRIVATE -g1) #should be enough for libbacktrace
|
||||
add_subdirectory(sdl)
|
||||
endif()
|
||||
|
||||
# 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
|
||||
$<$<AND:$<COMPILE_LANGUAGE:C>,$<C_COMPILER_ID:GNU>>:
|
||||
-Wall
|
||||
-Wextra
|
||||
-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
|
||||
-Wno-alloc-size-larger-than # holy shit, be quiet up GCC
|
||||
-Wmissing-prototypes
|
||||
-Wmissing-declarations
|
||||
-Wmissing-noreturn
|
||||
-Wnested-externs
|
||||
-Wformat-y2k
|
||||
-Wformat-security
|
||||
|
||||
$<$<VERSION_LESS:$<C_COMPILER_VERSION>,2.9.5>:
|
||||
-Wno-div-by-zero
|
||||
-Wendif-labels
|
||||
-Wdisabled-optimization
|
||||
>
|
||||
|
||||
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.0.0>:
|
||||
-Wold-style-definition
|
||||
-Wmissing-field-initializers
|
||||
>
|
||||
|
||||
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.1.0>:
|
||||
-Wshadow
|
||||
>
|
||||
|
||||
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.3.0>:
|
||||
-funit-at-a-time
|
||||
-Wlogical-op
|
||||
>
|
||||
|
||||
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.5.0>:
|
||||
-Wlogical-op
|
||||
-Wno-error=array-bounds
|
||||
>
|
||||
|
||||
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.6.0>:
|
||||
-Wno-suggest-attribute=noreturn
|
||||
-Wno-error=suggest-attribute=noreturn
|
||||
>
|
||||
|
||||
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,5.4.0>:
|
||||
-Wno-logical-op
|
||||
-Wno-error=logical-op
|
||||
>
|
||||
|
||||
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,6.1.0>:
|
||||
-Wno-tautological-compare
|
||||
-Wno-error=tautological-compare
|
||||
>
|
||||
|
||||
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,7.1.0>:
|
||||
-Wno-error=format-overflow=2
|
||||
-Wimplicit-fallthrough=4
|
||||
>
|
||||
|
||||
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,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
|
||||
>
|
||||
|
||||
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,9.1.0>:
|
||||
-Wno-error=address-of-packed-member
|
||||
>
|
||||
>
|
||||
|
||||
# C, Clang and Apple Clang
|
||||
$<$<AND:$<COMPILE_LANGUAGE:C>,$<OR:$<C_COMPILER_ID:AppleClang>,$<C_COMPILER_ID:Clang>>>:
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wno-absolute-value
|
||||
-Wno-trigraphs
|
||||
-Wno-error=non-literal-null-conversion
|
||||
-Wno-error=constant-conversion
|
||||
-Wno-unused-but-set-variable
|
||||
-Wno-error=unused-but-set-variable
|
||||
>
|
||||
|
||||
# C++, GNU, Clang and Apple Clang
|
||||
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<OR:$<C_COMPILER_ID:GNU>,$<C_COMPILER_ID:AppleClang>,$<C_COMPILER_ID:Clang>>>:
|
||||
-Wall
|
||||
-Wno-unused-function
|
||||
-Wno-unused-but-set-variable
|
||||
-Wno-unused-private-field
|
||||
>
|
||||
|
||||
# GNU
|
||||
$<$<C_COMPILER_ID:GNU>:
|
||||
-fmax-errors=5
|
||||
>
|
||||
)
|
||||
if(SRB2_CONFIG_ERRORMODE)
|
||||
target_compile_options(SRB2SDL2 PRIVATE
|
||||
$<$<OR:$<C_COMPILER_ID:GNU>,$<C_COMPILER_ID:AppleClang>,$<C_COMPILER_ID:Clang>>:
|
||||
-Werror
|
||||
>
|
||||
)
|
||||
endif()
|
||||
|
||||
# Link warnings configuration
|
||||
target_link_options(SRB2SDL2 PRIVATE
|
||||
$<$<C_COMPILER_ID:GNU>:
|
||||
# -Wl,--as-needed - Was controlled by NOLDWARNING
|
||||
>
|
||||
)
|
||||
|
||||
if(${SRB2_CONFIG_DEV_BUILD})
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DDEVELOP)
|
||||
endif()
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DCMAKECONFIG)
|
||||
|
||||
# Misc. build options from Makefiles
|
||||
if(SRB2_CONFIG_DEBUGMODE)
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -D_DEBUG -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()
|
||||
|
||||
if(SRB2_CONFIG_LTO AND NOT SRB2_CONFIG_DEBUGMODE)
|
||||
set_property(TARGET SRB2SDL2 PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||
endif()
|
||||
|
||||
if(${SRB2_CONFIG_SCREENFBO} AND NOT ${SRB2_CONFIG_STATIC_OPENGL})
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DUSE_FBO_OGL)
|
||||
endif()
|
||||
|
||||
if(${SRB2_CONFIG_SATURNPAK})
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DDOSATURNPAK)
|
||||
endif()
|
||||
|
||||
if(${SRB2_CONFIG_SATURNJOIN})
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DDOSATURNJOIN)
|
||||
endif()
|
||||
|
||||
# strip debug symbols into separate file when using gcc or clang.
|
||||
# to be consistent with Makefile, don't generate for OS X.
|
||||
if((CMAKE_COMPILER_IS_GNUCC OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") 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")
|
||||
endif()
|
||||
message(STATUS "Will make separate debug symbols in *.debug")
|
||||
add_custom_command(TARGET SRB2SDL2 POST_BUILD
|
||||
COMMAND ${CMAKE_OBJCOPY} ${OBJCOPY_ONLY_KEEP_DEBUG} $<TARGET_FILE:SRB2SDL2> $<TARGET_FILE:SRB2SDL2>.debug
|
||||
# mold linker: .gnu_debuglink is present by default, so --add-gnu-debuglink would fail
|
||||
COMMAND ${CMAKE_OBJCOPY} --strip-debug --remove-section=.gnu_debuglink $<TARGET_FILE:SRB2SDL2>
|
||||
COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=$<TARGET_FILE:SRB2SDL2>.debug $<TARGET_FILE:SRB2SDL2>
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# 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 OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
# also copy implicitly linked system libraries
|
||||
get_filename_component(MINGW_BIN_PATH ${CMAKE_CXX_COMPILER} PATH)
|
||||
if("${CMAKE_C_COMPILER_ID}" STREQUAL GNU)
|
||||
list(APPEND ADDITIONAL_DLLS
|
||||
"libgcc_s_dw2-1.dll"
|
||||
"libstdc++-6.dll"
|
||||
"libwinpthread-1.dll"
|
||||
)
|
||||
else()
|
||||
list(APPEND ADDITIONAL_DLLS
|
||||
"libunwind.dll"
|
||||
"libc++.dll"
|
||||
"libwinpthread-1.dll"
|
||||
)
|
||||
endif()
|
||||
list(TRANSFORM ADDITIONAL_DLLS PREPEND "${MINGW_BIN_PATH}/")
|
||||
endif()
|
||||
add_custom_command(TARGET SRB2SDL2 POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
$<TARGET_RUNTIME_DLLS:SRB2SDL2>
|
||||
${ADDITIONAL_DLLS}
|
||||
|
||||
$<TARGET_FILE_DIR:SRB2SDL2>
|
||||
COMMAND_EXPAND_LISTS
|
||||
COMMENT "Copying runtime DLLs"
|
||||
)
|
||||
if(NOT ${SRB2_SDL2_AVAILABLE} AND NOT ${SRB2_WIN32_AVAILABLE})
|
||||
message(FATAL_ERROR "There are no targets available to build an SRB2Kart executable. :(")
|
||||
endif()
|
||||
@@ -64,7 +64,7 @@ endif
|
||||
|
||||
# This must have high to low order.
|
||||
gcc_versions:=\
|
||||
151 150 15\
|
||||
152 151 150 15\
|
||||
142 141 140 14\
|
||||
132 131 130 13\
|
||||
123 122 121 120 12\
|
||||
@@ -77,7 +77,7 @@ gcc_versions:=\
|
||||
55 54 53 52 51 50\
|
||||
49 48 47 46 45 44 43 42 41 40
|
||||
|
||||
latest_gcc_version:=15.1.1
|
||||
latest_gcc_version:=15.2
|
||||
|
||||
# Automatically set version flag, but not if one was
|
||||
# manually set. And don't bother if this is a clean only
|
||||
|
||||
@@ -20,7 +20,7 @@ $(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\
|
||||
CXXFLAGS+= -Wno-aggregate-return
|
||||
|
||||
# -W -Wno-unused
|
||||
WFLAGS:=-Wall -Wno-trigraphs
|
||||
WFLAGS:=-Wall -Wno-trigraphs -Wnull-dereference
|
||||
ifndef GCC295
|
||||
#WFLAGS+=-Wno-packed
|
||||
endif
|
||||
|
||||
@@ -226,10 +226,6 @@ const char *I_LocateWad(void)
|
||||
return "/sdcard/srb2";
|
||||
}
|
||||
|
||||
void I_GetJoystickEvents(void){}
|
||||
|
||||
void I_GetJoystick2Events(void){}
|
||||
|
||||
char *I_GetEnv(const char *name)
|
||||
{
|
||||
LOGW("I_GetEnv() called?!");
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
target_sourcefile(c)
|
||||
+3
-3
@@ -13,13 +13,13 @@
|
||||
#ifndef __COMMAND_H__
|
||||
#define __COMMAND_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include "doomdef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "doomdef.h"
|
||||
|
||||
//===================================
|
||||
// Command buffer & command execution
|
||||
//===================================
|
||||
|
||||
+38
-3
@@ -11,6 +11,21 @@
|
||||
|
||||
#ifdef CMAKECONFIG
|
||||
|
||||
// Base SRB2 hashes
|
||||
#define ASSET_HASH_SRB2_SRB "${SRB2_ASSET_srb2.srb_HASH}"
|
||||
#ifdef USE_PATCH_DTA
|
||||
#define ASSET_HASH_PATCH_DTA "${SRB2_ASSET_patch.dta_HASH}"
|
||||
#endif
|
||||
|
||||
// SRB2Kart-specific hashes
|
||||
#define ASSET_HASH_GFX_KART "${SRB2_ASSET_gfx.kart_HASH}"
|
||||
#define ASSET_HASH_TEXTURES_KART "${SRB2_ASSET_textures.kart_HASH}"
|
||||
#define ASSET_HASH_CHARS_KART "${SRB2_ASSET_chars.kart_HASH}"
|
||||
#define ASSET_HASH_MAPS_KART "${SRB2_ASSET_maps.kart_HASH}"
|
||||
#ifdef USE_PATCH_KART
|
||||
#define ASSET_HASH_PATCH_KART "00000000000000000000000000000000"
|
||||
#endif
|
||||
|
||||
#define SRB2_COMP_REVISION "${SRB2_COMP_REVISION}"
|
||||
#define SRB2_COMP_BRANCH "${SRB2_COMP_BRANCH}"
|
||||
|
||||
@@ -18,10 +33,30 @@
|
||||
|
||||
#else
|
||||
|
||||
#define SRB2_COMP_REVISION ""
|
||||
#define SRB2_COMP_BRANCH ""
|
||||
/* Manually defined asset hashes for non-CMake builds
|
||||
* Last updated 2015 / 05 / 03 - SRB2 v2.1.15 - srb2.srb
|
||||
* Last updated 2018 / 12 / 23 - SRB2 v2.1.22 - patch.dta
|
||||
* Last updated 2019 / 01 / 18 - Kart v1.0.2 - Main assets
|
||||
* Last updated 2020 / 08 / 30 - Kart v1.3 - patch.kart
|
||||
* Last updated 2022 / 08 / 16 - Kart v1.4 - Main assets
|
||||
* Last updated 2022 / 08 / 19 - Kart v1.5 - gfx.kart
|
||||
* Last updated 2022 / 11 / 01 - Kart v1.6 - gfx.kart, maps.kart
|
||||
*/
|
||||
|
||||
#define CMAKE_ASSETS_DIR ""
|
||||
// Base SRB2 hashes
|
||||
#define ASSET_HASH_SRB2_SRB "c1b9577687f8a795104aef4600720ea7"
|
||||
#ifdef USE_PATCH_DTA
|
||||
#define ASSET_HASH_PATCH_DTA "b04fd9624bfd94dc96dcf4f400f7deb4"
|
||||
#endif
|
||||
|
||||
// SRB2Kart-specific hashes
|
||||
#define ASSET_HASH_GFX_KART "06f86ee16136eb8a7043b15001797034"
|
||||
#define ASSET_HASH_TEXTURES_KART "abb53d56aba47c3a8cb0f764da1c8b80"
|
||||
#define ASSET_HASH_CHARS_KART "e2c428347dde52858a3dacd29fc5b964"
|
||||
#define ASSET_HASH_MAPS_KART "d051e55141ba736582228c456953cd98"
|
||||
#ifdef USE_PATCH_KART
|
||||
#define ASSET_HASH_PATCH_KART "00000000000000000000000000000000"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -80,31 +80,6 @@
|
||||
|
||||
#include "lua_script.h"
|
||||
|
||||
/* Manually defined asset hashes for non-CMake builds
|
||||
* Last updated 2015 / 05 / 03 - SRB2 v2.1.15 - srb2.srb
|
||||
* Last updated 2018 / 12 / 23 - SRB2 v2.1.22 - patch.dta
|
||||
* Last updated 2019 / 01 / 18 - Kart v1.0.2 - Main assets
|
||||
* Last updated 2020 / 08 / 30 - Kart v1.3 - patch.kart
|
||||
* Last updated 2022 / 08 / 16 - Kart v1.4 - Main assets
|
||||
* Last updated 2022 / 08 / 19 - Kart v1.5 - gfx.kart
|
||||
* Last updated 2022 / 11 / 01 - Kart v1.6 - gfx.kart, maps.kart
|
||||
*/
|
||||
|
||||
// Base SRB2 hashes
|
||||
#define ASSET_HASH_SRB2_SRB "c1b9577687f8a795104aef4600720ea7"
|
||||
#ifdef USE_PATCH_DTA
|
||||
#define ASSET_HASH_PATCH_DTA "b04fd9624bfd94dc96dcf4f400f7deb4"
|
||||
#endif
|
||||
|
||||
// SRB2Kart-specific hashes
|
||||
#define ASSET_HASH_GFX_KART "06f86ee16136eb8a7043b15001797034"
|
||||
#define ASSET_HASH_TEXTURES_KART "abb53d56aba47c3a8cb0f764da1c8b80"
|
||||
#define ASSET_HASH_CHARS_KART "e2c428347dde52858a3dacd29fc5b964"
|
||||
#define ASSET_HASH_MAPS_KART "d051e55141ba736582228c456953cd98"
|
||||
#ifdef USE_PATCH_KART
|
||||
#define ASSET_HASH_PATCH_KART "00000000000000000000000000000000"
|
||||
#endif
|
||||
|
||||
#ifdef CMAKECONFIG
|
||||
#include "config.h"
|
||||
#else
|
||||
|
||||
@@ -167,6 +167,8 @@ static char returnWadPath[256];
|
||||
#include "../i_video.h"
|
||||
#include "../i_sound.h"
|
||||
#include "../i_system.h"
|
||||
#include "../i_time.h"
|
||||
#include "../i_net.h"
|
||||
#include "../screen.h" //vid.WndParent
|
||||
#include "../d_net.h"
|
||||
#include "../g_game.h"
|
||||
@@ -178,6 +180,10 @@ static char returnWadPath[256];
|
||||
|
||||
#include "../m_argv.h"
|
||||
|
||||
#ifdef MAC_ALERT
|
||||
#include "macosx/mac_alert.h"
|
||||
#endif
|
||||
|
||||
#include "../d_main.h"
|
||||
|
||||
#if !defined(NOMUMBLE) && defined(HAVE_MUMBLE)
|
||||
@@ -192,8 +198,6 @@ UINT8 keyboard_started = false;
|
||||
|
||||
#ifdef HAVE_TERMIOS
|
||||
// TERMIOS console code from Quake3: thank you!
|
||||
boolean stdin_active = true;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
size_t cursor;
|
||||
@@ -695,11 +699,7 @@ void I_JoyScale4(void)
|
||||
|
||||
|
||||
*/
|
||||
void I_ShutdownJoystick(void)
|
||||
{
|
||||
}
|
||||
|
||||
void I_GetJoystickEvents(UINT8 index)
|
||||
void I_ShutdownJoystick(UINT8 index)
|
||||
{
|
||||
(void)index;
|
||||
}
|
||||
|
||||
@@ -115,6 +115,10 @@ INT32 VID_GetModeForSize(INT32 w, INT32 h)
|
||||
return -1;
|
||||
}
|
||||
|
||||
void VID_RefreshModeList(void)
|
||||
{
|
||||
}
|
||||
|
||||
void VID_PrepareModeList(void)
|
||||
{
|
||||
}
|
||||
@@ -125,6 +129,13 @@ INT32 VID_SetMode(INT32 modeNum)
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean I_CheckAboveDesktopRes(INT32 width, INT32 height)
|
||||
{
|
||||
(void)width;
|
||||
(void)height;
|
||||
return false;
|
||||
}
|
||||
|
||||
void I_StartupGraphics(void)
|
||||
{
|
||||
}
|
||||
|
||||
+7
-7
@@ -40,13 +40,6 @@
|
||||
#define ASMCALL
|
||||
#endif
|
||||
|
||||
#define _USE_MATH_DEFINES // fixes M_PI errors in r_plane.c for Visual Studio
|
||||
#ifdef __cplusplus
|
||||
#include <cmath>
|
||||
#else
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -58,6 +51,13 @@ extern "C" {
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define _USE_MATH_DEFINES // fixes M_PI errors in r_plane.c for Visual Studio
|
||||
#ifdef __cplusplus
|
||||
#include <cmath>
|
||||
#else
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <ctype.h>
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
target_sourcefile(c)
|
||||
@@ -619,7 +619,6 @@ static void HWR_PrecacheLevelFlats(void)
|
||||
// lookup for flats that may´ve been already loaded
|
||||
// too lazy to make a hashtable or smth so unordered set will do :carbuncle:
|
||||
std::unordered_set<UINT32> flatpresent;
|
||||
lumpnum_t lump;
|
||||
size_t i, j;
|
||||
INT32 k;
|
||||
|
||||
@@ -649,9 +648,8 @@ static void HWR_PrecacheLevelFlats(void)
|
||||
const INT32 pic = ceiling ? sec->ceilingpic : sec->floorpic;
|
||||
|
||||
const levelflat_t *levelflat = &levelflats[pic];
|
||||
lump = levelflat->lumpnum;
|
||||
|
||||
load_flat(lump, R_NoEncore(sec, ceiling));
|
||||
load_flat(levelflat->lumpnum, R_NoEncore(sec, ceiling));
|
||||
|
||||
if (levelflat->speed) // is it an animated flat ?
|
||||
{
|
||||
@@ -672,9 +670,8 @@ static void HWR_PrecacheLevelFlats(void)
|
||||
for (i = 0; i < numlevelflats; i++)
|
||||
{
|
||||
const levelflat_t *levelflat = &levelflats[i];
|
||||
lump = levelflat->lumpnum;
|
||||
|
||||
load_flat(lump, false);
|
||||
load_flat(levelflat->lumpnum, false);
|
||||
|
||||
if (levelflat->speed) // is it an animated flat ?
|
||||
{
|
||||
|
||||
@@ -5538,7 +5538,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool
|
||||
player_t *viewplayer = &players[displayplayers[viewssnum]];
|
||||
const float fpov = FixedToFloat(R_GetPlayerFov(viewplayer));
|
||||
|
||||
auto reset_viewstate = [&](const float fpov)
|
||||
auto reset_viewstate = [&]()
|
||||
{
|
||||
HWR_SetTransform(fpov);
|
||||
HWR_ClearSprites();
|
||||
@@ -5558,7 +5558,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool
|
||||
currentportallist = &portallist;
|
||||
HWR_SetPortalState(GLPORTAL_SEARCH);
|
||||
|
||||
reset_viewstate(fpov);
|
||||
reset_viewstate();
|
||||
|
||||
if (rootportal)
|
||||
{
|
||||
@@ -5584,7 +5584,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool
|
||||
// draw normal things in current frame in current incremented stencil buffer area
|
||||
HWR_SetStencilState(HWR_STENCIL_NORMAL, stencil_level);
|
||||
|
||||
reset_viewstate(fpov);
|
||||
reset_viewstate();
|
||||
|
||||
if constexpr (Type == RenderViewpointType::kPortal)
|
||||
{
|
||||
|
||||
@@ -29,6 +29,10 @@ extern "C" {
|
||||
*/
|
||||
#define MAX_QUIT_FUNCS 16
|
||||
|
||||
void I_GetConsoleEvents(void);
|
||||
|
||||
extern boolean consolevent;
|
||||
extern boolean framebuffer;
|
||||
|
||||
/** \brief Graphic system had started up
|
||||
*/
|
||||
|
||||
+11
-2
@@ -95,6 +95,7 @@ INT32 VID_SetMode(INT32 modenum);
|
||||
*/
|
||||
const char *VID_GetModeName(INT32 modenum);
|
||||
|
||||
void VID_RefreshModeList(void);
|
||||
void VID_PrepareModeList(void);
|
||||
|
||||
/** \brief can video system do fullscreen
|
||||
@@ -121,12 +122,11 @@ void I_ReadScreen(UINT8 * restrict scr, INT32 scale);
|
||||
|
||||
UINT32 I_GetRefreshRate(void);
|
||||
|
||||
boolean I_CheckAboveDesktopRes(INT32 width, INT32 height);
|
||||
boolean I_CheckNativeRes(void);
|
||||
|
||||
void I_SetBorderlessWindow(void);
|
||||
|
||||
void I_HandleControllerHatRepeat(void);
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
|
||||
void RefreshOGLSDLSurface(void);
|
||||
@@ -135,6 +135,15 @@ boolean UseScreenFBO(void);
|
||||
extern boolean downsample;
|
||||
#endif
|
||||
|
||||
// So we can call this from i_video event loop
|
||||
void I_ShutdownJoystick(UINT8 index);
|
||||
|
||||
// Quick thing to make SDL_JOYDEVICEADDED events less of an abomination
|
||||
void I_UpdateJoystickDeviceIndex(UINT8 player);
|
||||
void I_UpdateJoystickDeviceIndices(UINT8 excludePlayer);
|
||||
|
||||
void I_HandleControllerHatRepeat(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
+20
-17
@@ -1064,9 +1064,13 @@ static void ArchiveTables(UINT8 **p)
|
||||
{
|
||||
// Write key
|
||||
e = ArchiveValue(p, TABLESINDEX, -2); // key should be either a number or a string, ArchiveValue can handle this.
|
||||
if (e == 2) // invalid key type (function, thread, lightuserdata, or anything we don't recognise)
|
||||
if (e == 1)
|
||||
n++; // the table contained a new table we'll have to archive. :(
|
||||
else if (e == 2) // invalid key type (function, thread, lightuserdata, or anything we don't recognise)
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "Index '%s' (%s) of table %d could not be archived!\n", lua_tostring(gL, -2), luaL_typename(gL, -2), i);
|
||||
lua_pop(gL, 1);
|
||||
continue;
|
||||
}
|
||||
else if (e == 3) // nil key due to invalid userdata. NOT an error.
|
||||
{
|
||||
@@ -1077,15 +1081,12 @@ static void ArchiveTables(UINT8 **p)
|
||||
// Write value
|
||||
e = ArchiveValue(p, TABLESINDEX, -1);
|
||||
if (e == 1)
|
||||
{
|
||||
n++; // the table contained a new table we'll have to archive. :(
|
||||
}
|
||||
else if (e == 2) // invalid value type
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "Type of value for table %d entry '%s' (%s) could not be archived!\n", i, lua_tostring(gL, -2), luaL_typename(gL, -1));
|
||||
}
|
||||
|
||||
lua_pop(gL, 1);
|
||||
|
||||
}
|
||||
lua_pop(gL, 1);
|
||||
WRITEUINT8(*p, ARCH_TEND);
|
||||
@@ -1276,13 +1277,21 @@ static void UnArchiveTables(UINT8 **p, boolean network)
|
||||
UINT8 ret;
|
||||
|
||||
ret = UnArchiveValue(p, TABLESINDEX, network);
|
||||
if (ret == 3)
|
||||
if (ret == 1) // End of table
|
||||
break;
|
||||
else if (ret == 2) // Key contains a new table
|
||||
n++;
|
||||
else if (ret == 3)
|
||||
{
|
||||
//CONS_Alert(CONS_WARNING,"Couldn't read mobj_t\n");
|
||||
lua_pushnil(gL);
|
||||
}
|
||||
else if (ret == 1) // read key
|
||||
break;
|
||||
|
||||
if (lua_isnil(gL, -1)) // If key is nil, skip this entry
|
||||
{
|
||||
lua_pop(gL, 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
ret = UnArchiveValue(p, TABLESINDEX, network);
|
||||
if (ret == 1)
|
||||
@@ -1291,21 +1300,15 @@ static void UnArchiveTables(UINT8 **p, boolean network)
|
||||
lua_pop(gL, 1); // Pop key
|
||||
break;
|
||||
}
|
||||
else if (ret == 2) // read value
|
||||
n++;
|
||||
else if (ret == 3)
|
||||
{
|
||||
//CONS_Alert(CONS_WARNING,"Couldn't read mobj_t\n");
|
||||
lua_pushnil(gL);
|
||||
}
|
||||
else if (ret == 2) // read value
|
||||
n++;
|
||||
|
||||
if (lua_isnil(gL, -2)) // if key is nil (if a function etc was accidentally saved)
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "A nil key in table %d was found! (Invalid key type or corrupted save?)\n", i);
|
||||
lua_pop(gL, 2); // pop key and value instead of setting them in the table, to prevent Lua panic errors
|
||||
}
|
||||
else
|
||||
lua_rawset(gL, -3);
|
||||
lua_rawset(gL, -3);
|
||||
}
|
||||
|
||||
lua_pop(gL, 1);
|
||||
|
||||
+43
-51
@@ -306,7 +306,6 @@ static void M_SetupMultiHandler(INT32 choice);
|
||||
|
||||
// Options
|
||||
// Split into multiple parts due to size
|
||||
static void M_VideoModeMenu(INT32 choice);
|
||||
static void M_Setup1PControlsMenu(void);
|
||||
static void M_Setup2PControlsMenu(void);
|
||||
static void M_Setup3PControlsMenu(void);
|
||||
@@ -9713,14 +9712,11 @@ static void M_ResetControls(INT32 choice)
|
||||
// ===============
|
||||
|
||||
//added : 30-01-98:
|
||||
#define MAXCOLUMNMODES 12 //max modes displayed in one column
|
||||
#define MAXMODEDESCS (MAXCOLUMNMODES*3)
|
||||
|
||||
static modedesc_t modedescs[MAXMODEDESCS];
|
||||
|
||||
static void M_VideoModeMenu(INT32 choice)
|
||||
void M_VideoModeMenu(INT32 choice)
|
||||
{
|
||||
INT32 i, j, vdup, nummodes, width, height;
|
||||
INT32 i, nummodes, width, height;
|
||||
const char *desc;
|
||||
|
||||
(void)choice;
|
||||
@@ -9734,54 +9730,30 @@ static void M_VideoModeMenu(INT32 choice)
|
||||
nummodes = VID_NumModes();
|
||||
|
||||
// DOS does not skip mode 0, because mode 0 is ALWAYS present
|
||||
i = 0;
|
||||
for (; i < nummodes && vidm_nummodes < MAXMODEDESCS; i++)
|
||||
for (i = 0; i < nummodes && vidm_nummodes < MAXMODEDESCS; i++)
|
||||
{
|
||||
desc = VID_GetModeName(i);
|
||||
if (desc)
|
||||
{
|
||||
vdup = 0;
|
||||
|
||||
// when a resolution exists both under VGA and VESA, keep the
|
||||
// VESA mode, which is always a higher modenum
|
||||
for (j = 0; j < vidm_nummodes; j++)
|
||||
{
|
||||
if (fastcmp(modedescs[j].desc, desc))
|
||||
{
|
||||
// mode(0): 320x200 is always standard VGA, not vesa
|
||||
if (modedescs[j].modenum)
|
||||
{
|
||||
modedescs[j].modenum = i;
|
||||
vdup = 1;
|
||||
if (!desc)
|
||||
continue;
|
||||
|
||||
if (i == vid.modenum)
|
||||
vidm_selected = j;
|
||||
}
|
||||
else
|
||||
vdup = 1;
|
||||
modedescs[vidm_nummodes].modenum = i;
|
||||
modedescs[vidm_nummodes].desc = desc;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == vid.modenum)
|
||||
vidm_selected = vidm_nummodes;
|
||||
|
||||
if (!vdup)
|
||||
{
|
||||
modedescs[vidm_nummodes].modenum = i;
|
||||
modedescs[vidm_nummodes].desc = desc;
|
||||
// Pull out the width and height
|
||||
sscanf(desc, "%u%*c%u", &width, &height);
|
||||
|
||||
if (i == vid.modenum)
|
||||
vidm_selected = vidm_nummodes;
|
||||
// Show resolutions above desktop res as red.
|
||||
if (I_CheckAboveDesktopRes(width, height))
|
||||
modedescs[vidm_nummodes].goodratio = 2;
|
||||
// Show multiples of 320x200 as green.
|
||||
else if (SCR_IsAspectCorrect(width, height))
|
||||
modedescs[vidm_nummodes].goodratio = 1;
|
||||
|
||||
// Pull out the width and height
|
||||
sscanf(desc, "%u%*c%u", &width, &height);
|
||||
|
||||
// Show multiples of 320x200 as green.
|
||||
if (SCR_IsAspectCorrect(width, height))
|
||||
modedescs[vidm_nummodes].goodratio = 1;
|
||||
|
||||
vidm_nummodes++;
|
||||
}
|
||||
}
|
||||
vidm_nummodes++;
|
||||
}
|
||||
|
||||
vidm_column_size = (vidm_nummodes+2) / 3;
|
||||
@@ -9977,7 +9949,11 @@ static void M_DrawVideoMode(void)
|
||||
V_DrawString(row, col, highlightflags|MENUCAPS, modedescs[i].desc);
|
||||
// Show multiples of 320x200 as green.
|
||||
else
|
||||
V_DrawString(row, col, ((modedescs[i].goodratio) ? recommendedflags : 0)|MENUCAPS, modedescs[i].desc);
|
||||
{
|
||||
const UINT8 goodratio = modedescs[i].goodratio;
|
||||
const INT32 goodflag = ((goodratio == 2) ? warningflags : (goodratio == 1) ? recommendedflags : 0);
|
||||
V_DrawString(row, col, goodflag|MENUCAPS, modedescs[i].desc);
|
||||
}
|
||||
|
||||
col += 8;
|
||||
if ((i % vidm_column_size) == (vidm_column_size-1))
|
||||
@@ -10001,7 +9977,6 @@ static void M_DrawVideoMode(void)
|
||||
va("Wait %d second%s", testtime, (testtime > 1) ? "s" : ""));
|
||||
M_CentreText(OP_VideoModeDef.y + 158,
|
||||
"or press ESC to return");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -10017,9 +9992,26 @@ static void M_DrawVideoMode(void)
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 138,
|
||||
recommendedflags|MENUCAPS, "Marked modes are recommended.");
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 146,
|
||||
highlightflags|MENUCAPS, "Other modes may have visual errors.");
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 158,
|
||||
highlightflags|MENUCAPS, "Larger modes may have performance issues.");
|
||||
warningflags|MENUCAPS, "Marked modes are above Desktop resolution");
|
||||
|
||||
if (rendermode == render_opengl)
|
||||
{
|
||||
#ifdef USE_FBO_OGL
|
||||
if (!cv_glframebuffer.value)
|
||||
#endif
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 154,
|
||||
warningflags|MENUCAPS, "and will have visual errors in OpenGL mode.");
|
||||
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 166,
|
||||
highlightflags|MENUCAPS, "Other modes may have visual errors.");
|
||||
}
|
||||
else
|
||||
{
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 154,
|
||||
highlightflags|MENUCAPS, "Other modes may have visual errors.");
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 166,
|
||||
highlightflags|MENUCAPS, "Larger modes may have performance issues.");
|
||||
}
|
||||
}
|
||||
|
||||
// Draw the cursor for the VidMode menu
|
||||
|
||||
@@ -223,6 +223,11 @@ extern menu_t *currentMenu;
|
||||
extern menu_t MainDef;
|
||||
extern menu_t SP_LoadDef;
|
||||
|
||||
#define MAXCOLUMNMODES 12 //max modes displayed in one column
|
||||
#define MAXMODEDESCS (MAXCOLUMNMODES*3)
|
||||
extern menu_t OP_VideoModeDef;
|
||||
void M_VideoModeMenu(INT32 choice);
|
||||
|
||||
// Call upon joystick hotplug
|
||||
void M_SetupJoystickMenu(INT32 choice);
|
||||
extern menu_t OP_JoystickSetDef;
|
||||
|
||||
+5
-4
@@ -1346,14 +1346,15 @@ void M_MinimapGenerate(void)
|
||||
minigen = AM_MinimapGenerate(mul);
|
||||
|
||||
if (minigen == NULL || minigen->buf == NULL)
|
||||
goto failure;
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, M_GetText("Couldn't create %s\n"), filepath);
|
||||
return;
|
||||
}
|
||||
|
||||
M_CreateScreenShotPalette();
|
||||
ret = M_SavePNG(filepath, minigen->buf, minigen->w, minigen->h, screenshot_palette);
|
||||
|
||||
failure:
|
||||
if (minigen->buf != NULL)
|
||||
free(minigen->buf);
|
||||
free(minigen->buf);
|
||||
|
||||
if (ret)
|
||||
{
|
||||
|
||||
+4
-4
@@ -14,6 +14,10 @@
|
||||
#ifndef __P_LOCAL__
|
||||
#define __P_LOCAL__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "command.h"
|
||||
#include "d_player.h"
|
||||
#include "d_think.h"
|
||||
@@ -24,10 +28,6 @@
|
||||
#include "p_maputl.h"
|
||||
#include "doomstat.h" // MAXSPLITSCREENPLAYERS
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define FLOATSPEED (FRACUNIT*4)
|
||||
|
||||
//#define VIEWHEIGHTS "41"
|
||||
|
||||
+1
-2
@@ -1385,8 +1385,7 @@ static void Polyobj_rotateThings(polyobj_t *po, vector2_t origin, angle_t delta,
|
||||
|
||||
if (mo->player)
|
||||
{
|
||||
angle_t localangle = P_GetLocalAngle(mo->player);
|
||||
P_ForceLocalAngle(mo->player, localangle + delta);
|
||||
P_ForceLocalAngle(mo->player, P_GetLocalAngle(mo->player) + delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
|
||||
#include "doomdef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
@@ -47,9 +43,4 @@ mobj_t *P_SetTarget2(mobj_t **mo, mobj_t *target
|
||||
#else
|
||||
#define P_SetTarget P_SetTarget2
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -14,8 +14,6 @@
|
||||
#include "doomdef.h"
|
||||
#include "g_game.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "r_fps.h"
|
||||
#include "r_local.h"
|
||||
#include "r_state.h"
|
||||
|
||||
+4
-4
@@ -15,16 +15,16 @@
|
||||
#ifndef __R_FPS_H__
|
||||
#define __R_FPS_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "m_fixed.h"
|
||||
#include "p_local.h"
|
||||
#include "r_state.h"
|
||||
#include "r_things.h"
|
||||
#include "m_perfstats.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern consvar_t cv_fpscap, cv_fpscapbg;
|
||||
|
||||
extern ps_metric_t ps_interp_frac;
|
||||
|
||||
+4
-4
@@ -14,14 +14,14 @@
|
||||
#ifndef __R_MAIN__
|
||||
#define __R_MAIN__
|
||||
|
||||
#include "d_player.h"
|
||||
#include "r_data.h"
|
||||
#include "m_perfstats.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "d_player.h"
|
||||
#include "r_data.h"
|
||||
#include "m_perfstats.h"
|
||||
|
||||
//
|
||||
// POV related.
|
||||
//
|
||||
|
||||
+5
-7
@@ -15,8 +15,6 @@
|
||||
#include "r_local.h"
|
||||
#include "r_sky.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "r_portal.h"
|
||||
#include "r_splats.h"
|
||||
#include "r_fps.h" // newview
|
||||
@@ -2231,12 +2229,12 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
lowcutslope = std::max(worldbottomslope, worldlowslope) + viewz;
|
||||
highcutslope = std::min(worldtopslope, worldhighslope) + viewz;
|
||||
|
||||
auto check_fof_offscreen = [&](ffloor_t* rover, INT32 bottom, INT32 bottomslope, INT32 top, INT32 topslope)
|
||||
auto check_fof_offscreen = [&](ffloor_t* rrover, INT32 bottom, INT32 bottomslope, INT32 top, INT32 topslope)
|
||||
{
|
||||
return ((P_GetFFloorTopZAt (rover, segleft .x, segleft .y) <= bottom + viewz
|
||||
&& P_GetFFloorTopZAt (rover, segright.x, segright.y) <= bottomslope + viewz)
|
||||
|| ( P_GetFFloorBottomZAt (rover, segleft .x, segleft .y) >= top + viewz
|
||||
&& P_GetFFloorBottomZAt (rover, segright.x, segright.y) >= topslope + viewz));
|
||||
return ((P_GetFFloorTopZAt (rrover, segleft .x, segleft .y) <= bottom + viewz
|
||||
&& P_GetFFloorTopZAt (rrover, segright.x, segright.y) <= bottomslope + viewz)
|
||||
|| ( P_GetFFloorBottomZAt (rrover, segleft .x, segleft .y) >= top + viewz
|
||||
&& P_GetFFloorBottomZAt (rrover, segright.x, segright.y) >= topslope + viewz));
|
||||
};
|
||||
|
||||
if (frontsector->ffloors && backsector->ffloors)
|
||||
|
||||
+1
-1
@@ -1577,7 +1577,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||
else
|
||||
blendmode = thing->blendmode;
|
||||
|
||||
if (thing->flags2 & MF2_SHADOW || thing->flags2 & MF2_SHADOW) // actually only the player should use this (temporary invisibility)
|
||||
if (thing->flags2 & MF2_SHADOW) // actually only the player should use this (temporary invisibility)
|
||||
trans = tr_trans80; // because now the translucency is set through FF_TRANSMASK
|
||||
else if (thing->frame & FF_TRANSMASK)
|
||||
{
|
||||
|
||||
@@ -1491,6 +1491,9 @@ musicdef_t *S_FindMusicCredit(const char *musname)
|
||||
{
|
||||
def = S_GetMusicCredit(i);
|
||||
|
||||
if (!def)
|
||||
continue;
|
||||
|
||||
if (hash != def->hash)
|
||||
continue;
|
||||
|
||||
|
||||
+5
-4
@@ -42,8 +42,8 @@ INT32 setmodeneeded = 0; // video mode change needed if > 0 (the mode number to
|
||||
static CV_PossibleValue_t shittyscreen_cons_t[] = {{0, "Okay"}, {1, "Shitty"}, {2, "Extra Shitty"}, {0, NULL}};
|
||||
|
||||
//added : 03-02-98: default screen mode, as loaded/saved in config
|
||||
consvar_t cv_scr_width = {"scr_width", "1280", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_scr_height = {"scr_height", "800", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_scr_width = {"scr_width", "1280", CV_SAVE|CV_CALL, CV_Unsigned, VID_RefreshModeList, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_scr_height = {"scr_height", "800", CV_SAVE|CV_CALL, CV_Unsigned, VID_RefreshModeList, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_renderview = {"renderview", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
consvar_t cv_frameskip = {"frameskip", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
@@ -315,8 +315,9 @@ void SCR_CheckDefaultMode(void)
|
||||
void SCR_SetDefaultMode(void)
|
||||
{
|
||||
// remember the default screen size
|
||||
CV_SetValue(&cv_scr_width, vid.width);
|
||||
CV_SetValue(&cv_scr_height, vid.height);
|
||||
CV_StealthSetValue(&cv_scr_width, vid.width);
|
||||
CV_StealthSetValue(&cv_scr_height, vid.height);
|
||||
VID_RefreshModeList(); // probably not needed but justin käs
|
||||
}
|
||||
|
||||
// Change fullscreen on/off according to cv_fullscreen
|
||||
|
||||
+329
-94
@@ -1,115 +1,350 @@
|
||||
# Declare SDL2 interface sources
|
||||
|
||||
target_sources(SRB2SDL2 PRIVATE
|
||||
mixer_sound.c
|
||||
ogl_sdl.c
|
||||
i_threads.c
|
||||
i_net.c
|
||||
i_system.cpp
|
||||
i_main.c
|
||||
i_video.c
|
||||
set(SRB2_CONFIG_SDL2_USEMIXER ON CACHE BOOL "Use SDL2_mixer or regular sdl sound")
|
||||
|
||||
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)
|
||||
set(SRB2_SDL2_SOUNDIMPL mixer_sound.c)
|
||||
else()
|
||||
message(WARNING "You specified that SDL2_mixer is available, but it was not found. Falling back to sdl sound.")
|
||||
set(SRB2_SDL2_SOUNDIMPL sdl_sound.c)
|
||||
endif()
|
||||
else()
|
||||
set(SRB2_SDL2_SOUNDIMPL sdl_sound.c)
|
||||
endif()
|
||||
|
||||
set(SRB2_SDL2_SOURCES
|
||||
dosstr.c
|
||||
endtxt.c
|
||||
hwsym_sdl.c
|
||||
i_main.c
|
||||
i_net.c
|
||||
i_system.c
|
||||
i_ttf.c
|
||||
i_video.c
|
||||
i_threads.c
|
||||
#IMG_xpm.c
|
||||
ogl_sdl.c
|
||||
|
||||
${SRB2_SDL2_SOUNDIMPL}
|
||||
)
|
||||
|
||||
if("${CMAKE_SYSTEM_NAME}" MATCHES Windows)
|
||||
target_sources(SRB2SDL2 PRIVATE
|
||||
../win32/win_dbg.c
|
||||
../win32/Srb2win.rc)
|
||||
set(SRB2_SDL2_HEADERS
|
||||
endtxt.h
|
||||
hwsym_sdl.h
|
||||
i_ttf.h
|
||||
ogl_sdl.h
|
||||
sdlmain.h
|
||||
)
|
||||
|
||||
source_group("Interface Code" FILES ${SRB2_SDL2_SOURCES} ${SRB2_SDL2_HEADERS})
|
||||
|
||||
# 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()
|
||||
else()
|
||||
find_package(SDL2)
|
||||
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_resources.c
|
||||
macosx/mac_resources.h
|
||||
macosx/Srb2mac.icns
|
||||
if(${SDL2_FOUND})
|
||||
set(SRB2_SDL2_TOTAL_SOURCES
|
||||
${SRB2_CORE_SOURCES}
|
||||
${SRB2_CORE_HEADERS}
|
||||
${SRB2_DISCORDRPC_SOURCES}
|
||||
${SRB2_DISCORDRPC_HEADERS}
|
||||
${SRB2_PNG_SOURCES}
|
||||
${SRB2_PNG_HEADERS}
|
||||
${SRB2_CORE_RENDER_SOURCES}
|
||||
${SRB2_CORE_GAME_SOURCES}
|
||||
${SRB2_LUA_SOURCES}
|
||||
${SRB2_LUA_HEADERS}
|
||||
${SRB2_BLUA_SOURCES}
|
||||
${SRB2_BLUA_HEADERS}
|
||||
${SRB2_SDL2_SOURCES}
|
||||
${SRB2_SDL2_HEADERS}
|
||||
)
|
||||
endif()
|
||||
|
||||
if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin)
|
||||
find_library(CORE_FOUNDATION_LIBRARY "CoreFoundation")
|
||||
source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS}
|
||||
${SRB2_PNG_SOURCES} ${SRB2_PNG_HEADERS})
|
||||
source_group("Renderer" FILES ${SRB2_CORE_RENDER_SOURCES})
|
||||
source_group("Game" FILES ${SRB2_CORE_GAME_SOURCES})
|
||||
source_group("Discord Rich Presence" FILES ${SRB2_DISCORDRPC_SOURCES} ${SRB2_DISCORDRPC_HEADERS})
|
||||
source_group("Assembly" FILES ${SRB2_ASM_SOURCES} ${SRB2_NASM_SOURCES})
|
||||
source_group("LUA" FILES ${SRB2_LUA_SOURCES} ${SRB2_LUA_HEADERS})
|
||||
source_group("LUA\\Interpreter" FILES ${SRB2_BLUA_SOURCES} ${SRB2_BLUA_HEADERS})
|
||||
|
||||
|
||||
if(${SRB2_CONFIG_HWRENDER})
|
||||
set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES}
|
||||
${SRB2_HWRENDER_SOURCES}
|
||||
${SRB2_HWRENDER_HEADERS}
|
||||
${SRB2_R_OPENGL_SOURCES}
|
||||
${SRB2_R_OPENGL_HEADERS}
|
||||
)
|
||||
|
||||
source_group("Hardware" FILES ${SRB2_HWRENDER_SOURCES} ${SRB2_HWRENDER_HEADERS})
|
||||
source_group("Hardware\\OpenGL Renderer" FILES ${SRB2_R_OPENGL_SOURCES} ${SRB2_R_OPENGL_HEADERS})
|
||||
endif()
|
||||
|
||||
if(${SRB2_USEASM})
|
||||
set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES}
|
||||
${SRB2_NASM_SOURCES}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES Windows)
|
||||
set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES}
|
||||
${CMAKE_SOURCE_DIR}/src/win32/win_dbg.c
|
||||
${CMAKE_SOURCE_DIR}/src/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")
|
||||
set(SRB2_SDL2_MAC_SOURCES
|
||||
macosx/mac_alert.c
|
||||
macosx/mac_alert.h
|
||||
macosx/mac_resources.c
|
||||
macosx/mac_resources.h
|
||||
macosx/Srb2mac.icns
|
||||
)
|
||||
source_group("Interface Code\\OSX Compatibility" FILES ${SRB2_SDL2_MAC_SOURCES})
|
||||
set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES} ${SRB2_SDL2_MAC_SOURCES})
|
||||
endif()
|
||||
|
||||
add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32 ${SRB2_SDL2_TOTAL_SOURCES})
|
||||
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME ${SRB2_SDL2_EXE_NAME})
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES Darwin)
|
||||
find_library(CORE_FOUNDATION_LIBRARY "CoreFoundation")
|
||||
target_link_libraries(SRB2SDL2 PRIVATE
|
||||
${CORE_FOUNDATION_LIBRARY}
|
||||
)
|
||||
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 "Sonic Robo Blast 2"
|
||||
MACOSX_BUNDLE_BUNDLE_VERSION ${SRB2_VERSION}
|
||||
|
||||
RESOURCE "${CMAKE_CURRENT_SOURCE_DIR}/macosx/Srb2mac.icns"
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(SRB2SDL2 PRIVATE
|
||||
${CORE_FOUNDATION_LIBRARY}
|
||||
${SDL2_LIBRARIES}
|
||||
${SDL2_MIXER_LIBRARIES}
|
||||
${GME_LIBRARIES}
|
||||
${OPENMPT_LIBRARIES}
|
||||
${MIXERX_LIBRARIES}
|
||||
${PNG_LIBRARIES}
|
||||
${ZLIB_LIBRARIES}
|
||||
${OPENGL_LIBRARIES}
|
||||
${CURL_LIBRARIES}
|
||||
${DISCORDRPC_LIBRARIES}
|
||||
)
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES Linux)
|
||||
target_link_libraries(SRB2SDL2 PRIVATE
|
||||
m
|
||||
rt
|
||||
)
|
||||
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)
|
||||
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 "SRB2Kart-Saturn"
|
||||
MACOSX_BUNDLE_BUNDLE_VERSION 1.6
|
||||
|
||||
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()
|
||||
target_link_libraries(SRB2SDL2 PRIVATE SDL2::SDL2 SDL2_mixer::SDL2_mixer)
|
||||
endif()
|
||||
|
||||
if("${CMAKE_SYSTEM_NAME}" MATCHES Linux)
|
||||
target_link_libraries(SRB2SDL2 PRIVATE m rt)
|
||||
endif()
|
||||
|
||||
if("${CMAKE_SYSTEM_NAME}" MATCHES Windows)
|
||||
target_link_libraries(SRB2SDL2 PRIVATE
|
||||
ws2_32
|
||||
)
|
||||
target_compile_options(SRB2SDL2 PRIVATE
|
||||
-U_WINDOWS
|
||||
)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MIXER -DSOUND=SOUND_MIXER)
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -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 $<TARGET_FILE:SRB2SDL2>.debug
|
||||
DESTINATION .
|
||||
OPTIONAL
|
||||
)
|
||||
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()
|
||||
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
|
||||
)"
|
||||
if(${CMAKE_SYSTEM} MATCHES Windows)
|
||||
target_link_libraries(SRB2SDL2 PRIVATE
|
||||
ws2_32
|
||||
)
|
||||
target_compile_options(SRB2SDL2 PRIVATE
|
||||
-U_WINDOWS
|
||||
)
|
||||
endif()
|
||||
|
||||
target_include_directories(SRB2SDL2 PRIVATE
|
||||
${SDL2_INCLUDE_DIRS}
|
||||
${SDL2_MIXER_INCLUDE_DIRS}
|
||||
${GME_INCLUDE_DIRS}
|
||||
${OPENMPT_INCLUDE_DIRS}
|
||||
${PNG_INCLUDE_DIRS}
|
||||
${ZLIB_INCLUDE_DIRS}
|
||||
${OPENGL_INCLUDE_DIRS}
|
||||
${CURL_INCLUDE_DIRS}
|
||||
${DISCORDRPC_INCLUDE_DIRS}
|
||||
)
|
||||
endif()
|
||||
|
||||
set(SRB2_SDL2_AVAILABLE YES PARENT_SCOPE)
|
||||
if(${SRB2_HAVE_MIXER})
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MIXER -DSOUND=SOUND_MIXER)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE
|
||||
-DHAVE_SDL
|
||||
-DHAVE_THREADS
|
||||
)
|
||||
|
||||
## strip debug symbols into separate file when using gcc
|
||||
# if(CMAKE_COMPILER_IS_GNUCC)
|
||||
# if(${CMAKE_BUILD_TYPE} MATCHES Debug)
|
||||
# message(STATUS "Will make separate debug symbols in *.debug")
|
||||
# add_custom_command(TARGET SRB2SDL2 POST_BUILD
|
||||
# COMMAND ${OBJCOPY} --only-keep-debug $<TARGET_FILE:SRB2SDL2> $<TARGET_FILE:SRB2SDL2>.debug
|
||||
# COMMAND ${OBJCOPY} --strip-debug $<TARGET_FILE:SRB2SDL2>
|
||||
# COMMAND ${OBJCOPY} --add-gnu-debuglink=$<TARGET_FILE_NAME:SRB2SDL2>.debug $<TARGET_FILE:SRB2SDL2>
|
||||
# )
|
||||
# endif()
|
||||
# endif()
|
||||
|
||||
#### Installation ####
|
||||
if(${CMAKE_SYSTEM} 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 .
|
||||
)
|
||||
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
|
||||
)
|
||||
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
|
||||
)
|
||||
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
|
||||
)
|
||||
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
|
||||
)
|
||||
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_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()
|
||||
+12
-10
@@ -201,6 +201,10 @@ static char returnWadPath[256];
|
||||
|
||||
#include "../s_sound.h"
|
||||
|
||||
#ifdef MAC_ALERT
|
||||
#include "macosx/mac_alert.h"
|
||||
#endif
|
||||
|
||||
#include "../d_main.h"
|
||||
|
||||
#if !defined(NOMUMBLE) && defined(HAVE_MUMBLE)
|
||||
@@ -209,14 +213,12 @@ static char returnWadPath[256];
|
||||
#include "../byteptr.h"
|
||||
#endif
|
||||
|
||||
SDL_bool consolevent = SDL_FALSE;
|
||||
SDL_bool framebuffer = SDL_FALSE;
|
||||
boolean consolevent = false;
|
||||
boolean framebuffer = false;
|
||||
UINT8 keyboard_started = false;
|
||||
|
||||
#ifdef HAVE_TERMIOS
|
||||
// TERMIOS console code from Quake3: thank you!
|
||||
SDL_bool stdin_active = SDL_TRUE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
size_t cursor;
|
||||
@@ -278,7 +280,7 @@ static void I_ShutdownConsole(void)
|
||||
if (consolevent)
|
||||
{
|
||||
I_OutputMsg("Shutdown tty console\n");
|
||||
consolevent = SDL_FALSE;
|
||||
consolevent = false;
|
||||
tcsetattr(STDIN_FILENO, TCSADRAIN, &tty_tc);
|
||||
}
|
||||
}
|
||||
@@ -297,7 +299,7 @@ static void I_StartupConsole(void)
|
||||
framebuffer = static_cast<SDL_bool>( M_CheckParm("-framebuffer"));
|
||||
|
||||
if (framebuffer)
|
||||
consolevent = SDL_FALSE;
|
||||
consolevent = false;
|
||||
|
||||
if (!consolevent)
|
||||
return;
|
||||
@@ -305,7 +307,7 @@ static void I_StartupConsole(void)
|
||||
if (isatty(STDIN_FILENO)!=1)
|
||||
{
|
||||
I_OutputMsg("stdin is not a tty, tty console mode failed\n");
|
||||
consolevent = SDL_FALSE;
|
||||
consolevent = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -507,7 +509,7 @@ static void I_StartupConsole(void)
|
||||
if (gotConsole)
|
||||
{
|
||||
SetConsoleTitleA("SRB2Kart Console");
|
||||
consolevent = SDL_TRUE;
|
||||
consolevent = true;
|
||||
}
|
||||
|
||||
//Let get the real console HANDLE, because Mingw's Bash is bad!
|
||||
@@ -540,7 +542,7 @@ static inline void I_StartupConsole(void)
|
||||
framebuffer = M_CheckParm("-framebuffer");
|
||||
|
||||
if (framebuffer)
|
||||
consolevent = SDL_FALSE;
|
||||
consolevent = false;
|
||||
}
|
||||
static inline void I_ShutdownConsole(void){}
|
||||
#endif
|
||||
@@ -761,7 +763,7 @@ void I_JoyScale4(void)
|
||||
}
|
||||
|
||||
// Cheat to get the device index for a joystick handle
|
||||
INT32 I_GetJoystickDeviceIndex(SDL_GameController *dev)
|
||||
static INT32 I_GetJoystickDeviceIndex(SDL_GameController *dev)
|
||||
{
|
||||
SDL_Joystick *joystick = NULL;
|
||||
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
/// \file i_threads.c
|
||||
/// \brief Multithreading abstraction
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
|
||||
#include "../doomdef.h"
|
||||
#include "../i_threads.h"
|
||||
|
||||
@@ -356,5 +354,3 @@ I_wake_all_cond (
|
||||
if (SDL_CondBroadcast(cond) == -1)
|
||||
abort();
|
||||
}
|
||||
|
||||
#endif // HAVE_THREADS
|
||||
+266
-93
@@ -84,15 +84,20 @@
|
||||
#endif
|
||||
|
||||
// maximum number of windowed modes (see windowedModes[][])
|
||||
#define MAXWINMODES (22)
|
||||
#define MAXWINMODES (128)
|
||||
|
||||
/** \brief
|
||||
*/
|
||||
static INT32 numVidModes = -1;
|
||||
static void I_FillScreenResolutionsList(boolean force);
|
||||
|
||||
/** \brief
|
||||
*/
|
||||
static char vidModeName[33][32]; // allow 33 different modes
|
||||
typedef struct
|
||||
{
|
||||
char name[10];
|
||||
INT32 w;
|
||||
INT32 h;
|
||||
} video_mode_t;
|
||||
|
||||
static video_mode_t windowedModes[MAXWINMODES] = {{"320x200", 320, 200}}; // make sure the default mode exists
|
||||
static const char *fallback_resolution_name = "Fallback";
|
||||
static int vid_nummodes = 1;
|
||||
|
||||
rendermode_t rendermode = render_none;
|
||||
|
||||
@@ -139,9 +144,6 @@ static SDL_bool disable_mouse = SDL_FALSE;
|
||||
#define MOUSE_MENU false //(!disable_mouse && cv_usemouse.value && menuactive && !USE_FULLSCREEN)
|
||||
#define MOUSEBUTTONS_MAX MOUSEBUTTONS
|
||||
|
||||
// first entry in the modelist which is not bigger than MAXVIDWIDTHxMAXVIDHEIGHT
|
||||
static INT32 firstEntry = 0;
|
||||
|
||||
// Total mouse motion X/Y offsets
|
||||
static INT32 mousemovex = 0, mousemovey = 0;
|
||||
|
||||
@@ -155,42 +157,13 @@ static SDL_bool usesdl2soft = SDL_FALSE;
|
||||
static SDL_bool borderlesswindow = SDL_FALSE;
|
||||
|
||||
// SDL2 vars
|
||||
SDL_Window *window = NULL;
|
||||
SDL_Renderer *renderer = NULL;
|
||||
static SDL_Window *window = NULL;
|
||||
static SDL_Renderer *renderer = NULL;
|
||||
static SDL_Texture *texture = NULL;
|
||||
#ifdef HWRENDER
|
||||
static SDL_GLContext sdlglcontext = NULL;
|
||||
#endif
|
||||
static SDL_bool havefocus = SDL_TRUE;
|
||||
static const char *fallback_resolution_name = "Fallback";
|
||||
|
||||
// windowed video modes from which to choose from.
|
||||
static INT32 windowedModes[MAXWINMODES][2] =
|
||||
{
|
||||
{2560,1440}, // 1.66
|
||||
{1920,1200}, // 1.60,6.00
|
||||
{1920,1080}, // 1.66
|
||||
{1680,1050}, // 1.60,5.25
|
||||
{1600,1200}, // 1.33
|
||||
{1600, 900}, // 1.66
|
||||
{1366, 768}, // 1.66
|
||||
{1440, 900}, // 1.60,4.50
|
||||
{1280,1024}, // 1.33?
|
||||
{1280, 960}, // 1.33,4.00
|
||||
{1280, 800}, // 1.60,4.00
|
||||
{1280, 720}, // 1.66
|
||||
{1152, 864}, // 1.33,3.60
|
||||
{1024, 768}, // 1.33,3.20
|
||||
{ 960, 600}, // 1.33,3.20
|
||||
{ 800, 600}, // 1.33,2.50
|
||||
{ 735, 415}, // 1.33,2.50
|
||||
{ 640, 480}, // 1.33,2.00
|
||||
{ 640, 400}, // 1.60,2.00
|
||||
{ 500, 300}, // 1.33
|
||||
{ 320, 240}, // 1.33,1.00
|
||||
{ 320, 200}, // 1.60,1.00
|
||||
};
|
||||
|
||||
#define CUSTOMMODENUM 9999
|
||||
static INT32 custom_width = 0;
|
||||
static INT32 custom_height = 0;
|
||||
|
||||
static SDL_bool Impl_CreateWindow(SDL_bool fullscreen);
|
||||
static void Impl_SetWindowIcon(void);
|
||||
@@ -516,11 +489,20 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
||||
return;
|
||||
}
|
||||
|
||||
if (windowmoved && rendermode == render_opengl)
|
||||
if (windowmoved)
|
||||
{
|
||||
I_CheckDesktopRes();
|
||||
|
||||
// if we say moved our game window to a different screen
|
||||
// refetch our resolutions
|
||||
I_FillScreenResolutionsList(false);
|
||||
#ifdef HWRENDER
|
||||
#ifdef USE_FBO_OGL
|
||||
I_DownSample();
|
||||
if (rendermode == render_opengl)
|
||||
{
|
||||
I_DownSample();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
windowmoved = SDL_FALSE;
|
||||
}
|
||||
@@ -537,7 +519,8 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
||||
|
||||
if (!firsttimeonmouse)
|
||||
{
|
||||
if (cv_usemouse.value) I_StartupMouse();
|
||||
if (cv_usemouse.value)
|
||||
I_StartupMouse();
|
||||
}
|
||||
}
|
||||
else if (!mousefocus && !kbfocus)
|
||||
@@ -1219,9 +1202,9 @@ static void VID_Command_ModeList_f(void)
|
||||
"Under opengl, fullscreen only supports native desktop resolution.\n"
|
||||
"Under software, the mode is stretched up to desktop resolution.\n");
|
||||
|
||||
for (i = 0; i < MAXWINMODES; i++)
|
||||
for (i = 0; i < vid_nummodes; i++)
|
||||
{
|
||||
CONS_Printf("%2d: %dx%d\n", i, windowedModes[i][0], windowedModes[i][1]);
|
||||
CONS_Printf("%2d: %dx%d\n", i, windowedModes[i].w, windowedModes[i].h);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1260,7 +1243,7 @@ static void I_CheckDesktopRes(void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (SDL_GetDesktopDisplayMode(currentDisplayIndex, &curmode) != 0)
|
||||
if (SDL_GetCurrentDisplayMode(currentDisplayIndex, &curmode) != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -1275,6 +1258,11 @@ boolean I_CheckNativeRes(void)
|
||||
return (vid.width == desktopwidth && vid.height == desktopheight);
|
||||
}
|
||||
|
||||
boolean I_CheckAboveDesktopRes(INT32 width, INT32 height)
|
||||
{
|
||||
return (width > desktopwidth || height > desktopheight);
|
||||
}
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
|
||||
void RefreshOGLSDLSurface(void)
|
||||
@@ -1426,7 +1414,7 @@ void I_FinishUpdate(void)
|
||||
#ifdef HWRENDER
|
||||
if (rendermode == render_opengl)
|
||||
{
|
||||
OglSdlFinishUpdate(cv_vidwait.value);
|
||||
OglSdlFinishUpdate(window);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -1505,13 +1493,207 @@ void I_SetPalette(RGBA_t *palette)
|
||||
}
|
||||
}
|
||||
|
||||
// make sure the canonical resolutions are always available
|
||||
static const struct {
|
||||
const int w, h;
|
||||
} canonicals[] = {
|
||||
{1920, 1200}, // 16:10
|
||||
{1280, 800}, // 16:10
|
||||
{ 960, 600}, // 16:10
|
||||
{ 640, 400}, // 16:10
|
||||
{ 320, 200}, // Vanilla Doom
|
||||
};
|
||||
static const int num_canonicals = sizeof(canonicals)/sizeof(*canonicals);
|
||||
|
||||
// [FG] sort resolutions by width first and height second
|
||||
static int cmp_resolutions(const void *a, const void *b)
|
||||
{
|
||||
const video_mode_t *ma = (const video_mode_t *) a;
|
||||
const video_mode_t *mb = (const video_mode_t *) b;
|
||||
|
||||
return (ma->w == mb->w) ? mb->h - ma->h : mb->w - ma->w;
|
||||
}
|
||||
|
||||
static void I_AppendResolution(SDL_DisplayMode *mode, int *list_size)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < *list_size; i++)
|
||||
if (windowedModes[i].w == mode->w
|
||||
&& windowedModes[i].h == mode->h)
|
||||
return;
|
||||
|
||||
snprintf(windowedModes[*list_size].name,
|
||||
sizeof(windowedModes[*list_size].name),
|
||||
"%dx%d", mode->w, mode->h);
|
||||
windowedModes[*list_size].w = mode->w;
|
||||
windowedModes[*list_size].h = mode->h;
|
||||
|
||||
(*list_size)++;
|
||||
}
|
||||
|
||||
// small helper to check if a video mode is canonical
|
||||
static boolean IsModeCanonical(int w, int h)
|
||||
{
|
||||
for (int i = 0; i < num_canonicals; i++)
|
||||
{
|
||||
if (canonicals[i].w == w && canonicals[i].h == h)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// check if our desired resolution already is in the videomode list
|
||||
static int IsCustomResolutionInList(int list_size)
|
||||
{
|
||||
INT32 custom_w = cv_scr_width.value;
|
||||
INT32 custom_h = cv_scr_height.value;
|
||||
|
||||
// startup
|
||||
if (!custom_w || !custom_h)
|
||||
return -2;
|
||||
|
||||
// invalid resolution
|
||||
// dont even attempt to add it
|
||||
if (custom_w < BASEVIDWIDTH || custom_w > MAXVIDWIDTH
|
||||
|| custom_h < BASEVIDHEIGHT || custom_h > MAXVIDHEIGHT)
|
||||
return -1;
|
||||
|
||||
for (int i = 0; i < list_size; i++)
|
||||
{
|
||||
if (windowedModes[i].w == custom_w && windowedModes[i].h == custom_h)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// I_FillScreenResolutionsList
|
||||
// Get all the supported screen resolutions
|
||||
// and fill the list with them
|
||||
//
|
||||
static void I_FillScreenResolutionsList(boolean force)
|
||||
{
|
||||
int currentDisplayIndex = -1;
|
||||
static int oldDisplayIndex = -1;
|
||||
SDL_DisplayMode mode;
|
||||
int i = 0, list_size = 0;
|
||||
int count = 0;
|
||||
char custom_resolution[10];
|
||||
|
||||
currentDisplayIndex = SDL_GetWindowDisplayIndex(window);
|
||||
|
||||
// No valid index
|
||||
if (currentDisplayIndex < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// didnt change screen, no need to redo the list
|
||||
if (!force && currentDisplayIndex == oldDisplayIndex)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
oldDisplayIndex = currentDisplayIndex;
|
||||
|
||||
// Don't call SDL_ListModes if SDL has not been initialized
|
||||
count = SDL_GetNumDisplayModes(currentDisplayIndex);
|
||||
|
||||
list_size = 0;
|
||||
|
||||
// on success, SDL_GetNumDisplayModes() always returns at least 1
|
||||
if (count > 0)
|
||||
{
|
||||
// -2 for the desired resolution and for NULL
|
||||
count = min(count, MAXWINMODES - 2 - num_canonicals);
|
||||
|
||||
for (i = count - 1 + num_canonicals; i >= 0; i--)
|
||||
{
|
||||
// make sure the canonical resolutions are always available
|
||||
if (i > count - 1)
|
||||
{
|
||||
mode.w = canonicals[i - count].w;
|
||||
mode.h = canonicals[i - count].h;
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_GetDisplayMode(currentDisplayIndex, i, &mode);
|
||||
}
|
||||
|
||||
I_AppendResolution(&mode, &list_size);
|
||||
}
|
||||
|
||||
windowedModes[list_size].name[0] = '\0';
|
||||
}
|
||||
|
||||
const int customresinlist = IsCustomResolutionInList(list_size);
|
||||
|
||||
if (customresinlist == 0)
|
||||
{
|
||||
// did not find mode from list, make custom resolution if the values somewhat make sense
|
||||
if (list_size < MAXWINMODES)
|
||||
{
|
||||
snprintf(custom_resolution, sizeof(custom_resolution), "%dx%d", cv_scr_width.value, cv_scr_height.value);
|
||||
|
||||
// [FG] if the desired resolution not in the list, append it
|
||||
snprintf(windowedModes[list_size].name,
|
||||
sizeof(windowedModes[list_size].name),
|
||||
"%dx%d", cv_scr_width.value, cv_scr_height.value);
|
||||
windowedModes[list_size].w = cv_scr_width.value;
|
||||
windowedModes[list_size].h = cv_scr_height.value;
|
||||
list_size++;
|
||||
}
|
||||
else
|
||||
CONS_Alert(CONS_ERROR, "Could not set custom resolution!\n");
|
||||
}
|
||||
else if (customresinlist == -1)
|
||||
CONS_Alert(CONS_ERROR, "Could not set custom resolution!\n");
|
||||
|
||||
// [FG] sort the list
|
||||
SDL_qsort(windowedModes, list_size, sizeof(*windowedModes), cmp_resolutions);
|
||||
|
||||
// if we have more video modes than we can list
|
||||
// try to shrink the list, lowest resolutions first
|
||||
// whilst keeping the canonicals
|
||||
if (list_size > MAXMODEDESCS)
|
||||
{
|
||||
// list is sorted from largest to smallest, so start at the end
|
||||
for (i = list_size - 1; i >= 0 && list_size > MAXMODEDESCS; i--)
|
||||
{
|
||||
if (IsModeCanonical(windowedModes[i].w, windowedModes[i].h))
|
||||
continue;
|
||||
|
||||
// Should we like, instead prioritize checking for non aspect correct resolutions to remove?
|
||||
|
||||
// we gotta shift everything
|
||||
// due to canonicals we cant just shrink the list
|
||||
for (int k = i; k < list_size - 1; k++)
|
||||
{
|
||||
windowedModes[k] = windowedModes[k + 1];
|
||||
}
|
||||
|
||||
list_size--;
|
||||
}
|
||||
}
|
||||
|
||||
windowedModes[list_size].name[0] = '\0';
|
||||
vid_nummodes = list_size;
|
||||
|
||||
// be sure to update the video menu
|
||||
if (menuactive &&
|
||||
currentMenu == &OP_VideoModeDef)
|
||||
M_VideoModeMenu(0);
|
||||
}
|
||||
|
||||
// return number of fullscreen + X11 modes
|
||||
INT32 VID_NumModes(void)
|
||||
{
|
||||
if (USE_FULLSCREEN && numVidModes != -1)
|
||||
return numVidModes - firstEntry;
|
||||
else
|
||||
return MAXWINMODES;
|
||||
return vid_nummodes;
|
||||
}
|
||||
|
||||
const char *VID_GetModeName(INT32 modeNum)
|
||||
@@ -1521,42 +1703,34 @@ const char *VID_GetModeName(INT32 modeNum)
|
||||
return fallback_resolution_name;
|
||||
}
|
||||
|
||||
if (modeNum > MAXWINMODES)
|
||||
if (modeNum > vid_nummodes)
|
||||
return NULL;
|
||||
|
||||
sprintf(&vidModeName[modeNum][0], "%dx%d",
|
||||
windowedModes[modeNum][0],
|
||||
windowedModes[modeNum][1]);
|
||||
|
||||
return &vidModeName[modeNum][0];
|
||||
return windowedModes[modeNum].name;
|
||||
}
|
||||
|
||||
INT32 VID_GetModeForSize(INT32 w, INT32 h)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAXWINMODES; i++)
|
||||
for (i = 0; i < vid_nummodes; i++)
|
||||
{
|
||||
if (windowedModes[i][0] == w && windowedModes[i][1] == h)
|
||||
if (windowedModes[i].w == w && windowedModes[i].h == h)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
// did not find mode from list, make custom resolution if the values somewhat make sense
|
||||
// opengl mode does not mind about max resolution defined in screen.h
|
||||
// if not using opengl, check against the maximum as well
|
||||
if ((w >= BASEVIDWIDTH && h >= BASEVIDHEIGHT) &&
|
||||
(rendermode == render_opengl || (w <= MAXVIDWIDTH && h <= MAXVIDHEIGHT)))
|
||||
{
|
||||
custom_width = w;
|
||||
custom_height = h;
|
||||
return CUSTOMMODENUM;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void VID_RefreshModeList(void)
|
||||
{
|
||||
// check if we even need to rebuild the list
|
||||
if (IsCustomResolutionInList(vid_nummodes) == 0)
|
||||
I_FillScreenResolutionsList(true);
|
||||
}
|
||||
|
||||
void VID_PrepareModeList(void)
|
||||
{
|
||||
// Under SDL2, we just use the windowed modes list, and scale in windowed fullscreen.
|
||||
@@ -1588,17 +1762,10 @@ INT32 VID_SetMode(INT32 modeNum)
|
||||
{
|
||||
vid.recalc = true;
|
||||
|
||||
if (modeNum >= 0 && modeNum < MAXWINMODES)
|
||||
if (modeNum >= 0 && modeNum < vid_nummodes)
|
||||
{
|
||||
vid.width = windowedModes[modeNum][0];
|
||||
vid.height = windowedModes[modeNum][1];
|
||||
vid.modenum = modeNum;
|
||||
}
|
||||
else if (modeNum == CUSTOMMODENUM && custom_width && custom_height)
|
||||
{
|
||||
// at this point these values are assumed to be okay
|
||||
vid.width = custom_width;
|
||||
vid.height = custom_height;
|
||||
vid.width = windowedModes[modeNum].w;
|
||||
vid.height = windowedModes[modeNum].h;
|
||||
vid.modenum = modeNum;
|
||||
}
|
||||
else
|
||||
@@ -1631,7 +1798,6 @@ INT32 VID_SetMode(INT32 modeNum)
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
static SDL_bool Impl_CreateContext(void)
|
||||
{
|
||||
// Renderer-specific stuff
|
||||
@@ -1654,6 +1820,9 @@ static SDL_bool Impl_CreateContext(void)
|
||||
I_Error("Failed to set up GL context: %s\n", SDL_GetError());
|
||||
}
|
||||
|
||||
// be sure to fill the resolution list the moment we have a window
|
||||
I_FillScreenResolutionsList(false);
|
||||
|
||||
return SDL_TRUE;
|
||||
}
|
||||
#endif
|
||||
@@ -1695,6 +1864,9 @@ static SDL_bool Impl_CreateContext(void)
|
||||
|
||||
SDL_RenderSetLogicalSize(renderer, BASEVIDWIDTH, BASEVIDHEIGHT);
|
||||
|
||||
// be sure to fill the resolution list the moment we have a window
|
||||
I_FillScreenResolutionsList(false);
|
||||
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
@@ -1932,8 +2104,6 @@ void I_StartupGraphics(void)
|
||||
usesdl2soft = M_CheckParm("-softblit");
|
||||
borderlesswindow = M_CheckParm("-borderless");
|
||||
|
||||
VID_Command_ModeList_f();
|
||||
|
||||
#ifdef HWRENDER
|
||||
if (rendermode == render_opengl)
|
||||
{
|
||||
@@ -1957,6 +2127,9 @@ void I_StartupGraphics(void)
|
||||
vid.height = BASEVIDHEIGHT; // BitsPerPixel is the SDL interface's
|
||||
vid.recalc = true; // Set up the console stufff
|
||||
|
||||
// be sure to print AFTER window creation
|
||||
VID_Command_ModeList_f();
|
||||
|
||||
#ifdef HAVE_TTF
|
||||
I_ShutdownTTF();
|
||||
#endif
|
||||
@@ -2028,17 +2201,17 @@ UINT32 I_GetRefreshRate(void)
|
||||
|
||||
static void Impl_SetVsync(void)
|
||||
{
|
||||
#if SDL_VERSION_ATLEAST(2,0,18)
|
||||
if (renderer)
|
||||
SDL_RenderSetVSync(renderer, cv_vidwait.value);
|
||||
#endif
|
||||
#ifdef HWRENDER
|
||||
if (!renderer && rendermode == render_opengl &&
|
||||
sdlglcontext != NULL && SDL_GL_GetCurrentContext() == sdlglcontext)
|
||||
if (rendermode == render_opengl &&
|
||||
sdlglcontext != NULL && SDL_GL_GetCurrentContext() == sdlglcontext)
|
||||
{
|
||||
SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0);
|
||||
}
|
||||
#endif
|
||||
#if SDL_VERSION_ATLEAST(2,0,18)
|
||||
if (renderer)
|
||||
SDL_RenderSetVSync(renderer, cv_vidwait.value);
|
||||
#endif
|
||||
}
|
||||
|
||||
void I_SetBorderlessWindow(void)
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Portions Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file
|
||||
/// \brief Graphical Alerts for MacOSX
|
||||
///
|
||||
/// Shows alerts, since we can't just print these to the screen when
|
||||
/// launched graphically on a mac.
|
||||
|
||||
#ifdef __APPLE_CC__
|
||||
|
||||
#include "mac_alert.h"
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
#define CFSTRINGIFY(x) CFStringCreateWithCString(NULL, x, kCFStringEncodingASCII)
|
||||
|
||||
int MacShowAlert(const char *title, const char *message, const char *button1, const char *button2, const char *button3)
|
||||
{
|
||||
CFOptionFlags results;
|
||||
|
||||
CFStringRef cf_title = CFSTRINGIFY(title);
|
||||
CFStringRef cf_message = CFSTRINGIFY(message);
|
||||
CFStringRef cf_button1 = NULL;
|
||||
CFStringRef cf_button2 = NULL;
|
||||
CFStringRef cf_button3 = NULL;
|
||||
|
||||
if (button1 != NULL)
|
||||
cf_button1 = CFSTRINGIFY(button1);
|
||||
if (button2 != NULL)
|
||||
cf_button2 = CFSTRINGIFY(button2);
|
||||
if (button3 != NULL)
|
||||
cf_button3 = CFSTRINGIFY(button3);
|
||||
|
||||
CFOptionFlags alert_flags = kCFUserNotificationStopAlertLevel | kCFUserNotificationNoDefaultButtonFlag;
|
||||
|
||||
CFUserNotificationDisplayAlert(0, alert_flags, NULL, NULL, NULL, cf_title, cf_message,
|
||||
cf_button1, cf_button2, cf_button3, &results);
|
||||
|
||||
if (cf_button1 != NULL)
|
||||
CFRelease(cf_button1);
|
||||
if (cf_button2 != NULL)
|
||||
CFRelease(cf_button2);
|
||||
if (cf_button3 != NULL)
|
||||
CFRelease(cf_button3);
|
||||
CFRelease(cf_message);
|
||||
CFRelease(cf_title);
|
||||
|
||||
return (int)results;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Portions Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file
|
||||
/// \brief Graphical Alerts for MacOSX
|
||||
///
|
||||
/// Shows alerts, since we can't just print these to the screen when
|
||||
/// launched graphically on a mac.
|
||||
|
||||
#ifdef __APPLE_CC__
|
||||
|
||||
extern int MacShowAlert(const char *title, const char *message, const char *button1, const char *button2, const char *button3);
|
||||
|
||||
#endif
|
||||
@@ -1,14 +1,5 @@
|
||||
#ifndef __MAC_RESOURCES_H__
|
||||
#define __MAC_RESOURCES_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void OSX_GetResourcesPath(char * buffer);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -461,7 +461,7 @@ void *I_GetSfx(sfxinfo_t *sfx)
|
||||
gme_track_info(emu, &info, 0);
|
||||
|
||||
len = (info->play_length * 441 / 10) << 2;
|
||||
mem = Z_Malloc(len, PU_SOUND, 0);
|
||||
mem = Z_Malloc(len, PU_SOUND, NULL);
|
||||
|
||||
gme_play(emu, len >> 1, mem);
|
||||
gme_free_info(info);
|
||||
@@ -499,7 +499,7 @@ void *I_GetSfx(sfxinfo_t *sfx)
|
||||
gme_track_info(emu, &info, 0);
|
||||
|
||||
len = (info->play_length * 441 / 10) << 2;
|
||||
mem = Z_Malloc(len, PU_SOUND, 0);
|
||||
mem = Z_Malloc(len, PU_SOUND, NULL);
|
||||
|
||||
gme_play(emu, len >> 1, mem);
|
||||
gme_free_info(info);
|
||||
|
||||
+2
-38
@@ -63,25 +63,15 @@ PFNglGetString pglGetString;
|
||||
#endif
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
|
||||
#if defined (__unix__)
|
||||
static boolean xwaylandcrap = false;
|
||||
#endif
|
||||
|
||||
boolean UseScreenFBO(void)
|
||||
{
|
||||
return ((supportFBO && cv_glframebuffer.value && downsample)
|
||||
#if defined (__unix__)
|
||||
|| (supportFBO && xwaylandcrap)
|
||||
#endif
|
||||
);
|
||||
return (supportFBO && cv_glframebuffer.value && downsample);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** \brief SDL video display surface
|
||||
*/
|
||||
INT32 oglflags = 0;
|
||||
SDL_GLContext sdlglcontext = NULL;
|
||||
|
||||
void *GetGLFunc(const char *proc)
|
||||
{
|
||||
@@ -201,17 +191,6 @@ boolean OglSdlSurface(INT32 w, INT32 h)
|
||||
supportNPO2tex = true;
|
||||
|
||||
glanisotropicmode_cons_t[1].value = maximumAnisotropy;
|
||||
|
||||
#if defined (__unix__)
|
||||
#ifdef USE_FBO_OGL
|
||||
// TODO: delet this since nvidia fixed their shit on 575
|
||||
char videodriver[4] = {'S','D','L',0};
|
||||
if (supportFBO && strstr((const char*)gl_renderer, "NVIDIA")
|
||||
&& (*strncpy(videodriver, SDL_GetCurrentVideoDriver(), sizeof(videodriver)-1) != '\0')
|
||||
&& (strncasecmp("x11", videodriver, 4) == 0))
|
||||
xwaylandcrap = true;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0);
|
||||
@@ -241,22 +220,14 @@ boolean OglSdlSurface(INT32 w, INT32 h)
|
||||
|
||||
\return void
|
||||
*/
|
||||
void OglSdlFinishUpdate(boolean waitvbl)
|
||||
void OglSdlFinishUpdate(SDL_Window *window)
|
||||
{
|
||||
static boolean oldwaitvbl = false;
|
||||
int sdlw, sdlh;
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
const boolean usefbo = UseScreenFBO();
|
||||
#endif
|
||||
|
||||
if (oldwaitvbl != waitvbl)
|
||||
{
|
||||
SDL_GL_SetSwapInterval(waitvbl ? 1 : 0);
|
||||
}
|
||||
|
||||
oldwaitvbl = waitvbl;
|
||||
|
||||
SDL_GetWindowSize(window, &sdlw, &sdlh);
|
||||
HWR_MakeScreenFinalTexture();
|
||||
|
||||
@@ -289,13 +260,6 @@ void OglSdlFinishUpdate(boolean waitvbl)
|
||||
if (!I_CheckNativeRes() || WipeInAction)
|
||||
#endif
|
||||
HWR_DrawScreenFinalTexture(realwidth, realheight, false);
|
||||
|
||||
#if defined (__unix__)
|
||||
#ifdef USE_FBO_OGL
|
||||
if (loaded_config)
|
||||
xwaylandcrap = false;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif //HWRENDER
|
||||
|
||||
+1
-3
@@ -20,11 +20,9 @@
|
||||
|
||||
boolean OglSdlSurface(INT32 w, INT32 h);
|
||||
|
||||
void OglSdlFinishUpdate(boolean vidwait);
|
||||
void OglSdlFinishUpdate(SDL_Window *window);
|
||||
boolean VID_LoadOGLAPI(void);
|
||||
|
||||
extern SDL_Renderer *renderer;
|
||||
extern SDL_GLContext sdlglcontext;
|
||||
extern Uint16 realwidth;
|
||||
extern Uint16 realheight;
|
||||
|
||||
@@ -23,9 +23,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern SDL_bool consolevent;
|
||||
extern SDL_bool framebuffer;
|
||||
|
||||
#include "../m_fixed.h"
|
||||
|
||||
// SDL2 stub macro
|
||||
@@ -67,21 +64,6 @@ extern SDLJoyInfo_t JoyInfo[4]; //MAXSPLITSCREENPLAYERS
|
||||
#define SDL_JDEADZONE 153
|
||||
#undef SDL_JDEADZONE
|
||||
|
||||
// So we can call this from i_video event loop
|
||||
void I_ShutdownJoystick(UINT8 index);
|
||||
|
||||
// Cheat to get the device index for a game controller handle
|
||||
INT32 I_GetJoystickDeviceIndex(SDL_GameController *dev);
|
||||
|
||||
// Quick thing to make SDL_JOYDEVICEADDED events less of an abomination
|
||||
void I_UpdateJoystickDeviceIndex(UINT8 player);
|
||||
void I_UpdateJoystickDeviceIndices(UINT8 excludePlayer);
|
||||
|
||||
void I_GetConsoleEvents(void);
|
||||
|
||||
// Needed for some WIN32 functions
|
||||
extern SDL_Window *window;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
+20
-1
@@ -1997,11 +1997,16 @@ void *W_CachePatchNameRotated(const char *name, INT32 rotationangle, INT32 tag)
|
||||
|
||||
rspr = (rotsprite_t *)W_GetCachedRotPatchPwad(WADFILENUM(num),LUMPNUM(num));
|
||||
|
||||
if (rspr == NULL)
|
||||
return W_CachePatchNum(W_GetNumForName("MISSING"), tag);
|
||||
|
||||
if (rspr->patches[idx] == NULL)
|
||||
{
|
||||
INT32 xpivot = 0, ypivot = 0;
|
||||
|
||||
ptr = (patch_t *)W_CachePatchNum(num, PU_PATCH);
|
||||
if (ptr == NULL)
|
||||
return W_CachePatchNum(W_GetNumForName("MISSING"), tag);
|
||||
|
||||
// >y pivot centered
|
||||
// >x pivot not centered
|
||||
@@ -2612,6 +2617,9 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
||||
|
||||
// Remember that we're assuming that the WAD will have a specific set of lumps in a specific order.
|
||||
UINT8 *wadData = (UINT8*)(W_CacheLumpNum(lumpnum, PU_LEVEL));
|
||||
if (wadData == NULL)
|
||||
I_Error("vres_GetMap: Invalid WadData!\n");
|
||||
|
||||
filelump_t *fileinfo = (filelump_t *)(wadData + LONG(((wadinfo_t *)wadData)->infotableofs));
|
||||
|
||||
i = LONG(((wadinfo_t *)wadData)->numlumps);
|
||||
@@ -2628,6 +2636,8 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
||||
}
|
||||
|
||||
vlumps = (virtlump_t*)(Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL));
|
||||
if (vlumps == NULL)
|
||||
I_Error("vres_GetMap: Out of memory!\n");
|
||||
|
||||
// Build the lumps, skipping over empty entries.
|
||||
for (i = 0, realentry = 0; i < numlumps; realentry++)
|
||||
@@ -2663,7 +2673,11 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
||||
lumpnum_t lumppos = lumpnum + 1;
|
||||
for (i = LUMPNUM(lumppos); i < wadfiles[WADFILENUM(lumpnum)]->numlumps; i++, lumppos++, numlumps++)
|
||||
{
|
||||
if (memcmp(W_CheckNameForNum(lumppos), "MAP", 3) == 0 || W_LumpLength(lumppos) == 0)
|
||||
const char *name = W_CheckNameForNum(lumppos);
|
||||
if (name == NULL)
|
||||
continue;
|
||||
|
||||
if (memcmp(name, "MAP", 3) == 0 || W_LumpLength(lumppos) == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -2671,10 +2685,15 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
||||
numlumps++;
|
||||
|
||||
vlumps = (virtlump_t*)(Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL));
|
||||
if (vlumps == NULL)
|
||||
I_Error("vres_GetMap: Out of memory!\n");
|
||||
|
||||
for (i = 0; i < numlumps; i++, lumpnum++)
|
||||
{
|
||||
// Check if it is map marker. It is not always first lump sadly, so we need to expect it anywhere
|
||||
const char *name = W_CheckNameForNum(lumpnum);
|
||||
if (name == NULL)
|
||||
continue;
|
||||
|
||||
if (strlen(name) == 5 && memcmp(name, "MAP", 3) == 0)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user