Compare commits

..
33 Commits
Author SHA1 Message Date
Alug bcc58f54e4 address some more software overflows 2026-02-02 20:03:33 +01:00
Alug 55203c8711 r_segs: use fixed point clamp in more places
replaces the old overflow clamping since we now have a function for this purpose
2026-02-02 16:12:30 +01:00
Alug 19d83f82e4 software renderer: "address" an absolute silly amount of overflowing fixed point maths
honestly be better to just completely switch over to 64bit maths, or even better floats....
this is mostly just bandaids but seems to make software more "visually stable"
2026-02-02 16:12:26 +01:00
Alug e4dbf1ce11 plug a potential memory leak in M_SaveConfig 2026-02-02 16:11:57 +01:00
Alug 10b9d96259 hw_clip: replace "RoundToInt" with lrint
prefer to use standard lib functions if possible
lrint does the same thing (well ofc as long as no one touches the rounding direction löl) and is even quite a lot faster (though this is negligible in this case)
2026-02-02 16:11:54 +01:00
indev b23154fd93 Prevent replays menu scoll bar from disappearing 2026-02-02 02:28:33 +03:00
Alug b0ee972178 r_plane: fix visplane hashing overflowing
shift into "int" to prevent super large values during multiply
2026-02-01 20:52:48 +01:00
Alug 544e1d3b21 "fix" overflow in R_InitViewMapping with high resolutions 2026-02-01 17:07:18 +01:00
Alug 0ca6947f99 fix a few type issues 2026-02-01 16:27:25 +01:00
indev 3122c08039 Add focus options for gamepad led and rumble 2026-02-01 02:49:03 +03:00
indev 7a279a6fd9 Prefix autoaccel cvars with 'kart' to avoid conflict with hostmod 2026-01-28 19:19:02 +03:00
Alug c4581bd9a6 Only save and keep track of controller ids on SDL versions 2.32.4 and up
Older versions break and have unstable ids on Windows, cant check for linux but ill just add a version check at this point
This was part of updating sdl with v9, which got reverted due to other issues but this was not reverted oopsie
2026-01-24 18:20:54 +01:00
Alug bb47b976a7 software: fix drawseg xrange item coord type being too small
both sprite and drawseg coords are int32
might fix some clipping issues
2026-01-23 18:33:11 +01:00
Alug 6c419ff22e fix few more implicit double/float conversions 2026-01-23 18:33:08 +01:00
Alug 522904527f add missing HAVE_CURL 2026-01-23 10:08:35 +01:00
Alug 30539371c2 more cmake stuffs
-add LTO option, enabled by default
-set optimization level to O3 and O0 for debug builds
-add ASAN and UBSAN options
-always compile with gnu debug symbols
2026-01-22 14:46:12 +01:00
Alug e2ecc315b4 cmake: attempt to fix dedicated build uhh building 2026-01-22 14:44:47 +01:00
Alug eb2f186205 Merge pull request #221 from P-AS/morecmakefixes
CMake fixes cherry-picked from srb2-legacy
2026-01-22 14:43:38 +01:00
Alug bbf06b3376 add "vid.udup" same as vid.dup but not scaled with "highreshudscale" 2026-01-22 14:26:24 +01:00
Alug a1f70b0b31 opengl: attempt to scale vhs effect "fuzzyness"
this makes it appear more or less the same in all resolutions, similar to software, while also improving performance quite a bit on higher resolutions
2026-01-22 14:26:23 +01:00
Alug 2e0f5c02a4 opengl: make vhs effect bars be affected by "fuzzines"
makes stuff slightly slower, but matches the software effect
2026-01-22 14:25:57 +01:00
Alug 0f7001ef5c opengl: tiny optimiazation for vhs effect
dont call rand within the loop, use xorshift instead
while not massive, we dont need to call rand thousands of times, the xorshift is visually indistinguishable
this is still rather slow due to the crapton of draw calls and should best be replaced by a shader or something
2026-01-22 14:25:54 +01:00
PAS 4600da5782 restore SRB2_SDL2_EXE_NAME 2026-01-21 15:54:32 -05:00
indev a3557fadef P_PlayRinglossSound from lua might desynch so print warning about that 2026-01-21 23:38:41 +03:00
Alug d9a67faf47 fix windoze compile 2026-01-21 21:11:52 +01:00
PAS 96eaf8850e Add path suffix for libgme cmake module 2026-01-21 15:01:51 -05:00
PAS e7efd46419 Fix FindGME pkg-config command, update LibFindMacros.cmake 2026-01-21 15:01:33 -05:00
PAS 346b1456cd CMake: Fix FindOPENMPT 2026-01-21 14:59:01 -05:00
PAS 9f5a5a735b Allow changing Cpak generator (from upstream) 2026-01-21 14:58:32 -05:00
PAS 8e4b304bed CMake: don't configure before CPACK_PACKAGE_DESCRIPTION_SUMMARY is set 2026-01-21 14:51:17 -05:00
Alug 607fbc54fc Merge pull request #220 from Indev450/fixcmake2
Fixup CMake, but simpler
2026-01-21 20:45:24 +01:00
Alug 59c9af97c2 joy_open: make debug prints actually print the player number 2026-01-21 19:54:03 +01:00
Alug 4e75d99026 simplify LUA_Alloc
Z_Realloc already handles everything internally, no need to manually free anything
2026-01-21 19:49:55 +01:00
37 changed files with 461 additions and 302 deletions

No files matched your search

