Compare commits

..
Author SHA1 Message Date
Alug 9dd38ec75e Merge branch 'Saturn-Next' into fixceemake 2025-12-26 21:47:34 +01:00
Alug c0775ff87b Merge pull request #214 from P-AS/fixceeemake
Fix the fixceemake branch for macOS CMake (and aarch64 Linux too)
2025-11-22 18:48:21 +01:00
cobalt2727 04e649d716 fix ARM builds being completely broken
If merged, this is the quickest approach to resolve https://github.com/STJr/SRB2/issues/513

...alternatively, we could just remove the option altogether but I don't have the time right now to test whether it's needed or not

To the best of my knowledge, this covers all possible amd64 `CMAKE_SYSTEM_PROCESSOR` values based on what I'm seeing at https://stackoverflow.com/questions/70475665/what-are-the-possible-values-of-cmake-system-processor
2025-11-21 00:55:56 -05:00
PAS ee31cc1722 Fix macOS/CMake build
Moved C++ includes out of extern "C" blocks
Added missing algorithm includes
Disabled threads on macOS, since macOS doesn't support C11 threads.h
Added extern "C" blocks to src/sdl/macosx/mac_resources.h and src/p_tick.h
Added #ifdef HAVE_THREADS guard to src/sdl/i_threads.c
Removed mac_alert code while I'm at it, since it's obsolete in SDL2
2025-11-18 12:47:40 -05:00
Alug 7657858407 CMAKE:fixup bunch of stuff
- Add saturnpak, saturnjoin, screenfbo settings
- Add libbacktrace stuff (hope thats correct)
- set openmpt, discordrpc and libbacktrace as optional libs
- move asset hashes to d_main, fixing CMAKECONFIG (which fixes commit stuff)
- propely handle md5 sources
- set "-rdynamic" and "-g" (-g1 on non debug builds) so libbacktrace can get proper backtraces
2025-11-14 06:00:43 +01:00
Alug 8af93e5f26 our windoze lib directory is libs not thirdparty 2025-11-13 20:06:25 +01:00
Alug fb640821c0 copy pa- uuhh port blankarts cmake build stuff
it actually compiles an executable that even starts!!!
TODO:
- fix windoze lib stuff, we dont use cpm
- fix git commit related stuff (shows just "illegal" on titlescreen)
- readd saturn specific things like saturnpak, fbo etc
- fix  CMAKECONFIG
2025-11-13 19:54:36 +01:00
97 changed files with 1692 additions and 2404 deletions

No files matched your search

