Compare commits

..
Author SHA1 Message Date
Alug f58772a570 z_zone: add asserts if zone memory functions are called from non main thread
also taken from srb2classic thanks!
2026-02-02 18:14:38 +01:00
Alug f7c065b22e refactor i_thread stuff
based on https://codeberg.org/srb2classic/srb2classic/commit/3670a7c1c193185cf4921de8955c96e63fbecc62
and other things from srb2classic
this also now allows to check if a thread failed to spawn and reduces duped stuff and such
2026-02-02 18:14:35 +01:00
Alug 55c8546d68 do not use Zone Memory for masterserver rules
this gets called from within non main threads!
zone memory is not thread safe!
2026-02-02 17:27:23 +01:00
Alug 1762f18116 delet all the Z_Free checks
Z_Free already checks its input internally!
2026-02-02 16:12:38 +01:00
Alug e4dbf1ce11 plug a potential memory leak in M_SaveConfig 2026-02-02 16:11:57 +01:00
Alug 10b9d96259 hw_clip: replace "RoundToInt" with lrint
prefer to use standard lib functions if possible
lrint does the same thing (well ofc as long as no one touches the rounding direction löl) and is even quite a lot faster (though this is negligible in this case)
2026-02-02 16:11:54 +01:00
indev b23154fd93 Prevent replays menu scoll bar from disappearing 2026-02-02 02:28:33 +03:00
Alug b0ee972178 r_plane: fix visplane hashing overflowing
shift into "int" to prevent super large values during multiply
2026-02-01 20:52:48 +01:00
Alug 544e1d3b21 "fix" overflow in R_InitViewMapping with high resolutions 2026-02-01 17:07:18 +01:00
Alug 0ca6947f99 fix a few type issues 2026-02-01 16:27:25 +01:00
indev 3122c08039 Add focus options for gamepad led and rumble 2026-02-01 02:49:03 +03:00
indev 7a279a6fd9 Prefix autoaccel cvars with 'kart' to avoid conflict with hostmod 2026-01-28 19:19:02 +03:00
Alug c4581bd9a6 Only save and keep track of controller ids on SDL versions 2.32.4 and up
Older versions break and have unstable ids on Windows, cant check for linux but ill just add a version check at this point
This was part of updating sdl with v9, which got reverted due to other issues but this was not reverted oopsie
2026-01-24 18:20:54 +01:00
Alug bb47b976a7 software: fix drawseg xrange item coord type being too small
both sprite and drawseg coords are int32
might fix some clipping issues
2026-01-23 18:33:11 +01:00
Alug 6c419ff22e fix few more implicit double/float conversions 2026-01-23 18:33:08 +01:00
Alug 522904527f add missing HAVE_CURL 2026-01-23 10:08:35 +01:00
Alug 30539371c2 more cmake stuffs
-add LTO option, enabled by default
-set optimization level to O3 and O0 for debug builds
-add ASAN and UBSAN options
-always compile with gnu debug symbols
2026-01-22 14:46:12 +01:00
Alug e2ecc315b4 cmake: attempt to fix dedicated build uhh building 2026-01-22 14:44:47 +01:00
Alug eb2f186205 Merge pull request #221 from P-AS/morecmakefixes
CMake fixes cherry-picked from srb2-legacy
2026-01-22 14:43:38 +01:00
Alug bbf06b3376 add "vid.udup" same as vid.dup but not scaled with "highreshudscale" 2026-01-22 14:26:24 +01:00
Alug a1f70b0b31 opengl: attempt to scale vhs effect "fuzzyness"
this makes it appear more or less the same in all resolutions, similar to software, while also improving performance quite a bit on higher resolutions
2026-01-22 14:26:23 +01:00
Alug 2e0f5c02a4 opengl: make vhs effect bars be affected by "fuzzines"
makes stuff slightly slower, but matches the software effect
2026-01-22 14:25:57 +01:00
Alug 0f7001ef5c opengl: tiny optimiazation for vhs effect
dont call rand within the loop, use xorshift instead
while not massive, we dont need to call rand thousands of times, the xorshift is visually indistinguishable
this is still rather slow due to the crapton of draw calls and should best be replaced by a shader or something
2026-01-22 14:25:54 +01:00
PAS 4600da5782 restore SRB2_SDL2_EXE_NAME 2026-01-21 15:54:32 -05:00
indev a3557fadef P_PlayRinglossSound from lua might desynch so print warning about that 2026-01-21 23:38:41 +03:00
Alug d9a67faf47 fix windoze compile 2026-01-21 21:11:52 +01:00
PAS 96eaf8850e Add path suffix for libgme cmake module 2026-01-21 15:01:51 -05:00
PAS e7efd46419 Fix FindGME pkg-config command, update LibFindMacros.cmake 2026-01-21 15:01:33 -05:00
PAS 346b1456cd CMake: Fix FindOPENMPT 2026-01-21 14:59:01 -05:00
PAS 9f5a5a735b Allow changing Cpak generator (from upstream) 2026-01-21 14:58:32 -05:00
PAS 8e4b304bed CMake: don't configure before CPACK_PACKAGE_DESCRIPTION_SUMMARY is set 2026-01-21 14:51:17 -05:00
Alug 607fbc54fc Merge pull request #220 from Indev450/fixcmake2
Fixup CMake, but simpler
2026-01-21 20:45:24 +01:00
Alug 276cf0a8cb fix string.c include
whoops, not sure why that was even done like that
string.c will include strcasestr.c and SRB2_HAVE_STRLCPY will ensure eitherways we dont use the included strlcpy stuff
2026-01-21 20:04:19 +01:00
Alug 59c9af97c2 joy_open: make debug prints actually print the player number 2026-01-21 19:54:03 +01:00
Alug 4e75d99026 simplify LUA_Alloc
Z_Realloc already handles everything internally, no need to manually free anything
2026-01-21 19:49:55 +01:00
Alug 8e91c16e97 cmake: enable gnu extensions
we rely on some of them like the cleanup macro
dont want those breaking or smth
2026-01-21 19:34:44 +01:00
Alug 186421fe85 cmake: link with peethread 2026-01-21 19:23:36 +01:00
Alug af952870c3 fix fbo oopsie 2026-01-21 19:22:40 +01:00
Alug 4eeb0b4b20 update readme to reflect this 2026-01-21 19:16:05 +01:00
Alug cb2c65e9d9 more cmake fixups
- skip asset install for linux
- pass fwrapv flag
- fix asset hash stuff
- pass rdynamic flag
- add saturn specific stuff, saturnpak, saturnjoin, libbacktrace and fix screen fbo stuff
2026-01-21 19:09:50 +01:00
cobalt2727 f7bbde3982 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
2026-01-21 18:24:53 +01:00
Alug c9fc3b4820 fixup cmake for macos
mostly based on the patch from https://github.com/Bijman/srb2bld
with some changes from https://github.com/Indev450/SRB2Kart-Saturn/pull/216
but doesent completely replace the build system with what blan has
compiles fine on nix, but needs testing on mac
2026-01-21 18:23:21 +01:00
Alug f5195dd137 Merge branch 'crashissuereports' into Saturn-Next 2026-01-20 17:32:30 +01:00
Alug 5289f13891 Show report issue button also on I_Error
also make wrapper functions for everything, to reduce code dupe
2026-01-20 17:32:22 +01:00
Alug 073b35690b dont attempt to show sdl message box on non dedicated builds running as dedicated 2026-01-20 17:32:19 +01:00
Alug 43d3ac102d HWR_RenderPlane: cleanup code that does nothing 2026-01-20 15:42:37 +01:00
Alug aa96f9ceb3 V_DrawVhsEffect: fix scaling with highreshudscale, fix downwards bar going out of screen bounds
this shouldnt account for highreshudscale at all
on very high resolutions the bars are still only half size, but atleast they dont become minuscule or just dont draw at all
also ensures both bars are clamped, on some resolutions sometimes they just go out of visible screen range
2026-01-20 14:57:18 +01:00
Alug 104b8260fb add reducevfx to accesability menu
If there are things that should be handled by that toggle def feel free to suggest them!
2026-01-19 14:35:10 +01:00
Alug edebc728ef remove unused stuff from joyinfo 2026-01-18 19:00:05 +01:00
Alug 08e7ce3b5b m_menu: clean up the skin display stuff a little 2026-01-16 13:27:20 +01:00
Alug 29f187b751 fix some windoze specific "-Wzero-as-null-pointer-constant" warnings 2026-01-16 12:53:34 +01:00
indev ac3a1ad5eb Add gcc 13.3 into list of supported versions 2026-01-16 12:02:21 +03:00
indev 1b8d7b1541 I_Error when dedi tries to go to main error
This will not fix the issue entirely but will at least prevent server
getting stuck and backtrace will show where did it try to go into menu from
2026-01-16 11:11:36 +03:00
Alug b812d61da2 Merge branch 'crashissuereports' into Saturn-Next 2026-01-14 12:58:44 +01:00
indev 6fd64383d3 This isn't ceepeepee rn :SmolBuncle: 2026-01-12 22:33:30 +03:00
Alug e984e7a6c8 Merge branch 'menumodels' into Saturn-Next 2026-01-12 19:13:21 +01:00
Alug 96f90ff9c4 push back models even further
bigger models still had parts being culled, hope this is generous enough idk
2026-01-12 19:13:17 +01:00
Alug 51aec0e012 Merge branch 'menumodels' into Saturn-Next 2026-01-12 18:40:38 +01:00
Alug faadd3e89f support the uhhh localskin setup with 3d models 2026-01-12 18:40:00 +01:00
Alug 0c091256f4 tiny cleanup + warning fix 2026-01-12 18:30:11 +01:00
indev 7a0fb01626 Make glOrtho remap coordinates to vid.width and vid.height, this makes calculating coordinates in HWR_Draw2DModel easier 2026-01-12 18:30:08 +01:00
Alug c01818e2e3 simplify skinnum bounds check
lul
2026-01-12 18:30:06 +01:00
Alug e17a8a505c fix the culling issues
i hope this is right.......
2026-01-12 18:30:03 +01:00
indev ab654deba7 Make HWR_Draw2DModel not depend on resolution, make 3d skin select use skinselectspin cvar 2026-01-12 18:29:58 +01:00
Alug b145d7fd0e WIP: show 3d models in player setup
this is incredibly ugly and hacked together
theres some weird culling issues and shit doesent really "scale" with different resolutions which needs to be fixed
but it kinda works
2026-01-12 18:29:55 +01:00
Alug 264c9e38ad d_netfil: dont use zone memory in CURLGetFile 2026-01-11 19:46:46 +01:00
indev e88773da4e How did i miss the = 2026-01-11 13:08:23 +03:00
indev 310f67a06c Fix smol mistake in strcasestr 2026-01-11 03:49:07 +03:00
indev 0914d5b8e2 -Wzero-as-null-pointer-constant is valid for c only since GCC 15.2 (from what i see) 2026-01-11 00:49:48 +03:00
Alug 291a4dbb25 disable midnight channel border flicker with "reducevfx" 2026-01-09 13:01:30 +01:00
Alug 8fe3d13935 fix InitColorLUT 2026-01-09 11:08:22 +01:00
Alug bdc326b14e leveltime be tic_t
:chaosleep:
2026-01-08 00:43:43 +01:00
Alug d938e38ad3 Acessability: add basic "reducevfx" toggle to disable/reduce certain effects
toggles certain effects, which may be troublesome to some players

-disabled hyudoro flashing, instead makes player translucent
- Makes rainbow colour effects, such as invul, change colours very slowly
- Disables underwater and heatwave screen effects
- Disables palette flashing
- Disables vhs effect

not the most pretty implementation, but im lazy and this works

feel free to suggest more things
2026-01-08 00:40:24 +01:00
Alug 3d4772455b K_SpawnSparkleTrail: check for blend effect apply outside the loop
tiny optimization
2026-01-08 00:40:24 +01:00
Alug e1f0089627 enable "Wzero-as-null-pointer-constant", fix cases of it
prevent ambiguity
shoutout blankart for making me aware this exists
2026-01-08 00:40:24 +01:00
Alug edbebbf082 fix wrong type for K_DriftSparkColor
all the colour stuff is still a bit of a mess, but generally its handled as an uint8
2026-01-02 18:34:13 +01:00
Alug 242dee499d initialize more globals that have been missed 2026-01-02 18:34:10 +01:00
Alug a2de1e24c5 d_cliserv: fix casts from nan to int type
in few cases the files totalsize might be 0, which results in a nan, casting that to int type is undefined behavior
2025-12-28 17:46:44 +01:00
Alug c0cce90e60 properly handle getcwd error in IdentifyVersion
if getcwd fails, the buffer contents will be undefined
so we shall just overwrite it again with "."
2025-12-27 15:34:26 +01:00
Alug 67e74b5874 fix w_wad oopsie 2025-12-27 15:13:20 +01:00
Alug 9639ace28a fix dedicated server build warnings 2025-12-27 15:07:13 +01:00
Alug a2616778cc fix another -Wnull-dereference warning 2025-12-27 15:06:50 +01:00
Alug 495c34dd40 fix gcc version detection fallback stuff
latest_gcc_version should always just be X.x not X.x.x
this broke some warning flags for me
2025-12-27 13:02:30 +01:00
Alug f38ca9aa28 Signal Handler: Add button to report issues to github
mostly based on what srb2 does with some stuff from srb2-legacy
the button will attempt to open the issue page on the saturn git when a crash occurs
2025-12-27 12:41:41 +01:00
Alug b0bf588c27 fix some null pointer dereferences
and enable -Wnull-dereference by default
2025-12-27 10:52:21 +01:00
Alug 35e4f35f6e fix some shadowed variables, enable -Wshadow by default 2025-12-27 10:32:16 +01:00
LJ Sonic 7866b769cc Do not archive table values for nil keys 2025-12-27 00:00:39 +01:00
Alug 1af1e42dab FBO: remove nvidia xwayland hack
this has been a non issue since a while now, so can remove this (we shouldnt work around driver bugs anyways)
2025-12-26 23:20:42 +01:00
Alug 40bd3e5e19 simplify opengl vsync set 2025-12-26 23:20:39 +01:00
119 changed files with 2601 additions and 2220 deletions

No files matched your search