+28 -26
View File
@@ -1,4 +1,9 @@
cmake_minimum_required(VERSION 3.5) 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. # DO NOT CHANGE THIS SRB2 STRING! Some variable names depend on this string.
# Version change is fine. # Version change is fine.
project(SRB2 project(SRB2
@@ -11,10 +16,31 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON) set(CMAKE_CXX_EXTENSIONS ON)
set(CMAKE_C_EXTENSIONS ON) set(CMAKE_C_EXTENSIONS ON)
if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) ##### PACKAGE CONFIGURATION #####
message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.")
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() 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 up CMAKE path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") 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 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_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) include_directories(${CMAKE_CURRENT_BINARY_DIR}/src)
add_subdirectory(src) add_subdirectory(src)
add_subdirectory(assets) add_subdirectory(assets)
## config.h generation ## config.h generation
set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary") set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary")
include(GitUtilities) 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_BRANCH "${SRB2_GIT_BRANCH}")
set(SRB2_COMP_REVISION "${SRB2_COMP_COMMIT}") set(SRB2_COMP_REVISION "${SRB2_COMP_COMMIT}")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/config.h) 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)
+2 -1
View File
@@ -1,6 +1,6 @@
include(LibFindMacros) include(LibFindMacros)
libfind_pkg_check_modules(GME_PKGCONF GME) libfind_pkg_check_modules(GME_PKGCONF LIBGME)
find_path(GME_INCLUDE_DIR find_path(GME_INCLUDE_DIR
NAMES gme.h NAMES gme.h
@@ -8,6 +8,7 @@ find_path(GME_INCLUDE_DIR
${GME_PKGCONF_INCLUDE_DIRS} ${GME_PKGCONF_INCLUDE_DIRS}
"/usr/include/gme" "/usr/include/gme"
"/usr/local/include/gme" "/usr/local/include/gme"
PATH_SUFFIXES gme
) )
find_library(GME_LIBRARY find_library(GME_LIBRARY
+2 -1
View File
@@ -1,6 +1,6 @@
include(LibFindMacros) include(LibFindMacros)
libfind_pkg_check_modules(OPENMPT_PKGCONF OPENMPT) libfind_pkg_check_modules(OPENMPT_PKGCONF LIBOPENMPT)
find_path(OPENMPT_INCLUDE_DIR find_path(OPENMPT_INCLUDE_DIR
NAMES libopenmpt.h NAMES libopenmpt.h
@@ -8,6 +8,7 @@ find_path(OPENMPT_INCLUDE_DIR
${OPENMPT_PKGCONF_INCLUDE_DIRS} ${OPENMPT_PKGCONF_INCLUDE_DIRS}
"/usr/include/libopenmpt" "/usr/include/libopenmpt"
"/usr/local/include/libopenmpt" "/usr/local/include/libopenmpt"
PATH_SUFFIXES libopenmpt
) )
find_library(OPENMPT_LIBRARY find_library(OPENMPT_LIBRARY
+37 -18
View File
@@ -1,4 +1,4 @@
# Version 2.2 # Version 2.4
# Public Domain, originally written by Lasse Kärkkäinen <tronic> # Public Domain, originally written by Lasse Kärkkäinen <tronic>
# Maintained at https://github.com/Tronic/cmake-modules # Maintained at https://github.com/Tronic/cmake-modules
# Please send your improvements as pull requests on Github. # Please send your improvements as pull requests on Github.
@@ -52,6 +52,10 @@ function (libfind_pkg_detect PREFIX)
if (libraryargs) if (libraryargs)
find_library(${PREFIX}_LIBRARY NAMES ${libraryargs} HINTS ${${PREFIX}_PKGCONF_LIBRARY_DIRS}) find_library(${PREFIX}_LIBRARY NAMES ${libraryargs} HINTS ${${PREFIX}_PKGCONF_LIBRARY_DIRS})
endif() endif()
# Read pkg-config version
if (${PREFIX}_PKGCONF_VERSION)
set(${PREFIX}_VERSION ${${PREFIX}_PKGCONF_VERSION} PARENT_SCOPE)
endif()
endfunction() endfunction()
# Extracts a version #define from a version.h file, output stored to <PREFIX>_VERSION. # 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 # Process deps to add to
foreach (i ${PREFIX} ${${PREFIX}_DEPENDENCIES}) 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! # The package seems to export option lists that we can use, woohoo!
list(APPEND includeopts ${${i}_INCLUDE_OPTS}) 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}) list(APPEND libraryopts ${${i}_LIBRARY_OPTS})
else() else()
# If plural forms don't exist or they equal singular forms if (DEFINED ${i}_LIBRARY)
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))
# Singular forms can be used # Singular forms can be used
if (DEFINED ${i}_INCLUDE_DIR) list(APPEND libraryopts ${i}_LIBRARY)
list(APPEND includeopts ${i}_INCLUDE_DIR)
endif()
if (DEFINED ${i}_LIBRARY)
list(APPEND libraryopts ${i}_LIBRARY)
endif()
else() else()
# Oh no, we don't know the option names if (DEFINED ${i}_LIBRARIES)
message(FATAL_ERROR "We couldn't determine config variable names for ${i} includes and libs. Aieeh!") # 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()
endif() endif()
endforeach() endforeach()
@@ -209,12 +228,12 @@ function (libfind_process PREFIX)
message(STATUS " ${PREFIX}_LIBRARY_OPTS=${libraryopts}") message(STATUS " ${PREFIX}_LIBRARY_OPTS=${libraryopts}")
message(STATUS " ${PREFIX}_LIBRARIES=${libs}") message(STATUS " ${PREFIX}_LIBRARIES=${libs}")
endif() 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() 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() return()
endif() endif()
+18 -7
View File
@@ -236,18 +236,23 @@ set(SRB2_CONFIG_HWRENDER ON CACHE BOOL
"Enable hardware rendering through OpenGL.") "Enable hardware rendering through OpenGL.")
set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL
"Use statically linked OpenGL. NOT RECOMMENDED.") "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 set(SRB2_CONFIG_DEDICATED OFF CACHE BOOL
"Build a dedicated server.") "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 set(SRB2_CONFIG_SATURNPAK ON CACHE BOOL
"Enable Saturn specific special packet. Required for using the newer resynch system") "Enable Saturn specific special packet. Required for using the newer resynch system")
set(SRB2_CONFIG_SATURNJOIN ON CACHE BOOL set(SRB2_CONFIG_SATURNJOIN ON CACHE BOOL
"Enable Saturn specific allowjoin toggle.") "Enable Saturn specific allowjoin toggle.")
set(SRB2_CONFIG_SCREENFBO ON CACHE BOOL
set(SRB2_CONFIG_LIBBACKTRACE ON CACHE BOOL "Enable hardware renderer (OpenGL) FBO downsampling support")
"Enable using libbacktrace for crashlogs")
if(${SRB2_CONFIG_DEDICATED}) if(${SRB2_CONFIG_DEDICATED})
set(SRB2_CONFIG_HAVE_GME NO) set(SRB2_CONFIG_HAVE_GME NO)
@@ -502,7 +507,6 @@ if(${SRB2_CONFIG_LIBBACKTRACE})
if(${LIBBACKTRACE_FOUND}) if(${LIBBACKTRACE_FOUND})
set(SRB2_HAVE_LIBBACKTRACE ON) set(SRB2_HAVE_LIBBACKTRACE ON)
add_definitions(-DHAVE_LIBBACKTRACE) add_definitions(-DHAVE_LIBBACKTRACE)
add_compile_options(-g)
else() else()
message(WARNING "You have specified that libbacktrace is available but it was not found.") message(WARNING "You have specified that libbacktrace is available but it was not found.")
endif() endif()
@@ -550,7 +554,6 @@ if(${SRB2_CONFIG_HWRENDER})
set(SRB2_R_OPENGL_HEADERS set(SRB2_R_OPENGL_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/hardware/r_opengl/r_opengl.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/r_opengl/r_opengl.h
) )
endif() endif()
if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL}) if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL})
@@ -589,6 +592,14 @@ endif()
# TODO: fix prng and P_CreateBlockmap overflow at some point # TODO: fix prng and P_CreateBlockmap overflow at some point
add_compile_options(-fwrapv) 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_definitions(-DCMAKECONFIG)
#add_library(SRB2Core STATIC #add_library(SRB2Core STATIC
+2
View File
@@ -907,7 +907,9 @@ void D_ClearState(void)
// okay, stop now // okay, stop now
// (otherwise the game still thinks we're playing!) // (otherwise the game still thinks we're playing!)
#ifdef HAVE_CURL
CURLAbortFile(); CURLAbortFile();
#endif
SV_StopServer(); SV_StopServer();
SV_ResetServer(); SV_ResetServer();
+3 -1
View File
@@ -1009,6 +1009,9 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_gamepadled[i]); CV_RegisterVar(&cv_gamepadled[i]);
} }
CV_RegisterVar(&cv_gamepadledifunfocused);
CV_RegisterVar(&cv_rumbleifunfocused);
CV_RegisterVar(&cv_usemouse); CV_RegisterVar(&cv_usemouse);
CV_RegisterVar(&cv_invertmouse); CV_RegisterVar(&cv_invertmouse);
CV_RegisterVar(&cv_mousexsens); CV_RegisterVar(&cv_mousexsens);
@@ -2655,7 +2658,6 @@ static void Command_Map_f(void)
return; return;
} }
last_map_cmd = I_GetTime(); last_map_cmd = I_GetTime();
size_t first_option; size_t first_option;
+93 -22
View File
@@ -1,21 +1,75 @@
# Declare dedicated interface sources # 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) if(${CMAKE_SYSTEM} MATCHES Windows)
target_sources(SRB2SDL2 PRIVATE set(SRB2_DEDICATED_TOTAL_SOURCES ${SRB2_DEDICATED_TOTAL_SOURCES}
../win32/win_dbg.c ${CMAKE_SOURCE_DIR}/src/win32/win_dbg.c
../win32/Srb2win.rc) ${CMAKE_SOURCE_DIR}/src/win32/Srb2win.rc
)
endif() endif()
add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32 ${SRB2_DEDICATED_TOTAL_SOURCES})
if(${CMAKE_SYSTEM} MATCHES Windows) 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) elseif(${CMAKE_SYSTEM} MATCHES Linux)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME lsrb2dlegacy) set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME lsrb2kartd)
else() 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() endif()
if(${CMAKE_SYSTEM} MATCHES Darwin) if(${CMAKE_SYSTEM} MATCHES Darwin)
@@ -24,25 +78,27 @@ if(${CMAKE_SYSTEM} MATCHES Darwin)
${CORE_LIB} ${CORE_LIB}
${PNG_LIBRARIES} ${PNG_LIBRARIES}
${ZLIB_LIBRARIES} ${ZLIB_LIBRARIES}
${CURL_LIBRARIES}
) )
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}") set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
else() else()
target_link_libraries(SRB2SDL2 PRIVATE target_link_libraries(SRB2SDL2 PRIVATE
${PNG_LIBRARIES} ${PNG_LIBRARIES}
${ZLIB_LIBRARIES} ${ZLIB_LIBRARIES}
${CURL_LIBRARIES}
) )
if(${CMAKE_SYSTEM} MATCHES Linux) if(${CMAKE_SYSTEM} MATCHES Linux)
target_link_libraries(SRB2SDL2 PRIVATE target_link_libraries(SRB2SDL2 PRIVATE
m m
rt rt
pthread
) )
endif() endif()
endif() endif()
#target_link_libraries(SRB2SDL2 PRIVATE SRB2Core) if(${SRB2_HAVE_LIBBACKTRACE})
target_link_libraries(SRB2SDL2 PRIVATE ${LIBBACKTRACE_LIBRARIES})
set_target_properties(SRB2SDL2 PROPERTIES VERSION ${SRB2_VERSION}) endif()
if(${CMAKE_SYSTEM} MATCHES Windows) if(${CMAKE_SYSTEM} MATCHES Windows)
target_link_libraries(SRB2SDL2 PRIVATE target_link_libraries(SRB2SDL2 PRIVATE
@@ -60,20 +116,35 @@ target_include_directories(SRB2SDL2 PRIVATE
target_compile_definitions(SRB2SDL2 PRIVATE target_compile_definitions(SRB2SDL2 PRIVATE
-DDEDICATED -DDEDICATED
-DHAVE_THREADS
) )
## strip debug symbols into separate file when using gcc if(SRB2_CONFIG_LTO AND NOT SRB2_CONFIG_DEBUGMODE)
if(CMAKE_COMPILER_IS_GNUCC) set_property(TARGET SRB2SDL2 PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
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() 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 #### #### Installation ####
if(${CMAKE_SYSTEM} MATCHES Darwin) if(${CMAKE_SYSTEM} MATCHES Darwin)
install(TARGETS SRB2SDL2 install(TARGETS SRB2SDL2
+4 -4
View File
@@ -456,10 +456,10 @@ consvar_t cv_litesteer[MAXSPLITSCREENPLAYERS] = {
//static CV_PossibleValue_t autoaccelcons_t[] = {{0, "Off"}, {1, "Manual"}, {2, "Automatic"}, {0, NULL}}; //static CV_PossibleValue_t autoaccelcons_t[] = {{0, "Off"}, {1, "Manual"}, {2, "Automatic"}, {0, NULL}};
consvar_t cv_autoaccel[MAXSPLITSCREENPLAYERS] = { consvar_t cv_autoaccel[MAXSPLITSCREENPLAYERS] = {
{"autoaccel", "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},
{"autoaccel2", "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},
{"autoaccel3", "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},
{"autoaccel4", "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}}; static CV_PossibleValue_t driftsparkpulse_t[] = {{0, "MIN"}, {FRACUNIT*3, "MAX"}, {0, NULL}};
+5 -2
View File
@@ -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} {"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) static void rumble_off_handle(void)
{ {
if (!cv_rumble[0].value) if (!cv_rumble[0].value)
@@ -930,7 +933,7 @@ void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT8 color)
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS); 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) || color >= MAXTRANSLATIONS)
{ {
return; return;
@@ -1009,7 +1012,7 @@ void G_PlayerDeviceRumble(INT32 playernum, UINT16 low_strength, UINT16 high_stre
{ {
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS); 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; return;
} }
+3
View File
@@ -116,6 +116,9 @@ extern consvar_t cv_rumble[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_rumblestrength[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_rumblestrength[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_gamepadledifunfocused;
extern consvar_t cv_rumbleifunfocused;
extern INT32 mousex, mousey; extern INT32 mousex, mousey;
extern INT32 joyxmove[MAXSPLITSCREENPLAYERS][JOYAXISSET], joyymove[MAXSPLITSCREENPLAYERS][JOYAXISSET]; extern INT32 joyxmove[MAXSPLITSCREENPLAYERS][JOYAXISSET], joyymove[MAXSPLITSCREENPLAYERS][JOYAXISSET];
+1 -1
View File
@@ -335,7 +335,7 @@ angle_t gld_FrustumAngle(angle_t tiltangle)
floatangle = 2.0 + (45.0 + ((double)tilt / 1.9)) * clipfov / 90.0; floatangle = 2.0 + (45.0 + ((double)tilt / 1.9)) * clipfov / 90.0;
if (floatangle >= 180.0) if (floatangle >= 180.0)
return 0xffffffff; return 0xffffffff;
a1 = (angle_t)xs_CRoundToInt(ANG1 * floatangle); a1 = (angle_t)lrint(ANG1 * floatangle);
return a1; return a1;
} }
+1 -1
View File
@@ -5444,7 +5444,7 @@ static void HWR_SetTransformAiming(FTransform *trans)
fixed_t fixedaiming = AIMINGTODY(aimingangle); 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)); 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 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; trans->shearing = true;
gl_aimingangle = 0; gl_aimingangle = 0;
} }
+1 -1
View File
@@ -579,7 +579,7 @@ md2found:
fclose(f); 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; FILE *f;
char name[20], filename[32]; char name[20], filename[32];
+26 -16
View File
@@ -3591,22 +3591,30 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8
1.0f, -1.0f, 1.0f 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 scrwf = (float)screen_width;
const GLfloat scrwh = (float)screen_height; 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 // Slight fuzziness
GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS); GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
GL_SetBlend(PF_Modulated|PF_Translucent|PF_NoDepthTest);
pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]); 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[0] = fix[2];
fix[6] = fix[0] + xfix; fix[6] = fix[0] + xfix;
fix[4] = fix[2] + xfix; fix[4] = fix[2] + xfix;
@@ -3624,8 +3632,8 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8
} }
// Upward bar // Upward bar
//GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS); GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
//pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]); pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
color[0] = color[1] = color[2] = 190; color[0] = color[1] = color[2] = 190;
color[3] = 250; 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; fix[1] = fix[7] += (fix[3] - fix[7])*2;
screenVerts[1] = screenVerts[10] += (screenVerts[4] - screenVerts[1])*2; screenVerts[1] = screenVerts[10] += (screenVerts[4] - screenVerts[1])*2;
pglTexCoordPointer(2, GL_FLOAT, 0, fix); pglTexCoordPointer(2, GL_FLOAT, 0, fix);
pglVertexPointer(3, GL_FLOAT, 0, screenVerts); pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4); pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
// Downward bar // Downward bar
//GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS); GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
//pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]); pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
fix[0] = 0.0f; fix[0] = 0.0f;
fix[6] = xfix; 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; fix[1] = fix[7] += (fix[3] - fix[7])*2;
screenVerts[1] = screenVerts[10] += (screenVerts[4] - screenVerts[1])*2; screenVerts[1] = screenVerts[10] += (screenVerts[4] - screenVerts[1])*2;
pglTexCoordPointer(2, GL_FLOAT, 0, fix); pglTexCoordPointer(2, GL_FLOAT, 0, fix);
pglVertexPointer(3, GL_FLOAT, 0, screenVerts); pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4); 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 xfix, yfix;
float origaspect, newaspect; 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] = static float off[12] =
{ {
@@ -3735,19 +3745,19 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh
if (origaspect < newaspect) if (origaspect < newaspect)
{ {
xoff = origaspect / newaspect; xoff = origaspect / newaspect;
yoff = 1; yoff = 1.0f;
} }
else if (origaspect > newaspect) else if (origaspect > newaspect)
{ {
xoff = 1; xoff = 1.0f;
yoff = newaspect / origaspect; yoff = newaspect / origaspect;
} }
// float off[12]; // float off[12];
off[0] = off[3] = -xoff; off[0] = off[3] = -xoff;
off[1] = off[10] = -yoff; off[1] = off[10] = -yoff;
off[4] = off[7] = yoff; off[4] = off[7] = yoff;
off[6] = off[9] = xoff; off[6] = off[9] = xoff;
// float fix[8]; // float fix[8];
fix[3] = fix[5] = yfix; fix[3] = fix[5] = yfix;
+11 -4
View File
@@ -1484,6 +1484,7 @@ static char *CHAT_WordWrap(INT32 x, INT32 w, INT32 option, const char *string)
x = 0; x = 0;
} }
} }
return newstring; return newstring;
} }
@@ -1522,7 +1523,7 @@ static void HU_drawMiniChat(void)
emote_t *emote = NULL; emote_t *emote = NULL;
int emotelen = 0; int emotelen = 0;
while(msg[j]) // iterate through msg while (msg[j]) // iterate through msg
{ {
if (msg[j] < HU_FONTSTART) // don't draw if (msg[j] < HU_FONTSTART) // don't draw
{ {
@@ -1554,14 +1555,17 @@ static void HU_drawMiniChat(void)
{ {
j++; j++;
} }
prev_linereturn = false; prev_linereturn = false;
dx += charwidth; dx += charwidth;
if (dx >= boxw) if (dx >= boxw)
{ {
dx = 0; dx = 0;
linescount += 1; linescount += 1;
} }
} }
dy = 0; dy = 0;
dx = 0; dx = 0;
msglines += linescount+1; msglines += linescount+1;
@@ -1598,7 +1602,7 @@ static void HU_drawMiniChat(void)
emote_t *emote = NULL; emote_t *emote = NULL;
int emotelen = 0; int emotelen = 0;
while(msg[j]) // iterate through msg while (msg[j]) // iterate through msg
{ {
if (msg[j] < HU_FONTSTART) // don't draw if (msg[j] < HU_FONTSTART) // don't draw
{ {
@@ -1643,12 +1647,14 @@ static void HU_drawMiniChat(void)
dx += charwidth; dx += charwidth;
prev_linereturn = false; prev_linereturn = false;
if (dx >= boxw) if (dx >= boxw)
{ {
dx = 0; dx = 0;
dy += charheight; dy += charheight;
} }
} }
dy += charheight; dy += charheight;
dx = 0; dx = 0;
if (msg) 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 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 clrflag = 0;
INT32 j = 0; INT32 j = 0;
@@ -1713,7 +1719,7 @@ static void HU_drawChatLog(INT32 offset)
emote_t *emote = NULL; emote_t *emote = NULL;
int emotelen = 0; int emotelen = 0;
while(msg[j]) // iterate through msg while (msg[j]) // iterate through msg
{ {
if (msg[j] < HU_FONTSTART) // don't draw if (msg[j] < HU_FONTSTART) // don't draw
{ {
@@ -1758,6 +1764,7 @@ static void HU_drawChatLog(INT32 offset)
dy += charheight; dy += charheight;
} }
} }
dy += charheight; dy += charheight;
dx = 0; dx = 0;
if (msg) if (msg)
+1
View File
@@ -1293,6 +1293,7 @@ static int lib_pPlayRinglossSound(lua_State *L)
player_t *player = NULL; player_t *player = NULL;
mobj_t *damager = NULL; mobj_t *damager = NULL;
NOHUD 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) if (!source)
return LUA_ErrInvalid(L, "mobj_t"); return LUA_ErrInvalid(L, "mobj_t");
if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) if (!lua_isnone(L, 2) && lua_isuserdata(L, 2))
+1 -1
View File
@@ -25,7 +25,7 @@
#include "lua_hook.h" // cmd errors #include "lua_hook.h" // cmd errors
boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor); boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor);
state_t *astate; state_t *astate = NULL;
boolean actionsoverridden[NUMACTIONS] = {false}; boolean actionsoverridden[NUMACTIONS] = {false};
+18 -21
View File
@@ -45,20 +45,20 @@ int hook_defrosting = 0;
// List of internal libraries to load from SRB2 // List of internal libraries to load from SRB2
static lua_CFunction liblist[] = { static lua_CFunction liblist[] = {
LUA_EnumLib, // global metatable for enums LUA_EnumLib, // global metatable for enums
LUA_SOCLib, // A_Action functions, freeslot LUA_SOCLib, // A_Action functions, freeslot
LUA_BaseLib, // string concatination by +, CONS_Printf, p_local.h stuff (P_InstaThrust, P_Move), etc. 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_MathLib, // fixed_t and angle_t math functions
LUA_HookLib, // hookAdd and hook-calling functions LUA_HookLib, // hookAdd and hook-calling functions
LUA_ConsoleLib, // console command/variable functions and structs LUA_ConsoleLib, // console command/variable functions and structs
LUA_InfoLib, // info.h stuff: mobjinfo_t, mobjinfo[], state_t, states[] LUA_InfoLib, // info.h stuff: mobjinfo_t, mobjinfo[], state_t, states[]
LUA_MobjLib, // mobj_t, mapthing_t LUA_MobjLib, // mobj_t, mapthing_t
LUA_PlayerLib, // player_t LUA_PlayerLib, // player_t
LUA_SkinLib, // skin_t, skins[] LUA_SkinLib, // skin_t, skins[]
LUA_ThinkerLib, // thinker_t LUA_ThinkerLib, // thinker_t
LUA_MapLib, // line_t, side_t, sector_t, subsector_t LUA_MapLib, // line_t, side_t, sector_t, subsector_t
LUA_BlockmapLib, // blockmap stuff LUA_BlockmapLib, // blockmap stuff
LUA_HudLib, // HUD stuff LUA_HudLib, // HUD stuff
NULL NULL
}; };
@@ -66,12 +66,8 @@ static lua_CFunction liblist[] = {
static void *LUA_Alloc(void *ud, void *ptr, size_t osize, size_t nsize) static void *LUA_Alloc(void *ud, void *ptr, size_t osize, size_t nsize)
{ {
(void)ud; (void)ud;
if (nsize == 0) { (void)osize;
if (osize != 0) return Z_Realloc(ptr, nsize, PU_LUA, NULL);
Z_Free(ptr);
return NULL;
} else
return Z_Realloc(ptr, nsize, PU_LUA, NULL);
} }
// Panic function Lua calls when there's an unprotected error. // 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); lua_setfield(L, LUA_REGISTRYINDEX, LREG_VALID);
// open srb2 libraries // open srb2 libraries
for(i = 0; liblist[i]; i++) { for (i = 0; liblist[i]; i++)
{
lua_pushcfunction(L, liblist[i]); lua_pushcfunction(L, liblist[i]);
lua_call(L, 0, 0); lua_call(L, 0, 0);
} }
+1 -1
View File
@@ -301,7 +301,7 @@ void Command_CheatNoTarget_f(void)
void Command_Scale_f(void) void Command_Scale_f(void)
{ {
const double scaled = atof(COM_Argv(1)); const double scaled = atof(COM_Argv(1));
fixed_t scale = FLOAT_TO_FIXED(scaled); fixed_t scale = DoubleToFixed(scaled);
REQUIRE_DEVMODE; REQUIRE_DEVMODE;
REQUIRE_INLEVEL; REQUIRE_INLEVEL;
+9 -29
View File
@@ -20,6 +20,7 @@ extern "C" {
#endif #endif
#include "doomtype.h" #include "doomtype.h"
#ifdef __GNUC__ #ifdef __GNUC__
#include <stdlib.h> #include <stdlib.h>
#endif #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 FIXED_TO_FLOAT(x) FixedToFloat(x) // (((float)(x)) / ((float)FRACUNIT))
#define FLOAT_TO_FIXED(f) FloatToFixed(f) // (fixed_t)((f) * ((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 /** \brief The FixedMul function
\param a fixed_t number \param a fixed_t number
@@ -265,35 +274,6 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedRound(fixed_t x)
return INT32_MAX; 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 typedef struct
{ {
fixed_t x; fixed_t x;
+1 -1
View File
@@ -4719,7 +4719,7 @@ static void M_DrawReplayHut(void)
if (y > scaledviewheight-80) if (y > scaledviewheight-80)
{ {
V_DrawFill(BASEVIDWIDTH-4, 75, 4, scaledviewheight-80, V_SNAPTOTOP|V_SNAPTORIGHT|239); 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 // Draw the cursor
+6
View File
@@ -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, "Show \"FOCUS LOST\"", &cv_showfocuslost, 100},
{IT_STRING|IT_CVAR, NULL, "Visible Mouse", &cv_mousevisible, 120}, {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[] = static const char* OP_FocusOptionsTooltips[] =
@@ -1216,6 +1220,8 @@ static const char* OP_FocusOptionsTooltips[] =
"Set manual framerate cap while the game is unfocused.", "Set manual framerate cap while the game is unfocused.",
"Should the FOCUS LOST window appear\n 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.", "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[] = static menuitem_t OP_DataOptionsMenu[] =
+2 -2
View File
@@ -540,7 +540,7 @@ static boolean M_BackupConfig(const char *filename)
void M_SaveConfig(const char *filename) void M_SaveConfig(const char *filename)
{ {
FILE *f; FILE *f;
char *filepath; CLEANUP(Z_Pfree) char *filepath = NULL;
// make sure not to write back the config until it's been correctly loaded // make sure not to write back the config until it's been correctly loaded
if (!loaded_config) if (!loaded_config)
@@ -558,7 +558,7 @@ void M_SaveConfig(const char *filename)
// append srb2home to beginning of filename // append srb2home to beginning of filename
// but check if srb2home isn't already there, first // but check if srb2home isn't already there, first
if (!strstr(filename, srb2home)) if (!strstr(filename, srb2home))
filepath = va(pandf,srb2home, filename); filepath = Z_StrDup(va(pandf, srb2home, filename));
else else
filepath = Z_StrDup(filename); filepath = Z_StrDup(filename);
+6 -6
View File
@@ -519,10 +519,10 @@ void R_GetRenderBlockMapDimensions(fixed_t drawdist, INT32 *xl, INT32 *xh, INT32
const fixed_t vyright = viewy + FixedMul(drawdist, FSIN(right)); const fixed_t vyright = viewy + FixedMul(drawdist, FSIN(right));
// Try to narrow the search to within only the field of view // Try to narrow the search to within only the field of view
*xl = (unsigned)(std::min(viewx, std::min(vxleft, vxright)) - bmaporgx)>>MAPBLOCKSHIFT; *xl = (unsigned)(FixedClamp((INT64)std::min(viewx, std::min(vxleft, vxright)) - bmaporgx))>>MAPBLOCKSHIFT;
*xh = (unsigned)(std::max(viewx, std::max(vxleft, vxright)) - bmaporgx)>>MAPBLOCKSHIFT; *xh = (unsigned)(FixedClamp((INT64)std::max(viewx, std::max(vxleft, vxright)) - bmaporgx))>>MAPBLOCKSHIFT;
*yl = (unsigned)(std::min(viewy, std::min(vyleft, vyright)) - bmaporgy)>>MAPBLOCKSHIFT; *yl = (unsigned)(FixedClamp((INT64)std::min(viewy, std::min(vyleft, vyright)) - bmaporgy))>>MAPBLOCKSHIFT;
*yh = (unsigned)(std::max(viewy, std::max(vyleft, vyright)) - bmaporgy)>>MAPBLOCKSHIFT; *yh = (unsigned)(FixedClamp((INT64)std::max(viewy, std::max(vyleft, vyright)) - bmaporgy))>>MAPBLOCKSHIFT;
if (*xh >= bmapwidth) if (*xh >= bmapwidth)
*xh = bmapwidth - 1; *xh = bmapwidth - 1;
@@ -1018,8 +1018,8 @@ static void R_InitViewMapping(void)
for (INT32 i = 0; i < j; i++) for (INT32 i = 0; i < j; i++)
{ {
fixed_t dy = (i - viewheight*8)<<FRACBITS; fixed_t dy = abs(i - viewheight*8) << FRACBITS;
dy = FixedMul(abs(dy), fovtan); dy = FixedMul(dy, fovtan);
yslopetab[i] = FixedDiv(centerx*FRACUNIT, dy); yslopetab[i] = FixedDiv(centerx*FRACUNIT, dy);
} }
} }
+2 -2
View File
@@ -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) 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 absx = FixedClamp(labs((INT64)x - (INT64)x1));
const fixed_t absy = abs(y - y1); const fixed_t absy = FixedClamp(labs((INT64)y - (INT64)y1));
#ifdef __cplusplus #ifdef __cplusplus
return std::max<fixed_t>(absx, absy); return std::max<fixed_t>(absx, absy);
#else #else
+15 -12
View File
@@ -57,8 +57,11 @@ visffloor_t visffloor[MAXFFLOORS] = {};
INT32 numffloors = 0; INT32 numffloors = 0;
//SoM: 3/23/2000: Boom visplane hashing routine. //SoM: 3/23/2000: Boom visplane hashing routine.
#define visplane_hash(picnum,lightlevel,height) \ constexpr unsigned int visplane_hash(const unsigned int picnum, const unsigned int lightlevel,
((unsigned)((picnum)*3+(lightlevel)+(height)*7) & VISPLANEHASHMASK) const unsigned int height)
{
return ((picnum * 3) + lightlevel + (height * 7)) & VISPLANEHASHMASK;
}
// //
// Clip values are the solid pixel bounding the range. // 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)); 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. // to step from those to the proper texture coordinate to start drawing at.
// That way, the texture coordinate is always calculated by its position // 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. // 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->xfrac = FixedClamp((INT64)ds->xoffs + (INT64)FixedMul(planecos, distance) + ((INT64)x1 - (INT64)centerx) * (INT64)ds->xstep);
ds->yfrac = ds->yoffs - FixedMul(planesin, distance) + (x1 - centerx) * ds->ystep; ds->yfrac = FixedClamp((INT64)ds->yoffs - (INT64)FixedMul(planesin, distance) + ((INT64)x1 - (INT64)centerx) * (INT64)ds->ystep);
if (ds->planeripple.active) 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) for (check = visplanes[hash]; check; check = check->next)
{ {
@@ -562,7 +565,7 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop)
} }
else 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); 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 // m is the v direction vector in view space
ang = ANG2RAD(ANGLE_180 - (angle + plangle)); ang = ANG2RAD(ANGLE_180 - (angle + plangle));
m->x = cos(ang); m->x = cosf(ang);
m->z = sin(ang); m->z = sinf(ang);
// n is the u direction vector in view space // n is the u direction vector in view space
n->x = sin(ang); n->x = sinf(ang);
n->z = -cos(ang); n->z = -cosf(ang);
plangle >>= ANGLETOFINESHIFT; plangle >>= ANGLETOFINESHIFT;
temp = P_GetSlopeZAt(slope, xpos + FINESINE(plangle), ypos + FINECOSINE(plangle)); 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; levelflat_t *levelflat;
void (*mapfunc)(drawspandata_t*, void(*)(drawspandata_t*), INT32, INT32, INT32, boolean) = R_MapPlane; void (*mapfunc)(drawspandata_t*, void(*)(drawspandata_t*), INT32, INT32, INT32, boolean) = R_MapPlane;
if (pl->minx > pl->maxx) if (!(pl->minx <= pl->maxx))
return; return;
// sky flat // sky flat
+2 -3
View File
@@ -246,7 +246,6 @@ static boolean TrimVisplaneBounds(const visplane_t* plane, INT16* start, INT16*
if (!(*start < *end)) if (!(*start < *end))
return true; return true;
/** Trims a visplane's horizontal gap to match its render area. /** Trims a visplane's horizontal gap to match its render area.
* *
* Visplanes' minx/maxx may sometimes exceed the area they're * 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; y = (viewy - skyboxmo[1]->y) * -mh->skybox_scaley;
// Apply transform to account for the skybox viewport angle. // Apply transform to account for the skybox viewport angle.
portal->viewx += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang)); portal->viewx += FixedMul(x, FINECOSINE(ang)) - FixedMul(y, FINESINE(ang));
portal->viewy += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang)); portal->viewy += FixedMul(x, FINESINE(ang)) + FixedMul(y, FINECOSINE(ang));
} }
if (mh->skybox_scalez > 0) if (mh->skybox_scalez > 0)
+81 -92
View File
@@ -226,10 +226,11 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
leftheight -= viewz; leftheight -= viewz;
rightheight -= viewz; rightheight -= viewz;
rlight->height = (centeryfrac) - FixedMul(leftheight, drawseg->scale1); rlight->height = FixedClamp((INT64)centeryfrac - FixedMul(leftheight, drawseg->scale1));
rlight->heightstep = (centeryfrac) - FixedMul(rightheight, drawseg->scale2); rlight->heightstep = FixedClamp((INT64)centeryfrac - FixedMul(rightheight, drawseg->scale2));
rlight->heightstep = (rlight->heightstep-rlight->height)/(range); rlight->heightstep = FixedClamp((INT64)rlight->heightstep - rlight->height)/(range);
rlight->startheight = rlight->height; // keep starting value here to reset for each repeat rlight->startheight = rlight->height; // keep starting value here to reset for each repeat
rlight->lightlevel = *light->lightlevel; rlight->lightlevel = *light->lightlevel;
rlight->extra_colormap = light->extra_colormap; rlight->extra_colormap = light->extra_colormap;
rlight->flags = static_cast<ffloortype_e>(light->flags); 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++) for (i = 0; i < dc->numlights; i++)
{ {
rlight = &dc->lightlist[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; lighttable_t **xwalllights;
sprbotscreen = INT32_MAX; 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; dc->iscale = 0xffffffffu / (unsigned)spryscale;
// draw the texture // draw the texture
@@ -407,7 +408,8 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
set_light_vars(i); set_light_vars(i);
height = rlight->height; height = rlight->height;
rlight->height += rlight->heightstep;
rlight->height = FixedClamp((INT64)rlight->height + rlight->heightstep);
if (height <= windowtop) if (height <= windowtop)
{ {
@@ -423,7 +425,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
for (i++; i < dc->numlights; i++) for (i++; i < dc->numlights; i++)
{ {
rlight = &dc->lightlist[i]; rlight = &dc->lightlist[i];
rlight->height += rlight->heightstep; rlight->height = FixedClamp((INT64)rlight->height + rlight->heightstep);
} }
continue; continue;
@@ -455,7 +457,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
if (frontsector->extra_colormap) if (frontsector->extra_colormap)
dc->colormap = frontsector->extra_colormap->colormap + (dc->colormap - colormaps); 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; dc->iscale = 0xffffffffu / (unsigned)spryscale;
// draw the texture // draw the texture
@@ -710,17 +712,6 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf
rw_scalestep = drawseg->scalestep; rw_scalestep = drawseg->scalestep;
spryscale = drawseg->scale1 + (x1 - drawseg->x1)*rw_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; dc->numlights = 0;
if (frontsector->numlights) 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 leftheight, rightheight;
fixed_t pfloorleft, pfloorright; fixed_t pfloorleft, pfloorright;
INT64 overflow_test;
light = &frontsector->lightlist[i]; light = &frontsector->lightlist[i];
rlight = &dc->lightlist[p]; rlight = &dc->lightlist[p];
@@ -760,17 +750,14 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf
continue; continue;
} }
leftheight -= viewz; leftheight -= viewz;
rightheight -= 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. // 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 = FixedClamp((INT64)centeryfrac - (((INT64)leftheight * drawseg->scale1)>>FRACBITS));
rlight->height = overflow_clamp(overflow_test); 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); rlight->flags = static_cast<ffloortype_e>(light->flags);
if (light->flags & FF_CUTLEVEL) if (light->flags & FF_CUTLEVEL)
@@ -781,13 +768,9 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf
rightheight -= 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. // 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 = FixedClamp((INT64)centeryfrac - (((INT64)leftheight*drawseg->scale1)>>FRACBITS));
rlight->botheight = overflow_clamp(overflow_test); rlight->botheightstep = FixedClamp(((INT64)centeryfrac - (((INT64)rightheight*drawseg->scale2)>>FRACBITS)));
rlight->botheightstep = FixedClamp((INT64)rlight->botheightstep - rlight->botheight)/(range);
overflow_test = (INT64)centeryfrac - (((INT64)rightheight*drawseg->scale2)>>FRACBITS);
rlight->botheightstep = overflow_clamp(overflow_test);
rlight->botheightstep = (rlight->botheightstep-rlight->botheight)/(range);
} }
rlight->lightlevel = *light->lightlevel; 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; right_bottom = P_GetFFloorBottomZAt(pfloor, drawseg->rightpos.x, drawseg->rightpos.y) - viewz;
// using INT64 to avoid 32bit overflow // using INT64 to avoid 32bit overflow
top_frac = (INT64)centeryfrac - (((INT64)left_top * drawseg->scale1) >> FRACBITS); top_frac = FixedClamp((INT64)centeryfrac - (((INT64)left_top * drawseg->scale1) >> FRACBITS));
bottom_frac = (INT64)centeryfrac - (((INT64)left_bottom * drawseg->scale1) >> FRACBITS); top_step = FixedClamp((INT64)centeryfrac - (((INT64)right_top * drawseg->scale2) >> FRACBITS));
top_step = (INT64)centeryfrac - (((INT64)right_top * drawseg->scale2) >> FRACBITS); bottom_frac = FixedClamp((INT64)centeryfrac - (((INT64)left_bottom * drawseg->scale1) >> FRACBITS));
bottom_step = (INT64)centeryfrac - (((INT64)right_bottom * drawseg->scale2) >> FRACBITS); bottom_step = FixedClamp((INT64)centeryfrac - (((INT64)right_bottom * drawseg->scale2) >> FRACBITS));
top_step = (top_step-top_frac)/(range); top_step = (top_step-top_frac)/(range);
bottom_step = (bottom_step-bottom_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 // Calculate bounds
// clamp the values if necessary to avoid overflows and rendering glitches caused by them // clamp the values if necessary to avoid overflows and rendering glitches caused by them
sprtopscreen = windowtop = overflow_clamp(top_frac); sprtopscreen = windowtop = top_frac;
sprbotscreen = windowbottom = overflow_clamp(bottom_frac); sprbotscreen = windowbottom = bottom_frac;
top_frac += top_step; top_frac += top_step;
bottom_frac += bottom_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++) for (i = 0; i < dc->numlights; i++)
{ {
rlight = &dc->lightlist[i]; rlight = &dc->lightlist[i];
rlight->height += rlight->heightstep;
rlight->height = FixedClamp((INT64)rlight->height + rlight->heightstep);
if (rlight->flags & FF_CUTLEVEL) 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; solid = 0;
height = rlight->height; height = rlight->height;
rlight->height += rlight->heightstep; rlight->height = FixedClamp((INT64)rlight->height + rlight->heightstep);
if (solid) if (solid)
{ {
bheight = rlight->botheight - (FRACUNIT >> 1); bheight = FixedClamp((INT64)rlight->botheight - (FRACUNIT >> 1));
rlight->botheight += rlight->botheightstep; rlight->botheight = FixedClamp((INT64)rlight->botheight + rlight->botheightstep);
} }
if (height <= windowtop) 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++) for (i++; i < dc->numlights; i++)
{ {
rlight = &dc->lightlist[i]; rlight = &dc->lightlist[i];
rlight->height += rlight->heightstep; rlight->height = FixedClamp((INT64)rlight->height + rlight->heightstep);
if (rlight->flags & FF_CUTLEVEL) if (rlight->flags & FF_CUTLEVEL)
rlight->botheight += rlight->botheightstep; rlight->botheight += rlight->botheightstep;
@@ -1212,7 +1197,7 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
for (; rw_x < rw_stopx; rw_x++) for (; rw_x < rw_stopx; rw_x++)
{ {
// mark floor / ceiling areas // mark floor / ceiling areas
yl = (topfrac+HEIGHTUNIT-1)>>HEIGHTBITS; yl = FixedClamp((INT64)topfrac + HEIGHTUNIT-1)>>HEIGHTBITS;
yh = bottomfrac>>HEIGHTBITS; yh = bottomfrac>>HEIGHTBITS;
// Mark ceiling // Mark ceiling
@@ -1363,15 +1348,17 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
//SoM: Calculate offsets for Thick fake floors. //SoM: Calculate offsets for Thick fake floors.
// calculate texture offset // calculate texture offset
angle = (rw_centerangle + xtoviewangle[rw_x])>>ANGLETOFINESHIFT; angle = (rw_centerangle + xtoviewangle[rw_x])>>ANGLETOFINESHIFT;
// Mask 4095 to guarantee this index is within bounds // 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) if (oldtexturecolumn != -1)
{ {
rw_bottomtexturemid += FixedMul(rw_bottomtextureslide, oldtexturecolumn-texturecolumn); const fixed_t coloff = FixedClamp((INT64)oldtexturecolumn - texturecolumn);
rw_midtexturemid += FixedMul(rw_midtextureslide, oldtexturecolumn-texturecolumn); rw_bottomtexturemid += FixedMul(rw_bottomtextureslide, coloff);
rw_toptexturemid += FixedMul(rw_toptextureslide, oldtexturecolumn-texturecolumn); rw_midtexturemid += FixedMul(rw_midtextureslide, coloff);
rw_midtextureback += FixedMul(rw_midtexturebackslide, oldtexturecolumn-texturecolumn); rw_toptexturemid += FixedMul(rw_toptextureslide, coloff);
rw_midtextureback += FixedMul(rw_midtexturebackslide, coloff);
} }
oldtexturecolumn = texturecolumn; oldtexturecolumn = texturecolumn;
@@ -1381,7 +1368,7 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
// calculate lighting // calculate lighting
pindex = FixedMul(rw_scale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; pindex = FixedMul(rw_scale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT;
if (pindex >= MAXLIGHTSCALE) if (pindex >= MAXLIGHTSCALE)
pindex = MAXLIGHTSCALE-1; pindex = MAXLIGHTSCALE-1;
dc->colormap = walllights[pindex]; dc->colormap = walllights[pindex];
@@ -1463,8 +1450,8 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
if (toptexture) if (toptexture)
{ {
// top wall // top wall
mid = pixhigh>>HEIGHTBITS; mid = pixhigh >> HEIGHTBITS;
pixhigh += pixhighstep; pixhigh = FixedClamp((INT64)pixhigh + pixhighstep);
if (mid >= floorclip[rw_x]) if (mid >= floorclip[rw_x])
mid = floorclip[rw_x]-1; mid = floorclip[rw_x]-1;
@@ -1493,8 +1480,8 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
if (bottomtexture) if (bottomtexture)
{ {
// bottom wall // bottom wall
mid = (pixlow+HEIGHTUNIT-1)>>HEIGHTBITS; mid = FixedClamp((INT64)pixlow+HEIGHTUNIT-1)>>HEIGHTBITS;
pixlow += pixlowstep; pixlow = FixedClamp((INT64)pixlow + pixlowstep);
// no space above wall? // no space above wall?
if (mid <= ceilingclip[rw_x]) if (mid <= ceilingclip[rw_x])
@@ -1545,10 +1532,10 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
{ {
for (i = 0; i < dc->numlights; i++) 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) 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; visffloor[i].b_frac += visffloor[i].b_step;
} }
rw_scale += rw_scalestep; rw_scale = FixedClamp((INT64)rw_scale + rw_scalestep);
topfrac += topstep;
bottomfrac += bottomstep; 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++) for (; rw_x < rw_stopx; rw_x++)
{ {
// mark floor / ceiling areas // mark floor / ceiling areas
yl = (topfrac+HEIGHTUNIT-1)>>HEIGHTBITS; yl = FixedClamp((INT64)topfrac + HEIGHTUNIT-1)>>HEIGHTBITS;
yh = bottomfrac>>HEIGHTBITS; yh = bottomfrac>>HEIGHTBITS;
// Mark ceiling // Mark ceiling
@@ -1822,7 +1810,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
// big room fix // big room fix
if (longboi) 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->x1 = rw_x = start;
ds_p->x2 = stop; ds_p->x2 = stop;
@@ -2205,8 +2193,8 @@ void R_StoreWallRange(INT32 start, INT32 stop)
} }
} }
rw_toptexturemid += sidedef->rowoffset; rw_toptexturemid = FixedClamp((INT64)rw_toptexturemid + sidedef->rowoffset);
rw_bottomtexturemid += sidedef->rowoffset; rw_bottomtexturemid = FixedClamp((INT64)rw_bottomtexturemid + sidedef->rowoffset);
R_AllocTextureColumnTables(rw_stopx - start); R_AllocTextureColumnTables(rw_stopx - start);
@@ -2491,8 +2479,9 @@ void R_StoreWallRange(INT32 start, INT32 stop)
rw_offset = -rw_offset; rw_offset = -rw_offset;
/// don't use texture offset for splats /// don't use texture offset for splats
rw_offset2 = rw_offset + curline->offset; rw_offset2 = FixedClamp((INT64)rw_offset + curline->offset);
rw_offset += sidedef->textureoffset + curline->offset; rw_offset = FixedClamp((INT64)rw_offset + (INT64)sidedef->textureoffset + curline->offset);
rw_centerangle = ANGLE_90 + viewangle - rw_normalangle; rw_centerangle = ANGLE_90 + viewangle - rw_normalangle;
// calculate light table // calculate light table
@@ -2552,8 +2541,8 @@ void R_StoreWallRange(INT32 start, INT32 stop)
auto set_topstep_normal = [&] auto set_topstep_normal = [&]
{ {
topstep = -FixedMul (rw_scalestep, worldtop); topstep = -FixedMul(rw_scalestep, worldtop);
topfrac = (centeryfrac>>4) - FixedMul (worldtop, rw_scale); topfrac = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldtop, rw_scale));
}; };
// untextured seg // 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 // 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) if (tophigh && !backsector && frontsector->ceilingpic == skyflatnum)
{ {
topstep = -FixedMul (rw_scalestep, worldbottom); topstep = -FixedMul(rw_scalestep, worldbottom);
topfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale); topfrac = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldbottom, rw_scale));
// account for slopes to try and get rid of sharp edges from the black void // account for slopes to try and get rid of sharp edges from the black void
if (frontsector->f_slope || (backsector && backsector->f_slope)) if (frontsector->f_slope || (backsector && backsector->f_slope))
{ {
topstep = -FixedMul (rw_scalestep, worldbottomslope); topstep = -FixedMul(rw_scalestep, worldbottomslope);
topfrac = (centeryfrac>>4) - FixedMul (worldbottomslope, rw_scale); topfrac = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldbottomslope, rw_scale));
} }
} }
else else
@@ -2590,18 +2579,18 @@ void R_StoreWallRange(INT32 start, INT32 stop)
else else
set_topstep_normal(); set_topstep_normal();
bottomstep = -FixedMul (rw_scalestep, worldbottom); bottomstep = -FixedMul(rw_scalestep, worldbottom);
bottomfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale); bottomfrac = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldbottom, rw_scale));
if (frontsector->c_slope) 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); topstep = (topfracend-topfrac)/(range);
} }
if (frontsector->f_slope) 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); bottomstep = (bottomfracend-bottomfrac)/(range);
} }
} }
@@ -2643,9 +2632,9 @@ void R_StoreWallRange(INT32 start, INT32 stop)
continue; continue;
} }
rlight->height = (centeryfrac>>4) - FixedMul(leftheight, rw_scale); rlight->height = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(leftheight, rw_scale));
rlight->heightstep = (centeryfrac>>4) - FixedMul(rightheight, ds_p->scale2); rlight->heightstep = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(rightheight, ds_p->scale2));
rlight->heightstep = (rlight->heightstep-rlight->height)/(range); rlight->heightstep = FixedClamp((INT64)rlight->heightstep - rlight->height)/(range);
rlight->flags = static_cast<ffloortype_e>(light->flags); rlight->flags = static_cast<ffloortype_e>(light->flags);
if (light->caster && light->caster->flags & FF_CUTSOLIDS) if (light->caster && light->caster->flags & FF_CUTSOLIDS)
@@ -2707,9 +2696,9 @@ void R_StoreWallRange(INT32 start, INT32 stop)
if (toptexture) 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); pixhighstep = (topfracend-pixhigh)/(range);
// If the lowest part of a ceiling stretching down covers the entire screen // 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) 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); pixlowstep = (bottomfracend-pixlow)/(range);
// If the highest part of a floor stretching up covers the entire screen // 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_slope = roverright;
visffloor[i].b_pos >>= 4; visffloor[i].b_pos >>= 4;
visffloor[i].b_pos_slope >>= 4; visffloor[i].b_pos_slope >>= 4;
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));
visffloor[i].b_step = (centeryfrac >> 4) - FixedMul(visffloor[i].b_pos_slope, ds_p->scale2); 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); 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 = height;
visffloor[i].b_pos = (visffloor[i].b_pos - viewz) >> 4; visffloor[i].b_pos = (visffloor[i].b_pos - viewz) >> 4;
visffloor[i].b_step = FixedMul(-rw_scalestep, visffloor[i].b_pos); 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) while (i < numffloors && visffloor[i].polyobj != curline->polyseg)
@@ -2880,7 +2869,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
if (markceiling) if (markceiling)
{ {
if (ceilingplane) //SoM: 3/29/2000: Check for null ceiling planes 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 else
markceiling = false; markceiling = false;
@@ -2894,7 +2883,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
if (markfloor) if (markfloor)
{ {
if (floorplane) //SoM: 3/29/2000: Check for null planes 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 else
markfloor = false; markfloor = false;
+9 -7
View File
@@ -11,6 +11,7 @@
/// \file r_things.c /// \file r_things.c
/// \brief Refresh of things, i.e. objects represented by sprites /// \brief Refresh of things, i.e. objects represented by sprites
#include "m_fixed.h"
#include "r_main.h" // stplyr #include "r_main.h" // stplyr
#include "r_fps.h" #include "r_fps.h"
#include "r_things.h" #include "r_things.h"
@@ -70,7 +71,7 @@ INT16 *screenheightarray = NULL;
typedef struct drawseg_xrange_item_s typedef struct drawseg_xrange_item_s
{ {
INT16 x1, x2; INT32 x1, x2;
drawseg_t *user; drawseg_t *user;
} drawseg_xrange_item_t; } drawseg_xrange_item_t;
@@ -489,8 +490,8 @@ void R_InitSprites(void)
for (angle = 1; angle < ROTANGLES; angle++) for (angle = 1; angle < ROTANGLES; angle++)
{ {
fa = ANG2RAD(FixedAngle((ROTANGDIFF * angle)<<FRACBITS)); fa = ANG2RAD(FixedAngle((ROTANGDIFF * angle)<<FRACBITS));
rollcosang[angle] = FLOAT_TO_FIXED(cos(-fa)); rollcosang[angle] = FLOAT_TO_FIXED(cosf(-fa));
rollsinang[angle] = FLOAT_TO_FIXED(sin(-fa)); rollsinang[angle] = FLOAT_TO_FIXED(sinf(-fa));
} }
#endif #endif
@@ -616,10 +617,11 @@ void R_DrawMaskedColumn(drawcolumndata_t* dc, column_t *column)
if (topdelta <= prevdelta) if (topdelta <= prevdelta)
topdelta += prevdelta; topdelta += prevdelta;
prevdelta = topdelta; 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; dc->yh = (bottomscreen-1)>>FRACBITS;
if (windowtop != INT32_MAX && windowbottom != INT32_MAX) 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) for (dc.x = vis->x1; dc.x <= vis->x2; dc.x++, spryscale += scalestep)
{ {
angle_t angle = ((vis->centerangle + xtoviewangle[dc.x]) >> ANGLETOFINESHIFT) & 0xFFF; 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) if (texturecolumn < 0 || texturecolumn >= pwidth)
continue; continue;
+1
View File
@@ -63,6 +63,7 @@ typedef struct viddef_s
INT32 dup; // scale 1, 2, 3 value for menus & overlays 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 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 smalldup; // factor for a little bit of scaling
UINT8 meddup; // factor for moderate, but not full, scaling UINT8 meddup; // factor for moderate, but not full, scaling
+15 -2
View File
@@ -169,7 +169,6 @@ if(${SDL2_FOUND})
target_link_libraries(SRB2SDL2 PRIVATE ${LIBBACKTRACE_LIBRARIES}) target_link_libraries(SRB2SDL2 PRIVATE ${LIBBACKTRACE_LIBRARIES})
endif() endif()
if(${CMAKE_SYSTEM} MATCHES Linux) if(${CMAKE_SYSTEM} MATCHES Linux)
target_link_libraries(SRB2SDL2 PRIVATE target_link_libraries(SRB2SDL2 PRIVATE
m m
@@ -230,6 +229,20 @@ if(${SDL2_FOUND})
-DHAVE_THREADS -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 ## strip debug symbols into separate file when using gcc
# if(CMAKE_COMPILER_IS_GNUCC) # if(CMAKE_COMPILER_IS_GNUCC)
# if(${CMAKE_BUILD_TYPE} MATCHES Debug) # if(${CMAKE_BUILD_TYPE} MATCHES Debug)
@@ -296,7 +309,7 @@ if(${SDL2_FOUND})
else() else()
find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}") find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}")
list(APPEND win_extra_dll_list ${SRB2_SDL2_DLL_${dllname}}) list(APPEND win_extra_dll_list ${SRB2_SDL2_DLL_${dllname}})
endif() endif()
endmacro() endmacro()
getwinlib(SDL2 "SDL2.dll") getwinlib(SDL2 "SDL2.dll")
if(${SRB2_CONFIG_SDL2_USEMIXER}) if(${SRB2_CONFIG_SDL2_USEMIXER})
+27 -7
View File
@@ -726,7 +726,9 @@ static void JoyReset(SDLJoyInfo_t *JoySet)
JoySet->dev = NULL; JoySet->dev = NULL;
JoySet->oldjoy = -1; JoySet->oldjoy = -1;
#if (SDL_VERSION_ATLEAST(2,32,4))
JoySet->id = -1; JoySet->id = -1;
#endif
} }
/** \brief SDL info about joystick /** \brief SDL info about joystick
@@ -783,7 +785,11 @@ void I_UpdateJoystickDeviceIndex(UINT8 player)
/////////////////////////////////////////////// ///////////////////////////////////////////////
if (JoyInfo[player].dev) if (JoyInfo[player].dev)
{ {
#if (SDL_VERSION_ATLEAST(2,32,4))
cv_usejoystick[player].value = JoyInfo[player].id + 1; cv_usejoystick[player].value = JoyInfo[player].id + 1;
#else
cv_usejoystick[player].value = I_GetJoystickDeviceIndex(JoyInfo[player].dev) + 1;
#endif
} }
else else
{ {
@@ -885,13 +891,13 @@ static int joy_open(int playerIndex, int joyIndex)
if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0) 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; return -1;
} }
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == 0) 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; return -1;
} }
@@ -902,7 +908,7 @@ static int joy_open(int playerIndex, int joyIndex)
if (num_joy == 0) 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; return -1;
} }
@@ -925,7 +931,7 @@ static int joy_open(int playerIndex, int joyIndex)
return SDL_CONTROLLER_AXIS_MAX; return SDL_CONTROLLER_AXIS_MAX;
// Else, we're changing devices, so send neutral joy events // 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); I_ShutdownJoystick(playerIndex);
} }
@@ -933,13 +939,15 @@ static int joy_open(int playerIndex, int joyIndex)
if (JoyInfo[playerIndex].dev == NULL) 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; 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); JoyInfo[playerIndex].id = I_GetJoystickDeviceIndex(JoyInfo[playerIndex].dev);
#endif
return SDL_CONTROLLER_AXIS_MAX; return SDL_CONTROLLER_AXIS_MAX;
} }
@@ -985,7 +993,9 @@ void I_InitJoystick(UINT8 index)
JoyInfo[index].dev = NULL; JoyInfo[index].dev = NULL;
JoyInfo[index].oldjoy = -1; JoyInfo[index].oldjoy = -1;
#if (SDL_VERSION_ATLEAST(2,32,4))
JoyInfo[index].id = -1; JoyInfo[index].id = -1;
#endif
if (cv_usejoystick[index].value) if (cv_usejoystick[index].value)
newcontroller = SDL_GameControllerOpen(cv_usejoystick[index].value-1); newcontroller = SDL_GameControllerOpen(cv_usejoystick[index].value-1);
@@ -999,17 +1009,27 @@ void I_InitJoystick(UINT8 index)
break; break;
} }
#if (SDL_VERSION_ATLEAST(2,32,4))
JoyInfo[index].id = I_GetJoystickDeviceIndex(JoyInfo[index].dev); JoyInfo[index].id = I_GetJoystickDeviceIndex(JoyInfo[index].dev);
#endif
if (newcontroller && i < MAXSPLITSCREENPLAYERS) // don't override an active device 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; 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) 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 // 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. // 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 else
{ {
+12
View File
@@ -784,7 +784,11 @@ static void Impl_HandleControllerAxisEvent(SDL_ControllerAxisEvent evt)
// Determine the Joystick IDs for each current open joystick // Determine the Joystick IDs for each current open joystick
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{ {
#if (SDL_VERSION_ATLEAST(2,32,4))
if (evt.which == JoyInfo[i].id) if (evt.which == JoyInfo[i].id)
#else
if (evt.which == SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(JoyInfo[i].dev)))
#endif
{ {
event.type = ev_joystick + i; event.type = ev_joystick + i;
break; break;
@@ -844,7 +848,11 @@ static void Impl_HandleControllerHatEvent(SDL_ControllerButtonEvent evt, Uint32
// Determine the Joystick IDs for each current open joystick // Determine the Joystick IDs for each current open joystick
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{ {
#if (SDL_VERSION_ATLEAST(2,32,4))
if (evt.which == JoyInfo[i].id) if (evt.which == JoyInfo[i].id)
#else
if (evt.which == SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(JoyInfo[i].dev)))
#endif
{ {
event.data1 = hat_buttons_base[i]; event.data1 = hat_buttons_base[i];
break; break;
@@ -906,7 +914,11 @@ static void Impl_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint
// Determine the Joystick IDs for each current open joystick // Determine the Joystick IDs for each current open joystick
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{ {
#if (SDL_VERSION_ATLEAST(2,32,4))
if (evt.which == JoyInfo[i].id) if (evt.which == JoyInfo[i].id)
#else
if (evt.which == SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(JoyInfo[i].dev)))
#endif
{ {
event.data1 = buttons_base[i]; event.data1 = buttons_base[i];
break; break;
+1 -1
View File
@@ -1107,7 +1107,7 @@ UINT32 I_GetSongPosition(void)
void I_UpdateSongLagThreshold(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)));
} }
/// ------------------------ /// ------------------------
+4
View File
@@ -23,6 +23,8 @@
extern "C" { extern "C" {
#endif #endif
#include "SDL_version.h"
#include "../m_fixed.h" #include "../m_fixed.h"
// SDL2 stub macro // SDL2 stub macro
@@ -39,8 +41,10 @@ typedef struct SDLJoyInfo_s
{ {
/// Controller handle /// Controller handle
SDL_GameController *dev; SDL_GameController *dev;
#if (SDL_VERSION_ATLEAST(2,32,4))
/// Controller index /// Controller index
INT32 id; INT32 id;
#endif
/// number of old joystick /// number of old joystick
int oldjoy; int oldjoy;
/// number of axies /// number of axies
+10 -10
View File
@@ -465,7 +465,7 @@ void V_CubeApply(RGBA_t *input)
if (!Cubeapply) if (!Cubeapply)
return; return;
linear = ((*input).s.red/255.0); linear = ((*input).s.red/255.0f);
#define dolerp(e1, e2) ((1 - linear)*e1 + linear*e2) #define dolerp(e1, e2) ((1 - linear)*e1 + linear*e2)
for (q = 0; q < 3; q++) 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]); 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++) for (q = 0; q < 3; q++)
{ {
working[0][q] = dolerp(working[0][q], working[1][q]); working[0][q] = dolerp(working[0][q], working[1][q]);
working[1][q] = dolerp(working[2][q], working[3][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++) for (q = 0; q < 3; q++)
{ {
working[0][q] = 255*dolerp(working[0][q], working[1][q]); working[0][q] = 255*dolerp(working[0][q], working[1][q]);
if (working[0][q] > 255.0f) if (working[0][q] > 255.0f)
working[0][q] = 255.0f; working[0][q] = 255.0f;
else if (working[0][q] < 0.0f) else if (working[0][q] < 0.0f)
working[0][q] = 0.0; working[0][q] = 0.0f;
} }
#undef dolerp #undef dolerp
@@ -1760,17 +1760,15 @@ void V_DrawVhsEffect(boolean rewind)
if (cv_reducevfx.value) if (cv_reducevfx.value)
return; return;
const INT32 dup = min(vid.width / BASEVIDWIDTH, vid.height / BASEVIDHEIGHT); barsize = vid.udup << 5;
updistort = vid.udup << (rewind ? 5 : 3);
barsize = dup << 5;
updistort = dup << (rewind ? 5 : 3);
downdistort = updistort >> 1; downdistort = updistort >> 1;
if (rewind) if (rewind)
V_DrawVhsEffect(false); // experimentation V_DrawVhsEffect(false); // experimentation
upbary -= renderdeltatics * (fixed_t)(dup * (rewind ? 3 : 1.8f)); upbary -= renderdeltatics * (fixed_t)(vid.udup * (rewind ? 3 : 1.8f));
downbary += renderdeltatics * (dup * (rewind ? 2 : 1)); downbary += renderdeltatics * (vid.udup * (rewind ? 2 : 1));
if (upbary < -barsize*FRACUNIT) if (upbary < -barsize*FRACUNIT)
upbary = vid.height << FRACBITS; upbary = vid.height << FRACBITS;
@@ -3930,6 +3928,8 @@ void V_Recalc(void)
vid.fdup = (vid.height*FRACUNIT) / BASEVIDHEIGHT; 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: 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 && (vid.width > 720) && (vid.height > 1280)) // ehhhh well this thing has so many issues, so ill lock it to higher resolutions instead
{ {