Compare commits

..
85 Commits
Author SHA1 Message Date
Gustaf Alhäll 89cecb88f5 Update license info 2025-12-06 19:45:35 +01:00
Gustaf Alhäll baf5c8d66b Fix music looping on digital 2025-12-06 19:45:32 +01:00
Gustaf Alhäll 72000c4546 Fix memory leak in AATree string trees 2025-12-06 19:45:29 +01:00
Gustaf Alhäll 82b774b2c3 Fix use-after-free when mobj is removed while still playing sounds 2025-12-06 19:45:27 +01:00
Gustaf Alhäll 3818b9ad1a Limit audio channels to 2 2025-12-05 00:22:09 +01:00
Alug ca8e811bd9 sdl_sound: attempt to fix sounds cutting off
i suck at explaining so just trust. :chonkbuncle:
Game sound handling has no idea which sound it is playing/checking, so a sound that ended frees its slot and it might get occupied again without the game knowing
so just encode the channel number into the sound so we can actually check
2025-12-04 17:52:38 +01:00
Alug 97ca034037 sdl_sound: handle explicit float conversions 2025-12-04 17:52:35 +01:00
Alug ac46f7ed00 add missing Fluidsynth ifdefs 2025-12-04 17:52:32 +01:00
Gustaf Alhäll 0afed59329 Fix MIDI music looping 2025-12-04 17:52:30 +01:00
Gustaf Alhäll ec3a1fee70 Tweak audio settings 2025-12-04 17:52:25 +01:00
Alug 5e8c0c3806 Add chorus and reverb settings to MIDI 2025-12-04 17:52:22 +01:00
Gustaf Alhäll 05ea898345 Fix Haiku build 2025-12-04 17:52:11 +01:00
Gustaf Alhäll 0c1fdc0be8 Fine-tune volume settings 2025-12-04 17:52:08 +01:00
Gustaf Alhäll 0e4c72e6f6 Implement MIDI seeking 2025-12-04 17:52:05 +01:00
Alug 29b83903ef delet the bird music resynching stuff
idk who even wants this, its pain, and even more pain to adapt
2025-12-04 17:52:03 +01:00
Alug 1cae09fa11 sdl_audio: use float M_PI for S_CURVE
meant for floats, prevents implicit double conversions
2025-12-04 17:51:59 +01:00
Alug 4a56819bc3 makefile: move openmpt stuff to before sdl stuff
seems to fix linking openmpt without mixer for some reason oh well
2025-12-01 16:49:11 +01:00
Alug 567a48aac3 sdl_sound: fix -Wmaybe-uninitialized warning 2025-12-01 16:49:08 +01:00
Alug d100401c5f this shouldnt be in sourcefile oops 2025-12-01 16:49:05 +01:00
Alug 6dee9fa561 add back "nearest" resampling from mixer
sdls own resampler uses linear interpolation, which sounds super muffled to me
some may like this, but i dont want to change how the game "sounds"
2025-12-01 16:49:01 +01:00
Alug 5bd7a09d9f force 44100khz sample rate
sounds better to me honestly
2025-12-01 16:48:56 +01:00
Alug 47477c2d03 make gme and tracker music slightly louder
prob needs some adjustment, but both were always quite quiet
2025-12-01 16:48:53 +01:00
Alug cd128a1084 lock audio stream in I_PlaySong
seems to fix weird crashes with gme
2025-12-01 16:48:49 +01:00
Alug 34f2afa3d9 add "audiobuffersize" handling
uses the SDL_AUDIO_DEVICE_SAMPLE_FRAMES hint
2025-12-01 16:48:46 +01:00
Alug 22f285edec disable sound precache for sdl sound 2025-12-01 16:48:43 +01:00
Alug 592abdef96 pitch is a float 2025-12-01 16:48:40 +01:00
Alug a27eee8e2f add few missing audiostream unlocks 2025-12-01 16:48:37 +01:00
Alug 904019d24b fix startup playing a super loud bit of music 2025-12-01 16:48:32 +01:00
Alug c6ca5a6f0f i_video: few type fixes for sdl3 2025-12-01 16:48:29 +01:00
Alug 2392f0484c remove hwr_shutdown call
honestly this didnt help with the issue i had, game should already release all the memory on quit anyways.
this just makes it take longer to quit
2025-12-01 16:48:26 +01:00
Alug 986a131a36 fix a few warnings 2025-12-01 16:48:23 +01:00
Alug e9685ef3e8 port srb2classics sdl audio system
still needs a little work reimplementing everything we got

from: https://codeberg.org/srb2classic/srb2classic/pulls/177
2025-12-01 16:48:18 +01:00
Alug 59f194cb9d fuckit SDL3 2025-12-01 16:48:15 +01:00
Alug 99d5590435 Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-30 19:34:36 +01:00
Alug 9b2cfe51d6 Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-28 18:24:07 +01:00
Alug 66619f42f9 Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-28 18:07:35 +01:00
Alug 890677e2b5 Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-27 23:33:28 +01:00
Alug 1105526eb1 fix perfstats freaking out 2025-11-26 10:10:14 +01:00
Alug d963df36f1 Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-26 10:10:12 +01:00
Alug 846967cb91 fix compile with HAVE_DISCORDRPC 2025-11-25 20:21:15 +01:00
Alug 6c8862ee4b Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-25 20:16:18 +01:00
Alug a49ea4defd Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-24 22:43:26 +01:00
Alug 3c776b321d Optimize: move a few strlen calls out of loops
when applicable and the input does not get modified within the loop
needs some testing incase i oversaw something
2025-11-24 20:52:03 +01:00
Alug 1ed9bfc9b4 Merge branch 'vidmodestuff' into Saturn-Testing 2025-11-24 20:50:04 +01:00
Alug a05413d925 fix erronous "Could not set custom resolution" warning on startup
the cvars may have not been initialised yet to anything
just return -2 and ignore
2025-11-24 20:49:45 +01:00
Alug fa9637fba4 Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-24 18:29:05 +01:00
Alug 7f50a09bcd Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-24 00:35:31 +01:00
Alug e25191d7df Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-24 00:30:49 +01:00
Alug f4d8a903e8 Merge branch 'vidmodestuff' into Saturn-Testing 2025-11-23 23:21:54 +01:00
Alug 8a8cbffd12 I_CheckDesktopRes: use SDL_GetCurrentDisplayMode
instead of SDL_GetDesktopDisplayMode, as the former only returns the display mode from when the window was created, which might not reflect the actual current desktop mode.
Maybe fixes some resolutions being incorrectly reported asa having visual issues
2025-11-23 23:21:47 +01:00
Alug 0adf356325 HACK: abuse batching system for sprites and drawnodes
use batching system without sorting for order sensitive things like sprites and transparent stuff
even despite not being "optimally" sorted, drawing them in one go, instead of directly still gives a nice speed increase in certain cases (on my ryzen 5600 i get around 120fps+ on teiai towers starting area!)
2025-11-23 23:08:09 +01:00
Alug 0fef290858 Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-23 22:52:10 +01:00
Alug 2516873ba1 fix signed integer overflow in polygon hash calculation
also gives a speedup on some maps lul
2025-11-22 18:55:30 +01:00
Alug c650394c31 Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-22 18:13:54 +01:00
Alug 1fb6c63097 fix dedi compile 2025-11-21 14:45:44 +01:00
Alug e95382075c Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-21 00:00:29 +01:00
Alug 2d9776d792 OpenGL: keep around our drawnodes memory
no need to constantly reallocate new memory
we dont have renderer switch, and the next level will render drawnodes anyways
those wont grow super big also, so theres no big worry about wasting tons of memory
yes i like ceepeepee vectors, how can you tell
2025-11-19 19:27:36 +01:00
Alug 7fa3d119e8 Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-19 19:26:41 +01:00
Alug e65741acaa Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-18 16:33:38 +01:00
Alug b36ab31a56 Merge remote-tracking branch 'origin/vidmodestuff' into Saturn-Testing 2025-11-18 16:33:35 +01:00
Alug a335da3473 Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-18 16:21:05 +01:00
Alug c312380944 check if our desired screen res already is in the videomode list
before deciding to rebuild the whole list when changing the resolution cvars
2025-11-18 05:22:50 +01:00
Alug b5bb2b42bf I_FillScreenResolutionsList: shrink list if it is too large
we check against MAXMODEDESCS, which is the maximum of modes the videomode can list
just in case we really get a display with a fuckton of resolutions, which most likely wont ever be the case though
this just removes the smallest modes from the list (accounting for the canonicals), to keep things simple
2025-11-18 04:55:50 +01:00
Alug d074f375ca M_VideoModeMenu: make sure red marked modes take precedence 2025-11-18 04:55:45 +01:00
Alug 6fd14f0a80 M_VideoModeMenu: remove old video mode dupe check 2025-11-18 04:55:41 +01:00
Alug d6bbb2c1b3 use static buffer for windowedModes names
no need to worry about memory management here :chaosleep:
2025-11-18 04:55:36 +01:00
Alug fa66b87965 cmp_resolutions: compare by numbers directly
instead by comparing it with strings
2025-11-18 04:55:30 +01:00
Alug c59d5db03e Merge remote-tracking branch 'origin/Saturn-Next' into vidmodestuff 2025-11-18 04:55:22 +01:00
Alug d2f3d5aa4d anew the testing branch
wiped it out completely
2025-11-17 20:26:49 +01:00
Alug 913b8878d8 Optimize: Use doomednum lookup also when (re)spawning mapthings
not just for loading savegame thinkers
Actually even provides slight runtime performance improvement, but mostly makes levelload faster
2025-11-17 20:26:07 +01:00
Alug f02b9f953e Merge branch 'vidmodestuff' into Saturn-Testing 2025-11-17 20:25:49 +01:00
Alug b6edc90553 mark resolutions listed above the current dektop resolution in red
as they lead to visual errors in openglmode without fbo support
2025-11-09 22:20:57 +01:00
Alug 23735121ff raise MAXWINMODES to 128
YES WINDOWS THANKS VERY MUCH SUPER COOL OF YOU
2025-11-09 20:40:03 +01:00
Alug 20950b698f make sure the default 320x200 mode exists 2025-11-09 20:39:58 +01:00
Alug 44df85d6a4 reduce the scope of this 2025-11-09 20:41:24 +01:00
Alug 42d53f1f6f Merge branch 'Saturn-Next' into vidmodestuff 2025-11-09 20:36:00 +01:00
Alug 48f2d0ff83 make sure our custom res fits within MAXVIDMODES
33 are alot so this probably will never be the case (i hope)
2025-11-09 20:21:30 +01:00
Alug 517723f9c1 handle custom res differently + make VID_NumModes return actual vidmodes
custom resolutions now will be put into the resolution list
which means they are selectable from the menu
2025-11-09 20:16:44 +01:00
Alug 6915077e0f refresh the video menu list if our resolution list changes
if you move the gamewindow to a different display, the video menu will now upadate to the new resolutions
2025-11-09 19:16:36 +01:00
Alug 406dbf333d use a video_mode_t thing for our custom resolution
perhaps we may merge it into windowedmodes? not sure
but this works for now
2025-11-09 19:13:38 +01:00
Alug a730dfd212 fix checking for if display changed 2025-11-09 19:13:35 +01:00
Alug 3058d365f3 no need to call I_FillScreenResolutionsList everywhere
its fine after startup, and when we move our window
2025-11-09 19:13:31 +01:00
Alug ccc453e0b0 fix windowmoved never resetting 2025-11-09 19:13:28 +01:00
Alug c3d02090e4 WIP: remove hardcoded resolutions
much thanks dsda-doom for most of the code for this
TODO:
- resolution menu needs to refresh if the list changes
- clean up
- handle custom resolutions more sane
- figure out the best maximum resolution list size the menu can display
2025-11-09 19:13:25 +01:00
Alug 20cd7621c3 delet numVidModes
wasnt doing anything
2025-11-09 19:13:22 +01:00
178 changed files with 6628 additions and 7735 deletions

No files matched your search

+27 -36
View File
@@ -1,46 +1,14 @@
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.5)
if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR})
message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.")
endif()
# DO NOT CHANGE THIS SRB2 STRING! Some variable names depend on this string. # DO NOT CHANGE THIS SRB2 STRING! Some variable names depend on this string.
# Version change is fine. # Version change is fine.
project(SRB2 project(SRB2
VERSION 1.6 VERSION 1.6
LANGUAGES C CXX) LANGUAGES C)
set(CMAKE_CXX_STANDARD 17) if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR})
set(CMAKE_CXX_STANDARD_REQUIRED ON) message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.")
#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 #####
set(SRB2_CPACK_GENERATOR "" CACHE STRING "Generator to use for making a package. E.g., ZIP, TGZ, DragNDrop (OSX only). Leave blank for default generator.")
if("${SRB2_CPACK_GENERATOR}" STREQUAL "")
if("${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
set(SRB2_CPACK_GENERATOR "ZIP")
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
set(SRB2_CPACK_GENERATOR "TGZ")
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
set(SRB2_CPACK_GENERATOR "TGZ")
endif()
endif() endif()
set(CPACK_GENERATOR ${SRB2_CPACK_GENERATOR})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Sonic Robo Blast 2 Kart" CACHE STRING "Program name for display purposes")
set(CPACK_PACKAGE_VENDOR "Kart Krew" CACHE STRING "Vendor name for display purposes")
#set(CPACK_PACKAGE_DESCRIPTION_FILE )
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_VERSION_MAJOR ${SRB2_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${SRB2_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${SRB2_VERSION_PATCH})
set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}")
include(CPack)
# Set up CMAKE path # Set up CMAKE path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
@@ -105,7 +73,6 @@ endif()
# OS macros # OS macros
if (UNIX) if (UNIX)
add_definitions(-DUNIXCOMMON) add_definitions(-DUNIXCOMMON)
add_link_options(-rdynamic) # Use -rdynamic so a backtrace log shows function names
endif() endif()
if(CMAKE_COMPILER_IS_GNUCC) if(CMAKE_COMPILER_IS_GNUCC)
@@ -128,12 +95,14 @@ set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
# Set EXE names so the assets CMakeLists can refer to its target # Set EXE names so the assets CMakeLists can refer to its target
set(SRB2_SDL2_EXE_NAME srb2kart CACHE STRING "Executable binary output name") set(SRB2_SDL2_EXE_NAME srb2kart CACHE STRING "Executable binary output name")
set(SRB2_WIN_EXE_NAME srb2kartdd CACHE STRING "Executable binary output name for DirectDraw build")
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src) include_directories(${CMAKE_CURRENT_BINARY_DIR}/src)
add_subdirectory(src) add_subdirectory(src)
add_subdirectory(assets) add_subdirectory(assets)
## config.h generation ## config.h generation
set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary") set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary")
include(GitUtilities) include(GitUtilities)
@@ -142,3 +111,25 @@ git_current_branch(SRB2_GIT_BRANCH "${CMAKE_SOURCE_DIR}")
set(SRB2_COMP_BRANCH "${SRB2_GIT_BRANCH}") set(SRB2_COMP_BRANCH "${SRB2_GIT_BRANCH}")
set(SRB2_COMP_REVISION "${SRB2_COMP_COMMIT}") set(SRB2_COMP_REVISION "${SRB2_COMP_COMMIT}")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/config.h) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/config.h)
##### PACKAGE CONFIGURATION #####
if(${CMAKE_SYSTEM} MATCHES "Windows")
set(CPACK_GENERATOR "ZIP")
endif()
if(${CMAKE_SYSTEM} MATCHES "Linux")
set(CPACK_GENERATOR "TGZ")
endif()
if(${CMAKE_SYSTEM} MATCHES "Darwin")
set(CPACK_GENERATOR "DragNDrop")
endif()
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Sonic Robo Blast 2 Kart" CACHE STRING "Program name for display purposes")
set(CPACK_PACKAGE_VENDOR "Kart Krew" CACHE STRING "Vendor name for display purposes")
#set(CPACK_PACKAGE_DESCRIPTION_FILE )
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_VERSION_MAJOR ${SRB2_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${SRB2_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${SRB2_VERSION_PATCH})
set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}")
include(CPack)
+1 -8
View File
@@ -13,12 +13,10 @@ Mainly for use in visual-only addons like secondcolor.
**Not netsafe**. Returns player's current sliptide roll angle, taking sliptideroll cvar value into account. **Not netsafe**. Returns player's current sliptide roll angle, taking sliptideroll cvar value into account.
## hud.setVoteBackground(name[, time\_per\_frame]) ## hud.setVoteBackground(name)
Changes vote background texture prefix (game looks for PREFIX + "W" or "C" (depends on resolution) + FRAME\_NUMBER). Changes vote background texture prefix (game looks for PREFIX + "W" or "C" (depends on resolution) + FRAME\_NUMBER).
If time\_per\_frame is set, each frame will last this amount of tics, default value is 2
## hud.add(fn, "vote") and hud.add(fn, "intermission") ## hud.add(fn, "vote") and hud.add(fn, "intermission")
Hud hooks for vote screen and intermission screen. They only get drawer (`v`) as argument. Hud hooks for vote screen and intermission screen. They only get drawer (`v`) as argument.
@@ -122,11 +120,6 @@ v.interpLatch(false)
``` ```
When using a custom string drawer, enable this mode to avoid interpolation artifacting when the string changes. When using a custom string drawer, enable this mode to avoid interpolation artifacting when the string changes.
## cameras[] global array
Local player cameras that can be accessed outside of hud hooks.
`#cameras` will return amount of available cameras. (0 on dedicated server, 1 with 1 player, 4 with 4p splitscreen, etc)
## mobj.spritexscale, mobj.spriteyscale, mobj.spritexoffset, mobj.spriteyoffset, mobj.rollangle, mobj.sloperoll, mobj.rollmodel fields ## mobj.spritexscale, mobj.spriteyscale, mobj.spritexoffset, mobj.spriteyoffset, mobj.rollangle, mobj.sloperoll, mobj.rollmodel fields
Same fields as in SRB2 2.2 Same fields as in SRB2 2.2
+3 -3
View File
@@ -22,14 +22,14 @@ We also have a Flatpak available on [Flathub](https://flathub.org/en/apps/org.sr
See [SRB2 Wiki/Source code compiling](http://wiki.srb2.org/wiki/Source_code_compiling). The compiling process for SRB2Kart is largely identical to SRB2. See [SRB2 Wiki/Source code compiling](http://wiki.srb2.org/wiki/Source_code_compiling). The compiling process for SRB2Kart is largely identical to SRB2.
For Windows only the Makefile build system with GCC or Clang compiler is supported. Currently only the Makefile build system with GCC or Clang compiler is supported.
CMake is NOT supported at the moment, but will be availible again soon.
Visual C++ (MSVC) is unsupported. Visual C++ (MSVC) is unsupported.
64-bit Windows builds are supported and recommended over 32-bit builds, they will build automatically when using the MSYS2 MinGW 64-bit executable (requires the mingw-w64-x86_64-gcc package), no extra flags needed! 64-bit Windows builds are supported and recommended over 32-bit builds, they will build automatically when using the MSYS2 MinGW 64-bit executable (requires the mingw-w64-x86_64-gcc package), no extra flags needed!
The specific DLLs can be found under /libs/dll-binaries/(i686 for 32bit/x86_64 for 64-bit)/ or in the Release packages The specific DLLs can be found under /libs/dll-binaries/(i686 for 32bit/x86_64 for 64-bit)/ or in the Release packages
MacOS and Linux can be build with CMake, but it is recommended to use the Makefile for Linux over CMake
Alternatively the [srb2bld](https://github.com/Bijman/srb2bld) script by Bijman can be used aswell! Alternatively the [srb2bld](https://github.com/Bijman/srb2bld) script by Bijman can be used aswell!
## Disclaimer ## Disclaimer
-5
View File
@@ -1,10 +1,5 @@
## Assets Target Configuration ## ## Assets Target Configuration ##
if(${CMAKE_SYSTEM} MATCHES Linux)
# Asset installation isn't part of the Linux target
return()
endif()
# For prepending the current source path, later # For prepending the current source path, later
FUNCTION(PREPEND var prefix) FUNCTION(PREPEND var prefix)
SET(listVar "") SET(listVar "")
+10 -6
View File
@@ -972,6 +972,14 @@ Public License instead of this License. But first, please read
Copyright (C) 1995-2018 Free Software Foundation, Inc. Copyright (C) 1995-2018 Free Software Foundation, Inc.
https://www.gnu.org/software/gettext/ https://www.gnu.org/software/gettext/
- FluidSynth
Copyright (C) 2000-2025 Peter Hanappe and others.
https://www.fluidsynth.org/
- libsndfile
Copyright (C) 1999-2016 Erik de Castro Lopo
https://libsndfile.github.io/libsndfile/
- mpg123 - mpg123
Copyright (c) 1995-2013 by Michael Hipp and others, Copyright (c) 1995-2013 by Michael Hipp and others,
free software under the terms of the LGPL v2.1 free software under the terms of the LGPL v2.1
@@ -1699,12 +1707,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
zlib License zlib License
applies to: applies to:
- Simple DirectMedia Layer - Simple DirectMedia Layer
Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
https://www.libsdl.org/hg.php https://libsdl.org/
- SDL_mixer: An audio mixer library based on the SDL library
Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
https://www.libsdl.org/projects/SDL_mixer/
- zlib - zlib
Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
+41
View File
@@ -0,0 +1,41 @@
# Find FluidSynth
# Once done, this will define
#
# FLUIDSYNTH_FOUND - system has FluidSynth
# FLUIDSYNTH_INCLUDE_DIRS - FluidSynth include directories
# FLUIDSYNTH_LIBRARIES - link libraries
include(LibFindMacros)
libfind_pkg_check_modules(FLUIDSYNTH_PKGCONF FLUIDSYNTH)
# includes
find_path(FLUIDSYNTH_INCLUDE_DIR
NAMES fluidsynth.h
PATHS
${FLUIDSYNTH_PKGCONF_INCLUDE_DIRS}
)
# library
find_library(FLUIDSYNTH_LIBRARY
NAMES fluidsynth
PATHS
${FLUIDSYNTH_PKGCONF_LIBRARY_DIRS}
"/usr/lib"
"/usr/local/lib"
)
# set include dir variables
set(FLUIDSYNTH_PROCESS_INCLUDES FLUIDSYNTH_INCLUDE_DIR)
set(FLUIDSYNTH_PROCESS_LIBS FLUIDSYNTH_LIBRARY)
libfind_process(FLUIDSYNTH)
if(FLUIDSYNTH_FOUND AND NOT TARGET FluidSynth::libfluidsynth)
add_library(FluidSynth::libfluidsynth UNKNOWN IMPORTED)
set_target_properties(
FluidSynth::libfluidsynth
PROPERTIES
IMPORTED_LOCATION "${FLUIDSYNTH_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${FLUIDSYNTH_INCLUDE_DIR}"
)
endif()
+1 -2
View File
@@ -1,6 +1,6 @@
include(LibFindMacros) include(LibFindMacros)
libfind_pkg_check_modules(GME_PKGCONF LIBGME) libfind_pkg_check_modules(GME_PKGCONF GME)
find_path(GME_INCLUDE_DIR find_path(GME_INCLUDE_DIR
NAMES gme.h NAMES gme.h
@@ -8,7 +8,6 @@ find_path(GME_INCLUDE_DIR
${GME_PKGCONF_INCLUDE_DIRS} ${GME_PKGCONF_INCLUDE_DIRS}
"/usr/include/gme" "/usr/include/gme"
"/usr/local/include/gme" "/usr/local/include/gme"
PATH_SUFFIXES gme
) )
find_library(GME_LIBRARY find_library(GME_LIBRARY
+1 -2
View File
@@ -1,6 +1,6 @@
include(LibFindMacros) include(LibFindMacros)
libfind_pkg_check_modules(OPENMPT_PKGCONF LIBOPENMPT) libfind_pkg_check_modules(OPENMPT_PKGCONF OPENMPT)
find_path(OPENMPT_INCLUDE_DIR find_path(OPENMPT_INCLUDE_DIR
NAMES libopenmpt.h NAMES libopenmpt.h
@@ -8,7 +8,6 @@ find_path(OPENMPT_INCLUDE_DIR
${OPENMPT_PKGCONF_INCLUDE_DIRS} ${OPENMPT_PKGCONF_INCLUDE_DIRS}
"/usr/include/libopenmpt" "/usr/include/libopenmpt"
"/usr/local/include/libopenmpt" "/usr/local/include/libopenmpt"
PATH_SUFFIXES libopenmpt
) )
find_library(OPENMPT_LIBRARY find_library(OPENMPT_LIBRARY
-33
View File
@@ -1,33 +0,0 @@
include(LibFindMacros)
libfind_pkg_check_modules(LIBBACKTRACE_PKGCONF LIBBACKTRACE)
find_path(LIBBACKTRACE_INCLUDE_DIR
NAMES backtrace.h
PATHS
${LIBBACKTRACE_PKGCONF_INCLUDE_DIRS}
"/usr/include"
"/usr/local/include"
)
find_library(LIBBACKTRACE_LIBRARY
NAMES backtrace
PATHS
${LIBBACKTRACE_PKGCONF_LIBRARY_DIRS}
"/usr/lib"
"/usr/local/lib"
)
set(LIBBACKTRACE_PROCESS_INCLUDES LIBBACKTRACE_INCLUDE_DIR)
set(LIBBACKTRACE_PROCESS_LIBS LIBBACKTRACE_LIBRARY)
libfind_process(LIBBACKTRACE)
if(LIBBACKTRACE_FOUND AND NOT TARGET libbacktrace)
add_library(libbacktrace UNKNOWN IMPORTED)
set_target_properties(
libbacktrace
PROPERTIES
IMPORTED_LOCATION "${LIBBACKTRACE_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${LIBBACKTRACE_INCLUDE_DIR}"
)
endif()
+18 -37
View File
@@ -1,4 +1,4 @@
# Version 2.4 # Version 2.2
# Public Domain, originally written by Lasse Kärkkäinen <tronic> # Public Domain, originally written by Lasse Kärkkäinen <tronic>
# Maintained at https://github.com/Tronic/cmake-modules # Maintained at https://github.com/Tronic/cmake-modules
# Please send your improvements as pull requests on Github. # Please send your improvements as pull requests on Github.
@@ -52,10 +52,6 @@ function (libfind_pkg_detect PREFIX)
if (libraryargs) if (libraryargs)
find_library(${PREFIX}_LIBRARY NAMES ${libraryargs} HINTS ${${PREFIX}_PKGCONF_LIBRARY_DIRS}) find_library(${PREFIX}_LIBRARY NAMES ${libraryargs} HINTS ${${PREFIX}_PKGCONF_LIBRARY_DIRS})
endif() endif()
# Read pkg-config version
if (${PREFIX}_PKGCONF_VERSION)
set(${PREFIX}_VERSION ${${PREFIX}_PKGCONF_VERSION} PARENT_SCOPE)
endif()
endfunction() endfunction()
# Extracts a version #define from a version.h file, output stored to <PREFIX>_VERSION. # Extracts a version #define from a version.h file, output stored to <PREFIX>_VERSION.
@@ -129,39 +125,24 @@ function (libfind_process PREFIX)
# Process deps to add to # Process deps to add to
foreach (i ${PREFIX} ${${PREFIX}_DEPENDENCIES}) foreach (i ${PREFIX} ${${PREFIX}_DEPENDENCIES})
if (DEFINED ${i}_INCLUDE_OPTS) if (DEFINED ${i}_INCLUDE_OPTS OR DEFINED ${i}_LIBRARY_OPTS)
# The package seems to export option lists that we can use, woohoo! # The package seems to export option lists that we can use, woohoo!
list(APPEND includeopts ${${i}_INCLUDE_OPTS}) list(APPEND includeopts ${${i}_INCLUDE_OPTS})
else()
if (DEFINED ${i}_INCLUDE_DIR)
# Singular forms can be used
list(APPEND includeopts ${i}_INCLUDE_DIR)
else()
if (DEFINED ${i}_INCLUDE_DIRS)
# Plural forms can be used
list(APPEND includeopts ${i}_INCLUDE_DIRS)
else()
# Oh no, we don't know the option names
message(FATAL_ERROR "We couldn't determine config variable names for ${i} includes. Aieeh!")
endif()
endif()
endif()
if (DEFINED ${i}_LIBRARY_OPTS)
# The package seems to export option lists that we can use, woohoo!
list(APPEND libraryopts ${${i}_LIBRARY_OPTS}) list(APPEND libraryopts ${${i}_LIBRARY_OPTS})
else() else()
if (DEFINED ${i}_LIBRARY) # If plural forms don't exist or they equal singular forms
if ((NOT DEFINED ${i}_INCLUDE_DIRS AND NOT DEFINED ${i}_LIBRARIES) OR
({i}_INCLUDE_DIR STREQUAL ${i}_INCLUDE_DIRS AND ${i}_LIBRARY STREQUAL ${i}_LIBRARIES))
# Singular forms can be used # Singular forms can be used
list(APPEND libraryopts ${i}_LIBRARY) if (DEFINED ${i}_INCLUDE_DIR)
else() list(APPEND includeopts ${i}_INCLUDE_DIR)
if (DEFINED ${i}_LIBRARIES)
# Plural forms can be used
list(APPEND libraryopts ${i}_LIBRARIES)
else()
# Oh no, we don't know the option names
message(FATAL_ERROR "We couldn't determine config variable names for ${i} libraries. Aieeh!")
endif() endif()
if (DEFINED ${i}_LIBRARY)
list(APPEND libraryopts ${i}_LIBRARY)
endif()
else()
# Oh no, we don't know the option names
message(FATAL_ERROR "We couldn't determine config variable names for ${i} includes and libs. Aieeh!")
endif() endif()
endif() endif()
endforeach() endforeach()
@@ -228,12 +209,12 @@ function (libfind_process PREFIX)
message(STATUS " ${PREFIX}_LIBRARY_OPTS=${libraryopts}") message(STATUS " ${PREFIX}_LIBRARY_OPTS=${libraryopts}")
message(STATUS " ${PREFIX}_LIBRARIES=${libs}") message(STATUS " ${PREFIX}_LIBRARIES=${libs}")
endif() endif()
set (${PREFIX}_INCLUDE_OPTS ${includeopts} PARENT_SCOPE)
set (${PREFIX}_LIBRARY_OPTS ${libraryopts} PARENT_SCOPE)
set (${PREFIX}_INCLUDE_DIRS ${includes} PARENT_SCOPE)
set (${PREFIX}_LIBRARIES ${libs} PARENT_SCOPE)
set (${PREFIX}_FOUND TRUE PARENT_SCOPE)
endif() endif()
set (${PREFIX}_INCLUDE_OPTS ${includeopts} PARENT_SCOPE)
set (${PREFIX}_LIBRARY_OPTS ${libraryopts} PARENT_SCOPE)
set (${PREFIX}_INCLUDE_DIRS ${includes} PARENT_SCOPE)
set (${PREFIX}_LIBRARIES ${libs} PARENT_SCOPE)
set (${PREFIX}_FOUND TRUE PARENT_SCOPE)
return() return()
endif() endif()
-1
View File
@@ -1,4 +1,3 @@
/cscope.out /cscope.out
*.json *.json
*.idx *.idx
*.gdb_history
+32 -88
View File
@@ -2,8 +2,6 @@
# Core sources # Core sources
set(SRB2_CORE_SOURCES set(SRB2_CORE_SOURCES
core/memory.cpp
core/thread_pool.cpp
am_map.c am_map.c
b_bot.c b_bot.c
command.c command.c
@@ -20,21 +18,17 @@ set(SRB2_CORE_SOURCES
f_wipe.c f_wipe.c
filesrch.c filesrch.c
g_game.c g_game.c
g_demo.c
g_input.c g_input.c
hu_stuff.c hu_stuff.c
i_tcp.c i_tcp.c
info.c info.c
k_hud.c
lzf.c lzf.c
m_aatree.c m_aatree.c
m_anigif.c m_anigif.c
m_argv.c m_argv.c
m_bbox.c m_bbox.c
m_cheat.c m_cheat.c
m_curl.c
m_cond.c m_cond.c
m_emotes.cpp
m_fixed.c m_fixed.c
m_menu.c m_menu.c
m_textinput.c m_textinput.c
@@ -46,25 +40,19 @@ set(SRB2_CORE_SOURCES
mserv.c mserv.c
http-mserv.c http-mserv.c
qs22j.c qs22j.c
r_skins.c
s_sound.c s_sound.c
screen.c screen.c
sounds.c sounds.c
st_stuff.c st_stuff.c
string.c #string.c
tables.c tables.c
v_video.c v_video.c
w_wad.cpp w_wad.c
y_inter.c y_inter.c
z_zone.cpp z_zone.c
) )
set(SRB2_CORE_HEADERS set(SRB2_CORE_HEADERS
core/memory.h
core/thread_pool.h
m_curl.h
m_emotes.h
k_hud.h
am_map.h am_map.h
b_bot.h b_bot.h
byteptr.h byteptr.h
@@ -90,7 +78,6 @@ set(SRB2_CORE_HEADERS
fastcmp.h fastcmp.h
filesrch.h filesrch.h
g_game.h g_game.h
g_demo.h
g_input.h g_input.h
g_state.h g_state.h
hu_stuff.h hu_stuff.h
@@ -122,7 +109,6 @@ set(SRB2_CORE_HEADERS
md5.h md5.h
mserv.h mserv.h
qs22j.h qs22j.h
r_skins.h
s_sound.h s_sound.h
screen.h screen.h
sounds.h sounds.h
@@ -137,18 +123,18 @@ set(SRB2_CORE_HEADERS
) )
set(SRB2_CORE_RENDER_SOURCES set(SRB2_CORE_RENDER_SOURCES
r_bsp.cpp r_bsp.c
r_data.c r_data.c
r_draw.cpp r_draw.c
r_fps.cpp r_fps.c
r_main.cpp r_main.c
r_patch.cpp r_patch.c
r_patchrotation.cpp r_patchrotation.c
r_plane.cpp r_plane.c
r_segs.cpp r_segs.c
r_sky.c r_sky.c
r_splats.c r_splats.c
r_things.cpp r_things.c
r_portal.c r_portal.c
r_bsp.h r_bsp.h
@@ -176,7 +162,7 @@ set(SRB2_CORE_GAME_SOURCES
p_inter.c p_inter.c
p_lights.c p_lights.c
p_map.c p_map.c
p_maputl.cpp p_maputl.c
p_mobj.c p_mobj.c
p_polyobj.c p_polyobj.c
p_saveg.c p_saveg.c
@@ -207,6 +193,10 @@ set(SRB2_CORE_GAME_SOURCES
k_stats.h k_stats.h
) )
if(NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
set(SRB2_CORE_SOURCES ${SRB2_CORE_SOURCES} string.c)
endif()
prepend_sources(SRB2_CORE_SOURCES) prepend_sources(SRB2_CORE_SOURCES)
prepend_sources(SRB2_CORE_HEADERS) prepend_sources(SRB2_CORE_HEADERS)
prepend_sources(SRB2_CORE_RENDER_SOURCES) prepend_sources(SRB2_CORE_RENDER_SOURCES)
@@ -236,23 +226,10 @@ set(SRB2_CONFIG_HWRENDER ON CACHE BOOL
"Enable hardware rendering through OpenGL.") "Enable hardware rendering through OpenGL.")
set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL
"Use statically linked OpenGL. NOT RECOMMENDED.") "Use statically linked OpenGL. NOT RECOMMENDED.")
set(SRB2_CONFIG_USE_FBO_OGL ON CACHE BOOL
"Enable OpenGL FBO Downsampling support.")
set(SRB2_CONFIG_DEDICATED OFF CACHE BOOL set(SRB2_CONFIG_DEDICATED OFF CACHE BOOL
"Build a dedicated server.") "Build a dedicated server.")
set(SRB2_CONFIG_LIBBACKTRACE ON CACHE BOOL
"Enable using libbacktrace for crashlogs.")
set(SRB2_CONFIG_LTO ON CACHE BOOL
"Enable link time optimizations, improves performance at the cost of longer link times.")
set(SRB2_CONFIG_ASAN OFF CACHE BOOL
"Compile with AddressSanitizer (libasan).")
set(SRB2_CONFIG_UBSAN OFF CACHE BOOL
"Compile with UndefinedBehaviorSanitizer (libubsan).")
set(SRB2_CONFIG_SATURNPAK ON CACHE BOOL
"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(${SRB2_CONFIG_DEDICATED}) if(${SRB2_CONFIG_DEDICATED})
set(SRB2_CONFIG_HAVE_GME NO) set(SRB2_CONFIG_HAVE_GME NO)
@@ -492,36 +469,16 @@ if(${SRB2_CONFIG_HAVE_CURL})
endif() endif()
endif() endif()
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}) if(${SRB2_CONFIG_HWRENDER})
add_definitions(-DHWRENDER) add_definitions(-DHWRENDER)
set(SRB2_HWRENDER_SOURCES set(SRB2_HWRENDER_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_batching.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_batching.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_shaders.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_shaders.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_bsp.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_bsp.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_cache.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_cache.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_draw.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_draw.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_portal.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_portal.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.c
@@ -536,6 +493,7 @@ if(${SRB2_CONFIG_HWRENDER})
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_data.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_data.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_defs.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_defs.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_dll.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_gl.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_gl.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_glob.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_glob.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.h
@@ -554,6 +512,7 @@ if(${SRB2_CONFIG_HWRENDER})
set(SRB2_R_OPENGL_HEADERS set(SRB2_R_OPENGL_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/hardware/r_opengl/r_opengl.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/r_opengl/r_opengl.h
) )
endif() endif()
if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL}) if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL})
@@ -566,40 +525,25 @@ if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL})
endif() endif()
endif() endif()
if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_SCREENFBO}) if(${SRB2_CONFIG_HWRENDER})
add_definitions(-DUSE_FBO_OGL) if(${SRB2_CONFIG_USE_FBO_OGL})
endif() set(SRB2_USE_FBO_OGL ON)
add_definitions(-DUSE_FBO_OGL)
if(${SRB2_CONFIG_SATURNPAK}) endif()
add_definitions(-DDOSATURNPAK)
endif()
if(${SRB2_CONFIG_SATURNJOIN})
add_definitions(-DDOSATURNJOIN)
endif() endif()
# Targets # Targets
# Compatibility flag with later versions of GCC # Compatibility flag with later versions of GCC
# We should really fix our code to not need this # We should really fix our code to not need this
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|x64|amd64|AMD64|em64t|EM64T)") set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -mno-ms-bitfields)
add_compile_options(-mno-ms-bitfields)
endif()
add_compile_options(-Wno-trigraphs)
endif() endif()
# TODO: fix prng and P_CreateBlockmap overflow at some point if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-fwrapv) set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-absolute-value)
if (${CMAKE_BUILD_TYPE} MATCHES Debug)
add_compile_options(-O0)
else()
add_compile_options(-O3)
endif() endif()
add_compile_options(-g)
add_definitions(-DCMAKECONFIG) add_definitions(-DCMAKECONFIG)
#add_library(SRB2Core STATIC #add_library(SRB2Core STATIC
+3 -4
View File
@@ -269,13 +269,13 @@ endif
ifdef USEASAN ifdef USEASAN
# compile with asan # compile with asan
opts+=-O1 -fsanitize=address -fno-omit-frame-pointer -fno-common opts+=-fsanitize=address
libs+=-fsanitize=address libs+=-fsanitize=address
endif endif
ifdef USEUBSAN ifdef USEUBSAN
# compile with ubsan # compile with asan
opts+=-O1 -fsanitize=undefined -fno-omit-frame-pointer opts+=-fsanitize=undefined
libs+=-fsanitize=undefined libs+=-fsanitize=undefined
endif endif
@@ -295,7 +295,6 @@ opts+=$(debug_opts)
opts+=$(foreach v,$(passthru_opts),$(if $($(v)),-D$(v))) opts+=$(foreach v,$(passthru_opts),$(if $($(v)),-D$(v)))
CWFLAGS+=-std=gnu17
CXXFLAGS+=-std=c++17 # force c17 for c++ since most vpss run older ubuntu versions with old compilers CXXFLAGS+=-std=c++17 # force c17 for c++ since most vpss run older ubuntu versions with old compilers
opts+=$(WFLAGS) $(CFLAGS) opts+=$(WFLAGS) $(CFLAGS)
+3 -3
View File
@@ -64,9 +64,9 @@ endif
# This must have high to low order. # This must have high to low order.
gcc_versions:=\ gcc_versions:=\
152 151 150 15\ 151 150 15\
142 141 140 14\ 142 141 140 14\
133 132 131 130 13\ 132 131 130 13\
123 122 121 120 12\ 123 122 121 120 12\
114 113 112 111 110 11\ 114 113 112 111 110 11\
105 104 103 102 101 100 10\ 105 104 103 102 101 100 10\
@@ -77,7 +77,7 @@ gcc_versions:=\
55 54 53 52 51 50\ 55 54 53 52 51 50\
49 48 47 46 45 44 43 42 41 40 49 48 47 46 45 44 43 42 41 40
latest_gcc_version:=15.2 latest_gcc_version:=15.1.1
# Automatically set version flag, but not if one was # Automatically set version flag, but not if one was
# manually set. And don't bother if this is a clean only # manually set. And don't bother if this is a clean only
+1 -1
View File
@@ -8,6 +8,7 @@ passthru_opts+=\
HAVE_MINIUPNPC\ HAVE_MINIUPNPC\
HAVE_DISCORDRPC DEVELOP\ HAVE_DISCORDRPC DEVELOP\
NOHOLEPUNCH\ NOHOLEPUNCH\
NOOPENMPT\
# build with debugging information # build with debugging information
ifdef DEBUGMODE ifdef DEBUGMODE
@@ -91,7 +92,6 @@ endif
default_packages:=\ default_packages:=\
LIBGME/libgme/LIBGME\ LIBGME/libgme/LIBGME\
OPENMPT/libopenmpt/LIBOPENMPT\
ZLIB/zlib\ ZLIB/zlib\
$(foreach p,$(default_packages),\ $(foreach p,$(default_packages),\
+13 -9
View File
@@ -29,8 +29,19 @@ ifndef NOHW
sources+=sdl/ogl_sdl.c sources+=sdl/ogl_sdl.c
endif endif
ifndef NOOPENMPT
LIBOPENMPT_PKGCONFIG?=libopenmpt
$(eval $(call Use_pkg_config,LIBOPENMPT))
opts+=-DHAVE_OPENMPT
endif
NOMIXER=1
ifdef NOMIXER ifdef NOMIXER
sources+=sdl/dummy_sound.c #sources+=sdl/dummy_sound.c
sources+=sdl/sdl_sound.c
SNDFILE_PKGCONFIG?=sndfile
$(eval $(call Use_pkg_config,SNDFILE))
else else
opts+=-DHAVE_MIXER opts+=-DHAVE_MIXER
sources+=sdl/mixer_sound.c sources+=sdl/mixer_sound.c
@@ -45,15 +56,8 @@ opts+=-DHAVE_THREADS
sources+=sdl/i_threads.c sources+=sdl/i_threads.c
endif endif
ifdef SDL_PKGCONFIG SDL_PKGCONFIG?=sdl3
$(eval $(call Use_pkg_config,SDL)) $(eval $(call Use_pkg_config,SDL))
else
SDL_CONFIG?=$(call Prefix,sdl2-config)
SDL_CFLAGS?=$(shell $(SDL_CONFIG) --cflags)
SDL_LDFLAGS?=$(shell $(SDL_CONFIG) \
$(if $(STATIC),--static-libs,--libs))
$(eval $(call Propogate_flags,SDL))
endif
ifdef MINGW ifdef MINGW
ifndef NOSDLMAIN ifndef NOSDLMAIN
+12 -16
View File
@@ -20,11 +20,7 @@ $(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\
CXXFLAGS+= -Wno-aggregate-return CXXFLAGS+= -Wno-aggregate-return
# -W -Wno-unused # -W -Wno-unused
WFLAGS:=-Wall -Wnull-dereference WFLAGS:=-Wall -Wno-trigraphs
#WFLAGS+=-Wno-trigraphs
ifdef GCC152
WFLAGS+=-Wzero-as-null-pointer-constant
endif
ifndef GCC295 ifndef GCC295
#WFLAGS+=-Wno-packed #WFLAGS+=-Wno-packed
endif endif
@@ -32,7 +28,7 @@ ifndef RELAXWARNINGS
WFLAGS+=-W WFLAGS+=-W
#WFLAGS+=-Wno-sign-compare #WFLAGS+=-Wno-sign-compare
ifndef GCC295 ifndef GCC295
# WFLAGS+=-Wno-div-by-zero WFLAGS+=-Wno-div-by-zero
endif endif
#WFLAGS+=-Wsystem-headers #WFLAGS+=-Wsystem-headers
WFLAGS+=-Wfloat-equal WFLAGS+=-Wfloat-equal
@@ -63,7 +59,7 @@ endif
endif endif
WFLAGS+=-Wsign-compare WFLAGS+=-Wsign-compare
ifdef GCC91 ifdef GCC91
# WFLAGS+=-Wno-error=address-of-packed-member WFLAGS+=-Wno-error=address-of-packed-member
endif endif
ifdef GCC45 ifdef GCC45
WFLAGS+=-Wlogical-op WFLAGS+=-Wlogical-op
@@ -106,14 +102,14 @@ endif
endif endif
WFLAGS+=-Wformat-y2k WFLAGS+=-Wformat-y2k
ifdef GCC71 ifdef GCC71
#WFLAGS+=-Wno-error=format-overflow=2 WFLAGS+=-Wno-error=format-overflow=2
endif endif
WFLAGS+=-Wformat-security WFLAGS+=-Wformat-security
ifndef GCC29 ifndef GCC29
#WFLAGS+=-Winit-self #WFLAGS+=-Winit-self
endif endif
ifdef GCC46 ifdef GCC46
#WFLAGS+=-Wno-suggest-attribute=noreturn WFLAGS+=-Wno-suggest-attribute=noreturn
endif endif
ifdef NOLDWARNING ifdef NOLDWARNING
@@ -131,21 +127,21 @@ ifdef GCC44
#WFLAGS+=-Wno-error=array-bounds #WFLAGS+=-Wno-error=array-bounds
endif endif
ifdef GCC46 ifdef GCC46
# WFLAGS+=-Wno-error=suggest-attribute=noreturn WFLAGS+=-Wno-error=suggest-attribute=noreturn
endif endif
ifdef GCC54 ifdef GCC54
# WFLAGS+=-Wno-logical-op -Wno-error=logical-op WFLAGS+=-Wno-logical-op -Wno-error=logical-op
endif endif
ifdef GCC61 ifdef GCC61
# WFLAGS+=-Wno-tautological-compare -Wno-error=tautological-compare WFLAGS+=-Wno-tautological-compare -Wno-error=tautological-compare
endif endif
ifdef GCC71 ifdef GCC71
WFLAGS+=-Wimplicit-fallthrough=4 WFLAGS+=-Wimplicit-fallthrough=4
endif endif
ifdef GCC81 ifdef GCC81
# WFLAGS+=-Wno-error=format-overflow WFLAGS+=-Wno-error=format-overflow
# WFLAGS+=-Wno-format-overflow WFLAGS+=-Wno-format-overflow
# WFLAGS+=-Wno-error=multistatement-macros WFLAGS+=-Wno-error=multistatement-macros
endif endif
ifneq (,$(filter $(CC) $(CXX),clang clang++)) ifneq (,$(filter $(CC) $(CXX),clang clang++))
@@ -184,6 +180,6 @@ endif
# Lua # Lua
ifdef GCC43 ifdef GCC43
ifndef GCC44 ifndef GCC44
#WFLAGS+=-Wno-logical-op WFLAGS+=-Wno-logical-op
endif endif
endif endif
+3 -3
View File
@@ -79,14 +79,14 @@ $(eval $(call _set,LIBOPENMPT))
lib:=../libs/SDL2_mixer/$(mingw) lib:=../libs/SDL2_mixer/$(mingw)
ifdef SDL ifdef SDL
mixer_opts:=-I$(lib)/include/SDL2 mixer_opts:=-I$(lib)/include/SDL3
mixer_libs:=-L$(lib)/lib mixer_libs:=-L$(lib)/lib
lib:=../libs/SDL2/$(mingw) lib:=../libs/SDL2/$(mingw)
SDL_opts:=-I$(lib)/include/SDL2\ SDL_opts:=-I$(lib)/include/SDL3\
$(mixer_opts) -Dmain=SDL_main $(mixer_opts) -Dmain=SDL_main
SDL_libs:=-L$(lib)/lib $(mixer_libs)\ SDL_libs:=-L$(lib)/lib $(mixer_libs)\
-lmingw32 -lSDL2main -lSDL2 -mwindows -lmingw32 -lSDL3main -lSDL3 -mwindows
$(eval $(call _set,SDL)) $(eval $(call _set,SDL))
endif endif
+1 -1
View File
@@ -1,4 +1,3 @@
string.c
am_map.c am_map.c
b_bot.c b_bot.c
command.c command.c
@@ -43,6 +42,7 @@ s_sound.c
screen.c screen.c
sounds.c sounds.c
st_stuff.c st_stuff.c
string.c
tables.c tables.c
v_video.c v_video.c
w_wad.c w_wad.c
+4
View File
@@ -226,6 +226,10 @@ const char *I_LocateWad(void)
return "/sdcard/srb2"; return "/sdcard/srb2";
} }
void I_GetJoystickEvents(void){}
void I_GetJoystick2Events(void){}
char *I_GetEnv(const char *name) char *I_GetEnv(const char *name)
{ {
LOGW("I_GetEnv() called?!"); LOGW("I_GetEnv() called?!");
+11 -11
View File
@@ -47,7 +47,7 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm
if (sonic->player->pflags & (PF_MACESPIN|PF_ITEMHANG)) if (sonic->player->pflags & (PF_MACESPIN|PF_ITEMHANG))
{ {
cmd->forwardmove = sonic->player->cmd.forwardmove; cmd->forwardmove = sonic->player->cmd.forwardmove;
cmd->angleturn = abs((signed)(tails->angle - sonic->angle)) >> TICCMD_REDUCE; cmd->angleturn = abs((signed)(tails->angle - sonic->angle))>>16;
if (sonic->angle < tails->angle) if (sonic->angle < tails->angle)
cmd->angleturn = -cmd->angleturn; cmd->angleturn = -cmd->angleturn;
} else if (dist > FixedMul(512*FRACUNIT, tails->scale)) } else if (dist > FixedMul(512*FRACUNIT, tails->scale))
@@ -139,13 +139,13 @@ void B_KeysToTiccmd(mobj_t *mo, ticcmd_t *cmd, boolean forward, boolean backward
// Don't mess with bot inputs during these unhandled movement conditions. // Don't mess with bot inputs during these unhandled movement conditions.
// The normal AI doesn't use abilities, so custom AI should be sending us exactly what it wants anyway. // The normal AI doesn't use abilities, so custom AI should be sending us exactly what it wants anyway.
if (forward) if (forward)
cmd->forwardmove += MAXPLMOVE << FRACBITS >> TICCMD_REDUCE; cmd->forwardmove += MAXPLMOVE<<FRACBITS>>16;
if (backward) if (backward)
cmd->forwardmove -= MAXPLMOVE<<FRACBITS >> TICCMD_REDUCE; cmd->forwardmove -= MAXPLMOVE<<FRACBITS>>16;
if (left || strafeleft) if (left || strafeleft)
cmd->sidemove -= MAXPLMOVE << FRACBITS >> TICCMD_REDUCE; cmd->sidemove -= MAXPLMOVE<<FRACBITS>>16;
if (right || straferight) if (right || straferight)
cmd->sidemove += MAXPLMOVE << FRACBITS >> TICCMD_REDUCE; cmd->sidemove += MAXPLMOVE<<FRACBITS>>16;
} else { } else {
// In standard 2D mode, interpret "forward" as "the way you're facing" and everything else as "the way you're not facing" // In standard 2D mode, interpret "forward" as "the way you're facing" and everything else as "the way you're not facing"
if (left || right) if (left || right)
@@ -163,23 +163,23 @@ void B_KeysToTiccmd(mobj_t *mo, ticcmd_t *cmd, boolean forward, boolean backward
right = true; right = true;
} }
if (left || strafeleft) if (left || strafeleft)
cmd->sidemove -= MAXPLMOVE << FRACBITS >> TICCMD_REDUCE; cmd->sidemove -= MAXPLMOVE<<FRACBITS>>16;
if (right || straferight) if (right || straferight)
cmd->sidemove += MAXPLMOVE << FRACBITS >> TICCMD_REDUCE; cmd->sidemove += MAXPLMOVE<<FRACBITS>>16;
} }
} else { } else {
if (forward) if (forward)
cmd->forwardmove += MAXPLMOVE << FRACBITS >> TICCMD_REDUCE; cmd->forwardmove += MAXPLMOVE<<FRACBITS>>16;
if (backward) if (backward)
cmd->forwardmove -= MAXPLMOVE << FRACBITS >> TICCMD_REDUCE; cmd->forwardmove -= MAXPLMOVE<<FRACBITS>>16;
if (left) if (left)
cmd->angleturn += 1280; cmd->angleturn += 1280;
if (right) if (right)
cmd->angleturn -= 1280; cmd->angleturn -= 1280;
if (strafeleft) if (strafeleft)
cmd->sidemove -= MAXPLMOVE << FRACBITS >> TICCMD_REDUCE; cmd->sidemove -= MAXPLMOVE<<FRACBITS>>16;
if (straferight) if (straferight)
cmd->sidemove += MAXPLMOVE << FRACBITS >> TICCMD_REDUCE; cmd->sidemove += MAXPLMOVE<<FRACBITS>>16;
} }
if (jump) if (jump)
cmd->buttons |= BT_DRIFT; cmd->buttons |= BT_DRIFT;
+1 -1
View File
@@ -434,7 +434,7 @@ LUA_API void lua_pushnumber (lua_State *L, lua_Number n) {
LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) { LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) {
lua_lock(L); lua_lock(L);
luaC_checkGC(L); luaC_checkGC(L);
setsvalue2s(L, L->top, (len == 0) ? luaS_newlstr(L, "", 0) : luaS_newlstr(L, s, len)); setsvalue2s(L, L->top, (len == 0) ? luaS_new(L, "") : luaS_newlstr(L, s, len));
api_incr_top(L); api_incr_top(L);
lua_unlock(L); lua_unlock(L);
} }
+3 -66
View File
@@ -20,7 +20,6 @@
#define lauxlib_c #define lauxlib_c
#define LUA_LIB #define LUA_LIB
#include "ldebug.h"
#include "lua.h" #include "lua.h"
#include "lauxlib.h" #include "lauxlib.h"
@@ -94,57 +93,6 @@ LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) {
/* }====================================================== */ /* }====================================================== */
/*
** {======================================================
** 'luaL_resourcetryagain'
** This function uses 'errno' to check whether the last error was
** related to lack of resources (e.g., not enough memory or too many
** open files). If so, the function performs a full garbage collection
** to try to release resources, and then it returns 1 to signal to
** the caller that it is worth trying again the failed operation.
** Otherwise, it returns 0. Because error codes are not ANSI C, the
** code must handle any combination of error codes that are defined.
** =======================================================
*/
LUALIB_API int luaL_resourcetryagain (lua_State *L) {
/* these are the resource-related errors in Linux */
#if defined(EMFILE) || defined(ENFILE) || defined(ENOMEM)
#if !defined(EMFILE) /* too many open files in the process */
#define EMFILE -1 /* if not defined, use an impossible value */
#endif
#if !defined(ENFILE) /* too many open files in the system */
#define ENFILE -1
#endif
#if !defined(ENOMEM) /* not enough memory */
#define ENOMEM -1
#endif
if (errno == EMFILE || errno == ENFILE || errno == ENOMEM) {
CONS_Alert(CONS_WARNING, "%s, force calling lua garbage collector\n", strerror(errno));
lua_gc(L, LUA_GCCOLLECT, 0); /* try to release resources with a full GC */
return 1; /* signal to try again the creation */
}
#endif
return 0; /* else, asume errors are not due to lack of resources */
}
/* }====================================================== */
/*
** {======================================================
** Userdata's metatable manipulation
** =======================================================
*/
LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def, LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def,
const char *const lst[]) { const char *const lst[]) {
const char *name = (def) ? luaL_optstring(L, narg, def) : const char *name = (def) ? luaL_optstring(L, narg, def) :
@@ -469,19 +417,8 @@ LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) {
LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {
while (l) { while (l--)
size_t space = bufffree(B); luaL_addchar(B, *s++);
if (space == 0) {
luaL_prepbuffer(B);
lua_assert(bufffree(B) == LUAL_BUFFERSIZE);
space = LUAL_BUFFERSIZE;
}
if (space > l) space = l;
memcpy(B->p, s, space);
B->p += space;
s += space;
l -= space;
}
} }
@@ -698,6 +635,6 @@ static int panic (lua_State *L) {
LUALIB_API lua_State *luaL_newstate (void) { LUALIB_API lua_State *luaL_newstate (void) {
lua_State *L = lua_newstate(l_alloc, NULL); lua_State *L = lua_newstate(l_alloc, NULL);
if (l_likely(L)) lua_atpanic(L, &panic); if (L) lua_atpanic(L, &panic);
return L; return L;
} }
-2
View File
@@ -95,8 +95,6 @@ LUALIB_API FUNCREPORT int (luaL_error) (lua_State *L, const char *fmt, ...);
LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def,
const char *const lst[]); const char *const lst[]);
LUALIB_API int (luaL_resourcetryagain) (lua_State *L);
LUALIB_API int (luaL_ref) (lua_State *L, int t); LUALIB_API int (luaL_ref) (lua_State *L, int t);
LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
+12 -13
View File
@@ -790,19 +790,18 @@ void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) {
case OPR_BXOR: codearith(fs, OP_BXOR, e1, e2); break; case OPR_BXOR: codearith(fs, OP_BXOR, e1, e2); break;
case OPR_BSHL: codearith(fs, OP_BSHL, e1, e2); break; case OPR_BSHL: codearith(fs, OP_BSHL, e1, e2); break;
case OPR_BSHR: codearith(fs, OP_BSHR, e1, e2); break; case OPR_BSHR: codearith(fs, OP_BSHR, e1, e2); break;
case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: case OPR_ADD: codearith(fs, OP_ADD, e1, e2); break;
case OPR_MOD: case OPR_POW: { case OPR_SUB: codearith(fs, OP_SUB, e1, e2); break;
codearith(fs, op - OPR_ADD + OP_ADD, e1, e2); case OPR_MUL: codearith(fs, OP_MUL, e1, e2); break;
break; case OPR_DIV: codearith(fs, OP_DIV, e1, e2); break;
} case OPR_MOD: codearith(fs, OP_MOD, e1, e2); break;
case OPR_EQ: case OPR_LT: case OPR_LE: { case OPR_POW: codearith(fs, OP_POW, e1, e2); break;
codecomp(fs, op - OPR_EQ + OP_EQ, 1, e1, e2); case OPR_EQ: codecomp(fs, OP_EQ, 1, e1, e2); break;
break; case OPR_NE: codecomp(fs, OP_EQ, 0, e1, e2); break;
} case OPR_LT: codecomp(fs, OP_LT, 1, e1, e2); break;
case OPR_NE: case OPR_GT: case OPR_GE: { case OPR_LE: codecomp(fs, OP_LE, 1, e1, e2); break;
codecomp(fs, op - OPR_NE + OP_EQ, 0, e1, e2); case OPR_GT: codecomp(fs, OP_LT, 0, e1, e2); break;
break; case OPR_GE: codecomp(fs, OP_LE, 0, e1, e2); break;
}
default: lua_assert(0); default: lua_assert(0);
} }
} }
+3 -3
View File
@@ -21,13 +21,13 @@
/* /*
** grep "ORDER OPR" if you change these enums (ORDER OP) ** grep "ORDER OPR" if you change these enums
*/ */
typedef enum BinOpr { typedef enum BinOpr {
OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW, OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW,
OPR_CONCAT, OPR_CONCAT,
OPR_EQ, OPR_LT, OPR_LE, OPR_NE, OPR_EQ,
OPR_NE, OPR_GT, OPR_GE, OPR_LT, OPR_LE, OPR_GT, OPR_GE,
OPR_AND, OPR_OR, OPR_AND, OPR_OR,
OPR_BAND, OPR_BOR, OPR_BXOR, OPR_BAND, OPR_BOR, OPR_BXOR,
OPR_BSHL, OPR_BSHR, OPR_BSHL, OPR_BSHR,
+5 -28
View File
@@ -542,39 +542,16 @@ static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos,
static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
TMS tm = 0;
Instruction i; Instruction i;
if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1)) if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1))
return NULL; /* calling function is not Lua (or is unknown) */ return NULL; /* calling function is not Lua (or is unknown) */
ci--; /* calling function */ ci--; /* calling function */
i = ci_func(ci)->l.p->code[currentpc(L, ci)]; i = ci_func(ci)->l.p->code[currentpc(L, ci)];
switch (GET_OPCODE(i)) { if (GET_OPCODE(i) == OP_CALL || GET_OPCODE(i) == OP_TAILCALL ||
case OP_CALL: GET_OPCODE(i) == OP_TFORLOOP)
case OP_TAILCALL: return getobjname(L, ci, GETARG_A(i), name);
case OP_TFORLOOP: else
return getobjname(L, ci, GETARG_A(i), name); return NULL; /* no useful name can be found */
case OP_GETGLOBAL:
case OP_SELF:
case OP_GETTABLE: tm = TM_INDEX; break;
case OP_SETGLOBAL:
case OP_SETTABLE: tm = TM_NEWINDEX; break;
case OP_EQ: tm = TM_EQ; break;
case OP_ADD: tm = TM_ADD; break;
case OP_SUB: tm = TM_SUB; break;
case OP_MUL: tm = TM_MUL; break;
case OP_DIV: tm = TM_DIV; break;
case OP_MOD: tm = TM_MOD; break;
case OP_POW: tm = TM_POW; break;
case OP_UNM: tm = TM_UNM; break;
case OP_LEN: tm = TM_LEN; break;
case OP_LT: tm = TM_LT; break;
case OP_LE: tm = TM_LE; break;
case OP_CONCAT: tm = TM_CONCAT; break;
default:
return NULL; /* else no useful name can be found */
}
*name = getstr(G(L)->tmname[tm]);
return "metamethod";
} }
+2 -2
View File
@@ -164,7 +164,7 @@ void luaD_reallocCI (lua_State *L, int newsize) {
void luaD_growstack (lua_State *L, int n) { void luaD_growstack (lua_State *L, int n) {
if (n <= L->stacksize) /* double size is enough? */ if (l_likely(n <= L->stacksize)) /* double size is enough? */
luaD_reallocstack(L, 2*L->stacksize); luaD_reallocstack(L, 2*L->stacksize);
else else
luaD_reallocstack(L, L->stacksize + n); luaD_reallocstack(L, L->stacksize + n);
@@ -318,7 +318,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) {
ci->top = L->top + LUA_MINSTACK; ci->top = L->top + LUA_MINSTACK;
lua_assert(ci->top <= L->stack_last); lua_assert(ci->top <= L->stack_last);
ci->nresults = nresults; ci->nresults = nresults;
if (l_unlikely(L->hookmask & LUA_MASKCALL)) if (L->hookmask & LUA_MASKCALL)
luaD_callhook(L, LUA_HOOKCALL, -1); luaD_callhook(L, LUA_HOOKCALL, -1);
lua_unlock(L); lua_unlock(L);
n = (*curr_func(L)->c.f)(L); /* do the actual call */ n = (*curr_func(L)->c.f)(L); /* do the actual call */
+24 -33
View File
@@ -58,6 +58,12 @@ static int pushresult (lua_State *L, int i, const char *filename) {
} }
static void fileerror (lua_State *L, int arg, const char *filename) {
lua_pushfstring(L, "%s: %s", filename, strerror(errno));
luaL_argerror(L, arg, lua_tostring(L, -1));
}
#define tofilep(L) ((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE)) #define tofilep(L) ((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE))
@@ -159,24 +165,6 @@ static int StartsWith(const char *a, const char *b) // this is wolfs being lazy
return 0; return 0;
} }
/*
** Equivalent to 'fopen', but if it fails due to a lack of resources
** (see 'luaL_resourcetryagain'), do an "emergency" garbage collection to try
** to close some files and then tries to open the file again.
*/
static FILE *trytoopen (lua_State *L, const char *path, const char *mode) {
FILE *f = fopen(path, mode);
if (f == NULL && luaL_resourcetryagain(L)) /* resource failure? */
f = fopen(path, mode); /* try to open again */
return f;
}
static void opencheck (lua_State *L, const char *fname, const char *mode) {
FILE **p = newfile(L);
*p = trytoopen(L, fname, mode);
if (l_unlikely(*p == NULL))
luaL_error(L, "cannot open file '%s' (%s)", fname, strerror(errno));
}
static int io_open(lua_State *L) static int io_open(lua_State *L)
{ {
@@ -224,7 +212,7 @@ static int io_open(lua_State *L)
} }
pf = newfile(L); pf = newfile(L);
*pf = trytoopen(L, destFilename, mode); *pf = fopen(destFilename, mode);
return (*pf == NULL) ? pushresult(L, 0, filename) : 1; return (*pf == NULL) ? pushresult(L, 0, filename) : 1;
} }
@@ -232,8 +220,6 @@ static int io_open(lua_State *L)
static int io_tmpfile (lua_State *L) { static int io_tmpfile (lua_State *L) {
FILE **pf = newfile(L); FILE **pf = newfile(L);
*pf = tmpfile(); *pf = tmpfile();
if (*pf == NULL && luaL_resourcetryagain(L)) /* resource failure? */
*pf = tmpfile(); /* try to open again */
return (*pf == NULL) ? pushresult(L, 0, NULL) : 1; return (*pf == NULL) ? pushresult(L, 0, NULL) : 1;
} }
@@ -252,7 +238,10 @@ static int g_iofile (lua_State *L, int f, const char *mode) {
if (!lua_isnoneornil(L, 1)) { if (!lua_isnoneornil(L, 1)) {
const char *filename = lua_tostring(L, 1); const char *filename = lua_tostring(L, 1);
if (filename) { if (filename) {
opencheck(L, filename, mode); FILE **pf = newfile(L);
*pf = fopen(filename, mode);
if (l_unlikely(*pf == NULL))
fileerror(L, 1, filename);
} }
else { else {
tofile(L); /* check that it's a valid file handle */ tofile(L); /* check that it's a valid file handle */
@@ -301,7 +290,10 @@ static int io_lines (lua_State *L) {
} }
else { else {
const char *filename = luaL_checkstring(L, 1); const char *filename = luaL_checkstring(L, 1);
opencheck(L, filename, "r"); FILE **pf = newfile(L);
*pf = fopen(filename, "r");
if (l_unlikely(*pf == NULL))
fileerror(L, 1, filename);
aux_lines(L, lua_gettop(L), 1); aux_lines(L, lua_gettop(L), 1);
return 1; return 1;
} }
@@ -356,21 +348,20 @@ static int read_line (lua_State *L, FILE *f) {
static int read_chars (lua_State *L, FILE *f, size_t n) { static int read_chars (lua_State *L, FILE *f, size_t n) {
size_t tbr = n; /* number of chars to be read */ size_t rlen; /* how much to read */
size_t rlen; /* how much to read in each cycle */ size_t nr; /* number of chars actually read */
size_t nr; /* number of chars actually read in each cycle */
luaL_Buffer b; luaL_Buffer b;
luaL_buffinit(L, &b); luaL_buffinit(L, &b);
rlen = LUAL_BUFFERSIZE; /* try to read that much each time */ rlen = LUAL_BUFFERSIZE; /* try to read that much each time */
do { do {
char *p = luaL_prepbuffer(&b); char *p = luaL_prepbuffer(&b);
if (rlen > tbr) rlen = tbr; /* cannot read more than asked */ if (rlen > n) rlen = n; /* cannot read more than asked */
nr = fread(p, sizeof(char), rlen, f); nr = fread(p, sizeof(char), rlen, f);
luaL_addsize(&b, nr); luaL_addsize(&b, nr);
tbr -= nr; /* still have to read 'tbr' chars */ n -= nr; /* still have to read `n' chars */
} while (tbr > 0 && nr == rlen); /* until end of count or eof */ } while (n > 0 && nr == rlen); /* until end of count or eof */
luaL_pushresult(&b); /* close buffer */ luaL_pushresult(&b); /* close buffer */
return (tbr == 0 || tbr < n); /* true iff read something */ return (n == 0 || lua_objlen(L, -1) > 0);
} }
@@ -433,13 +424,13 @@ static int f_read (lua_State *L) {
static int io_readline (lua_State *L) { static int io_readline (lua_State *L) {
FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1)); FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1));
int success; int sucess;
if (f == NULL) /* file is already closed? */ if (f == NULL) /* file is already closed? */
luaL_error(L, "file is already closed"); luaL_error(L, "file is already closed");
success = read_line(L, f); sucess = read_line(L, f);
if (ferror(f)) if (ferror(f))
return luaL_error(L, "%s", strerror(errno)); return luaL_error(L, "%s", strerror(errno));
if (success) return 1; if (sucess) return 1;
else { /* EOF */ else { /* EOF */
if (lua_toboolean(L, lua_upvalueindex(2))) { /* generator created file? */ if (lua_toboolean(L, lua_upvalueindex(2))) { /* generator created file? */
lua_settop(L, 0); lua_settop(L, 0);
+4 -4
View File
@@ -881,10 +881,10 @@ static const struct {
lu_byte right; /* right priority */ lu_byte right; /* right priority */
} priority[] = { /* ORDER OPR */ } priority[] = { /* ORDER OPR */
{6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `+' `-' `/' `%' */ {6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `+' `-' `/' `%' */
{10, 9}, {5, 4}, /* ^, .. (right associative) */ {10, 9}, {5, 4}, /* power and concat (right associative) */
{3, 3}, {3, 3}, {3, 3}, /* ==, <, <= */ {3, 3}, {3, 3}, /* equality and inequality */
{3, 3}, {3, 3}, {3, 3}, /* ~=, >, >= */ {3, 3}, {3, 3}, {3, 3}, {3, 3}, /* order */
{2, 2}, {1, 1} /* and, or */ {2, 2}, {1, 1} /* logical (and/or) */
,{6, 6}, {6, 6}, {6, 6}, /* bit-wise (band/bor/bxor) */ ,{6, 6}, {6, 6}, {6, 6}, /* bit-wise (band/bor/bxor) */
{7, 7}, {7, 7} /* shl/shr */ {7, 7}, {7, 7} /* shl/shr */
}; };
+4 -58
View File
@@ -51,7 +51,7 @@ static TString *newlstr (lua_State *L, const char *str, size_t l,
unsigned int h) { unsigned int h) {
TString *ts; TString *ts;
stringtable *tb; stringtable *tb;
if (l_unlikely(l+1 > (MAX_SIZET - sizeof(TString))/sizeof(char))) if (l+1 > (MAX_SIZET - sizeof(TString))/sizeof(char))
luaM_toobig(L); luaM_toobig(L);
ts = cast(TString *, luaM_malloc(L, (l+1)*sizeof(char)+sizeof(TString))); ts = cast(TString *, luaM_malloc(L, (l+1)*sizeof(char)+sizeof(TString)));
ts->tsv.len = l; ts->tsv.len = l;
@@ -72,72 +72,18 @@ static TString *newlstr (lua_State *L, const char *str, size_t l,
} }
// string hash taken from luaJIT TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
GCObject *o;
/* Unaligned load of uint32_t. */
static inline __attribute__((always_inline)) uint32_t getu32(const void* ptr)
{
uint32_t result;
memcpy(&result, ptr, 4);
return result;
}
// smol macro to look a little less messy lul
#define getu8(p) *cast(const uint8_t *, p)
/* Keyed sparse ARX string hash. Constant time. */
static unsigned hash_sparse(const char *str, size_t len)
{
/* Constants taken from lookup3 hash by Bob Jenkins. */
unsigned int a, b, h = cast(unsigned int, len);
#define rol(x, n) (((x)<<(n)) | ((x)>>(-cast(int, n)&(8*sizeof(x)-1))))
if (len >= 4) { /* Caveat: unaligned access! */
a = getu32(str);
h ^= getu32(str+len-4);
b = getu32(str+(len>>1)-2);
h ^= b; h -= rol(b, 14);
b += getu32(str+(len>>2)-1);
} else if (len > 0) {
a = getu8(str);
h ^= getu8(str+len-1);
b = getu8(str+(len>>1));
h ^= b; h -= rol(b, 14);
} else {
return 0;
}
a ^= h; a -= rol(h, 11);
b ^= a; b -= rol(a, 25);
h ^= b; h -= rol(b, 16);
#undef rol
return h;
}
#undef getu8
static inline __attribute__((always_inline)) unsigned luaS_hash (const char *str, size_t l) {
#if 0
unsigned int h = cast(unsigned int, l); /* seed */ unsigned int h = cast(unsigned int, l); /* seed */
size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */ size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */
size_t l1; size_t l1;
for (l1=l; l1>=step; l1-=step) /* compute hash */ for (l1=l; l1>=step; l1-=step) /* compute hash */
h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1])); h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1]));
return h;
#else
return hash_sparse(str, l);
#endif
}
TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
GCObject *o;
unsigned int h = luaS_hash(str, l);
for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)]; for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)];
o != NULL; o != NULL;
o = o->gch.next) { o = o->gch.next) {
TString *ts = rawgco2ts(o); TString *ts = rawgco2ts(o);
if (ts->tsv.hash == h && if (l_unlikely(ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0))) {
ts->tsv.len == l &&
(memcmp(str, getstr(ts), l) == 0)) {
/* string may be dead */ /* string may be dead */
if (isdead(G(L), o)) changewhite(o); if (isdead(G(L), o)) changewhite(o);
return ts; return ts;
+1 -1
View File
@@ -527,7 +527,7 @@ static int str_find_aux (lua_State *L, int find) {
if (find) { if (find) {
lua_pushinteger(L, s1-s+1); /* start */ lua_pushinteger(L, s1-s+1); /* start */
lua_pushinteger(L, res-s); /* end */ lua_pushinteger(L, res-s); /* end */
return push_captures(&ms, NULL, NULL) + 2; return push_captures(&ms, NULL, 0) + 2;
} }
else else
return push_captures(&ms, s1, res); return push_captures(&ms, s1, res);
+3 -3
View File
@@ -772,10 +772,10 @@ union luai_Cast { double l_d; long l_l; };
#include <stdio.h> #include <stdio.h>
#if defined(__GNUC__) #if defined(__GNUC__)
#define l_likely(x) (__builtin_expect(!!(x), 1)) #define l_likely(x) (__builtin_expect(((x) != 0), 1))
#define l_unlikely(x) (__builtin_expect(!!(x), 0)) #define l_unlikely(x) (__builtin_expect(((x) != 0), 0))
#else #else
#define l_likely(x) (x) #define l_likely(x) (x)
#define l_unlikely(x) (x) #define l_unlikely(x) (x)
#endif #endif
+16 -48
View File
@@ -28,7 +28,7 @@
/* limit for table tag-method chains (to avoid infinite loops) */ /* limit for table tag-method chains (to avoid loops) */
#define MAXTAGLOOP 100 #define MAXTAGLOOP 100
@@ -366,7 +366,6 @@ static void Arith (lua_State *L, StkId ra, TValue *rb,
#define arith_op(op,tm) { \ #define arith_op(op,tm) { \
StkId ra = RA(i); \
TValue *rb = RKB(i); \ TValue *rb = RKB(i); \
TValue *rc = RKC(i); \ TValue *rc = RKC(i); \
if (ttisnumber(rb) && ttisnumber(rc)) { \ if (ttisnumber(rb) && ttisnumber(rc)) { \
@@ -393,6 +392,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
/* main loop of interpreter */ /* main loop of interpreter */
for (;;) { for (;;) {
const Instruction i = *pc++; const Instruction i = *pc++;
StkId ra;
if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) && if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) &&
(--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) { (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) {
traceexec(L, pc); traceexec(L, pc);
@@ -402,28 +402,26 @@ void luaV_execute (lua_State *L, int nexeccalls) {
} }
base = L->base; base = L->base;
} }
/* warning!! several calls may realloc the stack and invalidate `ra' */
ra = RA(i);
lua_assert(base == L->base && L->base == L->ci->base); lua_assert(base == L->base && L->base == L->ci->base);
lua_assert(base <= L->top && L->top <= L->stack + L->stacksize); lua_assert(base <= L->top && L->top <= L->stack + L->stacksize);
lua_assert(L->top == L->ci->top || luaG_checkopenop(i)); lua_assert(L->top == L->ci->top || luaG_checkopenop(i));
switch (GET_OPCODE(i)) { switch (GET_OPCODE(i)) {
case OP_MOVE: { case OP_MOVE: {
StkId ra = RA(i);
setobjs2s(L, ra, RB(i)); setobjs2s(L, ra, RB(i));
continue; continue;
} }
case OP_LOADK: { case OP_LOADK: {
StkId ra = RA(i);
setobj2s(L, ra, KBx(i)); setobj2s(L, ra, KBx(i));
continue; continue;
} }
case OP_LOADBOOL: { case OP_LOADBOOL: {
StkId ra = RA(i);
setbvalue(ra, GETARG_B(i)); setbvalue(ra, GETARG_B(i));
if (GETARG_C(i)) pc++; /* skip next instruction (if C) */ if (GETARG_C(i)) pc++; /* skip next instruction (if C) */
continue; continue;
} }
case OP_LOADNIL: { case OP_LOADNIL: {
StkId ra = RA(i);
TValue *rb = RB(i); TValue *rb = RB(i);
do { do {
setnilvalue(rb--); setnilvalue(rb--);
@@ -431,13 +429,11 @@ void luaV_execute (lua_State *L, int nexeccalls) {
continue; continue;
} }
case OP_GETUPVAL: { case OP_GETUPVAL: {
StkId ra = RA(i);
int b = GETARG_B(i); int b = GETARG_B(i);
setobj2s(L, ra, cl->upvals[b]->v); setobj2s(L, ra, cl->upvals[b]->v);
continue; continue;
} }
case OP_GETGLOBAL: { case OP_GETGLOBAL: {
StkId ra = RA(i);
TValue g; TValue g;
TValue *rb = KBx(i); TValue *rb = KBx(i);
sethvalue(L, &g, cl->env); sethvalue(L, &g, cl->env);
@@ -446,14 +442,10 @@ void luaV_execute (lua_State *L, int nexeccalls) {
continue; continue;
} }
case OP_GETTABLE: { case OP_GETTABLE: {
StkId ra = RA(i); Protect(luaV_gettable(L, RB(i), RKC(i), ra));
StkId rb = RB(i);
TValue *rc = RKC(i);
Protect(luaV_gettable(L, rb, rc, ra));
continue; continue;
} }
case OP_SETGLOBAL: { case OP_SETGLOBAL: {
StkId ra = RA(i);
TValue g; TValue g;
sethvalue(L, &g, cl->env); sethvalue(L, &g, cl->env);
lua_assert(ttisstring(KBx(i))); lua_assert(ttisstring(KBx(i)));
@@ -461,21 +453,16 @@ void luaV_execute (lua_State *L, int nexeccalls) {
continue; continue;
} }
case OP_SETUPVAL: { case OP_SETUPVAL: {
StkId ra = RA(i);
UpVal *uv = cl->upvals[GETARG_B(i)]; UpVal *uv = cl->upvals[GETARG_B(i)];
setobj(L, uv->v, ra); setobj(L, uv->v, ra);
luaC_barrier(L, uv, ra); luaC_barrier(L, uv, ra);
continue; continue;
} }
case OP_SETTABLE: { case OP_SETTABLE: {
StkId ra = RA(i); Protect(luaV_settable(L, ra, RKB(i), RKC(i)));
TValue *rb = RKB(i);
TValue *rc = RKC(i);
Protect(luaV_settable(L, ra, rb, rc));
continue; continue;
} }
case OP_NEWTABLE: { case OP_NEWTABLE: {
StkId ra = RA(i);
int b = GETARG_B(i); int b = GETARG_B(i);
int c = GETARG_C(i); int c = GETARG_C(i);
sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c))); sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c)));
@@ -483,7 +470,6 @@ void luaV_execute (lua_State *L, int nexeccalls) {
continue; continue;
} }
case OP_SELF: { case OP_SELF: {
StkId ra = RA(i);
StkId rb = RB(i); StkId rb = RB(i);
setobjs2s(L, ra+1, rb); setobjs2s(L, ra+1, rb);
Protect(luaV_gettable(L, rb, RKC(i), ra)); Protect(luaV_gettable(L, rb, RKC(i), ra));
@@ -502,7 +488,6 @@ void luaV_execute (lua_State *L, int nexeccalls) {
continue; continue;
} }
case OP_DIV: { case OP_DIV: {
StkId ra = RA(i);
TValue *rb = RKB(i); TValue *rb = RKB(i);
TValue *rc = RKC(i); TValue *rc = RKC(i);
if (ttisnumber(rb) && ttisnumber(rc)) { if (ttisnumber(rb) && ttisnumber(rc)) {
@@ -518,7 +503,6 @@ void luaV_execute (lua_State *L, int nexeccalls) {
continue; continue;
} }
case OP_MOD: { case OP_MOD: {
StkId ra = RA(i);
TValue *rb = RKB(i); TValue *rb = RKB(i);
TValue *rc = RKC(i); TValue *rc = RKC(i);
if (ttisnumber(rb) && ttisnumber(rc)) { if (ttisnumber(rb) && ttisnumber(rc)) {
@@ -538,27 +522,26 @@ void luaV_execute (lua_State *L, int nexeccalls) {
continue; continue;
} }
case OP_BAND: { case OP_BAND: {
arith_op(luai_numand, TM_AND); arith_op(luai_numand, TM_AND);
continue; continue;
} }
case OP_BOR: { case OP_BOR: {
arith_op(luai_numor, TM_OR); arith_op(luai_numor, TM_OR);
continue; continue;
} }
case OP_BXOR: { case OP_BXOR: {
arith_op(luai_numxor, TM_XOR); arith_op(luai_numxor, TM_XOR);
continue; continue;
} }
case OP_BSHL: { case OP_BSHL: {
arith_op(luai_numshl, TM_SHL); arith_op(luai_numshl, TM_SHL);
continue; continue;
} }
case OP_BSHR: { case OP_BSHR: {
arith_op(luai_numshr, TM_SHR); arith_op(luai_numshr, TM_SHR);
continue; continue;
} }
case OP_BNOT: { case OP_BNOT: {
StkId ra = RA(i);
TValue *rb = RB(i); TValue *rb = RB(i);
if (ttisnumber(rb)) { if (ttisnumber(rb)) {
lua_Number nb = nvalue(rb); lua_Number nb = nvalue(rb);
@@ -570,7 +553,6 @@ void luaV_execute (lua_State *L, int nexeccalls) {
continue; continue;
} }
case OP_UNM: { case OP_UNM: {
StkId ra = RA(i);
TValue *rb = RB(i); TValue *rb = RB(i);
if (ttisnumber(rb)) { if (ttisnumber(rb)) {
lua_Number nb = nvalue(rb); lua_Number nb = nvalue(rb);
@@ -582,13 +564,11 @@ void luaV_execute (lua_State *L, int nexeccalls) {
continue; continue;
} }
case OP_NOT: { case OP_NOT: {
StkId ra = RA(i);
int res = l_isfalse(RB(i)); /* next assignment may change this value */ int res = l_isfalse(RB(i)); /* next assignment may change this value */
setbvalue(ra, res); setbvalue(ra, res);
continue; continue;
} }
case OP_LEN: { case OP_LEN: {
StkId ra = RA(i);
TValue *rb = RB(i); TValue *rb = RB(i);
switch (ttype(rb)) { switch (ttype(rb)) {
case LUA_TTABLE: { case LUA_TTABLE: {
@@ -646,14 +626,12 @@ void luaV_execute (lua_State *L, int nexeccalls) {
continue; continue;
} }
case OP_TEST: { case OP_TEST: {
StkId ra = RA(i);
if (l_isfalse(ra) != GETARG_C(i)) if (l_isfalse(ra) != GETARG_C(i))
dojump(L, pc, GETARG_sBx(*pc)); dojump(L, pc, GETARG_sBx(*pc));
pc++; pc++;
continue; continue;
} }
case OP_TESTSET: { case OP_TESTSET: {
StkId ra = RA(i);
TValue *rb = RB(i); TValue *rb = RB(i);
if (l_isfalse(rb) != GETARG_C(i)) { if (l_isfalse(rb) != GETARG_C(i)) {
setobjs2s(L, ra, rb); setobjs2s(L, ra, rb);
@@ -663,7 +641,6 @@ void luaV_execute (lua_State *L, int nexeccalls) {
continue; continue;
} }
case OP_CALL: { case OP_CALL: {
StkId ra = RA(i);
int b = GETARG_B(i); int b = GETARG_B(i);
int nresults = GETARG_C(i) - 1; int nresults = GETARG_C(i) - 1;
if (b != 0) L->top = ra+b; /* else previous instruction set top */ if (b != 0) L->top = ra+b; /* else previous instruction set top */
@@ -685,7 +662,6 @@ void luaV_execute (lua_State *L, int nexeccalls) {
} }
} }
case OP_TAILCALL: { case OP_TAILCALL: {
StkId ra = RA(i);
int b = GETARG_B(i); int b = GETARG_B(i);
if (b != 0) L->top = ra+b; /* else previous instruction set top */ if (b != 0) L->top = ra+b; /* else previous instruction set top */
L->savedpc = pc; L->savedpc = pc;
@@ -718,7 +694,6 @@ void luaV_execute (lua_State *L, int nexeccalls) {
} }
} }
case OP_RETURN: { case OP_RETURN: {
StkId ra = RA(i);
int b = GETARG_B(i); int b = GETARG_B(i);
if (b != 0) L->top = ra+b-1; if (b != 0) L->top = ra+b-1;
if (L->openupval) luaF_close(L, base); if (L->openupval) luaF_close(L, base);
@@ -734,7 +709,6 @@ void luaV_execute (lua_State *L, int nexeccalls) {
} }
} }
case OP_FORLOOP: { case OP_FORLOOP: {
StkId ra = RA(i);
lua_Number step = nvalue(ra+2); lua_Number step = nvalue(ra+2);
lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */ lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */
lua_Number limit = nvalue(ra+1); lua_Number limit = nvalue(ra+1);
@@ -747,7 +721,6 @@ void luaV_execute (lua_State *L, int nexeccalls) {
continue; continue;
} }
case OP_FORPREP: { case OP_FORPREP: {
StkId ra = RA(i);
const TValue *init = ra; const TValue *init = ra;
const TValue *plimit = ra+1; const TValue *plimit = ra+1;
const TValue *pstep = ra+2; const TValue *pstep = ra+2;
@@ -764,7 +737,6 @@ void luaV_execute (lua_State *L, int nexeccalls) {
continue; continue;
} }
case OP_TFORLOOP: { case OP_TFORLOOP: {
StkId ra = RA(i);
StkId cb = ra + 3; /* call base */ StkId cb = ra + 3; /* call base */
setobjs2s(L, cb+2, ra+2); setobjs2s(L, cb+2, ra+2);
setobjs2s(L, cb+1, ra+1); setobjs2s(L, cb+1, ra+1);
@@ -781,7 +753,6 @@ void luaV_execute (lua_State *L, int nexeccalls) {
continue; continue;
} }
case OP_SETLIST: { case OP_SETLIST: {
StkId ra = RA(i);
int n = GETARG_B(i); int n = GETARG_B(i);
int c = GETARG_C(i); int c = GETARG_C(i);
int last; int last;
@@ -804,12 +775,10 @@ void luaV_execute (lua_State *L, int nexeccalls) {
continue; continue;
} }
case OP_CLOSE: { case OP_CLOSE: {
StkId ra = RA(i);
luaF_close(L, ra); luaF_close(L, ra);
continue; continue;
} }
case OP_CLOSURE: { case OP_CLOSURE: {
StkId ra = RA(i);
Proto *p; Proto *p;
Closure *ncl; Closure *ncl;
int nup, j; int nup, j;
@@ -830,7 +799,6 @@ void luaV_execute (lua_State *L, int nexeccalls) {
continue; continue;
} }
case OP_VARARG: { case OP_VARARG: {
StkId ra = RA(i);
int b = GETARG_B(i) - 1; int b = GETARG_B(i) - 1;
int j; int j;
CallInfo *ci = L->ci; CallInfo *ci = L->ci;
+4 -4
View File
@@ -655,7 +655,7 @@ static void COM_Alias_f(void)
CONS_Printf(M_GetText("All aliases that start with \x87'%s'\x80 are:\n"), begin); CONS_Printf(M_GetText("All aliases that start with \x87'%s'\x80 are:\n"), begin);
int count = 0; int count = 0;
for (cmdalias_t *head = com_alias; head != NULL; head = head->next) for (cmdalias_t *head = com_alias; head->next != NULL; head = head->next)
{ {
if (strncmp(begin, head->name, szBegin) == 0) if (strncmp(begin, head->name, szBegin) == 0)
{ {
@@ -676,7 +676,7 @@ static void COM_Alias_f(void)
/* Display alias subtext, show all aliases. */ /* Display alias subtext, show all aliases. */
CONS_Printf(M_GetText("alias <name> <command>: create a shortcut command that executes other command(s)\n")); CONS_Printf(M_GetText("alias <name> <command>: create a shortcut command that executes other command(s)\n"));
for (cmdalias_t *head = com_alias; head != NULL; head = head->next) for (cmdalias_t *head = com_alias; head->next != NULL; head = head->next)
{ {
CONS_Printf(alias_format, head->name, head->value); CONS_Printf(alias_format, head->name, head->value);
} }
@@ -1178,7 +1178,7 @@ consvar_t *CV_FindVar(const char *name)
consvar_t *cvar; consvar_t *cvar;
for (cvar = consvar_vars; cvar; cvar = cvar->next) for (cvar = consvar_vars; cvar; cvar = cvar->next)
if (fasticmp(name, cvar->name)) if (fasticmp(name,cvar->name))
return cvar; return cvar;
return NULL; return NULL;
@@ -1793,7 +1793,7 @@ void CV_AddValue(consvar_t *var, INT32 increment)
if (newvalue == oldvalue) if (newvalue == oldvalue)
break; // don't loop forever if there's none of a certain gametype break; // don't loop forever if there's none of a certain gametype
if (newvalue >= 0 && newvalue < NUMMAPS && !mapheaderinfo[newvalue]) if (newvalue >= 0 && !mapheaderinfo[newvalue])
continue; // Don't allocate the header. That just makes memory usage skyrocket. continue; // Don't allocate the header. That just makes memory usage skyrocket.
} while (!M_CanShowLevelInList(newvalue, gt)); } while (!M_CanShowLevelInList(newvalue, gt));
+3 -3
View File
@@ -13,13 +13,13 @@
#ifndef __COMMAND_H__ #ifndef __COMMAND_H__
#define __COMMAND_H__ #define __COMMAND_H__
#include <stdio.h>
#include "doomdef.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include <stdio.h>
#include "doomdef.h"
//=================================== //===================================
// Command buffer & command execution // Command buffer & command execution
//=================================== //===================================
+38 -3
View File
@@ -11,6 +11,21 @@
#ifdef CMAKECONFIG #ifdef CMAKECONFIG
// Base SRB2 hashes
#define ASSET_HASH_SRB2_SRB "${SRB2_ASSET_srb2.srb_HASH}"
#ifdef USE_PATCH_DTA
#define ASSET_HASH_PATCH_DTA "${SRB2_ASSET_patch.dta_HASH}"
#endif
// SRB2Kart-specific hashes
#define ASSET_HASH_GFX_KART "${SRB2_ASSET_gfx.kart_HASH}"
#define ASSET_HASH_TEXTURES_KART "${SRB2_ASSET_textures.kart_HASH}"
#define ASSET_HASH_CHARS_KART "${SRB2_ASSET_chars.kart_HASH}"
#define ASSET_HASH_MAPS_KART "${SRB2_ASSET_maps.kart_HASH}"
#ifdef USE_PATCH_KART
#define ASSET_HASH_PATCH_KART "00000000000000000000000000000000"
#endif
#define SRB2_COMP_REVISION "${SRB2_COMP_REVISION}" #define SRB2_COMP_REVISION "${SRB2_COMP_REVISION}"
#define SRB2_COMP_BRANCH "${SRB2_COMP_BRANCH}" #define SRB2_COMP_BRANCH "${SRB2_COMP_BRANCH}"
@@ -18,10 +33,30 @@
#else #else
#define SRB2_COMP_REVISION "" /* Manually defined asset hashes for non-CMake builds
#define SRB2_COMP_BRANCH "" * Last updated 2015 / 05 / 03 - SRB2 v2.1.15 - srb2.srb
* Last updated 2018 / 12 / 23 - SRB2 v2.1.22 - patch.dta
* Last updated 2019 / 01 / 18 - Kart v1.0.2 - Main assets
* Last updated 2020 / 08 / 30 - Kart v1.3 - patch.kart
* Last updated 2022 / 08 / 16 - Kart v1.4 - Main assets
* Last updated 2022 / 08 / 19 - Kart v1.5 - gfx.kart
* Last updated 2022 / 11 / 01 - Kart v1.6 - gfx.kart, maps.kart
*/
#define CMAKE_ASSETS_DIR "" // Base SRB2 hashes
#define ASSET_HASH_SRB2_SRB "c1b9577687f8a795104aef4600720ea7"
#ifdef USE_PATCH_DTA
#define ASSET_HASH_PATCH_DTA "b04fd9624bfd94dc96dcf4f400f7deb4"
#endif
// SRB2Kart-specific hashes
#define ASSET_HASH_GFX_KART "06f86ee16136eb8a7043b15001797034"
#define ASSET_HASH_TEXTURES_KART "abb53d56aba47c3a8cb0f764da1c8b80"
#define ASSET_HASH_CHARS_KART "e2c428347dde52858a3dacd29fc5b964"
#define ASSET_HASH_MAPS_KART "d051e55141ba736582228c456953cd98"
#ifdef USE_PATCH_KART
#define ASSET_HASH_PATCH_KART "00000000000000000000000000000000"
#endif
#endif #endif
#endif #endif
+9 -17
View File
@@ -46,16 +46,16 @@
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
I_mutex con_mutex; I_mutex con_mutex;
// I_In_Exiting_Signal_Handler is an evil hack // g_in_exiting_signal_handler is an evil hack
// to avoid infinite SIGABRT recursion in the signal handler // to avoid infinite SIGABRT recursion in the signal handler
// due to poisoned locks or mach-o kernel not supporting locks in signals // due to poisoned locks or mach-o kernel not supporting locks in signals
// or something like that. idk // or something like that. idk
# define Lock_state() if (!I_In_Exiting_Signal_Handler()) { I_lock_mutex(&con_mutex); } # define Lock_state() if (!g_in_exiting_signal_handler) { I_lock_mutex(&con_mutex); }
# define Unlock_state() if (!I_In_Exiting_Signal_Handler()) { I_unlock_mutex(con_mutex); } # define Unlock_state() if (!g_in_exiting_signal_handler) { I_unlock_mutex(con_mutex); }
#else /*HAVE_THREADS*/ #else/*HAVE_THREADS*/
# define Lock_state() # define Lock_state()
# define Unlock_state() # define Unlock_state()
#endif /*HAVE_THREADS*/ #endif/*HAVE_THREADS*/
static boolean con_started = false; // console has been initialised static boolean con_started = false; // console has been initialised
boolean con_startup = false; // true at game startup, screen need refreshing boolean con_startup = false; // true at game startup, screen need refreshing
@@ -169,8 +169,6 @@ static CV_PossibleValue_t menuhighlight_cons_t[] =
}; };
consvar_t cons_menuhighlight = {"menuhighlight", "Gametype Default", CV_SAVE, menuhighlight_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cons_menuhighlight = {"menuhighlight", "Gametype Default", CV_SAVE, menuhighlight_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cons_consoleprintinmenu = {"consoleprintinmenu", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
static void CON_Print(char *msg); static void CON_Print(char *msg);
// //
@@ -428,7 +426,6 @@ void CON_Init(void)
CV_RegisterVar(&cons_backpic); CV_RegisterVar(&cons_backpic);
CV_RegisterVar(&cons_backcolor); CV_RegisterVar(&cons_backcolor);
CV_RegisterVar(&cons_menuhighlight); CV_RegisterVar(&cons_menuhighlight);
CV_RegisterVar(&cons_consoleprintinmenu);
COM_AddCommand("bind", CONS_Bind_f); COM_AddCommand("bind", CONS_Bind_f);
} }
else else
@@ -589,18 +586,12 @@ static void CON_ChangeHeight(void)
// Handles Console moves in/out of screen (per frame) // Handles Console moves in/out of screen (per frame)
// //
void CON_MoveConsole(void) static void CON_MoveConsole(void)
{ {
static fixed_t fracmovement = 0; static fixed_t fracmovement = 0;
Lock_state(); Lock_state();
if (con_curlines == con_destlines)
{
Unlock_state();
return;
}
// instant // instant
if (!cons_speed.value) if (!cons_speed.value)
{ {
@@ -1593,12 +1584,13 @@ void CON_Drawer(void)
} }
// console movement // console movement
CON_MoveConsole(); if (con_curlines != con_destlines)
CON_MoveConsole();
if (con_curlines > 0) if (con_curlines > 0)
CON_DrawConsole(); CON_DrawConsole();
else if (gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_CUTSCENE || gamestate == GS_CREDITS else if (gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_CUTSCENE || gamestate == GS_CREDITS
|| gamestate == GS_VOTING || gamestate == GS_EVALUATION || gamestate == GS_WAITINGPLAYERS || (cons_consoleprintinmenu.value && gamestate == GS_TITLESCREEN)) || gamestate == GS_VOTING || gamestate == GS_EVALUATION || gamestate == GS_WAITINGPLAYERS)
CON_DrawHudlines(); CON_DrawHudlines();
Unlock_state(); Unlock_state();
-10
View File
@@ -13,10 +13,6 @@
#ifndef __CONSOLE__ #ifndef __CONSOLE__
#define __CONSOLE__ #define __CONSOLE__
#ifdef __cplusplus
extern "C" {
#endif
#include "d_event.h" #include "d_event.h"
#include "command.h" #include "command.h"
#include "i_threads.h" #include "i_threads.h"
@@ -40,7 +36,6 @@ extern INT32 con_destlines;
extern UINT32 con_scalefactor; // console text scale factor extern UINT32 con_scalefactor; // console text scale factor
extern consvar_t cons_backcolor, cons_menuhighlight; extern consvar_t cons_backcolor, cons_menuhighlight;
extern consvar_t cons_consoleprintinmenu;
extern UINT8 *yellowmap, *purplemap, *greenmap, *bluemap, *graymap, *redmap, *orangemap,\ extern UINT8 *yellowmap, *purplemap, *greenmap, *bluemap, *graymap, *redmap, *orangemap,\
*skymap, *goldmap, *lavendermap, *teamap, *steelmap, *pinkmap, *brownmap, *peachmap; *skymap, *goldmap, *lavendermap, *teamap, *steelmap, *pinkmap, *brownmap, *peachmap;
@@ -56,7 +51,6 @@ void CON_ClearHUD(void); // clear heads up messages
void CON_Ticker(void); void CON_Ticker(void);
void CON_Drawer(void); void CON_Drawer(void);
void CON_MoveConsole(void);
void CONS_Error(const char *msg); // print out error msg, and wait a key void CONS_Error(const char *msg); // print out error msg, and wait a key
// force console to move out // force console to move out
@@ -67,8 +61,4 @@ boolean CON_Ready(void);
void CON_LogMessage(const char *msg); void CON_LogMessage(const char *msg);
#ifdef __cplusplus
} // extern "C"
#endif
#endif #endif
+403 -427
View File
File diff suppressed because it is too large. Load diff
+5 -5
View File
@@ -516,6 +516,7 @@ typedef struct
extern serverelem_t serverlist[MAXSERVERLIST]; extern serverelem_t serverlist[MAXSERVERLIST];
extern UINT32 serverlistcount; extern UINT32 serverlistcount;
extern UINT32 serverlistultimatecount;
extern INT32 mapchangepending; extern INT32 mapchangepending;
// Points inside doomcom // Points inside doomcom
@@ -626,6 +627,7 @@ void CL_ClearPlayer(INT32 playernum);
void CL_RemovePlayer(INT32 playernum, INT32 reason); void CL_RemovePlayer(INT32 playernum, INT32 reason);
void CL_QueryServerList(msg_server_t *list); void CL_QueryServerList(msg_server_t *list);
void CL_UpdateServerList(void); void CL_UpdateServerList(void);
void CL_TimeoutServerList(void);
void CL_AbortConnection(void); void CL_AbortConnection(void);
@@ -654,17 +656,15 @@ void D_ResetTiccmds(void);
tic_t GetLag(INT32 node); tic_t GetLag(INT32 node);
extern boolean hu_resynching; extern UINT8 hu_resynching;
#ifdef SATURNPAK #ifdef SATURNPAK
extern boolean hu_redownloadinggamestate; extern UINT8 hu_redownloadinggamestate;
#endif #endif
extern boolean hu_stopped; // kart, true when the game is stopped for players due to a disconnecting or connecting player extern boolean hu_stopped; // kart, true when the game is stopped for players due to a disconnecting or connecting player
#define SAVEGAMESIZE (768*1024)
typedef struct rewind_s typedef struct rewind_s
{ {
UINT8 savebuffer[SAVEGAMESIZE]; UINT8 savebuffer[(768*1024)];
tic_t leveltime; tic_t leveltime;
size_t demopos; size_t demopos;
+67 -107
View File
@@ -80,31 +80,6 @@
#include "lua_script.h" #include "lua_script.h"
/* Manually defined asset hashes for non-CMake builds
* Last updated 2015 / 05 / 03 - SRB2 v2.1.15 - srb2.srb
* Last updated 2018 / 12 / 23 - SRB2 v2.1.22 - patch.dta
* Last updated 2019 / 01 / 18 - Kart v1.0.2 - Main assets
* Last updated 2020 / 08 / 30 - Kart v1.3 - patch.kart
* Last updated 2022 / 08 / 16 - Kart v1.4 - Main assets
* Last updated 2022 / 08 / 19 - Kart v1.5 - gfx.kart
* Last updated 2022 / 11 / 01 - Kart v1.6 - gfx.kart, maps.kart
*/
// Base SRB2 hashes
#define ASSET_HASH_SRB2_SRB "c1b9577687f8a795104aef4600720ea7"
#ifdef USE_PATCH_DTA
#define ASSET_HASH_PATCH_DTA "b04fd9624bfd94dc96dcf4f400f7deb4"
#endif
// SRB2Kart-specific hashes
#define ASSET_HASH_GFX_KART "06f86ee16136eb8a7043b15001797034"
#define ASSET_HASH_TEXTURES_KART "abb53d56aba47c3a8cb0f764da1c8b80"
#define ASSET_HASH_CHARS_KART "e2c428347dde52858a3dacd29fc5b964"
#define ASSET_HASH_MAPS_KART "d051e55141ba736582228c456953cd98"
#ifdef USE_PATCH_KART
#define ASSET_HASH_PATCH_KART "00000000000000000000000000000000"
#endif
#ifdef CMAKECONFIG #ifdef CMAKECONFIG
#include "config.h" #include "config.h"
#else #else
@@ -130,8 +105,8 @@ static size_t startuppwadcount = 0;
// autoloading // autoloading
static char *autoloadwadfiles[MAX_WADFILES]; static char *autoloadwadfiles[MAX_WADFILES];
static char *autoloadwadfilespost[MAX_WADFILES]; static char *autoloadwadfilespost[MAX_WADFILES];
static size_t autoloadwadcount = 0; static size_t autoloadcount = 0;
static size_t postloadwadcount = 0; static size_t postloadcount = 0;
// //
boolean devparm = false; // started game with -devparm boolean devparm = false; // started game with -devparm
@@ -274,17 +249,21 @@ static void D_Renderview(void)
R_ApplyLevelInterpolators(R_GetTimeFrac(RTF_LEVEL)); R_ApplyLevelInterpolators(R_GetTimeFrac(RTF_LEVEL));
if (rendermode == render_soft && cv_homremoval.value) if (rendermode == render_soft)
{ {
if (cv_homremoval.value == 1) // if this is display player 1
if (cv_homremoval.value)
{ {
// Clear the software screen buffer to remove HOM if (cv_homremoval.value == 1)
memset(vid.screens[0], 31, vid.width * vid.height); {
} // Clear the software screen buffer to remove HOM
else if (cv_homremoval.value == 2) memset(vid.screens[0], 31, vid.width * vid.height);
{ }
//'development' HOM removal -- makes it blindingly obvious if HOM is spotted. else if (cv_homremoval.value == 2)
memset(vid.screens[0], 32+(timeinmap&15), vid.width * vid.height); {
//'development' HOM removal -- makes it blindingly obvious if HOM is spotted.
memset(vid.screens[0], 32+(timeinmap&15), vid.width * vid.height);
}
} }
} }
@@ -318,6 +297,7 @@ static void D_Renderview(void)
break; break;
default: // Initialize for P1 default: // Initialize for P1
viewwindowy = viewwindowx = 0; viewwindowy = viewwindowx = 0;
objectsdrawn = 0;
break; break;
} }
@@ -328,17 +308,19 @@ static void D_Renderview(void)
} }
else if (rendermode == render_soft) else if (rendermode == render_soft)
#endif #endif
{
R_RenderPlayerView(&players[displayplayers[i]]); R_RenderPlayerView(&players[displayplayers[i]]);
}
if (rendermode == render_soft)
{
if (i == 0)
R_ApplyViewMorph();
if (i == 0)
R_ApplyViewMorph();
#ifdef MOTIONBLUR #ifdef MOTIONBLUR
V_DoPostProcessor(i, postimgparam[i]); V_DoPostProcessor(i, postimgparam[i]);
#else #else
V_DoPostProcessor(i, 0); V_DoPostProcessor(i, 0);
#endif #endif
}
} }
} }
@@ -657,7 +639,7 @@ void D_SRB2Loop(void)
tic_t entertic = 0, oldentertics = 0, realtics = 0, rendertimeout = INFTICS; tic_t entertic = 0, oldentertics = 0, realtics = 0, rendertimeout = INFTICS;
double deltatics = 0.0; double deltatics = 0.0;
double deltasecs = 0.0; double deltasecs = 0.0;
UINT64 precision = 0; UINT64 precision;
boolean interp = false; boolean interp = false;
boolean doDisplay = false; boolean doDisplay = false;
@@ -697,11 +679,6 @@ void D_SRB2Loop(void)
for (;;) for (;;)
{ {
if (I_Interrupted())
{
I_Quit();
}
// capbudget is the minimum precise_t duration of a single loop iteration // capbudget is the minimum precise_t duration of a single loop iteration
precise_t capbudget; precise_t capbudget;
precise_t elapsed; precise_t elapsed;
@@ -781,6 +758,11 @@ void D_SRB2Loop(void)
doDisplay = true; doDisplay = true;
} }
if (!dedicated)
{
G_DeviceLEDTick();
}
} }
if (interp) if (interp)
@@ -810,9 +792,9 @@ void D_SRB2Loop(void)
} }
else if (!dedicated) else if (!dedicated)
{ {
// always update console movement // always update console and hud
// otherwise it will takes literal ages to open // otherwise it may take minutes to open it
CON_MoveConsole(); CON_Drawer();
} }
} }
@@ -822,13 +804,6 @@ void D_SRB2Loop(void)
if (takescreenshot) if (takescreenshot)
M_DoScreenShot(); M_DoScreenShot();
#ifndef DEDICATED
if (!dedicated && renderisnewtic)
{
G_DeviceLEDTick();
}
#endif
// consoleplayer -> displayplayers (hear sounds from viewpoint) // consoleplayer -> displayplayers (hear sounds from viewpoint)
S_UpdateSounds(); // move positional sounds S_UpdateSounds(); // move positional sounds
@@ -907,11 +882,10 @@ void D_ClearState(void)
// okay, stop now // okay, stop now
// (otherwise the game still thinks we're playing!) // (otherwise the game still thinks we're playing!)
#ifdef HAVE_CURL
CURLAbortFile(); CURLAbortFile();
#endif
SV_StopServer(); SV_StopServer();
SV_ResetServer(); SV_ResetServer();
serverlistultimatecount = 0;
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
CL_ClearPlayer(i); CL_ClearPlayer(i);
@@ -973,9 +947,6 @@ void D_ClearState(void)
// //
void D_StartTitle(void) void D_StartTitle(void)
{ {
if (dedicated)
I_Error("D_StartTitle is called on dedicated server");
D_ClearState(); D_ClearState();
multiplayer = netgame = false; // title menu shouldnt be a netgame or multiplayer lmao multiplayer = netgame = false; // title menu shouldnt be a netgame or multiplayer lmao
F_StartTitleScreen(); F_StartTitleScreen();
@@ -1037,38 +1008,25 @@ static INT32 D_DetectFileType(const char* filename)
} }
// autoload that shit // autoload that shit
static void D_AutoloadFile(const char *file, char **filearray, size_t *index) static void D_AutoloadFile(const char *file, char **filearray, size_t index)
{ {
char *newfile; char *newfile;
INT32 fileType = D_DetectFileType(file); INT32 fileType = D_DetectFileType(file);
if (*index >= MAX_WADFILES)
{
CONS_Printf("D_AutoloadFile: Failed to add file %s! Too many autoloaded files\n", file);
return;
}
if (!fileType) if (!fileType)
{ {
CONS_Printf("D_AutoloadFile: File %s is unknown or invalid\n", file); CONS_Printf("D_AutoloadFile: File %s is unknown or invalid\n", file);
return; return;
} }
if (fileType == 1)
{
CONS_Printf("D_AutoloadFile: File %s is a directory\n", file);
return;
}
if (fileType <= 6) if (fileType <= 6)
{ {
newfile = malloc(strlen(file) + 1); newfile = malloc(strlen(file) + 1);
if (!newfile) if (!newfile)
I_Error("D_AutoloadFile: No more free memory to autoload file %s", file); I_Error("No more free memory to AutoloadFile %s",file);
strcpy(newfile, file); strcpy(newfile, file);
filearray[*index] = newfile; filearray[index] = newfile;
(*index)++;
} }
else else
{ {
@@ -1111,7 +1069,7 @@ static void D_FindAddonsToAutoload(void)
// If the file is found, run our shit // If the file is found, run our shit
if (!autoloadconfigfile) // nope outta here if (!autoloadconfigfile) // nope outta here
{ {
autoloadwadcount = postloadwadcount = 0; // so D_AddAutoloadFiles can skip everything since nothings there to autoload autoloadcount = postloadcount = 0; // so D_AddAutoloadFiles can skip everything since nothings there to autoload
return; return;
} }
@@ -1137,34 +1095,27 @@ static void D_FindAddonsToAutoload(void)
if (newline) if (newline)
*newline = '\0'; *newline = '\0';
// ok so theres still issues with players adding stuff to autoload by accident
// sometimes this stuff contains maps
// you can probably imagine how that goes in a netgame....
if (W_CheckAutoLoadContainsMap(wadsToAutoload))
{
CONS_Printf("Autoload: file %s contains map data! skipping...", wadsToAutoload);
continue;
}
if (!postload && W_CheckPostLoadList(wadsToAutoload)) if (!postload && W_CheckPostLoadList(wadsToAutoload))
{ {
CONS_Printf("Autoload: forcing postload for file %s\n", wadsToAutoload); CONS_Printf("forcing postload for file %s\n", wadsToAutoload);
postload = true; postload = true;
} }
// LOAD IT // LOAD IT
if (!postload) if (!postload)
{ {
D_AutoloadFile(wadsToAutoload, autoloadwadfiles, &autoloadwadcount); D_AutoloadFile(wadsToAutoload, autoloadwadfiles, autoloadcount);
autoloadcount++;
} }
else else
{ {
D_AutoloadFile(wadsToAutoload, autoloadwadfilespost, &postloadwadcount); D_AutoloadFile(wadsToAutoload, autoloadwadfilespost, postloadcount);
postloadcount++;
} }
} }
autoloadwadfiles[autoloadwadcount] = NULL; autoloadwadfiles[autoloadcount] = NULL;
autoloadwadfilespost[postloadwadcount] = NULL; autoloadwadfilespost[postloadcount] = NULL;
// we dont want memory leaks around here do we? // we dont want memory leaks around here do we?
fclose(autoloadconfigfile); fclose(autoloadconfigfile);
@@ -1173,7 +1124,7 @@ static void D_FindAddonsToAutoload(void)
static void D_AddAutoloadFiles(void) static void D_AddAutoloadFiles(void)
{ {
// nothing to autoload // nothing to autoload
if (autoloadwadcount == 0) if (autoloadcount == 0)
return; return;
CONS_Printf("D_AutoloadFile(): Loading autoloaded addons...\n"); CONS_Printf("D_AutoloadFile(): Loading autoloaded addons...\n");
@@ -1181,15 +1132,15 @@ static void D_AddAutoloadFiles(void)
if (W_AddAutoloadedLocalFiles(autoloadwadfiles) == 0) if (W_AddAutoloadedLocalFiles(autoloadwadfiles) == 0)
CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n"); CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n");
D_CleanFile(autoloadwadfiles, autoloadwadcount); D_CleanFile(autoloadwadfiles, autoloadcount);
autoloadwadcount = 0; autoloadcount = 0;
} }
void D_AddPostloadFiles(void) void D_AddPostloadFiles(void)
{ {
// nothing to postload // nothing to postload
if (postloadwadcount == 0 || !netgame) if (postloadcount == 0 || !netgame)
return; return;
CONS_Printf("D_AddPostloadFiles(): Loading postloaded addons...\n"); CONS_Printf("D_AddPostloadFiles(): Loading postloaded addons...\n");
@@ -1197,9 +1148,9 @@ void D_AddPostloadFiles(void)
if (W_AddAutoloadedLocalFiles(autoloadwadfilespost) == 0) if (W_AddAutoloadedLocalFiles(autoloadwadfilespost) == 0)
CONS_Printf("D_AddPostloadFiles(): Are you sure you put in valid files or what?\n"); CONS_Printf("D_AddPostloadFiles(): Are you sure you put in valid files or what?\n");
D_CleanFile(autoloadwadfilespost, postloadwadcount); D_CleanFile(autoloadwadfilespost, postloadcount);
postloadwadcount = 0; postloadcount = 0;
} }
// ========================================================================== // ==========================================================================
@@ -1236,13 +1187,17 @@ static void IdentifyVersion(void)
#endif #endif
char tempsrb2path[256] = "."; char tempsrb2path[256] = ".";
if (getcwd(tempsrb2path, 256) == NULL) getcwd(tempsrb2path, 256);
strcpy(tempsrb2path, ".");
// get the current directory (possible problem on NT with "." as current dir) // get the current directory (possible problem on NT with "." as current dir)
if (!srb2waddir) if (!srb2waddir)
{ {
srb2waddir = tempsrb2path; if (tempsrb2path[0])
srb2waddir = tempsrb2path;
else
{
srb2waddir = ".";
}
} }
#if (1) // reduce the amount of findfile by only using full cwd in this func #if (1) // reduce the amount of findfile by only using full cwd in this func
@@ -1309,7 +1264,7 @@ static void IdentifyVersion(void)
if (AddIWAD("extra3.kart", srb2waddir)) if (AddIWAD("extra3.kart", srb2waddir))
found_extra3_kart = true; found_extra3_kart = true;
#if !defined (HAVE_SDL) || defined (HAVE_MIXER) #if defined (HAVE_SDL)
#define MUSICTEST(str) \ #define MUSICTEST(str) \
musicpath = va(pandf, srb2waddir, str);\ musicpath = va(pandf, srb2waddir, str);\
handle = W_OpenWadFile(&musicpath, false); \ handle = W_OpenWadFile(&musicpath, false); \
@@ -1663,6 +1618,12 @@ void D_SRB2Main(void)
strcpy(srb2, "SRB2Kart"); strcpy(srb2, "SRB2Kart");
D_MakeTitleString(srb2); D_MakeTitleString(srb2);
#if defined (__OS2__) && !defined (HAVE_SDL)
// set PM window title
snprintf(pmData->title, sizeof (pmData->title), "SRB2Kart" VERSIONSTRING ": %s", title);
pmData->title[sizeof (pmData->title) - 1] = '\0';
#endif
if (devparm) if (devparm)
CONS_Printf(M_GetText("Development mode ON.\n")); CONS_Printf(M_GetText("Development mode ON.\n"));
@@ -1909,8 +1870,7 @@ void D_SRB2Main(void)
if (M_CheckParm("-warp") && M_IsNextParm()) if (M_CheckParm("-warp") && M_IsNextParm())
{ {
const char *word = M_GetNextParm(); const char *word = M_GetNextParm();
pstartmap = G_FindMapByNameOrCode(word, NULL); pstartmap = G_FindMapByNameOrCode(word, 0);
if (! pstartmap) if (! pstartmap)
I_Error("Cannot find a map remotely named '%s'\n", word); I_Error("Cannot find a map remotely named '%s'\n", word);
else else
@@ -2043,7 +2003,7 @@ void D_SRB2Main(void)
if (M_CheckProtoParam("replay")) if (M_CheckProtoParam("replay"))
{ {
const char *replayurl = M_GetProtoParam(); const char *replayurl = M_GetProtoParam();
gconst char *replayname = strrchr(replayurl, '/'); char *replayname = strrchr(replayurl, '/');
if (!replayname || !replayurl) if (!replayname || !replayurl)
I_Error("REPLAY: Invalid URL."); I_Error("REPLAY: Invalid URL.");
+8 -10
View File
@@ -59,7 +59,7 @@ static INT16 reboundsize[MAXREBOUND];
static INT32 rebound_head, rebound_tail; static INT32 rebound_head, rebound_tail;
/// \brief max length per packet /// \brief max length per packet
INT16 hardware_MAXPACKETLENGTH = 0; INT16 hardware_MAXPACKETLENGTH;
boolean (*I_NetGet)(void) = NULL; boolean (*I_NetGet)(void) = NULL;
void (*I_NetSend)(void) = NULL; void (*I_NetSend)(void) = NULL;
@@ -96,7 +96,7 @@ INT32 ticruned = 0, ticmiss = 0;
// globals // globals
INT32 getbps = 0, sendbps = 0; INT32 getbps = 0, sendbps = 0;
float lostpercent = 0.0f, duppercent = 0.0f, gamelostpercent = 0.0f; float lostpercent = 0, duppercent = 0, gamelostpercent = 0;
INT32 packetheaderlength = 0; INT32 packetheaderlength = 0;
boolean Net_GetNetStat(void) boolean Net_GetNetStat(void)
@@ -492,7 +492,6 @@ void Net_AckTicker(void)
ackpak[i].acknum = 0; ackpak[i].acknum = 0;
continue; continue;
} }
DEBFILE(va("Resend ack %d, %u<%d at %u\n", ackpak[i].acknum, ackpak[i].senttime, DEBFILE(va("Resend ack %d, %u<%d at %u\n", ackpak[i].acknum, ackpak[i].senttime,
NODETIMEOUT, I_GetTime())); NODETIMEOUT, I_GetTime()));
memcpy(netbuffer, ackpak[i].pak.raw, ackpak[i].length); memcpy(netbuffer, ackpak[i].pak.raw, ackpak[i].length);
@@ -612,8 +611,12 @@ void Net_WaitAllAckReceived(UINT32 timeout)
static void InitNode(node_t *node) static void InitNode(node_t *node)
{ {
memset(node, 0, sizeof(node_t)); node->acktosend_head = node->acktosend_tail = 0;
memset(node->acktosend, 0, sizeof(node->acktosend));
node->firstacktosend = 0;
node->nextacknum = 1; node->nextacknum = 1;
node->remotefirstack = 0;
node->flags = 0;
} }
static void InitAck(void) static void InitAck(void)
@@ -1221,7 +1224,7 @@ void D_SetDoomcom(void)
if (doomcom) if (doomcom)
return; return;
doomcom = Z_Calloc(sizeof(doomcom_t), PU_STATIC, NULL); doomcom = Z_Calloc(sizeof (doomcom_t), PU_STATIC, NULL);
doomcom->id = DOOMCOM_ID; doomcom->id = DOOMCOM_ID;
doomcom->numslots = doomcom->numnodes = 1; doomcom->numslots = doomcom->numnodes = 1;
} }
@@ -1263,7 +1266,6 @@ boolean D_CheckNetGame(void)
ret = true; ret = true;
if (client && netgame) if (client && netgame)
netgame = false; netgame = false;
server = true; // WTF? server always true??? server = true; // WTF? server always true???
// no! The deault mode is server. Client is set elsewhere // no! The deault mode is server. Client is set elsewhere
// when the client executes connect command. // when the client executes connect command.
@@ -1299,7 +1301,6 @@ boolean D_CheckNetGame(void)
if (doomcom->id != DOOMCOM_ID) if (doomcom->id != DOOMCOM_ID)
I_Error("Doomcom buffer invalid!"); I_Error("Doomcom buffer invalid!");
if (doomcom->numnodes > MAXNETNODES) if (doomcom->numnodes > MAXNETNODES)
I_Error("Too many nodes (%d), max:%d", doomcom->numnodes, MAXNETNODES); I_Error("Too many nodes (%d), max:%d", doomcom->numnodes, MAXNETNODES);
@@ -1308,17 +1309,14 @@ boolean D_CheckNetGame(void)
{ {
char filename[21]; char filename[21];
INT32 k = doomcom->consoleplayer - 1; INT32 k = doomcom->consoleplayer - 1;
if (M_IsNextParm()) if (M_IsNextParm())
k = atoi(M_GetNextParm()) - 1; k = atoi(M_GetNextParm()) - 1;
while (!debugfile && k < MAXPLAYERS) while (!debugfile && k < MAXPLAYERS)
{ {
k++; k++;
sprintf(filename, "debug%d.txt", k); sprintf(filename, "debug%d.txt", k);
debugfile = fopen(va("%s" PATHSEP "%s", srb2home, filename), "w"); debugfile = fopen(va("%s" PATHSEP "%s", srb2home, filename), "w");
} }
if (debugfile) if (debugfile)
CONS_Printf(M_GetText("debug output to: %s\n"), va("%s" PATHSEP "%s", srb2home, filename)); CONS_Printf(M_GetText("debug output to: %s\n"), va("%s" PATHSEP "%s", srb2home, filename));
else else
+494 -190
View File
File diff suppressed because it is too large. Load diff
+5 -2
View File
@@ -21,7 +21,10 @@ extern "C" {
#include "command.h" #include "command.h"
void SendWeaponPref(UINT8 splitplayer); void SendWeaponPref(void);
void SendWeaponPref2(void);
void SendWeaponPref3(void);
void SendWeaponPref4(void);
// console vars // console vars
extern consvar_t cv_playername; extern consvar_t cv_playername;
@@ -292,7 +295,7 @@ typedef union {
// add game commands, needs cleanup // add game commands, needs cleanup
void D_RegisterServerCommands(void); void D_RegisterServerCommands(void);
void D_RegisterClientCommands(void); void D_RegisterClientCommands(void);
void D_SendPlayerConfig(UINT8 splitplayer); void D_SendPlayerConfig(void);
void Command_ExitGame_f(void); void Command_ExitGame_f(void);
void Command_Retry_f(void); void Command_Retry_f(void);
void D_GameTypeChanged(INT32 lastgametype); // not a real _OnChange function anymore void D_GameTypeChanged(INT32 lastgametype); // not a real _OnChange function anymore
+21 -30
View File
@@ -131,8 +131,6 @@ static UINT32 curl_origtotalfilesize;
static char *curl_realname = NULL; static char *curl_realname = NULL;
fileneeded_t *curl_curfile = NULL; fileneeded_t *curl_curfile = NULL;
HTTP_login *curl_logins = NULL; HTTP_login *curl_logins = NULL;
static void CURLGetFile(void);
#endif #endif
/** Fills a serverinfo packet with information about wad files loaded. /** Fills a serverinfo packet with information about wad files loaded.
@@ -960,7 +958,7 @@ void Got_Filetxpak(void)
|| fastcmp(filename, "music.kart") || fastcmp(filename, "music.kart")
|| fastcmp(filename, "patch.kart") || fastcmp(filename, "patch.kart")
)) ))
I_Error("Tried to download base-game file: \"%s\"", filename); I_Error("Tried to download \"%s\"", filename);
if (filenum >= fileneedednum) if (filenum >= fileneedednum)
{ {
@@ -1019,21 +1017,21 @@ void Got_Filetxpak(void)
switch(file->status) switch(file->status)
{ {
case FS_NOTFOUND: case FS_NOTFOUND:
s = "FS_NOTFOUND"; s = "FS_NOTFOUND";
break; break;
case FS_FOUND: case FS_FOUND:
s = "FS_FOUND"; s = "FS_FOUND";
break; break;
case FS_OPEN: case FS_OPEN:
s = "FS_OPEN"; s = "FS_OPEN";
break; break;
case FS_MD5SUMBAD: case FS_MD5SUMBAD:
s = "FS_MD5SUMBAD"; s = "FS_MD5SUMBAD";
break; break;
default: default:
s = "unknown"; s = "unknown";
break; break;
} }
I_Error("Received a file not requested (file id: %d, file status: %s)\n", filenum, s); I_Error("Received a file not requested (file id: %d, file status: %s)\n", filenum, s);
@@ -1165,12 +1163,8 @@ filestatus_t findfile(char *filename, const UINT8 *wantedmd5sum, boolean complet
filestatus_t homecheck; // store result of last file search filestatus_t homecheck; // store result of last file search
boolean badmd5 = false; // store whether md5 was bad from either of the first two searches (if nothing was found in the third) boolean badmd5 = false; // store whether md5 was bad from either of the first two searches (if nothing was found in the third)
// see IdentifyVersion // skip for startup, our mainwads wont be in there
// Iwads skip findfile due to passing fullpath to W_OpenWadFile if (loaded_config)
#if 0
// skip for Iwads, as they wont be in there
if (!startupiwadcount)
#endif
{ {
if (cv_addons_option.value == 3 && *cv_addons_folder.string != '\0') if (cv_addons_option.value == 3 && *cv_addons_folder.string != '\0')
{ {
@@ -1307,7 +1301,6 @@ void CURLPrepareFile(const char* url, int dfilenum)
if (!multi_handle) if (!multi_handle)
{ {
cc = curl_global_init(CURL_GLOBAL_ALL); cc = curl_global_init(CURL_GLOBAL_ALL);
if (cc < 0) if (cc < 0)
{ {
I_OutputMsg("libcurl: curl_global_init() returned %d\n", cc); I_OutputMsg("libcurl: curl_global_init() returned %d\n", cc);
@@ -1316,7 +1309,6 @@ void CURLPrepareFile(const char* url, int dfilenum)
{ {
multi_handle = curl_multi_init(); multi_handle = curl_multi_init();
} }
if (!multi_handle) if (!multi_handle)
{ {
I_OutputMsg("libcurl: curl_multi_init() failed\n"); I_OutputMsg("libcurl: curl_multi_init() failed\n");
@@ -1445,7 +1437,7 @@ void CURLAbortFile(void)
#endif #endif
} }
static void CURLGetFile(void) void CURLGetFile(void)
{ {
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
I_lock_mutex(&downloadmutex); I_lock_mutex(&downloadmutex);
@@ -1487,8 +1479,7 @@ static void CURLGetFile(void)
e = m->easy_handle; e = m->easy_handle;
easyres = m->data.result; easyres = m->data.result;
char *filename = malloc(strlen(curl_realname)+1); char *filename = Z_StrDup(curl_realname);
strcpy(filename, curl_realname);
nameonly(filename); nameonly(filename);
if (easyres != CURLE_OK) if (easyres != CURLE_OK)
@@ -1526,7 +1517,7 @@ static void CURLGetFile(void)
} }
} }
free(filename); Z_Free(filename);
curl_curfile->file = NULL; curl_curfile->file = NULL;
filedownload.remaining--; filedownload.remaining--;
mc = curl_multi_remove_handle(multi_handle, e); mc = curl_multi_remove_handle(multi_handle, e);
+1
View File
@@ -119,6 +119,7 @@ size_t nameonlylength(const char *s);
#ifdef HAVE_CURL #ifdef HAVE_CURL
void CURLPrepareFile(const char* url, int dfilenum); void CURLPrepareFile(const char* url, int dfilenum);
void CURLAbortFile(void); void CURLAbortFile(void);
void CURLGetFile(void);
HTTP_login * CURLGetLogin (const char *url, HTTP_login ***return_prev_next); HTTP_login * CURLGetLogin (const char *url, HTTP_login ***return_prev_next);
size_t curlwrite_data(void *ptr, size_t size, size_t nmemb, FILE *stream); size_t curlwrite_data(void *ptr, size_t size, size_t nmemb, FILE *stream);
#endif #endif
+3 -8
View File
@@ -46,20 +46,15 @@ typedef enum
// Mainly movements/button commands per game tick, // Mainly movements/button commands per game tick,
// plus a checksum for internal state consistency. // plus a checksum for internal state consistency.
// ticcmd turning bits
#define TICCMD_REDUCE 16
// ticcmd latency mask
#define TICCMD_LATENCYMASK 0xFF
// bits in angleturn // bits in angleturn
#define TICCMD_RECEIVED (0x01) /* Actual tic recieved from client */ #define TICCMD_RECEIVED 1
#define TICCMD_XY 2
typedef struct typedef struct
{ {
SINT8 forwardmove; // -MAXPLMOVE to MAXPLMOVE (50) SINT8 forwardmove; // -MAXPLMOVE to MAXPLMOVE (50)
SINT8 sidemove; // -MAXPLMOVE to MAXPLMOVE (50) SINT8 sidemove; // -MAXPLMOVE to MAXPLMOVE (50)
INT16 angleturn; // << TICCMD_REDUCE for angle delta - saved as 1 byte into demos INT16 angleturn; // <<16 for angle delta - saved as 1 byte into demos
INT16 aiming; // vertical aiming, see G_BuildTicCmd INT16 aiming; // vertical aiming, see G_BuildTicCmd
UINT16 buttons; UINT16 buttons;
INT16 driftturn; // SRB2Kart: Used for getting drift turn speed INT16 driftturn; // SRB2Kart: Used for getting drift turn speed
+22 -93
View File
@@ -1,75 +1,21 @@
# Declare dedicated interface sources # Declare dedicated interface sources
set(SRB2_DEDICATED_SOURCES target_sourcefile(c)
i_system.c
i_main.c
i_video.c
i_sound.c
i_threads.c
dosstr.c
endtxt.c
)
set(SRB2_DEDICATED_HEADERS target_sources(SRB2SDL2 PRIVATE)
endtxt.h
)
source_group("Interface Code" FILES ${SRB2_DEDICATED_SOURCES} ${SRB2_DEDICATED_HEADERS})
set(SRB2_DEDICATED_TOTAL_SOURCES
${SRB2_CORE_SOURCES}
${SRB2_CORE_HEADERS}
${SRB2_PNG_SOURCES}
${SRB2_PNG_HEADERS}
${SRB2_CORE_RENDER_SOURCES}
${SRB2_CORE_GAME_SOURCES}
${SRB2_LUA_SOURCES}
${SRB2_LUA_HEADERS}
${SRB2_BLUA_SOURCES}
${SRB2_BLUA_HEADERS}
${SRB2_DEDICATED_SOURCES}
${SRB2_DEDICATED_HEADERS}
)
source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS})
source_group("Renderer" FILES ${SRB2_CORE_RENDER_SOURCES})
source_group("Game" FILES ${SRB2_CORE_GAME_SOURCES})
source_group("LUA" FILES ${SRB2_LUA_SOURCES} ${SRB2_LUA_HEADERS})
source_group("LUA\\Interpreter" FILES ${SRB2_BLUA_SOURCES} ${SRB2_BLUA_HEADERS})
if(${CMAKE_SYSTEM} MATCHES Windows) if(${CMAKE_SYSTEM} MATCHES Windows)
set(SRB2_DEDICATED_TOTAL_SOURCES ${SRB2_DEDICATED_TOTAL_SOURCES} target_sources(SRB2SDL2 PRIVATE
${CMAKE_SOURCE_DIR}/src/win32/win_dbg.c ../win32/win_dbg.c
${CMAKE_SOURCE_DIR}/src/win32/Srb2win.rc ../win32/Srb2win.rc)
)
endif() endif()
add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32 ${SRB2_DEDICATED_TOTAL_SOURCES})
if(${CMAKE_SYSTEM} MATCHES Windows) if(${CMAKE_SYSTEM} MATCHES Windows)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2kartd) set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2legacy)
elseif(${CMAKE_SYSTEM} MATCHES Linux) elseif(${CMAKE_SYSTEM} MATCHES Linux)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME lsrb2kartd) set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME lsrb2dlegacy)
else() else()
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2kartd) set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2legacy)
endif()
if(${CMAKE_SYSTEM} MATCHES Darwin)
find_library(CORE_FOUNDATION_LIBRARY "CoreFoundation")
target_link_libraries(SRB2SDL2 PRIVATE
${CORE_FOUNDATION_LIBRARY}
)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
# Configure the app bundle icon and plist properties
target_sources(SRB2SDL2 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/macosx/Srb2mac.icns")
set_target_properties(SRB2SDL2 PROPERTIES
MACOSX_BUNDLE_ICON_FILE "Srb2mac"
MACOSX_BUNDLE_BUNDLE_NAME "Sonic Robo Blast 2"
MACOSX_BUNDLE_BUNDLE_VERSION ${SRB2_VERSION}
RESOURCE "${CMAKE_CURRENT_SOURCE_DIR}/macosx/Srb2mac.icns"
)
endif() endif()
if(${CMAKE_SYSTEM} MATCHES Darwin) if(${CMAKE_SYSTEM} MATCHES Darwin)
@@ -78,27 +24,25 @@ if(${CMAKE_SYSTEM} MATCHES Darwin)
${CORE_LIB} ${CORE_LIB}
${PNG_LIBRARIES} ${PNG_LIBRARIES}
${ZLIB_LIBRARIES} ${ZLIB_LIBRARIES}
${CURL_LIBRARIES}
) )
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}") set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
else() else()
target_link_libraries(SRB2SDL2 PRIVATE target_link_libraries(SRB2SDL2 PRIVATE
${PNG_LIBRARIES} ${PNG_LIBRARIES}
${ZLIB_LIBRARIES} ${ZLIB_LIBRARIES}
${CURL_LIBRARIES}
) )
if(${CMAKE_SYSTEM} MATCHES Linux) if(${CMAKE_SYSTEM} MATCHES Linux)
target_link_libraries(SRB2SDL2 PRIVATE target_link_libraries(SRB2SDL2 PRIVATE
m m
rt rt
pthread
) )
endif() endif()
endif() endif()
if(${SRB2_HAVE_LIBBACKTRACE}) #target_link_libraries(SRB2SDL2 PRIVATE SRB2Core)
target_link_libraries(SRB2SDL2 PRIVATE ${LIBBACKTRACE_LIBRARIES})
endif() set_target_properties(SRB2SDL2 PROPERTIES VERSION ${SRB2_VERSION})
if(${CMAKE_SYSTEM} MATCHES Windows) if(${CMAKE_SYSTEM} MATCHES Windows)
target_link_libraries(SRB2SDL2 PRIVATE target_link_libraries(SRB2SDL2 PRIVATE
@@ -116,34 +60,19 @@ target_include_directories(SRB2SDL2 PRIVATE
target_compile_definitions(SRB2SDL2 PRIVATE target_compile_definitions(SRB2SDL2 PRIVATE
-DDEDICATED -DDEDICATED
-DHAVE_THREADS
) )
if(SRB2_CONFIG_LTO AND NOT SRB2_CONFIG_DEBUGMODE)
set_property(TARGET SRB2SDL2 PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
if(SRB2_CONFIG_ASAN)
target_compile_options(SRB2SDL2 PRIVATE -fsanitize=address)
target_link_options(SRB2SDL2 PRIVATE -fsanitize=address)
endif()
if(SRB2_CONFIG_UBSAN)
target_compile_options(SRB2SDL2 PRIVATE -fsanitize=undefined)
target_link_options(SRB2SDL2 PRIVATE -fsanitize=undefined)
endif()
## strip debug symbols into separate file when using gcc ## strip debug symbols into separate file when using gcc
# if(CMAKE_COMPILER_IS_GNUCC) if(CMAKE_COMPILER_IS_GNUCC)
# if(${CMAKE_BUILD_TYPE} MATCHES Debug) if(${CMAKE_BUILD_TYPE} MATCHES Debug)
# message(STATUS "Will make separate debug symbols in *.debug") message(STATUS "Will make separate debug symbols in *.debug")
# add_custom_command(TARGET SRB2SDL2 POST_BUILD add_custom_command(TARGET SRB2SDL2 POST_BUILD
# COMMAND ${OBJCOPY} --only-keep-debug $<TARGET_FILE:SRB2SDL2> $<TARGET_FILE:SRB2SDL2>.debug COMMAND ${OBJCOPY} --only-keep-debug $<TARGET_FILE:SRB2SDL2> $<TARGET_FILE:SRB2SDL2>.debug
# COMMAND ${OBJCOPY} --strip-debug $<TARGET_FILE:SRB2SDL2> COMMAND ${OBJCOPY} --strip-debug $<TARGET_FILE:SRB2SDL2>
# COMMAND ${OBJCOPY} --add-gnu-debuglink=$<TARGET_FILE_NAME:SRB2SDL2>.debug $<TARGET_FILE:SRB2SDL2> COMMAND ${OBJCOPY} --add-gnu-debuglink=$<TARGET_FILE_NAME:SRB2SDL2>.debug $<TARGET_FILE:SRB2SDL2>
# ) )
# endif() endif()
# endif() endif()
#### Installation #### #### Installation ####
if(${CMAKE_SYSTEM} MATCHES Darwin) if(${CMAKE_SYSTEM} MATCHES Darwin)
+16 -20
View File
@@ -167,8 +167,6 @@ static char returnWadPath[256];
#include "../i_video.h" #include "../i_video.h"
#include "../i_sound.h" #include "../i_sound.h"
#include "../i_system.h" #include "../i_system.h"
#include "../i_time.h"
#include "../i_net.h"
#include "../screen.h" //vid.WndParent #include "../screen.h" //vid.WndParent
#include "../d_net.h" #include "../d_net.h"
#include "../g_game.h" #include "../g_game.h"
@@ -180,6 +178,10 @@ static char returnWadPath[256];
#include "../m_argv.h" #include "../m_argv.h"
#ifdef MAC_ALERT
#include "macosx/mac_alert.h"
#endif
#include "../d_main.h" #include "../d_main.h"
#if !defined(NOMUMBLE) && defined(HAVE_MUMBLE) #if !defined(NOMUMBLE) && defined(HAVE_MUMBLE)
@@ -194,6 +196,8 @@ UINT8 keyboard_started = false;
#ifdef HAVE_TERMIOS #ifdef HAVE_TERMIOS
// TERMIOS console code from Quake3: thank you! // TERMIOS console code from Quake3: thank you!
boolean stdin_active = true;
typedef struct typedef struct
{ {
size_t cursor; size_t cursor;
@@ -695,7 +699,11 @@ void I_JoyScale4(void)
*/ */
void I_ShutdownJoystick(UINT8 index) void I_ShutdownJoystick(void)
{
}
void I_GetJoystickEvents(UINT8 index)
{ {
(void)index; (void)index;
} }
@@ -984,7 +992,7 @@ void I_SleepDuration(precise_t duration)
#endif #endif
} }
static volatile sig_atomic_t g_in_exiting_signal_handler = false; boolean g_in_exiting_signal_handler = false;
static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_msg) static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_msg)
{ {
@@ -1048,11 +1056,6 @@ static void I_ReportSignal(int num, int coredumped)
I_OutputMsg("\nProcess killed by signal: %s\n\n", sigmsg); I_OutputMsg("\nProcess killed by signal: %s\n\n", sigmsg);
} }
boolean I_In_Exiting_Signal_Handler(void)
{
return g_in_exiting_signal_handler;
}
#ifndef NEWSIGNALHANDLER #ifndef NEWSIGNALHANDLER
FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num)
{ {
@@ -1072,17 +1075,11 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num)
} }
#endif #endif
static volatile sig_atomic_t interrupted = 0; FUNCNORETURN static ATTRNORETURN void quit_handler(int num)
boolean I_Interrupted(void)
{ {
return interrupted; signal(num, SIG_DFL); //default signal action
} raise(num);
I_Quit();
static void quit_handler(int num)
{
(void)num;
interrupted = 1;
} }
#ifdef HAVE_LIBBACKTRACE #ifdef HAVE_LIBBACKTRACE
@@ -1384,7 +1381,6 @@ static void I_Fork(void)
INT32 I_StartupSystem(void) INT32 I_StartupSystem(void)
{ {
W_Startup();
I_StartupConsole(); I_StartupConsole();
#ifdef NEWSIGNALHANDLER #ifdef NEWSIGNALHANDLER
// This is useful when debugging. It lets GDB attach to // This is useful when debugging. It lets GDB attach to
+4
View File
@@ -115,6 +115,10 @@ INT32 VID_GetModeForSize(INT32 w, INT32 h)
return -1; return -1;
} }
void VID_RefreshModeList(void)
{
}
void VID_PrepareModeList(void) void VID_PrepareModeList(void)
{ {
} }
+7 -24
View File
@@ -115,25 +115,20 @@ char *myfgets(char *buf, size_t bufsize, MYFILE *f)
size_t i = 0; size_t i = 0;
if (myfeof(f)) if (myfeof(f))
return NULL; return NULL;
// we need one byte for a null terminated string // we need one byte for a null terminated string
bufsize--; bufsize--;
while (i < bufsize && !myfeof(f)) while (i < bufsize && !myfeof(f))
{ {
char c = *f->curpos++; char c = *f->curpos++;
if (c == '^') if (c == '^')
buf[i++] = myfget_color(f); buf[i++] = myfget_color(f);
else if (c == '\\') else if (c == '\\')
buf[i++] = myfget_hex(f); buf[i++] = myfget_hex(f);
else if (c != '\r') else if (c != '\r')
buf[i++] = c; buf[i++] = c;
if (c == '\n') if (c == '\n')
break; break;
} }
buf[i] = '\0'; buf[i] = '\0';
dbg_line++; dbg_line++;
@@ -143,31 +138,25 @@ char *myfgets(char *buf, size_t bufsize, MYFILE *f)
static char *myhashfgets(char *buf, size_t bufsize, MYFILE *f) static char *myhashfgets(char *buf, size_t bufsize, MYFILE *f)
{ {
size_t i = 0; size_t i = 0;
if (myfeof(f)) if (myfeof(f))
return NULL; return NULL;
// we need one byte for a null terminated string // we need one byte for a null terminated string
bufsize--; bufsize--;
while (i < bufsize && !myfeof(f)) while (i < bufsize && !myfeof(f))
{ {
char c = *f->curpos++; char c = *f->curpos++;
if (c == '^') if (c == '^')
buf[i++] = myfget_color(f); buf[i++] = myfget_color(f);
else if (c == '\\') else if (c == '\\')
buf[i++] = myfget_hex(f); buf[i++] = myfget_hex(f);
else if (c != '\r') else if (c != '\r')
buf[i++] = c; buf[i++] = c;
if (c == '\n') // Ensure debug line is right... if (c == '\n') // Ensure debug line is right...
dbg_line++; dbg_line++;
if (c == '#') if (c == '#')
break; break;
} }
i++;
buf[i] = '\0'; buf[i] = '\0';
return buf; return buf;
@@ -184,7 +173,7 @@ FUNCPRINTF static void deh_warning(const char *first, ...)
vsnprintf(buf, 1000, first, argptr); // sizeof only returned 4 here. it didn't like that pointer. vsnprintf(buf, 1000, first, argptr); // sizeof only returned 4 here. it didn't like that pointer.
va_end(argptr); va_end(argptr);
if (dbg_line == -1) // Not in a SOC, line number unknown. if(dbg_line == -1) // Not in a SOC, line number unknown.
CONS_Alert(CONS_WARNING, "%s\n", buf); CONS_Alert(CONS_WARNING, "%s\n", buf);
else else
CONS_Alert(CONS_WARNING, "Line %u: %s\n", dbg_line, buf); CONS_Alert(CONS_WARNING, "Line %u: %s\n", dbg_line, buf);
@@ -326,10 +315,7 @@ static void readPlayer(MYFILE *f, INT32 num)
goto done; goto done;
PlayerMenu[num].status = IT_CALL; PlayerMenu[num].status = IT_CALL;
// A friendly neighborhood alias for brevity's sake for (i = 0; i < MAXLINELEN-3; i++)
const size_t note_size = sizeof(description[num].notes);
for (i = 0; i < (INT32)(MAXLINELEN-note_size-3); i++)
{ {
if (s[i] == '=') if (s[i] == '=')
{ {
@@ -337,12 +323,10 @@ static void readPlayer(MYFILE *f, INT32 num)
break; break;
} }
} }
if (playertext) if (playertext)
{ {
strlcpy(description[num].notes, playertext, note_size); strcpy(description[num].notes, playertext);
strlcat(description[num].notes, strcat(description[num].notes, myhashfgets(playertext, sizeof (description[num].notes), f));
myhashfgets(playertext, note_size, f), note_size);
} }
else else
strcpy(description[num].notes, ""); strcpy(description[num].notes, "");
@@ -351,7 +335,7 @@ static void readPlayer(MYFILE *f, INT32 num)
// It works down here, though. // It works down here, though.
{ {
INT32 numline = 0; INT32 numline = 0;
for (i = 0; (size_t)i < note_size-1; i++) for (i = 0; (size_t)i < sizeof(description[num].notes)-1; i++)
{ {
if (numline < 20 && description[num].notes[i] == '\n') if (numline < 20 && description[num].notes[i] == '\n')
numline++; numline++;
@@ -360,7 +344,6 @@ static void readPlayer(MYFILE *f, INT32 num)
break; break;
} }
} }
description[num].notes[strlen(description[num].notes)-1] = '\0'; description[num].notes[strlen(description[num].notes)-1] = '\0';
description[num].notes[i] = '\0'; description[num].notes[i] = '\0';
continue; continue;
@@ -8562,7 +8545,7 @@ static inline int lib_action(lua_State *L)
// Hardcoded A_Action name to call for super() or NULL if super() would be invalid. // Hardcoded A_Action name to call for super() or NULL if super() would be invalid.
// Set in lua_infolib. // Set in lua_infolib.
const char *superactions[MAXRECURSION] = {}; const char *superactions[MAXRECURSION];
UINT8 superstack = 0; UINT8 superstack = 0;
static int lib_dummysuper(lua_State *L) static int lib_dummysuper(lua_State *L)
-9
View File
@@ -13,10 +13,6 @@
#ifndef __DEHACKED_H__ #ifndef __DEHACKED_H__
#define __DEHACKED_H__ #define __DEHACKED_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "m_fixed.h" // for get_number #include "m_fixed.h" // for get_number
#include "info.h" #include "info.h"
@@ -75,9 +71,4 @@ typedef struct
} MYFILE; } MYFILE;
#define myfeof(a) (a->data + a->size <= a->curpos) #define myfeof(a) (a->data + a->size <= a->curpos)
char *myfgets(char *buf, size_t bufsize, MYFILE *f); char *myfgets(char *buf, size_t bufsize, MYFILE *f);
#ifdef __cplusplus
} // extern "C"
#endif
#endif #endif
+29 -35
View File
@@ -20,6 +20,7 @@
// but I can't stand that gibberish. D: // but I can't stand that gibberish. D:
#define SOUND_DUMMY 0 #define SOUND_DUMMY 0
#define SOUND_MIXER 1 #define SOUND_MIXER 1
#define SOUND_SDL 2
#ifndef SOUND #ifndef SOUND
#ifdef HAVE_SDL #ifdef HAVE_SDL
@@ -27,7 +28,7 @@
#ifdef HAVE_MIXER #ifdef HAVE_MIXER
#define SOUND SOUND_MIXER #define SOUND SOUND_MIXER
#else #else
#define SOUND SOUND_DUMMY #define SOUND SOUND_SDL
#endif #endif
#else #else
#define SOUND SOUND_DUMMY #define SOUND SOUND_DUMMY
@@ -40,45 +41,22 @@
#define ASMCALL #define ASMCALL
#endif #endif
#ifdef __cplusplus
extern "C" {
#endif
#include "doomtype.h" #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 <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stddef.h>
#include <string.h> #include <string.h>
#include <limits.h> #define _USE_MATH_DEFINES // fixes M_PI errors in r_plane.c for Visual Studio
#ifdef __cplusplus
#include <cmath>
#else
#include <math.h>
#endif #endif
#include <sys/types.h> #include <sys/types.h>
@@ -130,8 +108,8 @@ extern char logfilename[1024];
#else #else
#define VERSION 1 // Game version #define VERSION 1 // Game version
#define SUBVERSION 6 // more precise version number #define SUBVERSION 6 // more precise version number
#define VERSIONSTRING "Saturn v9.2" #define VERSIONSTRING "Saturn v9.x - Testing"
#define VERSIONSTRINGW L"Saturn v9.2" #define VERSIONSTRINGW L"Saturn v9.x - Testing "
#define SATURN_TESTING // comment out for saturn release builds! #define SATURN_TESTING // comment out for saturn release builds!
@@ -516,6 +494,22 @@ extern boolean capslock;
// i_system.c, replace getchar() once the keyboard has been appropriated // i_system.c, replace getchar() once the keyboard has been appropriated
INT32 I_GetKey(void); INT32 I_GetKey(void);
/* http://www.cse.yorku.ca/~oz/hash.html */
static inline
UINT32 quickncasehash (const char *p, size_t n)
{
size_t i = 0;
UINT32 x = 5381;
while (i < n && p[i])
{
x = (x * 33) ^ tolower(p[i]);
i++;
}
return x;
}
#ifndef __cplusplus #ifndef __cplusplus
#ifndef min // Double-Check with WATTCP-32's cdefs.h #ifndef min // Double-Check with WATTCP-32's cdefs.h
#define min(x, y) (((x) < (y)) ? (x) : (y)) #define min(x, y) (((x) < (y)) ? (x) : (y))
+1 -1
View File
@@ -542,7 +542,7 @@ extern mapthing_t *redctfstarts[MAXPLAYERS]; // CTF
#else #else
#define DEBUGFILE #define DEBUGFILE
#ifdef DEBUGFILE #ifdef DEBUGFILE
#define DEBFILE(msg) { if (UNLIKELY(debugfile)) { fputs(msg, debugfile); fflush(debugfile); } } #define DEBFILE(msg) { if (debugfile) { fputs(msg, debugfile); fflush(debugfile); } }
#else #else
#define DEBFILE(msg) {} #define DEBFILE(msg) {}
#endif #endif
+5 -16
View File
@@ -68,21 +68,8 @@ extern "C" {
#define strnicmp(x,y,n) strncasecmp(x,y,n) #define strnicmp(x,y,n) strncasecmp(x,y,n)
#endif #endif
// glibc 2.43 made alot of standard lib functions propagate the constness of its input pointers
// to not cause warnings or compile issues on older glibc versions we do this silly thing
// to not have a gazillion glibc version checks
#if defined(__GLIBC_PREREQ)
#if __GLIBC_PREREQ(2, 43)
#define gconst const
#else
#define gconst
#endif
#else
#define gconst
#endif
#ifndef _GNU_SOURCE
char *nongnu_strcasestr(const char *in, const char *what); char *nongnu_strcasestr(const char *in, const char *what);
#ifndef _GNU_SOURCE
#define strcasestr nongnu_strcasestr #define strcasestr nongnu_strcasestr
#endif #endif
@@ -140,9 +127,9 @@ size_t strlcpy(char *dst, const char *src, size_t dsize);
#define STRBUFCPY(dst,src) strlcpy(dst, src, sizeof dst) #define STRBUFCPY(dst,src) strlcpy(dst, src, sizeof dst)
/* Boolean type definition */ /* Boolean type definition */
#include <stdbool.h>
#ifndef _WIN32 #ifndef _WIN32
#include <stdbool.h>
// dont use stdbools _BOOL type // dont use stdbools _BOOL type
// its smaller (1 byte) than the old interger bool (4 bytes) // its smaller (1 byte) than the old interger bool (4 bytes)
// which results in packed struct sizes being mismatched between vanilla and this // which results in packed struct sizes being mismatched between vanilla and this
@@ -150,7 +137,9 @@ size_t strlcpy(char *dst, const char *src, size_t dsize);
// which we cant use as enumeration constants // which we cant use as enumeration constants
typedef int32_t boolean; typedef int32_t boolean;
#else #else
#define boolean int32_t #define false FALSE
#define true TRUE
#define boolean BOOL
#endif #endif
/* 7.18.2.1 Limits of exact-width integer types */ /* 7.18.2.1 Limits of exact-width integer types */
+5 -3
View File
@@ -644,7 +644,7 @@ void F_CreditDrawer(void)
sc = FRACUNIT; // quick hack so I don't have to add another field to credits_pics sc = FRACUNIT; // quick hack so I don't have to add another field to credits_pics
} }
V_DrawFixedPatch(credits_pics[i].x<<FRACBITS, (credits_pics[i].y<<FRACBITS) - 4*(animtimer<<FRACBITS)/5, sc, 0, W_CachePatchName(credits_pics[i].patch, PU_PATCH), colormap); V_DrawFixedPatch(credits_pics[i].x<<FRACBITS, (credits_pics[i].y<<FRACBITS) - 4*(animtimer<<FRACBITS)/5, sc, 0, W_CachePatchName(credits_pics[i].patch, PU_PATCH_LOWPRIORITY), colormap);
} }
// Dim the background // Dim the background
@@ -1172,7 +1172,9 @@ void F_StartWaitingPlayers(void)
randskin = M_RandomKey(numskins); randskin = M_RandomKey(numskins);
boolean waithires = skins[randskin].flags && SF_HIRES; boolean waithires = skins[randskin].flags && SF_HIRES;
Z_Free(waitcolormap); if (waitcolormap)
Z_Free(waitcolormap);
waitcolormap = R_GetTranslationColormap(randskin, skins[randskin].prefcolor, 0); waitcolormap = R_GetTranslationColormap(randskin, skins[randskin].prefcolor, 0);
if (waithires) if (waithires)
@@ -1316,7 +1318,7 @@ boolean F_ContinueResponder(event_t *event)
keypressed = true; keypressed = true;
imcontinuing = true; imcontinuing = true;
continuetime = TICRATE; continuetime = TICRATE;
S_StartSound(NULL, sfx_itemup); S_StartSound(0, sfx_itemup);
return true; return true;
} }
-5
View File
@@ -361,11 +361,6 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu)
// on for fade-to-black // on for fade-to-black
for (;;) for (;;)
{ {
if (I_Interrupted())
{
I_Quit();
}
// get fademask first so we can tell if it exists or not // get fademask first so we can tell if it exists or not
fmask = F_GetFadeMask(wipetype, wipeframe++); fmask = F_GetFadeMask(wipetype, wipeframe++);
+2 -2
View File
@@ -10,7 +10,7 @@ FUNCINLINE static ATTRINLINE boolean fasticmp(const char *s, const char *c)
} }
// case-sensitive of the above // case-sensitive of the above
FUNCINLINE static ATTRINLINE PUREFUNC boolean fastcmp(const char *s, const char *c) FUNCINLINE static ATTRINLINE boolean fastcmp(const char *s, const char *c)
{ {
for (; *s && *s == *c; s++, c++) ; for (; *s && *s == *c; s++, c++) ;
return (*s == *c); // make sure both strings ended return (*s == *c); // make sure both strings ended
@@ -18,7 +18,7 @@ FUNCINLINE static ATTRINLINE PUREFUNC boolean fastcmp(const char *s, const char
// length-limited of the above // length-limited of the above
// only true if both strings are at least l characters long AND match, case-sensitively! // only true if both strings are at least l characters long AND match, case-sensitively!
FUNCINLINE static ATTRINLINE PUREFUNC boolean fastncmp(const char *s, const char *c, UINT16 l) FUNCINLINE static ATTRINLINE boolean fastncmp(const char *s, const char *c, UINT16 l)
{ {
for (; *s && *s == *c && --l; s++, c++) ; for (; *s && *s == *c && --l; s++, c++) ;
return !l; // make sure you reached the end return !l; // make sure you reached the end
+10 -11
View File
@@ -49,7 +49,7 @@ size_t menupathindex[menudepth] = {};
size_t menudepthleft = menudepth; size_t menudepthleft = menudepth;
char menusearchbuf[MAXSTRINGLENGTH+1]; char menusearchbuf[MAXSTRINGLENGTH+1];
textinput_t menusearch = {}; textinput_t menusearch;
char **dirmenu = NULL, **coredirmenu = NULL; // core only local for this file char **dirmenu = NULL, **coredirmenu = NULL; // core only local for this file
size_t sizedirmenu = 0, sizecoredirmenu = 0; // ditto size_t sizedirmenu = 0, sizecoredirmenu = 0; // ditto
@@ -271,13 +271,10 @@ static boolean filemenucmp(char *haystack, char *needle)
{ {
static char localhaystack[128]; static char localhaystack[128];
strlcpy(localhaystack, haystack, 128); strlcpy(localhaystack, haystack, 128);
if (!cv_addons_search_case.value) if (!cv_addons_search_case.value)
strupr(localhaystack); strupr(localhaystack);
if (cv_addons_search_type.value) if (cv_addons_search_type.value)
return (strstr(localhaystack, needle) != NULL); return (strstr(localhaystack, needle) != 0);
return (!strncmp(localhaystack, needle, menusearch.length)); return (!strncmp(localhaystack, needle, menusearch.length));
} }
@@ -317,7 +314,8 @@ void closefilemenu(boolean validsize)
coredirmenu = NULL; coredirmenu = NULL;
} }
Z_Free(refreshdirname); if (refreshdirname)
Z_Free(refreshdirname);
refreshdirname = NULL; refreshdirname = NULL;
} }
@@ -345,7 +343,8 @@ void searchfilemenu(char *tempname)
if (!menusearch.length) if (!menusearch.length)
{ {
Z_Free(dirmenu); if (dirmenu)
Z_Free(dirmenu);
dirmenu = coredirmenu; dirmenu = coredirmenu;
sizedirmenu = sizecoredirmenu; sizedirmenu = sizecoredirmenu;
@@ -387,8 +386,8 @@ void searchfilemenu(char *tempname)
I_Error("searchfilemenu(): could not create \"No results...\"."); I_Error("searchfilemenu(): could not create \"No results...\".");
sizedirmenu = 1; sizedirmenu = 1;
dir_on[menudepthleft] = 0; dir_on[menudepthleft] = 0;
Z_Free(tempname); if (tempname)
Z_Free(tempname);
return; return;
} }
@@ -503,8 +502,8 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut)
{ {
closedir(dirhandle); closedir(dirhandle);
closefilemenu(false); closefilemenu(false);
Z_Free(tempname); if (tempname)
Z_Free(tempname);
return false; return false;
} }
+90 -159
View File
@@ -55,8 +55,6 @@
#include "k_stats.h" // SRB2kart #include "k_stats.h" // SRB2kart
#include "r_fps.h" // frame interpolation/uncapped #include "r_fps.h" // frame interpolation/uncapped
#include <errno.h>
#ifdef HAVE_DISCORDRPC #ifdef HAVE_DISCORDRPC
#include "discord.h" #include "discord.h"
#endif #endif
@@ -76,7 +74,7 @@ static tic_t demostarttime; // for comparative timing purposes
//@TODO put these all in a struct for namespacing purposes? //@TODO put these all in a struct for namespacing purposes?
static char demoname[128]; static char demoname[128];
savebuffer_t demobuf = {}; savebuffer_t demobuf = {0};
static UINT8 *demotime_p, *demoinfo_p; static UINT8 *demotime_p, *demoinfo_p;
static UINT8 *demoend; static UINT8 *demoend;
static UINT8 demoflags; static UINT8 demoflags;
@@ -248,12 +246,10 @@ void G_ReadDemoExtraData(void)
{ {
extradata = READUINT8(demobuf.p); extradata = READUINT8(demobuf.p);
player_t *player = &players[p];
if (extradata & DXD_RESPAWN) if (extradata & DXD_RESPAWN)
{ {
if (player->mo) if (players[p].mo)
P_DamageMobj(player->mo, NULL, NULL, DMG_INSTAKILL); // Is this how this should work..? P_DamageMobj(players[p].mo, NULL, NULL, DMG_INSTAKILL); // Is this how this should work..?
} }
if (extradata & DXD_SKIN) if (extradata & DXD_SKIN)
@@ -268,11 +264,11 @@ void G_ReadDemoExtraData(void)
kartspeed = READUINT8(demobuf.p); kartspeed = READUINT8(demobuf.p);
kartweight = READUINT8(demobuf.p); kartweight = READUINT8(demobuf.p);
if (!fasticmp(skins[player->skin].name, name)) if (!fasticmp(skins[players[p].skin].name, name))
FindClosestSkinForStats(p, kartspeed, kartweight); FindClosestSkinForStats(p, kartspeed, kartweight);
player->kartspeed = kartspeed; players[p].kartspeed = kartspeed;
player->kartweight = kartweight; players[p].kartweight = kartweight;
} }
if (extradata & DXD_COLOR) if (extradata & DXD_COLOR)
@@ -283,9 +279,9 @@ void G_ReadDemoExtraData(void)
for (i = 0; i < MAXSKINCOLORS; i++) for (i = 0; i < MAXSKINCOLORS; i++)
if (fasticmp(KartColor_Names[i], name)) // SRB2kart if (fasticmp(KartColor_Names[i], name)) // SRB2kart
{ {
player->skincolor = i; players[p].skincolor = i;
if (player->mo) if (players[p].mo)
player->mo->color = i; players[p].mo->color = i;
break; break;
} }
} }
@@ -304,17 +300,17 @@ void G_ReadDemoExtraData(void)
switch (extradata) switch (extradata)
{ {
case DXD_PST_PLAYING: case DXD_PST_PLAYING:
player->pflags |= PF_WANTSTOJOIN; // fuck you players[p].pflags |= PF_WANTSTOJOIN; // fuck you
break; break;
case DXD_PST_SPECTATING: case DXD_PST_SPECTATING:
player->pflags &= ~PF_WANTSTOJOIN; // double-fuck you players[p].pflags &= ~PF_WANTSTOJOIN; // double-fuck you
if (!playeringame[p]) if (!playeringame[p])
{ {
CL_ClearPlayer(p); CL_ClearPlayer(p);
playeringame[p] = true; playeringame[p] = true;
G_AddPlayer(p); G_AddPlayer(p);
player->spectator = true; players[p].spectator = true;
// There's likely an off-by-one error in timing recording or playback of joins. This hacks around it so I don't have to find out where that is. \o/ // There's likely an off-by-one error in timing recording or playback of joins. This hacks around it so I don't have to find out where that is. \o/
if (oldcmd[p].forwardmove) if (oldcmd[p].forwardmove)
@@ -322,11 +318,11 @@ void G_ReadDemoExtraData(void)
} }
else else
{ {
player->spectator = true; players[p].spectator = true;
if (player->mo) if (players[p].mo)
P_DamageMobj(player->mo, NULL, NULL, DMG_INSTAKILL); P_DamageMobj(players[p].mo, NULL, NULL, DMG_INSTAKILL);
else else
player->playerstate = PST_REBORN; players[p].playerstate = PST_REBORN;
} }
break; break;
case DXD_PST_LEFT: case DXD_PST_LEFT:
@@ -334,7 +330,7 @@ void G_ReadDemoExtraData(void)
break; break;
} }
G_ResetViews(false); // dont reset our freecam pls thx! G_ResetViews();
// maybe these are necessary? // maybe these are necessary?
if (G_BattleGametype()) if (G_BattleGametype())
@@ -1136,29 +1132,7 @@ void G_GhostTicker(void)
for (g = ghosts, p = NULL; g; g = g->next) for (g = ghosts, p = NULL; g; g = g->next)
{ {
// Skip normal demo data. // Skip normal demo data.
UINT8 ziptic; UINT8 ziptic = READUINT8(g->p);
if (g->done)
{
continue;
}
ziptic = READUINT8(g->p);
fadeghost:
// Demo ends after ghost data.
if (ziptic == DEMOMARKER)
{
g->mo->momx = g->mo->momy = g->mo->momz = 0;
g->done = true;
if (p)
{
p->next = g->next;
}
continue;
}
#ifdef DEMO_COMPAT_100 #ifdef DEMO_COMPAT_100
if (g->version != 0x0001) if (g->version != 0x0001)
@@ -1166,14 +1140,8 @@ fadeghost:
#endif #endif
while (ziptic != DW_END) // Get rid of extradata stuff while (ziptic != DW_END) // Get rid of extradata stuff
{ {
if (ziptic < MAXPLAYERS) if (ziptic == 0) // Only support player 0 info for now
{ {
#ifdef DEVELOP
UINT8 playerid = ziptic;
#endif
// We want to skip *any* player extradata because some demos have extradata for bogus players,
// but if there is tic data later for those players *then* we'll consider it invalid.
ziptic = READUINT8(g->p); ziptic = READUINT8(g->p);
if (ziptic & DXD_SKIN) if (ziptic & DXD_SKIN)
@@ -1185,26 +1153,13 @@ fadeghost:
if (ziptic & DXD_NAME) if (ziptic & DXD_NAME)
g->p += 16; // yea g->p += 16; // yea
if (ziptic & DXD_PLAYSTATE) if (ziptic & DXD_PLAYSTATE && READUINT8(g->p) != DXD_PST_PLAYING)
{ I_Error("Ghost is not a record attack ghost"); //@TODO lmao don't blow up like this
UINT8 playstate = READUINT8(g->p);
if (playstate != DXD_PST_PLAYING)
{
#ifdef DEVELOP
CONS_Alert(CONS_WARNING, "Ghost demo has non-playing playstate for player %d\n", playerid + 1);
#endif
;
}
}
} }
else if (ziptic == DW_RNG) else if (ziptic == DW_RNG)
{
g->p += 4; // RNG seed g->p += 4; // RNG seed
}
else else
{ I_Error("Ghost is not a record attack ghost"); //@TODO lmao don't blow up like this
I_Error("Ghost is not a record attack ghost DXD (ziptic = %u)", ziptic); //@TODO lmao don't blow up like this
}
ziptic = READUINT8(g->p); ziptic = READUINT8(g->p);
} }
@@ -1227,7 +1182,7 @@ fadeghost:
if (ziptic & ZT_DRIFT) if (ziptic & ZT_DRIFT)
g->p += 2; g->p += 2;
if (ziptic & ZT_LATENCY) if (ziptic & ZT_LATENCY)
g->p++; g->p += 1;
// Grab ghost data. // Grab ghost data.
ziptic = READUINT8(g->p); ziptic = READUINT8(g->p);
@@ -1236,12 +1191,10 @@ fadeghost:
if (g->version != 0x0001) if (g->version != 0x0001)
{ {
#endif #endif
if (ziptic == DEMOMARKER) // Had to end early for some reason
goto fadeghost;
if (ziptic == 0xFF) if (ziptic == 0xFF)
goto skippedghosttic; // Didn't write ghost info this frame goto skippedghosttic; // Didn't write ghost info this frame
if (ziptic != 0) else if (ziptic != 0)
I_Error("Ghost is not a record attack ghost ZIPTIC"); //@TODO lmao don't blow up like this I_Error("Ghost is not a record attack ghost"); //@TODO lmao don't blow up like this
ziptic = READUINT8(g->p); ziptic = READUINT8(g->p);
#ifdef DEMO_COMPAT_100 #ifdef DEMO_COMPAT_100
} }
@@ -1412,7 +1365,7 @@ fadeghost:
{ {
#endif #endif
if (READUINT8(g->p) != 0xFF) // Make sure there isn't other ghost data here. if (READUINT8(g->p) != 0xFF) // Make sure there isn't other ghost data here.
I_Error("Ghost is not a record attack ghost GHOSTEND"); //@TODO lmao don't blow up like this I_Error("Ghost is not a record attack ghost"); //@TODO lmao don't blow up like this
#ifdef DEMO_COMPAT_100 #ifdef DEMO_COMPAT_100
} }
#endif #endif
@@ -1432,6 +1385,20 @@ skippedghosttic:
break; break;
} }
// Demo ends after ghost data.
if (*g->p == DEMOMARKER)
{
g->mo->momx = g->mo->momy = g->mo->momz = 0;
if (p)
p->next = g->next;
else
ghosts = g->next;
Z_Free(g);
continue;
}
p = g; p = g;
} }
} }
@@ -1626,7 +1593,7 @@ void G_ConfirmRewind(tic_t rewindtime)
displayplayers[2] = olddp3; displayplayers[2] = olddp3;
displayplayers[3] = olddp4; displayplayers[3] = olddp4;
R_ExecuteSetViewSize(); R_ExecuteSetViewSize();
G_ResetViews(true); G_ResetViews();
for (i = splitscreen; i >= 0; i--) for (i = splitscreen; i >= 0; i--)
P_ResetCamera(&players[displayplayers[i]], &camera[i]); P_ResetCamera(&players[displayplayers[i]], &camera[i]);
@@ -2403,69 +2370,49 @@ static long G_GetCreationTime(char *filepath)
static char *G_GetDemoDate(menudemo_t *pdemo) static char *G_GetDemoDate(menudemo_t *pdemo)
{ {
char *endPos = NULL; char *datetime;
static char datetime[11]; datetime = malloc(sizeof(pdemo->date)); // mallocma balls
// no mallocma balls... :c
if (!datetime)
{
return NULL;
}
time_t file_time = 0; time_t file_time = 0;
const char *format = NULL;
struct tm *tm_buf = NULL;
CLEANUP(pfree) char *filename = NULL;
// get le filepath // get le filepath
char *filename;
filename = strdup(pdemo->filepath); filename = strdup(pdemo->filepath);
#if defined (_WIN32)
if (!filename) if (!filename)
{ {
#if defined (_WIN32) // if we cant get a filename try just getting the file create time
// if we cant get a filename try just getting the file creation time
file_time = G_GetCreationTime(pdemo->filepath); file_time = G_GetCreationTime(pdemo->filepath);
goto skipfilenametime; goto skipfilenametime;
#else
return NULL;
#endif
} }
#else
if (!filename)
{
free(datetime);
return NULL;
}
#endif
// get the actual filename Zzz... // get the actual filename Zzz...
nameonly(filename); nameonly(filename);
// the first 10 characters of a replay name usually is a unix timestamp // convert it to long Zzz....
file_time = strtol(filename, NULL, 10);
// not long enough to contain a valid timestamp free(filename); // dont need this anymore a
if (strlen(filename) < 10)
{
#if defined (_WIN32)
// try to get file creation time
file_time = G_GetCreationTime(pdemo->filepath);
goto skipfilenametime;
#else
return NULL;
#endif
}
#ifndef AVOID_ERRNO
errno = 0;
#endif
// get the timestamp as actual numbers lul
file_time = strtol(filename, &endPos, 10);
if (endPos == filename // Empty string
#ifndef AVOID_ERRNO
|| errno == ERANGE // Number out-of-range
#endif
|| file_time < 0) // Number is not positive
{
#if defined (_WIN32)
// just try and get the creation time then
file_time = G_GetCreationTime(pdemo->filepath);
#else
return NULL;
#endif
}
#if defined (_WIN32) #if defined (_WIN32)
skipfilenametime: skipfilenametime:
#endif #endif
// then throw it into localtime to get an actual human readable format lmao // then throw it into localtime to get an actual human readable format lmao
struct tm *tm_buf = NULL;
tm_buf = localtime(&file_time); tm_buf = localtime(&file_time);
// cant believe we ended up in 1970 // cant believe we ended up in 1970
@@ -2478,10 +2425,14 @@ skipfilenametime:
tm_buf = localtime(&file_time); tm_buf = localtime(&file_time);
if (tm_buf == NULL || tm_buf->tm_year <= 110) if (tm_buf == NULL || tm_buf->tm_year <= 110)
{
free(datetime);
return NULL; return NULL;
}
goto gotcreationtime; goto gotcreationtime;
#else #else
free(datetime);
return NULL; return NULL;
#endif #endif
} }
@@ -2490,27 +2441,17 @@ skipfilenametime:
gotcreationtime: gotcreationtime:
#endif #endif
const char *format;
// US ppl are special (: // US ppl are special (:
if (cv_demodateformat.value == 2) if (cv_demodateformat.value == 2)
format = "%m.%d.%Y"; format = "%m.%d.%Y";
else if (cv_demodateformat.value == 1) else if (cv_demodateformat.value == 1)
format = "%d.%m.%Y"; format = "%d.%m.%Y";
else else
{ format = strstr(setlocale(LC_TIME, NULL), "en_US") ? "%m.%d.%Y" : "%d.%m.%Y";
const char *locale = setlocale(LC_TIME, NULL);
if (locale == NULL) strftime(datetime, sizeof(pdemo->date), format, tm_buf);
format = "%d.%m.%Y"; // fallback to non US format
else if (strstr(locale, "en_US"))
format = "%m.%d.%Y";
else
format = "%d.%m.%Y";
}
if (strftime(datetime, sizeof(datetime), format, tm_buf) == 0)
{
return NULL;
}
return datetime; return datetime;
} }
@@ -2519,7 +2460,6 @@ void G_LoadDemoTitle(menudemo_t *pdemo)
{ {
UINT8 infobuffer[96], *info_p; UINT8 infobuffer[96], *info_p;
UINT16 pdemoversion; UINT16 pdemoversion;
char *demodate = NULL;
size_t count; size_t count;
FILE *handle = fopen(pdemo->filepath, "rb"); FILE *handle = fopen(pdemo->filepath, "rb");
@@ -2558,13 +2498,13 @@ void G_LoadDemoTitle(menudemo_t *pdemo)
memcpy(pdemo->title, info_p, 64); memcpy(pdemo->title, info_p, 64);
// demo date // demo date
char *demodate;
demodate = G_GetDemoDate(pdemo); demodate = G_GetDemoDate(pdemo);
if (demodate) if (demodate)
{ strncpy(pdemo->date, demodate, sizeof(pdemo->date));
strlcpy(pdemo->date, demodate, sizeof(pdemo->date));
}
free(demodate);
break; break;
#ifdef DEMO_COMPAT_100 #ifdef DEMO_COMPAT_100
case 0x0001: case 0x0001:
@@ -2605,7 +2545,7 @@ void G_DoPlayDemo(char *defdemoname)
boolean skiperrors = false; boolean skiperrors = false;
#endif #endif
boolean spectator; boolean spectator;
UINT8 slots[MAXPLAYERS] = {}, kartspeed[MAXPLAYERS] = {}, kartweight[MAXPLAYERS] = {}, numslots = 0; UINT8 slots[MAXPLAYERS], kartspeed[MAXPLAYERS], kartweight[MAXPLAYERS], numslots = 0;
G_InitDemoRewind(); G_InitDemoRewind();
@@ -2641,7 +2581,7 @@ void G_DoPlayDemo(char *defdemoname)
snprintf(msg, 1024, M_GetText("Failed to read file '%s'.\n"), defdemoname); snprintf(msg, 1024, M_GetText("Failed to read file '%s'.\n"), defdemoname);
CONS_Alert(CONS_ERROR, "%s", msg); CONS_Alert(CONS_ERROR, "%s", msg);
gameaction = ga_nothing; gameaction = ga_nothing;
M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); M_StartMessage(msg, NULL, MM_NOTHING);
return; return;
} }
@@ -2653,7 +2593,7 @@ void G_DoPlayDemo(char *defdemoname)
snprintf(msg, 1024, M_GetText("Failed to read lump '%s'.\n"), defdemoname); snprintf(msg, 1024, M_GetText("Failed to read lump '%s'.\n"), defdemoname);
CONS_Alert(CONS_ERROR, "%s", msg); CONS_Alert(CONS_ERROR, "%s", msg);
gameaction = ga_nothing; gameaction = ga_nothing;
M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); M_StartMessage(msg, NULL, MM_NOTHING);
return; return;
} }
else // it's an internal demo else // it's an internal demo
@@ -2673,7 +2613,7 @@ void G_DoPlayDemo(char *defdemoname)
{ {
snprintf(msg, 1024, M_GetText("%s is not a SRB2Kart replay file.\n"), pdemoname); snprintf(msg, 1024, M_GetText("%s is not a SRB2Kart replay file.\n"), pdemoname);
CONS_Alert(CONS_ERROR, "%s", msg); CONS_Alert(CONS_ERROR, "%s", msg);
M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); M_StartMessage(msg, NULL, MM_NOTHING);
G_ResetDemoPlayback(); G_ResetDemoPlayback();
return; return;
} }
@@ -2699,7 +2639,7 @@ void G_DoPlayDemo(char *defdemoname)
default: default:
snprintf(msg, 1024, M_GetText("%s is an incompatible replay format and cannot be played.\n"), pdemoname); snprintf(msg, 1024, M_GetText("%s is an incompatible replay format and cannot be played.\n"), pdemoname);
CONS_Alert(CONS_ERROR, "%s", msg); CONS_Alert(CONS_ERROR, "%s", msg);
M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); M_StartMessage(msg, NULL, MM_NOTHING);
G_ResetDemoPlayback(); G_ResetDemoPlayback();
return; return;
} }
@@ -2710,7 +2650,7 @@ void G_DoPlayDemo(char *defdemoname)
{ {
snprintf(msg, 1024, M_GetText("%s is the wrong type of recording and cannot be played.\n"), pdemoname); snprintf(msg, 1024, M_GetText("%s is the wrong type of recording and cannot be played.\n"), pdemoname);
CONS_Alert(CONS_ERROR, "%s", msg); CONS_Alert(CONS_ERROR, "%s", msg);
M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); M_StartMessage(msg, NULL, MM_NOTHING);
G_ResetDemoPlayback(); G_ResetDemoPlayback();
return; return;
} }
@@ -2727,7 +2667,7 @@ void G_DoPlayDemo(char *defdemoname)
{ {
snprintf(msg, 1024, M_GetText("%s is an alpha multiplayer replay and cannot be played.\n"), pdemoname); snprintf(msg, 1024, M_GetText("%s is an alpha multiplayer replay and cannot be played.\n"), pdemoname);
CONS_Alert(CONS_ERROR, "%s", msg); CONS_Alert(CONS_ERROR, "%s", msg);
M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); M_StartMessage(msg, NULL, MM_NOTHING);
G_ResetDemoPlayback(); G_ResetDemoPlayback();
return; return;
} }
@@ -2785,7 +2725,7 @@ void G_DoPlayDemo(char *defdemoname)
CONS_Alert(CONS_ERROR, "%s", msg); CONS_Alert(CONS_ERROR, "%s", msg);
if (!CON_Ready()) // In the console they'll just see the notice there! No point pulling them out. if (!CON_Ready()) // In the console they'll just see the notice there! No point pulling them out.
M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); M_StartMessage(msg, NULL, MM_NOTHING);
G_ResetDemoPlayback(); G_ResetDemoPlayback();
return; return;
@@ -2823,16 +2763,6 @@ void G_DoPlayDemo(char *defdemoname)
#endif #endif
demobuf.p += 4; // Extrainfo location demobuf.p += 4; // Extrainfo location
// ...*map* not loaded?
if (!gamemap || (gamemap > NUMMAPS) || (W_CheckNumForName(G_BuildMapName(gamemap)) == LUMPERROR))
{
snprintf(msg, 1024, M_GetText("%s features a course that is not currently loaded.\n"), pdemoname);
CONS_Alert(CONS_ERROR, "%s", msg);
M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER);
G_ResetDemoPlayback();
return;
}
#ifdef DEMO_COMPAT_100 #ifdef DEMO_COMPAT_100
if (demo.version == 0x0001) if (demo.version == 0x0001)
{ {
@@ -2860,7 +2790,7 @@ void G_DoPlayDemo(char *defdemoname)
{ {
snprintf(msg, 1024, M_GetText("%s features a character that is not currently loaded.\n"), pdemoname); snprintf(msg, 1024, M_GetText("%s features a character that is not currently loaded.\n"), pdemoname);
CONS_Alert(CONS_ERROR, "%s", msg); CONS_Alert(CONS_ERROR, "%s", msg);
M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); M_StartMessage(msg, NULL, MM_NOTHING);
G_ResetDemoPlayback(); G_ResetDemoPlayback();
return; return;
} }
@@ -2870,7 +2800,7 @@ void G_DoPlayDemo(char *defdemoname)
{ {
snprintf(msg, 1024, M_GetText("%s features a course that is not currently loaded.\n"), pdemoname); snprintf(msg, 1024, M_GetText("%s features a course that is not currently loaded.\n"), pdemoname);
CONS_Alert(CONS_ERROR, "%s", msg); CONS_Alert(CONS_ERROR, "%s", msg);
M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); M_StartMessage(msg, NULL, MM_NOTHING);
G_ResetDemoPlayback(); G_ResetDemoPlayback();
return; return;
} }
@@ -2893,7 +2823,7 @@ void G_DoPlayDemo(char *defdemoname)
{ {
snprintf(msg, 1024, M_GetText("%s contains no data to be played.\n"), pdemoname); snprintf(msg, 1024, M_GetText("%s contains no data to be played.\n"), pdemoname);
CONS_Alert(CONS_ERROR, "%s", msg); CONS_Alert(CONS_ERROR, "%s", msg);
M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); M_StartMessage(msg, NULL, MM_NOTHING);
G_ResetDemoPlayback(); G_ResetDemoPlayback();
return; return;
} }
@@ -2931,7 +2861,7 @@ void G_DoPlayDemo(char *defdemoname)
{ {
snprintf(msg, 1024, M_GetText("%s contains no data to be played.\n"), pdemoname); snprintf(msg, 1024, M_GetText("%s contains no data to be played.\n"), pdemoname);
CONS_Alert(CONS_ERROR, "%s", msg); CONS_Alert(CONS_ERROR, "%s", msg);
M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); M_StartMessage(msg, NULL, MM_NOTHING);
G_ResetDemoPlayback(); G_ResetDemoPlayback();
return; return;
} }
@@ -2980,7 +2910,7 @@ void G_DoPlayDemo(char *defdemoname)
{ {
snprintf(msg, 1024, M_GetText("%s is a Record Attack replay with spectators, and is thus invalid.\n"), pdemoname); snprintf(msg, 1024, M_GetText("%s is a Record Attack replay with spectators, and is thus invalid.\n"), pdemoname);
CONS_Alert(CONS_ERROR, "%s", msg); CONS_Alert(CONS_ERROR, "%s", msg);
M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); M_StartMessage(msg, NULL, MM_NOTHING);
G_ResetDemoPlayback(); G_ResetDemoPlayback();
return; return;
} }
@@ -2992,7 +2922,7 @@ void G_DoPlayDemo(char *defdemoname)
{ {
snprintf(msg, 1024, M_GetText("%s is a Record Attack replay with multiple players, and is thus invalid.\n"), pdemoname); snprintf(msg, 1024, M_GetText("%s is a Record Attack replay with multiple players, and is thus invalid.\n"), pdemoname);
CONS_Alert(CONS_ERROR, "%s", msg); CONS_Alert(CONS_ERROR, "%s", msg);
M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); M_StartMessage(msg, NULL, MM_NOTHING);
G_ResetDemoPlayback(); G_ResetDemoPlayback();
return; return;
} }
@@ -3602,6 +3532,7 @@ void G_FreeGhosts(void)
ghosts = NULL; ghosts = NULL;
} }
boolean G_CheckDemoStatus(void) boolean G_CheckDemoStatus(void)
{ {
G_FreeGhosts(); G_FreeGhosts();
-1
View File
@@ -149,7 +149,6 @@ typedef struct demoghost {
UINT8 checksum[16]; UINT8 checksum[16];
UINT8 *buffer, *p, color; UINT8 *buffer, *p, color;
UINT16 version; UINT16 version;
boolean done;
mobj_t oldmo, *mo; mobj_t oldmo, *mo;
struct demoghost *next; struct demoghost *next;
} demoghost; } demoghost;
+41 -106
View File
@@ -69,6 +69,9 @@ UINT8 botcolor = 0;
JoyType_t Joystick[MAXSPLITSCREENPLAYERS] = {}; JoyType_t Joystick[MAXSPLITSCREENPLAYERS] = {};
// 1024 bytes is plenty for a savegame
#define SAVEGAMESIZE (1024)
// SRB2kart // SRB2kart
char gamedatafilename[64] = "kartdata.dat"; char gamedatafilename[64] = "kartdata.dat";
char timeattackfolder[64] = "kart"; char timeattackfolder[64] = "kart";
@@ -129,7 +132,7 @@ UINT8 skincolor_bluering = SKINCOLOR_STEEL;
tic_t countdowntimer = 0; tic_t countdowntimer = 0;
boolean countdowntimeup = false; boolean countdowntimeup = false;
cutscene_t *cutscenes[128] = {}; cutscene_t *cutscenes[128];
INT16 nextmapoverride = 0; INT16 nextmapoverride = 0;
boolean skipstats = false; boolean skipstats = false;
@@ -141,7 +144,7 @@ mobj_t *blueflag = NULL;
mapthing_t *rflagpoint = NULL; mapthing_t *rflagpoint = NULL;
mapthing_t *bflagpoint = NULL; mapthing_t *bflagpoint = NULL;
struct quake quake = {}; struct quake quake;
// Map Header Information // Map Header Information
mapheader_t* mapheaderinfo[NUMMAPS] = {}; mapheader_t* mapheaderinfo[NUMMAPS] = {};
@@ -225,7 +228,7 @@ tic_t racecountdown = 0, exitcountdown = 0; // for racing
fixed_t gravity = 0; fixed_t gravity = 0;
fixed_t mapobjectscale = FRACUNIT; fixed_t mapobjectscale = FRACUNIT;
struct maplighting maplighting = {}; struct maplighting maplighting;
INT16 autobalance = 0; //for CTF team balance INT16 autobalance = 0; //for CTF team balance
INT16 teamscramble = 0; //for CTF team scramble INT16 teamscramble = 0; //for CTF team scramble
@@ -309,8 +312,6 @@ consvar_t cv_pauseifunfocused = {"pauseifunfocused", "Yes", CV_SAVE, CV_YesNo, N
static CV_PossibleValue_t songcredits_cons_t[] = {{0, "Off"}, {1, "Default"}, {2, "Box"}, {0, NULL}}; static CV_PossibleValue_t songcredits_cons_t[] = {{0, "Off"}, {1, "Default"}, {2, "Box"}, {0, NULL}};
consvar_t cv_songcredits = {"songcredits", "Default", CV_SAVE, songcredits_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_songcredits = {"songcredits", "Default", CV_SAVE, songcredits_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_pausesongcredits = {"pausesongcredits", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
// Show "FREE PLAY" when you're alone. :( // Show "FREE PLAY" when you're alone. :(
consvar_t cv_showfreeplay = { "showfreeplay", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showfreeplay = { "showfreeplay", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -451,14 +452,6 @@ consvar_t cv_litesteer[MAXSPLITSCREENPLAYERS] = {
{"litesteer4", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL} {"litesteer4", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}
}; };
//static CV_PossibleValue_t autoaccelcons_t[] = {{0, "Off"}, {1, "Manual"}, {2, "Automatic"}, {0, NULL}};
consvar_t cv_autoaccel[MAXSPLITSCREENPLAYERS] = {
{"kartautoaccel", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"kartautoaccel2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"kartautoaccel3", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"kartautoaccel4", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}
};
static CV_PossibleValue_t driftsparkpulse_t[] = {{0, "MIN"}, {FRACUNIT*3, "MAX"}, {0, NULL}}; static CV_PossibleValue_t driftsparkpulse_t[] = {{0, "MIN"}, {FRACUNIT*3, "MAX"}, {0, NULL}};
consvar_t cv_driftsparkpulse = {"driftsparkpulse", "1.4", CV_FLOAT | CV_SAVE, driftsparkpulse_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_driftsparkpulse = {"driftsparkpulse", "1.4", CV_FLOAT | CV_SAVE, driftsparkpulse_t, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -520,8 +513,11 @@ void G_ClearRecords(void)
INT16 i; INT16 i;
for (i = 0; i < NUMMAPS; ++i) for (i = 0; i < NUMMAPS; ++i)
{ {
Z_Free(mainrecords[i]); if (mainrecords[i])
mainrecords[i] = NULL; {
Z_Free(mainrecords[i]);
mainrecords[i] = NULL;
}
} }
} }
@@ -666,7 +662,7 @@ INT16 G_ClipAimingPitch(INT32 *aiming)
else if (*aiming < -limitangle) else if (*aiming < -limitangle)
*aiming = -limitangle; *aiming = -limitangle;
return (INT16)((*aiming) >> TICCMD_REDUCE); return (INT16)((*aiming)>>16);
} }
INT16 G_SoftwareClipAimingPitch(INT32 *aiming) INT16 G_SoftwareClipAimingPitch(INT32 *aiming)
@@ -679,7 +675,7 @@ INT16 G_SoftwareClipAimingPitch(INT32 *aiming)
else if (*aiming < -limitangle) else if (*aiming < -limitangle)
*aiming = -limitangle; *aiming = -limitangle;
return (INT16)((*aiming) >> TICCMD_REDUCE); return (INT16)((*aiming)>>16);
} }
INT32 JoyAxis(axis_input_e axissel, UINT8 player) INT32 JoyAxis(axis_input_e axissel, UINT8 player)
@@ -802,10 +798,6 @@ static fixed_t forwardmove[2] = {25<<FRACBITS>>16, 50<<FRACBITS>>16};
static fixed_t sidemove[2] = {2<<FRACBITS>>16, 4<<FRACBITS>>16}; static fixed_t sidemove[2] = {2<<FRACBITS>>16, 4<<FRACBITS>>16};
static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // + slow turn static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // + slow turn
//
// G_HandleLocalDriftturn
// Hack for Lua menus that check directional inputs with driftturn
//
static void G_HandleLocalDriftturn(ticcmd_t *cmd, UINT8 ssplayer) static void G_HandleLocalDriftturn(ticcmd_t *cmd, UINT8 ssplayer)
{ {
INT32 axis = 0; INT32 axis = 0;
@@ -868,8 +860,9 @@ static void G_HandleLocalDriftturn(ticcmd_t *cmd, UINT8 ssplayer)
// //
static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam) static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam)
{ {
boolean moveinput = false;
INT32 axis = 0; INT32 axis = 0;
const boolean usejoystick = cv_usejoystick[(ssplayer-1)].value; const boolean usejoystick = (cv_usejoystick[(ssplayer-1)].value);
// check for inputs and return button commands // check for inputs and return button commands
// for stuff like joining with item button, saltyhop, honking, etc. // for stuff like joining with item button, saltyhop, honking, etc.
@@ -904,11 +897,15 @@ static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam)
#undef CHECKINPUT #undef CHECKINPUT
moveinput = (InputDown(gc_turnleft, ssplayer) || InputDown(gc_turnright, ssplayer)
|| InputDown(gc_aimforward, ssplayer) || InputDown(gc_aimbackward, ssplayer) ||
(usejoystick && JoyAxis(AXISAIM, ssplayer) != 0) || (usejoystick && JoyAxis(AXISTURN, ssplayer) != 0));
axis = JoyAxis(AXISLOOKBACK, ssplayer); axis = JoyAxis(AXISLOOKBACK, ssplayer);
camspin[ssplayer-1] = (InputDown(gc_lookback, ssplayer) || (usejoystick && axis > 0)); camspin[ssplayer-1] = (InputDown(gc_lookback, ssplayer) || (usejoystick && axis > 0));
// Reset to our spec player if we watch someone else. // Reset to our spec player if we watch someone else.
if ((cmd->driftturn || cmd->buttons) if ((moveinput || cmd->buttons)
&& displayplayers[0] != consoleplayer && ssplayer == 1) && displayplayers[0] != consoleplayer && ssplayer == 1)
{ {
if (cv_director.value) if (cv_director.value)
@@ -920,63 +917,6 @@ static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam)
} }
} }
//
// G_HandleAutoAcceleration
//
static void G_HandleAutoAcceleration(ticcmd_t *cmd, player_t *player, UINT8 forplayer)
{
if (!cv_autoaccel[forplayer].value)
return;
if (gamestate != GS_LEVEL)
return;
// dont accel before and during countdown
if (leveltime <= starttime)
return;
// dont do this in menus or when console is onscreen
if (menuactive || CON_Ready())
return;
// gotta have a player that aint respawning
if (!player->mo || player->kartstuff[k_respawn])
return;
// dont need for "finished" players
if (player->exiting || (player->pflags & PF_TIMEOVER))
return;
// dont do during spinout
if (player->kartstuff[k_spinouttimer])
return;
// spectators and freecam dont need special handling, see G_BuildTiccmd
if (cmd->buttons & BT_BRAKE)
{
if (cmd->buttons & BT_DRIFT ||
player->kartstuff[k_sneakertimer] ||
player->kartstuff[k_squishedtimer])
{
cmd->forwardmove = (SINT8)forwardmove[0];
cmd->buttons |= BT_ACCELERATE;
}
else
{
// allows us to drive backwards if we need to
if (cmd->forwardmove > 0)
cmd->forwardmove = 0;
cmd->buttons &= ~BT_ACCELERATE;
}
}
else
{
cmd->forwardmove = (SINT8)forwardmove[1];
cmd->buttons |= BT_ACCELERATE;
}
}
// //
// G_BuildTiccmd // G_BuildTiccmd
// Builds a ticcmd from all of the available inputs // Builds a ticcmd from all of the available inputs
@@ -1019,7 +959,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
// Kart, don't build a ticcmd if someone is resynching or the server is stopped too so we don't fly off course in bad conditions // Kart, don't build a ticcmd if someone is resynching or the server is stopped too so we don't fly off course in bad conditions
if (paused || P_AutoPause() || (gamestate == GS_LEVEL && player->playerstate == PST_REBORN) || hu_resynching) if (paused || P_AutoPause() || (gamestate == GS_LEVEL && player->playerstate == PST_REBORN) || hu_resynching)
{ {
cmd->angleturn = (INT16)(lang >> TICCMD_REDUCE); cmd->angleturn = (INT16)(lang >> 16);
cmd->aiming = G_ClipAimingPitch(&laim); cmd->aiming = G_ClipAimingPitch(&laim);
return; return;
} }
@@ -1027,7 +967,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
// dumbass thing so we can use a few buttons but dont accidentally drive away // dumbass thing so we can use a few buttons but dont accidentally drive away
if (player->spectator || freecam) if (player->spectator || freecam)
{ {
cmd->angleturn = (INT16)(lang >> TICCMD_REDUCE); cmd->angleturn = (INT16)(lang >> 16);
G_BuildLocalTiccmd(cmd, ssplayer, freecam); G_BuildLocalTiccmd(cmd, ssplayer, freecam);
// let lua override everything // let lua override everything
@@ -1124,7 +1064,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
if (InputDown(gc_accelerate, ssplayer) || (gamepadjoystickmove && axis > 0) || player->kartstuff[k_sneakertimer]) if (InputDown(gc_accelerate, ssplayer) || (gamepadjoystickmove && axis > 0) || player->kartstuff[k_sneakertimer])
{ {
cmd->buttons |= BT_ACCELERATE; cmd->buttons |= BT_ACCELERATE;
forward = forwardmove[1]; // 50 forward = forwardmove[1]; // 50
} }
else if (analogjoystickmove && axis > 0) else if (analogjoystickmove && axis > 0)
{ {
@@ -1187,7 +1127,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
cmd->aiming = G_ClipAimingPitch(&laim); cmd->aiming = G_ClipAimingPitch(&laim);
mousex = mousey = 0; mousex = mousey = mlooky = 0;
if (forward > MAXPLMOVE) if (forward > MAXPLMOVE)
forward = MAXPLMOVE; forward = MAXPLMOVE;
@@ -1205,8 +1145,6 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
cmd->sidemove = (SINT8)(cmd->sidemove + side); cmd->sidemove = (SINT8)(cmd->sidemove + side);
} }
G_HandleAutoAcceleration(cmd, player, forplayer);
//{ SRB2kart - Drift support //{ SRB2kart - Drift support
// Not grouped with the rest of turn stuff because it needs to know what buttons you're pressing for rubber-burn turn // Not grouped with the rest of turn stuff because it needs to know what buttons you're pressing for rubber-burn turn
// limit turning to angleturn[1] to stop mouselook letting you look too fast // limit turning to angleturn[1] to stop mouselook letting you look too fast
@@ -1228,10 +1166,10 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|| (leveltime > starttime && (cmd->buttons & BT_ACCELERATE && cmd->buttons & BT_BRAKE)) // Rubber-burn turn || (leveltime > starttime && (cmd->buttons & BT_ACCELERATE && cmd->buttons & BT_BRAKE)) // Rubber-burn turn
|| (player->kartstuff[k_respawn]) // Respawning || (player->kartstuff[k_respawn]) // Respawning
|| (player->spectator || objectplacing))) // Not a physical player || (player->spectator || objectplacing))) // Not a physical player
lang += (cmd->angleturn << TICCMD_REDUCE); lang += (cmd->angleturn<<16);
cmd->angleturn = (INT16)(lang >> TICCMD_REDUCE); cmd->angleturn = (INT16)(lang >> 16);
cmd->latency = modeattacking ? 0 : (leveltime & TICCMD_LATENCYMASK); // Send leveltime when this tic was generated to the server for control lag calculations cmd->latency = modeattacking ? 0 : (leveltime & 0xFF); // Send leveltime when this tic was generated to the server for control lag calculations
if (!hu_stopped) if (!hu_stopped)
{ {
@@ -1812,15 +1750,14 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive)
// Increment a viewpoint by offset from the current player. A negative value // Increment a viewpoint by offset from the current player. A negative value
// decrements. // decrements.
// //
void G_AdjustViewEx(UINT8 viewnum, INT32 offset, boolean onlyactive, boolean resetfreecam) void G_AdjustView(UINT8 viewnum, INT32 offset, boolean onlyactive)
{ {
INT32 *displayplayerp, oldview; INT32 *displayplayerp, oldview;
displayplayerp = &displayplayers[viewnum-1]; displayplayerp = &displayplayers[viewnum-1];
oldview = (*displayplayerp); oldview = (*displayplayerp);
// turn off the freecam // turn off the freecam
if (resetfreecam) camera[viewnum-1].freecam = false;
camera[viewnum-1].freecam = false;
G_ResetView(viewnum, ( (*displayplayerp) + offset ), onlyactive); G_ResetView(viewnum, ( (*displayplayerp) + offset ), onlyactive);
@@ -1834,7 +1771,7 @@ void G_AdjustViewEx(UINT8 viewnum, INT32 offset, boolean onlyactive, boolean res
// Ensures all viewpoints are valid // Ensures all viewpoints are valid
// Also demotes splitscreen down to one player. // Also demotes splitscreen down to one player.
// //
void G_ResetViews(boolean resetfreecam) void G_ResetViews(void)
{ {
UINT8 splits; UINT8 splits;
UINT8 viewd; UINT8 viewd;
@@ -1858,7 +1795,7 @@ void G_ResetViews(boolean resetfreecam)
*/ */
for (viewd = 1; viewd <= splits; ++viewd) for (viewd = 1; viewd <= splits; ++viewd)
{ {
G_AdjustViewEx(viewd, 0, false, resetfreecam); G_AdjustView(viewd, 0, false);
} }
} }
@@ -1939,7 +1876,7 @@ void G_Ticker(boolean run)
G_CopyTiccmd(cmd, &netcmds[buf][i], 1); G_CopyTiccmd(cmd, &netcmds[buf][i], 1);
// Use the leveltime sent in the player's ticcmd to determine control lag // Use the leveltime sent in the player's ticcmd to determine control lag
cmd->latency = modeattacking ? 0 : min(((leveltime & TICCMD_LATENCYMASK) - cmd->latency) & TICCMD_LATENCYMASK, MAXPREDICTTICS-1); //@TODO add a cvar to allow setting this max cmd->latency = modeattacking ? 0 : min(((leveltime & 0xFF) - cmd->latency) & 0xFF, MAXPREDICTTICS-1); //@TODO add a cvar to allow setting this max
} }
} }
@@ -1947,6 +1884,7 @@ void G_Ticker(boolean run)
switch (gamestate) switch (gamestate)
{ {
case GS_LEVEL: case GS_LEVEL:
for (; ra_timeskip < starttime - TICRATE*4; ra_timeskip++) // this looks weird but this is done to not break compability with older demos for now. for (; ra_timeskip < starttime - TICRATE*4; ra_timeskip++) // this looks weird but this is done to not break compability with older demos for now.
{ {
if (demo.title) if (demo.title)
@@ -3495,7 +3433,7 @@ void G_LoadGameData(void)
INT32 i, j; INT32 i, j;
UINT8 modded = false; UINT8 modded = false;
UINT8 rtemp; UINT8 rtemp;
savebuffer_t save = {}; savebuffer_t save = {0};
//For records //For records
tic_t rectime; tic_t rectime;
@@ -3628,7 +3566,7 @@ void G_SaveGameData(boolean force)
size_t length; size_t length;
INT32 i, j; INT32 i, j;
UINT8 btemp; UINT8 btemp;
savebuffer_t save = {}; savebuffer_t save = {0};
(void)force; (void)force;
char backupfile[MAX_WADPATH+4]; char backupfile[MAX_WADPATH+4];
@@ -3799,7 +3737,7 @@ void G_LoadGame(UINT32 slot, INT16 mapoverride)
size_t length; size_t length;
char vcheck[VERSIONSIZE]; char vcheck[VERSIONSIZE];
char savename[255]; char savename[255];
savebuffer_t save = {}; savebuffer_t save = {0};
// memset savedata to all 0, fixes calling perfectly valid saves corrupt because of bots // memset savedata to all 0, fixes calling perfectly valid saves corrupt because of bots
memset(&savedata, 0, sizeof(savedata)); memset(&savedata, 0, sizeof(savedata));
@@ -3885,7 +3823,7 @@ void G_SaveGame(UINT32 savegameslot)
boolean saved; boolean saved;
char savename[256] = ""; char savename[256] = "";
const char *backup; const char *backup;
savebuffer_t save = {}; savebuffer_t save = {0};
sprintf(savename, savegamename, savegameslot); sprintf(savename, savegamename, savegameslot);
backup = va("%s",savename); backup = va("%s",savename);
@@ -3899,7 +3837,7 @@ void G_SaveGame(UINT32 savegameslot)
char name[VERSIONSIZE]; char name[VERSIONSIZE];
size_t length; size_t length;
save.p = save.buffer = (UINT8 *)Z_Malloc(1024, PU_STATIC, NULL); // 1024 bytes is plenty for a savegame save.p = save.buffer = (UINT8 *)Z_Malloc(SAVEGAMESIZE, PU_STATIC, NULL);
if (!save.p) if (!save.p)
{ {
CONS_Alert(CONS_ERROR, M_GetText("No more free memory for saving game data\n")); CONS_Alert(CONS_ERROR, M_GetText("No more free memory for saving game data\n"));
@@ -4150,13 +4088,12 @@ static void measurekeywords(mapsearchfreq_t *fr,
{ {
char *qp; char *qp;
char *sp; char *sp;
if (wanttable) if (wanttable)
(*dimp) = Z_Realloc((*dimp), 255 * sizeof (struct searchdim), (*dimp) = Z_Realloc((*dimp), 255 * sizeof (struct searchdim),
PU_STATIC, NULL); PU_STATIC, NULL);
for (qp = strtok(va("%s", q), " "); for (qp = strtok(va("%s", q), " ");
qp && fr->total < 255; qp && fr->total < 255;
qp = strtok(NULL, " ")) qp = strtok(0, " "))
{ {
if (( sp = strcasestr(s, qp) )) if (( sp = strcasestr(s, qp) ))
{ {
@@ -4165,12 +4102,10 @@ static void measurekeywords(mapsearchfreq_t *fr,
(*dimp)[(*cuntp)].pos = sp - s; (*dimp)[(*cuntp)].pos = sp - s;
(*dimp)[(*cuntp)].siz = strlen(qp); (*dimp)[(*cuntp)].siz = strlen(qp);
} }
(*cuntp)++; (*cuntp)++;
fr->total++; fr->total++;
} }
} }
if (wanttable) if (wanttable)
(*dimp) = Z_Realloc((*dimp), (*cuntp) * sizeof (struct searchdim), (*dimp) = Z_Realloc((*dimp), (*cuntp) * sizeof (struct searchdim),
PU_STATIC, NULL); PU_STATIC, NULL);
@@ -4239,7 +4174,7 @@ INT32 G_FindMap(const char *mapname, char **foundmapnamep,
{ {
newmapnum = mapnum; newmapnum = mapnum;
newmapname = realmapname; newmapname = realmapname;
realmapname = NULL; realmapname = 0;
Z_Free(apromapname); Z_Free(apromapname);
if (!wanttable) if (!wanttable)
break; break;
@@ -4260,7 +4195,7 @@ INT32 G_FindMap(const char *mapname, char **foundmapnamep,
{ {
apromapnum = mapnum; apromapnum = mapnum;
apromapname = realmapname; apromapname = realmapname;
realmapname = NULL; realmapname = 0;
} }
} }
else/* ...match individual keywords */ else/* ...match individual keywords */
+3 -7
View File
@@ -50,7 +50,7 @@ extern INT16 rw_maximums[NUM_WEAPONS];
// used in game menu // used in game menu
extern consvar_t cv_chatwidth, cv_chatnotifications, cv_chatheight, cv_chattime, cv_consolechat, cv_chatbacktint, cv_chatspamprotection, cv_chatcentertext/*, cv_compactscoreboard*/; extern consvar_t cv_chatwidth, cv_chatnotifications, cv_chatheight, cv_chattime, cv_consolechat, cv_chatbacktint, cv_chatspamprotection, cv_chatcentertext/*, cv_compactscoreboard*/;
extern consvar_t cv_songcredits, cv_pausesongcredits; extern consvar_t cv_songcredits;
extern consvar_t cv_showfreeplay; extern consvar_t cv_showfreeplay;
extern consvar_t cv_growmusic, cv_supermusic; extern consvar_t cv_growmusic, cv_supermusic;
extern consvar_t cv_pauseifunfocused; extern consvar_t cv_pauseifunfocused;
@@ -74,8 +74,6 @@ extern consvar_t cv_ydeadzone[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_litesteer[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_litesteer[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_autoaccel[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_guest, cv_ghost_staff; extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_guest, cv_ghost_staff;
// Hud offsets // Hud offsets
@@ -130,7 +128,6 @@ extern consvar_t cv_spinoutroll;
extern consvar_t cv_squishdance, cv_squishdancespeed; extern consvar_t cv_squishdance, cv_squishdancespeed;
extern consvar_t cv_playerblendeffects; extern consvar_t cv_playerblendeffects;
extern consvar_t cv_reducevfx;
extern consvar_t cv_cechotoggle; extern consvar_t cv_cechotoggle;
@@ -265,10 +262,9 @@ boolean G_CanView(INT32 playernum, UINT8 viewnum, boolean onlyactive);
INT32 G_FindView(INT32 startview, UINT8 viewnum, boolean onlyactive, boolean reverse); INT32 G_FindView(INT32 startview, UINT8 viewnum, boolean onlyactive, boolean reverse);
INT32 G_CountPlayersPotentiallyViewable(boolean active); INT32 G_CountPlayersPotentiallyViewable(boolean active);
void G_ResetViews(boolean resetfreecam); void G_ResetViews(void);
void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive); void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive);
void G_AdjustViewEx(UINT8 viewnum, INT32 offset, boolean onlyactive, boolean resetfreecam); void G_AdjustView(UINT8 viewnum, INT32 offset, boolean onlyactive);
#define G_AdjustView(v,o,oa) G_AdjustViewEx(v,o,oa, true)
void G_AddPlayer(INT32 playernum); void G_AddPlayer(INT32 playernum);
+13 -18
View File
@@ -34,7 +34,7 @@ static CV_PossibleValue_t onecontrolperkey_cons_t[] = {{1, "One"}, {2, "Several"
static CV_PossibleValue_t turnsmooth_cons_t[] = {{2, "Slow"}, {1, "Fast"}, {0, "Off"}, {0, NULL}}; static CV_PossibleValue_t turnsmooth_cons_t[] = {{2, "Slow"}, {1, "Fast"}, {0, "Off"}, {0, NULL}};
// mouse values are used once // mouse values are used once
consvar_t cv_mousexsens = {"mousexsens", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_mousesens = {"mousesens", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_mouseysens = {"mouseysens", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_mouseysens = {"mouseysens", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_controlperkey = {"controlperkey", "One", CV_SAVE, onecontrolperkey_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_controlperkey = {"controlperkey", "One", CV_SAVE, onecontrolperkey_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -81,9 +81,6 @@ consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS] = {
{"gamepadled4", "Skincolor", CV_SAVE|CV_CALL|CV_NOINIT, gamepadled_cons_t, led_off_handle4, 0, NULL, NULL, 0, 0, NULL} {"gamepadled4", "Skincolor", CV_SAVE|CV_CALL|CV_NOINIT, gamepadled_cons_t, led_off_handle4, 0, NULL, NULL, 0, 0, NULL}
}; };
consvar_t cv_gamepadledifunfocused = {"gamepadledunfocused", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_rumbleifunfocused = {"rumbleifunfocused", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
static void rumble_off_handle(void) static void rumble_off_handle(void)
{ {
if (!cv_rumble[0].value) if (!cv_rumble[0].value)
@@ -128,17 +125,17 @@ static void led_off_handle4(void)
G_ResetPlayerGamepadIndicatorColor(3); G_ResetPlayerGamepadIndicatorColor(3);
} }
INT32 mousex = 0, mousey = 0; INT32 mousex, mousey;
INT32 mlooky; // like mousey but with a custom sensitivity for mlook
// joystick values are repeated // joystick values are repeated
INT32 joyxmove[MAXSPLITSCREENPLAYERS][JOYAXISSET] = {}; INT32 joyxmove[MAXSPLITSCREENPLAYERS][JOYAXISSET], joyymove[MAXSPLITSCREENPLAYERS][JOYAXISSET];
INT32 joyymove[MAXSPLITSCREENPLAYERS][JOYAXISSET] = {};
// current state of the keys: true if pushed // current state of the keys: true if pushed
UINT8 gamekeydown[NUMINPUTS] = {}; UINT8 gamekeydown[NUMINPUTS];
// two key codes (or virtual key) per game control // two key codes (or virtual key) per game control
INT32 gamecontrol[MAXSPLITSCREENPLAYERS][num_gamecontrols][2] = {}; INT32 gamecontrol[MAXSPLITSCREENPLAYERS][num_gamecontrols][2];
typedef struct typedef struct
{ {
@@ -195,8 +192,9 @@ void G_MapEventsToControls(event_t *ev)
case ev_mouse: // buttons are virtual keys case ev_mouse: // buttons are virtual keys
if (menuactive || CON_Ready() || chat_on) if (menuactive || CON_Ready() || chat_on)
break; break;
mousex = (INT32)(ev->data2*((cv_mousexsens.value*cv_mousexsens.value)/110.0f + 0.1f)); mousex = (INT32)(ev->data2*((cv_mousesens.value*cv_mousesens.value)/110.0f + 0.1f));
mousey = (INT32)(ev->data3*((cv_mouseysens.value*cv_mouseysens.value)/110.0f + 0.1f)); mousey = (INT32)(ev->data3*((cv_mousesens.value*cv_mousesens.value)/110.0f + 0.1f));
mlooky = (INT32)(ev->data3*((cv_mouseysens.value*cv_mousesens.value)/110.0f + 0.1f));
break; break;
case ev_joystick: // buttons are virtual keys case ev_joystick: // buttons are virtual keys
@@ -217,7 +215,7 @@ void G_MapEventsToControls(event_t *ev)
case ev_joystick3: case ev_joystick3:
i = ev->data1; i = ev->data1;
if (i >= JOYAXISSET || menuactive) if (i >= JOYAXISSET)
break; break;
if (ev->data2 != INT32_MAX) joyxmove[2][i] = ev->data2; if (ev->data2 != INT32_MAX) joyxmove[2][i] = ev->data2;
if (ev->data3 != INT32_MAX) joyymove[2][i] = ev->data3; if (ev->data3 != INT32_MAX) joyymove[2][i] = ev->data3;
@@ -225,7 +223,7 @@ void G_MapEventsToControls(event_t *ev)
case ev_joystick4: case ev_joystick4:
i = ev->data1; i = ev->data1;
if (i >= JOYAXISSET || menuactive) if (i >= JOYAXISSET)
break; break;
if (ev->data2 != INT32_MAX) joyxmove[3][i] = ev->data2; if (ev->data2 != INT32_MAX) joyxmove[3][i] = ev->data2;
if (ev->data3 != INT32_MAX) joyymove[3][i] = ev->data3; if (ev->data3 != INT32_MAX) joyymove[3][i] = ev->data3;
@@ -933,7 +931,7 @@ void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT8 color)
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS); I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS);
if (cv_gamepadled[playernum].value == 0 || (window_notinfocus && cv_gamepadledifunfocused.value == 0) if (cv_gamepadled[playernum].value == 0
|| color >= MAXTRANSLATIONS) || color >= MAXTRANSLATIONS)
{ {
return; return;
@@ -948,8 +946,6 @@ void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT8 color)
static void G_ResetPlayerGamepadIndicatorColor(INT32 playernum) static void G_ResetPlayerGamepadIndicatorColor(INT32 playernum)
{ {
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS);
if (cv_gamepadled[playernum].value == 0) if (cv_gamepadled[playernum].value == 0)
{ {
I_SetGamepadIndicatorColor(playernum, 0, 0, 255); I_SetGamepadIndicatorColor(playernum, 0, 0, 255);
@@ -994,7 +990,6 @@ void G_ResetDeviceLED(void)
static void G_ResetPlayerDeviceRumble(INT32 playernum) static void G_ResetPlayerDeviceRumble(INT32 playernum)
{ {
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS);
I_GamepadRumble(playernum, 0, 0, 0); I_GamepadRumble(playernum, 0, 0, 0);
} }
@@ -1012,7 +1007,7 @@ void G_PlayerDeviceRumble(INT32 playernum, UINT16 low_strength, UINT16 high_stre
{ {
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS); I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS);
if (cv_rumble[playernum].value == 0 || (window_notinfocus && cv_rumbleifunfocused.value == 0)) if (cv_rumble[playernum].value == 0)
{ {
return; return;
} }
+2 -4
View File
@@ -109,17 +109,15 @@ typedef enum
} gamecontrols_e; } gamecontrols_e;
// mouse values are used once // mouse values are used once
extern consvar_t cv_mousexsens, cv_mouseysens; extern consvar_t cv_mousesens, cv_mouseysens;
extern consvar_t cv_controlperkey; extern consvar_t cv_controlperkey;
extern consvar_t cv_turnsmooth[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_turnsmooth[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_rumble[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_rumble[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_rumblestrength[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_rumblestrength[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_gamepadledifunfocused;
extern consvar_t cv_rumbleifunfocused;
extern INT32 mousex, mousey; extern INT32 mousex, mousey;
extern INT32 mlooky; //mousey with mlookSensitivity
extern INT32 joyxmove[MAXSPLITSCREENPLAYERS][JOYAXISSET], joyymove[MAXSPLITSCREENPLAYERS][JOYAXISSET]; extern INT32 joyxmove[MAXSPLITSCREENPLAYERS][JOYAXISSET], joyymove[MAXSPLITSCREENPLAYERS][JOYAXISSET];
+15 -9
View File
@@ -214,7 +214,7 @@ static int comparePolygonsNoShaders(const void *p1, const void *p2)
const PolygonArrayEntry *poly2 = *(PolygonArrayEntry *const *)p2; const PolygonArrayEntry *poly2 = *(PolygonArrayEntry *const *)p2;
const GLMipmap_t *texture1 = poly1->hash & 0x80000000 ? NULL : poly1->texture; const GLMipmap_t *texture1 = poly1->hash & 0x80000000 ? NULL : poly1->texture;
const GLMipmap_t *texture2 = poly2->hash & 0x80000000 ? NULL : poly2->texture; const GLMipmap_t *texture2 = poly1->hash & 0x80000000 ? NULL : poly2->texture;
// skywalls and horizon lines must retain their order for horizon lines to work // skywalls and horizon lines must retain their order for horizon lines to work
if (!texture1 && !texture2) if (!texture1 && !texture2)
@@ -237,7 +237,7 @@ static int comparePolygonsNoShaders(const void *p1, const void *p2)
// This function organizes the geometry collected by HWR_ProcessPolygon calls into batches and uses // This function organizes the geometry collected by HWR_ProcessPolygon calls into batches and uses
// the rendering backend to draw them. // the rendering backend to draw them.
void HWR_RenderBatches(void) void HWR_RenderBatches(boolean sort)
{ {
int finalVertexWritePos = 0; // position in finalVertexArray int finalVertexWritePos = 0; // position in finalVertexArray
int finalIndexWritePos = 0; // position in finalVertexIndexArray int finalIndexWritePos = 0; // position in finalVertexIndexArray
@@ -288,10 +288,13 @@ void HWR_RenderBatches(void)
polygonArraySorted[i] = &polygonArray[i]; polygonArraySorted[i] = &polygonArray[i];
} }
// sort polygons if (sort)
PS_START_TIMING(ps_hw_batchsorttime); {
qs22j(polygonArraySorted, polygonArraySize, sizeof(PolygonArrayEntry *), (useshader ? comparePolygons : comparePolygonsNoShaders)); // sort polygons
PS_STOP_TIMING(ps_hw_batchsorttime); PS_START_TIMING(ps_hw_batchsorttime);
qs22j(polygonArraySorted, polygonArraySize, sizeof(PolygonArrayEntry *), (useshader ? comparePolygons : comparePolygonsNoShaders));
PS_STOP_TIMING(ps_hw_batchsorttime);
}
// sort order // sort order
// 1. shader // 1. shader
@@ -300,7 +303,9 @@ void HWR_RenderBatches(void)
// 4. colors + light level // 4. colors + light level
// not sure about what order of the last 2 should be, or if it even matters // not sure about what order of the last 2 should be, or if it even matters
PS_START_TIMING(ps_hw_batchdrawtime); // dont overwrite this on consecutive calls
if (!sort)
PS_START_TIMING(ps_hw_batchdrawtime);
currentShader = polygonArraySorted[0]->shader; currentShader = polygonArraySorted[0]->shader;
currentTexture = polygonArraySorted[0]->texture; currentTexture = polygonArraySorted[0]->texture;
@@ -391,7 +396,7 @@ void HWR_RenderBatches(void)
nextSurfaceInfo = nextEntry->surf; nextSurfaceInfo = nextEntry->surf;
if (nextPolyFlags & PF_NoTexture) if (nextPolyFlags & PF_NoTexture)
nextTexture = NULL; nextTexture = 0;
if (useshader && currentShader != nextShader) if (useshader && currentShader != nextShader)
{ {
@@ -495,7 +500,8 @@ void HWR_RenderBatches(void)
polygonArraySize = 0; polygonArraySize = 0;
unsortedVertexArraySize = 0; unsortedVertexArraySize = 0;
PS_STOP_TIMING(ps_hw_batchdrawtime); if (!sort)
PS_STOP_TIMING(ps_hw_batchdrawtime);
} }
#endif // HWRENDER #endif // HWRENDER
+1 -1
View File
@@ -37,7 +37,7 @@ typedef struct
void HWR_StartBatching(void); void HWR_StartBatching(void);
void HWR_SetCurrentTexture(GLMipmap_t *texture); void HWR_SetCurrentTexture(GLMipmap_t *texture);
void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, int shader, boolean horizonSpecial); void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, int shader, boolean horizonSpecial);
void HWR_RenderBatches(void); void HWR_RenderBatches(boolean sort);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
@@ -15,6 +15,8 @@
#ifdef HWRENDER #ifdef HWRENDER
#include <unordered_set>
#include "hw_main.h" #include "hw_main.h"
#include "hw_glob.h" #include "hw_glob.h"
#include "hw_gl.h" #include "hw_gl.h"
@@ -98,7 +100,7 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm
position = 0; position = 0;
} }
position = max(((position * scale_y) + (FRACUNIT/2)) >> FRACBITS, 0); position = std::max(((position * scale_y) + (FRACUNIT/2)) >> FRACBITS, 0);
if (position + count >= pblockheight) if (position + count >= pblockheight)
count = pblockheight - position; count = pblockheight - position;
@@ -162,7 +164,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap,
fixed_t xfrac, xfracstep; fixed_t xfrac, xfracstep;
fixed_t yfracstep, scale_y; fixed_t yfracstep, scale_y;
const column_t *patchcol; const column_t *patchcol;
UINT8 *block = (UINT8 *)(mipmap->data); UINT8 *block = static_cast<UINT8 *>(mipmap->data);
INT32 bpp; INT32 bpp;
INT32 blockmodulo; INT32 blockmodulo;
RGBA_t *palette; RGBA_t *palette;
@@ -212,7 +214,7 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap,
fixed_t xfrac, xfracstep; fixed_t xfrac, xfracstep;
fixed_t yfracstep, scale_y; fixed_t yfracstep, scale_y;
const column_t *patchcol; const column_t *patchcol;
UINT8 *block = (UINT8 *)(mipmap->data); UINT8 *block = static_cast<UINT8 *>(mipmap->data);
INT32 bpp; INT32 bpp;
INT32 blockmodulo; INT32 blockmodulo;
INT32 width, height; INT32 width, height;
@@ -288,7 +290,7 @@ static UINT8 *MakeBlock(GLMipmap_t *glMipmap)
INT32 blocksize = (glMipmap->width * glMipmap->height); INT32 blocksize = (glMipmap->width * glMipmap->height);
bpp = format2bpp(glMipmap->format); bpp = format2bpp(glMipmap->format);
block = (UINT8 *)(Z_Malloc(blocksize*bpp, PU_HWRCACHE, &(glMipmap->data))); block = static_cast<UINT8 *>(Z_Malloc(blocksize*bpp, PU_HWRCACHE, &(glMipmap->data)));
switch (bpp) switch (bpp)
{ {
@@ -325,7 +327,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe
texture = textures[texnum]; texture = textures[texnum];
gltex->mipmap.flags = TF_CHROMAKEYED | TF_WRAPXY; gltex->mipmap.flags = TF_CHROMAKEYED | TF_WRAPXY;
gltex->mipmap.format = (GLTextureFormat_t)(textureformat); gltex->mipmap.format = static_cast<GLTextureFormat_t>(textureformat);
// hack the Legacy skies.. // hack the Legacy skies..
if (UNLIKELY(memcmp(texture->name, "SKY", 3) == 0 && if (UNLIKELY(memcmp(texture->name, "SKY", 3) == 0 &&
@@ -344,7 +346,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe
colormap += COLORMAP_REMAPOFFSET; colormap += COLORMAP_REMAPOFFSET;
#endif #endif
gltex->mipmap.colormap = (GLColormap_t *)(Z_Calloc(sizeof(*gltex->mipmap.colormap), PU_HWRPATCHCOLMIPMAP, NULL)); gltex->mipmap.colormap = static_cast<GLColormap_t *>(Z_Calloc(sizeof(*gltex->mipmap.colormap), PU_HWRPATCHCOLMIPMAP, NULL));
gltex->mipmap.colormap->source = colormap; gltex->mipmap.colormap->source = colormap;
memcpy(gltex->mipmap.colormap->data, colormap, 256 * sizeof(UINT8)); memcpy(gltex->mipmap.colormap->data, colormap, 256 * sizeof(UINT8));
@@ -377,7 +379,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe
// Composite the columns together. // Composite the columns together.
for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++) for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++)
{ {
pdata = (UINT8 *)(W_CacheLumpNumPwad(patch->wad, patch->lump, PU_LEVEL)); pdata = static_cast<UINT8 *>(W_CacheLumpNumPwad(patch->wad, patch->lump, PU_LEVEL));
realpatch = (softwarepatch_t *)pdata; realpatch = (softwarepatch_t *)pdata;
HWR_DrawTexturePatchInCache(&gltex->mipmap, blockwidth, blockheight, texture, patch, realpatch); HWR_DrawTexturePatchInCache(&gltex->mipmap, blockwidth, blockheight, texture, patch, realpatch);
@@ -413,7 +415,7 @@ void HWR_MakePatch(const patch_t *patch, GLPatch_t *glPatch, GLMipmap_t *glMipma
glMipmap->flags = 0; glMipmap->flags = 0;
// setup the texture info // setup the texture info
glMipmap->format = (GLTextureFormat_t)(patchformat); glMipmap->format = static_cast<GLTextureFormat_t>(patchformat);
glPatch->max_s = (float)patch->width / (float)glMipmap->width; glPatch->max_s = (float)patch->width / (float)glMipmap->width;
glPatch->max_t = (float)patch->height / (float)glMipmap->height; glPatch->max_t = (float)patch->height / (float)glMipmap->height;
@@ -455,7 +457,7 @@ static void HWR_FreeTextureData(patch_t *patch)
if (!patch || !patch->hardware) if (!patch || !patch->hardware)
return; return;
glPatch = (GLPatch_t *)(patch->hardware); glPatch = static_cast<GLPatch_t *>(patch->hardware);
if (vid.glstate == VID_GL_LIBRARY_LOADED) if (vid.glstate == VID_GL_LIBRARY_LOADED)
GL_DeleteTexture(glPatch->mipmap); GL_DeleteTexture(glPatch->mipmap);
@@ -471,7 +473,7 @@ void HWR_FreeTexture(patch_t *patch)
if (patch->hardware) if (patch->hardware)
{ {
GLPatch_t *glPatch = (GLPatch_t *)(patch->hardware); GLPatch_t *glPatch = static_cast<GLPatch_t *>(patch->hardware);
HWR_FreeTextureColormaps(patch); HWR_FreeTextureColormaps(patch);
@@ -497,7 +499,7 @@ static void HWR_FreeTextureColormaps(patch_t *patch)
if (!patch) if (!patch)
return; return;
pat = (GLPatch_t *)(patch->hardware); pat = static_cast<GLPatch_t *>(patch->hardware);
if (!pat) if (!pat)
return; return;
@@ -612,20 +614,25 @@ void HWR_FreeMapTextures(void)
gl_numtextures = 0; gl_numtextures = 0;
} }
#define NAME flatcheck
#define KEY_TY UINT32
#define HASH_FN vt_hash_integer
#define CMPR_FN vt_cmpr_integer
#include "../verstable.h"
static void HWR_PrecacheLevelFlats(void) static void HWR_PrecacheLevelFlats(void)
{ {
// lookup for flats that may´ve been already loaded // lookup for flats that may´ve been already loaded
flatcheck flatpresent; // too lazy to make a hashtable or smth so unordered set will do :carbuncle:
flatcheck_init(&flatpresent); std::unordered_set<UINT32> flatpresent;
lumpnum_t lump;
size_t i, j; size_t i, j;
INT32 k; INT32 k;
auto load_flat = [&](lumpnum_t lump, boolean noencoremap)
{
// flat already loaded?
if (flatpresent.count(lump) == 0)
{
HWR_GetFlat(lump, noencoremap);
flatpresent.insert(lump);
}
};
// special case for encore // special case for encore
#ifdef GLENCORE #ifdef GLENCORE
if (encoremap) if (encoremap)
@@ -642,24 +649,16 @@ static void HWR_PrecacheLevelFlats(void)
const INT32 pic = ceiling ? sec->ceilingpic : sec->floorpic; const INT32 pic = ceiling ? sec->ceilingpic : sec->floorpic;
const levelflat_t *levelflat = &levelflats[pic]; const levelflat_t *levelflat = &levelflats[pic];
lump = levelflat->lumpnum;
if (flatcheck_is_end(flatcheck_get(&flatpresent, levelflat->lumpnum))) load_flat(lump, R_NoEncore(sec, ceiling));
{
HWR_GetFlat(levelflat->lumpnum, R_NoEncore(sec, ceiling));
flatcheck_insert(&flatpresent, levelflat->lumpnum);
}
if (levelflat->speed) // is it an animated flat ? if (levelflat->speed) // is it an animated flat ?
{ {
// start from 0, occasionally basenumlump != flat->lumpnum // start from 0, occasionally basenumlump != flat->lumpnum
for (k = 0; k < levelflat->numpics; k++) for (k = 0; k < levelflat->numpics; k++)
{ {
lumpnum_t lump = levelflat->baselumpnum + k; load_flat(levelflat->baselumpnum + k, R_NoEncore(sec, ceiling));
if (flatcheck_is_end(flatcheck_get(&flatpresent, lump)))
{
HWR_GetFlat(lump, R_NoEncore(sec, ceiling));
flatcheck_insert(&flatpresent, lump);
}
} }
} }
} }
@@ -673,30 +672,20 @@ static void HWR_PrecacheLevelFlats(void)
for (i = 0; i < numlevelflats; i++) for (i = 0; i < numlevelflats; i++)
{ {
const levelflat_t *levelflat = &levelflats[i]; const levelflat_t *levelflat = &levelflats[i];
lump = levelflat->lumpnum;
if (flatcheck_is_end(flatcheck_get(&flatpresent, levelflat->lumpnum))) load_flat(lump, false);
{
HWR_GetFlat(levelflat->lumpnum, false);
flatcheck_insert(&flatpresent, levelflat->lumpnum);
}
if (levelflat->speed) // is it an animated flat ? if (levelflat->speed) // is it an animated flat ?
{ {
// start from 0, occasionally basenumlump != flat->lumpnum // start from 0, occasionally basenumlump != flat->lumpnum
for (k = 0; k < levelflat->numpics; k++) for (k = 0; k < levelflat->numpics; k++)
{ {
lumpnum_t lump = levelflat->baselumpnum + k; load_flat(levelflat->baselumpnum + k, false);
if (flatcheck_is_end(flatcheck_get(&flatpresent, lump)))
{
HWR_GetFlat(lump, false);
flatcheck_insert(&flatpresent, lump);
}
} }
} }
} }
} }
flatcheck_cleanup(&flatpresent);
} }
static void HWR_PrecacheLevelTextures(void) static void HWR_PrecacheLevelTextures(void)
@@ -706,7 +695,7 @@ static void HWR_PrecacheLevelTextures(void)
size_t i, j, f; size_t i, j, f;
INT32 h; INT32 h;
texturepresent = (char *)(calloc(gl_numtextures, sizeof(*texturepresent))); texturepresent = static_cast<char *>(calloc(gl_numtextures, sizeof(*texturepresent)));
if (texturepresent == NULL) if (texturepresent == NULL)
I_Error("%s: Out of memory looking up textures", "HWR_PrecacheLevel"); I_Error("%s: Out of memory looking up textures", "HWR_PrecacheLevel");
@@ -881,7 +870,7 @@ void HWR_LoadMapTextures(size_t pnumtextures)
HWR_FreeMapTextures(); HWR_FreeMapTextures();
gl_numtextures = pnumtextures; gl_numtextures = pnumtextures;
gl_textures = (GLMapTextureSet_t *)(calloc(gl_numtextures, sizeof(*gl_textures))); // *2 - 1 for encore-remapped texture and another for noencore texture (unused when not in encore), see: GLMapTextureSet_t gl_textures = static_cast<GLMapTextureSet_t *>(calloc(gl_numtextures, sizeof(*gl_textures))); // *2 - 1 for encore-remapped texture and another for noencore texture (unused when not in encore), see: GLMapTextureSet_t
if (gl_textures == NULL) if (gl_textures == NULL)
I_Error("HWR_LoadMapTextures: ran out of memory for OpenGL textures. Sad!"); I_Error("HWR_LoadMapTextures: ran out of memory for OpenGL textures. Sad!");
@@ -978,7 +967,7 @@ static void HWR_CacheFlat(GLMipmap_t *glMipmap, lumpnum_t flatlumpnum)
W_ReadLump(flatlumpnum, Z_Malloc(size, PU_HWRCACHE, &glMipmap->data)); W_ReadLump(flatlumpnum, Z_Malloc(size, PU_HWRCACHE, &glMipmap->data));
#ifdef GLENCORE #ifdef GLENCORE
flat = (UINT8 *)(glMipmap->data); flat = static_cast<UINT8 *>(glMipmap->data);
for (steppy = 0; steppy < size; steppy++) for (steppy = 0; steppy < size; steppy++)
{ {
if (flat[steppy] == HWR_PATCHES_CHROMAKEY_COLORINDEX) if (flat[steppy] == HWR_PATCHES_CHROMAKEY_COLORINDEX)
@@ -1022,7 +1011,7 @@ void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap)
if (!noencoremap && encoremap) if (!noencoremap && encoremap)
colormap += COLORMAP_REMAPOFFSET; colormap += COLORMAP_REMAPOFFSET;
#endif #endif
glMipmap->colormap = (GLColormap_t *)(Z_Calloc(sizeof(*glMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL)); glMipmap->colormap = static_cast<GLColormap_t *>(Z_Calloc(sizeof(*glMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL));
glMipmap->colormap->source = colormap; glMipmap->colormap->source = colormap;
memcpy(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); memcpy(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8));
} }
@@ -1046,7 +1035,7 @@ void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap)
// --------------------+ // --------------------+
static void HWR_LoadPatchMipmap(patch_t *patch, GLMipmap_t *glMipmap) static void HWR_LoadPatchMipmap(patch_t *patch, GLMipmap_t *glMipmap)
{ {
GLPatch_t *glPatch = (GLPatch_t *)(patch->hardware); GLPatch_t *glPatch = static_cast<GLPatch_t *>(patch->hardware);
if (!glMipmap->downloaded) if (!glMipmap->downloaded)
{ {
@@ -1067,7 +1056,7 @@ static void HWR_LoadPatchMipmap(patch_t *patch, GLMipmap_t *glMipmap)
// ----------------------+ // ----------------------+
static void HWR_UpdatePatchMipmap(patch_t *patch, GLMipmap_t *glMipmap) static void HWR_UpdatePatchMipmap(patch_t *patch, GLMipmap_t *glMipmap)
{ {
GLPatch_t *glPatch = (GLPatch_t *)(patch->hardware); GLPatch_t *glPatch = static_cast<GLPatch_t *>(patch->hardware);
HWR_MakePatch(patch, glPatch, glMipmap, true); HWR_MakePatch(patch, glPatch, glMipmap, true);
// If hardware does not have the texture, then call GL_SetTexture to upload it // If hardware does not have the texture, then call GL_SetTexture to upload it
@@ -1103,7 +1092,7 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap)
if (!patch->hardware) if (!patch->hardware)
Patch_CreateGL(patch); Patch_CreateGL(patch);
glPatch = (GLPatch_t *)(patch->hardware); glPatch = static_cast<GLPatch_t *>(patch->hardware);
// Blatant hack for encore colormapping aside... // Blatant hack for encore colormapping aside...
if (colormap == colormaps || colormap == NULL || colormap == (const UINT8*)(COLORMAP_REMAPOFFSET)) if (colormap == colormaps || colormap == NULL || colormap == (const UINT8*)(COLORMAP_REMAPOFFSET))
@@ -1139,12 +1128,12 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap)
// (it have a liste of mipmap) // (it have a liste of mipmap)
// this malloc is cleared in HWR_FreeColormapCache // this malloc is cleared in HWR_FreeColormapCache
// (...) unfortunately z_malloc fragment alot the memory :(so malloc is better // (...) unfortunately z_malloc fragment alot the memory :(so malloc is better
newMipmap = (GLMipmap_t *)(calloc(1, sizeof (*newMipmap))); newMipmap = static_cast<GLMipmap_t *>(calloc(1, sizeof (*newMipmap)));
if (newMipmap == NULL) if (newMipmap == NULL)
I_Error("%s: Out of memory", "HWR_GetMappedPatch"); I_Error("%s: Out of memory", "HWR_GetMappedPatch");
glMipmap->nextcolormap = newMipmap; glMipmap->nextcolormap = newMipmap;
newMipmap->colormap = (GLColormap_t *)(Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL)); newMipmap->colormap = static_cast<GLColormap_t *>(Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL));
newMipmap->colormap->source = colormap; newMipmap->colormap->source = colormap;
memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8));
@@ -1167,7 +1156,7 @@ patch_t *HWR_GetCachedGLPatchPwad(UINT16 wadnum, UINT16 lumpnum)
{ {
void *ptr = Z_Calloc(sizeof(patch_t), PU_PATCH, &lumpcache[lumpnum]); void *ptr = Z_Calloc(sizeof(patch_t), PU_PATCH, &lumpcache[lumpnum]);
Patch_Create(NULL, 0, ptr); Patch_Create(NULL, 0, ptr);
Patch_AllocateHardwarePatch((patch_t *)(ptr)); Patch_AllocateHardwarePatch(static_cast<patch_t *>(ptr));
} }
return (patch_t *)(lumpcache[lumpnum]); return (patch_t *)(lumpcache[lumpnum]);
@@ -1184,7 +1173,7 @@ static void HWR_DrawFadeMaskInCache(GLMipmap_t *mipmap, INT32 pblockwidth, INT32
{ {
INT32 i,j; INT32 i,j;
fixed_t posx, posy, stepx, stepy; fixed_t posx, posy, stepx, stepy;
UINT8 *block = (UINT8 *)(mipmap->data); // places the data directly into here UINT8 *block = static_cast<UINT8 *>(mipmap->data); // places the data directly into here
UINT8 *flat; UINT8 *flat;
UINT8 *dest, *src, texel; UINT8 *dest, *src, texel;
RGBA_t col; RGBA_t col;
@@ -1340,7 +1329,7 @@ void HWR_SetPalette(RGBA_t *palette)
static void HWR_SetPaletteLookup(RGBA_t *palette) static void HWR_SetPaletteLookup(RGBA_t *palette)
{ {
int r, g, b; int r, g, b;
UINT8 *lut = (UINT8 *)(Z_Malloc( UINT8 *lut = static_cast<UINT8 *>(Z_Malloc(
HWR_PALETTE_LUT_SIZE*HWR_PALETTE_LUT_SIZE*HWR_PALETTE_LUT_SIZE*sizeof(UINT8), HWR_PALETTE_LUT_SIZE*HWR_PALETTE_LUT_SIZE*HWR_PALETTE_LUT_SIZE*sizeof(UINT8),
PU_STATIC, NULL)); PU_STATIC, NULL));
#define STEP_SIZE (256/HWR_PALETTE_LUT_SIZE) #define STEP_SIZE (256/HWR_PALETTE_LUT_SIZE)
@@ -1385,7 +1374,7 @@ void HWR_SetMapPalette(void)
if (palsize < 768) // 256 * 3 if (palsize < 768) // 256 * 3
I_Error("HWR_SetMapPalette: A programmer assumed palette lumps are at least 768 bytes long, but apparently this was a wrong assumption!\n"); I_Error("HWR_SetMapPalette: A programmer assumed palette lumps are at least 768 bytes long, but apparently this was a wrong assumption!\n");
RGB_data = (UINT8 *)(W_CacheLumpNum(lumpnum, PU_CACHE)); RGB_data = static_cast<UINT8 *>(W_CacheLumpNum(lumpnum, PU_CACHE));
// we got the RGB palette now, but we need it in RGBA format. // we got the RGB palette now, but we need it in RGBA format.
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
{ {
@@ -1420,7 +1409,7 @@ static UINT32 HWR_CreateLightTable(UINT8 *lighttable)
{ {
UINT32 i, id; UINT32 i, id;
RGBA_t *palette = HWR_GetTexturePalette(); RGBA_t *palette = HWR_GetTexturePalette();
RGBA_t *hw_lighttable = (RGBA_t *)(Z_Malloc(256 * 32 * sizeof(RGBA_t), PU_STATIC, NULL)); RGBA_t *hw_lighttable = static_cast<RGBA_t *>(Z_Malloc(256 * 32 * sizeof(RGBA_t), PU_STATIC, NULL));
// To make the palette index -> RGBA mapping easier for the shader, // To make the palette index -> RGBA mapping easier for the shader,
// the hardware lighttable is composed of RGBA colors instead of palette indices. // the hardware lighttable is composed of RGBA colors instead of palette indices.
+1 -1
View File
@@ -335,7 +335,7 @@ angle_t gld_FrustumAngle(angle_t tiltangle)
floatangle = 2.0 + (45.0 + ((double)tilt / 1.9)) * clipfov / 90.0; floatangle = 2.0 + (45.0 + ((double)tilt / 1.9)) * clipfov / 90.0;
if (floatangle >= 180.0) if (floatangle >= 180.0)
return 0xffffffff; return 0xffffffff;
a1 = (angle_t)lrint(ANG1 * floatangle); a1 = (angle_t)xs_CRoundToInt(ANG1 * floatangle);
return a1; return a1;
} }
+1 -1
View File
@@ -54,7 +54,7 @@ struct GLMipmap_s
UINT16 width, height; UINT16 width, height;
UINT32 downloaded; // The GPU has this texture. UINT32 downloaded; // The GPU has this texture.
struct GLMipmap_s *nextcolormap; struct GLMipmap_s *nextcolormap;
struct GLColormap_s *colormap; struct GLColormap_s *colormap;
}; };
typedef struct GLMipmap_s GLMipmap_t; typedef struct GLMipmap_s GLMipmap_t;
+7 -7
View File
@@ -222,7 +222,7 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p
if (alphalevel) if (alphalevel)
{ {
FSurfaceInfo Surf = {}; FSurfaceInfo Surf;
Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff; Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff;
switch (alphalevel) switch (alphalevel)
@@ -385,7 +385,7 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale,
// clip it since it is used for bunny scroll in doom I // clip it since it is used for bunny scroll in doom I
if (alphalevel) if (alphalevel)
{ {
FSurfaceInfo Surf = {}; FSurfaceInfo Surf;
Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff; Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff;
switch (alphalevel) switch (alphalevel)
@@ -490,7 +490,7 @@ void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum)
void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength) void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength)
{ {
FOutVector v[4]; FOutVector v[4];
FSurfaceInfo Surf = {}; FSurfaceInfo Surf;
FBITFIELD poly_flags = PF_NoTexture|PF_Modulated|PF_NoDepthTest; FBITFIELD poly_flags = PF_NoTexture|PF_Modulated|PF_NoDepthTest;
v[0].x = v[3].x = -1.0f; v[0].x = v[3].x = -1.0f;
@@ -543,7 +543,7 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength)
void HWR_DrawConsoleBack(UINT32 color, INT32 height) void HWR_DrawConsoleBack(UINT32 color, INT32 height)
{ {
FOutVector v[4]; FOutVector v[4];
FSurfaceInfo Surf = {}; FSurfaceInfo Surf;
// setup some neat-o translucency effect // setup some neat-o translucency effect
if (!height) //cool hack 0 height is full height if (!height) //cool hack 0 height is full height
@@ -598,7 +598,7 @@ void HWR_drawAMline(const fline_t *fl, INT32 color)
void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color) void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color)
{ {
FOutVector v[4]; FOutVector v[4];
FSurfaceInfo Surf = {}; FSurfaceInfo Surf;
float fx, fy, fw, fh, fwait = 0; float fx, fy, fw, fh, fwait = 0;
RGBA_t *palette; RGBA_t *palette;
@@ -702,7 +702,7 @@ void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color)
void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 options) void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 options)
{ {
FOutVector v[4]; FOutVector v[4];
FSurfaceInfo Surf = {}; FSurfaceInfo Surf;
float fx, fy, fw, fh; float fx, fy, fw, fh;
if (w < 0 || h < 0) if (w < 0 || h < 0)
@@ -820,7 +820,7 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32
void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
{ {
FOutVector v[4]; FOutVector v[4];
FSurfaceInfo Surf = {}; FSurfaceInfo Surf;
float fx, fy, fw, fh; float fx, fy, fw, fh;
if (w < 0 || h < 0) if (w < 0 || h < 0)
-3
View File
@@ -80,9 +80,6 @@ UINT32 GL_CreateLightTable(RGBA_t *hw_lighttable);
void GL_ClearLightTables(void); void GL_ClearLightTables(void);
void GL_SetScreenPalette(RGBA_t *palette); void GL_SetScreenPalette(RGBA_t *palette);
void GL_Draw2DModel(model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex,
FTransform *pos, float hscale, float vscale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
#endif #endif
+219 -257
View File
@@ -101,8 +101,7 @@ sector_t *gl_backsector = NULL;
static constexpr float clipping_distances[] = {1024.0f, 2048.0f, 4096.0f, 6144.0f, 8192.0f, 12288.0f, 16384.0f}; static constexpr float clipping_distances[] = {1024.0f, 2048.0f, 4096.0f, 6144.0f, 8192.0f, 12288.0f, 16384.0f};
// values for bsp culling // values for bsp culling
// slightly higher than the far clipping plane to compensate for impreciseness // slightly higher than the far clipping plane to compensate for impreciseness
static constexpr INT32 bsp_culling_distances[] = { static constexpr INT32 bsp_culling_distances[] = {(1024+512)*FRACUNIT, (2048+512)*FRACUNIT, (4096+512)*FRACUNIT,
(1024+512)*FRACUNIT, (2048+512)*FRACUNIT, (4096+512)*FRACUNIT,
(6144+512)*FRACUNIT, (8192+512)*FRACUNIT, (12288+512)*FRACUNIT, (16384+512)*FRACUNIT}; (6144+512)*FRACUNIT, (8192+512)*FRACUNIT, (12288+512)*FRACUNIT, (16384+512)*FRACUNIT};
// Performance stats // Performance stats
@@ -242,6 +241,7 @@ consvar_t cv_glportals = {"gr_portals", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL,
consvar_t cv_glpaletterendering = {"gr_paletteshader", "Off", CV_CALL|CV_SAVE, CV_OnOff, CV_glpaletterendering_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_glpaletterendering = {"gr_paletteshader", "Off", CV_CALL|CV_SAVE, CV_OnOff, CV_glpaletterendering_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_glpalettedepth = {"gr_palettedepth", "16 bits", CV_SAVE|CV_CALL, glpalettedepth_cons_t, CV_glpalettedepth_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_glpalettedepth = {"gr_palettedepth", "16 bits", CV_SAVE|CV_CALL, glpalettedepth_cons_t, CV_glpalettedepth_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_glflashpal = {"gr_flashpal", "On", CV_CALL|CV_SAVE, CV_OnOff, CV_glpaletterendering_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_gltexturedepth = {"gr_texturedepth", "32 bits", CV_CALL|CV_SAVE, gltexdepth_cons_t, CV_gltextureformat_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_gltexturedepth = {"gr_texturedepth", "32 bits", CV_CALL|CV_SAVE, gltexdepth_cons_t, CV_gltextureformat_OnChange, 0, NULL, NULL, 0, 0, NULL};
@@ -550,7 +550,7 @@ static FUINT HWR_CalcSlopeLight(FUINT lightnum, pslope_t *slope, const sector_t
// Render a floor or ceiling convex polygon // Render a floor or ceiling convex polygon
static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap) static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap)
{ {
FSurfaceInfo Surf = {}; FSurfaceInfo Surf;
FOutVector *v3d; FOutVector *v3d;
polyvertex_t *pv; polyvertex_t *pv;
pslope_t *slope = NULL; pslope_t *slope = NULL;
@@ -587,11 +587,15 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
const sector_t *sec = FOFsector ? FOFsector : gl_frontsector; const sector_t *sec = FOFsector ? FOFsector : gl_frontsector;
// Get the slope pointer to simplify future code // Get the slope pointer to simplify future code
if (!isceiling && sec->f_slope) if (sec->f_slope && !isceiling)
slope = sec->f_slope; slope = sec->f_slope;
else if (isceiling && sec->c_slope) else if (sec->c_slope && isceiling)
slope = sec->c_slope; slope = sec->c_slope;
// Set fixedheight to the slope's height from our viewpoint, if we have a slope
if (slope)
fixedheight = P_GetSlopeZAt(slope, viewx, viewy);
height = FixedToFloat(fixedheight); height = FixedToFloat(fixedheight);
// Allocate plane-vertex buffer if we need to // Allocate plane-vertex buffer if we need to
@@ -639,8 +643,8 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
pv = planepoly->pts; pv = planepoly->pts;
// reference point for flat texture coord for each vertex around the polygon // reference point for flat texture coord for each vertex around the polygon
flatxref = static_cast<float>(static_cast<fixed_t>(pv->x) & (~flatflag)) / fflatsize; flatxref = (float)(((fixed_t)pv->x & (~flatflag)) / fflatsize);
flatyref = static_cast<float>(static_cast<fixed_t>(pv->y) & (~flatflag)) / fflatsize; flatyref = (float)(((fixed_t)pv->y & (~flatflag)) / fflatsize);
if (!isceiling) // it's a floor if (!isceiling) // it's a floor
{ {
@@ -657,13 +661,9 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
if (angle) // Only needs to be done if there's an altered angle if (angle) // Only needs to be done if there's an altered angle
{ {
// This needs to be done so that it scrolls in a different direction after rotation like software
tempxsow = flatxref; tempxsow = flatxref;
tempytow = flatyref; tempytow = flatyref;
anglef = ANG2RAD(InvAngle(angle)); anglef = ANG2RAD(InvAngle(angle));
// This needs to be done so everything aligns after rotation
// It would be done so that rotation is done, THEN the translation, but I couldn't get it to rotate AND scroll like software does
cosangf = cosf(anglef); cosangf = cosf(anglef);
sinangf = sinf(anglef); sinangf = sinf(anglef);
flatxref = (tempxsow * cosangf) - (tempytow * sinangf); flatxref = (tempxsow * cosangf) - (tempytow * sinangf);
@@ -683,19 +683,18 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
vert->s = (tempxsow * cosangf) - (tempytow * sinangf);\ vert->s = (tempxsow * cosangf) - (tempytow * sinangf);\
vert->t = (tempxsow * sinangf) + (tempytow * cosangf);\ vert->t = (tempxsow * sinangf) + (tempytow * cosangf);\
}\ }\
\
if (slope)\
{\
fixedheight = P_GetSlopeZAt(slope, FloatToFixed((vx)), FloatToFixed((vy)));\
height = FixedToFloat(fixedheight);\
}\
\ \
vert->x = (vx);\ vert->x = (vx);\
vert->y = height;\ vert->y = height;\
vert->z = (vy);\ vert->z = (vy);\
\ \
if (slope)\
{\
fixedheight = P_GetSlopeZAt(slope, FloatToFixed((vx)), FloatToFixed((vy)));\
vert->y = FixedToFloat(fixedheight);\
}\
} }
for (i = 0, v3d = planeVerts; i < (INT32)nrPlaneVerts; i++,v3d++, pv++) for (i = 0, v3d = planeVerts; i < (INT32)nrPlaneVerts; i++,v3d++,pv++)
SETUP3DVERT(v3d, pv->x, pv->y); SETUP3DVERT(v3d, pv->x, pv->y);
if (slope) if (slope)
@@ -808,7 +807,6 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
} }
} }
} }
#undef SETUP3DVERT
} }
#ifdef WALLSPLATS #ifdef WALLSPLATS
@@ -1368,22 +1366,23 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
// x offset the texture // x offset the texture
const fixed_t texturehpeg = gl_sidedef->textureoffset + gl_curline->offset; const fixed_t texturehpeg = gl_sidedef->textureoffset + gl_curline->offset;
const float cliplow = static_cast<float>(texturehpeg); const float cliplow = (float)texturehpeg;
const float cliphigh = static_cast<float>(texturehpeg) + static_cast<float>(gl_curline->length); const float cliphigh = ((float)texturehpeg + (float)gl_curline->length);
FUINT lightnum = gl_frontsector->lightlevel; FUINT lightnum = gl_frontsector->lightlevel;
extracolormap_t *colormap = gl_frontsector->extra_colormap; extracolormap_t *colormap = gl_frontsector->extra_colormap;
lightnum = HWR_CalcWallLight(lightnum, gl_curline, colormap); lightnum = HWR_CalcWallLight(lightnum, gl_curline, colormap);
FSurfaceInfo Surf = {}; FSurfaceInfo Surf;
Surf.PolyColor.s.alpha = 255; if (gl_frontsector)
Surf.PolyColor.s.alpha = 255;
const INT32 gl_midtexture = R_GetTextureNum(gl_sidedef->midtexture); const INT32 gl_midtexture = R_GetTextureNum(gl_sidedef->midtexture);
GLMapTexture_t *glTex = NULL; GLMapTexture_t *glTex = NULL;
static constexpr float FLOATMAX = static_cast<float>(INT32_MAX) / static_cast<float>(FRACUNIT); static constexpr float FLOATMAX = (float)INT32_MAX / (float)FRACUNIT;
static constexpr float FLOATMIN = static_cast<float>(INT32_MIN) / static_cast<float>(FRACUNIT); static constexpr float FLOATMIN = (float)INT32_MIN / (float)FRACUNIT;
// two sided line // two sided line
if (gl_backsector) if (gl_backsector)
@@ -1496,8 +1495,8 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
glTex = HWR_GetTexture(gl_toptexture, noencore); glTex = HWR_GetTexture(gl_toptexture, noencore);
wallVerts[3].t = wallVerts[2].t = static_cast<float>(texturevpeg) * glTex->scaleY; wallVerts[3].t = wallVerts[2].t = texturevpeg * glTex->scaleY;
wallVerts[0].t = wallVerts[1].t = static_cast<float>(texturevpeg + gl_frontsector->ceilingheight - gl_backsector->ceilingheight) * glTex->scaleY; wallVerts[0].t = wallVerts[1].t = (texturevpeg + gl_frontsector->ceilingheight - gl_backsector->ceilingheight) * glTex->scaleY;
wallVerts[0].s = wallVerts[3].s = cliplow * glTex->scaleX; wallVerts[0].s = wallVerts[3].s = cliplow * glTex->scaleX;
wallVerts[2].s = wallVerts[1].s = cliphigh * glTex->scaleX; wallVerts[2].s = wallVerts[1].s = cliphigh * glTex->scaleX;
@@ -1505,23 +1504,23 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
if (!(gl_linedef->flags & ML_EFFECT1)) if (!(gl_linedef->flags & ML_EFFECT1))
{ {
// Unskewed // Unskewed
wallVerts[3].t -= static_cast<float>(worldtop - gl_frontsector->ceilingheight) * glTex->scaleY; wallVerts[3].t -= (worldtop - gl_frontsector->ceilingheight) * glTex->scaleY;
wallVerts[2].t -= static_cast<float>(worldtopslope - gl_frontsector->ceilingheight) * glTex->scaleY; wallVerts[2].t -= (worldtopslope - gl_frontsector->ceilingheight) * glTex->scaleY;
wallVerts[0].t -= static_cast<float>(worldhigh - gl_backsector->ceilingheight) * glTex->scaleY; wallVerts[0].t -= (worldhigh - gl_backsector->ceilingheight) * glTex->scaleY;
wallVerts[1].t -= static_cast<float>(worldhighslope - gl_backsector->ceilingheight) * glTex->scaleY; wallVerts[1].t -= (worldhighslope - gl_backsector->ceilingheight) * glTex->scaleY;
} }
else if (gl_linedef->flags & ML_DONTPEGTOP) else if (gl_linedef->flags & ML_DONTPEGTOP)
{ {
// Skewed by top // Skewed by top
wallVerts[0].t = static_cast<float>(texturevpeg + (worldtop - worldhigh)) * glTex->scaleY; wallVerts[0].t = (texturevpeg + (worldtop - worldhigh)) * glTex->scaleY;
wallVerts[1].t = static_cast<float>(texturevpeg + (worldtopslope - worldhighslope)) * glTex->scaleY; wallVerts[1].t = (texturevpeg + (worldtopslope - worldhighslope)) * glTex->scaleY;
} }
else else
{ {
// Skewed by bottom // Skewed by bottom
wallVerts[0].t = wallVerts[1].t = static_cast<float>(texturevpeg + (worldtop - worldhigh)) * glTex->scaleY; wallVerts[0].t = wallVerts[1].t = (texturevpeg + (worldtop - worldhigh)) * glTex->scaleY;
wallVerts[3].t = wallVerts[0].t - static_cast<float>(worldtop - worldhigh) * glTex->scaleY; wallVerts[3].t = wallVerts[0].t - (worldtop - worldhigh) * glTex->scaleY;
wallVerts[2].t = wallVerts[1].t - static_cast<float>(worldtopslope - worldhighslope) * glTex->scaleY; wallVerts[2].t = wallVerts[1].t - (worldtopslope - worldhighslope) * glTex->scaleY;
} }
// set top/bottom coords // set top/bottom coords
@@ -1558,8 +1557,8 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
glTex = HWR_GetTexture(gl_bottomtexture, noencore); glTex = HWR_GetTexture(gl_bottomtexture, noencore);
wallVerts[3].t = wallVerts[2].t = static_cast<float>(texturevpeg * glTex->scaleY); wallVerts[3].t = wallVerts[2].t = texturevpeg * glTex->scaleY;
wallVerts[0].t = wallVerts[1].t = static_cast<float>(texturevpeg + (gl_backsector->floorheight - gl_frontsector->floorheight)) * glTex->scaleY; wallVerts[0].t = wallVerts[1].t = (texturevpeg + (gl_backsector->floorheight - gl_frontsector->floorheight)) * glTex->scaleY;
wallVerts[0].s = wallVerts[3].s = cliplow * glTex->scaleX; wallVerts[0].s = wallVerts[3].s = cliplow * glTex->scaleX;
wallVerts[2].s = wallVerts[1].s = cliphigh * glTex->scaleX; wallVerts[2].s = wallVerts[1].s = cliphigh * glTex->scaleX;
@@ -1567,22 +1566,22 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
if (!(gl_linedef->flags & ML_EFFECT1)) if (!(gl_linedef->flags & ML_EFFECT1))
{ {
// Unskewed // Unskewed
wallVerts[0].t -= static_cast<float>(worldbottom - gl_frontsector->floorheight) * glTex->scaleY; wallVerts[0].t -= (worldbottom - gl_frontsector->floorheight) * glTex->scaleY;
wallVerts[1].t -= static_cast<float>(worldbottomslope - gl_frontsector->floorheight) * glTex->scaleY; wallVerts[1].t -= (worldbottomslope - gl_frontsector->floorheight) * glTex->scaleY;
wallVerts[3].t -= static_cast<float>(worldlow - gl_backsector->floorheight) * glTex->scaleY; wallVerts[3].t -= (worldlow - gl_backsector->floorheight) * glTex->scaleY;
wallVerts[2].t -= static_cast<float>(worldlowslope - gl_backsector->floorheight) * glTex->scaleY; wallVerts[2].t -= (worldlowslope - gl_backsector->floorheight) * glTex->scaleY;
} }
else if (gl_linedef->flags & ML_DONTPEGBOTTOM) else if (gl_linedef->flags & ML_DONTPEGBOTTOM)
{ {
// Skewed by bottom // Skewed by bottom
wallVerts[0].t = wallVerts[1].t = static_cast<float>(texturevpeg + (worldlow - worldbottom)) * glTex->scaleY; wallVerts[0].t = wallVerts[1].t = (texturevpeg + (worldlow - worldbottom)) * glTex->scaleY;
wallVerts[2].t = wallVerts[1].t - static_cast<float>(worldlowslope - worldbottomslope) * glTex->scaleY; wallVerts[2].t = wallVerts[1].t - (worldlowslope - worldbottomslope) * glTex->scaleY;
} }
else else
{ {
// Skewed by top // Skewed by top
wallVerts[0].t = static_cast<float>(texturevpeg + (worldlow - worldbottom)) * glTex->scaleY; wallVerts[0].t = (texturevpeg + (worldlow - worldbottom)) * glTex->scaleY;
wallVerts[1].t = static_cast<float>(texturevpeg + (worldlowslope - worldbottomslope)) * glTex->scaleY; wallVerts[1].t = (texturevpeg + (worldlowslope - worldbottomslope)) * glTex->scaleY;
} }
// set top/bottom coords // set top/bottom coords
@@ -1744,13 +1743,13 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
glTex = HWR_GetTexture(gl_midtexture, noencore); glTex = HWR_GetTexture(gl_midtexture, noencore);
// Left side // Left side
wallVerts[3].t = static_cast<float>(texturevpeg * glTex->scaleY); wallVerts[3].t = texturevpeg * glTex->scaleY;
wallVerts[0].t = static_cast<float>(h - l + texturevpeg) * glTex->scaleY; wallVerts[0].t = (h - l + texturevpeg) * glTex->scaleY;
wallVerts[0].s = wallVerts[3].s = cliplow * glTex->scaleX; wallVerts[0].s = wallVerts[3].s = cliplow * glTex->scaleX;
// Right side // Right side
wallVerts[2].t = texturevpegslope * glTex->scaleY; wallVerts[2].t = texturevpegslope * glTex->scaleY;
wallVerts[1].t = static_cast<float>(hS - lS + texturevpegslope) * glTex->scaleY; wallVerts[1].t = (hS - lS + texturevpegslope) * glTex->scaleY;
wallVerts[2].s = wallVerts[1].s = cliphigh * glTex->scaleX; wallVerts[2].s = wallVerts[1].s = cliphigh * glTex->scaleX;
// set top/bottom coords // set top/bottom coords
@@ -1781,10 +1780,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
// Single sided line... Deal only with the middletexture (if one exists) // Single sided line... Deal only with the middletexture (if one exists)
if (gl_midtexture && gl_linedef->special != HORIZONSPECIAL) // Ignore horizon line for OGL if (gl_midtexture && gl_linedef->special != HORIZONSPECIAL) // Ignore horizon line for OGL
{ {
fixed_t texturevpeg;
glTex = HWR_GetTexture(gl_midtexture, noencore); glTex = HWR_GetTexture(gl_midtexture, noencore);
fixed_t texturevpeg;
// PEGGING // PEGGING
if ((gl_linedef->flags & (ML_DONTPEGBOTTOM|ML_EFFECT2)) == (ML_DONTPEGBOTTOM|ML_EFFECT2)) if ((gl_linedef->flags & (ML_DONTPEGBOTTOM|ML_EFFECT2)) == (ML_DONTPEGBOTTOM|ML_EFFECT2))
texturevpeg = gl_frontsector->floorheight + textureheight[gl_sidedef->midtexture] - gl_frontsector->ceilingheight + gl_sidedef->rowoffset; texturevpeg = gl_frontsector->floorheight + textureheight[gl_sidedef->midtexture] - gl_frontsector->ceilingheight + gl_sidedef->rowoffset;
@@ -1793,28 +1792,28 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
else else
texturevpeg = gl_sidedef->rowoffset; // top of texture at top texturevpeg = gl_sidedef->rowoffset; // top of texture at top
wallVerts[3].t = wallVerts[2].t = (static_cast<float>(texturevpeg) * glTex->scaleY); wallVerts[3].t = wallVerts[2].t = texturevpeg * glTex->scaleY;
wallVerts[0].t = wallVerts[1].t = static_cast<float>(texturevpeg + gl_frontsector->ceilingheight - gl_frontsector->floorheight) * glTex->scaleY; wallVerts[0].t = wallVerts[1].t = (texturevpeg + gl_frontsector->ceilingheight - gl_frontsector->floorheight) * glTex->scaleY;
wallVerts[0].s = wallVerts[3].s = cliplow * glTex->scaleX; wallVerts[0].s = wallVerts[3].s = cliplow * glTex->scaleX;
wallVerts[2].s = wallVerts[1].s = cliphigh * glTex->scaleX; wallVerts[2].s = wallVerts[1].s = cliphigh * glTex->scaleX;
// Texture correction for slopes // Texture correction for slopes
if (gl_linedef->flags & ML_EFFECT2) if (gl_linedef->flags & ML_EFFECT2)
{ {
wallVerts[3].t += static_cast<float>(gl_frontsector->ceilingheight - worldtop) * glTex->scaleY; wallVerts[3].t += (gl_frontsector->ceilingheight - worldtop) * glTex->scaleY;
wallVerts[2].t += static_cast<float>(gl_frontsector->ceilingheight - worldtopslope) * glTex->scaleY; wallVerts[2].t += (gl_frontsector->ceilingheight - worldtopslope) * glTex->scaleY;
wallVerts[0].t += static_cast<float>(gl_frontsector->floorheight - worldbottom) * glTex->scaleY; wallVerts[0].t += (gl_frontsector->floorheight - worldbottom) * glTex->scaleY;
wallVerts[1].t += static_cast<float>(gl_frontsector->floorheight - worldbottomslope) * glTex->scaleY; wallVerts[1].t += (gl_frontsector->floorheight - worldbottomslope) * glTex->scaleY;
} }
else if (gl_linedef->flags & ML_DONTPEGBOTTOM) else if (gl_linedef->flags & ML_DONTPEGBOTTOM)
{ {
wallVerts[3].t = wallVerts[0].t + static_cast<float>(worldbottom - worldtop) * glTex->scaleY; wallVerts[3].t = wallVerts[0].t + (worldbottom - worldtop) * glTex->scaleY;
wallVerts[2].t = wallVerts[1].t + static_cast<float>((worldbottomslope - worldtopslope)) * glTex->scaleY; wallVerts[2].t = wallVerts[1].t + ((worldbottomslope - worldtopslope)) * glTex->scaleY;
} }
else else
{ {
wallVerts[0].t = wallVerts[3].t - static_cast<float>(worldbottom - worldtop) * glTex->scaleY; wallVerts[0].t = wallVerts[3].t - (worldbottom - worldtop) * glTex->scaleY;
wallVerts[1].t = wallVerts[2].t - static_cast<float>(worldbottomslope - worldtopslope) * glTex->scaleY; wallVerts[1].t = wallVerts[2].t - (worldbottomslope - worldtopslope) * glTex->scaleY;
} }
//Set textures properly on single sided walls that are sloped //Set textures properly on single sided walls that are sloped
@@ -1871,13 +1870,12 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
//Hurdler: 3d-floors test //Hurdler: 3d-floors test
if (!gl_drawing_stencil && gl_backsector && gl_frontsector->tag != gl_backsector->tag && (gl_backsector->ffloors || gl_frontsector->ffloors)) if (!gl_drawing_stencil && gl_backsector && gl_frontsector->tag != gl_backsector->tag && (gl_backsector->ffloors || gl_frontsector->ffloors))
{ {
ffloor_t *rover; ffloor_t * rover;
fixed_t highcut = 0, lowcut = 0; fixed_t highcut = 0, lowcut = 0;
fixed_t lowcutslope = 0, highcutslope = 0; fixed_t lowcutslope = 0, highcutslope = 0;
// Used for height comparisons and etc across FOFs and slopes // Used for height comparisons and etc across FOFs and slopes
fixed_t high1, highslope1, low1, lowslope1; fixed_t high1, highslope1, low1, lowslope1;
fixed_t high2, highslope2, low2, lowslope2;
INT32 texnum; INT32 texnum;
@@ -1890,6 +1888,19 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
{ {
for (rover = gl_backsector->ffloors; rover; rover = rover->next) for (rover = gl_backsector->ffloors; rover; rover = rover->next)
{ {
boolean bothsides = false;
// Skip if it exists on both sectors.
ffloor_t * r2;
for (r2 = gl_frontsector->ffloors; r2; r2 = r2->next)
if (rover->master == r2->master)
{
bothsides = true;
break;
}
if (bothsides)
continue;
const ffloortype_e roverflags = rover->flags; const ffloortype_e roverflags = rover->flags;
if (!(roverflags & FF_EXISTS) || !(roverflags & FF_RENDERSIDES) || (roverflags & FF_INVERTSIDES)) if (!(roverflags & FF_EXISTS) || !(roverflags & FF_RENDERSIDES) || (roverflags & FF_INVERTSIDES))
@@ -1901,45 +1912,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
if ((high1 < lowcut || highslope1 < lowcutslope) || (low1 > highcut || lowslope1 > highcutslope)) if ((high1 < lowcut || highslope1 < lowcutslope) || (low1 > highcut || lowslope1 > highcutslope))
continue; continue;
ffloor_t * r2;
for (r2 = gl_frontsector->ffloors; r2; r2 = r2->next)
{
if (r2->master == rover->master) // Skip if same control line.
break;
const ffloortype_e r2flags = r2->flags;
if (!(r2flags & FF_EXISTS) || !(r2flags & FF_RENDERSIDES))
continue;
if (rover->flags & FF_EXTRA)
{
if (!(r2flags & FF_CUTEXTRA))
continue;
if (r2flags & FF_EXTRA && (r2flags & (FF_TRANSLUCENT|FF_FOG)) != (rover->flags & (FF_TRANSLUCENT|FF_FOG)))
continue;
}
else
{
if (!(r2flags & FF_CUTSOLIDS))
continue;
}
SLOPEPARAMS(*r2->t_slope, high2, highslope2, *r2->topheight)
SLOPEPARAMS(*r2->b_slope, low2, lowslope2, *r2->bottomheight)
if ((high2 < lowcut || highslope2 < lowcutslope) || (low2 > highcut || lowslope2 > highcutslope))
continue;
if ((high1 > high2 || highslope1 > highslope2) || (low1 < low2 || lowslope1 < lowslope2))
continue;
break;
}
if (r2)
continue;
side_t *side = R_GetFFloorSide(gl_curline->linedef, rover, gl_backsector); side_t *side = R_GetFFloorSide(gl_curline->linedef, rover, gl_backsector);
boolean do_texture_skew; boolean do_texture_skew;
@@ -2006,24 +1978,24 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
if (dont_peg_bottom) if (dont_peg_bottom)
texturevpeg -= (*rover->topheight - *rover->bottomheight); texturevpeg -= (*rover->topheight - *rover->bottomheight);
wallVerts[3].t = static_cast<float>((*rover->topheight - h) + texturevpeg) * glTex->scaleY; wallVerts[3].t = ((*rover->topheight - h) + texturevpeg) * glTex->scaleY;
wallVerts[2].t = static_cast<float>((*rover->topheight - hS) + texturevpeg) * glTex->scaleY; wallVerts[2].t = ((*rover->topheight - hS) + texturevpeg) * glTex->scaleY;
wallVerts[0].t = static_cast<float>((*rover->topheight - l) + texturevpeg) * glTex->scaleY; wallVerts[0].t = ((*rover->topheight - l) + texturevpeg) * glTex->scaleY;
wallVerts[1].t = static_cast<float>((*rover->topheight - lS) + texturevpeg) * glTex->scaleY; wallVerts[1].t = ((*rover->topheight - lS) + texturevpeg) * glTex->scaleY;
} }
else else
{ {
if (!dont_peg_bottom) // skew by top if (!dont_peg_bottom) // skew by top
{ {
wallVerts[3].t = wallVerts[2].t = (static_cast<float>(texturevpeg) * glTex->scaleY); wallVerts[3].t = wallVerts[2].t = texturevpeg * glTex->scaleY;
wallVerts[0].t = static_cast<float>((h - l) + texturevpeg) * glTex->scaleY; wallVerts[0].t = ((h - l) + texturevpeg) * glTex->scaleY;
wallVerts[1].t = static_cast<float>((hS - lS) + texturevpeg) * glTex->scaleY; wallVerts[1].t = ((hS - lS) + texturevpeg) * glTex->scaleY;
} }
else // skew by bottom else // skew by bottom
{ {
wallVerts[0].t = wallVerts[1].t = (static_cast<float>(texturevpeg) * glTex->scaleY); wallVerts[0].t = wallVerts[1].t = texturevpeg * glTex->scaleY;
wallVerts[3].t = wallVerts[0].t - static_cast<float>(h - l) * glTex->scaleY; wallVerts[3].t = wallVerts[0].t - (h - l) * glTex->scaleY;
wallVerts[2].t = wallVerts[1].t - static_cast<float>(hS - lS) * glTex->scaleY; wallVerts[2].t = wallVerts[1].t - (hS - lS) * glTex->scaleY;
} }
} }
@@ -2076,6 +2048,19 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
{ {
for (rover = gl_frontsector->ffloors; rover; rover = rover->next) for (rover = gl_frontsector->ffloors; rover; rover = rover->next)
{ {
boolean bothsides = false;
// Skip if it exists on both sectors.
ffloor_t * r2;
for (r2 = gl_backsector->ffloors; r2; r2 = r2->next)
if (rover->master == r2->master)
{
bothsides = true;
break;
}
if (bothsides)
continue;
const ffloortype_e roverflags = rover->flags; const ffloortype_e roverflags = rover->flags;
if (!(roverflags & FF_EXISTS) || !(roverflags & FF_RENDERSIDES) || !(roverflags & FF_ALLSIDES)) if (!(roverflags & FF_EXISTS) || !(roverflags & FF_RENDERSIDES) || !(roverflags & FF_ALLSIDES))
@@ -2087,44 +2072,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
if ((high1 < lowcut || highslope1 < lowcutslope) || (low1 > highcut || lowslope1 > highcutslope)) if ((high1 < lowcut || highslope1 < lowcutslope) || (low1 > highcut || lowslope1 > highcutslope))
continue; continue;
ffloor_t * r2;
for (r2 = gl_backsector->ffloors; r2; r2 = r2->next)
{
if (r2->master == rover->master) // Skip if same control line.
break;
const ffloortype_e r2flags = r2->flags;
if (!(r2flags & FF_EXISTS) || !(r2flags & FF_RENDERSIDES))
continue;
if (rover->flags & FF_EXTRA)
{
if (!(r2flags & FF_CUTEXTRA))
continue;
if (r2flags & FF_EXTRA && (r2flags & (FF_TRANSLUCENT|FF_FOG)) != (rover->flags & (FF_TRANSLUCENT|FF_FOG)))
continue;
}
else
{
if (!(r2flags & FF_CUTSOLIDS))
continue;
}
SLOPEPARAMS(*r2->t_slope, high2, highslope2, *r2->topheight)
SLOPEPARAMS(*r2->b_slope, low2, lowslope2, *r2->bottomheight)
if ((high2 < lowcut || highslope2 < lowcutslope) || (low2 > highcut || lowslope2 > highcutslope))
continue;
if ((high1 > high2 || highslope1 > highslope2) || (low1 < low2 || lowslope1 < lowslope2))
continue;
break;
}
if (r2)
continue;
side_t *side = R_GetFFloorSide(gl_curline->linedef, rover, gl_backsector); side_t *side = R_GetFFloorSide(gl_curline->linedef, rover, gl_backsector);
boolean do_texture_skew; boolean do_texture_skew;
@@ -2191,24 +2138,24 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
if (dont_peg_bottom) if (dont_peg_bottom)
texturevpeg -= (*rover->topheight - *rover->bottomheight); texturevpeg -= (*rover->topheight - *rover->bottomheight);
wallVerts[3].t = static_cast<float>((*rover->topheight - h) + texturevpeg) * glTex->scaleY; wallVerts[3].t = ((*rover->topheight - h) + texturevpeg) * glTex->scaleY;
wallVerts[2].t = static_cast<float>((*rover->topheight - hS) + texturevpeg) * glTex->scaleY; wallVerts[2].t = ((*rover->topheight - hS) + texturevpeg) * glTex->scaleY;
wallVerts[0].t = static_cast<float>((*rover->topheight - l) + texturevpeg) * glTex->scaleY; wallVerts[0].t = ((*rover->topheight - l) + texturevpeg) * glTex->scaleY;
wallVerts[1].t = static_cast<float>((*rover->topheight - lS) + texturevpeg) * glTex->scaleY; wallVerts[1].t = ((*rover->topheight - lS) + texturevpeg) * glTex->scaleY;
} }
else else
{ {
if (!dont_peg_bottom) // skew by top if (!dont_peg_bottom) // skew by top
{ {
wallVerts[3].t = wallVerts[2].t = (static_cast<float>(texturevpeg) * glTex->scaleY); wallVerts[3].t = wallVerts[2].t = texturevpeg * glTex->scaleY;
wallVerts[0].t = static_cast<float>((h - l) + texturevpeg) * glTex->scaleY; wallVerts[0].t = ((h - l) + texturevpeg) * glTex->scaleY;
wallVerts[1].t = static_cast<float>((hS - lS) + texturevpeg) * glTex->scaleY; wallVerts[1].t = ((hS - lS) + texturevpeg) * glTex->scaleY;
} }
else // skew by bottom else // skew by bottom
{ {
wallVerts[0].t = wallVerts[1].t = (static_cast<float>(texturevpeg) * glTex->scaleY); wallVerts[0].t = wallVerts[1].t = texturevpeg * glTex->scaleY;
wallVerts[3].t = wallVerts[0].t - static_cast<float>(h - l) * glTex->scaleY; wallVerts[3].t = wallVerts[0].t - (h - l) * glTex->scaleY;
wallVerts[2].t = wallVerts[1].t - static_cast<float>(hS - lS) * glTex->scaleY; wallVerts[2].t = wallVerts[1].t - (hS - lS) * glTex->scaleY;
} }
} }
@@ -2549,10 +2496,8 @@ static boolean HWR_CheckBBox(const fixed_t *bspcoord)
// Find the corners of the box // Find the corners of the box
// that define the edges from current viewpoint. // that define the edges from current viewpoint.
const INT32 boxpos = (viewx <= bspcoord[BOXLEFT] ? 0 : const INT32 boxpos = (viewx <= bspcoord[BOXLEFT] ? 0 : viewx < bspcoord[BOXRIGHT] ? 1 : 2) +
viewx < bspcoord[BOXRIGHT] ? 1 : 2) + (viewy >= bspcoord[BOXTOP] ? 0 : viewy > bspcoord[BOXBOTTOM] ? 4 : 8);
(viewy >= bspcoord[BOXTOP] ? 0 :
viewy > bspcoord[BOXBOTTOM] ? 4 : 8);
if (boxpos == 5) if (boxpos == 5)
return true; return true;
@@ -2672,9 +2617,8 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
INT32 flatflag; INT32 flatflag;
size_t len; size_t len;
float scrollx = 0.0f, scrolly = 0.0f; float scrollx = 0.0f, scrolly = 0.0f;
float anglef = 0.0f, cosangf = 0.0f, sinangf = 0.0f;
angle_t angle = 0; angle_t angle = 0;
FSurfaceInfo Surf = {}; FSurfaceInfo Surf;
fixed_t tempxsow, tempytow; fixed_t tempxsow, tempytow;
size_t nrPlaneVerts; size_t nrPlaneVerts;
@@ -2694,14 +2638,12 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
return; return;
} }
const sector_t *sec = FOFsector ? FOFsector : gl_frontsector;
// Allocate plane-vertex buffer if we need to // Allocate plane-vertex buffer if we need to
if (!planeVerts || nrPlaneVerts > numAllocedPlaneVerts) if (!planeVerts || nrPlaneVerts > numAllocedPlaneVerts)
{ {
numAllocedPlaneVerts = (UINT16)nrPlaneVerts; numAllocedPlaneVerts = (UINT16)nrPlaneVerts;
Z_Free(planeVerts); Z_Free(planeVerts);
Z_Malloc(numAllocedPlaneVerts * sizeof(FOutVector), PU_LEVEL, &planeVerts); Z_Malloc(numAllocedPlaneVerts * sizeof (FOutVector), PU_LEVEL, &planeVerts);
} }
height = FixedToFloat(fixedheight); height = FixedToFloat(fixedheight);
@@ -2744,51 +2686,72 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
flatxref = FixedToFloat(polysector->origVerts[0].x); flatxref = FixedToFloat(polysector->origVerts[0].x);
flatyref = FixedToFloat(polysector->origVerts[0].y); flatyref = FixedToFloat(polysector->origVerts[0].y);
flatxref = static_cast<float>(static_cast<fixed_t>(flatxref) & (~flatflag)) / fflatsize; flatxref = (float)(((fixed_t)flatxref & (~flatflag)) / fflatsize);
flatyref = static_cast<float>(static_cast<fixed_t>(flatyref) & (~flatflag)) / fflatsize; flatyref = (float)(((fixed_t)flatyref & (~flatflag)) / fflatsize);
if (!isceiling) // it's a floor // transform
v3d = planeVerts;
if (FOFsector != NULL)
{ {
scrollx = FixedToFloat(sec->floor_xoffs)/fflatsize; if (!isceiling) // it's a floor
scrolly = FixedToFloat(sec->floor_yoffs)/fflatsize; {
angle = sec->floorpic_angle; scrollx = FixedToFloat(FOFsector->floor_xoffs)/fflatsize;
scrolly = FixedToFloat(FOFsector->floor_yoffs)/fflatsize;
angle = FOFsector->floorpic_angle>>ANGLETOFINESHIFT;
}
else // it's a ceiling
{
scrollx = FixedToFloat(FOFsector->ceiling_xoffs)/fflatsize;
scrolly = FixedToFloat(FOFsector->ceiling_yoffs)/fflatsize;
angle = FOFsector->ceilingpic_angle>>ANGLETOFINESHIFT;
}
} }
else // it's a ceiling else if (gl_frontsector)
{ {
scrollx = FixedToFloat(sec->ceiling_xoffs)/fflatsize; if (!isceiling) // it's a floor
scrolly = FixedToFloat(sec->ceiling_yoffs)/fflatsize; {
angle = sec->ceilingpic_angle; scrollx = FixedToFloat(gl_frontsector->floor_xoffs)/fflatsize;
scrolly = FixedToFloat(gl_frontsector->floor_yoffs)/fflatsize;
angle = gl_frontsector->floorpic_angle>>ANGLETOFINESHIFT;
}
else // it's a ceiling
{
scrollx = FixedToFloat(gl_frontsector->ceiling_xoffs)/fflatsize;
scrolly = FixedToFloat(gl_frontsector->ceiling_yoffs)/fflatsize;
angle = gl_frontsector->ceilingpic_angle>>ANGLETOFINESHIFT;
}
} }
if (angle) // Only needs to be done if there's an altered angle if (angle) // Only needs to be done if there's an altered angle
{ {
// This needs to be done so that it scrolls in a different direction after rotation like software // This needs to be done so that it scrolls in a different direction after rotation like software
tempxsow = flatxref; tempxsow = FloatToFixed(scrollx);
tempytow = flatyref; tempytow = FloatToFixed(scrolly);
anglef = ANG2RAD(InvAngle(angle)); scrollx = (FixedToFloat(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle))));
scrolly = (FixedToFloat(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle))));
// This needs to be done so everything aligns after rotation // This needs to be done so everything aligns after rotation
// It would be done so that rotation is done, THEN the translation, but I couldn't get it to rotate AND scroll like software does // It would be done so that rotation is done, THEN the translation, but I couldn't get it to rotate AND scroll like software does
cosangf = cosf(anglef); tempxsow = FloatToFixed(flatxref);
sinangf = sinf(anglef); tempytow = FloatToFixed(flatyref);
flatxref = (tempxsow * cosangf) - (tempytow * sinangf); flatxref = (FixedToFloat(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle))));
flatyref = (tempxsow * sinangf) + (tempytow * cosangf); flatyref = (FixedToFloat(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle))));
} }
for (i = 0, v3d = planeVerts; i < (INT32)nrPlaneVerts; i++, v3d++) for (i = 0; i < (INT32)nrPlaneVerts; i++,v3d++)
{ {
// Go from the polysector's original vertex locations // Hurdler: add scrolling texture on floor/ceiling
// Means the flat is offset based on the original vertex locations v3d->s = (float)((FixedToFloat(polysector->origVerts[i].x) / fflatsize) - flatxref + scrollx); // Go from the polysector's original vertex locations
v3d->s = ((FixedToFloat(polysector->origVerts[i].x) / fflatsize) - flatxref + scrollx); v3d->t = (float)(flatyref - (FixedToFloat(polysector->origVerts[i].y) / fflatsize) + scrolly); // Means the flat is offset based on the original vertex locations
v3d->t = (flatyref - (FixedToFloat(polysector->origVerts[i].y) / fflatsize) + scrolly);
// Need to rotate before translate // Need to rotate before translate
if (angle) // Only needs to be done if there's an altered angle if (angle) // Only needs to be done if there's an altered angle
{ {
tempxsow = v3d->s; tempxsow = FloatToFixed(v3d->s);
tempytow = v3d->t; tempytow = FloatToFixed(v3d->t);
v3d->s = (tempxsow * cosangf) - (tempytow * sinangf); v3d->s = (FixedToFloat(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle))));
v3d->t = (tempxsow * sinangf) + (tempytow * cosangf); v3d->t = (FixedToFloat(-FixedMul(tempxsow, FINESINE(angle)) - FixedMul(tempytow, FINECOSINE(angle))));
} }
v3d->x = FixedToFloat(polysector->vertices[i]->x); v3d->x = FixedToFloat(polysector->vertices[i]->x);
@@ -2841,8 +2804,9 @@ static void HWR_AddPolyObjectPlanes(void)
light = R_GetPlaneLight(gl_frontsector, polyobjsector->floorheight, true); light = R_GetPlaneLight(gl_frontsector, polyobjsector->floorheight, true);
if (po_ptrs[i]->translucency > 0) if (po_ptrs[i]->translucency > 0)
{ {
FSurfaceInfo Surf = {}; FSurfaceInfo Surf;
FBITFIELD blendmode; FBITFIELD blendmode;
memset(&Surf, 0x00, sizeof(Surf));
blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf);
HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->floorpic].lumpnum, po_ptrs[i], false, polyobjsector->floorheight, HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->floorpic].lumpnum, po_ptrs[i], false, polyobjsector->floorheight,
(light == -1 ? gl_frontsector->lightlevel : *gl_frontsector->lightlist[light].lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gl_frontsector->extra_colormap : gl_frontsector->lightlist[light].extra_colormap)); (light == -1 ? gl_frontsector->lightlevel : *gl_frontsector->lightlist[light].lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gl_frontsector->extra_colormap : gl_frontsector->lightlist[light].extra_colormap));
@@ -2863,8 +2827,9 @@ static void HWR_AddPolyObjectPlanes(void)
light = R_GetPlaneLight(gl_frontsector, polyobjsector->ceilingheight, true); light = R_GetPlaneLight(gl_frontsector, polyobjsector->ceilingheight, true);
if (po_ptrs[i]->translucency > 0) if (po_ptrs[i]->translucency > 0)
{ {
FSurfaceInfo Surf = {}; FSurfaceInfo Surf;
FBITFIELD blendmode; FBITFIELD blendmode;
memset(&Surf, 0x00, sizeof(Surf));
blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf);
HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->ceilingpic].lumpnum, po_ptrs[i], true, polyobjsector->ceilingheight, HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->ceilingpic].lumpnum, po_ptrs[i], true, polyobjsector->ceilingheight,
(light == -1 ? gl_frontsector->lightlevel : *gl_frontsector->lightlist[light].lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gl_frontsector->extra_colormap : gl_frontsector->lightlist[light].extra_colormap)); (light == -1 ? gl_frontsector->lightlevel : *gl_frontsector->lightlist[light].lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gl_frontsector->extra_colormap : gl_frontsector->lightlist[light].extra_colormap));
@@ -2941,7 +2906,7 @@ static void HWR_Subsector(size_t num)
static sector_t tempsec; //SoM: 4/7/2000 static sector_t tempsec; //SoM: 4/7/2000
INT32 floorlightlevel; INT32 floorlightlevel;
INT32 ceilinglightlevel; INT32 ceilinglightlevel;
INT32 locFloorHeight = 0, locCeilingHeight = 0; INT32 locFloorHeight, locCeilingHeight;
INT32 cullFloorHeight, cullCeilingHeight; INT32 cullFloorHeight, cullCeilingHeight;
INT32 light = 0; INT32 light = 0;
extracolormap_t *floorcolormap; extracolormap_t *floorcolormap;
@@ -2987,12 +2952,11 @@ static void HWR_Subsector(size_t num)
cullFloorHeight = P_GetSectorFloorZAt (gl_frontsector, viewx, viewy); cullFloorHeight = P_GetSectorFloorZAt (gl_frontsector, viewx, viewy);
cullCeilingHeight = P_GetSectorCeilingZAt(gl_frontsector, viewx, viewy); cullCeilingHeight = P_GetSectorCeilingZAt(gl_frontsector, viewx, viewy);
locFloorHeight = P_GetSectorFloorZAt (gl_frontsector, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y);
locCeilingHeight = P_GetSectorCeilingZAt(gl_frontsector, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y);
if (gl_frontsector->ffloors) if (gl_frontsector->ffloors)
{ {
locFloorHeight = P_GetSectorFloorZAt (gl_frontsector, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y);
locCeilingHeight = P_GetSectorCeilingZAt(gl_frontsector, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y);
boolean anyMoved = gl_frontsector->moved; boolean anyMoved = gl_frontsector->moved;
if (anyMoved == false) if (anyMoved == false)
@@ -3047,7 +3011,8 @@ static void HWR_Subsector(size_t num)
{ {
HWR_GetFlat(levelflats[gl_frontsector->floorpic].lumpnum, R_NoEncore(gl_frontsector, false)); HWR_GetFlat(levelflats[gl_frontsector->floorpic].lumpnum, R_NoEncore(gl_frontsector, false));
HWR_RenderPlane(sub, &extrasubsectors[num], false, HWR_RenderPlane(sub, &extrasubsectors[num], false,
gl_frontsector->floorheight, // Hack to make things continue to work around slopes.
locFloorHeight == cullFloorHeight ? locFloorHeight : gl_frontsector->floorheight,
// We now return you to your regularly scheduled rendering. // We now return you to your regularly scheduled rendering.
PF_Occlude, floorlightlevel, levelflats[gl_frontsector->floorpic].lumpnum, NULL, 255, floorcolormap); PF_Occlude, floorlightlevel, levelflats[gl_frontsector->floorpic].lumpnum, NULL, 255, floorcolormap);
} }
@@ -3062,7 +3027,8 @@ static void HWR_Subsector(size_t num)
{ {
HWR_GetFlat(levelflats[gl_frontsector->ceilingpic].lumpnum, R_NoEncore(gl_frontsector, true)); HWR_GetFlat(levelflats[gl_frontsector->ceilingpic].lumpnum, R_NoEncore(gl_frontsector, true));
HWR_RenderPlane(sub, &extrasubsectors[num], true, HWR_RenderPlane(sub, &extrasubsectors[num], true,
gl_frontsector->ceilingheight, // Hack to make things continue to work around slopes.
locCeilingHeight == cullCeilingHeight ? locCeilingHeight : gl_frontsector->ceilingheight,
// We now return you to your regularly scheduled rendering. // We now return you to your regularly scheduled rendering.
PF_Occlude, ceilinglightlevel, levelflats[gl_frontsector->ceilingpic].lumpnum, NULL, 255, ceilingcolormap); PF_Occlude, ceilinglightlevel, levelflats[gl_frontsector->ceilingpic].lumpnum, NULL, 255, ceilingcolormap);
} }
@@ -3416,7 +3382,7 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t
{ {
float this_scale = 1.0f; float this_scale = 1.0f;
FOutVector swallVerts[4]; FOutVector swallVerts[4];
FSurfaceInfo sSurf = {}; FSurfaceInfo sSurf;
FBITFIELD blendmode = 0; FBITFIELD blendmode = 0;
fixed_t floorheight, mobjfloor; fixed_t floorheight, mobjfloor;
pslope_t *floorslope; pslope_t *floorslope;
@@ -3492,13 +3458,13 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t
if (spr->mobj && fabsf(this_scale - 1.0f) > 1.0E-36f) if (spr->mobj && fabsf(this_scale - 1.0f) > 1.0E-36f)
{ {
// Always a pixel above the floor, perfectly flat. // Always a pixel above the floor, perfectly flat.
swallVerts[0].y = swallVerts[1].y = swallVerts[2].y = swallVerts[3].y = spr->gzt - static_cast<float>(gpatch->topoffset) * this_scale - static_cast<float>(floorheight+3); swallVerts[0].y = swallVerts[1].y = swallVerts[2].y = swallVerts[3].y = spr->gzt - gpatch->topoffset * this_scale - (floorheight+3);
// Now transform the TOP vertices along the floor in the direction of the camera // Now transform the TOP vertices along the floor in the direction of the camera
swallVerts[3].x = spr->x1 + ((static_cast<float>(gpatch->height) * this_scale) + offset) * gl_viewcos; swallVerts[3].x = spr->x1 + ((gpatch->height * this_scale) + offset) * gl_viewcos;
swallVerts[2].x = spr->x2 + ((static_cast<float>(gpatch->height) * this_scale) + offset) * gl_viewcos; swallVerts[2].x = spr->x2 + ((gpatch->height * this_scale) + offset) * gl_viewcos;
swallVerts[3].z = spr->z1 + ((static_cast<float>(gpatch->height) * this_scale) + offset) * gl_viewsin; swallVerts[3].z = spr->z1 + ((gpatch->height * this_scale) + offset) * gl_viewsin;
swallVerts[2].z = spr->z2 + ((static_cast<float>(gpatch->height) * this_scale) + offset) * gl_viewsin; swallVerts[2].z = spr->z2 + ((gpatch->height * this_scale) + offset) * gl_viewsin;
} }
else else
{ {
@@ -3506,10 +3472,10 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t
swallVerts[0].y = swallVerts[1].y = swallVerts[2].y = swallVerts[3].y = spr->gzt - gpatch->topoffset - (floorheight+3); swallVerts[0].y = swallVerts[1].y = swallVerts[2].y = swallVerts[3].y = spr->gzt - gpatch->topoffset - (floorheight+3);
// Now transform the TOP vertices along the floor in the direction of the camera // Now transform the TOP vertices along the floor in the direction of the camera
swallVerts[3].x = spr->x1 + (static_cast<float>(gpatch->height) + offset) * gl_viewcos; swallVerts[3].x = spr->x1 + (gpatch->height + offset) * gl_viewcos;
swallVerts[2].x = spr->x2 + (static_cast<float>(gpatch->height) + offset) * gl_viewcos; swallVerts[2].x = spr->x2 + (gpatch->height + offset) * gl_viewcos;
swallVerts[3].z = spr->z1 + (static_cast<float>(gpatch->height) + offset) * gl_viewsin; swallVerts[3].z = spr->z1 + (gpatch->height + offset) * gl_viewsin;
swallVerts[2].z = spr->z2 + (static_cast<float>(gpatch->height) + offset) * gl_viewsin; swallVerts[2].z = spr->z2 + (gpatch->height + offset) * gl_viewsin;
} }
// We also need to move the bottom ones away when shadowoffs is on // We also need to move the bottom ones away when shadowoffs is on
@@ -3652,7 +3618,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite)
FOutVector baseWallVerts[4]; // This is what the verts should end up as FOutVector baseWallVerts[4]; // This is what the verts should end up as
patch_t *gpatch; patch_t *gpatch;
GLPatch_t *hwrpatch; GLPatch_t *hwrpatch;
FSurfaceInfo Surf = {}; FSurfaceInfo Surf;
extracolormap_t *colormap; extracolormap_t *colormap;
INT32 lightlevel; INT32 lightlevel;
boolean lightset = true; boolean lightset = true;
@@ -3779,15 +3745,8 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite)
blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude; blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude;
} }
if (sprmo->player) if (cv_playerfade.value && sprmo->player)
{ Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha);
// make hyu´d players translucent with reducevfx, could be done better, but im lazy as crap
if (cv_reducevfx.value && sprmo->player->kartstuff[k_hyudorotimer] > 0)
Surf.PolyColor.s.alpha = FixedMul(FRACUNIT/2, Surf.PolyColor.s.alpha);
if (cv_playerfade.value)
Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha);
}
if (HWR_UseShader()) if (HWR_UseShader())
{ {
@@ -3937,7 +3896,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr)
FOutVector wallVerts[4]; FOutVector wallVerts[4];
patch_t *gpatch; // sprite patch converted to hardware patch_t *gpatch; // sprite patch converted to hardware
GLPatch_t *hwrpatch; GLPatch_t *hwrpatch;
FSurfaceInfo Surf = {}; FSurfaceInfo Surf;
FBITFIELD blend = 0; FBITFIELD blend = 0;
INT32 shader = SHADER_NONE; INT32 shader = SHADER_NONE;
@@ -4076,15 +4035,8 @@ static void HWR_DrawSprite(gl_vissprite_t *spr)
blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude; blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude;
} }
if (sprmo->player) if (cv_playerfade.value && sprmo->player)
{ Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha);
// make hyu´d players translucent with reducevfx, could be done better, but im lazy as crap
if (cv_reducevfx.value && sprmo->player->kartstuff[k_hyudorotimer] > 0)
Surf.PolyColor.s.alpha = FixedMul(FRACUNIT/2, Surf.PolyColor.s.alpha);
if (cv_playerfade.value)
Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha);
}
if (HWR_UseShader()) if (HWR_UseShader())
{ {
@@ -4102,7 +4054,7 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr)
FOutVector wallVerts[4]; FOutVector wallVerts[4];
patch_t *gpatch; // sprite patch converted to hardware patch_t *gpatch; // sprite patch converted to hardware
GLPatch_t *hwrpatch; GLPatch_t *hwrpatch;
FSurfaceInfo Surf = {}; FSurfaceInfo Surf;
INT32 shader = SHADER_NONE; INT32 shader = SHADER_NONE;
@@ -4454,6 +4406,9 @@ static void HWR_RenderDrawNodes(void)
// Okay! Let's draw it all! Woo! // Okay! Let's draw it all! Woo!
GL_SetTransform(&atransform); GL_SetTransform(&atransform);
if (LIKELY(cv_glbatching.value))
HWR_StartBatching();
for (i = 0; i < numdrawnodes; i++) for (i = 0; i < numdrawnodes; i++)
{ {
gl_drawnode_t *drawnode = &drawnodes[sortindex[i]]; gl_drawnode_t *drawnode = &drawnodes[sortindex[i]];
@@ -4507,6 +4462,9 @@ static void HWR_RenderDrawNodes(void)
PS_STOP_TIMING(ps_hw_nodedrawtime); PS_STOP_TIMING(ps_hw_nodedrawtime);
if (LIKELY(cv_glbatching.value))
HWR_RenderBatches(false);
drawnodes.clear(); // clear so our size is 0 again! drawnodes.clear(); // clear so our size is 0 again!
} }
@@ -4847,7 +4805,7 @@ static void HWR_ProjectSprite(mobj_t *thing)
flip = sprframe->flip; // Will only be 0x00 or 0xFF flip = sprframe->flip; // Will only be 0x00 or 0xFF
if (papersprite && ang < ANGLE_180) if (papersprite && ang < ANGLE_180)
flip ^= 0xFF; flip ^= 0xFFFF;
} }
else else
{ {
@@ -5195,8 +5153,6 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
z2 = tr_y - x2 * rightsin; z2 = tr_y - x2 * rightsin;
x1 = tr_x + x1 * rightcos; x1 = tr_x + x1 * rightcos;
x2 = tr_x - x2 * rightcos; x2 = tr_x - x2 * rightcos;
//y1 = tr_y + y1 * rightcos;
//y2 = tr_y - y2 * rightcos;
// //
// store information in a vissprite // store information in a vissprite
@@ -5375,7 +5331,7 @@ void HWR_BuildSkyDome(void)
} }
// precompute to save a bit of division // precompute to save a bit of division
static constexpr float FINEDEGREE = (360.0f/static_cast<float>(FINEANGLES)); static constexpr float FINEDEGREE = (360.0f/(float)FINEANGLES);
static void HWR_DrawSkyBackground(void) static void HWR_DrawSkyBackground(void)
{ {
@@ -5393,7 +5349,7 @@ static void HWR_DrawSkyBackground(void)
//04/01/2000: Hurdler: added for T&L //04/01/2000: Hurdler: added for T&L
// It should replace all other gl_viewxxx when finished // It should replace all other gl_viewxxx when finished
HWR_SetTransformAiming(&dometransform); HWR_SetTransformAiming(&dometransform);
dometransform.angley = static_cast<float>((viewangle-ANGLE_270) >> ANGLETOFINESHIFT)*(FINEDEGREE); dometransform.angley = (float)((viewangle-ANGLE_270)>>ANGLETOFINESHIFT)*(FINEDEGREE);
HWR_GetTexture(texturetranslation[skytexture], false); HWR_GetTexture(texturetranslation[skytexture], false);
@@ -5438,9 +5394,9 @@ static void HWR_SetTransformAiming(FTransform *trans)
if (cv_glshearing.value) if (cv_glshearing.value)
{ {
fixed_t fixedaiming = AIMINGTODY(aimingangle); fixed_t fixedaiming = AIMINGTODY(aimingangle);
trans->viewaiming = FixedToFloat(fixedaiming) * (static_cast<float>(vid.width) / static_cast<float>(vid.height)) / (static_cast<float>(BASEVIDWIDTH) / static_cast<float>(BASEVIDHEIGHT)); trans->viewaiming = FixedToFloat(fixedaiming) * ((float)vid.width / vid.height) / ((float)BASEVIDWIDTH / BASEVIDHEIGHT);
if (splitscreen == 1) // only for 2 player splitscreen if (splitscreen == 1) // only for 2 player splitscreen
trans->viewaiming *= 2.125f; // splitscreen adjusts fov with 0.8, so compensate (but only halfway, since splitscreen means only half the screen is used) trans->viewaiming *= 2.125; // splitscreen adjusts fov with 0.8, so compensate (but only halfway, since splitscreen means only half the screen is used)
trans->shearing = true; trans->shearing = true;
gl_aimingangle = 0; gl_aimingangle = 0;
} }
@@ -5450,7 +5406,7 @@ static void HWR_SetTransformAiming(FTransform *trans)
gl_aimingangle = aimingangle; gl_aimingangle = aimingangle;
} }
trans->anglex = static_cast<float>(gl_aimingangle >> ANGLETOFINESHIFT)*(FINEDEGREE); trans->anglex = (float)(gl_aimingangle>>ANGLETOFINESHIFT)*(FINEDEGREE);
} }
void HWR_SetTransform(float fpov) void HWR_SetTransform(float fpov)
@@ -5469,11 +5425,11 @@ void HWR_SetTransform(float fpov)
atransform.z = gl_viewz; atransform.z = gl_viewz;
atransform.scalex = 1; atransform.scalex = 1;
atransform.scaley = static_cast<float>(vid.width) / static_cast<float>(vid.height); atransform.scaley = (float)vid.width/vid.height;
atransform.scalez = 1; atransform.scalez = 1;
HWR_SetTransformAiming(&atransform); HWR_SetTransformAiming(&atransform);
atransform.angley = static_cast<float>(viewangle >> ANGLETOFINESHIFT)*(FINEDEGREE); atransform.angley = (float)(viewangle>>ANGLETOFINESHIFT)*(FINEDEGREE);
yaw = 270.0f - atransform.angley; yaw = 270.0f - atransform.angley;
inv_yaw = 180.0f - yaw; inv_yaw = 180.0f - yaw;
@@ -5484,8 +5440,8 @@ void HWR_SetTransform(float fpov)
// only needed for sprite billboarding // only needed for sprite billboarding
if (cv_glspritebillboarding.value && !cv_glshearing.value) if (cv_glspritebillboarding.value && !cv_glshearing.value)
{ {
gl_viewludsin = FixedToFloat(FINECOSINE(gl_aimingangle >> ANGLETOFINESHIFT)); gl_viewludsin = FixedToFloat(FINECOSINE(gl_aimingangle>>ANGLETOFINESHIFT));
gl_viewludcos = FixedToFloat(-FINESINE(gl_aimingangle >> ANGLETOFINESHIFT)); gl_viewludcos = FixedToFloat(-FINESINE(gl_aimingangle>>ANGLETOFINESHIFT));
} }
atransform.fovangle = fpov; // Tails atransform.fovangle = fpov; // Tails
@@ -5513,6 +5469,7 @@ void HWR_SetTransform(float fpov)
void HWR_ClearClipper(void) void HWR_ClearClipper(void)
{ {
const angle_t a1 = gld_FrustumAngle(gl_aimingangle); const angle_t a1 = gld_FrustumAngle(gl_aimingangle);
gld_clipper_Clear(); gld_clipper_Clear();
gld_clipper_SafeAddClipRange(viewangle + a1, viewangle - a1); gld_clipper_SafeAddClipRange(viewangle + a1, viewangle - a1);
#ifdef HAVE_SPHEREFRUSTRUM #ifdef HAVE_SPHEREFRUSTRUM
@@ -5545,7 +5502,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool
player_t *viewplayer = &players[displayplayers[viewssnum]]; player_t *viewplayer = &players[displayplayers[viewssnum]];
const float fpov = FixedToFloat(R_GetPlayerFov(viewplayer)); const float fpov = FixedToFloat(R_GetPlayerFov(viewplayer));
auto reset_viewstate = [&]() auto reset_viewstate = [&](const float fpov)
{ {
HWR_SetTransform(fpov); HWR_SetTransform(fpov);
HWR_ClearSprites(); HWR_ClearSprites();
@@ -5565,7 +5522,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool
currentportallist = &portallist; currentportallist = &portallist;
HWR_SetPortalState(GLPORTAL_SEARCH); HWR_SetPortalState(GLPORTAL_SEARCH);
reset_viewstate(); reset_viewstate(fpov);
if (rootportal) if (rootportal)
{ {
@@ -5591,13 +5548,13 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool
// draw normal things in current frame in current incremented stencil buffer area // draw normal things in current frame in current incremented stencil buffer area
HWR_SetStencilState(HWR_STENCIL_NORMAL, stencil_level); HWR_SetStencilState(HWR_STENCIL_NORMAL, stencil_level);
reset_viewstate(); reset_viewstate(fpov);
if constexpr (Type == RenderViewpointType::kPortal) if constexpr (Type == RenderViewpointType::kPortal)
{ {
if (allow_portals && rootportal) if (allow_portals && rootportal)
{ {
HWR_PortalFrame(rootportal);// for portalclipsector, it could have gone null from search HWR_PortalFrame(rootportal); // for portalclipsector, it could have gone null from search
HWR_PortalClipping(rootportal); HWR_PortalClipping(rootportal);
} }
} }
@@ -5647,7 +5604,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool
PS_STOP_TIMING(ps_bsptime); PS_STOP_TIMING(ps_bsptime);
if (LIKELY(cv_glbatching.value)) if (LIKELY(cv_glbatching.value))
HWR_RenderBatches(); HWR_RenderBatches(true);
// Check for new console commands. // Check for new console commands.
NetUpdate(); NetUpdate();
@@ -5674,11 +5631,15 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool
HWR_SortVisSprites(); HWR_SortVisSprites();
PS_STOP_TIMING(ps_hw_spritesorttime); PS_STOP_TIMING(ps_hw_spritesorttime);
PS_START_TIMING(ps_hw_spritedrawtime); PS_START_TIMING(ps_hw_spritedrawtime);
if (LIKELY(cv_glbatching.value))
HWR_StartBatching();
if (UNLIKELY(cv_glmdls.value)) if (UNLIKELY(cv_glmdls.value))
HWR_DrawSprites<DrawSpritesType::kModels>(); HWR_DrawSprites<DrawSpritesType::kModels>();
else else
HWR_DrawSprites<DrawSpritesType::kSprites>(); HWR_DrawSprites<DrawSpritesType::kSprites>();
PS_STOP_TIMING(ps_hw_spritedrawtime); PS_STOP_TIMING(ps_hw_spritedrawtime);
if (LIKELY(cv_glbatching.value))
HWR_RenderBatches(false);
ps_numdrawnodes.value.i = 0; ps_numdrawnodes.value.i = 0;
ps_hw_nodesorttime.value.p = 0; ps_hw_nodesorttime.value.p = 0;
@@ -5746,7 +5707,7 @@ static void HWR_RollTransform(FTransform *tr, angle_t roll)
{ {
if (roll != 0) if (roll != 0)
{ {
tr->rollangle = static_cast<float>(roll) / static_cast<float>(ANG1); tr->rollangle = roll / (float)ANG1;
tr->roll = true; tr->roll = true;
tr->rollx = 1.0f; tr->rollx = 1.0f;
tr->rollz = 0.0f; tr->rollz = 0.0f;
@@ -5910,6 +5871,7 @@ void HWR_AddCommands(void)
CV_RegisterVar(&cv_glpaletterendering); CV_RegisterVar(&cv_glpaletterendering);
CV_RegisterVar(&cv_glpalettedepth); CV_RegisterVar(&cv_glpalettedepth);
CV_RegisterVar(&cv_glflashpal);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
@@ -6066,7 +6028,7 @@ static void HWR_DoPostProcessor(void)
{ {
// Armageddon Blast Flash! // Armageddon Blast Flash!
// Could this even be considered postprocessor? // Could this even be considered postprocessor?
if (!HWR_ShouldUsePaletteRendering()) if (!HWR_PalRenderFlashpal())
{ {
const player_t *player = &players[displayplayers[viewssnum]]; const player_t *player = &players[displayplayers[viewssnum]];
@@ -6079,7 +6041,7 @@ static void HWR_DoPostProcessor(void)
{-4.0f, -4.0f, 4.0f, 0.0f, 0.0f} {-4.0f, -4.0f, 4.0f, 0.0f, 0.0f}
}; };
FSurfaceInfo Surf = {}; FSurfaceInfo Surf;
// This won't change if the flash palettes are changed unfortunately, but it works for its purpose // This won't change if the flash palettes are changed unfortunately, but it works for its purpose
if (player->flashpal == PAL_NUKE) if (player->flashpal == PAL_NUKE)
@@ -6106,7 +6068,7 @@ static void HWR_DoPostProcessor(void)
const camera_t *thiscam = &camera[0]; const camera_t *thiscam = &camera[0];
// Not supported in splitscreen - someone want to add support? // Not supported in splitscreen - someone want to add support?
const boolean screenwave = (!splitscreen && !cv_reducevfx.value && (thiscam->postimg & POSTIMG_WATER || thiscam->postimg & POSTIMG_HEAT)); const boolean screenwave = (!splitscreen && (thiscam->postimg & POSTIMG_WATER || thiscam->postimg & POSTIMG_HEAT));
// Capture the screen for intermission and screen waving // Capture the screen for intermission and screen waving
if ((lastdraw || screenwave) && gamestate != GS_INTERMISSION) if ((lastdraw || screenwave) && gamestate != GS_INTERMISSION)
@@ -6145,7 +6107,7 @@ static void HWR_DoPostProcessor(void)
for (y = 0; y < SCREENVERTS; y++) for (y = 0; y < SCREENVERTS; y++)
{ {
// Change X position based on its Y position. // Change X position based on its Y position.
v[x][y][0] = x-4.5f + sinf(((disStart+(static_cast<float>(y) * WAVELENGTH)) / FREQUENCY)) / AMPLITUDE; // (x / scale) v[x][y][0] = x-4.5f + sinf(((disStart+((float)y * WAVELENGTH)) / FREQUENCY)) / AMPLITUDE; // (x / scale)
v[x][y][1] = y-4.5f; // (y / scale) v[x][y][1] = y-4.5f; // (y / scale)
} }
} }
+6
View File
@@ -208,6 +208,7 @@ extern consvar_t cv_glportals;
extern consvar_t cv_glpaletterendering; extern consvar_t cv_glpaletterendering;
extern consvar_t cv_glpalettedepth; extern consvar_t cv_glpalettedepth;
extern consvar_t cv_glflashpal;
FUNCINLINE static ATTRINLINE boolean HWR_UseShader(void) FUNCINLINE static ATTRINLINE boolean HWR_UseShader(void)
{ {
@@ -219,6 +220,11 @@ FUNCINLINE static ATTRINLINE boolean HWR_ShouldUsePaletteRendering(void)
return (cv_glpaletterendering.value && (pLocalPalette != NULL) && HWR_UseShader()); return (cv_glpaletterendering.value && (pLocalPalette != NULL) && HWR_UseShader());
} }
FUNCINLINE static ATTRINLINE boolean HWR_PalRenderFlashpal(void)
{
return (cv_glflashpal.value && HWR_ShouldUsePaletteRendering());
}
// Returns a pointer to the palette which should be used for caching textures. // Returns a pointer to the palette which should be used for caching textures.
FUNCINLINE static ATTRINLINE RGBA_t *HWR_GetTexturePalette(void) FUNCINLINE static ATTRINLINE RGBA_t *HWR_GetTexturePalette(void)
{ {
+22 -133
View File
@@ -579,7 +579,7 @@ md2found:
fclose(f); fclose(f);
} }
void HWR_AddPlayerMD2(INT32 skin, boolean local) // For MD2's that were added after startup void HWR_AddPlayerMD2(int skin, boolean local) // For MD2's that were added after startup
{ {
FILE *f; FILE *f;
char name[20], filename[32]; char name[20], filename[32];
@@ -693,15 +693,17 @@ static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMi
GLPatch_t *hwrBlendPatch = blendgpatch->hardware; GLPatch_t *hwrBlendPatch = blendgpatch->hardware;
UINT16 w = gpatch->width, h = gpatch->height; UINT16 w = gpatch->width, h = gpatch->height;
UINT32 size = w*h; UINT32 size = w*h;
RGBA_t *image, *blendimage, *cur; RGBA_t *image, *blendimage, *cur, blendcolor;
RGBA_t blendcolor = {};
RGBA_t *palette = HWR_GetTexturePalette(); RGBA_t *palette = HWR_GetTexturePalette();
UINT8 translation[17] = {}; // First the color index UINT8 translation[17]; // First the color index
UINT8 cutoff[17] = {}; // Brightness cutoff before using the next color UINT8 cutoff[17]; // Brightness cutoff before using the next color
UINT8 translen = 0; UINT8 translen = 0;
UINT8 i; UINT8 i;
UINT8 colorbrightnesses[17] = {}; UINT8 colorbrightnesses[17];
UINT8 color_match_lookup[256] = {}; // optimization attempt UINT8 color_match_lookup[256]; // optimization attempt
memset(translation, 0, sizeof(translation));
memset(cutoff, 0, sizeof(cutoff));
if (glMipmap->width == 0) if (glMipmap->width == 0)
{ {
@@ -714,10 +716,14 @@ static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMi
glMipmap->format = GL_TEXFMT_RGBA; glMipmap->format = GL_TEXFMT_RGBA;
} }
Z_Free(glMipmap->data); if (glMipmap->data)
glMipmap->data = NULL; {
Z_Free(glMipmap->data);
glMipmap->data = NULL;
}
cur = Z_Calloc(size*4, PU_HWRMODELTEXTURE, &glMipmap->data); cur = Z_Malloc(size*4, PU_HWRMODELTEXTURE, &glMipmap->data);
memset(cur, 0x00, size*4);
image = hwrPatch->mipmap->data; image = hwrPatch->mipmap->data;
blendimage = hwrBlendPatch->mipmap->data; blendimage = hwrBlendPatch->mipmap->data;
@@ -1031,6 +1037,7 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendgpatch, INT32 sk
GLPatch_t *glPatch = patch->hardware; GLPatch_t *glPatch = patch->hardware;
GLMipmap_t *glMipmap, *newMipmap; GLMipmap_t *glMipmap, *newMipmap;
if (blendgpatch == NULL || colormap == colormaps || colormap == NULL) if (blendgpatch == NULL || colormap == colormaps || colormap == NULL)
{ {
// Don't do any blending // Don't do any blending
@@ -1099,7 +1106,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
INT32 frame = 0; INT32 frame = 0;
INT32 nextFrame = -1; INT32 nextFrame = -1;
FTransform p; FTransform p;
FSurfaceInfo Surf = {}; FSurfaceInfo Surf;
if (!cv_glmdls.value || spr->precip) if (!cv_glmdls.value || spr->precip)
return; return;
@@ -1191,15 +1198,8 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
Surf.PolyFlags = HWR_GetBlendModeFlag(blendmode); Surf.PolyFlags = HWR_GetBlendModeFlag(blendmode);
} }
if (spr->mobj->player) if (cv_playerfade.value && spr->mobj->player)
{ Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(spr->mobj), Surf.PolyColor.s.alpha);
// make hyu´d players translucent with reducevfx, could be done better, but im lazy as crap
if (cv_reducevfx.value && spr->mobj->player->kartstuff[k_hyudorotimer] > 0)
Surf.PolyColor.s.alpha = FixedMul(FRACUNIT/2, Surf.PolyColor.s.alpha);
if (cv_playerfade.value)
Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(spr->mobj), Surf.PolyColor.s.alpha);
}
// dont forget to enabled the depth test because we can't do this like // dont forget to enabled the depth test because we can't do this like
// before: polygons models are not sorted // before: polygons models are not sorted
@@ -1336,8 +1336,8 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
if (spr->mobj->frame & FF_ANIMATE) if (spr->mobj->frame & FF_ANIMATE)
{ {
// set duration and tics to be the correct values for FF_ANIMATE states // set duration and tics to be the correct values for FF_ANIMATE states
durs = spr->mobj->state->var2; durs = (float)spr->mobj->state->var2;
tics = (INT32)spr->mobj->anim_duration; tics = (float)spr->mobj->anim_duration;
} }
//FIXME: this is not yet correct //FIXME: this is not yet correct
@@ -1468,115 +1468,4 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
} }
} }
// mostly copy paste of HWR_DrawMD2
// very ugly but our model code kinda sucks
void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t color, const UINT8 *colormap, fixed_t scale, INT32 frame, angle_t angle)
{
patch_t *gpatch, *blendgpatch;
GLPatch_t *hwrPatch = NULL, *hwrBlendPatch = NULL;
FTransform p;
FSurfaceInfo Surf = {};
if (!md2->model)
{
char filename[64];
CONS_Debug(DBG_RENDER, "Loading model... (%s)\n", md2->filename);
sprintf(filename, "mdls/%s", md2->filename);
md2->model = md2_readModel(filename);
if (md2->model)
{
md2_printModelInfo(md2->model);
GL_CreateModelVBOs(md2->model);
}
else
{
md2->error = true;
return;
}
}
if (md2->model->meshes[0].numFrames > 0)
frame = frame % md2->model->meshes[0].numFrames;
else
frame = 0;
gpatch = (patch_t *)(md2->glpatch);
if (gpatch)
hwrPatch = ((GLPatch_t *)gpatch->hardware);
if (!gpatch || !hwrPatch ||
((!hwrPatch->mipmap->format || !hwrPatch->mipmap->downloaded) && !md2->notexturefile))
md2_loadTexture(md2);
gpatch = (patch_t*)(md2->glpatch);
if (gpatch)
hwrPatch = ((GLPatch_t *)gpatch->hardware);
blendgpatch = (patch_t*)(md2->blendglpatch);
if (blendgpatch)
hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware);
if ((gpatch && hwrPatch && hwrPatch->mipmap->format) &&
(!blendgpatch || !hwrBlendPatch ||
((!hwrBlendPatch->mipmap->format || !hwrBlendPatch->mipmap->downloaded) && !md2->noblendfile)))
md2_loadBlendTexture(md2);
blendgpatch = (patch_t*)(md2->blendglpatch);
if (blendgpatch)
hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware);
Surf.PolyColor.rgba = 0xFFFFFFFF;
Surf.PolyFlags = PF_Occlude | PF_Modulated;
Surf.LightInfo.light_level = 255;
Surf.LightInfo.fade_start = 0;
Surf.LightInfo.fade_end = 31;
if (color != SKINCOLOR_NONE &&
blendgpatch && hwrBlendPatch->mipmap->format &&
gpatch->width == blendgpatch->width && gpatch->height == blendgpatch->height)
{
INT32 tcskinnum = TC_DEFAULT;
if (color)
tcskinnum = skinnum;
HWR_GetBlendedTexture(gpatch, blendgpatch, tcskinnum, colormap, color);
}
else if (hwrPatch && hwrPatch->mipmap->format)
{
GL_SetTexture(hwrPatch->mipmap);
}
memset(&p, 0x00, sizeof(FTransform));
p.x = x*vid.dup + (float)(vid.width - BASEVIDWIDTH*vid.dup)/2.f;
p.y = -420.f; // push it back to prevent wonky culling, idk lul
p.z = y*vid.dup + (float)(vid.height - BASEVIDHEIGHT*vid.dup)/2.f;
p.angley = FixedToFloat(AngleFixed(angle));
p.anglex = 0.f;
p.anglez = 0.f;
p.roll = false;
p.fliptype = TRANSFORM_NONE;
const float fscale = FixedToFloat(scale*vid.dup);
GL_Draw2DModel(
md2->model,
frame,
0.f,
0.f,
-1,
&p,
fscale,
fscale,
true, // flip it vertically lul
false,
&Surf
);
}
#endif //HWRENDER #endif //HWRENDER
-3
View File
@@ -45,9 +45,6 @@ void HWR_InitMD2(void);
void HWR_DrawMD2(gl_vissprite_t *spr); void HWR_DrawMD2(gl_vissprite_t *spr);
void HWR_AddPlayerMD2(INT32 skin, boolean local); void HWR_AddPlayerMD2(INT32 skin, boolean local);
void HWR_AddSpriteMD2(size_t spritenum); void HWR_AddSpriteMD2(size_t spritenum);
void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum,
skincolors_t color, const UINT8 *colormap,
fixed_t scale, INT32 frame, angle_t angle);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
+14 -14
View File
@@ -274,7 +274,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
if (!f) if (!f)
return NULL; return NULL;
retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, NULL); retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, 0);
//size_t fileLen; //size_t fileLen;
@@ -288,13 +288,13 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
{ {
texPos++; texPos++;
namelen = strlen(texPos) + 1; namelen = strlen(texPos) + 1;
texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, NULL); texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, 0);
strcpy(texturefilename, texPos); strcpy(texturefilename, texPos);
} }
else else
{ {
namelen = strlen(fileName) + 1; namelen = strlen(fileName) + 1;
texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, NULL); texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, 0);
strcpy(texturefilename, fileName); strcpy(texturefilename, fileName);
} }
@@ -316,7 +316,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
header = (md2header_t*)buffer; header = (md2header_t*)buffer;
retModel->numMeshes = 1; // MD2 only has one mesh retModel->numMeshes = 1; // MD2 only has one mesh
retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * retModel->numMeshes, ztag, NULL); retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * retModel->numMeshes, ztag, 0);
retModel->meshes[0].numFrames = header->numFrames; retModel->meshes[0].numFrames = header->numFrames;
// const float WUNITS = 1.0f; // const float WUNITS = 1.0f;
// float dataScale = WUNITS; // float dataScale = WUNITS;
@@ -332,7 +332,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
if (retModel->numMaterials <= 0) // Always at least one skin, duh if (retModel->numMaterials <= 0) // Always at least one skin, duh
retModel->numMaterials = 1; retModel->numMaterials = 1;
retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, NULL); retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, 0);
// int t; // int t;
for (t = 0; t < retModel->numMaterials; t++) for (t = 0; t < retModel->numMaterials; t++)
@@ -409,9 +409,9 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
float *uvptr; float *uvptr;
dataScale = 0.015624f; // 1 / 64.0f dataScale = 0.015624f; // 1 / 64.0f
retModel->meshes[0].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*header->numFrames, ztag, NULL); retModel->meshes[0].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*header->numFrames, ztag, 0);
retModel->meshes[0].numVertices = header->numXYZ; retModel->meshes[0].numVertices = header->numXYZ;
retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, NULL); retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, 0);
ptr = (char*)frames; ptr = (char*)frames;
for (i = 0; i < header->numFrames; i++, ptr += header->framesize) for (i = 0; i < header->numFrames; i++, ptr += header->framesize)
@@ -423,12 +423,12 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
md2vertex_t *vertex; md2vertex_t *vertex;
md2frame_t *framePtr = (md2frame_t*)ptr; md2frame_t *framePtr = (md2frame_t*)ptr;
retModel->meshes[0].tinyframes[i].vertices = (short*)Z_Malloc(sizeof(short) * 3 * header->numXYZ, ztag, NULL); retModel->meshes[0].tinyframes[i].vertices = (short*)Z_Malloc(sizeof(short) * 3 * header->numXYZ, ztag, 0);
retModel->meshes[0].tinyframes[i].normals = (char*)Z_Malloc(sizeof(char) * 3 * header->numXYZ, ztag, NULL); retModel->meshes[0].tinyframes[i].normals = (char*)Z_Malloc(sizeof(char) * 3 * header->numXYZ, ztag, 0);
// if (retModel->materials[0].lightmap) // if (retModel->materials[0].lightmap)
// retModel->meshes[0].tinyframes[i].tangents = (char*)malloc(sizeof(char));//(char*)Z_Malloc(sizeof(char)*3*header->numVerts, ztag); // retModel->meshes[0].tinyframes[i].tangents = (char*)malloc(sizeof(char));//(char*)Z_Malloc(sizeof(char)*3*header->numVerts, ztag);
retModel->meshes[0].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * header->numTris, ztag, NULL); retModel->meshes[0].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * header->numTris, ztag, 0);
vertptr = retModel->meshes[0].tinyframes[i].vertices; vertptr = retModel->meshes[0].tinyframes[i].vertices;
normptr = retModel->meshes[0].tinyframes[i].normals; normptr = retModel->meshes[0].tinyframes[i].normals;
@@ -484,8 +484,8 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
char *ptr; char *ptr;
retModel->meshes[0].numVertices = header->numTris * 3; retModel->meshes[0].numVertices = header->numTris * 3;
retModel->meshes[0].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*header->numFrames, ztag, NULL); retModel->meshes[0].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*header->numFrames, ztag, 0);
retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, NULL); retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, 0);
trisPtr = tris; trisPtr = tris;
uvptr = retModel->meshes[0].uvs; uvptr = retModel->meshes[0].uvs;
@@ -507,8 +507,8 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
md2vertex_t *vertex; md2vertex_t *vertex;
md2frame_t *framePtr = (md2frame_t*)ptr; md2frame_t *framePtr = (md2frame_t*)ptr;
retModel->meshes[0].frames[i].normals = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, NULL); retModel->meshes[0].frames[i].normals = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, 0);
retModel->meshes[0].frames[i].vertices = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, NULL); retModel->meshes[0].frames[i].vertices = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, 0);
// if (retModel->materials[0].lightmap) // if (retModel->materials[0].lightmap)
// retModel->meshes[0].frames[i].tangents = (float*)malloc(sizeof(float));//(float*)Z_Malloc(sizeof(float)*3*header->numTris*3, ztag); // retModel->meshes[0].frames[i].tangents = (float*)malloc(sizeof(float));//(float*)Z_Malloc(sizeof(float)*3*header->numTris*3, ztag);
//float *vertptr, *normptr; //float *vertptr, *normptr;
+12 -12
View File
@@ -168,7 +168,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat)
if (!f) if (!f)
return NULL; return NULL;
retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, NULL); retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, 0);
// find length of file // find length of file
fseek(f, 0, SEEK_END); fseek(f, 0, SEEK_END);
@@ -201,7 +201,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat)
if (retModel->numMaterials <= 0) // Always at least one skin, duh if (retModel->numMaterials <= 0) // Always at least one skin, duh
retModel->numMaterials = 1; retModel->numMaterials = 1;
retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, NULL); retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, 0);
for (t = 0; t < retModel->numMaterials; t++) for (t = 0; t < retModel->numMaterials; t++)
{ {
@@ -225,7 +225,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat)
retModel->materials[t].spheremap = false; retModel->materials[t].spheremap = false;
} }
retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t)*retModel->numMeshes, ztag, NULL); retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t)*retModel->numMeshes, ztag, 0);
matCount = 0; matCount = 0;
for (i = 0, surfEnd = 0; i < mdh->numSurfaces; i++) for (i = 0, surfEnd = 0; i < mdh->numSurfaces; i++)
@@ -298,9 +298,9 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat)
unsigned short *indexptr; unsigned short *indexptr;
md3Triangle *mdT; md3Triangle *mdT;
retModel->meshes[i].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*mdS->numFrames, ztag, NULL); retModel->meshes[i].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*mdS->numFrames, ztag, 0);
retModel->meshes[i].numVertices = mdS->numVerts; retModel->meshes[i].numVertices = mdS->numVerts;
retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numVerts, ztag, NULL); retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numVerts, ztag, 0);
for (j = 0; j < mdS->numFrames; j++) for (j = 0; j < mdS->numFrames; j++)
{ {
short *vertptr; short *vertptr;
@@ -308,12 +308,12 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat)
// char *tanptr; // char *tanptr;
int k; int k;
md3Vertex *mdV = (md3Vertex*)((char*)mdS + mdS->offsetXYZNormal + (mdS->numVerts*j*sizeof(md3Vertex))); md3Vertex *mdV = (md3Vertex*)((char*)mdS + mdS->offsetXYZNormal + (mdS->numVerts*j*sizeof(md3Vertex)));
retModel->meshes[i].tinyframes[j].vertices = (short*)Z_Malloc(sizeof(short)*3*mdS->numVerts, ztag, NULL); retModel->meshes[i].tinyframes[j].vertices = (short*)Z_Malloc(sizeof(short)*3*mdS->numVerts, ztag, 0);
retModel->meshes[i].tinyframes[j].normals = (char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag, NULL); retModel->meshes[i].tinyframes[j].normals = (char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag, 0);
// if (retModel->materials[0].lightmap) // if (retModel->materials[0].lightmap)
// retModel->meshes[i].tinyframes[j].tangents = (char*)malloc(sizeof(char));//(char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag); // retModel->meshes[i].tinyframes[j].tangents = (char*)malloc(sizeof(char));//(char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag);
retModel->meshes[i].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * mdS->numTriangles, ztag, NULL); retModel->meshes[i].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * mdS->numTriangles, ztag, 0);
vertptr = retModel->meshes[i].tinyframes[j].vertices; vertptr = retModel->meshes[i].tinyframes[j].vertices;
normptr = retModel->meshes[i].tinyframes[j].normals; normptr = retModel->meshes[i].tinyframes[j].normals;
@@ -374,16 +374,16 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat)
int k; int k;
retModel->meshes[i].numVertices = mdS->numTriangles * 3;//mdS->numVerts; retModel->meshes[i].numVertices = mdS->numTriangles * 3;//mdS->numVerts;
retModel->meshes[i].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*mdS->numFrames, ztag, NULL); retModel->meshes[i].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*mdS->numFrames, ztag, 0);
retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numTriangles*3, ztag, NULL); retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numTriangles*3, ztag, 0);
for (j = 0; j < mdS->numFrames; j++) for (j = 0; j < mdS->numFrames; j++)
{ {
float *vertptr; float *vertptr;
float *normptr; float *normptr;
md3Vertex *mdV = (md3Vertex*)((char*)mdS + mdS->offsetXYZNormal + (mdS->numVerts*j*sizeof(md3Vertex))); md3Vertex *mdV = (md3Vertex*)((char*)mdS + mdS->offsetXYZNormal + (mdS->numVerts*j*sizeof(md3Vertex)));
retModel->meshes[i].frames[j].vertices = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, NULL); retModel->meshes[i].frames[j].vertices = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, 0);
retModel->meshes[i].frames[j].normals = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, NULL); retModel->meshes[i].frames[j].normals = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, 0);
// if (retModel->materials[i].lightmap) // if (retModel->materials[i].lightmap)
// retModel->meshes[i].frames[j].tangents = (float*)malloc(sizeof(float));//(float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag); // retModel->meshes[i].frames[j].tangents = (float*)malloc(sizeof(float));//(float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag);
vertptr = retModel->meshes[i].frames[j].vertices; vertptr = retModel->meshes[i].frames[j].vertices;
+9 -9
View File
@@ -189,7 +189,7 @@ model_t *LoadModel(const char *filename, int ztag)
return NULL; return NULL;
} }
model->mdlFilename = (char*)Z_Malloc(strlen(filename)+1, ztag, NULL); model->mdlFilename = (char*)Z_Malloc(strlen(filename)+1, ztag, 0);
strcpy(model->mdlFilename, filename); strcpy(model->mdlFilename, filename);
Optimize(model); Optimize(model);
@@ -237,7 +237,7 @@ void GenerateVertexNormals(model_t *model)
{ {
mdlframe_t *frame = &mesh->frames[j]; mdlframe_t *frame = &mesh->frames[j];
int memTag = PU_STATIC; int memTag = PU_STATIC;
float *newNormals = (float*)Z_Malloc(sizeof(float)*3*mesh->numTriangles*3, memTag, NULL); float *newNormals = (float*)Z_Malloc(sizeof(float)*3*mesh->numTriangles*3, memTag, 0);
int k; int k;
float *vertPtr = frame->vertices; float *vertPtr = frame->vertices;
float *oldNormals; float *oldNormals;
@@ -309,7 +309,7 @@ static boolean AddMaterialToList(materiallist_t **head, material_t *material)
} }
// Didn't find it, so add to the list // Didn't find it, so add to the list
newMatNode = (materiallist_t*)Z_Malloc(sizeof(materiallist_t), PU_CACHE, NULL); newMatNode = (materiallist_t*)Z_Malloc(sizeof(materiallist_t), PU_CACHE, 0);
newMatNode->material = material; newMatNode->material = material;
ListAdd(newMatNode, (listitem_t**)head); ListAdd(newMatNode, (listitem_t**)head);
return true; return true;
@@ -351,7 +351,7 @@ void Optimize(model_t *model)
} }
memTag = PU_STATIC; memTag = PU_STATIC;
newMeshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * numMeshes, memTag, NULL); newMeshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * numMeshes, memTag, 0);
i = 0; i = 0;
for (node = matListHead; node; node = node->next) for (node = matListHead; node; node = node->next)
@@ -377,14 +377,14 @@ void Optimize(model_t *model)
newMesh->numFrames = 1; newMesh->numFrames = 1;
newMesh->numTriangles = numTriangles; newMesh->numTriangles = numTriangles;
newMesh->numVertices = numTriangles * 3; newMesh->numVertices = numTriangles * 3;
newMesh->uvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, NULL); newMesh->uvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, 0);
newMesh->frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t), memTag, NULL); newMesh->frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t), memTag, 0);
curFrame = &newMesh->frames[0]; curFrame = &newMesh->frames[0];
curFrame->material = curMat; curFrame->material = curMat;
curFrame->normals = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, NULL); curFrame->normals = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0);
curFrame->vertices = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, NULL); curFrame->vertices = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0);
curFrame->colors = (char*)Z_Malloc(sizeof(char)*4*numTriangles*3, memTag, NULL); curFrame->colors = (char*)Z_Malloc(sizeof(char)*4*numTriangles*3, memTag, 0);
// Now traverse the meshes of the model, adding in // Now traverse the meshes of the model, adding in
// vertices/normals/uvs that match the current material // vertices/normals/uvs that match the current material
+1 -1
View File
@@ -109,7 +109,7 @@ boolean HWR_InitShaders(void)
// returns INT32_MAX if not found // returns INT32_MAX if not found
static INT32 strstr_int(const char *str1, const char *str2) static INT32 strstr_int(const char *str1, const char *str2)
{ {
gconst char *location = strstr(str1, str2); char *location = strstr(str1, str2);
if (location) if (location)
return location - str1; return location - str1;
else else
+33 -80
View File
@@ -98,10 +98,10 @@ static size_t textureBufferSize = 0;
static LTListItem *LightTablesTail = NULL; static LTListItem *LightTablesTail = NULL;
static LTListItem *LightTablesHead = NULL; static LTListItem *LightTablesHead = NULL;
static RGBA_t screenPalette[256] = {}; // the palette for the postprocessing step in palette rendering static RGBA_t screenPalette[256] = {0}; // the palette for the postprocessing step in palette rendering
static GLuint screenPaletteTex = 0; // 1D texture containing the screen palette static GLuint screenPaletteTex = 0; // 1D texture containing the screen palette
static GLuint paletteLookupTex = 0; // 3D texture containing RGB -> palette index lookup table static GLuint paletteLookupTex = 0; // 3D texture containing RGB -> palette index lookup table
RGBA_t myPaletteData[256] = {}; // the palette for converting textures to RGBA RGBA_t myPaletteData[256] = {0}; // the palette for converting textures to RGBA
static GLint gltexformat = GL_RGB5_A1; static GLint gltexformat = GL_RGB5_A1;
GLint screen_width = 0; // used by Draw2DLine() GLint screen_width = 0; // used by Draw2DLine()
@@ -127,9 +127,9 @@ GLuint gl_num_extensions;
int majorGL = 0, minorGL = 0; int majorGL = 0, minorGL = 0;
//Hurdler: 04/10/2000: added for the kick ass coronas as Boris wanted;-) //Hurdler: 04/10/2000: added for the kick ass coronas as Boris wanted;-)
GLfloat modelMatrix[16] = {}; GLfloat modelMatrix[16] = {0};
GLfloat projMatrix[16] = {}; GLfloat projMatrix[16] = {0};
static GLint viewport[4]; static GLint viewport[4];
#ifdef USE_FBO_OGL #ifdef USE_FBO_OGL
enum enum
@@ -171,7 +171,7 @@ boolean supportstencil = false;
// flush all of the stored textures, leaving them unavailable at times such as between levels // flush all of the stored textures, leaving them unavailable at times such as between levels
// These need to start at 0 and be set to their number, and be reset to 0 when deleted so that Intel GPUs // These need to start at 0 and be set to their number, and be reset to 0 when deleted so that Intel GPUs
// can know when the textures aren't there, as textures are always considered resident in their virtual memory // can know when the textures aren't there, as textures are always considered resident in their virtual memory
static GLuint screenTextures[NUMSCREENTEXTURES] = {}; static GLuint screenTextures[NUMSCREENTEXTURES] = {0};
#define byte2float(byte) (GLfloat)(byte / 255.0f) #define byte2float(byte) (GLfloat)(byte / 255.0f)
@@ -404,14 +404,6 @@ static PFNglEnableClientState pglEnableClientState;
typedef void (APIENTRY * PFNglDisableClientState) (GLenum cap); typedef void (APIENTRY * PFNglDisableClientState) (GLenum cap);
static PFNglDisableClientState pglDisableClientState; static PFNglDisableClientState pglDisableClientState;
typedef void (APIENTRY * PFNglOrtho) (GLdouble left,
GLdouble right,
GLdouble bottom,
GLdouble top,
GLdouble nearVal,
GLdouble farVal);
static PFNglOrtho pglOrtho;
/* Lighting */ /* Lighting */
typedef void (APIENTRY * PFNglShadeModel) (GLenum mode); typedef void (APIENTRY * PFNglShadeModel) (GLenum mode);
static PFNglShadeModel pglShadeModel; static PFNglShadeModel pglShadeModel;
@@ -753,7 +745,7 @@ typedef struct gl_shaderstate_s
static gl_shaderstate_t gl_shaderstate; static gl_shaderstate_t gl_shaderstate;
// Shader info // Shader info
static float shader_leveltime = 0.0f; static float shader_leveltime = 0;
static float shader_light_x = 0.0f; static float shader_light_x = 0.0f;
static float shader_light_y = 0.0f; static float shader_light_y = 0.0f;
static float shader_light_z = 0.0f; static float shader_light_z = 0.0f;
@@ -866,8 +858,6 @@ void SetupGLFunc4(void)
GetGLfunc(glUniform3fv); GetGLfunc(glUniform3fv);
GetGLfunc(glGetUniformLocation); GetGLfunc(glGetUniformLocation);
GetGLfunc(glOrtho);
#ifdef GLDEBUGMESSAGE #ifdef GLDEBUGMESSAGE
GetGLfunc(glDebugMessageCallback); GetGLfunc(glDebugMessageCallback);
#endif #endif
@@ -1383,19 +1373,19 @@ void GL_Flush(void)
// -----------------+ // -----------------+
INT32 GL_isExtAvailable(const char *extension, const GLubyte *start) INT32 GL_isExtAvailable(const char *extension, const GLubyte *start)
{ {
gconst GLubyte *where, *terminator; GLubyte *where, *terminator;
if (!extension || !start) if (!extension || !start)
return 0; return 0;
where = (gconst GLubyte *)strchr(extension, ' '); where = (GLubyte *) strchr(extension, ' ');
if (where || *extension == '\0') if (where || *extension == '\0')
return 0; return 0;
for (;;) for (;;)
{ {
where = (gconst GLubyte *)strstr((const char *)start, extension); where = (GLubyte *) strstr((const char *) start, extension);
if (!where) if (!where)
break; break;
@@ -2219,10 +2209,16 @@ static void GL_Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRG
UNIFORM_1(shader->uniforms[gluniform_light_contrast], shader_light_contrast, pglUniform1f); UNIFORM_1(shader->uniforms[gluniform_light_contrast], shader_light_contrast, pglUniform1f);
UNIFORM_1(shader->uniforms[gluniform_light_backlight], shader_light_backlight, pglUniform1f); UNIFORM_1(shader->uniforms[gluniform_light_backlight], shader_light_backlight, pglUniform1f);
} }
else
{
UNIFORM_3(shader->uniforms[gluniform_light_dir], 0, 0, 0, pglUniform3f);
UNIFORM_1(shader->uniforms[gluniform_light_contrast], 0, pglUniform1f);
UNIFORM_1(shader->uniforms[gluniform_light_backlight], 0, pglUniform1f);
}
UNIFORM_1(shader->uniforms[gluniform_leveltime], shader_leveltime, pglUniform1f); UNIFORM_1(shader->uniforms[gluniform_leveltime], shader_leveltime, pglUniform1f);
UNIFORM_2(shader->uniforms[gluniform_scr_resolution], (GLfloat)vid.width, (GLfloat)vid.height, pglUniform2f); UNIFORM_2(shader->uniforms[gluniform_scr_resolution], vid.width, vid.height, pglUniform2f);
#undef UNIFORM_1 #undef UNIFORM_1
#undef UNIFORM_2 #undef UNIFORM_2
@@ -3100,39 +3096,6 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics
pglDisable(GL_NORMALIZE); pglDisable(GL_NORMALIZE);
} }
void GL_Draw2DModel(model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex,
FTransform *pos, float hscale, float vscale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface)
{
// save our matrix´s
pglMatrixMode(GL_PROJECTION);
pglPushMatrix();
pglMatrixMode(GL_MODELVIEW);
pglPushMatrix();
pglMatrixMode(GL_PROJECTION);
pglLoadIdentity();
// switch to ortho mode to make our lives easier
// thisll make sure our coords will be remapped to pixel coords
pglOrtho(0.0f, (float)vid.width, (float)vid.height, 0.0f, NZCLIP_PLANE, FAR_ZCLIP_DEFAULT);
pglMatrixMode(GL_MODELVIEW);
pglLoadIdentity();
pglEnable(GL_DEPTH_TEST);
pglDepthMask(GL_TRUE);
pglClear(GL_DEPTH_BUFFER_BIT);
GL_DrawModelEx(model, frameIndex, duration, tics, nextFrameIndex,
pos, hscale, vscale, flipped, hflipped, Surface);
// restore the matrix´s
pglMatrixMode(GL_PROJECTION);
pglPopMatrix();
pglMatrixMode(GL_MODELVIEW);
pglPopMatrix();
}
// -----------------+ // -----------------+
// SetTransform : // SetTransform :
// -----------------+ // -----------------+
@@ -3591,30 +3554,22 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8
1.0f, -1.0f, 1.0f 1.0f, -1.0f, 1.0f
}; };
xfix = 1/((float)screen_texsizew/(float)screen_width);
yfix = 1/((float)screen_texsizeh/(float)screen_height);
const GLfloat scrwf = (float)screen_width; const GLfloat scrwf = (float)screen_width;
const GLfloat scrwh = (float)screen_height; const GLfloat scrwh = (float)screen_height;
xfix = 1/((float)screen_texsizew/scrwf);
yfix = 1/((float)screen_texsizeh/scrwh);
GL_SetBlend(PF_Modulated|PF_Translucent|PF_NoDepthTest);
// Slight fuzziness // Slight fuzziness
GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS); GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
GL_SetBlend(PF_Modulated|PF_Translucent|PF_NoDepthTest);
pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]); pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
uint32_t r = rand(); const float stride = 2.f/scrwh;
const float ystep = 2.f/scrwh * (float)vid.udup/4.f; for (i = 0; i < 1; i += stride)
for (i = 0; i < 1; i += ystep)
{ {
// avoid calling rand thousands of times fix[2] = (float)(rand() % 128) / -22000.f * xfix;
r ^= r >> 13;
r ^= r >> 11;
r ^= r << 21;
fix[2] = (float)(r & 127) / -22000.f * xfix;
fix[0] = fix[2]; fix[0] = fix[2];
fix[6] = fix[0] + xfix; fix[6] = fix[0] + xfix;
fix[4] = fix[2] + xfix; fix[4] = fix[2] + xfix;
@@ -3632,8 +3587,8 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8
} }
// Upward bar // Upward bar
GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS); //GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]); //pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
color[0] = color[1] = color[2] = 190; color[0] = color[1] = color[2] = 190;
color[3] = 250; color[3] = 250;
@@ -3656,14 +3611,13 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8
fix[1] = fix[7] += (fix[3] - fix[7])*2; fix[1] = fix[7] += (fix[3] - fix[7])*2;
screenVerts[1] = screenVerts[10] += (screenVerts[4] - screenVerts[1])*2; screenVerts[1] = screenVerts[10] += (screenVerts[4] - screenVerts[1])*2;
pglTexCoordPointer(2, GL_FLOAT, 0, fix); pglTexCoordPointer(2, GL_FLOAT, 0, fix);
pglVertexPointer(3, GL_FLOAT, 0, screenVerts); pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4); pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
// Downward bar // Downward bar
GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS); //GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]); //pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
fix[0] = 0.0f; fix[0] = 0.0f;
fix[6] = xfix; fix[6] = xfix;
@@ -3682,7 +3636,6 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8
fix[1] = fix[7] += (fix[3] - fix[7])*2; fix[1] = fix[7] += (fix[3] - fix[7])*2;
screenVerts[1] = screenVerts[10] += (screenVerts[4] - screenVerts[1])*2; screenVerts[1] = screenVerts[10] += (screenVerts[4] - screenVerts[1])*2;
pglTexCoordPointer(2, GL_FLOAT, 0, fix); pglTexCoordPointer(2, GL_FLOAT, 0, fix);
pglVertexPointer(3, GL_FLOAT, 0, screenVerts); pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4); pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
@@ -3722,7 +3675,7 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh
{ {
float xfix, yfix; float xfix, yfix;
float origaspect, newaspect; float origaspect, newaspect;
float xoff = 1.0f, yoff = 1.0f; // xoffset and yoffset for the polygon to have black bars around the screen float xoff = 1, yoff = 1; // xoffset and yoffset for the polygon to have black bars around the screen
static float off[12] = static float off[12] =
{ {
@@ -3745,19 +3698,19 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh
if (origaspect < newaspect) if (origaspect < newaspect)
{ {
xoff = origaspect / newaspect; xoff = origaspect / newaspect;
yoff = 1.0f; yoff = 1;
} }
else if (origaspect > newaspect) else if (origaspect > newaspect)
{ {
xoff = 1.0f; xoff = 1;
yoff = newaspect / origaspect; yoff = newaspect / origaspect;
} }
// float off[12]; // float off[12];
off[0] = off[3] = -xoff; off[0] = off[3] = -xoff;
off[1] = off[10] = -yoff; off[1] = off[10] = -yoff;
off[4] = off[7] = yoff; off[4] = off[7] = yoff;
off[6] = off[9] = xoff; off[6] = off[9] = xoff;
// float fix[8]; // float fix[8];
fix[3] = fix[5] = yfix; fix[3] = fix[5] = yfix;
+1 -1
View File
@@ -27,7 +27,7 @@ extern "C" {
#ifdef HAVE_SDL #ifdef HAVE_SDL
#define _MATH_DEFINES_DEFINED #define _MATH_DEFINES_DEFINED
#include "SDL_opengl.h" //Alam_GBC: Simple, yes? #include <SDL3/SDL_opengl.h> //Alam_GBC: Simple, yes?
#else #else
#include <GL/gl.h> #include <GL/gl.h>
+5 -7
View File
@@ -189,7 +189,7 @@ HMS_connect (const char *format, ...)
seek = strlen(hms_api) + 1;/* + '/' */ seek = strlen(hms_api) + 1;/* + '/' */
va_start (ap, format); va_start (ap, format);
url = malloc(seek + vsnprintf(NULL, 0, format, ap) + sizeof HMS_QUERY_VERSION - 1 + token_length + 1); url = malloc(seek + vsnprintf(0, 0, format, ap) + sizeof HMS_QUERY_VERSION - 1 + token_length + 1);
va_end (ap); va_end (ap);
sprintf(url, "%s/", hms_api); sprintf(url, "%s/", hms_api);
@@ -225,10 +225,9 @@ HMS_connect (const char *format, ...)
{ {
cc = curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); cc = curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
if (cc != CURLE_OK) I_OutputMsg("libcurl: %s\n", buffer->errbuf); if (cc != CURLE_OK) I_OutputMsg("libcurl: %s\n", buffer->errbuf);
#ifdef LOGMESSAGES
cc = curl_easy_setopt(curl, CURLOPT_STDERR, logstream); cc = curl_easy_setopt(curl, CURLOPT_STDERR, logstream);
if (cc != CURLE_OK) I_OutputMsg("libcurl: %s\n", buffer->errbuf); if (cc != CURLE_OK) I_OutputMsg("libcurl: %s\n", buffer->errbuf);
#endif
} }
if (M_CheckParm("-bindaddr") && M_IsNextParm()) if (M_CheckParm("-bindaddr") && M_IsNextParm())
@@ -318,7 +317,6 @@ static void
HMS_end (struct HMS_buffer *buffer) HMS_end (struct HMS_buffer *buffer)
{ {
curl_easy_cleanup(buffer->curl); curl_easy_cleanup(buffer->curl);
free(buffer->errbuf);
free(buffer->buffer); free(buffer->buffer);
free(buffer); free(buffer);
} }
@@ -473,8 +471,8 @@ HMS_fetch_servers (msg_server_t *list, int query_id)
*end = '\0'; *end = '\0';
address = strtok(p, " "); address = strtok(p, " ");
port = strtok(NULL, " "); port = strtok(0, " ");
contact = strtok(NULL, ""); contact = strtok(0, "");
if (address && port) if (address && port)
{ {
@@ -541,7 +539,7 @@ HMS_compare_mod_version (char *buffer, size_t buffer_size)
if (HMS_do(hms)) if (HMS_do(hms))
{ {
version = strtok(hms->buffer, " "); version = strtok(hms->buffer, " ");
version_name = strtok(NULL, "\n"); version_name = strtok(0, "\n");
if (version && version_name) if (version && version_name)
{ {
+13 -19
View File
@@ -497,9 +497,7 @@ static void HU_removeChatText_Log(void)
{ {
chat_log[i] = chat_log[i+1]; chat_log[i] = chat_log[i+1];
} }
chat_nummsg_log--; // lost 1 msg. chat_nummsg_log--; // lost 1 msg.
chat_log[chat_nummsg_log] = NULL;
} }
static void Chatlogsize_OnChange(void) static void Chatlogsize_OnChange(void)
@@ -518,7 +516,6 @@ static void Chatlogsize_OnChange(void)
if (new_chat_log == NULL) if (new_chat_log == NULL)
{ {
free(chat_log); free(chat_log);
chat_log = NULL;
return; return;
} }
chat_log = new_chat_log; chat_log = new_chat_log;
@@ -1075,7 +1072,8 @@ static void Got_Saycmd(const UINT8 **p, INT32 playernum)
HU_AddChatText(va(fmt2, prefix, cstart, dispname, textcolor, msg), cv_chatnotifications.value); // add to chat HU_AddChatText(va(fmt2, prefix, cstart, dispname, textcolor, msg), cv_chatnotifications.value); // add to chat
Z_Free(tempchar); if (tempchar)
Z_Free(tempchar);
} }
#ifdef _DEBUG #ifdef _DEBUG
// I just want to point out while I'm here that because the data is still // I just want to point out while I'm here that because the data is still
@@ -1486,7 +1484,6 @@ static char *CHAT_WordWrap(INT32 x, INT32 w, INT32 option, const char *string)
x = 0; x = 0;
} }
} }
return newstring; return newstring;
} }
@@ -1525,7 +1522,7 @@ static void HU_drawMiniChat(void)
emote_t *emote = NULL; emote_t *emote = NULL;
int emotelen = 0; int emotelen = 0;
while (msg[j]) // iterate through msg while(msg[j]) // iterate through msg
{ {
if (msg[j] < HU_FONTSTART) // don't draw if (msg[j] < HU_FONTSTART) // don't draw
{ {
@@ -1557,21 +1554,19 @@ static void HU_drawMiniChat(void)
{ {
j++; j++;
} }
prev_linereturn = false; prev_linereturn = false;
dx += charwidth; dx += charwidth;
if (dx >= boxw) if (dx >= boxw)
{ {
dx = 0; dx = 0;
linescount += 1; linescount += 1;
} }
} }
dy = 0; dy = 0;
dx = 0; dx = 0;
msglines += linescount+1; msglines += linescount+1;
Z_Free(msg); if (msg)
Z_Free(msg);
} }
y = chaty - charheight*(msglines+1); y = chaty - charheight*(msglines+1);
@@ -1603,7 +1598,7 @@ static void HU_drawMiniChat(void)
emote_t *emote = NULL; emote_t *emote = NULL;
int emotelen = 0; int emotelen = 0;
while (msg[j]) // iterate through msg while(msg[j]) // iterate through msg
{ {
if (msg[j] < HU_FONTSTART) // don't draw if (msg[j] < HU_FONTSTART) // don't draw
{ {
@@ -1648,17 +1643,16 @@ static void HU_drawMiniChat(void)
dx += charwidth; dx += charwidth;
prev_linereturn = false; prev_linereturn = false;
if (dx >= boxw) if (dx >= boxw)
{ {
dx = 0; dx = 0;
dy += charheight; dy += charheight;
} }
} }
dy += charheight; dy += charheight;
dx = 0; dx = 0;
Z_Free(msg); if (msg)
Z_Free(msg);
} }
// decrement addy and make that shit smooth: // decrement addy and make that shit smooth:
@@ -1710,7 +1704,7 @@ static void HU_drawChatLog(INT32 offset)
V_DrawFillConsoleMap(chatx, chat_topy, boxw, boxh*charheight +2, 239|V_SNAPTOBOTTOM|V_SNAPTOLEFT); // log box V_DrawFillConsoleMap(chatx, chat_topy, boxw, boxh*charheight +2, 239|V_SNAPTOBOTTOM|V_SNAPTOLEFT); // log box
for (i = 0; i < chat_nummsg_log; i++) // iterate through our chatlog for (i=0; i<chat_nummsg_log; i++) // iterate through our chatlog
{ {
INT32 clrflag = 0; INT32 clrflag = 0;
INT32 j = 0; INT32 j = 0;
@@ -1719,7 +1713,7 @@ static void HU_drawChatLog(INT32 offset)
emote_t *emote = NULL; emote_t *emote = NULL;
int emotelen = 0; int emotelen = 0;
while (msg[j]) // iterate through msg while(msg[j]) // iterate through msg
{ {
if (msg[j] < HU_FONTSTART) // don't draw if (msg[j] < HU_FONTSTART) // don't draw
{ {
@@ -1744,7 +1738,7 @@ static void HU_drawChatLog(INT32 offset)
{ {
if ((y+dy+2 >= chat_topy) && (y+dy < (chat_bottomy))) if ((y+dy+2 >= chat_topy) && (y+dy < (chat_bottomy)))
{ {
M_DrawEmote(x+dx+2, y+dy+1, emote, V_SNAPTOBOTTOM|V_SNAPTOLEFT); M_DrawEmote(x+dx+2, y+dy, emote, V_SNAPTOBOTTOM|V_SNAPTOLEFT);
dx += EMOTEWIDTH - charwidth; dx += EMOTEWIDTH - charwidth;
} }
j += emotelen; j += emotelen;
@@ -1764,10 +1758,10 @@ static void HU_drawChatLog(INT32 offset)
dy += charheight; dy += charheight;
} }
} }
dy += charheight; dy += charheight;
dx = 0; dx = 0;
Z_Free(msg); if (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. 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.
+2 -2
View File
@@ -80,8 +80,6 @@ typedef struct
#define DOOMCOM_DATA(d) (doomdata_t *)&(d)->data #define DOOMCOM_DATA(d) (doomdata_t *)&(d)->data
extern doomcom_t *doomcom;
#ifdef HOLEPUNCH #ifdef HOLEPUNCH
typedef struct typedef struct
{ {
@@ -93,6 +91,8 @@ typedef struct
#define HOLEPUNCH_DATA(d) (holepunch_t *)&(d)->data #define HOLEPUNCH_DATA(d) (holepunch_t *)&(d)->data
#endif #endif
extern doomcom_t *doomcom;
/** \brief return packet in doomcom struct /** \brief return packet in doomcom struct
*/ */
extern boolean (*I_NetGet)(void); extern boolean (*I_NetGet)(void);
-2
View File
@@ -158,8 +158,6 @@ UINT32 I_GetSongLoopPoint(void);
boolean I_SetSongPosition(UINT32 position); boolean I_SetSongPosition(UINT32 position);
UINT32 I_GetSongPosition(void); UINT32 I_GetSongPosition(void);
void I_UpdateSongLagThreshold (void);
/// ------------------------ /// ------------------------
// MUSIC PLAYBACK // MUSIC PLAYBACK
/// ------------------------ /// ------------------------
+1 -9
View File
@@ -29,10 +29,6 @@ extern "C" {
*/ */
#define MAX_QUIT_FUNCS 16 #define MAX_QUIT_FUNCS 16
void I_GetConsoleEvents(void);
extern boolean consolevent;
extern boolean framebuffer;
/** \brief Graphic system had started up /** \brief Graphic system had started up
*/ */
@@ -43,7 +39,7 @@ extern UINT8 graphics_started;
extern UINT8 keyboard_started; extern UINT8 keyboard_started;
/** \brief Set to true when inside a signal handler that will exit the program. */ /** \brief Set to true when inside a signal handler that will exit the program. */
boolean I_In_Exiting_Signal_Handler(void); extern boolean g_in_exiting_signal_handler;
/** \brief The I_GetFreeMem function /** \brief The I_GetFreeMem function
@@ -195,10 +191,6 @@ INT32 I_StartupSystem(void);
*/ */
void I_ShutdownSystem(void); void I_ShutdownSystem(void);
/** \brief To check if a Interrupt or Terminate Signal was fired
*/
boolean I_Interrupted(void);
/** \brief The I_GetDiskFreeSpace function /** \brief The I_GetDiskFreeSpace function
\param freespace a INT64 pointer to hold the free space amount \param freespace a INT64 pointer to hold the free space amount
+22 -19
View File
@@ -496,10 +496,8 @@ static void cleanupnodes(void)
// Why can't I start at zero? // Why can't I start at zero?
for (j = 1; j < MAXNETNODES; j++) for (j = 1; j < MAXNETNODES; j++)
{
if (!(nodeingame[j] || SV_SendingFile(j))) if (!(nodeingame[j] || SV_SendingFile(j)))
nodeconnected[j] = false; nodeconnected[j] = false;
}
} }
static SINT8 getfreenode(void) static SINT8 getfreenode(void)
@@ -509,13 +507,11 @@ static SINT8 getfreenode(void)
cleanupnodes(); cleanupnodes();
for (j = 0; j < MAXNETNODES; j++) for (j = 0; j < MAXNETNODES; j++)
{
if (!nodeconnected[j]) if (!nodeconnected[j])
{ {
nodeconnected[j] = true; nodeconnected[j] = true;
return j; return j;
} }
}
/** \warning No free node? Just in case a node might not have been freed properly, /** \warning No free node? Just in case a node might not have been freed properly,
* look if there are connected nodes that aren't in game, and forget them. * look if there are connected nodes that aren't in game, and forget them.
@@ -572,12 +568,13 @@ void Command_Numnodes(void)
#ifdef HOLEPUNCH #ifdef HOLEPUNCH
/* not one of the reserved "local" addresses */ /* not one of the reserved "local" addresses */
static boolean is_external_address(UINT32 p) static boolean
is_external_address (UINT32 p)
{ {
UINT8 a = (p & 255); UINT8 a = (p & 255);
UINT8 b = ((p >> 8) & 255); UINT8 b = ((p >> 8) & 255);
if (p == (UINT32)~0) /* 255.255.255.255 */ if (p == (UINT32)~0)/* 255.255.255.255 */
return 0; return 0;
switch (a) switch (a)
@@ -587,7 +584,7 @@ static boolean is_external_address(UINT32 p)
case 127: case 127:
return false; return false;
case 172: case 172:
return (b & ~15) != 16; /* 16 - 31 */ return (b & ~15) != 16;/* 16 - 31 */
case 192: case 192:
return b != 168; return b != 168;
default: default:
@@ -766,7 +763,6 @@ static void SOCK_Send(void)
if (myfamily[i] == broadcastaddress[j].any.sa_family) if (myfamily[i] == broadcastaddress[j].any.sa_family)
{ {
c = SOCK_SendToAddr(mysockets[i], &broadcastaddress[j]); c = SOCK_SendToAddr(mysockets[i], &broadcastaddress[j]);
if (c == ERRSOCKET) if (c == ERRSOCKET)
{ {
e = errno; e = errno;
@@ -784,7 +780,6 @@ static void SOCK_Send(void)
if (myfamily[i] == clientaddress[doomcom->remotenode].any.sa_family) if (myfamily[i] == clientaddress[doomcom->remotenode].any.sa_family)
{ {
c = SOCK_SendToAddr(mysockets[i], &clientaddress[doomcom->remotenode]); c = SOCK_SendToAddr(mysockets[i], &clientaddress[doomcom->remotenode]);
if (c == ERRSOCKET) if (c == ERRSOCKET)
{ {
e = errno; e = errno;
@@ -797,7 +792,6 @@ static void SOCK_Send(void)
else else
{ {
c = SOCK_SendToAddr(nodesocket[doomcom->remotenode], &clientaddress[doomcom->remotenode]); c = SOCK_SendToAddr(nodesocket[doomcom->remotenode], &clientaddress[doomcom->remotenode]);
if (c == ERRSOCKET) if (c == ERRSOCKET)
{ {
e = errno; e = errno;
@@ -816,7 +810,7 @@ static void SOCK_Send(void)
static void SOCK_FreeNodenum(INT32 numnode) static void SOCK_FreeNodenum(INT32 numnode)
{ {
// can't disconnect from self :) // can't disconnect from self :)
if (numnode <= 0 || numnode > MAXNETNODES) if (!numnode || numnode > MAXNETNODES)
return; return;
DEBFILE(va("Free node %d (%s)\n", numnode, SOCK_GetNodeAddress(numnode))); DEBFILE(va("Free node %d (%s)\n", numnode, SOCK_GetNodeAddress(numnode)));
@@ -1066,6 +1060,7 @@ static boolean UDP_Socket(void)
#endif #endif
const char *serv; const char *serv;
for (s = 0; s < mysocketses; s++) for (s = 0; s < mysocketses; s++)
mysockets[s] = ERRSOCKET; mysockets[s] = ERRSOCKET;
for (s = 0; s < MAXNETNODES+1; s++) for (s = 0; s < MAXNETNODES+1; s++)
@@ -1436,12 +1431,14 @@ static void SOCK_RegisterHolePunch(void)
static boolean SOCK_OpenSocket(void) static boolean SOCK_OpenSocket(void)
{ {
memset(clientaddress, 0, sizeof(clientaddress)); size_t i;
memset(clientaddress, 0, sizeof (clientaddress));
memset(nodeconnected, false, sizeof(nodeconnected));
nodeconnected[0] = true; // always connected to self nodeconnected[0] = true; // always connected to self
for (i = 1; i < MAXNETNODES; i++)
nodeconnected[i] = false;
nodeconnected[BROADCASTADDR] = true; nodeconnected[BROADCASTADDR] = true;
I_NetSend = SOCK_Send; I_NetSend = SOCK_Send;
I_NetGet = SOCK_Get; I_NetGet = SOCK_Get;
I_NetCloseSocket = SOCK_CloseSocket; I_NetCloseSocket = SOCK_CloseSocket;
@@ -1481,7 +1478,7 @@ static boolean SOCK_Ban(INT32 node)
{ {
INT32 ban; INT32 ban;
if (node < 0 || node > MAXNETNODES) if (node > MAXNETNODES)
return false; return false;
ban = numbans; ban = numbans;
@@ -1512,8 +1509,11 @@ static boolean SOCK_SetBanUsername(const char *username)
username = "Direct IP ban"; username = "Direct IP ban";
} }
Z_Free(banned[numbans - 1].username); if (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); banned[numbans - 1].username = Z_StrDup(username);
@@ -1527,8 +1527,11 @@ static boolean SOCK_SetBanReason(const char *reason)
reason = "No reason given"; reason = "No reason given";
} }
Z_Free(banned[numbans - 1].reason); if (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); banned[numbans - 1].reason = Z_StrDup(reason);
+1 -1
View File
@@ -21,7 +21,7 @@
#include "m_fixed.h" #include "m_fixed.h"
#include "i_system.h" #include "i_system.h"
timestate_t g_time = {}; timestate_t g_time;
static CV_PossibleValue_t timescale_cons_t[] = {{FRACUNIT/20, "MIN"}, {20*FRACUNIT, "MAX"}, {0, NULL}}; static CV_PossibleValue_t timescale_cons_t[] = {{FRACUNIT/20, "MIN"}, {20*FRACUNIT, "MAX"}, {0, NULL}};
consvar_t cv_timescale = {"timescale", "1.0", CV_NETVAR|CV_CHEAT|CV_FLOAT, timescale_cons_t, NULL, FRACUNIT, NULL, NULL, 0, 0, NULL}; consvar_t cv_timescale = {"timescale", "1.0", CV_NETVAR|CV_CHEAT|CV_FLOAT, timescale_cons_t, NULL, FRACUNIT, NULL, NULL, 0, 0, NULL};
+4 -9
View File
@@ -95,6 +95,7 @@ INT32 VID_SetMode(INT32 modenum);
*/ */
const char *VID_GetModeName(INT32 modenum); const char *VID_GetModeName(INT32 modenum);
void VID_RefreshModeList(void);
void VID_PrepareModeList(void); void VID_PrepareModeList(void);
/** \brief can video system do fullscreen /** \brief can video system do fullscreen
@@ -121,10 +122,13 @@ void I_ReadScreen(UINT8 * restrict scr, INT32 scale);
UINT32 I_GetRefreshRate(void); UINT32 I_GetRefreshRate(void);
boolean I_CheckAboveDesktopRes(INT32 width, INT32 height);
boolean I_CheckNativeRes(void); boolean I_CheckNativeRes(void);
void I_SetBorderlessWindow(void); void I_SetBorderlessWindow(void);
void I_HandleControllerHatRepeat(void);
#ifdef USE_FBO_OGL #ifdef USE_FBO_OGL
void RefreshOGLSDLSurface(void); void RefreshOGLSDLSurface(void);
@@ -133,15 +137,6 @@ boolean UseScreenFBO(void);
extern boolean downsample; extern boolean downsample;
#endif #endif
// So we can call this from i_video event loop
void I_ShutdownJoystick(UINT8 index);
// Quick thing to make SDL_JOYDEVICEADDED events less of an abomination
void I_UpdateJoystickDeviceIndex(UINT8 player);
void I_UpdateJoystickDeviceIndices(UINT8 excludePlayer);
void I_HandleControllerHatRepeat(void);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
#endif #endif
-2
View File
@@ -19,8 +19,6 @@
#include "sounds.h" #include "sounds.h"
#include "m_fixed.h" #include "m_fixed.h"
#define MAXDOOMEDNUM 4095
// dehacked.c now has lists for the more named enums! PLEASE keep them up to date! // dehacked.c now has lists for the more named enums! PLEASE keep them up to date!
// For great modding!! // For great modding!!
+26 -41
View File
@@ -568,7 +568,7 @@ static patch_t *kp_racefinish[6];
static patch_t *kp_positionnum[NUMPOSNUMS][NUMPOSFRAMES]; static patch_t *kp_positionnum[NUMPOSNUMS][NUMPOSFRAMES];
static patch_t *kp_winnernum[NUMPOSFRAMES]; static patch_t *kp_winnernum[NUMPOSFRAMES];
patch_t *kp_facenum[MAXPLAYERS+1] = {}; static patch_t *kp_facenum[MAXPLAYERS+1];
static patch_t *kp_facehighlight[8]; static patch_t *kp_facehighlight[8];
static patch_t *kp_rankbumper; static patch_t *kp_rankbumper;
@@ -931,21 +931,21 @@ const char *K_GetItemPatch(UINT8 item, boolean tiny)
//} //}
static INT32 ITEM_X, ITEM_Y; // Item Window INT32 ITEM_X, ITEM_Y; // Item Window
static INT32 TIME_X, TIME_Y; // Time Sticker INT32 TIME_X, TIME_Y; // Time Sticker
static INT32 LAPS_X, LAPS_Y; // Lap Sticker INT32 LAPS_X, LAPS_Y; // Lap Sticker
static INT32 SPDM_X, SPDM_Y; // Speedometer INT32 SPDM_X, SPDM_Y; // Speedometer
static INT32 POSI_X, POSI_Y; // Position Number INT32 POSI_X, POSI_Y; // Position Number
static INT32 FACE_X, FACE_Y; // Top-four Faces INT32 FACE_X, FACE_Y; // Top-four Faces
static INT32 STCD_X, STCD_Y; // Starting countdown INT32 STCD_X, STCD_Y; // Starting countdown
static INT32 CHEK_Y; // CHECK graphic INT32 CHEK_Y; // CHECK graphic
static INT32 MINI_X, MINI_Y; // Minimap INT32 MINI_X, MINI_Y; // Minimap
static INT32 WANT_X, WANT_Y; // Battle WANTED poster INT32 WANT_X, WANT_Y; // Battle WANTED poster
// This is for the P2 and P4 side of splitscreen. Then we'll flip P1's and P2's to the bottom with V_SPLITSCREEN. // This is for the P2 and P4 side of splitscreen. Then we'll flip P1's and P2's to the bottom with V_SPLITSCREEN.
static INT32 ITEM2_X, ITEM2_Y; INT32 ITEM2_X, ITEM2_Y;
static INT32 LAPS2_X, LAPS2_Y; INT32 LAPS2_X, LAPS2_Y;
static INT32 POSI2_X, POSI2_Y; INT32 POSI2_X, POSI2_Y;
static void K_initKartHUD(void) static void K_initKartHUD(void)
{ {
@@ -1065,7 +1065,7 @@ static void K_initKartHUD(void)
} }
if (timeinmap > 113 || forceshowhud) if (timeinmap > 113 || forceshowhud)
hudtrans = (UINT8)cv_translucenthud.value; hudtrans = cv_translucenthud.value;
else if (timeinmap > 105) else if (timeinmap > 105)
hudtrans = ((((INT32)timeinmap) - 105)*cv_translucenthud.value)/(113-105); hudtrans = ((((INT32)timeinmap) - 105)*cv_translucenthud.value)/(113-105);
else else
@@ -1122,9 +1122,9 @@ void K_KartPlayerHUDUpdate(player_t *player)
UINT8 K_GetHudColor(void) UINT8 K_GetHudColor(void)
{ {
if (cv_colorizedhud.value && cv_colorizedhudcolor.value) if (cv_colorizedhud.value && cv_colorizedhudcolor.value)
return (UINT8)cv_colorizedhudcolor.value; return cv_colorizedhudcolor.value;
return ((stplyr && gamestate == GS_LEVEL) ? stplyr->skincolor : (UINT8)cv_playercolor.value); return ((stplyr && gamestate == GS_LEVEL) ? stplyr->skincolor : cv_playercolor.value);
} }
boolean K_UseColorHud(void) boolean K_UseColorHud(void)
@@ -1415,6 +1415,8 @@ static void K_drawKartStats(void)
break; break;
} }
} }
else
spdoffset = 0;
if (G_BattleGametype() && ((speedostyle != SPEEDO_DIAL) || splitscreen)) if (G_BattleGametype() && ((speedostyle != SPEEDO_DIAL) || splitscreen))
spdoffset += ((stplyr->kartstuff[k_bumper] ? -5 : -8)); spdoffset += ((stplyr->kartstuff[k_bumper] ? -5 : -8));
@@ -1524,7 +1526,7 @@ static void K_drawKartItem(void)
{ {
localcolor = K_GetHudColor(); localcolor = K_GetHudColor();
switch ((stplyr->kartstuff[k_itemroulette] % (14*3)) / 3) switch((stplyr->kartstuff[k_itemroulette] % (14*3)) / 3)
{ {
// Each case is handled in threes, to give three frames of in-game time to see the item on the roulette // Each case is handled in threes, to give three frames of in-game time to see the item on the roulette
case 0: // Sneaker case 0: // Sneaker
@@ -2193,7 +2195,7 @@ static boolean K_drawKartPositionFaces(void)
return true; return true;
if (!LUA_HudEnabled(hud_minirankings)) if (!LUA_HudEnabled(hud_minirankings))
return false; // Don't proceed but still return true for free play above if HUD is disabled. return false; // Don't proceed but still return true for free play above if HUD is disabled.
for (j = 0; j < numplayersingame; j++) for (j = 0; j < numplayersingame; j++)
{ {
@@ -3816,7 +3818,7 @@ static void K_drawKartMinimap(void)
if (cv_showminimapangle.value && (minidoticon || minilighticon) && !playertimedout) if (cv_showminimapangle.value && (minidoticon || minilighticon) && !playertimedout)
{ {
UINT8 *colormap = NULL; UINT8 *colormap;
drawinfo_t dims; drawinfo_t dims;
fixed_t interpx, interpy; fixed_t interpx, interpy;
fixed_t xoff = 0, yoff = 0; fixed_t xoff = 0, yoff = 0;
@@ -3827,27 +3829,10 @@ static void K_drawKartMinimap(void)
if (encoremode) if (encoremode)
ang = ANGLE_180 - ang; ang = ANGLE_180 - ang;
if (mobj->color) if (mobj->colorized)
{ colormap = R_GetTranslationColormap(TC_RAINBOW, mobj->color, GTC_CACHE);
if (mobj->colorized) else
{ colormap = R_GetLocalTranslationColormap(mobj->skin, mobj->localskin, mobj->color, GTC_CACHE, mobj->skinlocal);
colormap = R_GetTranslationColormap(TC_RAINBOW, mobj->color, GTC_CACHE);
}
else
{
const INT32 skinnum = K_GetMobjLocalSkinNum(mobj->skin, mobj->localskin, mobj->skinlocal);
// special case if startcolor is not the default (160 / Green)
if (skinnum && skins[skinnum].starttranscolor != skins[0].starttranscolor)
{
colormap = R_GetTranslationColormap(TC_DEFAULT, mobj->color, GTC_CACHE);
}
else
{
colormap = R_GetLocalTranslationColormap(mobj->skin, mobj->localskin, mobj->color, GTC_CACHE, mobj->skinlocal);
}
}
}
interpx = lerp(mobj->old_x, mobj->x); interpx = lerp(mobj->old_x, mobj->x);
interpy = lerp(mobj->old_y, mobj->y); interpy = lerp(mobj->old_y, mobj->y);
-3
View File
@@ -41,9 +41,6 @@ extern consvar_t cv_battlespeedo;
extern consvar_t cv_multiitemicon; extern consvar_t cv_multiitemicon;
extern consvar_t cv_huditemamount; extern consvar_t cv_huditemamount;
// for use in timeattack menu
extern patch_t *kp_facenum[MAXPLAYERS+1];
#define NUMSPEEDOSTUFF 8 #define NUMSPEEDOSTUFF 8
extern CV_PossibleValue_t speedo_cons_t[NUMSPEEDOSTUFF]; extern CV_PossibleValue_t speedo_cons_t[NUMSPEEDOSTUFF];
#define NUMDGAUGESTUFF 6 #define NUMDGAUGESTUFF 6
+67 -94
View File
@@ -47,8 +47,6 @@ consvar_t cv_airsparks = {"airdriftsparks", "Off", CV_SAVE, CV_OnOff, NULL, 0, N
consvar_t cv_playerblendeffects = {"playerblendeffects", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_playerblendeffects = {"playerblendeffects", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_reducevfx = {"reducevfx", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
// funn-E streeetch // funn-E streeetch
static CV_PossibleValue_t stretchfactor_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}}; static CV_PossibleValue_t stretchfactor_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}};
consvar_t cv_gravstretch = {"gravstretch", "MIN", CV_SAVE|CV_FLOAT, stretchfactor_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_gravstretch = {"gravstretch", "MIN", CV_SAVE|CV_FLOAT, stretchfactor_t, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -484,8 +482,7 @@ UINT8 colortranslations[MAXTRANSLATIONS][16] = {
// //
UINT8 K_RainbowColor(void) UINT8 K_RainbowColor(void)
{ {
const tic_t time = cv_reducevfx.value ? (leveltime >> 3) : leveltime; return (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1)));
return (UINT8)(1 + (time % (MAXSKINCOLORS-1)));
} }
// Define for getting accurate color brightness readings according to how the human eye sees them. // Define for getting accurate color brightness readings according to how the human eye sees them.
@@ -660,22 +657,13 @@ INT32 K_GetSkinNum(player_t *player)
// //
// returns the mobj skinnumber // returns the mobj skinnumber
// accounts for localskins ? // accounts for localskins
// //
INT32 K_GetMobjSkinNum(const skin_t *skin, boolean local) INT32 K_GetMobjSkinNum(const skin_t *skin, boolean local)
{ {
return skin - K_GetSkinArray(local); return skin - K_GetSkinArray(local);
} }
//
// returns the mobj skinnumber
// accounts for localskins
//
INT32 K_GetMobjLocalSkinNum(const skin_t *skin, const skin_t *localskin, boolean local)
{
return localskin ? (localskin - K_GetSkinArray(local)) : (skin - skins);
}
// //
// returns the players skinnumber // returns the players skinnumber
// accounts for localskins // accounts for localskins
@@ -776,8 +764,6 @@ void K_RegisterClientKartStuff(void)
CV_RegisterVar(&cv_playerblendeffects); CV_RegisterVar(&cv_playerblendeffects);
CV_RegisterVar(&cv_reducevfx);
CV_RegisterVar(&cv_saltyhop); CV_RegisterVar(&cv_saltyhop);
CV_RegisterVar(&cv_saltyhopsfx); CV_RegisterVar(&cv_saltyhopsfx);
CV_RegisterVar(&cv_saltysquish); CV_RegisterVar(&cv_saltysquish);
@@ -1489,6 +1475,7 @@ void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid)
fixed_t nx = FixedDiv(distx, dist); fixed_t nx = FixedDiv(distx, dist);
fixed_t ny = FixedDiv(disty, dist); fixed_t ny = FixedDiv(disty, dist);
dist = dist ? dist : 1;
distx = FixedMul(mobj1->radius+mobj2->radius, nx); distx = FixedMul(mobj1->radius+mobj2->radius, nx);
disty = FixedMul(mobj1->radius+mobj2->radius, ny); disty = FixedMul(mobj1->radius+mobj2->radius, ny);
@@ -2159,13 +2146,7 @@ static void K_GetKartBoostPower(player_t *player)
&& player->speed > 0 && player->speed > 0
&& !player->spectator) && !player->spectator)
{ {
mobj_t *dust = K_SpawnWipeoutTrail(player->mo, true); K_SpawnWipeoutTrail(player->mo, true);
// Technically, all mobjs that think can cause desynchs if they are spawned conditionally, so best we can do
// is to hide them if you are in saltyhop jump
if (dust && player->mo->salty.jump)
dust->flags2 |= MF2_DONTDRAW;
if (leveltime % 6 == 0) if (leveltime % 6 == 0)
S_StartSound(player->mo, sfx_cdfm70); S_StartSound(player->mo, sfx_cdfm70);
} }
@@ -3122,18 +3103,17 @@ static mobj_t *K_SpawnKartMissile(mobj_t *source, mobjtype_t type, angle_t an, I
return NULL; return NULL;
} }
static UINT8 K_DriftSparkColor(player_t *player, INT32 charge) static UINT16 K_DriftSparkColor(player_t *player, INT32 charge)
{ {
UINT8 color = SKINCOLOR_NONE; UINT16 color = SKINCOLOR_NONE;
const INT32 sparkval = K_GetKartDriftSparkValue(player);
if (charge >= sparkval*4) if (charge >= K_GetKartDriftSparkValue(player)*4)
{ {
color = K_RainbowColor(); color = K_RainbowColor();
} }
else if (charge >= sparkval*2) else if (charge >= K_GetKartDriftSparkValue(player)*2)
{ {
if (charge <= (sparkval*2)+(24*3)) if (charge <= (K_GetKartDriftSparkValue(player)*2)+(24*3))
color = SKINCOLOR_RASPBERRY; // transition color = SKINCOLOR_RASPBERRY; // transition
else else
color = SKINCOLOR_KETCHUP; color = SKINCOLOR_KETCHUP;
@@ -3614,8 +3594,6 @@ void K_SpawnSparkleTrail(mobj_t *mo)
I_Assert(mo != NULL); I_Assert(mo != NULL);
I_Assert(!P_MobjWasRemoved(mo)); I_Assert(!P_MobjWasRemoved(mo));
const boolean shouldblend = (mo->player && K_PlayerEffectsShouldBlend(mo->player));
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
{ {
fixed_t newx = mo->x + mo->momx + (P_RandomRange(-rad, rad)<<FRACBITS); fixed_t newx = mo->x + mo->momx + (P_RandomRange(-rad, rad)<<FRACBITS);
@@ -3633,14 +3611,14 @@ void K_SpawnSparkleTrail(mobj_t *mo)
sparkle->color = mo->color; sparkle->color = mo->color;
if (shouldblend) if (mo->player && K_PlayerEffectsShouldBlend(mo->player))
sparkle->blendmode = AST_ADD; sparkle->blendmode = AST_ADD;
} }
P_SetMobjState(sparkle, S_KARTINVULN_LARGE1); P_SetMobjState(sparkle, S_KARTINVULN_LARGE1);
} }
mobj_t *K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent) void K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent)
{ {
mobj_t *dust; mobj_t *dust;
angle_t aoff; angle_t aoff;
@@ -3681,8 +3659,6 @@ mobj_t *K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent)
if (translucent) if (translucent)
dust->flags2 |= MF2_SHADOW; dust->flags2 |= MF2_SHADOW;
return dust;
} }
// K_DriftDustHandling // K_DriftDustHandling
@@ -5203,24 +5179,6 @@ player_t *K_FindJawzTarget(mobj_t *actor, player_t *source)
return wtarg; return wtarg;
} }
static INT32 K_GetEngineClass(const player_t *player)
{
INT32 speed, weight;
speed = (player->kartspeed - 1) / 3;
weight = (player->kartweight - 1) / 3;
#define LOCKSTAT(stat) \
if (stat < 0) { stat = 0; } \
if (stat > 2) { stat = 2; }
LOCKSTAT(speed);
LOCKSTAT(weight);
#undef LOCKSTAT
return (speed + (3*weight));
}
// Engine Sounds. // Engine Sounds.
static void K_UpdateEngineSounds(player_t *player, ticcmd_t *cmd) static void K_UpdateEngineSounds(player_t *player, ticcmd_t *cmd)
{ {
@@ -5231,7 +5189,7 @@ static void K_UpdateEngineSounds(player_t *player, ticcmd_t *cmd)
static const UINT8 dampenval = 48; // 255 * 48 = close enough to FRACUNIT/6 static const UINT8 dampenval = 48; // 255 * 48 = close enough to FRACUNIT/6
INT32 class; // engine class number INT32 class, s, w; // engine class number
UINT8 volume = 255; UINT8 volume = 255;
fixed_t volumedampen = FRACUNIT; fixed_t volumedampen = FRACUNIT;
@@ -5267,7 +5225,7 @@ static void K_UpdateEngineSounds(player_t *player, ticcmd_t *cmd)
targetsnd = (((6 * cmd->forwardmove) / 25) + ((player->speed / mapobjectscale) / 5)) / 2; targetsnd = (((6 * cmd->forwardmove) / 25) + ((player->speed / mapobjectscale) / 5)) / 2;
} }
if (targetsnd < 0) { targetsnd = 0; } if (targetsnd < 0) { targetsnd = 0; }
if (targetsnd > 12) { targetsnd = 12; } if (targetsnd > 12) { targetsnd = 12; }
if (player->kartstuff[k_enginesnd] < targetsnd) { player->kartstuff[k_enginesnd]++; } if (player->kartstuff[k_enginesnd] < targetsnd) { player->kartstuff[k_enginesnd]++; }
@@ -5344,7 +5302,17 @@ static void K_UpdateEngineSounds(player_t *player, ticcmd_t *cmd)
return; return;
} }
class = K_GetEngineClass(player); s = (player->kartspeed - 1) / 3;
w = (player->kartweight - 1) / 3;
#define LOCKSTAT(stat) \
if (stat < 0) { stat = 0; } \
if (stat > 2) { stat = 2; }
LOCKSTAT(s);
LOCKSTAT(w);
#undef LOCKSTAT
class = s + (3*w);
S_StartSoundAtVolume(player->mo, (sfx_krta00 + player->kartstuff[k_enginesnd]) + (class * numsnds), volume); S_StartSoundAtVolume(player->mo, (sfx_krta00 + player->kartstuff[k_enginesnd]) + (class * numsnds), volume);
} }
@@ -5763,7 +5731,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
K_UpdateInvincibilitySounds(player); // Also thanks, VAda! K_UpdateInvincibilitySounds(player); // Also thanks, VAda!
// Plays the music during and after the starting countdown. // Plays the music during and after the starting countdown.
if ((leveltime <= MUSICSTARTTIME) && P_IsLocalPlayer(player)) if (P_IsLocalPlayer(player))
S_StartMapMusic(); S_StartMapMusic();
} }
@@ -5943,33 +5911,45 @@ static void K_KartDrift(player_t *player, boolean onground)
// Holding the Jump button will enable drifting. // Holding the Jump button will enable drifting.
// Drift Release (Moved here so you can't "chain" drifts) // Drift Release (Moved here so you can't "chain" drifts)
if (onground && player->kartstuff[k_drift] != -5 && player->kartstuff[k_drift] != 5) if ((player->kartstuff[k_drift] != -5 && player->kartstuff[k_drift] != 5)
// || (player->kartstuff[k_drift] >= 1 && player->kartstuff[k_turndir] != 1) || (player->kartstuff[k_drift] <= -1 && player->kartstuff[k_turndir] != -1))
&& player->kartstuff[k_driftcharge] < dsone
&& onground)
{ {
if (player->kartstuff[k_driftcharge] < dsone) player->kartstuff[k_driftcharge] = 0;
{ }
player->kartstuff[k_driftcharge] = 0; else if ((player->kartstuff[k_drift] != -5 && player->kartstuff[k_drift] != 5)
} // || (player->kartstuff[k_drift] >= 1 && player->kartstuff[k_turndir] != 1) || (player->kartstuff[k_drift] <= -1 && player->kartstuff[k_turndir] != -1))
else if (player->kartstuff[k_driftcharge] >= dsone && player->kartstuff[k_driftcharge] < dstwo) && (player->kartstuff[k_driftcharge] >= dsone && player->kartstuff[k_driftcharge] < dstwo)
{ && onground)
if (player->kartstuff[k_driftboost] < 20) {
player->kartstuff[k_driftboost] = 20; if (player->kartstuff[k_driftboost] < 20)
S_StartSound(player->mo, sfx_s23c); player->kartstuff[k_driftboost] = 20;
player->kartstuff[k_driftcharge] = 0; S_StartSound(player->mo, sfx_s23c);
} //K_SpawnDashDustRelease(player);
else if (player->kartstuff[k_driftcharge] < dsthree) player->kartstuff[k_driftcharge] = 0;
{ }
if (player->kartstuff[k_driftboost] < 50) else if ((player->kartstuff[k_drift] != -5 && player->kartstuff[k_drift] != 5)
player->kartstuff[k_driftboost] = 50; // || (player->kartstuff[k_drift] >= 1 && player->kartstuff[k_turndir] != 1) || (player->kartstuff[k_drift] <= -1 && player->kartstuff[k_turndir] != -1))
S_StartSound(player->mo, sfx_s23c); && player->kartstuff[k_driftcharge] < dsthree
player->kartstuff[k_driftcharge] = 0; && onground)
} {
else if (player->kartstuff[k_driftcharge] >= dsthree) if (player->kartstuff[k_driftboost] < 50)
{ player->kartstuff[k_driftboost] = 50;
if (player->kartstuff[k_driftboost] < 125) S_StartSound(player->mo, sfx_s23c);
player->kartstuff[k_driftboost] = 125; //K_SpawnDashDustRelease(player);
S_StartSound(player->mo, sfx_s23c); player->kartstuff[k_driftcharge] = 0;
player->kartstuff[k_driftcharge] = 0; }
} else if ((player->kartstuff[k_drift] != -5 && player->kartstuff[k_drift] != 5)
// || (player->kartstuff[k_drift] >= 1 && player->kartstuff[k_turndir] != 1) || (player->kartstuff[k_drift] <= -1 && player->kartstuff[k_turndir] != -1))
&& player->kartstuff[k_driftcharge] >= dsthree
&& onground)
{
if (player->kartstuff[k_driftboost] < 125)
player->kartstuff[k_driftboost] = 125;
S_StartSound(player->mo, sfx_s23c);
//K_SpawnDashDustRelease(player);
player->kartstuff[k_driftcharge] = 0;
} }
// Drifting: left or right? // Drifting: left or right?
@@ -6047,8 +6027,8 @@ static void K_KartDrift(player_t *player, boolean onground)
// Sound whenever you get a different tier of sparks // Sound whenever you get a different tier of sparks
if (driftblue if (driftblue
|| driftred || driftred
|| driftrainbow) || driftrainbow)
{ {
//S_StartSound(player->mo, sfx_s3ka2); //S_StartSound(player->mo, sfx_s3ka2);
if (P_IsLocalPlayer(player)) // UGHGHGH... if (P_IsLocalPlayer(player)) // UGHGHGH...
@@ -6183,13 +6163,6 @@ void K_KartUpdatePosition(player_t *player)
} }
} }
// the player should NOT be checked against themselves! lol
// otherwise prevcheck will effectively be halved
// sadly this stuff is exposed to lua and atleast one script uses those so we cant fix it
// oh well
//if (player == &players[i])
//continue;
const boolean isprevcheckpointi = mo->health == players[i].starpostnum; const boolean isprevcheckpointi = mo->health == players[i].starpostnum;
const boolean isnextcheckpointi = mo->health == (players[i].starpostnum + 1); const boolean isnextcheckpointi = mo->health == (players[i].starpostnum + 1);
@@ -6796,7 +6769,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
{ {
if (splitscreen) if (splitscreen)
{ {
if (!cv_reducevfx.value && leveltime & 1) if (leveltime & 1)
player->mo->flags2 |= MF2_DONTDRAW; player->mo->flags2 |= MF2_DONTDRAW;
else else
player->mo->flags2 &= ~MF2_DONTDRAW; player->mo->flags2 &= ~MF2_DONTDRAW;
@@ -6822,7 +6795,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
if (P_IsDisplayPlayer(player) if (P_IsDisplayPlayer(player)
|| (!P_IsDisplayPlayer(player) && (player->kartstuff[k_hyudorotimer] < (1*TICRATE/2) || player->kartstuff[k_hyudorotimer] > hyudorotime-(1*TICRATE/2)))) || (!P_IsDisplayPlayer(player) && (player->kartstuff[k_hyudorotimer] < (1*TICRATE/2) || player->kartstuff[k_hyudorotimer] > hyudorotime-(1*TICRATE/2))))
{ {
if (!cv_reducevfx.value && leveltime & 1) if (leveltime & 1)
player->mo->flags2 |= MF2_DONTDRAW; player->mo->flags2 |= MF2_DONTDRAW;
else else
player->mo->flags2 &= ~MF2_DONTDRAW; player->mo->flags2 &= ~MF2_DONTDRAW;
+1 -1
View File
@@ -57,7 +57,7 @@ boolean K_ShouldSlopeRoll(mobj_t *mobj);
void K_RollMobjBySlopes(mobj_t *mo, pslope_t *slope); void K_RollMobjBySlopes(mobj_t *mo, pslope_t *slope);
void K_SpawnBoostTrail(player_t *player); void K_SpawnBoostTrail(player_t *player);
void K_SpawnSparkleTrail(mobj_t *mo); void K_SpawnSparkleTrail(mobj_t *mo);
mobj_t *K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent); void K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent);
void K_DriftDustHandling(mobj_t *spawner); void K_DriftDustHandling(mobj_t *spawner);
void K_PuntMine(mobj_t *mine, mobj_t *punter); void K_PuntMine(mobj_t *mine, mobj_t *punter);
void K_DoSneaker(player_t *player, INT32 type); void K_DoSneaker(player_t *player, INT32 type);
+2 -1
View File
@@ -99,7 +99,8 @@ void K_EraseStats(void)
// The only field we want to remember // The only field we want to remember
boolean vanilla = kartstats.vanilla; boolean vanilla = kartstats.vanilla;
Z_Free(kartstats.copy); if (kartstats.copy)
Z_Free(kartstats.copy);
memset(&kartstats, 0, sizeof(kartstats_t)); memset(&kartstats, 0, sizeof(kartstats_t));
-1
View File
@@ -1293,7 +1293,6 @@ static int lib_pPlayRinglossSound(lua_State *L)
player_t *player = NULL; player_t *player = NULL;
mobj_t *damager = NULL; mobj_t *damager = NULL;
NOHUD NOHUD
LUA_UsageWarning(L, "P_PlayRinglossSound: using this function from lua might cause desynchs, consider using S_StartSound(origin, sfx_khurt1 + P_RandomKey(2)) as workaround");
if (!source) if (!source)
return LUA_ErrInvalid(L, "mobj_t"); return LUA_ErrInvalid(L, "mobj_t");
if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) if (!lua_isnone(L, 2) && lua_isuserdata(L, 2))
+22 -22
View File
@@ -615,7 +615,7 @@ FUNCINLINE static ATTRINLINE void res_hud(Hook_State *hook)
int LUA_HookMobj(mobj_t *mobj, int hook_type) int LUA_HookMobj(mobj_t *mobj, int hook_type)
{ {
Hook_State hook = {}; Hook_State hook;
if (prepare_mobj_hook(&hook, false, hook_type, mobj)) if (prepare_mobj_hook(&hook, false, hook_type, mobj))
{ {
LUA_PushUserdata(gL, mobj, META_MOBJ); LUA_PushUserdata(gL, mobj, META_MOBJ);
@@ -626,7 +626,7 @@ int LUA_HookMobj(mobj_t *mobj, int hook_type)
int LUA_Hook2Mobj(mobj_t *t1, mobj_t *t2, int hook_type) int LUA_Hook2Mobj(mobj_t *t1, mobj_t *t2, int hook_type)
{ {
Hook_State hook = {}; Hook_State hook;
if (prepare_mobj_hook(&hook, 0, hook_type, t1)) if (prepare_mobj_hook(&hook, 0, hook_type, t1))
{ {
LUA_PushUserdata(gL, t1, META_MOBJ); LUA_PushUserdata(gL, t1, META_MOBJ);
@@ -638,14 +638,14 @@ int LUA_Hook2Mobj(mobj_t *t1, mobj_t *t2, int hook_type)
void LUA_HookVoid(int type) void LUA_HookVoid(int type)
{ {
Hook_State hook = {}; Hook_State hook;
if (prepare_hook(&hook, 0, type)) if (prepare_hook(&hook, 0, type))
call_hooks(&hook, 0, res_none); call_hooks(&hook, 0, res_none);
} }
void LUA_HookInt(INT32 number, int hook_type) void LUA_HookInt(INT32 number, int hook_type)
{ {
Hook_State hook = {}; Hook_State hook;
if (prepare_hook(&hook, 0, hook_type)) if (prepare_hook(&hook, 0, hook_type))
{ {
lua_pushinteger(gL, number); lua_pushinteger(gL, number);
@@ -655,7 +655,7 @@ void LUA_HookInt(INT32 number, int hook_type)
/*void LUA_HookBool(boolean value, int hook_type) /*void LUA_HookBool(boolean value, int hook_type)
{ {
Hook_State hook = {}; Hook_State hook;
if (prepare_hook(&hook, 0, hook_type)) if (prepare_hook(&hook, 0, hook_type))
{ {
//lua_pushboolean(gL, value); //lua_pushboolean(gL, value);
@@ -665,7 +665,7 @@ void LUA_HookInt(INT32 number, int hook_type)
int LUA_HookPlayer(player_t *player, int hook_type) int LUA_HookPlayer(player_t *player, int hook_type)
{ {
Hook_State hook = {}; Hook_State hook;
if (prepare_hook(&hook, false, hook_type)) if (prepare_hook(&hook, false, hook_type))
{ {
LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, player, META_PLAYER);
@@ -676,7 +676,7 @@ int LUA_HookPlayer(player_t *player, int hook_type)
int LUA_HookTiccmd(player_t *player, ticcmd_t *cmd, int hook_type) int LUA_HookTiccmd(player_t *player, ticcmd_t *cmd, int hook_type)
{ {
Hook_State hook = {}; Hook_State hook;
if (prepare_hook(&hook, false, hook_type)) if (prepare_hook(&hook, false, hook_type))
{ {
LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, player, META_PLAYER);
@@ -695,7 +695,7 @@ int LUA_HookTiccmd(player_t *player, ticcmd_t *cmd, int hook_type)
void LUA_HookHUD(int hook_type, huddrawlist_h list) void LUA_HookHUD(int hook_type, huddrawlist_h list)
{ {
Hook_State hook = {}; Hook_State hook;
if (prepare_hud_hook(&hook, hook_type)) if (prepare_hud_hook(&hook, hook_type))
{ {
LUA_SetHudHook(hook_type, list); LUA_SetHudHook(hook_type, list);
@@ -723,7 +723,7 @@ static void hook_think_frame(int type)
int hook_index = 0; int hook_index = 0;
precise_t time_taken = 0; precise_t time_taken = 0;
Hook_State hook = {}; Hook_State hook;
const hook_t * map = &hookIds[type]; const hook_t * map = &hookIds[type];
int k; int k;
@@ -783,7 +783,7 @@ void LUA_HookPostThinkFrame(void)
int LUA_HookTouchSpecial(mobj_t *special, mobj_t *toucher) int LUA_HookTouchSpecial(mobj_t *special, mobj_t *toucher)
{ {
Hook_State hook = {}; Hook_State hook;
if (prepare_mobj_hook(&hook, false, MOBJ_HOOK(TouchSpecial), special)) if (prepare_mobj_hook(&hook, false, MOBJ_HOOK(TouchSpecial), special))
{ {
LUA_PushUserdata(gL, special, META_MOBJ); LUA_PushUserdata(gL, special, META_MOBJ);
@@ -802,7 +802,7 @@ static int damage_hook
int hook_type, int hook_type,
Hook_Callback results_handler Hook_Callback results_handler
){ ){
Hook_State hook = {}; Hook_State hook;
if (prepare_mobj_hook(&hook, 0, hook_type, target)) if (prepare_mobj_hook(&hook, 0, hook_type, target))
{ {
LUA_PushUserdata(gL, target, META_MOBJ); LUA_PushUserdata(gL, target, META_MOBJ);
@@ -890,8 +890,8 @@ int LUA_HookBotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
{ {
const char *skin = ((skin_t *)tails->skin)->name; const char *skin = ((skin_t *)tails->skin)->name;
Hook_State hook = {}; Hook_State hook;
BotAI_State botai = {}; BotAI_State botai;
if (prepare_string_hook(&hook, false, STRING_HOOK(BotAI), skin)) if (prepare_string_hook(&hook, false, STRING_HOOK(BotAI), skin))
{ {
@@ -911,7 +911,7 @@ int LUA_HookBotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
void LUA_HookLinedefExecute(line_t *line, mobj_t *mo, sector_t *sector) void LUA_HookLinedefExecute(line_t *line, mobj_t *mo, sector_t *sector)
{ {
Hook_State hook = {}; Hook_State hook;
if (prepare_string_hook if (prepare_string_hook
(&hook, 0, STRING_HOOK(LinedefExecute), line->text)) (&hook, 0, STRING_HOOK(LinedefExecute), line->text))
{ {
@@ -924,7 +924,7 @@ void LUA_HookLinedefExecute(line_t *line, mobj_t *mo, sector_t *sector)
int LUA_HookPlayerMsg(int source, int target, int flags, char *msg, int mute) int LUA_HookPlayerMsg(int source, int target, int flags, char *msg, int mute)
{ {
Hook_State hook = {}; Hook_State hook;
if (prepare_hook(&hook, false, HOOK(PlayerMsg))) if (prepare_hook(&hook, false, HOOK(PlayerMsg)))
{ {
LUA_PushUserdata(gL, &players[source], META_PLAYER); // Source player LUA_PushUserdata(gL, &players[source], META_PLAYER); // Source player
@@ -953,7 +953,7 @@ int LUA_HookPlayerMsg(int source, int target, int flags, char *msg, int mute)
int LUA_HookHurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source) int LUA_HookHurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source)
{ {
Hook_State hook = {}; Hook_State hook;
if (prepare_mobj_hook(&hook, false, MOBJ_HOOK(HurtMsg), inflictor)) if (prepare_mobj_hook(&hook, false, MOBJ_HOOK(HurtMsg), inflictor))
{ {
LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, player, META_PLAYER);
@@ -967,7 +967,7 @@ int LUA_HookHurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source)
void LUA_HookNetArchive(lua_CFunction archFunc, savebuffer_t *save) void LUA_HookNetArchive(lua_CFunction archFunc, savebuffer_t *save)
{ {
const hook_t * map = &hookIds[HOOK(NetVars)]; const hook_t * map = &hookIds[HOOK(NetVars)];
Hook_State hook = {}; Hook_State hook;
/* this is a remarkable case where the stack isn't reset */ /* this is a remarkable case where the stack isn't reset */
if (map->numHooks > 0) if (map->numHooks > 0)
{ {
@@ -997,7 +997,7 @@ void LUA_HookNetArchive(lua_CFunction archFunc, savebuffer_t *save)
void LUA_HookPlayerQuit(player_t *plr, int reason) void LUA_HookPlayerQuit(player_t *plr, int reason)
{ {
Hook_State hook = {}; Hook_State hook;
if (prepare_hook(&hook, 0, HOOK(PlayerQuit))) if (prepare_hook(&hook, 0, HOOK(PlayerQuit)))
{ {
LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit
@@ -1060,7 +1060,7 @@ int LUA_HookMusicChange(const char *oldname, struct MusicChange *param)
const int type = HOOK(MusicChange); const int type = HOOK(MusicChange);
const hook_t * map = &hookIds[type]; const hook_t * map = &hookIds[type];
Hook_State hook = {}; Hook_State hook;
int k; int k;
@@ -1096,7 +1096,7 @@ int LUA_HookMusicChange(const char *oldname, struct MusicChange *param)
int LUA_HookMusicCredit(musicdef_t *musicdef) int LUA_HookMusicCredit(musicdef_t *musicdef)
{ {
Hook_State hook = {}; Hook_State hook;
if (prepare_hook(&hook, 0, HOOK(MusicCredit))) if (prepare_hook(&hook, 0, HOOK(MusicCredit)))
{ {
LUA_PushUserdata(gL, musicdef, META_MUSICDEF); LUA_PushUserdata(gL, musicdef, META_MUSICDEF);
@@ -1114,7 +1114,7 @@ static int kartdamage_hook
int hook_type, int hook_type,
Hook_Callback results_handler Hook_Callback results_handler
){ ){
Hook_State hook = {}; Hook_State hook;
if (prepare_hook(&hook, 0, hook_type)) if (prepare_hook(&hook, 0, hook_type))
{ {
LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, player, META_PLAYER);
@@ -1163,7 +1163,7 @@ boolean LUA_HookPlayerExplode(player_t *player, mobj_t *inflictor, mobj_t *sourc
void LUA_HookSetupVote(INT16 result[], INT16 maxresults, UINT8 gt, UINT8 secondgt) void LUA_HookSetupVote(INT16 result[], INT16 maxresults, UINT8 gt, UINT8 secondgt)
{ {
Hook_State hook = {}; Hook_State hook;
if (prepare_hook(&hook, 0, HOOK(SetupVote))) if (prepare_hook(&hook, 0, HOOK(SetupVote)))
{ {
// { 0, 0, 0, 0, } // { 0, 0, 0, 0, }
+10 -65
View File
@@ -149,8 +149,7 @@ enum cameraf {
camera_momx, camera_momx,
camera_momy, camera_momy,
camera_momz, camera_momz,
camera_pnum, camera_pnum
camera_freecam,
}; };
@@ -170,7 +169,6 @@ static const char *const camera_opt[] = {
"momy", "momy",
"momz", "momz",
"pnum", "pnum",
"freecam",
NULL}; NULL};
enum hudpatch { enum hudpatch {
@@ -389,43 +387,10 @@ static int camera_get(lua_State *L)
case camera_pnum: case camera_pnum:
lua_pushinteger(L, camnum); lua_pushinteger(L, camnum);
break; break;
case camera_freecam:
lua_pushboolean(L, cam->freecam);
break;
} }
return 1; return 1;
} }
static int lib_getCamera(lua_State *L)
{
// No cameras on dedicated
if (dedicated)
return 0;
if (lua_type(L, 2) == LUA_TNUMBER)
{
int i = lua_tonumber(L, 2);
if (i < 0 || i > splitscreen)
return 0;
LUA_PushUserdata(L, &camera[i], META_CAMERA);
return 1;
}
return 0;
}
static int lib_lenCamera(lua_State *L)
{
if (dedicated)
lua_pushinteger(L, 0);
else
lua_pushinteger(L, splitscreen+1); // splitscreen == 0 -> 1 active camera, splitscreen == 1 -> 2 cameras and so on
return 1;
}
// //
// lib_draw // lib_draw
// //
@@ -1287,33 +1252,23 @@ extern int lib_hudadd(lua_State *L);
static int lib_hudsetvotebackground(lua_State *L) static int lib_hudsetvotebackground(lua_State *L)
{ {
// Reset to default
memset(VoteScreen.luaPrefix, 0, sizeof(VoteScreen.luaPrefix)); memset(VoteScreen.luaPrefix, 0, sizeof(VoteScreen.luaPrefix));
VoteScreen.timePerAnimFrame = 2;
if (!lua_isnoneornil(L, 1)) if (lua_isnoneornil(L, 1))
{ {
const char *prefix = luaL_checkstring(L, 1); return 0;
if (strlen(prefix) != 4)
{
return luaL_argerror(L, 1, "prefix should 4 characters wide");
}
strncpy(VoteScreen.luaPrefix, prefix, 4);
strupr(VoteScreen.luaPrefix);
} }
if (!lua_isnoneornil(L, 2)) const char *prefix = luaL_checkstring(L, 1);
if (strlen(prefix) != 4)
{ {
INT32 time_per_frame = luaL_checkinteger(L, 2); return luaL_argerror(L, 1, "prefix should 4 characters wide");
if (time_per_frame <= 0)
return luaL_argerror(L, 2, "time per frame should be 1 or more");
VoteScreen.timePerAnimFrame = time_per_frame;
} }
strncpy(VoteScreen.luaPrefix, prefix, 4);
strupr(VoteScreen.luaPrefix);
// Update background if we're already on vote screen // Update background if we're already on vote screen
if (gamestate == GS_VOTING) if (gamestate == GS_VOTING)
Y_VoteScreenCheck(); Y_VoteScreenCheck();
@@ -1416,16 +1371,6 @@ int LUA_HudLib(lua_State *L)
lua_setfield(L, -2, "__index"); lua_setfield(L, -2, "__index");
lua_pop(L,1); lua_pop(L,1);
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getCamera);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_lenCamera);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "cameras");
camera_fields_ref = Lua_CreateFieldTable(L, camera_opt); camera_fields_ref = Lua_CreateFieldTable(L, camera_opt);
luaL_register(L, "hud", lib_hud); luaL_register(L, "hud", lib_hud);
Loaded 100 of 178 files, more files were not shown because too many files have changed in this diff. Show more