+74 -146
View File
@@ -1,25 +1,20 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5)
if("${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
message(FATAL_ERROR "In-source builds are blocked. Please build from a separate directory.")
if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR})
message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.")
endif()
# Set 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.
# Version change is fine.
project(SRB2
VERSION 1.6
LANGUAGES C CXX)
if(APPLE)
# DiscordRPC needs but does not properly specify ObjC
enable_language(OBJC)
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#set(CMAKE_CXX_EXTENSIONS OFF) # optional but recommended: disables GNU extensions, forces pure ISO C++
set(CMAKE_CXX_EXTENSIONS ON)
set(CMAKE_C_EXTENSIONS ON)
##### PACKAGE CONFIGURATION #####
@@ -36,7 +31,7 @@ if("${SRB2_CPACK_GENERATOR}" STREQUAL "")
endif()
set(CPACK_GENERATOR ${SRB2_CPACK_GENERATOR})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "SRB2Kart" CACHE STRING "Program name for display purposes")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Sonic Robo Blast 2 Kart" CACHE STRING "Program name for display purposes")
set(CPACK_PACKAGE_VENDOR "Kart Krew" CACHE STRING "Vendor name for display purposes")
#set(CPACK_PACKAGE_DESCRIPTION_FILE )
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
@@ -44,126 +39,55 @@ set(CPACK_PACKAGE_VERSION_MAJOR ${SRB2_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${SRB2_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${SRB2_VERSION_PATCH})
set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}")
SET(CPACK_OUTPUT_FILE_PREFIX package)
include(CPack)
# Options
# Set up CMAKE path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
if("${CMAKE_SYSTEM_NAME}" MATCHES Linux)
set(SRB2_CONFIG_SYSTEM_LIBRARIES_DEFAULT ON)
else()
set(SRB2_CONFIG_SYSTEM_LIBRARIES_DEFAULT OFF)
endif()
### Useful functions
option(
SRB2_CONFIG_SYSTEM_LIBRARIES
"Link dependencies using CMake's find_package and do not use internal builds"
${SRB2_CONFIG_SYSTEM_LIBRARIES_DEFAULT}
)
option(SRB2_CONFIG_ENABLE_TESTS "Build the test suite" OFF)
# This option isn't recommended for distribution builds and probably won't work (yet).
cmake_dependent_option(
SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES
"Use dynamic libraries when compiling internal dependencies"
OFF "NOT SRB2_CONFIG_SYSTEM_LIBRARIES"
OFF
)
option(SRB2_CONFIG_ENABLE_DISCORDRPC "Enable Discord RPC features" ON)
option(SRB2_CONFIG_STATIC_STDLIB "Link static version of standard library. All dependencies must also be static" ON)
option(SRB2_CONFIG_HWRENDER "Enable hardware render (OpenGL) support" ON)
option(SRB2_CONFIG_STATIC_OPENGL "Enable static linking GL (do not do this)" OFF)
option(SRB2_CONFIG_ERRORMODE "Compile C code with warnings treated as errors." OFF)
option(SRB2_CONFIG_DEBUGMODE "Compile with PARANOIA, ZDEBUG, RANGECHECK and PACKETDROP defined." OFF)
option(SRB2_CONFIG_MOBJCONSISTANCY "Compile with MOBJCONSISTANCY defined." OFF)
option(SRB2_CONFIG_PACKETDROP "Compile with PACKETDROP defined." OFF)
option(SRB2_CONFIG_ZDEBUG "Compile with ZDEBUG defined." OFF)
# SRB2_CONFIG_PROFILEMODE is probably superceded by some CMake setting.
option(SRB2_CONFIG_PROFILEMODE "Compile for profiling (GCC only)." OFF)
option(SRB2_CONFIG_TRACY "Compile with Tracy profiling enabled" OFF)
option(SRB2_CONFIG_ASAN "Compile with AddressSanitizer (libasan)." OFF)
option(SRB2_CONFIG_UBSAN "Compile with UndefinedBehaviorSanitizer (libubsan)." OFF)
set(SRB2_CONFIG_ASSET_DIRECTORY "" CACHE PATH "Path to directory that contains all asset files for the installer. If set, assets will be part of installation and cpack.")
option(SRB2_CONFIG_LTO "Enable link time optimizations, improves performance at the cost of longer link times." ON)
option(SRB2_CONFIG_TIDY "Enable clang tiny, checks compiled code for issues at the cost of longer compile times." OFF)
# man i suck at explaining lmao
option(SRB2_CONFIG_SATURNPAK "Enable Saturn specific special packet. Required for using the newer resynch system" ON)
option(SRB2_CONFIG_SATURNJOIN "Enable Saturn specific allowjoin toggle." ON)
option(SRB2_CONFIG_SCREENFBO "Enable hardware render (OpenGL) FBO downsampling support" ON)
option(SRB2_CONFIG_LIBBACKTRACE "Enable using libbacktrace for crashlogs" ON)
#if(SRB2_CONFIG_ENABLE_TESTS)
# https://github.com/catchorg/Catch2
# CPMAddPackage(
# NAME Catch2
# VERSION 3.1.1
# GITHUB_REPOSITORY catchorg/Catch2
# OPTIONS
# "CATCH_INSTALL_DOCS OFF"
# )
# list(APPEND CMAKE_MODULE_PATH "${Catch2_SOURCE_DIR}/extras")
# include(CTest)
# include(Catch)
# add_executable(srb2tests)
# # To add tests, use target_sources to add individual test files to the target in subdirs.
# target_link_libraries(srb2tests PRIVATE Catch2::Catch2 Catch2::Catch2WithMain)
# target_compile_features(srb2tests PRIVATE c_std_11 cxx_std_17)
# catch_discover_tests(srb2tests)
#endif()
# Enable CCache
# (Set USE_CCACHE=ON to use, CCACHE_OPTIONS for options)
if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL Windows)
option(USE_CCACHE "Enable ccache support" OFF)
if(USE_CCACHE)
find_program(CCACHE_TOOL_PATH ccache)
if(CCACHE_TOOL_PATH)
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_TOOL_PATH} CACHE STRING "" FORCE)
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_TOOL_PATH} CACHE STRING "" FORCE)
else()
message(WARNING "USE_CCACHE was set but ccache is not found (set CCACHE_TOOL_PATH)")
endif()
endif()
else()
# TODO: fix windoze crap, i dont want cpm lol
#CPMAddPackage(
# NAME Ccache.cmake
# GITHUB_REPOSITORY TheLartians/Ccache.cmake
# VERSION 1.2.5
#)
endif()
# Dependencies
#add_subdirectory(thirdparty)
if("${SRB2_CONFIG_SYSTEM_LIBRARIES}")
find_package(ZLIB REQUIRED)
find_package(PNG REQUIRED)
find_package(SDL2 REQUIRED)
find_package(SDL2_mixer REQUIRED)
find_package(CURL REQUIRED)
find_package(OPENMPT OPTIONAL)
find_package(GME REQUIRED)
find_package(DiscordRPC OPTIONAL)
find_package(libbacktrace OPTIONAL)
endif()
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})
# Prepend sources with current source directory
function(prepend_sources SOURCE_FILES)
foreach(SOURCE_FILE ${${SOURCE_FILES}})
set(MODIFIED ${MODIFIED} ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_FILE})
endforeach()
set(${SOURCE_FILES} ${MODIFIED} PARENT_SCOPE)
endfunction()
# Macro to add OSX framework
macro(add_framework fwname appname)
find_library(FRAMEWORK_${fwname}
NAMES ${fwname}
PATHS ${CMAKE_OSX_SYSROOT}/System/Library
${CMAKE_OSX_SYSROOT}/Library
/System/Library
/Library
ATH_SUFFIXES Frameworks
NO_DEFAULT_PATH)
if( ${FRAMEWORK_${fwname}} STREQUAL FRAMEWORK_${fwname}-NOTFOUND)
MESSAGE(ERROR ": Framework ${fwname} not found")
else()
TARGET_LINK_LIBRARIES(${appname} PRIVATE "${FRAMEWORK_${fwname}}/${fwname}")
MESSAGE(STATUS "Framework ${fwname} found at ${FRAMEWORK_${fwname}}")
endif()
endmacro()
# Macro to copy Windows DLLs to Debug/Release folder for easy debugging
# Note: this is general purpose, we could copy anything. Just using for DLLs on MSVC though
macro(copy_files_to_build_dir target dlllist_var)
if(MSVC)
# http://stackoverflow.com/a/26983405/3064195
foreach(dlllist_item ${${dlllist_var}})
get_filename_component(dllname ${dlllist_item} NAME)
add_custom_command(TARGET ${target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${dlllist_item}
$<TARGET_FILE_DIR:${target}>/${dllname}
)
endforeach()
endif()
endmacro()
# bitness check
set(SRB2_SYSTEM_BITS 0)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
@@ -178,12 +102,32 @@ if(${SRB2_SYSTEM_BITS} EQUAL 0)
message(STATUS "Target bitness is unknown")
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_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
# Set EXE names so the assets CMakeLists can refer to its target
set(SRB2_SDL2_EXE_NAME "" CACHE STRING "Override executable binary output name")
set(SRB2_SDL2_EXE_SUFFIX "" CACHE STRING "Optional executable suffix, separated by an underscore")
set(SRB2_SDL2_EXE_NAME srb2kart CACHE STRING "Executable binary output name")
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src)
@@ -195,22 +139,6 @@ set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary")
include(GitUtilities)
git_latest_commit(SRB2_COMP_COMMIT "${CMAKE_SOURCE_DIR}")
git_current_branch(SRB2_GIT_BRANCH "${CMAKE_SOURCE_DIR}")
#git_working_tree_dirty(SRB2_COMP_UNCOMMITTED "${CMAKE_SOURCE_DIR}") #TODO: fix this
set(SRB2_COMP_BRANCH "${SRB2_GIT_BRANCH}")
set(SRB2_COMP_REVISION "${SRB2_COMP_COMMIT}")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/config.h)
if("${SRB2_SDL2_EXE_NAME}" STREQUAL "")
list(APPEND EXE_NAME_PARTS "srb2kart-saturn")
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.
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.
For Windows only the Makefile build system with GCC or Clang compiler is supported.
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!
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!
## Disclaimer
+44 -32
View File
@@ -5,48 +5,60 @@ if(${CMAKE_SYSTEM} MATCHES Linux)
return()
endif()
if("${SRB2_CONFIG_ASSET_DIRECTORY}" STREQUAL "")
message(WARNING "SRB2_CONFIG_ASSET_DIRECTORY is not set, so installation will not contain data files.")
return()
endif()
# For prepending the current source path, later
FUNCTION(PREPEND var prefix)
SET(listVar "")
FOREACH(f ${ARGN})
LIST(APPEND listVar "${prefix}/${f}")
ENDFOREACH(f)
SET(${var} "${listVar}" PARENT_SCOPE)
ENDFUNCTION(PREPEND)
get_filename_component(SRB2_ASSET_DIRECTORY_ABSOLUTE "${SRB2_CONFIG_ASSET_DIRECTORY}" ABSOLUTE)
set(SRB2_ASSET_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/installer"
CACHE STRING "Path to directory that contains all asset files for the installer.")
set(SRB2_ASSETS_DOCS
"README.txt"
"HISTORY.txt"
"README-SDL.txt"
"LICENSE.txt"
"LICENSE-3RD-PARTY.txt"
set(SRB2_ASSET_HASHED
"srb2.srb;\
gfx.kart;\
textures.kart;\
chars.kart;\
maps.kart"
CACHE STRING "Asset filenames to apply MD5 checks. No spaces between entries!"
)
list(TRANSFORM SRB2_ASSETS_DOCS PREPEND "/")
list(TRANSFORM SRB2_ASSETS_DOCS PREPEND "${SRB2_ASSET_DIRECTORY_ABSOLUTE}")
####################
# POST-V2.2 NOTE: Do not forget to add patch.pk3 to the end of this list!
####################
set(SRB2_ASSETS_GAME
"srb2.srb"
"gfx.kart"
"textures.kart"
"chars.kart"
"maps.kart"
set(SRB2_ASSET_DOCS
"README.txt;\
HISTORY.txt;\
LICENSE.txt;\
LICENSE-3RD-PARTY.txt"
CACHE STRING "Documentation filenames. In OS X, these are packaged separately from other assets. No spaces between entries!"
)
list(TRANSFORM SRB2_ASSETS_GAME PREPEND "/")
list(TRANSFORM SRB2_ASSETS_GAME PREPEND "${SRB2_ASSET_DIRECTORY_ABSOLUTE}")
set(SRB2_ASSETS ${SRB2_ASSET_DOCS} ${SRB2_ASSETS_GAME})
PREPEND(SRB2_ASSET_DOCS ${SRB2_ASSET_DIRECTORY} ${SRB2_ASSET_DOCS})
foreach(SRB2_ASSET ${SRB2_ASSET_HASHED})
file(MD5 ${SRB2_ASSET_DIRECTORY}/${SRB2_ASSET} "SRB2_ASSET_${SRB2_ASSET}_HASH")
set(SRB2_ASSET_${SRB2_ASSET}_HASH ${SRB2_ASSET_${SRB2_ASSET}_HASH} PARENT_SCOPE)
endforeach()
# Installation
if(${CMAKE_SYSTEM} MATCHES Darwin)
get_target_property(outname SRB2SDL2 OUTPUT_NAME)
install(FILES ${SRB2_ASSETS} DESTINATION "${outname}.app/Contents/Resources")
install(DIRECTORY "${SRB2_ASSET_DIRECTORY_ABSOLUTE}/models" DESTINATION "${outname}.app/Contents/Resources")
install(FILES ${SRB2_ASSETS_DOCS} DESTINATION .)
install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/"
DESTINATION "${outname}.app/Contents/Resources"
)
install(FILES ${SRB2_ASSET_DOCS}
DESTINATION .
OPTIONAL
)
else()
install(FILES ${SRB2_ASSETS} DESTINATION .)
install(DIRECTORY "${SRB2_ASSET_DIRECTORY_ABSOLUTE}/models" DESTINATION .)
install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/"
DESTINATION .
)
# Docs are assumed to be located in SRB2_ASSET_DIRECTORY, so don't install again
#install(FILES ${SRB2_ASSET_DOCS}
# DESTINATION .
# OPTIONAL
#)
endif()
-19
View File
@@ -1,19 +0,0 @@
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
set(CMAKE_BINARY_DIR "${BINARY_DIR}")
set(CMAKE_CURRENT_BINARY_DIR "${BINARY_DIR}")
# Set up CMAKE path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
include(GitUtilities)
git_current_branch(SRB2_COMP_BRANCH)
git_working_tree_dirty(SRB2_COMP_UNCOMMITTED)
git_latest_commit(SRB2_COMP_REVISION)
git_subject(subject)
string(REGEX REPLACE "([\"\\])" "\\\\\\1" SRB2_COMP_LASTCOMMIT "${subject}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in" "${CMAKE_CURRENT_SOURCE_DIR}/src/config.h")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in" "${CMAKE_CURRENT_SOURCE_DIR}/build/src/config.h")
-10
View File
@@ -21,13 +21,3 @@ find_library(DISCORDRPC_LIBRARY
set(DISCORDRPC_PROCESS_INCLUDES DISCORDRPC_INCLUDE_DIR)
set(DISCORDRPC_PROCESS_LIBS DISCORDRPC_LIBRARY)
libfind_process(DISCORDRPC)
if(DISCORDRPC_FOUND AND NOT TARGET DiscordRPC::DiscordRPC)
add_library(DiscordRPC::DiscordRPC UNKNOWN IMPORTED)
set_target_properties(
DiscordRPC::DiscordRPC
PROPERTIES
IMPORTED_LOCATION "${DISCORDRPC_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${DISCORDRPC_INCLUDE_DIR}"
)
endif()
+2 -11
View File
@@ -1,6 +1,6 @@
include(LibFindMacros)
libfind_pkg_check_modules(GME_PKGCONF GME)
libfind_pkg_check_modules(GME_PKGCONF LIBGME)
find_path(GME_INCLUDE_DIR
NAMES gme.h
@@ -8,6 +8,7 @@ find_path(GME_INCLUDE_DIR
${GME_PKGCONF_INCLUDE_DIRS}
"/usr/include/gme"
"/usr/local/include/gme"
PATH_SUFFIXES gme
)
find_library(GME_LIBRARY
@@ -21,13 +22,3 @@ find_library(GME_LIBRARY
set(GME_PROCESS_INCLUDES GME_INCLUDE_DIR)
set(GME_PROCESS_LIBS GME_LIBRARY)
libfind_process(GME)
if(GME_FOUND AND NOT TARGET gme)
add_library(gme UNKNOWN IMPORTED)
set_target_properties(
gme
PROPERTIES
IMPORTED_LOCATION "${GME_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${GME_INCLUDE_DIR}"
)
endif()
+2 -11
View File
@@ -1,6 +1,6 @@
include(LibFindMacros)
libfind_pkg_check_modules(OPENMPT_PKGCONF OPENMPT)
libfind_pkg_check_modules(OPENMPT_PKGCONF LIBOPENMPT)
find_path(OPENMPT_INCLUDE_DIR
NAMES libopenmpt.h
@@ -8,6 +8,7 @@ find_path(OPENMPT_INCLUDE_DIR
${OPENMPT_PKGCONF_INCLUDE_DIRS}
"/usr/include/libopenmpt"
"/usr/local/include/libopenmpt"
PATH_SUFFIXES libopenmpt
)
find_library(OPENMPT_LIBRARY
@@ -21,13 +22,3 @@ find_library(OPENMPT_LIBRARY
set(OPENMPT_PROCESS_INCLUDES OPENMPT_INCLUDE_DIR)
set(OPENMPT_PROCESS_LIBS OPENMPT_LIBRARY)
libfind_process(OPENMPT)
if(OPENMPT_FOUND AND NOT TARGET openmpt)
add_library(openmpt UNKNOWN IMPORTED)
set_target_properties(
openmpt
PROPERTIES
IMPORTED_LOCATION "${OPENMPT_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${OPENMPT_INCLUDE_DIR}"
)
endif()
-10
View File
@@ -31,13 +31,3 @@ find_library(SDL2_LIBRARY
set(SDL2_PROCESS_INCLUDES SDL2_INCLUDE_DIR)
set(SDL2_PROCESS_LIBS SDL2_LIBRARY)
libfind_process(SDL2)
if(SDL2_FOUND AND NOT TARGET SDL2::SDL2)
add_library(SDL2::SDL2 UNKNOWN IMPORTED)
set_target_properties(
SDL2::SDL2
PROPERTIES
IMPORTED_LOCATION "${SDL2_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}"
)
endif()
-10
View File
@@ -32,13 +32,3 @@ find_library(SDL2_MIXER_LIBRARY
set(SDL2_MIXER_PROCESS_INCLUDES SDL2_MIXER_INCLUDE_DIR)
set(SDL2_MIXER_PROCESS_LIBS SDL2_MIXER_LIBRARY)
libfind_process(SDL2_MIXER)
if(SDL2_MIXER_FOUND AND NOT TARGET SDL2_mixer::SDL2_mixer)
add_library(SDL2_mixer::SDL2_mixer UNKNOWN IMPORTED)
set_target_properties(
SDL2_mixer::SDL2_mixer
PROPERTIES
IMPORTED_LOCATION "${SDL2_MIXER_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_MIXER_INCLUDE_DIR}"
)
endif()
+24 -40
View File
@@ -6,54 +6,38 @@ endif()
set(__GitUtilities ON)
macro(_git_command)
execute_process(
COMMAND "${GIT_EXECUTABLE}" ${ARGN}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
function(git_describe variable path)
execute_process(COMMAND "${GIT_EXECUTABLE}" "describe"
WORKING_DIRECTORY "${path}"
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endmacro()
macro(_git_easy_command)
_git_command(${ARGN})
set(${variable} "${output}" PARENT_SCOPE)
endmacro()
function(git_current_branch variable)
_git_command(symbolic-ref -q --short HEAD)
# If a detached head, a ref could still be resolved.
if("${output}" STREQUAL "")
_git_command(describe --all --exact-match)
# Get the ref, in the form heads/master or
# remotes/origin/master so isolate the final part.
string(REGEX REPLACE ".*/" "" output "${output}")
endif()
set(${variable} "${output}" PARENT_SCOPE)
endfunction()
function(git_latest_commit variable)
_git_easy_command(rev-parse --short HEAD)
function(git_current_branch variable path)
execute_process(COMMAND ${GIT_EXECUTABLE} "symbolic-ref" "--short" "HEAD"
WORKING_DIRECTORY "${path}"
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(${variable} "${output}" PARENT_SCOPE)
endfunction()
function(git_working_tree_dirty variable)
_git_command(status --porcelain -uno)
function(git_latest_commit variable path)
execute_process(COMMAND ${GIT_EXECUTABLE} "rev-parse" "--short" "HEAD"
WORKING_DIRECTORY "${path}"
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(output STREQUAL "")
set(${variable} FALSE PARENT_SCOPE)
else()
set(${variable} TRUE PARENT_SCOPE)
endif()
endfunction()
function(git_subject variable)
_git_easy_command(log -1 "--format=%h %s")
endfunction()
function(get_git_dir variable)
_git_easy_command(rev-parse --git-dir)
endfunction()
set(${variable} "${output}" PARENT_SCOPE)
endfunction()
+37 -18
View File
@@ -1,4 +1,4 @@
# Version 2.2
# Version 2.4
# Public Domain, originally written by Lasse Kärkkäinen <tronic>
# Maintained at https://github.com/Tronic/cmake-modules
# Please send your improvements as pull requests on Github.
@@ -52,6 +52,10 @@ function (libfind_pkg_detect PREFIX)
if (libraryargs)
find_library(${PREFIX}_LIBRARY NAMES ${libraryargs} HINTS ${${PREFIX}_PKGCONF_LIBRARY_DIRS})
endif()
# Read pkg-config version
if (${PREFIX}_PKGCONF_VERSION)
set(${PREFIX}_VERSION ${${PREFIX}_PKGCONF_VERSION} PARENT_SCOPE)
endif()
endfunction()
# Extracts a version #define from a version.h file, output stored to <PREFIX>_VERSION.
@@ -125,24 +129,39 @@ function (libfind_process PREFIX)
# Process deps to add to
foreach (i ${PREFIX} ${${PREFIX}_DEPENDENCIES})
if (DEFINED ${i}_INCLUDE_OPTS OR DEFINED ${i}_LIBRARY_OPTS)
if (DEFINED ${i}_INCLUDE_OPTS)
# The package seems to export option lists that we can use, woohoo!
list(APPEND includeopts ${${i}_INCLUDE_OPTS})
else()
if (DEFINED ${i}_INCLUDE_DIR)
# Singular forms can be used
list(APPEND includeopts ${i}_INCLUDE_DIR)
else()
if (DEFINED ${i}_INCLUDE_DIRS)
# Plural forms can be used
list(APPEND includeopts ${i}_INCLUDE_DIRS)
else()
# Oh no, we don't know the option names
message(FATAL_ERROR "We couldn't determine config variable names for ${i} includes. Aieeh!")
endif()
endif()
endif()
if (DEFINED ${i}_LIBRARY_OPTS)
# The package seems to export option lists that we can use, woohoo!
list(APPEND libraryopts ${${i}_LIBRARY_OPTS})
else()
# If plural forms don't exist or they equal singular forms
if ((NOT DEFINED ${i}_INCLUDE_DIRS AND NOT DEFINED ${i}_LIBRARIES) OR
({i}_INCLUDE_DIR STREQUAL ${i}_INCLUDE_DIRS AND ${i}_LIBRARY STREQUAL ${i}_LIBRARIES))
if (DEFINED ${i}_LIBRARY)
# Singular forms can be used
if (DEFINED ${i}_INCLUDE_DIR)
list(APPEND includeopts ${i}_INCLUDE_DIR)
endif()
if (DEFINED ${i}_LIBRARY)
list(APPEND libraryopts ${i}_LIBRARY)
endif()
list(APPEND libraryopts ${i}_LIBRARY)
else()
# Oh no, we don't know the option names
message(FATAL_ERROR "We couldn't determine config variable names for ${i} includes and libs. Aieeh!")
if (DEFINED ${i}_LIBRARIES)
# Plural forms can be used
list(APPEND libraryopts ${i}_LIBRARIES)
else()
# Oh no, we don't know the option names
message(FATAL_ERROR "We couldn't determine config variable names for ${i} libraries. Aieeh!")
endif()
endif()
endif()
endforeach()
@@ -209,12 +228,12 @@ function (libfind_process PREFIX)
message(STATUS " ${PREFIX}_LIBRARY_OPTS=${libraryopts}")
message(STATUS " ${PREFIX}_LIBRARIES=${libs}")
endif()
set (${PREFIX}_INCLUDE_OPTS ${includeopts} PARENT_SCOPE)
set (${PREFIX}_LIBRARY_OPTS ${libraryopts} PARENT_SCOPE)
set (${PREFIX}_INCLUDE_DIRS ${includes} PARENT_SCOPE)
set (${PREFIX}_LIBRARIES ${libs} PARENT_SCOPE)
set (${PREFIX}_FOUND TRUE PARENT_SCOPE)
endif()
set (${PREFIX}_INCLUDE_OPTS ${includeopts} PARENT_SCOPE)
set (${PREFIX}_LIBRARY_OPTS ${libraryopts} PARENT_SCOPE)
set (${PREFIX}_INCLUDE_DIRS ${includes} PARENT_SCOPE)
set (${PREFIX}_LIBRARIES ${libs} PARENT_SCOPE)
set (${PREFIX}_FOUND TRUE PARENT_SCOPE)
return()
endif()
-1
View File
@@ -1,5 +1,4 @@
/cscope.out
*.json
*.idx
config.h
*.gdb_history
+542 -381
View File
@@ -1,146 +1,437 @@
add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32)
if(("${CMAKE_COMPILER_IS_GNUCC}" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND "${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
target_link_options(SRB2SDL2 PRIVATE "-Wl,--disable-dynamicbase")
if("${SRB2_CONFIG_STATIC_STDLIB}")
# On MinGW with internal libraries, link the standard library statically
if(CMAKE_LINKER_TYPE STREQUAL "LLD")
target_link_options(SRB2SDL2 PRIVATE -Wl, -static-libgcc -static-libstdc++ -static -lpthread)
else()
target_link_options(SRB2SDL2 PRIVATE -Wl,--add-stdcall-alias -static-libgcc -static-libstdc++ -static -lpthread)
endif()
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
target_link_libraries(SRB2SDL2 PRIVATE Threads::Threads)
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
target_link_options(SRB2SDL2 PRIVATE "-Wl,--large-address-aware")
endif()
endif()
set(SRB2_CONFIG_STD23 OFF CACHE BOOL
"Compiles the game under c23 and cxx23 instead c11 and cxx17.")
if(SRB2_CONFIG_STD23)
message("-- Compiling game with C23 and CXX23.")
target_compile_features(SRB2SDL2 PRIVATE c_std_23 cxx_std_23)
set_property(TARGET SRB2SDL2 PROPERTY C_STANDARD 23)
set_property(TARGET SRB2SDL2 PROPERTY CXX_STANDARD 23)
else()
message("-- Compiling game with C11 and CXX17.")
target_compile_features(SRB2SDL2 PRIVATE c_std_11 cxx_std_17)
set_property(TARGET SRB2SDL2 PROPERTY C_STANDARD 11)
set_property(TARGET SRB2SDL2 PROPERTY CXX_STANDARD 17)
endif()
# SRB2 Core
# Core sources
target_sourcefile(c)
target_sources(SRB2SDL2 PRIVATE comptime.c config.h.in)
set(SRB2_CORE_SOURCES
core/memory.cpp
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
)
target_sources(SRB2SDL2 PRIVATE md5.c md5.h)
set(SRB2_CORE_HEADERS
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
i_threads.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
set(SRB2_CONFIG_DEV_BUILD OFF CACHE BOOL
"Compile a development build of SRB2Kart.")
set(SRB2_CONFIG_HAVE_BLUA ON CACHE BOOL
"Enable Lua interpreter support")
set(SRB2_CONFIG_HAVE_PNG ON CACHE BOOL
"Enable PNG support. Depends on zlib, so will be disabled if you don't enable that too.")
set(SRB2_CONFIG_HAVE_ZLIB ON CACHE BOOL
"Enable zlib support.")
set(SRB2_CONFIG_HAVE_GME ON CACHE BOOL
"Enable GME support.")
set(SRB2_CONFIG_HAVE_OPENMPT ON CACHE BOOL
"Enable OpenMPT support.")
set(SRB2_CONFIG_HAVE_DISCORDRPC OFF CACHE BOOL
"Enable Discord rich presence support.")
set(SRB2_CONFIG_HAVE_CURL ON CACHE BOOL
"Enable curl support, used for downloading files via HTTP.")
set(SRB2_CONFIG_HWRENDER ON CACHE BOOL
"Enable hardware rendering through OpenGL.")
set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL
"Use statically linked OpenGL. NOT RECOMMENDED.")
set(SRB2_CONFIG_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_SKIP_COMPTIME OFF CACHE BOOL
"Skip Comptime rebuild.")
set(SRB2_CONFIG_SATURNPAK ON CACHE BOOL
"Enable Saturn specific special packet. Required for using the newer resynch system")
set(SRB2_CONFIG_SATURNJOIN ON CACHE BOOL
"Enable Saturn specific allowjoin toggle.")
set(SRB2_CONFIG_SCREENFBO ON CACHE BOOL
"Enable hardware renderer (OpenGL) FBO downsampling support")
if(NOT SRB2_CONFIG_SKIP_COMPTIME)
# This updates the modification time for comptime.c at the
# end of building so when the build system is ran next time,
# that file gets flagged. comptime.c will always be rebuilt.
#
# This begs the question, why always rebuild comptime.c?
# Some things like the git commit must be checked each time
# the program is built. But the build system determines which
# files should be rebuilt before anything else. So
# comptime.c, which only needs to be rebuilt based on
# information known at build time, must be told to rebuild
# before that information can be ascertained.
add_custom_command(
TARGET SRB2SDL2
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E touch_nocreate ${CMAKE_CURRENT_SOURCE_DIR}/comptime.c
if(${SRB2_CONFIG_DEDICATED})
set(SRB2_CONFIG_HAVE_GME NO)
set(SRB2_CONFIG_HAVE_OPENMPT NO)
set(SRB2_CONFIG_HWRENDER NO)
endif()
### use internal libraries?
if(${CMAKE_SYSTEM} MATCHES "Windows") ###set on Windows only
set(SRB2_CONFIG_USE_INTERNAL_LIBRARIES OFF CACHE BOOL
"Use SRB2Kart's internal copies of required dependencies (SDL2, PNG, zlib, GME, OpenMPT).")
endif()
if(${SRB2_CONFIG_HAVE_BLUA})
add_definitions(-DHAVE_BLUA)
set(SRB2_LUA_SOURCES
lua_baselib.c
lua_blockmaplib.c
lua_consolelib.c
lua_hooklib.c
lua_hudlib.c
lua_hudlib_drawlist.c
lua_infolib.c
lua_maplib.c
lua_mathlib.c
lua_mobjlib.c
lua_playerlib.c
lua_script.c
lua_skinlib.c
lua_thinkerlib.c
lua_udatalib.c
lua_glib.c
)
set(SRB2_LUA_HEADERS
lua_hook.h
lua_hud.h
lua_hudlib_drawlist.h
lua_libs.h
lua_script.h
lua_udatalib.h
lua_glib.h
)
prepend_sources(SRB2_LUA_SOURCES)
prepend_sources(SRB2_LUA_HEADERS)
source_group("LUA" FILES ${SRB2_LUA_SOURCES} ${SRB2_LUA_HEADERS})
set(SRB2_BLUA_SOURCES
blua/lapi.c
blua/lauxlib.c
blua/lbaselib.c
blua/ldblib.c
blua/lcode.c
blua/ldebug.c
blua/ldo.c
blua/ldump.c
blua/lfunc.c
blua/lgc.c
blua/linit.c
blua/liolib.c
blua/llex.c
blua/lmem.c
blua/lobject.c
blua/lopcodes.c
blua/lparser.c
blua/lstate.c
blua/lstring.c
blua/lstrlib.c
blua/ltable.c
blua/ltablib.c
blua/ltm.c
blua/lundump.c
blua/lvm.c
blua/lzio.c
)
set(SRB2_BLUA_HEADERS
blua/lapi.h
blua/lauxlib.h
blua/lcode.h
blua/ldebug.h
blua/ldo.h
blua/lfunc.h
blua/lgc.h
blua/llex.h
blua/llimits.h
blua/lmem.h
blua/lobject.h
blua/lopcodes.h
blua/lparser.h
blua/lstate.h
blua/lstring.h
blua/ltable.h
blua/ltm.h
blua/lua.h
blua/luaconf.h
blua/lualib.h
blua/lundump.h
blua/lvm.h
blua/lzio.h
)
prepend_sources(SRB2_BLUA_SOURCES)
prepend_sources(SRB2_BLUA_HEADERS)
source_group("LUA\\Interpreter" FILES ${SRB2_BLUA_SOURCES} ${SRB2_BLUA_HEADERS})
endif()
set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary")
add_custom_target(_SRB2_reconf ALL
COMMAND ${CMAKE_COMMAND} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DBINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/.. -P ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/Comptime.cmake
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.."
)
add_dependencies(SRB2SDL2 _SRB2_reconf)
if(SRB2_CONFIG_ASAN)
target_compile_options(SRB2SDL2 PRIVATE -fsanitize=address)
target_link_options(SRB2SDL2 PRIVATE -fsanitize=address)
endif()
if(SRB2_CONFIG_UBSAN)
target_compile_options(SRB2SDL2 PRIVATE -fsanitize=undefined)
target_link_options(SRB2SDL2 PRIVATE -fsanitize=undefined)
endif()
if(SRB2_CONFIG_TIDY)
set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-checks=*")
endif()
add_subdirectory(blua)
add_subdirectory(sdl)
add_subdirectory(core)
# OS macros
if (UNIX)
target_compile_definitions(SRB2SDL2 PRIVATE -DUNIXCOMMON)
target_link_libraries(SRB2SDL2 PRIVATE -rdynamic) # Use -rdynamic so a backtrace log shows function names
endif()
if(CMAKE_COMPILER_IS_GNUCC)
find_program(OBJCOPY objcopy)
endif()
if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
target_compile_definitions(SRB2SDL2 PRIVATE -DLINUX)
if(${SRB2_SYSTEM_BITS} EQUAL 64)
target_compile_definitions(SRB2SDL2 PRIVATE -DLINUX64)
if(${SRB2_CONFIG_HAVE_GME})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
set(GME_FOUND ON)
set(GME_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/gme/include)
if(${SRB2_SYSTEM_BITS} EQUAL 64)
set(GME_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/gme/win64 -lgme")
else() # 32-bit
set(GME_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/gme/win32 -lgme")
endif()
else()
find_package(GME)
endif()
if(${GME_FOUND})
set(SRB2_HAVE_GME ON)
add_definitions(-DHAVE_LIBGME)
else()
message(WARNING "You have specified that GME is available but it was not found.")
endif()
endif()
if("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
target_compile_definitions(SRB2SDL2 PRIVATE -DMACOSX)
if(${SRB2_CONFIG_HAVE_DISCORDRPC})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
set(DISCORDRPC_FOUND ON)
if(${SRB2_SYSTEM_BITS} EQUAL 64)
set(DISCORDRPC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/discord-rpc/win64-dynamic/include)
set(DISCORDRPC_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/discord-rpc/win64-dynamic/lib -ldiscord-rpc")
else() # 32-bit
set(DISCORDRPC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/discord-rpc/win32-dynamic/include)
set(DISCORDRPC_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/discord-rpc/win32-dynamic/lib -ldiscord-rpc")
endif()
else()
find_package(DiscordRPC)
endif()
if(${DISCORDRPC_FOUND})
set(SRB2_HAVE_DISCORDRPC ON)
add_definitions(-DHAVE_DISCORDRPC)
add_definitions(-DUSE_STUN)
set(SRB2_DISCORDRPC_SOURCES discord.c stun.c)
set(SRB2_DISCORDRPC_HEADERS discord.h stun.h)
prepend_sources(SRB2_DISCORDRPC_SOURCES)
prepend_sources(SRB2_DISCORDRPC_HEADERS)
source_group("Discord Rich Presence" FILES ${SRB2_DISCORDRPC_SOURCES} ${SRB2_DISCORDRPC_HEADERS})
else()
message(WARNING "You have specified that Discord Rich Presence is available but it was not found.")
endif()
endif()
# add toggle for this
target_link_libraries(SRB2SDL2 PRIVATE openmpt)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_OPENMPT)
target_link_libraries(SRB2SDL2 PRIVATE ZLIB::ZLIB PNG::PNG CURL::libcurl)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_ZLIB -DHAVE_PNG -DHAVE_CURL -D_LARGEFILE64_SOURCE)
target_compile_definitions(SRB2SDL2 PRIVATE -DUSE_STUN)
if(SRB2_CONFIG_ENABLE_DISCORDRPC)
target_link_libraries(SRB2SDL2 PRIVATE DiscordRPC::DiscordRPC)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_DISCORDRPC)
target_sources(SRB2SDL2 PRIVATE discord.c)
endif()
if(${SRB2_CONFIG_LIBBACKTRACE})
target_link_libraries(SRB2SDL2 PRIVATE libbacktrace)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_LIBBACKTRACE)
endif()
# FIXME macOS does not support C11 threads.h
if(NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
set(SRB2_HAVE_THREADS ON)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_THREADS)
if(${SRB2_CONFIG_HAVE_OPENMPT})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
set(OPENMPT_FOUND ON)
set(OPENMPT_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/inc)
if(${SRB2_SYSTEM_BITS} EQUAL 64)
set(OPENMPT_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/libopenmpt/lib/x86_64/mingw -lopenmpt")
else() # 32-bit
set(OPENMPT_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/libopenmpt/lib/x86/mingw -lopenmpt")
endif()
else()
find_package(OPENMPT)
endif()
if(${OPENMPT_FOUND})
set(SRB2_HAVE_OPENMPT ON)
add_definitions(-DHAVE_OPENMPT)
else()
message(WARNING "You have specified that OpenMPT is available but it was not found.")
endif()
endif()
if(${SRB2_CONFIG_HAVE_ZLIB})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
set(ZLIB_FOUND ON)
set(ZLIB_COMPAT ON)
set(WITH_GTEST OFF)
set(ZLIB_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/zlib)
if(${SRB2_SYSTEM_BITS} EQUAL 64)
set(ZLIB_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/zlib/win32 -lz64")
@@ -152,9 +443,9 @@ if(${SRB2_CONFIG_HAVE_ZLIB})
endif()
if(${ZLIB_FOUND})
set(SRB2_HAVE_ZLIB ON)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_ZLIB)
add_definitions(-DHAVE_ZLIB)
else()
message(WARNING "You have specified that ZLIB is available but it was not found. SRB2Kart-Saturn may not compile correctly.")
message(WARNING "You have specified that ZLIB is available but it was not found. SRB2Kart may not compile correctly.")
endif()
endif()
@@ -173,292 +464,162 @@ if(${SRB2_CONFIG_HAVE_PNG} AND ${SRB2_CONFIG_HAVE_ZLIB})
endif()
if(${PNG_FOUND})
set(SRB2_HAVE_PNG ON)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_PNG)
target_compile_definitions(SRB2SDL2 PRIVATE -D_LARGEFILE64_SOURCE)
add_definitions(-DHAVE_PNG)
add_definitions(-D_LARGEFILE64_SOURCE)
source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS})
else()
message(WARNING "You have specified that PNG is available but it was not found. SRB2Kart-Saturn may not compile correctly.")
message(WARNING "You have specified that PNG is available but it was not found. SRB2Kart may not compile correctly.")
endif()
endif()
endif()
if("${SRB2_CONFIG_HWRENDER}")
target_compile_definitions(SRB2SDL2 PRIVATE -DHWRENDER)
add_subdirectory(hardware)
if("${SRB2_CONFIG_STATIC_OPENGL}")
find_package(OpenGL)
if(${OPENGL_FOUND})
target_compile_definitions(SRB2SDL2 PRIVATE -DSTATIC_OPENGL)
else()
message(WARNING "You have specified static opengl but opengl was not found. Not setting HWRENDER.")
if(${SRB2_CONFIG_HAVE_CURL})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
set(CURL_FOUND ON)
set(CURL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/curl/include)
if(${SRB2_SYSTEM_BITS} EQUAL 64)
set(CURL_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/curl/lib64 -lcurl")
else() # 32-bit
set(CURL_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/curl/lib32 -lcurl")
endif()
else()
find_package(CURL)
endif()
if(${CURL_FOUND})
set(SRB2_HAVE_CURL ON)
add_definitions(-DHAVE_CURL)
else()
message(WARNING "You have specified that CURL is available but it was not found. SRB2Kart may not compile correctly.")
endif()
endif()
# TODO: build this with the game
if(${CMAKE_SYSTEM} MATCHES Windows AND ${CMAKE_C_COMPILER_ID} MATCHES "GNU" AND ${SRB2_SYSTEM_BITS} EQUAL 32)
target_link_libraries(SRB2SDL2 PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/../libs/drmingw/lib/win32/libexchndl.a"
"${CMAKE_CURRENT_SOURCE_DIR}/../libs/drmingw/lib/win32/libmgwhelp.a"
if(${SRB2_CONFIG_LIBBACKTRACE})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
if(${SRB2_SYSTEM_BITS} EQUAL 64)
set(LIBBACKTRACE_FOUND ON)
set(LIBBACKTRACE_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/libbacktrace/include)
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()
# Targets
# If using CCACHE, then force it.
# https://github.com/Cockatrice/Cockatrice/pull/3052/files
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
get_property(RULE_LAUNCH_COMPILE GLOBAL PROPERTY RULE_LAUNCH_COMPILE)
if(RULE_LAUNCH_COMPILE)
MESSAGE(STATUS "Force enabling CCache usage under macOS")
# Set up wrapper scripts
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/launch-c.in ${CMAKE_BINARY_DIR}/launch-c)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/launch-cxx.in ${CMAKE_BINARY_DIR}/launch-cxx)
execute_process(COMMAND chmod a+rx
"${CMAKE_BINARY_DIR}/launch-c"
"${CMAKE_BINARY_DIR}/launch-cxx")
# Set Xcode project attributes to route compilation through our scripts
set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/launch-c")
set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/launch-cxx")
set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR}/launch-c")
set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR}/launch-cxx")
endif()
endif()
# Compatibility flag with later versions of GCC
# We should really fix our code to not need this
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|x64|amd64|AMD64|em64t|EM64T)")
target_compile_options(SRB2SDL2 PRIVATE -mno-ms-bitfields)
add_compile_options(-mno-ms-bitfields)
endif()
target_compile_options(SRB2SDL2 PRIVATE -Wno-trigraphs)
add_compile_options(-Wno-trigraphs)
endif()
# TODO: fix prng and P_CreateBlockmap overflow at some point
target_compile_options(SRB2SDL2 PRIVATE -fwrapv)
add_compile_options(-fwrapv)
if (${CMAKE_BUILD_TYPE} MATCHES Debug)
target_compile_options(SRB2SDL2 PRIVATE -O0)
target_compile_options(SRB2SDL2 PRIVATE -g)
add_compile_options(-O0)
else()
target_compile_options(SRB2SDL2 PRIVATE -O3)
target_compile_options(SRB2SDL2 PRIVATE -g1) #should be enough for libbacktrace
add_compile_options(-O3)
endif()
# Compiler warnings configuration
target_compile_options(SRB2SDL2 PRIVATE
# Using generator expressions to handle per-language compile options
add_compile_options(-g)
# 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_definitions(-DCMAKECONFIG)
$<$<VERSION_LESS:$<C_COMPILER_VERSION>,2.9.5>:
-Wno-div-by-zero
-Wendif-labels
-Wdisabled-optimization
>
#add_library(SRB2Core STATIC
# ${SRB2_CORE_SOURCES}
# ${SRB2_CORE_HEADERS}
# ${SRB2_CORE_RENDER_SOURCES}
# ${SRB2_CORE_GAME_SOURCES}
# ${SRB2_LUA_SOURCES}
# ${SRB2_LUA_HEADERS}
# ${SRB2_BLUA_SOURCES}
# ${SRB2_BLUA_HEADERS}
#)
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.0.0>:
-Wold-style-definition
-Wmissing-field-initializers
>
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.1.0>:
-Wshadow
>
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.3.0>:
-funit-at-a-time
-Wlogical-op
>
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.5.0>:
-Wlogical-op
-Wno-error=array-bounds
>
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.6.0>:
-Wno-suggest-attribute=noreturn
-Wno-error=suggest-attribute=noreturn
>
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,5.4.0>:
-Wno-logical-op
-Wno-error=logical-op
>
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,6.1.0>:
-Wno-tautological-compare
-Wno-error=tautological-compare
>
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,7.1.0>:
-Wno-error=format-overflow=2
-Wimplicit-fallthrough=4
>
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,8.1.0>:
-Wno-error=format-overflow
-Wno-error=stringop-truncation
-Wno-error=stringop-overflow
-Wno-format-overflow
-Wno-stringop-truncation
-Wno-stringop-overflow
-Wno-error=multistatement-macros
>
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,9.1.0>:
-Wno-error=address-of-packed-member
>
>
# C, Clang and Apple Clang
$<$<AND:$<COMPILE_LANGUAGE:C>,$<OR:$<C_COMPILER_ID:AppleClang>,$<C_COMPILER_ID:Clang>>>:
-Wall
-Wextra
-Wno-absolute-value
-Wno-trigraphs
-Wno-error=non-literal-null-conversion
-Wno-error=constant-conversion
-Wno-unused-but-set-variable
-Wno-error=unused-but-set-variable
>
# C++, GNU, Clang and Apple Clang
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<OR:$<C_COMPILER_ID:GNU>,$<C_COMPILER_ID:AppleClang>,$<C_COMPILER_ID:Clang>>>:
-Wall
-Wno-unused-function
-Wno-unused-but-set-variable
-Wno-unused-private-field
>
# GNU
$<$<C_COMPILER_ID:GNU>:
-fmax-errors=5
>
)
if(SRB2_CONFIG_ERRORMODE)
target_compile_options(SRB2SDL2 PRIVATE
$<$<OR:$<C_COMPILER_ID:GNU>,$<C_COMPILER_ID:AppleClang>,$<C_COMPILER_ID:Clang>>:
-Werror
>
)
if(${SRB2_CONFIG_DEDICATED})
add_subdirectory(dedicated)
else()
add_subdirectory(sdl)
endif()
# Link warnings configuration
target_link_options(SRB2SDL2 PRIVATE
$<$<C_COMPILER_ID:GNU>:
# -Wl,--as-needed - Was controlled by NOLDWARNING
>
)
if(${SRB2_CONFIG_DEV_BUILD})
target_compile_definitions(SRB2SDL2 PRIVATE -DDEVELOP)
endif()
target_compile_definitions(SRB2SDL2 PRIVATE -DCMAKECONFIG)
# Misc. build options from Makefiles
if(SRB2_CONFIG_DEBUGMODE)
target_compile_definitions(SRB2SDL2 PRIVATE -D_DEBUG -DZDEBUG -DPARANOIA -DRANGECHECK -DPACKETDROP)
endif()
if(SRB2_CONFIG_MOBJCONSISTANCY)
target_compile_definitions(SRB2SDL2 PRIVATE -DMOBJCONSISTANCY)
endif()
if(SRB2_CONFIG_PACKETDROP)
target_compile_definitions(SRB2SDL2 PRIVATE -DPACKETDROP)
endif()
if(SRB2_CONFIG_ZDEBUG)
target_compile_definitions(SRB2SDL2 PRIVATE -DZDEBUG)
endif()
if(SRB2_CONFIG_PROFILEMODE AND "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
target_compile_options(SRB2SDL2 PRIVATE -pg)
target_link_options(SRB2SDL2 PRIVATE -pg)
endif()
if(SRB2_CONFIG_LTO AND NOT SRB2_CONFIG_DEBUGMODE)
set_property(TARGET SRB2SDL2 PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
if(${SRB2_CONFIG_SCREENFBO} AND NOT ${SRB2_CONFIG_STATIC_OPENGL})
target_compile_definitions(SRB2SDL2 PRIVATE -DUSE_FBO_OGL)
endif()
if(${SRB2_CONFIG_SATURNPAK})
target_compile_definitions(SRB2SDL2 PRIVATE -DDOSATURNPAK)
endif()
if(${SRB2_CONFIG_SATURNJOIN})
target_compile_definitions(SRB2SDL2 PRIVATE -DDOSATURNJOIN)
endif()
# strip debug symbols into separate file when using gcc or clang.
# to be consistent with Makefile, don't generate for OS X.
if((CMAKE_COMPILER_IS_GNUCC OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND NOT ("${CMAKE_SYSTEM_NAME}" MATCHES Darwin))
if((${CMAKE_BUILD_TYPE} MATCHES Debug) OR (${CMAKE_BUILD_TYPE} MATCHES RelWithDebInfo))
if(${CMAKE_BUILD_TYPE} MATCHES Debug)
set(OBJCOPY_ONLY_KEEP_DEBUG "--only-keep-debug")
endif()
message(STATUS "Will make separate debug symbols in *.debug")
add_custom_command(TARGET SRB2SDL2 POST_BUILD
COMMAND ${CMAKE_OBJCOPY} ${OBJCOPY_ONLY_KEEP_DEBUG} $<TARGET_FILE:SRB2SDL2> $<TARGET_FILE:SRB2SDL2>.debug
# mold linker: .gnu_debuglink is present by default, so --add-gnu-debuglink would fail
COMMAND ${CMAKE_OBJCOPY} --strip-debug --remove-section=.gnu_debuglink $<TARGET_FILE:SRB2SDL2>
COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=$<TARGET_FILE:SRB2SDL2>.debug $<TARGET_FILE:SRB2SDL2>
)
endif()
endif()
# copy DLLs to bin/ directory if building internal shared on windows
if("${CMAKE_SYSTEM_NAME}" STREQUAL Windows AND NOT "${SRB2_CONFIG_INTERNAL_LIBRARIES}" AND "${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}")
set(ADDITIONAL_DLLS "")
if("${CMAKE_C_COMPILER_ID}" STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# also copy implicitly linked system libraries
get_filename_component(MINGW_BIN_PATH ${CMAKE_CXX_COMPILER} PATH)
if("${CMAKE_C_COMPILER_ID}" STREQUAL GNU)
list(APPEND ADDITIONAL_DLLS
"libgcc_s_dw2-1.dll"
"libstdc++-6.dll"
"libwinpthread-1.dll"
)
else()
list(APPEND ADDITIONAL_DLLS
"libunwind.dll"
"libc++.dll"
"libwinpthread-1.dll"
)
endif()
list(TRANSFORM ADDITIONAL_DLLS PREPEND "${MINGW_BIN_PATH}/")
endif()
add_custom_command(TARGET SRB2SDL2 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_RUNTIME_DLLS:SRB2SDL2>
${ADDITIONAL_DLLS}
$<TARGET_FILE_DIR:SRB2SDL2>
COMMAND_EXPAND_LISTS
COMMENT "Copying runtime DLLs"
)
if(NOT ${SRB2_SDL2_AVAILABLE} AND NOT ${SRB2_WIN32_AVAILABLE})
message(FATAL_ERROR "There are no targets available to build an SRB2Kart executable. :(")
endif()
-5
View File
@@ -8,11 +8,6 @@ ifdef MINGW
libs+=-mconsole
endif
ifndef NOTHREADS
opts+=-DHAVE_THREADS
sources+=dedicated/i_threads.c
endif
NOOPENMPT=1
NOLIBGME=1
NOHW=1
+3 -3
View File
@@ -64,9 +64,9 @@ endif
# This must have high to low order.
gcc_versions:=\
151 150 15\
152 151 150 15\
142 141 140 14\
132 131 130 13\
133 132 131 130 13\
123 122 121 120 12\
114 113 112 111 110 11\
105 104 103 102 101 100 10\
@@ -77,7 +77,7 @@ gcc_versions:=\
55 54 53 52 51 50\
49 48 47 46 45 44 43 42 41 40
latest_gcc_version:=15.1.1
latest_gcc_version:=15.2
# Automatically set version flag, but not if one was
# manually set. And don't bother if this is a clean only
+5
View File
@@ -27,6 +27,11 @@ endif
sources+=$(call List,hardware/Sourcefile)
endif
ifndef NOTHREADS
opts+=-DHAVE_THREADS
sources+=i_threads.c
endif
ifndef NOMD5
sources+=md5.c
endif
-5
View File
@@ -40,11 +40,6 @@ sources+=sdl/mixer_sound.c
endif
endif
ifndef NOTHREADS
opts+=-DHAVE_THREADS
sources+=sdl/i_threads.c
endif
ifdef SDL_PKGCONFIG
$(eval $(call Use_pkg_config,SDL))
else
+4 -1
View File
@@ -20,7 +20,10 @@ $(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\
CXXFLAGS+= -Wno-aggregate-return
# -W -Wno-unused
WFLAGS:=-Wall -Wno-trigraphs
WFLAGS:=-Wall -Wno-trigraphs -Wnull-dereference
ifdef GCC152
WFLAGS+=-Wzero-as-null-pointer-constant
endif
ifndef GCC295
#WFLAGS+=-Wno-packed
endif
-4
View File
@@ -226,10 +226,6 @@ const char *I_LocateWad(void)
return "/sdcard/srb2";
}
void I_GetJoystickEvents(void){}
void I_GetJoystick2Events(void){}
char *I_GetEnv(const char *name)
{
LOGW("I_GetEnv() called?!");
-1
View File
@@ -1 +0,0 @@
target_sourcefile(c)
+1 -1
View File
@@ -527,7 +527,7 @@ static int str_find_aux (lua_State *L, int find) {
if (find) {
lua_pushinteger(L, s1-s+1); /* start */
lua_pushinteger(L, res-s); /* end */
return push_captures(&ms, NULL, 0) + 2;
return push_captures(&ms, NULL, NULL) + 2;
}
else
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>
#if defined(__GNUC__)
#define l_likely(x) (__builtin_expect(((x) != 0), 1))
#define l_unlikely(x) (__builtin_expect(((x) != 0), 0))
#define l_likely(x) (__builtin_expect(!!(x), 1))
#define l_unlikely(x) (__builtin_expect(!!(x), 0))
#else
#define l_likely(x) (x)
#define l_likely(x) (x)
#define l_unlikely(x) (x)
#endif
+3 -3
View File
@@ -44,14 +44,14 @@
#define MAXHUDLINES 20
#ifdef HAVE_THREADS
I_mutex con_mutex;
I_Mutex con_mutex;
// g_in_exiting_signal_handler is an evil hack
// to avoid infinite SIGABRT recursion in the signal handler
// due to poisoned locks or mach-o kernel not supporting locks in signals
// or something like that. idk
# define Lock_state() if (!g_in_exiting_signal_handler) { I_lock_mutex(&con_mutex); }
# define Unlock_state() if (!g_in_exiting_signal_handler) { I_unlock_mutex(con_mutex); }
# define Lock_state() if (!g_in_exiting_signal_handler) { I_LockMutex(&con_mutex); }
# define Unlock_state() if (!g_in_exiting_signal_handler) { I_UnlockMutex(con_mutex); }
#else/*HAVE_THREADS*/
# define Lock_state()
# define Unlock_state()
+1 -1
View File
@@ -22,7 +22,7 @@ void CON_Init(void);
boolean CON_Responder(event_t *ev);
#ifdef HAVE_THREADS
extern I_mutex con_mutex;
extern I_Mutex con_mutex;
#endif
// set true when screen size has changed, to adapt console
+49 -41
View File
@@ -332,7 +332,7 @@ void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(const UINT8 **p, INT32 playernu
#ifdef PARANOIA
if (id >= MAXNETXCMD)
I_Error("Command id %d too big", id);
if (listnetxcmd[id] != 0)
if (listnetxcmd[id] != NULL)
I_Error("Command id %d already used", id);
#endif
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));
if (buf == NULL)
{
textcmdbuf[playerid] = Z_Malloc(sizeof(textcmdbuf_t), PU_STATIC, NULL);
textcmdbuf[playerid] = (textcmdbuf_t*)Z_Malloc(sizeof(textcmdbuf_t), PU_STATIC, NULL);
textcmdbuf[playerid]->cmd[0] = 0;
textcmdbuf[playerid]->next = NULL;
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)
{
buf->next = Z_Malloc(sizeof(textcmdbuf_t), PU_STATIC, NULL);
buf->next = (textcmdbuf_t*)Z_Malloc(sizeof(textcmdbuf_t), PU_STATIC, NULL);
buf->next->cmd[0] = 0;
buf->next->next = NULL;
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 (!textcmdtic)
{
textcmdtic = *tctprev = Z_Calloc(sizeof (textcmdtic_t), PU_STATIC, NULL);
textcmdtic = *tctprev = (textcmdtic_t*)Z_Calloc(sizeof (textcmdtic_t), PU_STATIC, NULL);
textcmdtic->tic = tic;
}
// If we don't have an entry for the player, make it.
if (!textcmdtic->playercmds[playernum])
textcmdtic->playercmds[playernum] = Z_Calloc(MAXTEXTCMD, PU_STATIC, NULL);
textcmdtic->playercmds[playernum] = (UINT8*)Z_Calloc(MAXTEXTCMD, PU_STATIC, NULL);
return textcmdtic->playercmds[playernum];
}
@@ -1141,7 +1141,7 @@ typedef enum
static void GetPackets(void);
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
@@ -1182,7 +1182,7 @@ static void CV_LoadPlayerNames(UINT8 **p)
//
// Keep the local client informed of our status.
//
static inline void CL_DrawConnectionStatus(void)
static void CL_DrawConnectionStatus(void)
{
INT32 ccstime = I_GetTime();
@@ -1217,24 +1217,26 @@ static inline void CL_DrawConnectionStatus(void)
case CL_DOWNLOADSAVEGAME:
if (filedownload.current != -1)
{
UINT32 currentsize = fileneeded[filedownload.current].currentsize;
UINT32 totalsize = fileneeded[filedownload.current].totalsize;
INT32 dldlength;
INT32 dldlength = 0;
fileneeded_t *file = &fileneeded[filedownload.current];
UINT32 currentsize = file->currentsize;
UINT32 totalsize = file->totalsize;
cltext = M_GetText("Downloading game state...");
Net_GetNetStat();
dldlength = (INT32)((currentsize/(double)totalsize) * 256);
if (totalsize != 0)
dldlength = (INT32)((currentsize/(double)totalsize) * 256);
if (dldlength > 256)
dldlength = 256;
V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 111);
V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, dldlength, 8, 96);
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,
va("%3.1fK/s ", ((double)getbps)/1024));
va("%3.1fK/s ", ((double)getbps)/1024.0));
}
else
cltext = M_GetText("Waiting to download game state...");
@@ -1270,29 +1272,30 @@ static inline void CL_DrawConnectionStatus(void)
{
if (cl_mode == CL_CHECKFILES)
{
INT32 totalfileslength;
INT32 totalfileslength = 0;
INT32 checkednum = 0;
INT32 i;
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++)
if (fileneeded[i].status != FS_NOTCHECKED)
checkednum++;
// Loading progress
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP|MENUCAPS, "Checking server addons...");
totalfileslength = (INT32)((checkednum/(double)(fileneedednum)) * 256);
if (fileneedednum != 0)
totalfileslength = (INT32)((checkednum/(double)fileneedednum) * 256);
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, totalfileslength, 8, 160);
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)
{
INT32 totalfileslength;
INT32 totalfileslength = 0;
INT32 loadcompletednum = 0;
INT32 i;
@@ -1305,12 +1308,13 @@ static inline void CL_DrawConnectionStatus(void)
// Loading progress
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP|MENUCAPS, "Loading server addons...");
totalfileslength = (INT32)((loadcompletednum/(double)(fileneedednum)) * 256);
if (fileneedednum != 0)
totalfileslength = (INT32)((loadcompletednum/(double)fileneedednum) * 256);
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, totalfileslength, 8, 160);
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)
{
@@ -1438,19 +1442,22 @@ static inline void CL_DrawConnectionStatus(void)
}
else if (filedownload.current != -1)
{
INT32 dldlength;
INT32 totalfileslength;
UINT32 totaldldsize;
INT32 dldlength = 0;
INT32 totalfileslength = 0;
UINT32 totaldldsize = 0;
static char tempname[28];
fileneeded_t *file = &fileneeded[filedownload.current];
char *filename = file->filename;
UINT32 currentsize = file->currentsize;
UINT32 totalsize = file->totalsize;
// Draw the bottom box.
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");
Net_GetNetStat();
dldlength = (INT32)((file->currentsize/(double)file->totalsize) * 256);
if (totalsize != 0)
dldlength = (INT32)((currentsize/(double)totalsize) * 256);
if (dldlength > 256)
dldlength = 256;
V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, 256, 8, 175);
@@ -1483,29 +1490,30 @@ static inline void CL_DrawConnectionStatus(void)
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-22, V_YELLOWMAP|MENUCAPS,
va(M_GetText("\"%s\""), tempname));
V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, V_20TRANS|V_MONOSPACE|MENUCAPS,
va(" %4uK/%4uK",file->currentsize>>10,file->totalsize>>10));
va(" %4uK/%4uK", currentsize>>10, totalsize>>10));
V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-58, V_20TRANS|V_MONOSPACE|MENUCAPS,
va("%3.1fK/s ", ((double)getbps)/1024));
va("%3.1fK/s ", ((double)getbps)/1024.0));
// Download progress
if (file->currentsize != file->totalsize)
totaldldsize = filedownload.completedsize+file->currentsize; //Add in single file progress download if applicable
if (currentsize != totalsize)
totaldldsize = filedownload.completedsize+currentsize; // Add in single file progress download if applicable
else
totaldldsize = filedownload.completedsize;
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-14, V_YELLOWMAP|MENUCAPS, "Overall Download Progress");
totalfileslength = (INT32)((totaldldsize/(double)filedownload.totalsize) * 256);
if (filedownload.totalsize != 0)
totalfileslength = (INT32)((totaldldsize/(double)filedownload.totalsize) * 256);
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, 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,
va(" %4uM/%4uM",totaldldsize>>20,filedownload.totalsize>>20));
va(" %4uM/%4uM", totaldldsize>>20, filedownload.totalsize>>20));
else
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,
va("%2u/%2u Files ", filedownload.completednum, filedownload.totalnum));
@@ -1955,7 +1963,7 @@ static boolean SV_ResendingSavegameToAnyone(void)
static void SV_SendSaveGame(INT32 node, boolean resending)
{
size_t length, compressedlen;
savebuffer_t save = {0};
savebuffer_t save = {};
UINT8 *compressedsave;
UINT8 *buffertosend;
@@ -2025,7 +2033,7 @@ static consvar_t cv_dumpconsistency = {"dumpconsistency", "Off", CV_NETVAR, CV_O
static void SV_SavedGame(void)
{
size_t length;
savebuffer_t save = {0};
savebuffer_t save = {};
char tmpsave[264];
if (!cv_dumpconsistency.value)
@@ -2065,7 +2073,7 @@ static void SV_SavedGame(void)
static void CL_LoadReceivedSavegame(boolean reloading)
{
savebuffer_t save = {0};
savebuffer_t save = {};
size_t length, decompressedlen;
char tmpsave[264];
@@ -2822,11 +2830,11 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
F_TitleScreenDrawer();
CL_DrawConnectionStatus();
#ifdef HAVE_THREADS
I_lock_mutex(&m_menu_mutex);
I_LockMutex(&m_menu_mutex);
#endif
M_Drawer(); //Needed for drawing messageboxes on the connection screen
#ifdef HAVE_THREADS
I_unlock_mutex(m_menu_mutex);
I_UnlockMutex(m_menu_mutex);
#endif
I_UpdateNoVsync(); // page flip or blit buffer
if (moviemode)
@@ -7179,12 +7187,12 @@ void NetUpdate(void)
{
resptime = nowtime;
#ifdef HAVE_THREADS
I_lock_mutex(&m_menu_mutex);
I_LockMutex(&m_menu_mutex);
#endif
M_Ticker();
refreshdirmenu = 0;
#ifdef HAVE_THREADS
I_unlock_mutex(m_menu_mutex);
I_UnlockMutex(m_menu_mutex);
#endif
CON_Ticker();
}
@@ -7229,7 +7237,7 @@ void CL_ClearRewinds(void)
rewind_t *CL_SaveRewindPoint(size_t demopos)
{
savebuffer_t save = {0};
savebuffer_t save = {};
rewind_t *rewind;
if (rewindhead && rewindhead->leveltime + REWIND_POINT_INTERVAL > leveltime)
@@ -7252,7 +7260,7 @@ rewind_t *CL_SaveRewindPoint(size_t demopos)
rewind_t *CL_RewindToTime(tic_t time)
{
savebuffer_t save = {0};
savebuffer_t save = {};
rewind_t *rewind;
while (rewindhead && rewindhead->leveltime > time)
+17 -15
View File
@@ -223,13 +223,13 @@ void D_ProcessEvents(void)
// Menu input
#ifdef HAVE_THREADS
I_lock_mutex(&m_menu_mutex);
I_LockMutex(&m_menu_mutex);
#endif
{
eaten = M_Responder(ev);
}
#ifdef HAVE_THREADS
I_unlock_mutex(m_menu_mutex);
I_UnlockMutex(m_menu_mutex);
#endif
if (eaten)
@@ -244,13 +244,13 @@ void D_ProcessEvents(void)
// console input
#ifdef HAVE_THREADS
I_lock_mutex(&con_mutex);
I_LockMutex(&con_mutex);
#endif
{
eaten = CON_Responder(ev);
}
#ifdef HAVE_THREADS
I_unlock_mutex(con_mutex);
I_UnlockMutex(con_mutex);
#endif
if (eaten)
@@ -577,11 +577,11 @@ static boolean D_Display(void)
vid.recalc = false;
#ifdef HAVE_THREADS
I_lock_mutex(&m_menu_mutex);
I_LockMutex(&m_menu_mutex);
#endif
M_Drawer(); // menu is drawn even on top of everything...
#ifdef HAVE_THREADS
I_unlock_mutex(m_menu_mutex);
I_UnlockMutex(m_menu_mutex);
#endif
// focus lost moved to M_Drawer
@@ -664,7 +664,7 @@ void D_SRB2Loop(void)
tic_t entertic = 0, oldentertics = 0, realtics = 0, rendertimeout = INFTICS;
double deltatics = 0.0;
double deltasecs = 0.0;
UINT64 precision;
UINT64 precision = 0;
boolean interp = false;
boolean doDisplay = false;
@@ -907,7 +907,9 @@ void D_ClearState(void)
// okay, stop now
// (otherwise the game still thinks we're playing!)
#ifdef HAVE_CURL
CURLAbortFile();
#endif
SV_StopServer();
SV_ResetServer();
@@ -971,6 +973,9 @@ void D_ClearState(void)
//
void D_StartTitle(void)
{
if (dedicated)
I_Error("D_StartTitle is called on dedicated server");
D_ClearState();
multiplayer = netgame = false; // title menu shouldnt be a netgame or multiplayer lmao
F_StartTitleScreen();
@@ -1211,17 +1216,13 @@ static void IdentifyVersion(void)
#endif
char tempsrb2path[256] = ".";
getcwd(tempsrb2path, 256);
if (getcwd(tempsrb2path, 256) == NULL)
strcpy(tempsrb2path, ".");
// get the current directory (possible problem on NT with "." as current dir)
if (!srb2waddir)
{
if (tempsrb2path[0])
srb2waddir = tempsrb2path;
else
{
srb2waddir = ".";
}
srb2waddir = tempsrb2path;
}
#if (1) // reduce the amount of findfile by only using full cwd in this func
@@ -1894,7 +1895,8 @@ void D_SRB2Main(void)
if (M_CheckParm("-warp") && M_IsNextParm())
{
const char *word = M_GetNextParm();
pstartmap = G_FindMapByNameOrCode(word, 0);
pstartmap = G_FindMapByNameOrCode(word, NULL);
if (! pstartmap)
I_Error("Cannot find a map remotely named '%s'\n", word);
else
+2 -2
View File
@@ -59,7 +59,7 @@ static INT16 reboundsize[MAXREBOUND];
static INT32 rebound_head, rebound_tail;
/// \brief max length per packet
INT16 hardware_MAXPACKETLENGTH;
INT16 hardware_MAXPACKETLENGTH = 0;
boolean (*I_NetGet)(void) = NULL;
void (*I_NetSend)(void) = NULL;
@@ -96,7 +96,7 @@ INT32 ticruned = 0, ticmiss = 0;
// globals
INT32 getbps = 0, sendbps = 0;
float lostpercent = 0, duppercent = 0, gamelostpercent = 0;
float lostpercent = 0.0f, duppercent = 0.0f, gamelostpercent = 0.0f;
INT32 packetheaderlength = 0;
boolean Net_GetNetStat(void)
+13 -8
View File
@@ -54,6 +54,9 @@
#include "fastcmp.h"
#include "m_perfstats.h"
#include "r_data.h"
#include "r_skins.h"
#ifdef NETGAME_DEVMODE
#define CV_RESTRICT CV_NETVAR
#else
@@ -249,7 +252,7 @@ consvar_t cv_competitionboxes = {"competitionboxes", "Random", CV_NETVAR|CV_CHEA
#ifdef SEENAMES
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, 0, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_seenames = {"seenames", "Off", CV_SAVE, seenames_cons_t, 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
@@ -458,16 +461,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}};
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, 0, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_pingicon = {"pingicon", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 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, 0, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_pingstyle = {"pingstyle", "New", CV_SAVE, cv_pingstyle_cons_t, 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_luaimmersion = {"luaimmersion", "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_showviewpointtext = {"showviewpointtext", "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};
consvar_t cv_showdownloadprompt = {"showdownloadprompt", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
// Intermission time Tails 04-19-2002
static CV_PossibleValue_t inttime_cons_t[] = {{0, "MIN"}, {3600, "MAX"}, {0, NULL}};
@@ -1006,6 +1009,9 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_gamepadled[i]);
}
CV_RegisterVar(&cv_gamepadledifunfocused);
CV_RegisterVar(&cv_rumbleifunfocused);
CV_RegisterVar(&cv_usemouse);
CV_RegisterVar(&cv_invertmouse);
CV_RegisterVar(&cv_mousexsens);
@@ -2652,7 +2658,6 @@ static void Command_Map_f(void)
return;
}
last_map_cmd = I_GetTime();
size_t first_option;
@@ -2789,7 +2794,7 @@ static void Command_Map_f(void)
// G_TOLFlag handles both multiplayer gametype and ignores it for !multiplayer
else
{
if (!mapheaderinfo[newmapnum-1])
if (mapheaderinfo[newmapnum-1] == NULL)
{
CONS_Alert(CONS_WARNING, M_GetText("Invalid mapheaderinfo for Course %s (%s)\n"), realmapname, G_BuildMapName(newmapnum));
return;
+14 -9
View File
@@ -112,7 +112,7 @@ static fileused_t transferFiles[UINT8_MAX + 1];
INT32 fileneedednum = 0; // Number of files needed to join the server
fileneeded_t fileneeded[MAX_WADFILES] = {}; // List of needed files
#ifdef HAVE_THREADS
static I_mutex downloadmutex;
static I_Mutex downloadmutex;
#endif
char downloaddir[512] = "DOWNLOAD";
@@ -131,6 +131,8 @@ static UINT32 curl_origtotalfilesize;
static char *curl_realname = NULL;
fileneeded_t *curl_curfile = NULL;
HTTP_login *curl_logins = NULL;
static void CURLGetFile(void);
#endif
/** Fills a serverinfo packet with information about wad files loaded.
@@ -1305,6 +1307,7 @@ void CURLPrepareFile(const char* url, int dfilenum)
if (!multi_handle)
{
cc = curl_global_init(CURL_GLOBAL_ALL);
if (cc < 0)
{
I_OutputMsg("libcurl: curl_global_init() returned %d\n", cc);
@@ -1313,6 +1316,7 @@ void CURLPrepareFile(const char* url, int dfilenum)
{
multi_handle = curl_multi_init();
}
if (!multi_handle)
{
I_OutputMsg("libcurl: curl_multi_init() failed\n");
@@ -1423,7 +1427,7 @@ void CURLPrepareFile(const char* url, int dfilenum)
filedownload.http_running = true;
#ifdef HAVE_THREADS
I_spawn_thread("http-download", (I_thread_fn)CURLGetFile, NULL);
(void)!I_SpawnThread("http-download", (I_ThreadFn)CURLGetFile, NULL);
#endif
}
else
@@ -1436,15 +1440,15 @@ void CURLAbortFile(void)
#ifdef HAVE_THREADS
// lock and unlock to wait for the download thread to exit
I_lock_mutex(&downloadmutex);
I_unlock_mutex(downloadmutex);
I_LockMutex(&downloadmutex);
I_UnlockMutex(downloadmutex);
#endif
}
void CURLGetFile(void)
static void CURLGetFile(void)
{
#ifdef HAVE_THREADS
I_lock_mutex(&downloadmutex);
I_LockMutex(&downloadmutex);
#endif
CURLMcode mc; /* return code used by curl_multi_wait() */
CURLcode easyres; /* Return from easy interface */
@@ -1483,7 +1487,8 @@ void CURLGetFile(void)
e = m->easy_handle;
easyres = m->data.result;
char *filename = Z_StrDup(curl_realname);
char *filename = malloc(strlen(curl_realname)+1);
strcpy(filename, curl_realname);
nameonly(filename);
if (easyres != CURLE_OK)
@@ -1521,7 +1526,7 @@ void CURLGetFile(void)
}
}
Z_Free(filename);
free(filename);
curl_curfile->file = NULL;
filedownload.remaining--;
mc = curl_multi_remove_handle(multi_handle, e);
@@ -1544,7 +1549,7 @@ void CURLGetFile(void)
filedownload.http_running = false;
#ifdef HAVE_THREADS
I_unlock_mutex(downloadmutex);
I_UnlockMutex(downloadmutex);
#endif
}
-1
View File
@@ -119,7 +119,6 @@ size_t nameonlylength(const char *s);
#ifdef HAVE_CURL
void CURLPrepareFile(const char* url, int dfilenum);
void CURLAbortFile(void);
void CURLGetFile(void);
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);
#endif
+93 -22
View File
@@ -1,21 +1,75 @@
# Declare dedicated interface sources
target_sourcefile(c)
set(SRB2_DEDICATED_SOURCES
i_system.c
i_main.c
i_video.c
i_sound.c
i_threads.c
dosstr.c
endtxt.c
)
target_sources(SRB2SDL2 PRIVATE)
set(SRB2_DEDICATED_HEADERS
endtxt.h
)
source_group("Interface Code" FILES ${SRB2_DEDICATED_SOURCES} ${SRB2_DEDICATED_HEADERS})
set(SRB2_DEDICATED_TOTAL_SOURCES
${SRB2_CORE_SOURCES}
${SRB2_CORE_HEADERS}
${SRB2_PNG_SOURCES}
${SRB2_PNG_HEADERS}
${SRB2_CORE_RENDER_SOURCES}
${SRB2_CORE_GAME_SOURCES}
${SRB2_LUA_SOURCES}
${SRB2_LUA_HEADERS}
${SRB2_BLUA_SOURCES}
${SRB2_BLUA_HEADERS}
${SRB2_DEDICATED_SOURCES}
${SRB2_DEDICATED_HEADERS}
)
source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS})
source_group("Renderer" FILES ${SRB2_CORE_RENDER_SOURCES})
source_group("Game" FILES ${SRB2_CORE_GAME_SOURCES})
source_group("LUA" FILES ${SRB2_LUA_SOURCES} ${SRB2_LUA_HEADERS})
source_group("LUA\\Interpreter" FILES ${SRB2_BLUA_SOURCES} ${SRB2_BLUA_HEADERS})
if(${CMAKE_SYSTEM} MATCHES Windows)
target_sources(SRB2SDL2 PRIVATE
../win32/win_dbg.c
../win32/Srb2win.rc)
set(SRB2_DEDICATED_TOTAL_SOURCES ${SRB2_DEDICATED_TOTAL_SOURCES}
${CMAKE_SOURCE_DIR}/src/win32/win_dbg.c
${CMAKE_SOURCE_DIR}/src/win32/Srb2win.rc
)
endif()
add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32 ${SRB2_DEDICATED_TOTAL_SOURCES})
if(${CMAKE_SYSTEM} MATCHES Windows)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2legacy)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2kartd)
elseif(${CMAKE_SYSTEM} MATCHES Linux)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME lsrb2dlegacy)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME lsrb2kartd)
else()
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2legacy)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2kartd)
endif()
if(${CMAKE_SYSTEM} MATCHES Darwin)
find_library(CORE_FOUNDATION_LIBRARY "CoreFoundation")
target_link_libraries(SRB2SDL2 PRIVATE
${CORE_FOUNDATION_LIBRARY}
)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
# Configure the app bundle icon and plist properties
target_sources(SRB2SDL2 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/macosx/Srb2mac.icns")
set_target_properties(SRB2SDL2 PROPERTIES
MACOSX_BUNDLE_ICON_FILE "Srb2mac"
MACOSX_BUNDLE_BUNDLE_NAME "Sonic Robo Blast 2"
MACOSX_BUNDLE_BUNDLE_VERSION ${SRB2_VERSION}
RESOURCE "${CMAKE_CURRENT_SOURCE_DIR}/macosx/Srb2mac.icns"
)
endif()
if(${CMAKE_SYSTEM} MATCHES Darwin)
@@ -24,25 +78,27 @@ if(${CMAKE_SYSTEM} MATCHES Darwin)
${CORE_LIB}
${PNG_LIBRARIES}
${ZLIB_LIBRARIES}
${CURL_LIBRARIES}
)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
else()
target_link_libraries(SRB2SDL2 PRIVATE
${PNG_LIBRARIES}
${ZLIB_LIBRARIES}
${CURL_LIBRARIES}
)
if(${CMAKE_SYSTEM} MATCHES Linux)
target_link_libraries(SRB2SDL2 PRIVATE
m
rt
pthread
)
endif()
endif()
#target_link_libraries(SRB2SDL2 PRIVATE SRB2Core)
set_target_properties(SRB2SDL2 PROPERTIES VERSION ${SRB2_VERSION})
if(${SRB2_HAVE_LIBBACKTRACE})
target_link_libraries(SRB2SDL2 PRIVATE ${LIBBACKTRACE_LIBRARIES})
endif()
if(${CMAKE_SYSTEM} MATCHES Windows)
target_link_libraries(SRB2SDL2 PRIVATE
@@ -60,20 +116,35 @@ target_include_directories(SRB2SDL2 PRIVATE
target_compile_definitions(SRB2SDL2 PRIVATE
-DDEDICATED
-DHAVE_THREADS
)
## strip debug symbols into separate file when using gcc
if(CMAKE_COMPILER_IS_GNUCC)
if(${CMAKE_BUILD_TYPE} MATCHES Debug)
message(STATUS "Will make separate debug symbols in *.debug")
add_custom_command(TARGET SRB2SDL2 POST_BUILD
COMMAND ${OBJCOPY} --only-keep-debug $<TARGET_FILE:SRB2SDL2> $<TARGET_FILE:SRB2SDL2>.debug
COMMAND ${OBJCOPY} --strip-debug $<TARGET_FILE:SRB2SDL2>
COMMAND ${OBJCOPY} --add-gnu-debuglink=$<TARGET_FILE_NAME:SRB2SDL2>.debug $<TARGET_FILE:SRB2SDL2>
)
endif()
if(SRB2_CONFIG_LTO AND NOT SRB2_CONFIG_DEBUGMODE)
set_property(TARGET SRB2SDL2 PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
if(SRB2_CONFIG_ASAN)
target_compile_options(SRB2SDL2 PRIVATE -fsanitize=address)
target_link_options(SRB2SDL2 PRIVATE -fsanitize=address)
endif()
if(SRB2_CONFIG_UBSAN)
target_compile_options(SRB2SDL2 PRIVATE -fsanitize=undefined)
target_link_options(SRB2SDL2 PRIVATE -fsanitize=undefined)
endif()
## strip debug symbols into separate file when using gcc
# if(CMAKE_COMPILER_IS_GNUCC)
# if(${CMAKE_BUILD_TYPE} MATCHES Debug)
# message(STATUS "Will make separate debug symbols in *.debug")
# add_custom_command(TARGET SRB2SDL2 POST_BUILD
# COMMAND ${OBJCOPY} --only-keep-debug $<TARGET_FILE:SRB2SDL2> $<TARGET_FILE:SRB2SDL2>.debug
# COMMAND ${OBJCOPY} --strip-debug $<TARGET_FILE:SRB2SDL2>
# COMMAND ${OBJCOPY} --add-gnu-debuglink=$<TARGET_FILE_NAME:SRB2SDL2>.debug $<TARGET_FILE:SRB2SDL2>
# )
# endif()
# endif()
#### Installation ####
if(${CMAKE_SYSTEM} MATCHES Darwin)
install(TARGETS SRB2SDL2
-1
View File
@@ -2,6 +2,5 @@ i_system.c
i_main.c
i_video.c
i_sound.c
i_threads.c
dosstr.c
endtxt.c
+5 -9
View File
@@ -167,6 +167,8 @@ static char returnWadPath[256];
#include "../i_video.h"
#include "../i_sound.h"
#include "../i_system.h"
#include "../i_time.h"
#include "../i_net.h"
#include "../screen.h" //vid.WndParent
#include "../d_net.h"
#include "../g_game.h"
@@ -192,8 +194,6 @@ UINT8 keyboard_started = false;
#ifdef HAVE_TERMIOS
// TERMIOS console code from Quake3: thank you!
boolean stdin_active = true;
typedef struct
{
size_t cursor;
@@ -695,11 +695,7 @@ void I_JoyScale4(void)
*/
void I_ShutdownJoystick(void)
{
}
void I_GetJoystickEvents(UINT8 index)
void I_ShutdownJoystick(UINT8 index)
{
(void)index;
}
@@ -1385,8 +1381,8 @@ INT32 I_StartupSystem(void)
I_Fork();
#endif
#ifdef HAVE_THREADS
I_start_threads();
I_AddExitFunc(I_stop_threads);
I_StartThreads();
I_AddExitFunc(I_StopThreads);
#endif
I_RegisterSignals();
#ifndef NOMUMBLE
+34 -11
View File
@@ -40,24 +40,47 @@
#define ASMCALL
#endif
#define _USE_MATH_DEFINES // fixes M_PI errors in r_plane.c for Visual Studio
#ifdef __cplusplus
#include <cmath>
#else
#include <math.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#include "doomtype.h"
#ifdef __cplusplus /* Only when compiled as C++ */
#include <algorithm> /* std::min, std::max, std::sort, … */
#endif
#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" {
#else
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <limits.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
+5
View File
@@ -223,6 +223,8 @@ typedef int32_t boolean;
#define FUNCNOINLINE __attribute__((noinline))
#define FUNCWARNRV __attribute__((warn_unused_result))
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) // >= GCC 4.4
#ifdef __i386__ // i386 only
#define FUNCTARGET(X) __attribute__ ((__target__ (X)))
@@ -268,6 +270,9 @@ typedef int32_t boolean;
#ifndef FUNCTARGET
#define FUNCTARGET(x)
#endif
#ifndef FUNCWARNRV
#define FUNCWARNRV
#endif
#ifndef ATTRPACK
#define ATTRPACK
#endif
+2 -4
View File
@@ -1172,9 +1172,7 @@ void F_StartWaitingPlayers(void)
randskin = M_RandomKey(numskins);
boolean waithires = skins[randskin].flags && SF_HIRES;
if (waitcolormap)
Z_Free(waitcolormap);
Z_Free(waitcolormap);
waitcolormap = R_GetTranslationColormap(randskin, skins[randskin].prefcolor, 0);
if (waithires)
@@ -1318,7 +1316,7 @@ boolean F_ContinueResponder(event_t *event)
keypressed = true;
imcontinuing = true;
continuetime = TICRATE;
S_StartSound(0, sfx_itemup);
S_StartSound(NULL, sfx_itemup);
return true;
}
+2 -2
View File
@@ -388,11 +388,11 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu)
if (rendermode != render_none && drawMenu)
{
#ifdef HAVE_THREADS
I_lock_mutex(&m_menu_mutex);
I_LockMutex(&m_menu_mutex);
#endif
M_Drawer(); // menu is drawn even on top of wipes
#ifdef HAVE_THREADS
I_unlock_mutex(m_menu_mutex);
I_UnlockMutex(m_menu_mutex);
#endif
}
+11 -10
View File
@@ -49,7 +49,7 @@ size_t menupathindex[menudepth] = {};
size_t menudepthleft = menudepth;
char menusearchbuf[MAXSTRINGLENGTH+1];
textinput_t menusearch;
textinput_t menusearch = {};
char **dirmenu = NULL, **coredirmenu = NULL; // core only local for this file
size_t sizedirmenu = 0, sizecoredirmenu = 0; // ditto
@@ -271,10 +271,13 @@ static boolean filemenucmp(char *haystack, char *needle)
{
static char localhaystack[128];
strlcpy(localhaystack, haystack, 128);
if (!cv_addons_search_case.value)
strupr(localhaystack);
if (cv_addons_search_type.value)
return (strstr(localhaystack, needle) != 0);
return (strstr(localhaystack, needle) != NULL);
return (!strncmp(localhaystack, needle, menusearch.length));
}
@@ -314,8 +317,7 @@ void closefilemenu(boolean validsize)
coredirmenu = NULL;
}
if (refreshdirname)
Z_Free(refreshdirname);
Z_Free(refreshdirname);
refreshdirname = NULL;
}
@@ -343,8 +345,7 @@ void searchfilemenu(char *tempname)
if (!menusearch.length)
{
if (dirmenu)
Z_Free(dirmenu);
Z_Free(dirmenu);
dirmenu = coredirmenu;
sizedirmenu = sizecoredirmenu;
@@ -386,8 +387,8 @@ void searchfilemenu(char *tempname)
I_Error("searchfilemenu(): could not create \"No results...\".");
sizedirmenu = 1;
dir_on[menudepthleft] = 0;
if (tempname)
Z_Free(tempname);
Z_Free(tempname);
return;
}
@@ -502,8 +503,8 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut)
{
closedir(dirhandle);
closefilemenu(false);
if (tempname)
Z_Free(tempname);
Z_Free(tempname);
return false;
}
+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?
static char demoname[128];
savebuffer_t demobuf = {0};
savebuffer_t demobuf = {};
static UINT8 *demotime_p, *demoinfo_p;
static UINT8 *demoend;
static UINT8 demoflags;
+16 -19
View File
@@ -132,7 +132,7 @@ UINT8 skincolor_bluering = SKINCOLOR_STEEL;
tic_t countdowntimer = 0;
boolean countdowntimeup = false;
cutscene_t *cutscenes[128];
cutscene_t *cutscenes[128] = {};
INT16 nextmapoverride = 0;
boolean skipstats = false;
@@ -144,7 +144,7 @@ mobj_t *blueflag = NULL;
mapthing_t *rflagpoint = NULL;
mapthing_t *bflagpoint = NULL;
struct quake quake;
struct quake quake = {};
// Map Header Information
mapheader_t* mapheaderinfo[NUMMAPS] = {};
@@ -228,7 +228,7 @@ tic_t racecountdown = 0, exitcountdown = 0; // for racing
fixed_t gravity = 0;
fixed_t mapobjectscale = FRACUNIT;
struct maplighting maplighting;
struct maplighting maplighting = {};
INT16 autobalance = 0; //for CTF team balance
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}};
consvar_t cv_autoaccel[MAXSPLITSCREENPLAYERS] = {
{"autoaccel", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"autoaccel2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"autoaccel3", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"autoaccel4", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}
{"kartautoaccel", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"kartautoaccel2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"kartautoaccel3", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"kartautoaccel4", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}
};
static CV_PossibleValue_t driftsparkpulse_t[] = {{0, "MIN"}, {FRACUNIT*3, "MAX"}, {0, NULL}};
@@ -523,11 +523,8 @@ void G_ClearRecords(void)
INT16 i;
for (i = 0; i < NUMMAPS; ++i)
{
if (mainrecords[i])
{
Z_Free(mainrecords[i]);
mainrecords[i] = NULL;
}
Z_Free(mainrecords[i]);
mainrecords[i] = NULL;
}
}
@@ -3501,7 +3498,7 @@ void G_LoadGameData(void)
INT32 i, j;
UINT8 modded = false;
UINT8 rtemp;
savebuffer_t save = {0};
savebuffer_t save = {};
//For records
tic_t rectime;
@@ -3634,7 +3631,7 @@ void G_SaveGameData(boolean force)
size_t length;
INT32 i, j;
UINT8 btemp;
savebuffer_t save = {0};
savebuffer_t save = {};
(void)force;
char backupfile[MAX_WADPATH+4];
@@ -3805,7 +3802,7 @@ void G_LoadGame(UINT32 slot, INT16 mapoverride)
size_t length;
char vcheck[VERSIONSIZE];
char savename[255];
savebuffer_t save = {0};
savebuffer_t save = {};
// memset savedata to all 0, fixes calling perfectly valid saves corrupt because of bots
memset(&savedata, 0, sizeof(savedata));
@@ -3891,7 +3888,7 @@ void G_SaveGame(UINT32 savegameslot)
boolean saved;
char savename[256] = "";
const char *backup;
savebuffer_t save = {0};
savebuffer_t save = {};
sprintf(savename, savegamename, savegameslot);
backup = va("%s",savename);
@@ -4161,7 +4158,7 @@ static void measurekeywords(mapsearchfreq_t *fr,
PU_STATIC, NULL);
for (qp = strtok(va("%s", q), " ");
qp && fr->total < 255;
qp = strtok(0, " "))
qp = strtok(NULL, " "))
{
if (( sp = strcasestr(s, qp) ))
{
@@ -4242,7 +4239,7 @@ INT32 G_FindMap(const char *mapname, char **foundmapnamep,
{
newmapnum = mapnum;
newmapname = realmapname;
realmapname = 0;
realmapname = NULL;
Z_Free(apromapname);
if (!wanttable)
break;
@@ -4263,7 +4260,7 @@ INT32 G_FindMap(const char *mapname, char **foundmapnamep,
{
apromapnum = mapnum;
apromapname = realmapname;
realmapname = 0;
realmapname = NULL;
}
}
else/* ...match individual keywords */
+1
View File
@@ -130,6 +130,7 @@ extern consvar_t cv_spinoutroll;
extern consvar_t cv_squishdance, cv_squishdancespeed;
extern consvar_t cv_playerblendeffects;
extern consvar_t cv_reducevfx;
extern consvar_t cv_cechotoggle;
+8 -7
View File
@@ -81,6 +81,9 @@ consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS] = {
{"gamepadled4", "Skincolor", CV_SAVE|CV_CALL|CV_NOINIT, gamepadled_cons_t, led_off_handle4, 0, NULL, NULL, 0, 0, NULL}
};
consvar_t cv_gamepadledifunfocused = {"gamepadledunfocused", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_rumbleifunfocused = {"rumbleifunfocused", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
static void rumble_off_handle(void)
{
if (!cv_rumble[0].value)
@@ -930,7 +933,7 @@ void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT8 color)
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS);
if (cv_gamepadled[playernum].value == 0
if (cv_gamepadled[playernum].value == 0 || (window_notinfocus && cv_gamepadledifunfocused.value == 0)
|| color >= MAXTRANSLATIONS)
{
return;
@@ -945,6 +948,8 @@ void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT8 color)
static void G_ResetPlayerGamepadIndicatorColor(INT32 playernum)
{
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS);
if (cv_gamepadled[playernum].value == 0)
{
I_SetGamepadIndicatorColor(playernum, 0, 0, 255);
@@ -973,13 +978,8 @@ void G_DeviceLEDTick(void)
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
continue;
#pragma GCC diagnostic pop
G_SetPlayerGamepadIndicatorColor(i, newcolor);
curcolor[i] = newcolor;
@@ -994,6 +994,7 @@ void G_ResetDeviceLED(void)
static void G_ResetPlayerDeviceRumble(INT32 playernum)
{
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS);
I_GamepadRumble(playernum, 0, 0, 0);
}
@@ -1011,7 +1012,7 @@ void G_PlayerDeviceRumble(INT32 playernum, UINT16 low_strength, UINT16 high_stre
{
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS);
if (cv_rumble[playernum].value == 0)
if (cv_rumble[playernum].value == 0 || (window_notinfocus && cv_rumbleifunfocused.value == 0))
{
return;
}
+3
View File
@@ -116,6 +116,9 @@ extern consvar_t cv_rumble[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_rumblestrength[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_gamepadledifunfocused;
extern consvar_t cv_rumbleifunfocused;
extern INT32 mousex, mousey;
extern INT32 joyxmove[MAXSPLITSCREENPLAYERS][JOYAXISSET], joyymove[MAXSPLITSCREENPLAYERS][JOYAXISSET];
-1
View File
@@ -1 +0,0 @@
target_sourcefile(c)
+1 -1
View File
@@ -391,7 +391,7 @@ void HWR_RenderBatches(void)
nextSurfaceInfo = nextEntry->surf;
if (nextPolyFlags & PF_NoTexture)
nextTexture = 0;
nextTexture = NULL;
if (useshader && currentShader != nextShader)
{
+2 -5
View File
@@ -619,7 +619,6 @@ static void HWR_PrecacheLevelFlats(void)
// lookup for flats that may´ve been already loaded
// too lazy to make a hashtable or smth so unordered set will do :carbuncle:
std::unordered_set<UINT32> flatpresent;
lumpnum_t lump;
size_t i, j;
INT32 k;
@@ -649,9 +648,8 @@ static void HWR_PrecacheLevelFlats(void)
const INT32 pic = ceiling ? sec->ceilingpic : sec->floorpic;
const levelflat_t *levelflat = &levelflats[pic];
lump = levelflat->lumpnum;
load_flat(lump, R_NoEncore(sec, ceiling));
load_flat(levelflat->lumpnum, R_NoEncore(sec, ceiling));
if (levelflat->speed) // is it an animated flat ?
{
@@ -672,9 +670,8 @@ static void HWR_PrecacheLevelFlats(void)
for (i = 0; i < numlevelflats; i++)
{
const levelflat_t *levelflat = &levelflats[i];
lump = levelflat->lumpnum;
load_flat(lump, false);
load_flat(levelflat->lumpnum, false);
if (levelflat->speed) // is it an animated flat ?
{
+1 -1
View File
@@ -335,7 +335,7 @@ angle_t gld_FrustumAngle(angle_t tiltangle)
floatangle = 2.0 + (45.0 + ((double)tilt / 1.9)) * clipfov / 90.0;
if (floatangle >= 180.0)
return 0xffffffff;
a1 = (angle_t)xs_CRoundToInt(ANG1 * floatangle);
a1 = (angle_t)lrint(ANG1 * floatangle);
return a1;
}
+3
View File
@@ -80,6 +80,9 @@ UINT32 GL_CreateLightTable(RGBA_t *hw_lighttable);
void GL_ClearLightTables(void);
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
} // extern "C"
#endif
+44 -33
View File
@@ -101,7 +101,8 @@ sector_t *gl_backsector = NULL;
static constexpr float clipping_distances[] = {1024.0f, 2048.0f, 4096.0f, 6144.0f, 8192.0f, 12288.0f, 16384.0f};
// values for bsp culling
// slightly higher than the far clipping plane to compensate for impreciseness
static constexpr INT32 bsp_culling_distances[] = {(1024+512)*FRACUNIT, (2048+512)*FRACUNIT, (4096+512)*FRACUNIT,
static constexpr INT32 bsp_culling_distances[] = {
(1024+512)*FRACUNIT, (2048+512)*FRACUNIT, (4096+512)*FRACUNIT,
(6144+512)*FRACUNIT, (8192+512)*FRACUNIT, (12288+512)*FRACUNIT, (16384+512)*FRACUNIT};
// Performance stats
@@ -587,15 +588,11 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
const sector_t *sec = FOFsector ? FOFsector : gl_frontsector;
// Get the slope pointer to simplify future code
if (sec->f_slope && !isceiling)
if (!isceiling && sec->f_slope)
slope = sec->f_slope;
else if (sec->c_slope && isceiling)
else if (isceiling && 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);
// Allocate plane-vertex buffer if we need to
@@ -687,18 +684,19 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
vert->s = (tempxsow * cosangf) - (tempytow * sinangf);\
vert->t = (tempxsow * sinangf) + (tempytow * cosangf);\
}\
\
if (slope)\
{\
fixedheight = P_GetSlopeZAt(slope, FloatToFixed((vx)), FloatToFixed((vy)));\
height = FixedToFloat(fixedheight);\
}\
\
vert->x = (vx);\
vert->y = height;\
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);
if (slope)
@@ -1785,10 +1783,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
// Single sided line... Deal only with the middletexture (if one exists)
if (gl_midtexture && gl_linedef->special != HORIZONSPECIAL) // Ignore horizon line for OGL
{
glTex = HWR_GetTexture(gl_midtexture, noencore);
fixed_t texturevpeg;
glTex = HWR_GetTexture(gl_midtexture, noencore);
// PEGGING
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;
@@ -1875,8 +1873,8 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
//Hurdler: 3d-floors test
if (!gl_drawing_stencil && gl_backsector && gl_frontsector->tag != gl_backsector->tag && (gl_backsector->ffloors || gl_frontsector->ffloors))
{
ffloor_t * rover;
fixed_t highcut = 0, lowcut = 0;
ffloor_t *rover;
fixed_t highcut = 0, lowcut = 0;
fixed_t lowcutslope = 0, highcutslope = 0;
// Used for height comparisons and etc across FOFs and slopes
@@ -2947,7 +2945,7 @@ static void HWR_Subsector(size_t num)
static sector_t tempsec; //SoM: 4/7/2000
INT32 floorlightlevel;
INT32 ceilinglightlevel;
INT32 locFloorHeight, locCeilingHeight;
INT32 locFloorHeight = 0, locCeilingHeight = 0;
INT32 cullFloorHeight, cullCeilingHeight;
INT32 light = 0;
extracolormap_t *floorcolormap;
@@ -2993,11 +2991,12 @@ static void HWR_Subsector(size_t num)
cullFloorHeight = P_GetSectorFloorZAt (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)
{
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;
if (anyMoved == false)
@@ -3052,8 +3051,7 @@ static void HWR_Subsector(size_t num)
{
HWR_GetFlat(levelflats[gl_frontsector->floorpic].lumpnum, R_NoEncore(gl_frontsector, false));
HWR_RenderPlane(sub, &extrasubsectors[num], false,
// Hack to make things continue to work around slopes.
locFloorHeight == cullFloorHeight ? locFloorHeight : gl_frontsector->floorheight,
gl_frontsector->floorheight,
// We now return you to your regularly scheduled rendering.
PF_Occlude, floorlightlevel, levelflats[gl_frontsector->floorpic].lumpnum, NULL, 255, floorcolormap);
}
@@ -3068,8 +3066,7 @@ static void HWR_Subsector(size_t num)
{
HWR_GetFlat(levelflats[gl_frontsector->ceilingpic].lumpnum, R_NoEncore(gl_frontsector, true));
HWR_RenderPlane(sub, &extrasubsectors[num], true,
// Hack to make things continue to work around slopes.
locCeilingHeight == cullCeilingHeight ? locCeilingHeight : gl_frontsector->ceilingheight,
gl_frontsector->ceilingheight,
// We now return you to your regularly scheduled rendering.
PF_Occlude, ceilinglightlevel, levelflats[gl_frontsector->ceilingpic].lumpnum, NULL, 255, ceilingcolormap);
}
@@ -3786,8 +3783,15 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite)
blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude;
}
if (cv_playerfade.value && sprmo->player)
Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha);
if (sprmo->player)
{
// 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())
{
@@ -4076,8 +4080,15 @@ static void HWR_DrawSprite(gl_vissprite_t *spr)
blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude;
}
if (cv_playerfade.value && sprmo->player)
Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha);
if (sprmo->player)
{
// 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())
{
@@ -5433,7 +5444,7 @@ static void HWR_SetTransformAiming(FTransform *trans)
fixed_t fixedaiming = AIMINGTODY(aimingangle);
trans->viewaiming = FixedToFloat(fixedaiming) * (static_cast<float>(vid.width) / static_cast<float>(vid.height)) / (static_cast<float>(BASEVIDWIDTH) / static_cast<float>(BASEVIDHEIGHT));
if (splitscreen == 1) // only for 2 player splitscreen
trans->viewaiming *= 2.125; // splitscreen adjusts fov with 0.8, so compensate (but only halfway, since splitscreen means only half the screen is used)
trans->viewaiming *= 2.125f; // splitscreen adjusts fov with 0.8, so compensate (but only halfway, since splitscreen means only half the screen is used)
trans->shearing = true;
gl_aimingangle = 0;
}
@@ -5538,7 +5549,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool
player_t *viewplayer = &players[displayplayers[viewssnum]];
const float fpov = FixedToFloat(R_GetPlayerFov(viewplayer));
auto reset_viewstate = [&](const float fpov)
auto reset_viewstate = [&]()
{
HWR_SetTransform(fpov);
HWR_ClearSprites();
@@ -5558,7 +5569,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool
currentportallist = &portallist;
HWR_SetPortalState(GLPORTAL_SEARCH);
reset_viewstate(fpov);
reset_viewstate();
if (rootportal)
{
@@ -5584,7 +5595,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool
// draw normal things in current frame in current incremented stencil buffer area
HWR_SetStencilState(HWR_STENCIL_NORMAL, stencil_level);
reset_viewstate(fpov);
reset_viewstate();
if constexpr (Type == RenderViewpointType::kPortal)
{
@@ -6100,7 +6111,7 @@ static void HWR_DoPostProcessor(void)
const camera_t *thiscam = &camera[0];
// Not supported in splitscreen - someone want to add support?
const boolean screenwave = (!splitscreen && (thiscam->postimg & POSTIMG_WATER || thiscam->postimg & POSTIMG_HEAT));
const boolean screenwave = (!splitscreen && !cv_reducevfx.value && (thiscam->postimg & POSTIMG_WATER || thiscam->postimg & POSTIMG_HEAT));
// Capture the screen for intermission and screen waving
if ((lastdraw || screenwave) && gamestate != GS_INTERMISSION)
+122 -3
View File
@@ -579,7 +579,7 @@ md2found:
fclose(f);
}
void HWR_AddPlayerMD2(int skin, boolean local) // For MD2's that were added after startup
void HWR_AddPlayerMD2(INT32 skin, boolean local) // For MD2's that were added after startup
{
FILE *f;
char name[20], filename[32];
@@ -1198,8 +1198,15 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
Surf.PolyFlags = HWR_GetBlendModeFlag(blendmode);
}
if (cv_playerfade.value && spr->mobj->player)
Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(spr->mobj), Surf.PolyColor.s.alpha);
if (spr->mobj->player)
{
// 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
// before: polygons models are not sorted
@@ -1468,4 +1475,116 @@ 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
+3
View File
@@ -45,6 +45,9 @@ void HWR_InitMD2(void);
void HWR_DrawMD2(gl_vissprite_t *spr);
void HWR_AddPlayerMD2(INT32 skin, boolean local);
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
} // extern "C"
+14 -14
View File
@@ -274,7 +274,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
if (!f)
return NULL;
retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, 0);
retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, NULL);
//size_t fileLen;
@@ -288,13 +288,13 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
{
texPos++;
namelen = strlen(texPos) + 1;
texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, 0);
texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, NULL);
strcpy(texturefilename, texPos);
}
else
{
namelen = strlen(fileName) + 1;
texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, 0);
texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, NULL);
strcpy(texturefilename, fileName);
}
@@ -316,7 +316,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
header = (md2header_t*)buffer;
retModel->numMeshes = 1; // MD2 only has one mesh
retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * retModel->numMeshes, ztag, 0);
retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * retModel->numMeshes, ztag, NULL);
retModel->meshes[0].numFrames = header->numFrames;
// const float WUNITS = 1.0f;
// 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
retModel->numMaterials = 1;
retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, 0);
retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, NULL);
// int 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;
dataScale = 0.015624f; // 1 / 64.0f
retModel->meshes[0].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*header->numFrames, ztag, 0);
retModel->meshes[0].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*header->numFrames, ztag, NULL);
retModel->meshes[0].numVertices = header->numXYZ;
retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, 0);
retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, NULL);
ptr = (char*)frames;
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;
md2frame_t *framePtr = (md2frame_t*)ptr;
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, 0);
retModel->meshes[0].tinyframes[i].vertices = (short*)Z_Malloc(sizeof(short) * 3 * header->numXYZ, ztag, NULL);
retModel->meshes[0].tinyframes[i].normals = (char*)Z_Malloc(sizeof(char) * 3 * header->numXYZ, ztag, NULL);
// 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].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * header->numTris, ztag, 0);
retModel->meshes[0].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * header->numTris, ztag, NULL);
vertptr = retModel->meshes[0].tinyframes[i].vertices;
normptr = retModel->meshes[0].tinyframes[i].normals;
@@ -484,8 +484,8 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
char *ptr;
retModel->meshes[0].numVertices = header->numTris * 3;
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, 0);
retModel->meshes[0].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*header->numFrames, ztag, NULL);
retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, NULL);
trisPtr = tris;
uvptr = retModel->meshes[0].uvs;
@@ -507,8 +507,8 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
md2vertex_t *vertex;
md2frame_t *framePtr = (md2frame_t*)ptr;
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, 0);
retModel->meshes[0].frames[i].normals = (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, NULL);
// 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);
//float *vertptr, *normptr;
+12 -12
View File
@@ -168,7 +168,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat)
if (!f)
return NULL;
retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, 0);
retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, NULL);
// find length of file
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
retModel->numMaterials = 1;
retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, 0);
retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, NULL);
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->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t)*retModel->numMeshes, ztag, 0);
retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t)*retModel->numMeshes, ztag, NULL);
matCount = 0;
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;
md3Triangle *mdT;
retModel->meshes[i].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*mdS->numFrames, ztag, 0);
retModel->meshes[i].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*mdS->numFrames, ztag, NULL);
retModel->meshes[i].numVertices = mdS->numVerts;
retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numVerts, ztag, 0);
retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numVerts, ztag, NULL);
for (j = 0; j < mdS->numFrames; j++)
{
short *vertptr;
@@ -308,12 +308,12 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat)
// char *tanptr;
int k;
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, 0);
retModel->meshes[i].tinyframes[j].normals = (char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag, 0);
retModel->meshes[i].tinyframes[j].vertices = (short*)Z_Malloc(sizeof(short)*3*mdS->numVerts, ztag, NULL);
retModel->meshes[i].tinyframes[j].normals = (char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag, NULL);
// 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].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * mdS->numTriangles, ztag, 0);
retModel->meshes[i].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * mdS->numTriangles, ztag, NULL);
vertptr = retModel->meshes[i].tinyframes[j].vertices;
normptr = retModel->meshes[i].tinyframes[j].normals;
@@ -374,16 +374,16 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat)
int k;
retModel->meshes[i].numVertices = mdS->numTriangles * 3;//mdS->numVerts;
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, 0);
retModel->meshes[i].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*mdS->numFrames, ztag, NULL);
retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numTriangles*3, ztag, NULL);
for (j = 0; j < mdS->numFrames; j++)
{
float *vertptr;
float *normptr;
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, 0);
retModel->meshes[i].frames[j].normals = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, 0);
retModel->meshes[i].frames[j].vertices = (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, NULL);
// 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);
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;
}
model->mdlFilename = (char*)Z_Malloc(strlen(filename)+1, ztag, 0);
model->mdlFilename = (char*)Z_Malloc(strlen(filename)+1, ztag, NULL);
strcpy(model->mdlFilename, filename);
Optimize(model);
@@ -237,7 +237,7 @@ void GenerateVertexNormals(model_t *model)
{
mdlframe_t *frame = &mesh->frames[j];
int memTag = PU_STATIC;
float *newNormals = (float*)Z_Malloc(sizeof(float)*3*mesh->numTriangles*3, memTag, 0);
float *newNormals = (float*)Z_Malloc(sizeof(float)*3*mesh->numTriangles*3, memTag, NULL);
int k;
float *vertPtr = frame->vertices;
float *oldNormals;
@@ -309,7 +309,7 @@ static boolean AddMaterialToList(materiallist_t **head, material_t *material)
}
// Didn't find it, so add to the list
newMatNode = (materiallist_t*)Z_Malloc(sizeof(materiallist_t), PU_CACHE, 0);
newMatNode = (materiallist_t*)Z_Malloc(sizeof(materiallist_t), PU_CACHE, NULL);
newMatNode->material = material;
ListAdd(newMatNode, (listitem_t**)head);
return true;
@@ -351,7 +351,7 @@ void Optimize(model_t *model)
}
memTag = PU_STATIC;
newMeshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * numMeshes, memTag, 0);
newMeshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * numMeshes, memTag, NULL);
i = 0;
for (node = matListHead; node; node = node->next)
@@ -377,14 +377,14 @@ void Optimize(model_t *model)
newMesh->numFrames = 1;
newMesh->numTriangles = numTriangles;
newMesh->numVertices = numTriangles * 3;
newMesh->uvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, 0);
newMesh->frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t), memTag, 0);
newMesh->uvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, NULL);
newMesh->frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t), memTag, NULL);
curFrame = &newMesh->frames[0];
curFrame->material = curMat;
curFrame->normals = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0);
curFrame->vertices = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0);
curFrame->colors = (char*)Z_Malloc(sizeof(char)*4*numTriangles*3, memTag, 0);
curFrame->normals = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, NULL);
curFrame->vertices = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, NULL);
curFrame->colors = (char*)Z_Malloc(sizeof(char)*4*numTriangles*3, memTag, NULL);
// Now traverse the meshes of the model, adding in
// vertices/normals/uvs that match the current material
+76 -23
View File
@@ -98,10 +98,10 @@ static size_t textureBufferSize = 0;
static LTListItem *LightTablesTail = NULL;
static LTListItem *LightTablesHead = NULL;
static RGBA_t screenPalette[256] = {0}; // the palette for the postprocessing step in palette rendering
static RGBA_t screenPalette[256] = {}; // the palette for the postprocessing step in palette rendering
static GLuint screenPaletteTex = 0; // 1D texture containing the screen palette
static GLuint paletteLookupTex = 0; // 3D texture containing RGB -> palette index lookup table
RGBA_t myPaletteData[256] = {0}; // the palette for converting textures to RGBA
RGBA_t myPaletteData[256] = {}; // the palette for converting textures to RGBA
static GLint gltexformat = GL_RGB5_A1;
GLint screen_width = 0; // used by Draw2DLine()
@@ -127,9 +127,9 @@ GLuint gl_num_extensions;
int majorGL = 0, minorGL = 0;
//Hurdler: 04/10/2000: added for the kick ass coronas as Boris wanted;-)
GLfloat modelMatrix[16] = {0};
GLfloat projMatrix[16] = {0};
static GLint viewport[4];
GLfloat modelMatrix[16] = {};
GLfloat projMatrix[16] = {};
static GLint viewport[4];
#ifdef USE_FBO_OGL
enum
@@ -171,7 +171,7 @@ boolean supportstencil = false;
// 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
// can know when the textures aren't there, as textures are always considered resident in their virtual memory
static GLuint screenTextures[NUMSCREENTEXTURES] = {0};
static GLuint screenTextures[NUMSCREENTEXTURES] = {};
#define byte2float(byte) (GLfloat)(byte / 255.0f)
@@ -404,6 +404,14 @@ static PFNglEnableClientState pglEnableClientState;
typedef void (APIENTRY * PFNglDisableClientState) (GLenum cap);
static PFNglDisableClientState pglDisableClientState;
typedef void (APIENTRY * PFNglOrtho) (GLdouble left,
GLdouble right,
GLdouble bottom,
GLdouble top,
GLdouble nearVal,
GLdouble farVal);
static PFNglOrtho pglOrtho;
/* Lighting */
typedef void (APIENTRY * PFNglShadeModel) (GLenum mode);
static PFNglShadeModel pglShadeModel;
@@ -745,7 +753,7 @@ typedef struct gl_shaderstate_s
static gl_shaderstate_t gl_shaderstate;
// Shader info
static float shader_leveltime = 0;
static float shader_leveltime = 0.0f;
static float shader_light_x = 0.0f;
static float shader_light_y = 0.0f;
static float shader_light_z = 0.0f;
@@ -858,6 +866,8 @@ void SetupGLFunc4(void)
GetGLfunc(glUniform3fv);
GetGLfunc(glGetUniformLocation);
GetGLfunc(glOrtho);
#ifdef GLDEBUGMESSAGE
GetGLfunc(glDebugMessageCallback);
#endif
@@ -3090,6 +3100,39 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics
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 :
// -----------------+
@@ -3548,22 +3591,30 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8
1.0f, -1.0f, 1.0f
};
xfix = 1/((float)screen_texsizew/(float)screen_width);
yfix = 1/((float)screen_texsizeh/(float)screen_height);
const GLfloat scrwf = (float)screen_width;
const GLfloat scrwh = (float)screen_height;
xfix = 1/((float)screen_texsizew/scrwf);
yfix = 1/((float)screen_texsizeh/scrwh);
GL_SetBlend(PF_Modulated|PF_Translucent|PF_NoDepthTest);
// Slight fuzziness
GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
GL_SetBlend(PF_Modulated|PF_Translucent|PF_NoDepthTest);
pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
const float stride = 2.f/scrwh;
uint32_t r = rand();
for (i = 0; i < 1; i += stride)
const float ystep = 2.f/scrwh * (float)vid.udup/4.f;
for (i = 0; i < 1; i += ystep)
{
fix[2] = (float)(rand() % 128) / -22000.f * xfix;
// avoid calling rand thousands of times
r ^= r >> 13;
r ^= r >> 11;
r ^= r << 21;
fix[2] = (float)(r & 127) / -22000.f * xfix;
fix[0] = fix[2];
fix[6] = fix[0] + xfix;
fix[4] = fix[2] + xfix;
@@ -3581,8 +3632,8 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8
}
// Upward bar
//GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
//pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
color[0] = color[1] = color[2] = 190;
color[3] = 250;
@@ -3605,13 +3656,14 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8
fix[1] = fix[7] += (fix[3] - fix[7])*2;
screenVerts[1] = screenVerts[10] += (screenVerts[4] - screenVerts[1])*2;
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
// Downward bar
//GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
//pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
fix[0] = 0.0f;
fix[6] = xfix;
@@ -3630,6 +3682,7 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8
fix[1] = fix[7] += (fix[3] - fix[7])*2;
screenVerts[1] = screenVerts[10] += (screenVerts[4] - screenVerts[1])*2;
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
@@ -3669,7 +3722,7 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh
{
float xfix, yfix;
float origaspect, newaspect;
float xoff = 1, yoff = 1; // xoffset and yoffset for the polygon to have black bars around the screen
float xoff = 1.0f, yoff = 1.0f; // xoffset and yoffset for the polygon to have black bars around the screen
static float off[12] =
{
@@ -3692,19 +3745,19 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh
if (origaspect < newaspect)
{
xoff = origaspect / newaspect;
yoff = 1;
yoff = 1.0f;
}
else if (origaspect > newaspect)
{
xoff = 1;
xoff = 1.0f;
yoff = newaspect / origaspect;
}
// float off[12];
off[0] = off[3] = -xoff;
off[1] = off[10] = -yoff;
off[4] = off[7] = yoff;
off[6] = off[9] = xoff;
off[4] = off[7] = yoff;
off[6] = off[9] = xoff;
// float fix[8];
fix[3] = fix[5] = yfix;
+13 -13
View File
@@ -62,7 +62,7 @@ static int hms_started;
static char *hms_api;
#ifdef HAVE_THREADS
static I_mutex hms_api_mutex;
static I_Mutex hms_api_mutex;
#endif
static char *hms_server_token;
@@ -90,9 +90,9 @@ Printf_url (const char *url)
boolean startup;
#ifdef HAVE_THREADS
I_lock_mutex(&con_mutex);
I_LockMutex(&con_mutex);
startup = con_startup;
I_unlock_mutex(con_mutex);
I_UnlockMutex(con_mutex);
#else
startup = con_startup;
#endif
@@ -183,19 +183,19 @@ HMS_connect (const char *format, ...)
}
#ifdef HAVE_THREADS
I_lock_mutex(&hms_api_mutex);
I_LockMutex(&hms_api_mutex);
#endif
seek = strlen(hms_api) + 1;/* + '/' */
va_start (ap, format);
url = malloc(seek + vsnprintf(0, 0, format, ap) + sizeof HMS_QUERY_VERSION - 1 + token_length + 1);
url = malloc(seek + vsnprintf(NULL, 0, format, ap) + sizeof HMS_QUERY_VERSION - 1 + token_length + 1);
va_end (ap);
sprintf(url, "%s/", hms_api);
#ifdef HAVE_THREADS
I_unlock_mutex(hms_api_mutex);
I_UnlockMutex(hms_api_mutex);
#endif
va_start (ap, format);
@@ -471,18 +471,18 @@ HMS_fetch_servers (msg_server_t *list, int query_id)
*end = '\0';
address = strtok(p, " ");
port = strtok(0, " ");
contact = strtok(0, "");
port = strtok(NULL, " ");
contact = strtok(NULL, "");
if (address && port)
{
#ifdef HAVE_THREADS
I_lock_mutex(&ms_QueryId_mutex);
I_LockMutex(&ms_QueryId_mutex);
{
if (query_id != ms_QueryId)
doing_shit = 0;
}
I_unlock_mutex(ms_QueryId_mutex);
I_UnlockMutex(ms_QueryId_mutex);
if (! doing_shit)
break;
@@ -539,7 +539,7 @@ HMS_compare_mod_version (char *buffer, size_t buffer_size)
if (HMS_do(hms))
{
version = strtok(hms->buffer, " ");
version_name = strtok(0, "\n");
version_name = strtok(NULL, "\n");
if (version && version_name)
{
@@ -611,14 +611,14 @@ void
HMS_set_api (char *api)
{
#ifdef HAVE_THREADS
I_lock_mutex(&hms_api_mutex);
I_LockMutex(&hms_api_mutex);
#endif
{
free(hms_api);
hms_api = Strip_trailing_slashes(api);
}
#ifdef HAVE_THREADS
I_unlock_mutex(hms_api_mutex);
I_UnlockMutex(hms_api_mutex);
#endif
}
+15 -12
View File
@@ -1072,8 +1072,7 @@ static void Got_Saycmd(const UINT8 **p, INT32 playernum)
HU_AddChatText(va(fmt2, prefix, cstart, dispname, textcolor, msg), cv_chatnotifications.value); // add to chat
if (tempchar)
Z_Free(tempchar);
Z_Free(tempchar);
}
#ifdef _DEBUG
// I just want to point out while I'm here that because the data is still
@@ -1484,6 +1483,7 @@ static char *CHAT_WordWrap(INT32 x, INT32 w, INT32 option, const char *string)
x = 0;
}
}
return newstring;
}
@@ -1522,7 +1522,7 @@ static void HU_drawMiniChat(void)
emote_t *emote = NULL;
int emotelen = 0;
while(msg[j]) // iterate through msg
while (msg[j]) // iterate through msg
{
if (msg[j] < HU_FONTSTART) // don't draw
{
@@ -1554,19 +1554,21 @@ static void HU_drawMiniChat(void)
{
j++;
}
prev_linereturn = false;
dx += charwidth;
if (dx >= boxw)
{
dx = 0;
linescount += 1;
}
}
dy = 0;
dx = 0;
msglines += linescount+1;
if (msg)
Z_Free(msg);
Z_Free(msg);
}
y = chaty - charheight*(msglines+1);
@@ -1598,7 +1600,7 @@ static void HU_drawMiniChat(void)
emote_t *emote = NULL;
int emotelen = 0;
while(msg[j]) // iterate through msg
while (msg[j]) // iterate through msg
{
if (msg[j] < HU_FONTSTART) // don't draw
{
@@ -1643,16 +1645,17 @@ static void HU_drawMiniChat(void)
dx += charwidth;
prev_linereturn = false;
if (dx >= boxw)
{
dx = 0;
dy += charheight;
}
}
dy += charheight;
dx = 0;
if (msg)
Z_Free(msg);
Z_Free(msg);
}
// decrement addy and make that shit smooth:
@@ -1704,7 +1707,7 @@ static void HU_drawChatLog(INT32 offset)
V_DrawFillConsoleMap(chatx, chat_topy, boxw, boxh*charheight +2, 239|V_SNAPTOBOTTOM|V_SNAPTOLEFT); // log box
for (i=0; i<chat_nummsg_log; i++) // iterate through our chatlog
for (i = 0; i < chat_nummsg_log; i++) // iterate through our chatlog
{
INT32 clrflag = 0;
INT32 j = 0;
@@ -1713,7 +1716,7 @@ static void HU_drawChatLog(INT32 offset)
emote_t *emote = NULL;
int emotelen = 0;
while(msg[j]) // iterate through msg
while (msg[j]) // iterate through msg
{
if (msg[j] < HU_FONTSTART) // don't draw
{
@@ -1758,10 +1761,10 @@ static void HU_drawChatLog(INT32 offset)
dy += charheight;
}
}
dy += charheight;
dx = 0;
if (msg)
Z_Free(msg);
Z_Free(msg);
}
if (((chat_scroll >= chat_maxscroll) || (chat_scrollmedown)) && !(justscrolleddown || justscrolledup || chat_scrolltime)) // was already at the bottom of the page before new maxscroll calculation and was NOT scrolling.
+4
View File
@@ -29,6 +29,10 @@ extern "C" {
*/
#define MAX_QUIT_FUNCS 16
void I_GetConsoleEvents(void);
extern boolean consolevent;
extern boolean framebuffer;
/** \brief Graphic system had started up
*/
+4 -10
View File
@@ -1510,11 +1510,8 @@ static boolean SOCK_SetBanUsername(const char *username)
username = "Direct IP ban";
}
if (banned[numbans - 1].username)
{
Z_Free(banned[numbans - 1].username);
banned[numbans - 1].username = NULL;
}
Z_Free(banned[numbans - 1].username);
banned[numbans - 1].username = NULL;
banned[numbans - 1].username = Z_StrDup(username);
@@ -1528,11 +1525,8 @@ static boolean SOCK_SetBanReason(const char *reason)
reason = "No reason given";
}
if (banned[numbans - 1].reason)
{
Z_Free(banned[numbans - 1].reason);
banned[numbans - 1].reason = NULL;
}
Z_Free(banned[numbans - 1].reason);
banned[numbans - 1].reason = NULL;
banned[numbans - 1].reason = Z_StrDup(reason);
+87 -59
View File
@@ -1,4 +1,4 @@
// SONIC ROBO BLAST 2
// SONIC ROBO BLAST 2 KART
//-----------------------------------------------------------------------------
// Copyright (C) 2020-2023 by James R.
//
@@ -9,12 +9,14 @@
/// \file i_threads.c
/// \brief Multithreading abstraction
#if defined (__unix__) || (!defined(__APPLE__) && defined (UNIXCOMMON))
#ifdef HAVE_THREADS
#if defined (__unix__) || defined(UNIXCOMMON)
#include <pthread.h>
#include "../i_threads.h"
#include "../doomdef.h"
#include "i_threads.h"
#include "doomdef.h"
#include "doomtype.h"
typedef struct thread_s thread_t;
@@ -22,7 +24,7 @@ struct thread_s
{
thread_t *next;
void *userdata;
I_thread_fn func;
I_ThreadFn func;
pthread_t thread;
};
@@ -41,12 +43,8 @@ static void *HandleThread(void *data)
return NULL;
}
void
I_spawn_thread (
const char * name,
I_thread_fn entry,
void * userdata
)
FUNCWARNRV
int I_SpawnThread(const char *name, I_ThreadFn entry, void *userdata)
{
thread_t *thread;
(void)name;
@@ -66,17 +64,20 @@ I_spawn_thread (
if (thread == NULL)
{
thread = malloc(sizeof(thread_t));
if (thread == NULL)
return false;
thread->next = thread_list;
thread_list = thread;
}
thread->func = entry;
thread->userdata = userdata;
pthread_create(&thread->thread, NULL, HandleThread, thread);
int err = pthread_create(&thread->thread, NULL, HandleThread, thread);
pthread_mutex_unlock(&thread_lock);
return err == 0;
}
int I_thread_is_stopped(void)
int I_ThreadIsStopped(void)
{
thread_t *thread;
pthread_mutex_lock(&thread_lock);
@@ -94,11 +95,11 @@ int I_thread_is_stopped(void)
return true;
}
void I_start_threads(void)
void I_StartThreads(void)
{
}
void I_stop_threads(void)
void I_StopThreads(void)
{
thread_t *thread = thread_list;
while (thread != NULL)
@@ -109,7 +110,7 @@ void I_stop_threads(void)
}
}
void I_lock_mutex(I_mutex *anchor)
void I_LockMutex(I_Mutex *anchor)
{
pthread_mutex_lock(&thread_lock);
if (*anchor == NULL)
@@ -127,25 +128,25 @@ void I_lock_mutex(I_mutex *anchor)
pthread_mutex_lock(*anchor);
}
void I_unlock_mutex(I_mutex id)
void I_UnlockMutex(I_Mutex id)
{
pthread_mutex_unlock(id);
}
void I_hold_cond(I_cond *cond_anchor, I_mutex mutex_id)
void I_HoldCond(I_Cond *condAnchor, I_Mutex mutexId)
{
I_Assert(mutex_id != NULL);
I_Assert(mutexId != NULL);
pthread_mutex_lock(&thread_lock);
if (*cond_anchor == NULL)
if (*condAnchor == NULL)
{
*cond_anchor = malloc(sizeof(pthread_cond_t));
pthread_cond_init(*cond_anchor, NULL);
*condAnchor = malloc(sizeof(pthread_cond_t));
pthread_cond_init(*condAnchor, NULL);
}
pthread_mutex_unlock(&thread_lock);
pthread_cond_wait(*cond_anchor, mutex_id);
pthread_cond_wait(*condAnchor, mutexId);
}
void I_wake_one_cond(I_cond *anchor)
void I_WakeOneCond(I_Cond *anchor)
{
pthread_mutex_lock(&thread_lock);
if (*anchor == NULL)
@@ -157,7 +158,7 @@ void I_wake_one_cond(I_cond *anchor)
pthread_cond_signal(*anchor);
}
void I_wake_all_cond(I_cond *anchor)
void I_WakeAllCond(I_Cond *anchor)
{
pthread_mutex_lock(&thread_lock);
if (*anchor == NULL)
@@ -168,12 +169,17 @@ void I_wake_all_cond(I_cond *anchor)
pthread_mutex_unlock(&thread_lock);
pthread_cond_broadcast(*anchor);
}
thread_handle_t I_GetCurrentThread(void)
{
return pthread_self();
}
#elif defined (_WIN32)
#include <windows.h>
#include "../i_threads.h"
#include "../doomdef.h"
#include "../doomtype.h"
#include "i_threads.h"
#include "doomdef.h"
#include "doomtype.h"
typedef struct thread_s thread_t;
@@ -181,9 +187,9 @@ struct thread_s
{
thread_t *next;
void *userdata;
I_thread_fn func;
I_ThreadFn func;
HANDLE thread;
DWORD thread_id;
DWORD threadId;
};
// we use a linked list to avoid moving memory blocks when allocating new threads.
@@ -201,7 +207,8 @@ static DWORD __stdcall HandleThread(void *data)
return 0;
}
void I_spawn_thread(const char *name, I_thread_fn entry, void *userdata)
FUNCWARNRV
int I_SpawnThread(const char *name, I_ThreadFn entry, void *userdata)
{
thread_t *thread;
(void)name;
@@ -219,17 +226,20 @@ void I_spawn_thread(const char *name, I_thread_fn entry, void *userdata)
if (thread == NULL)
{
thread = malloc(sizeof(thread_t));
if (thread == NULL)
return false;
thread->next = thread_list;
thread_list = thread;
}
thread->func = entry;
thread->userdata = userdata;
thread->thread = CreateThread(NULL, 0, HandleThread, thread, 0, &thread->thread_id);
thread->thread = CreateThread(NULL, 0, HandleThread, thread, 0, &thread->threadId);
LeaveCriticalSection(&thread_lock);
return thread->thread != NULL;
}
int I_thread_is_stopped(void)
int I_ThreadIsStopped(void)
{
thread_t *thread;
EnterCriticalSection(&thread_lock);
@@ -247,12 +257,12 @@ int I_thread_is_stopped(void)
return true;
}
void I_start_threads(void)
void I_StartThreads(void)
{
InitializeCriticalSection(&thread_lock);
}
void I_stop_threads(void)
void I_StopThreads(void)
{
thread_t *thread = thread_list;
while (thread != NULL)
@@ -264,7 +274,7 @@ void I_stop_threads(void)
DeleteCriticalSection(&thread_lock);
}
void I_lock_mutex(I_mutex *anchor)
void I_LockMutex(I_Mutex *anchor)
{
EnterCriticalSection(&thread_lock);
if (*anchor == NULL)
@@ -276,25 +286,25 @@ void I_lock_mutex(I_mutex *anchor)
EnterCriticalSection(*anchor);
}
void I_unlock_mutex(I_mutex id)
void I_UnlockMutex(I_Mutex id)
{
LeaveCriticalSection(id);
}
void I_hold_cond(I_cond *cond_anchor, I_mutex mutex_id)
void I_HoldCond(I_Cond *condAnchor, I_Mutex mutexId)
{
I_Assert(mutex_id != NULL);
I_Assert(mutexId != NULL);
EnterCriticalSection(&thread_lock);
if (*cond_anchor == NULL)
if (*condAnchor == NULL)
{
*cond_anchor = malloc(sizeof(CONDITION_VARIABLE));
InitializeConditionVariable(*cond_anchor);
*condAnchor = malloc(sizeof(CONDITION_VARIABLE));
InitializeConditionVariable(*condAnchor);
}
LeaveCriticalSection(&thread_lock);
SleepConditionVariableCS(*cond_anchor, mutex_id, INFINITE);
SleepConditionVariableCS(*condAnchor, mutexId, INFINITE);
}
void I_wake_one_cond(I_cond *anchor)
void I_WakeOneCond(I_Cond *anchor)
{
EnterCriticalSection(&thread_lock);
if (*anchor == NULL)
@@ -306,7 +316,7 @@ void I_wake_one_cond(I_cond *anchor)
WakeConditionVariable(*anchor);
}
void I_wake_all_cond(I_cond *anchor)
void I_WakeAllCond(I_Cond *anchor)
{
EnterCriticalSection(&thread_lock);
if (*anchor == NULL)
@@ -317,48 +327,66 @@ void I_wake_all_cond(I_cond *anchor)
LeaveCriticalSection(&thread_lock);
WakeAllConditionVariable(*anchor);
}
void *I_GetCurrentThread(void)
{
return GetCurrentThread();
}
#else
void I_spawn_thread(const char *name, I_thread_fn entry, void *userdata)
#include "i_threads.h"
FUNCWARNRV
int I_SpawnThread(const char *name, I_ThreadFn entry, void *userdata)
{
(void)name;
entry(userdata);
return true;
}
int I_thread_is_stopped(void)
int I_ThreadIsStopped(void)
{
return true;
}
void I_StartThreads(void)
{
}
void I_start_threads(void)
void I_StopThreads(void)
{
}
void I_stop_threads(void)
{
}
void I_lock_mutex(I_mutex *anchor)
void I_LockMutex(I_Mutex *anchor)
{
(void)anchor;
}
void I_unlock_mutex(I_mutex id)
void I_UnlockMutex(I_Mutex id)
{
(void)id;
}
void I_hold_cond(I_cond *cond_anchor, I_mutex mutex_id)
void I_HoldCond(I_Cond *condAnchor, I_Mutex mutexId)
{
(void)cond_anchor;
(void)mutex_id;
(void)condAnchor;
(void)mutexId;
}
void I_wake_one_cond(I_cond *anchor)
void I_WakeOneCond(I_Cond *anchor)
{
(void)anchor;
}
void I_wake_all_cond(I_cond *anchor)
void I_WakeAllCond(I_Cond *anchor)
{
(void)anchor;
}
void *I_GetCurrentThread(void)
{
return NULL;
}
#endif
#endif // HAVE_THREADS
+25 -13
View File
@@ -1,6 +1,6 @@
// SONIC ROBO BLAST 2 KART
//-----------------------------------------------------------------------------
// Copyright (C) 2020 by James R.
// Copyright (C) 2020-2023 by James R.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
@@ -14,34 +14,46 @@
#ifndef I_THREADS_H
#define I_THREADS_H
#include "doomtype.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*I_thread_fn)(void *userdata);
typedef void (*I_ThreadFn)(void *userdata);
typedef void * I_mutex;
typedef void * I_cond;
typedef void * I_Mutex;
typedef void * I_Cond;
void I_start_threads (void);
void I_stop_threads (void);
#ifdef __linux__
typedef long unsigned int thread_handle_t;
#else
typedef void *thread_handle_t;
#endif
void I_spawn_thread (const char *name, I_thread_fn, void *userdata);
void I_StartThreads (void);
void I_StopThreads (void);
FUNCWARNRV
int I_SpawnThread (const char *name, I_ThreadFn, void *userdata);
/* check in your thread whether to return early */
int I_thread_is_stopped (void);
int I_ThreadIsStopped (void);
void I_lock_mutex (I_mutex *);
void I_unlock_mutex (I_mutex);
void I_LockMutex (I_Mutex *);
void I_UnlockMutex (I_Mutex);
void I_hold_cond (I_cond *, I_mutex);
void I_HoldCond (I_Cond *, I_Mutex);
void I_wake_one_cond (I_cond *);
void I_wake_all_cond (I_cond *);
void I_WakeOneCond (I_Cond *);
void I_WakeAllCond (I_Cond *);
thread_handle_t I_GetCurrentThread(void);
#ifdef __cplusplus
} // extern "C"
#endif
#endif/*I_THREADS_H*/
#endif/*HAVE_THREADS*/
+1 -1
View File
@@ -21,7 +21,7 @@
#include "m_fixed.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}};
consvar_t cv_timescale = {"timescale", "1.0", CV_NETVAR|CV_CHEAT|CV_FLOAT, timescale_cons_t, NULL, FRACUNIT, NULL, NULL, 0, 0, NULL};
+9 -2
View File
@@ -125,8 +125,6 @@ boolean I_CheckNativeRes(void);
void I_SetBorderlessWindow(void);
void I_HandleControllerHatRepeat(void);
#ifdef USE_FBO_OGL
void RefreshOGLSDLSurface(void);
@@ -135,6 +133,15 @@ boolean UseScreenFBO(void);
extern boolean downsample;
#endif
// So we can call this from i_video event loop
void I_ShutdownJoystick(UINT8 index);
// Quick thing to make SDL_JOYDEVICEADDED events less of an abomination
void I_UpdateJoystickDeviceIndex(UINT8 player);
void I_UpdateJoystickDeviceIndices(UINT8 excludePlayer);
void I_HandleControllerHatRepeat(void);
#ifdef __cplusplus
} // extern "C"
#endif
+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_winnernum[NUMPOSFRAMES];
patch_t *kp_facenum[MAXPLAYERS+1];
patch_t *kp_facenum[MAXPLAYERS+1] = {};
static patch_t *kp_facehighlight[8];
static patch_t *kp_rankbumper;
@@ -1065,7 +1065,7 @@ static void K_initKartHUD(void)
}
if (timeinmap > 113 || forceshowhud)
hudtrans = cv_translucenthud.value;
hudtrans = (UINT8)cv_translucenthud.value;
else if (timeinmap > 105)
hudtrans = ((((INT32)timeinmap) - 105)*cv_translucenthud.value)/(113-105);
else
@@ -1122,9 +1122,9 @@ void K_KartPlayerHUDUpdate(player_t *player)
UINT8 K_GetHudColor(void)
{
if (cv_colorizedhud.value && cv_colorizedhudcolor.value)
return cv_colorizedhudcolor.value;
return (UINT8)cv_colorizedhudcolor.value;
return ((stplyr && gamestate == GS_LEVEL) ? stplyr->skincolor : cv_playercolor.value);
return ((stplyr && gamestate == GS_LEVEL) ? stplyr->skincolor : (UINT8)cv_playercolor.value);
}
boolean K_UseColorHud(void)
@@ -1526,7 +1526,7 @@ static void K_drawKartItem(void)
{
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
case 0: // Sneaker
@@ -2195,7 +2195,7 @@ static boolean K_drawKartPositionFaces(void)
return true;
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++)
{
+17 -9
View File
@@ -47,6 +47,8 @@ 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_reducevfx = {"reducevfx", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
// funn-E streeetch
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};
@@ -482,7 +484,8 @@ UINT8 colortranslations[MAXTRANSLATIONS][16] = {
//
UINT8 K_RainbowColor(void)
{
return (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1)));
const tic_t time = cv_reducevfx.value ? (leveltime >> 3) : leveltime;
return (UINT8)(1 + (time % (MAXSKINCOLORS-1)));
}
// Define for getting accurate color brightness readings according to how the human eye sees them.
@@ -764,6 +767,8 @@ void K_RegisterClientKartStuff(void)
CV_RegisterVar(&cv_playerblendeffects);
CV_RegisterVar(&cv_reducevfx);
CV_RegisterVar(&cv_saltyhop);
CV_RegisterVar(&cv_saltyhopsfx);
CV_RegisterVar(&cv_saltysquish);
@@ -3103,17 +3108,18 @@ static mobj_t *K_SpawnKartMissile(mobj_t *source, mobjtype_t type, angle_t an, I
return NULL;
}
static UINT16 K_DriftSparkColor(player_t *player, INT32 charge)
static UINT8 K_DriftSparkColor(player_t *player, INT32 charge)
{
UINT16 color = SKINCOLOR_NONE;
UINT8 color = SKINCOLOR_NONE;
const INT32 sparkval = K_GetKartDriftSparkValue(player);
if (charge >= K_GetKartDriftSparkValue(player)*4)
if (charge >= sparkval*4)
{
color = K_RainbowColor();
}
else if (charge >= K_GetKartDriftSparkValue(player)*2)
else if (charge >= sparkval*2)
{
if (charge <= (K_GetKartDriftSparkValue(player)*2)+(24*3))
if (charge <= (sparkval*2)+(24*3))
color = SKINCOLOR_RASPBERRY; // transition
else
color = SKINCOLOR_KETCHUP;
@@ -3594,6 +3600,8 @@ void K_SpawnSparkleTrail(mobj_t *mo)
I_Assert(mo != NULL);
I_Assert(!P_MobjWasRemoved(mo));
const boolean shouldblend = (mo->player && K_PlayerEffectsShouldBlend(mo->player));
for (i = 0; i < 3; i++)
{
fixed_t newx = mo->x + mo->momx + (P_RandomRange(-rad, rad)<<FRACBITS);
@@ -3611,7 +3619,7 @@ void K_SpawnSparkleTrail(mobj_t *mo)
sparkle->color = mo->color;
if (mo->player && K_PlayerEffectsShouldBlend(mo->player))
if (shouldblend)
sparkle->blendmode = AST_ADD;
}
@@ -6765,7 +6773,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
{
if (splitscreen)
{
if (leveltime & 1)
if (!cv_reducevfx.value && leveltime & 1)
player->mo->flags2 |= MF2_DONTDRAW;
else
player->mo->flags2 &= ~MF2_DONTDRAW;
@@ -6791,7 +6799,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
if (P_IsDisplayPlayer(player)
|| (!P_IsDisplayPlayer(player) && (player->kartstuff[k_hyudorotimer] < (1*TICRATE/2) || player->kartstuff[k_hyudorotimer] > hyudorotime-(1*TICRATE/2))))
{
if (leveltime & 1)
if (!cv_reducevfx.value && leveltime & 1)
player->mo->flags2 |= MF2_DONTDRAW;
else
player->mo->flags2 &= ~MF2_DONTDRAW;
+1 -2
View File
@@ -99,8 +99,7 @@ void K_EraseStats(void)
// The only field we want to remember
boolean vanilla = kartstats.vanilla;
if (kartstats.copy)
Z_Free(kartstats.copy);
Z_Free(kartstats.copy);
memset(&kartstats, 0, sizeof(kartstats_t));
+1
View File
@@ -1293,6 +1293,7 @@ static int lib_pPlayRinglossSound(lua_State *L)
player_t *player = NULL;
mobj_t *damager = NULL;
NOHUD
LUA_UsageWarning(L, "P_PlayRinglossSound: using this function from lua might cause desynchs, consider using S_StartSound(origin, sfx_khurt1 + P_RandomKey(2)) as workaround");
if (!source)
return LUA_ErrInvalid(L, "mobj_t");
if (!lua_isnone(L, 2) && lua_isuserdata(L, 2))
+3 -12
View File
@@ -136,18 +136,9 @@ void LUA_HUD_DestroyDrawList(huddrawlist_h list)
{
if (list == NULL) return;
if (list->items)
{
Z_Free(list->items);
}
if (list->olditems)
{
Z_Free(list->olditems);
}
if (list->strbuf)
{
Z_Free(list->strbuf);
}
Z_Free(list->items);
Z_Free(list->olditems);
Z_Free(list->strbuf);
Z_Free(list);
}
+1 -1
View File
@@ -25,7 +25,7 @@
#include "lua_hook.h" // cmd errors
boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor);
state_t *astate;
state_t *astate = NULL;
boolean actionsoverridden[NUMACTIONS] = {false};
+1 -1
View File
@@ -475,7 +475,7 @@ int mobj_localskin_setter(lua_State *L)
}
else
{
mo->localskin = 0;
mo->localskin = NULL;
mo->skinlocal = false;
}
}
+38 -38
View File
@@ -45,20 +45,20 @@ int hook_defrosting = 0;
// List of internal libraries to load from SRB2
static lua_CFunction liblist[] = {
LUA_EnumLib, // global metatable for enums
LUA_SOCLib, // A_Action functions, freeslot
LUA_BaseLib, // string concatination by +, CONS_Printf, p_local.h stuff (P_InstaThrust, P_Move), etc.
LUA_MathLib, // fixed_t and angle_t math functions
LUA_HookLib, // hookAdd and hook-calling functions
LUA_ConsoleLib, // console command/variable functions and structs
LUA_InfoLib, // info.h stuff: mobjinfo_t, mobjinfo[], state_t, states[]
LUA_MobjLib, // mobj_t, mapthing_t
LUA_PlayerLib, // player_t
LUA_SkinLib, // skin_t, skins[]
LUA_ThinkerLib, // thinker_t
LUA_MapLib, // line_t, side_t, sector_t, subsector_t
LUA_BlockmapLib, // blockmap stuff
LUA_HudLib, // HUD stuff
LUA_EnumLib, // global metatable for enums
LUA_SOCLib, // A_Action functions, freeslot
LUA_BaseLib, // string concatination by +, CONS_Printf, p_local.h stuff (P_InstaThrust, P_Move), etc.
LUA_MathLib, // fixed_t and angle_t math functions
LUA_HookLib, // hookAdd and hook-calling functions
LUA_ConsoleLib, // console command/variable functions and structs
LUA_InfoLib, // info.h stuff: mobjinfo_t, mobjinfo[], state_t, states[]
LUA_MobjLib, // mobj_t, mapthing_t
LUA_PlayerLib, // player_t
LUA_SkinLib, // skin_t, skins[]
LUA_ThinkerLib, // thinker_t
LUA_MapLib, // line_t, side_t, sector_t, subsector_t
LUA_BlockmapLib, // blockmap stuff
LUA_HudLib, // HUD stuff
NULL
};
@@ -66,12 +66,8 @@ static lua_CFunction liblist[] = {
static void *LUA_Alloc(void *ud, void *ptr, size_t osize, size_t nsize)
{
(void)ud;
if (nsize == 0) {
if (osize != 0)
Z_Free(ptr);
return NULL;
} else
return Z_Realloc(ptr, nsize, PU_LUA, NULL);
(void)osize;
return Z_Realloc(ptr, nsize, PU_LUA, NULL);
}
// Panic function Lua calls when there's an unprotected error.
@@ -213,7 +209,8 @@ void LUA_ClearState(void)
lua_setfield(L, LUA_REGISTRYINDEX, LREG_VALID);
// open srb2 libraries
for(i = 0; liblist[i]; i++) {
for (i = 0; liblist[i]; i++)
{
lua_pushcfunction(L, liblist[i]);
lua_call(L, 0, 0);
}
@@ -1064,9 +1061,13 @@ static void ArchiveTables(UINT8 **p)
{
// Write key
e = ArchiveValue(p, TABLESINDEX, -2); // key should be either a number or a string, ArchiveValue can handle this.
if (e == 2) // invalid key type (function, thread, lightuserdata, or anything we don't recognise)
if (e == 1)
n++; // the table contained a new table we'll have to archive. :(
else if (e == 2) // invalid key type (function, thread, lightuserdata, or anything we don't recognise)
{
CONS_Alert(CONS_ERROR, "Index '%s' (%s) of table %d could not be archived!\n", lua_tostring(gL, -2), luaL_typename(gL, -2), i);
lua_pop(gL, 1);
continue;
}
else if (e == 3) // nil key due to invalid userdata. NOT an error.
{
@@ -1077,15 +1078,12 @@ static void ArchiveTables(UINT8 **p)
// Write value
e = ArchiveValue(p, TABLESINDEX, -1);
if (e == 1)
{
n++; // the table contained a new table we'll have to archive. :(
}
else if (e == 2) // invalid value type
{
CONS_Alert(CONS_ERROR, "Type of value for table %d entry '%s' (%s) could not be archived!\n", i, lua_tostring(gL, -2), luaL_typename(gL, -1));
}
lua_pop(gL, 1);
}
lua_pop(gL, 1);
WRITEUINT8(*p, ARCH_TEND);
@@ -1276,13 +1274,21 @@ static void UnArchiveTables(UINT8 **p, boolean network)
UINT8 ret;
ret = UnArchiveValue(p, TABLESINDEX, network);
if (ret == 3)
if (ret == 1) // End of table
break;
else if (ret == 2) // Key contains a new table
n++;
else if (ret == 3)
{
//CONS_Alert(CONS_WARNING,"Couldn't read mobj_t\n");
lua_pushnil(gL);
}
else if (ret == 1) // read key
break;
if (lua_isnil(gL, -1)) // If key is nil, skip this entry
{
lua_pop(gL, 1);
continue;
}
ret = UnArchiveValue(p, TABLESINDEX, network);
if (ret == 1)
@@ -1291,21 +1297,15 @@ static void UnArchiveTables(UINT8 **p, boolean network)
lua_pop(gL, 1); // Pop key
break;
}
else if (ret == 2) // read value
n++;
else if (ret == 3)
{
//CONS_Alert(CONS_WARNING,"Couldn't read mobj_t\n");
lua_pushnil(gL);
}
else if (ret == 2) // read value
n++;
if (lua_isnil(gL, -2)) // if key is nil (if a function etc was accidentally saved)
{
CONS_Alert(CONS_ERROR, "A nil key in table %d was found! (Invalid key type or corrupted save?)\n", i);
lua_pop(gL, 2); // pop key and value instead of setting them in the table, to prevent Lua panic errors
}
else
lua_rawset(gL, -3);
lua_rawset(gL, -3);
}
lua_pop(gL, 1);
+3 -6
View File
@@ -695,16 +695,13 @@ INT32 GIF_close(void)
fclose(gif_out);
gif_out = NULL;
if (gifbwr_buf)
Z_Free(gifbwr_buf);
Z_Free(gifbwr_buf);
gifbwr_buf = gifbwr_cur = NULL;
if (gifframe_data)
Z_Free(gifframe_data);
Z_Free(gifframe_data);
gifframe_data = NULL;
if (giflzw_hashTable)
Z_Free(giflzw_hashTable);
Z_Free(giflzw_hashTable);
giflzw_hashTable = NULL;
Z_Free(scrbuf_screens);
+5 -5
View File
@@ -80,7 +80,7 @@ static UINT8 cheatf_warp(void)
if (success)
{
G_SaveGameData(true); //G_SetGameModified(false);
S_StartSound(0, sfx_kc42);
S_StartSound(NULL, sfx_kc42);
}
// Refresh secrets menu existing.
@@ -117,13 +117,13 @@ static UINT8 cheatf_devmode(void)
#endif
static cheatseq_t cheat_warp = {
0, cheatf_warp,
NULL, cheatf_warp,
//{ 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 }
};
static cheatseq_t cheat_warp_joy = {
0, cheatf_warp,
NULL, cheatf_warp,
/*{ SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_UPARROW),
SCRAMBLE(KEY_RIGHTARROW), SCRAMBLE(KEY_RIGHTARROW), SCRAMBLE(KEY_UPARROW),
SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_UPARROW),
@@ -136,7 +136,7 @@ static cheatseq_t cheat_warp_joy = {
#ifdef DEVELOP
static cheatseq_t cheat_devmode = {
0, cheatf_devmode,
NULL, cheatf_devmode,
{ SCRAMBLE('d'), SCRAMBLE('e'), SCRAMBLE('v'), SCRAMBLE('m'), SCRAMBLE('o'), SCRAMBLE('d'), SCRAMBLE('e'), 0xff }
};
#endif
@@ -301,7 +301,7 @@ void Command_CheatNoTarget_f(void)
void Command_Scale_f(void)
{
const double scaled = atof(COM_Argv(1));
fixed_t scale = FLOAT_TO_FIXED(scaled);
fixed_t scale = DoubleToFixed(scaled);
REQUIRE_DEVMODE;
REQUIRE_INLEVEL;
+4 -7
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;
num = ++conditionSets[set - 1].numconditions;
conditionSets[set - 1].condition = Z_Realloc(conditionSets[set - 1].condition, sizeof(condition_t)*num, PU_STATIC, 0);
conditionSets[set - 1].condition = Z_Realloc(conditionSets[set - 1].condition, sizeof(condition_t)*num, PU_STATIC, NULL);
cond = conditionSets[set - 1].condition;
@@ -248,12 +248,9 @@ void M_AddRawCondition(UINT8 set, UINT8 id, conditiontype_t c, INT32 r, INT16 x1
void M_ClearConditionSet(UINT8 set)
{
if (conditionSets[set - 1].numconditions)
{
Z_Free(conditionSets[set - 1].condition);
conditionSets[set - 1].condition = NULL;
conditionSets[set - 1].numconditions = 0;
}
Z_Free(conditionSets[set - 1].condition);
conditionSets[set - 1].condition = NULL;
conditionSets[set - 1].numconditions = 0;
conditionSets[set - 1].achieved = false;
}
+4 -4
View File
@@ -12,14 +12,14 @@
#ifndef __M_EMOTES__
#define __M_EMOTES__
#ifdef __cplusplus
extern "C" {
#endif
#include "doomdef.h"
#include "m_fixed.h"
#include "command.h"
#ifdef __cplusplus
extern "C" {
#endif
extern consvar_t cv_emotes;
#define MAXEMOTENAME 32
-29
View File
@@ -265,35 +265,6 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedRound(fixed_t x)
return INT32_MAX;
}
/** \brief The xs_CRoundToInt function
\param val double number
\return Round toward nearest, but ties round toward even
*/
#if defined(SRB2_BIG_ENDIAN)
#define _xs_iexp_ 0
#define _xs_iman_ 1
#else
#define _xs_iexp_ 1 //intel is little endian
#define _xs_iman_ 0
#endif //BigEndian_
typedef double real64;
typedef union _xs_doubleints
{
real64 val;
unsigned ival[2];
} _xs_doubleints;
FUNCMATH FUNCINLINE static ATTRINLINE int xs_CRoundToInt(real64 val)
{
_xs_doubleints uval;
uval.val = val + 6755399441055744.0;
return uval.ival[_xs_iman_];
}
typedef struct
{
fixed_t x;
+150 -95
View File
@@ -12,6 +12,8 @@
/// \file m_menu.c
/// \brief XMOD's extremely revamped menu system.
#include "screen.h"
#include "tables.h"
#ifdef __GNUC__
#include <unistd.h>
#endif
@@ -140,7 +142,7 @@ typedef enum
} text_enum;
#ifdef HAVE_THREADS
I_mutex m_menu_mutex;
I_Mutex m_menu_mutex;
#endif
M_waiting_mode_t m_waiting_mode = M_NOT_WAITING;
@@ -1965,7 +1967,7 @@ void M_Ticker(void)
}
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
I_lock_mutex(&ms_ServerList_mutex);
I_LockMutex(&ms_ServerList_mutex);
{
if (ms_ServerList)
{
@@ -1974,7 +1976,7 @@ void M_Ticker(void)
ms_ServerList = NULL;
}
}
I_unlock_mutex(ms_ServerList_mutex);
I_UnlockMutex(ms_ServerList_mutex);
#endif
}
@@ -4012,14 +4014,14 @@ size_t demolist_all_size = 0;
boolean replaynamesloaded = false;
#ifdef HAVE_THREADS
I_mutex replayquerymutex;
I_Mutex replayquerymutex;
// g_in_exiting_signal_handler is an evil hack
// to avoid infinite SIGABRT recursion in the signal handler
// due to poisoned locks or mach-o kernel not supporting locks in signals
// or something like that. idk
# define Lock_search_state() if (!g_in_exiting_signal_handler) { I_lock_mutex(&replayquerymutex); }
# define Unlock_search_state() if (!g_in_exiting_signal_handler) { I_unlock_mutex(replayquerymutex); }
# define Lock_search_state() if (!g_in_exiting_signal_handler) { I_LockMutex(&replayquerymutex); }
# define Unlock_search_state() if (!g_in_exiting_signal_handler) { I_UnlockMutex(replayquerymutex); }
#else/*HAVE_THREADS*/
# define Lock_search_state()
# define Unlock_search_state()
@@ -4086,7 +4088,10 @@ static void LoadReplayNames(void)
Unlock_search_state();
#ifdef HAVE_THREADS
I_spawn_thread("replay-names-load", ReplayNamesLoadThread, replaydirpath);
if (!I_SpawnThread("replay-names-load", ReplayNamesLoadThread, replaydirpath))
{
free(replaydirpath);
}
#else
ReplayNamesLoadThread(replaydirpath);
#endif
@@ -4717,7 +4722,7 @@ static void M_DrawReplayHut(void)
if (y > scaledviewheight-80)
{
V_DrawFill(BASEVIDWIDTH-4, 75, 4, scaledviewheight-80, V_SNAPTOTOP|V_SNAPTORIGHT|239);
V_DrawFill(BASEVIDWIDTH-3, 76 + (scaledviewheight-80) * replayhutmenuy / y, 2, (((scaledviewheight-80) * (scaledviewheight-80))-1) / y - 1, V_SNAPTOTOP|V_SNAPTORIGHT|229);
V_DrawFill(BASEVIDWIDTH-3, 76 + (scaledviewheight-80) * replayhutmenuy / y, 2, max((((scaledviewheight-80) * (scaledviewheight-80))-1) / y - 1, 1), V_SNAPTOTOP|V_SNAPTORIGHT|229);
}
// Draw the cursor
@@ -5354,7 +5359,7 @@ void M_PopupMasterServerRules(void)
{
firstDismissedRulesThisBoot = false;
M_StartMessage(va("%s\n(press any key)", rules), NULL, MM_NOTHING);
Z_Free(rules);
free(rules);
}
}
#endif
@@ -5385,7 +5390,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na
{
CONS_Printf("custom settings menu initiation\n");
for (CVARSETUP = 0; CVARSETUP < MAXMENUCCVARS; ++CVARSETUP)
OP_CustomCvarMenu[CVARSETUP] = (menuitem_t){IT_DISABLED, NULL, "", 0, INT16_MAX};
OP_CustomCvarMenu[CVARSETUP] = (menuitem_t){IT_DISABLED, NULL, "", NULL, INT16_MAX};
}
if (category && ((ccvarposition == 0 && category[0] != '\0') || !fasticmp(category, OP_CustomCvarMenu[ccvarlaststheader].text)))
@@ -6558,17 +6563,22 @@ static void M_EraseGuest(INT32 choice)
static void M_OverwriteGuest(const char *which)
{
char *rguest = Z_StrDup(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-guest.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value)));
char *rguest;
UINT8 *buf;
size_t len;
len = FIL_ReadFile(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-%s-%s.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value), cv_chooseskin.string, which), &buf);
if (!len) {
if (!len)
return;
}
if (FIL_FileExists(rguest)) {
rguest = Z_StrDup(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-guest.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value)));
if (FIL_FileExists(rguest))
{
M_StopMessage(0);
remove(rguest);
}
FIL_WriteFile(rguest, buf, len);
Z_Free(rguest);
@@ -6677,11 +6687,11 @@ static void M_EndGame(INT32 choice)
void M_SetWaitingMode(int mode)
{
#ifdef HAVE_THREADS
I_lock_mutex(&m_menu_mutex);
I_LockMutex(&m_menu_mutex);
#endif
m_waiting_mode = mode;
#ifdef HAVE_THREADS
I_unlock_mutex(m_menu_mutex);
I_UnlockMutex(m_menu_mutex);
#endif
}
@@ -6690,11 +6700,11 @@ int M_GetWaitingMode(void)
int mode;
#ifdef HAVE_THREADS
I_lock_mutex(&m_menu_mutex);
I_LockMutex(&m_menu_mutex);
#endif
mode = m_waiting_mode;
#ifdef HAVE_THREADS
I_unlock_mutex(m_menu_mutex);
I_UnlockMutex(m_menu_mutex);
#endif
return mode;
@@ -6706,20 +6716,23 @@ static void Spawn_masterserver_thread(const char *name, void (*thread)(int*))
{
int *id = malloc(sizeof *id);
I_lock_mutex(&ms_QueryId_mutex);
I_LockMutex(&ms_QueryId_mutex);
*id = ms_QueryId;
I_unlock_mutex(ms_QueryId_mutex);
I_UnlockMutex(ms_QueryId_mutex);
I_spawn_thread(name, (I_thread_fn)thread, id);
if (!I_SpawnThread(name, (I_ThreadFn)thread, id))
{
free(id);
}
}
static int Same_instance(int id)
{
int okay;
I_lock_mutex(&ms_QueryId_mutex);
I_LockMutex(&ms_QueryId_mutex);
okay = ( id == ms_QueryId );
I_unlock_mutex(ms_QueryId_mutex);
I_UnlockMutex(ms_QueryId_mutex);
return okay;
}
@@ -6748,9 +6761,9 @@ static void Fetch_servers_thread(int *id)
M_SetWaitingMode(M_NOT_WAITING);
#ifdef HAVE_THREADS
I_lock_mutex(&ms_ServerList_mutex);
I_LockMutex(&ms_ServerList_mutex);
ms_ServerList = server_list;
I_unlock_mutex(ms_ServerList_mutex);
I_UnlockMutex(ms_ServerList_mutex);
#else
CL_QueryServerList(server_list);
free(server_list);
@@ -6783,7 +6796,7 @@ static void M_SearchServerList(void)
serverlistsearchedcount = 0;
#ifdef HAVE_THREADS
I_lock_mutex(&ms_ServerList_mutex);
I_LockMutex(&ms_ServerList_mutex);
#endif
for (UINT32 i = 0; i < serverlistcount; ++i)
@@ -6794,7 +6807,7 @@ static void M_SearchServerList(void)
}
#ifdef HAVE_THREADS
I_unlock_mutex(ms_ServerList_mutex);
I_UnlockMutex(ms_ServerList_mutex);
#endif
if (menuinput.length > 0)
@@ -7160,11 +7173,11 @@ static void M_CheckMODVersion(int id)
{
sprintf(updatestring, UPDATE_ALERT_STRING, VERSIONSTRING, updatecheck);
#ifdef HAVE_THREADS
I_lock_mutex(&m_menu_mutex);
I_LockMutex(&m_menu_mutex);
#endif
M_StartMessage(updatestring, NULL, MM_NOTHING);
#ifdef HAVE_THREADS
I_unlock_mutex(m_menu_mutex);
I_UnlockMutex(m_menu_mutex);
#endif
}
}
@@ -7210,13 +7223,13 @@ static void M_ConnectMenu(INT32 choice)
itemOn = 0;
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
I_lock_mutex(&ms_QueryId_mutex);
I_LockMutex(&ms_QueryId_mutex);
{
ms_QueryId++;
}
I_unlock_mutex(ms_QueryId_mutex);
I_UnlockMutex(ms_QueryId_mutex);
I_lock_mutex(&ms_ServerList_mutex);
I_LockMutex(&ms_ServerList_mutex);
{
if (ms_ServerList)
{
@@ -7224,7 +7237,7 @@ static void M_ConnectMenu(INT32 choice)
ms_ServerList = NULL;
}
}
I_unlock_mutex(ms_ServerList_mutex);
I_UnlockMutex(ms_ServerList_mutex);
#ifdef UPDATE_ALERT
Spawn_masterserver_thread("check-new-version", Check_new_version_thread);
@@ -7494,7 +7507,7 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade)
if ((lumpnum = W_CheckNumForName(va("%sE", mapname))) != LUMPERROR)
mappingforencore = (patch_t *)W_CachePatchNum(lumpnum, PU_PATCH);*/
V_DrawFixedPatch((x+w)<<FRACBITS, (y)<<FRACBITS, FRACUNIT/2, V_FLIP, PictureOfLevel, 0);
V_DrawFixedPatch((x+w)<<FRACBITS, (y)<<FRACBITS, FRACUNIT/2, V_FLIP, PictureOfLevel, NULL);
{
static angle_t rubyfloattime = 0;
@@ -7585,7 +7598,6 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade)
static void M_DrawServerMenu(void)
{
M_DrawLevelSelectOnly(false, false);
#ifdef MASTERSERVER
if (currentMenu == &MP_ServerDef && cv_advertise.value) // Remind players where they're hosting.
@@ -7900,7 +7912,7 @@ static void M_HandleConnectIP(INT32 choice)
if (exitmenu)
{
if (currentMenu->prevMenu)
M_SetupNextMenu (currentMenu->prevMenu);
M_SetupNextMenu(currentMenu->prevMenu);
else
M_ClearMenus(true);
}
@@ -7946,6 +7958,7 @@ static void M_DrawSetupMultiPlayerMenu(void)
UINT8 i;
UINT8 s, w;
const UINT8 *flashcol = V_GetStringColormap(highlightflags);
INT32 skinnum = 0;
INT32 statx, staty;
UINT32 speenframe;
INT32 sltw, actw, hetw;
@@ -8159,7 +8172,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+40+GRIDSTATOFFSET)<<FRACBITS, (staty+80)<<FRACBITS, FRACUNIT>>1, 0, statud, flashcol);
// bg
V_DrawFixedPatch(((statx+48+GRIDSTATOFFSET)<<FRACBITS)+(FRACUNIT>>1), (staty+73)<<FRACBITS, FRACUNIT>>1, 0, statbg, 0);
V_DrawFixedPatch(((statx+48+GRIDSTATOFFSET)<<FRACBITS)+(FRACUNIT>>1), (staty+73)<<FRACBITS, FRACUNIT>>1, 0, statbg, NULL);
for (i = 0; i < numskins; i++) // draw the stat dots
{
@@ -8218,7 +8231,7 @@ static void M_DrawSetupMultiPlayerMenu(void)
V_DrawFixedPatch((statx+64)<<FRACBITS, staty<<FRACBITS, FRACUNIT, 0, statlr, flashcol);
V_DrawFixedPatch((statx+24)<<FRACBITS, (staty+22)<<FRACBITS, FRACUNIT, 0, statud, flashcol);
// bg
V_DrawFixedPatch((statx+34)<<FRACBITS, (staty+10)<<FRACBITS, FRACUNIT, 0, statbg, 0);
V_DrawFixedPatch((statx+34)<<FRACBITS, (staty+10)<<FRACBITS, FRACUNIT, 0, statbg, NULL);
for (i = 0; i < numskins; i++) // draw the stat dots
{
@@ -8268,10 +8281,9 @@ static void M_DrawSetupMultiPlayerMenu(void)
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);
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);
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);
}
break;
@@ -8310,14 +8322,12 @@ static void M_DrawSetupMultiPlayerMenu(void)
if (setupm_skinselect < numskins)
{
UINT8 *cmap = R_GetTranslationColormap(setupm_skinselect, setupm_fakecolor, GTC_MENUCACHE);
cursor = facewantprefix[skinsorted[setupm_skinselect]];
V_DrawFixedPatch(((curx-8) << FRACBITS), ((cury-8) << FRACBITS), FRACUNIT, 0, cursor, cmap);
}
else
{
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);
}
@@ -8381,7 +8391,6 @@ static void M_DrawSetupMultiPlayerMenu(void)
else
{
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);
}
@@ -8506,7 +8515,7 @@ static void M_DrawSetupMultiPlayerMenu(void)
switch (cv_skinselectmenu.value)
{
case SKINMENUTYPE_2D:
skintodisplay = setupm_fakeskin;
skintodisplay = (UINT8)setupm_fakeskin;
if (setupm_skinlockedselect) // show the skin we are trying to select
skintodisplay = skinstats[setupm_skinxpos][setupm_skinypos][setupm_skinselect];
else if (skinstatscount[setupm_skinxpos][setupm_skinypos] && itemOn == 1)
@@ -8514,19 +8523,22 @@ static void M_DrawSetupMultiPlayerMenu(void)
break;
case SKINMENUTYPE_EXTENDED:
case SKINMENUTYPE_GRID:
skintodisplay = (itemOn == 1 && setupm_skinselect < numskins ? skinsorted[setupm_skinselect] : setupm_fakeskin);
skintodisplay = ((itemOn == 1 && (setupm_skinselect < numskins)) ? skinsorted[setupm_skinselect] : (UINT8)setupm_fakeskin);
break;
default:
skintodisplay = setupm_fakeskin;
skintodisplay = (UINT8)setupm_fakeskin;
break;
}
const INT32 skinnum = R_SkinAvailable(skins[skintodisplay].name);
if (skintodisplay >= MAXSKINS)
skintodisplay = 0;
if (skinnum != -1)
sprdef = &skins[skinnum].spritedef;
else
sprdef = &skins[0].spritedef;
skinnum = R_SkinAvailable(skins[skintodisplay].name);
if (skinnum < 0 || skinnum >= MAXSKINS)
skinnum = 0;
sprdef = &skins[skinnum].spritedef;
if (!sprdef->numframes) // No frames ??
return; // Can't render!
@@ -8535,37 +8547,59 @@ static void M_DrawSetupMultiPlayerMenu(void)
if (frame >= sprdef->numframes) // Walking animation missing
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
V_DrawFill(mx + 36 - (charw/2), my+65, charw, 84, 239);
#undef charw
// draw player sprite
if (setupm_fakecolor) // inverse should never happen
{
UINT8 *colormap = R_GetTranslationColormap(skintodisplay, setupm_fakecolor, GTC_MENUCACHE);
if (skins[skintodisplay].flags & SF_HIRES)
#ifdef HWRENDER
md2_t *md2 = &md2_playermodels[skinnum];
#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)
{
V_DrawFixedPatch((mx+36)<<FRACBITS,
(my+131)<<FRACBITS,
skins[skintodisplay].highresscale,
flags, patch, colormap);
const angle_t ROTATE_PER_TIC = (UINT64)ANGLE_45 * cv_skinselectspin.value / TICRATE;
angle_t angle = I_GetTime()*ROTATE_PER_TIC + FixedMul(cv_uncappedhud.value ? renderdeltatics : FRACUNIT, ROTATE_PER_TIC);
HWR_Draw2DModel(md2, mx, my, skinnum, (skincolors_t)setupm_fakecolor, colormap, 8*FRACUNIT/3, frame, angle);
}
else
V_DrawMappedPatch(mx+36, my+131, flags, patch, colormap);
#endif
{
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
@@ -9866,7 +9900,7 @@ static void M_DrawLocalSkinMenu(void)
spriteframe_t *sprframe;
patch_t *patch;
UINT8 frame;
INT16 skintodisplay;
INT32 skintodisplay = 0;
UINT32 speenframe;
skin_t displayskin;
@@ -9897,12 +9931,12 @@ static void M_DrawLocalSkinMenu(void)
// skin 0 is default player sprite
skintodisplay = R_AnySkinAvailable(cv_fakelocalskin.string);
if (skintodisplay == -1)
if (skintodisplay < 0)
{
// ATTEMPT TO FIND REAL SKIN
skintodisplay = R_AnySkinAvailable(cv_skin.string);
if (skintodisplay == -1) // STILL NOTHIN? use sonic instead
if (skintodisplay < 0) // STILL NOTHIN? use sonic instead
{
skintodisplay = 0;
}
@@ -9919,24 +9953,10 @@ static void M_DrawLocalSkinMenu(void)
if (frame >= sprdef->numframes) // Walking animation missing
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
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);
V_DrawMappedPatch(mx, my+50, 0, (patch_t *)W_CachePatchName(displayskin.facewant, PU_PATCH), colormap);
@@ -9949,13 +9969,48 @@ static void M_DrawLocalSkinMenu(void)
else
V_DrawString(mx+20, my+118, V_ALLOWLOWERCASE|highlightflags, displayskin.realname);
if (displayskin.flags & SF_HIRES)
// draw player sprite
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)
{
V_DrawFixedPatch((mx+220)<<FRACBITS, (my+120)<<FRACBITS, displayskin.highresscale, flags, patch, colormap);
const angle_t ROTATE_PER_TIC = (UINT64)ANGLE_45 * cv_skinselectspin.value / TICRATE;
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
V_DrawMappedPatch(mx+220, my+120, flags, patch, colormap);
#undef charw
#endif
{
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
+1 -1
View File
@@ -215,7 +215,7 @@ void M_SetupNextMenu(menu_t *menudef);
void M_ClearMenus(boolean callexitmenufunc);
#ifdef HAVE_THREADS
extern I_mutex m_menu_mutex;
extern I_Mutex m_menu_mutex;
#endif
extern menu_t *currentMenu;
+24 -16
View File
@@ -1205,6 +1205,10 @@ static menuitem_t OP_FocusOptionsMenu[] =
{IT_STRING|IT_CVAR, NULL, "Show \"FOCUS LOST\"", &cv_showfocuslost, 100},
{IT_STRING|IT_CVAR, NULL, "Visible Mouse", &cv_mousevisible, 120},
{IT_STRING|IT_CVAR, NULL, "Gamepad LED Color While Unfocused ", &cv_gamepadledifunfocused, 140},
{IT_STRING|IT_CVAR, NULL, "Gamepad Rumble While Unfocused", &cv_rumbleifunfocused, 150},
};
static const char* OP_FocusOptionsTooltips[] =
@@ -1216,6 +1220,8 @@ static const char* OP_FocusOptionsTooltips[] =
"Set manual framerate cap while the game is unfocused.",
"Should the FOCUS LOST window appear\n while the game is unfocused?",
"Displays the mouse cursor while the game is in focus.",
"Should gamepad LED indicator change color when unfocused?",
"Should gamepad rumble apply when unfocused?",
};
static menuitem_t OP_DataOptionsMenu[] =
@@ -1633,33 +1639,34 @@ static menuitem_t OP_AccessibilityMenu[] =
{IT_STRING|IT_CVAR|IT_CV_SLIDER, NULL, "Saturation", &cv_globalsaturation, 25},
{IT_SUBMENU|IT_STRING, NULL, "Video Color Settings...", &OP_ColorOptionsDef, 30},
{IT_STRING|IT_CVAR, NULL, "Midnight Channel Flicker", &cv_lessflicker, 35},
{IT_STRING|IT_CVAR, NULL, "Reduce Effects", &cv_reducevfx, 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, 40},
{IT_STRING|IT_CVAR, NULL, "Minimum Sector Brightness", &cv_secbright, 45},
#ifdef HWRENDER
{IT_STRING|IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 45},
{IT_STRING|IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 50},
#endif
{IT_STRING|IT_CVAR, NULL, "Water Surface Ripples", &cv_ripplewater, 50},
{IT_STRING|IT_CVAR, NULL, "Water Surface Ripples", &cv_ripplewater, 55},
{IT_STRING|IT_CVAR, NULL, "Fade Players near Camera", &cv_playerfade, 55},
{IT_STRING|IT_CVAR, NULL, "Fade Players near Camera", &cv_playerfade, 60},
{IT_STRING|IT_CVAR, NULL, "Quake Screenshakes", &cv_screenquake, 60},
{IT_STRING|IT_CVAR, NULL, "Quake Screenshakes", &cv_screenquake, 65},
{IT_CALL|IT_STRING, NULL, "Camera Options...", M_CameraMenu, 65},
{IT_CALL|IT_STRING, NULL, "Camera Options...", M_CameraMenu, 70},
{IT_HEADER, NULL, "Audio", NULL, 75},
{IT_HEADER, NULL, "Audio", NULL, 80},
{IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 85},
{IT_STRING|IT_CVAR, NULL, "Same Sound Limit", &cv_samesoundlimit, 90},
{IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 90},
{IT_STRING|IT_CVAR, NULL, "Same Sound Limit", &cv_samesoundlimit, 95},
{IT_HEADER, NULL, "Controls", NULL, 100},
{IT_HEADER, NULL, "Controls", NULL, 105},
{IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P1)", &cv_autoaccel[0], 110},
{IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P2)", &cv_autoaccel[1], 115},
{IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P3)", &cv_autoaccel[2], 120},
{IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P4)", &cv_autoaccel[3], 125},
{IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P1)", &cv_autoaccel[0], 115},
{IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P2)", &cv_autoaccel[1], 120},
{IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P3)", &cv_autoaccel[2], 125},
{IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P4)", &cv_autoaccel[3], 130},
};
static const char* OP_AccessibilityTooltips[] =
@@ -1669,10 +1676,11 @@ static const char* OP_AccessibilityTooltips[] =
"Gamma (brightness) of the game.",
"Saturation 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.",
"Sets minimum sector brightness, useful for dark areas",
#ifdef HWRENDER
"Should the game do Screen Textures? Provides a good boost to frames\nat the cost of some visual effects not working when disabled.",
"Disabling Screen Textures will disable the Underwater and Heat screen effects.",
#endif
"Toggles the ripple effect on water surfaces",
"Fades other Players that are close to the camera in and out",
+7 -6
View File
@@ -540,7 +540,7 @@ static boolean M_BackupConfig(const char *filename)
void M_SaveConfig(const char *filename)
{
FILE *f;
char *filepath;
CLEANUP(Z_Pfree) char *filepath = NULL;
// make sure not to write back the config until it's been correctly loaded
if (!loaded_config)
@@ -558,7 +558,7 @@ void M_SaveConfig(const char *filename)
// append srb2home to beginning of filename
// but check if srb2home isn't already there, first
if (!strstr(filename, srb2home))
filepath = va(pandf,srb2home, filename);
filepath = Z_StrDup(va(pandf, srb2home, filename));
else
filepath = Z_StrDup(filename);
@@ -1346,14 +1346,15 @@ void M_MinimapGenerate(void)
minigen = AM_MinimapGenerate(mul);
if (minigen == NULL || minigen->buf == NULL)
goto failure;
{
CONS_Alert(CONS_ERROR, M_GetText("Couldn't create %s\n"), filepath);
return;
}
M_CreateScreenShotPalette();
ret = M_SavePNG(filepath, minigen->buf, minigen->w, minigen->h, screenshot_palette);
failure:
if (minigen->buf != NULL)
free(minigen->buf);
free(minigen->buf);
if (ret)
{
+9 -9
View File
@@ -110,12 +110,12 @@ perfstatrow_t rendertime_rows[] = {
{"ui ", "UI render: ", &ps_uitime, PS_TIME},
{"finupdt", "I_FinishUpdate:", &ps_swaptime, PS_TIME},
{0}
{}
};
perfstatrow_t gamelogicbrief_row[] = {
{"logic ", "Game logic: ", &ps_tictime, PS_TIME},
{0}
{}
};
perfstatrow_t commoncounter_rows[] = {
@@ -123,20 +123,20 @@ perfstatrow_t commoncounter_rows[] = {
{"sprites", "Sprites: ", &ps_numsprites, 0},
{"drwnode", "Drawnodes: ", &ps_numdrawnodes, 0},
{"plyobjs", "Polyobjects: ", &ps_numpolyobjects, 0},
{0}
{}
};
perfstatrow_t interpolation_rows[] = {
{"intpfrc", "Interp frac: ", &ps_interp_frac, 0},
{"intplag", "Interp lag: ", &ps_interp_lag, 0},
{0}
{}
};
#ifdef HWRENDER
perfstatrow_t batchcount_rows[] = {
{"polygon", "Polygons: ", &ps_hw_numpolys, 0},
{"vertex ", "Vertices: ", &ps_hw_numverts, 0},
{0}
{}
};
perfstatrow_t batchcalls_rows[] = {
@@ -145,7 +145,7 @@ perfstatrow_t batchcalls_rows[] = {
{"texture", "Textures: ", &ps_hw_numtextures, 0},
{"polyflg", "Polyflags: ", &ps_hw_numpolyflags, 0},
{"colors ", "Colors: ", &ps_hw_numcolors, 0},
{0}
{}
};
#endif
@@ -164,7 +164,7 @@ perfstatrow_t gamelogic_rows[] = {
{" lthinkf", " LUAh_ThinkFrame:", &ps_lua_thinkframe_time, PS_TIME|PS_LEVEL},
{" lpostthinkf", " LUAh_PostThinkFrame:", &ps_lua_postthinkframe_time, PS_TIME|PS_LEVEL},
{" other ", " Other: ", &ps_otherlogictime, PS_TIME|PS_LEVEL},
{0}
{}
};
perfstatrow_t thinkercount_rows[] = {
@@ -176,13 +176,13 @@ perfstatrow_t thinkercount_rows[] = {
{" precip ", " Precipitation: ", &ps_precipcount, PS_LEVEL},
{" other ", " Other: ", &ps_otherthcount, PS_LEVEL},
{" remove ", " Pending removal:", &ps_removecount, PS_LEVEL},
{0}
{}
};
perfstatrow_t misc_calls_rows[] = {
{"lmhook", "Lua mobj hooks: ", &ps_lua_mobjhooks, PS_LEVEL},
{"chkpos", "P_CheckPosition:", &ps_checkposition_calls, PS_LEVEL},
{0}
{}
};
// Sample collection status for averaging.
+37 -32
View File
@@ -41,11 +41,11 @@ static time_t MSLastPing;
static char *MSRules;
#ifdef HAVE_THREADS
static I_mutex MSMutex;
static I_cond MSCond;
static I_Mutex MSMutex;
static I_Cond MSCond;
# define Lock_state() I_lock_mutex (&MSMutex)
# define Unlock_state() I_unlock_mutex (MSMutex)
# define Lock_state() I_LockMutex (&MSMutex)
# define Unlock_state() I_UnlockMutex (MSMutex)
#else/*HAVE_THREADS*/
# define Lock_state()
# define Unlock_state()
@@ -90,10 +90,10 @@ consvar_t cv_masterserver_nagattempts = {"masterserver_nagattempts", "5", CV_SAV
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
int ms_QueryId = 0;
I_mutex ms_QueryId_mutex;
I_Mutex ms_QueryId_mutex;
msg_server_t *ms_ServerList = NULL;
I_mutex ms_ServerList_mutex;
I_Mutex ms_ServerList_mutex;
#endif
UINT16 current_port = 0;
@@ -129,11 +129,11 @@ void AddMServCommands(void)
static void WarnGUI (void)
{
#ifdef HAVE_THREADS
I_lock_mutex(&m_menu_mutex);
I_LockMutex(&m_menu_mutex);
#endif
M_PopupMasterServerConnectError();
#ifdef HAVE_THREADS
I_unlock_mutex(m_menu_mutex);
I_UnlockMutex(m_menu_mutex);
#endif
}
@@ -168,12 +168,12 @@ char *GetMODVersion(int id)
c = HMS_compare_mod_version(buffer, 16);
#ifdef HAVE_THREADS
I_lock_mutex(&ms_QueryId_mutex);
I_LockMutex(&ms_QueryId_mutex);
{
if (id != ms_QueryId)
c = -1;
}
I_unlock_mutex(ms_QueryId_mutex);
I_UnlockMutex(ms_QueryId_mutex);
#endif
if (c > 0)
@@ -219,8 +219,9 @@ static void Get_masterserver_rules(boolean checkfirst)
if (HMS_fetch_rules(rules, sizeof rules))
{
Lock_state();
Z_Free(MSRules);
MSRules = Z_StrDup(rules);
if (MSRules)
free(MSRules);
MSRules = strdup(rules);
if (MSRegistered == true)
{
@@ -340,7 +341,7 @@ Finish_unlist (void)
Unlock_state();
#ifdef HAVE_THREADS
I_wake_all_cond(&MSCond);
I_WakeAllCond(&MSCond);
#endif
}
}
@@ -376,7 +377,7 @@ New_server_id (void)
Lock_state();
{
*id = ++MSId;
I_wake_all_cond(&MSCond);
I_WakeAllCond(&MSCond);
}
Unlock_state();
return id;
@@ -391,7 +392,7 @@ Register_server_thread (int *id)
{
/* wait for previous unlist to finish */
while (*id == MSId && MSRegistered)
I_hold_cond(&MSCond, MSMutex);
I_HoldCond(&MSCond, MSMutex);
same = ( *id == MSId );/* it could have been a while */
}
@@ -443,7 +444,7 @@ Change_masterserver_thread (char *api)
Lock_state();
{
while (MSRegistered)
I_hold_cond(&MSCond, MSMutex);
I_HoldCond(&MSCond, MSMutex);
}
Unlock_state();
@@ -463,9 +464,9 @@ void RegisterServer(void)
{
#ifdef MASTERSERVER
#ifdef HAVE_THREADS
I_spawn_thread(
(void)!I_SpawnThread(
"register-server",
(I_thread_fn)Register_server_thread,
(I_ThreadFn)Register_server_thread,
New_server_id()
);
#else
@@ -477,9 +478,9 @@ void RegisterServer(void)
static void UpdateServer(void)
{
#ifdef HAVE_THREADS
I_spawn_thread(
(void)!I_SpawnThread(
"update-server",
(I_thread_fn)Update_server_thread,
(I_ThreadFn)Update_server_thread,
Server_id()
);
#else
@@ -491,9 +492,9 @@ void UnregisterServer(void)
{
#ifdef MASTERSERVER
#ifdef HAVE_THREADS
I_spawn_thread(
(void)!I_SpawnThread(
"unlist-server",
(I_thread_fn)Unlist_server_thread,
(I_ThreadFn)Unlist_server_thread,
Server_id()
);
#else
@@ -507,7 +508,7 @@ char *GetMasterServerRules(void)
char *rules;
Lock_state();
rules = MSRules ? Z_StrDup(MSRules) : NULL;
rules = MSRules ? strdup(MSRules) : NULL;
Unlock_state();
return rules;
@@ -556,14 +557,18 @@ void MasterClient_Ticker(void)
static void
Set_api (const char *api)
{
char *dapi = strdup(api);
#ifdef HAVE_THREADS
I_spawn_thread(
"change-masterserver",
(I_thread_fn)Change_masterserver_thread,
strdup(api)
);
if (!I_SpawnThread(
"change-masterserver",
(I_ThreadFn)Change_masterserver_thread,
dapi
))
{
free(dapi);
}
#else
Finish_masterserver_change(strdup(api));
Finish_masterserver_change(dapi);
#endif
}
@@ -571,9 +576,9 @@ void
Get_rules (void)
{
#ifdef HAVE_THREADS
I_spawn_thread(
"get-masterserver-rules",
(I_thread_fn)Get_masterserver_rules_thread,
(void)!I_SpawnThread(
"get-masterserver-rules",
(I_ThreadFn)Get_masterserver_rules_thread,
NULL
);
#else
+2 -2
View File
@@ -69,10 +69,10 @@ extern consvar_t cv_rendezvousserver;
#ifdef HAVE_THREADS
extern int ms_QueryId;
extern I_mutex ms_QueryId_mutex;
extern I_Mutex ms_QueryId_mutex;
extern msg_server_t *ms_ServerList;
extern I_mutex ms_ServerList_mutex;
extern I_Mutex ms_ServerList_mutex;
#endif
#ifdef MASTERSERVER
void RegisterServer(void);
+4 -4
View File
@@ -5977,7 +5977,7 @@ void A_Boss7Chase(void *thing)
if (actor->flags2 & MF2_FRET)
{
P_SetMobjState(actor, S_BLACKEGG_DESTROYPLAT1);
S_StartSound(0, sfx_s3k53);
S_StartSound(NULL, sfx_s3k53);
actor->flags2 &= ~MF2_FRET;
return;
}
@@ -6011,7 +6011,7 @@ void A_Boss7Chase(void *thing)
{
// Punch him!
P_SetMobjState(actor, actor->info->meleestate);
S_StartSound(0, sfx_begrnd); // warning sound
S_StartSound(NULL, sfx_begrnd); // warning sound
return;
}
}
@@ -6057,7 +6057,7 @@ void A_Boss7Chase(void *thing)
case 2: // Homing Missile
A_FaceTarget(actor);
P_SetMobjState(actor, actor->info->missilestate);
S_StartSound(0, sfx_beflap);
S_StartSound(NULL, sfx_beflap);
break;
}
@@ -10739,7 +10739,7 @@ void A_BrakChase(void *thing)
{
actor->reactiontime--;
if (actor->reactiontime == 0 && actor->type == MT_CYBRAKDEMON)
S_StartSound(0, sfx_bewar1 + P_RandomKey(4));
S_StartSound(NULL, sfx_bewar1 + P_RandomKey(4));
}
// modify target threshold
+14 -13
View File
@@ -3606,10 +3606,10 @@ static void P_CalculatePrecipFloor(precipmobj_t *mobj)
// Just the identification of a precip thinker. The thinker
// should never actually be called!
//
void P_NullPrecipThinker(precipmobj_t *mobj)
FUNCNORETURN void P_NullPrecipThinker(precipmobj_t *mobj)
{
(void)mobj;
I_Assert("P_NullPrecipThinker should not be called" == 0);
I_Error("P_NullPrecipThinker should not be called");
}
boolean P_PrecipThinker(precipmobj_t *mobj)
@@ -4012,7 +4012,7 @@ static void P_Boss3Thinker(mobj_t *mobj)
if ((UINT32)mobj->extravalue1 + TICRATE*2 < leveltime)
{
mobj->extravalue1 = (INT32)leveltime;
S_StartSound(0, sfx_buzz1);
S_StartSound(NULL, sfx_buzz1);
}
// If in the center, check to make sure
@@ -4631,7 +4631,7 @@ static void P_Boss7Thinker(mobj_t *mobj)
if (mobj->health > 0)
mobj->health--;
S_StartSound(0, (mobj->health) ? sfx_behurt : sfx_bedie2);
S_StartSound(NULL, (mobj->health) ? sfx_behurt : sfx_bedie2);
mobj->reactiontime /= 3;
@@ -4670,7 +4670,7 @@ static void P_Boss7Thinker(mobj_t *mobj)
INT32 i;
mobj->state->nextstate = mobj->info->painstate; // Reset
S_StartSound(0, sfx_bedeen);
S_StartSound(NULL, sfx_bedeen);
for (i = 0; i < MAXPLAYERS; i++)
{
@@ -4694,7 +4694,7 @@ static void P_Boss7Thinker(mobj_t *mobj)
mobj->state->nextstate = mobj->info->spawnstate;
// Laugh
S_StartSound(0, sfx_bewar1 + P_RandomKey(4));
S_StartSound(NULL, sfx_bewar1 + P_RandomKey(4));
}
}
}
@@ -4714,7 +4714,7 @@ static void P_Boss7Thinker(mobj_t *mobj)
var2 = 2*TICRATE + (80<<16);
A_LobShot(mobj);
S_StartSound(0, sfx_begoop);
S_StartSound(NULL, sfx_begoop);
}
}
else if (mobj->state == &states[S_BLACKEGG_SHOOT2])
@@ -4738,7 +4738,7 @@ static void P_Boss7Thinker(mobj_t *mobj)
S_StopSound(missile);
if (leveltime & 1)
S_StartSound(0, sfx_beshot);
S_StartSound(NULL, sfx_beshot);
}
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;
mobj_t *mo2;
S_StartSound(0, sfx_befall);
S_StartSound(NULL, sfx_befall);
z = mobj->floorz;
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);
// Laugh
S_StartSound(0, sfx_bewar1 + P_RandomKey(4));
S_StartSound(NULL, sfx_bewar1 + P_RandomKey(4));
}
P_SetMobjState(mobj, mobj->info->spawnstate);
}
else if (mobj->state == &states[mobj->info->deathstate] && mobj->tics == mobj->state->tics)
S_StartSound(0, sfx_bedie1 + (P_RandomFixed() & 1));
S_StartSound(NULL, sfx_bedie1 + (P_RandomFixed() & 1));
}
// Metal Sonic battle boss
@@ -10711,7 +10711,7 @@ void P_SpawnPlayer(INT32 playernum)
// the dead body mobj retains the skin through the 'spritedef' override).
mobj->skin = &skins[p->skin];
mobj->localskin = (p->localskin ? K_GetPlayerSkin(p) : 0);
mobj->localskin = (p->localskin ? K_GetPlayerSkin(p) : NULL);
mobj->skinlocal = p->skinlocal;
mobj->health = p->health;
@@ -12354,8 +12354,9 @@ 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)
{
if (!pl)
if (!pl || cv_reducevfx.value) // no palette flashing with reducevfx
return;
pl->flashcount = duration;
pl->flashpal = type;
}
+1 -2
View File
@@ -1385,8 +1385,7 @@ static void Polyobj_rotateThings(polyobj_t *po, vector2_t origin, angle_t delta,
if (mo->player)
{
angle_t localangle = P_GetLocalAngle(mo->player);
P_ForceLocalAngle(mo->player, localangle + delta);
P_ForceLocalAngle(mo->player, P_GetLocalAngle(mo->player) + delta);
}
}
}
+3 -5
View File
@@ -320,9 +320,7 @@ void P_AddGradesForMare(INT16 i, UINT8 mare, char *gtext)
*/
void P_DeleteGrades(INT16 i)
{
if (mapheaderinfo[i]->grades)
Z_Free(mapheaderinfo[i]->grades);
Z_Free(mapheaderinfo[i]->grades);
mapheaderinfo[i]->grades = NULL;
mapheaderinfo[i]->numGradedMares = 0;
}
@@ -1022,7 +1020,7 @@ void P_WriteThings(lumpnum_t lumpnum)
size_t i, length;
mapthing_t *mt;
UINT8 *data;
savebuffer_t save = {0};
savebuffer_t save = {};
INT16 temp;
data = W_CacheLumpNum(lumpnum, PU_LEVEL);
@@ -1166,7 +1164,7 @@ static void P_LoadLineDefs2(void)
for (; i--; ld++)
{
ld->frontsector = sides[ld->sidenum[0]].sector; //e6y: Can't be -1 here
ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : 0;
ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : NULL;
// Repeat count for midtexture
if ((ld->flags & ML_EFFECT5) && (ld->sidenum[1] != 0xffff))
+4 -5
View File
@@ -4579,8 +4579,8 @@ static inline void P_AddFFloorToList(sector_t *sec, ffloor_t *ffloor)
if (!sec->ffloors)
{
sec->ffloors = ffloor;
ffloor->next = 0;
ffloor->prev = 0;
ffloor->next = NULL;
ffloor->prev = NULL;
return;
}
@@ -4588,7 +4588,7 @@ static inline void P_AddFFloorToList(sector_t *sec, ffloor_t *ffloor)
rover->next = ffloor;
ffloor->prev = rover;
ffloor->next = 0;
ffloor->next = NULL;
}
/** Adds a 3Dfloor.
@@ -6221,8 +6221,7 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate)
// Allocate each list
for (i = 0; i < numsectors; i++)
if(secthinkers[i].thinkers)
Z_Free(secthinkers[i].thinkers);
Z_Free(secthinkers[i].thinkers);
Z_Free(secthinkers);
+8 -9
View File
@@ -16,14 +16,14 @@
#include "doomdef.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __GNUG__
#pragma interface
#endif
#ifdef __cplusplus
extern "C" {
#endif
extern tic_t leveltime;
// Called by G_Ticker. Carries out all thinking of enemies and players.
@@ -42,14 +42,13 @@ mobj_t *P_SetTarget2(mobj_t **mo, mobj_t *target
#endif
);
#ifdef __cplusplus
}
#endif
#ifdef PARANOIA
#define P_SetTarget(...) P_SetTarget2(__VA_ARGS__, __FILE__, __LINE__)
#else
#define P_SetTarget P_SetTarget2
#endif
#ifdef __cplusplus
} // extern "C"
#endif
#endif
-2
View File
@@ -14,8 +14,6 @@
#include "doomdef.h"
#include "g_game.h"
#include <algorithm>
#include "r_fps.h"
#include "r_local.h"
#include "r_state.h"
+1 -2
View File
@@ -1720,8 +1720,7 @@ void R_InitData(void)
void R_ClearTextureNumCache(boolean btell)
{
if (tidcache)
Z_Free(tidcache);
Z_Free(tidcache);
tidcache = NULL;
if (btell)
CONS_Debug(DBG_SETUP, "Fun Fact: There are %d textures used in this map.\n", tidcachelen);
+8 -2
View File
@@ -289,8 +289,14 @@ void R_GenerateBlendTables(void)
state->LocalPalette = static_cast<RGBA_t *>(memcpy(malloc(palsize), pLocalPalette, palsize));
state->gammaCorrectedPalette = static_cast<RGBA_t *>(memcpy(malloc(palsize), pGammaCorrectedPalette, palsize));
I_spawn_thread("blend-tables",
R_GenerateBlendTables_Thread, state);
if (!I_SpawnThread("blend-tables",
R_GenerateBlendTables_Thread, state))
{
free(state->gammaCorrectedPalette);
free(state->LocalPalette);
free(state);
I_Error("R_GenerateBlendTables: Failed to generate BlendTables\n"); // should we just retry on main thread instead?
}
#else
struct GenerateBlendTables_State state = {pLocalPalette, pGammaCorrectedPalette};
R_GenerateBlendTables_Core(&state);
+9 -13
View File
@@ -925,11 +925,11 @@ void R_ExecuteSetViewSize(void)
viewheight = vid.height;
if (splitscreen)
{
viewheight >>= 1;
if (splitscreen > 1)
{
viewwidth >>= 1;
if (splitscreen > 1)
viewwidth >>= 1;
}
centerx = viewwidth/2;
@@ -956,13 +956,9 @@ void R_ExecuteSetViewSize(void)
screenheightarray[i] = (INT16)viewheight;
}
if (ds_su)
Z_Free(ds_su);
if (ds_sv)
Z_Free(ds_sv);
if (ds_sz)
Z_Free(ds_sz);
Z_Free(ds_su);
Z_Free(ds_sv);
Z_Free(ds_sz);
ds_su = ds_sv = ds_sz = NULL;
memset(scalelight, 0xFF, sizeof(scalelight));
@@ -1018,8 +1014,8 @@ static void R_InitViewMapping(void)
for (INT32 i = 0; i < j; i++)
{
fixed_t dy = (i - viewheight*8)<<FRACBITS;
dy = FixedMul(abs(dy), fovtan);
fixed_t dy = abs(i - viewheight*8) << FRACBITS;
dy = FixedMul(dy, fovtan);
yslopetab[i] = FixedDiv(centerx*FRACUNIT, dy);
}
}
@@ -1087,7 +1083,7 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y)
ret = &subsectors[nodenum & ~NF_SUBSECTOR];
for (i = 0; i < ret->numlines; i++)
if (P_PointOnLineSide(x, y, segs[ret->firstline + i].linedef) != segs[ret->firstline + i].side)
return 0;
return NULL;
return ret;
}
+2 -4
View File
@@ -405,10 +405,8 @@ static void Patch_FreeData(patch_t *patch)
}*/
#endif
if (patch->columnofs)
Z_Free(patch->columnofs);
if (patch->columns)
Z_Free(patch->columns);
Z_Free(patch->columnofs);
Z_Free(patch->columns);
}
void Patch_Free(patch_t *patch)
+12 -9
View File
@@ -57,8 +57,11 @@ visffloor_t visffloor[MAXFFLOORS] = {};
INT32 numffloors = 0;
//SoM: 3/23/2000: Boom visplane hashing routine.
#define visplane_hash(picnum,lightlevel,height) \
((unsigned)((picnum)*3+(lightlevel)+(height)*7) & VISPLANEHASHMASK)
constexpr unsigned int visplane_hash(const unsigned int picnum, const unsigned int lightlevel,
const unsigned int height)
{
return ((picnum * 3) + lightlevel + (height * 7)) & VISPLANEHASHMASK;
}
//
// Clip values are the solid pixel bounding the range.
@@ -136,7 +139,7 @@ void R_AllocPlaneMemory(void)
}
yslopetab = static_cast<fixed_t*>(Z_Realloc(yslopetab, sizeof(*yslopetab) * (viewheight * 16), PU_STATIC, NULL));
spanstart = static_cast<fixed_t*>(Z_Realloc(spanstart, sizeof(*spanstart) * viewheight, PU_STATIC, NULL));
spanstart = static_cast<INT32*>(Z_Realloc(spanstart, sizeof(*spanstart) * viewheight, PU_STATIC, NULL));
}
//
@@ -451,7 +454,7 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
}
}
hash = visplane_hash(picnum, lightlevel, height);
hash = visplane_hash(picnum, lightlevel, height >> FRACBITS);
for (check = visplanes[hash]; check; check = check->next)
{
@@ -562,7 +565,7 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop)
}
else
{
unsigned hash = visplane_hash(pl->picnum, pl->lightlevel, pl->height);
unsigned hash = visplane_hash(pl->picnum, pl->lightlevel, pl->height >> FRACBITS);
new_pl = new_visplane(hash);
}
@@ -920,12 +923,12 @@ static void R_SetSlopePlane(drawspandata_t* ds, pslope_t *slope, fixed_t xpos, f
// m is the v direction vector in view space
ang = ANG2RAD(ANGLE_180 - (angle + plangle));
m->x = cos(ang);
m->z = sin(ang);
m->x = cosf(ang);
m->z = sinf(ang);
// n is the u direction vector in view space
n->x = sin(ang);
n->z = -cos(ang);
n->x = sinf(ang);
n->z = -cosf(ang);
plangle >>= ANGLETOFINESHIFT;
temp = P_GetSlopeZAt(slope, xpos + FINESINE(plangle), ypos + FINECOSINE(plangle));
-1
View File
@@ -246,7 +246,6 @@ static boolean TrimVisplaneBounds(const visplane_t* plane, INT16* start, INT16*
if (!(*start < *end))
return true;
/** Trims a visplane's horizontal gap to match its render area.
*
* Visplanes' minx/maxx may sometimes exceed the area they're
+7 -7
View File
@@ -2231,12 +2231,12 @@ void R_StoreWallRange(INT32 start, INT32 stop)
lowcutslope = std::max(worldbottomslope, worldlowslope) + viewz;
highcutslope = std::min(worldtopslope, worldhighslope) + viewz;
auto check_fof_offscreen = [&](ffloor_t* rover, INT32 bottom, INT32 bottomslope, INT32 top, INT32 topslope)
auto check_fof_offscreen = [&](ffloor_t* rrover, INT32 bottom, INT32 bottomslope, INT32 top, INT32 topslope)
{
return ((P_GetFFloorTopZAt (rover, segleft .x, segleft .y) <= bottom + viewz
&& P_GetFFloorTopZAt (rover, segright.x, segright.y) <= bottomslope + viewz)
|| ( P_GetFFloorBottomZAt (rover, segleft .x, segleft .y) >= top + viewz
&& P_GetFFloorBottomZAt (rover, segright.x, segright.y) >= topslope + viewz));
return ((P_GetFFloorTopZAt (rrover, segleft .x, segleft .y) <= bottom + viewz
&& P_GetFFloorTopZAt (rrover, segright.x, segright.y) <= bottomslope + viewz)
|| ( P_GetFFloorBottomZAt (rrover, segleft .x, segleft .y) >= top + viewz
&& P_GetFFloorBottomZAt (rrover, segright.x, segright.y) >= topslope + viewz));
};
if (frontsector->ffloors && backsector->ffloors)
@@ -2880,7 +2880,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
if (markceiling)
{
if (ceilingplane) //SoM: 3/29/2000: Check for null ceiling planes
ceilingplane = R_CheckPlane (ceilingplane, rw_x, rw_stopx-1);
ceilingplane = R_CheckPlane(ceilingplane, rw_x, rw_stopx-1);
else
markceiling = false;
@@ -2894,7 +2894,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
if (markfloor)
{
if (floorplane) //SoM: 3/29/2000: Check for null planes
floorplane = R_CheckPlane (floorplane, rw_x, rw_stopx-1);
floorplane = R_CheckPlane(floorplane, rw_x, rw_stopx-1);
else
markfloor = false;
+1 -1
View File
@@ -302,7 +302,7 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar)
if (player->mo)
{
player->mo->localskin = 0;
player->mo->localskin = NULL;
player->mo->skinlocal = false;
}
}
+18 -11
View File
@@ -70,7 +70,7 @@ INT16 *screenheightarray = NULL;
typedef struct drawseg_xrange_item_s
{
INT16 x1, x2;
INT32 x1, x2;
drawseg_t *user;
} drawseg_xrange_item_t;
@@ -391,7 +391,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
// allocate space for the frames present and copy sprtemp to it
if (spritedef->numframes && // has been allocated
spritedef->numframes < maxframe) // more frames are defined ?
spritedef->numframes < maxframe) // more frames are defined ?
{
Z_Free(spritedef->spriteframes);
@@ -489,8 +489,8 @@ void R_InitSprites(void)
for (angle = 1; angle < ROTANGLES; angle++)
{
fa = ANG2RAD(FixedAngle((ROTANGDIFF * angle)<<FRACBITS));
rollcosang[angle] = FLOAT_TO_FIXED(cos(-fa));
rollsinang[angle] = FLOAT_TO_FIXED(sin(-fa));
rollcosang[angle] = FLOAT_TO_FIXED(cosf(-fa));
rollsinang[angle] = FLOAT_TO_FIXED(sinf(-fa));
}
#endif
@@ -532,8 +532,8 @@ void R_ClearSprites(void)
visspritecount = numvisiblesprites = clippedvissprites = 0;
}
static INT16 *vissprite_clipbot[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {0};
static INT16 *vissprite_cliptop[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {0};
static INT16 *vissprite_clipbot[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {};
static INT16 *vissprite_cliptop[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {};
static void R_AllocVisSpriteChunkMemory(UINT32 chunk)
{
@@ -658,7 +658,7 @@ void R_DrawMaskedColumn(drawcolumndata_t* dc, column_t *column)
dc->texturemid = basetexturemid;
}
INT32 lengthcol; // column->length : for flipped column function pointers and multi-patch on 2sided wall = texture->height
INT32 lengthcol = 0; // 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)
{
@@ -1577,7 +1577,7 @@ static void R_ProjectSprite(mobj_t *thing)
else
blendmode = thing->blendmode;
if (thing->flags2 & MF2_SHADOW || thing->flags2 & MF2_SHADOW) // actually only the player should use this (temporary invisibility)
if (thing->flags2 & MF2_SHADOW) // actually only the player should use this (temporary invisibility)
trans = tr_trans80; // because now the translucency is set through FF_TRANSMASK
else if (thing->frame & FF_TRANSMASK)
{
@@ -1588,8 +1588,15 @@ static void R_ProjectSprite(mobj_t *thing)
else
trans = 0;
if (cv_playerfade.value && thing->player)
trans = static_cast<INT32>(R_GetThingTransTable(R_DoPlayerFade(thing), static_cast<transnum_t>(trans)));
if (thing->player)
{
// 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..
if (vflip)
@@ -3086,7 +3093,7 @@ static void R_DrawMaskedList(drawnode_t* head)
void R_DrawMasked(maskcount_t* masks, INT32 nummasks)
{
INT32 i;
drawnode_t *heads; /**< Drawnode lists; as many as number of views/portals. */
drawnode_t *heads = NULL; /**< Drawnode lists; as many as number of views/portals. */
heads = static_cast<drawnode_t*>(calloc(nummasks, sizeof(drawnode_t)));
+6 -3
View File
@@ -884,7 +884,7 @@ static void S_StopChannel(INT32 cnum)
if (cnum != i && c->sfxinfo == channels[i].sfxinfo)
break;
c->sfxinfo = 0;
c->sfxinfo = NULL;
}
c->origin = NULL;
@@ -1271,7 +1271,7 @@ static musicdef_t *S_AddMusicCredit(void)
return &musicdefs[chunk][i];
}
struct cursongcredit cursongcredit = {0}; // Currently displayed song credit info
struct cursongcredit cursongcredit = {}; // Currently displayed song credit info
static boolean ReadMusicDefFields(UINT16 wadnum, int line, char *stoken, musicdef_t **defp)
{
@@ -1491,6 +1491,9 @@ musicdef_t *S_FindMusicCredit(const char *musname)
{
def = S_GetMusicCredit(i);
if (!def)
continue;
if (hash != def->hash)
continue;
@@ -1701,7 +1704,7 @@ static void S_UnloadMusic(void)
music.flags = 0;
music.looping = false;
music_refade_cv = 0;
music_refade_cv = NULL;
}
static boolean S_PlayMusic(boolean looping, UINT32 fadeinms)
Loaded 100 of 119 files, more files were not shown because too many files have changed in this diff. Show more