Compare commits
33
Commits
fixcmake2
...
fixedclamp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bcc58f54e4 | ||
|
|
55203c8711 | ||
|
|
19d83f82e4 | ||
|
|
e4dbf1ce11 | ||
|
|
10b9d96259 | ||
|
|
b23154fd93 | ||
|
|
b0ee972178 | ||
|
|
544e1d3b21 | ||
|
|
0ca6947f99 | ||
|
|
3122c08039 | ||
|
|
7a279a6fd9 | ||
|
|
c4581bd9a6 | ||
|
|
bb47b976a7 | ||
|
|
6c419ff22e | ||
|
|
522904527f | ||
|
|
30539371c2 | ||
|
|
e2ecc315b4 | ||
|
|
eb2f186205 | ||
|
|
bbf06b3376 | ||
|
|
a1f70b0b31 | ||
|
|
2e0f5c02a4 | ||
|
|
0f7001ef5c | ||
|
|
4600da5782 | ||
|
|
a3557fadef | ||
|
|
d9a67faf47 | ||
|
|
96eaf8850e | ||
|
|
e7efd46419 | ||
|
|
346b1456cd | ||
|
|
9f5a5a735b | ||
|
|
8e4b304bed | ||
|
|
607fbc54fc | ||
|
|
59c9af97c2 | ||
|
|
4e75d99026 |
No files matched your search
+28
-26
@@ -1,4 +1,9 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
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()
|
||||
|
||||
# DO NOT CHANGE THIS SRB2 STRING! Some variable names depend on this string.
|
||||
# Version change is fine.
|
||||
project(SRB2
|
||||
@@ -11,10 +16,31 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS ON)
|
||||
set(CMAKE_C_EXTENSIONS ON)
|
||||
|
||||
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.")
|
||||
##### 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 "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)
|
||||
|
||||
# Set up CMAKE path
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
|
||||
|
||||
@@ -102,14 +128,12 @@ set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||
|
||||
# Set EXE names so the assets CMakeLists can refer to its target
|
||||
set(SRB2_SDL2_EXE_NAME srb2kart 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)
|
||||
@@ -118,25 +142,3 @@ git_current_branch(SRB2_GIT_BRANCH "${CMAKE_SOURCE_DIR}")
|
||||
set(SRB2_COMP_BRANCH "${SRB2_GIT_BRANCH}")
|
||||
set(SRB2_COMP_REVISION "${SRB2_COMP_COMMIT}")
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/config.h)
|
||||
|
||||
##### PACKAGE CONFIGURATION #####
|
||||
|
||||
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()
|
||||
|
||||
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)
|
||||
@@ -1,6 +1,6 @@
|
||||
include(LibFindMacros)
|
||||
|
||||
libfind_pkg_check_modules(GME_PKGCONF GME)
|
||||
libfind_pkg_check_modules(GME_PKGCONF LIBGME)
|
||||
|
||||
find_path(GME_INCLUDE_DIR
|
||||
NAMES gme.h
|
||||
@@ -8,6 +8,7 @@ find_path(GME_INCLUDE_DIR
|
||||
${GME_PKGCONF_INCLUDE_DIRS}
|
||||
"/usr/include/gme"
|
||||
"/usr/local/include/gme"
|
||||
PATH_SUFFIXES gme
|
||||
)
|
||||
|
||||
find_library(GME_LIBRARY
|
||||
@@ -20,4 +21,4 @@ find_library(GME_LIBRARY
|
||||
|
||||
set(GME_PROCESS_INCLUDES GME_INCLUDE_DIR)
|
||||
set(GME_PROCESS_LIBS GME_LIBRARY)
|
||||
libfind_process(GME)
|
||||
libfind_process(GME)
|
||||
@@ -1,6 +1,6 @@
|
||||
include(LibFindMacros)
|
||||
|
||||
libfind_pkg_check_modules(OPENMPT_PKGCONF OPENMPT)
|
||||
libfind_pkg_check_modules(OPENMPT_PKGCONF LIBOPENMPT)
|
||||
|
||||
find_path(OPENMPT_INCLUDE_DIR
|
||||
NAMES libopenmpt.h
|
||||
@@ -8,6 +8,7 @@ find_path(OPENMPT_INCLUDE_DIR
|
||||
${OPENMPT_PKGCONF_INCLUDE_DIRS}
|
||||
"/usr/include/libopenmpt"
|
||||
"/usr/local/include/libopenmpt"
|
||||
PATH_SUFFIXES libopenmpt
|
||||
)
|
||||
|
||||
find_library(OPENMPT_LIBRARY
|
||||
@@ -20,4 +21,4 @@ find_library(OPENMPT_LIBRARY
|
||||
|
||||
set(OPENMPT_PROCESS_INCLUDES OPENMPT_INCLUDE_DIR)
|
||||
set(OPENMPT_PROCESS_LIBS OPENMPT_LIBRARY)
|
||||
libfind_process(OPENMPT)
|
||||
libfind_process(OPENMPT)
|
||||
@@ -1,4 +1,4 @@
|
||||
# Version 2.2
|
||||
# Version 2.4
|
||||
# Public Domain, originally written by Lasse Kärkkäinen <tronic>
|
||||
# Maintained at https://github.com/Tronic/cmake-modules
|
||||
# Please send your improvements as pull requests on Github.
|
||||
@@ -52,6 +52,10 @@ function (libfind_pkg_detect PREFIX)
|
||||
if (libraryargs)
|
||||
find_library(${PREFIX}_LIBRARY NAMES ${libraryargs} HINTS ${${PREFIX}_PKGCONF_LIBRARY_DIRS})
|
||||
endif()
|
||||
# Read pkg-config version
|
||||
if (${PREFIX}_PKGCONF_VERSION)
|
||||
set(${PREFIX}_VERSION ${${PREFIX}_PKGCONF_VERSION} PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Extracts a version #define from a version.h file, output stored to <PREFIX>_VERSION.
|
||||
@@ -125,24 +129,39 @@ function (libfind_process PREFIX)
|
||||
|
||||
# Process deps to add to
|
||||
foreach (i ${PREFIX} ${${PREFIX}_DEPENDENCIES})
|
||||
if (DEFINED ${i}_INCLUDE_OPTS OR DEFINED ${i}_LIBRARY_OPTS)
|
||||
if (DEFINED ${i}_INCLUDE_OPTS)
|
||||
# The package seems to export option lists that we can use, woohoo!
|
||||
list(APPEND includeopts ${${i}_INCLUDE_OPTS})
|
||||
else()
|
||||
if (DEFINED ${i}_INCLUDE_DIR)
|
||||
# Singular forms can be used
|
||||
list(APPEND includeopts ${i}_INCLUDE_DIR)
|
||||
else()
|
||||
if (DEFINED ${i}_INCLUDE_DIRS)
|
||||
# Plural forms can be used
|
||||
list(APPEND includeopts ${i}_INCLUDE_DIRS)
|
||||
else()
|
||||
# Oh no, we don't know the option names
|
||||
message(FATAL_ERROR "We couldn't determine config variable names for ${i} includes. Aieeh!")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (DEFINED ${i}_LIBRARY_OPTS)
|
||||
# The package seems to export option lists that we can use, woohoo!
|
||||
list(APPEND libraryopts ${${i}_LIBRARY_OPTS})
|
||||
else()
|
||||
# If plural forms don't exist or they equal singular forms
|
||||
if ((NOT DEFINED ${i}_INCLUDE_DIRS AND NOT DEFINED ${i}_LIBRARIES) OR
|
||||
({i}_INCLUDE_DIR STREQUAL ${i}_INCLUDE_DIRS AND ${i}_LIBRARY STREQUAL ${i}_LIBRARIES))
|
||||
if (DEFINED ${i}_LIBRARY)
|
||||
# Singular forms can be used
|
||||
if (DEFINED ${i}_INCLUDE_DIR)
|
||||
list(APPEND includeopts ${i}_INCLUDE_DIR)
|
||||
endif()
|
||||
if (DEFINED ${i}_LIBRARY)
|
||||
list(APPEND libraryopts ${i}_LIBRARY)
|
||||
endif()
|
||||
list(APPEND libraryopts ${i}_LIBRARY)
|
||||
else()
|
||||
# Oh no, we don't know the option names
|
||||
message(FATAL_ERROR "We couldn't determine config variable names for ${i} includes and libs. Aieeh!")
|
||||
if (DEFINED ${i}_LIBRARIES)
|
||||
# Plural forms can be used
|
||||
list(APPEND libraryopts ${i}_LIBRARIES)
|
||||
else()
|
||||
# Oh no, we don't know the option names
|
||||
message(FATAL_ERROR "We couldn't determine config variable names for ${i} libraries. Aieeh!")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
@@ -209,12 +228,12 @@ function (libfind_process PREFIX)
|
||||
message(STATUS " ${PREFIX}_LIBRARY_OPTS=${libraryopts}")
|
||||
message(STATUS " ${PREFIX}_LIBRARIES=${libs}")
|
||||
endif()
|
||||
set (${PREFIX}_INCLUDE_OPTS ${includeopts} PARENT_SCOPE)
|
||||
set (${PREFIX}_LIBRARY_OPTS ${libraryopts} PARENT_SCOPE)
|
||||
set (${PREFIX}_INCLUDE_DIRS ${includes} PARENT_SCOPE)
|
||||
set (${PREFIX}_LIBRARIES ${libs} PARENT_SCOPE)
|
||||
set (${PREFIX}_FOUND TRUE PARENT_SCOPE)
|
||||
endif()
|
||||
set (${PREFIX}_INCLUDE_OPTS ${includeopts} PARENT_SCOPE)
|
||||
set (${PREFIX}_LIBRARY_OPTS ${libraryopts} PARENT_SCOPE)
|
||||
set (${PREFIX}_INCLUDE_DIRS ${includes} PARENT_SCOPE)
|
||||
set (${PREFIX}_LIBRARIES ${libs} PARENT_SCOPE)
|
||||
set (${PREFIX}_FOUND TRUE PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
||||
+18
-7
@@ -236,18 +236,23 @@ 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_SCREENFBO ON CACHE BOOL
|
||||
"Enable hardware renderer (OpenGL) FBO downsampling support")
|
||||
set(SRB2_CONFIG_DEDICATED OFF CACHE BOOL
|
||||
"Build a dedicated server.")
|
||||
set(SRB2_CONFIG_LIBBACKTRACE ON CACHE BOOL
|
||||
"Enable using libbacktrace for crashlogs.")
|
||||
set(SRB2_CONFIG_LTO ON CACHE BOOL
|
||||
"Enable link time optimizations, improves performance at the cost of longer link times.")
|
||||
set(SRB2_CONFIG_ASAN OFF CACHE BOOL
|
||||
"Compile with AddressSanitizer (libasan).")
|
||||
set(SRB2_CONFIG_UBSAN OFF CACHE BOOL
|
||||
"Compile with UndefinedBehaviorSanitizer (libubsan).")
|
||||
|
||||
set(SRB2_CONFIG_SATURNPAK ON CACHE BOOL
|
||||
"Enable Saturn specific special packet. Required for using the newer resynch system")
|
||||
set(SRB2_CONFIG_SATURNJOIN ON CACHE BOOL
|
||||
"Enable Saturn specific allowjoin toggle.")
|
||||
|
||||
set(SRB2_CONFIG_LIBBACKTRACE ON CACHE BOOL
|
||||
"Enable using libbacktrace for crashlogs")
|
||||
set(SRB2_CONFIG_SCREENFBO ON CACHE BOOL
|
||||
"Enable hardware renderer (OpenGL) FBO downsampling support")
|
||||
|
||||
if(${SRB2_CONFIG_DEDICATED})
|
||||
set(SRB2_CONFIG_HAVE_GME NO)
|
||||
@@ -502,7 +507,6 @@ if(${SRB2_CONFIG_LIBBACKTRACE})
|
||||
if(${LIBBACKTRACE_FOUND})
|
||||
set(SRB2_HAVE_LIBBACKTRACE ON)
|
||||
add_definitions(-DHAVE_LIBBACKTRACE)
|
||||
add_compile_options(-g)
|
||||
else()
|
||||
message(WARNING "You have specified that libbacktrace is available but it was not found.")
|
||||
endif()
|
||||
@@ -550,7 +554,6 @@ if(${SRB2_CONFIG_HWRENDER})
|
||||
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})
|
||||
@@ -589,6 +592,14 @@ endif()
|
||||
# TODO: fix prng and P_CreateBlockmap overflow at some point
|
||||
add_compile_options(-fwrapv)
|
||||
|
||||
if (${CMAKE_BUILD_TYPE} MATCHES Debug)
|
||||
add_compile_options(-O0)
|
||||
else()
|
||||
add_compile_options(-O3)
|
||||
endif()
|
||||
|
||||
add_compile_options(-g)
|
||||
|
||||
add_definitions(-DCMAKECONFIG)
|
||||
|
||||
#add_library(SRB2Core STATIC
|
||||
|
||||
@@ -907,7 +907,9 @@ void D_ClearState(void)
|
||||
|
||||
// okay, stop now
|
||||
// (otherwise the game still thinks we're playing!)
|
||||
#ifdef HAVE_CURL
|
||||
CURLAbortFile();
|
||||
#endif
|
||||
SV_StopServer();
|
||||
SV_ResetServer();
|
||||
|
||||
|
||||
+3
-1
@@ -1009,6 +1009,9 @@ void D_RegisterClientCommands(void)
|
||||
CV_RegisterVar(&cv_gamepadled[i]);
|
||||
}
|
||||
|
||||
CV_RegisterVar(&cv_gamepadledifunfocused);
|
||||
CV_RegisterVar(&cv_rumbleifunfocused);
|
||||
|
||||
CV_RegisterVar(&cv_usemouse);
|
||||
CV_RegisterVar(&cv_invertmouse);
|
||||
CV_RegisterVar(&cv_mousexsens);
|
||||
@@ -2655,7 +2658,6 @@ static void Command_Map_f(void)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
last_map_cmd = I_GetTime();
|
||||
|
||||
size_t first_option;
|
||||
|
||||
@@ -1,21 +1,75 @@
|
||||
# Declare dedicated interface sources
|
||||
|
||||
target_sourcefile(c)
|
||||
set(SRB2_DEDICATED_SOURCES
|
||||
i_system.c
|
||||
i_main.c
|
||||
i_video.c
|
||||
i_sound.c
|
||||
i_threads.c
|
||||
dosstr.c
|
||||
endtxt.c
|
||||
)
|
||||
|
||||
target_sources(SRB2SDL2 PRIVATE)
|
||||
set(SRB2_DEDICATED_HEADERS
|
||||
endtxt.h
|
||||
)
|
||||
|
||||
source_group("Interface Code" FILES ${SRB2_DEDICATED_SOURCES} ${SRB2_DEDICATED_HEADERS})
|
||||
|
||||
set(SRB2_DEDICATED_TOTAL_SOURCES
|
||||
${SRB2_CORE_SOURCES}
|
||||
${SRB2_CORE_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_DEDICATED_SOURCES}
|
||||
${SRB2_DEDICATED_HEADERS}
|
||||
)
|
||||
|
||||
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})
|
||||
source_group("LUA" FILES ${SRB2_LUA_SOURCES} ${SRB2_LUA_HEADERS})
|
||||
source_group("LUA\\Interpreter" FILES ${SRB2_BLUA_SOURCES} ${SRB2_BLUA_HEADERS})
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES Windows)
|
||||
target_sources(SRB2SDL2 PRIVATE
|
||||
../win32/win_dbg.c
|
||||
../win32/Srb2win.rc)
|
||||
set(SRB2_DEDICATED_TOTAL_SOURCES ${SRB2_DEDICATED_TOTAL_SOURCES}
|
||||
${CMAKE_SOURCE_DIR}/src/win32/win_dbg.c
|
||||
${CMAKE_SOURCE_DIR}/src/win32/Srb2win.rc
|
||||
)
|
||||
endif()
|
||||
|
||||
add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32 ${SRB2_DEDICATED_TOTAL_SOURCES})
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES Windows)
|
||||
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2legacy)
|
||||
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2kartd)
|
||||
elseif(${CMAKE_SYSTEM} MATCHES Linux)
|
||||
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME lsrb2dlegacy)
|
||||
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME lsrb2kartd)
|
||||
else()
|
||||
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2legacy)
|
||||
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2kartd)
|
||||
endif()
|
||||
|
||||
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()
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES Darwin)
|
||||
@@ -24,25 +78,27 @@ if(${CMAKE_SYSTEM} MATCHES Darwin)
|
||||
${CORE_LIB}
|
||||
${PNG_LIBRARIES}
|
||||
${ZLIB_LIBRARIES}
|
||||
${CURL_LIBRARIES}
|
||||
)
|
||||
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
|
||||
else()
|
||||
target_link_libraries(SRB2SDL2 PRIVATE
|
||||
${PNG_LIBRARIES}
|
||||
${ZLIB_LIBRARIES}
|
||||
${CURL_LIBRARIES}
|
||||
)
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES Linux)
|
||||
target_link_libraries(SRB2SDL2 PRIVATE
|
||||
m
|
||||
rt
|
||||
pthread
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#target_link_libraries(SRB2SDL2 PRIVATE SRB2Core)
|
||||
|
||||
set_target_properties(SRB2SDL2 PROPERTIES VERSION ${SRB2_VERSION})
|
||||
if(${SRB2_HAVE_LIBBACKTRACE})
|
||||
target_link_libraries(SRB2SDL2 PRIVATE ${LIBBACKTRACE_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES Windows)
|
||||
target_link_libraries(SRB2SDL2 PRIVATE
|
||||
@@ -60,20 +116,35 @@ target_include_directories(SRB2SDL2 PRIVATE
|
||||
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE
|
||||
-DDEDICATED
|
||||
-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()
|
||||
if(SRB2_CONFIG_LTO AND NOT SRB2_CONFIG_DEBUGMODE)
|
||||
set_property(TARGET SRB2SDL2 PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||
endif()
|
||||
|
||||
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()
|
||||
|
||||
## 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
|
||||
|
||||
+4
-4
@@ -456,10 +456,10 @@ consvar_t cv_litesteer[MAXSPLITSCREENPLAYERS] = {
|
||||
|
||||
//static CV_PossibleValue_t autoaccelcons_t[] = {{0, "Off"}, {1, "Manual"}, {2, "Automatic"}, {0, NULL}};
|
||||
consvar_t cv_autoaccel[MAXSPLITSCREENPLAYERS] = {
|
||||
{"autoaccel", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"autoaccel2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"autoaccel3", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"autoaccel4", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}
|
||||
{"kartautoaccel", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"kartautoaccel2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"kartautoaccel3", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"kartautoaccel4", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}
|
||||
};
|
||||
|
||||
static CV_PossibleValue_t driftsparkpulse_t[] = {{0, "MIN"}, {FRACUNIT*3, "MAX"}, {0, NULL}};
|
||||
|
||||
+5
-2
@@ -81,6 +81,9 @@ consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS] = {
|
||||
{"gamepadled4", "Skincolor", CV_SAVE|CV_CALL|CV_NOINIT, gamepadled_cons_t, led_off_handle4, 0, NULL, NULL, 0, 0, NULL}
|
||||
};
|
||||
|
||||
consvar_t cv_gamepadledifunfocused = {"gamepadledunfocused", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_rumbleifunfocused = {"rumbleifunfocused", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
static void rumble_off_handle(void)
|
||||
{
|
||||
if (!cv_rumble[0].value)
|
||||
@@ -930,7 +933,7 @@ void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT8 color)
|
||||
|
||||
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS);
|
||||
|
||||
if (cv_gamepadled[playernum].value == 0
|
||||
if (cv_gamepadled[playernum].value == 0 || (window_notinfocus && cv_gamepadledifunfocused.value == 0)
|
||||
|| color >= MAXTRANSLATIONS)
|
||||
{
|
||||
return;
|
||||
@@ -1009,7 +1012,7 @@ void G_PlayerDeviceRumble(INT32 playernum, UINT16 low_strength, UINT16 high_stre
|
||||
{
|
||||
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS);
|
||||
|
||||
if (cv_rumble[playernum].value == 0)
|
||||
if (cv_rumble[playernum].value == 0 || (window_notinfocus && cv_rumbleifunfocused.value == 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -116,6 +116,9 @@ extern consvar_t cv_rumble[MAXSPLITSCREENPLAYERS];
|
||||
extern consvar_t cv_rumblestrength[MAXSPLITSCREENPLAYERS];
|
||||
extern consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS];
|
||||
|
||||
extern consvar_t cv_gamepadledifunfocused;
|
||||
extern consvar_t cv_rumbleifunfocused;
|
||||
|
||||
extern INT32 mousex, mousey;
|
||||
|
||||
extern INT32 joyxmove[MAXSPLITSCREENPLAYERS][JOYAXISSET], joyymove[MAXSPLITSCREENPLAYERS][JOYAXISSET];
|
||||
|
||||
@@ -335,7 +335,7 @@ angle_t gld_FrustumAngle(angle_t tiltangle)
|
||||
floatangle = 2.0 + (45.0 + ((double)tilt / 1.9)) * clipfov / 90.0;
|
||||
if (floatangle >= 180.0)
|
||||
return 0xffffffff;
|
||||
a1 = (angle_t)xs_CRoundToInt(ANG1 * floatangle);
|
||||
a1 = (angle_t)lrint(ANG1 * floatangle);
|
||||
return a1;
|
||||
}
|
||||
|
||||
|
||||
@@ -5444,7 +5444,7 @@ static void HWR_SetTransformAiming(FTransform *trans)
|
||||
fixed_t fixedaiming = AIMINGTODY(aimingangle);
|
||||
trans->viewaiming = FixedToFloat(fixedaiming) * (static_cast<float>(vid.width) / static_cast<float>(vid.height)) / (static_cast<float>(BASEVIDWIDTH) / static_cast<float>(BASEVIDHEIGHT));
|
||||
if (splitscreen == 1) // only for 2 player splitscreen
|
||||
trans->viewaiming *= 2.125; // splitscreen adjusts fov with 0.8, so compensate (but only halfway, since splitscreen means only half the screen is used)
|
||||
trans->viewaiming *= 2.125f; // splitscreen adjusts fov with 0.8, so compensate (but only halfway, since splitscreen means only half the screen is used)
|
||||
trans->shearing = true;
|
||||
gl_aimingangle = 0;
|
||||
}
|
||||
|
||||
@@ -579,7 +579,7 @@ md2found:
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void HWR_AddPlayerMD2(int skin, boolean local) // For MD2's that were added after startup
|
||||
void HWR_AddPlayerMD2(INT32 skin, boolean local) // For MD2's that were added after startup
|
||||
{
|
||||
FILE *f;
|
||||
char name[20], filename[32];
|
||||
|
||||
@@ -3591,22 +3591,30 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8
|
||||
1.0f, -1.0f, 1.0f
|
||||
};
|
||||
|
||||
xfix = 1/((float)screen_texsizew/(float)screen_width);
|
||||
yfix = 1/((float)screen_texsizeh/(float)screen_height);
|
||||
|
||||
const GLfloat scrwf = (float)screen_width;
|
||||
const GLfloat scrwh = (float)screen_height;
|
||||
|
||||
xfix = 1/((float)screen_texsizew/scrwf);
|
||||
yfix = 1/((float)screen_texsizeh/scrwh);
|
||||
|
||||
GL_SetBlend(PF_Modulated|PF_Translucent|PF_NoDepthTest);
|
||||
|
||||
// Slight fuzziness
|
||||
GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
|
||||
GL_SetBlend(PF_Modulated|PF_Translucent|PF_NoDepthTest);
|
||||
pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
|
||||
|
||||
const float stride = 2.f/scrwh;
|
||||
uint32_t r = rand();
|
||||
|
||||
for (i = 0; i < 1; i += stride)
|
||||
const float ystep = 2.f/scrwh * (float)vid.udup/4.f;
|
||||
|
||||
for (i = 0; i < 1; i += ystep)
|
||||
{
|
||||
fix[2] = (float)(rand() % 128) / -22000.f * xfix;
|
||||
// avoid calling rand thousands of times
|
||||
r ^= r >> 13;
|
||||
r ^= r >> 11;
|
||||
r ^= r << 21;
|
||||
|
||||
fix[2] = (float)(r & 127) / -22000.f * xfix;
|
||||
fix[0] = fix[2];
|
||||
fix[6] = fix[0] + xfix;
|
||||
fix[4] = fix[2] + xfix;
|
||||
@@ -3624,8 +3632,8 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8
|
||||
}
|
||||
|
||||
// Upward bar
|
||||
//GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
|
||||
//pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
|
||||
GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
|
||||
pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
|
||||
|
||||
color[0] = color[1] = color[2] = 190;
|
||||
color[3] = 250;
|
||||
@@ -3648,13 +3656,14 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8
|
||||
|
||||
fix[1] = fix[7] += (fix[3] - fix[7])*2;
|
||||
screenVerts[1] = screenVerts[10] += (screenVerts[4] - screenVerts[1])*2;
|
||||
|
||||
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
|
||||
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
|
||||
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
// Downward bar
|
||||
//GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
|
||||
//pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
|
||||
GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
|
||||
pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
|
||||
|
||||
fix[0] = 0.0f;
|
||||
fix[6] = xfix;
|
||||
@@ -3673,6 +3682,7 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8
|
||||
|
||||
fix[1] = fix[7] += (fix[3] - fix[7])*2;
|
||||
screenVerts[1] = screenVerts[10] += (screenVerts[4] - screenVerts[1])*2;
|
||||
|
||||
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
|
||||
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
|
||||
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
@@ -3712,7 +3722,7 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh
|
||||
{
|
||||
float xfix, yfix;
|
||||
float origaspect, newaspect;
|
||||
float xoff = 1, yoff = 1; // xoffset and yoffset for the polygon to have black bars around the screen
|
||||
float xoff = 1.0f, yoff = 1.0f; // xoffset and yoffset for the polygon to have black bars around the screen
|
||||
|
||||
static float off[12] =
|
||||
{
|
||||
@@ -3735,19 +3745,19 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh
|
||||
if (origaspect < newaspect)
|
||||
{
|
||||
xoff = origaspect / newaspect;
|
||||
yoff = 1;
|
||||
yoff = 1.0f;
|
||||
}
|
||||
else if (origaspect > newaspect)
|
||||
{
|
||||
xoff = 1;
|
||||
xoff = 1.0f;
|
||||
yoff = newaspect / origaspect;
|
||||
}
|
||||
|
||||
// float off[12];
|
||||
off[0] = off[3] = -xoff;
|
||||
off[1] = off[10] = -yoff;
|
||||
off[4] = off[7] = yoff;
|
||||
off[6] = off[9] = xoff;
|
||||
off[4] = off[7] = yoff;
|
||||
off[6] = off[9] = xoff;
|
||||
|
||||
// float fix[8];
|
||||
fix[3] = fix[5] = yfix;
|
||||
|
||||
+11
-4
@@ -1484,6 +1484,7 @@ static char *CHAT_WordWrap(INT32 x, INT32 w, INT32 option, const char *string)
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return newstring;
|
||||
}
|
||||
|
||||
@@ -1522,7 +1523,7 @@ static void HU_drawMiniChat(void)
|
||||
emote_t *emote = NULL;
|
||||
int emotelen = 0;
|
||||
|
||||
while(msg[j]) // iterate through msg
|
||||
while (msg[j]) // iterate through msg
|
||||
{
|
||||
if (msg[j] < HU_FONTSTART) // don't draw
|
||||
{
|
||||
@@ -1554,14 +1555,17 @@ static void HU_drawMiniChat(void)
|
||||
{
|
||||
j++;
|
||||
}
|
||||
|
||||
prev_linereturn = false;
|
||||
dx += charwidth;
|
||||
|
||||
if (dx >= boxw)
|
||||
{
|
||||
dx = 0;
|
||||
linescount += 1;
|
||||
}
|
||||
}
|
||||
|
||||
dy = 0;
|
||||
dx = 0;
|
||||
msglines += linescount+1;
|
||||
@@ -1598,7 +1602,7 @@ static void HU_drawMiniChat(void)
|
||||
emote_t *emote = NULL;
|
||||
int emotelen = 0;
|
||||
|
||||
while(msg[j]) // iterate through msg
|
||||
while (msg[j]) // iterate through msg
|
||||
{
|
||||
if (msg[j] < HU_FONTSTART) // don't draw
|
||||
{
|
||||
@@ -1643,12 +1647,14 @@ static void HU_drawMiniChat(void)
|
||||
|
||||
dx += charwidth;
|
||||
prev_linereturn = false;
|
||||
|
||||
if (dx >= boxw)
|
||||
{
|
||||
dx = 0;
|
||||
dy += charheight;
|
||||
}
|
||||
}
|
||||
|
||||
dy += charheight;
|
||||
dx = 0;
|
||||
if (msg)
|
||||
@@ -1704,7 +1710,7 @@ static void HU_drawChatLog(INT32 offset)
|
||||
|
||||
V_DrawFillConsoleMap(chatx, chat_topy, boxw, boxh*charheight +2, 239|V_SNAPTOBOTTOM|V_SNAPTOLEFT); // log box
|
||||
|
||||
for (i=0; i<chat_nummsg_log; i++) // iterate through our chatlog
|
||||
for (i = 0; i < chat_nummsg_log; i++) // iterate through our chatlog
|
||||
{
|
||||
INT32 clrflag = 0;
|
||||
INT32 j = 0;
|
||||
@@ -1713,7 +1719,7 @@ static void HU_drawChatLog(INT32 offset)
|
||||
emote_t *emote = NULL;
|
||||
int emotelen = 0;
|
||||
|
||||
while(msg[j]) // iterate through msg
|
||||
while (msg[j]) // iterate through msg
|
||||
{
|
||||
if (msg[j] < HU_FONTSTART) // don't draw
|
||||
{
|
||||
@@ -1758,6 +1764,7 @@ static void HU_drawChatLog(INT32 offset)
|
||||
dy += charheight;
|
||||
}
|
||||
}
|
||||
|
||||
dy += charheight;
|
||||
dx = 0;
|
||||
if (msg)
|
||||
|
||||
@@ -1293,6 +1293,7 @@ static int lib_pPlayRinglossSound(lua_State *L)
|
||||
player_t *player = NULL;
|
||||
mobj_t *damager = NULL;
|
||||
NOHUD
|
||||
LUA_UsageWarning(L, "P_PlayRinglossSound: using this function from lua might cause desynchs, consider using S_StartSound(origin, sfx_khurt1 + P_RandomKey(2)) as workaround");
|
||||
if (!source)
|
||||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
if (!lua_isnone(L, 2) && lua_isuserdata(L, 2))
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@
|
||||
#include "lua_hook.h" // cmd errors
|
||||
|
||||
boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor);
|
||||
state_t *astate;
|
||||
state_t *astate = NULL;
|
||||
|
||||
boolean actionsoverridden[NUMACTIONS] = {false};
|
||||
|
||||
|
||||
+18
-21
@@ -45,20 +45,20 @@ int hook_defrosting = 0;
|
||||
|
||||
// List of internal libraries to load from SRB2
|
||||
static lua_CFunction liblist[] = {
|
||||
LUA_EnumLib, // global metatable for enums
|
||||
LUA_SOCLib, // A_Action functions, freeslot
|
||||
LUA_BaseLib, // string concatination by +, CONS_Printf, p_local.h stuff (P_InstaThrust, P_Move), etc.
|
||||
LUA_MathLib, // fixed_t and angle_t math functions
|
||||
LUA_HookLib, // hookAdd and hook-calling functions
|
||||
LUA_ConsoleLib, // console command/variable functions and structs
|
||||
LUA_InfoLib, // info.h stuff: mobjinfo_t, mobjinfo[], state_t, states[]
|
||||
LUA_MobjLib, // mobj_t, mapthing_t
|
||||
LUA_PlayerLib, // player_t
|
||||
LUA_SkinLib, // skin_t, skins[]
|
||||
LUA_ThinkerLib, // thinker_t
|
||||
LUA_MapLib, // line_t, side_t, sector_t, subsector_t
|
||||
LUA_BlockmapLib, // blockmap stuff
|
||||
LUA_HudLib, // HUD stuff
|
||||
LUA_EnumLib, // global metatable for enums
|
||||
LUA_SOCLib, // A_Action functions, freeslot
|
||||
LUA_BaseLib, // string concatination by +, CONS_Printf, p_local.h stuff (P_InstaThrust, P_Move), etc.
|
||||
LUA_MathLib, // fixed_t and angle_t math functions
|
||||
LUA_HookLib, // hookAdd and hook-calling functions
|
||||
LUA_ConsoleLib, // console command/variable functions and structs
|
||||
LUA_InfoLib, // info.h stuff: mobjinfo_t, mobjinfo[], state_t, states[]
|
||||
LUA_MobjLib, // mobj_t, mapthing_t
|
||||
LUA_PlayerLib, // player_t
|
||||
LUA_SkinLib, // skin_t, skins[]
|
||||
LUA_ThinkerLib, // thinker_t
|
||||
LUA_MapLib, // line_t, side_t, sector_t, subsector_t
|
||||
LUA_BlockmapLib, // blockmap stuff
|
||||
LUA_HudLib, // HUD stuff
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -66,12 +66,8 @@ static lua_CFunction liblist[] = {
|
||||
static void *LUA_Alloc(void *ud, void *ptr, size_t osize, size_t nsize)
|
||||
{
|
||||
(void)ud;
|
||||
if (nsize == 0) {
|
||||
if (osize != 0)
|
||||
Z_Free(ptr);
|
||||
return NULL;
|
||||
} else
|
||||
return Z_Realloc(ptr, nsize, PU_LUA, NULL);
|
||||
(void)osize;
|
||||
return Z_Realloc(ptr, nsize, PU_LUA, NULL);
|
||||
}
|
||||
|
||||
// Panic function Lua calls when there's an unprotected error.
|
||||
@@ -213,7 +209,8 @@ void LUA_ClearState(void)
|
||||
lua_setfield(L, LUA_REGISTRYINDEX, LREG_VALID);
|
||||
|
||||
// open srb2 libraries
|
||||
for(i = 0; liblist[i]; i++) {
|
||||
for (i = 0; liblist[i]; i++)
|
||||
{
|
||||
lua_pushcfunction(L, liblist[i]);
|
||||
lua_call(L, 0, 0);
|
||||
}
|
||||
|
||||
+1
-1
@@ -301,7 +301,7 @@ void Command_CheatNoTarget_f(void)
|
||||
void Command_Scale_f(void)
|
||||
{
|
||||
const double scaled = atof(COM_Argv(1));
|
||||
fixed_t scale = FLOAT_TO_FIXED(scaled);
|
||||
fixed_t scale = DoubleToFixed(scaled);
|
||||
|
||||
REQUIRE_DEVMODE;
|
||||
REQUIRE_INLEVEL;
|
||||
|
||||
+9
-29
@@ -20,6 +20,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include "doomtype.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
@@ -71,6 +72,14 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t DoubleToFixed(double f)
|
||||
#define FIXED_TO_FLOAT(x) FixedToFloat(x) // (((float)(x)) / ((float)FRACUNIT))
|
||||
#define FLOAT_TO_FIXED(f) FloatToFixed(f) // (fixed_t)((f) * ((float)FRACUNIT))
|
||||
|
||||
FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedClamp(INT64 val)
|
||||
{
|
||||
// stoopid includes
|
||||
#define FCLAMP(x, y, z) ((x) < (y) ? (y) : ((x) > (z) ? (z) : (x)))
|
||||
return (fixed_t)(FCLAMP(val, (INT64)INT32_MIN, (INT64)INT32_MAX));
|
||||
#undef FCLAMP
|
||||
}
|
||||
|
||||
/** \brief The FixedMul function
|
||||
|
||||
\param a fixed_t number
|
||||
@@ -265,35 +274,6 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedRound(fixed_t x)
|
||||
return INT32_MAX;
|
||||
}
|
||||
|
||||
/** \brief The xs_CRoundToInt function
|
||||
|
||||
\param val double number
|
||||
|
||||
\return Round toward nearest, but ties round toward even
|
||||
*/
|
||||
#if defined(SRB2_BIG_ENDIAN)
|
||||
#define _xs_iexp_ 0
|
||||
#define _xs_iman_ 1
|
||||
#else
|
||||
#define _xs_iexp_ 1 //intel is little endian
|
||||
#define _xs_iman_ 0
|
||||
#endif //BigEndian_
|
||||
|
||||
typedef double real64;
|
||||
|
||||
typedef union _xs_doubleints
|
||||
{
|
||||
real64 val;
|
||||
unsigned ival[2];
|
||||
} _xs_doubleints;
|
||||
|
||||
FUNCMATH FUNCINLINE static ATTRINLINE int xs_CRoundToInt(real64 val)
|
||||
{
|
||||
_xs_doubleints uval;
|
||||
uval.val = val + 6755399441055744.0;
|
||||
return uval.ival[_xs_iman_];
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
fixed_t x;
|
||||
|
||||
+1
-1
@@ -4719,7 +4719,7 @@ static void M_DrawReplayHut(void)
|
||||
if (y > scaledviewheight-80)
|
||||
{
|
||||
V_DrawFill(BASEVIDWIDTH-4, 75, 4, scaledviewheight-80, V_SNAPTOTOP|V_SNAPTORIGHT|239);
|
||||
V_DrawFill(BASEVIDWIDTH-3, 76 + (scaledviewheight-80) * replayhutmenuy / y, 2, (((scaledviewheight-80) * (scaledviewheight-80))-1) / y - 1, V_SNAPTOTOP|V_SNAPTORIGHT|229);
|
||||
V_DrawFill(BASEVIDWIDTH-3, 76 + (scaledviewheight-80) * replayhutmenuy / y, 2, max((((scaledviewheight-80) * (scaledviewheight-80))-1) / y - 1, 1), V_SNAPTOTOP|V_SNAPTORIGHT|229);
|
||||
}
|
||||
|
||||
// Draw the cursor
|
||||
|
||||
@@ -1205,6 +1205,10 @@ static menuitem_t OP_FocusOptionsMenu[] =
|
||||
{IT_STRING|IT_CVAR, NULL, "Show \"FOCUS LOST\"", &cv_showfocuslost, 100},
|
||||
|
||||
{IT_STRING|IT_CVAR, NULL, "Visible Mouse", &cv_mousevisible, 120},
|
||||
|
||||
{IT_STRING|IT_CVAR, NULL, "Gamepad LED Color While Unfocused ", &cv_gamepadledifunfocused, 140},
|
||||
{IT_STRING|IT_CVAR, NULL, "Gamepad Rumble While Unfocused", &cv_rumbleifunfocused, 150},
|
||||
|
||||
};
|
||||
|
||||
static const char* OP_FocusOptionsTooltips[] =
|
||||
@@ -1216,6 +1220,8 @@ static const char* OP_FocusOptionsTooltips[] =
|
||||
"Set manual framerate cap while the game is unfocused.",
|
||||
"Should the FOCUS LOST window appear\n while the game is unfocused?",
|
||||
"Displays the mouse cursor while the game is in focus.",
|
||||
"Should gamepad LED indicator change color when unfocused?",
|
||||
"Should gamepad rumble apply when unfocused?",
|
||||
};
|
||||
|
||||
static menuitem_t OP_DataOptionsMenu[] =
|
||||
|
||||
+2
-2
@@ -540,7 +540,7 @@ static boolean M_BackupConfig(const char *filename)
|
||||
void M_SaveConfig(const char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
char *filepath;
|
||||
CLEANUP(Z_Pfree) char *filepath = NULL;
|
||||
|
||||
// make sure not to write back the config until it's been correctly loaded
|
||||
if (!loaded_config)
|
||||
@@ -558,7 +558,7 @@ void M_SaveConfig(const char *filename)
|
||||
// append srb2home to beginning of filename
|
||||
// but check if srb2home isn't already there, first
|
||||
if (!strstr(filename, srb2home))
|
||||
filepath = va(pandf,srb2home, filename);
|
||||
filepath = Z_StrDup(va(pandf, srb2home, filename));
|
||||
else
|
||||
filepath = Z_StrDup(filename);
|
||||
|
||||
|
||||
+6
-6
@@ -519,10 +519,10 @@ void R_GetRenderBlockMapDimensions(fixed_t drawdist, INT32 *xl, INT32 *xh, INT32
|
||||
const fixed_t vyright = viewy + FixedMul(drawdist, FSIN(right));
|
||||
|
||||
// Try to narrow the search to within only the field of view
|
||||
*xl = (unsigned)(std::min(viewx, std::min(vxleft, vxright)) - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
*xh = (unsigned)(std::max(viewx, std::max(vxleft, vxright)) - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
*yl = (unsigned)(std::min(viewy, std::min(vyleft, vyright)) - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
*yh = (unsigned)(std::max(viewy, std::max(vyleft, vyright)) - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
*xl = (unsigned)(FixedClamp((INT64)std::min(viewx, std::min(vxleft, vxright)) - bmaporgx))>>MAPBLOCKSHIFT;
|
||||
*xh = (unsigned)(FixedClamp((INT64)std::max(viewx, std::max(vxleft, vxright)) - bmaporgx))>>MAPBLOCKSHIFT;
|
||||
*yl = (unsigned)(FixedClamp((INT64)std::min(viewy, std::min(vyleft, vyright)) - bmaporgy))>>MAPBLOCKSHIFT;
|
||||
*yh = (unsigned)(FixedClamp((INT64)std::max(viewy, std::max(vyleft, vyright)) - bmaporgy))>>MAPBLOCKSHIFT;
|
||||
|
||||
if (*xh >= bmapwidth)
|
||||
*xh = bmapwidth - 1;
|
||||
@@ -1018,8 +1018,8 @@ static void R_InitViewMapping(void)
|
||||
|
||||
for (INT32 i = 0; i < j; i++)
|
||||
{
|
||||
fixed_t dy = (i - viewheight*8)<<FRACBITS;
|
||||
dy = FixedMul(abs(dy), fovtan);
|
||||
fixed_t dy = abs(i - viewheight*8) << FRACBITS;
|
||||
dy = FixedMul(dy, fovtan);
|
||||
yslopetab[i] = FixedDiv(centerx*FRACUNIT, dy);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -152,8 +152,8 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y);
|
||||
|
||||
FUNCMATH FUNCINLINE static ATTRINLINE fixed_t R_QuickDist(fixed_t x1, fixed_t y1, fixed_t x, fixed_t y)
|
||||
{
|
||||
const fixed_t absx = abs(x - x1);
|
||||
const fixed_t absy = abs(y - y1);
|
||||
const fixed_t absx = FixedClamp(labs((INT64)x - (INT64)x1));
|
||||
const fixed_t absy = FixedClamp(labs((INT64)y - (INT64)y1));
|
||||
#ifdef __cplusplus
|
||||
return std::max<fixed_t>(absx, absy);
|
||||
#else
|
||||
|
||||
+15
-12
@@ -57,8 +57,11 @@ visffloor_t visffloor[MAXFFLOORS] = {};
|
||||
INT32 numffloors = 0;
|
||||
|
||||
//SoM: 3/23/2000: Boom visplane hashing routine.
|
||||
#define visplane_hash(picnum,lightlevel,height) \
|
||||
((unsigned)((picnum)*3+(lightlevel)+(height)*7) & VISPLANEHASHMASK)
|
||||
constexpr unsigned int visplane_hash(const unsigned int picnum, const unsigned int lightlevel,
|
||||
const unsigned int height)
|
||||
{
|
||||
return ((picnum * 3) + lightlevel + (height * 7)) & VISPLANEHASHMASK;
|
||||
}
|
||||
|
||||
//
|
||||
// Clip values are the solid pixel bounding the range.
|
||||
@@ -136,7 +139,7 @@ void R_AllocPlaneMemory(void)
|
||||
}
|
||||
|
||||
yslopetab = static_cast<fixed_t*>(Z_Realloc(yslopetab, sizeof(*yslopetab) * (viewheight * 16), PU_STATIC, NULL));
|
||||
spanstart = static_cast<fixed_t*>(Z_Realloc(spanstart, sizeof(*spanstart) * viewheight, PU_STATIC, NULL));
|
||||
spanstart = static_cast<INT32*>(Z_Realloc(spanstart, sizeof(*spanstart) * viewheight, PU_STATIC, NULL));
|
||||
}
|
||||
|
||||
//
|
||||
@@ -225,8 +228,8 @@ static void R_MapPlane(drawspandata_t *ds, spandrawfunc_t *localspanfunc, INT32
|
||||
// to step from those to the proper texture coordinate to start drawing at.
|
||||
// That way, the texture coordinate is always calculated by its position
|
||||
// on the screen and not by its position relative to the edge of the visplane.
|
||||
ds->xfrac = ds->xoffs + FixedMul(planecos, distance) + (x1 - centerx) * ds->xstep;
|
||||
ds->yfrac = ds->yoffs - FixedMul(planesin, distance) + (x1 - centerx) * ds->ystep;
|
||||
ds->xfrac = FixedClamp((INT64)ds->xoffs + (INT64)FixedMul(planecos, distance) + ((INT64)x1 - (INT64)centerx) * (INT64)ds->xstep);
|
||||
ds->yfrac = FixedClamp((INT64)ds->yoffs - (INT64)FixedMul(planesin, distance) + ((INT64)x1 - (INT64)centerx) * (INT64)ds->ystep);
|
||||
|
||||
if (ds->planeripple.active)
|
||||
{
|
||||
@@ -451,7 +454,7 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
|
||||
}
|
||||
}
|
||||
|
||||
hash = visplane_hash(picnum, lightlevel, height);
|
||||
hash = visplane_hash(picnum, lightlevel, height >> FRACBITS);
|
||||
|
||||
for (check = visplanes[hash]; check; check = check->next)
|
||||
{
|
||||
@@ -562,7 +565,7 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop)
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned hash = visplane_hash(pl->picnum, pl->lightlevel, pl->height);
|
||||
unsigned hash = visplane_hash(pl->picnum, pl->lightlevel, pl->height >> FRACBITS);
|
||||
new_pl = new_visplane(hash);
|
||||
}
|
||||
|
||||
@@ -920,12 +923,12 @@ static void R_SetSlopePlane(drawspandata_t* ds, pslope_t *slope, fixed_t xpos, f
|
||||
|
||||
// m is the v direction vector in view space
|
||||
ang = ANG2RAD(ANGLE_180 - (angle + plangle));
|
||||
m->x = cos(ang);
|
||||
m->z = sin(ang);
|
||||
m->x = cosf(ang);
|
||||
m->z = sinf(ang);
|
||||
|
||||
// n is the u direction vector in view space
|
||||
n->x = sin(ang);
|
||||
n->z = -cos(ang);
|
||||
n->x = sinf(ang);
|
||||
n->z = -cosf(ang);
|
||||
|
||||
plangle >>= ANGLETOFINESHIFT;
|
||||
temp = P_GetSlopeZAt(slope, xpos + FINESINE(plangle), ypos + FINECOSINE(plangle));
|
||||
@@ -1009,7 +1012,7 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle
|
||||
levelflat_t *levelflat;
|
||||
void (*mapfunc)(drawspandata_t*, void(*)(drawspandata_t*), INT32, INT32, INT32, boolean) = R_MapPlane;
|
||||
|
||||
if (pl->minx > pl->maxx)
|
||||
if (!(pl->minx <= pl->maxx))
|
||||
return;
|
||||
|
||||
// sky flat
|
||||
|
||||
+2
-3
@@ -246,7 +246,6 @@ static boolean TrimVisplaneBounds(const visplane_t* plane, INT16* start, INT16*
|
||||
if (!(*start < *end))
|
||||
return true;
|
||||
|
||||
|
||||
/** Trims a visplane's horizontal gap to match its render area.
|
||||
*
|
||||
* Visplanes' minx/maxx may sometimes exceed the area they're
|
||||
@@ -313,8 +312,8 @@ void Portal_AddSkybox(const visplane_t* plane)
|
||||
y = (viewy - skyboxmo[1]->y) * -mh->skybox_scaley;
|
||||
|
||||
// Apply transform to account for the skybox viewport angle.
|
||||
portal->viewx += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang));
|
||||
portal->viewy += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang));
|
||||
portal->viewx += FixedMul(x, FINECOSINE(ang)) - FixedMul(y, FINESINE(ang));
|
||||
portal->viewy += FixedMul(x, FINESINE(ang)) + FixedMul(y, FINECOSINE(ang));
|
||||
}
|
||||
|
||||
if (mh->skybox_scalez > 0)
|
||||
|
||||
+81
-92
@@ -226,10 +226,11 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
|
||||
leftheight -= viewz;
|
||||
rightheight -= viewz;
|
||||
|
||||
rlight->height = (centeryfrac) - FixedMul(leftheight, drawseg->scale1);
|
||||
rlight->heightstep = (centeryfrac) - FixedMul(rightheight, drawseg->scale2);
|
||||
rlight->heightstep = (rlight->heightstep-rlight->height)/(range);
|
||||
rlight->startheight = rlight->height; // keep starting value here to reset for each repeat
|
||||
rlight->height = FixedClamp((INT64)centeryfrac - FixedMul(leftheight, drawseg->scale1));
|
||||
rlight->heightstep = FixedClamp((INT64)centeryfrac - FixedMul(rightheight, drawseg->scale2));
|
||||
rlight->heightstep = FixedClamp((INT64)rlight->heightstep - rlight->height)/(range);
|
||||
rlight->startheight = rlight->height; // keep starting value here to reset for each repeat
|
||||
|
||||
rlight->lightlevel = *light->lightlevel;
|
||||
rlight->extra_colormap = light->extra_colormap;
|
||||
rlight->flags = static_cast<ffloortype_e>(light->flags);
|
||||
@@ -341,7 +342,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
|
||||
for (i = 0; i < dc->numlights; i++)
|
||||
{
|
||||
rlight = &dc->lightlist[i];
|
||||
rlight->height += rlight->heightstep;
|
||||
rlight->height = FixedClamp((INT64)rlight->height + rlight->heightstep);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,9 +356,9 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
|
||||
lighttable_t **xwalllights;
|
||||
|
||||
sprbotscreen = INT32_MAX;
|
||||
sprtopscreen = windowtop = (centeryfrac - FixedMul(dc->texturemid, spryscale));
|
||||
sprtopscreen = windowtop = FixedClamp((INT64)centeryfrac - FixedMul(dc->texturemid, spryscale));
|
||||
|
||||
realbot = windowbottom = FixedMul(textureheight[texnum], spryscale) + sprtopscreen;
|
||||
realbot = windowbottom = FixedClamp((INT64)FixedMul(textureheight[texnum], spryscale) + sprtopscreen);
|
||||
dc->iscale = 0xffffffffu / (unsigned)spryscale;
|
||||
|
||||
// draw the texture
|
||||
@@ -407,7 +408,8 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
|
||||
set_light_vars(i);
|
||||
|
||||
height = rlight->height;
|
||||
rlight->height += rlight->heightstep;
|
||||
|
||||
rlight->height = FixedClamp((INT64)rlight->height + rlight->heightstep);
|
||||
|
||||
if (height <= windowtop)
|
||||
{
|
||||
@@ -423,7 +425,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
|
||||
for (i++; i < dc->numlights; i++)
|
||||
{
|
||||
rlight = &dc->lightlist[i];
|
||||
rlight->height += rlight->heightstep;
|
||||
rlight->height = FixedClamp((INT64)rlight->height + rlight->heightstep);
|
||||
}
|
||||
|
||||
continue;
|
||||
@@ -455,7 +457,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
|
||||
if (frontsector->extra_colormap)
|
||||
dc->colormap = frontsector->extra_colormap->colormap + (dc->colormap - colormaps);
|
||||
|
||||
sprtopscreen = centeryfrac - FixedMul(dc->texturemid, spryscale);
|
||||
sprtopscreen = FixedClamp((INT64)centeryfrac - FixedMul(dc->texturemid, spryscale));
|
||||
dc->iscale = 0xffffffffu / (unsigned)spryscale;
|
||||
|
||||
// draw the texture
|
||||
@@ -710,17 +712,6 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf
|
||||
rw_scalestep = drawseg->scalestep;
|
||||
spryscale = drawseg->scale1 + (x1 - drawseg->x1)*rw_scalestep;
|
||||
|
||||
#define CLAMPMAX INT32_MAX
|
||||
#define CLAMPMIN (-INT32_MAX) // This is not INT32_MIN on purpose! INT32_MIN makes the drawers freak out.
|
||||
auto overflow_clamp = [&](INT64 overflow_test)
|
||||
{
|
||||
return (overflow_test > (INT64)CLAMPMAX) ? CLAMPMAX :
|
||||
(overflow_test > (INT64)CLAMPMIN) ? (fixed_t)overflow_test :
|
||||
CLAMPMIN;
|
||||
};
|
||||
#undef CLAMPMAX
|
||||
#undef CLAMPMIN
|
||||
|
||||
dc->numlights = 0;
|
||||
if (frontsector->numlights)
|
||||
{
|
||||
@@ -736,7 +727,6 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf
|
||||
{
|
||||
fixed_t leftheight, rightheight;
|
||||
fixed_t pfloorleft, pfloorright;
|
||||
INT64 overflow_test;
|
||||
light = &frontsector->lightlist[i];
|
||||
rlight = &dc->lightlist[p];
|
||||
|
||||
@@ -760,17 +750,14 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf
|
||||
continue;
|
||||
}
|
||||
|
||||
leftheight -= viewz;
|
||||
leftheight -= viewz;
|
||||
rightheight -= viewz;
|
||||
|
||||
// Monster Iestyn (25/03/18): do not skip these lights if they fail overflow test, just clamp them instead so they behave.
|
||||
overflow_test = (INT64)centeryfrac - (((INT64)leftheight*drawseg->scale1)>>FRACBITS);
|
||||
rlight->height = overflow_clamp(overflow_test);
|
||||
rlight->height = FixedClamp((INT64)centeryfrac - (((INT64)leftheight * drawseg->scale1)>>FRACBITS));
|
||||
rlight->heightstep = FixedClamp((INT64)centeryfrac - (((INT64)rightheight * drawseg->scale2)>>FRACBITS));
|
||||
rlight->heightstep = FixedClamp((INT64)rlight->heightstep - rlight->height)/(range);
|
||||
|
||||
overflow_test = (INT64)centeryfrac - (((INT64)rightheight*drawseg->scale2)>>FRACBITS);
|
||||
rlight->heightstep = overflow_clamp(overflow_test);
|
||||
|
||||
rlight->heightstep = (rlight->heightstep-rlight->height)/(range);
|
||||
rlight->flags = static_cast<ffloortype_e>(light->flags);
|
||||
|
||||
if (light->flags & FF_CUTLEVEL)
|
||||
@@ -781,13 +768,9 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf
|
||||
rightheight -= viewz;
|
||||
|
||||
// Monster Iestyn (25/03/18): do not skip these lights if they fail overflow test, just clamp them instead so they behave.
|
||||
overflow_test = (INT64)centeryfrac - (((INT64)leftheight*drawseg->scale1)>>FRACBITS);
|
||||
rlight->botheight = overflow_clamp(overflow_test);
|
||||
|
||||
overflow_test = (INT64)centeryfrac - (((INT64)rightheight*drawseg->scale2)>>FRACBITS);
|
||||
rlight->botheightstep = overflow_clamp(overflow_test);
|
||||
|
||||
rlight->botheightstep = (rlight->botheightstep-rlight->botheight)/(range);
|
||||
rlight->botheight = FixedClamp((INT64)centeryfrac - (((INT64)leftheight*drawseg->scale1)>>FRACBITS));
|
||||
rlight->botheightstep = FixedClamp(((INT64)centeryfrac - (((INT64)rightheight*drawseg->scale2)>>FRACBITS)));
|
||||
rlight->botheightstep = FixedClamp((INT64)rlight->botheightstep - rlight->botheight)/(range);
|
||||
}
|
||||
|
||||
rlight->lightlevel = *light->lightlevel;
|
||||
@@ -896,10 +879,10 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf
|
||||
right_bottom = P_GetFFloorBottomZAt(pfloor, drawseg->rightpos.x, drawseg->rightpos.y) - viewz;
|
||||
|
||||
// using INT64 to avoid 32bit overflow
|
||||
top_frac = (INT64)centeryfrac - (((INT64)left_top * drawseg->scale1) >> FRACBITS);
|
||||
bottom_frac = (INT64)centeryfrac - (((INT64)left_bottom * drawseg->scale1) >> FRACBITS);
|
||||
top_step = (INT64)centeryfrac - (((INT64)right_top * drawseg->scale2) >> FRACBITS);
|
||||
bottom_step = (INT64)centeryfrac - (((INT64)right_bottom * drawseg->scale2) >> FRACBITS);
|
||||
top_frac = FixedClamp((INT64)centeryfrac - (((INT64)left_top * drawseg->scale1) >> FRACBITS));
|
||||
top_step = FixedClamp((INT64)centeryfrac - (((INT64)right_top * drawseg->scale2) >> FRACBITS));
|
||||
bottom_frac = FixedClamp((INT64)centeryfrac - (((INT64)left_bottom * drawseg->scale1) >> FRACBITS));
|
||||
bottom_step = FixedClamp((INT64)centeryfrac - (((INT64)right_bottom * drawseg->scale2) >> FRACBITS));
|
||||
|
||||
top_step = (top_step-top_frac)/(range);
|
||||
bottom_step = (bottom_step-bottom_frac)/(range);
|
||||
@@ -921,8 +904,8 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf
|
||||
|
||||
// Calculate bounds
|
||||
// clamp the values if necessary to avoid overflows and rendering glitches caused by them
|
||||
sprtopscreen = windowtop = overflow_clamp(top_frac);
|
||||
sprbotscreen = windowbottom = overflow_clamp(bottom_frac);
|
||||
sprtopscreen = windowtop = top_frac;
|
||||
sprbotscreen = windowbottom = bottom_frac;
|
||||
|
||||
top_frac += top_step;
|
||||
bottom_frac += bottom_step;
|
||||
@@ -935,9 +918,11 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf
|
||||
for (i = 0; i < dc->numlights; i++)
|
||||
{
|
||||
rlight = &dc->lightlist[i];
|
||||
rlight->height += rlight->heightstep;
|
||||
|
||||
rlight->height = FixedClamp((INT64)rlight->height + rlight->heightstep);
|
||||
|
||||
if (rlight->flags & FF_CUTLEVEL)
|
||||
rlight->botheight += rlight->botheightstep;
|
||||
rlight->botheight = FixedClamp((INT64)rlight->botheight + rlight->botheightstep);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1045,12 +1030,12 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf
|
||||
solid = 0;
|
||||
|
||||
height = rlight->height;
|
||||
rlight->height += rlight->heightstep;
|
||||
rlight->height = FixedClamp((INT64)rlight->height + rlight->heightstep);
|
||||
|
||||
if (solid)
|
||||
{
|
||||
bheight = rlight->botheight - (FRACUNIT >> 1);
|
||||
rlight->botheight += rlight->botheightstep;
|
||||
bheight = FixedClamp((INT64)rlight->botheight - (FRACUNIT >> 1));
|
||||
rlight->botheight = FixedClamp((INT64)rlight->botheight + rlight->botheightstep);
|
||||
}
|
||||
|
||||
if (height <= windowtop)
|
||||
@@ -1078,7 +1063,7 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf
|
||||
for (i++; i < dc->numlights; i++)
|
||||
{
|
||||
rlight = &dc->lightlist[i];
|
||||
rlight->height += rlight->heightstep;
|
||||
rlight->height = FixedClamp((INT64)rlight->height + rlight->heightstep);
|
||||
|
||||
if (rlight->flags & FF_CUTLEVEL)
|
||||
rlight->botheight += rlight->botheightstep;
|
||||
@@ -1212,7 +1197,7 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
|
||||
for (; rw_x < rw_stopx; rw_x++)
|
||||
{
|
||||
// mark floor / ceiling areas
|
||||
yl = (topfrac+HEIGHTUNIT-1)>>HEIGHTBITS;
|
||||
yl = FixedClamp((INT64)topfrac + HEIGHTUNIT-1)>>HEIGHTBITS;
|
||||
yh = bottomfrac>>HEIGHTBITS;
|
||||
|
||||
// Mark ceiling
|
||||
@@ -1363,15 +1348,17 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
|
||||
//SoM: Calculate offsets for Thick fake floors.
|
||||
// calculate texture offset
|
||||
angle = (rw_centerangle + xtoviewangle[rw_x])>>ANGLETOFINESHIFT;
|
||||
|
||||
// Mask 4095 to guarantee this index is within bounds
|
||||
texturecolumn = rw_offset-FixedMul(FINETANGENT(angle & 4095), rw_distance);
|
||||
texturecolumn = FixedClamp((INT64)rw_offset - FixedMul(FINETANGENT(angle & 4095), rw_distance));
|
||||
|
||||
if (oldtexturecolumn != -1)
|
||||
{
|
||||
rw_bottomtexturemid += FixedMul(rw_bottomtextureslide, oldtexturecolumn-texturecolumn);
|
||||
rw_midtexturemid += FixedMul(rw_midtextureslide, oldtexturecolumn-texturecolumn);
|
||||
rw_toptexturemid += FixedMul(rw_toptextureslide, oldtexturecolumn-texturecolumn);
|
||||
rw_midtextureback += FixedMul(rw_midtexturebackslide, oldtexturecolumn-texturecolumn);
|
||||
const fixed_t coloff = FixedClamp((INT64)oldtexturecolumn - texturecolumn);
|
||||
rw_bottomtexturemid += FixedMul(rw_bottomtextureslide, coloff);
|
||||
rw_midtexturemid += FixedMul(rw_midtextureslide, coloff);
|
||||
rw_toptexturemid += FixedMul(rw_toptextureslide, coloff);
|
||||
rw_midtextureback += FixedMul(rw_midtexturebackslide, coloff);
|
||||
}
|
||||
oldtexturecolumn = texturecolumn;
|
||||
|
||||
@@ -1381,7 +1368,7 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
|
||||
// calculate lighting
|
||||
pindex = FixedMul(rw_scale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT;
|
||||
|
||||
if (pindex >= MAXLIGHTSCALE)
|
||||
if (pindex >= MAXLIGHTSCALE)
|
||||
pindex = MAXLIGHTSCALE-1;
|
||||
|
||||
dc->colormap = walllights[pindex];
|
||||
@@ -1463,8 +1450,8 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
|
||||
if (toptexture)
|
||||
{
|
||||
// top wall
|
||||
mid = pixhigh>>HEIGHTBITS;
|
||||
pixhigh += pixhighstep;
|
||||
mid = pixhigh >> HEIGHTBITS;
|
||||
pixhigh = FixedClamp((INT64)pixhigh + pixhighstep);
|
||||
|
||||
if (mid >= floorclip[rw_x])
|
||||
mid = floorclip[rw_x]-1;
|
||||
@@ -1493,8 +1480,8 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
|
||||
if (bottomtexture)
|
||||
{
|
||||
// bottom wall
|
||||
mid = (pixlow+HEIGHTUNIT-1)>>HEIGHTBITS;
|
||||
pixlow += pixlowstep;
|
||||
mid = FixedClamp((INT64)pixlow+HEIGHTUNIT-1)>>HEIGHTBITS;
|
||||
pixlow = FixedClamp((INT64)pixlow + pixlowstep);
|
||||
|
||||
// no space above wall?
|
||||
if (mid <= ceilingclip[rw_x])
|
||||
@@ -1545,10 +1532,10 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
|
||||
{
|
||||
for (i = 0; i < dc->numlights; i++)
|
||||
{
|
||||
dc->lightlist[i].height += dc->lightlist[i].heightstep;
|
||||
dc->lightlist[i].height = FixedClamp((INT64)dc->lightlist[i].height + dc->lightlist[i].heightstep);
|
||||
|
||||
if (dc->lightlist[i].flags & FF_CUTSOLIDS)
|
||||
dc->lightlist[i].botheight += dc->lightlist[i].botheightstep;
|
||||
dc->lightlist[i].botheight = FixedClamp((INT64)dc->lightlist[i].botheight + dc->lightlist[i].botheightstep);;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1569,9 +1556,10 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
|
||||
visffloor[i].b_frac += visffloor[i].b_step;
|
||||
}
|
||||
|
||||
rw_scale += rw_scalestep;
|
||||
topfrac += topstep;
|
||||
bottomfrac += bottomstep;
|
||||
rw_scale = FixedClamp((INT64)rw_scale + rw_scalestep);
|
||||
|
||||
topfrac = FixedClamp((INT64)topfrac + topstep);
|
||||
bottomfrac = FixedClamp((INT64)bottomfrac + bottomstep);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1585,7 +1573,7 @@ static void R_MarkSegBounds(void)
|
||||
for (; rw_x < rw_stopx; rw_x++)
|
||||
{
|
||||
// mark floor / ceiling areas
|
||||
yl = (topfrac+HEIGHTUNIT-1)>>HEIGHTBITS;
|
||||
yl = FixedClamp((INT64)topfrac + HEIGHTUNIT-1)>>HEIGHTBITS;
|
||||
yh = bottomfrac>>HEIGHTBITS;
|
||||
|
||||
// Mark ceiling
|
||||
@@ -1822,7 +1810,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
|
||||
// big room fix
|
||||
if (longboi)
|
||||
rw_distance = (fixed_t)R_CalcSegDist(curline,viewx,viewy);
|
||||
rw_distance = FixedClamp(R_CalcSegDist(curline, viewx, viewy));
|
||||
|
||||
ds_p->x1 = rw_x = start;
|
||||
ds_p->x2 = stop;
|
||||
@@ -2205,8 +2193,8 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
}
|
||||
}
|
||||
|
||||
rw_toptexturemid += sidedef->rowoffset;
|
||||
rw_bottomtexturemid += sidedef->rowoffset;
|
||||
rw_toptexturemid = FixedClamp((INT64)rw_toptexturemid + sidedef->rowoffset);
|
||||
rw_bottomtexturemid = FixedClamp((INT64)rw_bottomtexturemid + sidedef->rowoffset);
|
||||
|
||||
R_AllocTextureColumnTables(rw_stopx - start);
|
||||
|
||||
@@ -2491,8 +2479,9 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
rw_offset = -rw_offset;
|
||||
|
||||
/// don't use texture offset for splats
|
||||
rw_offset2 = rw_offset + curline->offset;
|
||||
rw_offset += sidedef->textureoffset + curline->offset;
|
||||
rw_offset2 = FixedClamp((INT64)rw_offset + curline->offset);
|
||||
rw_offset = FixedClamp((INT64)rw_offset + (INT64)sidedef->textureoffset + curline->offset);
|
||||
|
||||
rw_centerangle = ANGLE_90 + viewangle - rw_normalangle;
|
||||
|
||||
// calculate light table
|
||||
@@ -2552,8 +2541,8 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
|
||||
auto set_topstep_normal = [&]
|
||||
{
|
||||
topstep = -FixedMul (rw_scalestep, worldtop);
|
||||
topfrac = (centeryfrac>>4) - FixedMul (worldtop, rw_scale);
|
||||
topstep = -FixedMul(rw_scalestep, worldtop);
|
||||
topfrac = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldtop, rw_scale));
|
||||
};
|
||||
|
||||
// untextured seg
|
||||
@@ -2574,14 +2563,14 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
// this is an attempt to fix issues with textureless single sided lines drawing nothing where they should just draw sky instead
|
||||
if (tophigh && !backsector && frontsector->ceilingpic == skyflatnum)
|
||||
{
|
||||
topstep = -FixedMul (rw_scalestep, worldbottom);
|
||||
topfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale);
|
||||
topstep = -FixedMul(rw_scalestep, worldbottom);
|
||||
topfrac = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldbottom, rw_scale));
|
||||
|
||||
// account for slopes to try and get rid of sharp edges from the black void
|
||||
if (frontsector->f_slope || (backsector && backsector->f_slope))
|
||||
{
|
||||
topstep = -FixedMul (rw_scalestep, worldbottomslope);
|
||||
topfrac = (centeryfrac>>4) - FixedMul (worldbottomslope, rw_scale);
|
||||
topstep = -FixedMul(rw_scalestep, worldbottomslope);
|
||||
topfrac = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldbottomslope, rw_scale));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2590,18 +2579,18 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
else
|
||||
set_topstep_normal();
|
||||
|
||||
bottomstep = -FixedMul (rw_scalestep, worldbottom);
|
||||
bottomfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale);
|
||||
bottomstep = -FixedMul(rw_scalestep, worldbottom);
|
||||
bottomfrac = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldbottom, rw_scale));
|
||||
|
||||
if (frontsector->c_slope)
|
||||
{
|
||||
fixed_t topfracend = (centeryfrac>>4) - FixedMul (worldtopslope, ds_p->scale2);
|
||||
fixed_t topfracend = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldtopslope, ds_p->scale2));
|
||||
topstep = (topfracend-topfrac)/(range);
|
||||
}
|
||||
|
||||
if (frontsector->f_slope)
|
||||
{
|
||||
fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldbottomslope, ds_p->scale2);
|
||||
fixed_t bottomfracend = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldbottomslope, ds_p->scale2));
|
||||
bottomstep = (bottomfracend-bottomfrac)/(range);
|
||||
}
|
||||
}
|
||||
@@ -2643,9 +2632,9 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
continue;
|
||||
}
|
||||
|
||||
rlight->height = (centeryfrac>>4) - FixedMul(leftheight, rw_scale);
|
||||
rlight->heightstep = (centeryfrac>>4) - FixedMul(rightheight, ds_p->scale2);
|
||||
rlight->heightstep = (rlight->heightstep-rlight->height)/(range);
|
||||
rlight->height = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(leftheight, rw_scale));
|
||||
rlight->heightstep = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(rightheight, ds_p->scale2));
|
||||
rlight->heightstep = FixedClamp((INT64)rlight->heightstep - rlight->height)/(range);
|
||||
rlight->flags = static_cast<ffloortype_e>(light->flags);
|
||||
|
||||
if (light->caster && light->caster->flags & FF_CUTSOLIDS)
|
||||
@@ -2707,9 +2696,9 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
|
||||
if (toptexture)
|
||||
{
|
||||
fixed_t topfracend = (centeryfrac>>4) - FixedMul(worldhighslope, ds_p->scale2);
|
||||
fixed_t topfracend = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldhighslope, ds_p->scale2));
|
||||
|
||||
pixhigh = (centeryfrac>>4) - FixedMul (worldhigh, rw_scale);
|
||||
pixhigh = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldhigh, rw_scale));
|
||||
pixhighstep = (topfracend-pixhigh)/(range);
|
||||
|
||||
// If the lowest part of a ceiling stretching down covers the entire screen
|
||||
@@ -2719,9 +2708,9 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
|
||||
if (bottomtexture)
|
||||
{
|
||||
fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldlowslope, ds_p->scale2);
|
||||
fixed_t bottomfracend = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldlowslope, ds_p->scale2));
|
||||
|
||||
pixlow = (centeryfrac>>4) - FixedMul (worldlow, rw_scale);
|
||||
pixlow = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldlow, rw_scale));
|
||||
pixlowstep = (bottomfracend-pixlow)/(range);
|
||||
|
||||
// If the highest part of a floor stretching up covers the entire screen
|
||||
@@ -2742,8 +2731,8 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
visffloor[i].b_pos_slope = roverright;
|
||||
visffloor[i].b_pos >>= 4;
|
||||
visffloor[i].b_pos_slope >>= 4;
|
||||
visffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(visffloor[i].b_pos, rw_scale);
|
||||
visffloor[i].b_step = (centeryfrac >> 4) - FixedMul(visffloor[i].b_pos_slope, ds_p->scale2);
|
||||
visffloor[i].b_frac = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(visffloor[i].b_pos, rw_scale));
|
||||
visffloor[i].b_step = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(visffloor[i].b_pos_slope, ds_p->scale2));
|
||||
visffloor[i].b_step = (visffloor[i].b_step-visffloor[i].b_frac)/(range);
|
||||
};
|
||||
|
||||
@@ -2849,7 +2838,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
visffloor[i].b_pos = height;
|
||||
visffloor[i].b_pos = (visffloor[i].b_pos - viewz) >> 4;
|
||||
visffloor[i].b_step = FixedMul(-rw_scalestep, visffloor[i].b_pos);
|
||||
visffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(visffloor[i].b_pos, rw_scale);
|
||||
visffloor[i].b_frac = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(visffloor[i].b_pos, rw_scale));
|
||||
};
|
||||
|
||||
while (i < numffloors && visffloor[i].polyobj != curline->polyseg)
|
||||
@@ -2880,7 +2869,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
if (markceiling)
|
||||
{
|
||||
if (ceilingplane) //SoM: 3/29/2000: Check for null ceiling planes
|
||||
ceilingplane = R_CheckPlane (ceilingplane, rw_x, rw_stopx-1);
|
||||
ceilingplane = R_CheckPlane(ceilingplane, rw_x, rw_stopx-1);
|
||||
else
|
||||
markceiling = false;
|
||||
|
||||
@@ -2894,7 +2883,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
if (markfloor)
|
||||
{
|
||||
if (floorplane) //SoM: 3/29/2000: Check for null planes
|
||||
floorplane = R_CheckPlane (floorplane, rw_x, rw_stopx-1);
|
||||
floorplane = R_CheckPlane(floorplane, rw_x, rw_stopx-1);
|
||||
else
|
||||
markfloor = false;
|
||||
|
||||
|
||||
+9
-7
@@ -11,6 +11,7 @@
|
||||
/// \file r_things.c
|
||||
/// \brief Refresh of things, i.e. objects represented by sprites
|
||||
|
||||
#include "m_fixed.h"
|
||||
#include "r_main.h" // stplyr
|
||||
#include "r_fps.h"
|
||||
#include "r_things.h"
|
||||
@@ -70,7 +71,7 @@ INT16 *screenheightarray = NULL;
|
||||
|
||||
typedef struct drawseg_xrange_item_s
|
||||
{
|
||||
INT16 x1, x2;
|
||||
INT32 x1, x2;
|
||||
drawseg_t *user;
|
||||
} drawseg_xrange_item_t;
|
||||
|
||||
@@ -489,8 +490,8 @@ void R_InitSprites(void)
|
||||
for (angle = 1; angle < ROTANGLES; angle++)
|
||||
{
|
||||
fa = ANG2RAD(FixedAngle((ROTANGDIFF * angle)<<FRACBITS));
|
||||
rollcosang[angle] = FLOAT_TO_FIXED(cos(-fa));
|
||||
rollsinang[angle] = FLOAT_TO_FIXED(sin(-fa));
|
||||
rollcosang[angle] = FLOAT_TO_FIXED(cosf(-fa));
|
||||
rollsinang[angle] = FLOAT_TO_FIXED(sinf(-fa));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -616,10 +617,11 @@ void R_DrawMaskedColumn(drawcolumndata_t* dc, column_t *column)
|
||||
if (topdelta <= prevdelta)
|
||||
topdelta += prevdelta;
|
||||
prevdelta = topdelta;
|
||||
topscreen = sprtopscreen + spryscale*topdelta;
|
||||
bottomscreen = topscreen + spryscale*column->length;
|
||||
|
||||
dc->yl = (topscreen+FRACUNIT-1)>>FRACBITS;
|
||||
topscreen = FixedClamp((INT64)sprtopscreen + (INT64)spryscale * (INT64)topdelta);
|
||||
bottomscreen = FixedClamp((INT64)topscreen + (INT64)spryscale * (INT64)column->length);
|
||||
|
||||
dc->yl = FixedClamp((INT64)topscreen + (FRACUNIT-1))>>FRACBITS;
|
||||
dc->yh = (bottomscreen-1)>>FRACBITS;
|
||||
|
||||
if (windowtop != INT32_MAX && windowbottom != INT32_MAX)
|
||||
@@ -885,7 +887,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
|
||||
for (dc.x = vis->x1; dc.x <= vis->x2; dc.x++, spryscale += scalestep)
|
||||
{
|
||||
angle_t angle = ((vis->centerangle + xtoviewangle[dc.x]) >> ANGLETOFINESHIFT) & 0xFFF;
|
||||
texturecolumn = (vis->paperoffset - FixedMul(FINETANGENT(angle), vis->paperdistance)) / horzscale;
|
||||
texturecolumn = FixedClamp((INT64)vis->paperoffset - FixedMul(FINETANGENT(angle), vis->paperdistance)) / horzscale;
|
||||
|
||||
if (texturecolumn < 0 || texturecolumn >= pwidth)
|
||||
continue;
|
||||
|
||||
@@ -63,6 +63,7 @@ typedef struct viddef_s
|
||||
|
||||
INT32 dup; // scale 1, 2, 3 value for menus & overlays
|
||||
INT32 fdup; // same as dup, but exact value when aspect ratio isn't 320/200
|
||||
INT32 udup; // same as dup but does not account for highreshudscale
|
||||
UINT8 smalldup; // factor for a little bit of scaling
|
||||
UINT8 meddup; // factor for moderate, but not full, scaling
|
||||
|
||||
|
||||
+15
-2
@@ -169,7 +169,6 @@ if(${SDL2_FOUND})
|
||||
target_link_libraries(SRB2SDL2 PRIVATE ${LIBBACKTRACE_LIBRARIES})
|
||||
endif()
|
||||
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES Linux)
|
||||
target_link_libraries(SRB2SDL2 PRIVATE
|
||||
m
|
||||
@@ -230,6 +229,20 @@ if(${SDL2_FOUND})
|
||||
-DHAVE_THREADS
|
||||
)
|
||||
|
||||
if(SRB2_CONFIG_LTO AND NOT SRB2_CONFIG_DEBUGMODE)
|
||||
set_property(TARGET SRB2SDL2 PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||
endif()
|
||||
|
||||
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()
|
||||
|
||||
## strip debug symbols into separate file when using gcc
|
||||
# if(CMAKE_COMPILER_IS_GNUCC)
|
||||
# if(${CMAKE_BUILD_TYPE} MATCHES Debug)
|
||||
@@ -296,7 +309,7 @@ if(${SDL2_FOUND})
|
||||
else()
|
||||
find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}")
|
||||
list(APPEND win_extra_dll_list ${SRB2_SDL2_DLL_${dllname}})
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
getwinlib(SDL2 "SDL2.dll")
|
||||
if(${SRB2_CONFIG_SDL2_USEMIXER})
|
||||
|
||||
+30
-7
@@ -30,7 +30,10 @@
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)
|
||||
#include <poll.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define RPC_NO_WINDOWS_H
|
||||
@@ -723,7 +726,9 @@ static void JoyReset(SDLJoyInfo_t *JoySet)
|
||||
|
||||
JoySet->dev = NULL;
|
||||
JoySet->oldjoy = -1;
|
||||
#if (SDL_VERSION_ATLEAST(2,32,4))
|
||||
JoySet->id = -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** \brief SDL info about joystick
|
||||
@@ -780,7 +785,11 @@ void I_UpdateJoystickDeviceIndex(UINT8 player)
|
||||
///////////////////////////////////////////////
|
||||
if (JoyInfo[player].dev)
|
||||
{
|
||||
#if (SDL_VERSION_ATLEAST(2,32,4))
|
||||
cv_usejoystick[player].value = JoyInfo[player].id + 1;
|
||||
#else
|
||||
cv_usejoystick[player].value = I_GetJoystickDeviceIndex(JoyInfo[player].dev) + 1;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -882,13 +891,13 @@ static int joy_open(int playerIndex, int joyIndex)
|
||||
|
||||
if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0)
|
||||
{
|
||||
CONS_Printf(M_GetText("Joystick subsystem not started\n"));
|
||||
CONS_Printf("Joystick subsystem not started\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == 0)
|
||||
{
|
||||
CONS_Printf(M_GetText("Game Controller subsystem not started\n"));
|
||||
CONS_Printf("Game Controller subsystem not started\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -899,7 +908,7 @@ static int joy_open(int playerIndex, int joyIndex)
|
||||
|
||||
if (num_joy == 0)
|
||||
{
|
||||
CONS_Printf("%s", M_GetText("Found no joysticks on this system\n"));
|
||||
CONS_Printf("%s", "Found no joysticks on this system\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -922,7 +931,7 @@ static int joy_open(int playerIndex, int joyIndex)
|
||||
return SDL_CONTROLLER_AXIS_MAX;
|
||||
|
||||
// Else, we're changing devices, so send neutral joy events
|
||||
CONS_Debug(DBG_GAMELOGIC, "Joystick1 device is changing; resetting events...\n");
|
||||
CONS_Debug(DBG_GAMELOGIC, "Joystick %d device is changing; resetting events...\n", playerIndex+1);
|
||||
I_ShutdownJoystick(playerIndex);
|
||||
}
|
||||
|
||||
@@ -930,13 +939,15 @@ static int joy_open(int playerIndex, int joyIndex)
|
||||
|
||||
if (JoyInfo[playerIndex].dev == NULL)
|
||||
{
|
||||
CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: Couldn't open device - %s\n"), SDL_GetError());
|
||||
CONS_Debug(DBG_GAMELOGIC, "Joystick %d: Couldn't open device - %s\n", playerIndex+1, SDL_GetError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: %s\n"), SDL_GameControllerName(JoyInfo[playerIndex].dev));
|
||||
CONS_Debug(DBG_GAMELOGIC, "Joystick %d: %s\n", playerIndex+1, SDL_GameControllerName(JoyInfo[playerIndex].dev));
|
||||
|
||||
#if (SDL_VERSION_ATLEAST(2,32,4))
|
||||
JoyInfo[playerIndex].id = I_GetJoystickDeviceIndex(JoyInfo[playerIndex].dev);
|
||||
#endif
|
||||
|
||||
return SDL_CONTROLLER_AXIS_MAX;
|
||||
}
|
||||
@@ -982,7 +993,9 @@ void I_InitJoystick(UINT8 index)
|
||||
|
||||
JoyInfo[index].dev = NULL;
|
||||
JoyInfo[index].oldjoy = -1;
|
||||
#if (SDL_VERSION_ATLEAST(2,32,4))
|
||||
JoyInfo[index].id = -1;
|
||||
#endif
|
||||
|
||||
if (cv_usejoystick[index].value)
|
||||
newcontroller = SDL_GameControllerOpen(cv_usejoystick[index].value-1);
|
||||
@@ -996,17 +1009,27 @@ void I_InitJoystick(UINT8 index)
|
||||
break;
|
||||
}
|
||||
|
||||
#if (SDL_VERSION_ATLEAST(2,32,4))
|
||||
JoyInfo[index].id = I_GetJoystickDeviceIndex(JoyInfo[index].dev);
|
||||
#endif
|
||||
|
||||
if (newcontroller && i < MAXSPLITSCREENPLAYERS) // don't override an active device
|
||||
{
|
||||
#if (SDL_VERSION_ATLEAST(2,32,4))
|
||||
cv_usejoystick[index].value = JoyInfo[index].id + 1;
|
||||
#else
|
||||
cv_usejoystick[index].value = I_GetJoystickDeviceIndex(JoyInfo[index].dev) + 1;
|
||||
#endif
|
||||
}
|
||||
else if (newcontroller && joy_open(index, cv_usejoystick[index].value) != -1)
|
||||
{
|
||||
#if (SDL_VERSION_ATLEAST(2,32,4))
|
||||
JoyInfo[index].oldjoy = JoyInfo[index].id + 1;
|
||||
#else
|
||||
// SDL's device indexes are unstable, so cv_usejoystick may not match
|
||||
// the actual device index. So let's cheat a bit and find the device's current index.
|
||||
JoyInfo[index].oldjoy = JoyInfo[index].id + 1;
|
||||
JoyInfo[index].oldjoy = I_GetJoystickDeviceIndex(JoyInfo[index].dev) + 1;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -784,7 +784,11 @@ static void Impl_HandleControllerAxisEvent(SDL_ControllerAxisEvent evt)
|
||||
// Determine the Joystick IDs for each current open joystick
|
||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
{
|
||||
#if (SDL_VERSION_ATLEAST(2,32,4))
|
||||
if (evt.which == JoyInfo[i].id)
|
||||
#else
|
||||
if (evt.which == SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(JoyInfo[i].dev)))
|
||||
#endif
|
||||
{
|
||||
event.type = ev_joystick + i;
|
||||
break;
|
||||
@@ -844,7 +848,11 @@ static void Impl_HandleControllerHatEvent(SDL_ControllerButtonEvent evt, Uint32
|
||||
// Determine the Joystick IDs for each current open joystick
|
||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
{
|
||||
#if (SDL_VERSION_ATLEAST(2,32,4))
|
||||
if (evt.which == JoyInfo[i].id)
|
||||
#else
|
||||
if (evt.which == SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(JoyInfo[i].dev)))
|
||||
#endif
|
||||
{
|
||||
event.data1 = hat_buttons_base[i];
|
||||
break;
|
||||
@@ -906,7 +914,11 @@ static void Impl_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint
|
||||
// Determine the Joystick IDs for each current open joystick
|
||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
{
|
||||
#if (SDL_VERSION_ATLEAST(2,32,4))
|
||||
if (evt.which == JoyInfo[i].id)
|
||||
#else
|
||||
if (evt.which == SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(JoyInfo[i].dev)))
|
||||
#endif
|
||||
{
|
||||
event.data1 = buttons_base[i];
|
||||
break;
|
||||
|
||||
@@ -1107,7 +1107,7 @@ UINT32 I_GetSongPosition(void)
|
||||
|
||||
void I_UpdateSongLagThreshold(void)
|
||||
{
|
||||
stutter_threshold = cv_music_resync_powerups_only.value ? 0 : (cv_music_resync_threshold.value/1000.0*(4*44100));
|
||||
stutter_threshold = (UINT32)(cv_music_resync_powerups_only.value ? 0 : (cv_music_resync_threshold.value/1000.0*(4*44100)));
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "SDL_version.h"
|
||||
|
||||
#include "../m_fixed.h"
|
||||
|
||||
// SDL2 stub macro
|
||||
@@ -39,8 +41,10 @@ typedef struct SDLJoyInfo_s
|
||||
{
|
||||
/// Controller handle
|
||||
SDL_GameController *dev;
|
||||
#if (SDL_VERSION_ATLEAST(2,32,4))
|
||||
/// Controller index
|
||||
INT32 id;
|
||||
#endif
|
||||
/// number of old joystick
|
||||
int oldjoy;
|
||||
/// number of axies
|
||||
|
||||
+10
-10
@@ -465,7 +465,7 @@ void V_CubeApply(RGBA_t *input)
|
||||
if (!Cubeapply)
|
||||
return;
|
||||
|
||||
linear = ((*input).s.red/255.0);
|
||||
linear = ((*input).s.red/255.0f);
|
||||
#define dolerp(e1, e2) ((1 - linear)*e1 + linear*e2)
|
||||
for (q = 0; q < 3; q++)
|
||||
{
|
||||
@@ -475,21 +475,21 @@ void V_CubeApply(RGBA_t *input)
|
||||
working[3][q] = dolerp(Cubepal[0][1][1][q], Cubepal[1][1][1][q]);
|
||||
}
|
||||
|
||||
linear = ((*input).s.green/255.0);
|
||||
linear = ((*input).s.green/255.0f);
|
||||
for (q = 0; q < 3; q++)
|
||||
{
|
||||
working[0][q] = dolerp(working[0][q], working[1][q]);
|
||||
working[1][q] = dolerp(working[2][q], working[3][q]);
|
||||
}
|
||||
|
||||
linear = ((*input).s.blue/255.0);
|
||||
linear = ((*input).s.blue/255.0f);
|
||||
for (q = 0; q < 3; q++)
|
||||
{
|
||||
working[0][q] = 255*dolerp(working[0][q], working[1][q]);
|
||||
if (working[0][q] > 255.0f)
|
||||
working[0][q] = 255.0f;
|
||||
else if (working[0][q] < 0.0f)
|
||||
working[0][q] = 0.0;
|
||||
working[0][q] = 0.0f;
|
||||
}
|
||||
#undef dolerp
|
||||
|
||||
@@ -1760,17 +1760,15 @@ void V_DrawVhsEffect(boolean rewind)
|
||||
if (cv_reducevfx.value)
|
||||
return;
|
||||
|
||||
const INT32 dup = min(vid.width / BASEVIDWIDTH, vid.height / BASEVIDHEIGHT);
|
||||
|
||||
barsize = dup << 5;
|
||||
updistort = dup << (rewind ? 5 : 3);
|
||||
barsize = vid.udup << 5;
|
||||
updistort = vid.udup << (rewind ? 5 : 3);
|
||||
downdistort = updistort >> 1;
|
||||
|
||||
if (rewind)
|
||||
V_DrawVhsEffect(false); // experimentation
|
||||
|
||||
upbary -= renderdeltatics * (fixed_t)(dup * (rewind ? 3 : 1.8f));
|
||||
downbary += renderdeltatics * (dup * (rewind ? 2 : 1));
|
||||
upbary -= renderdeltatics * (fixed_t)(vid.udup * (rewind ? 3 : 1.8f));
|
||||
downbary += renderdeltatics * (vid.udup * (rewind ? 2 : 1));
|
||||
|
||||
if (upbary < -barsize*FRACUNIT)
|
||||
upbary = vid.height << FRACBITS;
|
||||
@@ -3930,6 +3928,8 @@ void V_Recalc(void)
|
||||
vid.fdup = (vid.height*FRACUNIT) / BASEVIDHEIGHT;
|
||||
}
|
||||
|
||||
vid.udup = vid.dup;
|
||||
|
||||
if (loaded_config // this could use a better name, since it is more and indicator that early startup is done and its safe to do sketchy shit now :chaosleep:
|
||||
&& (vid.width > 720) && (vid.height > 1280)) // ehhhh well this thing has so many issues, so ill lock it to higher resolutions instead
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user