+144 -72
View File
@@ -1,20 +1,25 @@
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) if("${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.") message(FATAL_ERROR "In-source builds are blocked. Please build from a separate directory.")
endif() endif()
# Set up CMAKE path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
include(CMakeDependentOption)
#include(cmake/CPM.cmake)
# 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
VERSION 1.6 VERSION 1.6
LANGUAGES C CXX) LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17) if(APPLE)
set(CMAKE_CXX_STANDARD_REQUIRED ON) # DiscordRPC needs but does not properly specify ObjC
#set(CMAKE_CXX_EXTENSIONS OFF) # optional but recommended: disables GNU extensions, forces pure ISO C++ enable_language(OBJC)
set(CMAKE_CXX_EXTENSIONS ON) endif()
set(CMAKE_C_EXTENSIONS ON)
##### PACKAGE CONFIGURATION ##### ##### PACKAGE CONFIGURATION #####
@@ -31,7 +36,7 @@ if("${SRB2_CPACK_GENERATOR}" STREQUAL "")
endif() endif()
set(CPACK_GENERATOR ${SRB2_CPACK_GENERATOR}) 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_DESCRIPTION_SUMMARY "SRB2Kart" CACHE STRING "Program name for display purposes")
set(CPACK_PACKAGE_VENDOR "Kart Krew" CACHE STRING "Vendor name for display purposes") set(CPACK_PACKAGE_VENDOR "Kart Krew" CACHE STRING "Vendor name for display purposes")
#set(CPACK_PACKAGE_DESCRIPTION_FILE ) #set(CPACK_PACKAGE_DESCRIPTION_FILE )
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
@@ -39,54 +44,125 @@ set(CPACK_PACKAGE_VERSION_MAJOR ${SRB2_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${SRB2_VERSION_MINOR}) set(CPACK_PACKAGE_VERSION_MINOR ${SRB2_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${SRB2_VERSION_PATCH}) set(CPACK_PACKAGE_VERSION_PATCH ${SRB2_VERSION_PATCH})
set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}") set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}")
SET(CPACK_OUTPUT_FILE_PREFIX package)
include(CPack) include(CPack)
# Set up CMAKE path # Options
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
### Useful functions if("${CMAKE_SYSTEM_NAME}" MATCHES Linux)
set(SRB2_CONFIG_SYSTEM_LIBRARIES_DEFAULT ON)
else()
set(SRB2_CONFIG_SYSTEM_LIBRARIES_DEFAULT OFF)
endif()
# Prepend sources with current source directory option(
function(prepend_sources SOURCE_FILES) SRB2_CONFIG_SYSTEM_LIBRARIES
foreach(SOURCE_FILE ${${SOURCE_FILES}}) "Link dependencies using CMake's find_package and do not use internal builds"
set(MODIFIED ${MODIFIED} ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_FILE}) ${SRB2_CONFIG_SYSTEM_LIBRARIES_DEFAULT}
endforeach() )
set(${SOURCE_FILES} ${MODIFIED} PARENT_SCOPE) option(SRB2_CONFIG_ENABLE_TESTS "Build the test suite" OFF)
endfunction() # This option isn't recommended for distribution builds and probably won't work (yet).
cmake_dependent_option(
SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES
"Use dynamic libraries when compiling internal dependencies"
OFF "NOT SRB2_CONFIG_SYSTEM_LIBRARIES"
OFF
)
option(SRB2_CONFIG_ENABLE_DISCORDRPC "Enable Discord RPC features" ON)
option(SRB2_CONFIG_STATIC_STDLIB "Link static version of standard library. All dependencies must also be static" ON)
option(SRB2_CONFIG_HWRENDER "Enable hardware render (OpenGL) support" ON)
option(SRB2_CONFIG_STATIC_OPENGL "Enable static linking GL (do not do this)" OFF)
option(SRB2_CONFIG_ERRORMODE "Compile C code with warnings treated as errors." OFF)
option(SRB2_CONFIG_DEBUGMODE "Compile with PARANOIA, ZDEBUG, RANGECHECK and PACKETDROP defined." OFF)
option(SRB2_CONFIG_MOBJCONSISTANCY "Compile with MOBJCONSISTANCY defined." OFF)
option(SRB2_CONFIG_PACKETDROP "Compile with PACKETDROP defined." OFF)
option(SRB2_CONFIG_ZDEBUG "Compile with ZDEBUG defined." OFF)
# SRB2_CONFIG_PROFILEMODE is probably superceded by some CMake setting.
option(SRB2_CONFIG_PROFILEMODE "Compile for profiling (GCC only)." OFF)
option(SRB2_CONFIG_TRACY "Compile with Tracy profiling enabled" OFF)
option(SRB2_CONFIG_ASAN "Compile with AddressSanitizer (libasan)." OFF)
option(SRB2_CONFIG_UBSAN "Compile with UndefinedBehaviorSanitizer (libubsan)." OFF)
set(SRB2_CONFIG_ASSET_DIRECTORY "" CACHE PATH "Path to directory that contains all asset files for the installer. If set, assets will be part of installation and cpack.")
option(SRB2_CONFIG_LTO "Enable link time optimizations, improves performance at the cost of longer link times." ON)
option(SRB2_CONFIG_TIDY "Enable clang tiny, checks compiled code for issues at the cost of longer compile times." OFF)
# Macro to add OSX framework # man i suck at explaining lmao
macro(add_framework fwname appname) option(SRB2_CONFIG_SATURNPAK "Enable Saturn specific special packet. Required for using the newer resynch system" ON)
find_library(FRAMEWORK_${fwname} option(SRB2_CONFIG_SATURNJOIN "Enable Saturn specific allowjoin toggle." ON)
NAMES ${fwname} option(SRB2_CONFIG_SCREENFBO "Enable hardware render (OpenGL) FBO downsampling support" ON)
PATHS ${CMAKE_OSX_SYSROOT}/System/Library option(SRB2_CONFIG_LIBBACKTRACE "Enable using libbacktrace for crashlogs" ON)
${CMAKE_OSX_SYSROOT}/Library
/System/Library
/Library
ATH_SUFFIXES Frameworks
NO_DEFAULT_PATH)
if( ${FRAMEWORK_${fwname}} STREQUAL FRAMEWORK_${fwname}-NOTFOUND)
MESSAGE(ERROR ": Framework ${fwname} not found")
else()
TARGET_LINK_LIBRARIES(${appname} PRIVATE "${FRAMEWORK_${fwname}}/${fwname}")
MESSAGE(STATUS "Framework ${fwname} found at ${FRAMEWORK_${fwname}}")
endif()
endmacro()
# Macro to copy Windows DLLs to Debug/Release folder for easy debugging #if(SRB2_CONFIG_ENABLE_TESTS)
# Note: this is general purpose, we could copy anything. Just using for DLLs on MSVC though # https://github.com/catchorg/Catch2
macro(copy_files_to_build_dir target dlllist_var) # CPMAddPackage(
if(MSVC) # NAME Catch2
# http://stackoverflow.com/a/26983405/3064195 # VERSION 3.1.1
foreach(dlllist_item ${${dlllist_var}}) # GITHUB_REPOSITORY catchorg/Catch2
get_filename_component(dllname ${dlllist_item} NAME) # OPTIONS
add_custom_command(TARGET ${target} POST_BUILD # "CATCH_INSTALL_DOCS OFF"
COMMAND ${CMAKE_COMMAND} -E copy_if_different # )
${dlllist_item} # list(APPEND CMAKE_MODULE_PATH "${Catch2_SOURCE_DIR}/extras")
$<TARGET_FILE_DIR:${target}>/${dllname} # include(CTest)
) # include(Catch)
endforeach() # add_executable(srb2tests)
# # To add tests, use target_sources to add individual test files to the target in subdirs.
# target_link_libraries(srb2tests PRIVATE Catch2::Catch2 Catch2::Catch2WithMain)
# target_compile_features(srb2tests PRIVATE c_std_11 cxx_std_17)
# catch_discover_tests(srb2tests)
#endif()
# Enable CCache
# (Set USE_CCACHE=ON to use, CCACHE_OPTIONS for options)
if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL Windows)
option(USE_CCACHE "Enable ccache support" OFF)
if(USE_CCACHE)
find_program(CCACHE_TOOL_PATH ccache)
if(CCACHE_TOOL_PATH)
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_TOOL_PATH} CACHE STRING "" FORCE)
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_TOOL_PATH} CACHE STRING "" FORCE)
else()
message(WARNING "USE_CCACHE was set but ccache is not found (set CCACHE_TOOL_PATH)")
endif()
endif() endif()
endmacro() else()
# TODO: fix windoze crap, i dont want cpm lol
#CPMAddPackage(
# NAME Ccache.cmake
# GITHUB_REPOSITORY TheLartians/Ccache.cmake
# VERSION 1.2.5
#)
endif()
# Dependencies
#add_subdirectory(thirdparty)
if("${SRB2_CONFIG_SYSTEM_LIBRARIES}")
find_package(ZLIB REQUIRED)
find_package(PNG REQUIRED)
find_package(SDL2 REQUIRED)
find_package(SDL2_mixer REQUIRED)
find_package(CURL REQUIRED)
find_package(OPENMPT OPTIONAL)
find_package(GME REQUIRED)
find_package(DiscordRPC OPTIONAL)
find_package(libbacktrace OPTIONAL)
endif()
if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR})
message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.")
endif()
if ((${SRB2_USE_CCACHE}) AND (${CMAKE_C_COMPILER} MATCHES "clang"))
message(WARNING "Using clang and CCache: You may want to set environment variable CCACHE_CPP2=yes to prevent include errors during compile.")
endif()
# Add sources from Sourcefile
function(target_sourcefile type)
file(STRINGS Sourcefile list
REGEX "[-0-9A-Za-z_]+\.${type}")
target_sources(SRB2SDL2 PRIVATE ${list})
endfunction()
# bitness check # bitness check
set(SRB2_SYSTEM_BITS 0) set(SRB2_SYSTEM_BITS 0)
@@ -102,32 +178,12 @@ if(${SRB2_SYSTEM_BITS} EQUAL 0)
message(STATUS "Target bitness is unknown") message(STATUS "Target bitness is unknown")
endif() endif()
# OS macros
if (UNIX)
add_definitions(-DUNIXCOMMON)
add_link_options(-rdynamic) # Use -rdynamic so a backtrace log shows function names
endif()
if(CMAKE_COMPILER_IS_GNUCC)
find_program(OBJCOPY objcopy)
endif()
if(${CMAKE_SYSTEM} MATCHES "Linux")
add_definitions(-DLINUX)
if(${SRB2_SYSTEM_BITS} EQUAL 64)
add_definitions(-DLINUX64)
endif()
endif()
if(${CMAKE_SYSTEM} MATCHES "Darwin")
add_definitions(-DMACOSX)
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
# Set EXE names so the assets CMakeLists can refer to its target # Set 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 "" CACHE STRING "Override executable binary output name")
set(SRB2_SDL2_EXE_SUFFIX "" CACHE STRING "Optional executable suffix, separated by an underscore")
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src) include_directories(${CMAKE_CURRENT_BINARY_DIR}/src)
@@ -139,6 +195,22 @@ set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary")
include(GitUtilities) include(GitUtilities)
git_latest_commit(SRB2_COMP_COMMIT "${CMAKE_SOURCE_DIR}") git_latest_commit(SRB2_COMP_COMMIT "${CMAKE_SOURCE_DIR}")
git_current_branch(SRB2_GIT_BRANCH "${CMAKE_SOURCE_DIR}") git_current_branch(SRB2_GIT_BRANCH "${CMAKE_SOURCE_DIR}")
#git_working_tree_dirty(SRB2_COMP_UNCOMMITTED "${CMAKE_SOURCE_DIR}") #TODO: fix this
set(SRB2_COMP_BRANCH "${SRB2_GIT_BRANCH}") set(SRB2_COMP_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)
if("${SRB2_SDL2_EXE_NAME}" STREQUAL "")
list(APPEND EXE_NAME_PARTS "srb2kart-saturn")
if(NOT "${SRB2_GIT_BRANCH}" STREQUAL "master")
list(APPEND EXE_NAME_PARTS ${SRB2_GIT_BRANCH})
endif()
else()
list(APPEND EXE_NAME_PARTS ${SRB2_SDL2_EXE_NAME})
endif()
list(APPEND EXE_NAME_PARTS ${SRB2_SDL2_EXE_SUFFIX})
list(JOIN EXE_NAME_PARTS "_" EXE_NAME)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME ${EXE_NAME})
+3 -3
View File
@@ -22,14 +22,14 @@ We also have a Flatpak available on [Flathub](https://flathub.org/en/apps/org.sr
See [SRB2 Wiki/Source code compiling](http://wiki.srb2.org/wiki/Source_code_compiling). The compiling process for SRB2Kart is largely identical to SRB2. See [SRB2 Wiki/Source code compiling](http://wiki.srb2.org/wiki/Source_code_compiling). The compiling process for SRB2Kart is largely identical to SRB2.
For Windows only the Makefile build system with GCC or Clang compiler is supported. Currently only the Makefile build system with GCC or Clang compiler is supported.
CMake is NOT supported at the moment, but will be availible again soon.
Visual C++ (MSVC) is unsupported. Visual C++ (MSVC) is unsupported.
64-bit Windows builds are supported and recommended over 32-bit builds, they will build automatically when using the MSYS2 MinGW 64-bit executable (requires the mingw-w64-x86_64-gcc package), no extra flags needed! 64-bit Windows builds are supported and recommended over 32-bit builds, they will build automatically when using the MSYS2 MinGW 64-bit executable (requires the mingw-w64-x86_64-gcc package), no extra flags needed!
The specific DLLs can be found under /libs/dll-binaries/(i686 for 32bit/x86_64 for 64-bit)/ or in the Release packages The specific DLLs can be found under /libs/dll-binaries/(i686 for 32bit/x86_64 for 64-bit)/ or in the Release packages
MacOS and Linux can be build with CMake, but it is recommended to use the Makefile for Linux over CMake
Alternatively the [srb2bld](https://github.com/Bijman/srb2bld) script by Bijman can be used aswell! Alternatively the [srb2bld](https://github.com/Bijman/srb2bld) script by Bijman can be used aswell!
## Disclaimer ## Disclaimer
+32 -44
View File
@@ -5,60 +5,48 @@ if(${CMAKE_SYSTEM} MATCHES Linux)
return() return()
endif() endif()
# For prepending the current source path, later if("${SRB2_CONFIG_ASSET_DIRECTORY}" STREQUAL "")
FUNCTION(PREPEND var prefix) message(WARNING "SRB2_CONFIG_ASSET_DIRECTORY is not set, so installation will not contain data files.")
SET(listVar "") return()
FOREACH(f ${ARGN}) endif()
LIST(APPEND listVar "${prefix}/${f}")
ENDFOREACH(f)
SET(${var} "${listVar}" PARENT_SCOPE)
ENDFUNCTION(PREPEND)
set(SRB2_ASSET_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/installer" get_filename_component(SRB2_ASSET_DIRECTORY_ABSOLUTE "${SRB2_CONFIG_ASSET_DIRECTORY}" ABSOLUTE)
CACHE STRING "Path to directory that contains all asset files for the installer.")
set(SRB2_ASSET_HASHED set(SRB2_ASSETS_DOCS
"srb2.srb;\ "README.txt"
gfx.kart;\ "HISTORY.txt"
textures.kart;\ "README-SDL.txt"
chars.kart;\ "LICENSE.txt"
maps.kart" "LICENSE-3RD-PARTY.txt"
CACHE STRING "Asset filenames to apply MD5 checks. No spaces between entries!"
) )
list(TRANSFORM SRB2_ASSETS_DOCS PREPEND "/")
list(TRANSFORM SRB2_ASSETS_DOCS PREPEND "${SRB2_ASSET_DIRECTORY_ABSOLUTE}")
set(SRB2_ASSET_DOCS ####################
"README.txt;\ # POST-V2.2 NOTE: Do not forget to add patch.pk3 to the end of this list!
HISTORY.txt;\ ####################
LICENSE.txt;\
LICENSE-3RD-PARTY.txt" set(SRB2_ASSETS_GAME
CACHE STRING "Documentation filenames. In OS X, these are packaged separately from other assets. No spaces between entries!" "srb2.srb"
"gfx.kart"
"textures.kart"
"chars.kart"
"maps.kart"
) )
list(TRANSFORM SRB2_ASSETS_GAME PREPEND "/")
list(TRANSFORM SRB2_ASSETS_GAME PREPEND "${SRB2_ASSET_DIRECTORY_ABSOLUTE}")
PREPEND(SRB2_ASSET_DOCS ${SRB2_ASSET_DIRECTORY} ${SRB2_ASSET_DOCS}) set(SRB2_ASSETS ${SRB2_ASSET_DOCS} ${SRB2_ASSETS_GAME})
foreach(SRB2_ASSET ${SRB2_ASSET_HASHED})
file(MD5 ${SRB2_ASSET_DIRECTORY}/${SRB2_ASSET} "SRB2_ASSET_${SRB2_ASSET}_HASH")
set(SRB2_ASSET_${SRB2_ASSET}_HASH ${SRB2_ASSET_${SRB2_ASSET}_HASH} PARENT_SCOPE)
endforeach()
# Installation # Installation
if(${CMAKE_SYSTEM} MATCHES Darwin) if(${CMAKE_SYSTEM} MATCHES Darwin)
get_target_property(outname SRB2SDL2 OUTPUT_NAME) get_target_property(outname SRB2SDL2 OUTPUT_NAME)
install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/" install(FILES ${SRB2_ASSETS} DESTINATION "${outname}.app/Contents/Resources")
DESTINATION "${outname}.app/Contents/Resources" install(DIRECTORY "${SRB2_ASSET_DIRECTORY_ABSOLUTE}/models" DESTINATION "${outname}.app/Contents/Resources")
) install(FILES ${SRB2_ASSETS_DOCS} DESTINATION .)
install(FILES ${SRB2_ASSET_DOCS}
DESTINATION .
OPTIONAL
)
else() else()
install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/" install(FILES ${SRB2_ASSETS} DESTINATION .)
DESTINATION . install(DIRECTORY "${SRB2_ASSET_DIRECTORY_ABSOLUTE}/models" DESTINATION .)
)
# Docs are assumed to be located in SRB2_ASSET_DIRECTORY, so don't install again
#install(FILES ${SRB2_ASSET_DOCS}
# DESTINATION .
# OPTIONAL
#)
endif() endif()
+19
View File
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
set(CMAKE_BINARY_DIR "${BINARY_DIR}")
set(CMAKE_CURRENT_BINARY_DIR "${BINARY_DIR}")
# Set up CMAKE path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
include(GitUtilities)
git_current_branch(SRB2_COMP_BRANCH)
git_working_tree_dirty(SRB2_COMP_UNCOMMITTED)
git_latest_commit(SRB2_COMP_REVISION)
git_subject(subject)
string(REGEX REPLACE "([\"\\])" "\\\\\\1" SRB2_COMP_LASTCOMMIT "${subject}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in" "${CMAKE_CURRENT_SOURCE_DIR}/src/config.h")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in" "${CMAKE_CURRENT_SOURCE_DIR}/build/src/config.h")
+10
View File
@@ -21,3 +21,13 @@ find_library(DISCORDRPC_LIBRARY
set(DISCORDRPC_PROCESS_INCLUDES DISCORDRPC_INCLUDE_DIR) set(DISCORDRPC_PROCESS_INCLUDES DISCORDRPC_INCLUDE_DIR)
set(DISCORDRPC_PROCESS_LIBS DISCORDRPC_LIBRARY) set(DISCORDRPC_PROCESS_LIBS DISCORDRPC_LIBRARY)
libfind_process(DISCORDRPC) libfind_process(DISCORDRPC)
if(DISCORDRPC_FOUND AND NOT TARGET DiscordRPC::DiscordRPC)
add_library(DiscordRPC::DiscordRPC UNKNOWN IMPORTED)
set_target_properties(
DiscordRPC::DiscordRPC
PROPERTIES
IMPORTED_LOCATION "${DISCORDRPC_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${DISCORDRPC_INCLUDE_DIR}"
)
endif()
+11 -2
View File
@@ -1,6 +1,6 @@
include(LibFindMacros) include(LibFindMacros)
libfind_pkg_check_modules(GME_PKGCONF LIBGME) libfind_pkg_check_modules(GME_PKGCONF GME)
find_path(GME_INCLUDE_DIR find_path(GME_INCLUDE_DIR
NAMES gme.h NAMES gme.h
@@ -8,7 +8,6 @@ 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
@@ -22,3 +21,13 @@ find_library(GME_LIBRARY
set(GME_PROCESS_INCLUDES GME_INCLUDE_DIR) set(GME_PROCESS_INCLUDES GME_INCLUDE_DIR)
set(GME_PROCESS_LIBS GME_LIBRARY) set(GME_PROCESS_LIBS GME_LIBRARY)
libfind_process(GME) libfind_process(GME)
if(GME_FOUND AND NOT TARGET gme)
add_library(gme UNKNOWN IMPORTED)
set_target_properties(
gme
PROPERTIES
IMPORTED_LOCATION "${GME_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${GME_INCLUDE_DIR}"
)
endif()
+11 -2
View File
@@ -1,6 +1,6 @@
include(LibFindMacros) include(LibFindMacros)
libfind_pkg_check_modules(OPENMPT_PKGCONF LIBOPENMPT) libfind_pkg_check_modules(OPENMPT_PKGCONF OPENMPT)
find_path(OPENMPT_INCLUDE_DIR find_path(OPENMPT_INCLUDE_DIR
NAMES libopenmpt.h NAMES libopenmpt.h
@@ -8,7 +8,6 @@ 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
@@ -22,3 +21,13 @@ find_library(OPENMPT_LIBRARY
set(OPENMPT_PROCESS_INCLUDES OPENMPT_INCLUDE_DIR) set(OPENMPT_PROCESS_INCLUDES OPENMPT_INCLUDE_DIR)
set(OPENMPT_PROCESS_LIBS OPENMPT_LIBRARY) set(OPENMPT_PROCESS_LIBS OPENMPT_LIBRARY)
libfind_process(OPENMPT) libfind_process(OPENMPT)
if(OPENMPT_FOUND AND NOT TARGET openmpt)
add_library(openmpt UNKNOWN IMPORTED)
set_target_properties(
openmpt
PROPERTIES
IMPORTED_LOCATION "${OPENMPT_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${OPENMPT_INCLUDE_DIR}"
)
endif()
+10
View File
@@ -31,3 +31,13 @@ find_library(SDL2_LIBRARY
set(SDL2_PROCESS_INCLUDES SDL2_INCLUDE_DIR) set(SDL2_PROCESS_INCLUDES SDL2_INCLUDE_DIR)
set(SDL2_PROCESS_LIBS SDL2_LIBRARY) set(SDL2_PROCESS_LIBS SDL2_LIBRARY)
libfind_process(SDL2) libfind_process(SDL2)
if(SDL2_FOUND AND NOT TARGET SDL2::SDL2)
add_library(SDL2::SDL2 UNKNOWN IMPORTED)
set_target_properties(
SDL2::SDL2
PROPERTIES
IMPORTED_LOCATION "${SDL2_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}"
)
endif()
+10
View File
@@ -32,3 +32,13 @@ find_library(SDL2_MIXER_LIBRARY
set(SDL2_MIXER_PROCESS_INCLUDES SDL2_MIXER_INCLUDE_DIR) set(SDL2_MIXER_PROCESS_INCLUDES SDL2_MIXER_INCLUDE_DIR)
set(SDL2_MIXER_PROCESS_LIBS SDL2_MIXER_LIBRARY) set(SDL2_MIXER_PROCESS_LIBS SDL2_MIXER_LIBRARY)
libfind_process(SDL2_MIXER) libfind_process(SDL2_MIXER)
if(SDL2_MIXER_FOUND AND NOT TARGET SDL2_mixer::SDL2_mixer)
add_library(SDL2_mixer::SDL2_mixer UNKNOWN IMPORTED)
set_target_properties(
SDL2_mixer::SDL2_mixer
PROPERTIES
IMPORTED_LOCATION "${SDL2_MIXER_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_MIXER_INCLUDE_DIR}"
)
endif()
+39 -23
View File
@@ -6,38 +6,54 @@ endif()
set(__GitUtilities ON) set(__GitUtilities ON)
function(git_describe variable path) macro(_git_command)
execute_process(COMMAND "${GIT_EXECUTABLE}" "describe" execute_process(
WORKING_DIRECTORY "${path}" COMMAND "${GIT_EXECUTABLE}" ${ARGN}
RESULT_VARIABLE result WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE output OUTPUT_VARIABLE output
ERROR_QUIET ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
) )
endmacro()
macro(_git_easy_command)
_git_command(${ARGN})
set(${variable} "${output}" PARENT_SCOPE)
endmacro()
function(git_current_branch variable)
_git_command(symbolic-ref -q --short HEAD)
# If a detached head, a ref could still be resolved.
if("${output}" STREQUAL "")
_git_command(describe --all --exact-match)
# Get the ref, in the form heads/master or
# remotes/origin/master so isolate the final part.
string(REGEX REPLACE ".*/" "" output "${output}")
endif()
set(${variable} "${output}" PARENT_SCOPE) set(${variable} "${output}" PARENT_SCOPE)
endfunction() endfunction()
function(git_current_branch variable path) function(git_latest_commit variable)
execute_process(COMMAND ${GIT_EXECUTABLE} "symbolic-ref" "--short" "HEAD" _git_easy_command(rev-parse --short HEAD)
WORKING_DIRECTORY "${path}"
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(${variable} "${output}" PARENT_SCOPE)
endfunction() endfunction()
function(git_latest_commit variable path) function(git_working_tree_dirty variable)
execute_process(COMMAND ${GIT_EXECUTABLE} "rev-parse" "--short" "HEAD" _git_command(status --porcelain -uno)
WORKING_DIRECTORY "${path}"
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(${variable} "${output}" PARENT_SCOPE) if(output STREQUAL "")
set(${variable} FALSE PARENT_SCOPE)
else()
set(${variable} TRUE PARENT_SCOPE)
endif()
endfunction()
function(git_subject variable)
_git_easy_command(log -1 "--format=%h %s")
endfunction()
function(get_git_dir variable)
_git_easy_command(rev-parse --git-dir)
endfunction() endfunction()
+18 -37
View File
@@ -1,4 +1,4 @@
# Version 2.4 # Version 2.2
# 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,10 +52,6 @@ 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.
@@ -129,39 +125,24 @@ 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) if (DEFINED ${i}_INCLUDE_OPTS OR DEFINED ${i}_LIBRARY_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 (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 # Singular forms can be used
list(APPEND libraryopts ${i}_LIBRARY) if (DEFINED ${i}_INCLUDE_DIR)
else() list(APPEND includeopts ${i}_INCLUDE_DIR)
if (DEFINED ${i}_LIBRARIES)
# Plural forms can be used
list(APPEND libraryopts ${i}_LIBRARIES)
else()
# Oh no, we don't know the option names
message(FATAL_ERROR "We couldn't determine config variable names for ${i} libraries. Aieeh!")
endif() endif()
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()
endif() endif()
endforeach() endforeach()
@@ -228,12 +209,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()
+1
View File
@@ -1,4 +1,5 @@
/cscope.out /cscope.out
*.json *.json
*.idx *.idx
config.h
*.gdb_history *.gdb_history
+381 -541
View File
@@ -1,436 +1,146 @@
# SRB2 Core add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32)
if(("${CMAKE_COMPILER_IS_GNUCC}" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND "${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
target_link_options(SRB2SDL2 PRIVATE "-Wl,--disable-dynamicbase")
if("${SRB2_CONFIG_STATIC_STDLIB}")
# On MinGW with internal libraries, link the standard library statically
if(CMAKE_LINKER_TYPE STREQUAL "LLD")
target_link_options(SRB2SDL2 PRIVATE -Wl, -static-libgcc -static-libstdc++ -static -lpthread)
else()
target_link_options(SRB2SDL2 PRIVATE -Wl,--add-stdcall-alias -static-libgcc -static-libstdc++ -static -lpthread)
endif()
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
target_link_libraries(SRB2SDL2 PRIVATE Threads::Threads)
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
target_link_options(SRB2SDL2 PRIVATE "-Wl,--large-address-aware")
endif()
endif()
set(SRB2_CONFIG_STD23 OFF CACHE BOOL
"Compiles the game under c23 and cxx23 instead c11 and cxx17.")
if(SRB2_CONFIG_STD23)
message("-- Compiling game with C23 and CXX23.")
target_compile_features(SRB2SDL2 PRIVATE c_std_23 cxx_std_23)
set_property(TARGET SRB2SDL2 PROPERTY C_STANDARD 23)
set_property(TARGET SRB2SDL2 PROPERTY CXX_STANDARD 23)
else()
message("-- Compiling game with C11 and CXX17.")
target_compile_features(SRB2SDL2 PRIVATE c_std_11 cxx_std_17)
set_property(TARGET SRB2SDL2 PROPERTY C_STANDARD 11)
set_property(TARGET SRB2SDL2 PROPERTY CXX_STANDARD 17)
endif()
# Core sources # Core sources
set(SRB2_CORE_SOURCES target_sourcefile(c)
core/memory.cpp target_sources(SRB2SDL2 PRIVATE comptime.c config.h.in)
core/thread_pool.cpp
am_map.c
b_bot.c
command.c
comptime.c
console.c
d_clisrv.c
d_main.c
d_net.c
d_netcmd.c
d_netfil.c
d_protocol.c
dehacked.c
f_finale.c
f_wipe.c
filesrch.c
g_game.c
g_demo.c
g_input.c
hu_stuff.c
i_tcp.c
info.c
k_hud.c
lzf.c
m_aatree.c
m_anigif.c
m_argv.c
m_bbox.c
m_cheat.c
m_curl.c
m_cond.c
m_emotes.cpp
m_fixed.c
m_menu.c
m_textinput.c
m_misc.c
m_perfstats.c
m_queue.c
m_random.c
md5.c
mserv.c
http-mserv.c
qs22j.c
r_skins.c
s_sound.c
screen.c
sounds.c
st_stuff.c
string.c
tables.c
v_video.c
w_wad.c
y_inter.c
z_zone.cpp
)
set(SRB2_CORE_HEADERS target_sources(SRB2SDL2 PRIVATE md5.c md5.h)
core/memory.h
core/thread_pool.h
m_curl.h
m_emotes.h
k_hud.h
am_map.h
b_bot.h
byteptr.h
command.h
console.h
d_clisrv.h
d_event.h
d_main.h
d_net.h
d_netcmd.h
d_netfil.h
d_player.h
d_protocol.h
d_think.h
d_ticcmd.h
dehacked.h
doomdata.h
doomdef.h
doomstat.h
doomtype.h
endian.h
f_finale.h
fastcmp.h
filesrch.h
g_game.h
g_demo.h
g_input.h
g_state.h
hu_stuff.h
i_joy.h
i_net.h
i_sound.h
i_system.h
i_tcp.h
i_time.h
i_video.h
info.h
keys.h
lzf.h
m_aatree.h
m_anigif.h
m_argv.h
m_bbox.h
m_cheat.h
m_cond.h
m_dllist.h
m_fixed.h
m_menu.h
m_textinput.h
m_misc.h
m_queue.h
m_perfstats.h
m_random.h
m_swap.h
md5.h
mserv.h
qs22j.h
r_skins.h
s_sound.h
screen.h
sounds.h
st_stuff.h
tables.h
v_video.h
w_wad.h
y_inter.h
z_zone.h
config.h.in
)
set(SRB2_CORE_RENDER_SOURCES
r_bsp.cpp
r_data.c
r_draw.cpp
r_fps.cpp
r_main.cpp
r_patch.cpp
r_patchrotation.cpp
r_plane.cpp
r_segs.cpp
r_sky.c
r_splats.c
r_things.cpp
r_portal.c
r_bsp.h
r_data.h
r_defs.h
r_draw.h
r_fps.h
r_local.h
r_main.h
r_patch.h
r_patchrotation.h
r_plane.h
r_segs.h
r_sky.h
r_splats.h
r_state.h
r_things.h
r_portal.h
)
set(SRB2_CORE_GAME_SOURCES
p_ceilng.c
p_enemy.c
p_floor.c
p_inter.c
p_lights.c
p_map.c
p_maputl.cpp
p_mobj.c
p_polyobj.c
p_saveg.c
p_setup.c
p_sight.c
p_slopes.c
p_spec.c
p_telept.c
p_tick.c
p_user.c
k_director.c
k_kart.c
k_stats.c
i_time.c
p_local.h
p_maputl.h
p_mobj.h
p_polyobj.h
p_pspr.h
p_saveg.h
p_setup.h
p_slopes.h
p_spec.h
p_tick.h
k_director.h
k_kart.h
k_stats.h
)
prepend_sources(SRB2_CORE_SOURCES)
prepend_sources(SRB2_CORE_HEADERS)
prepend_sources(SRB2_CORE_RENDER_SOURCES)
prepend_sources(SRB2_CORE_GAME_SOURCES)
set(SRB2_CORE_HEADERS ${SRB2_CORE_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/config.h)
source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS})
source_group("Renderer" FILES ${SRB2_CORE_RENDER_SOURCES})
source_group("Game" FILES ${SRB2_CORE_GAME_SOURCES})
### Configuration ### Configuration
set(SRB2_CONFIG_HAVE_BLUA ON CACHE BOOL set(SRB2_CONFIG_DEV_BUILD OFF CACHE BOOL
"Enable Lua interpreter support") "Compile a development build of SRB2Kart.")
set(SRB2_CONFIG_HAVE_PNG ON CACHE BOOL
"Enable PNG support. Depends on zlib, so will be disabled if you don't enable that too.")
set(SRB2_CONFIG_HAVE_ZLIB ON CACHE BOOL
"Enable zlib support.")
set(SRB2_CONFIG_HAVE_GME ON CACHE BOOL
"Enable GME support.")
set(SRB2_CONFIG_HAVE_OPENMPT ON CACHE BOOL
"Enable OpenMPT support.")
set(SRB2_CONFIG_HAVE_DISCORDRPC OFF CACHE BOOL
"Enable Discord rich presence support.")
set(SRB2_CONFIG_HAVE_CURL ON CACHE BOOL
"Enable curl support, used for downloading files via HTTP.")
set(SRB2_CONFIG_HWRENDER ON CACHE BOOL
"Enable hardware rendering through OpenGL.")
set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL
"Use statically linked OpenGL. NOT RECOMMENDED.")
set(SRB2_CONFIG_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 set(SRB2_CONFIG_SKIP_COMPTIME OFF CACHE BOOL
"Enable Saturn specific special packet. Required for using the newer resynch system") "Skip Comptime rebuild.")
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")
if(${SRB2_CONFIG_DEDICATED}) if(NOT SRB2_CONFIG_SKIP_COMPTIME)
set(SRB2_CONFIG_HAVE_GME NO) # This updates the modification time for comptime.c at the
set(SRB2_CONFIG_HAVE_OPENMPT NO) # end of building so when the build system is ran next time,
set(SRB2_CONFIG_HWRENDER NO) # that file gets flagged. comptime.c will always be rebuilt.
endif() #
# This begs the question, why always rebuild comptime.c?
### use internal libraries? # Some things like the git commit must be checked each time
if(${CMAKE_SYSTEM} MATCHES "Windows") ###set on Windows only # the program is built. But the build system determines which
set(SRB2_CONFIG_USE_INTERNAL_LIBRARIES OFF CACHE BOOL # files should be rebuilt before anything else. So
"Use SRB2Kart's internal copies of required dependencies (SDL2, PNG, zlib, GME, OpenMPT).") # comptime.c, which only needs to be rebuilt based on
endif() # information known at build time, must be told to rebuild
# before that information can be ascertained.
if(${SRB2_CONFIG_HAVE_BLUA}) add_custom_command(
add_definitions(-DHAVE_BLUA) TARGET SRB2SDL2
set(SRB2_LUA_SOURCES POST_BUILD
lua_baselib.c COMMAND ${CMAKE_COMMAND} -E touch_nocreate ${CMAKE_CURRENT_SOURCE_DIR}/comptime.c
lua_blockmaplib.c
lua_consolelib.c
lua_hooklib.c
lua_hudlib.c
lua_hudlib_drawlist.c
lua_infolib.c
lua_maplib.c
lua_mathlib.c
lua_mobjlib.c
lua_playerlib.c
lua_script.c
lua_skinlib.c
lua_thinkerlib.c
lua_udatalib.c
lua_glib.c
) )
set(SRB2_LUA_HEADERS
lua_hook.h
lua_hud.h
lua_hudlib_drawlist.h
lua_libs.h
lua_script.h
lua_udatalib.h
lua_glib.h
)
prepend_sources(SRB2_LUA_SOURCES)
prepend_sources(SRB2_LUA_HEADERS)
source_group("LUA" FILES ${SRB2_LUA_SOURCES} ${SRB2_LUA_HEADERS})
set(SRB2_BLUA_SOURCES
blua/lapi.c
blua/lauxlib.c
blua/lbaselib.c
blua/ldblib.c
blua/lcode.c
blua/ldebug.c
blua/ldo.c
blua/ldump.c
blua/lfunc.c
blua/lgc.c
blua/linit.c
blua/liolib.c
blua/llex.c
blua/lmem.c
blua/lobject.c
blua/lopcodes.c
blua/lparser.c
blua/lstate.c
blua/lstring.c
blua/lstrlib.c
blua/ltable.c
blua/ltablib.c
blua/ltm.c
blua/lundump.c
blua/lvm.c
blua/lzio.c
)
set(SRB2_BLUA_HEADERS
blua/lapi.h
blua/lauxlib.h
blua/lcode.h
blua/ldebug.h
blua/ldo.h
blua/lfunc.h
blua/lgc.h
blua/llex.h
blua/llimits.h
blua/lmem.h
blua/lobject.h
blua/lopcodes.h
blua/lparser.h
blua/lstate.h
blua/lstring.h
blua/ltable.h
blua/ltm.h
blua/lua.h
blua/luaconf.h
blua/lualib.h
blua/lundump.h
blua/lvm.h
blua/lzio.h
)
prepend_sources(SRB2_BLUA_SOURCES)
prepend_sources(SRB2_BLUA_HEADERS)
source_group("LUA\\Interpreter" FILES ${SRB2_BLUA_SOURCES} ${SRB2_BLUA_HEADERS})
endif() endif()
if(${SRB2_CONFIG_HAVE_GME}) set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary")
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) add_custom_target(_SRB2_reconf ALL
set(GME_FOUND ON) COMMAND ${CMAKE_COMMAND} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DBINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/.. -P ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/Comptime.cmake
set(GME_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/gme/include) WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.."
if(${SRB2_SYSTEM_BITS} EQUAL 64) )
set(GME_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/gme/win64 -lgme") add_dependencies(SRB2SDL2 _SRB2_reconf)
else() # 32-bit
set(GME_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/gme/win32 -lgme") if(SRB2_CONFIG_ASAN)
endif() target_compile_options(SRB2SDL2 PRIVATE -fsanitize=address)
else() target_link_options(SRB2SDL2 PRIVATE -fsanitize=address)
find_package(GME) endif()
endif()
if(${GME_FOUND}) if(SRB2_CONFIG_UBSAN)
set(SRB2_HAVE_GME ON) target_compile_options(SRB2SDL2 PRIVATE -fsanitize=undefined)
add_definitions(-DHAVE_LIBGME) target_link_options(SRB2SDL2 PRIVATE -fsanitize=undefined)
else() endif()
message(WARNING "You have specified that GME is available but it was not found.")
if(SRB2_CONFIG_TIDY)
set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-checks=*")
endif()
add_subdirectory(blua)
add_subdirectory(sdl)
add_subdirectory(core)
# OS macros
if (UNIX)
target_compile_definitions(SRB2SDL2 PRIVATE -DUNIXCOMMON)
target_link_libraries(SRB2SDL2 PRIVATE -rdynamic) # Use -rdynamic so a backtrace log shows function names
endif()
if(CMAKE_COMPILER_IS_GNUCC)
find_program(OBJCOPY objcopy)
endif()
if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
target_compile_definitions(SRB2SDL2 PRIVATE -DLINUX)
if(${SRB2_SYSTEM_BITS} EQUAL 64)
target_compile_definitions(SRB2SDL2 PRIVATE -DLINUX64)
endif() endif()
endif() endif()
if(${SRB2_CONFIG_HAVE_DISCORDRPC}) if("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) target_compile_definitions(SRB2SDL2 PRIVATE -DMACOSX)
set(DISCORDRPC_FOUND ON)
if(${SRB2_SYSTEM_BITS} EQUAL 64)
set(DISCORDRPC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/discord-rpc/win64-dynamic/include)
set(DISCORDRPC_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/discord-rpc/win64-dynamic/lib -ldiscord-rpc")
else() # 32-bit
set(DISCORDRPC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/discord-rpc/win32-dynamic/include)
set(DISCORDRPC_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/discord-rpc/win32-dynamic/lib -ldiscord-rpc")
endif()
else()
find_package(DiscordRPC)
endif()
if(${DISCORDRPC_FOUND})
set(SRB2_HAVE_DISCORDRPC ON)
add_definitions(-DHAVE_DISCORDRPC)
add_definitions(-DUSE_STUN)
set(SRB2_DISCORDRPC_SOURCES discord.c stun.c)
set(SRB2_DISCORDRPC_HEADERS discord.h stun.h)
prepend_sources(SRB2_DISCORDRPC_SOURCES)
prepend_sources(SRB2_DISCORDRPC_HEADERS)
source_group("Discord Rich Presence" FILES ${SRB2_DISCORDRPC_SOURCES} ${SRB2_DISCORDRPC_HEADERS})
else()
message(WARNING "You have specified that Discord Rich Presence is available but it was not found.")
endif()
endif() endif()
if(${SRB2_CONFIG_HAVE_OPENMPT}) # add toggle for this
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) target_link_libraries(SRB2SDL2 PRIVATE openmpt)
set(OPENMPT_FOUND ON) target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_OPENMPT)
set(OPENMPT_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/inc)
if(${SRB2_SYSTEM_BITS} EQUAL 64) target_link_libraries(SRB2SDL2 PRIVATE ZLIB::ZLIB PNG::PNG CURL::libcurl)
set(OPENMPT_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/libopenmpt/lib/x86_64/mingw -lopenmpt") target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_ZLIB -DHAVE_PNG -DHAVE_CURL -D_LARGEFILE64_SOURCE)
else() # 32-bit
set(OPENMPT_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/libopenmpt/lib/x86/mingw -lopenmpt") target_compile_definitions(SRB2SDL2 PRIVATE -DUSE_STUN)
endif() if(SRB2_CONFIG_ENABLE_DISCORDRPC)
else() target_link_libraries(SRB2SDL2 PRIVATE DiscordRPC::DiscordRPC)
find_package(OPENMPT) target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_DISCORDRPC)
endif() target_sources(SRB2SDL2 PRIVATE discord.c)
if(${OPENMPT_FOUND}) endif()
set(SRB2_HAVE_OPENMPT ON)
add_definitions(-DHAVE_OPENMPT) if(${SRB2_CONFIG_LIBBACKTRACE})
else() target_link_libraries(SRB2SDL2 PRIVATE libbacktrace)
message(WARNING "You have specified that OpenMPT is available but it was not found.") target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_LIBBACKTRACE)
endif() endif()
# FIXME macOS does not support C11 threads.h
if(NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
set(SRB2_HAVE_THREADS ON)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_THREADS)
endif() endif()
if(${SRB2_CONFIG_HAVE_ZLIB}) if(${SRB2_CONFIG_HAVE_ZLIB})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
set(ZLIB_FOUND ON) set(ZLIB_FOUND ON)
set(ZLIB_COMPAT ON)
set(WITH_GTEST OFF)
set(ZLIB_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/zlib) set(ZLIB_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/zlib)
if(${SRB2_SYSTEM_BITS} EQUAL 64) if(${SRB2_SYSTEM_BITS} EQUAL 64)
set(ZLIB_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/zlib/win32 -lz64") set(ZLIB_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/zlib/win32 -lz64")
@@ -442,9 +152,9 @@ if(${SRB2_CONFIG_HAVE_ZLIB})
endif() endif()
if(${ZLIB_FOUND}) if(${ZLIB_FOUND})
set(SRB2_HAVE_ZLIB ON) set(SRB2_HAVE_ZLIB ON)
add_definitions(-DHAVE_ZLIB) target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_ZLIB)
else() else()
message(WARNING "You have specified that ZLIB is available but it was not found. SRB2Kart may not compile correctly.") message(WARNING "You have specified that ZLIB is available but it was not found. SRB2Kart-Saturn may not compile correctly.")
endif() endif()
endif() endif()
@@ -463,162 +173,292 @@ if(${SRB2_CONFIG_HAVE_PNG} AND ${SRB2_CONFIG_HAVE_ZLIB})
endif() endif()
if(${PNG_FOUND}) if(${PNG_FOUND})
set(SRB2_HAVE_PNG ON) set(SRB2_HAVE_PNG ON)
add_definitions(-DHAVE_PNG) target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_PNG)
add_definitions(-D_LARGEFILE64_SOURCE) target_compile_definitions(SRB2SDL2 PRIVATE -D_LARGEFILE64_SOURCE)
source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS})
else() else()
message(WARNING "You have specified that PNG is available but it was not found. SRB2Kart may not compile correctly.") message(WARNING "You have specified that PNG is available but it was not found. SRB2Kart-Saturn may not compile correctly.")
endif() endif()
endif() endif()
endif() endif()
if(${SRB2_CONFIG_HAVE_CURL}) if("${SRB2_CONFIG_HWRENDER}")
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) target_compile_definitions(SRB2SDL2 PRIVATE -DHWRENDER)
set(CURL_FOUND ON) add_subdirectory(hardware)
set(CURL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/curl/include)
if(${SRB2_SYSTEM_BITS} EQUAL 64) if("${SRB2_CONFIG_STATIC_OPENGL}")
set(CURL_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/curl/lib64 -lcurl") find_package(OpenGL)
else() # 32-bit if(${OPENGL_FOUND})
set(CURL_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/curl/lib32 -lcurl") target_compile_definitions(SRB2SDL2 PRIVATE -DSTATIC_OPENGL)
else()
message(WARNING "You have specified static opengl but opengl was not found. Not setting HWRENDER.")
endif() endif()
else()
find_package(CURL)
endif()
if(${CURL_FOUND})
set(SRB2_HAVE_CURL ON)
add_definitions(-DHAVE_CURL)
else()
message(WARNING "You have specified that CURL is available but it was not found. SRB2Kart may not compile correctly.")
endif() endif()
endif() endif()
if(${SRB2_CONFIG_LIBBACKTRACE}) # TODO: build this with the game
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) if(${CMAKE_SYSTEM} MATCHES Windows AND ${CMAKE_C_COMPILER_ID} MATCHES "GNU" AND ${SRB2_SYSTEM_BITS} EQUAL 32)
if(${SRB2_SYSTEM_BITS} EQUAL 64) target_link_libraries(SRB2SDL2 PRIVATE
set(LIBBACKTRACE_FOUND ON) "${CMAKE_CURRENT_SOURCE_DIR}/../libs/drmingw/lib/win32/libexchndl.a"
set(LIBBACKTRACE_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/libbacktrace/include) "${CMAKE_CURRENT_SOURCE_DIR}/../libs/drmingw/lib/win32/libmgwhelp.a"
set(LIBBACKTRACE_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/libbacktrace/lib/x86_64 -lbacktrace")
else() # 32-bit
message(WARNING "libbacktrace is unsupported on 32-bit builds.")
endif()
else()
find_package(libbacktrace)
endif()
if(${LIBBACKTRACE_FOUND})
set(SRB2_HAVE_LIBBACKTRACE ON)
add_definitions(-DHAVE_LIBBACKTRACE)
else()
message(WARNING "You have specified that libbacktrace is available but it was not found.")
endif()
endif()
if(${SRB2_CONFIG_HWRENDER})
add_definitions(-DHWRENDER)
set(SRB2_HWRENDER_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_batching.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_shaders.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_bsp.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_cache.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_draw.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_portal.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md3load.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_model.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/u_list.c
) )
target_include_directories(SRB2SDL2 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../libs/drmingw/include")
set (SRB2_HWRENDER_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_batching.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_shaders.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_data.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_defs.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_gl.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_glob.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_portal.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md3load.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_model.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/u_list.h
)
set(SRB2_R_OPENGL_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/hardware/r_opengl/r_opengl.c
)
set(SRB2_R_OPENGL_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/hardware/r_opengl/r_opengl.h
)
endif()
if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL})
find_package(OpenGL)
if(${OPENGL_FOUND})
add_definitions(-DHWRENDER)
add_definitions(-DSTATIC_OPENGL)
else()
message(WARNING "You have specified static opengl but opengl was not found. Not setting HWRENDER.")
endif()
endif()
if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_SCREENFBO})
add_definitions(-DUSE_FBO_OGL)
endif()
if(${SRB2_CONFIG_SATURNPAK})
add_definitions(-DDOSATURNPAK)
endif()
if(${SRB2_CONFIG_SATURNJOIN})
add_definitions(-DDOSATURNJOIN)
endif() endif()
# Targets # Targets
# If using CCACHE, then force it.
# https://github.com/Cockatrice/Cockatrice/pull/3052/files
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
get_property(RULE_LAUNCH_COMPILE GLOBAL PROPERTY RULE_LAUNCH_COMPILE)
if(RULE_LAUNCH_COMPILE)
MESSAGE(STATUS "Force enabling CCache usage under macOS")
# Set up wrapper scripts
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/launch-c.in ${CMAKE_BINARY_DIR}/launch-c)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/launch-cxx.in ${CMAKE_BINARY_DIR}/launch-cxx)
execute_process(COMMAND chmod a+rx
"${CMAKE_BINARY_DIR}/launch-c"
"${CMAKE_BINARY_DIR}/launch-cxx")
# Set Xcode project attributes to route compilation through our scripts
set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/launch-c")
set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/launch-cxx")
set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR}/launch-c")
set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR}/launch-cxx")
endif()
endif()
# Compatibility flag with later versions of GCC # Compatibility flag with later versions of GCC
# We should really fix our code to not need this # We should really fix our code to not need this
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|x64|amd64|AMD64|em64t|EM64T)") if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|x64|amd64|AMD64|em64t|EM64T)")
add_compile_options(-mno-ms-bitfields) target_compile_options(SRB2SDL2 PRIVATE -mno-ms-bitfields)
endif() endif()
add_compile_options(-Wno-trigraphs) target_compile_options(SRB2SDL2 PRIVATE -Wno-trigraphs)
endif() 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) target_compile_options(SRB2SDL2 PRIVATE -fwrapv)
if (${CMAKE_BUILD_TYPE} MATCHES Debug) if (${CMAKE_BUILD_TYPE} MATCHES Debug)
add_compile_options(-O0) target_compile_options(SRB2SDL2 PRIVATE -O0)
target_compile_options(SRB2SDL2 PRIVATE -g)
else() else()
add_compile_options(-O3) target_compile_options(SRB2SDL2 PRIVATE -O3)
target_compile_options(SRB2SDL2 PRIVATE -g1) #should be enough for libbacktrace
endif() endif()
add_compile_options(-g) # Compiler warnings configuration
target_compile_options(SRB2SDL2 PRIVATE
# Using generator expressions to handle per-language compile options
add_definitions(-DCMAKECONFIG) # C, GNU
# This is a direct translation from versions.mk
$<$<AND:$<COMPILE_LANGUAGE:C>,$<C_COMPILER_ID:GNU>>:
-Wall
-Wextra
-Wno-trigraphs
-W # Was controlled by RELAXWARNINGS
-Wfloat-equal
-Wundef
-Wpointer-arith
-Wbad-function-cast
-Wcast-qual
-Wcast-align # Was controlled by NOCASTALIGNWARN
-Wwrite-strings
-Wsign-compare
-Wno-comment
-Wno-alloc-size-larger-than # holy shit, be quiet up GCC
-Wmissing-prototypes
-Wmissing-declarations
-Wmissing-noreturn
-Wnested-externs
-Wformat-y2k
-Wformat-security
#add_library(SRB2Core STATIC $<$<VERSION_LESS:$<C_COMPILER_VERSION>,2.9.5>:
# ${SRB2_CORE_SOURCES} -Wno-div-by-zero
# ${SRB2_CORE_HEADERS} -Wendif-labels
# ${SRB2_CORE_RENDER_SOURCES} -Wdisabled-optimization
# ${SRB2_CORE_GAME_SOURCES} >
# ${SRB2_LUA_SOURCES}
# ${SRB2_LUA_HEADERS}
# ${SRB2_BLUA_SOURCES}
# ${SRB2_BLUA_HEADERS}
#)
if(${SRB2_CONFIG_DEDICATED}) $<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.0.0>:
add_subdirectory(dedicated) -Wold-style-definition
else() -Wmissing-field-initializers
add_subdirectory(sdl) >
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.1.0>:
-Wshadow
>
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.3.0>:
-funit-at-a-time
-Wlogical-op
>
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.5.0>:
-Wlogical-op
-Wno-error=array-bounds
>
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.6.0>:
-Wno-suggest-attribute=noreturn
-Wno-error=suggest-attribute=noreturn
>
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,5.4.0>:
-Wno-logical-op
-Wno-error=logical-op
>
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,6.1.0>:
-Wno-tautological-compare
-Wno-error=tautological-compare
>
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,7.1.0>:
-Wno-error=format-overflow=2
-Wimplicit-fallthrough=4
>
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,8.1.0>:
-Wno-error=format-overflow
-Wno-error=stringop-truncation
-Wno-error=stringop-overflow
-Wno-format-overflow
-Wno-stringop-truncation
-Wno-stringop-overflow
-Wno-error=multistatement-macros
>
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,9.1.0>:
-Wno-error=address-of-packed-member
>
>
# C, Clang and Apple Clang
$<$<AND:$<COMPILE_LANGUAGE:C>,$<OR:$<C_COMPILER_ID:AppleClang>,$<C_COMPILER_ID:Clang>>>:
-Wall
-Wextra
-Wno-absolute-value
-Wno-trigraphs
-Wno-error=non-literal-null-conversion
-Wno-error=constant-conversion
-Wno-unused-but-set-variable
-Wno-error=unused-but-set-variable
>
# C++, GNU, Clang and Apple Clang
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<OR:$<C_COMPILER_ID:GNU>,$<C_COMPILER_ID:AppleClang>,$<C_COMPILER_ID:Clang>>>:
-Wall
-Wno-unused-function
-Wno-unused-but-set-variable
-Wno-unused-private-field
>
# GNU
$<$<C_COMPILER_ID:GNU>:
-fmax-errors=5
>
)
if(SRB2_CONFIG_ERRORMODE)
target_compile_options(SRB2SDL2 PRIVATE
$<$<OR:$<C_COMPILER_ID:GNU>,$<C_COMPILER_ID:AppleClang>,$<C_COMPILER_ID:Clang>>:
-Werror
>
)
endif() endif()
if(NOT ${SRB2_SDL2_AVAILABLE} AND NOT ${SRB2_WIN32_AVAILABLE}) # Link warnings configuration
message(FATAL_ERROR "There are no targets available to build an SRB2Kart executable. :(") target_link_options(SRB2SDL2 PRIVATE
$<$<C_COMPILER_ID:GNU>:
# -Wl,--as-needed - Was controlled by NOLDWARNING
>
)
if(${SRB2_CONFIG_DEV_BUILD})
target_compile_definitions(SRB2SDL2 PRIVATE -DDEVELOP)
endif()
target_compile_definitions(SRB2SDL2 PRIVATE -DCMAKECONFIG)
# Misc. build options from Makefiles
if(SRB2_CONFIG_DEBUGMODE)
target_compile_definitions(SRB2SDL2 PRIVATE -D_DEBUG -DZDEBUG -DPARANOIA -DRANGECHECK -DPACKETDROP)
endif()
if(SRB2_CONFIG_MOBJCONSISTANCY)
target_compile_definitions(SRB2SDL2 PRIVATE -DMOBJCONSISTANCY)
endif()
if(SRB2_CONFIG_PACKETDROP)
target_compile_definitions(SRB2SDL2 PRIVATE -DPACKETDROP)
endif()
if(SRB2_CONFIG_ZDEBUG)
target_compile_definitions(SRB2SDL2 PRIVATE -DZDEBUG)
endif()
if(SRB2_CONFIG_PROFILEMODE AND "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
target_compile_options(SRB2SDL2 PRIVATE -pg)
target_link_options(SRB2SDL2 PRIVATE -pg)
endif()
if(SRB2_CONFIG_LTO AND NOT SRB2_CONFIG_DEBUGMODE)
set_property(TARGET SRB2SDL2 PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
if(${SRB2_CONFIG_SCREENFBO} AND NOT ${SRB2_CONFIG_STATIC_OPENGL})
target_compile_definitions(SRB2SDL2 PRIVATE -DUSE_FBO_OGL)
endif()
if(${SRB2_CONFIG_SATURNPAK})
target_compile_definitions(SRB2SDL2 PRIVATE -DDOSATURNPAK)
endif()
if(${SRB2_CONFIG_SATURNJOIN})
target_compile_definitions(SRB2SDL2 PRIVATE -DDOSATURNJOIN)
endif()
# strip debug symbols into separate file when using gcc or clang.
# to be consistent with Makefile, don't generate for OS X.
if((CMAKE_COMPILER_IS_GNUCC OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND NOT ("${CMAKE_SYSTEM_NAME}" MATCHES Darwin))
if((${CMAKE_BUILD_TYPE} MATCHES Debug) OR (${CMAKE_BUILD_TYPE} MATCHES RelWithDebInfo))
if(${CMAKE_BUILD_TYPE} MATCHES Debug)
set(OBJCOPY_ONLY_KEEP_DEBUG "--only-keep-debug")
endif()
message(STATUS "Will make separate debug symbols in *.debug")
add_custom_command(TARGET SRB2SDL2 POST_BUILD
COMMAND ${CMAKE_OBJCOPY} ${OBJCOPY_ONLY_KEEP_DEBUG} $<TARGET_FILE:SRB2SDL2> $<TARGET_FILE:SRB2SDL2>.debug
# mold linker: .gnu_debuglink is present by default, so --add-gnu-debuglink would fail
COMMAND ${CMAKE_OBJCOPY} --strip-debug --remove-section=.gnu_debuglink $<TARGET_FILE:SRB2SDL2>
COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=$<TARGET_FILE:SRB2SDL2>.debug $<TARGET_FILE:SRB2SDL2>
)
endif()
endif()
# copy DLLs to bin/ directory if building internal shared on windows
if("${CMAKE_SYSTEM_NAME}" STREQUAL Windows AND NOT "${SRB2_CONFIG_INTERNAL_LIBRARIES}" AND "${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}")
set(ADDITIONAL_DLLS "")
if("${CMAKE_C_COMPILER_ID}" STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# also copy implicitly linked system libraries
get_filename_component(MINGW_BIN_PATH ${CMAKE_CXX_COMPILER} PATH)
if("${CMAKE_C_COMPILER_ID}" STREQUAL GNU)
list(APPEND ADDITIONAL_DLLS
"libgcc_s_dw2-1.dll"
"libstdc++-6.dll"
"libwinpthread-1.dll"
)
else()
list(APPEND ADDITIONAL_DLLS
"libunwind.dll"
"libc++.dll"
"libwinpthread-1.dll"
)
endif()
list(TRANSFORM ADDITIONAL_DLLS PREPEND "${MINGW_BIN_PATH}/")
endif()
add_custom_command(TARGET SRB2SDL2 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_RUNTIME_DLLS:SRB2SDL2>
${ADDITIONAL_DLLS}
$<TARGET_FILE_DIR:SRB2SDL2>
COMMAND_EXPAND_LISTS
COMMENT "Copying runtime DLLs"
)
endif() endif()
+3 -3
View File
@@ -64,9 +64,9 @@ endif
# This must have high to low order. # This must have high to low order.
gcc_versions:=\ gcc_versions:=\
152 151 150 15\ 151 150 15\
142 141 140 14\ 142 141 140 14\
133 132 131 130 13\ 132 131 130 13\
123 122 121 120 12\ 123 122 121 120 12\
114 113 112 111 110 11\ 114 113 112 111 110 11\
105 104 103 102 101 100 10\ 105 104 103 102 101 100 10\
@@ -77,7 +77,7 @@ gcc_versions:=\
55 54 53 52 51 50\ 55 54 53 52 51 50\
49 48 47 46 45 44 43 42 41 40 49 48 47 46 45 44 43 42 41 40
latest_gcc_version:=15.2 latest_gcc_version:=15.1.1
# Automatically set version flag, but not if one was # Automatically set version flag, but not if one was
# manually set. And don't bother if this is a clean only # manually set. And don't bother if this is a clean only
+1 -4
View File
@@ -20,10 +20,7 @@ $(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\
CXXFLAGS+= -Wno-aggregate-return CXXFLAGS+= -Wno-aggregate-return
# -W -Wno-unused # -W -Wno-unused
WFLAGS:=-Wall -Wno-trigraphs -Wnull-dereference WFLAGS:=-Wall -Wno-trigraphs
ifdef GCC152
WFLAGS+=-Wzero-as-null-pointer-constant
endif
ifndef GCC295 ifndef GCC295
#WFLAGS+=-Wno-packed #WFLAGS+=-Wno-packed
endif endif
+4
View File
@@ -226,6 +226,10 @@ const char *I_LocateWad(void)
return "/sdcard/srb2"; return "/sdcard/srb2";
} }
void I_GetJoystickEvents(void){}
void I_GetJoystick2Events(void){}
char *I_GetEnv(const char *name) char *I_GetEnv(const char *name)
{ {
LOGW("I_GetEnv() called?!"); LOGW("I_GetEnv() called?!");
+1
View File
@@ -0,0 +1 @@
target_sourcefile(c)
+1 -1
View File
@@ -527,7 +527,7 @@ static int str_find_aux (lua_State *L, int find) {
if (find) { if (find) {
lua_pushinteger(L, s1-s+1); /* start */ lua_pushinteger(L, s1-s+1); /* start */
lua_pushinteger(L, res-s); /* end */ lua_pushinteger(L, res-s); /* end */
return push_captures(&ms, NULL, NULL) + 2; return push_captures(&ms, NULL, 0) + 2;
} }
else else
return push_captures(&ms, s1, res); return push_captures(&ms, s1, res);
+3 -3
View File
@@ -772,10 +772,10 @@ union luai_Cast { double l_d; long l_l; };
#include <stdio.h> #include <stdio.h>
#if defined(__GNUC__) #if defined(__GNUC__)
#define l_likely(x) (__builtin_expect(!!(x), 1)) #define l_likely(x) (__builtin_expect(((x) != 0), 1))
#define l_unlikely(x) (__builtin_expect(!!(x), 0)) #define l_unlikely(x) (__builtin_expect(((x) != 0), 0))
#else #else
#define l_likely(x) (x) #define l_likely(x) (x)
#define l_unlikely(x) (x) #define l_unlikely(x) (x)
#endif #endif
+37 -45
View File
@@ -332,7 +332,7 @@ void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(const UINT8 **p, INT32 playernu
#ifdef PARANOIA #ifdef PARANOIA
if (id >= MAXNETXCMD) if (id >= MAXNETXCMD)
I_Error("Command id %d too big", id); I_Error("Command id %d too big", id);
if (listnetxcmd[id] != NULL) if (listnetxcmd[id] != 0)
I_Error("Command id %d already used", id); I_Error("Command id %d already used", id);
#endif #endif
listnetxcmd[id] = cmd_f; listnetxcmd[id] = cmd_f;
@@ -365,7 +365,7 @@ void SendNetXCmdForPlayer(UINT8 playerid, netxcmd_t id, const void *param, size_
CONS_Alert(CONS_NOTICE, M_GetText("NetXCmd buffer full, delaying netcmd %d... (size: %d, needed: %s)\n"), id, localtextcmd[playerid][0], sizeu1(nparam)); CONS_Alert(CONS_NOTICE, M_GetText("NetXCmd buffer full, delaying netcmd %d... (size: %d, needed: %s)\n"), id, localtextcmd[playerid][0], sizeu1(nparam));
if (buf == NULL) if (buf == NULL)
{ {
textcmdbuf[playerid] = (textcmdbuf_t*)Z_Malloc(sizeof(textcmdbuf_t), PU_STATIC, NULL); textcmdbuf[playerid] = Z_Malloc(sizeof(textcmdbuf_t), PU_STATIC, NULL);
textcmdbuf[playerid]->cmd[0] = 0; textcmdbuf[playerid]->cmd[0] = 0;
textcmdbuf[playerid]->next = NULL; textcmdbuf[playerid]->next = NULL;
WriteNetXCmd(textcmdbuf[playerid]->cmd, id, param, nparam); WriteNetXCmd(textcmdbuf[playerid]->cmd, id, param, nparam);
@@ -377,7 +377,7 @@ void SendNetXCmdForPlayer(UINT8 playerid, netxcmd_t id, const void *param, size_
if (buf->cmd[0]+2+nparam > MAXTEXTCMD) if (buf->cmd[0]+2+nparam > MAXTEXTCMD)
{ {
buf->next = (textcmdbuf_t*)Z_Malloc(sizeof(textcmdbuf_t), PU_STATIC, NULL); buf->next = Z_Malloc(sizeof(textcmdbuf_t), PU_STATIC, NULL);
buf->next->cmd[0] = 0; buf->next->cmd[0] = 0;
buf->next->next = NULL; buf->next->next = NULL;
WriteNetXCmd(buf->next->cmd, id, param, nparam); WriteNetXCmd(buf->next->cmd, id, param, nparam);
@@ -454,13 +454,13 @@ static UINT8* D_GetTextcmd(tic_t tic, INT32 playernum)
// If we don't have an entry for the tic, make it. // If we don't have an entry for the tic, make it.
if (!textcmdtic) if (!textcmdtic)
{ {
textcmdtic = *tctprev = (textcmdtic_t*)Z_Calloc(sizeof (textcmdtic_t), PU_STATIC, NULL); textcmdtic = *tctprev = Z_Calloc(sizeof (textcmdtic_t), PU_STATIC, NULL);
textcmdtic->tic = tic; textcmdtic->tic = tic;
} }
// If we don't have an entry for the player, make it. // If we don't have an entry for the player, make it.
if (!textcmdtic->playercmds[playernum]) if (!textcmdtic->playercmds[playernum])
textcmdtic->playercmds[playernum] = (UINT8*)Z_Calloc(MAXTEXTCMD, PU_STATIC, NULL); textcmdtic->playercmds[playernum] = Z_Calloc(MAXTEXTCMD, PU_STATIC, NULL);
return textcmdtic->playercmds[playernum]; return textcmdtic->playercmds[playernum];
} }
@@ -1141,7 +1141,7 @@ typedef enum
static void GetPackets(void); static void GetPackets(void);
static cl_mode_t cl_mode = CL_SEARCHING; static cl_mode_t cl_mode = CL_SEARCHING;
static UINT16 cl_lastcheckedfilecount = 0; // used for full file list static UINT16 cl_lastcheckedfilecount = 0; // used for full file list
// Player name send/load // Player name send/load
@@ -1182,7 +1182,7 @@ static void CV_LoadPlayerNames(UINT8 **p)
// //
// Keep the local client informed of our status. // Keep the local client informed of our status.
// //
static void CL_DrawConnectionStatus(void) static inline void CL_DrawConnectionStatus(void)
{ {
INT32 ccstime = I_GetTime(); INT32 ccstime = I_GetTime();
@@ -1217,26 +1217,24 @@ static void CL_DrawConnectionStatus(void)
case CL_DOWNLOADSAVEGAME: case CL_DOWNLOADSAVEGAME:
if (filedownload.current != -1) if (filedownload.current != -1)
{ {
INT32 dldlength = 0; UINT32 currentsize = fileneeded[filedownload.current].currentsize;
fileneeded_t *file = &fileneeded[filedownload.current]; UINT32 totalsize = fileneeded[filedownload.current].totalsize;
UINT32 currentsize = file->currentsize; INT32 dldlength;
UINT32 totalsize = file->totalsize;
cltext = M_GetText("Downloading game state..."); cltext = M_GetText("Downloading game state...");
Net_GetNetStat(); Net_GetNetStat();
if (totalsize != 0) dldlength = (INT32)((currentsize/(double)totalsize) * 256);
dldlength = (INT32)((currentsize/(double)totalsize) * 256);
if (dldlength > 256) if (dldlength > 256)
dldlength = 256; dldlength = 256;
V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 111); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 111);
V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, dldlength, 8, 96); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, dldlength, 8, 96);
V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE,
va(" %4uK/%4uK", currentsize>>10, totalsize>>10)); va(" %4uK/%4uK",currentsize>>10,totalsize>>10));
V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE,
va("%3.1fK/s ", ((double)getbps)/1024.0)); va("%3.1fK/s ", ((double)getbps)/1024));
} }
else else
cltext = M_GetText("Waiting to download game state..."); cltext = M_GetText("Waiting to download game state...");
@@ -1272,30 +1270,29 @@ static void CL_DrawConnectionStatus(void)
{ {
if (cl_mode == CL_CHECKFILES) if (cl_mode == CL_CHECKFILES)
{ {
INT32 totalfileslength = 0; INT32 totalfileslength;
INT32 checkednum = 0; INT32 checkednum = 0;
INT32 i; INT32 i;
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-24, V_YELLOWMAP|MENUCAPS, "Press ESC to abort"); V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-24, V_YELLOWMAP|MENUCAPS, "Press ESC to abort");
// ima just count files here //ima just count files here
for (i = 0; i < fileneedednum; i++) for (i = 0; i < fileneedednum; i++)
if (fileneeded[i].status != FS_NOTCHECKED) if (fileneeded[i].status != FS_NOTCHECKED)
checkednum++; checkednum++;
// Loading progress // Loading progress
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP|MENUCAPS, "Checking server addons..."); V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP|MENUCAPS, "Checking server addons...");
if (fileneedednum != 0) totalfileslength = (INT32)((checkednum/(double)(fileneedednum)) * 256);
totalfileslength = (INT32)((checkednum/(double)fileneedednum) * 256);
M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1); M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1);
V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 175); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 175);
V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, totalfileslength, 8, 160); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, totalfileslength, 8, 160);
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS,
va(" %2u/%2u Files", checkednum, fileneedednum)); va(" %2u/%2u Files",checkednum,fileneedednum));
} }
else if (cl_mode == CL_LOADFILES) else if (cl_mode == CL_LOADFILES)
{ {
INT32 totalfileslength = 0; INT32 totalfileslength;
INT32 loadcompletednum = 0; INT32 loadcompletednum = 0;
INT32 i; INT32 i;
@@ -1308,13 +1305,12 @@ static void CL_DrawConnectionStatus(void)
// Loading progress // Loading progress
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP|MENUCAPS, "Loading server addons..."); V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP|MENUCAPS, "Loading server addons...");
if (fileneedednum != 0) totalfileslength = (INT32)((loadcompletednum/(double)(fileneedednum)) * 256);
totalfileslength = (INT32)((loadcompletednum/(double)fileneedednum) * 256);
M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1); M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1);
V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 175); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 175);
V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, totalfileslength, 8, 160); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, totalfileslength, 8, 160);
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS,
va(" %2u/%2u Files", loadcompletednum, fileneedednum)); va(" %2u/%2u Files",loadcompletednum,fileneedednum));
} }
else if (cl_mode == CL_VIEWSERVER) else if (cl_mode == CL_VIEWSERVER)
{ {
@@ -1442,22 +1438,19 @@ static void CL_DrawConnectionStatus(void)
} }
else if (filedownload.current != -1) else if (filedownload.current != -1)
{ {
INT32 dldlength = 0; INT32 dldlength;
INT32 totalfileslength = 0; INT32 totalfileslength;
UINT32 totaldldsize = 0; UINT32 totaldldsize;
static char tempname[28]; static char tempname[28];
fileneeded_t *file = &fileneeded[filedownload.current]; fileneeded_t *file = &fileneeded[filedownload.current];
char *filename = file->filename; char *filename = file->filename;
UINT32 currentsize = file->currentsize;
UINT32 totalsize = file->totalsize;
// Draw the bottom box. // Draw the bottom box.
M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-58-8, 32, 1); M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-58-8, 32, 1);
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-14, V_YELLOWMAP|MENUCAPS, "Press ESC to abort"); V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-14, V_YELLOWMAP|MENUCAPS, "Press ESC to abort");
Net_GetNetStat(); Net_GetNetStat();
if (totalsize != 0) dldlength = (INT32)((file->currentsize/(double)file->totalsize) * 256);
dldlength = (INT32)((currentsize/(double)totalsize) * 256);
if (dldlength > 256) if (dldlength > 256)
dldlength = 256; dldlength = 256;
V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, 256, 8, 175); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, 256, 8, 175);
@@ -1490,30 +1483,29 @@ static void CL_DrawConnectionStatus(void)
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-22, V_YELLOWMAP|MENUCAPS, V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-22, V_YELLOWMAP|MENUCAPS,
va(M_GetText("\"%s\""), tempname)); va(M_GetText("\"%s\""), tempname));
V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, V_20TRANS|V_MONOSPACE|MENUCAPS, V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, V_20TRANS|V_MONOSPACE|MENUCAPS,
va(" %4uK/%4uK", currentsize>>10, totalsize>>10)); va(" %4uK/%4uK",file->currentsize>>10,file->totalsize>>10));
V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-58, V_20TRANS|V_MONOSPACE|MENUCAPS, V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-58, V_20TRANS|V_MONOSPACE|MENUCAPS,
va("%3.1fK/s ", ((double)getbps)/1024.0)); va("%3.1fK/s ", ((double)getbps)/1024));
// Download progress // Download progress
if (currentsize != totalsize) if (file->currentsize != file->totalsize)
totaldldsize = filedownload.completedsize+currentsize; // Add in single file progress download if applicable totaldldsize = filedownload.completedsize+file->currentsize; //Add in single file progress download if applicable
else else
totaldldsize = filedownload.completedsize; totaldldsize = filedownload.completedsize;
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-14, V_YELLOWMAP|MENUCAPS, "Overall Download Progress"); V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-14, V_YELLOWMAP|MENUCAPS, "Overall Download Progress");
if (filedownload.totalsize != 0) totalfileslength = (INT32)((totaldldsize/(double)filedownload.totalsize) * 256);
totalfileslength = (INT32)((totaldldsize/(double)filedownload.totalsize) * 256);
M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1); M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1);
V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 175); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 175);
V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, totalfileslength, 8, 160); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, totalfileslength, 8, 160);
if (filedownload.totalsize>>20 >= 10) // display in MB if over 10MB if (filedownload.totalsize>>20 >= 10) //display in MB if over 10MB
V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS,
va(" %4uM/%4uM", totaldldsize>>20, filedownload.totalsize>>20)); va(" %4uM/%4uM",totaldldsize>>20,filedownload.totalsize>>20));
else else
V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS,
va(" %4uK/%4uK", totaldldsize>>10, filedownload.totalsize>>10)); va(" %4uK/%4uK",totaldldsize>>10,filedownload.totalsize>>10));
V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS,
va("%2u/%2u Files ", filedownload.completednum, filedownload.totalnum)); va("%2u/%2u Files ", filedownload.completednum, filedownload.totalnum));
@@ -1963,7 +1955,7 @@ static boolean SV_ResendingSavegameToAnyone(void)
static void SV_SendSaveGame(INT32 node, boolean resending) static void SV_SendSaveGame(INT32 node, boolean resending)
{ {
size_t length, compressedlen; size_t length, compressedlen;
savebuffer_t save = {}; savebuffer_t save = {0};
UINT8 *compressedsave; UINT8 *compressedsave;
UINT8 *buffertosend; UINT8 *buffertosend;
@@ -2033,7 +2025,7 @@ static consvar_t cv_dumpconsistency = {"dumpconsistency", "Off", CV_NETVAR, CV_O
static void SV_SavedGame(void) static void SV_SavedGame(void)
{ {
size_t length; size_t length;
savebuffer_t save = {}; savebuffer_t save = {0};
char tmpsave[264]; char tmpsave[264];
if (!cv_dumpconsistency.value) if (!cv_dumpconsistency.value)
@@ -2073,7 +2065,7 @@ static void SV_SavedGame(void)
static void CL_LoadReceivedSavegame(boolean reloading) static void CL_LoadReceivedSavegame(boolean reloading)
{ {
savebuffer_t save = {}; savebuffer_t save = {0};
size_t length, decompressedlen; size_t length, decompressedlen;
char tmpsave[264]; char tmpsave[264];
@@ -7237,7 +7229,7 @@ void CL_ClearRewinds(void)
rewind_t *CL_SaveRewindPoint(size_t demopos) rewind_t *CL_SaveRewindPoint(size_t demopos)
{ {
savebuffer_t save = {}; savebuffer_t save = {0};
rewind_t *rewind; rewind_t *rewind;
if (rewindhead && rewindhead->leveltime + REWIND_POINT_INTERVAL > leveltime) if (rewindhead && rewindhead->leveltime + REWIND_POINT_INTERVAL > leveltime)
@@ -7260,7 +7252,7 @@ rewind_t *CL_SaveRewindPoint(size_t demopos)
rewind_t *CL_RewindToTime(tic_t time) rewind_t *CL_RewindToTime(tic_t time)
{ {
savebuffer_t save = {}; savebuffer_t save = {0};
rewind_t *rewind; rewind_t *rewind;
while (rewindhead && rewindhead->leveltime > time) while (rewindhead && rewindhead->leveltime > time)
+9 -11
View File
@@ -664,7 +664,7 @@ void D_SRB2Loop(void)
tic_t entertic = 0, oldentertics = 0, realtics = 0, rendertimeout = INFTICS; tic_t entertic = 0, oldentertics = 0, realtics = 0, rendertimeout = INFTICS;
double deltatics = 0.0; double deltatics = 0.0;
double deltasecs = 0.0; double deltasecs = 0.0;
UINT64 precision = 0; UINT64 precision;
boolean interp = false; boolean interp = false;
boolean doDisplay = false; boolean doDisplay = false;
@@ -907,9 +907,7 @@ 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();
@@ -973,9 +971,6 @@ void D_ClearState(void)
// //
void D_StartTitle(void) void D_StartTitle(void)
{ {
if (dedicated)
I_Error("D_StartTitle is called on dedicated server");
D_ClearState(); D_ClearState();
multiplayer = netgame = false; // title menu shouldnt be a netgame or multiplayer lmao multiplayer = netgame = false; // title menu shouldnt be a netgame or multiplayer lmao
F_StartTitleScreen(); F_StartTitleScreen();
@@ -1216,13 +1211,17 @@ static void IdentifyVersion(void)
#endif #endif
char tempsrb2path[256] = "."; char tempsrb2path[256] = ".";
if (getcwd(tempsrb2path, 256) == NULL) getcwd(tempsrb2path, 256);
strcpy(tempsrb2path, ".");
// get the current directory (possible problem on NT with "." as current dir) // get the current directory (possible problem on NT with "." as current dir)
if (!srb2waddir) if (!srb2waddir)
{ {
srb2waddir = tempsrb2path; if (tempsrb2path[0])
srb2waddir = tempsrb2path;
else
{
srb2waddir = ".";
}
} }
#if (1) // reduce the amount of findfile by only using full cwd in this func #if (1) // reduce the amount of findfile by only using full cwd in this func
@@ -1895,8 +1894,7 @@ void D_SRB2Main(void)
if (M_CheckParm("-warp") && M_IsNextParm()) if (M_CheckParm("-warp") && M_IsNextParm())
{ {
const char *word = M_GetNextParm(); const char *word = M_GetNextParm();
pstartmap = G_FindMapByNameOrCode(word, NULL); pstartmap = G_FindMapByNameOrCode(word, 0);
if (! pstartmap) if (! pstartmap)
I_Error("Cannot find a map remotely named '%s'\n", word); I_Error("Cannot find a map remotely named '%s'\n", word);
else else
+2 -2
View File
@@ -59,7 +59,7 @@ static INT16 reboundsize[MAXREBOUND];
static INT32 rebound_head, rebound_tail; static INT32 rebound_head, rebound_tail;
/// \brief max length per packet /// \brief max length per packet
INT16 hardware_MAXPACKETLENGTH = 0; INT16 hardware_MAXPACKETLENGTH;
boolean (*I_NetGet)(void) = NULL; boolean (*I_NetGet)(void) = NULL;
void (*I_NetSend)(void) = NULL; void (*I_NetSend)(void) = NULL;
@@ -96,7 +96,7 @@ INT32 ticruned = 0, ticmiss = 0;
// globals // globals
INT32 getbps = 0, sendbps = 0; INT32 getbps = 0, sendbps = 0;
float lostpercent = 0.0f, duppercent = 0.0f, gamelostpercent = 0.0f; float lostpercent = 0, duppercent = 0, gamelostpercent = 0;
INT32 packetheaderlength = 0; INT32 packetheaderlength = 0;
boolean Net_GetNetStat(void) boolean Net_GetNetStat(void)
+8 -13
View File
@@ -54,9 +54,6 @@
#include "fastcmp.h" #include "fastcmp.h"
#include "m_perfstats.h" #include "m_perfstats.h"
#include "r_data.h"
#include "r_skins.h"
#ifdef NETGAME_DEVMODE #ifdef NETGAME_DEVMODE
#define CV_RESTRICT CV_NETVAR #define CV_RESTRICT CV_NETVAR
#else #else
@@ -252,7 +249,7 @@ consvar_t cv_competitionboxes = {"competitionboxes", "Random", CV_NETVAR|CV_CHEA
#ifdef SEENAMES #ifdef SEENAMES
static CV_PossibleValue_t seenames_cons_t[] = {{0, "Off"}, {1, "Colorless"}, {2, "Team"}, {3, "Ally/Foe"}, {0, NULL}}; static CV_PossibleValue_t seenames_cons_t[] = {{0, "Off"}, {1, "Colorless"}, {2, "Team"}, {3, "Ally/Foe"}, {0, NULL}};
consvar_t cv_seenames = {"seenames", "Off", CV_SAVE, seenames_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_seenames = {"seenames", "Off", CV_SAVE, seenames_cons_t, 0, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_allowseenames = {"allowseenames", "No", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_allowseenames = {"allowseenames", "No", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
#endif #endif
@@ -461,16 +458,16 @@ consvar_t cv_showping = {"showping", "Always", CV_SAVE, showping_cons_t, NULL, 0
static CV_PossibleValue_t pingmeasurement_cons_t[] = {{0, "Frames"}, {1, "Milliseconds"}, {0, NULL}}; static CV_PossibleValue_t pingmeasurement_cons_t[] = {{0, "Frames"}, {1, "Milliseconds"}, {0, NULL}};
consvar_t cv_pingmeasurement = {"pingmeasurement", "Frames", CV_SAVE, pingmeasurement_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_pingmeasurement = {"pingmeasurement", "Frames", CV_SAVE, pingmeasurement_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_pingicon = {"pingicon", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_pingicon = {"pingicon", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t cv_pingstyle_cons_t[] = {{0, "New"}, {1, "Old"}, {0, NULL}}; static CV_PossibleValue_t cv_pingstyle_cons_t[] = {{0, "New"}, {1, "Old"}, {0, NULL}};
consvar_t cv_pingstyle = {"pingstyle", "New", CV_SAVE, cv_pingstyle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_pingstyle = {"pingstyle", "New", CV_SAVE, cv_pingstyle_cons_t, 0, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_luaimmersion = {"luaimmersion", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_luaimmersion = {"luaimmersion", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_showviewpointtext = {"showviewpointtext", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showviewpointtext = {"showviewpointtext", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_showdownloadprompt = {"showdownloadprompt", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showdownloadprompt = {"showdownloadprompt", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL};
// Intermission time Tails 04-19-2002 // Intermission time Tails 04-19-2002
static CV_PossibleValue_t inttime_cons_t[] = {{0, "MIN"}, {3600, "MAX"}, {0, NULL}}; static CV_PossibleValue_t inttime_cons_t[] = {{0, "MIN"}, {3600, "MAX"}, {0, NULL}};
@@ -1009,9 +1006,6 @@ 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);
@@ -2658,6 +2652,7 @@ 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;
@@ -2794,7 +2789,7 @@ static void Command_Map_f(void)
// G_TOLFlag handles both multiplayer gametype and ignores it for !multiplayer // G_TOLFlag handles both multiplayer gametype and ignores it for !multiplayer
else else
{ {
if (mapheaderinfo[newmapnum-1] == NULL) if (!mapheaderinfo[newmapnum-1])
{ {
CONS_Alert(CONS_WARNING, M_GetText("Invalid mapheaderinfo for Course %s (%s)\n"), realmapname, G_BuildMapName(newmapnum)); CONS_Alert(CONS_WARNING, M_GetText("Invalid mapheaderinfo for Course %s (%s)\n"), realmapname, G_BuildMapName(newmapnum));
return; return;
+3 -8
View File
@@ -131,8 +131,6 @@ static UINT32 curl_origtotalfilesize;
static char *curl_realname = NULL; static char *curl_realname = NULL;
fileneeded_t *curl_curfile = NULL; fileneeded_t *curl_curfile = NULL;
HTTP_login *curl_logins = NULL; HTTP_login *curl_logins = NULL;
static void CURLGetFile(void);
#endif #endif
/** Fills a serverinfo packet with information about wad files loaded. /** Fills a serverinfo packet with information about wad files loaded.
@@ -1307,7 +1305,6 @@ void CURLPrepareFile(const char* url, int dfilenum)
if (!multi_handle) if (!multi_handle)
{ {
cc = curl_global_init(CURL_GLOBAL_ALL); cc = curl_global_init(CURL_GLOBAL_ALL);
if (cc < 0) if (cc < 0)
{ {
I_OutputMsg("libcurl: curl_global_init() returned %d\n", cc); I_OutputMsg("libcurl: curl_global_init() returned %d\n", cc);
@@ -1316,7 +1313,6 @@ void CURLPrepareFile(const char* url, int dfilenum)
{ {
multi_handle = curl_multi_init(); multi_handle = curl_multi_init();
} }
if (!multi_handle) if (!multi_handle)
{ {
I_OutputMsg("libcurl: curl_multi_init() failed\n"); I_OutputMsg("libcurl: curl_multi_init() failed\n");
@@ -1445,7 +1441,7 @@ void CURLAbortFile(void)
#endif #endif
} }
static void CURLGetFile(void) void CURLGetFile(void)
{ {
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
I_lock_mutex(&downloadmutex); I_lock_mutex(&downloadmutex);
@@ -1487,8 +1483,7 @@ static void CURLGetFile(void)
e = m->easy_handle; e = m->easy_handle;
easyres = m->data.result; easyres = m->data.result;
char *filename = malloc(strlen(curl_realname)+1); char *filename = Z_StrDup(curl_realname);
strcpy(filename, curl_realname);
nameonly(filename); nameonly(filename);
if (easyres != CURLE_OK) if (easyres != CURLE_OK)
@@ -1526,7 +1521,7 @@ static void CURLGetFile(void)
} }
} }
free(filename); Z_Free(filename);
curl_curfile->file = NULL; curl_curfile->file = NULL;
filedownload.remaining--; filedownload.remaining--;
mc = curl_multi_remove_handle(multi_handle, e); mc = curl_multi_remove_handle(multi_handle, e);
+1
View File
@@ -119,6 +119,7 @@ size_t nameonlylength(const char *s);
#ifdef HAVE_CURL #ifdef HAVE_CURL
void CURLPrepareFile(const char* url, int dfilenum); void CURLPrepareFile(const char* url, int dfilenum);
void CURLAbortFile(void); void CURLAbortFile(void);
void CURLGetFile(void);
HTTP_login * CURLGetLogin (const char *url, HTTP_login ***return_prev_next); HTTP_login * CURLGetLogin (const char *url, HTTP_login ***return_prev_next);
size_t curlwrite_data(void *ptr, size_t size, size_t nmemb, FILE *stream); size_t curlwrite_data(void *ptr, size_t size, size_t nmemb, FILE *stream);
#endif #endif
+22 -93
View File
@@ -1,75 +1,21 @@
# Declare dedicated interface sources # Declare dedicated interface sources
set(SRB2_DEDICATED_SOURCES target_sourcefile(c)
i_system.c
i_main.c
i_video.c
i_sound.c
i_threads.c
dosstr.c
endtxt.c
)
set(SRB2_DEDICATED_HEADERS target_sources(SRB2SDL2 PRIVATE)
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)
set(SRB2_DEDICATED_TOTAL_SOURCES ${SRB2_DEDICATED_TOTAL_SOURCES} target_sources(SRB2SDL2 PRIVATE
${CMAKE_SOURCE_DIR}/src/win32/win_dbg.c ../win32/win_dbg.c
${CMAKE_SOURCE_DIR}/src/win32/Srb2win.rc ../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 srb2kartd) set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2legacy)
elseif(${CMAKE_SYSTEM} MATCHES Linux) elseif(${CMAKE_SYSTEM} MATCHES Linux)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME lsrb2kartd) set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME lsrb2dlegacy)
else() else()
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2kartd) set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2legacy)
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)
@@ -78,27 +24,25 @@ 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()
if(${SRB2_HAVE_LIBBACKTRACE}) #target_link_libraries(SRB2SDL2 PRIVATE SRB2Core)
target_link_libraries(SRB2SDL2 PRIVATE ${LIBBACKTRACE_LIBRARIES})
endif() set_target_properties(SRB2SDL2 PROPERTIES VERSION ${SRB2_VERSION})
if(${CMAKE_SYSTEM} MATCHES Windows) if(${CMAKE_SYSTEM} MATCHES Windows)
target_link_libraries(SRB2SDL2 PRIVATE target_link_libraries(SRB2SDL2 PRIVATE
@@ -116,34 +60,19 @@ target_include_directories(SRB2SDL2 PRIVATE
target_compile_definitions(SRB2SDL2 PRIVATE target_compile_definitions(SRB2SDL2 PRIVATE
-DDEDICATED -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 ## 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)
# message(STATUS "Will make separate debug symbols in *.debug") message(STATUS "Will make separate debug symbols in *.debug")
# add_custom_command(TARGET SRB2SDL2 POST_BUILD add_custom_command(TARGET SRB2SDL2 POST_BUILD
# COMMAND ${OBJCOPY} --only-keep-debug $<TARGET_FILE:SRB2SDL2> $<TARGET_FILE:SRB2SDL2>.debug COMMAND ${OBJCOPY} --only-keep-debug $<TARGET_FILE:SRB2SDL2> $<TARGET_FILE:SRB2SDL2>.debug
# COMMAND ${OBJCOPY} --strip-debug $<TARGET_FILE:SRB2SDL2> COMMAND ${OBJCOPY} --strip-debug $<TARGET_FILE:SRB2SDL2>
# COMMAND ${OBJCOPY} --add-gnu-debuglink=$<TARGET_FILE_NAME:SRB2SDL2>.debug $<TARGET_FILE:SRB2SDL2> COMMAND ${OBJCOPY} --add-gnu-debuglink=$<TARGET_FILE_NAME:SRB2SDL2>.debug $<TARGET_FILE:SRB2SDL2>
# ) )
# endif() endif()
# endif() endif()
#### Installation #### #### Installation ####
if(${CMAKE_SYSTEM} MATCHES Darwin) if(${CMAKE_SYSTEM} MATCHES Darwin)
+7 -3
View File
@@ -167,8 +167,6 @@ static char returnWadPath[256];
#include "../i_video.h" #include "../i_video.h"
#include "../i_sound.h" #include "../i_sound.h"
#include "../i_system.h" #include "../i_system.h"
#include "../i_time.h"
#include "../i_net.h"
#include "../screen.h" //vid.WndParent #include "../screen.h" //vid.WndParent
#include "../d_net.h" #include "../d_net.h"
#include "../g_game.h" #include "../g_game.h"
@@ -194,6 +192,8 @@ UINT8 keyboard_started = false;
#ifdef HAVE_TERMIOS #ifdef HAVE_TERMIOS
// TERMIOS console code from Quake3: thank you! // TERMIOS console code from Quake3: thank you!
boolean stdin_active = true;
typedef struct typedef struct
{ {
size_t cursor; size_t cursor;
@@ -695,7 +695,11 @@ void I_JoyScale4(void)
*/ */
void I_ShutdownJoystick(UINT8 index) void I_ShutdownJoystick(void)
{
}
void I_GetJoystickEvents(UINT8 index)
{ {
(void)index; (void)index;
} }
+9 -32
View File
@@ -40,47 +40,24 @@
#define ASMCALL #define ASMCALL
#endif #endif
#include "doomtype.h" #define _USE_MATH_DEFINES // fixes M_PI errors in r_plane.c for Visual Studio
#ifdef __cplusplus
#ifdef __cplusplus /* Only when compiled as C++ */ #include <cmath>
#include <algorithm> /* std::min, std::max, std::sort, … */ #else
#include <math.h>
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
// Force libc++ to expose std::min/std::max even when <cmath> is included first (Apple clang quirk)
#ifndef _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
#define _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
#endif
#ifndef _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
#define _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
#endif
// Optional: only try <version> if it actually exists (newer Xcode)
#if __has_include(<version>)
#include <version>
#endif
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <cstddef>
#include <cstring>
#include <climits>
extern "C" { extern "C" {
#else #endif
#include <math.h>
#include "doomtype.h"
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stddef.h>
#include <string.h> #include <string.h>
#include <limits.h>
#endif
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <ctype.h> #include <ctype.h>
+1 -1
View File
@@ -1318,7 +1318,7 @@ boolean F_ContinueResponder(event_t *event)
keypressed = true; keypressed = true;
imcontinuing = true; imcontinuing = true;
continuetime = TICRATE; continuetime = TICRATE;
S_StartSound(NULL, sfx_itemup); S_StartSound(0, sfx_itemup);
return true; return true;
} }
+2 -5
View File
@@ -49,7 +49,7 @@ size_t menupathindex[menudepth] = {};
size_t menudepthleft = menudepth; size_t menudepthleft = menudepth;
char menusearchbuf[MAXSTRINGLENGTH+1]; char menusearchbuf[MAXSTRINGLENGTH+1];
textinput_t menusearch = {}; textinput_t menusearch;
char **dirmenu = NULL, **coredirmenu = NULL; // core only local for this file char **dirmenu = NULL, **coredirmenu = NULL; // core only local for this file
size_t sizedirmenu = 0, sizecoredirmenu = 0; // ditto size_t sizedirmenu = 0, sizecoredirmenu = 0; // ditto
@@ -271,13 +271,10 @@ static boolean filemenucmp(char *haystack, char *needle)
{ {
static char localhaystack[128]; static char localhaystack[128];
strlcpy(localhaystack, haystack, 128); strlcpy(localhaystack, haystack, 128);
if (!cv_addons_search_case.value) if (!cv_addons_search_case.value)
strupr(localhaystack); strupr(localhaystack);
if (cv_addons_search_type.value) if (cv_addons_search_type.value)
return (strstr(localhaystack, needle) != NULL); return (strstr(localhaystack, needle) != 0);
return (!strncmp(localhaystack, needle, menusearch.length)); return (!strncmp(localhaystack, needle, menusearch.length));
} }
+1 -1
View File
@@ -76,7 +76,7 @@ static tic_t demostarttime; // for comparative timing purposes
//@TODO put these all in a struct for namespacing purposes? //@TODO put these all in a struct for namespacing purposes?
static char demoname[128]; static char demoname[128];
savebuffer_t demobuf = {}; savebuffer_t demobuf = {0};
static UINT8 *demotime_p, *demoinfo_p; static UINT8 *demotime_p, *demoinfo_p;
static UINT8 *demoend; static UINT8 *demoend;
static UINT8 demoflags; static UINT8 demoflags;
+14 -14
View File
@@ -132,7 +132,7 @@ UINT8 skincolor_bluering = SKINCOLOR_STEEL;
tic_t countdowntimer = 0; tic_t countdowntimer = 0;
boolean countdowntimeup = false; boolean countdowntimeup = false;
cutscene_t *cutscenes[128] = {}; cutscene_t *cutscenes[128];
INT16 nextmapoverride = 0; INT16 nextmapoverride = 0;
boolean skipstats = false; boolean skipstats = false;
@@ -144,7 +144,7 @@ mobj_t *blueflag = NULL;
mapthing_t *rflagpoint = NULL; mapthing_t *rflagpoint = NULL;
mapthing_t *bflagpoint = NULL; mapthing_t *bflagpoint = NULL;
struct quake quake = {}; struct quake quake;
// Map Header Information // Map Header Information
mapheader_t* mapheaderinfo[NUMMAPS] = {}; mapheader_t* mapheaderinfo[NUMMAPS] = {};
@@ -228,7 +228,7 @@ tic_t racecountdown = 0, exitcountdown = 0; // for racing
fixed_t gravity = 0; fixed_t gravity = 0;
fixed_t mapobjectscale = FRACUNIT; fixed_t mapobjectscale = FRACUNIT;
struct maplighting maplighting = {}; struct maplighting maplighting;
INT16 autobalance = 0; //for CTF team balance INT16 autobalance = 0; //for CTF team balance
INT16 teamscramble = 0; //for CTF team scramble INT16 teamscramble = 0; //for CTF team scramble
@@ -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] = {
{"kartautoaccel", "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},
{"kartautoaccel2", "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},
{"kartautoaccel3", "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},
{"kartautoaccel4", "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}}; static CV_PossibleValue_t driftsparkpulse_t[] = {{0, "MIN"}, {FRACUNIT*3, "MAX"}, {0, NULL}};
@@ -3501,7 +3501,7 @@ void G_LoadGameData(void)
INT32 i, j; INT32 i, j;
UINT8 modded = false; UINT8 modded = false;
UINT8 rtemp; UINT8 rtemp;
savebuffer_t save = {}; savebuffer_t save = {0};
//For records //For records
tic_t rectime; tic_t rectime;
@@ -3634,7 +3634,7 @@ void G_SaveGameData(boolean force)
size_t length; size_t length;
INT32 i, j; INT32 i, j;
UINT8 btemp; UINT8 btemp;
savebuffer_t save = {}; savebuffer_t save = {0};
(void)force; (void)force;
char backupfile[MAX_WADPATH+4]; char backupfile[MAX_WADPATH+4];
@@ -3805,7 +3805,7 @@ void G_LoadGame(UINT32 slot, INT16 mapoverride)
size_t length; size_t length;
char vcheck[VERSIONSIZE]; char vcheck[VERSIONSIZE];
char savename[255]; char savename[255];
savebuffer_t save = {}; savebuffer_t save = {0};
// memset savedata to all 0, fixes calling perfectly valid saves corrupt because of bots // memset savedata to all 0, fixes calling perfectly valid saves corrupt because of bots
memset(&savedata, 0, sizeof(savedata)); memset(&savedata, 0, sizeof(savedata));
@@ -3891,7 +3891,7 @@ void G_SaveGame(UINT32 savegameslot)
boolean saved; boolean saved;
char savename[256] = ""; char savename[256] = "";
const char *backup; const char *backup;
savebuffer_t save = {}; savebuffer_t save = {0};
sprintf(savename, savegamename, savegameslot); sprintf(savename, savegamename, savegameslot);
backup = va("%s",savename); backup = va("%s",savename);
@@ -4161,7 +4161,7 @@ static void measurekeywords(mapsearchfreq_t *fr,
PU_STATIC, NULL); PU_STATIC, NULL);
for (qp = strtok(va("%s", q), " "); for (qp = strtok(va("%s", q), " ");
qp && fr->total < 255; qp && fr->total < 255;
qp = strtok(NULL, " ")) qp = strtok(0, " "))
{ {
if (( sp = strcasestr(s, qp) )) if (( sp = strcasestr(s, qp) ))
{ {
@@ -4242,7 +4242,7 @@ INT32 G_FindMap(const char *mapname, char **foundmapnamep,
{ {
newmapnum = mapnum; newmapnum = mapnum;
newmapname = realmapname; newmapname = realmapname;
realmapname = NULL; realmapname = 0;
Z_Free(apromapname); Z_Free(apromapname);
if (!wanttable) if (!wanttable)
break; break;
@@ -4263,7 +4263,7 @@ INT32 G_FindMap(const char *mapname, char **foundmapnamep,
{ {
apromapnum = mapnum; apromapnum = mapnum;
apromapname = realmapname; apromapname = realmapname;
realmapname = NULL; realmapname = 0;
} }
} }
else/* ...match individual keywords */ else/* ...match individual keywords */
-1
View File
@@ -130,7 +130,6 @@ extern consvar_t cv_spinoutroll;
extern consvar_t cv_squishdance, cv_squishdancespeed; extern consvar_t cv_squishdance, cv_squishdancespeed;
extern consvar_t cv_playerblendeffects; extern consvar_t cv_playerblendeffects;
extern consvar_t cv_reducevfx;
extern consvar_t cv_cechotoggle; extern consvar_t cv_cechotoggle;
+7 -8
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} {"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)
@@ -933,7 +930,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 || (window_notinfocus && cv_gamepadledifunfocused.value == 0) if (cv_gamepadled[playernum].value == 0
|| color >= MAXTRANSLATIONS) || color >= MAXTRANSLATIONS)
{ {
return; return;
@@ -948,8 +945,6 @@ void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT8 color)
static void G_ResetPlayerGamepadIndicatorColor(INT32 playernum) static void G_ResetPlayerGamepadIndicatorColor(INT32 playernum)
{ {
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS);
if (cv_gamepadled[playernum].value == 0) if (cv_gamepadled[playernum].value == 0)
{ {
I_SetGamepadIndicatorColor(playernum, 0, 0, 255); I_SetGamepadIndicatorColor(playernum, 0, 0, 255);
@@ -978,8 +973,13 @@ void G_DeviceLEDTick(void)
newcolor = G_GetSkinColorForGamepad(i); newcolor = G_GetSkinColorForGamepad(i);
// compiler be absolutely tripping
// delet this if this gets fixed within gcc
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
if (curcolor[i] == newcolor) // dont update if same colour if (curcolor[i] == newcolor) // dont update if same colour
continue; continue;
#pragma GCC diagnostic pop
G_SetPlayerGamepadIndicatorColor(i, newcolor); G_SetPlayerGamepadIndicatorColor(i, newcolor);
curcolor[i] = newcolor; curcolor[i] = newcolor;
@@ -994,7 +994,6 @@ void G_ResetDeviceLED(void)
static void G_ResetPlayerDeviceRumble(INT32 playernum) static void G_ResetPlayerDeviceRumble(INT32 playernum)
{ {
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS);
I_GamepadRumble(playernum, 0, 0, 0); I_GamepadRumble(playernum, 0, 0, 0);
} }
@@ -1012,7 +1011,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 || (window_notinfocus && cv_rumbleifunfocused.value == 0)) if (cv_rumble[playernum].value == 0)
{ {
return; return;
} }
-3
View File
@@ -116,9 +116,6 @@ 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
View File
@@ -0,0 +1 @@
target_sourcefile(c)
+1 -1
View File
@@ -391,7 +391,7 @@ void HWR_RenderBatches(void)
nextSurfaceInfo = nextEntry->surf; nextSurfaceInfo = nextEntry->surf;
if (nextPolyFlags & PF_NoTexture) if (nextPolyFlags & PF_NoTexture)
nextTexture = NULL; nextTexture = 0;
if (useshader && currentShader != nextShader) if (useshader && currentShader != nextShader)
{ {
+5 -2
View File
@@ -619,6 +619,7 @@ static void HWR_PrecacheLevelFlats(void)
// lookup for flats that may´ve been already loaded // lookup for flats that may´ve been already loaded
// too lazy to make a hashtable or smth so unordered set will do :carbuncle: // too lazy to make a hashtable or smth so unordered set will do :carbuncle:
std::unordered_set<UINT32> flatpresent; std::unordered_set<UINT32> flatpresent;
lumpnum_t lump;
size_t i, j; size_t i, j;
INT32 k; INT32 k;
@@ -648,8 +649,9 @@ static void HWR_PrecacheLevelFlats(void)
const INT32 pic = ceiling ? sec->ceilingpic : sec->floorpic; const INT32 pic = ceiling ? sec->ceilingpic : sec->floorpic;
const levelflat_t *levelflat = &levelflats[pic]; const levelflat_t *levelflat = &levelflats[pic];
lump = levelflat->lumpnum;
load_flat(levelflat->lumpnum, R_NoEncore(sec, ceiling)); load_flat(lump, R_NoEncore(sec, ceiling));
if (levelflat->speed) // is it an animated flat ? if (levelflat->speed) // is it an animated flat ?
{ {
@@ -670,8 +672,9 @@ static void HWR_PrecacheLevelFlats(void)
for (i = 0; i < numlevelflats; i++) for (i = 0; i < numlevelflats; i++)
{ {
const levelflat_t *levelflat = &levelflats[i]; const levelflat_t *levelflat = &levelflats[i];
lump = levelflat->lumpnum;
load_flat(levelflat->lumpnum, false); load_flat(lump, false);
if (levelflat->speed) // is it an animated flat ? if (levelflat->speed) // is it an animated flat ?
{ {
+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)lrint(ANG1 * floatangle); a1 = (angle_t)xs_CRoundToInt(ANG1 * floatangle);
return a1; return a1;
} }
-3
View File
@@ -80,9 +80,6 @@ UINT32 GL_CreateLightTable(RGBA_t *hw_lighttable);
void GL_ClearLightTables(void); void GL_ClearLightTables(void);
void GL_SetScreenPalette(RGBA_t *palette); void GL_SetScreenPalette(RGBA_t *palette);
void GL_Draw2DModel(model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex,
FTransform *pos, float hscale, float vscale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
#endif #endif
+33 -44
View File
@@ -101,8 +101,7 @@ sector_t *gl_backsector = NULL;
static constexpr float clipping_distances[] = {1024.0f, 2048.0f, 4096.0f, 6144.0f, 8192.0f, 12288.0f, 16384.0f}; static constexpr float clipping_distances[] = {1024.0f, 2048.0f, 4096.0f, 6144.0f, 8192.0f, 12288.0f, 16384.0f};
// values for bsp culling // values for bsp culling
// slightly higher than the far clipping plane to compensate for impreciseness // slightly higher than the far clipping plane to compensate for impreciseness
static constexpr INT32 bsp_culling_distances[] = { static constexpr INT32 bsp_culling_distances[] = {(1024+512)*FRACUNIT, (2048+512)*FRACUNIT, (4096+512)*FRACUNIT,
(1024+512)*FRACUNIT, (2048+512)*FRACUNIT, (4096+512)*FRACUNIT,
(6144+512)*FRACUNIT, (8192+512)*FRACUNIT, (12288+512)*FRACUNIT, (16384+512)*FRACUNIT}; (6144+512)*FRACUNIT, (8192+512)*FRACUNIT, (12288+512)*FRACUNIT, (16384+512)*FRACUNIT};
// Performance stats // Performance stats
@@ -588,11 +587,15 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
const sector_t *sec = FOFsector ? FOFsector : gl_frontsector; const sector_t *sec = FOFsector ? FOFsector : gl_frontsector;
// Get the slope pointer to simplify future code // Get the slope pointer to simplify future code
if (!isceiling && sec->f_slope) if (sec->f_slope && !isceiling)
slope = sec->f_slope; slope = sec->f_slope;
else if (isceiling && sec->c_slope) else if (sec->c_slope && isceiling)
slope = sec->c_slope; slope = sec->c_slope;
// Set fixedheight to the slope's height from our viewpoint, if we have a slope
if (slope)
fixedheight = P_GetSlopeZAt(slope, viewx, viewy);
height = FixedToFloat(fixedheight); height = FixedToFloat(fixedheight);
// Allocate plane-vertex buffer if we need to // Allocate plane-vertex buffer if we need to
@@ -684,19 +687,18 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
vert->s = (tempxsow * cosangf) - (tempytow * sinangf);\ vert->s = (tempxsow * cosangf) - (tempytow * sinangf);\
vert->t = (tempxsow * sinangf) + (tempytow * cosangf);\ vert->t = (tempxsow * sinangf) + (tempytow * cosangf);\
}\ }\
\
if (slope)\
{\
fixedheight = P_GetSlopeZAt(slope, FloatToFixed((vx)), FloatToFixed((vy)));\
height = FixedToFloat(fixedheight);\
}\
\ \
vert->x = (vx);\ vert->x = (vx);\
vert->y = height;\ vert->y = height;\
vert->z = (vy);\ vert->z = (vy);\
\ \
if (slope)\
{\
fixedheight = P_GetSlopeZAt(slope, FloatToFixed((vx)), FloatToFixed((vy)));\
vert->y = FixedToFloat(fixedheight);\
}\
} }
for (i = 0, v3d = planeVerts; i < (INT32)nrPlaneVerts; i++,v3d++, pv++) for (i = 0, v3d = planeVerts; i < (INT32)nrPlaneVerts; i++,v3d++,pv++)
SETUP3DVERT(v3d, pv->x, pv->y); SETUP3DVERT(v3d, pv->x, pv->y);
if (slope) if (slope)
@@ -1783,10 +1785,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
// Single sided line... Deal only with the middletexture (if one exists) // Single sided line... Deal only with the middletexture (if one exists)
if (gl_midtexture && gl_linedef->special != HORIZONSPECIAL) // Ignore horizon line for OGL if (gl_midtexture && gl_linedef->special != HORIZONSPECIAL) // Ignore horizon line for OGL
{ {
fixed_t texturevpeg;
glTex = HWR_GetTexture(gl_midtexture, noencore); glTex = HWR_GetTexture(gl_midtexture, noencore);
fixed_t texturevpeg;
// PEGGING // PEGGING
if ((gl_linedef->flags & (ML_DONTPEGBOTTOM|ML_EFFECT2)) == (ML_DONTPEGBOTTOM|ML_EFFECT2)) if ((gl_linedef->flags & (ML_DONTPEGBOTTOM|ML_EFFECT2)) == (ML_DONTPEGBOTTOM|ML_EFFECT2))
texturevpeg = gl_frontsector->floorheight + textureheight[gl_sidedef->midtexture] - gl_frontsector->ceilingheight + gl_sidedef->rowoffset; texturevpeg = gl_frontsector->floorheight + textureheight[gl_sidedef->midtexture] - gl_frontsector->ceilingheight + gl_sidedef->rowoffset;
@@ -1873,8 +1875,8 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
//Hurdler: 3d-floors test //Hurdler: 3d-floors test
if (!gl_drawing_stencil && gl_backsector && gl_frontsector->tag != gl_backsector->tag && (gl_backsector->ffloors || gl_frontsector->ffloors)) if (!gl_drawing_stencil && gl_backsector && gl_frontsector->tag != gl_backsector->tag && (gl_backsector->ffloors || gl_frontsector->ffloors))
{ {
ffloor_t *rover; ffloor_t * rover;
fixed_t highcut = 0, lowcut = 0; fixed_t highcut = 0, lowcut = 0;
fixed_t lowcutslope = 0, highcutslope = 0; fixed_t lowcutslope = 0, highcutslope = 0;
// Used for height comparisons and etc across FOFs and slopes // Used for height comparisons and etc across FOFs and slopes
@@ -2945,7 +2947,7 @@ static void HWR_Subsector(size_t num)
static sector_t tempsec; //SoM: 4/7/2000 static sector_t tempsec; //SoM: 4/7/2000
INT32 floorlightlevel; INT32 floorlightlevel;
INT32 ceilinglightlevel; INT32 ceilinglightlevel;
INT32 locFloorHeight = 0, locCeilingHeight = 0; INT32 locFloorHeight, locCeilingHeight;
INT32 cullFloorHeight, cullCeilingHeight; INT32 cullFloorHeight, cullCeilingHeight;
INT32 light = 0; INT32 light = 0;
extracolormap_t *floorcolormap; extracolormap_t *floorcolormap;
@@ -2991,12 +2993,11 @@ static void HWR_Subsector(size_t num)
cullFloorHeight = P_GetSectorFloorZAt (gl_frontsector, viewx, viewy); cullFloorHeight = P_GetSectorFloorZAt (gl_frontsector, viewx, viewy);
cullCeilingHeight = P_GetSectorCeilingZAt(gl_frontsector, viewx, viewy); cullCeilingHeight = P_GetSectorCeilingZAt(gl_frontsector, viewx, viewy);
locFloorHeight = P_GetSectorFloorZAt (gl_frontsector, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y);
locCeilingHeight = P_GetSectorCeilingZAt(gl_frontsector, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y);
if (gl_frontsector->ffloors) if (gl_frontsector->ffloors)
{ {
locFloorHeight = P_GetSectorFloorZAt (gl_frontsector, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y);
locCeilingHeight = P_GetSectorCeilingZAt(gl_frontsector, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y);
boolean anyMoved = gl_frontsector->moved; boolean anyMoved = gl_frontsector->moved;
if (anyMoved == false) if (anyMoved == false)
@@ -3051,7 +3052,8 @@ static void HWR_Subsector(size_t num)
{ {
HWR_GetFlat(levelflats[gl_frontsector->floorpic].lumpnum, R_NoEncore(gl_frontsector, false)); HWR_GetFlat(levelflats[gl_frontsector->floorpic].lumpnum, R_NoEncore(gl_frontsector, false));
HWR_RenderPlane(sub, &extrasubsectors[num], false, HWR_RenderPlane(sub, &extrasubsectors[num], false,
gl_frontsector->floorheight, // Hack to make things continue to work around slopes.
locFloorHeight == cullFloorHeight ? locFloorHeight : gl_frontsector->floorheight,
// We now return you to your regularly scheduled rendering. // We now return you to your regularly scheduled rendering.
PF_Occlude, floorlightlevel, levelflats[gl_frontsector->floorpic].lumpnum, NULL, 255, floorcolormap); PF_Occlude, floorlightlevel, levelflats[gl_frontsector->floorpic].lumpnum, NULL, 255, floorcolormap);
} }
@@ -3066,7 +3068,8 @@ static void HWR_Subsector(size_t num)
{ {
HWR_GetFlat(levelflats[gl_frontsector->ceilingpic].lumpnum, R_NoEncore(gl_frontsector, true)); HWR_GetFlat(levelflats[gl_frontsector->ceilingpic].lumpnum, R_NoEncore(gl_frontsector, true));
HWR_RenderPlane(sub, &extrasubsectors[num], true, HWR_RenderPlane(sub, &extrasubsectors[num], true,
gl_frontsector->ceilingheight, // Hack to make things continue to work around slopes.
locCeilingHeight == cullCeilingHeight ? locCeilingHeight : gl_frontsector->ceilingheight,
// We now return you to your regularly scheduled rendering. // We now return you to your regularly scheduled rendering.
PF_Occlude, ceilinglightlevel, levelflats[gl_frontsector->ceilingpic].lumpnum, NULL, 255, ceilingcolormap); PF_Occlude, ceilinglightlevel, levelflats[gl_frontsector->ceilingpic].lumpnum, NULL, 255, ceilingcolormap);
} }
@@ -3783,15 +3786,8 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite)
blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude; blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude;
} }
if (sprmo->player) if (cv_playerfade.value && sprmo->player)
{ Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha);
// make hyu´d players translucent with reducevfx, could be done better, but im lazy as crap
if (cv_reducevfx.value && sprmo->player->kartstuff[k_hyudorotimer] > 0)
Surf.PolyColor.s.alpha = FixedMul(FRACUNIT/2, Surf.PolyColor.s.alpha);
if (cv_playerfade.value)
Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha);
}
if (HWR_UseShader()) if (HWR_UseShader())
{ {
@@ -4080,15 +4076,8 @@ static void HWR_DrawSprite(gl_vissprite_t *spr)
blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude; blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude;
} }
if (sprmo->player) if (cv_playerfade.value && sprmo->player)
{ Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha);
// make hyu´d players translucent with reducevfx, could be done better, but im lazy as crap
if (cv_reducevfx.value && sprmo->player->kartstuff[k_hyudorotimer] > 0)
Surf.PolyColor.s.alpha = FixedMul(FRACUNIT/2, Surf.PolyColor.s.alpha);
if (cv_playerfade.value)
Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha);
}
if (HWR_UseShader()) if (HWR_UseShader())
{ {
@@ -5444,7 +5433,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.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; trans->shearing = true;
gl_aimingangle = 0; gl_aimingangle = 0;
} }
@@ -5549,7 +5538,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool
player_t *viewplayer = &players[displayplayers[viewssnum]]; player_t *viewplayer = &players[displayplayers[viewssnum]];
const float fpov = FixedToFloat(R_GetPlayerFov(viewplayer)); const float fpov = FixedToFloat(R_GetPlayerFov(viewplayer));
auto reset_viewstate = [&]() auto reset_viewstate = [&](const float fpov)
{ {
HWR_SetTransform(fpov); HWR_SetTransform(fpov);
HWR_ClearSprites(); HWR_ClearSprites();
@@ -5569,7 +5558,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool
currentportallist = &portallist; currentportallist = &portallist;
HWR_SetPortalState(GLPORTAL_SEARCH); HWR_SetPortalState(GLPORTAL_SEARCH);
reset_viewstate(); reset_viewstate(fpov);
if (rootportal) if (rootportal)
{ {
@@ -5595,7 +5584,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool
// draw normal things in current frame in current incremented stencil buffer area // draw normal things in current frame in current incremented stencil buffer area
HWR_SetStencilState(HWR_STENCIL_NORMAL, stencil_level); HWR_SetStencilState(HWR_STENCIL_NORMAL, stencil_level);
reset_viewstate(); reset_viewstate(fpov);
if constexpr (Type == RenderViewpointType::kPortal) if constexpr (Type == RenderViewpointType::kPortal)
{ {
@@ -6111,7 +6100,7 @@ static void HWR_DoPostProcessor(void)
const camera_t *thiscam = &camera[0]; const camera_t *thiscam = &camera[0];
// Not supported in splitscreen - someone want to add support? // Not supported in splitscreen - someone want to add support?
const boolean screenwave = (!splitscreen && !cv_reducevfx.value && (thiscam->postimg & POSTIMG_WATER || thiscam->postimg & POSTIMG_HEAT)); const boolean screenwave = (!splitscreen && (thiscam->postimg & POSTIMG_WATER || thiscam->postimg & POSTIMG_HEAT));
// Capture the screen for intermission and screen waving // Capture the screen for intermission and screen waving
if ((lastdraw || screenwave) && gamestate != GS_INTERMISSION) if ((lastdraw || screenwave) && gamestate != GS_INTERMISSION)
+3 -122
View File
@@ -579,7 +579,7 @@ md2found:
fclose(f); 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; FILE *f;
char name[20], filename[32]; char name[20], filename[32];
@@ -1198,15 +1198,8 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
Surf.PolyFlags = HWR_GetBlendModeFlag(blendmode); Surf.PolyFlags = HWR_GetBlendModeFlag(blendmode);
} }
if (spr->mobj->player) if (cv_playerfade.value && spr->mobj->player)
{ Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(spr->mobj), Surf.PolyColor.s.alpha);
// make hyu´d players translucent with reducevfx, could be done better, but im lazy as crap
if (cv_reducevfx.value && spr->mobj->player->kartstuff[k_hyudorotimer] > 0)
Surf.PolyColor.s.alpha = FixedMul(FRACUNIT/2, Surf.PolyColor.s.alpha);
if (cv_playerfade.value)
Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(spr->mobj), Surf.PolyColor.s.alpha);
}
// dont forget to enabled the depth test because we can't do this like // dont forget to enabled the depth test because we can't do this like
// before: polygons models are not sorted // before: polygons models are not sorted
@@ -1475,116 +1468,4 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
} }
} }
// mostly copy paste of HWR_DrawMD2
// very ugly but our model code kinda sucks
void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t color, const UINT8 *colormap, fixed_t scale, INT32 frame, angle_t angle)
{
patch_t *gpatch, *blendgpatch;
GLPatch_t *hwrPatch = NULL, *hwrBlendPatch = NULL;
FTransform p;
FSurfaceInfo Surf;
if (!md2->model)
{
char filename[64];
CONS_Debug(DBG_RENDER, "Loading model... (%s)\n", md2->filename);
sprintf(filename, "mdls/%s", md2->filename);
md2->model = md2_readModel(filename);
if (md2->model)
{
md2_printModelInfo(md2->model);
GL_CreateModelVBOs(md2->model);
}
else
{
md2->error = true;
return;
}
}
if (md2->model->meshes[0].numFrames > 0)
frame = frame % md2->model->meshes[0].numFrames;
else
frame = 0;
gpatch = (patch_t *)(md2->glpatch);
if (gpatch)
hwrPatch = ((GLPatch_t *)gpatch->hardware);
if (!gpatch || !hwrPatch ||
((!hwrPatch->mipmap->format || !hwrPatch->mipmap->downloaded) && !md2->notexturefile))
md2_loadTexture(md2);
gpatch = (patch_t*)(md2->glpatch);
if (gpatch)
hwrPatch = ((GLPatch_t *)gpatch->hardware);
blendgpatch = (patch_t*)(md2->blendglpatch);
if (blendgpatch)
hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware);
if ((gpatch && hwrPatch && hwrPatch->mipmap->format) &&
(!blendgpatch || !hwrBlendPatch ||
((!hwrBlendPatch->mipmap->format || !hwrBlendPatch->mipmap->downloaded) && !md2->noblendfile)))
md2_loadBlendTexture(md2);
blendgpatch = (patch_t*)(md2->blendglpatch);
if (blendgpatch)
hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware);
memset(&Surf, 0x00, sizeof(FSurfaceInfo));
Surf.PolyColor.rgba = 0xFFFFFFFF;
Surf.PolyFlags = PF_Occlude | PF_Modulated;
Surf.LightInfo.light_level = 255;
Surf.LightInfo.fade_start = 0;
Surf.LightInfo.fade_end = 31;
if (color != SKINCOLOR_NONE &&
blendgpatch && hwrBlendPatch->mipmap->format &&
gpatch->width == blendgpatch->width && gpatch->height == blendgpatch->height)
{
INT32 tcskinnum = TC_DEFAULT;
if (color)
tcskinnum = skinnum;
HWR_GetBlendedTexture(gpatch, blendgpatch, tcskinnum, colormap, color);
}
else if (hwrPatch && hwrPatch->mipmap->format)
{
GL_SetTexture(hwrPatch->mipmap);
}
memset(&p, 0x00, sizeof(FTransform));
p.x = x*vid.dup + (float)(vid.width - BASEVIDWIDTH*vid.dup)/2.f;
p.y = -420.f; // push it back to prevent wonky culling, idk lul
p.z = y*vid.dup + (float)(vid.height - BASEVIDHEIGHT*vid.dup)/2.f;
p.angley = FixedToFloat(AngleFixed(angle));
p.anglex = 0.f;
p.anglez = 0.f;
p.roll = false;
p.fliptype = TRANSFORM_NONE;
const float fscale = FixedToFloat(scale*vid.dup);
GL_Draw2DModel(
md2->model,
frame,
0.f,
0.f,
-1,
&p,
fscale,
fscale,
true, // flip it vertically lul
false,
&Surf
);
}
#endif //HWRENDER #endif //HWRENDER
-3
View File
@@ -45,9 +45,6 @@ void HWR_InitMD2(void);
void HWR_DrawMD2(gl_vissprite_t *spr); void HWR_DrawMD2(gl_vissprite_t *spr);
void HWR_AddPlayerMD2(INT32 skin, boolean local); void HWR_AddPlayerMD2(INT32 skin, boolean local);
void HWR_AddSpriteMD2(size_t spritenum); void HWR_AddSpriteMD2(size_t spritenum);
void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum,
skincolors_t color, const UINT8 *colormap,
fixed_t scale, INT32 frame, angle_t angle);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
+14 -14
View File
@@ -274,7 +274,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
if (!f) if (!f)
return NULL; return NULL;
retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, NULL); retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, 0);
//size_t fileLen; //size_t fileLen;
@@ -288,13 +288,13 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
{ {
texPos++; texPos++;
namelen = strlen(texPos) + 1; namelen = strlen(texPos) + 1;
texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, NULL); texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, 0);
strcpy(texturefilename, texPos); strcpy(texturefilename, texPos);
} }
else else
{ {
namelen = strlen(fileName) + 1; namelen = strlen(fileName) + 1;
texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, NULL); texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, 0);
strcpy(texturefilename, fileName); strcpy(texturefilename, fileName);
} }
@@ -316,7 +316,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
header = (md2header_t*)buffer; header = (md2header_t*)buffer;
retModel->numMeshes = 1; // MD2 only has one mesh retModel->numMeshes = 1; // MD2 only has one mesh
retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * retModel->numMeshes, ztag, NULL); retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * retModel->numMeshes, ztag, 0);
retModel->meshes[0].numFrames = header->numFrames; retModel->meshes[0].numFrames = header->numFrames;
// const float WUNITS = 1.0f; // const float WUNITS = 1.0f;
// float dataScale = WUNITS; // float dataScale = WUNITS;
@@ -332,7 +332,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
if (retModel->numMaterials <= 0) // Always at least one skin, duh if (retModel->numMaterials <= 0) // Always at least one skin, duh
retModel->numMaterials = 1; retModel->numMaterials = 1;
retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, NULL); retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, 0);
// int t; // int t;
for (t = 0; t < retModel->numMaterials; t++) for (t = 0; t < retModel->numMaterials; t++)
@@ -409,9 +409,9 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
float *uvptr; float *uvptr;
dataScale = 0.015624f; // 1 / 64.0f dataScale = 0.015624f; // 1 / 64.0f
retModel->meshes[0].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*header->numFrames, ztag, NULL); retModel->meshes[0].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*header->numFrames, ztag, 0);
retModel->meshes[0].numVertices = header->numXYZ; retModel->meshes[0].numVertices = header->numXYZ;
retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, NULL); retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, 0);
ptr = (char*)frames; ptr = (char*)frames;
for (i = 0; i < header->numFrames; i++, ptr += header->framesize) for (i = 0; i < header->numFrames; i++, ptr += header->framesize)
@@ -423,12 +423,12 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
md2vertex_t *vertex; md2vertex_t *vertex;
md2frame_t *framePtr = (md2frame_t*)ptr; md2frame_t *framePtr = (md2frame_t*)ptr;
retModel->meshes[0].tinyframes[i].vertices = (short*)Z_Malloc(sizeof(short) * 3 * header->numXYZ, ztag, NULL); retModel->meshes[0].tinyframes[i].vertices = (short*)Z_Malloc(sizeof(short) * 3 * header->numXYZ, ztag, 0);
retModel->meshes[0].tinyframes[i].normals = (char*)Z_Malloc(sizeof(char) * 3 * header->numXYZ, ztag, NULL); retModel->meshes[0].tinyframes[i].normals = (char*)Z_Malloc(sizeof(char) * 3 * header->numXYZ, ztag, 0);
// if (retModel->materials[0].lightmap) // if (retModel->materials[0].lightmap)
// retModel->meshes[0].tinyframes[i].tangents = (char*)malloc(sizeof(char));//(char*)Z_Malloc(sizeof(char)*3*header->numVerts, ztag); // retModel->meshes[0].tinyframes[i].tangents = (char*)malloc(sizeof(char));//(char*)Z_Malloc(sizeof(char)*3*header->numVerts, ztag);
retModel->meshes[0].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * header->numTris, ztag, NULL); retModel->meshes[0].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * header->numTris, ztag, 0);
vertptr = retModel->meshes[0].tinyframes[i].vertices; vertptr = retModel->meshes[0].tinyframes[i].vertices;
normptr = retModel->meshes[0].tinyframes[i].normals; normptr = retModel->meshes[0].tinyframes[i].normals;
@@ -484,8 +484,8 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
char *ptr; char *ptr;
retModel->meshes[0].numVertices = header->numTris * 3; retModel->meshes[0].numVertices = header->numTris * 3;
retModel->meshes[0].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*header->numFrames, ztag, NULL); retModel->meshes[0].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*header->numFrames, ztag, 0);
retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, NULL); retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, 0);
trisPtr = tris; trisPtr = tris;
uvptr = retModel->meshes[0].uvs; uvptr = retModel->meshes[0].uvs;
@@ -507,8 +507,8 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
md2vertex_t *vertex; md2vertex_t *vertex;
md2frame_t *framePtr = (md2frame_t*)ptr; md2frame_t *framePtr = (md2frame_t*)ptr;
retModel->meshes[0].frames[i].normals = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, NULL); retModel->meshes[0].frames[i].normals = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, 0);
retModel->meshes[0].frames[i].vertices = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, NULL); retModel->meshes[0].frames[i].vertices = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, 0);
// if (retModel->materials[0].lightmap) // if (retModel->materials[0].lightmap)
// retModel->meshes[0].frames[i].tangents = (float*)malloc(sizeof(float));//(float*)Z_Malloc(sizeof(float)*3*header->numTris*3, ztag); // retModel->meshes[0].frames[i].tangents = (float*)malloc(sizeof(float));//(float*)Z_Malloc(sizeof(float)*3*header->numTris*3, ztag);
//float *vertptr, *normptr; //float *vertptr, *normptr;
+12 -12
View File
@@ -168,7 +168,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat)
if (!f) if (!f)
return NULL; return NULL;
retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, NULL); retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, 0);
// find length of file // find length of file
fseek(f, 0, SEEK_END); fseek(f, 0, SEEK_END);
@@ -201,7 +201,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat)
if (retModel->numMaterials <= 0) // Always at least one skin, duh if (retModel->numMaterials <= 0) // Always at least one skin, duh
retModel->numMaterials = 1; retModel->numMaterials = 1;
retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, NULL); retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, 0);
for (t = 0; t < retModel->numMaterials; t++) for (t = 0; t < retModel->numMaterials; t++)
{ {
@@ -225,7 +225,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat)
retModel->materials[t].spheremap = false; retModel->materials[t].spheremap = false;
} }
retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t)*retModel->numMeshes, ztag, NULL); retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t)*retModel->numMeshes, ztag, 0);
matCount = 0; matCount = 0;
for (i = 0, surfEnd = 0; i < mdh->numSurfaces; i++) for (i = 0, surfEnd = 0; i < mdh->numSurfaces; i++)
@@ -298,9 +298,9 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat)
unsigned short *indexptr; unsigned short *indexptr;
md3Triangle *mdT; md3Triangle *mdT;
retModel->meshes[i].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*mdS->numFrames, ztag, NULL); retModel->meshes[i].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*mdS->numFrames, ztag, 0);
retModel->meshes[i].numVertices = mdS->numVerts; retModel->meshes[i].numVertices = mdS->numVerts;
retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numVerts, ztag, NULL); retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numVerts, ztag, 0);
for (j = 0; j < mdS->numFrames; j++) for (j = 0; j < mdS->numFrames; j++)
{ {
short *vertptr; short *vertptr;
@@ -308,12 +308,12 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat)
// char *tanptr; // char *tanptr;
int k; int k;
md3Vertex *mdV = (md3Vertex*)((char*)mdS + mdS->offsetXYZNormal + (mdS->numVerts*j*sizeof(md3Vertex))); md3Vertex *mdV = (md3Vertex*)((char*)mdS + mdS->offsetXYZNormal + (mdS->numVerts*j*sizeof(md3Vertex)));
retModel->meshes[i].tinyframes[j].vertices = (short*)Z_Malloc(sizeof(short)*3*mdS->numVerts, ztag, NULL); retModel->meshes[i].tinyframes[j].vertices = (short*)Z_Malloc(sizeof(short)*3*mdS->numVerts, ztag, 0);
retModel->meshes[i].tinyframes[j].normals = (char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag, NULL); retModel->meshes[i].tinyframes[j].normals = (char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag, 0);
// if (retModel->materials[0].lightmap) // if (retModel->materials[0].lightmap)
// retModel->meshes[i].tinyframes[j].tangents = (char*)malloc(sizeof(char));//(char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag); // retModel->meshes[i].tinyframes[j].tangents = (char*)malloc(sizeof(char));//(char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag);
retModel->meshes[i].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * mdS->numTriangles, ztag, NULL); retModel->meshes[i].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * mdS->numTriangles, ztag, 0);
vertptr = retModel->meshes[i].tinyframes[j].vertices; vertptr = retModel->meshes[i].tinyframes[j].vertices;
normptr = retModel->meshes[i].tinyframes[j].normals; normptr = retModel->meshes[i].tinyframes[j].normals;
@@ -374,16 +374,16 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat)
int k; int k;
retModel->meshes[i].numVertices = mdS->numTriangles * 3;//mdS->numVerts; retModel->meshes[i].numVertices = mdS->numTriangles * 3;//mdS->numVerts;
retModel->meshes[i].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*mdS->numFrames, ztag, NULL); retModel->meshes[i].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*mdS->numFrames, ztag, 0);
retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numTriangles*3, ztag, NULL); retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numTriangles*3, ztag, 0);
for (j = 0; j < mdS->numFrames; j++) for (j = 0; j < mdS->numFrames; j++)
{ {
float *vertptr; float *vertptr;
float *normptr; float *normptr;
md3Vertex *mdV = (md3Vertex*)((char*)mdS + mdS->offsetXYZNormal + (mdS->numVerts*j*sizeof(md3Vertex))); md3Vertex *mdV = (md3Vertex*)((char*)mdS + mdS->offsetXYZNormal + (mdS->numVerts*j*sizeof(md3Vertex)));
retModel->meshes[i].frames[j].vertices = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, NULL); retModel->meshes[i].frames[j].vertices = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, 0);
retModel->meshes[i].frames[j].normals = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, NULL); retModel->meshes[i].frames[j].normals = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, 0);
// if (retModel->materials[i].lightmap) // if (retModel->materials[i].lightmap)
// retModel->meshes[i].frames[j].tangents = (float*)malloc(sizeof(float));//(float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag); // retModel->meshes[i].frames[j].tangents = (float*)malloc(sizeof(float));//(float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag);
vertptr = retModel->meshes[i].frames[j].vertices; vertptr = retModel->meshes[i].frames[j].vertices;
+9 -9
View File
@@ -189,7 +189,7 @@ model_t *LoadModel(const char *filename, int ztag)
return NULL; return NULL;
} }
model->mdlFilename = (char*)Z_Malloc(strlen(filename)+1, ztag, NULL); model->mdlFilename = (char*)Z_Malloc(strlen(filename)+1, ztag, 0);
strcpy(model->mdlFilename, filename); strcpy(model->mdlFilename, filename);
Optimize(model); Optimize(model);
@@ -237,7 +237,7 @@ void GenerateVertexNormals(model_t *model)
{ {
mdlframe_t *frame = &mesh->frames[j]; mdlframe_t *frame = &mesh->frames[j];
int memTag = PU_STATIC; int memTag = PU_STATIC;
float *newNormals = (float*)Z_Malloc(sizeof(float)*3*mesh->numTriangles*3, memTag, NULL); float *newNormals = (float*)Z_Malloc(sizeof(float)*3*mesh->numTriangles*3, memTag, 0);
int k; int k;
float *vertPtr = frame->vertices; float *vertPtr = frame->vertices;
float *oldNormals; float *oldNormals;
@@ -309,7 +309,7 @@ static boolean AddMaterialToList(materiallist_t **head, material_t *material)
} }
// Didn't find it, so add to the list // Didn't find it, so add to the list
newMatNode = (materiallist_t*)Z_Malloc(sizeof(materiallist_t), PU_CACHE, NULL); newMatNode = (materiallist_t*)Z_Malloc(sizeof(materiallist_t), PU_CACHE, 0);
newMatNode->material = material; newMatNode->material = material;
ListAdd(newMatNode, (listitem_t**)head); ListAdd(newMatNode, (listitem_t**)head);
return true; return true;
@@ -351,7 +351,7 @@ void Optimize(model_t *model)
} }
memTag = PU_STATIC; memTag = PU_STATIC;
newMeshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * numMeshes, memTag, NULL); newMeshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * numMeshes, memTag, 0);
i = 0; i = 0;
for (node = matListHead; node; node = node->next) for (node = matListHead; node; node = node->next)
@@ -377,14 +377,14 @@ void Optimize(model_t *model)
newMesh->numFrames = 1; newMesh->numFrames = 1;
newMesh->numTriangles = numTriangles; newMesh->numTriangles = numTriangles;
newMesh->numVertices = numTriangles * 3; newMesh->numVertices = numTriangles * 3;
newMesh->uvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, NULL); newMesh->uvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, 0);
newMesh->frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t), memTag, NULL); newMesh->frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t), memTag, 0);
curFrame = &newMesh->frames[0]; curFrame = &newMesh->frames[0];
curFrame->material = curMat; curFrame->material = curMat;
curFrame->normals = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, NULL); curFrame->normals = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0);
curFrame->vertices = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, NULL); curFrame->vertices = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0);
curFrame->colors = (char*)Z_Malloc(sizeof(char)*4*numTriangles*3, memTag, NULL); curFrame->colors = (char*)Z_Malloc(sizeof(char)*4*numTriangles*3, memTag, 0);
// Now traverse the meshes of the model, adding in // Now traverse the meshes of the model, adding in
// vertices/normals/uvs that match the current material // vertices/normals/uvs that match the current material
+23 -76
View File
@@ -98,10 +98,10 @@ static size_t textureBufferSize = 0;
static LTListItem *LightTablesTail = NULL; static LTListItem *LightTablesTail = NULL;
static LTListItem *LightTablesHead = NULL; static LTListItem *LightTablesHead = NULL;
static RGBA_t screenPalette[256] = {}; // the palette for the postprocessing step in palette rendering static RGBA_t screenPalette[256] = {0}; // the palette for the postprocessing step in palette rendering
static GLuint screenPaletteTex = 0; // 1D texture containing the screen palette static GLuint screenPaletteTex = 0; // 1D texture containing the screen palette
static GLuint paletteLookupTex = 0; // 3D texture containing RGB -> palette index lookup table static GLuint paletteLookupTex = 0; // 3D texture containing RGB -> palette index lookup table
RGBA_t myPaletteData[256] = {}; // the palette for converting textures to RGBA RGBA_t myPaletteData[256] = {0}; // the palette for converting textures to RGBA
static GLint gltexformat = GL_RGB5_A1; static GLint gltexformat = GL_RGB5_A1;
GLint screen_width = 0; // used by Draw2DLine() GLint screen_width = 0; // used by Draw2DLine()
@@ -127,9 +127,9 @@ GLuint gl_num_extensions;
int majorGL = 0, minorGL = 0; int majorGL = 0, minorGL = 0;
//Hurdler: 04/10/2000: added for the kick ass coronas as Boris wanted;-) //Hurdler: 04/10/2000: added for the kick ass coronas as Boris wanted;-)
GLfloat modelMatrix[16] = {}; GLfloat modelMatrix[16] = {0};
GLfloat projMatrix[16] = {}; GLfloat projMatrix[16] = {0};
static GLint viewport[4]; static GLint viewport[4];
#ifdef USE_FBO_OGL #ifdef USE_FBO_OGL
enum enum
@@ -171,7 +171,7 @@ boolean supportstencil = false;
// flush all of the stored textures, leaving them unavailable at times such as between levels // flush all of the stored textures, leaving them unavailable at times such as between levels
// These need to start at 0 and be set to their number, and be reset to 0 when deleted so that Intel GPUs // These need to start at 0 and be set to their number, and be reset to 0 when deleted so that Intel GPUs
// can know when the textures aren't there, as textures are always considered resident in their virtual memory // can know when the textures aren't there, as textures are always considered resident in their virtual memory
static GLuint screenTextures[NUMSCREENTEXTURES] = {}; static GLuint screenTextures[NUMSCREENTEXTURES] = {0};
#define byte2float(byte) (GLfloat)(byte / 255.0f) #define byte2float(byte) (GLfloat)(byte / 255.0f)
@@ -404,14 +404,6 @@ static PFNglEnableClientState pglEnableClientState;
typedef void (APIENTRY * PFNglDisableClientState) (GLenum cap); typedef void (APIENTRY * PFNglDisableClientState) (GLenum cap);
static PFNglDisableClientState pglDisableClientState; static PFNglDisableClientState pglDisableClientState;
typedef void (APIENTRY * PFNglOrtho) (GLdouble left,
GLdouble right,
GLdouble bottom,
GLdouble top,
GLdouble nearVal,
GLdouble farVal);
static PFNglOrtho pglOrtho;
/* Lighting */ /* Lighting */
typedef void (APIENTRY * PFNglShadeModel) (GLenum mode); typedef void (APIENTRY * PFNglShadeModel) (GLenum mode);
static PFNglShadeModel pglShadeModel; static PFNglShadeModel pglShadeModel;
@@ -753,7 +745,7 @@ typedef struct gl_shaderstate_s
static gl_shaderstate_t gl_shaderstate; static gl_shaderstate_t gl_shaderstate;
// Shader info // Shader info
static float shader_leveltime = 0.0f; static float shader_leveltime = 0;
static float shader_light_x = 0.0f; static float shader_light_x = 0.0f;
static float shader_light_y = 0.0f; static float shader_light_y = 0.0f;
static float shader_light_z = 0.0f; static float shader_light_z = 0.0f;
@@ -866,8 +858,6 @@ void SetupGLFunc4(void)
GetGLfunc(glUniform3fv); GetGLfunc(glUniform3fv);
GetGLfunc(glGetUniformLocation); GetGLfunc(glGetUniformLocation);
GetGLfunc(glOrtho);
#ifdef GLDEBUGMESSAGE #ifdef GLDEBUGMESSAGE
GetGLfunc(glDebugMessageCallback); GetGLfunc(glDebugMessageCallback);
#endif #endif
@@ -3100,39 +3090,6 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics
pglDisable(GL_NORMALIZE); pglDisable(GL_NORMALIZE);
} }
void GL_Draw2DModel(model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex,
FTransform *pos, float hscale, float vscale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface)
{
// save our matrix´s
pglMatrixMode(GL_PROJECTION);
pglPushMatrix();
pglMatrixMode(GL_MODELVIEW);
pglPushMatrix();
pglMatrixMode(GL_PROJECTION);
pglLoadIdentity();
// switch to ortho mode to make our lives easier
// thisll make sure our coords will be remapped to pixel coords
pglOrtho(0.0f, (float)vid.width, (float)vid.height, 0.0f, NZCLIP_PLANE, FAR_ZCLIP_DEFAULT);
pglMatrixMode(GL_MODELVIEW);
pglLoadIdentity();
pglEnable(GL_DEPTH_TEST);
pglDepthMask(GL_TRUE);
pglClear(GL_DEPTH_BUFFER_BIT);
GL_DrawModelEx(model, frameIndex, duration, tics, nextFrameIndex,
pos, hscale, vscale, flipped, hflipped, Surface);
// restore the matrix´s
pglMatrixMode(GL_PROJECTION);
pglPopMatrix();
pglMatrixMode(GL_MODELVIEW);
pglPopMatrix();
}
// -----------------+ // -----------------+
// SetTransform : // SetTransform :
// -----------------+ // -----------------+
@@ -3591,30 +3548,22 @@ 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]);
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 += stride)
for (i = 0; i < 1; i += ystep)
{ {
// avoid calling rand thousands of times fix[2] = (float)(rand() % 128) / -22000.f * xfix;
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;
@@ -3632,8 +3581,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;
@@ -3656,14 +3605,13 @@ 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;
@@ -3682,7 +3630,6 @@ 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);
@@ -3722,7 +3669,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.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] = static float off[12] =
{ {
@@ -3745,19 +3692,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.0f; yoff = 1;
} }
else if (origaspect > newaspect) else if (origaspect > newaspect)
{ {
xoff = 1.0f; xoff = 1;
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;
+4 -4
View File
@@ -189,7 +189,7 @@ HMS_connect (const char *format, ...)
seek = strlen(hms_api) + 1;/* + '/' */ seek = strlen(hms_api) + 1;/* + '/' */
va_start (ap, format); va_start (ap, format);
url = malloc(seek + vsnprintf(NULL, 0, format, ap) + sizeof HMS_QUERY_VERSION - 1 + token_length + 1); url = malloc(seek + vsnprintf(0, 0, format, ap) + sizeof HMS_QUERY_VERSION - 1 + token_length + 1);
va_end (ap); va_end (ap);
sprintf(url, "%s/", hms_api); sprintf(url, "%s/", hms_api);
@@ -471,8 +471,8 @@ HMS_fetch_servers (msg_server_t *list, int query_id)
*end = '\0'; *end = '\0';
address = strtok(p, " "); address = strtok(p, " ");
port = strtok(NULL, " "); port = strtok(0, " ");
contact = strtok(NULL, ""); contact = strtok(0, "");
if (address && port) if (address && port)
{ {
@@ -539,7 +539,7 @@ HMS_compare_mod_version (char *buffer, size_t buffer_size)
if (HMS_do(hms)) if (HMS_do(hms))
{ {
version = strtok(hms->buffer, " "); version = strtok(hms->buffer, " ");
version_name = strtok(NULL, "\n"); version_name = strtok(0, "\n");
if (version && version_name) if (version && version_name)
{ {
+4 -11
View File
@@ -1484,7 +1484,6 @@ static char *CHAT_WordWrap(INT32 x, INT32 w, INT32 option, const char *string)
x = 0; x = 0;
} }
} }
return newstring; return newstring;
} }
@@ -1523,7 +1522,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
{ {
@@ -1555,17 +1554,14 @@ 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;
@@ -1602,7 +1598,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
{ {
@@ -1647,14 +1643,12 @@ 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)
@@ -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 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;
@@ -1719,7 +1713,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
{ {
@@ -1764,7 +1758,6 @@ static void HU_drawChatLog(INT32 offset)
dy += charheight; dy += charheight;
} }
} }
dy += charheight; dy += charheight;
dx = 0; dx = 0;
if (msg) if (msg)
-4
View File
@@ -29,10 +29,6 @@ extern "C" {
*/ */
#define MAX_QUIT_FUNCS 16 #define MAX_QUIT_FUNCS 16
void I_GetConsoleEvents(void);
extern boolean consolevent;
extern boolean framebuffer;
/** \brief Graphic system had started up /** \brief Graphic system had started up
*/ */
+1 -1
View File
@@ -21,7 +21,7 @@
#include "m_fixed.h" #include "m_fixed.h"
#include "i_system.h" #include "i_system.h"
timestate_t g_time = {}; timestate_t g_time;
static CV_PossibleValue_t timescale_cons_t[] = {{FRACUNIT/20, "MIN"}, {20*FRACUNIT, "MAX"}, {0, NULL}}; static CV_PossibleValue_t timescale_cons_t[] = {{FRACUNIT/20, "MIN"}, {20*FRACUNIT, "MAX"}, {0, NULL}};
consvar_t cv_timescale = {"timescale", "1.0", CV_NETVAR|CV_CHEAT|CV_FLOAT, timescale_cons_t, NULL, FRACUNIT, NULL, NULL, 0, 0, NULL}; consvar_t cv_timescale = {"timescale", "1.0", CV_NETVAR|CV_CHEAT|CV_FLOAT, timescale_cons_t, NULL, FRACUNIT, NULL, NULL, 0, 0, NULL};
+2 -9
View File
@@ -125,6 +125,8 @@ boolean I_CheckNativeRes(void);
void I_SetBorderlessWindow(void); void I_SetBorderlessWindow(void);
void I_HandleControllerHatRepeat(void);
#ifdef USE_FBO_OGL #ifdef USE_FBO_OGL
void RefreshOGLSDLSurface(void); void RefreshOGLSDLSurface(void);
@@ -133,15 +135,6 @@ boolean UseScreenFBO(void);
extern boolean downsample; extern boolean downsample;
#endif #endif
// So we can call this from i_video event loop
void I_ShutdownJoystick(UINT8 index);
// Quick thing to make SDL_JOYDEVICEADDED events less of an abomination
void I_UpdateJoystickDeviceIndex(UINT8 player);
void I_UpdateJoystickDeviceIndices(UINT8 excludePlayer);
void I_HandleControllerHatRepeat(void);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
#endif #endif
+6 -6
View File
@@ -568,7 +568,7 @@ static patch_t *kp_racefinish[6];
static patch_t *kp_positionnum[NUMPOSNUMS][NUMPOSFRAMES]; static patch_t *kp_positionnum[NUMPOSNUMS][NUMPOSFRAMES];
static patch_t *kp_winnernum[NUMPOSFRAMES]; static patch_t *kp_winnernum[NUMPOSFRAMES];
patch_t *kp_facenum[MAXPLAYERS+1] = {}; patch_t *kp_facenum[MAXPLAYERS+1];
static patch_t *kp_facehighlight[8]; static patch_t *kp_facehighlight[8];
static patch_t *kp_rankbumper; static patch_t *kp_rankbumper;
@@ -1065,7 +1065,7 @@ static void K_initKartHUD(void)
} }
if (timeinmap > 113 || forceshowhud) if (timeinmap > 113 || forceshowhud)
hudtrans = (UINT8)cv_translucenthud.value; hudtrans = cv_translucenthud.value;
else if (timeinmap > 105) else if (timeinmap > 105)
hudtrans = ((((INT32)timeinmap) - 105)*cv_translucenthud.value)/(113-105); hudtrans = ((((INT32)timeinmap) - 105)*cv_translucenthud.value)/(113-105);
else else
@@ -1122,9 +1122,9 @@ void K_KartPlayerHUDUpdate(player_t *player)
UINT8 K_GetHudColor(void) UINT8 K_GetHudColor(void)
{ {
if (cv_colorizedhud.value && cv_colorizedhudcolor.value) if (cv_colorizedhud.value && cv_colorizedhudcolor.value)
return (UINT8)cv_colorizedhudcolor.value; return cv_colorizedhudcolor.value;
return ((stplyr && gamestate == GS_LEVEL) ? stplyr->skincolor : (UINT8)cv_playercolor.value); return ((stplyr && gamestate == GS_LEVEL) ? stplyr->skincolor : cv_playercolor.value);
} }
boolean K_UseColorHud(void) boolean K_UseColorHud(void)
@@ -1526,7 +1526,7 @@ static void K_drawKartItem(void)
{ {
localcolor = K_GetHudColor(); localcolor = K_GetHudColor();
switch ((stplyr->kartstuff[k_itemroulette] % (14*3)) / 3) switch((stplyr->kartstuff[k_itemroulette] % (14*3)) / 3)
{ {
// Each case is handled in threes, to give three frames of in-game time to see the item on the roulette // Each case is handled in threes, to give three frames of in-game time to see the item on the roulette
case 0: // Sneaker case 0: // Sneaker
@@ -2195,7 +2195,7 @@ static boolean K_drawKartPositionFaces(void)
return true; return true;
if (!LUA_HudEnabled(hud_minirankings)) if (!LUA_HudEnabled(hud_minirankings))
return false; // Don't proceed but still return true for free play above if HUD is disabled. return false; // Don't proceed but still return true for free play above if HUD is disabled.
for (j = 0; j < numplayersingame; j++) for (j = 0; j < numplayersingame; j++)
{ {
+9 -17
View File
@@ -47,8 +47,6 @@ consvar_t cv_airsparks = {"airdriftsparks", "Off", CV_SAVE, CV_OnOff, NULL, 0, N
consvar_t cv_playerblendeffects = {"playerblendeffects", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_playerblendeffects = {"playerblendeffects", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_reducevfx = {"reducevfx", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
// funn-E streeetch // funn-E streeetch
static CV_PossibleValue_t stretchfactor_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}}; static CV_PossibleValue_t stretchfactor_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}};
consvar_t cv_gravstretch = {"gravstretch", "MIN", CV_SAVE|CV_FLOAT, stretchfactor_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_gravstretch = {"gravstretch", "MIN", CV_SAVE|CV_FLOAT, stretchfactor_t, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -484,8 +482,7 @@ UINT8 colortranslations[MAXTRANSLATIONS][16] = {
// //
UINT8 K_RainbowColor(void) UINT8 K_RainbowColor(void)
{ {
const tic_t time = cv_reducevfx.value ? (leveltime >> 3) : leveltime; return (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1)));
return (UINT8)(1 + (time % (MAXSKINCOLORS-1)));
} }
// Define for getting accurate color brightness readings according to how the human eye sees them. // Define for getting accurate color brightness readings according to how the human eye sees them.
@@ -767,8 +764,6 @@ void K_RegisterClientKartStuff(void)
CV_RegisterVar(&cv_playerblendeffects); CV_RegisterVar(&cv_playerblendeffects);
CV_RegisterVar(&cv_reducevfx);
CV_RegisterVar(&cv_saltyhop); CV_RegisterVar(&cv_saltyhop);
CV_RegisterVar(&cv_saltyhopsfx); CV_RegisterVar(&cv_saltyhopsfx);
CV_RegisterVar(&cv_saltysquish); CV_RegisterVar(&cv_saltysquish);
@@ -3108,18 +3103,17 @@ static mobj_t *K_SpawnKartMissile(mobj_t *source, mobjtype_t type, angle_t an, I
return NULL; return NULL;
} }
static UINT8 K_DriftSparkColor(player_t *player, INT32 charge) static UINT16 K_DriftSparkColor(player_t *player, INT32 charge)
{ {
UINT8 color = SKINCOLOR_NONE; UINT16 color = SKINCOLOR_NONE;
const INT32 sparkval = K_GetKartDriftSparkValue(player);
if (charge >= sparkval*4) if (charge >= K_GetKartDriftSparkValue(player)*4)
{ {
color = K_RainbowColor(); color = K_RainbowColor();
} }
else if (charge >= sparkval*2) else if (charge >= K_GetKartDriftSparkValue(player)*2)
{ {
if (charge <= (sparkval*2)+(24*3)) if (charge <= (K_GetKartDriftSparkValue(player)*2)+(24*3))
color = SKINCOLOR_RASPBERRY; // transition color = SKINCOLOR_RASPBERRY; // transition
else else
color = SKINCOLOR_KETCHUP; color = SKINCOLOR_KETCHUP;
@@ -3600,8 +3594,6 @@ void K_SpawnSparkleTrail(mobj_t *mo)
I_Assert(mo != NULL); I_Assert(mo != NULL);
I_Assert(!P_MobjWasRemoved(mo)); I_Assert(!P_MobjWasRemoved(mo));
const boolean shouldblend = (mo->player && K_PlayerEffectsShouldBlend(mo->player));
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
{ {
fixed_t newx = mo->x + mo->momx + (P_RandomRange(-rad, rad)<<FRACBITS); fixed_t newx = mo->x + mo->momx + (P_RandomRange(-rad, rad)<<FRACBITS);
@@ -3619,7 +3611,7 @@ void K_SpawnSparkleTrail(mobj_t *mo)
sparkle->color = mo->color; sparkle->color = mo->color;
if (shouldblend) if (mo->player && K_PlayerEffectsShouldBlend(mo->player))
sparkle->blendmode = AST_ADD; sparkle->blendmode = AST_ADD;
} }
@@ -6773,7 +6765,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
{ {
if (splitscreen) if (splitscreen)
{ {
if (!cv_reducevfx.value && leveltime & 1) if (leveltime & 1)
player->mo->flags2 |= MF2_DONTDRAW; player->mo->flags2 |= MF2_DONTDRAW;
else else
player->mo->flags2 &= ~MF2_DONTDRAW; player->mo->flags2 &= ~MF2_DONTDRAW;
@@ -6799,7 +6791,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
if (P_IsDisplayPlayer(player) if (P_IsDisplayPlayer(player)
|| (!P_IsDisplayPlayer(player) && (player->kartstuff[k_hyudorotimer] < (1*TICRATE/2) || player->kartstuff[k_hyudorotimer] > hyudorotime-(1*TICRATE/2)))) || (!P_IsDisplayPlayer(player) && (player->kartstuff[k_hyudorotimer] < (1*TICRATE/2) || player->kartstuff[k_hyudorotimer] > hyudorotime-(1*TICRATE/2))))
{ {
if (!cv_reducevfx.value && leveltime & 1) if (leveltime & 1)
player->mo->flags2 |= MF2_DONTDRAW; player->mo->flags2 |= MF2_DONTDRAW;
else else
player->mo->flags2 &= ~MF2_DONTDRAW; player->mo->flags2 &= ~MF2_DONTDRAW;
-1
View File
@@ -1293,7 +1293,6 @@ 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 = NULL; state_t *astate;
boolean actionsoverridden[NUMACTIONS] = {false}; boolean actionsoverridden[NUMACTIONS] = {false};
+1 -1
View File
@@ -475,7 +475,7 @@ int mobj_localskin_setter(lua_State *L)
} }
else else
{ {
mo->localskin = NULL; mo->localskin = 0;
mo->skinlocal = false; mo->skinlocal = false;
} }
} }
+38 -38
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,8 +66,12 @@ 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;
(void)osize; if (nsize == 0) {
return Z_Realloc(ptr, nsize, PU_LUA, NULL); 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. // 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); 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);
} }
@@ -1061,13 +1064,9 @@ static void ArchiveTables(UINT8 **p)
{ {
// Write key // Write key
e = ArchiveValue(p, TABLESINDEX, -2); // key should be either a number or a string, ArchiveValue can handle this. e = ArchiveValue(p, TABLESINDEX, -2); // key should be either a number or a string, ArchiveValue can handle this.
if (e == 1) if (e == 2) // invalid key type (function, thread, lightuserdata, or anything we don't recognise)
n++; // the table contained a new table we'll have to archive. :(
else if (e == 2) // invalid key type (function, thread, lightuserdata, or anything we don't recognise)
{ {
CONS_Alert(CONS_ERROR, "Index '%s' (%s) of table %d could not be archived!\n", lua_tostring(gL, -2), luaL_typename(gL, -2), i); CONS_Alert(CONS_ERROR, "Index '%s' (%s) of table %d could not be archived!\n", lua_tostring(gL, -2), luaL_typename(gL, -2), i);
lua_pop(gL, 1);
continue;
} }
else if (e == 3) // nil key due to invalid userdata. NOT an error. else if (e == 3) // nil key due to invalid userdata. NOT an error.
{ {
@@ -1078,12 +1077,15 @@ static void ArchiveTables(UINT8 **p)
// Write value // Write value
e = ArchiveValue(p, TABLESINDEX, -1); e = ArchiveValue(p, TABLESINDEX, -1);
if (e == 1) if (e == 1)
{
n++; // the table contained a new table we'll have to archive. :( n++; // the table contained a new table we'll have to archive. :(
}
else if (e == 2) // invalid value type else if (e == 2) // invalid value type
{
CONS_Alert(CONS_ERROR, "Type of value for table %d entry '%s' (%s) could not be archived!\n", i, lua_tostring(gL, -2), luaL_typename(gL, -1)); CONS_Alert(CONS_ERROR, "Type of value for table %d entry '%s' (%s) could not be archived!\n", i, lua_tostring(gL, -2), luaL_typename(gL, -1));
}
lua_pop(gL, 1); lua_pop(gL, 1);
} }
lua_pop(gL, 1); lua_pop(gL, 1);
WRITEUINT8(*p, ARCH_TEND); WRITEUINT8(*p, ARCH_TEND);
@@ -1274,21 +1276,13 @@ static void UnArchiveTables(UINT8 **p, boolean network)
UINT8 ret; UINT8 ret;
ret = UnArchiveValue(p, TABLESINDEX, network); ret = UnArchiveValue(p, TABLESINDEX, network);
if (ret == 1) // End of table if (ret == 3)
break;
else if (ret == 2) // Key contains a new table
n++;
else if (ret == 3)
{ {
//CONS_Alert(CONS_WARNING,"Couldn't read mobj_t\n"); //CONS_Alert(CONS_WARNING,"Couldn't read mobj_t\n");
lua_pushnil(gL); lua_pushnil(gL);
} }
else if (ret == 1) // read key
if (lua_isnil(gL, -1)) // If key is nil, skip this entry break;
{
lua_pop(gL, 1);
continue;
}
ret = UnArchiveValue(p, TABLESINDEX, network); ret = UnArchiveValue(p, TABLESINDEX, network);
if (ret == 1) if (ret == 1)
@@ -1297,15 +1291,21 @@ static void UnArchiveTables(UINT8 **p, boolean network)
lua_pop(gL, 1); // Pop key lua_pop(gL, 1); // Pop key
break; break;
} }
else if (ret == 2) // read value
n++;
else if (ret == 3) else if (ret == 3)
{ {
//CONS_Alert(CONS_WARNING,"Couldn't read mobj_t\n"); //CONS_Alert(CONS_WARNING,"Couldn't read mobj_t\n");
lua_pushnil(gL); lua_pushnil(gL);
} }
else if (ret == 2) // read value
n++;
lua_rawset(gL, -3); if (lua_isnil(gL, -2)) // if key is nil (if a function etc was accidentally saved)
{
CONS_Alert(CONS_ERROR, "A nil key in table %d was found! (Invalid key type or corrupted save?)\n", i);
lua_pop(gL, 2); // pop key and value instead of setting them in the table, to prevent Lua panic errors
}
else
lua_rawset(gL, -3);
} }
lua_pop(gL, 1); lua_pop(gL, 1);
+5 -5
View File
@@ -80,7 +80,7 @@ static UINT8 cheatf_warp(void)
if (success) if (success)
{ {
G_SaveGameData(true); //G_SetGameModified(false); G_SaveGameData(true); //G_SetGameModified(false);
S_StartSound(NULL, sfx_kc42); S_StartSound(0, sfx_kc42);
} }
// Refresh secrets menu existing. // Refresh secrets menu existing.
@@ -117,13 +117,13 @@ static UINT8 cheatf_devmode(void)
#endif #endif
static cheatseq_t cheat_warp = { static cheatseq_t cheat_warp = {
NULL, cheatf_warp, 0, cheatf_warp,
//{ SCRAMBLE('r'), SCRAMBLE('e'), SCRAMBLE('d'), SCRAMBLE('x'), SCRAMBLE('v'), SCRAMBLE('i'), 0xff } //{ SCRAMBLE('r'), SCRAMBLE('e'), SCRAMBLE('d'), SCRAMBLE('x'), SCRAMBLE('v'), SCRAMBLE('i'), 0xff }
{ SCRAMBLE('b'), SCRAMBLE('a'), SCRAMBLE('n'), SCRAMBLE('a'), SCRAMBLE('n'), SCRAMBLE('a'), 0xff } { SCRAMBLE('b'), SCRAMBLE('a'), SCRAMBLE('n'), SCRAMBLE('a'), SCRAMBLE('n'), SCRAMBLE('a'), 0xff }
}; };
static cheatseq_t cheat_warp_joy = { static cheatseq_t cheat_warp_joy = {
NULL, cheatf_warp, 0, cheatf_warp,
/*{ SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_UPARROW), /*{ SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_UPARROW),
SCRAMBLE(KEY_RIGHTARROW), SCRAMBLE(KEY_RIGHTARROW), SCRAMBLE(KEY_UPARROW), SCRAMBLE(KEY_RIGHTARROW), SCRAMBLE(KEY_RIGHTARROW), SCRAMBLE(KEY_UPARROW),
SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_UPARROW), SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_UPARROW),
@@ -136,7 +136,7 @@ static cheatseq_t cheat_warp_joy = {
#ifdef DEVELOP #ifdef DEVELOP
static cheatseq_t cheat_devmode = { static cheatseq_t cheat_devmode = {
NULL, cheatf_devmode, 0, cheatf_devmode,
{ SCRAMBLE('d'), SCRAMBLE('e'), SCRAMBLE('v'), SCRAMBLE('m'), SCRAMBLE('o'), SCRAMBLE('d'), SCRAMBLE('e'), 0xff } { SCRAMBLE('d'), SCRAMBLE('e'), SCRAMBLE('v'), SCRAMBLE('m'), SCRAMBLE('o'), SCRAMBLE('d'), SCRAMBLE('e'), 0xff }
}; };
#endif #endif
@@ -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 = DoubleToFixed(scaled); fixed_t scale = FLOAT_TO_FIXED(scaled);
REQUIRE_DEVMODE; REQUIRE_DEVMODE;
REQUIRE_INLEVEL; REQUIRE_INLEVEL;
+1 -1
View File
@@ -235,7 +235,7 @@ void M_AddRawCondition(UINT8 set, UINT8 id, conditiontype_t c, INT32 r, INT16 x1
wnum = conditionSets[set - 1].numconditions; wnum = conditionSets[set - 1].numconditions;
num = ++conditionSets[set - 1].numconditions; num = ++conditionSets[set - 1].numconditions;
conditionSets[set - 1].condition = Z_Realloc(conditionSets[set - 1].condition, sizeof(condition_t)*num, PU_STATIC, NULL); conditionSets[set - 1].condition = Z_Realloc(conditionSets[set - 1].condition, sizeof(condition_t)*num, PU_STATIC, 0);
cond = conditionSets[set - 1].condition; cond = conditionSets[set - 1].condition;
+4 -4
View File
@@ -12,14 +12,14 @@
#ifndef __M_EMOTES__ #ifndef __M_EMOTES__
#define __M_EMOTES__ #define __M_EMOTES__
#include "doomdef.h"
#include "m_fixed.h"
#include "command.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include "doomdef.h"
#include "m_fixed.h"
#include "command.h"
extern consvar_t cv_emotes; extern consvar_t cv_emotes;
#define MAXEMOTENAME 32 #define MAXEMOTENAME 32
+29 -9
View File
@@ -20,7 +20,6 @@ extern "C" {
#endif #endif
#include "doomtype.h" #include "doomtype.h"
#ifdef __GNUC__ #ifdef __GNUC__
#include <stdlib.h> #include <stdlib.h>
#endif #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 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
@@ -274,6 +265,35 @@ 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;
+63 -108
View File
@@ -12,8 +12,6 @@
/// \file m_menu.c /// \file m_menu.c
/// \brief XMOD's extremely revamped menu system. /// \brief XMOD's extremely revamped menu system.
#include "screen.h"
#include "tables.h"
#ifdef __GNUC__ #ifdef __GNUC__
#include <unistd.h> #include <unistd.h>
#endif #endif
@@ -4719,7 +4717,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, 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 // Draw the cursor
@@ -5387,7 +5385,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na
{ {
CONS_Printf("custom settings menu initiation\n"); CONS_Printf("custom settings menu initiation\n");
for (CVARSETUP = 0; CVARSETUP < MAXMENUCCVARS; ++CVARSETUP) for (CVARSETUP = 0; CVARSETUP < MAXMENUCCVARS; ++CVARSETUP)
OP_CustomCvarMenu[CVARSETUP] = (menuitem_t){IT_DISABLED, NULL, "", NULL, INT16_MAX}; OP_CustomCvarMenu[CVARSETUP] = (menuitem_t){IT_DISABLED, NULL, "", 0, INT16_MAX};
} }
if (category && ((ccvarposition == 0 && category[0] != '\0') || !fasticmp(category, OP_CustomCvarMenu[ccvarlaststheader].text))) if (category && ((ccvarposition == 0 && category[0] != '\0') || !fasticmp(category, OP_CustomCvarMenu[ccvarlaststheader].text)))
@@ -7496,7 +7494,7 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade)
if ((lumpnum = W_CheckNumForName(va("%sE", mapname))) != LUMPERROR) if ((lumpnum = W_CheckNumForName(va("%sE", mapname))) != LUMPERROR)
mappingforencore = (patch_t *)W_CachePatchNum(lumpnum, PU_PATCH);*/ mappingforencore = (patch_t *)W_CachePatchNum(lumpnum, PU_PATCH);*/
V_DrawFixedPatch((x+w)<<FRACBITS, (y)<<FRACBITS, FRACUNIT/2, V_FLIP, PictureOfLevel, NULL); V_DrawFixedPatch((x+w)<<FRACBITS, (y)<<FRACBITS, FRACUNIT/2, V_FLIP, PictureOfLevel, 0);
{ {
static angle_t rubyfloattime = 0; static angle_t rubyfloattime = 0;
@@ -7902,7 +7900,7 @@ static void M_HandleConnectIP(INT32 choice)
if (exitmenu) if (exitmenu)
{ {
if (currentMenu->prevMenu) if (currentMenu->prevMenu)
M_SetupNextMenu(currentMenu->prevMenu); M_SetupNextMenu (currentMenu->prevMenu);
else else
M_ClearMenus(true); M_ClearMenus(true);
} }
@@ -7948,7 +7946,6 @@ static void M_DrawSetupMultiPlayerMenu(void)
UINT8 i; UINT8 i;
UINT8 s, w; UINT8 s, w;
const UINT8 *flashcol = V_GetStringColormap(highlightflags); const UINT8 *flashcol = V_GetStringColormap(highlightflags);
INT32 skinnum = 0;
INT32 statx, staty; INT32 statx, staty;
UINT32 speenframe; UINT32 speenframe;
INT32 sltw, actw, hetw; INT32 sltw, actw, hetw;
@@ -8162,7 +8159,7 @@ static void M_DrawSetupMultiPlayerMenu(void)
V_DrawFixedPatch(((statx+61+GRIDSTATOFFSET)<<FRACBITS) + (FRACUNIT>>1), (staty+67)<<FRACBITS, FRACUNIT>>1, 0, statlr, flashcol); V_DrawFixedPatch(((statx+61+GRIDSTATOFFSET)<<FRACBITS) + (FRACUNIT>>1), (staty+67)<<FRACBITS, FRACUNIT>>1, 0, statlr, flashcol);
V_DrawFixedPatch((statx+40+GRIDSTATOFFSET)<<FRACBITS, (staty+80)<<FRACBITS, FRACUNIT>>1, 0, statud, flashcol); V_DrawFixedPatch((statx+40+GRIDSTATOFFSET)<<FRACBITS, (staty+80)<<FRACBITS, FRACUNIT>>1, 0, statud, flashcol);
// bg // bg
V_DrawFixedPatch(((statx+48+GRIDSTATOFFSET)<<FRACBITS)+(FRACUNIT>>1), (staty+73)<<FRACBITS, FRACUNIT>>1, 0, statbg, NULL); V_DrawFixedPatch(((statx+48+GRIDSTATOFFSET)<<FRACBITS)+(FRACUNIT>>1), (staty+73)<<FRACBITS, FRACUNIT>>1, 0, statbg, 0);
for (i = 0; i < numskins; i++) // draw the stat dots for (i = 0; i < numskins; i++) // draw the stat dots
{ {
@@ -8221,7 +8218,7 @@ static void M_DrawSetupMultiPlayerMenu(void)
V_DrawFixedPatch((statx+64)<<FRACBITS, staty<<FRACBITS, FRACUNIT, 0, statlr, flashcol); V_DrawFixedPatch((statx+64)<<FRACBITS, staty<<FRACBITS, FRACUNIT, 0, statlr, flashcol);
V_DrawFixedPatch((statx+24)<<FRACBITS, (staty+22)<<FRACBITS, FRACUNIT, 0, statud, flashcol); V_DrawFixedPatch((statx+24)<<FRACBITS, (staty+22)<<FRACBITS, FRACUNIT, 0, statud, flashcol);
// bg // bg
V_DrawFixedPatch((statx+34)<<FRACBITS, (staty+10)<<FRACBITS, FRACUNIT, 0, statbg, NULL); V_DrawFixedPatch((statx+34)<<FRACBITS, (staty+10)<<FRACBITS, FRACUNIT, 0, statbg, 0);
for (i = 0; i < numskins; i++) // draw the stat dots for (i = 0; i < numskins; i++) // draw the stat dots
{ {
@@ -8271,9 +8268,10 @@ static void M_DrawSetupMultiPlayerMenu(void)
INT32 curx = (((setupm_skinselect % SKINGRIDNEWWIDTH) * 18) + ((BASEVIDWIDTH / 2) - (18 * SKINGRIDNEWWIDTH/2)) + SKINXSHIFT) + 20; INT32 curx = (((setupm_skinselect % SKINGRIDNEWWIDTH) * 18) + ((BASEVIDWIDTH / 2) - (18 * SKINGRIDNEWWIDTH/2)) + SKINXSHIFT) + 20;
INT32 cury = (((setupm_skinselect / SKINGRIDNEWWIDTH) - setupm_skinypos) * 18) + ((BASEVIDHEIGHT / 2) - (18 * (SKINGRIDNEWWIDTH/2))+ gridyoffset); INT32 cury = (((setupm_skinselect / SKINGRIDNEWWIDTH) - setupm_skinypos) * 18) + ((BASEVIDHEIGHT / 2) - (18 * (SKINGRIDNEWWIDTH/2))+ gridyoffset);
UINT8 cursorframe = (I_GetTime() / 4) % 7; UINT8 cursorframe = (I_GetTime() / 4) % 7;
cursor = (patch_t *)W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_PATCH);
V_DrawFixedPatch((curx << FRACBITS) - (FRACUNIT), (cury << FRACBITS) - (FRACUNIT), FRACUNIT+(FRACUNIT>>3), 0, cursor, NULL); cursor = (patch_t *)W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_PATCH);
V_DrawFixedPatch((curx << FRACBITS) - (FRACUNIT), (cury << FRACBITS) - (FRACUNIT), FRACUNIT+(FRACUNIT>>3), 0, cursor, NULL);
} }
break; break;
@@ -8312,12 +8310,14 @@ static void M_DrawSetupMultiPlayerMenu(void)
if (setupm_skinselect < numskins) if (setupm_skinselect < numskins)
{ {
UINT8 *cmap = R_GetTranslationColormap(setupm_skinselect, setupm_fakecolor, GTC_MENUCACHE); UINT8 *cmap = R_GetTranslationColormap(setupm_skinselect, setupm_fakecolor, GTC_MENUCACHE);
cursor = facewantprefix[skinsorted[setupm_skinselect]]; cursor = facewantprefix[skinsorted[setupm_skinselect]];
V_DrawFixedPatch(((curx-8) << FRACBITS), ((cury-8) << FRACBITS), FRACUNIT, 0, cursor, cmap); V_DrawFixedPatch(((curx-8) << FRACBITS), ((cury-8) << FRACBITS), FRACUNIT, 0, cursor, cmap);
} }
else else
{ {
UINT8 cursorframe = (I_GetTime() / 4) % 7; UINT8 cursorframe = (I_GetTime() / 4) % 7;
cursor = (patch_t *)W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_PATCH); cursor = (patch_t *)W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_PATCH);
V_DrawFixedPatch((curx << FRACBITS) - (FRACUNIT), (cury << FRACBITS) - (FRACUNIT), FRACUNIT+(FRACUNIT>>3), 0, cursor, NULL); V_DrawFixedPatch((curx << FRACBITS) - (FRACUNIT), (cury << FRACBITS) - (FRACUNIT), FRACUNIT+(FRACUNIT>>3), 0, cursor, NULL);
} }
@@ -8381,6 +8381,7 @@ static void M_DrawSetupMultiPlayerMenu(void)
else else
{ {
UINT8 cursorframe = (I_GetTime() / 4) % 7; UINT8 cursorframe = (I_GetTime() / 4) % 7;
cursor = (patch_t *)W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_PATCH); cursor = (patch_t *)W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_PATCH);
V_DrawFixedPatch((curx << FRACBITS) - (FRACUNIT), (cury << FRACBITS) - (FRACUNIT), FRACUNIT+(FRACUNIT>>3), 0, cursor, NULL); V_DrawFixedPatch((curx << FRACBITS) - (FRACUNIT), (cury << FRACBITS) - (FRACUNIT), FRACUNIT+(FRACUNIT>>3), 0, cursor, NULL);
} }
@@ -8505,7 +8506,7 @@ static void M_DrawSetupMultiPlayerMenu(void)
switch (cv_skinselectmenu.value) switch (cv_skinselectmenu.value)
{ {
case SKINMENUTYPE_2D: case SKINMENUTYPE_2D:
skintodisplay = (UINT8)setupm_fakeskin; skintodisplay = setupm_fakeskin;
if (setupm_skinlockedselect) // show the skin we are trying to select if (setupm_skinlockedselect) // show the skin we are trying to select
skintodisplay = skinstats[setupm_skinxpos][setupm_skinypos][setupm_skinselect]; skintodisplay = skinstats[setupm_skinxpos][setupm_skinypos][setupm_skinselect];
else if (skinstatscount[setupm_skinxpos][setupm_skinypos] && itemOn == 1) else if (skinstatscount[setupm_skinxpos][setupm_skinypos] && itemOn == 1)
@@ -8513,22 +8514,19 @@ static void M_DrawSetupMultiPlayerMenu(void)
break; break;
case SKINMENUTYPE_EXTENDED: case SKINMENUTYPE_EXTENDED:
case SKINMENUTYPE_GRID: case SKINMENUTYPE_GRID:
skintodisplay = ((itemOn == 1 && (setupm_skinselect < numskins)) ? skinsorted[setupm_skinselect] : (UINT8)setupm_fakeskin); skintodisplay = (itemOn == 1 && setupm_skinselect < numskins ? skinsorted[setupm_skinselect] : setupm_fakeskin);
break; break;
default: default:
skintodisplay = (UINT8)setupm_fakeskin; skintodisplay = setupm_fakeskin;
break; break;
} }
if (skintodisplay >= MAXSKINS) const INT32 skinnum = R_SkinAvailable(skins[skintodisplay].name);
skintodisplay = 0;
skinnum = R_SkinAvailable(skins[skintodisplay].name); if (skinnum != -1)
sprdef = &skins[skinnum].spritedef;
if (skinnum < 0 || skinnum >= MAXSKINS) else
skinnum = 0; sprdef = &skins[0].spritedef;
sprdef = &skins[skinnum].spritedef;
if (!sprdef->numframes) // No frames ?? if (!sprdef->numframes) // No frames ??
return; // Can't render! return; // Can't render!
@@ -8537,59 +8535,37 @@ static void M_DrawSetupMultiPlayerMenu(void)
if (frame >= sprdef->numframes) // Walking animation missing if (frame >= sprdef->numframes) // Walking animation missing
frame = 0; // Try to use standing frame frame = 0; // Try to use standing frame
sprframe = &sprdef->spriteframes[frame];
// minenice's speen css, it's a piece of shit but hey
speenframe = (I_GetTime()*cv_skinselectspin.value/TICRATE + 1)%8;
// this is a very shitty solution for checking if a sprite needs flipping
// but it works
if ((speenframe > 4) && (sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe]))
flags = V_FLIP; // This sprite is left/right flipped!
patch = (patch_t *)W_CachePatchNum(sprframe->lumppat[speenframe], PU_PATCH);
// draw box around guy // draw box around guy
V_DrawFill(mx + 36 - (charw/2), my+65, charw, 84, 239); V_DrawFill(mx + 36 - (charw/2), my+65, charw, 84, 239);
#undef charw
// draw player sprite // draw player sprite
if (setupm_fakecolor) // inverse should never happen if (setupm_fakecolor) // inverse should never happen
{ {
UINT8 *colormap = R_GetTranslationColormap(skintodisplay, setupm_fakecolor, GTC_MENUCACHE); UINT8 *colormap = R_GetTranslationColormap(skintodisplay, setupm_fakecolor, GTC_MENUCACHE);
#ifdef HWRENDER
md2_t *md2 = &md2_playermodels[skinnum]; if (skins[skintodisplay].flags & SF_HIRES)
#endif
mx += 36;
my += 131;
#ifdef HWRENDER
// if we have 3d models enabled and a model exists
// try to show it instead of the sprite
if (rendermode == render_opengl && cv_glmdls.value
&& !md2->error && !md2->notfound)
{ {
const angle_t ROTATE_PER_TIC = (UINT64)ANGLE_45 * cv_skinselectspin.value / TICRATE; V_DrawFixedPatch((mx+36)<<FRACBITS,
angle_t angle = I_GetTime()*ROTATE_PER_TIC + FixedMul(cv_uncappedhud.value ? renderdeltatics : FRACUNIT, ROTATE_PER_TIC); (my+131)<<FRACBITS,
HWR_Draw2DModel(md2, mx, my, skinnum, (skincolors_t)setupm_fakecolor, colormap, 8*FRACUNIT/3, frame, angle); skins[skintodisplay].highresscale,
flags, patch, colormap);
} }
else else
#endif V_DrawMappedPatch(mx+36, my+131, flags, patch, colormap);
{
sprframe = &sprdef->spriteframes[frame];
// minenice's speen css, it's a piece of shit but hey
speenframe = (I_GetTime()*cv_skinselectspin.value/TICRATE + 1)%8;
// this is a very shitty solution for checking if a sprite needs flipping
// but it works
if ((speenframe > 4) && (sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe]))
{
flags = V_FLIP; // This sprite is left/right flipped!
}
patch = (patch_t *)W_CachePatchNum(sprframe->lumppat[speenframe], PU_PATCH);
if (skins[skintodisplay].flags & SF_HIRES)
{
V_DrawFixedPatch(mx<<FRACBITS,
my<<FRACBITS,
skins[skintodisplay].highresscale,
flags, patch, colormap);
}
else
{
V_DrawMappedPatch(mx, my, flags, patch, colormap);
}
}
} }
#undef charw
} }
// Handle 1P/2P MP Setup // Handle 1P/2P MP Setup
@@ -9890,7 +9866,7 @@ static void M_DrawLocalSkinMenu(void)
spriteframe_t *sprframe; spriteframe_t *sprframe;
patch_t *patch; patch_t *patch;
UINT8 frame; UINT8 frame;
INT32 skintodisplay = 0; INT16 skintodisplay;
UINT32 speenframe; UINT32 speenframe;
skin_t displayskin; skin_t displayskin;
@@ -9921,12 +9897,12 @@ static void M_DrawLocalSkinMenu(void)
// skin 0 is default player sprite // skin 0 is default player sprite
skintodisplay = R_AnySkinAvailable(cv_fakelocalskin.string); skintodisplay = R_AnySkinAvailable(cv_fakelocalskin.string);
if (skintodisplay < 0) if (skintodisplay == -1)
{ {
// ATTEMPT TO FIND REAL SKIN // ATTEMPT TO FIND REAL SKIN
skintodisplay = R_AnySkinAvailable(cv_skin.string); skintodisplay = R_AnySkinAvailable(cv_skin.string);
if (skintodisplay < 0) // STILL NOTHIN? use sonic instead if (skintodisplay == -1) // STILL NOTHIN? use sonic instead
{ {
skintodisplay = 0; skintodisplay = 0;
} }
@@ -9943,10 +9919,24 @@ static void M_DrawLocalSkinMenu(void)
if (frame >= sprdef->numframes) // Walking animation missing if (frame >= sprdef->numframes) // Walking animation missing
frame = 0; // Try to use standing frame frame = 0; // Try to use standing frame
sprframe = &sprdef->spriteframes[frame];
//minenice's speen css, it's a piece of shit but hey
//patch = (patch_t *)W_CachePatchNum(sprframe->lumppat[1], PU_PATCH);
speenframe = (I_GetTime()*cv_skinselectspin.value/TICRATE + 1)%8;
//this is a very shitty solution for checking if a sprite needs flipping
//but it works
if ((speenframe > 4) && (sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe]))
{
flags = V_FLIP; // This sprite is left/right flipped!
}
patch = (patch_t *)W_CachePatchNum(sprframe->lumppat[speenframe], PU_PATCH);
// draw box around guy // draw box around guy
V_DrawFill(mx + 220 - (charw/2), my+54, charw, 84, 239); V_DrawFill(mx + 220 - (charw/2), my+54, charw, 84, 239);
#undef charw
// draw player sprite
UINT8 *colormap = R_GetLocalTranslationColormap(&skins[displayskin.localnum], (displayskin.localskin ? &localskins[displayskin.localnum] : NULL), cv_playercolor.value, GTC_MENUCACHE, displayskin.localskin); UINT8 *colormap = R_GetLocalTranslationColormap(&skins[displayskin.localnum], (displayskin.localskin ? &localskins[displayskin.localnum] : NULL), cv_playercolor.value, GTC_MENUCACHE, displayskin.localskin);
V_DrawMappedPatch(mx, my+50, 0, (patch_t *)W_CachePatchName(displayskin.facewant, PU_PATCH), colormap); V_DrawMappedPatch(mx, my+50, 0, (patch_t *)W_CachePatchName(displayskin.facewant, PU_PATCH), colormap);
@@ -9959,48 +9949,13 @@ static void M_DrawLocalSkinMenu(void)
else else
V_DrawString(mx+20, my+118, V_ALLOWLOWERCASE|highlightflags, displayskin.realname); V_DrawString(mx+20, my+118, V_ALLOWLOWERCASE|highlightflags, displayskin.realname);
// draw player sprite if (displayskin.flags & SF_HIRES)
mx += 220;
my += 120;
#ifdef HWRENDER
md2_t *md2 = (displayskin.localskin ? &md2_localplayermodels[skintodisplay] : &md2_playermodels[skintodisplay]);
// if we have 3d models enabled and a model exists
// try to show it instead of the sprite
if (rendermode == render_opengl && cv_glmdls.value
&& !md2->error && !md2->notfound)
{ {
const angle_t ROTATE_PER_TIC = (UINT64)ANGLE_45 * cv_skinselectspin.value / TICRATE; V_DrawFixedPatch((mx+220)<<FRACBITS, (my+120)<<FRACBITS, displayskin.highresscale, flags, patch, colormap);
angle_t angle = I_GetTime()*ROTATE_PER_TIC + FixedMul(cv_uncappedhud.value ? renderdeltatics : FRACUNIT, ROTATE_PER_TIC);
HWR_Draw2DModel(md2, mx, my, skintodisplay, (skincolors_t)cv_playercolor.value, colormap, 8*FRACUNIT/3, frame, angle);
} }
else else
#endif V_DrawMappedPatch(mx+220, my+120, flags, patch, colormap);
{ #undef charw
sprframe = &sprdef->spriteframes[frame];
// minenice's speen css, it's a piece of shit but hey
speenframe = (I_GetTime()*cv_skinselectspin.value/TICRATE + 1)%8;
// this is a very shitty solution for checking if a sprite needs flipping
// but it works
if ((speenframe > 4) && (sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe]))
{
flags = V_FLIP; // This sprite is left/right flipped!
}
patch = (patch_t *)W_CachePatchNum(sprframe->lumppat[speenframe], PU_PATCH);
if (displayskin.flags & SF_HIRES)
{
V_DrawFixedPatch(mx<<FRACBITS, my<<FRACBITS, displayskin.highresscale, flags, patch, colormap);
}
else
{
V_DrawMappedPatch(mx, my, flags, patch, colormap);
}
}
} }
// Draw the video modes list, a-la-Quake // Draw the video modes list, a-la-Quake
+16 -24
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, "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[] =
@@ -1220,8 +1216,6 @@ 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[] =
@@ -1639,34 +1633,33 @@ static menuitem_t OP_AccessibilityMenu[] =
{IT_STRING|IT_CVAR|IT_CV_SLIDER, NULL, "Saturation", &cv_globalsaturation, 25}, {IT_STRING|IT_CVAR|IT_CV_SLIDER, NULL, "Saturation", &cv_globalsaturation, 25},
{IT_SUBMENU|IT_STRING, NULL, "Video Color Settings...", &OP_ColorOptionsDef, 30}, {IT_SUBMENU|IT_STRING, NULL, "Video Color Settings...", &OP_ColorOptionsDef, 30},
{IT_STRING|IT_CVAR, NULL, "Reduce Effects", &cv_reducevfx, 35}, {IT_STRING|IT_CVAR, NULL, "Midnight Channel Flicker", &cv_lessflicker, 35},
{IT_STRING|IT_CVAR, NULL, "Midnight Channel Flicker", &cv_lessflicker, 40}, // obsolete now? or still better be a seperate toggle?
{IT_STRING|IT_CVAR, NULL, "Minimum Sector Brightness", &cv_secbright, 45}, {IT_STRING|IT_CVAR, NULL, "Minimum Sector Brightness", &cv_secbright, 40},
#ifdef HWRENDER #ifdef HWRENDER
{IT_STRING|IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 50}, {IT_STRING|IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 45},
#endif #endif
{IT_STRING|IT_CVAR, NULL, "Water Surface Ripples", &cv_ripplewater, 55}, {IT_STRING|IT_CVAR, NULL, "Water Surface Ripples", &cv_ripplewater, 50},
{IT_STRING|IT_CVAR, NULL, "Fade Players near Camera", &cv_playerfade, 60}, {IT_STRING|IT_CVAR, NULL, "Fade Players near Camera", &cv_playerfade, 55},
{IT_STRING|IT_CVAR, NULL, "Quake Screenshakes", &cv_screenquake, 65}, {IT_STRING|IT_CVAR, NULL, "Quake Screenshakes", &cv_screenquake, 60},
{IT_CALL|IT_STRING, NULL, "Camera Options...", M_CameraMenu, 70}, {IT_CALL|IT_STRING, NULL, "Camera Options...", M_CameraMenu, 65},
{IT_HEADER, NULL, "Audio", NULL, 80}, {IT_HEADER, NULL, "Audio", NULL, 75},
{IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 90}, {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 85},
{IT_STRING|IT_CVAR, NULL, "Same Sound Limit", &cv_samesoundlimit, 95}, {IT_STRING|IT_CVAR, NULL, "Same Sound Limit", &cv_samesoundlimit, 90},
{IT_HEADER, NULL, "Controls", NULL, 105}, {IT_HEADER, NULL, "Controls", NULL, 100},
{IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P1)", &cv_autoaccel[0], 115}, {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P1)", &cv_autoaccel[0], 110},
{IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P2)", &cv_autoaccel[1], 120}, {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P2)", &cv_autoaccel[1], 115},
{IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P3)", &cv_autoaccel[2], 125}, {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P3)", &cv_autoaccel[2], 120},
{IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P4)", &cv_autoaccel[3], 130}, {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P4)", &cv_autoaccel[3], 125},
}; };
static const char* OP_AccessibilityTooltips[] = static const char* OP_AccessibilityTooltips[] =
@@ -1676,11 +1669,10 @@ static const char* OP_AccessibilityTooltips[] =
"Gamma (brightness) of the game.", "Gamma (brightness) of the game.",
"Saturation of the game.", "Saturation of the game.",
"Advanced color settings of the game.", "Advanced color settings of the game.",
"Reduces or disables certain effects players might be sensitive to\nSuch as flashing, flickering, certain screen effects and more.",
"Disables the flicker effect on Midnight Channel.", "Disables the flicker effect on Midnight Channel.",
"Sets minimum sector brightness, useful for dark areas", "Sets minimum sector brightness, useful for dark areas",
#ifdef HWRENDER #ifdef HWRENDER
"Disabling Screen Textures will disable the Underwater and Heat screen effects.", "Should the game do Screen Textures? Provides a good boost to frames\nat the cost of some visual effects not working when disabled.",
#endif #endif
"Toggles the ripple effect on water surfaces", "Toggles the ripple effect on water surfaces",
"Fades other Players that are close to the camera in and out", "Fades other Players that are close to the camera in and out",
+6 -7
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;
CLEANUP(Z_Pfree) char *filepath = NULL; char *filepath;
// 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 = Z_StrDup(va(pandf, srb2home, filename)); filepath = va(pandf,srb2home, filename);
else else
filepath = Z_StrDup(filename); filepath = Z_StrDup(filename);
@@ -1346,15 +1346,14 @@ void M_MinimapGenerate(void)
minigen = AM_MinimapGenerate(mul); minigen = AM_MinimapGenerate(mul);
if (minigen == NULL || minigen->buf == NULL) if (minigen == NULL || minigen->buf == NULL)
{ goto failure;
CONS_Alert(CONS_ERROR, M_GetText("Couldn't create %s\n"), filepath);
return;
}
M_CreateScreenShotPalette(); M_CreateScreenShotPalette();
ret = M_SavePNG(filepath, minigen->buf, minigen->w, minigen->h, screenshot_palette); ret = M_SavePNG(filepath, minigen->buf, minigen->w, minigen->h, screenshot_palette);
free(minigen->buf); failure:
if (minigen->buf != NULL)
free(minigen->buf);
if (ret) if (ret)
{ {
+9 -9
View File
@@ -110,12 +110,12 @@ perfstatrow_t rendertime_rows[] = {
{"ui ", "UI render: ", &ps_uitime, PS_TIME}, {"ui ", "UI render: ", &ps_uitime, PS_TIME},
{"finupdt", "I_FinishUpdate:", &ps_swaptime, PS_TIME}, {"finupdt", "I_FinishUpdate:", &ps_swaptime, PS_TIME},
{} {0}
}; };
perfstatrow_t gamelogicbrief_row[] = { perfstatrow_t gamelogicbrief_row[] = {
{"logic ", "Game logic: ", &ps_tictime, PS_TIME}, {"logic ", "Game logic: ", &ps_tictime, PS_TIME},
{} {0}
}; };
perfstatrow_t commoncounter_rows[] = { perfstatrow_t commoncounter_rows[] = {
@@ -123,20 +123,20 @@ perfstatrow_t commoncounter_rows[] = {
{"sprites", "Sprites: ", &ps_numsprites, 0}, {"sprites", "Sprites: ", &ps_numsprites, 0},
{"drwnode", "Drawnodes: ", &ps_numdrawnodes, 0}, {"drwnode", "Drawnodes: ", &ps_numdrawnodes, 0},
{"plyobjs", "Polyobjects: ", &ps_numpolyobjects, 0}, {"plyobjs", "Polyobjects: ", &ps_numpolyobjects, 0},
{} {0}
}; };
perfstatrow_t interpolation_rows[] = { perfstatrow_t interpolation_rows[] = {
{"intpfrc", "Interp frac: ", &ps_interp_frac, 0}, {"intpfrc", "Interp frac: ", &ps_interp_frac, 0},
{"intplag", "Interp lag: ", &ps_interp_lag, 0}, {"intplag", "Interp lag: ", &ps_interp_lag, 0},
{} {0}
}; };
#ifdef HWRENDER #ifdef HWRENDER
perfstatrow_t batchcount_rows[] = { perfstatrow_t batchcount_rows[] = {
{"polygon", "Polygons: ", &ps_hw_numpolys, 0}, {"polygon", "Polygons: ", &ps_hw_numpolys, 0},
{"vertex ", "Vertices: ", &ps_hw_numverts, 0}, {"vertex ", "Vertices: ", &ps_hw_numverts, 0},
{} {0}
}; };
perfstatrow_t batchcalls_rows[] = { perfstatrow_t batchcalls_rows[] = {
@@ -145,7 +145,7 @@ perfstatrow_t batchcalls_rows[] = {
{"texture", "Textures: ", &ps_hw_numtextures, 0}, {"texture", "Textures: ", &ps_hw_numtextures, 0},
{"polyflg", "Polyflags: ", &ps_hw_numpolyflags, 0}, {"polyflg", "Polyflags: ", &ps_hw_numpolyflags, 0},
{"colors ", "Colors: ", &ps_hw_numcolors, 0}, {"colors ", "Colors: ", &ps_hw_numcolors, 0},
{} {0}
}; };
#endif #endif
@@ -164,7 +164,7 @@ perfstatrow_t gamelogic_rows[] = {
{" lthinkf", " LUAh_ThinkFrame:", &ps_lua_thinkframe_time, PS_TIME|PS_LEVEL}, {" lthinkf", " LUAh_ThinkFrame:", &ps_lua_thinkframe_time, PS_TIME|PS_LEVEL},
{" lpostthinkf", " LUAh_PostThinkFrame:", &ps_lua_postthinkframe_time, PS_TIME|PS_LEVEL}, {" lpostthinkf", " LUAh_PostThinkFrame:", &ps_lua_postthinkframe_time, PS_TIME|PS_LEVEL},
{" other ", " Other: ", &ps_otherlogictime, PS_TIME|PS_LEVEL}, {" other ", " Other: ", &ps_otherlogictime, PS_TIME|PS_LEVEL},
{} {0}
}; };
perfstatrow_t thinkercount_rows[] = { perfstatrow_t thinkercount_rows[] = {
@@ -176,13 +176,13 @@ perfstatrow_t thinkercount_rows[] = {
{" precip ", " Precipitation: ", &ps_precipcount, PS_LEVEL}, {" precip ", " Precipitation: ", &ps_precipcount, PS_LEVEL},
{" other ", " Other: ", &ps_otherthcount, PS_LEVEL}, {" other ", " Other: ", &ps_otherthcount, PS_LEVEL},
{" remove ", " Pending removal:", &ps_removecount, PS_LEVEL}, {" remove ", " Pending removal:", &ps_removecount, PS_LEVEL},
{} {0}
}; };
perfstatrow_t misc_calls_rows[] = { perfstatrow_t misc_calls_rows[] = {
{"lmhook", "Lua mobj hooks: ", &ps_lua_mobjhooks, PS_LEVEL}, {"lmhook", "Lua mobj hooks: ", &ps_lua_mobjhooks, PS_LEVEL},
{"chkpos", "P_CheckPosition:", &ps_checkposition_calls, PS_LEVEL}, {"chkpos", "P_CheckPosition:", &ps_checkposition_calls, PS_LEVEL},
{} {0}
}; };
// Sample collection status for averaging. // Sample collection status for averaging.
+4 -4
View File
@@ -5977,7 +5977,7 @@ void A_Boss7Chase(void *thing)
if (actor->flags2 & MF2_FRET) if (actor->flags2 & MF2_FRET)
{ {
P_SetMobjState(actor, S_BLACKEGG_DESTROYPLAT1); P_SetMobjState(actor, S_BLACKEGG_DESTROYPLAT1);
S_StartSound(NULL, sfx_s3k53); S_StartSound(0, sfx_s3k53);
actor->flags2 &= ~MF2_FRET; actor->flags2 &= ~MF2_FRET;
return; return;
} }
@@ -6011,7 +6011,7 @@ void A_Boss7Chase(void *thing)
{ {
// Punch him! // Punch him!
P_SetMobjState(actor, actor->info->meleestate); P_SetMobjState(actor, actor->info->meleestate);
S_StartSound(NULL, sfx_begrnd); // warning sound S_StartSound(0, sfx_begrnd); // warning sound
return; return;
} }
} }
@@ -6057,7 +6057,7 @@ void A_Boss7Chase(void *thing)
case 2: // Homing Missile case 2: // Homing Missile
A_FaceTarget(actor); A_FaceTarget(actor);
P_SetMobjState(actor, actor->info->missilestate); P_SetMobjState(actor, actor->info->missilestate);
S_StartSound(NULL, sfx_beflap); S_StartSound(0, sfx_beflap);
break; break;
} }
@@ -10739,7 +10739,7 @@ void A_BrakChase(void *thing)
{ {
actor->reactiontime--; actor->reactiontime--;
if (actor->reactiontime == 0 && actor->type == MT_CYBRAKDEMON) if (actor->reactiontime == 0 && actor->type == MT_CYBRAKDEMON)
S_StartSound(NULL, sfx_bewar1 + P_RandomKey(4)); S_StartSound(0, sfx_bewar1 + P_RandomKey(4));
} }
// modify target threshold // modify target threshold
+13 -14
View File
@@ -3606,10 +3606,10 @@ static void P_CalculatePrecipFloor(precipmobj_t *mobj)
// Just the identification of a precip thinker. The thinker // Just the identification of a precip thinker. The thinker
// should never actually be called! // should never actually be called!
// //
FUNCNORETURN void P_NullPrecipThinker(precipmobj_t *mobj) void P_NullPrecipThinker(precipmobj_t *mobj)
{ {
(void)mobj; (void)mobj;
I_Error("P_NullPrecipThinker should not be called"); I_Assert("P_NullPrecipThinker should not be called" == 0);
} }
boolean P_PrecipThinker(precipmobj_t *mobj) boolean P_PrecipThinker(precipmobj_t *mobj)
@@ -4012,7 +4012,7 @@ static void P_Boss3Thinker(mobj_t *mobj)
if ((UINT32)mobj->extravalue1 + TICRATE*2 < leveltime) if ((UINT32)mobj->extravalue1 + TICRATE*2 < leveltime)
{ {
mobj->extravalue1 = (INT32)leveltime; mobj->extravalue1 = (INT32)leveltime;
S_StartSound(NULL, sfx_buzz1); S_StartSound(0, sfx_buzz1);
} }
// If in the center, check to make sure // If in the center, check to make sure
@@ -4631,7 +4631,7 @@ static void P_Boss7Thinker(mobj_t *mobj)
if (mobj->health > 0) if (mobj->health > 0)
mobj->health--; mobj->health--;
S_StartSound(NULL, (mobj->health) ? sfx_behurt : sfx_bedie2); S_StartSound(0, (mobj->health) ? sfx_behurt : sfx_bedie2);
mobj->reactiontime /= 3; mobj->reactiontime /= 3;
@@ -4670,7 +4670,7 @@ static void P_Boss7Thinker(mobj_t *mobj)
INT32 i; INT32 i;
mobj->state->nextstate = mobj->info->painstate; // Reset mobj->state->nextstate = mobj->info->painstate; // Reset
S_StartSound(NULL, sfx_bedeen); S_StartSound(0, sfx_bedeen);
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ {
@@ -4694,7 +4694,7 @@ static void P_Boss7Thinker(mobj_t *mobj)
mobj->state->nextstate = mobj->info->spawnstate; mobj->state->nextstate = mobj->info->spawnstate;
// Laugh // Laugh
S_StartSound(NULL, sfx_bewar1 + P_RandomKey(4)); S_StartSound(0, sfx_bewar1 + P_RandomKey(4));
} }
} }
} }
@@ -4714,7 +4714,7 @@ static void P_Boss7Thinker(mobj_t *mobj)
var2 = 2*TICRATE + (80<<16); var2 = 2*TICRATE + (80<<16);
A_LobShot(mobj); A_LobShot(mobj);
S_StartSound(NULL, sfx_begoop); S_StartSound(0, sfx_begoop);
} }
} }
else if (mobj->state == &states[S_BLACKEGG_SHOOT2]) else if (mobj->state == &states[S_BLACKEGG_SHOOT2])
@@ -4738,7 +4738,7 @@ static void P_Boss7Thinker(mobj_t *mobj)
S_StopSound(missile); S_StopSound(missile);
if (leveltime & 1) if (leveltime & 1)
S_StartSound(NULL, sfx_beshot); S_StartSound(0, sfx_beshot);
} }
else if (mobj->state == &states[S_BLACKEGG_JUMP1] && mobj->tics == 1) else if (mobj->state == &states[S_BLACKEGG_JUMP1] && mobj->tics == 1)
{ {
@@ -4871,7 +4871,7 @@ static void P_Boss7Thinker(mobj_t *mobj)
fixed_t x,y,z; fixed_t x,y,z;
mobj_t *mo2; mobj_t *mo2;
S_StartSound(NULL, sfx_befall); S_StartSound(0, sfx_befall);
z = mobj->floorz; z = mobj->floorz;
for (j = 0; j < 2; j++) for (j = 0; j < 2; j++)
@@ -4910,13 +4910,13 @@ static void P_Boss7Thinker(mobj_t *mobj)
P_DamageMobj(players[i].mo, mobj, mobj, 1); P_DamageMobj(players[i].mo, mobj, mobj, 1);
// Laugh // Laugh
S_StartSound(NULL, sfx_bewar1 + P_RandomKey(4)); S_StartSound(0, sfx_bewar1 + P_RandomKey(4));
} }
P_SetMobjState(mobj, mobj->info->spawnstate); P_SetMobjState(mobj, mobj->info->spawnstate);
} }
else if (mobj->state == &states[mobj->info->deathstate] && mobj->tics == mobj->state->tics) else if (mobj->state == &states[mobj->info->deathstate] && mobj->tics == mobj->state->tics)
S_StartSound(NULL, sfx_bedie1 + (P_RandomFixed() & 1)); S_StartSound(0, sfx_bedie1 + (P_RandomFixed() & 1));
} }
// Metal Sonic battle boss // Metal Sonic battle boss
@@ -10711,7 +10711,7 @@ void P_SpawnPlayer(INT32 playernum)
// the dead body mobj retains the skin through the 'spritedef' override). // the dead body mobj retains the skin through the 'spritedef' override).
mobj->skin = &skins[p->skin]; mobj->skin = &skins[p->skin];
mobj->localskin = (p->localskin ? K_GetPlayerSkin(p) : NULL); mobj->localskin = (p->localskin ? K_GetPlayerSkin(p) : 0);
mobj->skinlocal = p->skinlocal; mobj->skinlocal = p->skinlocal;
mobj->health = p->health; mobj->health = p->health;
@@ -12354,9 +12354,8 @@ mobj_t *P_SPMAngle(mobj_t *source, mobjtype_t type, angle_t angle, UINT8 allowai
// //
void P_FlashPal(player_t *pl, UINT16 type, UINT16 duration) void P_FlashPal(player_t *pl, UINT16 type, UINT16 duration)
{ {
if (!pl || cv_reducevfx.value) // no palette flashing with reducevfx if (!pl)
return; return;
pl->flashcount = duration; pl->flashcount = duration;
pl->flashpal = type; pl->flashpal = type;
} }
+2 -1
View File
@@ -1385,7 +1385,8 @@ static void Polyobj_rotateThings(polyobj_t *po, vector2_t origin, angle_t delta,
if (mo->player) if (mo->player)
{ {
P_ForceLocalAngle(mo->player, P_GetLocalAngle(mo->player) + delta); angle_t localangle = P_GetLocalAngle(mo->player);
P_ForceLocalAngle(mo->player, localangle + delta);
} }
} }
} }
+2 -2
View File
@@ -1022,7 +1022,7 @@ void P_WriteThings(lumpnum_t lumpnum)
size_t i, length; size_t i, length;
mapthing_t *mt; mapthing_t *mt;
UINT8 *data; UINT8 *data;
savebuffer_t save = {}; savebuffer_t save = {0};
INT16 temp; INT16 temp;
data = W_CacheLumpNum(lumpnum, PU_LEVEL); data = W_CacheLumpNum(lumpnum, PU_LEVEL);
@@ -1166,7 +1166,7 @@ static void P_LoadLineDefs2(void)
for (; i--; ld++) for (; i--; ld++)
{ {
ld->frontsector = sides[ld->sidenum[0]].sector; //e6y: Can't be -1 here ld->frontsector = sides[ld->sidenum[0]].sector; //e6y: Can't be -1 here
ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : NULL; ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : 0;
// Repeat count for midtexture // Repeat count for midtexture
if ((ld->flags & ML_EFFECT5) && (ld->sidenum[1] != 0xffff)) if ((ld->flags & ML_EFFECT5) && (ld->sidenum[1] != 0xffff))
+3 -3
View File
@@ -4579,8 +4579,8 @@ static inline void P_AddFFloorToList(sector_t *sec, ffloor_t *ffloor)
if (!sec->ffloors) if (!sec->ffloors)
{ {
sec->ffloors = ffloor; sec->ffloors = ffloor;
ffloor->next = NULL; ffloor->next = 0;
ffloor->prev = NULL; ffloor->prev = 0;
return; return;
} }
@@ -4588,7 +4588,7 @@ static inline void P_AddFFloorToList(sector_t *sec, ffloor_t *ffloor)
rover->next = ffloor; rover->next = ffloor;
ffloor->prev = rover; ffloor->prev = rover;
ffloor->next = NULL; ffloor->next = 0;
} }
/** Adds a 3Dfloor. /** Adds a 3Dfloor.
+9 -8
View File
@@ -16,14 +16,14 @@
#include "doomdef.h" #include "doomdef.h"
#ifdef __GNUG__
#pragma interface
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#ifdef __GNUG__
#pragma interface
#endif
extern tic_t leveltime; extern tic_t leveltime;
// Called by G_Ticker. Carries out all thinking of enemies and players. // Called by G_Ticker. Carries out all thinking of enemies and players.
@@ -42,13 +42,14 @@ mobj_t *P_SetTarget2(mobj_t **mo, mobj_t *target
#endif #endif
); );
#ifdef __cplusplus
}
#endif
#ifdef PARANOIA #ifdef PARANOIA
#define P_SetTarget(...) P_SetTarget2(__VA_ARGS__, __FILE__, __LINE__) #define P_SetTarget(...) P_SetTarget2(__VA_ARGS__, __FILE__, __LINE__)
#else #else
#define P_SetTarget P_SetTarget2 #define P_SetTarget P_SetTarget2
#endif #endif
#ifdef __cplusplus
} // extern "C"
#endif
#endif #endif
+2
View File
@@ -14,6 +14,8 @@
#include "doomdef.h" #include "doomdef.h"
#include "g_game.h" #include "g_game.h"
#include <algorithm>
#include "r_fps.h" #include "r_fps.h"
#include "r_local.h" #include "r_local.h"
#include "r_state.h" #include "r_state.h"
+7 -7
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)(FixedClamp((INT64)std::min(viewx, std::min(vxleft, vxright)) - bmaporgx))>>MAPBLOCKSHIFT; *xl = (unsigned)(std::min(viewx, std::min(vxleft, vxright)) - bmaporgx)>>MAPBLOCKSHIFT;
*xh = (unsigned)(FixedClamp((INT64)std::max(viewx, std::max(vxleft, vxright)) - bmaporgx))>>MAPBLOCKSHIFT; *xh = (unsigned)(std::max(viewx, std::max(vxleft, vxright)) - bmaporgx)>>MAPBLOCKSHIFT;
*yl = (unsigned)(FixedClamp((INT64)std::min(viewy, std::min(vyleft, vyright)) - bmaporgy))>>MAPBLOCKSHIFT; *yl = (unsigned)(std::min(viewy, std::min(vyleft, vyright)) - bmaporgy)>>MAPBLOCKSHIFT;
*yh = (unsigned)(FixedClamp((INT64)std::max(viewy, std::max(vyleft, vyright)) - bmaporgy))>>MAPBLOCKSHIFT; *yh = (unsigned)(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 = abs(i - viewheight*8) << FRACBITS; fixed_t dy = (i - viewheight*8)<<FRACBITS;
dy = FixedMul(dy, fovtan); dy = FixedMul(abs(dy), fovtan);
yslopetab[i] = FixedDiv(centerx*FRACUNIT, dy); yslopetab[i] = FixedDiv(centerx*FRACUNIT, dy);
} }
} }
@@ -1087,7 +1087,7 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y)
ret = &subsectors[nodenum & ~NF_SUBSECTOR]; ret = &subsectors[nodenum & ~NF_SUBSECTOR];
for (i = 0; i < ret->numlines; i++) for (i = 0; i < ret->numlines; i++)
if (P_PointOnLineSide(x, y, segs[ret->firstline + i].linedef) != segs[ret->firstline + i].side) if (P_PointOnLineSide(x, y, segs[ret->firstline + i].linedef) != segs[ret->firstline + i].side)
return NULL; return 0;
return ret; return ret;
} }
+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 = FixedClamp(labs((INT64)x - (INT64)x1)); const fixed_t absx = abs(x - x1);
const fixed_t absy = FixedClamp(labs((INT64)y - (INT64)y1)); const fixed_t absy = abs(y - y1);
#ifdef __cplusplus #ifdef __cplusplus
return std::max<fixed_t>(absx, absy); return std::max<fixed_t>(absx, absy);
#else #else
+12 -15
View File
@@ -57,11 +57,8 @@ 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.
constexpr unsigned int visplane_hash(const unsigned int picnum, const unsigned int lightlevel, #define visplane_hash(picnum,lightlevel,height) \
const unsigned int height) ((unsigned)((picnum)*3+(lightlevel)+(height)*7) & VISPLANEHASHMASK)
{
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.
@@ -139,7 +136,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<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. // 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 = FixedClamp((INT64)ds->xoffs + (INT64)FixedMul(planecos, distance) + ((INT64)x1 - (INT64)centerx) * (INT64)ds->xstep); ds->xfrac = ds->xoffs + FixedMul(planecos, distance) + (x1 - centerx) * ds->xstep;
ds->yfrac = FixedClamp((INT64)ds->yoffs - (INT64)FixedMul(planesin, distance) + ((INT64)x1 - (INT64)centerx) * (INT64)ds->ystep); ds->yfrac = ds->yoffs - FixedMul(planesin, distance) + (x1 - centerx) * ds->ystep;
if (ds->planeripple.active) 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) for (check = visplanes[hash]; check; check = check->next)
{ {
@@ -565,7 +562,7 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop)
} }
else 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); 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 // m is the v direction vector in view space
ang = ANG2RAD(ANGLE_180 - (angle + plangle)); ang = ANG2RAD(ANGLE_180 - (angle + plangle));
m->x = cosf(ang); m->x = cos(ang);
m->z = sinf(ang); m->z = sin(ang);
// n is the u direction vector in view space // n is the u direction vector in view space
n->x = sinf(ang); n->x = sin(ang);
n->z = -cosf(ang); n->z = -cos(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));
@@ -1012,7 +1009,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
+3 -2
View File
@@ -246,6 +246,7 @@ 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
@@ -312,8 +313,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)
+97 -86
View File
@@ -226,11 +226,10 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
leftheight -= viewz; leftheight -= viewz;
rightheight -= viewz; rightheight -= viewz;
rlight->height = FixedClamp((INT64)centeryfrac - FixedMul(leftheight, drawseg->scale1)); rlight->height = (centeryfrac) - FixedMul(leftheight, drawseg->scale1);
rlight->heightstep = FixedClamp((INT64)centeryfrac - FixedMul(rightheight, drawseg->scale2)); rlight->heightstep = (centeryfrac) - FixedMul(rightheight, drawseg->scale2);
rlight->heightstep = FixedClamp((INT64)rlight->heightstep - rlight->height)/(range); rlight->heightstep = (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);
@@ -342,7 +341,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 = 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; lighttable_t **xwalllights;
sprbotscreen = INT32_MAX; 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; dc->iscale = 0xffffffffu / (unsigned)spryscale;
// draw the texture // draw the texture
@@ -408,8 +407,7 @@ 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)
{ {
@@ -425,7 +423,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 = FixedClamp((INT64)rlight->height + rlight->heightstep); rlight->height += rlight->heightstep;
} }
continue; continue;
@@ -457,7 +455,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 = FixedClamp((INT64)centeryfrac - FixedMul(dc->texturemid, spryscale)); sprtopscreen = centeryfrac - FixedMul(dc->texturemid, spryscale);
dc->iscale = 0xffffffffu / (unsigned)spryscale; dc->iscale = 0xffffffffu / (unsigned)spryscale;
// draw the texture // draw the texture
@@ -712,6 +710,17 @@ 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)
{ {
@@ -727,6 +736,7 @@ 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];
@@ -750,14 +760,17 @@ 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.
rlight->height = FixedClamp((INT64)centeryfrac - (((INT64)leftheight * drawseg->scale1)>>FRACBITS)); overflow_test = (INT64)centeryfrac - (((INT64)leftheight*drawseg->scale1)>>FRACBITS);
rlight->heightstep = FixedClamp((INT64)centeryfrac - (((INT64)rightheight * drawseg->scale2)>>FRACBITS)); rlight->height = overflow_clamp(overflow_test);
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)
@@ -768,9 +781,13 @@ 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.
rlight->botheight = FixedClamp((INT64)centeryfrac - (((INT64)leftheight*drawseg->scale1)>>FRACBITS)); overflow_test = (INT64)centeryfrac - (((INT64)leftheight*drawseg->scale1)>>FRACBITS);
rlight->botheightstep = FixedClamp(((INT64)centeryfrac - (((INT64)rightheight*drawseg->scale2)>>FRACBITS))); rlight->botheight = overflow_clamp(overflow_test);
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;
@@ -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; 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 = FixedClamp((INT64)centeryfrac - (((INT64)left_top * drawseg->scale1) >> FRACBITS)); top_frac = (INT64)centeryfrac - (((INT64)left_top * drawseg->scale1) >> FRACBITS);
top_step = FixedClamp((INT64)centeryfrac - (((INT64)right_top * drawseg->scale2) >> FRACBITS)); bottom_frac = (INT64)centeryfrac - (((INT64)left_bottom * drawseg->scale1) >> FRACBITS);
bottom_frac = FixedClamp((INT64)centeryfrac - (((INT64)left_bottom * drawseg->scale1) >> FRACBITS)); top_step = (INT64)centeryfrac - (((INT64)right_top * drawseg->scale2) >> FRACBITS);
bottom_step = FixedClamp((INT64)centeryfrac - (((INT64)right_bottom * drawseg->scale2) >> FRACBITS)); bottom_step = (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);
@@ -904,8 +921,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 = top_frac; sprtopscreen = windowtop = overflow_clamp(top_frac);
sprbotscreen = windowbottom = bottom_frac; sprbotscreen = windowbottom = overflow_clamp(bottom_frac);
top_frac += top_step; top_frac += top_step;
bottom_frac += bottom_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++) 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 = 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; solid = 0;
height = rlight->height; height = rlight->height;
rlight->height = FixedClamp((INT64)rlight->height + rlight->heightstep); rlight->height += rlight->heightstep;
if (solid) if (solid)
{ {
bheight = FixedClamp((INT64)rlight->botheight - (FRACUNIT >> 1)); bheight = rlight->botheight - (FRACUNIT >> 1);
rlight->botheight = FixedClamp((INT64)rlight->botheight + rlight->botheightstep); rlight->botheight += rlight->botheightstep;
} }
if (height <= windowtop) 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++) for (i++; i < dc->numlights; i++)
{ {
rlight = &dc->lightlist[i]; rlight = &dc->lightlist[i];
rlight->height = FixedClamp((INT64)rlight->height + rlight->heightstep); rlight->height += rlight->heightstep;
if (rlight->flags & FF_CUTLEVEL) if (rlight->flags & FF_CUTLEVEL)
rlight->botheight += rlight->botheightstep; rlight->botheight += rlight->botheightstep;
@@ -1197,7 +1212,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 = FixedClamp((INT64)topfrac + HEIGHTUNIT-1)>>HEIGHTBITS; yl = (topfrac+HEIGHTUNIT-1)>>HEIGHTBITS;
yh = bottomfrac>>HEIGHTBITS; yh = bottomfrac>>HEIGHTBITS;
// Mark ceiling // Mark ceiling
@@ -1348,17 +1363,15 @@ 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 = FixedClamp((INT64)rw_offset - FixedMul(FINETANGENT(angle & 4095), rw_distance)); texturecolumn = rw_offset-FixedMul(FINETANGENT(angle & 4095), rw_distance);
if (oldtexturecolumn != -1) if (oldtexturecolumn != -1)
{ {
const fixed_t coloff = FixedClamp((INT64)oldtexturecolumn - texturecolumn); rw_bottomtexturemid += FixedMul(rw_bottomtextureslide, oldtexturecolumn-texturecolumn);
rw_bottomtexturemid += FixedMul(rw_bottomtextureslide, coloff); rw_midtexturemid += FixedMul(rw_midtextureslide, oldtexturecolumn-texturecolumn);
rw_midtexturemid += FixedMul(rw_midtextureslide, coloff); rw_toptexturemid += FixedMul(rw_toptextureslide, oldtexturecolumn-texturecolumn);
rw_toptexturemid += FixedMul(rw_toptextureslide, coloff); rw_midtextureback += FixedMul(rw_midtexturebackslide, oldtexturecolumn-texturecolumn);
rw_midtextureback += FixedMul(rw_midtexturebackslide, coloff);
} }
oldtexturecolumn = texturecolumn; oldtexturecolumn = texturecolumn;
@@ -1368,7 +1381,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];
@@ -1450,8 +1463,8 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
if (toptexture) if (toptexture)
{ {
// top wall // top wall
mid = pixhigh >> HEIGHTBITS; mid = pixhigh>>HEIGHTBITS;
pixhigh = FixedClamp((INT64)pixhigh + pixhighstep); pixhigh += pixhighstep;
if (mid >= floorclip[rw_x]) if (mid >= floorclip[rw_x])
mid = floorclip[rw_x]-1; mid = floorclip[rw_x]-1;
@@ -1480,8 +1493,8 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
if (bottomtexture) if (bottomtexture)
{ {
// bottom wall // bottom wall
mid = FixedClamp((INT64)pixlow+HEIGHTUNIT-1)>>HEIGHTBITS; mid = (pixlow+HEIGHTUNIT-1)>>HEIGHTBITS;
pixlow = FixedClamp((INT64)pixlow + pixlowstep); pixlow += pixlowstep;
// no space above wall? // no space above wall?
if (mid <= ceilingclip[rw_x]) if (mid <= ceilingclip[rw_x])
@@ -1532,10 +1545,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 = 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) 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; visffloor[i].b_frac += visffloor[i].b_step;
} }
rw_scale = FixedClamp((INT64)rw_scale + rw_scalestep); rw_scale += rw_scalestep;
topfrac += topstep;
topfrac = FixedClamp((INT64)topfrac + topstep); bottomfrac += bottomstep;
bottomfrac = FixedClamp((INT64)bottomfrac + bottomstep);
} }
} }
@@ -1573,7 +1585,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 = FixedClamp((INT64)topfrac + HEIGHTUNIT-1)>>HEIGHTBITS; yl = (topfrac+HEIGHTUNIT-1)>>HEIGHTBITS;
yh = bottomfrac>>HEIGHTBITS; yh = bottomfrac>>HEIGHTBITS;
// Mark ceiling // Mark ceiling
@@ -1810,7 +1822,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
// big room fix // big room fix
if (longboi) 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->x1 = rw_x = start;
ds_p->x2 = stop; ds_p->x2 = stop;
@@ -2193,8 +2205,8 @@ void R_StoreWallRange(INT32 start, INT32 stop)
} }
} }
rw_toptexturemid = FixedClamp((INT64)rw_toptexturemid + sidedef->rowoffset); rw_toptexturemid += sidedef->rowoffset;
rw_bottomtexturemid = FixedClamp((INT64)rw_bottomtexturemid + sidedef->rowoffset); rw_bottomtexturemid += sidedef->rowoffset;
R_AllocTextureColumnTables(rw_stopx - start); R_AllocTextureColumnTables(rw_stopx - start);
@@ -2219,12 +2231,12 @@ void R_StoreWallRange(INT32 start, INT32 stop)
lowcutslope = std::max(worldbottomslope, worldlowslope) + viewz; lowcutslope = std::max(worldbottomslope, worldlowslope) + viewz;
highcutslope = std::min(worldtopslope, worldhighslope) + viewz; highcutslope = std::min(worldtopslope, worldhighslope) + viewz;
auto check_fof_offscreen = [&](ffloor_t* rrover, INT32 bottom, INT32 bottomslope, INT32 top, INT32 topslope) auto check_fof_offscreen = [&](ffloor_t* rover, INT32 bottom, INT32 bottomslope, INT32 top, INT32 topslope)
{ {
return ((P_GetFFloorTopZAt (rrover, segleft .x, segleft .y) <= bottom + viewz return ((P_GetFFloorTopZAt (rover, segleft .x, segleft .y) <= bottom + viewz
&& P_GetFFloorTopZAt (rrover, segright.x, segright.y) <= bottomslope + viewz) && P_GetFFloorTopZAt (rover, segright.x, segright.y) <= bottomslope + viewz)
|| ( P_GetFFloorBottomZAt (rrover, segleft .x, segleft .y) >= top + viewz || ( P_GetFFloorBottomZAt (rover, segleft .x, segleft .y) >= top + viewz
&& P_GetFFloorBottomZAt (rrover, segright.x, segright.y) >= topslope + viewz)); && P_GetFFloorBottomZAt (rover, segright.x, segright.y) >= topslope + viewz));
}; };
if (frontsector->ffloors && backsector->ffloors) if (frontsector->ffloors && backsector->ffloors)
@@ -2479,9 +2491,8 @@ 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 = FixedClamp((INT64)rw_offset + curline->offset); rw_offset2 = rw_offset + curline->offset;
rw_offset = FixedClamp((INT64)rw_offset + (INT64)sidedef->textureoffset + curline->offset); rw_offset += sidedef->textureoffset + curline->offset;
rw_centerangle = ANGLE_90 + viewangle - rw_normalangle; rw_centerangle = ANGLE_90 + viewangle - rw_normalangle;
// calculate light table // calculate light table
@@ -2541,8 +2552,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 = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldtop, rw_scale)); topfrac = (centeryfrac>>4) - FixedMul (worldtop, rw_scale);
}; };
// untextured seg // 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 // 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 = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldbottom, rw_scale)); topfrac = (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 = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldbottomslope, rw_scale)); topfrac = (centeryfrac>>4) - FixedMul (worldbottomslope, rw_scale);
} }
} }
else else
@@ -2579,18 +2590,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 = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldbottom, rw_scale)); bottomfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale);
if (frontsector->c_slope) 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); topstep = (topfracend-topfrac)/(range);
} }
if (frontsector->f_slope) 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); bottomstep = (bottomfracend-bottomfrac)/(range);
} }
} }
@@ -2632,9 +2643,9 @@ void R_StoreWallRange(INT32 start, INT32 stop)
continue; continue;
} }
rlight->height = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(leftheight, rw_scale)); rlight->height = (centeryfrac>>4) - FixedMul(leftheight, rw_scale);
rlight->heightstep = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(rightheight, ds_p->scale2)); rlight->heightstep = (centeryfrac>>4) - FixedMul(rightheight, ds_p->scale2);
rlight->heightstep = FixedClamp((INT64)rlight->heightstep - rlight->height)/(range); 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->caster && light->caster->flags & FF_CUTSOLIDS) if (light->caster && light->caster->flags & FF_CUTSOLIDS)
@@ -2696,9 +2707,9 @@ void R_StoreWallRange(INT32 start, INT32 stop)
if (toptexture) 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); 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
@@ -2708,9 +2719,9 @@ void R_StoreWallRange(INT32 start, INT32 stop)
if (bottomtexture) 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); 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
@@ -2731,8 +2742,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 = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(visffloor[i].b_pos, rw_scale)); visffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(visffloor[i].b_pos, rw_scale);
visffloor[i].b_step = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(visffloor[i].b_pos_slope, ds_p->scale2)); visffloor[i].b_step = (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);
}; };
@@ -2838,7 +2849,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 = 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) while (i < numffloors && visffloor[i].polyobj != curline->polyseg)
@@ -2869,7 +2880,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;
@@ -2883,7 +2894,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;
+1 -1
View File
@@ -302,7 +302,7 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar)
if (player->mo) if (player->mo)
{ {
player->mo->localskin = NULL; player->mo->localskin = 0;
player->mo->skinlocal = false; player->mo->skinlocal = false;
} }
} }
+14 -23
View File
@@ -11,7 +11,6 @@
/// \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"
@@ -71,7 +70,7 @@ INT16 *screenheightarray = NULL;
typedef struct drawseg_xrange_item_s typedef struct drawseg_xrange_item_s
{ {
INT32 x1, x2; INT16 x1, x2;
drawseg_t *user; drawseg_t *user;
} drawseg_xrange_item_t; } drawseg_xrange_item_t;
@@ -490,8 +489,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(cosf(-fa)); rollcosang[angle] = FLOAT_TO_FIXED(cos(-fa));
rollsinang[angle] = FLOAT_TO_FIXED(sinf(-fa)); rollsinang[angle] = FLOAT_TO_FIXED(sin(-fa));
} }
#endif #endif
@@ -533,8 +532,8 @@ void R_ClearSprites(void)
visspritecount = numvisiblesprites = clippedvissprites = 0; visspritecount = numvisiblesprites = clippedvissprites = 0;
} }
static INT16 *vissprite_clipbot[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {}; static INT16 *vissprite_clipbot[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {0};
static INT16 *vissprite_cliptop[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {}; static INT16 *vissprite_cliptop[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {0};
static void R_AllocVisSpriteChunkMemory(UINT32 chunk) static void R_AllocVisSpriteChunkMemory(UINT32 chunk)
{ {
@@ -617,11 +616,10 @@ 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;
topscreen = FixedClamp((INT64)sprtopscreen + (INT64)spryscale * (INT64)topdelta); dc->yl = (topscreen+FRACUNIT-1)>>FRACBITS;
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)
@@ -660,7 +658,7 @@ void R_DrawMaskedColumn(drawcolumndata_t* dc, column_t *column)
dc->texturemid = basetexturemid; dc->texturemid = basetexturemid;
} }
INT32 lengthcol = 0; // column->length : for flipped column function pointers and multi-patch on 2sided wall = texture->height INT32 lengthcol; // column->length : for flipped column function pointers and multi-patch on 2sided wall = texture->height
static void R_DrawFlippedMaskedColumn(drawcolumndata_t* dc, column_t *column) static void R_DrawFlippedMaskedColumn(drawcolumndata_t* dc, column_t *column)
{ {
@@ -887,7 +885,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 = FixedClamp((INT64)vis->paperoffset - FixedMul(FINETANGENT(angle), vis->paperdistance)) / horzscale; texturecolumn = (vis->paperoffset - FixedMul(FINETANGENT(angle), vis->paperdistance)) / horzscale;
if (texturecolumn < 0 || texturecolumn >= pwidth) if (texturecolumn < 0 || texturecolumn >= pwidth)
continue; continue;
@@ -1579,7 +1577,7 @@ static void R_ProjectSprite(mobj_t *thing)
else else
blendmode = thing->blendmode; blendmode = thing->blendmode;
if (thing->flags2 & MF2_SHADOW) // actually only the player should use this (temporary invisibility) if (thing->flags2 & MF2_SHADOW || thing->flags2 & MF2_SHADOW) // actually only the player should use this (temporary invisibility)
trans = tr_trans80; // because now the translucency is set through FF_TRANSMASK trans = tr_trans80; // because now the translucency is set through FF_TRANSMASK
else if (thing->frame & FF_TRANSMASK) else if (thing->frame & FF_TRANSMASK)
{ {
@@ -1590,15 +1588,8 @@ static void R_ProjectSprite(mobj_t *thing)
else else
trans = 0; trans = 0;
if (thing->player) if (cv_playerfade.value && thing->player)
{ trans = static_cast<INT32>(R_GetThingTransTable(R_DoPlayerFade(thing), static_cast<transnum_t>(trans)));
// make hyu´d players translucent with reducevfx, could be done better, but im lazy as crap
if (cv_reducevfx.value && thing->player->kartstuff[k_hyudorotimer] > 0)
trans = static_cast<INT32>(R_GetThingTransTable(FRACUNIT/2, static_cast<transnum_t>(trans)));
if (cv_playerfade.value)
trans = static_cast<INT32>(R_GetThingTransTable(R_DoPlayerFade(thing), static_cast<transnum_t>(trans)));
}
//SoM: 3/17/2000: Disregard sprites that are out of view.. //SoM: 3/17/2000: Disregard sprites that are out of view..
if (vflip) if (vflip)
@@ -3095,7 +3086,7 @@ static void R_DrawMaskedList(drawnode_t* head)
void R_DrawMasked(maskcount_t* masks, INT32 nummasks) void R_DrawMasked(maskcount_t* masks, INT32 nummasks)
{ {
INT32 i; INT32 i;
drawnode_t *heads = NULL; /**< Drawnode lists; as many as number of views/portals. */ drawnode_t *heads; /**< Drawnode lists; as many as number of views/portals. */
heads = static_cast<drawnode_t*>(calloc(nummasks, sizeof(drawnode_t))); heads = static_cast<drawnode_t*>(calloc(nummasks, sizeof(drawnode_t)));
+3 -6
View File
@@ -884,7 +884,7 @@ static void S_StopChannel(INT32 cnum)
if (cnum != i && c->sfxinfo == channels[i].sfxinfo) if (cnum != i && c->sfxinfo == channels[i].sfxinfo)
break; break;
c->sfxinfo = NULL; c->sfxinfo = 0;
} }
c->origin = NULL; c->origin = NULL;
@@ -1271,7 +1271,7 @@ static musicdef_t *S_AddMusicCredit(void)
return &musicdefs[chunk][i]; return &musicdefs[chunk][i];
} }
struct cursongcredit cursongcredit = {}; // Currently displayed song credit info struct cursongcredit cursongcredit = {0}; // Currently displayed song credit info
static boolean ReadMusicDefFields(UINT16 wadnum, int line, char *stoken, musicdef_t **defp) static boolean ReadMusicDefFields(UINT16 wadnum, int line, char *stoken, musicdef_t **defp)
{ {
@@ -1491,9 +1491,6 @@ musicdef_t *S_FindMusicCredit(const char *musname)
{ {
def = S_GetMusicCredit(i); def = S_GetMusicCredit(i);
if (!def)
continue;
if (hash != def->hash) if (hash != def->hash)
continue; continue;
@@ -1704,7 +1701,7 @@ static void S_UnloadMusic(void)
music.flags = 0; music.flags = 0;
music.looping = false; music.looping = false;
music_refade_cv = NULL; music_refade_cv = 0;
} }
static boolean S_PlayMusic(boolean looping, UINT32 fadeinms) static boolean S_PlayMusic(boolean looping, UINT32 fadeinms)
+2 -2
View File
@@ -253,9 +253,9 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32
void S_ChangeMusicSpecial (const char *mmusic); void S_ChangeMusicSpecial (const char *mmusic);
void S_SetRestoreMusicFadeInCvar(consvar_t *cvar); void S_SetRestoreMusicFadeInCvar (consvar_t *cvar);
#define S_ClearRestoreMusicFadeInCvar() \ #define S_ClearRestoreMusicFadeInCvar() \
S_SetRestoreMusicFadeInCvar(NULL) S_SetRestoreMusicFadeInCvar(0)
int S_GetRestoreMusicFadeIn (void); int S_GetRestoreMusicFadeIn (void);
// Stops the music. // Stops the music.
-1
View File
@@ -63,7 +63,6 @@ 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
+96 -348
View File
@@ -1,367 +1,115 @@
# Declare SDL2 interface sources # Declare SDL2 interface sources
set(SRB2_CONFIG_SDL2_USEMIXER ON CACHE BOOL "Use SDL2_mixer or regular sdl sound") target_sources(SRB2SDL2 PRIVATE
mixer_sound.c
if(${SRB2_CONFIG_SDL2_USEMIXER}) ogl_sdl.c
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) i_threads.c
set(SDL2_MIXER_FOUND ON) i_net.c
if(${SRB2_SYSTEM_BITS} EQUAL 64) i_system.cpp
set(SDL2_MIXER_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/x86_64-w64-mingw32/include/SDL2) i_main.c
set(SDL2_MIXER_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/x86_64-w64-mingw32/lib -lSDL2_mixer") i_video.c
else() # 32-bit
set(SDL2_MIXER_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/i686-w64-mingw32/include/SDL2)
set(SDL2_MIXER_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/i686-w64-mingw32/lib -lSDL2_mixer")
endif()
else()
find_package(SDL2_mixer)
endif()
if(${SDL2_MIXER_FOUND})
set(SRB2_HAVE_MIXER ON)
set(SRB2_SDL2_SOUNDIMPL mixer_sound.c)
else()
message(WARNING "You specified that SDL2_mixer is available, but it was not found. Falling back to sdl sound.")
set(SRB2_SDL2_SOUNDIMPL sdl_sound.c)
endif()
else()
set(SRB2_SDL2_SOUNDIMPL sdl_sound.c)
endif()
set(SRB2_SDL2_SOURCES
dosstr.c dosstr.c
endtxt.c endtxt.c
hwsym_sdl.c hwsym_sdl.c
i_main.c
i_net.c
i_system.cpp
i_ttf.c
i_video.c
i_threads.c
#IMG_xpm.c
ogl_sdl.c
${SRB2_SDL2_SOUNDIMPL}
) )
set(SRB2_SDL2_HEADERS if("${CMAKE_SYSTEM_NAME}" MATCHES Windows)
endtxt.h target_sources(SRB2SDL2 PRIVATE
hwsym_sdl.h ../win32/win_dbg.c
i_ttf.h ../win32/Srb2win.rc)
ogl_sdl.h
sdlmain.h
)
source_group("Interface Code" FILES ${SRB2_SDL2_SOURCES} ${SRB2_SDL2_HEADERS})
# Dependency
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
set(SDL2_FOUND ON)
if(${SRB2_SYSTEM_BITS} EQUAL 64)
set(SDL2_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/SDL2/x86_64-w64-mingw32/include/SDL2)
set(SDL2_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDL2/x86_64-w64-mingw32/lib -lSDL2")
else() # 32-bit
set(SDL2_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/SDL2/i686-w64-mingw32/include/SDL2)
set(SDL2_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDL2/i686-w64-mingw32/lib -lSDL2")
endif()
else()
find_package(SDL2)
endif() endif()
if(${SDL2_FOUND}) if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin)
set(SRB2_SDL2_TOTAL_SOURCES set(MACOSX_BUNDLE_ICON_FILE Srb2mac.icns)
${SRB2_CORE_SOURCES} set_source_files_properties(macosx/Srb2mac.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
${SRB2_CORE_HEADERS} target_sources(SRB2SDL2 PRIVATE
${SRB2_DISCORDRPC_SOURCES} macosx/mac_resources.c
${SRB2_DISCORDRPC_HEADERS} macosx/mac_resources.h
${SRB2_PNG_SOURCES} macosx/Srb2mac.icns
${SRB2_PNG_HEADERS}
${SRB2_CORE_RENDER_SOURCES}
${SRB2_CORE_GAME_SOURCES}
${SRB2_LUA_SOURCES}
${SRB2_LUA_HEADERS}
${SRB2_BLUA_SOURCES}
${SRB2_BLUA_HEADERS}
${SRB2_SDL2_SOURCES}
${SRB2_SDL2_HEADERS}
) )
endif()
source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS} if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin)
${SRB2_PNG_SOURCES} ${SRB2_PNG_HEADERS}) find_library(CORE_FOUNDATION_LIBRARY "CoreFoundation")
source_group("Renderer" FILES ${SRB2_CORE_RENDER_SOURCES})
source_group("Game" FILES ${SRB2_CORE_GAME_SOURCES})
source_group("Discord Rich Presence" FILES ${SRB2_DISCORDRPC_SOURCES} ${SRB2_DISCORDRPC_HEADERS})
source_group("Assembly" FILES ${SRB2_ASM_SOURCES} ${SRB2_NASM_SOURCES})
source_group("LUA" FILES ${SRB2_LUA_SOURCES} ${SRB2_LUA_HEADERS})
source_group("LUA\\Interpreter" FILES ${SRB2_BLUA_SOURCES} ${SRB2_BLUA_HEADERS})
if(${SRB2_CONFIG_HWRENDER})
set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES}
${SRB2_HWRENDER_SOURCES}
${SRB2_HWRENDER_HEADERS}
${SRB2_R_OPENGL_SOURCES}
${SRB2_R_OPENGL_HEADERS}
)
source_group("Hardware" FILES ${SRB2_HWRENDER_SOURCES} ${SRB2_HWRENDER_HEADERS})
source_group("Hardware\\OpenGL Renderer" FILES ${SRB2_R_OPENGL_SOURCES} ${SRB2_R_OPENGL_HEADERS})
endif()
if(${SRB2_USEASM})
set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES}
${SRB2_NASM_SOURCES}
)
endif()
if(${CMAKE_SYSTEM} MATCHES Windows)
set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES}
${CMAKE_SOURCE_DIR}/src/win32/win_dbg.c
${CMAKE_SOURCE_DIR}/src/win32/Srb2win.rc
)
endif()
if(${CMAKE_SYSTEM} MATCHES Darwin)
set(MACOSX_BUNDLE_ICON_FILE Srb2mac.icns)
set_source_files_properties(macosx/Srb2mac.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
set(SRB2_SDL2_MAC_SOURCES
macosx/mac_resources.c
macosx/mac_resources.h
macosx/Srb2mac.icns
)
source_group("Interface Code\\OSX Compatibility" FILES ${SRB2_SDL2_MAC_SOURCES})
set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES} ${SRB2_SDL2_MAC_SOURCES})
endif()
add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32 ${SRB2_SDL2_TOTAL_SOURCES})
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME ${SRB2_SDL2_EXE_NAME})
if(${CMAKE_SYSTEM} MATCHES Darwin)
find_library(CORE_FOUNDATION_LIBRARY "CoreFoundation")
target_link_libraries(SRB2SDL2 PRIVATE
${CORE_FOUNDATION_LIBRARY}
)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
# Configure the app bundle icon and plist properties
target_sources(SRB2SDL2 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/macosx/Srb2mac.icns")
set_target_properties(SRB2SDL2 PROPERTIES
MACOSX_BUNDLE_ICON_FILE "Srb2mac"
MACOSX_BUNDLE_BUNDLE_NAME "Sonic Robo Blast 2"
MACOSX_BUNDLE_BUNDLE_VERSION ${SRB2_VERSION}
RESOURCE "${CMAKE_CURRENT_SOURCE_DIR}/macosx/Srb2mac.icns"
)
endif()
target_link_libraries(SRB2SDL2 PRIVATE target_link_libraries(SRB2SDL2 PRIVATE
${SDL2_LIBRARIES} ${CORE_FOUNDATION_LIBRARY}
${SDL2_MIXER_LIBRARIES}
${GME_LIBRARIES}
${OPENMPT_LIBRARIES}
${MIXERX_LIBRARIES}
${PNG_LIBRARIES}
${ZLIB_LIBRARIES}
${OPENGL_LIBRARIES}
${CURL_LIBRARIES}
${DISCORDRPC_LIBRARIES}
) )
if(${SRB2_HAVE_LIBBACKTRACE})
target_link_libraries(SRB2SDL2 PRIVATE ${LIBBACKTRACE_LIBRARIES})
endif()
if(${CMAKE_SYSTEM} MATCHES Linux)
target_link_libraries(SRB2SDL2 PRIVATE
m
rt
pthread
)
endif()
if(${CMAKE_SYSTEM} MATCHES Windows AND ${CMAKE_C_COMPILER_ID} MATCHES "GNU" AND ${SRB2_SYSTEM_BITS} EQUAL 32)
target_link_libraries(SRB2SDL2 PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/../../libs/drmingw/lib/win32/libexchndl.a"
"${CMAKE_CURRENT_SOURCE_DIR}/../../libs/drmingw/lib/win32/libmgwhelp.a"
)
target_include_directories(SRB2SDL2 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../libs/drmingw/include")
endif()
#target_link_libraries(SRB2SDL2 PRIVATE SRB2Core) #target_link_libraries(SRB2SDL2 PRIVATE SRB2Core)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
if(${SRB2_USEASM}) # Configure the app bundle icon and plist properties
if(${SRB2_CONFIG_YASM}) target_sources(SRB2SDL2 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/macosx/Srb2mac.icns")
set(ASM_ASSEMBLER_TEMP ${CMAKE_ASM_YASM_COMPILER}) set_target_properties(SRB2SDL2 PROPERTIES
set(ASM_ASSEMBLER_OBJFORMAT ${CMAKE_ASM_YASM_OBJECT_FORMAT}) MACOSX_BUNDLE_ICON_FILE "Srb2mac"
set_source_files_properties(${SRB2_NASM_SOURCES} LANGUAGE ASM_YASM) MACOSX_BUNDLE_BUNDLE_NAME "SRB2Kart-Saturn"
else() MACOSX_BUNDLE_BUNDLE_VERSION 1.6
set(ASM_ASSEMBLER_TEMP ${CMAKE_ASM_NASM_COMPILER})
set(ASM_ASSEMBLER_OBJFORMAT ${CMAKE_ASM_NASM_OBJECT_FORMAT})
set_source_files_properties(${SRB2_NASM_SOURCES} LANGUAGE ASM_NASM)
endif()
endif()
if(${CMAKE_SYSTEM} MATCHES Windows) RESOURCE "${CMAKE_CURRENT_SOURCE_DIR}/macosx/Srb2mac.icns"
target_link_libraries(SRB2SDL2 PRIVATE
ws2_32
)
target_compile_options(SRB2SDL2 PRIVATE
-U_WINDOWS
)
endif()
target_include_directories(SRB2SDL2 PRIVATE
${SDL2_INCLUDE_DIRS}
${SDL2_MIXER_INCLUDE_DIRS}
${GME_INCLUDE_DIRS}
${OPENMPT_INCLUDE_DIRS}
${PNG_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
${OPENGL_INCLUDE_DIRS}
${CURL_INCLUDE_DIRS}
${DISCORDRPC_INCLUDE_DIRS}
) )
if(${SRB2_HAVE_MIXER})
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MIXER -DSOUND=SOUND_MIXER)
endif()
target_compile_definitions(SRB2SDL2 PRIVATE
-DHAVE_SDL
-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()
#### Installation ####
if(${CMAKE_SYSTEM} MATCHES Darwin)
install(TARGETS SRB2SDL2
BUNDLE DESTINATION .
)
set_property(TARGET SRB2SDL2 PROPERTY INSTALL_RPATH_USE_LINK_PATH ON)
else()
install(TARGETS SRB2SDL2 SRB2SDL2
RUNTIME DESTINATION .
)
endif()
if(${CMAKE_SYSTEM} MATCHES Windows)
set(win_extra_dll_list "")
macro(getwinlib dllname defaultname)
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
if (${CMAKE_GENERATOR} STREQUAL "MinGW Makefiles")
if(${SRB2_SYSTEM_BITS} EQUAL 64)
find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}"
HINTS ${CMAKE_SOURCE_DIR}/libs/dll-binaries/x86_64
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/x86_64-w64-mingw32/bin
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/x86_64-w64-mingw32/bin
HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86_64/mingw
)
else()
find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}"
HINTS ${CMAKE_SOURCE_DIR}/libs/dll-binaries/i686
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/i686-w64-mingw32/bin
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/i686-w64-mingw32/bin
HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86/mingw
)
endif()
else()
if(${SRB2_SYSTEM_BITS} EQUAL 64)
find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}"
HINTS ${CMAKE_SOURCE_DIR}/libs/dll-binaries/x86_64
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/lib/x64
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/lib/x64
HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86_64/mingw
)
else()
find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}"
HINTS ${CMAKE_SOURCE_DIR}/libs/dll-binaries/i686
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/lib/x86
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/lib/x86
HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86/mingw
)
endif()
endif()
list(APPEND win_extra_dll_list ${SRB2_SDL2_DLL_${dllname}})
else()
find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}")
list(APPEND win_extra_dll_list ${SRB2_SDL2_DLL_${dllname}})
endif()
endmacro()
getwinlib(SDL2 "SDL2.dll")
if(${SRB2_CONFIG_SDL2_USEMIXER})
getwinlib(SDL2_mixer "SDL2_mixer.dll")
getwinlib(libogg_0 "libogg-0.dll")
getwinlib(libvorbis_0 "libvorbis-0.dll")
getwinlib(libvorbisfile_3 "libvorbisfile-3.dll")
endif()
if(${SRB2_CONFIG_HAVE_GME})
getwinlib(libgme "libgme.dll")
endif()
if(${SRB2_CONFIG_HAVE_OPENMPT})
getwinlib(libopenmpt "libopenmpt.dll")
endif()
if(${SRB2_CONFIG_HAVE_DISCORDRPC})
getwinlib(discord-rpc "discord-rpc.dll")
endif()
install(PROGRAMS
${win_extra_dll_list}
DESTINATION .
)
# We also want to copy those DLLs to build directories on MSVC.
# So we'll add a post_build step.
copy_files_to_build_dir(SRB2SDL2 win_extra_dll_list)
endif()
# Mac bundle fixup
# HACK: THIS IS IMPORTANT! See the escaped \${CMAKE_INSTALL_PREFIX}? This
# makes it so that var is evaluated LATER during cpack, not right now!
# This fixes the quirk where the bundled libraries don't land in the final package
# https://cmake.org/pipermail/cmake/2011-March/043532.html
#
# HOWEVER: ${CPACK_PACKAGE_DESCRIPTION_SUMMARY} is NOT escaped, because that var
# is only available to us at this step. Read the link: ${CMAKE_INSTALL_PREFIX} at
# this current step points to the CMAKE build folder, NOT the folder that CPACK uses.
# Therefore, it makes sense to escape that var, but not the other.
if(${CMAKE_SYSTEM} MATCHES Darwin)
install(CODE "
include(BundleUtilities)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${CPACK_PACKAGE_DESCRIPTION_SUMMARY}.app\"
\"\"
/Library/Frameworks
)"
)
endif()
set(SRB2_SDL2_AVAILABLE YES PARENT_SCOPE)
else()
message(WARNING "SDL2 was not found, so the SDL2 target will not be available.")
set(SRB2_SDL2_AVAILABLE NO PARENT_SCOPE)
endif() endif()
if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}" AND NOT "${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}")
target_link_libraries(SRB2SDL2 PRIVATE SDL2::SDL2-static SDL2_mixer::SDL2_mixer-static)
else()
target_link_libraries(SRB2SDL2 PRIVATE SDL2::SDL2 SDL2_mixer::SDL2_mixer)
endif()
if("${CMAKE_SYSTEM_NAME}" MATCHES Linux)
target_link_libraries(SRB2SDL2 PRIVATE m rt)
endif()
if("${CMAKE_SYSTEM_NAME}" MATCHES Windows)
target_link_libraries(SRB2SDL2 PRIVATE
ws2_32
)
target_compile_options(SRB2SDL2 PRIVATE
-U_WINDOWS
)
endif()
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MIXER -DSOUND=SOUND_MIXER)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_SDL)
#### Installation ####
if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin)
install(TARGETS SRB2SDL2
BUNDLE DESTINATION .
)
set_property(TARGET SRB2SDL2 PROPERTY INSTALL_RPATH_USE_LINK_PATH ON)
else()
install(TARGETS SRB2SDL2 SRB2SDL2
RUNTIME DESTINATION .
)
if ((${CMAKE_BUILD_TYPE} MATCHES Debug) OR (${CMAKE_BUILD_TYPE} MATCHES RelWithDebInfo))
set(SRB2_DEBUG_INSTALL OFF CACHE BOOL "Insert *.debug file into the install directory or package.")
if (${SRB2_DEBUG_INSTALL})
install(FILES $<TARGET_FILE:SRB2SDL2>.debug
DESTINATION .
OPTIONAL
)
endif()
endif()
endif()
# Mac bundle fixup
# HACK: THIS IS IMPORTANT! See the escaped \${CMAKE_INSTALL_PREFIX}? This
# makes it so that var is evaluated LATER during cpack, not right now!
# This fixes the quirk where the bundled libraries don't land in the final package
# https://cmake.org/pipermail/cmake/2011-March/043532.html
#
# HOWEVER: ${CPACK_PACKAGE_DESCRIPTION_SUMMARY} is NOT escaped, because that var
# is only available to us at this step. Read the link: ${CMAKE_INSTALL_PREFIX} at
# this current step points to the CMAKE build folder, NOT the folder that CPACK uses.
# Therefore, it makes sense to escape that var, but not the other.
if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin)
install(CODE "
include(BundleUtilities)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${CPACK_PACKAGE_DESCRIPTION_SUMMARY}.app\"
\"\"
/Library/Frameworks
)"
)
endif()
set(SRB2_SDL2_AVAILABLE YES PARENT_SCOPE)
+81 -145
View File
@@ -31,10 +31,6 @@
#include <signal.h> #include <signal.h>
#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)
#include <poll.h>
#endif
#ifdef _WIN32 #ifdef _WIN32
#define RPC_NO_WINDOWS_H #define RPC_NO_WINDOWS_H
#include <windows.h> #include <windows.h>
@@ -213,12 +209,14 @@ static char returnWadPath[256];
#include "../byteptr.h" #include "../byteptr.h"
#endif #endif
boolean consolevent = false; SDL_bool consolevent = SDL_FALSE;
boolean framebuffer = false; SDL_bool framebuffer = SDL_FALSE;
UINT8 keyboard_started = false; UINT8 keyboard_started = false;
#ifdef HAVE_TERMIOS #ifdef HAVE_TERMIOS
// TERMIOS console code from Quake3: thank you! // TERMIOS console code from Quake3: thank you!
SDL_bool stdin_active = SDL_TRUE;
typedef struct typedef struct
{ {
size_t cursor; size_t cursor;
@@ -280,7 +278,7 @@ static void I_ShutdownConsole(void)
if (consolevent) if (consolevent)
{ {
I_OutputMsg("Shutdown tty console\n"); I_OutputMsg("Shutdown tty console\n");
consolevent = false; consolevent = SDL_FALSE;
tcsetattr(STDIN_FILENO, TCSADRAIN, &tty_tc); tcsetattr(STDIN_FILENO, TCSADRAIN, &tty_tc);
} }
} }
@@ -299,7 +297,7 @@ static void I_StartupConsole(void)
framebuffer = static_cast<SDL_bool>( M_CheckParm("-framebuffer")); framebuffer = static_cast<SDL_bool>( M_CheckParm("-framebuffer"));
if (framebuffer) if (framebuffer)
consolevent = false; consolevent = SDL_FALSE;
if (!consolevent) if (!consolevent)
return; return;
@@ -307,7 +305,7 @@ static void I_StartupConsole(void)
if (isatty(STDIN_FILENO)!=1) if (isatty(STDIN_FILENO)!=1)
{ {
I_OutputMsg("stdin is not a tty, tty console mode failed\n"); I_OutputMsg("stdin is not a tty, tty console mode failed\n");
consolevent = false; consolevent = SDL_FALSE;
return; return;
} }
@@ -509,7 +507,7 @@ static void I_StartupConsole(void)
if (gotConsole) if (gotConsole)
{ {
SetConsoleTitleA("SRB2Kart Console"); SetConsoleTitleA("SRB2Kart Console");
consolevent = true; consolevent = SDL_TRUE;
} }
//Let get the real console HANDLE, because Mingw's Bash is bad! //Let get the real console HANDLE, because Mingw's Bash is bad!
@@ -542,7 +540,7 @@ static inline void I_StartupConsole(void)
framebuffer = M_CheckParm("-framebuffer"); framebuffer = M_CheckParm("-framebuffer");
if (framebuffer) if (framebuffer)
consolevent = false; consolevent = SDL_FALSE;
} }
static inline void I_ShutdownConsole(void){} static inline void I_ShutdownConsole(void){}
#endif #endif
@@ -726,14 +724,13 @@ 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 JoySet->axises = JoySet->buttons = JoySet->hats = JoySet->balls = 0;
} }
/** \brief SDL info about joystick /** \brief SDL info about joystick
*/ */
SDLJoyInfo_t JoyInfo[MAXSPLITSCREENPLAYERS] = {}; SDLJoyInfo_t JoyInfo[MAXSPLITSCREENPLAYERS];
INT32 numcontrollers = 0; INT32 numcontrollers = 0;
// //
@@ -741,30 +738,30 @@ INT32 numcontrollers = 0;
// //
void I_JoyScale(void) void I_JoyScale(void)
{ {
Joystick[0].bGamepadStyle = cv_joyscale[0].value == 0; Joystick[0].bGamepadStyle = cv_joyscale[0].value==0;
JoyInfo[0].scale = Joystick[0].bGamepadStyle ? 1 : cv_joyscale[0].value; JoyInfo[0].scale = Joystick[0].bGamepadStyle?1:cv_joyscale[0].value;
} }
void I_JoyScale2(void) void I_JoyScale2(void)
{ {
Joystick[1].bGamepadStyle = cv_joyscale[1].value == 0; Joystick[1].bGamepadStyle = cv_joyscale[1].value==0;
JoyInfo[1].scale = Joystick[1].bGamepadStyle ? 1 : cv_joyscale[1].value; JoyInfo[1].scale = Joystick[1].bGamepadStyle?1:cv_joyscale[1].value;
} }
void I_JoyScale3(void) void I_JoyScale3(void)
{ {
Joystick[2].bGamepadStyle = cv_joyscale[2].value == 0; Joystick[2].bGamepadStyle = cv_joyscale[2].value==0;
JoyInfo[2].scale = Joystick[2].bGamepadStyle ? 1 : cv_joyscale[2].value; JoyInfo[2].scale = Joystick[2].bGamepadStyle?1:cv_joyscale[2].value;
} }
void I_JoyScale4(void) void I_JoyScale4(void)
{ {
Joystick[3].bGamepadStyle = cv_joyscale[3].value == 0; Joystick[3].bGamepadStyle = cv_joyscale[3].value==0;
JoyInfo[3].scale = Joystick[3].bGamepadStyle ? 1 : cv_joyscale[3].value; JoyInfo[3].scale = Joystick[3].bGamepadStyle?1:cv_joyscale[3].value;
} }
// Cheat to get the device index for a joystick handle // Cheat to get the device index for a joystick handle
static INT32 I_GetJoystickDeviceIndex(SDL_GameController *dev) INT32 I_GetJoystickDeviceIndex(SDL_GameController *dev)
{ {
SDL_Joystick *joystick = NULL; SDL_Joystick *joystick = NULL;
@@ -785,11 +782,7 @@ 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
{ {
@@ -891,13 +884,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("Joystick subsystem not started\n"); CONS_Printf(M_GetText("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("Game Controller subsystem not started\n"); CONS_Printf(M_GetText("Game Controller subsystem not started\n"));
return -1; return -1;
} }
@@ -908,7 +901,7 @@ static int joy_open(int playerIndex, int joyIndex)
if (num_joy == 0) 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; return -1;
} }
@@ -931,25 +924,38 @@ 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, "Joystick %d device is changing; resetting events...\n", playerIndex+1); CONS_Debug(DBG_GAMELOGIC, "Joystick1 device is changing; resetting events...\n");
I_ShutdownJoystick(playerIndex); I_ShutdownJoystick(playerIndex);
} }
JoyInfo[playerIndex].dev = newdev; JoyInfo[playerIndex].dev = newdev;
JoyInfo[playerIndex].id = I_GetJoystickDeviceIndex(JoyInfo[playerIndex].dev);
if (JoyInfo[playerIndex].dev == NULL) 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; return -1;
} }
else
{
CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: %s\n"), SDL_GameControllerName(JoyInfo[playerIndex].dev));
JoyInfo[playerIndex].axises = SDL_CONTROLLER_AXIS_MAX;
CONS_Debug(DBG_GAMELOGIC, "Joystick %d: %s\n", playerIndex+1, SDL_GameControllerName(JoyInfo[playerIndex].dev)); if (JoyInfo[playerIndex].axises > JOYAXISSET*2)
JoyInfo[playerIndex].axises = JOYAXISSET*2;
#if (SDL_VERSION_ATLEAST(2,32,4)) JoyInfo[playerIndex].buttons = SDL_CONTROLLER_BUTTON_MAX ; // dpad is 4 buttons
JoyInfo[playerIndex].id = I_GetJoystickDeviceIndex(JoyInfo[playerIndex].dev); if (JoyInfo[playerIndex].buttons > JOYBUTTONS)
#endif JoyInfo[playerIndex].buttons = JOYBUTTONS;
return SDL_CONTROLLER_AXIS_MAX; JoyInfo[playerIndex].hats = 4;
if (JoyInfo[playerIndex].hats > JOYHATS)
JoyInfo[playerIndex].hats = JOYHATS;
JoyInfo[playerIndex].balls = 0;
return JoyInfo[playerIndex].axises;
}
} }
// //
@@ -993,9 +999,8 @@ 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 JoyInfo[index].axises = JoyInfo[index].buttons = JoyInfo[index].hats = JoyInfo[index].balls = 0;
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);
@@ -1009,27 +1014,17 @@ 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 = I_GetJoystickDeviceIndex(JoyInfo[index].dev) + 1; JoyInfo[index].oldjoy = JoyInfo[index].id + 1;
#endif
} }
else else
{ {
@@ -1389,7 +1384,7 @@ void I_SleepDuration(precise_t duration)
#endif #endif
} }
static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_msg, char *signal_ttl); static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_msg);
#ifdef HAVE_LIBBACKTRACE #ifdef HAVE_LIBBACKTRACE
#include <backtrace.h> #include <backtrace.h>
@@ -1485,7 +1480,6 @@ static void bt_error_cb(void *data, const char *msg, int errnum)
static void write_backtrace(bt_crash_reason_t reason) static void write_backtrace(bt_crash_reason_t reason)
{ {
char sig_msg[512]; char sig_msg[512];
char sig_name[128];
const char *filename = va("%s" PATHSEP CRASH_LOGFILE_NAME, srb2home); const char *filename = va("%s" PATHSEP CRASH_LOGFILE_NAME, srb2home);
FILE *out = fopen(filename, "a+"); FILE *out = fopen(filename, "a+");
@@ -1542,8 +1536,8 @@ static void write_backtrace(bt_crash_reason_t reason)
switch (reason.type) switch (reason.type)
{ {
case BTCRASH_SIGNAL: case BTCRASH_SIGNAL:
I_PrintSignal(reason.value.signal, false, sig_msg, sig_name); I_PrintSignal(reason.value.signal, false, sig_msg);
fprintf(out, "%s - %s", sig_name, sig_msg); fprintf(out, "%s", sig_msg);
break; break;
case BTCRASH_ERRORMSG: case BTCRASH_ERRORMSG:
@@ -1579,49 +1573,42 @@ static std::thread::id g_main_thread_id;
boolean g_in_exiting_signal_handler = false; boolean g_in_exiting_signal_handler = false;
static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_msg, char *signal_name) static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_msg)
{ {
const char *sigmsg, *signame; const char *sigmsg;
switch (signal_num) switch (signal_num)
{ {
#ifdef SIGINT #ifdef SIGINT
case SIGINT: case SIGINT:
sigmsg = ("SRB2Kart-Saturn was interrupted prematurely by the user."); sigmsg = ("SIGINT - SRB2Kart-Saturn was interrupted prematurely by the user.");
signame = "SIGINT";
break; break;
#endif #endif
case SIGILL: // illegal instruction - invalid function image case SIGILL: // illegal instruction - invalid function image
sigmsg = ("SRB2Kart-Saturn has attempted to execute an illegal instruction and needs to close."); sigmsg = ("SIGILL - SRB2Kart-Saturn has attempted to execute an illegal instruction and needs to close.");
signame = "SIGILL";
break; break;
case SIGFPE: // mathematical exception case SIGFPE: // mathematical exception
sigmsg = ("SRB2Kart-Saturn has encountered a mathematical exception and needs to close."); sigmsg = ("SIGFPE - SRB2Kart-Saturn has encountered a mathematical exception and needs to close.");
signame = "SIGFPE";
break; break;
case SIGSEGV: // segment violation case SIGSEGV: // segment violation
sigmsg = ("SRB2Kart-Saturn has attempted to access a memory location that it shouldn't and needs to close."); sigmsg = ("SIGSEGV - SRB2Kart-Saturn has attempted to access a memory location that it shouldn't and needs to close.");
signame = "SIGSEGV";
break; break;
#ifdef SIGTERM #ifdef SIGTERM
case SIGTERM: // Software termination signal from kill case SIGTERM: // Software termination signal from kill
sigmsg = ("SRB2Kart-Saturn was terminated by a kill signal."); sigmsg = ("SIGTERM - SRB2Kart-Saturn was terminated by a kill signal.");
signame = "SIGTERM";
break; break;
#endif #endif
#ifdef SIGBREAK #ifdef SIGBREAK
case SIGBREAK: // Ctrl-Break sequence case SIGBREAK: // Ctrl-Break sequence
sigmsg =("SIGBREAK - SRB2Kart-Saturn was terminated by a Ctrl-Break sequence."); sigmsg =("SIGBREAK - SRB2Kart-Saturn was terminated by a Ctrl-Break sequence.");
signame = "SIGBREAK";
break; break;
#endif #endif
case SIGABRT: // abnormal termination triggered by abort call case SIGABRT: // abnormal termination triggered by abort call
sigmsg = ("SRB2Kart-Saturn was terminated by an abort signal."); sigmsg = ("SIGABRT - SRB2Kart-Saturn was terminated by an abort signal.");
signame = "SIGABRT";
break; break;
default: default:
sigmsg = "SRB2Kart-Saturn was terminated by an unknown signal."; sprintf(signal_msg, "Signal number %d", signal_num);
signame = core_dumped ? "Unknown signal" : va("Signal number %d", signal_num); sigmsg = (core_dumped ? "Unknown signal" : signal_msg);
break; break;
} }
@@ -1636,80 +1623,18 @@ static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_ms
{ {
sprintf(signal_msg, "%s", sigmsg); sprintf(signal_msg, "%s", sigmsg);
} }
sprintf(signal_name, "%s", signame);
}
static int I_OpenURL(const char *url)
{
#if SDL_VERSION_ATLEAST(2,0,14)
return SDL_OpenURL(va("%s", url));
#else
return -1;
#endif
}
static void I_ShowErrorBox(const char *title, const char *msg)
{
if (M_CheckParm("-dedicated"))
return;
const char *reportmsg = "\n\n\nTo help us figure out the cause, please report the issue to our github page with " CRASH_LOGFILE_NAME " attached.\n\nSorry for the inconvenience!";
const SDL_MessageBoxButtonData buttons[] = {
{ SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 0, "OK" },
{ 0, 1, "Report Issue" },
};
const SDL_MessageBoxData messageboxdata = {
SDL_MESSAGEBOX_ERROR, /* .flags */
NULL, /* .window */
title, /* .title */
va("%s %s", msg, reportmsg), /* .message */
SDL_arraysize(buttons), /* .numbuttons */
buttons, /* .buttons */
NULL /* .colorScheme */
};
int buttonid;
SDL_ShowMessageBox(&messageboxdata, &buttonid);
if (buttonid == 1)
I_OpenURL("https://github.com/Indev450/SRB2Kart-Saturn/issues");
}
static void I_ShowSimpleErrorBox(const char *title, char *msg)
{
if (M_CheckParm("-dedicated"))
return;
// Implement message box with SDL_ShowSimpleMessageBox,
// which should fail gracefully if it can't put a message box up
// on the target system
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title, msg, NULL);
// Note that SDL_ShowSimpleMessageBox does *not* require SDL to be
// initialized at the time, so calling it after SDL_Quit() is
// perfectly okay! In addition, we do this on purpose so the
// fullscreen window is closed before displaying the error message
// in case the fullscreen window blocks it for some absurd reason.
} }
static void I_ReportSignal(int num, int coredumped) static void I_ReportSignal(int num, int coredumped)
{ {
char sigmsg[512]; char sigmsg[512];
char signame[128];
char sigttl[512] = "Process killed by signal: ";
I_PrintSignal(num, coredumped, sigmsg, signame); I_PrintSignal(num, coredumped, sigmsg);
size_t len = strlen(sigmsg); size_t len = strlen(sigmsg);
snprintf(sigmsg + len, sizeof(sigmsg) - len, "\n\nCrash report has been saved into %s", CRASH_LOGFILE_NAME); snprintf(sigmsg + len, sizeof(sigmsg) - len, "\n\nCrash report has been saved into %s", CRASH_LOGFILE_NAME);
I_OutputMsg("\nProcess killed by signal: %s\n\n", sigmsg);
strcat(sigttl, signame); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Process killed by signal", sigmsg, NULL);
I_OutputMsg("\n%s\n\n", sigttl);
//I_ShowSimpleErrorBox(sigttl, sigmsg);
I_ShowErrorBox(sigttl, sigmsg);
} }
#ifndef NEWSIGNALHANDLER #ifndef NEWSIGNALHANDLER
@@ -1817,7 +1742,10 @@ FUNCNORETURN static ATTRNORETURN void newsignalhandler_Warn(const char *pr)
); );
I_OutputMsg("%s\n", text); I_OutputMsg("%s\n", text);
I_ShowSimpleErrorBox("Startup error", text);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
"Startup error",
text, NULL);
I_ShutdownConsole(); I_ShutdownConsole();
exit(-1); exit(-1);
@@ -1979,7 +1907,6 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...)
{ {
va_list argptr; va_list argptr;
char buffer[8192]; char buffer[8192];
const char *sigttl = "";
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
if (std::this_thread::get_id() != g_main_thread_id) if (std::this_thread::get_id() != g_main_thread_id)
@@ -2016,9 +1943,12 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...)
va_start(argptr, error); va_start(argptr, error);
vsnprintf(buffer, 8192, error, argptr); vsnprintf(buffer, 8192, error, argptr);
va_end(argptr); va_end(argptr);
// Implement message box with SDL_ShowSimpleMessageBox,
sigttl = "SRB2Kart " VERSIONSTRING " Recursive Error"; // which should fail gracefully if it can't put a message box up
I_ShowSimpleErrorBox(sigttl, buffer); // on the target system
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
"SRB2Kart " VERSIONSTRING " Recursive Error",
buffer, NULL);
W_Shutdown(); W_Shutdown();
exit(-1); // recursive errors detected exit(-1); // recursive errors detected
@@ -2058,9 +1988,15 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...)
I_ShutdownSystem(); I_ShutdownSystem();
SDL_Quit(); SDL_Quit();
sigttl = "SRB2Kart " VERSIONSTRING " Error"; // Implement message box with SDL_ShowSimpleMessageBox,
//I_ShowSimpleErrorBox(sigttl, buffer); // which should fail gracefully if it can't put a message box up
I_ShowErrorBox(sigttl, buffer); // on the target system
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "SRB2Kart " VERSIONSTRING " Error", buffer, NULL);
// Note that SDL_ShowSimpleMessageBox does *not* require SDL to be
// initialized at the time, so calling it after SDL_Quit() is
// perfectly okay! In addition, we do this on purpose so the
// fullscreen window is closed before displaying the error message
// in case the fullscreen window blocks it for some absurd reason.
W_Shutdown(); W_Shutdown();
@@ -2486,7 +2422,7 @@ static const char *locateWad(void)
return NULL; return NULL;
} }
extern "C" const char *I_LocateWad(void) const char *I_LocateWad(void)
{ {
const char *waddir = NULL; const char *waddir = NULL;
+11 -26
View File
@@ -155,12 +155,9 @@ static SDL_bool usesdl2soft = SDL_FALSE;
static SDL_bool borderlesswindow = SDL_FALSE; static SDL_bool borderlesswindow = SDL_FALSE;
// SDL2 vars // SDL2 vars
static SDL_Window *window = NULL; SDL_Window *window = NULL;
static SDL_Renderer *renderer = NULL; SDL_Renderer *renderer = NULL;
static SDL_Texture *texture = NULL; static SDL_Texture *texture = NULL;
#ifdef HWRENDER
static SDL_GLContext sdlglcontext = NULL;
#endif
static SDL_bool havefocus = SDL_TRUE; static SDL_bool havefocus = SDL_TRUE;
static const char *fallback_resolution_name = "Fallback"; static const char *fallback_resolution_name = "Fallback";
@@ -467,7 +464,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
} }
else else
{ {
raxis = JoyInfo[pid].scale != 1 ? ((raxis/JoyInfo[pid].scale)*JoyInfo[pid].scale) : raxis; raxis = JoyInfo[pid].scale!=1?((raxis/JoyInfo[pid].scale)*JoyInfo[pid].scale):raxis;
#ifdef SDL_JDEADZONE #ifdef SDL_JDEADZONE
if (-SDL_JDEADZONE <= raxis && raxis <= SDL_JDEADZONE) if (-SDL_JDEADZONE <= raxis && raxis <= SDL_JDEADZONE)
@@ -784,11 +781,7 @@ 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;
@@ -848,11 +841,7 @@ 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;
@@ -914,11 +903,7 @@ 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;
@@ -1441,7 +1426,7 @@ void I_FinishUpdate(void)
#ifdef HWRENDER #ifdef HWRENDER
if (rendermode == render_opengl) if (rendermode == render_opengl)
{ {
OglSdlFinishUpdate(window); OglSdlFinishUpdate(cv_vidwait.value);
return; return;
} }
#endif #endif
@@ -2043,17 +2028,17 @@ UINT32 I_GetRefreshRate(void)
static void Impl_SetVsync(void) static void Impl_SetVsync(void)
{ {
#ifdef HWRENDER
if (rendermode == render_opengl &&
sdlglcontext != NULL && SDL_GL_GetCurrentContext() == sdlglcontext)
{
SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0);
}
#endif
#if SDL_VERSION_ATLEAST(2,0,18) #if SDL_VERSION_ATLEAST(2,0,18)
if (renderer) if (renderer)
SDL_RenderSetVSync(renderer, cv_vidwait.value); SDL_RenderSetVSync(renderer, cv_vidwait.value);
#endif #endif
#ifdef HWRENDER
if (!renderer && rendermode == render_opengl &&
sdlglcontext != NULL && SDL_GL_GetCurrentContext() == sdlglcontext)
{
SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0);
}
#endif
} }
void I_SetBorderlessWindow(void) void I_SetBorderlessWindow(void)
+4 -1
View File
@@ -4,8 +4,11 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
void OSX_GetResourcesPath(char * buffer); void OSX_GetResourcesPath(char * buffer);
#ifdef __cplusplus #ifdef __cplusplus
} } // extern "C"
#endif #endif
#endif #endif
+3 -3
View File
@@ -461,7 +461,7 @@ void *I_GetSfx(sfxinfo_t *sfx)
gme_track_info(emu, &info, 0); gme_track_info(emu, &info, 0);
len = (info->play_length * 441 / 10) << 2; len = (info->play_length * 441 / 10) << 2;
mem = Z_Malloc(len, PU_SOUND, NULL); mem = Z_Malloc(len, PU_SOUND, 0);
gme_play(emu, len >> 1, mem); gme_play(emu, len >> 1, mem);
gme_free_info(info); gme_free_info(info);
@@ -499,7 +499,7 @@ void *I_GetSfx(sfxinfo_t *sfx)
gme_track_info(emu, &info, 0); gme_track_info(emu, &info, 0);
len = (info->play_length * 441 / 10) << 2; len = (info->play_length * 441 / 10) << 2;
mem = Z_Malloc(len, PU_SOUND, NULL); mem = Z_Malloc(len, PU_SOUND, 0);
gme_play(emu, len >> 1, mem); gme_play(emu, len >> 1, mem);
gme_free_info(info); gme_free_info(info);
@@ -1107,7 +1107,7 @@ UINT32 I_GetSongPosition(void)
void I_UpdateSongLagThreshold(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));
} }
/// ------------------------ /// ------------------------
+38 -2
View File
@@ -63,15 +63,25 @@ PFNglGetString pglGetString;
#endif #endif
#ifdef USE_FBO_OGL #ifdef USE_FBO_OGL
#if defined (__unix__)
static boolean xwaylandcrap = false;
#endif
boolean UseScreenFBO(void) boolean UseScreenFBO(void)
{ {
return (supportFBO && cv_glframebuffer.value && downsample); return ((supportFBO && cv_glframebuffer.value && downsample)
#if defined (__unix__)
|| (supportFBO && xwaylandcrap)
#endif
);
} }
#endif #endif
/** \brief SDL video display surface /** \brief SDL video display surface
*/ */
INT32 oglflags = 0; INT32 oglflags = 0;
SDL_GLContext sdlglcontext = NULL;
void *GetGLFunc(const char *proc) void *GetGLFunc(const char *proc)
{ {
@@ -191,6 +201,17 @@ boolean OglSdlSurface(INT32 w, INT32 h)
supportNPO2tex = true; supportNPO2tex = true;
glanisotropicmode_cons_t[1].value = maximumAnisotropy; glanisotropicmode_cons_t[1].value = maximumAnisotropy;
#if defined (__unix__)
#ifdef USE_FBO_OGL
// TODO: delet this since nvidia fixed their shit on 575
char videodriver[4] = {'S','D','L',0};
if (supportFBO && strstr((const char*)gl_renderer, "NVIDIA")
&& (*strncpy(videodriver, SDL_GetCurrentVideoDriver(), sizeof(videodriver)-1) != '\0')
&& (strncasecmp("x11", videodriver, 4) == 0))
xwaylandcrap = true;
#endif
#endif
} }
SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0); SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0);
@@ -220,14 +241,22 @@ boolean OglSdlSurface(INT32 w, INT32 h)
\return void \return void
*/ */
void OglSdlFinishUpdate(SDL_Window *window) void OglSdlFinishUpdate(boolean waitvbl)
{ {
static boolean oldwaitvbl = false;
int sdlw, sdlh; int sdlw, sdlh;
#ifdef USE_FBO_OGL #ifdef USE_FBO_OGL
const boolean usefbo = UseScreenFBO(); const boolean usefbo = UseScreenFBO();
#endif #endif
if (oldwaitvbl != waitvbl)
{
SDL_GL_SetSwapInterval(waitvbl ? 1 : 0);
}
oldwaitvbl = waitvbl;
SDL_GetWindowSize(window, &sdlw, &sdlh); SDL_GetWindowSize(window, &sdlw, &sdlh);
HWR_MakeScreenFinalTexture(); HWR_MakeScreenFinalTexture();
@@ -260,6 +289,13 @@ void OglSdlFinishUpdate(SDL_Window *window)
if (!I_CheckNativeRes() || WipeInAction) if (!I_CheckNativeRes() || WipeInAction)
#endif #endif
HWR_DrawScreenFinalTexture(realwidth, realheight, false); HWR_DrawScreenFinalTexture(realwidth, realheight, false);
#if defined (__unix__)
#ifdef USE_FBO_OGL
if (loaded_config)
xwaylandcrap = false;
#endif
#endif
} }
#endif //HWRENDER #endif //HWRENDER
+3 -1
View File
@@ -20,9 +20,11 @@
boolean OglSdlSurface(INT32 w, INT32 h); boolean OglSdlSurface(INT32 w, INT32 h);
void OglSdlFinishUpdate(SDL_Window *window); void OglSdlFinishUpdate(boolean vidwait);
boolean VID_LoadOGLAPI(void); boolean VID_LoadOGLAPI(void);
extern SDL_Renderer *renderer;
extern SDL_GLContext sdlglcontext;
extern Uint16 realwidth; extern Uint16 realwidth;
extern Uint16 realheight; extern Uint16 realheight;
+21 -7
View File
@@ -23,7 +23,8 @@
extern "C" { extern "C" {
#endif #endif
#include "SDL_version.h" extern SDL_bool consolevent;
extern SDL_bool framebuffer;
#include "../m_fixed.h" #include "../m_fixed.h"
@@ -41,22 +42,20 @@ 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
//int axises; int axises;
/// scale of axises /// scale of axises
INT32 scale; INT32 scale;
/// number of buttons /// number of buttons
//int buttons; int buttons;
/// number of hats /// number of hats
//int hats; int hats;
/// number of balls /// number of balls
//int balls; int balls;
} SDLJoyInfo_t; } SDLJoyInfo_t;
/** \brief SDL info about controller 1 /** \brief SDL info about controller 1
@@ -68,6 +67,21 @@ extern SDLJoyInfo_t JoyInfo[4]; //MAXSPLITSCREENPLAYERS
#define SDL_JDEADZONE 153 #define SDL_JDEADZONE 153
#undef SDL_JDEADZONE #undef SDL_JDEADZONE
// So we can call this from i_video event loop
void I_ShutdownJoystick(UINT8 index);
// Cheat to get the device index for a game controller handle
INT32 I_GetJoystickDeviceIndex(SDL_GameController *dev);
// Quick thing to make SDL_JOYDEVICEADDED events less of an abomination
void I_UpdateJoystickDeviceIndex(UINT8 player);
void I_UpdateJoystickDeviceIndices(UINT8 excludePlayer);
void I_GetConsoleEvents(void);
// Needed for some WIN32 functions
extern SDL_Window *window;
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
#endif #endif
+1 -1
View File
@@ -720,7 +720,7 @@ void ST_DrawDemoTitleEntry(void)
static void ST_MayonakaStatic(void) static void ST_MayonakaStatic(void)
{ {
INT32 flag; INT32 flag;
if (cv_lessflicker.value || cv_reducevfx.value) if (cv_lessflicker.value)
flag = V_70TRANS; flag = V_70TRANS;
else else
flag = (leveltime%2) ? V_90TRANS : V_70TRANS; flag = (leveltime%2) ? V_90TRANS : V_70TRANS;
+4 -8
View File
@@ -23,10 +23,6 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <string.h>
#include <ctype.h>
#include <stddef.h>
static inline int static inline int
trycmp (char **pp, char *cp, trycmp (char **pp, char *cp,
const char *q, size_t qn) const char *q, size_t qn)
@@ -77,8 +73,8 @@ nongnu_strcasestr (const char *s, const char *q)
up = strchr(s, uc); up = strchr(s, uc);
lp = strchr(s, lc); lp = strchr(s, lc);
if (up == NULL && lp == NULL) if (!( (intptr_t)up|(intptr_t)lp ))
return NULL; return 0;
if (!lp || ( up && up < lp )) if (!lp || ( up && up < lp ))
{ {
@@ -104,12 +100,12 @@ nongnu_strcasestr (const char *s, const char *q)
if (trycmp(ppa, cpa, q, qn) == 0) if (trycmp(ppa, cpa, q, qn) == 0)
return (*ppa); return (*ppa);
if (up == NULL && lp == NULL) if (!( (intptr_t)up|(intptr_t)lp ))
break; break;
if (!(*ppa) || ( (*ppb) && (*ppb) < (*ppa) )) if (!(*ppa) || ( (*ppb) && (*ppb) < (*ppa) ))
swapp(&ppa, &ppb, &cpa, &cpb); swapp(&ppa, &ppb, &cpa, &cpb);
} }
return NULL; return 0;
} }
+108 -124
View File
@@ -15,7 +15,6 @@
#include "doomdef.h" #include "doomdef.h"
#include "d_main.h" #include "d_main.h"
#include "g_game.h"
#include "r_local.h" #include "r_local.h"
#include "p_local.h" #include "p_local.h"
#include "v_video.h" #include "v_video.h"
@@ -465,7 +464,7 @@ void V_CubeApply(RGBA_t *input)
if (!Cubeapply) if (!Cubeapply)
return; return;
linear = ((*input).s.red/255.0f); linear = ((*input).s.red/255.0);
#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 +474,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.0f); linear = ((*input).s.green/255.0);
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.0f); linear = ((*input).s.blue/255.0);
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.0f; working[0][q] = 0.0;
} }
#undef dolerp #undef dolerp
@@ -1742,7 +1741,6 @@ void V_DrawHorizontallyScaledFullScreenPatch(patch_t *patch)
void V_DrawVhsEffect(boolean rewind) void V_DrawVhsEffect(boolean rewind)
{ {
fixed_t uby, dby; fixed_t uby, dby;
// upbary is the bar going from top to bottom for some reason
static fixed_t upbary = 100*FRACUNIT, downbary = 150*FRACUNIT; static fixed_t upbary = 100*FRACUNIT, downbary = 150*FRACUNIT;
UINT8 barsize, updistort, downdistort; UINT8 barsize, updistort, downdistort;
@@ -1757,27 +1755,20 @@ void V_DrawVhsEffect(boolean rewind)
#endif #endif
SINT8 offs; SINT8 offs;
if (cv_reducevfx.value) barsize = vid.dup << 5;
return; updistort = vid.dup << (rewind ? 5 : 3);
barsize = vid.udup << 5;
updistort = vid.udup << (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)(vid.udup * (rewind ? 3 : 1.8f)); upbary -= renderdeltatics * (vid.dup * (rewind ? 3 : 1.8f));
downbary += renderdeltatics * (vid.udup * (rewind ? 2 : 1)); downbary += renderdeltatics * (vid.dup * (rewind ? 2 : 1));
if (upbary < -barsize*FRACUNIT) if (upbary < -barsize*FRACUNIT)
upbary = vid.height << FRACBITS; upbary = vid.height << FRACBITS;
if (upbary > vid.height << FRACBITS)
upbary = -barsize*FRACUNIT;
if (downbary > vid.height << FRACBITS) if (downbary > vid.height << FRACBITS)
downbary = -barsize*FRACUNIT; downbary = -barsize*FRACUNIT;
if (downbary < -barsize*FRACUNIT)
downbary = vid.height << FRACBITS;
uby = upbary >> FRACBITS; uby = upbary >> FRACBITS;
dby = downbary >> FRACBITS; dby = downbary >> FRACBITS;
@@ -3648,130 +3639,127 @@ void V_DoPostProcessor(INT32 view, INT32 param)
UINT8 *tmpscr = vid.screens[4]; UINT8 *tmpscr = vid.screens[4];
UINT8 *srcscr = vid.screens[0]; UINT8 *srcscr = vid.screens[0];
if (!cv_reducevfx.value) if (thiscam->postimg & POSTIMG_WATER)
{ {
if (thiscam->postimg & POSTIMG_WATER) INT32 y;
// Set disStart to a range from 0 to FINEANGLE, incrementing by 128 per tic
angle_t disStart = (((leveltime-1)*128) + (R_GetTimeFrac(RTF_LEVEL) / (FRACUNIT/128))) & FINEMASK;
INT32 newpix;
INT32 sine;
//UINT8 *transme = transtables + ((tr_trans50-1)<<FF_TRANSSHIFT);
for (y = yoffset; y < yoffset+viewheight; y++)
{ {
INT32 y; sine = (FINESINE(disStart)*5)>>FRACBITS;
// Set disStart to a range from 0 to FINEANGLE, incrementing by 128 per tic newpix = abs(sine);
angle_t disStart = (((leveltime-1)*128) + (R_GetTimeFrac(RTF_LEVEL) / (FRACUNIT/128))) & FINEMASK;
INT32 newpix;
INT32 sine;
//UINT8 *transme = transtables + ((tr_trans50-1)<<FF_TRANSSHIFT);
for (y = yoffset; y < yoffset+viewheight; y++) if (sine < 0)
{ {
sine = (FINESINE(disStart)*5)>>FRACBITS; memcpy(&tmpscr[(y*vid.width)+xoffset+newpix], &srcscr[(y*vid.width)+xoffset], viewwidth-newpix);
newpix = abs(sine);
if (sine < 0) // Cleanup edge
while (newpix)
{ {
memcpy(&tmpscr[(y*vid.width)+xoffset+newpix], &srcscr[(y*vid.width)+xoffset], viewwidth-newpix); tmpscr[(y*vid.width)+xoffset+newpix] = srcscr[(y*vid.width)+xoffset];
newpix--;
// Cleanup edge
while (newpix)
{
tmpscr[(y*vid.width)+xoffset+newpix] = srcscr[(y*vid.width)+xoffset];
newpix--;
}
} }
else }
{ else
memcpy(&tmpscr[(y*vid.width)+xoffset+0], &srcscr[(y*vid.width)+xoffset+sine], viewwidth-newpix); {
memcpy(&tmpscr[(y*vid.width)+xoffset+0], &srcscr[(y*vid.width)+xoffset+sine], viewwidth-newpix);
// Cleanup edge // Cleanup edge
while (newpix) while (newpix)
{ {
tmpscr[(y*vid.width)+xoffset+viewwidth-newpix] = srcscr[(y*vid.width)+xoffset+(viewwidth-1)]; tmpscr[(y*vid.width)+xoffset+viewwidth-newpix] = srcscr[(y*vid.width)+xoffset+(viewwidth-1)];
newpix--; newpix--;
}
} }
/*
Unoptimized version
for (x = 0; x < vid.width; x++)
{
newpix = (x + sine);
if (newpix < 0)
newpix = 0;
else if (newpix >= vid.width)
newpix = vid.width-1;
tmpscr[y*vid.width + x] = srcscr[y*vid.width+newpix]; // *(transme + (srcscr[y*vid.width+x]<<8) + srcscr[y*vid.width+newpix]);
}*/
disStart += 22;//the offset into the displacement map, increment each game loop
disStart &= FINEMASK; //clip it to FINEMASK
} }
UINT8 *tmp = tmpscr; /*
tmpscr = srcscr; Unoptimized version
srcscr = tmp; for (x = 0; x < vid.width; x++)
{
newpix = (x + sine);
if (newpix < 0)
newpix = 0;
else if (newpix >= vid.width)
newpix = vid.width-1;
tmpscr[y*vid.width + x] = srcscr[y*vid.width+newpix]; // *(transme + (srcscr[y*vid.width+x]<<8) + srcscr[y*vid.width+newpix]);
}*/
disStart += 22;//the offset into the displacement map, increment each game loop
disStart &= FINEMASK; //clip it to FINEMASK
} }
else if (thiscam->postimg & POSTIMG_HEAT) // Heat wave
UINT8 *tmp = tmpscr;
tmpscr = srcscr;
srcscr = tmp;
}
else if (thiscam->postimg & POSTIMG_HEAT) // Heat wave
{
INT32 y;
// Make sure table is built
if (heatshifter == NULL || lastheight != viewheight)
{ {
INT32 y; if (heatshifter)
Z_Free(heatshifter);
// Make sure table is built heatshifter = Z_Calloc(viewheight * sizeof(boolean), PU_STATIC, NULL);
if (heatshifter == NULL || lastheight != viewheight)
for (y = 0; y < viewheight; y++)
{ {
if (heatshifter) if (M_RandomChance(FRACUNIT/8)) // 12.5%
Z_Free(heatshifter); heatshifter[y] = true;
heatshifter = Z_Calloc(viewheight * sizeof(boolean), PU_STATIC, NULL);
for (y = 0; y < viewheight; y++)
{
if (M_RandomChance(FRACUNIT/8)) // 12.5%
heatshifter[y] = true;
}
heatindex[0] = heatindex[1] = heatindex[2] = heatindex[3] = 0;
lastheight = viewheight;
} }
for (y = yoffset; y < yoffset+viewheight; y++) heatindex[0] = heatindex[1] = heatindex[2] = heatindex[3] = 0;
{ lastheight = viewheight;
if (heatshifter[heatindex[view]++])
{
// Shift this row of pixels to the right by 2
tmpscr[(y*vid.width)+xoffset] = srcscr[(y*vid.width)+xoffset];
memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset+vid.dup], viewwidth-vid.dup);
}
else
memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth);
heatindex[view] %= viewheight;
}
if (renderisnewtic) // This isn't interpolated... but how do you interpolate a one-pixel shift?
{
heatindex[view]++;
heatindex[view] %= vid.height;
}
UINT8 *tmp = tmpscr;
tmpscr = srcscr;
srcscr = tmp;
} }
for (y = yoffset; y < yoffset+viewheight; y++)
{
if (heatshifter[heatindex[view]++])
{
// Shift this row of pixels to the right by 2
tmpscr[(y*vid.width)+xoffset] = srcscr[(y*vid.width)+xoffset];
memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset+vid.dup], viewwidth-vid.dup);
}
else
memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth);
heatindex[view] %= viewheight;
}
if (renderisnewtic) // This isn't interpolated... but how do you interpolate a one-pixel shift?
{
heatindex[view]++;
heatindex[view] %= vid.height;
}
UINT8 *tmp = tmpscr;
tmpscr = srcscr;
srcscr = tmp;
}
#ifdef MOTIONBLUR #ifdef MOTIONBLUR
if (thiscam->postimg & POSTIMG_MOTION) // Motion Blur! if (thiscam->postimg & POSTIMG_MOTION) // Motion Blur!
{
INT32 x, y;
// TODO: Add a postimg_param so that we can pick the translucency level...
UINT8 *transme = transtables + ((param-1)<<FF_TRANSSHIFT);
for (y = yoffset; y < yoffset+viewheight; y++)
{ {
INT32 x, y; for (x = xoffset; x < xoffset+viewwidth; x++)
tmpscr[y*vid.width + x] = colormaps[*(transme + (srcscr [(y*vid.width)+x ] <<8) + (tmpscr[(y*vid.width)+x]))];
// TODO: Add a postimg_param so that we can pick the translucency level...
UINT8 *transme = transtables + ((param-1)<<FF_TRANSSHIFT);
for (y = yoffset; y < yoffset+viewheight; y++)
{
for (x = xoffset; x < xoffset+viewwidth; x++)
tmpscr[y*vid.width + x] = colormaps[*(transme + (srcscr [(y*vid.width)+x ] <<8) + (tmpscr[(y*vid.width)+x]))];
}
} }
#endif
} }
#endif
if ((thiscam->postimg & POSTIMG_FLIP) && !(thiscam->postimg & POSTIMG_MIRROR)) // Flip the screen upside-down if ((thiscam->postimg & POSTIMG_FLIP) && !(thiscam->postimg & POSTIMG_MIRROR)) // Flip the screen upside-down
{ {
@@ -3826,7 +3814,7 @@ void InitColorLUT(colorlookup_t *lut, RGBA_t *palette, boolean makecolors)
lut->init = true; lut->init = true;
memcpy(lut->palette, palette, palsize); memcpy(lut->palette, palette, palsize);
for (i = 0; i < 0x10000; i++) for (i = 0; i < 0xFFFF; i++)
lut->table[i] = 0xFFFF; lut->table[i] = 0xFFFF;
if (makecolors) if (makecolors)
@@ -3839,9 +3827,7 @@ void InitColorLUT(colorlookup_t *lut, RGBA_t *palette, boolean makecolors)
{ {
for (b = 0; b < 0xFF; b++) for (b = 0; b < 0xFF; b++)
{ {
i = CLUTINDEX(r, g, b); lut->table[i] = GetColorLUT(lut, r, g, b);
if (lut->table[i] == 0xFFFF)
lut->table[i] = NearestPaletteColor(r, g, b, palette);
} }
} }
} }
@@ -3928,8 +3914,6 @@ 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
{ {
+10 -29
View File
@@ -697,12 +697,12 @@ static lumpinfo_t* ResGetLumpsZip(FILE* handle, UINT16* nlmp)
strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1);
// Strip away file address and extension for the 8char name. // Strip away file address and extension for the 8char name.
if ((trimname = strrchr(fullname, '/')) != NULL) if ((trimname = strrchr(fullname, '/')) != 0)
trimname++; trimname++;
else else
trimname = fullname; // Care taken for root files. trimname = fullname; // Care taken for root files.
if ((dotpos = strrchr(trimname, '.')) == NULL) if ((dotpos = strrchr(trimname, '.')) == 0)
dotpos = fullname + strlen(fullname); // Watch for files without extension. dotpos = fullname + strlen(fullname); // Watch for files without extension.
memset(lump_p->name, '\0', 9); // Making sure they're initialized to 0. Is it necessary? memset(lump_p->name, '\0', 9); // Making sure they're initialized to 0. Is it necessary?
@@ -1667,9 +1667,9 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si
if (fread(rawData, 1, rawSize, handle) < rawSize) if (fread(rawData, 1, rawSize, handle) < rawSize)
I_Error("wad %d, lump %d: cannot read compressed data", wad, lump); I_Error("wad %d, lump %d: cannot read compressed data", wad, lump);
strm.zalloc = NULL; strm.zalloc = Z_NULL;
strm.zfree = NULL; strm.zfree = Z_NULL;
strm.opaque = NULL; strm.opaque = Z_NULL;
strm.total_in = strm.avail_in = rawSize; strm.total_in = strm.avail_in = rawSize;
strm.total_out = strm.avail_out = decSize; strm.total_out = strm.avail_out = decSize;
@@ -1997,16 +1997,11 @@ void *W_CachePatchNameRotated(const char *name, INT32 rotationangle, INT32 tag)
rspr = (rotsprite_t *)W_GetCachedRotPatchPwad(WADFILENUM(num),LUMPNUM(num)); rspr = (rotsprite_t *)W_GetCachedRotPatchPwad(WADFILENUM(num),LUMPNUM(num));
if (rspr == NULL)
return W_CachePatchNum(W_GetNumForName("MISSING"), tag);
if (rspr->patches[idx] == NULL) if (rspr->patches[idx] == NULL)
{ {
INT32 xpivot = 0, ypivot = 0; INT32 xpivot = 0, ypivot = 0;
ptr = (patch_t *)W_CachePatchNum(num, PU_PATCH); ptr = (patch_t *)W_CachePatchNum(num, PU_PATCH);
if (ptr == NULL)
return W_CachePatchNum(W_GetNumForName("MISSING"), tag);
// >y pivot centered // >y pivot centered
// >x pivot not centered // >x pivot not centered
@@ -2238,14 +2233,14 @@ static int W_VerifyPK3(FILE *fp, lumpchecklist_t *checklist, boolean status)
strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1);
// Strip away file address and extension for the 8char name. // Strip away file address and extension for the 8char name.
if ((trimname = strrchr(fullname, '/')) != NULL) if ((trimname = strrchr(fullname, '/')) != 0)
trimname++; trimname++;
else else
trimname = fullname; // Care taken for root files. trimname = fullname; // Care taken for root files.
if (*trimname) // Ignore directories, well kinda if (*trimname) // Ignore directories, well kinda
{ {
if ((dotpos = strrchr(trimname, '.')) == NULL) if ((dotpos = strrchr(trimname, '.')) == 0)
dotpos = fullname + strlen(fullname); // Watch for files without extension. dotpos = fullname + strlen(fullname); // Watch for files without extension.
memset(lumpname, '\0', 9); // Making sure they're initialized to 0. Is it necessary? memset(lumpname, '\0', 9); // Making sure they're initialized to 0. Is it necessary?
@@ -2483,14 +2478,14 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist)
strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1);
// Strip away file address and extension for the 8char name. // Strip away file address and extension for the 8char name.
if ((trimname = strrchr(fullname, '/')) != NULL) if ((trimname = strrchr(fullname, '/')) != 0)
trimname++; trimname++;
else else
trimname = fullname; // Care taken for root files. trimname = fullname; // Care taken for root files.
if (*trimname) // Ignore directories, well kinda if (*trimname) // Ignore directories, well kinda
{ {
if ((dotpos = strrchr(trimname, '.')) == NULL) if ((dotpos = strrchr(trimname, '.')) == 0)
dotpos = fullname + strlen(fullname); // Watch for files without extension. dotpos = fullname + strlen(fullname); // Watch for files without extension.
memset(lumpname, '\0', 9); // Making sure they're initialized to 0. Is it necessary? memset(lumpname, '\0', 9); // Making sure they're initialized to 0. Is it necessary?
@@ -2617,9 +2612,6 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
// Remember that we're assuming that the WAD will have a specific set of lumps in a specific order. // Remember that we're assuming that the WAD will have a specific set of lumps in a specific order.
UINT8 *wadData = (UINT8*)(W_CacheLumpNum(lumpnum, PU_LEVEL)); UINT8 *wadData = (UINT8*)(W_CacheLumpNum(lumpnum, PU_LEVEL));
if (wadData == NULL)
I_Error("vres_GetMap: Invalid WadData!\n");
filelump_t *fileinfo = (filelump_t *)(wadData + LONG(((wadinfo_t *)wadData)->infotableofs)); filelump_t *fileinfo = (filelump_t *)(wadData + LONG(((wadinfo_t *)wadData)->infotableofs));
i = LONG(((wadinfo_t *)wadData)->numlumps); i = LONG(((wadinfo_t *)wadData)->numlumps);
@@ -2636,8 +2628,6 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
} }
vlumps = (virtlump_t*)(Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL)); vlumps = (virtlump_t*)(Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL));
if (vlumps == NULL)
I_Error("vres_GetMap: Out of memory!\n");
// Build the lumps, skipping over empty entries. // Build the lumps, skipping over empty entries.
for (i = 0, realentry = 0; i < numlumps; realentry++) for (i = 0, realentry = 0; i < numlumps; realentry++)
@@ -2673,11 +2663,7 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
lumpnum_t lumppos = lumpnum + 1; lumpnum_t lumppos = lumpnum + 1;
for (i = LUMPNUM(lumppos); i < wadfiles[WADFILENUM(lumpnum)]->numlumps; i++, lumppos++, numlumps++) for (i = LUMPNUM(lumppos); i < wadfiles[WADFILENUM(lumpnum)]->numlumps; i++, lumppos++, numlumps++)
{ {
const char *name = W_CheckNameForNum(lumppos); if (memcmp(W_CheckNameForNum(lumppos), "MAP", 3) == 0 || W_LumpLength(lumppos) == 0)
if (name == NULL)
continue;
if (memcmp(name, "MAP", 3) == 0 || W_LumpLength(lumppos) == 0)
{ {
break; break;
} }
@@ -2685,15 +2671,10 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
numlumps++; numlumps++;
vlumps = (virtlump_t*)(Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL)); vlumps = (virtlump_t*)(Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL));
if (vlumps == NULL)
I_Error("vres_GetMap: Out of memory!\n");
for (i = 0; i < numlumps; i++, lumpnum++) for (i = 0; i < numlumps; i++, lumpnum++)
{ {
// Check if it is map marker. It is not always first lump sadly, so we need to expect it anywhere // Check if it is map marker. It is not always first lump sadly, so we need to expect it anywhere
const char *name = W_CheckNameForNum(lumpnum); const char *name = W_CheckNameForNum(lumpnum);
if (name == NULL)
continue;
if (strlen(name) == 5 && memcmp(name, "MAP", 3) == 0) if (strlen(name) == 5 && memcmp(name, "MAP", 3) == 0)
{ {
+6 -6
View File
@@ -187,13 +187,13 @@ static VOID ShowModuleInfo(HANDLE LogFile, HMODULE ModuleHandle)
// Open the code module file so that we can get its file date // Open the code module file so that we can get its file date
// and size. // and size.
ModuleFile = CreateFileA(ModName, GENERIC_READ, ModuleFile = CreateFileA(ModName, GENERIC_READ,
FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_SHARE_READ, 0, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL); FILE_ATTRIBUTE_NORMAL, 0);
if (ModuleFile != INVALID_HANDLE_VALUE) if (ModuleFile != INVALID_HANDLE_VALUE)
{ {
FILETIME LastWriteTime; FILETIME LastWriteTime;
FileSize = GetFileSize(ModuleFile, NULL); FileSize = GetFileSize(ModuleFile, 0);
if (GetFileTime(ModuleFile, NULL, NULL, &LastWriteTime)) if (GetFileTime(ModuleFile, 0, 0, &LastWriteTime))
{ {
wsprintfA(TimeBuffer, " - file date is "); wsprintfA(TimeBuffer, " - file date is ");
PrintTime(TimeBuffer + strlen(TimeBuffer), LastWriteTime); PrintTime(TimeBuffer + strlen(TimeBuffer), LastWriteTime);
@@ -227,7 +227,7 @@ static VOID RecordModuleList(HANDLE LogFile)
size_t PageSize; size_t PageSize;
size_t NumPages; size_t NumPages;
size_t pageNum = 0; size_t pageNum = 0;
LPVOID LastAllocationBase = NULL; LPVOID LastAllocationBase = 0;
FPrintf(LogFile, "\r\n" FPrintf(LogFile, "\r\n"
"\tModule list: names, addresses, sizes, time stamps " "\tModule list: names, addresses, sizes, time stamps "
@@ -385,7 +385,7 @@ LONG WINAPI RecordExceptionInfo(PEXCEPTION_POINTERS data/*, LPCSTR Message, LPST
} }
// Append to the error log. // Append to the error log.
SetFilePointer(fileHandle, 0, NULL, FILE_END); SetFilePointer(fileHandle, 0, 0, FILE_END);
// Print out some blank lines to separate this error log from any previous ones. // Print out some blank lines to separate this error log from any previous ones.
FPrintf(fileHandle, "Email Sonic Team Junior so we can fix the bugs\r\n"); // Tails FPrintf(fileHandle, "Email Sonic Team Junior so we can fix the bugs\r\n"); // Tails
+4 -4
View File
@@ -104,7 +104,7 @@ typedef struct
} y_voteclient; } y_voteclient;
// votescreen stuff // votescreen stuff
votescreen_t VoteScreen = {}; votescreen_t VoteScreen = {0};
static y_votelvlinfo levelinfo[5]; static y_votelvlinfo levelinfo[5];
static y_voteclient voteclient; static y_voteclient voteclient;
@@ -1093,7 +1093,7 @@ void Y_VoteDrawer(void)
V_DrawSmallScaledPatch(BASEVIDWIDTH-100, y, V_SNAPTORIGHT, pic); V_DrawSmallScaledPatch(BASEVIDWIDTH-100, y, V_SNAPTORIGHT, pic);
else else
{ {
V_DrawFixedPatch((BASEVIDWIDTH-20)<<FRACBITS, (y)<<FRACBITS, FRACUNIT/2, V_FLIP|V_SNAPTORIGHT, pic, NULL); V_DrawFixedPatch((BASEVIDWIDTH-20)<<FRACBITS, (y)<<FRACBITS, FRACUNIT/2, V_FLIP|V_SNAPTORIGHT, pic, 0);
V_DrawFixedPatch((BASEVIDWIDTH-60)<<FRACBITS, ((y+25)<<FRACBITS) - (rubyheight<<1), FRACUNIT, V_SNAPTORIGHT, VoteScreen.rubyicon, NULL); V_DrawFixedPatch((BASEVIDWIDTH-60)<<FRACBITS, ((y+25)<<FRACBITS) - (rubyheight<<1), FRACUNIT, V_SNAPTORIGHT, VoteScreen.rubyicon, NULL);
} }
@@ -1117,7 +1117,7 @@ void Y_VoteDrawer(void)
V_DrawTinyScaledPatch(BASEVIDWIDTH-60, y, V_SNAPTORIGHT, pic); V_DrawTinyScaledPatch(BASEVIDWIDTH-60, y, V_SNAPTORIGHT, pic);
else else
{ {
V_DrawFixedPatch((BASEVIDWIDTH-20)<<FRACBITS, y<<FRACBITS, FRACUNIT/4, V_FLIP|V_SNAPTORIGHT, pic, NULL); V_DrawFixedPatch((BASEVIDWIDTH-20)<<FRACBITS, y<<FRACBITS, FRACUNIT/4, V_FLIP|V_SNAPTORIGHT, pic, 0);
V_DrawFixedPatch((BASEVIDWIDTH-40)<<FRACBITS, (y<<FRACBITS) + (25<<(FRACBITS-1)) - rubyheight, FRACUNIT/2, V_SNAPTORIGHT, VoteScreen.rubyicon, NULL); V_DrawFixedPatch((BASEVIDWIDTH-40)<<FRACBITS, (y<<FRACBITS) + (25<<(FRACBITS-1)) - rubyheight, FRACUNIT/2, V_SNAPTORIGHT, VoteScreen.rubyicon, NULL);
} }
@@ -1164,7 +1164,7 @@ void Y_VoteDrawer(void)
V_DrawTinyScaledPatch(x, y, V_SNAPTOLEFT, pic); V_DrawTinyScaledPatch(x, y, V_SNAPTOLEFT, pic);
else else
{ {
V_DrawFixedPatch((x+40)<<FRACBITS, (y)<<FRACBITS, FRACUNIT/4, V_SNAPTOLEFT|V_FLIP, pic, NULL); V_DrawFixedPatch((x+40)<<FRACBITS, (y)<<FRACBITS, FRACUNIT/4, V_SNAPTOLEFT|V_FLIP, pic, 0);
V_DrawFixedPatch((x+20)<<FRACBITS, (y<<FRACBITS) + (25<<(FRACBITS-1)) - rubyheight, FRACUNIT/2, V_SNAPTOLEFT, VoteScreen.rubyicon, NULL); V_DrawFixedPatch((x+20)<<FRACBITS, (y<<FRACBITS) + (25<<(FRACBITS-1)) - rubyheight, FRACUNIT/2, V_SNAPTOLEFT, VoteScreen.rubyicon, NULL);
} }