Compare commits

..
1 Commits
Author SHA1 Message Date
Alug 813ed67211 fix windoze compile 2026-01-21 21:11:57 +01:00
37 changed files with 304 additions and 463 deletions

No files matched your search

+26 -28
View File
@@ -1,9 +1,4 @@
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
@@ -16,31 +11,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
set(CMAKE_C_EXTENSIONS ON)
##### 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()
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()
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/")
@@ -128,12 +102,14 @@ 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)
@@ -142,3 +118,25 @@ 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)
+2 -3
View File
@@ -1,6 +1,6 @@
include(LibFindMacros)
libfind_pkg_check_modules(GME_PKGCONF LIBGME)
libfind_pkg_check_modules(GME_PKGCONF GME)
find_path(GME_INCLUDE_DIR
NAMES gme.h
@@ -8,7 +8,6 @@ find_path(GME_INCLUDE_DIR
${GME_PKGCONF_INCLUDE_DIRS}
"/usr/include/gme"
"/usr/local/include/gme"
PATH_SUFFIXES gme
)
find_library(GME_LIBRARY
@@ -21,4 +20,4 @@ find_library(GME_LIBRARY
set(GME_PROCESS_INCLUDES GME_INCLUDE_DIR)
set(GME_PROCESS_LIBS GME_LIBRARY)
libfind_process(GME)
libfind_process(GME)
+2 -3
View File
@@ -1,6 +1,6 @@
include(LibFindMacros)
libfind_pkg_check_modules(OPENMPT_PKGCONF LIBOPENMPT)
libfind_pkg_check_modules(OPENMPT_PKGCONF OPENMPT)
find_path(OPENMPT_INCLUDE_DIR
NAMES libopenmpt.h
@@ -8,7 +8,6 @@ find_path(OPENMPT_INCLUDE_DIR
${OPENMPT_PKGCONF_INCLUDE_DIRS}
"/usr/include/libopenmpt"
"/usr/local/include/libopenmpt"
PATH_SUFFIXES libopenmpt
)
find_library(OPENMPT_LIBRARY
@@ -21,4 +20,4 @@ find_library(OPENMPT_LIBRARY
set(OPENMPT_PROCESS_INCLUDES OPENMPT_INCLUDE_DIR)
set(OPENMPT_PROCESS_LIBS OPENMPT_LIBRARY)
libfind_process(OPENMPT)
libfind_process(OPENMPT)
+18 -37
View File
@@ -1,4 +1,4 @@
# Version 2.4
# Version 2.2
# 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,10 +52,6 @@ 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.
@@ -129,39 +125,24 @@ function (libfind_process PREFIX)
# Process deps to add to
foreach (i ${PREFIX} ${${PREFIX}_DEPENDENCIES})
if (DEFINED ${i}_INCLUDE_OPTS)
if (DEFINED ${i}_INCLUDE_OPTS OR DEFINED ${i}_LIBRARY_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 (DEFINED ${i}_LIBRARY)
# 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))
# Singular forms can be used
list(APPEND libraryopts ${i}_LIBRARY)
else()
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!")
if (DEFINED ${i}_INCLUDE_DIR)
list(APPEND includeopts ${i}_INCLUDE_DIR)
endif()
if (DEFINED ${i}_LIBRARY)
list(APPEND libraryopts ${i}_LIBRARY)
endif()
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!")
endif()
endif()
endforeach()
@@ -228,12 +209,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()
+7 -18
View File
@@ -236,23 +236,18 @@ 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_SCREENFBO ON CACHE BOOL
"Enable hardware renderer (OpenGL) FBO downsampling support")
set(SRB2_CONFIG_LIBBACKTRACE ON CACHE BOOL
"Enable using libbacktrace for crashlogs")
if(${SRB2_CONFIG_DEDICATED})
set(SRB2_CONFIG_HAVE_GME NO)
@@ -507,6 +502,7 @@ 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()
@@ -554,6 +550,7 @@ 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})
@@ -592,14 +589,6 @@ 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
-2
View File
@@ -907,9 +907,7 @@ void D_ClearState(void)
// okay, stop now
// (otherwise the game still thinks we're playing!)
#ifdef HAVE_CURL
CURLAbortFile();
#endif
SV_StopServer();
SV_ResetServer();
+1 -3
View File
@@ -1009,9 +1009,6 @@ 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);
@@ -2658,6 +2655,7 @@ static void Command_Map_f(void)
return;
}
last_map_cmd = I_GetTime();
size_t first_option;
+22 -93
View File
@@ -1,75 +1,21 @@
# Declare dedicated interface sources
set(SRB2_DEDICATED_SOURCES
i_system.c
i_main.c
i_video.c
i_sound.c
i_threads.c
dosstr.c
endtxt.c
)
target_sourcefile(c)
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})
target_sources(SRB2SDL2 PRIVATE)
if(${CMAKE_SYSTEM} MATCHES Windows)
set(SRB2_DEDICATED_TOTAL_SOURCES ${SRB2_DEDICATED_TOTAL_SOURCES}
${CMAKE_SOURCE_DIR}/src/win32/win_dbg.c
${CMAKE_SOURCE_DIR}/src/win32/Srb2win.rc
)
target_sources(SRB2SDL2 PRIVATE
../win32/win_dbg.c
../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 srb2kartd)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2legacy)
elseif(${CMAKE_SYSTEM} MATCHES Linux)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME lsrb2kartd)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME lsrb2dlegacy)
else()
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"
)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2legacy)
endif()
if(${CMAKE_SYSTEM} MATCHES Darwin)
@@ -78,27 +24,25 @@ 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()
if(${SRB2_HAVE_LIBBACKTRACE})
target_link_libraries(SRB2SDL2 PRIVATE ${LIBBACKTRACE_LIBRARIES})
endif()
#target_link_libraries(SRB2SDL2 PRIVATE SRB2Core)
set_target_properties(SRB2SDL2 PROPERTIES VERSION ${SRB2_VERSION})
if(${CMAKE_SYSTEM} MATCHES Windows)
target_link_libraries(SRB2SDL2 PRIVATE
@@ -116,34 +60,19 @@ target_include_directories(SRB2SDL2 PRIVATE
target_compile_definitions(SRB2SDL2 PRIVATE
-DDEDICATED
-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)
# 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()
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)
+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}};
consvar_t cv_autoaccel[MAXSPLITSCREENPLAYERS] = {
{"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}
{"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}
};
static CV_PossibleValue_t driftsparkpulse_t[] = {{0, "MIN"}, {FRACUNIT*3, "MAX"}, {0, NULL}};
+2 -5
View File
@@ -81,9 +81,6 @@ 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)
@@ -933,7 +930,7 @@ void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT8 color)
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS);
if (cv_gamepadled[playernum].value == 0 || (window_notinfocus && cv_gamepadledifunfocused.value == 0)
if (cv_gamepadled[playernum].value == 0
|| color >= MAXTRANSLATIONS)
{
return;
@@ -1012,7 +1009,7 @@ void G_PlayerDeviceRumble(INT32 playernum, UINT16 low_strength, UINT16 high_stre
{
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS);
if (cv_rumble[playernum].value == 0 || (window_notinfocus && cv_rumbleifunfocused.value == 0))
if (cv_rumble[playernum].value == 0)
{
return;
}
-3
View File
@@ -116,9 +116,6 @@ 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];
+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;
if (floatangle >= 180.0)
return 0xffffffff;
a1 = (angle_t)lrint(ANG1 * floatangle);
a1 = (angle_t)xs_CRoundToInt(ANG1 * floatangle);
return a1;
}
+1 -1
View File
@@ -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.125f; // splitscreen adjusts fov with 0.8, so compensate (but only halfway, since splitscreen means only half the screen is used)
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->shearing = true;
gl_aimingangle = 0;
}
+1 -1
View File
@@ -579,7 +579,7 @@ md2found:
fclose(f);
}
void HWR_AddPlayerMD2(INT32 skin, boolean local) // For MD2's that were added after startup
void HWR_AddPlayerMD2(int skin, boolean local) // For MD2's that were added after startup
{
FILE *f;
char name[20], filename[32];
+16 -26
View File
@@ -3591,30 +3591,22 @@ 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]);
uint32_t r = rand();
const float stride = 2.f/scrwh;
const float ystep = 2.f/scrwh * (float)vid.udup/4.f;
for (i = 0; i < 1; i += ystep)
for (i = 0; i < 1; i += stride)
{
// avoid calling rand thousands of times
r ^= r >> 13;
r ^= r >> 11;
r ^= r << 21;
fix[2] = (float)(r & 127) / -22000.f * xfix;
fix[2] = (float)(rand() % 128) / -22000.f * xfix;
fix[0] = fix[2];
fix[6] = fix[0] + xfix;
fix[4] = fix[2] + xfix;
@@ -3632,8 +3624,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;
@@ -3656,14 +3648,13 @@ 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;
@@ -3682,7 +3673,6 @@ 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);
@@ -3722,7 +3712,7 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh
{
float xfix, yfix;
float origaspect, newaspect;
float xoff = 1.0f, yoff = 1.0f; // xoffset and yoffset for the polygon to have black bars around the screen
float xoff = 1, yoff = 1; // xoffset and yoffset for the polygon to have black bars around the screen
static float off[12] =
{
@@ -3745,19 +3735,19 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh
if (origaspect < newaspect)
{
xoff = origaspect / newaspect;
yoff = 1.0f;
yoff = 1;
}
else if (origaspect > newaspect)
{
xoff = 1.0f;
xoff = 1;
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;
+4 -11
View File
@@ -1484,7 +1484,6 @@ static char *CHAT_WordWrap(INT32 x, INT32 w, INT32 option, const char *string)
x = 0;
}
}
return newstring;
}
@@ -1523,7 +1522,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
{
@@ -1555,17 +1554,14 @@ 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;
@@ -1602,7 +1598,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
{
@@ -1647,14 +1643,12 @@ static void HU_drawMiniChat(void)
dx += charwidth;
prev_linereturn = false;
if (dx >= boxw)
{
dx = 0;
dy += charheight;
}
}
dy += charheight;
dx = 0;
if (msg)
@@ -1710,7 +1704,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;
@@ -1719,7 +1713,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
{
@@ -1764,7 +1758,6 @@ static void HU_drawChatLog(INT32 offset)
dy += charheight;
}
}
dy += charheight;
dx = 0;
if (msg)
-1
View File
@@ -1293,7 +1293,6 @@ 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
View File
@@ -25,7 +25,7 @@
#include "lua_hook.h" // cmd errors
boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor);
state_t *astate = NULL;
state_t *astate;
boolean actionsoverridden[NUMACTIONS] = {false};
+21 -18
View File
@@ -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,8 +66,12 @@ static lua_CFunction liblist[] = {
static void *LUA_Alloc(void *ud, void *ptr, size_t osize, size_t nsize)
{
(void)ud;
(void)osize;
return Z_Realloc(ptr, nsize, PU_LUA, NULL);
if (nsize == 0) {
if (osize != 0)
Z_Free(ptr);
return NULL;
} else
return Z_Realloc(ptr, nsize, PU_LUA, NULL);
}
// Panic function Lua calls when there's an unprotected error.
@@ -209,8 +213,7 @@ 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
View File
@@ -301,7 +301,7 @@ void Command_CheatNoTarget_f(void)
void Command_Scale_f(void)
{
const double scaled = atof(COM_Argv(1));
fixed_t scale = DoubleToFixed(scaled);
fixed_t scale = FLOAT_TO_FIXED(scaled);
REQUIRE_DEVMODE;
REQUIRE_INLEVEL;
+29 -9
View File
@@ -20,7 +20,6 @@ extern "C" {
#endif
#include "doomtype.h"
#ifdef __GNUC__
#include <stdlib.h>
#endif
@@ -72,14 +71,6 @@ 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
@@ -274,6 +265,35 @@ 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
View File
@@ -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, max((((scaledviewheight-80) * (scaledviewheight-80))-1) / y - 1, 1), V_SNAPTOTOP|V_SNAPTORIGHT|229);
V_DrawFill(BASEVIDWIDTH-3, 76 + (scaledviewheight-80) * replayhutmenuy / y, 2, (((scaledviewheight-80) * (scaledviewheight-80))-1) / y - 1, V_SNAPTOTOP|V_SNAPTORIGHT|229);
}
// Draw the cursor
-6
View File
@@ -1205,10 +1205,6 @@ 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[] =
@@ -1220,8 +1216,6 @@ 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
View File
@@ -540,7 +540,7 @@ static boolean M_BackupConfig(const char *filename)
void M_SaveConfig(const char *filename)
{
FILE *f;
CLEANUP(Z_Pfree) char *filepath = NULL;
char *filepath;
// 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 = Z_StrDup(va(pandf, srb2home, filename));
filepath = va(pandf,srb2home, filename);
else
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));
// Try to narrow the search to within only the field of view
*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;
*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;
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 = abs(i - viewheight*8) << FRACBITS;
dy = FixedMul(dy, fovtan);
fixed_t dy = (i - viewheight*8)<<FRACBITS;
dy = FixedMul(abs(dy), fovtan);
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)
{
const fixed_t absx = FixedClamp(labs((INT64)x - (INT64)x1));
const fixed_t absy = FixedClamp(labs((INT64)y - (INT64)y1));
const fixed_t absx = abs(x - x1);
const fixed_t absy = abs(y - y1);
#ifdef __cplusplus
return std::max<fixed_t>(absx, absy);
#else
+12 -15
View File
@@ -57,11 +57,8 @@ visffloor_t visffloor[MAXFFLOORS] = {};
INT32 numffloors = 0;
//SoM: 3/23/2000: Boom visplane hashing routine.
constexpr unsigned int visplane_hash(const unsigned int picnum, const unsigned int lightlevel,
const unsigned int height)
{
return ((picnum * 3) + lightlevel + (height * 7)) & VISPLANEHASHMASK;
}
#define visplane_hash(picnum,lightlevel,height) \
((unsigned)((picnum)*3+(lightlevel)+(height)*7) & VISPLANEHASHMASK)
//
// Clip values are the solid pixel bounding the range.
@@ -139,7 +136,7 @@ void R_AllocPlaneMemory(void)
}
yslopetab = static_cast<fixed_t*>(Z_Realloc(yslopetab, sizeof(*yslopetab) * (viewheight * 16), PU_STATIC, NULL));
spanstart = static_cast<INT32*>(Z_Realloc(spanstart, sizeof(*spanstart) * viewheight, PU_STATIC, NULL));
spanstart = static_cast<fixed_t*>(Z_Realloc(spanstart, sizeof(*spanstart) * viewheight, PU_STATIC, NULL));
}
//
@@ -228,8 +225,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 = 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);
ds->xfrac = ds->xoffs + FixedMul(planecos, distance) + (x1 - centerx) * ds->xstep;
ds->yfrac = ds->yoffs - FixedMul(planesin, distance) + (x1 - centerx) * ds->ystep;
if (ds->planeripple.active)
{
@@ -454,7 +451,7 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
}
}
hash = visplane_hash(picnum, lightlevel, height >> FRACBITS);
hash = visplane_hash(picnum, lightlevel, height);
for (check = visplanes[hash]; check; check = check->next)
{
@@ -565,7 +562,7 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop)
}
else
{
unsigned hash = visplane_hash(pl->picnum, pl->lightlevel, pl->height >> FRACBITS);
unsigned hash = visplane_hash(pl->picnum, pl->lightlevel, pl->height);
new_pl = new_visplane(hash);
}
@@ -923,12 +920,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 = cosf(ang);
m->z = sinf(ang);
m->x = cos(ang);
m->z = sin(ang);
// n is the u direction vector in view space
n->x = sinf(ang);
n->z = -cosf(ang);
n->x = sin(ang);
n->z = -cos(ang);
plangle >>= ANGLETOFINESHIFT;
temp = P_GetSlopeZAt(slope, xpos + FINESINE(plangle), ypos + FINECOSINE(plangle));
@@ -1012,7 +1009,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
+3 -2
View File
@@ -246,6 +246,7 @@ 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
@@ -312,8 +313,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)
+92 -81
View File
@@ -226,11 +226,10 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
leftheight -= viewz;
rightheight -= viewz;
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->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->lightlevel = *light->lightlevel;
rlight->extra_colormap = light->extra_colormap;
rlight->flags = static_cast<ffloortype_e>(light->flags);
@@ -342,7 +341,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 = FixedClamp((INT64)rlight->height + rlight->heightstep);
rlight->height += rlight->heightstep;
}
}
@@ -356,9 +355,9 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
lighttable_t **xwalllights;
sprbotscreen = INT32_MAX;
sprtopscreen = windowtop = FixedClamp((INT64)centeryfrac - FixedMul(dc->texturemid, spryscale));
sprtopscreen = windowtop = (centeryfrac - FixedMul(dc->texturemid, spryscale));
realbot = windowbottom = FixedClamp((INT64)FixedMul(textureheight[texnum], spryscale) + sprtopscreen);
realbot = windowbottom = FixedMul(textureheight[texnum], spryscale) + sprtopscreen;
dc->iscale = 0xffffffffu / (unsigned)spryscale;
// draw the texture
@@ -408,8 +407,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
set_light_vars(i);
height = rlight->height;
rlight->height = FixedClamp((INT64)rlight->height + rlight->heightstep);
rlight->height += rlight->heightstep;
if (height <= windowtop)
{
@@ -425,7 +423,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
for (i++; i < dc->numlights; i++)
{
rlight = &dc->lightlist[i];
rlight->height = FixedClamp((INT64)rlight->height + rlight->heightstep);
rlight->height += rlight->heightstep;
}
continue;
@@ -457,7 +455,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 = FixedClamp((INT64)centeryfrac - FixedMul(dc->texturemid, spryscale));
sprtopscreen = centeryfrac - FixedMul(dc->texturemid, spryscale);
dc->iscale = 0xffffffffu / (unsigned)spryscale;
// draw the texture
@@ -712,6 +710,17 @@ 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)
{
@@ -727,6 +736,7 @@ 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];
@@ -750,14 +760,17 @@ 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.
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)leftheight*drawseg->scale1)>>FRACBITS);
rlight->height = overflow_clamp(overflow_test);
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)
@@ -768,9 +781,13 @@ 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.
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);
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->lightlevel = *light->lightlevel;
@@ -879,10 +896,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 = 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_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_step = (top_step-top_frac)/(range);
bottom_step = (bottom_step-bottom_frac)/(range);
@@ -904,8 +921,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 = top_frac;
sprbotscreen = windowbottom = bottom_frac;
sprtopscreen = windowtop = overflow_clamp(top_frac);
sprbotscreen = windowbottom = overflow_clamp(bottom_frac);
top_frac += top_step;
bottom_frac += bottom_step;
@@ -918,11 +935,9 @@ 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 = FixedClamp((INT64)rlight->height + rlight->heightstep);
rlight->height += rlight->heightstep;
if (rlight->flags & FF_CUTLEVEL)
rlight->botheight = FixedClamp((INT64)rlight->botheight + rlight->botheightstep);
rlight->botheight += rlight->botheightstep;
}
}
@@ -1030,12 +1045,12 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf
solid = 0;
height = rlight->height;
rlight->height = FixedClamp((INT64)rlight->height + rlight->heightstep);
rlight->height += rlight->heightstep;
if (solid)
{
bheight = FixedClamp((INT64)rlight->botheight - (FRACUNIT >> 1));
rlight->botheight = FixedClamp((INT64)rlight->botheight + rlight->botheightstep);
bheight = rlight->botheight - (FRACUNIT >> 1);
rlight->botheight += rlight->botheightstep;
}
if (height <= windowtop)
@@ -1063,7 +1078,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 = FixedClamp((INT64)rlight->height + rlight->heightstep);
rlight->height += rlight->heightstep;
if (rlight->flags & FF_CUTLEVEL)
rlight->botheight += rlight->botheightstep;
@@ -1197,7 +1212,7 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
for (; rw_x < rw_stopx; rw_x++)
{
// mark floor / ceiling areas
yl = FixedClamp((INT64)topfrac + HEIGHTUNIT-1)>>HEIGHTBITS;
yl = (topfrac+HEIGHTUNIT-1)>>HEIGHTBITS;
yh = bottomfrac>>HEIGHTBITS;
// Mark ceiling
@@ -1348,17 +1363,15 @@ 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 = FixedClamp((INT64)rw_offset - FixedMul(FINETANGENT(angle & 4095), rw_distance));
texturecolumn = rw_offset-FixedMul(FINETANGENT(angle & 4095), rw_distance);
if (oldtexturecolumn != -1)
{
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);
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);
}
oldtexturecolumn = texturecolumn;
@@ -1368,7 +1381,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];
@@ -1450,8 +1463,8 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
if (toptexture)
{
// top wall
mid = pixhigh >> HEIGHTBITS;
pixhigh = FixedClamp((INT64)pixhigh + pixhighstep);
mid = pixhigh>>HEIGHTBITS;
pixhigh += pixhighstep;
if (mid >= floorclip[rw_x])
mid = floorclip[rw_x]-1;
@@ -1480,8 +1493,8 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
if (bottomtexture)
{
// bottom wall
mid = FixedClamp((INT64)pixlow+HEIGHTUNIT-1)>>HEIGHTBITS;
pixlow = FixedClamp((INT64)pixlow + pixlowstep);
mid = (pixlow+HEIGHTUNIT-1)>>HEIGHTBITS;
pixlow += pixlowstep;
// no space above wall?
if (mid <= ceilingclip[rw_x])
@@ -1532,10 +1545,10 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
{
for (i = 0; i < dc->numlights; i++)
{
dc->lightlist[i].height = FixedClamp((INT64)dc->lightlist[i].height + dc->lightlist[i].heightstep);
dc->lightlist[i].height += dc->lightlist[i].heightstep;
if (dc->lightlist[i].flags & FF_CUTSOLIDS)
dc->lightlist[i].botheight = FixedClamp((INT64)dc->lightlist[i].botheight + dc->lightlist[i].botheightstep);;
dc->lightlist[i].botheight += dc->lightlist[i].botheightstep;
}
}
@@ -1556,10 +1569,9 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
visffloor[i].b_frac += visffloor[i].b_step;
}
rw_scale = FixedClamp((INT64)rw_scale + rw_scalestep);
topfrac = FixedClamp((INT64)topfrac + topstep);
bottomfrac = FixedClamp((INT64)bottomfrac + bottomstep);
rw_scale += rw_scalestep;
topfrac += topstep;
bottomfrac += bottomstep;
}
}
@@ -1573,7 +1585,7 @@ static void R_MarkSegBounds(void)
for (; rw_x < rw_stopx; rw_x++)
{
// mark floor / ceiling areas
yl = FixedClamp((INT64)topfrac + HEIGHTUNIT-1)>>HEIGHTBITS;
yl = (topfrac+HEIGHTUNIT-1)>>HEIGHTBITS;
yh = bottomfrac>>HEIGHTBITS;
// Mark ceiling
@@ -1810,7 +1822,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
// big room fix
if (longboi)
rw_distance = FixedClamp(R_CalcSegDist(curline, viewx, viewy));
rw_distance = (fixed_t)R_CalcSegDist(curline,viewx,viewy);
ds_p->x1 = rw_x = start;
ds_p->x2 = stop;
@@ -2193,8 +2205,8 @@ void R_StoreWallRange(INT32 start, INT32 stop)
}
}
rw_toptexturemid = FixedClamp((INT64)rw_toptexturemid + sidedef->rowoffset);
rw_bottomtexturemid = FixedClamp((INT64)rw_bottomtexturemid + sidedef->rowoffset);
rw_toptexturemid += sidedef->rowoffset;
rw_bottomtexturemid += sidedef->rowoffset;
R_AllocTextureColumnTables(rw_stopx - start);
@@ -2479,9 +2491,8 @@ void R_StoreWallRange(INT32 start, INT32 stop)
rw_offset = -rw_offset;
/// don't use texture offset for splats
rw_offset2 = FixedClamp((INT64)rw_offset + curline->offset);
rw_offset = FixedClamp((INT64)rw_offset + (INT64)sidedef->textureoffset + curline->offset);
rw_offset2 = rw_offset + curline->offset;
rw_offset += sidedef->textureoffset + curline->offset;
rw_centerangle = ANGLE_90 + viewangle - rw_normalangle;
// calculate light table
@@ -2541,8 +2552,8 @@ void R_StoreWallRange(INT32 start, INT32 stop)
auto set_topstep_normal = [&]
{
topstep = -FixedMul(rw_scalestep, worldtop);
topfrac = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldtop, rw_scale));
topstep = -FixedMul (rw_scalestep, worldtop);
topfrac = (centeryfrac>>4) - FixedMul (worldtop, rw_scale);
};
// untextured seg
@@ -2563,14 +2574,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 = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldbottom, rw_scale));
topstep = -FixedMul (rw_scalestep, worldbottom);
topfrac = (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 = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldbottomslope, rw_scale));
topstep = -FixedMul (rw_scalestep, worldbottomslope);
topfrac = (centeryfrac>>4) - FixedMul (worldbottomslope, rw_scale);
}
}
else
@@ -2579,18 +2590,18 @@ void R_StoreWallRange(INT32 start, INT32 stop)
else
set_topstep_normal();
bottomstep = -FixedMul(rw_scalestep, worldbottom);
bottomfrac = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldbottom, rw_scale));
bottomstep = -FixedMul (rw_scalestep, worldbottom);
bottomfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale);
if (frontsector->c_slope)
{
fixed_t topfracend = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldtopslope, ds_p->scale2));
fixed_t topfracend = (centeryfrac>>4) - FixedMul (worldtopslope, ds_p->scale2);
topstep = (topfracend-topfrac)/(range);
}
if (frontsector->f_slope)
{
fixed_t bottomfracend = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldbottomslope, ds_p->scale2));
fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldbottomslope, ds_p->scale2);
bottomstep = (bottomfracend-bottomfrac)/(range);
}
}
@@ -2632,9 +2643,9 @@ void R_StoreWallRange(INT32 start, INT32 stop)
continue;
}
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->height = (centeryfrac>>4) - FixedMul(leftheight, rw_scale);
rlight->heightstep = (centeryfrac>>4) - FixedMul(rightheight, ds_p->scale2);
rlight->heightstep = (rlight->heightstep-rlight->height)/(range);
rlight->flags = static_cast<ffloortype_e>(light->flags);
if (light->caster && light->caster->flags & FF_CUTSOLIDS)
@@ -2696,9 +2707,9 @@ void R_StoreWallRange(INT32 start, INT32 stop)
if (toptexture)
{
fixed_t topfracend = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldhighslope, ds_p->scale2));
fixed_t topfracend = (centeryfrac>>4) - FixedMul(worldhighslope, ds_p->scale2);
pixhigh = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldhigh, rw_scale));
pixhigh = (centeryfrac>>4) - FixedMul (worldhigh, rw_scale);
pixhighstep = (topfracend-pixhigh)/(range);
// If the lowest part of a ceiling stretching down covers the entire screen
@@ -2708,9 +2719,9 @@ void R_StoreWallRange(INT32 start, INT32 stop)
if (bottomtexture)
{
fixed_t bottomfracend = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldlowslope, ds_p->scale2));
fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldlowslope, ds_p->scale2);
pixlow = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldlow, rw_scale));
pixlow = (centeryfrac>>4) - FixedMul (worldlow, rw_scale);
pixlowstep = (bottomfracend-pixlow)/(range);
// If the highest part of a floor stretching up covers the entire screen
@@ -2731,8 +2742,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 = 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_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_step = (visffloor[i].b_step-visffloor[i].b_frac)/(range);
};
@@ -2838,7 +2849,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 = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(visffloor[i].b_pos, rw_scale));
visffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(visffloor[i].b_pos, rw_scale);
};
while (i < numffloors && visffloor[i].polyobj != curline->polyseg)
@@ -2869,7 +2880,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;
@@ -2883,7 +2894,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;
+7 -9
View File
@@ -11,7 +11,6 @@
/// \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"
@@ -71,7 +70,7 @@ INT16 *screenheightarray = NULL;
typedef struct drawseg_xrange_item_s
{
INT32 x1, x2;
INT16 x1, x2;
drawseg_t *user;
} drawseg_xrange_item_t;
@@ -490,8 +489,8 @@ void R_InitSprites(void)
for (angle = 1; angle < ROTANGLES; angle++)
{
fa = ANG2RAD(FixedAngle((ROTANGDIFF * angle)<<FRACBITS));
rollcosang[angle] = FLOAT_TO_FIXED(cosf(-fa));
rollsinang[angle] = FLOAT_TO_FIXED(sinf(-fa));
rollcosang[angle] = FLOAT_TO_FIXED(cos(-fa));
rollsinang[angle] = FLOAT_TO_FIXED(sin(-fa));
}
#endif
@@ -617,11 +616,10 @@ 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;
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->yl = (topscreen+FRACUNIT-1)>>FRACBITS;
dc->yh = (bottomscreen-1)>>FRACBITS;
if (windowtop != INT32_MAX && windowbottom != INT32_MAX)
@@ -887,7 +885,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 = FixedClamp((INT64)vis->paperoffset - FixedMul(FINETANGENT(angle), vis->paperdistance)) / horzscale;
texturecolumn = (vis->paperoffset - FixedMul(FINETANGENT(angle), vis->paperdistance)) / horzscale;
if (texturecolumn < 0 || texturecolumn >= pwidth)
continue;
-1
View File
@@ -63,7 +63,6 @@ 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
+2 -15
View File
@@ -169,6 +169,7 @@ if(${SDL2_FOUND})
target_link_libraries(SRB2SDL2 PRIVATE ${LIBBACKTRACE_LIBRARIES})
endif()
if(${CMAKE_SYSTEM} MATCHES Linux)
target_link_libraries(SRB2SDL2 PRIVATE
m
@@ -229,20 +230,6 @@ 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)
@@ -309,7 +296,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})
+7 -27
View File
@@ -726,9 +726,7 @@ 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
@@ -785,11 +783,7 @@ 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
{
@@ -891,13 +885,13 @@ static int joy_open(int playerIndex, int joyIndex)
if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0)
{
CONS_Printf("Joystick subsystem not started\n");
CONS_Printf(M_GetText("Joystick subsystem not started\n"));
return -1;
}
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == 0)
{
CONS_Printf("Game Controller subsystem not started\n");
CONS_Printf(M_GetText("Game Controller subsystem not started\n"));
return -1;
}
@@ -908,7 +902,7 @@ static int joy_open(int playerIndex, int joyIndex)
if (num_joy == 0)
{
CONS_Printf("%s", "Found no joysticks on this system\n");
CONS_Printf("%s", M_GetText("Found no joysticks on this system\n"));
return -1;
}
@@ -931,7 +925,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, "Joystick %d device is changing; resetting events...\n", playerIndex+1);
CONS_Debug(DBG_GAMELOGIC, "Joystick1 device is changing; resetting events...\n");
I_ShutdownJoystick(playerIndex);
}
@@ -939,15 +933,13 @@ static int joy_open(int playerIndex, int joyIndex)
if (JoyInfo[playerIndex].dev == NULL)
{
CONS_Debug(DBG_GAMELOGIC, "Joystick %d: Couldn't open device - %s\n", playerIndex+1, SDL_GetError());
CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: Couldn't open device - %s\n"), SDL_GetError());
return -1;
}
CONS_Debug(DBG_GAMELOGIC, "Joystick %d: %s\n", playerIndex+1, SDL_GameControllerName(JoyInfo[playerIndex].dev));
CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: %s\n"), 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;
}
@@ -993,9 +985,7 @@ 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);
@@ -1009,27 +999,17 @@ 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 = I_GetJoystickDeviceIndex(JoyInfo[index].dev) + 1;
#endif
JoyInfo[index].oldjoy = JoyInfo[index].id + 1;
}
else
{
-12
View File
@@ -784,11 +784,7 @@ 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;
@@ -848,11 +844,7 @@ 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;
@@ -914,11 +906,7 @@ 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;
+1 -1
View File
@@ -1107,7 +1107,7 @@ UINT32 I_GetSongPosition(void)
void I_UpdateSongLagThreshold(void)
{
stutter_threshold = (UINT32)(cv_music_resync_powerups_only.value ? 0 : (cv_music_resync_threshold.value/1000.0*(4*44100)));
stutter_threshold = cv_music_resync_powerups_only.value ? 0 : (cv_music_resync_threshold.value/1000.0*(4*44100));
}
/// ------------------------
-4
View File
@@ -23,8 +23,6 @@
extern "C" {
#endif
#include "SDL_version.h"
#include "../m_fixed.h"
// SDL2 stub macro
@@ -41,10 +39,8 @@ 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
View File
@@ -465,7 +465,7 @@ void V_CubeApply(RGBA_t *input)
if (!Cubeapply)
return;
linear = ((*input).s.red/255.0f);
linear = ((*input).s.red/255.0);
#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.0f);
linear = ((*input).s.green/255.0);
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.0f);
linear = ((*input).s.blue/255.0);
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.0f;
working[0][q] = 0.0;
}
#undef dolerp
@@ -1760,15 +1760,17 @@ void V_DrawVhsEffect(boolean rewind)
if (cv_reducevfx.value)
return;
barsize = vid.udup << 5;
updistort = vid.udup << (rewind ? 5 : 3);
const INT32 dup = min(vid.width / BASEVIDWIDTH, vid.height / BASEVIDHEIGHT);
barsize = dup << 5;
updistort = dup << (rewind ? 5 : 3);
downdistort = updistort >> 1;
if (rewind)
V_DrawVhsEffect(false); // experimentation
upbary -= renderdeltatics * (fixed_t)(vid.udup * (rewind ? 3 : 1.8f));
downbary += renderdeltatics * (vid.udup * (rewind ? 2 : 1));
upbary -= renderdeltatics * (fixed_t)(dup * (rewind ? 3 : 1.8f));
downbary += renderdeltatics * (dup * (rewind ? 2 : 1));
if (upbary < -barsize*FRACUNIT)
upbary = vid.height << FRACBITS;
@@ -3928,8 +3930,6 @@ 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
{