Merge remote-tracking branch 'origin/master' into freeplay
This commit is contained in:
commit
a6c831b5a0
209 files changed
+14868
-12386
No files matched your search
@@ -36,7 +36,7 @@ jobs:
|
||||
- v1-SRB2-APT
|
||||
- run:
|
||||
name: Install SDK
|
||||
command: apt-get -qq -y --no-install-recommends install git build-essential nasm libpng-dev:i386 libsdl2-mixer-dev:i386 libgme-dev:i386 gettext ccache wget gcc-multilib upx openssh-client
|
||||
command: apt-get -qq -y --no-install-recommends install git build-essential nasm libpng-dev:i386 libsdl2-mixer-dev:i386 libgme-dev:i386 libcurl4-openssl-dev:i386 gettext ccache wget gcc-multilib upx openssh-client
|
||||
- save_cache:
|
||||
key: v1-SRB2-APT
|
||||
paths:
|
||||
|
||||
+68
-49
@@ -23,6 +23,7 @@ matrix:
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- gcc-4.4
|
||||
compiler: gcc-4.4
|
||||
@@ -37,6 +38,7 @@ matrix:
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- gcc-4.6
|
||||
compiler: gcc-4.6
|
||||
@@ -51,6 +53,7 @@ matrix:
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- gcc-4.7
|
||||
compiler: gcc-4.7
|
||||
@@ -72,6 +75,7 @@ matrix:
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- gcc-4.8
|
||||
compiler: gcc-4.8
|
||||
@@ -88,6 +92,7 @@ matrix:
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- gcc-7
|
||||
compiler: gcc-7
|
||||
@@ -104,6 +109,7 @@ matrix:
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- gcc-8
|
||||
compiler: gcc-8
|
||||
@@ -124,6 +130,7 @@ matrix:
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- clang-3.5
|
||||
compiler: clang-3.5
|
||||
@@ -140,6 +147,7 @@ matrix:
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- clang-3.6
|
||||
compiler: clang-3.6
|
||||
@@ -156,6 +164,7 @@ matrix:
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- clang-3.7
|
||||
compiler: clang-3.7
|
||||
@@ -172,6 +181,7 @@ matrix:
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- clang-3.8
|
||||
compiler: clang-3.8
|
||||
@@ -188,6 +198,7 @@ matrix:
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- clang-3.9
|
||||
compiler: clang-3.9
|
||||
@@ -294,6 +305,7 @@ matrix:
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- gcc-4.8
|
||||
compiler: gcc-4.8
|
||||
@@ -435,6 +447,31 @@ matrix:
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- gcc-4.8
|
||||
compiler: gcc-4.8
|
||||
dist: xenial
|
||||
if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1")
|
||||
AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1"))
|
||||
AND env(DPL_TERMINATE_MAIN) != "1"
|
||||
env:
|
||||
- _DPL_JOB_ENABLED=1
|
||||
- _DPL_JOB_NAME=focal
|
||||
- _DPL_DPUT_TARGET=1
|
||||
- _DPL_PACKAGE_SOURCE=1
|
||||
- PACKAGE_DISTRO=focal
|
||||
- PACKAGE_SUBVERSION=~20.04focal
|
||||
#gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
|
||||
- os: linux
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libsdl2-mixer-dev
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- gcc-4.8
|
||||
compiler: gcc-4.8
|
||||
@@ -458,6 +495,31 @@ matrix:
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- gcc-4.8
|
||||
compiler: gcc-4.8
|
||||
dist: xenial
|
||||
if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1")
|
||||
AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1"))
|
||||
AND env(DPL_TERMINATE_MAIN) != "1"
|
||||
env:
|
||||
- _DPL_JOB_ENABLED=1
|
||||
- _DPL_JOB_NAME=xenial
|
||||
- _DPL_DPUT_TARGET=1
|
||||
- _DPL_PACKAGE_SOURCE=1
|
||||
- PACKAGE_DISTRO=xenial
|
||||
- PACKAGE_SUBVERSION=~16.04xenial
|
||||
#gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
|
||||
- os: linux
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libsdl2-mixer-dev
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- gcc-4.8
|
||||
compiler: gcc-4.8
|
||||
@@ -481,6 +543,7 @@ matrix:
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- gcc-4.8
|
||||
compiler: gcc-4.8
|
||||
@@ -490,57 +553,11 @@ matrix:
|
||||
AND env(DPL_TERMINATE_MAIN) != "1"
|
||||
env:
|
||||
- _DPL_JOB_ENABLED=1
|
||||
- _DPL_JOB_NAME=disco
|
||||
- _DPL_JOB_NAME=eoan
|
||||
- _DPL_DPUT_TARGET=1
|
||||
- _DPL_PACKAGE_SOURCE=1
|
||||
- PACKAGE_DISTRO=disco
|
||||
- PACKAGE_SUBVERSION=~19.04disco
|
||||
#gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
|
||||
- os: linux
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libsdl2-mixer-dev
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- p7zip-full
|
||||
- gcc-4.8
|
||||
compiler: gcc-4.8
|
||||
dist: xenial
|
||||
if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1")
|
||||
AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1"))
|
||||
AND env(DPL_TERMINATE_MAIN) != "1"
|
||||
env:
|
||||
- _DPL_JOB_ENABLED=1
|
||||
- _DPL_JOB_NAME=cosmic
|
||||
- _DPL_DPUT_TARGET=1
|
||||
- _DPL_PACKAGE_SOURCE=1
|
||||
- PACKAGE_DISTRO=cosmic
|
||||
- PACKAGE_SUBVERSION=~18.10cosmic
|
||||
#gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
|
||||
- os: linux
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libsdl2-mixer-dev
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- p7zip-full
|
||||
- gcc-4.8
|
||||
compiler: gcc-4.8
|
||||
dist: xenial
|
||||
if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1")
|
||||
AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1"))
|
||||
AND env(DPL_TERMINATE_MAIN) != "1"
|
||||
env:
|
||||
- _DPL_JOB_ENABLED=1
|
||||
- _DPL_JOB_NAME=xenial
|
||||
- _DPL_DPUT_TARGET=1
|
||||
- _DPL_PACKAGE_SOURCE=1
|
||||
- PACKAGE_DISTRO=xenial
|
||||
- PACKAGE_SUBVERSION=~16.04xenial
|
||||
- PACKAGE_DISTRO=eoan
|
||||
- PACKAGE_SUBVERSION=~19.10eoan
|
||||
#gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
|
||||
allow_failures:
|
||||
- compiler: clang-3.5
|
||||
@@ -567,6 +584,7 @@ addons:
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- zlib1g-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
homebrew:
|
||||
taps:
|
||||
@@ -576,6 +594,7 @@ addons:
|
||||
- game-music-emu
|
||||
- p7zip
|
||||
- cmake
|
||||
- curl
|
||||
update: true
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)
|
||||
# DO NOT CHANGE THIS SRB2 STRING! Some variable names depend on this string.
|
||||
# Version change is fine.
|
||||
project(SRB2
|
||||
VERSION 1.1.0
|
||||
VERSION 1.3
|
||||
LANGUAGES C)
|
||||
|
||||
if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR})
|
||||
|
||||
+141
-145
@@ -1,145 +1,141 @@
|
||||
version: 1.1.0.{branch}-{build}
|
||||
os: MinGW
|
||||
|
||||
environment:
|
||||
CC: ccache
|
||||
CCACHE_CC: i686-w64-mingw32-gcc
|
||||
CCACHE_CC_64: x86_64-w64-mingw32-gcc
|
||||
WINDRES: windres
|
||||
# c:\mingw-w64 i686 has gcc 6.3.0, so use c:\msys64 7.3.0 instead
|
||||
MINGW_SDK: c:\msys64\mingw32
|
||||
# c:\msys64 x86_64 has gcc 8.2.0, so use c:\mingw-w64 7.3.0 instead
|
||||
MINGW_SDK_64: C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64
|
||||
CFLAGS: -Wall -W -Werror -Wno-error=implicit-fallthrough -Wimplicit-fallthrough=3 -Wno-tautological-compare -Wno-error=suggest-attribute=noreturn
|
||||
NASM_ZIP: nasm-2.12.01
|
||||
NASM_URL: http://www.nasm.us/pub/nasm/releasebuilds/2.12.01/win64/nasm-2.12.01-win64.zip
|
||||
UPX_ZIP: upx391w
|
||||
UPX_URL: http://upx.sourceforge.net/download/upx391w.zip
|
||||
CCACHE_EXE: ccache.exe
|
||||
CCACHE_URL: http://alam.srb2.org/ccache.exe
|
||||
CCACHE_COMPRESS: true
|
||||
CCACHE_DIR: C:\Users\appveyor\.ccache
|
||||
# Disable UPX by default. The user can override this in their Appveyor project settings
|
||||
NOUPX: 1
|
||||
##############################
|
||||
# DEPLOYER VARIABLES
|
||||
# DPL_ENABLED=1 builds installers for branch names starting with `deployer`.
|
||||
# DPL_TAG_ENABLED=1 will also build installers for release tags. DPL_ENABLED=1 must also be set.
|
||||
# Set these in the Appveyor project settings
|
||||
##############################
|
||||
DPL_ENABLED: 0
|
||||
DPL_TAG_ENABLED: 0
|
||||
DPL_INSTALLER_NAME: srb2kart-v110
|
||||
# Asset handling is barebones vs. Travis Deployer. We operate on 7z only.
|
||||
# Include the README files and the OpenGL batch in the main and patch archives.
|
||||
# The x86/x64 archives contain the DLL binaries.
|
||||
ASSET_ARCHIVE_PATH: https://github.com/mazmazz/Kart-Public/releases/download/kart_assets/srb2kart-v102-assets.7z
|
||||
ASSET_ARCHIVE_PATCH_PATH: https://github.com/mazmazz/Kart-Public/releases/download/kart_assets/srb2kart-v102-patch-assets.7z
|
||||
ASSET_ARCHIVE_X86_PATH: https://github.com/mazmazz/Kart-Public/releases/download/kart_assets/srb2kart-v102-x86-assets.7z
|
||||
ASSET_ARCHIVE_X64_PATH: https://github.com/mazmazz/Kart-Public/releases/download/kart_assets/srb2kart-v102-x64-assets.7z
|
||||
ASSET_ARCHIVE_OPTIONAL_PATH: https://github.com/mazmazz/Kart-Public/releases/download/kart_assets/srb2kart-v102-optional-assets.7z
|
||||
# This is overridden to 1 for release tag builds
|
||||
ASSET_FILES_OPTIONAL_GET: 0
|
||||
# For patches, also include the X86/X64 DLLs.
|
||||
PACKAGE_PATCH_DLL_GET: 0
|
||||
# Delete all asset downloads so they can be redownloaded
|
||||
ASSET_CLEAN: 0
|
||||
|
||||
cache:
|
||||
- nasm-2.12.01.zip
|
||||
- upx391w.zip
|
||||
- ccache.exe
|
||||
- C:\Users\appveyor\.ccache
|
||||
- C:\Users\appveyor\srb2_cache
|
||||
|
||||
install:
|
||||
- if [%CONFIGURATION%] == [SDL64] ( set "X86_64=1" )
|
||||
- if [%CONFIGURATION%] == [SDL64] ( set "CONFIGURATION=SDL" )
|
||||
- if [%CONFIGURATION%] == [DD64] ( set "X86_64=1" )
|
||||
- if [%CONFIGURATION%] == [DD64] ( set "CONFIGURATION=DD" )
|
||||
- if [%X86_64%] == [1] ( set "MINGW_SDK=%MINGW_SDK_64%" )
|
||||
- if [%X86_64%] == [1] ( set "CCACHE_CC=%CCACHE_CC_64%" )
|
||||
|
||||
- if not exist "%NASM_ZIP%.zip" appveyor DownloadFile "%NASM_URL%" -FileName "%NASM_ZIP%.zip"
|
||||
- 7z x -y "%NASM_ZIP%.zip" -o%TMP% >null
|
||||
- robocopy /S /xx /ns /nc /nfl /ndl /np /njh /njs "%TMP%\%NASM_ZIP%" "%MINGW_SDK%\bin" nasm.exe || exit 0
|
||||
|
||||
- if not exist "%UPX_ZIP%.zip" appveyor DownloadFile "%UPX_URL%" -FileName "%UPX_ZIP%.zip"
|
||||
- 7z x -y "%UPX_ZIP%.zip" -o%TMP% >null
|
||||
- robocopy /S /xx /ns /nc /nfl /ndl /np /njh /njs "%TMP%\%UPX_ZIP%" "%MINGW_SDK%\bin" upx.exe || exit 0
|
||||
|
||||
- if not exist "%CCACHE_EXE%" appveyor DownloadFile "%CCACHE_URL%" -FileName "%CCACHE_EXE%"
|
||||
- ccache -M 99M
|
||||
- xcopy /Y /V /I ccache.exe "%MINGW_SDK%\bin"
|
||||
|
||||
configuration:
|
||||
- SDL
|
||||
- SDL64
|
||||
#- DD
|
||||
#- DD64
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- configuration: DD
|
||||
- configuration: DD64
|
||||
|
||||
before_build:
|
||||
- set "Path=%MINGW_SDK%\bin;%Path%"
|
||||
- if [%X86_64%] == [1] ( x86_64-w64-mingw32-gcc --version ) else ( i686-w64-mingw32-gcc --version )
|
||||
- mingw32-make --version
|
||||
- if not [%X86_64%] == [1] ( nasm -v )
|
||||
- if not [%NOUPX%] == [1] ( upx -V )
|
||||
- ccache -V
|
||||
- ccache -s
|
||||
- if [%NOUPX%] == [1] ( set "NOUPX=NOUPX=1" ) else ( set "NOUPX=" )
|
||||
- set "SRB2_MFLAGS=-C src WARNINGMODE=1 CCACHE=1 GCC72=1 NOOBJDUMP=1 %NOUPX%"
|
||||
- if [%X86_64%] == [1] ( set "MINGW_FLAGS=MINGW64=1 X86_64=1" ) else ( set "MINGW_FLAGS=MINGW=1" )
|
||||
- set "SRB2_MFLAGS=%SRB2_MFLAGS% %MINGW_FLAGS% %CONFIGURATION%=1"
|
||||
|
||||
build_script:
|
||||
- cmd: mingw32-make.exe %SRB2_MFLAGS% clean
|
||||
- cmd: mingw32-make.exe %SRB2_MFLAGS% ERRORMODE=1 -k
|
||||
|
||||
after_build:
|
||||
- if [%X86_64%] == [1] (
|
||||
set "BUILD_PATH=bin\Mingw64\Release"
|
||||
) else (
|
||||
set "BUILD_PATH=bin\Mingw\Release"
|
||||
)
|
||||
- if [%X86_64%] == [1] ( set "CONFIGURATION=%CONFIGURATION%64" )
|
||||
- ccache -s
|
||||
- cmd: git rev-parse --short %APPVEYOR_REPO_COMMIT%>%TMP%/gitshort.txt
|
||||
- cmd: set /P GITSHORT=<%TMP%/gitshort.txt
|
||||
- set BUILD_ARCHIVE=%APPVEYOR_REPO_BRANCH%-%GITSHORT%-%CONFIGURATION%.7z
|
||||
- set BUILDSARCHIVE=%APPVEYOR_REPO_BRANCH%-%CONFIGURATION%.7z
|
||||
- cmd: 7z a %BUILD_ARCHIVE% %BUILD_PATH% -xr!.gitignore
|
||||
- appveyor PushArtifact %BUILD_ARCHIVE%
|
||||
- cmd: copy %BUILD_ARCHIVE% %BUILDSARCHIVE%
|
||||
- appveyor PushArtifact %BUILDSARCHIVE%
|
||||
##############################
|
||||
# DEPLOYER SCRIPT
|
||||
##############################
|
||||
- if [%DPL_ENABLED%] == [1] ( call "deployer\appveyor\deployer.bat" )
|
||||
|
||||
test: off
|
||||
|
||||
#deploy:
|
||||
# - provider: FTP
|
||||
# protocol: ftps
|
||||
# host:
|
||||
# secure: NsLJEPIBvmwCOj8Tg8RoRQ==
|
||||
# username:
|
||||
# secure: ejxi5mvk7oLYu7QtbYojajEPigMy0mokaKhuEVuDZcA=
|
||||
# password:
|
||||
# secure: Hbn6Uy3lT0YZ88yFJ3aW4w==
|
||||
# folder: appveyor
|
||||
# application:
|
||||
# active_mode: false
|
||||
# on:
|
||||
# branch: master
|
||||
# appveyor_repo_tag: true
|
||||
|
||||
|
||||
on_finish:
|
||||
#- cmd: echo xfreerdp /u:appveyor /cert-ignore +clipboard /v:<ip>:<port>
|
||||
#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
||||
version: 1.3.{branch}-{build}
|
||||
os: MinGW
|
||||
|
||||
environment:
|
||||
CC: ccache
|
||||
CCACHE_CC: i686-w64-mingw32-gcc
|
||||
CCACHE_CC_64: x86_64-w64-mingw32-gcc
|
||||
WINDRES: windres
|
||||
# c:\mingw-w64 i686 has gcc 6.3.0, so use c:\msys64 7.3.0 instead
|
||||
MINGW_SDK: c:\msys64\mingw32
|
||||
# c:\msys64 x86_64 has gcc 8.2.0, so use c:\mingw-w64 7.3.0 instead
|
||||
MINGW_SDK_64: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64
|
||||
CFLAGS: -Wall -W -Werror -Wno-error=implicit-fallthrough -Wimplicit-fallthrough=3 -Wno-tautological-compare -Wno-error=suggest-attribute=noreturn
|
||||
NASM_ZIP: nasm-2.12.01
|
||||
NASM_URL: http://www.nasm.us/pub/nasm/releasebuilds/2.12.01/win64/nasm-2.12.01-win64.zip
|
||||
UPX_ZIP: upx391w
|
||||
UPX_URL: http://upx.sourceforge.net/download/upx391w.zip
|
||||
CCACHE_EXE: ccache.exe
|
||||
CCACHE_URL: http://alam.srb2.org/ccache.exe
|
||||
CCACHE_COMPRESS: true
|
||||
CCACHE_DIR: C:\Users\appveyor\.ccache
|
||||
# Disable UPX by default. The user can override this in their Appveyor project settings
|
||||
NOUPX: 1
|
||||
##############################
|
||||
# DEPLOYER VARIABLES
|
||||
# DPL_ENABLED=1 builds installers for branch names starting with `deployer`.
|
||||
# DPL_TAG_ENABLED=1 will also build installers for release tags. DPL_ENABLED=1 must also be set.
|
||||
# Set these in the Appveyor project settings
|
||||
##############################
|
||||
DPL_ENABLED: 0
|
||||
DPL_TAG_ENABLED: 0
|
||||
DPL_INSTALLER_NAME: srb2kart-v13
|
||||
# Asset handling is barebones vs. Travis Deployer. We operate on 7z only.
|
||||
# Include the README files and the OpenGL batch in the main and patch archives.
|
||||
# The x86/x64 archives contain the DLL binaries.
|
||||
ASSET_ARCHIVE_PATH: https://github.com/mazmazz/Kart-Public/releases/download/kart_assets/srb2kart-v102-assets.7z
|
||||
ASSET_ARCHIVE_PATCH_PATH: https://github.com/mazmazz/Kart-Public/releases/download/kart_assets/srb2kart-v102-patch-assets.7z
|
||||
ASSET_ARCHIVE_X86_PATH: https://github.com/mazmazz/Kart-Public/releases/download/kart_assets/srb2kart-v102-x86-assets.7z
|
||||
ASSET_ARCHIVE_X64_PATH: https://github.com/mazmazz/Kart-Public/releases/download/kart_assets/srb2kart-v102-x64-assets.7z
|
||||
ASSET_ARCHIVE_OPTIONAL_PATH: https://github.com/mazmazz/Kart-Public/releases/download/kart_assets/srb2kart-v102-optional-assets.7z
|
||||
# This is overridden to 1 for release tag builds
|
||||
ASSET_FILES_OPTIONAL_GET: 0
|
||||
# For patches, also include the X86/X64 DLLs.
|
||||
PACKAGE_PATCH_DLL_GET: 0
|
||||
# Delete all asset downloads so they can be redownloaded
|
||||
ASSET_CLEAN: 0
|
||||
|
||||
cache:
|
||||
- nasm-2.12.01.zip
|
||||
- upx391w.zip
|
||||
- ccache.exe
|
||||
- C:\Users\appveyor\.ccache
|
||||
- C:\Users\appveyor\srb2_cache
|
||||
|
||||
install:
|
||||
- if [%CONFIGURATION%] == [SDL64] ( set "X86_64=1" )
|
||||
- if [%CONFIGURATION%] == [SDL64] ( set "CONFIGURATION=SDL" )
|
||||
- if [%X86_64%] == [1] ( set "MINGW_SDK=%MINGW_SDK_64%" )
|
||||
- if [%X86_64%] == [1] ( set "CCACHE_CC=%CCACHE_CC_64%" )
|
||||
|
||||
- if not exist "%NASM_ZIP%.zip" appveyor DownloadFile "%NASM_URL%" -FileName "%NASM_ZIP%.zip"
|
||||
- 7z x -y "%NASM_ZIP%.zip" -o%TMP% >null
|
||||
- robocopy /S /xx /ns /nc /nfl /ndl /np /njh /njs "%TMP%\%NASM_ZIP%" "%MINGW_SDK%\bin" nasm.exe || exit 0
|
||||
|
||||
- if not exist "%UPX_ZIP%.zip" appveyor DownloadFile "%UPX_URL%" -FileName "%UPX_ZIP%.zip"
|
||||
- 7z x -y "%UPX_ZIP%.zip" -o%TMP% >null
|
||||
- robocopy /S /xx /ns /nc /nfl /ndl /np /njh /njs "%TMP%\%UPX_ZIP%" "%MINGW_SDK%\bin" upx.exe || exit 0
|
||||
|
||||
- if not exist "%CCACHE_EXE%" appveyor DownloadFile "%CCACHE_URL%" -FileName "%CCACHE_EXE%"
|
||||
- ccache -M 99M
|
||||
- xcopy /Y /V /I ccache.exe "%MINGW_SDK%\bin"
|
||||
|
||||
configuration:
|
||||
- SDL
|
||||
#- SDL64
|
||||
|
||||
before_build:
|
||||
- set "Path=%MINGW_SDK%\bin;%Path%"
|
||||
- if [%X86_64%] == [1] ( x86_64-w64-mingw32-gcc --version ) else ( i686-w64-mingw32-gcc --version )
|
||||
- mingw32-make --version
|
||||
- if not [%X86_64%] == [1] ( nasm -v )
|
||||
- if not [%NOUPX%] == [1] ( upx -V )
|
||||
- ccache -V
|
||||
- ccache -s
|
||||
- if [%NOUPX%] == [1] ( set "NOUPX=NOUPX=1" ) else ( set "NOUPX=" )
|
||||
- if defined [%APPVEYOR_PULL_REQUEST_HEAD_COMMIT%] ( set "COMMIT=%APPVEYOR_PULL_REQUEST_HEAD_COMMIT%" ) else ( set "COMMIT=%APPVEYOR_REPO_COMMIT%" )
|
||||
- cmd: git rev-parse --short %COMMIT%>%TMP%/gitshort.txt
|
||||
- cmd: set /P GITSHORT=<%TMP%/gitshort.txt
|
||||
# for pull requests, take the owner's name only, if this isn't the same repo of course
|
||||
- set "REPO=%APPVEYOR_REPO_BRANCH%"
|
||||
- if not [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [] ( if not [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [%APPVEYOR_REPO_NAME%] ( for /f "delims=/" %%a in ("%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%") do set "REPO=%%a-%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%" ) )
|
||||
- set "EXENAME=EXENAME=srb2win-%REPO%-%GITSHORT%.exe"
|
||||
- set "SRB2_MFLAGS=-C src WARNINGMODE=1 CCACHE=1 NOOBJDUMP=1 %NOUPX% %EXENAME%"
|
||||
- if [%X86_64%] == [1] ( set "MINGW_FLAGS=MINGW64=1 X86_64=1 GCC81=1" ) else ( set "MINGW_FLAGS=MINGW=1 GCC91=1" )
|
||||
- set "SRB2_MFLAGS=%SRB2_MFLAGS% %MINGW_FLAGS% %CONFIGURATION%=1"
|
||||
|
||||
build_script:
|
||||
- cmd: mingw32-make.exe %SRB2_MFLAGS% clean
|
||||
- cmd: mingw32-make.exe %SRB2_MFLAGS% ERRORMODE=1 -k
|
||||
|
||||
after_build:
|
||||
- if [%X86_64%] == [1] (
|
||||
set "BUILD_PATH=bin\Mingw64\Release"
|
||||
) else (
|
||||
set "BUILD_PATH=bin\Mingw\Release"
|
||||
)
|
||||
- if [%X86_64%] == [1] ( set "CONFIGURATION=%CONFIGURATION%64" )
|
||||
- ccache -s
|
||||
- set BUILD_ARCHIVE=%REPO%-%GITSHORT%-%CONFIGURATION%.7z
|
||||
- set BUILDSARCHIVE=%REPO%-%CONFIGURATION%.7z
|
||||
- cmd: 7z a %BUILD_ARCHIVE% %BUILD_PATH% -xr!.gitignore
|
||||
- appveyor PushArtifact %BUILD_ARCHIVE%
|
||||
- cmd: copy %BUILD_ARCHIVE% %BUILDSARCHIVE%
|
||||
- appveyor PushArtifact %BUILDSARCHIVE%
|
||||
##############################
|
||||
# DEPLOYER SCRIPT
|
||||
##############################
|
||||
- if [%DPL_ENABLED%] == [1] ( call "deployer\appveyor\deployer.bat" )
|
||||
|
||||
test: off
|
||||
|
||||
#deploy:
|
||||
# - provider: FTP
|
||||
# protocol: ftps
|
||||
# host:
|
||||
# secure: NsLJEPIBvmwCOj8Tg8RoRQ==
|
||||
# username:
|
||||
# secure: ejxi5mvk7oLYu7QtbYojajEPigMy0mokaKhuEVuDZcA=
|
||||
# password:
|
||||
# secure: Hbn6Uy3lT0YZ88yFJ3aW4w==
|
||||
# folder: appveyor
|
||||
# application:
|
||||
# active_mode: false
|
||||
# on:
|
||||
# branch: master
|
||||
# appveyor_repo_tag: true
|
||||
|
||||
|
||||
on_finish:
|
||||
#- cmd: echo xfreerdp /u:appveyor /cert-ignore +clipboard /v:<ip>:<port>
|
||||
#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
||||
@@ -0,0 +1,23 @@
|
||||
include(LibFindMacros)
|
||||
|
||||
libfind_pkg_check_modules(DISCORDRPC_PKGCONF DISCORDRPC)
|
||||
|
||||
find_path(DISCORDRPC_INCLUDE_DIR
|
||||
NAMES discord_rpc.h
|
||||
PATHS
|
||||
${DISCORDRPC_PKGCONF_INCLUDE_DIRS}
|
||||
"/usr/include"
|
||||
"/usr/local/include"
|
||||
)
|
||||
|
||||
find_library(DISCORDRPC_LIBRARY
|
||||
NAMES discord-rpc
|
||||
PATHS
|
||||
${DISCORDRPC_PKGCONF_LIBRARY_DIRS}
|
||||
"/usr/lib"
|
||||
"/usr/local/lib"
|
||||
)
|
||||
|
||||
set(DISCORDRPC_PROCESS_INCLUDES DISCORDRPC_INCLUDE_DIR)
|
||||
set(DISCORDRPC_PROCESS_LIBS DISCORDRPC_LIBRARY)
|
||||
libfind_process(DISCORDRPC)
|
||||
@@ -10,6 +10,7 @@ Build-Depends: debhelper (>= 7.0.50~),
|
||||
libpng-dev | libpng16-dev | libpng12-dev (>= 1.2.7),
|
||||
zlib1g-dev,
|
||||
libgme-dev,
|
||||
libcurl4-openssl-dev,
|
||||
libglu1-dev | libglu-dev,
|
||||
libosmesa6-dev | libgl-dev,
|
||||
nasm [i386]
|
||||
@@ -24,6 +25,7 @@ Depends: ${SHLIBS_DEPENDS}, ${MISC_DEPENDS},
|
||||
libsdl2-mixer-2.0-0,
|
||||
zlib1g,
|
||||
libgme0,
|
||||
libcurl4,
|
||||
libpng | libpng16-16 | libpng12-0
|
||||
Description: A cross-platform 3D Sonic fangame
|
||||
Sonic Robo Blast 2 is a 3D open-source Sonic the Hedgehog
|
||||
|
||||
+3
-17
@@ -1,6 +1,6 @@
|
||||
# SRB2Kart - Which DLLs do I need to bundle?
|
||||
|
||||
Updated 12/4/2018 (v2.1.21)
|
||||
Updated 8/23/2020 (v1.3)
|
||||
|
||||
Here are the required DLLs, per build. For each architecture, copy all the binaries from these folders:
|
||||
|
||||
@@ -14,6 +14,7 @@ and don't forget to build r_opengl.dll for srb2dd.
|
||||
|
||||
* libs\dll-binaries\i686\exchndl.dll
|
||||
* libs\dll-binaries\i686\libgme.dll
|
||||
* libs\dll-binaries\i686\discord-rpc.dll
|
||||
* libs\dll-binaries\i686\mgwhelp.dll (depend for exchndl.dll)
|
||||
* libs\SDL2\i686-w64-mingw32\bin\SDL2.dll
|
||||
* libs\SDL2_mixer\i686-w64-mingw32\bin\*.dll (get everything)
|
||||
@@ -22,22 +23,7 @@ and don't forget to build r_opengl.dll for srb2dd.
|
||||
|
||||
* libs\dll-binaries\x86_64\exchndl.dll
|
||||
* libs\dll-binaries\x86_64\libgme.dll
|
||||
* libs\dll-binaries\x86_64\discord-rpc.dll
|
||||
* libs\dll-binaries\x86_64\mgwhelp.dll (depend for exchndl.dll)
|
||||
* libs\SDL2\x86_64-w64-mingw32\bin\SDL2.dll
|
||||
* libs\SDL2_mixer\x86_64-w64-mingw32\bin\*.dll (get everything)
|
||||
|
||||
## srb2kartdd, 32-bit
|
||||
|
||||
* libs\dll-binaries\i686\exchndl.dll
|
||||
* libs\dll-binaries\i686\fmodex.dll
|
||||
* libs\dll-binaries\i686\libgme.dll
|
||||
* libs\dll-binaries\i686\mgwhelp.dll (depend for exchndl.dll)
|
||||
* r_opengl.dll (build this from make)
|
||||
|
||||
## srb2kartdd, 64-bit
|
||||
|
||||
* libs\dll-binaries\x86_64\exchndl.dll
|
||||
* libs\dll-binaries\x86_64\fmodex.dll
|
||||
* libs\dll-binaries\x86_64\libgme.dll
|
||||
* libs\dll-binaries\x86_64\mgwhelp.dll (depend for exchndl.dll)
|
||||
* r_opengl.dll (build this from make)
|
||||
+1136
-413
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,5 @@
|
||||
#ifndef __CURL_CURLVER_H
|
||||
#define __CURL_CURLVER_H
|
||||
#ifndef CURLINC_CURLVER_H
|
||||
#define CURLINC_CURLVER_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
@@ -7,11 +7,11 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
@@ -26,17 +26,17 @@
|
||||
a script at release-time. This was made its own header file in 7.11.2 */
|
||||
|
||||
/* This is the global package copyright */
|
||||
#define LIBCURL_COPYRIGHT "1996 - 2011 Daniel Stenberg, <daniel@haxx.se>."
|
||||
#define LIBCURL_COPYRIGHT "1996 - 2020 Daniel Stenberg, <daniel@haxx.se>."
|
||||
|
||||
/* This is the version number of the libcurl package from which this header
|
||||
file origins: */
|
||||
#define LIBCURL_VERSION "7.21.6"
|
||||
#define LIBCURL_VERSION "7.69.0"
|
||||
|
||||
/* The numeric version number is also available "in parts" by using these
|
||||
defines: */
|
||||
#define LIBCURL_VERSION_MAJOR 7
|
||||
#define LIBCURL_VERSION_MINOR 21
|
||||
#define LIBCURL_VERSION_PATCH 6
|
||||
#define LIBCURL_VERSION_MINOR 69
|
||||
#define LIBCURL_VERSION_PATCH 0
|
||||
|
||||
/* This is the numeric version of the libcurl version number, meant for easier
|
||||
parsing and comparions by programs. The LIBCURL_VERSION_NUM define will
|
||||
@@ -52,18 +52,26 @@
|
||||
This 6-digit (24 bits) hexadecimal number does not show pre-release number,
|
||||
and it is always a greater number in a more recent release. It makes
|
||||
comparisons with greater than and less than work.
|
||||
|
||||
Note: This define is the full hex number and _does not_ use the
|
||||
CURL_VERSION_BITS() macro since curl's own configure script greps for it
|
||||
and needs it to contain the full number.
|
||||
*/
|
||||
#define LIBCURL_VERSION_NUM 0x071506
|
||||
#define LIBCURL_VERSION_NUM 0x074500
|
||||
|
||||
/*
|
||||
* This is the date and time when the full source package was created. The
|
||||
* timestamp is not stored in git, as the timestamp is properly set in the
|
||||
* tarballs by the maketgz script.
|
||||
*
|
||||
* The format of the date should follow this template:
|
||||
* The format of the date follows this template:
|
||||
*
|
||||
* "Mon Feb 12 11:35:33 UTC 2007"
|
||||
* "2007-11-23"
|
||||
*/
|
||||
#define LIBCURL_TIMESTAMP "Fri Apr 22 17:18:50 UTC 2011"
|
||||
#define LIBCURL_TIMESTAMP "2020-03-04"
|
||||
|
||||
#endif /* __CURL_CURLVER_H */
|
||||
#define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|(z))
|
||||
#define CURL_AT_LEAST_VERSION(x,y,z) \
|
||||
(LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z))
|
||||
|
||||
#endif /* CURLINC_CURLVER_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef __CURL_EASY_H
|
||||
#define __CURL_EASY_H
|
||||
#ifndef CURLINC_EASY_H
|
||||
#define CURLINC_EASY_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
@@ -7,11 +7,11 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
@@ -58,7 +58,7 @@ CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...);
|
||||
* curl_easy_duphandle() for each new thread to avoid a series of identical
|
||||
* curl_easy_setopt() invokes in every thread.
|
||||
*/
|
||||
CURL_EXTERN CURL* curl_easy_duphandle(CURL *curl);
|
||||
CURL_EXTERN CURL *curl_easy_duphandle(CURL *curl);
|
||||
|
||||
/*
|
||||
* NAME curl_easy_reset()
|
||||
@@ -95,6 +95,16 @@ CURL_EXTERN CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen,
|
||||
CURL_EXTERN CURLcode curl_easy_send(CURL *curl, const void *buffer,
|
||||
size_t buflen, size_t *n);
|
||||
|
||||
|
||||
/*
|
||||
* NAME curl_easy_upkeep()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Performs connection upkeep for the given session handle.
|
||||
*/
|
||||
CURL_EXTERN CURLcode curl_easy_upkeep(CURL *curl);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef __CURL_MPRINTF_H
|
||||
#define __CURL_MPRINTF_H
|
||||
#ifndef CURLINC_MPRINTF_H
|
||||
#define CURLINC_MPRINTF_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
@@ -7,11 +7,11 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
@@ -24,8 +24,7 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h> /* needed for FILE */
|
||||
|
||||
#include "curl.h"
|
||||
#include "curl.h" /* for CURL_EXTERN */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -44,38 +43,8 @@ CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength,
|
||||
CURL_EXTERN char *curl_maprintf(const char *format, ...);
|
||||
CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args);
|
||||
|
||||
#ifdef _MPRINTF_REPLACE
|
||||
# undef printf
|
||||
# undef fprintf
|
||||
# undef sprintf
|
||||
# undef vsprintf
|
||||
# undef snprintf
|
||||
# undef vprintf
|
||||
# undef vfprintf
|
||||
# undef vsnprintf
|
||||
# undef aprintf
|
||||
# undef vaprintf
|
||||
# define printf curl_mprintf
|
||||
# define fprintf curl_mfprintf
|
||||
#ifdef CURLDEBUG
|
||||
/* When built with CURLDEBUG we define away the sprintf() functions since we
|
||||
don't want internal code to be using them */
|
||||
# define sprintf sprintf_was_used
|
||||
# define vsprintf vsprintf_was_used
|
||||
#else
|
||||
# define sprintf curl_msprintf
|
||||
# define vsprintf curl_mvsprintf
|
||||
#endif
|
||||
# define snprintf curl_msnprintf
|
||||
# define vprintf curl_mvprintf
|
||||
# define vfprintf curl_mvfprintf
|
||||
# define vsnprintf curl_mvsnprintf
|
||||
# define aprintf curl_maprintf
|
||||
# define vaprintf curl_mvaprintf
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CURL_MPRINTF_H */
|
||||
#endif /* CURLINC_MPRINTF_H */
|
||||
+137
-26
@@ -1,5 +1,5 @@
|
||||
#ifndef __CURL_MULTI_H
|
||||
#define __CURL_MULTI_H
|
||||
#ifndef CURLINC_MULTI_H
|
||||
#define CURLINC_MULTI_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
@@ -7,11 +7,11 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
@@ -52,7 +52,11 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(BUILDING_LIBCURL) || defined(CURL_STRICTER)
|
||||
typedef struct Curl_multi CURLM;
|
||||
#else
|
||||
typedef void CURLM;
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or
|
||||
@@ -64,6 +68,12 @@ typedef enum {
|
||||
CURLM_INTERNAL_ERROR, /* this is a libcurl bug */
|
||||
CURLM_BAD_SOCKET, /* the passed in socket argument did not match */
|
||||
CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */
|
||||
CURLM_ADDED_ALREADY, /* an easy handle already added to a multi handle was
|
||||
attempted to get added - again */
|
||||
CURLM_RECURSIVE_API_CALL, /* an api function was called from inside a
|
||||
callback */
|
||||
CURLM_WAKEUP_FAILURE, /* wakeup is unavailable or failed */
|
||||
CURLM_BAD_FUNCTION_ARGUMENT, /* function called with a bad parameter */
|
||||
CURLM_LAST
|
||||
} CURLMcode;
|
||||
|
||||
@@ -72,6 +82,11 @@ typedef enum {
|
||||
curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */
|
||||
#define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM
|
||||
|
||||
/* bitmask bits for CURLMOPT_PIPELINING */
|
||||
#define CURLPIPE_NOTHING 0L
|
||||
#define CURLPIPE_HTTP1 1L
|
||||
#define CURLPIPE_MULTIPLEX 2L
|
||||
|
||||
typedef enum {
|
||||
CURLMSG_NONE, /* first, not used */
|
||||
CURLMSG_DONE, /* This easy handle has completed. 'result' contains
|
||||
@@ -89,6 +104,19 @@ struct CURLMsg {
|
||||
};
|
||||
typedef struct CURLMsg CURLMsg;
|
||||
|
||||
/* Based on poll(2) structure and values.
|
||||
* We don't use pollfd and POLL* constants explicitly
|
||||
* to cover platforms without poll(). */
|
||||
#define CURL_WAIT_POLLIN 0x0001
|
||||
#define CURL_WAIT_POLLPRI 0x0002
|
||||
#define CURL_WAIT_POLLOUT 0x0004
|
||||
|
||||
struct curl_waitfd {
|
||||
curl_socket_t fd;
|
||||
short events;
|
||||
short revents; /* not supported yet */
|
||||
};
|
||||
|
||||
/*
|
||||
* Name: curl_multi_init()
|
||||
*
|
||||
@@ -133,6 +161,43 @@ CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,
|
||||
fd_set *exc_fd_set,
|
||||
int *max_fd);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_wait()
|
||||
*
|
||||
* Desc: Poll on all fds within a CURLM set as well as any
|
||||
* additional fds passed to the function.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_wait(CURLM *multi_handle,
|
||||
struct curl_waitfd extra_fds[],
|
||||
unsigned int extra_nfds,
|
||||
int timeout_ms,
|
||||
int *ret);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_poll()
|
||||
*
|
||||
* Desc: Poll on all fds within a CURLM set as well as any
|
||||
* additional fds passed to the function.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_poll(CURLM *multi_handle,
|
||||
struct curl_waitfd extra_fds[],
|
||||
unsigned int extra_nfds,
|
||||
int timeout_ms,
|
||||
int *ret);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_wakeup()
|
||||
*
|
||||
* Desc: wakes up a sleeping curl_multi_poll call.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_wakeup(CURLM *multi_handle);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_perform()
|
||||
*
|
||||
@@ -146,8 +211,8 @@ CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code. *NOTE* that this only
|
||||
* returns errors etc regarding the whole multi stack. There might
|
||||
* still have occurred problems on invidual transfers even when this
|
||||
* returns OK.
|
||||
* still have occurred problems on individual transfers even when
|
||||
* this returns OK.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle,
|
||||
int *running_handles);
|
||||
@@ -180,7 +245,7 @@ CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle);
|
||||
* curl_multi_cleanup().
|
||||
*
|
||||
* The 'CURLMsg' struct is meant to be very simple and only contain
|
||||
* very basic informations. If more involved information is wanted,
|
||||
* very basic information. If more involved information is wanted,
|
||||
* we will provide the particular "transfer handle" in that struct
|
||||
* and that should/could/would be used in subsequent
|
||||
* curl_easy_getinfo() calls (or similar). The point being that we
|
||||
@@ -279,37 +344,58 @@ CURL_EXTERN CURLMcode curl_multi_socket_all(CURLM *multi_handle,
|
||||
CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle,
|
||||
long *milliseconds);
|
||||
|
||||
#undef CINIT /* re-using the same name as in curl.h */
|
||||
|
||||
#ifdef CURL_ISOCPP
|
||||
#define CINIT(name,type,num) CURLMOPT_ ## name = CURLOPTTYPE_ ## type + num
|
||||
#else
|
||||
/* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */
|
||||
#define LONG CURLOPTTYPE_LONG
|
||||
#define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT
|
||||
#define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT
|
||||
#define OFF_T CURLOPTTYPE_OFF_T
|
||||
#define CINIT(name,type,number) CURLMOPT_/**/name = type + number
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
/* This is the socket callback function pointer */
|
||||
CINIT(SOCKETFUNCTION, FUNCTIONPOINT, 1),
|
||||
CURLOPT(CURLMOPT_SOCKETFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 1),
|
||||
|
||||
/* This is the argument passed to the socket callback */
|
||||
CINIT(SOCKETDATA, OBJECTPOINT, 2),
|
||||
CURLOPT(CURLMOPT_SOCKETDATA, CURLOPTTYPE_OBJECTPOINT, 2),
|
||||
|
||||
/* set to 1 to enable pipelining for this multi handle */
|
||||
CINIT(PIPELINING, LONG, 3),
|
||||
CURLOPT(CURLMOPT_PIPELINING, CURLOPTTYPE_LONG, 3),
|
||||
|
||||
/* This is the timer callback function pointer */
|
||||
CINIT(TIMERFUNCTION, FUNCTIONPOINT, 4),
|
||||
CURLOPT(CURLMOPT_TIMERFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 4),
|
||||
|
||||
/* This is the argument passed to the timer callback */
|
||||
CINIT(TIMERDATA, OBJECTPOINT, 5),
|
||||
CURLOPT(CURLMOPT_TIMERDATA, CURLOPTTYPE_OBJECTPOINT, 5),
|
||||
|
||||
/* maximum number of entries in the connection cache */
|
||||
CINIT(MAXCONNECTS, LONG, 6),
|
||||
CURLOPT(CURLMOPT_MAXCONNECTS, CURLOPTTYPE_LONG, 6),
|
||||
|
||||
/* maximum number of (pipelining) connections to one host */
|
||||
CURLOPT(CURLMOPT_MAX_HOST_CONNECTIONS, CURLOPTTYPE_LONG, 7),
|
||||
|
||||
/* maximum number of requests in a pipeline */
|
||||
CURLOPT(CURLMOPT_MAX_PIPELINE_LENGTH, CURLOPTTYPE_LONG, 8),
|
||||
|
||||
/* a connection with a content-length longer than this
|
||||
will not be considered for pipelining */
|
||||
CURLOPT(CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE, CURLOPTTYPE_OFF_T, 9),
|
||||
|
||||
/* a connection with a chunk length longer than this
|
||||
will not be considered for pipelining */
|
||||
CURLOPT(CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE, CURLOPTTYPE_OFF_T, 10),
|
||||
|
||||
/* a list of site names(+port) that are blacklisted from
|
||||
pipelining */
|
||||
CURLOPT(CURLMOPT_PIPELINING_SITE_BL, CURLOPTTYPE_OBJECTPOINT, 11),
|
||||
|
||||
/* a list of server types that are blacklisted from
|
||||
pipelining */
|
||||
CURLOPT(CURLMOPT_PIPELINING_SERVER_BL, CURLOPTTYPE_OBJECTPOINT, 12),
|
||||
|
||||
/* maximum number of open connections in total */
|
||||
CURLOPT(CURLMOPT_MAX_TOTAL_CONNECTIONS, CURLOPTTYPE_LONG, 13),
|
||||
|
||||
/* This is the server push callback function pointer */
|
||||
CURLOPT(CURLMOPT_PUSHFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 14),
|
||||
|
||||
/* This is the argument passed to the server push callback */
|
||||
CURLOPT(CURLMOPT_PUSHDATA, CURLOPTTYPE_OBJECTPOINT, 15),
|
||||
|
||||
/* maximum number of concurrent streams to support on a connection */
|
||||
CURLOPT(CURLMOPT_MAX_CONCURRENT_STREAMS, CURLOPTTYPE_LONG, 16),
|
||||
|
||||
CURLMOPT_LASTENTRY /* the last unused */
|
||||
} CURLMoption;
|
||||
@@ -338,6 +424,31 @@ CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle,
|
||||
CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle,
|
||||
curl_socket_t sockfd, void *sockp);
|
||||
|
||||
|
||||
/*
|
||||
* Name: curl_push_callback
|
||||
*
|
||||
* Desc: This callback gets called when a new stream is being pushed by the
|
||||
* server. It approves or denies the new stream.
|
||||
*
|
||||
* Returns: CURL_PUSH_OK or CURL_PUSH_DENY.
|
||||
*/
|
||||
#define CURL_PUSH_OK 0
|
||||
#define CURL_PUSH_DENY 1
|
||||
|
||||
struct curl_pushheaders; /* forward declaration only */
|
||||
|
||||
CURL_EXTERN char *curl_pushheader_bynum(struct curl_pushheaders *h,
|
||||
size_t num);
|
||||
CURL_EXTERN char *curl_pushheader_byname(struct curl_pushheaders *h,
|
||||
const char *name);
|
||||
|
||||
typedef int (*curl_push_callback)(CURL *parent,
|
||||
CURL *easy,
|
||||
size_t num_headers,
|
||||
struct curl_pushheaders *headers,
|
||||
void *userp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef __STDC_HEADERS_H
|
||||
#define __STDC_HEADERS_H
|
||||
#ifndef CURLINC_STDCHEADERS_H
|
||||
#define CURLINC_STDCHEADERS_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
@@ -7,11 +7,11 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
@@ -24,10 +24,10 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
size_t fread (void *, size_t, size_t, FILE *);
|
||||
size_t fwrite (const void *, size_t, size_t, FILE *);
|
||||
size_t fread(void *, size_t, size_t, FILE *);
|
||||
size_t fwrite(const void *, size_t, size_t, FILE *);
|
||||
|
||||
int strcasecmp(const char *, const char *);
|
||||
int strncasecmp(const char *, const char *, size_t);
|
||||
|
||||
#endif /* __STDC_HEADERS_H */
|
||||
#endif /* CURLINC_STDCHEADERS_H */
|
||||
@@ -0,0 +1,504 @@
|
||||
#ifndef CURLINC_SYSTEM_H
|
||||
#define CURLINC_SYSTEM_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/*
|
||||
* Try to keep one section per platform, compiler and architecture, otherwise,
|
||||
* if an existing section is reused for a different one and later on the
|
||||
* original is adjusted, probably the piggybacking one can be adversely
|
||||
* changed.
|
||||
*
|
||||
* In order to differentiate between platforms/compilers/architectures use
|
||||
* only compiler built in predefined preprocessor symbols.
|
||||
*
|
||||
* curl_off_t
|
||||
* ----------
|
||||
*
|
||||
* For any given platform/compiler curl_off_t must be typedef'ed to a 64-bit
|
||||
* wide signed integral data type. The width of this data type must remain
|
||||
* constant and independent of any possible large file support settings.
|
||||
*
|
||||
* As an exception to the above, curl_off_t shall be typedef'ed to a 32-bit
|
||||
* wide signed integral data type if there is no 64-bit type.
|
||||
*
|
||||
* As a general rule, curl_off_t shall not be mapped to off_t. This rule shall
|
||||
* only be violated if off_t is the only 64-bit data type available and the
|
||||
* size of off_t is independent of large file support settings. Keep your
|
||||
* build on the safe side avoiding an off_t gating. If you have a 64-bit
|
||||
* off_t then take for sure that another 64-bit data type exists, dig deeper
|
||||
* and you will find it.
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(__DJGPP__) || defined(__GO32__)
|
||||
# if defined(__DJGPP__) && (__DJGPP__ > 1)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__SALFORDC__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__BORLANDC__)
|
||||
# if (__BORLANDC__ < 0x520)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__TURBOC__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__WATCOMC__)
|
||||
# if defined(__386__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__POCC__)
|
||||
# if (__POCC__ < 280)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# elif defined(_MSC_VER)
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__LCC__)
|
||||
# if defined(__e2k__) /* MCST eLbrus C Compiler */
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
# else /* Local (or Little) C Compiler */
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
# endif
|
||||
|
||||
#elif defined(__SYMBIAN32__)
|
||||
# if defined(__EABI__) /* Treat all ARM compilers equally */
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(__CW32__)
|
||||
# pragma longlong on
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(__VC32__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
|
||||
|
||||
#elif defined(__MWERKS__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(_WIN32_WCE)
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__MINGW32__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_WS2TCPIP_H 1
|
||||
|
||||
#elif defined(__VMS)
|
||||
# if defined(__VAX)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
|
||||
|
||||
#elif defined(__OS400__)
|
||||
# if defined(__ILEC400__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
# endif
|
||||
|
||||
#elif defined(__MVS__)
|
||||
# if defined(__IBMC__) || defined(__IBMCPP__)
|
||||
# if defined(_ILP32)
|
||||
# elif defined(_LP64)
|
||||
# endif
|
||||
# if defined(_LONG_LONG)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(_LP64)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
# endif
|
||||
|
||||
#elif defined(__370__)
|
||||
# if defined(__IBMC__) || defined(__IBMCPP__)
|
||||
# if defined(_ILP32)
|
||||
# elif defined(_LP64)
|
||||
# endif
|
||||
# if defined(_LONG_LONG)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(_LP64)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
# endif
|
||||
|
||||
#elif defined(TPF)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__TINYC__) /* also known as tcc */
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
|
||||
#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* Oracle Solaris Studio */
|
||||
# if !defined(__LP64) && (defined(__ILP32) || \
|
||||
defined(__i386) || \
|
||||
defined(__sparcv8) || \
|
||||
defined(__sparcv8plus))
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(__LP64) || \
|
||||
defined(__amd64) || defined(__sparcv9)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
|
||||
#elif defined(__xlc__) /* IBM xlc compiler */
|
||||
# if !defined(_LP64)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
|
||||
/* ===================================== */
|
||||
/* KEEP MSVC THE PENULTIMATE ENTRY */
|
||||
/* ===================================== */
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
# if (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64)
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
/* ===================================== */
|
||||
/* KEEP GENERIC GCC THE LAST ENTRY */
|
||||
/* ===================================== */
|
||||
|
||||
#elif defined(__GNUC__) && !defined(_SCO_DS)
|
||||
# if !defined(__LP64__) && \
|
||||
(defined(__ILP32__) || defined(__i386__) || defined(__hppa__) || \
|
||||
defined(__ppc__) || defined(__powerpc__) || defined(__arm__) || \
|
||||
defined(__sparc__) || defined(__mips__) || defined(__sh__) || \
|
||||
defined(__XTENSA__) || \
|
||||
(defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 4) || \
|
||||
(defined(__LONG_MAX__) && __LONG_MAX__ == 2147483647L))
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(__LP64__) || \
|
||||
defined(__x86_64__) || defined(__ppc64__) || defined(__sparc64__) || \
|
||||
defined(__e2k__) || \
|
||||
(defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 8) || \
|
||||
(defined(__LONG_MAX__) && __LONG_MAX__ == 9223372036854775807L)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
|
||||
#else
|
||||
/* generic "safe guess" on old 32 bit style */
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
#endif
|
||||
|
||||
#ifdef _AIX
|
||||
/* AIX needs <sys/poll.h> */
|
||||
#define CURL_PULL_SYS_POLL_H
|
||||
#endif
|
||||
|
||||
|
||||
/* CURL_PULL_WS2TCPIP_H is defined above when inclusion of header file */
|
||||
/* ws2tcpip.h is required here to properly make type definitions below. */
|
||||
#ifdef CURL_PULL_WS2TCPIP_H
|
||||
# include <winsock2.h>
|
||||
# include <windows.h>
|
||||
# include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
/* CURL_PULL_SYS_TYPES_H is defined above when inclusion of header file */
|
||||
/* sys/types.h is required here to properly make type definitions below. */
|
||||
#ifdef CURL_PULL_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
/* CURL_PULL_SYS_SOCKET_H is defined above when inclusion of header file */
|
||||
/* sys/socket.h is required here to properly make type definitions below. */
|
||||
#ifdef CURL_PULL_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
/* CURL_PULL_SYS_POLL_H is defined above when inclusion of header file */
|
||||
/* sys/poll.h is required here to properly make type definitions below. */
|
||||
#ifdef CURL_PULL_SYS_POLL_H
|
||||
# include <sys/poll.h>
|
||||
#endif
|
||||
|
||||
/* Data type definition of curl_socklen_t. */
|
||||
#ifdef CURL_TYPEOF_CURL_SOCKLEN_T
|
||||
typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t;
|
||||
#endif
|
||||
|
||||
/* Data type definition of curl_off_t. */
|
||||
|
||||
#ifdef CURL_TYPEOF_CURL_OFF_T
|
||||
typedef CURL_TYPEOF_CURL_OFF_T curl_off_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* CURL_ISOCPP and CURL_OFF_T_C definitions are done here in order to allow
|
||||
* these to be visible and exported by the external libcurl interface API,
|
||||
* while also making them visible to the library internals, simply including
|
||||
* curl_setup.h, without actually needing to include curl.h internally.
|
||||
* If some day this section would grow big enough, all this should be moved
|
||||
* to its own header file.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Figure out if we can use the ## preprocessor operator, which is supported
|
||||
* by ISO/ANSI C and C++. Some compilers support it without setting __STDC__
|
||||
* or __cplusplus so we need to carefully check for them too.
|
||||
*/
|
||||
|
||||
#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \
|
||||
defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \
|
||||
defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \
|
||||
defined(__ILEC400__)
|
||||
/* This compiler is believed to have an ISO compatible preprocessor */
|
||||
#define CURL_ISOCPP
|
||||
#else
|
||||
/* This compiler is believed NOT to have an ISO compatible preprocessor */
|
||||
#undef CURL_ISOCPP
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Macros for minimum-width signed and unsigned curl_off_t integer constants.
|
||||
*/
|
||||
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ == 0x0551)
|
||||
# define CURLINC_OFF_T_C_HLPR2(x) x
|
||||
# define CURLINC_OFF_T_C_HLPR1(x) CURLINC_OFF_T_C_HLPR2(x)
|
||||
# define CURL_OFF_T_C(Val) CURLINC_OFF_T_C_HLPR1(Val) ## \
|
||||
CURLINC_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_T)
|
||||
# define CURL_OFF_TU_C(Val) CURLINC_OFF_T_C_HLPR1(Val) ## \
|
||||
CURLINC_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_TU)
|
||||
#else
|
||||
# ifdef CURL_ISOCPP
|
||||
# define CURLINC_OFF_T_C_HLPR2(Val,Suffix) Val ## Suffix
|
||||
# else
|
||||
# define CURLINC_OFF_T_C_HLPR2(Val,Suffix) Val/**/Suffix
|
||||
# endif
|
||||
# define CURLINC_OFF_T_C_HLPR1(Val,Suffix) CURLINC_OFF_T_C_HLPR2(Val,Suffix)
|
||||
# define CURL_OFF_T_C(Val) CURLINC_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_T)
|
||||
# define CURL_OFF_TU_C(Val) CURLINC_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_TU)
|
||||
#endif
|
||||
|
||||
#endif /* CURLINC_SYSTEM_H */
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,125 @@
|
||||
#ifndef CURLINC_URLAPI_H
|
||||
#define CURLINC_URLAPI_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2018 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include "curl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* the error codes for the URL API */
|
||||
typedef enum {
|
||||
CURLUE_OK,
|
||||
CURLUE_BAD_HANDLE, /* 1 */
|
||||
CURLUE_BAD_PARTPOINTER, /* 2 */
|
||||
CURLUE_MALFORMED_INPUT, /* 3 */
|
||||
CURLUE_BAD_PORT_NUMBER, /* 4 */
|
||||
CURLUE_UNSUPPORTED_SCHEME, /* 5 */
|
||||
CURLUE_URLDECODE, /* 6 */
|
||||
CURLUE_OUT_OF_MEMORY, /* 7 */
|
||||
CURLUE_USER_NOT_ALLOWED, /* 8 */
|
||||
CURLUE_UNKNOWN_PART, /* 9 */
|
||||
CURLUE_NO_SCHEME, /* 10 */
|
||||
CURLUE_NO_USER, /* 11 */
|
||||
CURLUE_NO_PASSWORD, /* 12 */
|
||||
CURLUE_NO_OPTIONS, /* 13 */
|
||||
CURLUE_NO_HOST, /* 14 */
|
||||
CURLUE_NO_PORT, /* 15 */
|
||||
CURLUE_NO_QUERY, /* 16 */
|
||||
CURLUE_NO_FRAGMENT /* 17 */
|
||||
} CURLUcode;
|
||||
|
||||
typedef enum {
|
||||
CURLUPART_URL,
|
||||
CURLUPART_SCHEME,
|
||||
CURLUPART_USER,
|
||||
CURLUPART_PASSWORD,
|
||||
CURLUPART_OPTIONS,
|
||||
CURLUPART_HOST,
|
||||
CURLUPART_PORT,
|
||||
CURLUPART_PATH,
|
||||
CURLUPART_QUERY,
|
||||
CURLUPART_FRAGMENT,
|
||||
CURLUPART_ZONEID /* added in 7.65.0 */
|
||||
} CURLUPart;
|
||||
|
||||
#define CURLU_DEFAULT_PORT (1<<0) /* return default port number */
|
||||
#define CURLU_NO_DEFAULT_PORT (1<<1) /* act as if no port number was set,
|
||||
if the port number matches the
|
||||
default for the scheme */
|
||||
#define CURLU_DEFAULT_SCHEME (1<<2) /* return default scheme if
|
||||
missing */
|
||||
#define CURLU_NON_SUPPORT_SCHEME (1<<3) /* allow non-supported scheme */
|
||||
#define CURLU_PATH_AS_IS (1<<4) /* leave dot sequences */
|
||||
#define CURLU_DISALLOW_USER (1<<5) /* no user+password allowed */
|
||||
#define CURLU_URLDECODE (1<<6) /* URL decode on get */
|
||||
#define CURLU_URLENCODE (1<<7) /* URL encode on set */
|
||||
#define CURLU_APPENDQUERY (1<<8) /* append a form style part */
|
||||
#define CURLU_GUESS_SCHEME (1<<9) /* legacy curl-style guessing */
|
||||
#define CURLU_NO_AUTHORITY (1<<10) /* Allow empty authority when the
|
||||
scheme is unknown. */
|
||||
|
||||
typedef struct Curl_URL CURLU;
|
||||
|
||||
/*
|
||||
* curl_url() creates a new CURLU handle and returns a pointer to it.
|
||||
* Must be freed with curl_url_cleanup().
|
||||
*/
|
||||
CURL_EXTERN CURLU *curl_url(void);
|
||||
|
||||
/*
|
||||
* curl_url_cleanup() frees the CURLU handle and related resources used for
|
||||
* the URL parsing. It will not free strings previously returned with the URL
|
||||
* API.
|
||||
*/
|
||||
CURL_EXTERN void curl_url_cleanup(CURLU *handle);
|
||||
|
||||
/*
|
||||
* curl_url_dup() duplicates a CURLU handle and returns a new copy. The new
|
||||
* handle must also be freed with curl_url_cleanup().
|
||||
*/
|
||||
CURL_EXTERN CURLU *curl_url_dup(CURLU *in);
|
||||
|
||||
/*
|
||||
* curl_url_get() extracts a specific part of the URL from a CURLU
|
||||
* handle. Returns error code. The returned pointer MUST be freed with
|
||||
* curl_free() afterwards.
|
||||
*/
|
||||
CURL_EXTERN CURLUcode curl_url_get(CURLU *handle, CURLUPart what,
|
||||
char **part, unsigned int flags);
|
||||
|
||||
/*
|
||||
* curl_url_set() sets a specific part of the URL in a CURLU handle. Returns
|
||||
* error code. The passed in string will be copied. Passing a NULL instead of
|
||||
* a part string, clears that part.
|
||||
*/
|
||||
CURL_EXTERN CURLUcode curl_url_set(CURLU *handle, CURLUPart what,
|
||||
const char *part, unsigned int flags);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CURLINC_URLAPI_H */
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<LibraryPath Condition="'$(Platform)' == 'Win32'">$(SolutionDir)libs\discord-rpc\win32-dynamic\lib;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath Condition="'$(Platform)' == 'Win32'">$(SolutionDir)libs\discord-rpc\win32-dynamic\lib;$(IncludePath)</IncludePath>
|
||||
<LibraryPath Condition="'$(Platform)' == 'x64'">$(SolutionDir)libs\discord-rpc\win64-dynamic\lib;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath Condition="'$(Platform)' == 'x64'">$(SolutionDir)libs\discord-rpc\win64-dynamic\lib;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Platform)' == 'Win32' OR '$(Platform)' == 'x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>discord-rpc.dll.a;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
||||
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(DISCORD_DYNAMIC_LIB)
|
||||
#if defined(_WIN32)
|
||||
#if defined(DISCORD_BUILDING_SDK)
|
||||
#define DISCORD_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define DISCORD_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define DISCORD_EXPORT __attribute__((visibility("default")))
|
||||
#endif
|
||||
#else
|
||||
#define DISCORD_EXPORT
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
DISCORD_EXPORT void Discord_Register(const char* applicationId, const char* command);
|
||||
DISCORD_EXPORT void Discord_RegisterSteamGame(const char* applicationId, const char* steamId);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,87 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
// clang-format off
|
||||
|
||||
#if defined(DISCORD_DYNAMIC_LIB)
|
||||
# if defined(_WIN32)
|
||||
# if defined(DISCORD_BUILDING_SDK)
|
||||
# define DISCORD_EXPORT __declspec(dllexport)
|
||||
# else
|
||||
# define DISCORD_EXPORT __declspec(dllimport)
|
||||
# endif
|
||||
# else
|
||||
# define DISCORD_EXPORT __attribute__((visibility("default")))
|
||||
# endif
|
||||
#else
|
||||
# define DISCORD_EXPORT
|
||||
#endif
|
||||
|
||||
// clang-format on
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct DiscordRichPresence {
|
||||
const char* state; /* max 128 bytes */
|
||||
const char* details; /* max 128 bytes */
|
||||
int64_t startTimestamp;
|
||||
int64_t endTimestamp;
|
||||
const char* largeImageKey; /* max 32 bytes */
|
||||
const char* largeImageText; /* max 128 bytes */
|
||||
const char* smallImageKey; /* max 32 bytes */
|
||||
const char* smallImageText; /* max 128 bytes */
|
||||
const char* partyId; /* max 128 bytes */
|
||||
int partySize;
|
||||
int partyMax;
|
||||
const char* matchSecret; /* max 128 bytes */
|
||||
const char* joinSecret; /* max 128 bytes */
|
||||
const char* spectateSecret; /* max 128 bytes */
|
||||
int8_t instance;
|
||||
} DiscordRichPresence;
|
||||
|
||||
typedef struct DiscordUser {
|
||||
const char* userId;
|
||||
const char* username;
|
||||
const char* discriminator;
|
||||
const char* avatar;
|
||||
} DiscordUser;
|
||||
|
||||
typedef struct DiscordEventHandlers {
|
||||
void (*ready)(const DiscordUser* request);
|
||||
void (*disconnected)(int errorCode, const char* message);
|
||||
void (*errored)(int errorCode, const char* message);
|
||||
void (*joinGame)(const char* joinSecret);
|
||||
void (*spectateGame)(const char* spectateSecret);
|
||||
void (*joinRequest)(const DiscordUser* request);
|
||||
} DiscordEventHandlers;
|
||||
|
||||
#define DISCORD_REPLY_NO 0
|
||||
#define DISCORD_REPLY_YES 1
|
||||
#define DISCORD_REPLY_IGNORE 2
|
||||
|
||||
DISCORD_EXPORT void Discord_Initialize(const char* applicationId,
|
||||
DiscordEventHandlers* handlers,
|
||||
int autoRegister,
|
||||
const char* optionalSteamId);
|
||||
DISCORD_EXPORT void Discord_Shutdown(void);
|
||||
|
||||
/* checks for incoming messages, dispatches callbacks */
|
||||
DISCORD_EXPORT void Discord_RunCallbacks(void);
|
||||
|
||||
/* If you disable the lib starting its own io thread, you'll need to call this from your own */
|
||||
#ifdef DISCORD_DISABLE_IO_THREAD
|
||||
DISCORD_EXPORT void Discord_UpdateConnection(void);
|
||||
#endif
|
||||
|
||||
DISCORD_EXPORT void Discord_UpdatePresence(const DiscordRichPresence* presence);
|
||||
DISCORD_EXPORT void Discord_ClearPresence(void);
|
||||
|
||||
DISCORD_EXPORT void Discord_Respond(const char* userid, /* DISCORD_REPLY_ */ int reply);
|
||||
|
||||
DISCORD_EXPORT void Discord_UpdateHandlers(DiscordEventHandlers* handlers);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
Binary file not shown.
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(DISCORD_DYNAMIC_LIB)
|
||||
#if defined(_WIN32)
|
||||
#if defined(DISCORD_BUILDING_SDK)
|
||||
#define DISCORD_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define DISCORD_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define DISCORD_EXPORT __attribute__((visibility("default")))
|
||||
#endif
|
||||
#else
|
||||
#define DISCORD_EXPORT
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
DISCORD_EXPORT void Discord_Register(const char* applicationId, const char* command);
|
||||
DISCORD_EXPORT void Discord_RegisterSteamGame(const char* applicationId, const char* steamId);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,87 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
// clang-format off
|
||||
|
||||
#if defined(DISCORD_DYNAMIC_LIB)
|
||||
# if defined(_WIN32)
|
||||
# if defined(DISCORD_BUILDING_SDK)
|
||||
# define DISCORD_EXPORT __declspec(dllexport)
|
||||
# else
|
||||
# define DISCORD_EXPORT __declspec(dllimport)
|
||||
# endif
|
||||
# else
|
||||
# define DISCORD_EXPORT __attribute__((visibility("default")))
|
||||
# endif
|
||||
#else
|
||||
# define DISCORD_EXPORT
|
||||
#endif
|
||||
|
||||
// clang-format on
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct DiscordRichPresence {
|
||||
const char* state; /* max 128 bytes */
|
||||
const char* details; /* max 128 bytes */
|
||||
int64_t startTimestamp;
|
||||
int64_t endTimestamp;
|
||||
const char* largeImageKey; /* max 32 bytes */
|
||||
const char* largeImageText; /* max 128 bytes */
|
||||
const char* smallImageKey; /* max 32 bytes */
|
||||
const char* smallImageText; /* max 128 bytes */
|
||||
const char* partyId; /* max 128 bytes */
|
||||
int partySize;
|
||||
int partyMax;
|
||||
const char* matchSecret; /* max 128 bytes */
|
||||
const char* joinSecret; /* max 128 bytes */
|
||||
const char* spectateSecret; /* max 128 bytes */
|
||||
int8_t instance;
|
||||
} DiscordRichPresence;
|
||||
|
||||
typedef struct DiscordUser {
|
||||
const char* userId;
|
||||
const char* username;
|
||||
const char* discriminator;
|
||||
const char* avatar;
|
||||
} DiscordUser;
|
||||
|
||||
typedef struct DiscordEventHandlers {
|
||||
void (*ready)(const DiscordUser* request);
|
||||
void (*disconnected)(int errorCode, const char* message);
|
||||
void (*errored)(int errorCode, const char* message);
|
||||
void (*joinGame)(const char* joinSecret);
|
||||
void (*spectateGame)(const char* spectateSecret);
|
||||
void (*joinRequest)(const DiscordUser* request);
|
||||
} DiscordEventHandlers;
|
||||
|
||||
#define DISCORD_REPLY_NO 0
|
||||
#define DISCORD_REPLY_YES 1
|
||||
#define DISCORD_REPLY_IGNORE 2
|
||||
|
||||
DISCORD_EXPORT void Discord_Initialize(const char* applicationId,
|
||||
DiscordEventHandlers* handlers,
|
||||
int autoRegister,
|
||||
const char* optionalSteamId);
|
||||
DISCORD_EXPORT void Discord_Shutdown(void);
|
||||
|
||||
/* checks for incoming messages, dispatches callbacks */
|
||||
DISCORD_EXPORT void Discord_RunCallbacks(void);
|
||||
|
||||
/* If you disable the lib starting its own io thread, you'll need to call this from your own */
|
||||
#ifdef DISCORD_DISABLE_IO_THREAD
|
||||
DISCORD_EXPORT void Discord_UpdateConnection(void);
|
||||
#endif
|
||||
|
||||
DISCORD_EXPORT void Discord_UpdatePresence(const DiscordRichPresence* presence);
|
||||
DISCORD_EXPORT void Discord_ClearPresence(void);
|
||||
|
||||
DISCORD_EXPORT void Discord_Respond(const char* userid, /* DISCORD_REPLY_ */ int reply);
|
||||
|
||||
DISCORD_EXPORT void Discord_UpdateHandlers(DiscordEventHandlers* handlers);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2002-2015 Jose Fonseca
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
// Set the unhandled exception handler.
|
||||
// Must be called when exchndll.dll is statically loaded (as opposed to loaded
|
||||
// dynamically via LoadLibrary)
|
||||
EXTERN_C VOID APIENTRY
|
||||
ExcHndlInit(void);
|
||||
|
||||
|
||||
// Override the report file name.
|
||||
//
|
||||
// Default is prog_name.RPT, in the same directory as the main executable.
|
||||
//
|
||||
// You can also pass "-" for stderr.
|
||||
EXTERN_C BOOL APIENTRY
|
||||
ExcHndlSetLogFileNameA(const char *szLogFileName);
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Platform)' == 'Win32' OR '$(Platform)' == 'x64'">
|
||||
<IncludePath>$(SolutionDir)libs\gme\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath Condition="'$(Platform)' == 'Win32'">$(SolutionDir)libs\gme\win32;$(LibraryPath)</LibraryPath>
|
||||
<LibraryPath Condition="'$(Platform)' == 'x64'">$(SolutionDir)libs\gme\win64;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Platform)' == 'Win32' OR '$(Platform)' == 'x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>libgme.dll.a;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
||||
+54
-3
@@ -35,6 +35,7 @@ set(SRB2_CORE_SOURCES
|
||||
m_random.c
|
||||
md5.c
|
||||
mserv.c
|
||||
http-mserv.c
|
||||
s_sound.c
|
||||
screen.c
|
||||
sounds.c
|
||||
@@ -220,6 +221,10 @@ set(SRB2_CONFIG_HAVE_ZLIB ON CACHE BOOL
|
||||
"Enable zlib support.")
|
||||
set(SRB2_CONFIG_HAVE_GME ON CACHE BOOL
|
||||
"Enable GME support.")
|
||||
set(SRB2_CONFIG_HAVE_DISCORDRPC OFF CACHE BOOL
|
||||
"Enable Discord rich presence support.")
|
||||
set(SRB2_CONFIG_HAVE_CURL ON CACHE BOOL
|
||||
"Enable curl support, used for downloading files via HTTP.")
|
||||
set(SRB2_CONFIG_HWRENDER ON CACHE BOOL
|
||||
"Enable hardware rendering through OpenGL.")
|
||||
set(SRB2_CONFIG_USEASM OFF CACHE BOOL
|
||||
@@ -232,7 +237,7 @@ set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL
|
||||
### use internal libraries?
|
||||
if(${CMAKE_SYSTEM} MATCHES "Windows") ###set on Windows only
|
||||
set(SRB2_CONFIG_USE_INTERNAL_LIBRARIES OFF CACHE BOOL
|
||||
"Use SRB2's internal copies of required dependencies (SDL2, PNG, zlib, GME).")
|
||||
"Use SRB2Kart's internal copies of required dependencies (SDL2, PNG, zlib, GME).")
|
||||
endif()
|
||||
|
||||
if(${SRB2_CONFIG_HAVE_BLUA})
|
||||
@@ -275,6 +280,7 @@ if(${SRB2_CONFIG_HAVE_BLUA})
|
||||
blua/lfunc.c
|
||||
blua/lgc.c
|
||||
blua/linit.c
|
||||
blua/liolib.c
|
||||
blua/llex.c
|
||||
blua/lmem.c
|
||||
blua/lobject.c
|
||||
@@ -326,7 +332,7 @@ if(${SRB2_CONFIG_HAVE_GME})
|
||||
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
|
||||
set(GME_FOUND ON)
|
||||
set(GME_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/gme/include)
|
||||
if(${SRB2_SYSTEM_BITS} EQUAL 64)
|
||||
if(${SRB2_SYSTEM_BITS} EQUAL 64)
|
||||
set(GME_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/gme/win64 -lgme")
|
||||
else() # 32-bit
|
||||
set(GME_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/gme/win32 -lgme")
|
||||
@@ -342,6 +348,32 @@ if(${SRB2_CONFIG_HAVE_GME})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(${SRB2_CONFIG_HAVE_DISCORDRPC})
|
||||
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
|
||||
set(DISCORDRPC_FOUND ON)
|
||||
if(${SRB2_SYSTEM_BITS} EQUAL 64)
|
||||
set(DISCORDRPC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/discord-rpc/win64-dynamic/include)
|
||||
set(DISCORDRPC_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/discord-rpc/win64-dynamic/lib -ldiscord-rpc")
|
||||
else() # 32-bit
|
||||
set(DISCORDRPC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/discord-rpc/win32-dynamic/include)
|
||||
set(DISCORDRPC_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/discord-rpc/win32-dynamic/lib -ldiscord-rpc")
|
||||
endif()
|
||||
else()
|
||||
find_package(DiscordRPC)
|
||||
endif()
|
||||
if(${DISCORDRPC_FOUND})
|
||||
set(SRB2_HAVE_DISCORDRPC ON)
|
||||
add_definitions(-DHAVE_DISCORDRPC)
|
||||
set(SRB2_DISCORDRPC_SOURCES discord.c)
|
||||
set(SRB2_DISCORDRPC_HEADERS discord.h)
|
||||
prepend_sources(SRB2_DISCORDRPC_SOURCES)
|
||||
prepend_sources(SRB2_DISCORDRPC_HEADERS)
|
||||
source_group("Discord Rich Presence" FILES ${SRB2_DISCORDRPC_SOURCES} ${SRB2_DISCORDRPC_HEADERS})
|
||||
else()
|
||||
message(WARNING "You have specified that Discord Rich Presence is available but it was not found.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(${SRB2_CONFIG_HAVE_ZLIB})
|
||||
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
|
||||
set(ZLIB_FOUND ON)
|
||||
@@ -391,6 +423,26 @@ if(${SRB2_CONFIG_HAVE_PNG} AND ${SRB2_CONFIG_HAVE_ZLIB})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(${SRB2_CONFIG_HAVE_CURL})
|
||||
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
|
||||
set(CURL_FOUND ON)
|
||||
set(CURL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/curl/include)
|
||||
if(${SRB2_SYSTEM_BITS} EQUAL 64)
|
||||
set(CURL_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/curl/lib64 -lcurl")
|
||||
else() # 32-bit
|
||||
set(CURL_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/curl/lib32 -lcurl")
|
||||
endif()
|
||||
else()
|
||||
find_package(CURL)
|
||||
endif()
|
||||
if(${CURL_FOUND})
|
||||
set(SRB2_HAVE_CURL ON)
|
||||
add_definitions(-DHAVE_CURL)
|
||||
else()
|
||||
message(WARNING "You have specified that CURL is available but it was not found. SRB2Kart may not compile correctly.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(${SRB2_CONFIG_HWRENDER})
|
||||
add_definitions(-DHWRENDER)
|
||||
set(SRB2_HWRENDER_SOURCES
|
||||
@@ -414,7 +466,6 @@ if(${SRB2_CONFIG_HWRENDER})
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_defs.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_dll.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_drv.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_glide.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_glob.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_light.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.h
|
||||
|
||||
+82
-35
@@ -60,10 +60,10 @@
|
||||
# Compile with GCC 4.6x version, add 'GCC46=1'
|
||||
# Compile a profile version, add 'PROFILEMODE=1'
|
||||
# Compile a debug version, add 'DEBUGMODE=1'
|
||||
# Compile with extra warnings, add 'WARNINGMODE=1'
|
||||
# Compile with less warnings, add 'RELAXWARNINGS=1'
|
||||
# Generate compiler errors for most compiler warnings, add 'ERRORMODE=1'
|
||||
# Compile without NASM's tmap.nas, add 'NOASM=1'
|
||||
# Compile without 3D hardware support, add 'NOHW=1'
|
||||
# Compile without 3D sound support, add 'NOHS=1'
|
||||
# Compile with GDBstubs, add 'RDB=1'
|
||||
# Compile without PNG, add 'NOPNG=1'
|
||||
# Compile without zlib, add 'NOZLIB=1'
|
||||
@@ -81,6 +81,58 @@
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
ALL_SYSTEMS=\
|
||||
PANDORA\
|
||||
LINUX64\
|
||||
MINGW64\
|
||||
HAIKU\
|
||||
DUMMY\
|
||||
DJGPPDOS\
|
||||
MINGW\
|
||||
UNIX\
|
||||
LINUX\
|
||||
SOLARIS\
|
||||
FREEBSD\
|
||||
MACOSX\
|
||||
SDL\
|
||||
|
||||
# check for user specified system
|
||||
ifeq (,$(filter $(ALL_SYSTEMS),$(.VARIABLES)))
|
||||
ifeq ($(OS),Windows_NT) # all windows are Windows_NT...
|
||||
|
||||
$(info Detected a Windows system, compiling for 32-bit MinGW SDL2...)
|
||||
|
||||
# go for a 32-bit sdl mingw exe by default
|
||||
MINGW=1
|
||||
SDL=1
|
||||
WINDOWSHELL=1
|
||||
|
||||
else # if you on the *nix
|
||||
|
||||
system:=$(shell uname -s)
|
||||
|
||||
ifeq ($(system),Linux)
|
||||
new_system=LINUX
|
||||
else
|
||||
|
||||
$(error \
|
||||
Could not automatically detect your system,\
|
||||
try specifying a system manually)
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(shell getconf LONG_BIT),64)
|
||||
system+=64-bit
|
||||
new_system:=$(new_system)64
|
||||
endif
|
||||
|
||||
$(info Detected $(system) ($(new_system))...)
|
||||
$(new_system)=1
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
# SRB2 data files
|
||||
D_DIR?=../bin/Resources
|
||||
D_FILES=$(D_DIR)/srb2.srb \
|
||||
@@ -136,7 +188,6 @@ NOPNG=1
|
||||
NOZLIB=1
|
||||
NONET=1
|
||||
NOHW=1
|
||||
NOHS=1
|
||||
NOASM=1
|
||||
NOIPX=1
|
||||
EXENAME?=srb2dummy
|
||||
@@ -167,7 +218,6 @@ endif
|
||||
ifdef PANDORA
|
||||
NONX86=1
|
||||
NOHW=1
|
||||
NOHS=1
|
||||
endif
|
||||
|
||||
ifdef WII
|
||||
@@ -217,7 +267,6 @@ NOPNG=1
|
||||
NOZLIB=1
|
||||
NONET=1
|
||||
#NOHW=1
|
||||
NOHS=1
|
||||
NOASM=1
|
||||
NOIPX=1
|
||||
NONX86=1
|
||||
@@ -267,6 +316,7 @@ endif
|
||||
|
||||
ifdef NONET
|
||||
OPTS+=-DNONET
|
||||
NOCURL=1
|
||||
else
|
||||
ifdef NO_IPV6
|
||||
OPTS+=-DNO_IPV6
|
||||
@@ -286,13 +336,6 @@ endif
|
||||
$(OBJDIR)/hw_md2load.o $(OBJDIR)/hw_md3load.o $(OBJDIR)/hw_model.o $(OBJDIR)/u_list.o
|
||||
endif
|
||||
|
||||
ifdef NOHS
|
||||
OPTS+=-DNOHS
|
||||
else
|
||||
OPTS+=-DHW3SOUND
|
||||
OBJS+=$(OBJDIR)/hw3sound.o
|
||||
endif
|
||||
|
||||
OPTS += -DCOMPVERSION
|
||||
|
||||
ifndef NONX86
|
||||
@@ -369,6 +412,16 @@ else
|
||||
NOPNG=1
|
||||
endif
|
||||
|
||||
ifndef NOCURL
|
||||
OPTS+=-DHAVE_CURL
|
||||
CURLCONFIG?=curl-config
|
||||
CURL_CFLAGS?=$(shell $(CURLCONFIG) --cflags)
|
||||
CURL_LDFLAGS?=$(shell $(CURLCONFIG) --libs)
|
||||
|
||||
LIBS+=$(CURL_LDFLAGS)
|
||||
CFLAGS+=$(CURL_CFLAGS)
|
||||
endif
|
||||
|
||||
ifdef STATIC
|
||||
LIBS:=-static $(LIBS)
|
||||
endif
|
||||
@@ -385,6 +438,12 @@ CFLAGS+=-DHAVE_MINIUPNPC
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef HAVE_DISCORDRPC
|
||||
LIBS+=-ldiscord-rpc
|
||||
CFLAGS+=-DHAVE_DISCORDRPC
|
||||
OBJS+=$(OBJDIR)/discord.o
|
||||
endif
|
||||
|
||||
ifndef NO_LUA
|
||||
include blua/Makefile.cfg
|
||||
endif
|
||||
@@ -537,6 +596,7 @@ OBJS:=$(i_main_o) \
|
||||
$(OBJDIR)/w_wad.o \
|
||||
$(OBJDIR)/filesrch.o \
|
||||
$(OBJDIR)/mserv.o \
|
||||
$(OBJDIR)/http-mserv.o\
|
||||
$(OBJDIR)/i_tcp.o \
|
||||
$(OBJDIR)/lzf.o \
|
||||
$(OBJDIR)/vid_copy.o \
|
||||
@@ -741,8 +801,8 @@ ifdef SDL
|
||||
ifdef MINGW
|
||||
$(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h \
|
||||
doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \
|
||||
command.h hardware/hw_data.h hardware/hw_glide.h hardware/hw_defs.h \
|
||||
hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h \
|
||||
command.h hardware/hw_data.h hardware/hw_defs.h hardware/hw_md2.h \
|
||||
hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h \
|
||||
hardware/hw_md2load.h hardware/hw_md3load.h hardware/hw_model.h hardware/u_list.h \
|
||||
am_map.h d_event.h d_player.h p_pspr.h m_fixed.h tables.h info.h d_think.h \
|
||||
p_mobj.h doomdata.h d_ticcmd.h r_defs.h hardware/hw_dll.h
|
||||
@@ -750,8 +810,8 @@ $(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h
|
||||
else
|
||||
$(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h \
|
||||
doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \
|
||||
command.h hardware/hw_data.h hardware/hw_glide.h hardware/hw_defs.h \
|
||||
hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h \
|
||||
command.h hardware/hw_data.h hardware/hw_defs.h hardware/hw_md2.h \
|
||||
hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h \
|
||||
hardware/hw_md2load.h hardware/hw_md3load.h hardware/hw_model.h hardware/u_list.h \
|
||||
am_map.h d_event.h d_player.h p_pspr.h m_fixed.h tables.h info.h d_think.h \
|
||||
p_mobj.h doomdata.h d_ticcmd.h r_defs.h hardware/hw_dll.h
|
||||
@@ -904,8 +964,8 @@ ifndef SDL
|
||||
ifndef NOHW
|
||||
$(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h \
|
||||
doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \
|
||||
command.h hardware/hw_data.h hardware/hw_glide.h hardware/hw_defs.h \
|
||||
hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h \
|
||||
command.h hardware/hw_data.h hardware/hw_defs.h hardware/hw_md2.h \
|
||||
hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h \
|
||||
hardware/hw_md2load.h hardware/hw_md3load.h hardware/hw_model.h hardware/u_list.h \
|
||||
am_map.h d_event.h d_player.h p_pspr.h m_fixed.h tables.h info.h d_think.h \
|
||||
p_mobj.h doomdata.h d_ticcmd.h r_defs.h hardware/hw_dll.h
|
||||
@@ -913,8 +973,8 @@ $(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h
|
||||
|
||||
$(OBJDIR)/ogl_win.o: hardware/r_opengl/ogl_win.c hardware/r_opengl/r_opengl.h \
|
||||
doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \
|
||||
command.h hardware/hw_data.h hardware/hw_glide.h hardware/hw_defs.h \
|
||||
hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h \
|
||||
command.h hardware/hw_data.h hardware/hw_defs.h hardware/hw_md2.h \
|
||||
hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h \
|
||||
hardware/hw_md2load.h hardware/hw_md3load.h hardware/hw_model.h hardware/u_list.h \
|
||||
am_map.h d_event.h d_player.h p_pspr.h m_fixed.h tables.h info.h d_think.h \
|
||||
p_mobj.h doomdata.h d_ticcmd.h r_defs.h hardware/hw_dll.h
|
||||
@@ -922,27 +982,14 @@ $(OBJDIR)/ogl_win.o: hardware/r_opengl/ogl_win.c hardware/r_opengl/r_opengl.h \
|
||||
|
||||
$(OBJDIR)/r_minigl.o: hardware/r_minigl/r_minigl.c hardware/r_opengl/r_opengl.h \
|
||||
doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \
|
||||
command.h hardware/hw_data.h hardware/hw_glide.h hardware/hw_defs.h \
|
||||
hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h \
|
||||
command.h hardware/hw_data.h hardware/hw_defs.h hardware/hw_md2.h \
|
||||
hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h \
|
||||
hardware/hw_md2load.h hardware/hw_md3load.h hardware/hw_model.h hardware/u_list.h \
|
||||
am_map.h d_event.h d_player.h p_pspr.h m_fixed.h tables.h info.h d_think.h \
|
||||
p_mobj.h doomdata.h d_ticcmd.h r_defs.h hardware/hw_dll.h
|
||||
$(CC) $(CFLAGS) $(WFLAGS) -D_WINDOWS -mwindows -c $< -o $@
|
||||
endif
|
||||
|
||||
ifndef NOHS
|
||||
$(OBJDIR)/s_ds3d.o: hardware/s_ds3d/s_ds3d.c hardware/hw3dsdrv.h \
|
||||
hardware/hw_dll.h
|
||||
$(CC) $(ARCHOPTS) -Os -o $(OBJDIR)/s_ds3d.o $(WFLAGS) -D_WINDOWS -mwindows -c hardware/s_ds3d/s_ds3d.c
|
||||
|
||||
$(OBJDIR)/s_fmod.o: hardware/s_openal/s_openal.c hardware/hw3dsdrv.h \
|
||||
hardware/hw_dll.h
|
||||
$(CC) $(ARCHOPTS) -Os -o $(OBJDIR)/s_fmod.o $(WFLAGS) -D_WINDOWS -mwindows -c hardware/s_fmod/s_fmod.c
|
||||
|
||||
$(OBJDIR)/s_openal.o: hardware/s_openal/s_openal.c hardware/hw3dsdrv.h \
|
||||
hardware/hw_dll.h
|
||||
$(CC) $(ARCHOPTS) -Os -o $(OBJDIR)/s_openal.o $(WFLAGS) -D_WINDOWS -mwindows -c hardware/s_openal/s_openal.c
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
+117
-33
@@ -1,3 +1,4 @@
|
||||
# vim: ft=make
|
||||
#
|
||||
# Makefile.cfg for SRB2
|
||||
#
|
||||
@@ -7,11 +8,114 @@
|
||||
# and other things
|
||||
#
|
||||
|
||||
ifdef GCC81
|
||||
GCC80=1
|
||||
# See the following variable don't start with 'GCC'. This is
|
||||
# to avoid a false positive with the version detection...
|
||||
|
||||
SUPPORTED_GCC_VERSIONS:=\
|
||||
101 102\
|
||||
91 92 93\
|
||||
81 82 83 84\
|
||||
71 72 73 74 75\
|
||||
61 62 63 64\
|
||||
51 52 53 54 55\
|
||||
40 41 42 43 44 45 46 47 48 49
|
||||
|
||||
LATEST_GCC_VERSION=10.2
|
||||
|
||||
# gcc or g++
|
||||
ifdef PREFIX
|
||||
CC=$(PREFIX)-gcc
|
||||
CXX=$(PREFIX)-g++
|
||||
OBJCOPY=$(PREFIX)-objcopy
|
||||
OBJDUMP=$(PREFIX)-objdump
|
||||
STRIP=$(PREFIX)-strip
|
||||
WINDRES=$(PREFIX)-windres
|
||||
else
|
||||
OBJCOPY=objcopy
|
||||
OBJDUMP=objdump
|
||||
STRIP=strip
|
||||
WINDRES=windres
|
||||
endif
|
||||
|
||||
ifdef GCC80
|
||||
# because Apple screws with us on this
|
||||
# need to get bintools from homebrew
|
||||
ifdef MACOSX
|
||||
CC=clang
|
||||
CXX=clang
|
||||
OBJCOPY=gobjcopy
|
||||
OBJDUMP=gobjdump
|
||||
endif
|
||||
|
||||
# Automatically set version flag, but not if one was manually set
|
||||
ifeq (,$(filter GCC%,$(.VARIABLES)))
|
||||
version:=$(shell $(CC) --version)
|
||||
# check if this is in fact GCC
|
||||
ifneq (,$(or $(findstring gcc,$(version)),$(findstring GCC,$(version))))
|
||||
version:=$(shell $(CC) -dumpversion)
|
||||
|
||||
# Turn version into words of major, minor
|
||||
v:=$(subst ., ,$(version))
|
||||
# concat. major minor
|
||||
v:=$(word 1,$(v))$(word 2,$(v))
|
||||
|
||||
# If this version is not in the list, default to the latest supported
|
||||
ifeq (,$(filter $(v),$(SUPPORTED_GCC_VERSIONS)))
|
||||
$(info\
|
||||
Your compiler version, GCC $(version), is not supported by the Makefile.\
|
||||
The Makefile will assume GCC $(LATEST_GCC_VERSION).)
|
||||
GCC$(subst .,,$(LATEST_GCC_VERSION))=1
|
||||
else
|
||||
$(info Detected GCC $(version) (GCC$(v)))
|
||||
GCC$(v)=1
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef GCC102
|
||||
GCC101=1
|
||||
endif
|
||||
|
||||
ifdef GCC101
|
||||
GCC93=1
|
||||
endif
|
||||
|
||||
ifdef GCC93
|
||||
GCC92=1
|
||||
endif
|
||||
|
||||
ifdef GCC92
|
||||
GCC91=1
|
||||
endif
|
||||
|
||||
ifdef GCC91
|
||||
GCC84=1
|
||||
endif
|
||||
|
||||
ifdef GCC84
|
||||
GCC83=1
|
||||
endif
|
||||
|
||||
ifdef GCC83
|
||||
GCC82=1
|
||||
endif
|
||||
|
||||
ifdef GCC82
|
||||
GCC81=1
|
||||
endif
|
||||
|
||||
ifdef GCC81
|
||||
GCC75=1
|
||||
endif
|
||||
|
||||
ifdef GCC75
|
||||
GCC74=1
|
||||
endif
|
||||
|
||||
ifdef GCC74
|
||||
GCC73=1
|
||||
endif
|
||||
|
||||
ifdef GCC73
|
||||
GCC72=1
|
||||
endif
|
||||
|
||||
@@ -36,6 +140,10 @@ GCC61=1
|
||||
endif
|
||||
|
||||
ifdef GCC61
|
||||
GCC55=1
|
||||
endif
|
||||
|
||||
ifdef GCC55
|
||||
GCC54=1
|
||||
endif
|
||||
|
||||
@@ -106,10 +214,7 @@ WFLAGS=-Wall
|
||||
ifndef GCC295
|
||||
#WFLAGS+=-Wno-packed
|
||||
endif
|
||||
ifdef ERRORMODE
|
||||
WARNINGMODE=1
|
||||
endif
|
||||
ifdef WARNINGMODE
|
||||
ifndef RELAXWARNINGS
|
||||
WFLAGS+=-W
|
||||
#WFLAGS+=-Wno-sign-compare
|
||||
ifndef GCC295
|
||||
@@ -186,6 +291,9 @@ ifndef GCC295
|
||||
endif
|
||||
endif
|
||||
WFLAGS+=-Wformat-y2k
|
||||
ifdef GCC71
|
||||
WFLAGS+=-Wno-error=format-overflow=2
|
||||
endif
|
||||
WFLAGS+=-Wformat-security
|
||||
ifndef GCC29
|
||||
#WFLAGS+=-Winit-self
|
||||
@@ -222,9 +330,9 @@ endif
|
||||
ifdef GCC71
|
||||
WFLAGS+=-Wno-error=implicit-fallthrough
|
||||
WFLAGS+=-Wno-implicit-fallthrough
|
||||
WFLAGS+=-Wno-error=format-truncation
|
||||
WFLAGS+=-Wno-format-truncation
|
||||
endif
|
||||
ifdef GCC80
|
||||
ifdef GCC81
|
||||
WFLAGS+=-Wno-error=format-overflow
|
||||
WFLAGS+=-Wno-error=stringop-truncation
|
||||
WFLAGS+=-Wno-error=stringop-overflow
|
||||
@@ -452,30 +560,6 @@ ifdef ARCHNAME
|
||||
BIN:=$(BIN)/$(ARCHNAME)
|
||||
endif
|
||||
|
||||
# gcc or g++
|
||||
ifdef PREFIX
|
||||
CC=$(PREFIX)-gcc
|
||||
CXX=$(PREFIX)-g++
|
||||
OBJCOPY=$(PREFIX)-objcopy
|
||||
OBJDUMP=$(PREFIX)-objdump
|
||||
STRIP=$(PREFIX)-strip
|
||||
WINDRES=$(PREFIX)-windres
|
||||
else
|
||||
OBJCOPY=objcopy
|
||||
OBJDUMP=objdump
|
||||
STRIP=strip
|
||||
WINDRES=windres
|
||||
endif
|
||||
|
||||
# because Apple screws with us on this
|
||||
# need to get bintools from homebrew
|
||||
ifdef MACOSX
|
||||
CC=clang
|
||||
CXX=clang
|
||||
OBJCOPY=gobjcopy
|
||||
OBJDUMP=gobjdump
|
||||
endif
|
||||
|
||||
OBJDUMP_OPTS?=--wide --source --line-numbers
|
||||
LD=$(CC)
|
||||
|
||||
|
||||
@@ -862,10 +862,8 @@ static inline void AM_drawWalls(void)
|
||||
{
|
||||
size_t i;
|
||||
static mline_t l;
|
||||
#ifdef ESLOPE
|
||||
fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends
|
||||
fixed_t backf1 = 0, backf2 = 0, backc1 = 0, backc2 = 0; // back floor ceiling ends
|
||||
#endif
|
||||
|
||||
for (i = 0; i < numlines; i++)
|
||||
{
|
||||
@@ -873,7 +871,6 @@ static inline void AM_drawWalls(void)
|
||||
l.a.y = lines[i].v1->y >> FRACTOMAPBITS;
|
||||
l.b.x = lines[i].v2->x >> FRACTOMAPBITS;
|
||||
l.b.y = lines[i].v2->y >> FRACTOMAPBITS;
|
||||
#ifdef ESLOPE
|
||||
#define SLOPEPARAMS(slope, end1, end2, normalheight) \
|
||||
if (slope) { \
|
||||
end1 = P_GetZAt(slope, lines[i].v1->x, lines[i].v1->y); \
|
||||
@@ -888,7 +885,6 @@ static inline void AM_drawWalls(void)
|
||||
SLOPEPARAMS(lines[i].backsector->c_slope, backc1, backc2, lines[i].backsector->ceilingheight)
|
||||
}
|
||||
#undef SLOPEPARAMS
|
||||
#endif
|
||||
|
||||
if (!lines[i].backsector) // 1-sided
|
||||
{
|
||||
@@ -897,19 +893,11 @@ static inline void AM_drawWalls(void)
|
||||
else
|
||||
AM_drawMline(&l, WALLCOLORS);
|
||||
}
|
||||
#ifdef ESLOPE
|
||||
else if ((backf1 == backc1 && backf2 == backc2) // Back is thok barrier
|
||||
|| (frontf1 == frontc1 && frontf2 == frontc2)) // Front is thok barrier
|
||||
{
|
||||
if (backf1 == backc1 && backf2 == backc2
|
||||
&& frontf1 == frontc1 && frontf2 == frontc2) // BOTH are thok barriers
|
||||
#else
|
||||
else if (lines[i].backsector->floorheight == lines[i].backsector->ceilingheight // Back is thok barrier
|
||||
|| lines[i].frontsector->floorheight == lines[i].frontsector->ceilingheight) // Front is thok barrier
|
||||
{
|
||||
if (lines[i].backsector->floorheight == lines[i].backsector->ceilingheight
|
||||
&& lines[i].frontsector->floorheight == lines[i].frontsector->ceilingheight) // BOTH are thok barriers
|
||||
#endif
|
||||
{
|
||||
if (lines[i].flags & ML_NOCLIMB)
|
||||
AM_drawMline(&l, NOCLIMBTSWALLCOLORS);
|
||||
@@ -927,20 +915,10 @@ static inline void AM_drawWalls(void)
|
||||
else
|
||||
{
|
||||
if (lines[i].flags & ML_NOCLIMB) {
|
||||
#ifdef ESLOPE
|
||||
if (backf1 != frontf1 || backf2 != frontf2) {
|
||||
#else
|
||||
if (lines[i].backsector->floorheight
|
||||
!= lines[i].frontsector->floorheight) {
|
||||
#endif
|
||||
AM_drawMline(&l, NOCLIMBFDWALLCOLORS); // floor level change
|
||||
}
|
||||
#ifdef ESLOPE
|
||||
else if (backc1 != frontc1 || backc2 != frontc2) {
|
||||
#else
|
||||
else if (lines[i].backsector->ceilingheight
|
||||
!= lines[i].frontsector->ceilingheight) {
|
||||
#endif
|
||||
AM_drawMline(&l, NOCLIMBCDWALLCOLORS); // ceiling level change
|
||||
}
|
||||
else
|
||||
@@ -948,20 +926,10 @@ static inline void AM_drawWalls(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef ESLOPE
|
||||
if (backf1 != frontf1 || backf2 != frontf2) {
|
||||
#else
|
||||
if (lines[i].backsector->floorheight
|
||||
!= lines[i].frontsector->floorheight) {
|
||||
#endif
|
||||
AM_drawMline(&l, FDWALLCOLORS); // floor level change
|
||||
}
|
||||
#ifdef ESLOPE
|
||||
else if (backc1 != frontc1 || backc2 != frontc2) {
|
||||
#else
|
||||
else if (lines[i].backsector->ceilingheight
|
||||
!= lines[i].frontsector->ceilingheight) {
|
||||
#endif
|
||||
AM_drawMline(&l, CDWALLCOLORS); // ceiling level change
|
||||
}
|
||||
else
|
||||
|
||||
@@ -18,6 +18,7 @@ OBJS:=$(OBJS) \
|
||||
$(OBJDIR)/ldo.o \
|
||||
$(OBJDIR)/lfunc.o \
|
||||
$(OBJDIR)/linit.o \
|
||||
$(OBJDIR)/liolib.o \
|
||||
$(OBJDIR)/llex.o \
|
||||
$(OBJDIR)/lmem.o \
|
||||
$(OBJDIR)/lobject.o \
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
static const luaL_Reg lualibs[] = {
|
||||
{"", luaopen_base},
|
||||
{LUA_TABLIBNAME, luaopen_table},
|
||||
{LUA_IOLIBNAME, luaopen_io},
|
||||
{LUA_STRLIBNAME, luaopen_string},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,590 @@
|
||||
/*
|
||||
** $Id: liolib.c,v 2.73.1.3 2008/01/18 17:47:43 roberto Exp $
|
||||
** Standard I/O (and system) library
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define liolib_c
|
||||
#define LUA_LIB
|
||||
|
||||
#include "lua.h"
|
||||
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
#include "../i_system.h"
|
||||
#include "../doomdef.h"
|
||||
#include "../d_main.h"
|
||||
#include "../m_misc.h"
|
||||
|
||||
|
||||
|
||||
#define IO_INPUT 1
|
||||
#define IO_OUTPUT 2
|
||||
|
||||
#define FILELIMIT 1024*1024 // Size limit for reading/writing files
|
||||
|
||||
|
||||
static const char *const fnames[] = {"input", "output"};
|
||||
static const char *whitelist[] = { // Allow scripters to write files of these types to SRB2's folder
|
||||
".txt",
|
||||
".sav2",
|
||||
".cfg",
|
||||
".png",
|
||||
".bmp"
|
||||
};
|
||||
|
||||
|
||||
static int pushresult (lua_State *L, int i, const char *filename) {
|
||||
int en = errno; /* calls to Lua API may change this value */
|
||||
if (i) {
|
||||
lua_pushboolean(L, 1);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
lua_pushnil(L);
|
||||
if (filename)
|
||||
lua_pushfstring(L, "%s: %s", filename, strerror(en));
|
||||
else
|
||||
lua_pushfstring(L, "%s", strerror(en));
|
||||
lua_pushinteger(L, en);
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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))
|
||||
|
||||
|
||||
static int io_type (lua_State *L) {
|
||||
void *ud;
|
||||
luaL_checkany(L, 1);
|
||||
ud = lua_touserdata(L, 1);
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, LUA_FILEHANDLE);
|
||||
if (ud == NULL || !lua_getmetatable(L, 1) || !lua_rawequal(L, -2, -1))
|
||||
lua_pushnil(L); /* not a file */
|
||||
else if (*((FILE **)ud) == NULL)
|
||||
lua_pushliteral(L, "closed file");
|
||||
else
|
||||
lua_pushliteral(L, "file");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static FILE *tofile (lua_State *L) {
|
||||
FILE **f = tofilep(L);
|
||||
if (*f == NULL)
|
||||
luaL_error(L, "attempt to use a closed file");
|
||||
return *f;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** When creating file handles, always creates a `closed' file handle
|
||||
** before opening the actual file; so, if there is a memory error, the
|
||||
** file is not left opened.
|
||||
*/
|
||||
static FILE **newfile (lua_State *L) {
|
||||
FILE **pf = (FILE **)lua_newuserdata(L, sizeof(FILE *));
|
||||
*pf = NULL; /* file handle is currently `closed' */
|
||||
luaL_getmetatable(L, LUA_FILEHANDLE);
|
||||
lua_setmetatable(L, -2);
|
||||
return pf;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** function to (not) close the standard files stdin, stdout, and stderr
|
||||
*/
|
||||
static int io_noclose (lua_State *L) {
|
||||
lua_pushnil(L);
|
||||
lua_pushliteral(L, "cannot close standard file");
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** function to close regular files
|
||||
*/
|
||||
static int io_fclose (lua_State *L) {
|
||||
FILE **p = tofilep(L);
|
||||
int ok = (fclose(*p) == 0);
|
||||
*p = NULL;
|
||||
return pushresult(L, ok, NULL);
|
||||
}
|
||||
|
||||
|
||||
static int aux_close (lua_State *L) {
|
||||
lua_getfenv(L, 1);
|
||||
lua_getfield(L, -1, "__close");
|
||||
return (lua_tocfunction(L, -1))(L);
|
||||
}
|
||||
|
||||
|
||||
static int io_close (lua_State *L) {
|
||||
if (lua_isnone(L, 1))
|
||||
lua_rawgeti(L, LUA_ENVIRONINDEX, IO_OUTPUT);
|
||||
tofile(L); /* make sure argument is a file */
|
||||
return aux_close(L);
|
||||
}
|
||||
|
||||
|
||||
static int io_gc (lua_State *L) {
|
||||
FILE *f = *tofilep(L);
|
||||
/* ignore closed files */
|
||||
if (f != NULL)
|
||||
aux_close(L);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int io_tostring (lua_State *L) {
|
||||
FILE *f = *tofilep(L);
|
||||
if (f == NULL)
|
||||
lua_pushliteral(L, "file (closed)");
|
||||
else
|
||||
lua_pushfstring(L, "file (%p)", f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int StartsWith(const char *a, const char *b) // this is wolfs being lazy yet again
|
||||
{
|
||||
if(strncmp(a, b, strlen(b)) == 0) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int io_open (lua_State *L) {
|
||||
FILE **pf;
|
||||
const char *filename = luaL_checkstring(L, 1);
|
||||
int pass = 0;
|
||||
size_t i;
|
||||
int length = strlen(filename);
|
||||
char *splitter, *forward, *backward;
|
||||
char *destFilename;
|
||||
const char *mode = luaL_optstring(L, 2, "r");
|
||||
|
||||
for (i = 0; i < (sizeof (whitelist) / sizeof(const char *)); i++)
|
||||
{
|
||||
if (!stricmp(&filename[length - strlen(whitelist[i])], whitelist[i]))
|
||||
{
|
||||
pass = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (strstr(filename, "..") || strchr(filename, ':') || StartsWith(filename, "\\")
|
||||
|| StartsWith(filename, "/") || !pass)
|
||||
{
|
||||
luaL_error(L,"access denied to %s", filename);
|
||||
return pushresult(L,0,filename);
|
||||
}
|
||||
|
||||
destFilename = va("%s"PATHSEP"luafiles"PATHSEP"%s", srb2home, filename);
|
||||
|
||||
// Make directories as needed
|
||||
splitter = destFilename;
|
||||
|
||||
forward = strchr(splitter, '/');
|
||||
backward = strchr(splitter, '\\');
|
||||
while ((splitter = (forward && backward) ? min(forward, backward) : (forward ?: backward)))
|
||||
{
|
||||
*splitter = 0;
|
||||
I_mkdir(destFilename, 0755);
|
||||
*splitter = '/';
|
||||
splitter++;
|
||||
|
||||
forward = strchr(splitter, '/');
|
||||
backward = strchr(splitter, '\\');
|
||||
}
|
||||
|
||||
pf = newfile(L);
|
||||
*pf = fopen(destFilename, mode);
|
||||
return (*pf == NULL) ? pushresult(L, 0, filename) : 1;
|
||||
}
|
||||
|
||||
|
||||
static int io_tmpfile (lua_State *L) {
|
||||
FILE **pf = newfile(L);
|
||||
*pf = tmpfile();
|
||||
return (*pf == NULL) ? pushresult(L, 0, NULL) : 1;
|
||||
}
|
||||
|
||||
|
||||
static FILE *getiofile (lua_State *L, int findex) {
|
||||
FILE *f;
|
||||
lua_rawgeti(L, LUA_ENVIRONINDEX, findex);
|
||||
f = *(FILE **)lua_touserdata(L, -1);
|
||||
if (f == NULL)
|
||||
luaL_error(L, "standard %s file is closed", fnames[findex - 1]);
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
static int g_iofile (lua_State *L, int f, const char *mode) {
|
||||
if (!lua_isnoneornil(L, 1)) {
|
||||
const char *filename = lua_tostring(L, 1);
|
||||
if (filename) {
|
||||
FILE **pf = newfile(L);
|
||||
*pf = fopen(filename, mode);
|
||||
if (*pf == NULL)
|
||||
fileerror(L, 1, filename);
|
||||
}
|
||||
else {
|
||||
tofile(L); /* check that it's a valid file handle */
|
||||
lua_pushvalue(L, 1);
|
||||
}
|
||||
lua_rawseti(L, LUA_ENVIRONINDEX, f);
|
||||
}
|
||||
/* return current value */
|
||||
lua_rawgeti(L, LUA_ENVIRONINDEX, f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int io_input (lua_State *L) {
|
||||
return g_iofile(L, IO_INPUT, "r");
|
||||
}
|
||||
|
||||
|
||||
static int io_output (lua_State *L) {
|
||||
return g_iofile(L, IO_OUTPUT, "w");
|
||||
}
|
||||
|
||||
|
||||
static int io_readline (lua_State *L);
|
||||
|
||||
|
||||
static void aux_lines (lua_State *L, int idx, int toclose) {
|
||||
lua_pushvalue(L, idx);
|
||||
lua_pushboolean(L, toclose); /* close/not close file when finished */
|
||||
lua_pushcclosure(L, io_readline, 2);
|
||||
}
|
||||
|
||||
|
||||
static int f_lines (lua_State *L) {
|
||||
tofile(L); /* check that it's a valid file handle */
|
||||
aux_lines(L, 1, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int io_lines (lua_State *L) {
|
||||
if (lua_isnoneornil(L, 1)) { /* no arguments? */
|
||||
/* will iterate over default input */
|
||||
lua_rawgeti(L, LUA_ENVIRONINDEX, IO_INPUT);
|
||||
return f_lines(L);
|
||||
}
|
||||
else {
|
||||
const char *filename = luaL_checkstring(L, 1);
|
||||
FILE **pf = newfile(L);
|
||||
*pf = fopen(filename, "r");
|
||||
if (*pf == NULL)
|
||||
fileerror(L, 1, filename);
|
||||
aux_lines(L, lua_gettop(L), 1);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** {======================================================
|
||||
** READ
|
||||
** =======================================================
|
||||
*/
|
||||
|
||||
|
||||
static int read_number (lua_State *L, FILE *f) {
|
||||
lua_Number d;
|
||||
if (fscanf(f, LUA_NUMBER_SCAN, &d) == 1) {
|
||||
lua_pushnumber(L, d);
|
||||
return 1;
|
||||
}
|
||||
else return 0; /* read fails */
|
||||
}
|
||||
|
||||
|
||||
static int test_eof (lua_State *L, FILE *f) {
|
||||
int c = getc(f);
|
||||
ungetc(c, f);
|
||||
lua_pushlstring(L, NULL, 0);
|
||||
return (c != EOF);
|
||||
}
|
||||
|
||||
|
||||
static int read_line (lua_State *L, FILE *f) {
|
||||
luaL_Buffer b;
|
||||
luaL_buffinit(L, &b);
|
||||
for (;;) {
|
||||
size_t l;
|
||||
char *p = luaL_prepbuffer(&b);
|
||||
if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) { /* eof? */
|
||||
luaL_pushresult(&b); /* close buffer */
|
||||
return (lua_objlen(L, -1) > 0); /* check whether read something */
|
||||
}
|
||||
l = strlen(p);
|
||||
if (l == 0 || p[l-1] != '\n')
|
||||
luaL_addsize(&b, l);
|
||||
else {
|
||||
luaL_addsize(&b, l - 1); /* do not include `eol' */
|
||||
luaL_pushresult(&b); /* close buffer */
|
||||
return 1; /* read at least an `eol' */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int read_chars (lua_State *L, FILE *f, size_t n) {
|
||||
size_t rlen; /* how much to read */
|
||||
size_t nr; /* number of chars actually read */
|
||||
luaL_Buffer b;
|
||||
luaL_buffinit(L, &b);
|
||||
rlen = LUAL_BUFFERSIZE; /* try to read that much each time */
|
||||
do {
|
||||
char *p = luaL_prepbuffer(&b);
|
||||
if (rlen > n) rlen = n; /* cannot read more than asked */
|
||||
nr = fread(p, sizeof(char), rlen, f);
|
||||
luaL_addsize(&b, nr);
|
||||
n -= nr; /* still have to read `n' chars */
|
||||
} while (n > 0 && nr == rlen); /* until end of count or eof */
|
||||
luaL_pushresult(&b); /* close buffer */
|
||||
return (n == 0 || lua_objlen(L, -1) > 0);
|
||||
}
|
||||
|
||||
|
||||
static int g_read (lua_State *L, FILE *f, int first) {
|
||||
int nargs = lua_gettop(L) - 1;
|
||||
int success;
|
||||
int n;
|
||||
clearerr(f);
|
||||
if (nargs == 0) { /* no arguments? */
|
||||
success = read_line(L, f);
|
||||
n = first+1; /* to return 1 result */
|
||||
}
|
||||
else { /* ensure stack space for all results and for auxlib's buffer */
|
||||
luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments");
|
||||
success = 1;
|
||||
for (n = first; nargs-- && success; n++) {
|
||||
if (lua_type(L, n) == LUA_TNUMBER) {
|
||||
size_t l = (size_t)lua_tointeger(L, n);
|
||||
success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l);
|
||||
}
|
||||
else {
|
||||
const char *p = lua_tostring(L, n);
|
||||
luaL_argcheck(L, p && p[0] == '*', n, "invalid option");
|
||||
switch (p[1]) {
|
||||
case 'n': /* number */
|
||||
success = read_number(L, f);
|
||||
break;
|
||||
case 'l': /* line */
|
||||
success = read_line(L, f);
|
||||
break;
|
||||
case 'a': /* file */
|
||||
read_chars(L, f, ~((size_t)0)); /* read MAX_SIZE_T chars */
|
||||
success = 1; /* always success */
|
||||
break;
|
||||
default:
|
||||
return luaL_argerror(L, n, "invalid format");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ferror(f))
|
||||
return pushresult(L, 0, NULL);
|
||||
if (!success) {
|
||||
lua_pop(L, 1); /* remove last result */
|
||||
lua_pushnil(L); /* push nil instead */
|
||||
}
|
||||
return n - first;
|
||||
}
|
||||
|
||||
|
||||
static int io_read (lua_State *L) {
|
||||
return g_read(L, getiofile(L, IO_INPUT), 1);
|
||||
}
|
||||
|
||||
|
||||
static int f_read (lua_State *L) {
|
||||
return g_read(L, tofile(L), 2);
|
||||
}
|
||||
|
||||
|
||||
static int io_readline (lua_State *L) {
|
||||
FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1));
|
||||
int sucess;
|
||||
if (f == NULL) /* file is already closed? */
|
||||
luaL_error(L, "file is already closed");
|
||||
sucess = read_line(L, f);
|
||||
if (ferror(f))
|
||||
return luaL_error(L, "%s", strerror(errno));
|
||||
if (sucess) return 1;
|
||||
else { /* EOF */
|
||||
if (lua_toboolean(L, lua_upvalueindex(2))) { /* generator created file? */
|
||||
lua_settop(L, 0);
|
||||
lua_pushvalue(L, lua_upvalueindex(1));
|
||||
aux_close(L); /* close it */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* }====================================================== */
|
||||
|
||||
|
||||
static int g_write (lua_State *L, FILE *f, int arg) {
|
||||
int nargs = lua_gettop(L) - 1;
|
||||
int status = 1;
|
||||
size_t count;
|
||||
for (; nargs--; arg++) {
|
||||
if (lua_type(L, arg) == LUA_TNUMBER) {
|
||||
/* optimization: could be done exactly as for strings */
|
||||
status = status &&
|
||||
fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0;
|
||||
}
|
||||
else {
|
||||
size_t l;
|
||||
const char *s = luaL_checklstring(L, arg, &l);
|
||||
count += l;
|
||||
if (ftell(f) + l > FILELIMIT)
|
||||
{
|
||||
luaL_error(L,"write limit bypassed in file. Changes have been discarded.");
|
||||
break;
|
||||
}
|
||||
status = status && (fwrite(s, sizeof(char), l, f) == l);
|
||||
}
|
||||
}
|
||||
return pushresult(L, status, NULL);
|
||||
}
|
||||
|
||||
|
||||
static int io_write (lua_State *L) {
|
||||
return g_write(L, getiofile(L, IO_OUTPUT), 1);
|
||||
}
|
||||
|
||||
|
||||
static int f_write (lua_State *L) {
|
||||
return g_write(L, tofile(L), 2);
|
||||
}
|
||||
|
||||
|
||||
static int f_seek (lua_State *L) {
|
||||
static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END};
|
||||
static const char *const modenames[] = {"set", "cur", "end", NULL};
|
||||
FILE *f = tofile(L);
|
||||
int op = luaL_checkoption(L, 2, "cur", modenames);
|
||||
long offset = luaL_optlong(L, 3, 0);
|
||||
op = fseek(f, offset, mode[op]);
|
||||
if (op)
|
||||
return pushresult(L, 0, NULL); /* error */
|
||||
else {
|
||||
lua_pushinteger(L, ftell(f));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int f_setvbuf (lua_State *L) {
|
||||
static const int mode[] = {_IONBF, _IOFBF, _IOLBF};
|
||||
static const char *const modenames[] = {"no", "full", "line", NULL};
|
||||
FILE *f = tofile(L);
|
||||
int op = luaL_checkoption(L, 2, NULL, modenames);
|
||||
lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE);
|
||||
int res = setvbuf(f, NULL, mode[op], sz);
|
||||
return pushresult(L, res == 0, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int io_flush (lua_State *L) {
|
||||
return pushresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL);
|
||||
}
|
||||
|
||||
|
||||
static int f_flush (lua_State *L) {
|
||||
return pushresult(L, fflush(tofile(L)) == 0, NULL);
|
||||
}
|
||||
|
||||
|
||||
static const luaL_Reg iolib[] = {
|
||||
{"close", io_close},
|
||||
{"flush", io_flush},
|
||||
{"input", io_input},
|
||||
{"lines", io_lines},
|
||||
{"open", io_open},
|
||||
{"output", io_output},
|
||||
{"read", io_read},
|
||||
{"tmpfile", io_tmpfile},
|
||||
{"type", io_type},
|
||||
{"write", io_write},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
static const luaL_Reg flib[] = {
|
||||
{"close", io_close},
|
||||
{"flush", f_flush},
|
||||
{"lines", f_lines},
|
||||
{"read", f_read},
|
||||
{"seek", f_seek},
|
||||
{"setvbuf", f_setvbuf},
|
||||
{"write", f_write},
|
||||
{"__gc", io_gc},
|
||||
{"__tostring", io_tostring},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
static void createmeta (lua_State *L) {
|
||||
luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */
|
||||
lua_pushvalue(L, -1); /* push metatable */
|
||||
lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */
|
||||
luaL_register(L, NULL, flib); /* file methods */
|
||||
}
|
||||
|
||||
|
||||
static void createstdfile (lua_State *L, FILE *f, int k, const char *fname) {
|
||||
*newfile(L) = f;
|
||||
if (k > 0) {
|
||||
lua_pushvalue(L, -1);
|
||||
lua_rawseti(L, LUA_ENVIRONINDEX, k);
|
||||
}
|
||||
lua_pushvalue(L, -2); /* copy environment */
|
||||
lua_setfenv(L, -2); /* set it */
|
||||
lua_setfield(L, -3, fname);
|
||||
}
|
||||
|
||||
|
||||
static void newfenv (lua_State *L, lua_CFunction cls) {
|
||||
lua_createtable(L, 0, 1);
|
||||
lua_pushcfunction(L, cls);
|
||||
lua_setfield(L, -2, "__close");
|
||||
}
|
||||
|
||||
|
||||
LUALIB_API int luaopen_io (lua_State *L) {
|
||||
createmeta(L);
|
||||
/* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */
|
||||
newfenv(L, io_fclose);
|
||||
lua_replace(L, LUA_ENVIRONINDEX);
|
||||
/* open library */
|
||||
luaL_register(L, LUA_IOLIBNAME, iolib);
|
||||
/* create (and set) default files */
|
||||
newfenv(L, io_noclose); /* close function for default files */
|
||||
createstdfile(L, stdin, IO_INPUT, "stdin");
|
||||
createstdfile(L, stdout, IO_OUTPUT, "stdout");
|
||||
createstdfile(L, stderr, 0, "stderr");
|
||||
lua_pop(L, 1); /* pop environment for default files */
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@ LUALIB_API int (luaopen_base) (lua_State *L);
|
||||
#define LUA_TABLIBNAME "table"
|
||||
LUALIB_API int (luaopen_table) (lua_State *L);
|
||||
|
||||
#define LUA_IOLIBNAME "io"
|
||||
LUALIB_API int (luaopen_io) (lua_State *L);
|
||||
|
||||
#define LUA_STRLIBNAME "string"
|
||||
LUALIB_API int (luaopen_string) (lua_State *L);
|
||||
|
||||
|
||||
+4
-6
@@ -322,8 +322,8 @@ static void Arith (lua_State *L, StkId ra, TValue *rb,
|
||||
case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break;
|
||||
case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break;
|
||||
case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break;
|
||||
case TM_DIV: if (nc == 0) { lua_pushliteral(L, "divide by zero error"); lua_error(L); } else setnvalue(ra, luai_numdiv(nb, nc)); break;
|
||||
case TM_MOD: if (nc == 0) { lua_pushliteral(L, "modulo by zero error"); lua_error(L); } else setnvalue(ra, luai_nummod(nb, nc)); break;
|
||||
case TM_DIV: if (nc == 0) { luaG_runerror(L, "divide by zero error"); } else setnvalue(ra, luai_numdiv(nb, nc)); break;
|
||||
case TM_MOD: if (nc == 0) { luaG_runerror(L, "modulo by zero error"); } else setnvalue(ra, luai_nummod(nb, nc)); break;
|
||||
case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break;
|
||||
case TM_UNM: setnvalue(ra, luai_numunm(nb)); break;
|
||||
case TM_AND: setnvalue(ra, luai_numand(nb, nc)); break;
|
||||
@@ -492,8 +492,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
||||
lua_Number nb = nvalue(rb), nc = nvalue(rc);
|
||||
if (nc == 0) {
|
||||
lua_pushliteral(L, "divide by zero error");
|
||||
lua_error(L);
|
||||
luaG_runerror(L, "divide by zero error");
|
||||
}
|
||||
else
|
||||
setnvalue(ra, luai_numdiv(nb, nc));
|
||||
@@ -508,8 +507,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
||||
lua_Number nb = nvalue(rb), nc = nvalue(rc);
|
||||
if (nc == 0) {
|
||||
lua_pushliteral(L, "modulo by zero error");
|
||||
lua_error(L);
|
||||
luaG_runerror(L, "modulo by zero error");
|
||||
}
|
||||
else
|
||||
setnvalue(ra, luai_nummod(nb, nc));
|
||||
|
||||
+6
-11
@@ -56,7 +56,7 @@ static void CV_EnforceExecVersion(void);
|
||||
static boolean CV_FilterVarByVersion(consvar_t *v, const char *valstr);
|
||||
|
||||
static boolean CV_Command(void);
|
||||
static consvar_t *CV_FindVar(const char *name);
|
||||
consvar_t *CV_FindVar(const char *name);
|
||||
static const char *CV_StringValue(const char *var_name);
|
||||
static consvar_t *consvar_vars; // list of registered console variables
|
||||
|
||||
@@ -86,7 +86,7 @@ static boolean joyaxis_default[4] = {false,false,false,false};
|
||||
static INT32 joyaxis_count[4] = {0,0,0,0};
|
||||
#endif
|
||||
|
||||
#define COM_BUF_SIZE 8192 // command buffer size
|
||||
#define COM_BUF_SIZE 0x4000 // command buffer size, 0x4000 = 16384
|
||||
#define MAX_ALIAS_RECURSION 100 // max recursion allowed for aliases
|
||||
|
||||
static INT32 com_wait; // one command per frame (for cmd sequences)
|
||||
@@ -532,7 +532,6 @@ static void COM_ExecuteString(char *ptext)
|
||||
{
|
||||
if (!stricmp(com_argv[0], cmd->name)) //case insensitive now that we have lower and uppercase!
|
||||
{
|
||||
recursion = 0;
|
||||
cmd->function();
|
||||
return;
|
||||
}
|
||||
@@ -544,10 +543,7 @@ static void COM_ExecuteString(char *ptext)
|
||||
if (!stricmp(com_argv[0], a->name))
|
||||
{
|
||||
if (recursion > MAX_ALIAS_RECURSION)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Alias recursion cycle detected!\n"));
|
||||
recursion = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
char buf[1024];
|
||||
@@ -579,15 +575,15 @@ static void COM_ExecuteString(char *ptext)
|
||||
}
|
||||
WRITESTRING(write, read);
|
||||
|
||||
// Monster Iestyn: keep track of how many levels of recursion we're in
|
||||
recursion++;
|
||||
COM_BufInsertText(buf);
|
||||
recursion--;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
recursion = 0;
|
||||
|
||||
// check cvars
|
||||
// Hurdler: added at Ebola's request ;)
|
||||
// (don't flood the console in software mode with bad gr_xxx command)
|
||||
@@ -1027,7 +1023,7 @@ static const char *cv_null_string = "";
|
||||
* \return Pointer to the variable if found, or NULL.
|
||||
* \sa CV_FindNetVar
|
||||
*/
|
||||
static consvar_t *CV_FindVar(const char *name)
|
||||
consvar_t *CV_FindVar(const char *name)
|
||||
{
|
||||
consvar_t *cvar;
|
||||
|
||||
@@ -1307,8 +1303,7 @@ found:
|
||||
|
||||
var->string = var->zstring = Z_StrDup(valstr);
|
||||
|
||||
if (var->flags & CV_PASSWORD); // Don't change value for password field
|
||||
else if (override)
|
||||
if (override)
|
||||
var->value = overrideval;
|
||||
else if (var->flags & CV_FLOAT)
|
||||
{
|
||||
|
||||
+4
-2
@@ -98,8 +98,7 @@ typedef enum
|
||||
CV_HIDEN = 1024, // variable is not part of the cvar list so cannot be accessed by the console
|
||||
// can only be set when we have the pointer to it
|
||||
// used on menus
|
||||
CV_CHEAT = 2048, // Don't let this be used in multiplayer unless cheats are on.
|
||||
CV_PASSWORD = 4096 // Password field
|
||||
CV_CHEAT = 2048 // Don't let this be used in multiplayer unless cheats are on.
|
||||
} cvflags_t;
|
||||
|
||||
typedef struct CV_PossibleValue_s
|
||||
@@ -173,4 +172,7 @@ void CV_ResetCheatNetVars(void);
|
||||
boolean CV_IsSetToDefault(consvar_t *v);
|
||||
UINT8 CV_CheatsEnabled(void);
|
||||
|
||||
// Returns cvar by name. Exposed here for Lua.
|
||||
consvar_t *CV_FindVar(const char *name);
|
||||
|
||||
#endif // __COMMAND_H__
|
||||
+2
-2
@@ -37,7 +37,7 @@
|
||||
* 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 2019 / 05 / 06 - Kart v1.1.0 - patch.kart
|
||||
* Last updated 2020 / 08 / 30 - Kart v1.3 - patch.kart
|
||||
*/
|
||||
|
||||
// Base SRB2 hashes
|
||||
@@ -52,7 +52,7 @@
|
||||
#define ASSET_HASH_CHARS_KART "e2c428347dde52858a3dacd29fc5b964"
|
||||
#define ASSET_HASH_MAPS_KART "1335cd064656aedca359cfbb5233ac4a"
|
||||
#ifdef USE_PATCH_KART
|
||||
#define ASSET_HASH_PATCH_KART "7093231f2c3c1cca1a909a708be85d9a"
|
||||
#define ASSET_HASH_PATCH_KART "f7b68076f8abc54e1a78963d97f69ab2"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
+146
-5
@@ -31,6 +31,7 @@
|
||||
#include "i_video.h"
|
||||
#include "z_zone.h"
|
||||
#include "i_system.h"
|
||||
#include "i_threads.h"
|
||||
#include "d_main.h"
|
||||
#include "m_menu.h"
|
||||
#include "filesrch.h"
|
||||
@@ -45,6 +46,16 @@
|
||||
|
||||
#define MAXHUDLINES 20
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
I_mutex con_mutex;
|
||||
|
||||
# define Lock_state() I_lock_mutex(&con_mutex)
|
||||
# define Unlock_state() I_unlock_mutex(con_mutex)
|
||||
#else/*HAVE_THREADS*/
|
||||
# define Lock_state()
|
||||
# define Unlock_state()
|
||||
#endif/*HAVE_THREADS*/
|
||||
|
||||
static boolean con_started = false; // console has been initialised
|
||||
boolean con_startup = false; // true at game startup, screen need refreshing
|
||||
static boolean con_forcepic = true; // at startup toggle console translucency when first off
|
||||
@@ -170,6 +181,8 @@ static void CONS_hudlines_Change(void)
|
||||
{
|
||||
INT32 i;
|
||||
|
||||
Lock_state();
|
||||
|
||||
// Clear the currently displayed lines
|
||||
for (i = 0; i < con_hudlines; i++)
|
||||
con_hudtime[i] = 0;
|
||||
@@ -181,6 +194,8 @@ static void CONS_hudlines_Change(void)
|
||||
|
||||
con_hudlines = cons_hudlines.value;
|
||||
|
||||
Unlock_state();
|
||||
|
||||
CONS_Printf(M_GetText("Number of console HUD lines is now %d\n"), con_hudlines);
|
||||
}
|
||||
|
||||
@@ -188,12 +203,16 @@ static void CONS_hudlines_Change(void)
|
||||
//
|
||||
static void CONS_Clear_f(void)
|
||||
{
|
||||
Lock_state();
|
||||
|
||||
memset(con_buffer, 0, CON_BUFFERSIZE);
|
||||
|
||||
con_cx = 0;
|
||||
con_cy = con_totallines-1;
|
||||
con_line = &con_buffer[con_cy*con_width];
|
||||
con_scrollup = 0;
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
|
||||
// Choose english keymap
|
||||
@@ -369,20 +388,29 @@ void CON_Init(void)
|
||||
for (i = 0; i < NUMINPUTS; i++)
|
||||
bindtable[i] = NULL;
|
||||
|
||||
Lock_state();
|
||||
|
||||
// clear all lines
|
||||
memset(con_buffer, 0, CON_BUFFERSIZE);
|
||||
|
||||
// make sure it is ready for the loading screen
|
||||
con_width = 0;
|
||||
|
||||
Unlock_state();
|
||||
|
||||
CON_RecalcSize();
|
||||
|
||||
CON_SetupColormaps();
|
||||
|
||||
Lock_state();
|
||||
|
||||
//note: CON_Ticker should always execute at least once before D_Display()
|
||||
con_clipviewtop = -1; // -1 does not clip
|
||||
|
||||
con_hudlines = atoi(cons_hudlines.defaultvalue);
|
||||
|
||||
Unlock_state();
|
||||
|
||||
// setup console input filtering
|
||||
CON_InputInit();
|
||||
|
||||
@@ -391,15 +419,23 @@ void CON_Init(void)
|
||||
COM_AddCommand("cls", CONS_Clear_f);
|
||||
//COM_AddCommand("english", CONS_English_f);
|
||||
// set console full screen for game startup MAKE SURE VID_Init() done !!!
|
||||
Lock_state();
|
||||
|
||||
con_destlines = vid.height;
|
||||
con_curlines = vid.height;
|
||||
|
||||
Unlock_state();
|
||||
|
||||
if (!dedicated)
|
||||
{
|
||||
Lock_state();
|
||||
|
||||
con_started = true;
|
||||
con_startup = true; // need explicit screen refresh until we are in Doom loop
|
||||
consoletoggle = false;
|
||||
|
||||
Unlock_state();
|
||||
|
||||
CV_RegisterVar(&cons_msgtimeout);
|
||||
CV_RegisterVar(&cons_hudlines);
|
||||
CV_RegisterVar(&cons_speed);
|
||||
@@ -411,19 +447,27 @@ void CON_Init(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
Lock_state();
|
||||
|
||||
con_started = true;
|
||||
con_startup = false; // need explicit screen refresh until we are in Doom loop
|
||||
consoletoggle = true;
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
}
|
||||
// Console input initialization
|
||||
//
|
||||
static void CON_InputInit(void)
|
||||
{
|
||||
Lock_state();
|
||||
|
||||
// prepare the first prompt line
|
||||
memset(inputlines, 0, sizeof (inputlines));
|
||||
inputline = 0;
|
||||
input_cur = input_sel = input_len = 0;
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
|
||||
//======================================================================
|
||||
@@ -439,6 +483,8 @@ static void CON_RecalcSize(void)
|
||||
char *tmp_buffer;
|
||||
char *string;
|
||||
|
||||
Lock_state();
|
||||
|
||||
switch (cv_constextsize.value)
|
||||
{
|
||||
case V_NOSCALEPATCH:
|
||||
@@ -476,11 +522,18 @@ static void CON_RecalcSize(void)
|
||||
|
||||
// check for change of video width
|
||||
if (conw == con_width)
|
||||
{
|
||||
Unlock_state();
|
||||
return; // didn't change
|
||||
}
|
||||
|
||||
Unlock_state();
|
||||
|
||||
tmp_buffer = Z_Malloc(CON_BUFFERSIZE, PU_STATIC, NULL);
|
||||
string = Z_Malloc(CON_BUFFERSIZE, PU_STATIC, NULL); // BP: it is a line but who know
|
||||
|
||||
Lock_state();
|
||||
|
||||
oldcon_width = con_width;
|
||||
oldnumlines = con_totallines;
|
||||
oldcon_cy = con_cy;
|
||||
@@ -501,6 +554,8 @@ static void CON_RecalcSize(void)
|
||||
con_line = &con_buffer[con_cy*con_width];
|
||||
con_scrollup = 0;
|
||||
|
||||
Unlock_state();
|
||||
|
||||
// re-arrange console text buffer to keep text
|
||||
if (oldcon_width) // not the first time
|
||||
{
|
||||
@@ -525,7 +580,11 @@ static void CON_RecalcSize(void)
|
||||
|
||||
static void CON_ChangeHeight(void)
|
||||
{
|
||||
INT32 minheight = 20 * con_scalefactor; // 20 = 8+8+4
|
||||
INT32 minheight;
|
||||
|
||||
Lock_state();
|
||||
|
||||
minheight = 20 * con_scalefactor; // 20 = 8+8+4
|
||||
|
||||
// toggle console in
|
||||
con_destlines = (cons_height.value*vid.height)/100;
|
||||
@@ -535,13 +594,19 @@ static void CON_ChangeHeight(void)
|
||||
con_destlines = vid.height;
|
||||
|
||||
con_destlines &= ~0x3; // multiple of text row height
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
|
||||
// Handles Console moves in/out of screen (per frame)
|
||||
//
|
||||
static void CON_MoveConsole(void)
|
||||
{
|
||||
const fixed_t conspeed = FixedDiv(cons_speed.value*vid.fdupy, FRACUNIT);
|
||||
fixed_t conspeed;
|
||||
|
||||
Lock_state();
|
||||
|
||||
conspeed = FixedDiv(cons_speed.value*vid.fdupy, FRACUNIT);
|
||||
|
||||
// instant
|
||||
if (!cons_speed.value)
|
||||
@@ -563,6 +628,8 @@ static void CON_MoveConsole(void)
|
||||
if (con_curlines < con_destlines)
|
||||
con_curlines = con_destlines;
|
||||
}
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
|
||||
INT32 CON_ShiftChar(INT32 ch)
|
||||
@@ -587,27 +654,44 @@ void CON_ClearHUD(void)
|
||||
{
|
||||
INT32 i;
|
||||
|
||||
Lock_state();
|
||||
|
||||
for (i = 0; i < con_hudlines; i++)
|
||||
con_hudtime[i] = 0;
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
|
||||
// Force console to move out immediately
|
||||
// note: con_ticker will set consoleready false
|
||||
void CON_ToggleOff(void)
|
||||
{
|
||||
Lock_state();
|
||||
|
||||
if (!con_destlines)
|
||||
{
|
||||
Unlock_state();
|
||||
return;
|
||||
}
|
||||
|
||||
con_destlines = 0;
|
||||
con_curlines = 0;
|
||||
CON_ClearHUD();
|
||||
con_forcepic = 0;
|
||||
con_clipviewtop = -1; // remove console clipping of view
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
|
||||
boolean CON_Ready(void)
|
||||
{
|
||||
return consoleready;
|
||||
boolean ready;
|
||||
Lock_state();
|
||||
{
|
||||
ready = consoleready;
|
||||
}
|
||||
Unlock_state();
|
||||
return ready;
|
||||
}
|
||||
|
||||
// Console ticker: handles console move in/out, cursor blinking
|
||||
@@ -615,7 +699,11 @@ boolean CON_Ready(void)
|
||||
void CON_Ticker(void)
|
||||
{
|
||||
INT32 i;
|
||||
INT32 minheight = 20 * con_scalefactor; // 20 = 8+8+4
|
||||
INT32 minheight;
|
||||
|
||||
Lock_state();
|
||||
|
||||
minheight = 20 * con_scalefactor; // 20 = 8+8+4
|
||||
|
||||
// cursor blinking
|
||||
con_tick++;
|
||||
@@ -673,6 +761,8 @@ void CON_Ticker(void)
|
||||
if (con_hudtime[i] < 0)
|
||||
con_hudtime[i] = 0;
|
||||
}
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -684,32 +774,51 @@ void CON_Ticker(void)
|
||||
|
||||
static void CON_InputClear(void)
|
||||
{
|
||||
Lock_state();
|
||||
|
||||
memset(inputlines[inputline], 0, CON_MAXPROMPTCHARS);
|
||||
input_cur = input_sel = input_len = 0;
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
|
||||
static void CON_InputSetString(const char *c)
|
||||
{
|
||||
Lock_state();
|
||||
|
||||
memset(inputlines[inputline], 0, CON_MAXPROMPTCHARS);
|
||||
strcpy(inputlines[inputline], c);
|
||||
input_cur = input_sel = input_len = strlen(c);
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
|
||||
static void CON_InputAddString(const char *c)
|
||||
{
|
||||
size_t csize = strlen(c);
|
||||
|
||||
Lock_state();
|
||||
|
||||
if (input_len + csize > CON_MAXPROMPTCHARS-1)
|
||||
{
|
||||
Unlock_state();
|
||||
return;
|
||||
}
|
||||
if (input_cur != input_len)
|
||||
memmove(&inputlines[inputline][input_cur+csize], &inputlines[inputline][input_cur], input_len-input_cur);
|
||||
memcpy(&inputlines[inputline][input_cur], c, csize);
|
||||
input_len += csize;
|
||||
input_sel = (input_cur += csize);
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
|
||||
static void CON_InputDelSelection(void)
|
||||
{
|
||||
size_t start, end, len;
|
||||
|
||||
Lock_state();
|
||||
|
||||
if (input_cur > input_sel)
|
||||
{
|
||||
start = input_sel;
|
||||
@@ -728,27 +837,39 @@ static void CON_InputDelSelection(void)
|
||||
|
||||
input_len -= len;
|
||||
input_sel = input_cur = start;
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
|
||||
static void CON_InputAddChar(char c)
|
||||
{
|
||||
if (input_len >= CON_MAXPROMPTCHARS-1)
|
||||
return;
|
||||
|
||||
Lock_state();
|
||||
|
||||
if (input_cur != input_len)
|
||||
memmove(&inputlines[inputline][input_cur+1], &inputlines[inputline][input_cur], input_len-input_cur);
|
||||
inputlines[inputline][input_cur++] = c;
|
||||
inputlines[inputline][++input_len] = 0;
|
||||
input_sel = input_cur;
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
|
||||
static void CON_InputDelChar(void)
|
||||
{
|
||||
if (!input_cur)
|
||||
return;
|
||||
|
||||
Lock_state();
|
||||
|
||||
if (input_cur != input_len)
|
||||
memmove(&inputlines[inputline][input_cur-1], &inputlines[inputline][input_cur], input_len-input_cur);
|
||||
inputlines[inputline][--input_len] = 0;
|
||||
input_sel = --input_cur;
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1174,6 +1295,8 @@ static void CON_Print(char *msg)
|
||||
S_StartSound(NULL, sfx_radio);
|
||||
}
|
||||
|
||||
Lock_state();
|
||||
|
||||
if (!(*msg & 0x80))
|
||||
{
|
||||
con_line[con_cx++] = '\x80';
|
||||
@@ -1234,7 +1357,10 @@ static void CON_Print(char *msg)
|
||||
}
|
||||
|
||||
if (*msg == '\0')
|
||||
{
|
||||
Unlock_state();
|
||||
return;
|
||||
}
|
||||
|
||||
// printable character
|
||||
for (l = 0; l < (con_width-11) && msg[l] > ' '; l++)
|
||||
@@ -1252,6 +1378,8 @@ static void CON_Print(char *msg)
|
||||
for (; l > 0; l--)
|
||||
con_line[con_cx++] = *(msg++);
|
||||
}
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
|
||||
void CON_LogMessage(const char *msg)
|
||||
@@ -1283,6 +1411,7 @@ void CONS_Printf(const char *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
static char *txt = NULL;
|
||||
boolean startup;
|
||||
|
||||
if (txt == NULL)
|
||||
txt = malloc(8192);
|
||||
@@ -1315,11 +1444,16 @@ void CONS_Printf(const char *fmt, ...)
|
||||
CON_LogMessage(txt);
|
||||
#endif
|
||||
|
||||
Lock_state();
|
||||
|
||||
// make sure new text is visible
|
||||
con_scrollup = 0;
|
||||
startup = con_startup;
|
||||
|
||||
Unlock_state();
|
||||
|
||||
// if not in display loop, force screen update
|
||||
if (con_startup)
|
||||
if (startup)
|
||||
{
|
||||
#if (defined (_WINDOWS)) || (defined (__OS2__) && !defined (HAVE_SDL))
|
||||
patch_t *con_backpic = W_CachePatchName("KARTKREW", PU_CACHE);
|
||||
@@ -1633,8 +1767,13 @@ static void CON_DrawConsole(void)
|
||||
//
|
||||
void CON_Drawer(void)
|
||||
{
|
||||
Lock_state();
|
||||
|
||||
if (!con_started || !graphics_started)
|
||||
{
|
||||
Unlock_state();
|
||||
return;
|
||||
}
|
||||
|
||||
if (con_recalc)
|
||||
CON_RecalcSize();
|
||||
@@ -1644,4 +1783,6 @@ void CON_Drawer(void)
|
||||
else if (gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_CUTSCENE || gamestate == GS_CREDITS
|
||||
|| gamestate == GS_VOTING || gamestate == GS_EVALUATION || gamestate == GS_WAITINGPLAYERS)
|
||||
CON_DrawHudlines();
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "d_event.h"
|
||||
#include "command.h"
|
||||
#include "i_threads.h"
|
||||
|
||||
#ifdef _WII
|
||||
void CON_InitWii(void);
|
||||
@@ -21,6 +22,10 @@ void CON_Init(void);
|
||||
|
||||
boolean CON_Responder(event_t *ev);
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
extern I_mutex con_mutex;
|
||||
#endif
|
||||
|
||||
// set true when screen size has changed, to adapt console
|
||||
extern boolean con_recalc;
|
||||
|
||||
|
||||
+781
-467
File diff suppressed because it is too large.
Load diff
+61
-30
@@ -13,13 +13,19 @@
|
||||
#ifndef __D_CLISRV__
|
||||
#define __D_CLISRV__
|
||||
|
||||
#include "d_event.h"
|
||||
#include "d_ticcmd.h"
|
||||
#include "d_net.h"
|
||||
#include "d_netcmd.h"
|
||||
#include "tables.h"
|
||||
#include "d_player.h"
|
||||
#include "mserv.h"
|
||||
|
||||
#include "md5.h"
|
||||
/*
|
||||
The 'packet version' is used to distinguish packet formats.
|
||||
This version is independent of VERSION and SUBVERSION. Different
|
||||
applications may follow different packet versions.
|
||||
*/
|
||||
#define PACKETVERSION 0
|
||||
|
||||
// Network play related stuff.
|
||||
// There is a data struct that stores network
|
||||
@@ -29,14 +35,11 @@
|
||||
|
||||
// SOME numpty changed all the gametype constants and it fell out of sync with vanilla and now we have to pretend to be vanilla when talking to the master server...
|
||||
#define VANILLA_GT_RACE 2
|
||||
#if VERSION < 210
|
||||
#define VANILLA_GT_MATCH 1
|
||||
#else
|
||||
#define VANILLA_GT_MATCH 3
|
||||
#endif
|
||||
|
||||
// Networking and tick handling related.
|
||||
#define BACKUPTICS 32
|
||||
#define TICQUEUE 512 // more than enough for most timeouts....
|
||||
#define MAXTEXTCMD 256
|
||||
//
|
||||
// Packet structure
|
||||
@@ -76,9 +79,6 @@ typedef enum
|
||||
PT_CLIENT4MIS,
|
||||
PT_BASICKEEPALIVE,// Keep the network alive during wipes, as tics aren't advanced and NetUpdate isn't called
|
||||
|
||||
PT_JOINCHALLENGE, // You must give a password to joinnnnn
|
||||
PT_DOWNLOADFILESOKAY, // You can download files from the server....
|
||||
|
||||
PT_CANFAIL, // This is kind of a priority. Anything bigger than CANFAIL
|
||||
// allows HSendPacket(*, true, *, *) to return false.
|
||||
// In addition, this packet can't occupy all the available slots.
|
||||
@@ -328,6 +328,11 @@ typedef struct
|
||||
|
||||
char server_context[8]; // Unique context id, generated at server startup.
|
||||
|
||||
// Discord info (always defined for net compatibility)
|
||||
UINT8 maxplayer;
|
||||
boolean allownewplayer;
|
||||
boolean discordinvites;
|
||||
|
||||
UINT8 varlengthinputs[0]; // Playernames and netvars
|
||||
} ATTRPACK serverconfig_pak;
|
||||
|
||||
@@ -342,32 +347,37 @@ typedef struct {
|
||||
#pragma warning(default : 4200)
|
||||
#endif
|
||||
|
||||
#define MAXAPPLICATION 16
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 _255;/* see serverinfo_pak */
|
||||
UINT8 packetversion;
|
||||
char application[MAXAPPLICATION];
|
||||
UINT8 version; // Different versions don't work
|
||||
UINT8 subversion; // Contains build version
|
||||
UINT8 localplayers;
|
||||
UINT8 needsdownload;
|
||||
UINT8 challengenum; // Non-zero if trying to join with a password attempt
|
||||
UINT8 challengeanswer[MD5_LEN]; // Join challenge
|
||||
UINT8 localplayers; // number of splitscreen players
|
||||
UINT8 mode;
|
||||
} ATTRPACK clientconfig_pak;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 challengenum; // Number to send back in join attempt
|
||||
UINT8 question[MD5_LEN]; // Challenge data to be manipulated and answered with
|
||||
} ATTRPACK joinchallenge_pak;
|
||||
|
||||
#define SV_SPEEDMASK 0x03
|
||||
#define SV_LOTSOFADDONS 0x20
|
||||
#define SV_DEDICATED 0x40
|
||||
#define SV_PASSWORD 0x80
|
||||
#define SV_SPEEDMASK 0x03 // used to send kartspeed
|
||||
#define SV_DEDICATED 0x40 // server is dedicated
|
||||
#define SV_LOTSOFADDONS 0x20 // flag used to ask for full file list in d_netfil
|
||||
|
||||
#define MAXSERVERNAME 32
|
||||
#define MAXFILENEEDED 915
|
||||
#define MAX_MIRROR_LENGTH 256
|
||||
// This packet is too large
|
||||
typedef struct
|
||||
{
|
||||
/*
|
||||
In the old packet, 'version' is the first field. Now that field is set
|
||||
to 255 always, so older versions won't be confused with the new
|
||||
versions or vice-versa.
|
||||
*/
|
||||
UINT8 _255;
|
||||
UINT8 packetversion;
|
||||
char application[MAXAPPLICATION];
|
||||
UINT8 version;
|
||||
UINT8 subversion;
|
||||
UINT8 numberofplayer;
|
||||
@@ -377,7 +387,6 @@ typedef struct
|
||||
UINT8 cheatsenabled;
|
||||
UINT8 kartvars; // Previously isdedicated, now appropriated for our own nefarious purposes
|
||||
UINT8 fileneedednum;
|
||||
SINT8 adminplayer;
|
||||
tic_t time;
|
||||
tic_t leveltime;
|
||||
char servername[MAXSERVERNAME];
|
||||
@@ -386,6 +395,7 @@ typedef struct
|
||||
unsigned char mapmd5[16];
|
||||
UINT8 actnum;
|
||||
UINT8 iszone;
|
||||
char httpsource[MAX_MIRROR_LENGTH]; // HTTP URL to download from, always defined for compatibility
|
||||
UINT8 fileneeded[MAXFILENEEDED]; // is filled with writexxx (byteptr.h)
|
||||
} ATTRPACK serverinfo_pak;
|
||||
|
||||
@@ -463,7 +473,6 @@ typedef struct
|
||||
UINT8 textcmd[MAXTEXTCMD+1]; // 66049 bytes (wut??? 64k??? More like 257 bytes...)
|
||||
filetx_pak filetxpak; // 139 bytes
|
||||
clientconfig_pak clientcfg; // 153 bytes
|
||||
joinchallenge_pak joinchallenge; // 17 bytes
|
||||
serverinfo_pak serverinfo; // 1024 bytes
|
||||
serverrefuse_pak serverrefuse; // 65025 bytes (somehow I feel like those values are garbage...)
|
||||
askinfo_pak askinfo; // 61 bytes
|
||||
@@ -480,7 +489,7 @@ typedef struct
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
#define MAXSERVERLIST 64 // Depends only on the display
|
||||
#define MAXSERVERLIST (MAXNETNODES-1)
|
||||
typedef struct
|
||||
{
|
||||
SINT8 node;
|
||||
@@ -493,7 +502,7 @@ extern INT32 mapchangepending;
|
||||
|
||||
// Points inside doomcom
|
||||
extern doomdata_t *netbuffer;
|
||||
|
||||
extern consvar_t cv_httpsource;
|
||||
extern consvar_t cv_showjoinaddress;
|
||||
extern consvar_t cv_playbackspeed;
|
||||
|
||||
@@ -521,7 +530,12 @@ typedef enum
|
||||
|
||||
} kickreason_t;
|
||||
|
||||
/* the max number of name changes in some time period */
|
||||
#define MAXNAMECHANGES (5)
|
||||
#define NAMECHANGERATE (60*TICRATE)
|
||||
|
||||
extern boolean server;
|
||||
extern boolean serverrunning;
|
||||
#define client (!server)
|
||||
extern boolean dedicated; // For dedicated server
|
||||
extern UINT16 software_MAXPACKETLENGTH;
|
||||
@@ -543,8 +557,10 @@ extern consvar_t
|
||||
#endif
|
||||
cv_netticbuffer, cv_allownewplayer, cv_maxplayers, cv_resynchattempts, cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed;
|
||||
|
||||
extern consvar_t cv_discordinvites;
|
||||
|
||||
// Used in d_net, the only dependence
|
||||
tic_t ExpandTics(INT32 low);
|
||||
tic_t ExpandTics(INT32 low, tic_t basetic);
|
||||
void D_ClientServerInit(void);
|
||||
|
||||
// Initialise the other field
|
||||
@@ -568,8 +584,8 @@ void CL_RemoveSplitscreenPlayer(UINT8 p);
|
||||
void CL_Reset(void);
|
||||
void CL_ClearPlayer(INT32 playernum);
|
||||
void CL_RemovePlayer(INT32 playernum, INT32 reason);
|
||||
void CL_UpdateServerList(boolean internetsearch, INT32 room);
|
||||
boolean CL_Responder(event_t *ev);
|
||||
void CL_QueryServerList(msg_server_t *list);
|
||||
void CL_UpdateServerList(void);
|
||||
// Is there a game running
|
||||
boolean Playing(void);
|
||||
|
||||
@@ -602,4 +618,19 @@ UINT8 GetFreeXCmdSize(void);
|
||||
|
||||
extern UINT8 hu_resynching;
|
||||
extern UINT8 hu_stopped; // kart, true when the game is stopped for players due to a disconnecting or connecting player
|
||||
|
||||
typedef struct rewind_s {
|
||||
UINT8 savebuffer[(768*1024)];
|
||||
tic_t leveltime;
|
||||
size_t demopos;
|
||||
|
||||
ticcmd_t oldcmd[MAXPLAYERS];
|
||||
mobj_t oldghost[MAXPLAYERS];
|
||||
|
||||
struct rewind_s *next;
|
||||
} rewind_t;
|
||||
|
||||
void CL_ClearRewinds(void);
|
||||
rewind_t *CL_SaveRewindPoint(size_t demopos);
|
||||
rewind_t *CL_RewindToTime(tic_t time);
|
||||
#endif
|
||||
+118
-105
@@ -50,6 +50,7 @@ int snprintf(char *str, size_t n, const char *fmt, ...);
|
||||
#include "hu_stuff.h"
|
||||
#include "i_sound.h"
|
||||
#include "i_system.h"
|
||||
#include "i_threads.h"
|
||||
#include "i_video.h"
|
||||
#include "m_argv.h"
|
||||
#include "m_menu.h"
|
||||
@@ -68,7 +69,6 @@ int snprintf(char *str, size_t n, const char *fmt, ...);
|
||||
#include "m_cheat.h"
|
||||
#include "y_inter.h"
|
||||
#include "p_local.h" // chasecam
|
||||
#include "mserv.h" // ms_RoomId
|
||||
#include "m_misc.h" // screenshot functionality
|
||||
#include "dehacked.h" // Dehacked list test
|
||||
#include "m_cond.h" // condition initialization
|
||||
@@ -102,6 +102,10 @@ int snprintf(char *str, size_t n, const char *fmt, ...);
|
||||
#include "lua_script.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
#include "discord.h"
|
||||
#endif
|
||||
|
||||
// platform independant focus loss
|
||||
UINT8 window_notinfocus = false;
|
||||
|
||||
@@ -143,6 +147,8 @@ boolean advancedemo;
|
||||
INT32 debugload = 0;
|
||||
#endif
|
||||
|
||||
char savegamename[256];
|
||||
|
||||
#ifdef _arch_dreamcast
|
||||
char srb2home[256] = "/cd";
|
||||
char srb2path[256] = "/cd";
|
||||
@@ -180,39 +186,11 @@ void D_PostEvent_end(void) {};
|
||||
#endif
|
||||
|
||||
// modifier keys
|
||||
// Now handled in I_OsPolling
|
||||
UINT8 shiftdown = 0; // 0x1 left, 0x2 right
|
||||
UINT8 ctrldown = 0; // 0x1 left, 0x2 right
|
||||
UINT8 altdown = 0; // 0x1 left, 0x2 right
|
||||
boolean capslock = 0; // gee i wonder what this does.
|
||||
//
|
||||
// D_ModifierKeyResponder
|
||||
// Sets global shift/ctrl/alt variables, never actually eats events
|
||||
//
|
||||
static inline void D_ModifierKeyResponder(event_t *ev)
|
||||
{
|
||||
if (ev->type == ev_keydown || ev->type == ev_console) switch (ev->data1)
|
||||
{
|
||||
case KEY_LSHIFT: shiftdown |= 0x1; return;
|
||||
case KEY_RSHIFT: shiftdown |= 0x2; return;
|
||||
case KEY_LCTRL: ctrldown |= 0x1; return;
|
||||
case KEY_RCTRL: ctrldown |= 0x2; return;
|
||||
case KEY_LALT: altdown |= 0x1; return;
|
||||
case KEY_RALT: altdown |= 0x2; return;
|
||||
case KEY_CAPSLOCK: capslock = !capslock; return;
|
||||
|
||||
default: return;
|
||||
}
|
||||
else if (ev->type == ev_keyup) switch (ev->data1)
|
||||
{
|
||||
case KEY_LSHIFT: shiftdown &= ~0x1; return;
|
||||
case KEY_RSHIFT: shiftdown &= ~0x2; return;
|
||||
case KEY_LCTRL: ctrldown &= ~0x1; return;
|
||||
case KEY_RCTRL: ctrldown &= ~0x2; return;
|
||||
case KEY_LALT: altdown &= ~0x1; return;
|
||||
case KEY_RALT: altdown &= ~0x2; return;
|
||||
default: return;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// D_ProcessEvents
|
||||
@@ -222,20 +200,16 @@ void D_ProcessEvents(void)
|
||||
{
|
||||
event_t *ev;
|
||||
|
||||
boolean eaten;
|
||||
|
||||
for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1))
|
||||
{
|
||||
ev = &events[eventtail];
|
||||
|
||||
// Set global shift/ctrl/alt down variables
|
||||
D_ModifierKeyResponder(ev); // never eats events
|
||||
|
||||
// Screenshots over everything so that they can be taken anywhere.
|
||||
if (M_ScreenshotResponder(ev))
|
||||
continue; // ate the event
|
||||
|
||||
if (CL_Responder(ev))
|
||||
continue;
|
||||
|
||||
if (gameaction == ga_nothing && gamestate == GS_TITLESCREEN)
|
||||
{
|
||||
if (cht_Responder(ev))
|
||||
@@ -249,11 +223,36 @@ void D_ProcessEvents(void)
|
||||
}
|
||||
|
||||
// Menu input
|
||||
if (M_Responder(ev))
|
||||
#ifdef HAVE_THREADS
|
||||
I_lock_mutex(&m_menu_mutex);
|
||||
#endif
|
||||
{
|
||||
eaten = M_Responder(ev);
|
||||
}
|
||||
#ifdef HAVE_THREADS
|
||||
I_unlock_mutex(m_menu_mutex);
|
||||
#endif
|
||||
|
||||
if (eaten)
|
||||
continue; // menu ate the event
|
||||
|
||||
// Demo input:
|
||||
if (demo.playback)
|
||||
if (M_DemoResponder(ev))
|
||||
continue; // demo ate the event
|
||||
|
||||
// console input
|
||||
if (CON_Responder(ev))
|
||||
#ifdef HAVE_THREADS
|
||||
I_lock_mutex(&con_mutex);
|
||||
#endif
|
||||
{
|
||||
eaten = CON_Responder(ev);
|
||||
}
|
||||
#ifdef HAVE_THREADS
|
||||
I_unlock_mutex(con_mutex);
|
||||
#endif
|
||||
|
||||
if (eaten)
|
||||
continue; // ate the event
|
||||
|
||||
G_Responder(ev);
|
||||
@@ -276,29 +275,29 @@ static void D_Display(void)
|
||||
INT32 wipedefindex = 0;
|
||||
UINT8 i;
|
||||
|
||||
if (dedicated)
|
||||
return;
|
||||
|
||||
if (nodrawers)
|
||||
return; // for comparative timing/profiling
|
||||
|
||||
// check for change of screen size (video mode)
|
||||
if (setmodeneeded && !wipe)
|
||||
SCR_SetMode(); // change video mode
|
||||
|
||||
if (vid.recalc)
|
||||
SCR_Recalc(); // NOTE! setsizeneeded is set by SCR_Recalc()
|
||||
|
||||
// change the view size if needed
|
||||
if (setsizeneeded)
|
||||
if (!dedicated)
|
||||
{
|
||||
R_ExecuteSetViewSize();
|
||||
forcerefresh = true; // force background redraw
|
||||
}
|
||||
if (nodrawers)
|
||||
return; // for comparative timing/profiling
|
||||
|
||||
// draw buffered stuff to screen
|
||||
// Used only by linux GGI version
|
||||
I_UpdateNoBlit();
|
||||
// check for change of screen size (video mode)
|
||||
if (setmodeneeded && !wipe)
|
||||
SCR_SetMode(); // change video mode
|
||||
|
||||
if (vid.recalc)
|
||||
SCR_Recalc(); // NOTE! setsizeneeded is set by SCR_Recalc()
|
||||
|
||||
// change the view size if needed
|
||||
if (setsizeneeded)
|
||||
{
|
||||
R_ExecuteSetViewSize();
|
||||
forcerefresh = true; // force background redraw
|
||||
}
|
||||
|
||||
// draw buffered stuff to screen
|
||||
// Used only by linux GGI version
|
||||
I_UpdateNoBlit();
|
||||
}
|
||||
|
||||
// save the current screen if about to wipe
|
||||
wipe = (gamestate != wipegamestate);
|
||||
@@ -316,7 +315,7 @@ static void D_Display(void)
|
||||
wipedefindex = wipe_multinter_toblack;
|
||||
}
|
||||
|
||||
if (rendermode != render_none)
|
||||
if (!dedicated)
|
||||
{
|
||||
// Fade to black first
|
||||
if (gamestate != GS_LEVEL // fades to black on its own timing, always
|
||||
@@ -336,8 +335,16 @@ static void D_Display(void)
|
||||
|
||||
F_WipeStartScreen();
|
||||
}
|
||||
else //dedicated servers
|
||||
{
|
||||
F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK);
|
||||
wipegamestate = gamestate;
|
||||
}
|
||||
}
|
||||
|
||||
if (dedicated) //bail out after wipe logic
|
||||
return;
|
||||
|
||||
// do buffered drawing
|
||||
switch (gamestate)
|
||||
{
|
||||
@@ -447,7 +454,7 @@ static void D_Display(void)
|
||||
{
|
||||
if (i > 0) // Splitscreen-specific
|
||||
{
|
||||
switch (i)
|
||||
switch (i)
|
||||
{
|
||||
case 1:
|
||||
if (splitscreen > 1)
|
||||
@@ -475,7 +482,7 @@ static void D_Display(void)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
topleft = screens[0] + viewwindowy*vid.width + viewwindowx;
|
||||
}
|
||||
|
||||
@@ -541,7 +548,13 @@ static void D_Display(void)
|
||||
if (gamestate != GS_TIMEATTACK)
|
||||
CON_Drawer();
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
I_lock_mutex(&m_menu_mutex);
|
||||
#endif
|
||||
M_Drawer(); // menu is drawn even on top of everything
|
||||
#ifdef HAVE_THREADS
|
||||
I_unlock_mutex(m_menu_mutex);
|
||||
#endif
|
||||
// focus lost moved to M_Drawer
|
||||
|
||||
//
|
||||
@@ -613,9 +626,6 @@ void D_SRB2Loop(void)
|
||||
|
||||
// Pushing of + parameters is now done back in D_SRB2Main, not here.
|
||||
|
||||
CONS_Printf("I_StartupKeyboard()...\n");
|
||||
I_StartupKeyboard();
|
||||
|
||||
#ifdef _WINDOWS
|
||||
CONS_Printf("I_StartupMouse()...\n");
|
||||
I_DoStartupMouse();
|
||||
@@ -720,6 +730,13 @@ void D_SRB2Loop(void)
|
||||
#ifdef HAVE_BLUA
|
||||
LUA_Step();
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
if (! dedicated)
|
||||
{
|
||||
Discord_RunCallbacks();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -834,9 +851,23 @@ static inline void D_CleanFile(char **filearray)
|
||||
// Identify the SRB2 version, and IWAD file to use.
|
||||
// ==========================================================================
|
||||
|
||||
static boolean AddIWAD(void)
|
||||
{
|
||||
char * path = va(pandf,srb2path,"srb2.srb");
|
||||
|
||||
if (FIL_ReadFileOK(path))
|
||||
{
|
||||
D_AddFile(path, startupwadfiles);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static void IdentifyVersion(void)
|
||||
{
|
||||
char *srb2wad1, *srb2wad2;
|
||||
const char *srb2waddir = NULL;
|
||||
|
||||
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
|
||||
@@ -860,43 +891,21 @@ static void IdentifyVersion(void)
|
||||
#ifdef _arch_dreamcast
|
||||
srb2waddir = "/cd";
|
||||
#else
|
||||
srb2waddir = ".";
|
||||
srb2waddir = srb2path;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if defined (macintosh) && !defined (HAVE_SDL)
|
||||
// cwd is always "/" when app is dbl-clicked
|
||||
if (!stricmp(srb2waddir, "/"))
|
||||
srb2waddir = I_GetWadDir();
|
||||
#endif
|
||||
// Commercial.
|
||||
srb2wad1 = malloc(strlen(srb2waddir)+1+8+1);
|
||||
srb2wad2 = malloc(strlen(srb2waddir)+1+8+1);
|
||||
if (srb2wad1 == NULL && srb2wad2 == NULL)
|
||||
I_Error("No more free memory to look in %s", srb2waddir);
|
||||
if (srb2wad1 != NULL)
|
||||
sprintf(srb2wad1, pandf, srb2waddir, "srb2.srb");
|
||||
if (srb2wad2 != NULL)
|
||||
sprintf(srb2wad2, pandf, srb2waddir, "srb2.wad");
|
||||
// Load the IWAD
|
||||
if (! AddIWAD())
|
||||
{
|
||||
I_Error("SRB2.SRB not found! Expected in %s\n", srb2waddir);
|
||||
}
|
||||
|
||||
// will be overwritten in case of -cdrom or unix/win home
|
||||
snprintf(configfile, sizeof configfile, "%s" PATHSEP CONFIGFILENAME, srb2waddir);
|
||||
configfile[sizeof configfile - 1] = '\0';
|
||||
|
||||
// Load the IWAD
|
||||
if (srb2wad2 != NULL && FIL_ReadFileOK(srb2wad2))
|
||||
D_AddFile(srb2wad2, startupwadfiles);
|
||||
else if (srb2wad1 != NULL && FIL_ReadFileOK(srb2wad1))
|
||||
D_AddFile(srb2wad1, startupwadfiles);
|
||||
else
|
||||
I_Error("SRB2.SRB/SRB2.WAD not found! Expected in %s, ss files: %s or %s\n", srb2waddir, srb2wad1, srb2wad2);
|
||||
|
||||
if (srb2wad1)
|
||||
free(srb2wad1);
|
||||
if (srb2wad2)
|
||||
free(srb2wad2);
|
||||
|
||||
// if you change the ordering of this or add/remove a file, be sure to update the md5
|
||||
// checking in D_SRB2Main
|
||||
|
||||
@@ -1301,6 +1310,14 @@ void D_SRB2Main(void)
|
||||
CONS_Printf("I_StartupGraphics()...\n");
|
||||
I_StartupGraphics();
|
||||
|
||||
#ifdef HWRENDER
|
||||
if (rendermode == render_opengl)
|
||||
{
|
||||
for (i = 0; i < numwadfiles; i++)
|
||||
HWR_LoadShaders(i, (wadfiles[i]->type == RET_PK3));
|
||||
}
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------- CONSOLE
|
||||
// setup loading screen
|
||||
SCR_Startup();
|
||||
@@ -1409,17 +1426,6 @@ void D_SRB2Main(void)
|
||||
CONS_Printf("ST_Init(): Init status bar.\n");
|
||||
ST_Init();
|
||||
|
||||
if (M_CheckParm("-room"))
|
||||
{
|
||||
if (!M_IsNextParm())
|
||||
I_Error("usage: -room <room_id>\nCheck the Master Server's webpage for room ID numbers.\n");
|
||||
ms_RoomId = atoi(M_GetNextParm());
|
||||
|
||||
#ifdef UPDATE_ALERT
|
||||
GetMODVersion_Console();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set up splitscreen players before joining!
|
||||
if (!dedicated && (M_CheckParm("-splitscreen") && M_IsNextParm()))
|
||||
{
|
||||
@@ -1595,6 +1601,13 @@ void D_SRB2Main(void)
|
||||
if (!P_SetupLevel(false))
|
||||
I_Quit(); // fail so reset game stuff
|
||||
}
|
||||
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
if (! dedicated)
|
||||
{
|
||||
DRPC_Init();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
const char *D_Home(void)
|
||||
|
||||
+4
-7
@@ -805,9 +805,6 @@ static const char *packettypename[NUMPACKETTYPE] =
|
||||
"CLIENT4MIS",
|
||||
"BASICKEEPALIVE",
|
||||
|
||||
"JOINCHALLENGE",
|
||||
"DOWNLOADFILESOKAY",
|
||||
|
||||
"FILEFRAGMENT",
|
||||
"TEXTCMD",
|
||||
"TEXTCMD2",
|
||||
@@ -833,7 +830,7 @@ static void DebugPrintpacket(const char *header)
|
||||
break;
|
||||
case PT_CLIENTJOIN:
|
||||
fprintf(debugfile, " number %d mode %d\n", netbuffer->u.clientcfg.localplayers,
|
||||
netbuffer->u.clientcfg.needsdownload);
|
||||
netbuffer->u.clientcfg.mode);
|
||||
break;
|
||||
case PT_SERVERTICS:
|
||||
{
|
||||
@@ -842,7 +839,7 @@ static void DebugPrintpacket(const char *header)
|
||||
size_t ntxtcmd = &((UINT8 *)netbuffer)[doomcom->datalength] - cmd;
|
||||
|
||||
fprintf(debugfile, " firsttic %u ply %d tics %d ntxtcmd %s\n ",
|
||||
(UINT32)ExpandTics(serverpak->starttic), serverpak->numslots, serverpak->numtics, sizeu1(ntxtcmd));
|
||||
(UINT32)serverpak->starttic, serverpak->numslots, serverpak->numtics, sizeu1(ntxtcmd));
|
||||
/// \todo Display more readable information about net commands
|
||||
fprintfstringnewline((char *)cmd, ntxtcmd);
|
||||
/*fprintfstring((char *)cmd, 3);
|
||||
@@ -865,8 +862,8 @@ static void DebugPrintpacket(const char *header)
|
||||
case PT_NODEKEEPALIVE:
|
||||
case PT_NODEKEEPALIVEMIS:
|
||||
fprintf(debugfile, " tic %4u resendfrom %u\n",
|
||||
(UINT32)ExpandTics(netbuffer->u.clientpak.client_tic),
|
||||
(UINT32)ExpandTics (netbuffer->u.clientpak.resendfrom));
|
||||
(UINT32)netbuffer->u.clientpak.client_tic,
|
||||
(UINT32)netbuffer->u.clientpak.resendfrom);
|
||||
break;
|
||||
case PT_BASICKEEPALIVE:
|
||||
fprintf(debugfile, " keep alive\n");
|
||||
|
||||
+5
-1
@@ -19,7 +19,9 @@
|
||||
#define __D_NET__
|
||||
|
||||
// Max computers in a game
|
||||
#define MAXNETNODES (MAXPLAYERS+4)
|
||||
// 127 is probably as high as this can go, because
|
||||
// SINT8 is used for nodes sometimes >:(
|
||||
#define MAXNETNODES 127
|
||||
#define BROADCASTADDR MAXNETNODES
|
||||
#define NETSPLITSCREEN // Kart's splitscreen netgame feature
|
||||
|
||||
@@ -41,6 +43,8 @@ extern SINT8 nodetoplayer4[MAXNETNODES]; // Say the numplayer for this node if a
|
||||
extern UINT8 playerpernode[MAXNETNODES]; // Used specially for splitscreen
|
||||
extern boolean nodeingame[MAXNETNODES]; // Set false as nodes leave game
|
||||
|
||||
extern boolean serverrunning;
|
||||
|
||||
INT32 Net_GetFreeAcks(boolean urgent);
|
||||
void Net_AckTicker(void);
|
||||
|
||||
|
||||
+112
-143
@@ -55,6 +55,10 @@
|
||||
#define CV_RESTRICT 0
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
#include "discord.h"
|
||||
#endif
|
||||
|
||||
// ------
|
||||
// protos
|
||||
// ------
|
||||
@@ -77,6 +81,7 @@ static void Got_RandomSeed(UINT8 **cp, INT32 playernum);
|
||||
static void Got_RunSOCcmd(UINT8 **cp, INT32 playernum);
|
||||
static void Got_Teamchange(UINT8 **cp, INT32 playernum);
|
||||
static void Got_Clearscores(UINT8 **cp, INT32 playernum);
|
||||
static void Got_DiscordInfo(UINT8 **cp, INT32 playernum);
|
||||
|
||||
static void PointLimit_OnChange(void);
|
||||
static void TimeLimit_OnChange(void);
|
||||
@@ -172,7 +177,6 @@ static void Got_Verification(UINT8 **cp, INT32 playernum);
|
||||
static void Got_Removal(UINT8 **cp, INT32 playernum);
|
||||
static void Command_Verify_f(void);
|
||||
static void Command_RemoveAdmin_f(void);
|
||||
static void Command_ChangeJoinPassword_f(void);
|
||||
static void Command_MotD_f(void);
|
||||
static void Got_MotD_f(UINT8 **cp, INT32 playernum);
|
||||
|
||||
@@ -554,8 +558,6 @@ void D_RegisterServerCommands(void)
|
||||
RegisterNetXCmd(XD_PICKVOTE, Got_PickVotecmd);
|
||||
|
||||
// Remote Administration
|
||||
CV_RegisterVar(&cv_dummyjoinpassword);
|
||||
COM_AddCommand("joinpassword", Command_ChangeJoinPassword_f);
|
||||
COM_AddCommand("password", Command_Changepassword_f);
|
||||
RegisterNetXCmd(XD_LOGIN, Got_Login);
|
||||
COM_AddCommand("login", Command_Login_f); // useful in dedicated to kick off remote admin
|
||||
@@ -686,6 +688,7 @@ void D_RegisterServerCommands(void)
|
||||
CV_RegisterVar(&cv_maxsend);
|
||||
CV_RegisterVar(&cv_noticedownload);
|
||||
CV_RegisterVar(&cv_downloadspeed);
|
||||
CV_RegisterVar(&cv_httpsource);
|
||||
#ifndef NONET
|
||||
CV_RegisterVar(&cv_allownewplayer);
|
||||
#ifdef VANILLAJOINNEXTROUND
|
||||
@@ -706,10 +709,13 @@ void D_RegisterServerCommands(void)
|
||||
CV_RegisterVar(&cv_showping);
|
||||
|
||||
#ifdef SEENAMES
|
||||
CV_RegisterVar(&cv_allowseenames);
|
||||
CV_RegisterVar(&cv_allowseenames);
|
||||
#endif
|
||||
|
||||
CV_RegisterVar(&cv_dummyconsvar);
|
||||
|
||||
CV_RegisterVar(&cv_discordinvites);
|
||||
RegisterNetXCmd(XD_DISCORD, Got_DiscordInfo);
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
@@ -1003,6 +1009,12 @@ void D_RegisterClientCommands(void)
|
||||
#if defined(HAVE_BLUA) && defined(LUA_ALLOW_BYTECODE)
|
||||
COM_AddCommand("dumplua", Command_Dumplua_f);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
CV_RegisterVar(&cv_discordrp);
|
||||
CV_RegisterVar(&cv_discordstreamer);
|
||||
CV_RegisterVar(&cv_discordasks);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Checks if a name (as received from another player) is okay.
|
||||
@@ -1207,6 +1219,8 @@ static void SetPlayerName(INT32 playernum, char *newname)
|
||||
if (netgame)
|
||||
HU_AddChatText(va("\x82*%s renamed to %s", player_names[playernum], newname), false);
|
||||
|
||||
player_name_changes[playernum]++;
|
||||
|
||||
strcpy(player_names[playernum], newname);
|
||||
demo_extradata[playernum] |= DXD_NAME;
|
||||
}
|
||||
@@ -1388,7 +1402,12 @@ static void SendNameAndColor(void)
|
||||
snacpending++;
|
||||
|
||||
// Don't change name if muted
|
||||
if (cv_mute.value && !(server || IsPlayerAdmin(consoleplayer)))
|
||||
if (player_name_changes[consoleplayer] >= MAXNAMECHANGES)
|
||||
{
|
||||
CV_StealthSet(&cv_playername, player_names[consoleplayer]);
|
||||
HU_AddChatText("\x85*You must wait to change your name again", false);
|
||||
}
|
||||
else if (cv_mute.value && !(server || IsPlayerAdmin(consoleplayer)))
|
||||
CV_StealthSet(&cv_playername, player_names[consoleplayer]);
|
||||
else // Cleanup name if changing it
|
||||
CleanupPlayerName(consoleplayer, cv_playername.zstring);
|
||||
@@ -1512,7 +1531,12 @@ static void SendNameAndColor2(void)
|
||||
snac2pending++;
|
||||
|
||||
// Don't change name if muted
|
||||
if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[1])))
|
||||
if (player_name_changes[displayplayers[1]] >= MAXNAMECHANGES)
|
||||
{
|
||||
CV_StealthSet(&cv_playername2, player_names[displayplayers[1]]);
|
||||
HU_AddChatText("\x85*You must wait to change your name again", false);
|
||||
}
|
||||
else if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[1])))
|
||||
CV_StealthSet(&cv_playername2, player_names[displayplayers[1]]);
|
||||
else // Cleanup name if changing it
|
||||
CleanupPlayerName(displayplayers[1], cv_playername2.zstring);
|
||||
@@ -1627,7 +1651,12 @@ static void SendNameAndColor3(void)
|
||||
snac3pending++;
|
||||
|
||||
// Don't change name if muted
|
||||
if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[2])))
|
||||
if (player_name_changes[displayplayers[2]] >= MAXNAMECHANGES)
|
||||
{
|
||||
CV_StealthSet(&cv_playername3, player_names[displayplayers[2]]);
|
||||
HU_AddChatText("\x85*You must wait to change your name again", false);
|
||||
}
|
||||
else if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[2])))
|
||||
CV_StealthSet(&cv_playername3, player_names[displayplayers[2]]);
|
||||
else // Cleanup name if changing it
|
||||
CleanupPlayerName(displayplayers[2], cv_playername3.zstring);
|
||||
@@ -1750,7 +1779,12 @@ static void SendNameAndColor4(void)
|
||||
snac4pending++;
|
||||
|
||||
// Don't change name if muted
|
||||
if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[3])))
|
||||
if (player_name_changes[displayplayers[3]] >= MAXNAMECHANGES)
|
||||
{
|
||||
CV_StealthSet(&cv_playername4, player_names[displayplayers[3]]);
|
||||
HU_AddChatText("\x85*You must wait to change your name again", false);
|
||||
}
|
||||
else if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[3])))
|
||||
CV_StealthSet(&cv_playername4, player_names[displayplayers[3]]);
|
||||
else // Cleanup name if changing it
|
||||
CleanupPlayerName(displayplayers[3], cv_playername4.zstring);
|
||||
@@ -1805,8 +1839,11 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
|
||||
skin = READUINT8(*cp);
|
||||
|
||||
// set name
|
||||
if (strcasecmp(player_names[playernum], name) != 0)
|
||||
SetPlayerName(playernum, name);
|
||||
if (player_name_changes[playernum] < MAXNAMECHANGES)
|
||||
{
|
||||
if (strcasecmp(player_names[playernum], name) != 0)
|
||||
SetPlayerName(playernum, name);
|
||||
}
|
||||
|
||||
// set color
|
||||
p->skincolor = color % MAXSKINCOLORS;
|
||||
@@ -1862,6 +1899,11 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
|
||||
}
|
||||
else
|
||||
SetPlayerSkinByNum(playernum, skin);
|
||||
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
if (playernum == consoleplayer)
|
||||
DRPC_UpdatePresence();
|
||||
#endif
|
||||
}
|
||||
|
||||
void SendWeaponPref(void)
|
||||
@@ -2041,6 +2083,9 @@ static void Command_View_f(void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (demo.freecam)
|
||||
return;
|
||||
|
||||
displayplayerp = &displayplayers[viewnum-1];
|
||||
|
||||
if (COM_Argc() > 1)/* switch to player */
|
||||
@@ -2670,6 +2715,10 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
|
||||
if (demo.recording) // Okay, level loaded, character spawned and skinned,
|
||||
G_BeginRecording(); // I AM NOW READY TO RECORD.
|
||||
demo.deferstart = true;
|
||||
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
DRPC_UpdatePresence();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void Command_Pause(void)
|
||||
@@ -2689,11 +2738,17 @@ static void Command_Pause(void)
|
||||
|
||||
if (cv_pause.value || server || (IsPlayerAdmin(consoleplayer)))
|
||||
{
|
||||
if (!paused && (modeattacking || !(gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_VOTING || gamestate == GS_WAITINGPLAYERS)))
|
||||
if (!paused && (!(gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_VOTING || gamestate == GS_WAITINGPLAYERS)))
|
||||
{
|
||||
CONS_Printf(M_GetText("You can't pause here.\n"));
|
||||
return;
|
||||
}
|
||||
else if (modeattacking) // in time attack, pausing restarts the map
|
||||
{
|
||||
M_ModeAttackRetry(0); // directly call from m_menu;
|
||||
return;
|
||||
}
|
||||
|
||||
SendNetXCmd(XD_PAUSE, &buf, 2);
|
||||
}
|
||||
else
|
||||
@@ -2770,6 +2825,12 @@ static void Command_Respawn(void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (players[consoleplayer].mo && (players[consoleplayer].kartstuff[k_spinouttimer] || spbplace == players[consoleplayer].kartstuff[k_position])) // KART: Nice try, but no, you won't be cheesing spb anymore (x2)
|
||||
{
|
||||
CONS_Printf(M_GetText("Nice try.\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
/*if (!G_RaceGametype()) // srb2kart: not necessary, respawning makes you lose a bumper in battle, so it's not desirable to use as a way to escape a hit
|
||||
{
|
||||
CONS_Printf(M_GetText("You may only use this in co-op, race, and competition!\n"));
|
||||
@@ -2792,7 +2853,7 @@ static void Got_Respawn(UINT8 **cp, INT32 playernum)
|
||||
INT32 respawnplayer = READINT32(*cp);
|
||||
|
||||
// You can't respawn someone else. Nice try, there.
|
||||
if (respawnplayer != playernum) // srb2kart: "|| (!G_RaceGametype())"
|
||||
if (respawnplayer != playernum || players[respawnplayer].kartstuff[k_spinouttimer] || spbplace == players[respawnplayer].kartstuff[k_position]) // srb2kart: "|| (!G_RaceGametype())"
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Illegal respawn command received from %s\n"), player_names[playernum]);
|
||||
if (server)
|
||||
@@ -3957,131 +4018,6 @@ static void Got_Removal(UINT8 **cp, INT32 playernum)
|
||||
CONS_Printf(M_GetText("You are no longer a server administrator.\n"));
|
||||
}
|
||||
|
||||
// Join password stuff
|
||||
consvar_t cv_dummyjoinpassword = {"dummyjoinpassword", "", CV_HIDEN|CV_NOSHOWHELP|CV_PASSWORD, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
#define NUMJOINCHALLENGES 32
|
||||
static UINT8 joinpassmd5[MD5_LEN+1];
|
||||
boolean joinpasswordset = false;
|
||||
static UINT8 joinpasschallenges[NUMJOINCHALLENGES][MD5_LEN];
|
||||
static tic_t joinpasschallengeson[NUMJOINCHALLENGES];
|
||||
|
||||
boolean D_IsJoinPasswordOn(void)
|
||||
{
|
||||
return joinpasswordset;
|
||||
}
|
||||
|
||||
static inline void GetChallengeAnswer(UINT8 *question, UINT8 *passwordmd5, UINT8 *answer)
|
||||
{
|
||||
D_MD5PasswordPass(question, MD5_LEN, (char *) passwordmd5, answer);
|
||||
}
|
||||
|
||||
void D_ComputeChallengeAnswer(UINT8 *question, const char *pw, UINT8 *answer)
|
||||
{
|
||||
static UINT8 passwordmd5[MD5_LEN+1];
|
||||
|
||||
memset(passwordmd5, 0x00, MD5_LEN+1);
|
||||
D_MD5PasswordPass((const UINT8 *)pw, strlen(pw), BASESALT, &passwordmd5);
|
||||
GetChallengeAnswer(question, passwordmd5, answer);
|
||||
}
|
||||
|
||||
void D_SetJoinPassword(const char *pw)
|
||||
{
|
||||
memset(joinpassmd5, 0x00, MD5_LEN+1);
|
||||
D_MD5PasswordPass((const UINT8 *)pw, strlen(pw), BASESALT, &joinpassmd5);
|
||||
joinpasswordset = true;
|
||||
}
|
||||
|
||||
boolean D_VerifyJoinPasswordChallenge(UINT8 num, UINT8 *answer)
|
||||
{
|
||||
boolean passed = false;
|
||||
|
||||
num %= NUMJOINCHALLENGES;
|
||||
|
||||
//@TODO use a constant-time memcmp....
|
||||
if (joinpasschallengeson[num] > 0 && memcmp(answer, joinpasschallenges[num], MD5_LEN) == 0)
|
||||
passed = true;
|
||||
|
||||
// Wipe and reset the challenge so that it can't be tried against again, as a small measure against brute-force attacks.
|
||||
memset(joinpasschallenges[num], 0x00, MD5_LEN);
|
||||
joinpasschallengeson[num] = 0;
|
||||
|
||||
return passed;
|
||||
}
|
||||
|
||||
void D_MakeJoinPasswordChallenge(UINT8 *num, UINT8 *question)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < NUMJOINCHALLENGES; i++)
|
||||
{
|
||||
(*num) = M_RandomKey(NUMJOINCHALLENGES);
|
||||
|
||||
if (joinpasschallengeson[(*num)] == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (joinpasschallengeson[(*num)] > 0)
|
||||
{
|
||||
// Ugh, all challenges are (probably) taken. Let's find the oldest one and overwrite it.
|
||||
tic_t oldesttic = INT32_MAX;
|
||||
|
||||
for (i = 0; i < NUMJOINCHALLENGES; i++)
|
||||
{
|
||||
if (joinpasschallengeson[i] < oldesttic)
|
||||
{
|
||||
(*num) = i;
|
||||
oldesttic = joinpasschallengeson[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
joinpasschallengeson[(*num)] = I_GetTime();
|
||||
|
||||
memset(question, 0x00, MD5_LEN);
|
||||
for (i = 0; i < MD5_LEN; i++)
|
||||
question[i] = M_RandomByte();
|
||||
|
||||
// Store the answer in memory. What was the question again?
|
||||
GetChallengeAnswer(question, joinpassmd5, joinpasschallenges[(*num)]);
|
||||
|
||||
// This ensures that num is always non-zero and will be valid when used for the answer
|
||||
if ((*num) == 0)
|
||||
(*num) = NUMJOINCHALLENGES;
|
||||
}
|
||||
|
||||
// Remote Administration
|
||||
static void Command_ChangeJoinPassword_f(void)
|
||||
{
|
||||
#ifdef NOMD5
|
||||
// If we have no MD5 support then completely disable XD_LOGIN responses for security.
|
||||
CONS_Alert(CONS_NOTICE, "Remote administration commands are not supported in this build.\n");
|
||||
#else
|
||||
if (client) // cannot change remotely
|
||||
{
|
||||
CONS_Printf(M_GetText("Only the server can use this.\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (COM_Argc() != 2)
|
||||
{
|
||||
CONS_Printf(M_GetText("joinpassword <password>: set a password to join the server\nUse -remove to disable the password.\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(COM_Argv(1), "-remove") == 0)
|
||||
{
|
||||
joinpasswordset = false;
|
||||
CONS_Printf(M_GetText("Join password removed.\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
D_SetJoinPassword(COM_Argv(1));
|
||||
CONS_Printf(M_GetText("Join password set.\n"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void Command_MotD_f(void)
|
||||
{
|
||||
size_t i, j;
|
||||
@@ -4201,7 +4137,7 @@ static void Command_RunSOC(void)
|
||||
static void Got_RunSOCcmd(UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
char filename[256];
|
||||
filestatus_t ncs = FS_NOTFOUND;
|
||||
filestatus_t ncs = FS_NOTCHECKED;
|
||||
|
||||
if (playernum != serverplayer && !IsPlayerAdmin(playernum))
|
||||
{
|
||||
@@ -4373,7 +4309,7 @@ static void Command_Delfile(void)
|
||||
static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
char filename[241];
|
||||
filestatus_t ncs = FS_NOTFOUND;
|
||||
filestatus_t ncs = FS_NOTCHECKED;
|
||||
UINT8 md5sum[16];
|
||||
boolean kick = false;
|
||||
boolean toomany = false;
|
||||
@@ -4468,7 +4404,7 @@ static void Got_Delfilecmd(UINT8 **cp, INT32 playernum)
|
||||
static void Got_Addfilecmd(UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
char filename[241];
|
||||
filestatus_t ncs = FS_NOTFOUND;
|
||||
filestatus_t ncs = FS_NOTCHECKED;
|
||||
UINT8 md5sum[16];
|
||||
|
||||
READSTRINGN(*cp, filename, 240);
|
||||
@@ -4756,6 +4692,10 @@ static void TimeLimit_OnChange(void)
|
||||
}
|
||||
else if (netgame || multiplayer)
|
||||
CONS_Printf(M_GetText("Time limit disabled\n"));
|
||||
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
DRPC_UpdatePresence();
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Adjusts certain settings to match a changed gametype.
|
||||
@@ -5326,11 +5266,11 @@ static void Fishcake_OnChange(void)
|
||||
static void Command_Isgamemodified_f(void)
|
||||
{
|
||||
if (majormods)
|
||||
CONS_Printf("The game has been modified with major add-ons, so you cannot play Record Attack.\n");
|
||||
CONS_Printf("The game has been modified with major addons, so you cannot play Record Attack.\n");
|
||||
else if (savemoddata)
|
||||
CONS_Printf("The game has been modified with an add-on with its own save data, so you can play Record Attack and earn medals.\n");
|
||||
CONS_Printf("The game has been modified with an addon with its own save data, so you can play Record Attack and earn medals.\n");
|
||||
else if (modifiedgame)
|
||||
CONS_Printf("The game has been modified with only minor add-ons. You can play Record Attack, earn medals and unlock extras.\n");
|
||||
CONS_Printf("The game has been modified with only minor addons. You can play Record Attack, earn medals and unlock extras.\n");
|
||||
else
|
||||
CONS_Printf("The game has not been modified. You can play Record Attack, earn medals and unlock extras.\n");
|
||||
}
|
||||
@@ -5781,3 +5721,32 @@ static void KartEliminateLast_OnChange(void)
|
||||
if (G_RaceGametype() && cv_karteliminatelast.value)
|
||||
P_CheckRacers();
|
||||
}
|
||||
|
||||
void Got_DiscordInfo(UINT8 **p, INT32 playernum)
|
||||
{
|
||||
if (playernum != serverplayer /*&& !IsPlayerAdmin(playernum)*/)
|
||||
{
|
||||
// protect against hacked/buggy client
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Illegal Discord info command received from %s\n"), player_names[playernum]);
|
||||
if (server)
|
||||
{
|
||||
XBOXSTATIC UINT8 buf[2];
|
||||
|
||||
buf[0] = (UINT8)playernum;
|
||||
buf[1] = KICK_MSG_CON_FAIL;
|
||||
SendNetXCmd(XD_KICK, &buf, 2);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't do anything with the information if we don't have Discord RP support
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
discordInfo.maxPlayers = READUINT8(*p);
|
||||
discordInfo.joinsAllowed = (boolean)READUINT8(*p);
|
||||
discordInfo.everyoneCanInvite = (boolean)READUINT8(*p);
|
||||
|
||||
DRPC_UpdatePresence();
|
||||
#else
|
||||
(*p) += 3;
|
||||
#endif
|
||||
}
|
||||
+3
-10
@@ -178,9 +178,10 @@ typedef enum
|
||||
XD_MODIFYVOTE, // 23
|
||||
XD_PICKVOTE, // 24
|
||||
XD_REMOVEPLAYER,// 25
|
||||
XD_DISCORD, // 26
|
||||
#ifdef HAVE_BLUA
|
||||
XD_LUACMD, // 26
|
||||
XD_LUAVAR, // 27
|
||||
XD_LUACMD, // 27
|
||||
XD_LUAVAR, // 28
|
||||
#endif
|
||||
MAXNETXCMD
|
||||
} netxcmd_t;
|
||||
@@ -246,14 +247,6 @@ void RemoveAdminPlayer(INT32 playernum);
|
||||
void ItemFinder_OnChange(void);
|
||||
void D_SetPassword(const char *pw);
|
||||
|
||||
extern consvar_t cv_dummyjoinpassword;
|
||||
extern boolean joinpasswordset;
|
||||
boolean D_IsJoinPasswordOn(void);
|
||||
void D_ComputeChallengeAnswer(UINT8 *question, const char *pw, UINT8 *answer);
|
||||
void D_SetJoinPassword(const char *pw);
|
||||
boolean D_VerifyJoinPasswordChallenge(UINT8 num, UINT8 *answer);
|
||||
void D_MakeJoinPasswordChallenge(UINT8 *num, UINT8 *question);
|
||||
|
||||
// used for the player setup menu
|
||||
UINT8 CanChangeSkin(INT32 playernum);
|
||||
|
||||
|
||||
+222
-25
@@ -42,6 +42,10 @@
|
||||
#include <utime.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CURL
|
||||
#include "curl/curl.h"
|
||||
#endif
|
||||
|
||||
#include "doomdef.h"
|
||||
#include "doomstat.h"
|
||||
#include "d_main.h"
|
||||
@@ -65,6 +69,11 @@
|
||||
// Prototypes
|
||||
static boolean SV_SendFile(INT32 node, const char *filename, UINT8 fileid);
|
||||
|
||||
#ifdef HAVE_CURL
|
||||
size_t curlwrite_data(void *ptr, size_t size, size_t nmemb, FILE *stream);
|
||||
int curlprogress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
|
||||
#endif
|
||||
|
||||
// Sender structure
|
||||
typedef struct filetx_s
|
||||
{
|
||||
@@ -99,6 +108,26 @@ char downloaddir[512] = "DOWNLOAD";
|
||||
#ifdef CLIENT_LOADINGSCREEN
|
||||
// for cl loading screen
|
||||
INT32 lastfilenum = -1;
|
||||
INT32 downloadcompletednum = 0;
|
||||
UINT32 downloadcompletedsize = 0;
|
||||
INT32 totalfilesrequestednum = 0;
|
||||
UINT32 totalfilesrequestedsize = 0;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CURL
|
||||
static CURL *http_handle;
|
||||
static CURLM *multi_handle;
|
||||
boolean curl_running = false;
|
||||
boolean curl_failedwebdownload = false;
|
||||
static double curl_dlnow;
|
||||
static double curl_dltotal;
|
||||
static time_t curl_starttime;
|
||||
INT32 curl_transfers = 0;
|
||||
static int curl_runninghandles = 0;
|
||||
static UINT32 curl_origfilesize;
|
||||
static UINT32 curl_origtotalfilesize;
|
||||
static char *curl_realname = NULL;
|
||||
fileneeded_t *curl_curfile = NULL;
|
||||
#endif
|
||||
|
||||
/** Fills a serverinfo packet with information about wad files loaded.
|
||||
@@ -116,7 +145,7 @@ UINT8 *PutFileNeeded(UINT16 firstfile)
|
||||
char wadfilename[MAX_WADPATH] = "";
|
||||
UINT8 filestatus;
|
||||
|
||||
for (i = mainwads; i < numwadfiles; i++)
|
||||
for (i = mainwads+1; i < numwadfiles; i++) //mainwads+1, otherwise we start on the first mainwad
|
||||
{
|
||||
// If it has only music/sound lumps, don't put it in the list
|
||||
if (!wadfiles[i]->important)
|
||||
@@ -182,7 +211,7 @@ void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr, UINT16 fi
|
||||
p = (UINT8 *)fileneededstr;
|
||||
for (i = firstfile; i < fileneedednum; i++)
|
||||
{
|
||||
fileneeded[i].status = FS_NOTFOUND; // We haven't even started looking for the file yet
|
||||
fileneeded[i].status = FS_NOTCHECKED; // We haven't even started looking for the file yet
|
||||
filestatus = READUINT8(p); // The first byte is the file status
|
||||
fileneeded[i].willsend = (UINT8)(filestatus >> 4);
|
||||
fileneeded[i].totalsize = READUINT32(p); // The four next bytes are the file size
|
||||
@@ -238,10 +267,10 @@ boolean CL_CheckDownloadable(void)
|
||||
{
|
||||
CONS_Printf(" * \"%s\" (%dK)", fileneeded[i].filename, fileneeded[i].totalsize >> 10);
|
||||
|
||||
if (fileneeded[i].status == FS_NOTFOUND)
|
||||
CONS_Printf(M_GetText(" not found, md5: "));
|
||||
else if (fileneeded[i].status == FS_MD5SUMBAD)
|
||||
if (fileneeded[i].status == FS_MD5SUMBAD)
|
||||
CONS_Printf(M_GetText(" wrong version, md5: "));
|
||||
else
|
||||
CONS_Printf(M_GetText(" not found, md5: "));
|
||||
|
||||
{
|
||||
INT32 j;
|
||||
@@ -296,7 +325,7 @@ boolean CL_SendRequestFile(void)
|
||||
netbuffer->packettype = PT_REQUESTFILE;
|
||||
p = (char *)netbuffer->u.textcmd;
|
||||
for (i = 0; i < fileneedednum; i++)
|
||||
if ((fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD))
|
||||
if ((fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD || fileneeded[i].status == FS_FALLBACK))
|
||||
{
|
||||
totalfreespaceneeded += fileneeded[i].totalsize;
|
||||
nameonly(fileneeded[i].filename);
|
||||
@@ -345,15 +374,17 @@ boolean Got_RequestFilePak(INT32 node)
|
||||
* \return 0 if some files are missing
|
||||
* 1 if all files exist
|
||||
* 2 if some already loaded files are not requested or are in a different order
|
||||
* 3 too many files, over WADLIMIT
|
||||
* 4 still checking, continuing next tic
|
||||
*
|
||||
*/
|
||||
INT32 CL_CheckFiles(void)
|
||||
{
|
||||
INT32 i, j;
|
||||
char wadfilename[MAX_WADPATH];
|
||||
INT32 ret = 1;
|
||||
size_t packetsize = 0;
|
||||
size_t filestoget = 0;
|
||||
size_t filestoload = 0;
|
||||
boolean downloadrequired = false;
|
||||
|
||||
// if (M_CheckParm("-nofiles"))
|
||||
// return 1;
|
||||
@@ -370,7 +401,7 @@ INT32 CL_CheckFiles(void)
|
||||
if (modifiedgame)
|
||||
{
|
||||
CONS_Debug(DBG_NETPLAY, "game is modified; only doing basic checks\n");
|
||||
for (i = 0, j = mainwads; i < fileneedednum || j < numwadfiles;)
|
||||
for (i = 0, j = mainwads+1; i < fileneedednum || j < numwadfiles;)
|
||||
{
|
||||
if (j < numwadfiles && !wadfiles[j]->important)
|
||||
{
|
||||
@@ -399,10 +430,19 @@ INT32 CL_CheckFiles(void)
|
||||
|
||||
for (i = 0; i < fileneedednum; i++)
|
||||
{
|
||||
if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_FALLBACK)
|
||||
downloadrequired = true;
|
||||
|
||||
if (fileneeded[i].status == FS_FOUND || fileneeded[i].status == FS_NOTFOUND)
|
||||
filestoload++;
|
||||
|
||||
if (fileneeded[i].status != FS_NOTCHECKED) //since we're running this over multiple tics now, its possible for us to come across files checked in previous tics
|
||||
continue;
|
||||
|
||||
CONS_Debug(DBG_NETPLAY, "searching for '%s' ", fileneeded[i].filename);
|
||||
|
||||
// Check in already loaded files
|
||||
for (j = mainwads; wadfiles[j]; j++)
|
||||
for (j = mainwads+1; wadfiles[j]; j++)
|
||||
{
|
||||
nameonly(strcpy(wadfilename, wadfiles[j]->filename));
|
||||
if (!stricmp(wadfilename, fileneeded[i].filename) &&
|
||||
@@ -410,36 +450,35 @@ INT32 CL_CheckFiles(void)
|
||||
{
|
||||
CONS_Debug(DBG_NETPLAY, "already loaded\n");
|
||||
fileneeded[i].status = FS_OPEN;
|
||||
break;
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
if (fileneeded[i].status != FS_NOTFOUND)
|
||||
continue;
|
||||
|
||||
packetsize += nameonlylength(fileneeded[i].filename) + 22;
|
||||
|
||||
if (mainwads+filestoget >= MAX_WADFILES)
|
||||
return 3;
|
||||
|
||||
filestoget++;
|
||||
|
||||
fileneeded[i].status = findfile(fileneeded[i].filename, fileneeded[i].md5sum, true);
|
||||
CONS_Debug(DBG_NETPLAY, "found %d\n", fileneeded[i].status);
|
||||
if (fileneeded[i].status != FS_FOUND)
|
||||
ret = 0;
|
||||
return 4;
|
||||
}
|
||||
return ret;
|
||||
|
||||
//now making it here means we've checked the entire list and no FS_NOTCHECKED files remain
|
||||
if (numwadfiles+filestoload > MAX_WADFILES)
|
||||
return 3;
|
||||
else if (downloadrequired)
|
||||
return 0; //some stuff is FS_NOTFOUND, needs download
|
||||
else
|
||||
return 1; //everything is FS_OPEN or FS_FOUND, proceed to loading
|
||||
}
|
||||
|
||||
// Load it now
|
||||
void CL_LoadServerFiles(void)
|
||||
boolean CL_LoadServerFiles(void)
|
||||
{
|
||||
INT32 i;
|
||||
|
||||
// if (M_CheckParm("-nofiles"))
|
||||
// return;
|
||||
|
||||
for (i = 1; i < fileneedednum; i++)
|
||||
for (i = 0; i < fileneedednum; i++)
|
||||
{
|
||||
if (fileneeded[i].status == FS_OPEN)
|
||||
continue; // Already loaded
|
||||
@@ -448,6 +487,7 @@ void CL_LoadServerFiles(void)
|
||||
P_AddWadFile(fileneeded[i].filename);
|
||||
G_SetGameModified(true, false);
|
||||
fileneeded[i].status = FS_OPEN;
|
||||
return false;
|
||||
}
|
||||
else if (fileneeded[i].status == FS_MD5SUMBAD)
|
||||
I_Error("Wrong version of file %s", fileneeded[i].filename);
|
||||
@@ -473,6 +513,7 @@ void CL_LoadServerFiles(void)
|
||||
fileneeded[i].status, s);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Number of files to send
|
||||
@@ -743,7 +784,7 @@ void SV_FileSendTicker(void)
|
||||
if (ram)
|
||||
M_Memcpy(p->data, &f->id.ram[transfer[i].position], size);
|
||||
else if (fread(p->data, 1, size, transfer[i].currentfile) != size)
|
||||
I_Error("SV_FileSendTicker: can't read %s byte on %s at %d because %s", sizeu1(size), f->id.filename, transfer[i].position, strerror(ferror(transfer[i].currentfile)));
|
||||
I_Error("SV_FileSendTicker: can't read %s byte on %s at %d because %s", sizeu1(size), f->id.filename, transfer[i].position, M_FileError(transfer[i].currentfile));
|
||||
p->position = LONG(transfer[i].position);
|
||||
// Put flag so receiver knows the total size
|
||||
if (transfer[i].position + size == f->size)
|
||||
@@ -822,7 +863,7 @@ void Got_Filetxpak(void)
|
||||
// We can receive packet in the wrong order, anyway all os support gaped file
|
||||
fseek(file->file, pos, SEEK_SET);
|
||||
if (fwrite(netbuffer->u.filetxpak.data,size,1,file->file) != 1)
|
||||
I_Error("Can't write to %s: %s\n",filename, strerror(ferror(file->file)));
|
||||
I_Error("Can't write to %s: %s\n",filename, M_FileError(file->file));
|
||||
file->currentsize += size;
|
||||
|
||||
// Finished?
|
||||
@@ -833,6 +874,10 @@ void Got_Filetxpak(void)
|
||||
file->status = FS_FOUND;
|
||||
CONS_Printf(M_GetText("Downloading %s...(done)\n"),
|
||||
filename);
|
||||
#ifndef NONET
|
||||
downloadcompletednum++;
|
||||
downloadcompletedsize += file->totalsize;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1015,3 +1060,155 @@ filestatus_t findfile(char *filename, const UINT8 *wantedmd5sum, boolean complet
|
||||
|
||||
return (badmd5 ? FS_MD5SUMBAD : FS_NOTFOUND); // md5 sum bad or file not found
|
||||
}
|
||||
|
||||
#ifdef HAVE_CURL
|
||||
size_t curlwrite_data(void *ptr, size_t size, size_t nmemb, FILE *stream)
|
||||
{
|
||||
size_t written;
|
||||
written = fwrite(ptr, size, nmemb, stream);
|
||||
return written;
|
||||
}
|
||||
|
||||
int curlprogress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
|
||||
{
|
||||
(void)clientp;
|
||||
(void)ultotal;
|
||||
(void)ulnow; // Function prototype requires these but we won't use, so just discard
|
||||
curl_dlnow = dlnow;
|
||||
curl_dltotal = dltotal;
|
||||
getbytes = curl_dlnow / (time(NULL) - curl_starttime); // To-do: Make this more accurate???
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CURLPrepareFile(const char* url, int dfilenum)
|
||||
{
|
||||
#ifdef PARANOIA
|
||||
if (M_CheckParm("-nodownload"))
|
||||
I_Error("Attempted to download files in -nodownload mode");
|
||||
#endif
|
||||
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
http_handle = curl_easy_init();
|
||||
multi_handle = curl_multi_init();
|
||||
|
||||
if (http_handle && multi_handle)
|
||||
{
|
||||
I_mkdir(downloaddir, 0755);
|
||||
|
||||
curl_curfile = &fileneeded[dfilenum];
|
||||
curl_realname = curl_curfile->filename;
|
||||
nameonly(curl_realname);
|
||||
|
||||
curl_origfilesize = curl_curfile->currentsize;
|
||||
curl_origtotalfilesize = curl_curfile->totalsize;
|
||||
|
||||
curl_easy_setopt(http_handle, CURLOPT_URL, va("%s/%s", url, curl_realname));
|
||||
|
||||
// Only allow HTTP and HTTPS
|
||||
curl_easy_setopt(http_handle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP|CURLPROTO_HTTPS);
|
||||
|
||||
curl_easy_setopt(http_handle, CURLOPT_USERAGENT, va("SRB2Kart/v%d.%d", VERSION, SUBVERSION)); // Set user agent as some servers won't accept invalid user agents.
|
||||
|
||||
// Follow a redirect request, if sent by the server.
|
||||
curl_easy_setopt(http_handle, CURLOPT_FOLLOWLOCATION, 1L);
|
||||
|
||||
curl_easy_setopt(http_handle, CURLOPT_FAILONERROR, 1L);
|
||||
|
||||
CONS_Printf("Downloading %s from %s\n", curl_realname, url);
|
||||
|
||||
strcatbf(curl_curfile->filename, downloaddir, "/");
|
||||
curl_curfile->file = fopen(curl_curfile->filename, "wb");
|
||||
curl_easy_setopt(http_handle, CURLOPT_WRITEDATA, curl_curfile->file);
|
||||
curl_easy_setopt(http_handle, CURLOPT_WRITEFUNCTION, curlwrite_data);
|
||||
curl_easy_setopt(http_handle, CURLOPT_NOPROGRESS, 0L);
|
||||
curl_easy_setopt(http_handle, CURLOPT_PROGRESSFUNCTION, curlprogress_callback);
|
||||
|
||||
curl_curfile->status = FS_DOWNLOADING;
|
||||
lastfilenum = dfilenum;
|
||||
curl_multi_add_handle(multi_handle, http_handle);
|
||||
|
||||
curl_multi_perform(multi_handle, &curl_runninghandles);
|
||||
curl_starttime = time(NULL);
|
||||
curl_running = true;
|
||||
}
|
||||
}
|
||||
|
||||
void CURLGetFile(void)
|
||||
{
|
||||
CURLMcode mc; /* return code used by curl_multi_wait() */
|
||||
CURLcode easyres; /* Return from easy interface */
|
||||
int numfds;
|
||||
CURLMsg *m; /* for picking up messages with the transfer status */
|
||||
CURL *e;
|
||||
int msgs_left; /* how many messages are left */
|
||||
const char *easy_handle_error;
|
||||
long response_code = 0;
|
||||
|
||||
if (curl_runninghandles)
|
||||
{
|
||||
curl_multi_perform(multi_handle, &curl_runninghandles);
|
||||
|
||||
/* wait for activity, timeout or "nothing" */
|
||||
mc = curl_multi_wait(multi_handle, NULL, 0, 1000, &numfds);
|
||||
|
||||
if (mc != CURLM_OK)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, "curl_multi_wait() failed, code %d.\n", mc);
|
||||
return;
|
||||
}
|
||||
curl_curfile->currentsize = curl_dlnow;
|
||||
curl_curfile->totalsize = curl_dltotal;
|
||||
}
|
||||
|
||||
/* See how the transfers went */
|
||||
while ((m = curl_multi_info_read(multi_handle, &msgs_left)))
|
||||
{
|
||||
if (m && (m->msg == CURLMSG_DONE))
|
||||
{
|
||||
e = m->easy_handle;
|
||||
easyres = m->data.result;
|
||||
if (easyres != CURLE_OK)
|
||||
{
|
||||
if (easyres == CURLE_HTTP_RETURNED_ERROR)
|
||||
curl_easy_getinfo(e, CURLINFO_RESPONSE_CODE, &response_code);
|
||||
|
||||
easy_handle_error = (response_code) ? va("HTTP reponse code %ld", response_code) : curl_easy_strerror(easyres);
|
||||
curl_curfile->status = FS_FALLBACK;
|
||||
curl_curfile->currentsize = curl_origfilesize;
|
||||
curl_curfile->totalsize = curl_origtotalfilesize;
|
||||
curl_failedwebdownload = true;
|
||||
fclose(curl_curfile->file);
|
||||
remove(curl_curfile->filename);
|
||||
curl_curfile->file = NULL;
|
||||
//nameonly(curl_curfile->filename);
|
||||
nameonly(curl_realname);
|
||||
CONS_Printf(M_GetText("Failed to download %s (%s)\n"), curl_realname, easy_handle_error);
|
||||
}
|
||||
else
|
||||
{
|
||||
nameonly(curl_realname);
|
||||
CONS_Printf(M_GetText("Finished downloading %s\n"), curl_realname);
|
||||
downloadcompletednum++;
|
||||
downloadcompletedsize += curl_curfile->totalsize;
|
||||
curl_curfile->status = FS_FOUND;
|
||||
fclose(curl_curfile->file);
|
||||
}
|
||||
|
||||
curl_running = false;
|
||||
curl_transfers--;
|
||||
curl_multi_remove_handle(multi_handle, e);
|
||||
curl_easy_cleanup(e);
|
||||
|
||||
if (!curl_transfers)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!curl_transfers)
|
||||
{
|
||||
curl_multi_cleanup(multi_handle);
|
||||
curl_global_cleanup();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+19
-2
@@ -25,12 +25,14 @@ typedef enum
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FS_NOTCHECKED,
|
||||
FS_NOTFOUND,
|
||||
FS_FOUND,
|
||||
FS_REQUESTED,
|
||||
FS_DOWNLOADING,
|
||||
FS_OPEN, // Is opened and used in w_wad
|
||||
FS_MD5SUMBAD
|
||||
FS_MD5SUMBAD,
|
||||
FS_FALLBACK, // HTTP failed
|
||||
} filestatus_t;
|
||||
|
||||
typedef struct
|
||||
@@ -51,6 +53,16 @@ extern char downloaddir[512];
|
||||
|
||||
#ifdef CLIENT_LOADINGSCREEN
|
||||
extern INT32 lastfilenum;
|
||||
extern INT32 downloadcompletednum;
|
||||
extern UINT32 downloadcompletedsize;
|
||||
extern INT32 totalfilesrequestednum;
|
||||
extern UINT32 totalfilesrequestedsize;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CURL
|
||||
extern boolean curl_failedwebdownload;
|
||||
extern boolean curl_running;
|
||||
extern INT32 curl_transfers;
|
||||
#endif
|
||||
|
||||
UINT8 *PutFileNeeded(UINT16 firstfile);
|
||||
@@ -58,7 +70,7 @@ void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr, UINT16 fi
|
||||
void CL_PrepareDownloadSaveGame(const char *tmpsave);
|
||||
|
||||
INT32 CL_CheckFiles(void);
|
||||
void CL_LoadServerFiles(void);
|
||||
boolean CL_LoadServerFiles(void);
|
||||
void SV_SendRam(INT32 node, void *data, size_t size, freemethod_t freemethod,
|
||||
UINT8 fileid);
|
||||
|
||||
@@ -83,4 +95,9 @@ filestatus_t checkfilemd5(char *filename, const UINT8 *wantedmd5sum);
|
||||
void nameonly(char *s);
|
||||
size_t nameonlylength(const char *s);
|
||||
|
||||
#ifdef HAVE_CURL
|
||||
void CURLPrepareFile(const char* url, int dfilenum);
|
||||
void CURLGetFile(void);
|
||||
#endif
|
||||
|
||||
#endif // __D_NETFIL__
|
||||
+29
-194
@@ -42,10 +42,6 @@
|
||||
#include "r_draw.h" // translation colormap consts (for lua)
|
||||
#endif
|
||||
|
||||
#ifdef HWRENDER
|
||||
#include "hardware/hw_light.h"
|
||||
#endif
|
||||
|
||||
#ifdef PC_DOS
|
||||
#include <stdio.h> // for snprintf
|
||||
//int snprintf(char *str, size_t n, const char *fmt, ...);
|
||||
@@ -335,21 +331,6 @@ static INT32 searchvalue(const char *s)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HWRENDER
|
||||
static float searchfvalue(const char *s)
|
||||
{
|
||||
while (s[0] != '=' && s[0])
|
||||
s++;
|
||||
if (s[0] == '=')
|
||||
return (float)atof(&s[1]);
|
||||
else
|
||||
{
|
||||
deh_warning("No value found");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// These are for clearing all of various things
|
||||
static void clear_conditionsets(void)
|
||||
{
|
||||
@@ -854,128 +835,6 @@ static void readthing(MYFILE *f, INT32 num)
|
||||
Z_Free(s);
|
||||
}
|
||||
|
||||
#ifdef HWRENDER
|
||||
static void readlight(MYFILE *f, INT32 num)
|
||||
{
|
||||
char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL);
|
||||
char *word;
|
||||
char *tmp;
|
||||
INT32 value;
|
||||
float fvalue;
|
||||
|
||||
do
|
||||
{
|
||||
if (myfgets(s, MAXLINELEN, f))
|
||||
{
|
||||
if (s[0] == '\n')
|
||||
break;
|
||||
|
||||
tmp = strchr(s, '#');
|
||||
if (tmp)
|
||||
*tmp = '\0';
|
||||
if (s == tmp)
|
||||
continue; // Skip comment lines, but don't break.
|
||||
|
||||
fvalue = searchfvalue(s);
|
||||
value = searchvalue(s);
|
||||
|
||||
word = strtok(s, " ");
|
||||
if (word)
|
||||
strupr(word);
|
||||
else
|
||||
break;
|
||||
|
||||
if (fastcmp(word, "TYPE"))
|
||||
{
|
||||
DEH_WriteUndoline(word, va("%d", lspr[num].type), UNDO_NONE);
|
||||
lspr[num].type = (UINT16)value;
|
||||
}
|
||||
else if (fastcmp(word, "OFFSETX"))
|
||||
{
|
||||
DEH_WriteUndoline(word, va("%f", lspr[num].light_xoffset), UNDO_NONE);
|
||||
lspr[num].light_xoffset = fvalue;
|
||||
}
|
||||
else if (fastcmp(word, "OFFSETY"))
|
||||
{
|
||||
DEH_WriteUndoline(word, va("%f", lspr[num].light_yoffset), UNDO_NONE);
|
||||
lspr[num].light_yoffset = fvalue;
|
||||
}
|
||||
else if (fastcmp(word, "CORONACOLOR"))
|
||||
{
|
||||
DEH_WriteUndoline(word, va("%u", lspr[num].corona_color), UNDO_NONE);
|
||||
lspr[num].corona_color = value;
|
||||
}
|
||||
else if (fastcmp(word, "CORONARADIUS"))
|
||||
{
|
||||
DEH_WriteUndoline(word, va("%f", lspr[num].corona_radius), UNDO_NONE);
|
||||
lspr[num].corona_radius = fvalue;
|
||||
}
|
||||
else if (fastcmp(word, "DYNAMICCOLOR"))
|
||||
{
|
||||
DEH_WriteUndoline(word, va("%u", lspr[num].dynamic_color), UNDO_NONE);
|
||||
lspr[num].dynamic_color = value;
|
||||
}
|
||||
else if (fastcmp(word, "DYNAMICRADIUS"))
|
||||
{
|
||||
DEH_WriteUndoline(word, va("%f", lspr[num].dynamic_radius), UNDO_NONE);
|
||||
lspr[num].dynamic_radius = fvalue;
|
||||
|
||||
/// \note Update the sqrradius! unnecessary?
|
||||
lspr[num].dynamic_sqrradius = fvalue * fvalue;
|
||||
}
|
||||
else
|
||||
deh_warning("Light %d: unknown word '%s'", num, word);
|
||||
}
|
||||
} while (!myfeof(f)); // finish when the line is empty
|
||||
|
||||
Z_Free(s);
|
||||
}
|
||||
|
||||
static void readspritelight(MYFILE *f, INT32 num)
|
||||
{
|
||||
char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL);
|
||||
char *word;
|
||||
char *tmp;
|
||||
INT32 value;
|
||||
|
||||
do
|
||||
{
|
||||
if (myfgets(s, MAXLINELEN, f))
|
||||
{
|
||||
if (s[0] == '\n')
|
||||
break;
|
||||
|
||||
tmp = strchr(s, '#');
|
||||
if (tmp)
|
||||
*tmp = '\0';
|
||||
if (s == tmp)
|
||||
continue; // Skip comment lines, but don't break.
|
||||
|
||||
value = searchvalue(s);
|
||||
|
||||
word = strtok(s, " ");
|
||||
if (word)
|
||||
strupr(word);
|
||||
else
|
||||
break;
|
||||
|
||||
if (fastcmp(word, "LIGHTTYPE"))
|
||||
{
|
||||
INT32 oldvar;
|
||||
for (oldvar = 0; t_lspr[num] != &lspr[oldvar]; oldvar++)
|
||||
;
|
||||
DEH_WriteUndoline(word, va("%d", oldvar), UNDO_NONE);
|
||||
t_lspr[num] = &lspr[value];
|
||||
}
|
||||
else
|
||||
deh_warning("Sprite %d: unknown word '%s'", num, word);
|
||||
}
|
||||
} while (!myfeof(f)); // finish when the line is empty
|
||||
|
||||
Z_Free(s);
|
||||
}
|
||||
#endif // HWRENDER
|
||||
|
||||
static const struct {
|
||||
const char *name;
|
||||
const UINT16 flag;
|
||||
@@ -1066,6 +925,18 @@ static void readlevelheader(MYFILE *f, INT32 num)
|
||||
sizeof(mapheaderinfo[num-1]->subttl), va("Level header %d: subtitle", num));
|
||||
continue;
|
||||
}
|
||||
else if (fastcmp(word, "LEVELNAME"))
|
||||
{
|
||||
deh_strlcpy(mapheaderinfo[num-1]->lvlttl, word2,
|
||||
sizeof(mapheaderinfo[num-1]->lvlttl), va("Level header %d: levelname", num));
|
||||
continue;
|
||||
}
|
||||
else if (fastcmp(word, "ZONETITLE"))
|
||||
{
|
||||
deh_strlcpy(mapheaderinfo[num-1]->zonttl, word2,
|
||||
sizeof(mapheaderinfo[num-1]->zonttl), va("Level header %d: zonetitle", num));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Lua custom options also go above, contents may be case sensitive.
|
||||
if (fastncmp(word, "LUA.", 4))
|
||||
@@ -1128,16 +999,6 @@ static void readlevelheader(MYFILE *f, INT32 num)
|
||||
}
|
||||
|
||||
// Strings that can be truncated
|
||||
else if (fastcmp(word, "LEVELNAME"))
|
||||
{
|
||||
deh_strlcpy(mapheaderinfo[num-1]->lvlttl, word2,
|
||||
sizeof(mapheaderinfo[num-1]->lvlttl), va("Level header %d: levelname", num));
|
||||
}
|
||||
else if (fastcmp(word, "ZONETITLE"))
|
||||
{
|
||||
deh_strlcpy(mapheaderinfo[num-1]->zonttl, word2,
|
||||
sizeof(mapheaderinfo[num-1]->zonttl), va("Level header %d: zonetitle", num));
|
||||
}
|
||||
else if (fastcmp(word, "SCRIPTNAME"))
|
||||
{
|
||||
deh_strlcpy(mapheaderinfo[num-1]->scriptname, word2,
|
||||
@@ -3513,37 +3374,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
|
||||
readAnimTex(f, i);
|
||||
// This is not a major mod.
|
||||
}*/
|
||||
else if (fastcmp(word, "LIGHT"))
|
||||
{
|
||||
#ifdef HWRENDER
|
||||
// TODO: Read lights by name
|
||||
if (i > 0 && i < NUMLIGHTS)
|
||||
readlight(f, i);
|
||||
else
|
||||
{
|
||||
deh_warning("Light number %d out of range (1 - %d)", i, NUMLIGHTS-1);
|
||||
ignorelines(f);
|
||||
}
|
||||
DEH_WriteUndoline(word, word2, UNDO_HEADER);
|
||||
// This is not a major mod.
|
||||
#endif
|
||||
}
|
||||
else if (fastcmp(word, "SPRITE"))
|
||||
{
|
||||
#ifdef HWRENDER
|
||||
if (i == 0 && word2[0] != '0') // If word2 isn't a number
|
||||
i = get_sprite(word2); // find a sprite by name
|
||||
if (i < NUMSPRITES && i >= 0)
|
||||
readspritelight(f, i);
|
||||
else
|
||||
{
|
||||
deh_warning("Sprite number %d out of range (0 - %d)", i, NUMSPRITES-1);
|
||||
ignorelines(f);
|
||||
}
|
||||
DEH_WriteUndoline(word, word2, UNDO_HEADER);
|
||||
// This is not a major mod.
|
||||
#endif
|
||||
}
|
||||
else if (fastcmp(word, "LEVEL"))
|
||||
{
|
||||
// Support using the actual map name,
|
||||
@@ -7391,7 +7221,7 @@ static const char *const MOBJTYPE_LIST[] = { // array length left dynamic for s
|
||||
|
||||
// Castle Eggman Scenery
|
||||
"MT_CHAIN", // CEZ Chain
|
||||
"MT_FLAME", // Flame (has corona)
|
||||
"MT_FLAME", // Flame
|
||||
"MT_EGGSTATUE", // Eggman Statue
|
||||
"MT_MACEPOINT", // Mace rotation point
|
||||
"MT_SWINGMACEPOINT", // Mace swinging point
|
||||
@@ -7936,7 +7766,6 @@ static const char *const MOBJTYPE_LIST[] = { // array length left dynamic for s
|
||||
"MT_TWINKLECARTAMBIENCE",
|
||||
"MT_EXPLODINGBARREL",
|
||||
"MT_MERRYHORSE",
|
||||
"MT_ARIDTOAD",
|
||||
"MT_BLUEFRUIT",
|
||||
"MT_ORANGEFRUIT",
|
||||
"MT_REDFRUIT",
|
||||
@@ -7947,6 +7776,7 @@ static const char *const MOBJTYPE_LIST[] = { // array length left dynamic for s
|
||||
"MT_BOOSTPROMPT",
|
||||
"MT_BOOSTOFF",
|
||||
"MT_BOOSTON",
|
||||
"MT_ARIDTOAD",
|
||||
"MT_LIZARDMAN",
|
||||
"MT_LIONMAN",
|
||||
|
||||
@@ -8794,13 +8624,11 @@ struct {
|
||||
{"FF_COLORMAPONLY",FF_COLORMAPONLY}, ///< Only copy the colormap, not the lightlevel
|
||||
{"FF_GOOWATER",FF_GOOWATER}, ///< Used with ::FF_SWIMMABLE. Makes thick bouncey goop.
|
||||
|
||||
#ifdef ESLOPE
|
||||
// Slope flags
|
||||
{"SL_NOPHYSICS",SL_NOPHYSICS}, // Don't do momentum adjustment with this slope
|
||||
{"SL_NODYNAMIC",SL_NODYNAMIC}, // Slope will never need to move during the level, so don't fuss with recalculating it
|
||||
{"SL_ANCHORVERTEX",SL_ANCHORVERTEX},// Slope is using a Slope Vertex Thing to anchor its position
|
||||
{"SL_VERTEXSLOPE",SL_VERTEXSLOPE}, // Slope is built from three Slope Vertex Things
|
||||
#endif
|
||||
|
||||
// Angles
|
||||
{"ANG1",ANG1},
|
||||
@@ -9799,8 +9627,7 @@ static inline int lib_getenum(lua_State *L)
|
||||
if (mathlib) return luaL_error(L, "constant '%s' could not be parsed.\n", word);
|
||||
|
||||
// DYNAMIC variables too!!
|
||||
// Try not to add anything that would break netgames or timeattack replays here.
|
||||
// You know, like consoleplayer, displayplayers, or gametime.
|
||||
|
||||
if (fastcmp(word,"gamemap")) {
|
||||
lua_pushinteger(L, gamemap);
|
||||
return 1;
|
||||
@@ -9881,24 +9708,23 @@ static inline int lib_getenum(lua_State *L)
|
||||
return 0;
|
||||
LUA_PushUserdata(L, &players[serverplayer], META_PLAYER);
|
||||
return 1;
|
||||
} else if (fastcmp(word,"consoleplayer")) { // Player controlling the console, basically our local player
|
||||
if (consoleplayer < 0 || !playeringame[consoleplayer])
|
||||
return 0;
|
||||
LUA_PushUserdata(L, &players[consoleplayer], META_PLAYER);
|
||||
return 1;
|
||||
/*} else if (fastcmp(word,"admin")) {
|
||||
LUA_Deprecated(L, "admin", "IsPlayerAdmin(player)");
|
||||
if (!playeringame[adminplayers[0]] || IsPlayerAdmin(serverplayer))
|
||||
return 0;
|
||||
LUA_PushUserdata(L, &players[adminplayers[0]], META_PLAYER);
|
||||
return 1;*/
|
||||
} else if (fastcmp(word,"emeralds")) {
|
||||
lua_pushinteger(L, emeralds);
|
||||
return 1;
|
||||
} else if (fastcmp(word,"gravity")) {
|
||||
lua_pushinteger(L, gravity);
|
||||
return 1;
|
||||
} else if (fastcmp(word,"VERSIONSTRING")) {
|
||||
lua_pushstring(L, VERSIONSTRING);
|
||||
return 1;
|
||||
} else if (fastcmp(word, "token")) {
|
||||
lua_pushinteger(L, token);
|
||||
return 1;
|
||||
} else if (fastcmp(word,"gamespeed")) {
|
||||
lua_pushinteger(L, gamespeed);
|
||||
return 1;
|
||||
@@ -9932,6 +9758,15 @@ static inline int lib_getenum(lua_State *L)
|
||||
} else if (fastcmp(word,"numlaps")) {
|
||||
lua_pushinteger(L, cv_numlaps.value);
|
||||
return 1;
|
||||
} else if (fastcmp(word,"racecountdown")) {
|
||||
lua_pushinteger(L, racecountdown);
|
||||
return 1;
|
||||
} else if (fastcmp(word,"exitcountdown")) {
|
||||
lua_pushinteger(L, exitcountdown); // This name is pretty dumb. Hence why we'll prefer more descriptive names at least in Lua...
|
||||
return 1;
|
||||
} else if (fastcmp(word,"replayplayback")) {
|
||||
lua_pushboolean(L, demo.playback);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
+712
@@ -0,0 +1,712 @@
|
||||
// SONIC ROBO BLAST 2 KART
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2018-2020 by Sally "TehRealSalt" Cochenour.
|
||||
// Copyright (C) 2018-2020 by Kart Krew.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file discord.h
|
||||
/// \brief Discord Rich Presence handling
|
||||
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
|
||||
#ifdef HAVE_CURL
|
||||
#include <curl/curl.h>
|
||||
#endif // HAVE_CURL
|
||||
|
||||
#include "i_system.h"
|
||||
#include "d_clisrv.h"
|
||||
#include "d_netcmd.h"
|
||||
#include "i_net.h"
|
||||
#include "g_game.h"
|
||||
#include "p_tick.h"
|
||||
#include "m_menu.h" // gametype_cons_t
|
||||
#include "r_things.h" // skins
|
||||
#include "mserv.h" // cv_advertise
|
||||
#include "z_zone.h"
|
||||
#include "byteptr.h"
|
||||
|
||||
#include "discord.h"
|
||||
#include "doomdef.h"
|
||||
|
||||
// Feel free to provide your own, if you care enough to create another Discord app for this :P
|
||||
#define DISCORD_APPID "503531144395096085"
|
||||
|
||||
// length of IP strings
|
||||
#define IP_SIZE 21
|
||||
|
||||
consvar_t cv_discordrp = {"discordrp", "On", CV_SAVE|CV_CALL, CV_OnOff, DRPC_UpdatePresence, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_discordstreamer = {"discordstreamer", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_discordasks = {"discordasks", "Yes", CV_SAVE|CV_CALL, CV_YesNo, DRPC_UpdatePresence, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
struct discordInfo_s discordInfo;
|
||||
|
||||
discordRequest_t *discordRequestList = NULL;
|
||||
|
||||
#ifdef HAVE_CURL
|
||||
struct SelfIPbuffer
|
||||
{
|
||||
CURL *curl;
|
||||
char *pointer;
|
||||
size_t length;
|
||||
};
|
||||
|
||||
static char self_ip[IP_SIZE];
|
||||
#endif // HAVE_CURL
|
||||
|
||||
/*--------------------------------------------------
|
||||
static char *DRPC_XORIPString(const char *input)
|
||||
|
||||
Simple XOR encryption/decryption. Not complex or
|
||||
very secretive because we aren't sending anything
|
||||
that isn't easily accessible via our Master Server anyway.
|
||||
--------------------------------------------------*/
|
||||
static char *DRPC_XORIPString(const char *input)
|
||||
{
|
||||
const UINT8 xor[IP_SIZE] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21};
|
||||
char *output = malloc(sizeof(char) * (IP_SIZE+1));
|
||||
UINT8 i;
|
||||
|
||||
for (i = 0; i < IP_SIZE; i++)
|
||||
{
|
||||
char xorinput;
|
||||
|
||||
if (!input[i])
|
||||
break;
|
||||
|
||||
xorinput = input[i] ^ xor[i];
|
||||
|
||||
if (xorinput < 32 || xorinput > 126)
|
||||
{
|
||||
xorinput = input[i];
|
||||
}
|
||||
|
||||
output[i] = xorinput;
|
||||
}
|
||||
|
||||
output[i] = '\0';
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------
|
||||
static void DRPC_HandleReady(const DiscordUser *user)
|
||||
|
||||
Callback function, ran when the game connects to Discord.
|
||||
|
||||
Input Arguments:-
|
||||
user - Struct containing Discord user info.
|
||||
|
||||
Return:-
|
||||
None
|
||||
--------------------------------------------------*/
|
||||
static void DRPC_HandleReady(const DiscordUser *user)
|
||||
{
|
||||
if (cv_discordstreamer.value)
|
||||
{
|
||||
CONS_Printf("Discord: connected to %s\n", user->username);
|
||||
}
|
||||
else
|
||||
{
|
||||
CONS_Printf("Discord: connected to %s#%s (%s)\n", user->username, user->discriminator, user->userId);
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------
|
||||
static void DRPC_HandleDisconnect(int err, const char *msg)
|
||||
|
||||
Callback function, ran when disconnecting from Discord.
|
||||
|
||||
Input Arguments:-
|
||||
err - Error type
|
||||
msg - Error message
|
||||
|
||||
Return:-
|
||||
None
|
||||
--------------------------------------------------*/
|
||||
static void DRPC_HandleDisconnect(int err, const char *msg)
|
||||
{
|
||||
CONS_Printf("Discord: disconnected (%d: %s)\n", err, msg);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------
|
||||
static void DRPC_HandleError(int err, const char *msg)
|
||||
|
||||
Callback function, ran when Discord outputs an error.
|
||||
|
||||
Input Arguments:-
|
||||
err - Error type
|
||||
msg - Error message
|
||||
|
||||
Return:-
|
||||
None
|
||||
--------------------------------------------------*/
|
||||
static void DRPC_HandleError(int err, const char *msg)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, "Discord error (%d: %s)\n", err, msg);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------
|
||||
static void DRPC_HandleJoin(const char *secret)
|
||||
|
||||
Callback function, ran when Discord wants to
|
||||
connect a player to the game via a channel invite
|
||||
or a join request.
|
||||
|
||||
Input Arguments:-
|
||||
secret - Value that links you to the server.
|
||||
|
||||
Return:-
|
||||
None
|
||||
--------------------------------------------------*/
|
||||
static void DRPC_HandleJoin(const char *secret)
|
||||
{
|
||||
char *ip = DRPC_XORIPString(secret);
|
||||
CONS_Printf("Connecting to %s via Discord\n", ip);
|
||||
COM_BufAddText(va("connect \"%s\"\n", ip));
|
||||
free(ip);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------
|
||||
static boolean DRPC_InvitesAreAllowed(void)
|
||||
|
||||
Determines whenever or not invites or
|
||||
ask to join requests are allowed.
|
||||
|
||||
Input Arguments:-
|
||||
None
|
||||
|
||||
Return:-
|
||||
true if invites are allowed, false otherwise.
|
||||
--------------------------------------------------*/
|
||||
static boolean DRPC_InvitesAreAllowed(void)
|
||||
{
|
||||
if (!Playing())
|
||||
{
|
||||
// We're not playing, so we should not be getting invites.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cv_discordasks.value == 0)
|
||||
{
|
||||
// Client has the CVar set to off, so never allow invites from this client.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (discordInfo.joinsAllowed == true)
|
||||
{
|
||||
if (discordInfo.everyoneCanInvite == true)
|
||||
{
|
||||
// Everyone's allowed!
|
||||
return true;
|
||||
}
|
||||
else if (consoleplayer == serverplayer || IsPlayerAdmin(consoleplayer))
|
||||
{
|
||||
// Only admins are allowed!
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Did not pass any of the checks
|
||||
return false;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------
|
||||
static void DRPC_HandleJoinRequest(const DiscordUser *requestUser)
|
||||
|
||||
Callback function, ran when Discord wants to
|
||||
ask the player if another Discord user can join
|
||||
or not.
|
||||
|
||||
Input Arguments:-
|
||||
requestUser - DiscordUser struct for the user trying to connect.
|
||||
|
||||
Return:-
|
||||
None
|
||||
--------------------------------------------------*/
|
||||
static void DRPC_HandleJoinRequest(const DiscordUser *requestUser)
|
||||
{
|
||||
discordRequest_t *append = discordRequestList;
|
||||
discordRequest_t *newRequest;
|
||||
|
||||
if (DRPC_InvitesAreAllowed() == false)
|
||||
{
|
||||
// Something weird happened if this occurred...
|
||||
Discord_Respond(requestUser->userId, DISCORD_REPLY_IGNORE);
|
||||
return;
|
||||
}
|
||||
|
||||
newRequest = Z_Calloc(sizeof(discordRequest_t), PU_STATIC, NULL);
|
||||
|
||||
newRequest->username = Z_Calloc(344, PU_STATIC, NULL);
|
||||
snprintf(newRequest->username, 344, "%s", requestUser->username);
|
||||
|
||||
newRequest->discriminator = Z_Calloc(8, PU_STATIC, NULL);
|
||||
snprintf(newRequest->discriminator, 8, "%s", requestUser->discriminator);
|
||||
|
||||
newRequest->userID = Z_Calloc(32, PU_STATIC, NULL);
|
||||
snprintf(newRequest->userID, 32, "%s", requestUser->userId);
|
||||
|
||||
if (append != NULL)
|
||||
{
|
||||
discordRequest_t *prev = NULL;
|
||||
|
||||
while (append != NULL)
|
||||
{
|
||||
// CHECK FOR DUPES!! Ignore any that already exist from the same user.
|
||||
if (!strcmp(newRequest->userID, append->userID))
|
||||
{
|
||||
Discord_Respond(newRequest->userID, DISCORD_REPLY_IGNORE);
|
||||
DRPC_RemoveRequest(newRequest);
|
||||
return;
|
||||
}
|
||||
|
||||
prev = append;
|
||||
append = append->next;
|
||||
}
|
||||
|
||||
newRequest->prev = prev;
|
||||
prev->next = newRequest;
|
||||
}
|
||||
else
|
||||
{
|
||||
discordRequestList = newRequest;
|
||||
M_RefreshPauseMenu();
|
||||
}
|
||||
|
||||
// Made it to the end, request was valid, so play the request sound :)
|
||||
S_StartSound(NULL, sfx_requst);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------
|
||||
void DRPC_RemoveRequest(discordRequest_t *removeRequest)
|
||||
|
||||
See header file for description.
|
||||
--------------------------------------------------*/
|
||||
void DRPC_RemoveRequest(discordRequest_t *removeRequest)
|
||||
{
|
||||
if (removeRequest->prev != NULL)
|
||||
{
|
||||
removeRequest->prev->next = removeRequest->next;
|
||||
}
|
||||
|
||||
if (removeRequest->next != NULL)
|
||||
{
|
||||
removeRequest->next->prev = removeRequest->prev;
|
||||
|
||||
if (removeRequest == discordRequestList)
|
||||
{
|
||||
discordRequestList = removeRequest->next;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (removeRequest == discordRequestList)
|
||||
{
|
||||
discordRequestList = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Z_Free(removeRequest->username);
|
||||
Z_Free(removeRequest->userID);
|
||||
Z_Free(removeRequest);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------
|
||||
void DRPC_Init(void)
|
||||
|
||||
See header file for description.
|
||||
--------------------------------------------------*/
|
||||
void DRPC_Init(void)
|
||||
{
|
||||
DiscordEventHandlers handlers;
|
||||
memset(&handlers, 0, sizeof(handlers));
|
||||
|
||||
handlers.ready = DRPC_HandleReady;
|
||||
handlers.disconnected = DRPC_HandleDisconnect;
|
||||
handlers.errored = DRPC_HandleError;
|
||||
handlers.joinGame = DRPC_HandleJoin;
|
||||
handlers.joinRequest = DRPC_HandleJoinRequest;
|
||||
|
||||
Discord_Initialize(DISCORD_APPID, &handlers, 1, NULL);
|
||||
I_AddExitFunc(Discord_Shutdown);
|
||||
DRPC_UpdatePresence();
|
||||
}
|
||||
|
||||
#ifdef HAVE_CURL
|
||||
/*--------------------------------------------------
|
||||
static size_t DRPC_WriteServerIP(char *s, size_t size, size_t n, void *userdata)
|
||||
|
||||
Writing function for use with curl. Only intended to be used with simple text.
|
||||
|
||||
Input Arguments:-
|
||||
s - Data to write
|
||||
size - Always 1.
|
||||
n - Length of data
|
||||
userdata - Passed in from CURLOPT_WRITEDATA, intended to be SelfIPbuffer
|
||||
|
||||
Return:-
|
||||
Number of bytes wrote in this pass.
|
||||
--------------------------------------------------*/
|
||||
static size_t DRPC_WriteServerIP(char *s, size_t size, size_t n, void *userdata)
|
||||
{
|
||||
struct SelfIPbuffer *buffer;
|
||||
size_t newlength;
|
||||
|
||||
buffer = userdata;
|
||||
|
||||
newlength = buffer->length + size*n;
|
||||
buffer->pointer = realloc(buffer->pointer, newlength+1);
|
||||
|
||||
memcpy(buffer->pointer + buffer->length, s, size*n);
|
||||
|
||||
buffer->pointer[newlength] = '\0';
|
||||
buffer->length = newlength;
|
||||
|
||||
return size*n;
|
||||
}
|
||||
#endif // HAVE_CURL
|
||||
|
||||
/*--------------------------------------------------
|
||||
static const char *DRPC_GetServerIP(void)
|
||||
|
||||
Retrieves the IP address of the server that you're
|
||||
connected to. Will attempt to use curl for getting your
|
||||
own IP address, if it's not yours.
|
||||
--------------------------------------------------*/
|
||||
static const char *DRPC_GetServerIP(void)
|
||||
{
|
||||
const char *address;
|
||||
|
||||
// If you're connected
|
||||
if (I_GetNodeAddress && (address = I_GetNodeAddress(servernode)) != NULL)
|
||||
{
|
||||
if (strcmp(address, "self"))
|
||||
{
|
||||
// We're not the server, so we could successfully get the IP!
|
||||
// No need to do anything else :)
|
||||
return address;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_CURL
|
||||
// This is a little bit goofy, but
|
||||
// there's practically no good way to get your own public IP address,
|
||||
// so we've gotta break out curl for this :V
|
||||
if (!self_ip[0])
|
||||
{
|
||||
CURL *curl;
|
||||
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
curl = curl_easy_init();
|
||||
|
||||
if (curl)
|
||||
{
|
||||
// The API to get your public IP address from.
|
||||
// Picked because it's stupid simple and it's been up for a long time.
|
||||
const char *api = "http://ip4only.me/api/";
|
||||
|
||||
struct SelfIPbuffer buffer;
|
||||
CURLcode success;
|
||||
|
||||
buffer.length = 0;
|
||||
buffer.pointer = malloc(buffer.length+1);
|
||||
buffer.pointer[0] = '\0';
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, api);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, DRPC_WriteServerIP);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
|
||||
|
||||
success = curl_easy_perform(curl);
|
||||
|
||||
if (success == CURLE_OK)
|
||||
{
|
||||
char *tmp;
|
||||
tmp = strtok(buffer.pointer, ",");
|
||||
|
||||
if (!strcmp(tmp, "IPv4")) // ensure correct type of IP
|
||||
{
|
||||
tmp = strtok(NULL, ",");
|
||||
strncpy(self_ip, tmp, IP_SIZE); // Yay, we have the IP :)
|
||||
}
|
||||
}
|
||||
|
||||
free(buffer.pointer);
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
if (self_ip[0])
|
||||
return self_ip;
|
||||
else
|
||||
#endif // HAVE_CURL
|
||||
return NULL; // Could not get your IP for whatever reason, so we cannot do Discord invites
|
||||
}
|
||||
|
||||
/*--------------------------------------------------
|
||||
void DRPC_EmptyRequests(void)
|
||||
|
||||
Empties the request list. Any existing requests
|
||||
will get an ignore reply.
|
||||
--------------------------------------------------*/
|
||||
static void DRPC_EmptyRequests(void)
|
||||
{
|
||||
while (discordRequestList != NULL)
|
||||
{
|
||||
Discord_Respond(discordRequestList->userID, DISCORD_REPLY_IGNORE);
|
||||
DRPC_RemoveRequest(discordRequestList);
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------
|
||||
void DRPC_UpdatePresence(void)
|
||||
|
||||
See header file for description.
|
||||
--------------------------------------------------*/
|
||||
void DRPC_UpdatePresence(void)
|
||||
{
|
||||
char detailstr[48+1];
|
||||
|
||||
char mapimg[8+1];
|
||||
char mapname[5+21+21+2+1];
|
||||
|
||||
char charimg[4+SKINNAMESIZE+1];
|
||||
char charname[11+SKINNAMESIZE+1];
|
||||
|
||||
boolean joinSecretSet = false;
|
||||
|
||||
DiscordRichPresence discordPresence;
|
||||
memset(&discordPresence, 0, sizeof(discordPresence));
|
||||
|
||||
if (dedicated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cv_discordrp.value)
|
||||
{
|
||||
// User doesn't want to show their game information, so update with empty presence.
|
||||
// This just shows that they're playing SRB2Kart. (If that's too much, then they should disable game activity :V)
|
||||
DRPC_EmptyRequests();
|
||||
Discord_UpdatePresence(&discordPresence);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef DEVELOP
|
||||
// This way, we can use the invite feature in-dev, but not have snoopers seeing any potential secrets! :P
|
||||
discordPresence.largeImageKey = "miscdevelop";
|
||||
discordPresence.largeImageText = "No peeking!";
|
||||
discordPresence.state = "Testing the game";
|
||||
|
||||
DRPC_EmptyRequests();
|
||||
Discord_UpdatePresence(&discordPresence);
|
||||
return;
|
||||
#endif // DEVELOP
|
||||
|
||||
// Server info
|
||||
if (netgame)
|
||||
{
|
||||
if (cv_advertise.value)
|
||||
{
|
||||
discordPresence.state = "Public";
|
||||
}
|
||||
else
|
||||
{
|
||||
discordPresence.state = "Private";
|
||||
}
|
||||
|
||||
discordPresence.partyId = server_context; // Thanks, whoever gave us Mumble support, for implementing the EXACT thing Discord wanted for this field!
|
||||
discordPresence.partySize = D_NumPlayers(); // Players in server
|
||||
discordPresence.partyMax = discordInfo.maxPlayers; // Max players
|
||||
|
||||
if (DRPC_InvitesAreAllowed() == true)
|
||||
{
|
||||
const char *join;
|
||||
|
||||
// Grab the host's IP for joining.
|
||||
if ((join = DRPC_GetServerIP()) != NULL)
|
||||
{
|
||||
char *xorjoin = DRPC_XORIPString(join);
|
||||
discordPresence.joinSecret = xorjoin;
|
||||
free(xorjoin);
|
||||
|
||||
joinSecretSet = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reset discord info if you're not in a place that uses it!
|
||||
// Important for if you join a server that compiled without HAVE_DISCORDRPC,
|
||||
// so that you don't ever end up using bad information from another server.
|
||||
memset(&discordInfo, 0, sizeof(discordInfo));
|
||||
|
||||
// Offline info
|
||||
if (Playing())
|
||||
discordPresence.state = "Offline";
|
||||
else if (demo.playback && !demo.title)
|
||||
discordPresence.state = "Watching Replay";
|
||||
else
|
||||
discordPresence.state = "Menu";
|
||||
}
|
||||
|
||||
// Gametype info
|
||||
if ((gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_VOTING) && Playing())
|
||||
{
|
||||
if (modeattacking)
|
||||
discordPresence.details = "Time Attack";
|
||||
else
|
||||
{
|
||||
snprintf(detailstr, 48, "%s%s%s",
|
||||
gametype_cons_t[gametype].strvalue,
|
||||
(gametype == GT_RACE) ? va(" | %s", kartspeed_cons_t[gamespeed].strvalue) : "",
|
||||
(encoremode == true) ? " | Encore" : ""
|
||||
);
|
||||
discordPresence.details = detailstr;
|
||||
}
|
||||
}
|
||||
|
||||
if ((gamestate == GS_LEVEL || gamestate == GS_INTERMISSION) // Map info
|
||||
&& !(demo.playback && demo.title))
|
||||
{
|
||||
if ((gamemap >= 1 && gamemap <= 60) // supported race maps
|
||||
|| (gamemap >= 136 && gamemap <= 164)) // supported battle maps
|
||||
{
|
||||
snprintf(mapimg, 8, "%s", G_BuildMapName(gamemap));
|
||||
strlwr(mapimg);
|
||||
discordPresence.largeImageKey = mapimg; // Map image
|
||||
}
|
||||
else if (mapheaderinfo[gamemap-1]->menuflags & LF2_HIDEINMENU)
|
||||
{
|
||||
// Hell map, use the method that got you here :P
|
||||
discordPresence.largeImageKey = "miscdice";
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is probably a custom map!
|
||||
discordPresence.largeImageKey = "mapcustom";
|
||||
}
|
||||
|
||||
if (mapheaderinfo[gamemap-1]->menuflags & LF2_HIDEINMENU)
|
||||
{
|
||||
// Hell map, hide the name
|
||||
discordPresence.largeImageText = "Map: ???";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Map name on tool tip
|
||||
snprintf(mapname, 48, "Map: %s", G_BuildMapTitle(gamemap));
|
||||
discordPresence.largeImageText = mapname;
|
||||
}
|
||||
|
||||
if (gamestate == GS_LEVEL && Playing())
|
||||
{
|
||||
const time_t currentTime = time(NULL);
|
||||
const time_t mapTimeStart = currentTime - ((leveltime + (modeattacking ? starttime : 0)) / TICRATE);
|
||||
|
||||
discordPresence.startTimestamp = mapTimeStart;
|
||||
|
||||
if (timelimitintics > 0)
|
||||
{
|
||||
const time_t mapTimeEnd = mapTimeStart + ((timelimitintics + starttime + 1) / TICRATE);
|
||||
discordPresence.endTimestamp = mapTimeEnd;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (gamestate == GS_VOTING)
|
||||
{
|
||||
discordPresence.largeImageKey = (G_BattleGametype() ? "miscredplanet" : "miscblueplanet");
|
||||
discordPresence.largeImageText = "Voting";
|
||||
}
|
||||
else
|
||||
{
|
||||
discordPresence.largeImageKey = "misctitle";
|
||||
discordPresence.largeImageText = "Title Screen";
|
||||
}
|
||||
|
||||
// Character info
|
||||
if (Playing() && playeringame[consoleplayer] && !players[consoleplayer].spectator)
|
||||
{
|
||||
// Supported skin names
|
||||
static const char *supportedSkins[] = {
|
||||
// base game
|
||||
"sonic",
|
||||
"tails",
|
||||
"knuckles",
|
||||
"eggman",
|
||||
"metalsonic",
|
||||
// bonus chars
|
||||
"flicky",
|
||||
"motobug",
|
||||
"amy",
|
||||
"mighty",
|
||||
"ray",
|
||||
"espio",
|
||||
"vector",
|
||||
"chao",
|
||||
"gamma",
|
||||
"chaos",
|
||||
"shadow",
|
||||
"rouge",
|
||||
"herochao",
|
||||
"darkchao",
|
||||
"cream",
|
||||
"omega",
|
||||
"blaze",
|
||||
"silver",
|
||||
"wonderboy",
|
||||
"arle",
|
||||
"nights",
|
||||
"sakura",
|
||||
"ulala",
|
||||
"beat",
|
||||
"vyse",
|
||||
"aiai",
|
||||
"kiryu",
|
||||
"aigis",
|
||||
"miku",
|
||||
"doom",
|
||||
NULL
|
||||
};
|
||||
|
||||
boolean customChar = true;
|
||||
UINT8 checkSkin = 0;
|
||||
|
||||
// Character image
|
||||
while (supportedSkins[checkSkin] != NULL)
|
||||
{
|
||||
if (!strcmp(skins[players[consoleplayer].skin].name, supportedSkins[checkSkin]))
|
||||
{
|
||||
snprintf(charimg, 21, "char%s", supportedSkins[checkSkin]);
|
||||
discordPresence.smallImageKey = charimg;
|
||||
customChar = false;
|
||||
break;
|
||||
}
|
||||
|
||||
checkSkin++;
|
||||
}
|
||||
|
||||
if (customChar == true)
|
||||
{
|
||||
// Use the custom character icon!
|
||||
discordPresence.smallImageKey = "charcustom";
|
||||
}
|
||||
|
||||
snprintf(charname, 28, "Character: %s", skins[players[consoleplayer].skin].realname);
|
||||
discordPresence.smallImageText = charname; // Character name
|
||||
}
|
||||
|
||||
if (joinSecretSet == false)
|
||||
{
|
||||
// Not able to join? Flush the request list, if it exists.
|
||||
DRPC_EmptyRequests();
|
||||
}
|
||||
|
||||
Discord_UpdatePresence(&discordPresence);
|
||||
}
|
||||
|
||||
#endif // HAVE_DISCORDRPC
|
||||
@@ -0,0 +1,80 @@
|
||||
// SONIC ROBO BLAST 2 KART
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2018-2020 by Sally "TehRealSalt" Cochenour.
|
||||
// Copyright (C) 2018-2020 by Kart Krew.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file discord.h
|
||||
/// \brief Discord Rich Presence handling
|
||||
|
||||
#ifndef __DISCORD__
|
||||
#define __DISCORD__
|
||||
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
|
||||
#include "discord_rpc.h"
|
||||
|
||||
extern consvar_t cv_discordrp;
|
||||
extern consvar_t cv_discordstreamer;
|
||||
extern consvar_t cv_discordasks;
|
||||
|
||||
extern struct discordInfo_s {
|
||||
UINT8 maxPlayers;
|
||||
boolean joinsAllowed;
|
||||
boolean everyoneCanInvite;
|
||||
} discordInfo;
|
||||
|
||||
typedef struct discordRequest_s {
|
||||
char *username; // Discord user name.
|
||||
char *discriminator; // Discord discriminator (The little hashtag thing after the username). Separated for a "hide discriminators" cvar.
|
||||
char *userID; // The ID of the Discord user, gets used with Discord_Respond()
|
||||
|
||||
// HAHAHA, no.
|
||||
// *Maybe* if it was only PNG I would boot up curl just to get AND convert this to Doom GFX,
|
||||
// but it can *also* be a JEPG, WebP, or GIF :)
|
||||
// Hey, wanna add ImageMagick as a dependency? :dying:
|
||||
//patch_t *avatar;
|
||||
|
||||
struct discordRequest_s *next; // Next request in the list.
|
||||
struct discordRequest_s *prev; // Previous request in the list. Not used normally, but just in case something funky happens, this should repair the list.
|
||||
} discordRequest_t;
|
||||
|
||||
extern discordRequest_t *discordRequestList;
|
||||
|
||||
|
||||
/*--------------------------------------------------
|
||||
void DRPC_RemoveRequest(void);
|
||||
|
||||
Removes an invite from the list.
|
||||
--------------------------------------------------*/
|
||||
|
||||
void DRPC_RemoveRequest(discordRequest_t *removeRequest);
|
||||
|
||||
|
||||
/*--------------------------------------------------
|
||||
void DRPC_Init(void);
|
||||
|
||||
Initalizes Discord Rich Presence by linking the Application ID
|
||||
and setting the callback functions.
|
||||
--------------------------------------------------*/
|
||||
|
||||
void DRPC_Init(void);
|
||||
|
||||
|
||||
/*--------------------------------------------------
|
||||
void DRPC_UpdatePresence(void);
|
||||
|
||||
Updates what is displayed by Rich Presence on the user's profile.
|
||||
Should be called whenever something that is displayed is
|
||||
changed in-game.
|
||||
--------------------------------------------------*/
|
||||
|
||||
void DRPC_UpdatePresence(void);
|
||||
|
||||
|
||||
#endif // HAVE_DISCORDRPC
|
||||
|
||||
#endif // __DISCORD__
|
||||
+24
-40
@@ -30,7 +30,6 @@
|
||||
#ifdef HAVE_MIXER
|
||||
//#if !defined(DC) && !defined(_WIN32_WCE) && !defined(_XBOX) && !defined(GP2X)
|
||||
#define SOUND SOUND_MIXER
|
||||
#define NOHS // No HW3SOUND
|
||||
#ifdef HW3SOUND
|
||||
#undef HW3SOUND
|
||||
#endif
|
||||
@@ -47,7 +46,6 @@
|
||||
// Use FMOD?
|
||||
#ifdef HAVE_FMOD
|
||||
#define SOUND SOUND_FMOD
|
||||
#define NOHS // No HW3SOUND
|
||||
#ifdef HW3SOUND
|
||||
#undef HW3SOUND
|
||||
#endif
|
||||
@@ -64,10 +62,6 @@
|
||||
#if !defined (HWRENDER) && !defined (NOHW)
|
||||
#define HWRENDER
|
||||
#endif
|
||||
// judgecutor: 3D sound support
|
||||
#if !defined(HW3SOUND) && !defined (NOHS)
|
||||
#define HW3SOUND
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (_WIN32) || defined (_WIN32_WCE)
|
||||
@@ -138,8 +132,12 @@
|
||||
|
||||
#ifdef LOGMESSAGES
|
||||
extern FILE *logstream;
|
||||
extern char logfilename[1024];
|
||||
#endif
|
||||
|
||||
/* A mod name to further distinguish versions. */
|
||||
#define SRB2APPLICATION "SRB2Kart"
|
||||
|
||||
//#define DEVELOP // Disable this for release builds to remove excessive cheat commands and enable MD5 checking and stuff, all in one go. :3
|
||||
#ifdef DEVELOP
|
||||
#define VERSION 0 // Game version
|
||||
@@ -149,10 +147,10 @@ extern FILE *logstream;
|
||||
// most interface strings are ignored in development mode.
|
||||
// we use comprevision and compbranch instead.
|
||||
#else
|
||||
#define VERSION 110 // Game version
|
||||
#define SUBVERSION 0 // more precise version number
|
||||
#define VERSIONSTRING "v1.1"
|
||||
#define VERSIONSTRINGW L"v1.1"
|
||||
#define VERSION 1 // Game version
|
||||
#define SUBVERSION 3 // more precise version number
|
||||
#define VERSIONSTRING "v1.3"
|
||||
#define VERSIONSTRINGW L"v1.3"
|
||||
// Hey! If you change this, add 1 to the MODVERSION below! Otherwise we can't force updates!
|
||||
// And change CMakeLists.txt, for CMake users!
|
||||
// AND appveyor.yml, for the build bots!
|
||||
@@ -183,32 +181,13 @@ extern FILE *logstream;
|
||||
// Please change to apply to your modification (we don't want everyone asking where your mod is on SRB2.org!).
|
||||
#define UPDATE_ALERT_STRING \
|
||||
"A new update is available for SRB2Kart.\n"\
|
||||
"Please visit mb.srb2.org to download it.\n"\
|
||||
"Please visit kartkrew.org to download it.\n"\
|
||||
"\n"\
|
||||
"You are using version: %s\n"\
|
||||
"The newest version is: %s\n"\
|
||||
"\n"\
|
||||
"This update is required for online\n"\
|
||||
"play using the Master Server.\n"\
|
||||
"You will not be able to connect to\n"\
|
||||
"the Master Server until you update to\n"\
|
||||
"the newest version of the game.\n"\
|
||||
"\n"\
|
||||
"(Press a key)\n"
|
||||
|
||||
// The string used in the I_Error alert upon trying to host through command line parameters.
|
||||
// Generally less filled with newlines, since Windows gives you lots more room to work with.
|
||||
#define UPDATE_ALERT_STRING_CONSOLE \
|
||||
"A new update is available for SRB2Kart.\n"\
|
||||
"Please visit mb.srb2.org to download it.\n"\
|
||||
"\n"\
|
||||
"You are using version: %s\n"\
|
||||
"The newest version is: %s\n"\
|
||||
"\n"\
|
||||
"This update is required for online play using the Master Server.\n"\
|
||||
"You will not be able to connect to the Master Server\n"\
|
||||
"until you update to the newest version of the game.\n"
|
||||
|
||||
// For future use, the codebase is the version of SRB2 that the modification is based on,
|
||||
// and should not be changed unless you have merged changes between versions of SRB2
|
||||
// (such as 2.0.4 to 2.0.5, etc) into your working copy.
|
||||
@@ -225,7 +204,7 @@ extern FILE *logstream;
|
||||
// it's only for detection of the version the player is using so the MS can alert them of an update.
|
||||
// Only set it higher, not lower, obviously.
|
||||
// Note that we use this to help keep internal testing in check; this is why v2.1.0 is not version "1".
|
||||
#define MODVERSION 5
|
||||
#define MODVERSION 7
|
||||
|
||||
// Filter consvars by version
|
||||
// To version config.cfg, MAJOREXECVERSION is set equal to MODVERSION automatically.
|
||||
@@ -502,7 +481,7 @@ void CONS_Debug(INT32 debugflags, const char *fmt, ...) FUNCDEBUG;
|
||||
|
||||
// Things that used to be in dstrings.h
|
||||
#define SAVEGAMENAME "srb2sav"
|
||||
char savegamename[256];
|
||||
extern char savegamename[256];
|
||||
|
||||
// m_misc.h
|
||||
#ifdef GETTEXT
|
||||
@@ -548,6 +527,9 @@ extern INT32 cv_debug;
|
||||
extern UINT8 shiftdown, ctrldown, altdown;
|
||||
extern boolean capslock;
|
||||
|
||||
// WARNING: a should be unsigned but to add with 2048, it isn't!
|
||||
#define AIMINGTODY(a) (FINETANGENT((2048+(((INT32)a)>>ANGLETOFINESHIFT)) & FINEMASK)*160)
|
||||
|
||||
// if we ever make our alloc stuff...
|
||||
#define ZZ_Alloc(x) Z_Malloc(x, PU_STATIC, NULL)
|
||||
|
||||
@@ -599,11 +581,9 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
|
||||
/// Kalaron/Eternity Engine slope code (SRB2CB ported)
|
||||
#define ESLOPE
|
||||
|
||||
#ifdef ESLOPE
|
||||
/// Backwards compatibility with SRB2CB's slope linedef types.
|
||||
/// \note A simple shim that prints a warning.
|
||||
#define ESLOPE_TYPESHIM
|
||||
#endif
|
||||
|
||||
/// Delete file while the game is running.
|
||||
/// \note EXTREMELY buggy, tends to crash game.
|
||||
@@ -633,11 +613,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
|
||||
/// Most modifications should probably enable this.
|
||||
//#define SAVEGAME_OTHERVERSIONS
|
||||
|
||||
#if !defined (_NDS) && !defined (_PSP)
|
||||
/// Shuffle's incomplete OpenGL sorting code.
|
||||
#define SHUFFLE // This has nothing to do with sorting, why was it disabled?
|
||||
#endif
|
||||
|
||||
#if !defined (_NDS) && !defined (_PSP)
|
||||
/// Allow the use of the SOC RESETINFO command.
|
||||
/// \note Builds that are tight on memory should disable this.
|
||||
@@ -674,6 +649,15 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
|
||||
/// on the bright side it fixes some weird issues with translucent walls
|
||||
/// \note SRB2CB port.
|
||||
/// SRB2CB itself ported this from PrBoom+
|
||||
#define NEWCLIP
|
||||
//#define NEWCLIP
|
||||
|
||||
/// Hardware renderer: OpenGL
|
||||
#define GL_SHADERS
|
||||
|
||||
#if defined (HAVE_CURL) && ! defined (NONET)
|
||||
#define MASTERSERVER
|
||||
#else
|
||||
#undef UPDATE_ALERT
|
||||
#endif
|
||||
|
||||
#endif // __DOOMDEF__
|
||||
+2
-2
@@ -448,7 +448,7 @@ extern UINT8 maxXtraLife; // Max extra lives from rings
|
||||
extern mobj_t *hunt1, *hunt2, *hunt3; // Emerald hunt locations
|
||||
|
||||
// For racing
|
||||
extern UINT32 countdown, countdown2;
|
||||
extern tic_t racecountdown, exitcountdown;
|
||||
|
||||
extern fixed_t gravity;
|
||||
extern fixed_t mapobjectscale;
|
||||
@@ -549,7 +549,7 @@ extern consvar_t cv_downloading; // allow clients to downloading WADs.
|
||||
extern consvar_t cv_nettimeout; // SRB2Kart: Advanced server options menu
|
||||
extern consvar_t cv_jointimeout;
|
||||
extern consvar_t cv_maxping;
|
||||
extern ticcmd_t netcmds[BACKUPTICS][MAXPLAYERS];
|
||||
extern ticcmd_t netcmds[TICQUEUE][MAXPLAYERS];
|
||||
extern INT32 serverplayer;
|
||||
extern INT32 adminplayers[MAXPLAYERS];
|
||||
|
||||
|
||||
+12
-3
@@ -24,6 +24,7 @@
|
||||
#include "w_wad.h"
|
||||
#include "z_zone.h"
|
||||
#include "i_system.h"
|
||||
#include "i_threads.h"
|
||||
#include "m_menu.h"
|
||||
#include "dehacked.h"
|
||||
#include "g_input.h"
|
||||
@@ -317,7 +318,13 @@ void F_IntroDrawer(void)
|
||||
{
|
||||
I_OsPolling();
|
||||
I_UpdateNoBlit();
|
||||
#ifdef HAVE_THREADS
|
||||
I_lock_mutex(&m_menu_mutex);
|
||||
#endif
|
||||
M_Drawer(); // menu is drawn even on top of wipes
|
||||
#ifdef HAVE_THREADS
|
||||
I_unlock_mutex(m_menu_mutex);
|
||||
#endif
|
||||
I_FinishUpdate(); // Update the screen with the image Tails 06-19-2001
|
||||
}
|
||||
}
|
||||
@@ -442,6 +449,7 @@ static const char *credits[] = {
|
||||
"\"Lat\'\"",
|
||||
"\"Monster Iestyn\"",
|
||||
"\"Shuffle\"",
|
||||
"\"SteelT\"",
|
||||
"",
|
||||
"\1Lead Artists",
|
||||
"Desmond \"Blade\" DesJardins",
|
||||
@@ -466,17 +474,17 @@ static const char *credits[] = {
|
||||
"\"DirkTheHusky\"",
|
||||
"\"LJSTAR\"",
|
||||
"\"MotorRoach\"",
|
||||
"\"Mr. McScrewup\"",
|
||||
"\"Nev3r\"",
|
||||
"\"rairai104n\"",
|
||||
"\"Ritz\"",
|
||||
"\"Rob\"",
|
||||
"\"SmithyGNC\"",
|
||||
"\"Snu\"",
|
||||
"\"Spherallic\"",
|
||||
"\"TelosTurntable\"",
|
||||
"\"VAdaPEGA\"",
|
||||
"\"Virt\"",
|
||||
"\"Voltrix\"",
|
||||
"\"zxyspku\"",
|
||||
"",
|
||||
"\1Sound Design",
|
||||
"James \"SeventhSentinel\" Hall",
|
||||
@@ -504,6 +512,7 @@ static const char *credits[] = {
|
||||
"Sherman \"CoatRack\" DesJardins",
|
||||
"Colette \"fickleheart\" Bordelon",
|
||||
"Vivian \"toaster\" Grannell",
|
||||
"\"Gunla\"",
|
||||
"James \"SeventhSentinel\" Hall",
|
||||
"\"Lat\'\"",
|
||||
"\"MK\"",
|
||||
@@ -566,7 +575,7 @@ static struct {
|
||||
// This Tyler52 gag is troublesome
|
||||
// Alignment should be ((spaces+1 * 100) + (headers+1 * 38) + (lines * 15))
|
||||
// Current max image spacing: (200*17)
|
||||
{112, (15*100)+(17*38)+(86*15), "TYLER52", SKINCOLOR_NONE},
|
||||
{112, (15*100)+(17*38)+(88*15), "TYLER52", SKINCOLOR_NONE},
|
||||
{0, 0, NULL, SKINCOLOR_NONE}
|
||||
};
|
||||
|
||||
|
||||
+12
-1
@@ -22,6 +22,7 @@
|
||||
#include "z_zone.h"
|
||||
|
||||
#include "i_system.h"
|
||||
#include "i_threads.h"
|
||||
#include "m_menu.h"
|
||||
#include "console.h"
|
||||
#include "d_main.h"
|
||||
@@ -372,12 +373,22 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu)
|
||||
HWR_DoWipe(wipetype, wipeframe-1); // send in the wipe type and wipeframe because we need to cache the graphic
|
||||
else
|
||||
#endif
|
||||
F_DoWipe(fmask);
|
||||
if (rendermode != render_none) //this allows F_RunWipe to be called in dedicated servers
|
||||
F_DoWipe(fmask);
|
||||
|
||||
I_OsPolling();
|
||||
I_UpdateNoBlit();
|
||||
|
||||
if (drawMenu)
|
||||
{
|
||||
#ifdef HAVE_THREADS
|
||||
I_lock_mutex(&m_menu_mutex);
|
||||
#endif
|
||||
M_Drawer(); // menu is drawn even on top of wipes
|
||||
#ifdef HAVE_THREADS
|
||||
I_unlock_mutex(m_menu_mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
I_FinishUpdate(); // page flip or blit buffer
|
||||
|
||||
|
||||
+141
-32
@@ -43,12 +43,18 @@
|
||||
#include "y_inter.h"
|
||||
#include "v_video.h"
|
||||
#include "dehacked.h" // get_number (for ghost thok)
|
||||
#include "lua_script.h" // LUA_ArchiveDemo and LUA_UnArchiveDemo
|
||||
#include "lua_hook.h"
|
||||
#include "lua_libs.h" // gL (Lua state)
|
||||
#include "b_bot.h"
|
||||
#include "m_cond.h" // condition sets
|
||||
#include "md5.h" // demo checksums
|
||||
#include "k_kart.h" // SRB2kart
|
||||
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
#include "discord.h"
|
||||
#endif
|
||||
|
||||
gameaction_t gameaction;
|
||||
gamestate_t gamestate = GS_NULL;
|
||||
UINT8 ultimatemode = false;
|
||||
@@ -233,7 +239,7 @@ mobj_t *hunt1;
|
||||
mobj_t *hunt2;
|
||||
mobj_t *hunt3;
|
||||
|
||||
UINT32 countdown, countdown2; // for racing
|
||||
tic_t racecountdown, exitcountdown; // for racing
|
||||
|
||||
fixed_t gravity;
|
||||
fixed_t mapobjectscale;
|
||||
@@ -287,7 +293,8 @@ UINT32 timesBeatenWithEmeralds;
|
||||
//@TODO put these all in a struct for namespacing purposes?
|
||||
static char demoname[128];
|
||||
static UINT8 *demobuffer = NULL;
|
||||
static UINT8 *demo_p, *demotime_p, *demoinfo_p;
|
||||
static UINT8 *demotime_p, *demoinfo_p;
|
||||
UINT8 *demo_p;
|
||||
static UINT8 *demoend;
|
||||
static UINT8 demoflags;
|
||||
static boolean demosynced = true; // console warning message
|
||||
@@ -544,6 +551,8 @@ char player_names[MAXPLAYERS][MAXPLAYERNAME+1] =
|
||||
"Player 16"
|
||||
}; // SRB2kart - removed Players 17 through 32
|
||||
|
||||
INT32 player_name_changes[MAXPLAYERS];
|
||||
|
||||
INT16 rw_maximums[NUM_WEAPONS] =
|
||||
{
|
||||
800, // MAX_INFINITY
|
||||
@@ -785,7 +794,7 @@ void G_SetGameModified(boolean silent, boolean major)
|
||||
majormods = true;
|
||||
|
||||
if (!silent)
|
||||
CONS_Alert(CONS_NOTICE, M_GetText("Game must be restarted to play record attack.\n"));
|
||||
CONS_Alert(CONS_NOTICE, M_GetText("Game must be restarted to play Record Attack.\n"));
|
||||
|
||||
// If in record attack recording, cancel it.
|
||||
if (modeattacking)
|
||||
@@ -1887,7 +1896,7 @@ boolean G_Responder(event_t *ev)
|
||||
}
|
||||
}
|
||||
|
||||
if (gamestate == GS_LEVEL && ev->type == ev_keydown && multiplayer && demo.playback)
|
||||
if (gamestate == GS_LEVEL && ev->type == ev_keydown && multiplayer && demo.playback && !demo.freecam)
|
||||
{
|
||||
if (ev->data1 == gamecontrolbis[gc_viewpoint][0] || ev->data1 == gamecontrolbis[gc_viewpoint][1])
|
||||
{
|
||||
@@ -1931,11 +1940,8 @@ boolean G_Responder(event_t *ev)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Anything else opens the menu if not already open, except for a few keys...
|
||||
if (!(
|
||||
// Rankings
|
||||
ev->data1 == gamecontrol[gc_scores][0] || ev->data1 == gamecontrol[gc_scores][1]
|
||||
))
|
||||
// open menu but only w/ esc
|
||||
if (ev->data1 == 32)
|
||||
{
|
||||
M_StartControlPanel();
|
||||
|
||||
@@ -2323,6 +2329,12 @@ void G_Ticker(boolean run)
|
||||
UINT32 i;
|
||||
INT32 buf;
|
||||
ticcmd_t *cmd;
|
||||
UINT32 ra_timeskip = (modeattacking && !demo.playback && leveltime < starttime - TICRATE*4) ? 0 : (starttime - TICRATE*4 - 1);
|
||||
// starttime - TICRATE*4 is where we want RA to start when we PLAY IT, so we will loop the main thinker on RA start to get it to this point,
|
||||
// the reason this is done is to ensure that ghosts won't look out of synch with other map elements (objects, moving platforms...)
|
||||
// when we REPLAY, don't skip, let the camera spin, do its thing etc~
|
||||
|
||||
// also the -1 is to ensure that the thinker runs in the loop below.
|
||||
|
||||
P_MapStart();
|
||||
// do player reborns if needed
|
||||
@@ -2361,7 +2373,7 @@ void G_Ticker(boolean run)
|
||||
default: I_Error("gameaction = %d\n", gameaction);
|
||||
}
|
||||
|
||||
buf = gametic % BACKUPTICS;
|
||||
buf = gametic % TICQUEUE;
|
||||
|
||||
if (!demo.playback)
|
||||
// read/write demo and check turbo cheat
|
||||
@@ -2395,12 +2407,16 @@ void G_Ticker(boolean run)
|
||||
switch (gamestate)
|
||||
{
|
||||
case GS_LEVEL:
|
||||
if (demo.title)
|
||||
F_TitleDemoTicker();
|
||||
P_Ticker(run); // tic the game
|
||||
ST_Ticker();
|
||||
AM_Ticker();
|
||||
HU_Ticker();
|
||||
|
||||
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)
|
||||
F_TitleDemoTicker();
|
||||
P_Ticker(run); // tic the game
|
||||
ST_Ticker();
|
||||
AM_Ticker();
|
||||
HU_Ticker();
|
||||
}
|
||||
break;
|
||||
|
||||
case GS_INTERMISSION:
|
||||
@@ -2491,6 +2507,11 @@ void G_Ticker(boolean run)
|
||||
spectatedelay3--;
|
||||
if (spectatedelay4)
|
||||
spectatedelay4--;
|
||||
|
||||
if (gametic % NAMECHANGERATE == 0)
|
||||
{
|
||||
memset(player_name_changes, 0, sizeof player_name_changes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3640,7 +3661,7 @@ tryagain:
|
||||
|
||||
void G_AddMapToBuffer(INT16 map)
|
||||
{
|
||||
INT16 bufx, refreshnum = (TOLMaps(G_TOLFlag(gametype)) / 2) + 1;
|
||||
INT16 bufx, refreshnum = max(0, TOLMaps(G_TOLFlag(gametype))-3);
|
||||
|
||||
// Add the map to the buffer.
|
||||
for (bufx = NUMMAPS-1; bufx > 0; bufx--)
|
||||
@@ -4586,7 +4607,7 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool
|
||||
{
|
||||
// Clear a bunch of variables
|
||||
tokenlist = token = sstimer = redscore = bluescore = lastmap = 0;
|
||||
countdown = countdown2 = mapreset = 0;
|
||||
racecountdown = exitcountdown = mapreset = 0;
|
||||
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
@@ -4710,7 +4731,7 @@ char *G_BuildMapTitle(INT32 mapnum)
|
||||
}
|
||||
else if (!(mapheaderinfo[mapnum-1]->levelflags & LF_NOZONE))
|
||||
{
|
||||
zonetext = M_GetText("ZONE");
|
||||
zonetext = M_GetText("Zone");
|
||||
len += strlen(zonetext) + 1; // ' ' + zonetext
|
||||
}
|
||||
if (strlen(mapheaderinfo[mapnum-1]->actnum) > 0)
|
||||
@@ -4740,6 +4761,11 @@ char *G_BuildMapTitle(INT32 mapnum)
|
||||
#define DF_RECORDATTACK 0x02 // This demo is from record attack and contains its final completion time!
|
||||
#define DF_NIGHTSATTACK 0x04 // This demo is from NiGHTS attack and contains its time left, score, and mares!
|
||||
#define DF_ATTACKMASK 0x06 // This demo is from ??? attack and contains ???
|
||||
|
||||
#ifdef HAVE_BLUA
|
||||
#define DF_LUAVARS 0x20 // this demo contains extra lua vars; this is mostly used for backwards compability
|
||||
#endif
|
||||
|
||||
#define DF_ATTACKSHIFT 1
|
||||
#define DF_ENCORE 0x40
|
||||
#define DF_MULTIPLAYER 0x80 // This demo was recorded in multiplayer mode!
|
||||
@@ -4866,6 +4892,16 @@ void G_ReadDemoExtraData(void)
|
||||
INT32 p, extradata, i;
|
||||
char name[17];
|
||||
|
||||
if (leveltime > starttime)
|
||||
{
|
||||
rewind_t *rewind = CL_SaveRewindPoint(demo_p - demobuffer);
|
||||
if (rewind)
|
||||
{
|
||||
memcpy(rewind->oldcmd, oldcmd, sizeof (oldcmd));
|
||||
memcpy(rewind->oldghost, oldghost, sizeof (oldghost));
|
||||
}
|
||||
}
|
||||
|
||||
memset(name, '\0', 17);
|
||||
|
||||
p = READUINT8(demo_p);
|
||||
@@ -5904,6 +5940,8 @@ static rewindinfo_t *rewindhead = NULL; // Reverse chronological order
|
||||
|
||||
void G_InitDemoRewind(void)
|
||||
{
|
||||
CL_ClearRewinds();
|
||||
|
||||
while (rewindhead)
|
||||
{
|
||||
rewindinfo_t *p = rewindhead->prev;
|
||||
@@ -6025,19 +6063,35 @@ void G_ConfirmRewind(tic_t rewindtime)
|
||||
|
||||
CV_StealthSetValue(&cv_renderview, 0);
|
||||
|
||||
if (rewindtime > starttime)
|
||||
if (rewindtime <= starttime)
|
||||
{
|
||||
sound_disabled = true; // Prevent sound spam
|
||||
demo.rewinding = true;
|
||||
demo.rewinding = false;
|
||||
G_DoPlayDemo(NULL); // Restart the current demo
|
||||
}
|
||||
else
|
||||
demo.rewinding = false;
|
||||
{
|
||||
rewind_t *rewind;
|
||||
sound_disabled = true; // Prevent sound spam
|
||||
demo.rewinding = true;
|
||||
|
||||
G_DoPlayDemo(NULL); // Restart the current demo
|
||||
rewind = CL_RewindToTime(rewindtime);
|
||||
|
||||
if (rewind)
|
||||
{
|
||||
demo_p = demobuffer + rewind->demopos;
|
||||
memcpy(oldcmd, rewind->oldcmd, sizeof (oldcmd));
|
||||
memcpy(oldghost, rewind->oldghost, sizeof (oldghost));
|
||||
paused = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
demo.rewinding = true;
|
||||
G_DoPlayDemo(NULL); // Restart the current demo
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < rewindtime && leveltime < rewindtime; j++)
|
||||
{
|
||||
//TryRunTics(1);
|
||||
G_Ticker((j % NEWTICRATERATIO) == 0);
|
||||
}
|
||||
|
||||
@@ -6049,6 +6103,9 @@ void G_ConfirmRewind(tic_t rewindtime)
|
||||
|
||||
COM_BufInsertText("renderview on\n");
|
||||
|
||||
if (demo.freecam)
|
||||
return; // don't touch from there
|
||||
|
||||
splitscreen = oldss;
|
||||
displayplayers[0] = olddp1;
|
||||
displayplayers[1] = olddp2;
|
||||
@@ -6283,8 +6340,8 @@ void G_RecordDemo(const char *name)
|
||||
maxsize = 1024*1024*2;
|
||||
if (M_CheckParm("-maxdemo") && M_IsNextParm())
|
||||
maxsize = atoi(M_GetNextParm()) * 1024;
|
||||
// if (demobuffer)
|
||||
// free(demobuffer);
|
||||
if (demobuffer)
|
||||
free(demobuffer);
|
||||
demo_p = NULL;
|
||||
demobuffer = malloc(maxsize);
|
||||
demoend = demobuffer + maxsize;
|
||||
@@ -6324,6 +6381,12 @@ void G_BeginRecording(void)
|
||||
if (encoremode)
|
||||
demoflags |= DF_ENCORE;
|
||||
|
||||
#ifdef HAVE_BLUA
|
||||
if (!modeattacking) // Ghosts don't read luavars, and you shouldn't ever need to save Lua in replays, you doof!
|
||||
// SERIOUSLY THOUGH WHY WOULD YOU LOAD HOSTMOD AND RECORD A GHOST WITH IT !????
|
||||
demoflags |= DF_LUAVARS;
|
||||
#endif
|
||||
|
||||
// Setup header.
|
||||
M_Memcpy(demo_p, DEMOHEADER, 12); demo_p += 12;
|
||||
WRITEUINT8(demo_p,VERSION);
|
||||
@@ -6332,7 +6395,7 @@ void G_BeginRecording(void)
|
||||
|
||||
// Full replay title
|
||||
demo_p += 64;
|
||||
snprintf(demo.titlename, 64, "%s - %s", G_BuildMapTitle(gamemap), modeattacking ? "Record Attack" : connectedservername);
|
||||
snprintf(demo.titlename, 64, "%s - %s", G_BuildMapTitle(gamemap), modeattacking ? "Time Attack" : connectedservername);
|
||||
|
||||
// demo checksum
|
||||
demo_p += 16;
|
||||
@@ -6420,11 +6483,18 @@ void G_BeginRecording(void)
|
||||
// Kart speed and weight
|
||||
WRITEUINT8(demo_p, skins[player->skin].kartspeed);
|
||||
WRITEUINT8(demo_p, skins[player->skin].kartweight);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
WRITEUINT8(demo_p, 0xFF); // Denote the end of the player listing
|
||||
|
||||
#ifdef HAVE_BLUA
|
||||
// player lua vars, always saved even if empty... Unless it's record attack.
|
||||
if (!modeattacking)
|
||||
LUA_ArchiveDemo();
|
||||
#endif
|
||||
|
||||
memset(&oldcmd,0,sizeof(oldcmd));
|
||||
memset(&oldghost,0,sizeof(oldghost));
|
||||
memset(&ghostext,0,sizeof(ghostext));
|
||||
@@ -6576,7 +6646,7 @@ static void G_LoadDemoExtraFiles(UINT8 **pp)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Too many files loaded to add anymore for demo playback\n"));
|
||||
if (!CON_Ready())
|
||||
M_StartMessage(M_GetText("There are too many files loaded to add this demo's add-ons.\n\nDemo playback may desync.\n\nPress ESC\n"), NULL, MM_NOTHING);
|
||||
M_StartMessage(M_GetText("There are too many files loaded to add this demo's addons.\n\nDemo playback may desync.\n\nPress ESC\n"), NULL, MM_NOTHING);
|
||||
}
|
||||
else if (ncs != FS_FOUND)
|
||||
{
|
||||
@@ -6588,7 +6658,7 @@ static void G_LoadDemoExtraFiles(UINT8 **pp)
|
||||
CONS_Alert(CONS_NOTICE, M_GetText("Unknown error finding file %s\n"), filename);
|
||||
|
||||
if (!CON_Ready())
|
||||
M_StartMessage(M_GetText("There were errors trying to add this demo's add-ons. Check the console for more information.\n\nDemo playback may desync.\n\nPress ESC\n"), NULL, MM_NOTHING);
|
||||
M_StartMessage(M_GetText("There were errors trying to add this demo's addons. Check the console for more information.\n\nDemo playback may desync.\n\nPress ESC\n"), NULL, MM_NOTHING);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -7100,6 +7170,7 @@ void G_DoPlayDemo(char *defdemoname)
|
||||
M_StartMessage(msg, NULL, MM_NOTHING);
|
||||
Z_Free(pdemoname);
|
||||
Z_Free(demobuffer);
|
||||
demobuffer = NULL;
|
||||
demo.playback = false;
|
||||
demo.title = false;
|
||||
return;
|
||||
@@ -7128,6 +7199,7 @@ void G_DoPlayDemo(char *defdemoname)
|
||||
M_StartMessage(msg, NULL, MM_NOTHING);
|
||||
Z_Free(pdemoname);
|
||||
Z_Free(demobuffer);
|
||||
demobuffer = NULL;
|
||||
demo.playback = false;
|
||||
demo.title = false;
|
||||
return;
|
||||
@@ -7140,6 +7212,7 @@ void G_DoPlayDemo(char *defdemoname)
|
||||
M_StartMessage(msg, NULL, MM_NOTHING);
|
||||
Z_Free(pdemoname);
|
||||
Z_Free(demobuffer);
|
||||
demobuffer = NULL;
|
||||
demo.playback = false;
|
||||
demo.title = false;
|
||||
return;
|
||||
@@ -7159,6 +7232,7 @@ void G_DoPlayDemo(char *defdemoname)
|
||||
M_StartMessage(msg, NULL, MM_NOTHING);
|
||||
Z_Free(pdemoname);
|
||||
Z_Free(demobuffer);
|
||||
demobuffer = NULL;
|
||||
demo.playback = false;
|
||||
demo.title = false;
|
||||
return;
|
||||
@@ -7219,6 +7293,7 @@ void G_DoPlayDemo(char *defdemoname)
|
||||
M_StartMessage(msg, NULL, MM_NOTHING);
|
||||
Z_Free(pdemoname);
|
||||
Z_Free(demobuffer);
|
||||
demobuffer = NULL;
|
||||
demo.playback = false;
|
||||
demo.title = false;
|
||||
return;
|
||||
@@ -7289,6 +7364,7 @@ void G_DoPlayDemo(char *defdemoname)
|
||||
M_StartMessage(msg, NULL, MM_NOTHING);
|
||||
Z_Free(pdemoname);
|
||||
Z_Free(demobuffer);
|
||||
demobuffer = NULL;
|
||||
demo.playback = false;
|
||||
demo.title = false;
|
||||
return;
|
||||
@@ -7302,6 +7378,7 @@ void G_DoPlayDemo(char *defdemoname)
|
||||
M_StartMessage(msg, NULL, MM_NOTHING);
|
||||
Z_Free(pdemoname);
|
||||
Z_Free(demobuffer);
|
||||
demobuffer = NULL;
|
||||
demo.playback = false;
|
||||
demo.title = false;
|
||||
return;
|
||||
@@ -7326,6 +7403,7 @@ void G_DoPlayDemo(char *defdemoname)
|
||||
M_StartMessage(msg, NULL, MM_NOTHING);
|
||||
Z_Free(pdemoname);
|
||||
Z_Free(demobuffer);
|
||||
demobuffer = NULL;
|
||||
demo.playback = false;
|
||||
demo.title = false;
|
||||
return;
|
||||
@@ -7369,6 +7447,7 @@ void G_DoPlayDemo(char *defdemoname)
|
||||
M_StartMessage(msg, NULL, MM_NOTHING);
|
||||
Z_Free(pdemoname);
|
||||
Z_Free(demobuffer);
|
||||
demobuffer = NULL;
|
||||
demo.playback = false;
|
||||
demo.title = false;
|
||||
return;
|
||||
@@ -7419,11 +7498,12 @@ void G_DoPlayDemo(char *defdemoname)
|
||||
|
||||
if (modeattacking)
|
||||
{
|
||||
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);
|
||||
M_StartMessage(msg, NULL, MM_NOTHING);
|
||||
Z_Free(pdemoname);
|
||||
Z_Free(demobuffer);
|
||||
demobuffer = NULL;
|
||||
demo.playback = false;
|
||||
demo.title = false;
|
||||
return;
|
||||
@@ -7433,11 +7513,12 @@ void G_DoPlayDemo(char *defdemoname)
|
||||
|
||||
if (modeattacking && numslots > 1)
|
||||
{
|
||||
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);
|
||||
M_StartMessage(msg, NULL, MM_NOTHING);
|
||||
Z_Free(pdemoname);
|
||||
Z_Free(demobuffer);
|
||||
demobuffer = NULL;
|
||||
demo.playback = false;
|
||||
demo.title = false;
|
||||
return;
|
||||
@@ -7482,6 +7563,19 @@ void G_DoPlayDemo(char *defdemoname)
|
||||
p = READUINT8(demo_p);
|
||||
}
|
||||
|
||||
// end of player read (the 0xFF marker)
|
||||
// so this is where we are to read our lua variables (if possible!)
|
||||
#ifdef HAVE_BLUA
|
||||
if (demoflags & DF_LUAVARS) // again, used for compability, lua shit will be saved to replays regardless of if it's even been loaded
|
||||
{
|
||||
if (!gL) // No Lua state! ...I guess we'll just start one...
|
||||
LUA_ClearState();
|
||||
|
||||
// No modeattacking check, DF_LUAVARS won't be present here.
|
||||
LUA_UnArchiveDemo();
|
||||
}
|
||||
#endif
|
||||
|
||||
splitscreen = 0;
|
||||
|
||||
if (demo.title)
|
||||
@@ -8075,6 +8169,7 @@ ATTRNORETURN void FUNCNORETURN G_StopMetalRecording(void)
|
||||
saved = FIL_WriteFile(va("%sMS.LMP", G_BuildMapName(gamemap)), demobuffer, demo_p - demobuffer); // finally output the file.
|
||||
}
|
||||
free(demobuffer);
|
||||
demobuffer = NULL;
|
||||
metalrecording = false;
|
||||
if (saved)
|
||||
I_Error("Saved to %sMS.LMP", G_BuildMapName(gamemap));
|
||||
@@ -8094,8 +8189,18 @@ void G_StopDemo(void)
|
||||
demo.timing = false;
|
||||
singletics = false;
|
||||
|
||||
demo.freecam = false;
|
||||
// reset democam shit too:
|
||||
democam.cam = NULL;
|
||||
democam.soundmobj = NULL;
|
||||
democam.localangle = 0;
|
||||
democam.localaiming = 0;
|
||||
democam.turnheld = false;
|
||||
democam.keyboardlook = false;
|
||||
|
||||
CV_SetValue(&cv_playbackspeed, 1);
|
||||
demo.rewinding = false;
|
||||
CL_ClearRewinds();
|
||||
|
||||
if (gamestate == GS_LEVEL && rendermode != render_none)
|
||||
{
|
||||
@@ -8245,6 +8350,7 @@ void G_SaveDemo(void)
|
||||
if (FIL_WriteFile(va(pandf, srb2home, demoname), demobuffer, demo_p - demobuffer)) // finally output the file.
|
||||
demo.savemode = DSM_SAVED;
|
||||
free(demobuffer);
|
||||
demobuffer = NULL;
|
||||
demo.recording = false;
|
||||
|
||||
if (modeattacking != ATTACKING_RECORD)
|
||||
@@ -8313,6 +8419,9 @@ boolean G_DemoTitleResponder(event_t *ev)
|
||||
void G_SetGamestate(gamestate_t newstate)
|
||||
{
|
||||
gamestate = newstate;
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
DRPC_UpdatePresence();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* These functions handle the exitgame flag. Before, when the user
|
||||
|
||||
+7
-1
@@ -26,11 +26,14 @@ extern char customversionstring[32];
|
||||
#ifdef SEENAMES
|
||||
extern player_t *seenplayer;
|
||||
#endif
|
||||
extern char player_names[MAXPLAYERS][MAXPLAYERNAME+1];
|
||||
extern char player_names[MAXPLAYERS][MAXPLAYERNAME+1];
|
||||
extern INT32 player_name_changes[MAXPLAYERS];
|
||||
|
||||
extern player_t players[MAXPLAYERS];
|
||||
extern boolean playeringame[MAXPLAYERS];
|
||||
|
||||
extern UINT8 *demo_p;
|
||||
|
||||
// ======================================
|
||||
// DEMO playback/recording related stuff.
|
||||
// ======================================
|
||||
@@ -60,6 +63,9 @@ struct demovars_s {
|
||||
DSM_WILLSAVE,
|
||||
DSM_SAVED
|
||||
} savemode;
|
||||
|
||||
boolean freecam;
|
||||
|
||||
};
|
||||
|
||||
extern struct demovars_s demo;
|
||||
|
||||
+9
-99
@@ -1,17 +1,12 @@
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2019 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file
|
||||
/// \brief convert SRB2 map
|
||||
@@ -19,6 +14,7 @@
|
||||
#include "../doomdef.h"
|
||||
#include "../doomstat.h"
|
||||
#ifdef HWRENDER
|
||||
#include "hw_main.h"
|
||||
#include "hw_glob.h"
|
||||
#include "../r_local.h"
|
||||
#include "../z_zone.h"
|
||||
@@ -60,77 +56,12 @@ static INT32 totalsubsecpolys = 0;
|
||||
// --------------------------------------------------------------------------
|
||||
// Polygon fast alloc / free
|
||||
// --------------------------------------------------------------------------
|
||||
//hurdler: quick fix for those who wants to play with larger wad
|
||||
|
||||
#define ZPLANALLOC
|
||||
#ifndef ZPLANALLOC
|
||||
//#define POLYPOOLSIZE 1024000 // may be much over what is needed
|
||||
/// \todo check out how much is used
|
||||
static size_t POLYPOOLSIZE = 1024000;
|
||||
|
||||
static UINT8 *gr_polypool = NULL;
|
||||
static UINT8 *gr_ppcurrent;
|
||||
static size_t gr_ppfree;
|
||||
#endif
|
||||
|
||||
// only between levels, clear poly pool
|
||||
static void HWR_ClearPolys(void)
|
||||
{
|
||||
#ifndef ZPLANALLOC
|
||||
gr_ppcurrent = gr_polypool;
|
||||
gr_ppfree = POLYPOOLSIZE;
|
||||
#endif
|
||||
}
|
||||
|
||||
// allocate pool for fast alloc of polys
|
||||
void HWR_InitPolyPool(void)
|
||||
{
|
||||
#ifndef ZPLANALLOC
|
||||
INT32 pnum;
|
||||
|
||||
//hurdler: quick fix for those who wants to play with larger wad
|
||||
if ((pnum = M_CheckParm("-polypoolsize")))
|
||||
POLYPOOLSIZE = atoi(myargv[pnum+1])*1024; // (in kb)
|
||||
|
||||
CONS_Debug(DBG_RENDER, "HWR_InitPolyPool(): allocating %d bytes\n", POLYPOOLSIZE);
|
||||
gr_polypool = malloc(POLYPOOLSIZE);
|
||||
if (!gr_polypool)
|
||||
I_Error("HWR_InitPolyPool(): couldn't malloc polypool\n");
|
||||
HWR_ClearPolys();
|
||||
#endif
|
||||
}
|
||||
|
||||
void HWR_FreePolyPool(void)
|
||||
{
|
||||
#ifndef ZPLANALLOC
|
||||
if (gr_polypool)
|
||||
free(gr_polypool);
|
||||
gr_polypool = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
static poly_t *HWR_AllocPoly(INT32 numpts)
|
||||
{
|
||||
poly_t *p;
|
||||
size_t size = sizeof (poly_t) + sizeof (polyvertex_t) * numpts;
|
||||
#ifdef ZPLANALLOC
|
||||
p = Z_Malloc(size, PU_HWRPLANE, NULL);
|
||||
#else
|
||||
#ifdef PARANOIA
|
||||
if (!gr_polypool)
|
||||
I_Error("Used gr_polypool without init!\n");
|
||||
if (!gr_ppcurrent)
|
||||
I_Error("gr_ppcurrent == NULL!\n");
|
||||
#endif
|
||||
|
||||
if (gr_ppfree < size)
|
||||
I_Error("HWR_AllocPoly(): no more memory %u bytes left, %u bytes needed\n\n%s\n",
|
||||
gr_ppfree, size, "You can try the param -polypoolsize 2048 (or higher if needed)");
|
||||
|
||||
p = (poly_t *)gr_ppcurrent;
|
||||
gr_ppcurrent += size;
|
||||
gr_ppfree -= size;
|
||||
#endif
|
||||
p->numpts = numpts;
|
||||
return p;
|
||||
}
|
||||
@@ -139,17 +70,7 @@ static polyvertex_t *HWR_AllocVertex(void)
|
||||
{
|
||||
polyvertex_t *p;
|
||||
size_t size = sizeof (polyvertex_t);
|
||||
#ifdef ZPLANALLOC
|
||||
p = Z_Malloc(size, PU_HWRPLANE, NULL);
|
||||
#else
|
||||
if (gr_ppfree < size)
|
||||
I_Error("HWR_AllocVertex(): no more memory %u bytes left, %u bytes needed\n\n%s\n",
|
||||
gr_ppfree, size, "You can try the param -polypoolsize 2048 (or higher if needed)");
|
||||
|
||||
p = (polyvertex_t *)gr_ppcurrent;
|
||||
gr_ppcurrent += size;
|
||||
gr_ppfree -= size;
|
||||
#endif
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -157,16 +78,9 @@ static polyvertex_t *HWR_AllocVertex(void)
|
||||
/// for now don't free because it doesn't free in reverse order
|
||||
static void HWR_FreePoly(poly_t *poly)
|
||||
{
|
||||
#ifdef ZPLANALLOC
|
||||
Z_Free(poly);
|
||||
#else
|
||||
const size_t size = sizeof (poly_t) + sizeof (polyvertex_t) * poly->numpts;
|
||||
memset(poly, 0x00, size);
|
||||
//mempoly -= polysize;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// Return interception along bsp line,
|
||||
// with the polygon segment
|
||||
//
|
||||
@@ -577,8 +491,8 @@ static inline void SearchDivline(node_t *bsp, fdivline_t *divline)
|
||||
divline->dy = FIXED_TO_FLOAT(bsp->dy);
|
||||
}
|
||||
|
||||
#ifdef HWR_LOADING_SCREEN
|
||||
//Hurdler: implement a loading status
|
||||
#ifdef HWR_LOADING_SCREEN
|
||||
static size_t ls_count = 0;
|
||||
static UINT8 ls_percent = 0;
|
||||
|
||||
@@ -836,8 +750,6 @@ static INT32 SolveTProblem(void)
|
||||
return 0;
|
||||
|
||||
CONS_Debug(DBG_RENDER, "Solving T-joins. This may take a while. Please wait...\n");
|
||||
CON_Drawer(); //let the user know what we are doing
|
||||
I_FinishUpdate(); // page flip or blit buffer
|
||||
|
||||
numsplitpoly = 0;
|
||||
|
||||
@@ -964,11 +876,9 @@ void HWR_CreatePlanePolygons(INT32 bspnum)
|
||||
CONS_Debug(DBG_RENDER, "Creating polygons, please wait...\n");
|
||||
#ifdef HWR_LOADING_SCREEN
|
||||
ls_count = ls_percent = 0; // reset the loading status
|
||||
#endif
|
||||
CON_Drawer(); //let the user know what we are doing
|
||||
I_FinishUpdate(); // page flip or blit buffer
|
||||
|
||||
HWR_ClearPolys();
|
||||
#endif
|
||||
|
||||
// find min/max boundaries of map
|
||||
//CONS_Debug(DBG_RENDER, "Looking for boundaries of map...\n");
|
||||
|
||||
+90
-250
@@ -1,18 +1,12 @@
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2019 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file
|
||||
/// \brief load and convert graphics to the hardware format
|
||||
@@ -20,6 +14,7 @@
|
||||
#include "../doomdef.h"
|
||||
|
||||
#ifdef HWRENDER
|
||||
#include "hw_main.h"
|
||||
#include "hw_glob.h"
|
||||
#include "hw_drv.h"
|
||||
|
||||
@@ -31,10 +26,6 @@
|
||||
#include "../v_video.h"
|
||||
#include "../r_draw.h"
|
||||
|
||||
//Hurdler: 25/04/2000: used for new colormap code in hardware mode
|
||||
//static UINT8 *gr_colormap = NULL; // by default it must be NULL ! (because colormap tables are not initialized)
|
||||
boolean firetranslucent = false;
|
||||
|
||||
// Values set after a call to HWR_ResizeBlock()
|
||||
static INT32 blocksize, blockwidth, blockheight;
|
||||
|
||||
@@ -139,17 +130,17 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap,
|
||||
count--;
|
||||
|
||||
texel = source[yfrac>>FRACBITS];
|
||||
|
||||
if (firetranslucent && (transtables[(texel<<8)+0x40000]!=texel))
|
||||
alpha = 0x80;
|
||||
else
|
||||
alpha = 0xff;
|
||||
alpha = 0xff;
|
||||
|
||||
//Hurdler: not perfect, but better than holes
|
||||
if (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX && (mipmap->flags & TF_CHROMAKEYED))
|
||||
texel = HWR_CHROMAKEY_EQUIVALENTCOLORINDEX;
|
||||
alpha = 0x00;
|
||||
|
||||
//texel = HWR_CHROMAKEY_EQUIVALENTCOLORINDEX;
|
||||
// Lat: Don't do that, some weirdos still use CYAN on their WALLTEXTURES for translucency :V
|
||||
|
||||
//Hurdler: 25/04/2000: now support colormap in hardware mode
|
||||
else if (mipmap->colormap)
|
||||
if (mipmap->colormap)
|
||||
texel = mipmap->colormap[texel];
|
||||
|
||||
// hope compiler will get this switch out of the loops (dreams...)
|
||||
@@ -181,16 +172,16 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap,
|
||||
}
|
||||
|
||||
|
||||
// resize the patch to be 3dfx compliant
|
||||
// resize the patch
|
||||
// set : blocksize = blockwidth * blockheight (no bpp used)
|
||||
// blockwidth
|
||||
// blockheight
|
||||
//note : 8bit (1 byte per pixel) palettized format
|
||||
static void HWR_ResizeBlock(INT32 originalwidth, INT32 originalheight,
|
||||
GrTexInfo *grInfo)
|
||||
GLTexInfo *grInfo)
|
||||
{
|
||||
// Build the full textures from patches.
|
||||
static const GrLOD_t gr_lods[9] =
|
||||
static const GLlod_t gr_lods[9] =
|
||||
{
|
||||
GR_LOD_LOG2_256,
|
||||
GR_LOD_LOG2_128,
|
||||
@@ -205,7 +196,7 @@ static void HWR_ResizeBlock(INT32 originalwidth, INT32 originalheight,
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GrAspectRatio_t aspect;
|
||||
GLAspectRatio_t aspect;
|
||||
float max_s;
|
||||
float max_t;
|
||||
} booring_aspect_t;
|
||||
@@ -226,41 +217,21 @@ static void HWR_ResizeBlock(INT32 originalwidth, INT32 originalheight,
|
||||
INT32 j,k;
|
||||
INT32 max,min;
|
||||
|
||||
// find a power of 2 width/height
|
||||
if (cv_grrounddown.value)
|
||||
{
|
||||
blockwidth = 256;
|
||||
while (originalwidth < blockwidth)
|
||||
blockwidth >>= 1;
|
||||
if (blockwidth < 1)
|
||||
I_Error("3D GenerateTexture : too small");
|
||||
// size up to nearest power of 2
|
||||
blockwidth = 1;
|
||||
while (blockwidth < originalwidth)
|
||||
blockwidth <<= 1;
|
||||
// scale down the original graphics to fit in 2048
|
||||
if (blockwidth > 2048)
|
||||
blockwidth = 2048;
|
||||
|
||||
blockheight = 256;
|
||||
while (originalheight < blockheight)
|
||||
blockheight >>= 1;
|
||||
if (blockheight < 1)
|
||||
I_Error("3D GenerateTexture : too small");
|
||||
}
|
||||
else
|
||||
{
|
||||
//size up to nearest power of 2
|
||||
blockwidth = 1;
|
||||
while (blockwidth < originalwidth)
|
||||
blockwidth <<= 1;
|
||||
// scale down the original graphics to fit in 256
|
||||
if (blockwidth > 2048)
|
||||
blockwidth = 2048;
|
||||
//I_Error("3D GenerateTexture : too big");
|
||||
|
||||
//size up to nearest power of 2
|
||||
blockheight = 1;
|
||||
while (blockheight < originalheight)
|
||||
blockheight <<= 1;
|
||||
// scale down the original graphics to fit in 256
|
||||
if (blockheight > 2048)
|
||||
blockheight = 2048;
|
||||
//I_Error("3D GenerateTexture : too big");
|
||||
}
|
||||
// size up to nearest power of 2
|
||||
blockheight = 1;
|
||||
while (blockheight < originalheight)
|
||||
blockheight <<= 1;
|
||||
// scale down the original graphics to fit in 2048
|
||||
if (blockheight > 2048)
|
||||
blockheight = 2048;
|
||||
|
||||
// do the boring LOD stuff.. blech!
|
||||
if (blockwidth >= blockheight)
|
||||
@@ -324,7 +295,7 @@ static UINT8 *MakeBlock(GLMipmap_t *grMipmap)
|
||||
{
|
||||
UINT8 *block;
|
||||
INT32 bpp, i;
|
||||
UINT16 bu16 = ((0x00 <<8) | HWR_CHROMAKEY_EQUIVALENTCOLORINDEX);
|
||||
UINT16 bu16 = ((0x00 <<8) | HWR_PATCHES_CHROMAKEY_COLORINDEX);
|
||||
|
||||
bpp = format2bpp[grMipmap->grInfo.format];
|
||||
block = Z_Malloc(blocksize*bpp, PU_HWRCACHE, &(grMipmap->grInfo.data));
|
||||
@@ -335,8 +306,8 @@ static UINT8 *MakeBlock(GLMipmap_t *grMipmap)
|
||||
case 2:
|
||||
// fill background with chromakey, alpha = 0
|
||||
for (i = 0; i < blocksize; i++)
|
||||
//[segabor]
|
||||
memcpy(block+i*sizeof(UINT16), &bu16, sizeof(UINT16));
|
||||
|
||||
break;
|
||||
case 4: memset(block, 0x00, blocksize*sizeof(UINT32)); break;
|
||||
}
|
||||
@@ -379,6 +350,13 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex)
|
||||
grtex->mipmap.height = (UINT16)blockheight;
|
||||
grtex->mipmap.grInfo.format = textureformat;
|
||||
|
||||
grtex->mipmap.colormap = colormaps;
|
||||
|
||||
#ifdef GLENCORE
|
||||
if (encoremap)
|
||||
grtex->mipmap.colormap += (256*32);
|
||||
#endif
|
||||
|
||||
block = MakeBlock(&grtex->mipmap);
|
||||
|
||||
if (skyspecial) //Hurdler: not efficient, but better than holes in the sky (and it's done only at level loading)
|
||||
@@ -430,7 +408,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex)
|
||||
}
|
||||
|
||||
// patch may be NULL if grMipmap has been initialised already and makebitmap is false
|
||||
void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, boolean makebitmap)
|
||||
void HWR_MakePatch (patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, boolean makebitmap)
|
||||
{
|
||||
INT32 newwidth, newheight;
|
||||
|
||||
@@ -445,8 +423,8 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm
|
||||
grPatch->leftoffset = SHORT(patch->leftoffset);
|
||||
grPatch->topoffset = SHORT(patch->topoffset);
|
||||
|
||||
// find the good 3dfx size (boring spec)
|
||||
HWR_ResizeBlock (SHORT(patch->width), SHORT(patch->height), &grMipmap->grInfo);
|
||||
// resize patch
|
||||
HWR_ResizeBlock(SHORT(patch->width), SHORT(patch->height), &grMipmap->grInfo);
|
||||
grMipmap->width = (UINT16)blockwidth;
|
||||
grMipmap->height = (UINT16)blockheight;
|
||||
|
||||
@@ -465,23 +443,12 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm
|
||||
Z_Free(grMipmap->grInfo.data);
|
||||
grMipmap->grInfo.data = NULL;
|
||||
|
||||
// if rounddown, rounddown patches as well as textures
|
||||
if (cv_grrounddown.value)
|
||||
{
|
||||
newwidth = blockwidth;
|
||||
newheight = blockheight;
|
||||
}
|
||||
else
|
||||
{
|
||||
// no rounddown, do not size up patches, so they don't look 'scaled'
|
||||
newwidth = min(grPatch->width, blockwidth);
|
||||
newheight = min(grPatch->height, blockheight);
|
||||
}
|
||||
newwidth = min(grPatch->width, blockwidth);
|
||||
newheight = min(grPatch->height, blockheight);
|
||||
|
||||
if (makebitmap)
|
||||
{
|
||||
MakeBlock(grMipmap);
|
||||
|
||||
HWR_DrawPatchInCache(grMipmap,
|
||||
newwidth, newheight,
|
||||
blockwidth*format2bpp[grMipmap->grInfo.format],
|
||||
@@ -495,7 +462,6 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm
|
||||
grPatch->max_t = (float)newheight / (float)blockheight;
|
||||
}
|
||||
|
||||
|
||||
// =================================================
|
||||
// CACHING HANDLING
|
||||
// =================================================
|
||||
@@ -515,10 +481,10 @@ static void FreeMipmapColormap(INT32 patchnum, void *patch)
|
||||
{
|
||||
GLPatch_t* const grpatch = patch;
|
||||
(void)patchnum; //unused
|
||||
while (grpatch->mipmap.nextcolormap)
|
||||
while (grpatch->mipmap->nextcolormap)
|
||||
{
|
||||
GLMipmap_t *grmip = grpatch->mipmap.nextcolormap;
|
||||
grpatch->mipmap.nextcolormap = grmip->nextcolormap;
|
||||
GLMipmap_t *grmip = grpatch->mipmap->nextcolormap;
|
||||
grpatch->mipmap->nextcolormap = grmip->nextcolormap;
|
||||
if (grmip->grInfo.data) Z_Free(grmip->grInfo.data);
|
||||
free(grmip);
|
||||
}
|
||||
@@ -562,7 +528,7 @@ void HWR_PrepLevelCache(size_t pnumtextures)
|
||||
gr_numtextures = pnumtextures;
|
||||
gr_textures = calloc(pnumtextures, sizeof (*gr_textures));
|
||||
if (gr_textures == NULL)
|
||||
I_Error("3D can't alloc gr_textures");
|
||||
I_Error("HWR_PrepLevelCache: can't alloc gr_textures");
|
||||
}
|
||||
|
||||
void HWR_SetPalette(RGBA_t *palette)
|
||||
@@ -593,7 +559,7 @@ GLTexture_t *HWR_GetTexture(INT32 tex)
|
||||
GLTexture_t *grtex;
|
||||
#ifdef PARANOIA
|
||||
if ((unsigned)tex >= gr_numtextures)
|
||||
I_Error(" HWR_GetTexture: tex >= numtextures\n");
|
||||
I_Error("HWR_GetTexture: tex >= numtextures\n");
|
||||
#endif
|
||||
grtex = &gr_textures[tex];
|
||||
|
||||
@@ -611,8 +577,13 @@ GLTexture_t *HWR_GetTexture(INT32 tex)
|
||||
|
||||
static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
|
||||
{
|
||||
#ifdef GLENCORE
|
||||
UINT8 *flat;
|
||||
size_t steppy;
|
||||
#endif
|
||||
size_t size, pflatsize;
|
||||
|
||||
|
||||
// setup the texture info
|
||||
grMipmap->grInfo.smallLodLog2 = GR_LOD_LOG2_64;
|
||||
grMipmap->grInfo.largeLodLog2 = GR_LOD_LOG2_64;
|
||||
@@ -652,15 +623,37 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
|
||||
// the flat raw data needn't be converted with palettized textures
|
||||
W_ReadLump(flatlumpnum, Z_Malloc(W_LumpLength(flatlumpnum),
|
||||
PU_HWRCACHE, &grMipmap->grInfo.data));
|
||||
|
||||
#ifdef GLENCORE
|
||||
flat = grMipmap->grInfo.data;
|
||||
for (steppy = 0; steppy < size; steppy++)
|
||||
if (flat[steppy] != HWR_PATCHES_CHROMAKEY_COLORINDEX)
|
||||
flat[steppy] = grMipmap->colormap[flat[steppy]];
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// Download a Doom 'flat' to the hardware cache and make it ready for use
|
||||
void HWR_GetFlat(lumpnum_t flatlumpnum)
|
||||
void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap)
|
||||
{
|
||||
GLMipmap_t *grmip;
|
||||
|
||||
grmip = &HWR_GetCachedGLPatch(flatlumpnum)->mipmap;
|
||||
grmip = HWR_GetCachedGLPatch(flatlumpnum)->mipmap;
|
||||
|
||||
grmip->colormap = colormaps;
|
||||
|
||||
#ifdef GLENCORE
|
||||
if (!noencoremap && encoremap)
|
||||
grmip->colormap += (256*32);
|
||||
#endif
|
||||
|
||||
grmip->colormap = colormaps;
|
||||
|
||||
#ifdef GLENCORE
|
||||
if (!noencoremap && encoremap)
|
||||
grmip->colormap += (256*32);
|
||||
#endif
|
||||
|
||||
|
||||
if (!grmip->downloaded && !grmip->grInfo.data)
|
||||
HWR_CacheFlat(grmip, flatlumpnum);
|
||||
@@ -697,22 +690,22 @@ static void HWR_LoadMappedPatch(GLMipmap_t *grmip, GLPatch_t *gpatch)
|
||||
void HWR_GetPatch(GLPatch_t *gpatch)
|
||||
{
|
||||
// is it in hardware cache
|
||||
if (!gpatch->mipmap.downloaded && !gpatch->mipmap.grInfo.data)
|
||||
if (!gpatch->mipmap->downloaded && !gpatch->mipmap->grInfo.data)
|
||||
{
|
||||
// load the software patch, PU_STATIC or the Z_Malloc for hardware patch will
|
||||
// flush the software patch before the conversion! oh yeah I suffered
|
||||
patch_t *ptr = W_CacheLumpNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC);
|
||||
HWR_MakePatch(ptr, gpatch, &gpatch->mipmap, true);
|
||||
patch_t *patch = W_CacheLumpNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC);
|
||||
HWR_MakePatch(patch, gpatch, gpatch->mipmap, true);
|
||||
|
||||
// this is inefficient.. but the hardware patch in heap is purgeable so it should
|
||||
// not fragment memory, and besides the REAL cache here is the hardware memory
|
||||
Z_Free(ptr);
|
||||
Z_Free(patch);
|
||||
}
|
||||
|
||||
HWD.pfnSetTexture(&gpatch->mipmap);
|
||||
HWD.pfnSetTexture(gpatch->mipmap);
|
||||
|
||||
// The system-memory patch data can be purged now.
|
||||
Z_ChangeTag(gpatch->mipmap.grInfo.data, PU_HWRCACHE_UNLOCKED);
|
||||
Z_ChangeTag(gpatch->mipmap->grInfo.data, PU_HWRCACHE_UNLOCKED);
|
||||
}
|
||||
|
||||
|
||||
@@ -732,7 +725,7 @@ void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap)
|
||||
|
||||
// search for the mimmap
|
||||
// skip the first (no colormap translated)
|
||||
for (grmip = &gpatch->mipmap; grmip->nextcolormap; )
|
||||
for (grmip = gpatch->mipmap; grmip->nextcolormap; )
|
||||
{
|
||||
grmip = grmip->nextcolormap;
|
||||
if (grmip->colormap == colormap)
|
||||
@@ -762,164 +755,10 @@ void HWR_UnlockCachedPatch(GLPatch_t *gpatch)
|
||||
if (!gpatch)
|
||||
return;
|
||||
|
||||
Z_ChangeTag(gpatch->mipmap.grInfo.data, PU_HWRCACHE_UNLOCKED);
|
||||
Z_ChangeTag(gpatch->mipmap->grInfo.data, PU_HWRCACHE_UNLOCKED);
|
||||
Z_ChangeTag(gpatch, PU_HWRPATCHINFO_UNLOCKED);
|
||||
}
|
||||
|
||||
static const INT32 picmode2GR[] =
|
||||
{
|
||||
GR_TEXFMT_P_8, // PALETTE
|
||||
0, // INTENSITY (unsupported yet)
|
||||
GR_TEXFMT_ALPHA_INTENSITY_88, // INTENSITY_ALPHA (corona use this)
|
||||
0, // RGB24 (unsupported yet)
|
||||
GR_RGBA, // RGBA32 (opengl only)
|
||||
};
|
||||
|
||||
static void HWR_DrawPicInCache(UINT8 *block, INT32 pblockwidth, INT32 pblockheight,
|
||||
INT32 blockmodulo, pic_t *pic, INT32 bpp)
|
||||
{
|
||||
INT32 i,j;
|
||||
fixed_t posx, posy, stepx, stepy;
|
||||
UINT8 *dest, *src, texel;
|
||||
UINT16 texelu16;
|
||||
INT32 picbpp;
|
||||
RGBA_t col;
|
||||
|
||||
stepy = ((INT32)SHORT(pic->height)<<FRACBITS)/pblockheight;
|
||||
stepx = ((INT32)SHORT(pic->width)<<FRACBITS)/pblockwidth;
|
||||
picbpp = format2bpp[picmode2GR[pic->mode]];
|
||||
posy = 0;
|
||||
for (j = 0; j < pblockheight; j++)
|
||||
{
|
||||
posx = 0;
|
||||
dest = &block[j*blockmodulo];
|
||||
src = &pic->data[(posy>>FRACBITS)*SHORT(pic->width)*picbpp];
|
||||
for (i = 0; i < pblockwidth;i++)
|
||||
{
|
||||
switch (pic->mode)
|
||||
{ // source bpp
|
||||
case PALETTE :
|
||||
texel = src[(posx+FRACUNIT/2)>>FRACBITS];
|
||||
switch (bpp)
|
||||
{ // destination bpp
|
||||
case 1 :
|
||||
*dest++ = texel; break;
|
||||
case 2 :
|
||||
texelu16 = (UINT16)(texel | 0xff00);
|
||||
memcpy(dest, &texelu16, sizeof(UINT16));
|
||||
dest += sizeof(UINT16);
|
||||
break;
|
||||
case 3 :
|
||||
col = V_GetColor(texel);
|
||||
memcpy(dest, &col, sizeof(RGBA_t)-sizeof(UINT8));
|
||||
dest += sizeof(RGBA_t)-sizeof(UINT8);
|
||||
break;
|
||||
case 4 :
|
||||
memcpy(dest, &V_GetColor(texel), sizeof(RGBA_t));
|
||||
dest += sizeof(RGBA_t);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case INTENSITY :
|
||||
*dest++ = src[(posx+FRACUNIT/2)>>FRACBITS];
|
||||
break;
|
||||
case INTENSITY_ALPHA : // assume dest bpp = 2
|
||||
memcpy(dest, src + ((posx+FRACUNIT/2)>>FRACBITS)*sizeof(UINT16), sizeof(UINT16));
|
||||
dest += sizeof(UINT16);
|
||||
break;
|
||||
case RGB24 :
|
||||
break; // not supported yet
|
||||
case RGBA32 : // assume dest bpp = 4
|
||||
dest += sizeof(UINT32);
|
||||
memcpy(dest, src + ((posx+FRACUNIT/2)>>FRACBITS)*sizeof(UINT32), sizeof(UINT32));
|
||||
break;
|
||||
}
|
||||
posx += stepx;
|
||||
}
|
||||
posy += stepy;
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------+
|
||||
// HWR_GetPic : Download a Doom pic (raw row encoded with no 'holes')
|
||||
// Returns :
|
||||
// -----------------+
|
||||
GLPatch_t *HWR_GetPic(lumpnum_t lumpnum)
|
||||
{
|
||||
GLPatch_t *grpatch;
|
||||
|
||||
grpatch = HWR_GetCachedGLPatch(lumpnum);
|
||||
|
||||
if (!grpatch->mipmap.downloaded && !grpatch->mipmap.grInfo.data)
|
||||
{
|
||||
pic_t *pic;
|
||||
UINT8 *block;
|
||||
size_t len;
|
||||
INT32 newwidth, newheight;
|
||||
|
||||
pic = W_CacheLumpNum(lumpnum, PU_CACHE);
|
||||
grpatch->width = SHORT(pic->width);
|
||||
grpatch->height = SHORT(pic->height);
|
||||
len = W_LumpLength(lumpnum) - sizeof (pic_t);
|
||||
|
||||
grpatch->leftoffset = 0;
|
||||
grpatch->topoffset = 0;
|
||||
|
||||
// find the good 3dfx size (boring spec)
|
||||
HWR_ResizeBlock (grpatch->width, grpatch->height, &grpatch->mipmap.grInfo);
|
||||
grpatch->mipmap.width = (UINT16)blockwidth;
|
||||
grpatch->mipmap.height = (UINT16)blockheight;
|
||||
|
||||
if (pic->mode == PALETTE)
|
||||
grpatch->mipmap.grInfo.format = textureformat; // can be set by driver
|
||||
else
|
||||
grpatch->mipmap.grInfo.format = picmode2GR[pic->mode];
|
||||
|
||||
Z_Free(grpatch->mipmap.grInfo.data);
|
||||
|
||||
// allocate block
|
||||
block = MakeBlock(&grpatch->mipmap);
|
||||
|
||||
// if rounddown, rounddown patches as well as textures
|
||||
if (cv_grrounddown.value)
|
||||
{
|
||||
newwidth = blockwidth;
|
||||
newheight = blockheight;
|
||||
}
|
||||
else
|
||||
{
|
||||
// no rounddown, do not size up patches, so they don't look 'scaled'
|
||||
newwidth = min(SHORT(pic->width),blockwidth);
|
||||
newheight = min(SHORT(pic->height),blockheight);
|
||||
}
|
||||
|
||||
|
||||
if (grpatch->width == blockwidth &&
|
||||
grpatch->height == blockheight &&
|
||||
format2bpp[grpatch->mipmap.grInfo.format] == format2bpp[picmode2GR[pic->mode]])
|
||||
{
|
||||
// no conversion needed
|
||||
M_Memcpy(grpatch->mipmap.grInfo.data, pic->data,len);
|
||||
}
|
||||
else
|
||||
HWR_DrawPicInCache(block, newwidth, newheight,
|
||||
blockwidth*format2bpp[grpatch->mipmap.grInfo.format],
|
||||
pic,
|
||||
format2bpp[grpatch->mipmap.grInfo.format]);
|
||||
|
||||
Z_Unlock(pic);
|
||||
Z_ChangeTag(block, PU_HWRCACHE_UNLOCKED);
|
||||
|
||||
grpatch->mipmap.flags = 0;
|
||||
grpatch->max_s = (float)newwidth / (float)blockwidth;
|
||||
grpatch->max_t = (float)newheight / (float)blockheight;
|
||||
}
|
||||
HWD.pfnSetTexture(&grpatch->mipmap);
|
||||
//CONS_Debug(DBG_RENDER, "picloaded at %x as texture %d\n",grpatch->mipmap.grInfo.data, grpatch->mipmap.downloaded);
|
||||
|
||||
return grpatch;
|
||||
}
|
||||
|
||||
GLPatch_t *HWR_GetCachedGLPatchPwad(UINT16 wadnum, UINT16 lumpnum)
|
||||
{
|
||||
aatree_t *hwrcache = wadfiles[wadnum]->hwrcache;
|
||||
@@ -930,6 +769,7 @@ GLPatch_t *HWR_GetCachedGLPatchPwad(UINT16 wadnum, UINT16 lumpnum)
|
||||
grpatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL);
|
||||
grpatch->wadnum = wadnum;
|
||||
grpatch->lumpnum = lumpnum;
|
||||
grpatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL);
|
||||
M_AATreeSet(hwrcache, lumpnum, grpatch);
|
||||
}
|
||||
|
||||
@@ -1033,7 +873,7 @@ void HWR_GetFadeMask(lumpnum_t fademasklumpnum)
|
||||
{
|
||||
GLMipmap_t *grmip;
|
||||
|
||||
grmip = &HWR_GetCachedGLPatch(fademasklumpnum)->mipmap;
|
||||
grmip = HWR_GetCachedGLPatch(fademasklumpnum)->mipmap;
|
||||
|
||||
if (!grmip->downloaded && !grmip->grInfo.data)
|
||||
HWR_CacheFadeMask(grmip, fademasklumpnum);
|
||||
|
||||
+10
-11
@@ -70,16 +70,17 @@
|
||||
|
||||
#include <math.h>
|
||||
#include "../v_video.h"
|
||||
#include "hw_main.h"
|
||||
#include "hw_clip.h"
|
||||
#include "hw_glob.h"
|
||||
#include "../r_main.h"
|
||||
#include "../r_state.h"
|
||||
#include "../tables.h"
|
||||
#include "r_opengl/r_opengl.h"
|
||||
#include "../r_main.h" // for cv_fov
|
||||
|
||||
#ifdef HAVE_SPHEREFRUSTRUM
|
||||
static GLfloat viewMatrix[16];
|
||||
static GLfloat projMatrix[16];
|
||||
static GLdouble viewMatrix[16];
|
||||
static GLdouble projMatrix[16];
|
||||
float frustum[6][4];
|
||||
#endif
|
||||
|
||||
@@ -320,12 +321,12 @@ void gld_clipper_Clear(void)
|
||||
|
||||
#define RMUL (1.6f/1.333333f)
|
||||
|
||||
angle_t gld_FrustumAngle(void)
|
||||
angle_t gld_FrustumAngle(angle_t tiltangle)
|
||||
{
|
||||
double floatangle;
|
||||
angle_t a1;
|
||||
|
||||
float tilt = (float)fabs(((double)(int)aimingangle) / ANG1);
|
||||
float tilt = (float)fabs(((double)(int)tiltangle) / ANG1);
|
||||
|
||||
// NEWCLIP TODO: SRB2CBTODO: make a global render_fov for this function
|
||||
|
||||
@@ -334,12 +335,10 @@ angle_t gld_FrustumAngle(void)
|
||||
float render_multiplier = 64.0f / render_fovratio / RMUL;
|
||||
|
||||
if (tilt > 90.0f)
|
||||
{
|
||||
tilt = 90.0f;
|
||||
}
|
||||
|
||||
// If the pitch is larger than this you can look all around at a FOV of 90
|
||||
if (abs((signed)aimingangle) > 46 * ANG1)
|
||||
if (abs((signed)tiltangle) > 46 * ANG1)
|
||||
return 0xffffffff;
|
||||
|
||||
// ok, this is a gross hack that barely works...
|
||||
@@ -352,7 +351,7 @@ angle_t gld_FrustumAngle(void)
|
||||
}
|
||||
|
||||
// SRB2CB I don't think used any of this stuff, let's disable for now since SRB2 probably doesn't want it either
|
||||
// compiler complains about (p)glGetDoublev anyway, in case anyone wants this
|
||||
// compiler complains about (p)glGetFloatv anyway, in case anyone wants this
|
||||
// only r_opengl.c can use the base gl funcs as it turns out, that's a problem for whoever wants sphere frustum checks
|
||||
// btw to renable define HAVE_SPHEREFRUSTRUM in hw_clip.h
|
||||
#ifdef HAVE_SPHEREFRUSTRUM
|
||||
@@ -381,7 +380,7 @@ void gld_FrustrumSetup(void)
|
||||
float t;
|
||||
float clip[16];
|
||||
|
||||
pglGeFloatv(GL_PROJECTION_MATRIX, projMatrix);
|
||||
pglGetFloatv(GL_PROJECTION_MATRIX, projMatrix);
|
||||
pglGetFloatv(GL_MODELVIEW_MATRIX, viewMatrix);
|
||||
|
||||
clip[0] = CALCMATRIX(0, 0, 1, 4, 2, 8, 3, 12);
|
||||
@@ -463,4 +462,4 @@ boolean gld_SphereInFrustum(float x, float y, float z, float radius)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -17,7 +17,7 @@
|
||||
boolean gld_clipper_SafeCheckRange(angle_t startAngle, angle_t endAngle);
|
||||
void gld_clipper_SafeAddClipRange(angle_t startangle, angle_t endangle);
|
||||
void gld_clipper_Clear(void);
|
||||
angle_t gld_FrustumAngle(void);
|
||||
angle_t gld_FrustumAngle(angle_t tiltangle);
|
||||
#ifdef HAVE_SPHEREFRUSTRUM
|
||||
void gld_FrustrumSetup(void);
|
||||
boolean gld_SphereInFrustum(float x, float y, float z, float radius);
|
||||
|
||||
+66
-40
@@ -1,77 +1,101 @@
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2019 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file
|
||||
/// \brief defines structures and exports for the standard 3D driver DLL used by Doom Legacy
|
||||
/// \brief defines structures and exports for the standard GPU driver
|
||||
|
||||
#ifndef _HWR_DATA_
|
||||
#define _HWR_DATA_
|
||||
|
||||
#if defined (_WIN32) && !defined (__CYGWIN__) && !defined (_XBOX)
|
||||
//#define WIN32_LEAN_AND_MEAN
|
||||
#define RPC_NO_WINDOWS_H
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "../doomdef.h"
|
||||
//THIS MUST DISAPPEAR!!!
|
||||
#include "hw_glide.h"
|
||||
#include "../screen.h"
|
||||
|
||||
|
||||
// ==========================================================================
|
||||
// TEXTURE INFO
|
||||
// ==========================================================================
|
||||
|
||||
//
|
||||
// hw_glide.h
|
||||
//
|
||||
|
||||
typedef long GLAspectRatio_t;
|
||||
#define GR_ASPECT_LOG2_8x1 3 /* 8W x 1H */
|
||||
#define GR_ASPECT_LOG2_4x1 2 /* 4W x 1H */
|
||||
#define GR_ASPECT_LOG2_2x1 1 /* 2W x 1H */
|
||||
#define GR_ASPECT_LOG2_1x1 0 /* 1W x 1H */
|
||||
#define GR_ASPECT_LOG2_1x2 -1 /* 1W x 2H */
|
||||
#define GR_ASPECT_LOG2_1x4 -2 /* 1W x 4H */
|
||||
#define GR_ASPECT_LOG2_1x8 -3 /* 1W x 8H */
|
||||
|
||||
typedef long GLlod_t;
|
||||
#define GR_LOD_LOG2_256 0x8
|
||||
#define GR_LOD_LOG2_128 0x7
|
||||
#define GR_LOD_LOG2_64 0x6
|
||||
#define GR_LOD_LOG2_32 0x5
|
||||
#define GR_LOD_LOG2_16 0x4
|
||||
#define GR_LOD_LOG2_8 0x3
|
||||
#define GR_LOD_LOG2_4 0x2
|
||||
#define GR_LOD_LOG2_2 0x1
|
||||
#define GR_LOD_LOG2_1 0x0
|
||||
|
||||
typedef long GLTextureFormat_t;
|
||||
#define GR_TEXFMT_ALPHA_8 0x2 /* (0..0xFF) alpha */
|
||||
#define GR_TEXFMT_INTENSITY_8 0x3 /* (0..0xFF) intensity */
|
||||
#define GR_TEXFMT_ALPHA_INTENSITY_44 0x4
|
||||
#define GR_TEXFMT_P_8 0x5 /* 8-bit palette */
|
||||
#define GR_TEXFMT_RGB_565 0xa
|
||||
#define GR_TEXFMT_ARGB_1555 0xb
|
||||
#define GR_TEXFMT_ARGB_4444 0xc
|
||||
#define GR_TEXFMT_ALPHA_INTENSITY_88 0xd
|
||||
#define GR_TEXFMT_AP_88 0xe /* 8-bit alpha 8-bit palette */
|
||||
#define GR_RGBA 0x6 // 32 bit RGBA !
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GLlod_t smallLodLog2;
|
||||
GLlod_t largeLodLog2;
|
||||
GLAspectRatio_t aspectRatioLog2;
|
||||
GLTextureFormat_t format;
|
||||
void *data;
|
||||
} GLTexInfo;
|
||||
|
||||
// grInfo.data holds the address of the graphics data cached in heap memory
|
||||
// NULL if the texture is not in Doom heap cache.
|
||||
struct GLMipmap_s
|
||||
{
|
||||
GrTexInfo grInfo; //for TexDownloadMipMap
|
||||
FxU32 flags;
|
||||
UINT16 height;
|
||||
UINT16 width;
|
||||
UINT32 downloaded; // the dll driver have it in there cache ?
|
||||
GLTexInfo grInfo;
|
||||
unsigned long flags;
|
||||
UINT16 width, height;
|
||||
UINT32 downloaded; // tex_downloaded
|
||||
|
||||
struct GLMipmap_s *nextcolormap;
|
||||
const UINT8 *colormap;
|
||||
|
||||
// opengl
|
||||
struct GLMipmap_s *nextmipmap; // opengl : liste of all texture in opengl driver
|
||||
struct GLMipmap_s *nextmipmap;
|
||||
struct GLMipmap_s *nextcolormap;
|
||||
const UINT8 *colormap;
|
||||
};
|
||||
typedef struct GLMipmap_s GLMipmap_t;
|
||||
|
||||
|
||||
//
|
||||
// Doom texture info, as cached for hardware rendering
|
||||
//
|
||||
struct GLTexture_s
|
||||
{
|
||||
GLMipmap_t mipmap;
|
||||
float scaleX; //used for scaling textures on walls
|
||||
float scaleY;
|
||||
GLMipmap_t mipmap;
|
||||
float scaleX; //used for scaling textures on walls
|
||||
float scaleY;
|
||||
};
|
||||
typedef struct GLTexture_s GLTexture_t;
|
||||
|
||||
|
||||
// a cached patch as converted to hardware format, holding the original patch_t
|
||||
// header so that the existing code can retrieve ->width, ->height as usual
|
||||
// This is returned by W_CachePatchNum()/W_CachePatchName(), when rendermode
|
||||
// is 'render_opengl'. Else it returns the normal patch_t data.
|
||||
|
||||
struct GLPatch_s
|
||||
{
|
||||
// the 4 first fields come right away from the original patch_t
|
||||
@@ -83,8 +107,10 @@ struct GLPatch_s
|
||||
float max_s,max_t;
|
||||
UINT16 wadnum; // the software patch lump num for when the hardware patch
|
||||
UINT16 lumpnum; // was flushed, and we need to re-create it
|
||||
GLMipmap_t mipmap;
|
||||
};
|
||||
GLMipmap_t *mipmap;
|
||||
|
||||
boolean notfound; // if the texture file was not found, mark it here (used in model texture loading)
|
||||
} ATTRPACK;
|
||||
typedef struct GLPatch_s GLPatch_t;
|
||||
|
||||
#endif //_HWR_DATA_
|
||||
+87
-66
@@ -19,6 +19,7 @@
|
||||
#ifndef _HWR_DEFS_
|
||||
#define _HWR_DEFS_
|
||||
#include "../doomtype.h"
|
||||
#include "../r_defs.h"
|
||||
|
||||
#define ZCLIP_PLANE 4.0f // Used for the actual game drawing
|
||||
#define NZCLIP_PLANE 0.9f // Seems to be only used for the HUD and screen textures
|
||||
@@ -41,17 +42,8 @@ typedef unsigned char FBOOLEAN;
|
||||
// ==========================================================================
|
||||
|
||||
// byte value for paletted graphics, which represent the transparent color
|
||||
#ifdef _NDS
|
||||
// NDS is hardwired to use zero as transparent color
|
||||
#define HWR_PATCHES_CHROMAKEY_COLORINDEX 0
|
||||
#define HWR_CHROMAKEY_EQUIVALENTCOLORINDEX 1
|
||||
#else
|
||||
#define HWR_PATCHES_CHROMAKEY_COLORINDEX 247
|
||||
#define HWR_CHROMAKEY_EQUIVALENTCOLORINDEX 220
|
||||
#endif
|
||||
|
||||
// the chroma key color shows on border sprites, set it to black
|
||||
#define HWR_PATCHES_CHROMAKEY_COLORVALUE (0x00000000) //RGBA format as in grSstWinOpen()
|
||||
|
||||
// RGBA Color components with float type ranging [ 0 ... 1 ]
|
||||
struct FRGBAFloat
|
||||
@@ -73,8 +65,6 @@ struct FColorARGB
|
||||
typedef struct FColorARGB ARGB_t;
|
||||
typedef struct FColorARGB FColorARGB;
|
||||
|
||||
|
||||
|
||||
// ==========================================================================
|
||||
// VECTORS
|
||||
// ==========================================================================
|
||||
@@ -85,22 +75,65 @@ typedef struct
|
||||
FLOAT x,y;
|
||||
} F2DCoord, v2d_t;
|
||||
|
||||
// Simple 3D vector
|
||||
typedef struct FVector
|
||||
{
|
||||
FLOAT x,y,z;
|
||||
} FVector;
|
||||
// ======================
|
||||
// wallVert3D
|
||||
// ----------------------
|
||||
// :crab: IS GONE! :crab:
|
||||
// ======================
|
||||
|
||||
// 3D model vector (coords + texture coords)
|
||||
// -----------
|
||||
// structures
|
||||
// -----------
|
||||
|
||||
// a vertex of a Doom 'plane' polygon
|
||||
typedef struct
|
||||
{
|
||||
//FVector Point;
|
||||
FLOAT x,y,z;
|
||||
FLOAT s,t,w; // texture coordinates
|
||||
} v3d_t, wallVert3D;
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
} polyvertex_t;
|
||||
|
||||
//Hurdler: Transform (coords + angles)
|
||||
//BP: transform order : scale(rotation_x(rotation_y(translation(v))))
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4200)
|
||||
#endif
|
||||
|
||||
// a convex 'plane' polygon, clockwise order
|
||||
typedef struct
|
||||
{
|
||||
INT32 numpts;
|
||||
polyvertex_t pts[0];
|
||||
} poly_t;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(default : 4200)
|
||||
#endif
|
||||
|
||||
// holds extra info for 3D render, for each subsector in subsectors[]
|
||||
typedef struct
|
||||
{
|
||||
poly_t *planepoly; // the generated convex polygon
|
||||
} extrasubsector_t;
|
||||
|
||||
// needed for sprite rendering
|
||||
// equivalent of the software renderer's vissprites
|
||||
typedef struct gr_vissprite_s
|
||||
{
|
||||
// Doubly linked list
|
||||
struct gr_vissprite_s *prev;
|
||||
struct gr_vissprite_s *next;
|
||||
float x1, x2;
|
||||
float z1, z2;
|
||||
float tz, ty;
|
||||
lumpnum_t patchlumpnum;
|
||||
boolean flip;
|
||||
UINT8 translucency; //alpha level 0-255
|
||||
mobj_t *mobj;
|
||||
boolean precip; // Tails 08-25-2002
|
||||
boolean vflip;
|
||||
//Hurdler: 25/04/2000: now support colormap in hardware mode
|
||||
UINT8 *colormap;
|
||||
INT32 dispoffset; // copy of info->dispoffset, affects ordering but not drawing
|
||||
} gr_vissprite_t;
|
||||
|
||||
// Kart features
|
||||
#define USE_FTRANSFORM_ANGLEZ
|
||||
@@ -124,18 +157,17 @@ typedef struct
|
||||
#ifdef USE_FTRANSFORM_MIRROR
|
||||
boolean mirror; // SRB2Kart: Encore Mode
|
||||
#endif
|
||||
boolean shearing; // 14042019
|
||||
angle_t viewaiming; // 17052019
|
||||
} FTransform;
|
||||
|
||||
// Transformed vector, as passed to HWR API
|
||||
typedef struct
|
||||
{
|
||||
FLOAT x,y,z;
|
||||
FUINT argb; // flat-shaded color
|
||||
FLOAT sow; // s texture ordinate (s over w)
|
||||
FLOAT tow; // t texture ordinate (t over w)
|
||||
FLOAT s,t;
|
||||
} FOutVector;
|
||||
|
||||
|
||||
// ==========================================================================
|
||||
// RENDER MODES
|
||||
// ==========================================================================
|
||||
@@ -144,7 +176,7 @@ typedef struct
|
||||
// You pass a combination of these flags to DrawPolygon()
|
||||
enum EPolyFlags
|
||||
{
|
||||
// the first 5 are mutually exclusive
|
||||
// the first 5 are mutually exclusive
|
||||
|
||||
PF_Masked = 0x00000001, // Poly is alpha scaled and 0 alpha pels are discarded (holes in texture)
|
||||
PF_Translucent = 0x00000002, // Poly is transparent, alpha = level of transparency
|
||||
@@ -156,7 +188,7 @@ enum EPolyFlags
|
||||
PF_Fog = 0x00000040, // Fog blocks
|
||||
PF_Blending = (PF_Environment|PF_Additive|PF_Translucent|PF_Masked|PF_Substractive|PF_Fog)&~PF_NoAlphaTest,
|
||||
|
||||
// other flag bits
|
||||
// other flag bits
|
||||
|
||||
PF_Occlude = 0x00000100, // Update the depth buffer
|
||||
PF_NoDepthTest = 0x00000200, // Disable the depth test mode
|
||||
@@ -164,21 +196,15 @@ enum EPolyFlags
|
||||
PF_Decal = 0x00000800, // Enable polygon offset
|
||||
PF_Modulated = 0x00001000, // Modulation (multiply output with constant ARGB)
|
||||
// When set, pass the color constant into the FSurfaceInfo -> FlatColor
|
||||
PF_NoTexture = 0x00002000, // Use the small white texture
|
||||
PF_Corona = 0x00004000, // Tell the rendrer we are drawing a corona
|
||||
PF_Unused = 0x00008000, // Unused
|
||||
PF_NoTexture = 0x00002000, // Disable texture
|
||||
PF_Ripple = 0x00004000, // Water shader effect
|
||||
// 0x00008000
|
||||
PF_RemoveYWrap = 0x00010000, // Force clamp texture on Y
|
||||
PF_ForceWrapX = 0x00020000, // Force repeat texture on X
|
||||
PF_ForceWrapY = 0x00040000, // Force repeat texture on Y
|
||||
PF_Clip = 0x40000000, // clip to frustum and nearz plane (glide only, automatic in opengl)
|
||||
PF_NoZClip = 0x20000000, // in conjonction with PF_Clip
|
||||
PF_Debug = 0x80000000 // print debug message in driver :)
|
||||
};
|
||||
|
||||
|
||||
enum ESurfFlags
|
||||
{
|
||||
SF_DYNLIGHT = 0x00000001,
|
||||
// 0x20000000
|
||||
// 0x40000000
|
||||
// 0x80000000
|
||||
|
||||
};
|
||||
|
||||
@@ -191,46 +217,42 @@ enum ETextureFlags
|
||||
TF_TRANSPARENT = 0x00000040, // texture with some alpha == 0
|
||||
};
|
||||
|
||||
#ifdef TODO
|
||||
struct FTextureInfo
|
||||
{
|
||||
FUINT Width; // Pixels
|
||||
FUINT Height; // Pixels
|
||||
FUBYTE *TextureData; // Image data
|
||||
FUINT Format; // FORMAT_RGB, ALPHA ...
|
||||
FBITFIELD Flags; // Flags to tell driver about texture (see ETextureFlags)
|
||||
void DriverExtra; // (OpenGL texture object nr, ...)
|
||||
// chromakey enabled,...
|
||||
|
||||
struct FTextureInfo *Next; // Manage list of downloaded textures.
|
||||
};
|
||||
#else
|
||||
typedef struct GLMipmap_s FTextureInfo;
|
||||
#endif
|
||||
|
||||
// jimita 14032019
|
||||
struct FLightInfo
|
||||
{
|
||||
FUINT light_level;
|
||||
FUINT fade_start;
|
||||
FUINT fade_end;
|
||||
};
|
||||
typedef struct FLightInfo FLightInfo;
|
||||
|
||||
// Description of a renderable surface
|
||||
struct FSurfaceInfo
|
||||
{
|
||||
FUINT PolyFlags; // Surface flags -- UNUSED YET --
|
||||
RGBA_t FlatColor; // Flat-shaded color used with PF_Modulated mode
|
||||
FUINT PolyFlags;
|
||||
RGBA_t PolyColor;
|
||||
RGBA_t TintColor;
|
||||
RGBA_t FadeColor;
|
||||
FLightInfo LightInfo; // jimita 14032019
|
||||
};
|
||||
typedef struct FSurfaceInfo FSurfaceInfo;
|
||||
|
||||
//Hurdler: added for backward compatibility
|
||||
enum hwdsetspecialstate
|
||||
{
|
||||
HWD_SET_FOG_TABLE = 1,
|
||||
HWD_SET_FOG_MODE,
|
||||
HWD_SET_FOG_COLOR,
|
||||
HWD_SET_FOG_DENSITY,
|
||||
HWD_SET_FOV,
|
||||
HWD_SET_SHADERS,
|
||||
|
||||
HWD_SET_TEXTUREFILTERMODE,
|
||||
HWD_SET_TEXTUREANISOTROPICMODE,
|
||||
|
||||
HWD_NUMSTATE
|
||||
};
|
||||
|
||||
typedef enum hwdsetspecialstate hwdspecialstate_t;
|
||||
|
||||
#define GL_DEFAULTMIX 0x00000000
|
||||
#define GL_DEFAULTFOG 0xFF000000
|
||||
|
||||
enum hwdfiltermode
|
||||
{
|
||||
HWD_SET_TEXTUREFILTER_POINTSAMPLED,
|
||||
@@ -241,5 +263,4 @@ enum hwdfiltermode
|
||||
HWD_SET_TEXTUREFILTER_MIXED3,
|
||||
};
|
||||
|
||||
|
||||
#endif //_HWR_DEFS_
|
||||
@@ -54,8 +54,6 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef void (*I_Error_t) (const char *error, ...) FUNCIERROR;
|
||||
|
||||
// ==========================================================================
|
||||
// MATHS
|
||||
// ==========================================================================
|
||||
@@ -63,7 +61,8 @@ typedef void (*I_Error_t) (const char *error, ...) FUNCIERROR;
|
||||
// Constants
|
||||
#define DEGREE (0.017453292519943295769236907684883l) // 2*PI/360
|
||||
|
||||
void DBG_Printf(const char *lpFmt, ...) /*FUNCPRINTF*/;
|
||||
void GL_DBG_Printf(const char *format, ...) /*FUNCPRINTF*/;
|
||||
#define DBG_Printf GL_DBG_Printf
|
||||
|
||||
#ifdef _WINDOWS
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
|
||||
|
||||
+283
-331
@@ -1,17 +1,12 @@
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2019 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file
|
||||
/// \brief miscellaneous drawing (mainly 2d)
|
||||
@@ -23,6 +18,7 @@
|
||||
#include "../doomdef.h"
|
||||
|
||||
#ifdef HWRENDER
|
||||
#include "hw_main.h"
|
||||
#include "hw_glob.h"
|
||||
#include "hw_drv.h"
|
||||
|
||||
@@ -41,9 +37,6 @@
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
|
||||
float gr_patch_scalex;
|
||||
float gr_patch_scaley;
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
@@ -63,9 +56,6 @@ typedef struct
|
||||
#if defined(_MSC_VER)
|
||||
#pragma pack()
|
||||
#endif
|
||||
typedef UINT8 GLRGB[3];
|
||||
|
||||
#define BLENDMODE PF_Translucent
|
||||
|
||||
static UINT8 softwaretranstogl[11] = { 0, 25, 51, 76,102,127,153,178,204,229,255};
|
||||
static UINT8 softwaretranstogl_hi[11] = { 0, 51,102,153,204,255,255,255,255,255,255};
|
||||
@@ -119,12 +109,12 @@ void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option)
|
||||
|
||||
v[0].z = v[1].z = v[2].z = v[3].z = 1.0f;
|
||||
|
||||
v[0].sow = v[3].sow = 0.0f;
|
||||
v[2].sow = v[1].sow = gpatch->max_s;
|
||||
v[0].tow = v[1].tow = 0.0f;
|
||||
v[2].tow = v[3].tow = gpatch->max_t;
|
||||
v[0].s = v[3].s = 0.0f;
|
||||
v[2].s = v[1].s = gpatch->max_s;
|
||||
v[0].t = v[1].t = 0.0f;
|
||||
v[2].t = v[3].t = gpatch->max_t;
|
||||
|
||||
flags = BLENDMODE|PF_Clip|PF_NoZClip|PF_NoDepthTest;
|
||||
flags = PF_Translucent|PF_NoDepthTest;
|
||||
|
||||
if (option & V_WRAPX)
|
||||
flags |= PF_ForceWrapX;
|
||||
@@ -220,7 +210,7 @@ void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale,
|
||||
// if it's meant to cover the whole screen, black out the rest
|
||||
// cx and cy are possibly *slightly* off from float maths
|
||||
// This is done before here compared to software because we directly alter cx and cy to centre
|
||||
/*if (cx >= -0.1f && cx <= 0.1f && SHORT(gpatch->width) == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && SHORT(gpatch->height) == BASEVIDHEIGHT)
|
||||
if (cx >= -0.1f && cx <= 0.1f && SHORT(gpatch->width) == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && SHORT(gpatch->height) == BASEVIDHEIGHT)
|
||||
{
|
||||
// Need to temporarily cache the real patch to get the colour of the top left pixel
|
||||
patch_t *realpatch = W_CacheLumpNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC);
|
||||
@@ -228,7 +218,7 @@ void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale,
|
||||
const UINT8 *source = (const UINT8 *)(column) + 3;
|
||||
HWR_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, (column->topdelta == 0xff ? 31 : source[0]));
|
||||
Z_Free(realpatch);
|
||||
}*/
|
||||
}
|
||||
// centre screen
|
||||
if (fabsf((float)vid.width - (float)BASEVIDWIDTH * dupx) > 1.0E-36f)
|
||||
{
|
||||
@@ -279,19 +269,19 @@ void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale,
|
||||
|
||||
if (option & V_FLIP)
|
||||
{
|
||||
v[0].sow = v[3].sow = gpatch->max_s;
|
||||
v[2].sow = v[1].sow = 0.0f;
|
||||
v[0].s = v[3].s = gpatch->max_s;
|
||||
v[2].s = v[1].s = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
v[0].sow = v[3].sow = 0.0f;
|
||||
v[2].sow = v[1].sow = gpatch->max_s;
|
||||
v[0].s = v[3].s = 0.0f;
|
||||
v[2].s = v[1].s = gpatch->max_s;
|
||||
}
|
||||
|
||||
v[0].tow = v[1].tow = 0.0f;
|
||||
v[2].tow = v[3].tow = gpatch->max_t;
|
||||
v[0].t = v[1].t = 0.0f;
|
||||
v[2].t = v[3].t = gpatch->max_t;
|
||||
|
||||
flags = BLENDMODE|PF_Clip|PF_NoZClip|PF_NoDepthTest;
|
||||
flags = PF_Translucent|PF_NoDepthTest;
|
||||
|
||||
if (option & V_WRAPX)
|
||||
flags |= PF_ForceWrapX;
|
||||
@@ -302,11 +292,11 @@ void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale,
|
||||
if (alphalevel)
|
||||
{
|
||||
FSurfaceInfo Surf;
|
||||
Surf.FlatColor.s.red = Surf.FlatColor.s.green = Surf.FlatColor.s.blue = 0xff;
|
||||
if (alphalevel == 13) Surf.FlatColor.s.alpha = softwaretranstogl_lo[hudtrans];
|
||||
else if (alphalevel == 14) Surf.FlatColor.s.alpha = softwaretranstogl[hudtrans];
|
||||
else if (alphalevel == 15) Surf.FlatColor.s.alpha = softwaretranstogl_hi[hudtrans];
|
||||
else Surf.FlatColor.s.alpha = softwaretranstogl[10-alphalevel];
|
||||
Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff;
|
||||
if (alphalevel == 13) Surf.PolyColor.s.alpha = softwaretranstogl_lo[hudtrans];
|
||||
else if (alphalevel == 14) Surf.PolyColor.s.alpha = softwaretranstogl[hudtrans];
|
||||
else if (alphalevel == 15) Surf.PolyColor.s.alpha = softwaretranstogl_hi[hudtrans];
|
||||
else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel];
|
||||
flags |= PF_Modulated;
|
||||
HWD.pfnDrawPolygon(&Surf, v, 4, flags);
|
||||
}
|
||||
@@ -368,7 +358,7 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal
|
||||
// if it's meant to cover the whole screen, black out the rest
|
||||
// cx and cy are possibly *slightly* off from float maths
|
||||
// This is done before here compared to software because we directly alter cx and cy to centre
|
||||
/*if (cx >= -0.1f && cx <= 0.1f && SHORT(gpatch->width) == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && SHORT(gpatch->height) == BASEVIDHEIGHT)
|
||||
if (cx >= -0.1f && cx <= 0.1f && SHORT(gpatch->width) == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && SHORT(gpatch->height) == BASEVIDHEIGHT)
|
||||
{
|
||||
// Need to temporarily cache the real patch to get the colour of the top left pixel
|
||||
patch_t *realpatch = W_CacheLumpNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC);
|
||||
@@ -376,7 +366,7 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal
|
||||
const UINT8 *source = (const UINT8 *)(column) + 3;
|
||||
HWR_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, (column->topdelta == 0xff ? 31 : source[0]));
|
||||
Z_Free(realpatch);
|
||||
}*/
|
||||
}
|
||||
// centre screen
|
||||
if (fabsf((float)vid.width - (float)BASEVIDWIDTH * dupx) > 1.0E-36f)
|
||||
{
|
||||
@@ -440,12 +430,12 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal
|
||||
|
||||
v[0].z = v[1].z = v[2].z = v[3].z = 1.0f;
|
||||
|
||||
v[0].sow = v[3].sow = ((sx)/(float)SHORT(gpatch->width) )*gpatch->max_s;
|
||||
v[2].sow = v[1].sow = ((w )/(float)SHORT(gpatch->width) )*gpatch->max_s;
|
||||
v[0].tow = v[1].tow = ((sy)/(float)SHORT(gpatch->height))*gpatch->max_t;
|
||||
v[2].tow = v[3].tow = ((h )/(float)SHORT(gpatch->height))*gpatch->max_t;
|
||||
v[0].s = v[3].s = ((sx)/(float)SHORT(gpatch->width) )*gpatch->max_s;
|
||||
v[2].s = v[1].s = ((w )/(float)SHORT(gpatch->width) )*gpatch->max_s;
|
||||
v[0].t = v[1].t = ((sy)/(float)SHORT(gpatch->height))*gpatch->max_t;
|
||||
v[2].t = v[3].t = ((h )/(float)SHORT(gpatch->height))*gpatch->max_t;
|
||||
|
||||
flags = BLENDMODE|PF_Clip|PF_NoZClip|PF_NoDepthTest;
|
||||
flags = PF_Translucent|PF_NoDepthTest;
|
||||
|
||||
if (option & V_WRAPX)
|
||||
flags |= PF_ForceWrapX;
|
||||
@@ -456,11 +446,11 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal
|
||||
if (alphalevel)
|
||||
{
|
||||
FSurfaceInfo Surf;
|
||||
Surf.FlatColor.s.red = Surf.FlatColor.s.green = Surf.FlatColor.s.blue = 0xff;
|
||||
if (alphalevel == 13) Surf.FlatColor.s.alpha = softwaretranstogl_lo[hudtrans];
|
||||
else if (alphalevel == 14) Surf.FlatColor.s.alpha = softwaretranstogl[hudtrans];
|
||||
else if (alphalevel == 15) Surf.FlatColor.s.alpha = softwaretranstogl_hi[hudtrans];
|
||||
else Surf.FlatColor.s.alpha = softwaretranstogl[10-alphalevel];
|
||||
Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff;
|
||||
if (alphalevel == 13) Surf.PolyColor.s.alpha = softwaretranstogl_lo[cv_translucenthud.value];
|
||||
else if (alphalevel == 14) Surf.PolyColor.s.alpha = softwaretranstogl[cv_translucenthud.value];
|
||||
else if (alphalevel == 15) Surf.PolyColor.s.alpha = softwaretranstogl_hi[cv_translucenthud.value];
|
||||
else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel];
|
||||
flags |= PF_Modulated;
|
||||
HWD.pfnDrawPolygon(&Surf, v, 4, flags);
|
||||
}
|
||||
@@ -468,41 +458,6 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal
|
||||
HWD.pfnDrawPolygon(NULL, v, 4, flags);
|
||||
}
|
||||
|
||||
void HWR_DrawPic(INT32 x, INT32 y, lumpnum_t lumpnum)
|
||||
{
|
||||
FOutVector v[4];
|
||||
const GLPatch_t *patch;
|
||||
|
||||
// make pic ready in hardware cache
|
||||
patch = HWR_GetPic(lumpnum);
|
||||
|
||||
// 3--2
|
||||
// | /|
|
||||
// |/ |
|
||||
// 0--1
|
||||
|
||||
v[0].x = v[3].x = 2.0f * (float)x/vid.width - 1;
|
||||
v[2].x = v[1].x = 2.0f * (float)(x + patch->width*FIXED_TO_FLOAT(vid.fdupx))/vid.width - 1;
|
||||
v[0].y = v[1].y = 1.0f - 2.0f * (float)y/vid.height;
|
||||
v[2].y = v[3].y = 1.0f - 2.0f * (float)(y + patch->height*FIXED_TO_FLOAT(vid.fdupy))/vid.height;
|
||||
|
||||
v[0].z = v[1].z = v[2].z = v[3].z = 1.0f;
|
||||
|
||||
v[0].sow = v[3].sow = 0;
|
||||
v[2].sow = v[1].sow = patch->max_s;
|
||||
v[0].tow = v[1].tow = 0;
|
||||
v[2].tow = v[3].tow = patch->max_t;
|
||||
|
||||
|
||||
//Hurdler: Boris, the same comment as above... but maybe for pics
|
||||
// it not a problem since they don't have any transparent pixel
|
||||
// if I'm right !?
|
||||
// But then, the question is: why not 0 instead of PF_Masked ?
|
||||
// or maybe PF_Environment ??? (like what I said above)
|
||||
// BP: PF_Environment don't change anything ! and 0 is undifined
|
||||
HWD.pfnDrawPolygon(NULL, v, 4, BLENDMODE | PF_NoDepthTest | PF_Clip | PF_NoZClip);
|
||||
}
|
||||
|
||||
// ==========================================================================
|
||||
// V_VIDEO.C STUFF
|
||||
// ==========================================================================
|
||||
@@ -563,12 +518,12 @@ void HWR_DrawFlatFill (INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum
|
||||
v[0].z = v[1].z = v[2].z = v[3].z = 1.0f;
|
||||
|
||||
// flat is 64x64 lod and texture offsets are [0.0, 1.0]
|
||||
v[0].sow = v[3].sow = (float)((x & flatflag)/dflatsize);
|
||||
v[2].sow = v[1].sow = (float)(v[0].sow + w/dflatsize);
|
||||
v[0].tow = v[1].tow = (float)((y & flatflag)/dflatsize);
|
||||
v[2].tow = v[3].tow = (float)(v[0].tow + h/dflatsize);
|
||||
v[0].s = v[3].s = (float)((x & flatflag)/dflatsize);
|
||||
v[2].s = v[1].s = (float)(v[0].s + w/dflatsize);
|
||||
v[0].t = v[1].t = (float)((y & flatflag)/dflatsize);
|
||||
v[2].t = v[3].t = (float)(v[0].t + h/dflatsize);
|
||||
|
||||
HWR_GetFlat(flatlumpnum);
|
||||
HWR_GetFlat(flatlumpnum, false); // Never Encore map drawflatfill, duh.
|
||||
|
||||
//Hurdler: Boris, the same comment as above... but maybe for pics
|
||||
// it not a problem since they don't have any transparent pixel
|
||||
@@ -598,20 +553,20 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength)
|
||||
v[2].y = v[3].y = 1.0f;
|
||||
v[0].z = v[1].z = v[2].z = v[3].z = 1.0f;
|
||||
|
||||
v[0].sow = v[3].sow = 0.0f;
|
||||
v[2].sow = v[1].sow = 1.0f;
|
||||
v[0].tow = v[1].tow = 1.0f;
|
||||
v[2].tow = v[3].tow = 0.0f;
|
||||
v[0].s = v[3].s = 0.0f;
|
||||
v[2].s = v[1].s = 1.0f;
|
||||
v[0].t = v[1].t = 1.0f;
|
||||
v[2].t = v[3].t = 0.0f;
|
||||
|
||||
if (color & 0xFF00) // Do COLORMAP fade.
|
||||
{
|
||||
Surf.FlatColor.rgba = UINT2RGBA(0x01010160);
|
||||
Surf.FlatColor.s.alpha = (strength*8);
|
||||
Surf.PolyColor.rgba = UINT2RGBA(0x01010160);
|
||||
Surf.PolyColor.s.alpha = (strength*8);
|
||||
}
|
||||
else // Do TRANSMAP** fade.
|
||||
{
|
||||
Surf.FlatColor.rgba = pLocalPalette[color].rgba;
|
||||
Surf.FlatColor.s.alpha = (UINT8)(strength*25.5f);
|
||||
Surf.PolyColor.rgba = pLocalPalette[color].rgba;
|
||||
Surf.PolyColor.s.alpha = (UINT8)(strength*25.5f);
|
||||
}
|
||||
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);
|
||||
}
|
||||
@@ -632,13 +587,13 @@ void HWR_DrawConsoleBack(UINT32 color, INT32 height)
|
||||
v[2].y = v[3].y = 1.0f;
|
||||
v[0].z = v[1].z = v[2].z = v[3].z = 1.0f;
|
||||
|
||||
v[0].sow = v[3].sow = 0.0f;
|
||||
v[2].sow = v[1].sow = 1.0f;
|
||||
v[0].tow = v[1].tow = 1.0f;
|
||||
v[2].tow = v[3].tow = 0.0f;
|
||||
v[0].s = v[3].s = 0.0f;
|
||||
v[2].s = v[1].s = 1.0f;
|
||||
v[0].t = v[1].t = 1.0f;
|
||||
v[2].t = v[3].t = 0.0f;
|
||||
|
||||
Surf.FlatColor.rgba = UINT2RGBA(color);
|
||||
Surf.FlatColor.s.alpha = 0x80;
|
||||
Surf.PolyColor.rgba = UINT2RGBA(color);
|
||||
Surf.PolyColor.s.alpha = 0x80;
|
||||
|
||||
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);
|
||||
}
|
||||
@@ -773,6 +728,7 @@ void HWR_DrawViewBorder(INT32 clearlines)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ==========================================================================
|
||||
// AM_MAP.C DRAWING STUFF
|
||||
// ==========================================================================
|
||||
@@ -797,225 +753,6 @@ void HWR_drawAMline(const fline_t *fl, INT32 color)
|
||||
HWD.pfnDraw2DLine(&v1, &v2, color_rgba);
|
||||
}
|
||||
|
||||
// -----------------+
|
||||
// HWR_DrawFill : draw flat coloured rectangle, with no texture
|
||||
// -----------------+
|
||||
void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
|
||||
{
|
||||
FOutVector v[4];
|
||||
FSurfaceInfo Surf;
|
||||
float fx, fy, fw, fh;
|
||||
|
||||
if (w < 0 || h < 0)
|
||||
return; // consistency w/ software
|
||||
|
||||
// 3--2
|
||||
// | /|
|
||||
// |/ |
|
||||
// 0--1
|
||||
|
||||
fx = (float)x;
|
||||
fy = (float)y;
|
||||
fw = (float)w;
|
||||
fh = (float)h;
|
||||
|
||||
if (!(color & V_NOSCALESTART))
|
||||
{
|
||||
float dupx = (float)vid.dupx, dupy = (float)vid.dupy;
|
||||
|
||||
if (x == 0 && y == 0 && w == BASEVIDWIDTH && h == BASEVIDHEIGHT)
|
||||
{
|
||||
RGBA_t rgbaColour = V_GetColor(color);
|
||||
FRGBAFloat clearColour;
|
||||
clearColour.red = (float)rgbaColour.s.red / 255;
|
||||
clearColour.green = (float)rgbaColour.s.green / 255;
|
||||
clearColour.blue = (float)rgbaColour.s.blue / 255;
|
||||
clearColour.alpha = 1;
|
||||
HWD.pfnClearBuffer(true, false, &clearColour);
|
||||
return;
|
||||
}
|
||||
|
||||
fx *= dupx;
|
||||
fy *= dupy;
|
||||
fw *= dupx;
|
||||
fh *= dupy;
|
||||
|
||||
if (fabsf((float)vid.width - (float)BASEVIDWIDTH * dupx) > 1.0E-36f)
|
||||
{
|
||||
if (color & V_SNAPTORIGHT)
|
||||
fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx));
|
||||
else if (!(color & V_SNAPTOLEFT))
|
||||
fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)) / 2;
|
||||
}
|
||||
if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * dupy) > 1.0E-36f)
|
||||
{
|
||||
// same thing here
|
||||
if (color & V_SNAPTOBOTTOM)
|
||||
fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy));
|
||||
else if (!(color & V_SNAPTOTOP))
|
||||
fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) / 2;
|
||||
}
|
||||
if (color & V_SPLITSCREEN)
|
||||
fy += ((float)BASEVIDHEIGHT * dupy)/2;
|
||||
if (color & V_HORZSCREEN)
|
||||
fx += ((float)BASEVIDWIDTH * dupx)/2;
|
||||
}
|
||||
|
||||
if (fx >= vid.width || fy >= vid.height)
|
||||
return;
|
||||
if (fx < 0)
|
||||
{
|
||||
fw += fx;
|
||||
fx = 0;
|
||||
}
|
||||
if (fy < 0)
|
||||
{
|
||||
fh += fy;
|
||||
fy = 0;
|
||||
}
|
||||
|
||||
if (fw <= 0 || fh <= 0)
|
||||
return;
|
||||
if (fx + fw > vid.width)
|
||||
fw = (float)vid.width - fx;
|
||||
if (fy + fh > vid.height)
|
||||
fh = (float)vid.height - fy;
|
||||
|
||||
fx = -1 + fx / (vid.width / 2);
|
||||
fy = 1 - fy / (vid.height / 2);
|
||||
fw = fw / (vid.width / 2);
|
||||
fh = fh / (vid.height / 2);
|
||||
|
||||
v[0].x = v[3].x = fx;
|
||||
v[2].x = v[1].x = fx + fw;
|
||||
v[0].y = v[1].y = fy;
|
||||
v[2].y = v[3].y = fy - fh;
|
||||
|
||||
//Hurdler: do we still use this argb color? if not, we should remove it
|
||||
v[0].argb = v[1].argb = v[2].argb = v[3].argb = 0xff00ff00; //;
|
||||
v[0].z = v[1].z = v[2].z = v[3].z = 1.0f;
|
||||
|
||||
v[0].sow = v[3].sow = 0.0f;
|
||||
v[2].sow = v[1].sow = 1.0f;
|
||||
v[0].tow = v[1].tow = 0.0f;
|
||||
v[2].tow = v[3].tow = 1.0f;
|
||||
|
||||
Surf.FlatColor = V_GetColor(color);
|
||||
|
||||
HWD.pfnDrawPolygon(&Surf, v, 4,
|
||||
PF_Modulated|PF_NoTexture|PF_NoDepthTest);
|
||||
}
|
||||
|
||||
|
||||
// -------------------+
|
||||
// HWR_DrawConsoleFill : draw flat coloured transparent rectangle because that's cool, and hw sucks less than sw for that.
|
||||
// -------------------+
|
||||
void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 options)
|
||||
{
|
||||
FOutVector v[4];
|
||||
FSurfaceInfo Surf;
|
||||
float fx, fy, fw, fh;
|
||||
|
||||
if (w < 0 || h < 0)
|
||||
return; // consistency w/ software
|
||||
|
||||
// 3--2
|
||||
// | /|
|
||||
// |/ |
|
||||
// 0--1
|
||||
|
||||
fx = (float)x;
|
||||
fy = (float)y;
|
||||
fw = (float)w;
|
||||
fh = (float)h;
|
||||
|
||||
if (!(options & V_NOSCALESTART))
|
||||
{
|
||||
float dupx = (float)vid.dupx, dupy = (float)vid.dupy;
|
||||
|
||||
if (x == 0 && y == 0 && w == BASEVIDWIDTH && h == BASEVIDHEIGHT)
|
||||
{
|
||||
RGBA_t rgbaColour = V_GetColor(color);
|
||||
FRGBAFloat clearColour;
|
||||
clearColour.red = (float)rgbaColour.s.red / 255;
|
||||
clearColour.green = (float)rgbaColour.s.green / 255;
|
||||
clearColour.blue = (float)rgbaColour.s.blue / 255;
|
||||
clearColour.alpha = 1;
|
||||
HWD.pfnClearBuffer(true, false, &clearColour);
|
||||
return;
|
||||
}
|
||||
|
||||
fx *= dupx;
|
||||
fy *= dupy;
|
||||
fw *= dupx;
|
||||
fh *= dupy;
|
||||
|
||||
if (fabsf((float)vid.width - ((float)BASEVIDWIDTH * dupx)) > 1.0E-36f)
|
||||
{
|
||||
if (options & V_SNAPTORIGHT)
|
||||
fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx));
|
||||
else if (!(options & V_SNAPTOLEFT))
|
||||
fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)) / 2;
|
||||
}
|
||||
if (fabsf((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) > 1.0E-36f)
|
||||
{
|
||||
// same thing here
|
||||
if (options & V_SNAPTOBOTTOM)
|
||||
fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy));
|
||||
else if (!(options & V_SNAPTOTOP))
|
||||
fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) / 2;
|
||||
}
|
||||
if (options & V_SPLITSCREEN)
|
||||
fy += ((float)BASEVIDHEIGHT * dupy)/2;
|
||||
if (options & V_HORZSCREEN)
|
||||
fx += ((float)BASEVIDWIDTH * dupx)/2;
|
||||
}
|
||||
|
||||
if (fx >= vid.width || fy >= vid.height)
|
||||
return;
|
||||
if (fx < 0)
|
||||
{
|
||||
fw += fx;
|
||||
fx = 0;
|
||||
}
|
||||
if (fy < 0)
|
||||
{
|
||||
fh += fy;
|
||||
fy = 0;
|
||||
}
|
||||
|
||||
if (fw <= 0 || fh <= 0)
|
||||
return;
|
||||
if (fx + fw > vid.width)
|
||||
fw = (float)vid.width - fx;
|
||||
if (fy + fh > vid.height)
|
||||
fh = (float)vid.height - fy;
|
||||
|
||||
fx = -1 + fx / (vid.width / 2);
|
||||
fy = 1 - fy / (vid.height / 2);
|
||||
fw = fw / (vid.width / 2);
|
||||
fh = fh / (vid.height / 2);
|
||||
|
||||
v[0].x = v[3].x = fx;
|
||||
v[2].x = v[1].x = fx + fw;
|
||||
v[0].y = v[1].y = fy;
|
||||
v[2].y = v[3].y = fy - fh;
|
||||
|
||||
//Hurdler: do we still use this argb color? if not, we should remove it
|
||||
v[0].argb = v[1].argb = v[2].argb = v[3].argb = 0xff00ff00; //;
|
||||
v[0].z = v[1].z = v[2].z = v[3].z = 1.0f;
|
||||
|
||||
v[0].sow = v[3].sow = 0.0f;
|
||||
v[2].sow = v[1].sow = 1.0f;
|
||||
v[0].tow = v[1].tow = 0.0f;
|
||||
v[2].tow = v[3].tow = 1.0f;
|
||||
|
||||
Surf.FlatColor.rgba = UINT2RGBA(color);
|
||||
Surf.FlatColor.s.alpha = 0x80;
|
||||
|
||||
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);
|
||||
}
|
||||
|
||||
// -----------------+
|
||||
// HWR_DrawDiag : draw flat coloured rectangle, with no texture
|
||||
// -----------------+
|
||||
@@ -1097,22 +834,234 @@ void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color)
|
||||
v[3].y = fy - fh;
|
||||
v[2].y = fy - fwait;
|
||||
|
||||
//Hurdler: do we still use this argb color? if not, we should remove it
|
||||
v[0].argb = v[1].argb = v[2].argb = v[3].argb = 0xff00ff00; //;
|
||||
v[0].z = v[1].z = v[2].z = v[3].z = 1.0f;
|
||||
|
||||
v[0].sow = v[3].sow = 0.0f;
|
||||
v[2].sow = v[1].sow = 1.0f;
|
||||
v[0].tow = v[1].tow = 0.0f;
|
||||
v[2].tow = v[3].tow = 1.0f;
|
||||
v[0].s = v[3].s = 0.0f;
|
||||
v[2].s = v[1].s = 1.0f;
|
||||
v[0].t = v[1].t = 0.0f;
|
||||
v[2].t = v[3].t = 1.0f;
|
||||
|
||||
Surf.FlatColor = V_GetColor(color);
|
||||
Surf.PolyColor = V_GetColor(color);
|
||||
|
||||
HWD.pfnDrawPolygon(&Surf, v, 4,
|
||||
PF_Modulated|PF_NoTexture|PF_NoDepthTest);
|
||||
}
|
||||
|
||||
// -------------------+
|
||||
// HWR_DrawConsoleFill : draw flat coloured transparent rectangle because that's cool, and hw sucks less than sw for that.
|
||||
// -------------------+
|
||||
void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 options)
|
||||
{
|
||||
FOutVector v[4];
|
||||
FSurfaceInfo Surf;
|
||||
float fx, fy, fw, fh;
|
||||
|
||||
if (w < 0 || h < 0)
|
||||
return; // consistency w/ software
|
||||
|
||||
// 3--2
|
||||
// | /|
|
||||
// |/ |
|
||||
// 0--1
|
||||
|
||||
fx = (float)x;
|
||||
fy = (float)y;
|
||||
fw = (float)w;
|
||||
fh = (float)h;
|
||||
|
||||
if (!(options & V_NOSCALESTART))
|
||||
{
|
||||
float dupx = (float)vid.dupx, dupy = (float)vid.dupy;
|
||||
|
||||
if (x == 0 && y == 0 && w == BASEVIDWIDTH && h == BASEVIDHEIGHT)
|
||||
{
|
||||
RGBA_t rgbaColour = V_GetColor(color);
|
||||
FRGBAFloat clearColour;
|
||||
clearColour.red = (float)rgbaColour.s.red / 255;
|
||||
clearColour.green = (float)rgbaColour.s.green / 255;
|
||||
clearColour.blue = (float)rgbaColour.s.blue / 255;
|
||||
clearColour.alpha = 1;
|
||||
HWD.pfnClearBuffer(true, false, &clearColour);
|
||||
return;
|
||||
}
|
||||
|
||||
fx *= dupx;
|
||||
fy *= dupy;
|
||||
fw *= dupx;
|
||||
fh *= dupy;
|
||||
|
||||
if (fabsf((float)vid.width - ((float)BASEVIDWIDTH * dupx)) > 1.0E-36f)
|
||||
{
|
||||
if (options & V_SNAPTORIGHT)
|
||||
fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx));
|
||||
else if (!(options & V_SNAPTOLEFT))
|
||||
fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)) / 2;
|
||||
}
|
||||
if (fabsf((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) > 1.0E-36f)
|
||||
{
|
||||
// same thing here
|
||||
if (options & V_SNAPTOBOTTOM)
|
||||
fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy));
|
||||
else if (!(options & V_SNAPTOTOP))
|
||||
fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) / 2;
|
||||
}
|
||||
if (options & V_SPLITSCREEN)
|
||||
fy += ((float)BASEVIDHEIGHT * dupy)/2;
|
||||
if (options & V_HORZSCREEN)
|
||||
fx += ((float)BASEVIDWIDTH * dupx)/2;
|
||||
|
||||
}
|
||||
|
||||
if (fx >= vid.width || fy >= vid.height)
|
||||
return;
|
||||
if (fx < 0)
|
||||
{
|
||||
fw += fx;
|
||||
fx = 0;
|
||||
}
|
||||
if (fy < 0)
|
||||
{
|
||||
fh += fy;
|
||||
fy = 0;
|
||||
}
|
||||
|
||||
if (fw <= 0 || fh <= 0)
|
||||
return;
|
||||
if (fx + fw > vid.width)
|
||||
fw = (float)vid.width - fx;
|
||||
if (fy + fh > vid.height)
|
||||
fh = (float)vid.height - fy;
|
||||
|
||||
fx = -1 + fx / (vid.width / 2);
|
||||
fy = 1 - fy / (vid.height / 2);
|
||||
fw = fw / (vid.width / 2);
|
||||
fh = fh / (vid.height / 2);
|
||||
|
||||
v[0].x = v[3].x = fx;
|
||||
v[2].x = v[1].x = fx + fw;
|
||||
v[0].y = v[1].y = fy;
|
||||
v[2].y = v[3].y = fy - fh;
|
||||
|
||||
v[0].z = v[1].z = v[2].z = v[3].z = 1.0f;
|
||||
|
||||
v[0].s = v[3].s = 0.0f;
|
||||
v[2].s = v[1].s = 1.0f;
|
||||
v[0].t = v[1].t = 0.0f;
|
||||
v[2].t = v[3].t = 1.0f;
|
||||
|
||||
Surf.PolyColor.rgba = UINT2RGBA(color);
|
||||
Surf.PolyColor.s.alpha = 0x80;
|
||||
|
||||
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);
|
||||
}
|
||||
|
||||
// -----------------+
|
||||
// HWR_DrawFill : draw flat coloured rectangle, with no texture
|
||||
// -----------------+
|
||||
void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
|
||||
{
|
||||
FOutVector v[4];
|
||||
FSurfaceInfo Surf;
|
||||
float fx, fy, fw, fh;
|
||||
|
||||
if (w < 0 || h < 0)
|
||||
return; // consistency w/ software
|
||||
|
||||
// 3--2
|
||||
// | /|
|
||||
// |/ |
|
||||
// 0--1
|
||||
|
||||
fx = (float)x;
|
||||
fy = (float)y;
|
||||
fw = (float)w;
|
||||
fh = (float)h;
|
||||
|
||||
if (!(color & V_NOSCALESTART))
|
||||
{
|
||||
float dupx = (float)vid.dupx, dupy = (float)vid.dupy;
|
||||
|
||||
if (x == 0 && y == 0 && w == BASEVIDWIDTH && h == BASEVIDHEIGHT)
|
||||
{
|
||||
RGBA_t rgbaColour = V_GetColor(color);
|
||||
FRGBAFloat clearColour;
|
||||
clearColour.red = (float)rgbaColour.s.red / 255;
|
||||
clearColour.green = (float)rgbaColour.s.green / 255;
|
||||
clearColour.blue = (float)rgbaColour.s.blue / 255;
|
||||
clearColour.alpha = 1;
|
||||
HWD.pfnClearBuffer(true, false, &clearColour);
|
||||
return;
|
||||
}
|
||||
|
||||
fx *= dupx;
|
||||
fy *= dupy;
|
||||
fw *= dupx;
|
||||
fh *= dupy;
|
||||
|
||||
if (fabsf((float)vid.width - (float)BASEVIDWIDTH * dupx) > 1.0E-36f)
|
||||
{
|
||||
if (color & V_SNAPTORIGHT)
|
||||
fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx));
|
||||
else if (!(color & V_SNAPTOLEFT))
|
||||
fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)) / 2;
|
||||
}
|
||||
if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * dupy) > 1.0E-36f)
|
||||
{
|
||||
// same thing here
|
||||
if (color & V_SNAPTOBOTTOM)
|
||||
fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy));
|
||||
else if (!(color & V_SNAPTOTOP))
|
||||
fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) / 2;
|
||||
}
|
||||
if (color & V_SPLITSCREEN)
|
||||
fy += ((float)BASEVIDHEIGHT * dupy)/2;
|
||||
if (color & V_HORZSCREEN)
|
||||
fx += ((float)BASEVIDWIDTH * dupx)/2;
|
||||
|
||||
}
|
||||
|
||||
if (fx >= vid.width || fy >= vid.height)
|
||||
return;
|
||||
if (fx < 0)
|
||||
{
|
||||
fw += fx;
|
||||
fx = 0;
|
||||
}
|
||||
if (fy < 0)
|
||||
{
|
||||
fh += fy;
|
||||
fy = 0;
|
||||
}
|
||||
|
||||
if (fw <= 0 || fh <= 0)
|
||||
return;
|
||||
if (fx + fw > vid.width)
|
||||
fw = (float)vid.width - fx;
|
||||
if (fy + fh > vid.height)
|
||||
fh = (float)vid.height - fy;
|
||||
|
||||
fx = -1 + fx / (vid.width / 2);
|
||||
fy = 1 - fy / (vid.height / 2);
|
||||
fw = fw / (vid.width / 2);
|
||||
fh = fh / (vid.height / 2);
|
||||
|
||||
v[0].x = v[3].x = fx;
|
||||
v[2].x = v[1].x = fx + fw;
|
||||
v[0].y = v[1].y = fy;
|
||||
v[2].y = v[3].y = fy - fh;
|
||||
|
||||
v[0].z = v[1].z = v[2].z = v[3].z = 1.0f;
|
||||
|
||||
v[0].s = v[3].s = 0.0f;
|
||||
v[2].s = v[1].s = 1.0f;
|
||||
v[0].t = v[1].t = 0.0f;
|
||||
v[2].t = v[3].t = 1.0f;
|
||||
|
||||
Surf.PolyColor = V_GetColor(color);
|
||||
|
||||
HWD.pfnDrawPolygon(&Surf, v, 4,
|
||||
PF_Modulated|PF_NoTexture|PF_NoDepthTest);
|
||||
}
|
||||
|
||||
#ifdef HAVE_PNG
|
||||
|
||||
@@ -1196,21 +1145,24 @@ UINT8 *HWR_GetScreenshot(void)
|
||||
return buf;
|
||||
}
|
||||
|
||||
boolean HWR_Screenshot(const char *lbmname)
|
||||
boolean HWR_Screenshot(const char *pathname)
|
||||
{
|
||||
boolean ret;
|
||||
UINT8 *buf = malloc(vid.width * vid.height * 3 * sizeof (*buf));
|
||||
|
||||
if (!buf)
|
||||
{
|
||||
CONS_Debug(DBG_RENDER, "HWR_Screenshot: Failed to allocate memory\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
// returns 24bit 888 RGB
|
||||
HWD.pfnReadRect(0, 0, vid.width, vid.height, vid.width * 3, (void *)buf);
|
||||
|
||||
#ifdef USE_PNG
|
||||
ret = M_SavePNG(lbmname, buf, vid.width, vid.height, NULL);
|
||||
ret = M_SavePNG(pathname, buf, vid.width, vid.height, NULL);
|
||||
#else
|
||||
ret = saveTGA(lbmname, buf, vid.width, vid.height);
|
||||
ret = saveTGA(pathname, buf, vid.width, vid.height);
|
||||
#endif
|
||||
free(buf);
|
||||
return ret;
|
||||
|
||||
+43
-38
@@ -1,21 +1,15 @@
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2019 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file
|
||||
/// \brief imports/exports for the 3D hardware low-level interface API
|
||||
/// \brief imports/exports for the GPU hardware low-level interface API
|
||||
|
||||
#ifndef __HWR_DRV_H__
|
||||
#define __HWR_DRV_H__
|
||||
@@ -32,13 +26,7 @@
|
||||
// STANDARD DLL EXPORTS
|
||||
// ==========================================================================
|
||||
|
||||
EXPORT boolean HWRAPI(Init) (I_Error_t ErrorFunction);
|
||||
#ifndef HAVE_SDL
|
||||
EXPORT void HWRAPI(Shutdown) (void);
|
||||
#endif
|
||||
#ifdef _WINDOWS
|
||||
EXPORT void HWRAPI(GetModeList) (vmode_t **pvidmodes, INT32 *numvidmodes);
|
||||
#endif
|
||||
EXPORT boolean HWRAPI(Init) (void);
|
||||
#if defined (PURESDL) || defined (macintosh)
|
||||
EXPORT void HWRAPI(SetPalette) (INT32 *, RGBA_t *gamma);
|
||||
#else
|
||||
@@ -58,14 +46,13 @@ EXPORT void HWRAPI(ClearMipMapCache) (void);
|
||||
EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value);
|
||||
|
||||
//Hurdler: added for new development
|
||||
EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex, FTransform *pos, float scale, UINT8 flipped, UINT8 *color);
|
||||
EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex, FTransform *pos, float scale, UINT8 flipped, FSurfaceInfo *Surface);
|
||||
EXPORT void HWRAPI(CreateModelVBOs) (model_t *model);
|
||||
EXPORT void HWRAPI(SetTransform) (FTransform *ptransform);
|
||||
EXPORT void HWRAPI(SetTransform) (FTransform *stransform);
|
||||
EXPORT INT32 HWRAPI(GetTextureUsed) (void);
|
||||
EXPORT INT32 HWRAPI(GetRenderVersion) (void);
|
||||
|
||||
#define SCREENVERTS 10
|
||||
EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2]);
|
||||
EXPORT void HWRAPI(RenderSkyDome) (INT32 tex, INT32 texture_width, INT32 texture_height, FTransform transform);
|
||||
|
||||
EXPORT void HWRAPI(FlushScreenTextures) (void);
|
||||
EXPORT void HWRAPI(StartScreenWipe) (void);
|
||||
EXPORT void HWRAPI(EndScreenWipe) (void);
|
||||
@@ -74,6 +61,22 @@ EXPORT void HWRAPI(DrawIntermissionBG) (void);
|
||||
EXPORT void HWRAPI(MakeScreenTexture) (void);
|
||||
EXPORT void HWRAPI(MakeScreenFinalTexture) (void);
|
||||
EXPORT void HWRAPI(DrawScreenFinalTexture) (int width, int height);
|
||||
|
||||
#define SCREENVERTS 10
|
||||
EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2]);
|
||||
|
||||
// jimita
|
||||
EXPORT boolean HWRAPI(LoadShaders) (void);
|
||||
EXPORT void HWRAPI(KillShaders) (void);
|
||||
EXPORT void HWRAPI(SetShader) (int shader);
|
||||
EXPORT void HWRAPI(UnSetShader) (void);
|
||||
|
||||
EXPORT void HWRAPI(LoadCustomShader) (int number, char *shader, size_t size, boolean fragment);
|
||||
EXPORT void HWRAPI(InitCustomShaders) (void);
|
||||
|
||||
EXPORT void HWRAPI(StartBatching) (void);
|
||||
EXPORT void HWRAPI(RenderBatches) (int *sNumPolys, int *sNumVerts, int *sNumCalls, int *sNumShaders, int *sNumTextures, int *sNumPolyFlags, int *sNumColors);
|
||||
|
||||
// ==========================================================================
|
||||
// HWR DRIVER OBJECT, FOR CLIENT PROGRAM
|
||||
// ==========================================================================
|
||||
@@ -93,18 +96,11 @@ struct hwdriver_s
|
||||
ReadRect pfnReadRect;
|
||||
GClipRect pfnGClipRect;
|
||||
ClearMipMapCache pfnClearMipMapCache;
|
||||
SetSpecialState pfnSetSpecialState;//Hurdler: added for backward compatibility
|
||||
SetSpecialState pfnSetSpecialState;
|
||||
DrawModel pfnDrawModel;
|
||||
CreateModelVBOs pfnCreateModelVBOs;
|
||||
SetTransform pfnSetTransform;
|
||||
GetTextureUsed pfnGetTextureUsed;
|
||||
GetRenderVersion pfnGetRenderVersion;
|
||||
#ifdef _WINDOWS
|
||||
GetModeList pfnGetModeList;
|
||||
#endif
|
||||
#ifndef HAVE_SDL
|
||||
Shutdown pfnShutdown;
|
||||
#endif
|
||||
PostImgRedraw pfnPostImgRedraw;
|
||||
FlushScreenTextures pfnFlushScreenTextures;
|
||||
StartScreenWipe pfnStartScreenWipe;
|
||||
@@ -114,16 +110,25 @@ struct hwdriver_s
|
||||
MakeScreenTexture pfnMakeScreenTexture;
|
||||
MakeScreenFinalTexture pfnMakeScreenFinalTexture;
|
||||
DrawScreenFinalTexture pfnDrawScreenFinalTexture;
|
||||
|
||||
RenderSkyDome pfnRenderSkyDome;
|
||||
|
||||
LoadShaders pfnLoadShaders;
|
||||
KillShaders pfnKillShaders;
|
||||
SetShader pfnSetShader;
|
||||
UnSetShader pfnUnSetShader;
|
||||
|
||||
LoadCustomShader pfnLoadCustomShader;
|
||||
InitCustomShaders pfnInitCustomShaders;
|
||||
|
||||
StartBatching pfnStartBatching;
|
||||
RenderBatches pfnRenderBatches;
|
||||
};
|
||||
|
||||
extern struct hwdriver_s hwdriver;
|
||||
|
||||
//Hurdler: 16/10/99: added for OpenGL gamma correction
|
||||
//extern RGBA_t gamma_correction;
|
||||
|
||||
#define HWD hwdriver
|
||||
|
||||
#endif //not defined _CREATE_DLL_
|
||||
|
||||
#endif //__HWR_DRV_H__
|
||||
|
||||
#endif //__HWR_DRV_H__
|
||||
@@ -1,71 +0,0 @@
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file
|
||||
/// \brief Declaration needed by Glide renderer
|
||||
/// !!! To be replaced by our own def in the future !!!
|
||||
|
||||
#ifndef _GLIDE_H_
|
||||
#define _GLIDE_H_
|
||||
|
||||
#ifndef __GLIDE_H__
|
||||
|
||||
typedef unsigned long FxU32;
|
||||
typedef long FxI32;
|
||||
|
||||
typedef FxI32 GrAspectRatio_t;
|
||||
#define GR_ASPECT_LOG2_8x1 3 /* 8W x 1H */
|
||||
#define GR_ASPECT_LOG2_4x1 2 /* 4W x 1H */
|
||||
#define GR_ASPECT_LOG2_2x1 1 /* 2W x 1H */
|
||||
#define GR_ASPECT_LOG2_1x1 0 /* 1W x 1H */
|
||||
#define GR_ASPECT_LOG2_1x2 -1 /* 1W x 2H */
|
||||
#define GR_ASPECT_LOG2_1x4 -2 /* 1W x 4H */
|
||||
#define GR_ASPECT_LOG2_1x8 -3 /* 1W x 8H */
|
||||
|
||||
typedef FxI32 GrLOD_t;
|
||||
#define GR_LOD_LOG2_256 0x8
|
||||
#define GR_LOD_LOG2_128 0x7
|
||||
#define GR_LOD_LOG2_64 0x6
|
||||
#define GR_LOD_LOG2_32 0x5
|
||||
#define GR_LOD_LOG2_16 0x4
|
||||
#define GR_LOD_LOG2_8 0x3
|
||||
#define GR_LOD_LOG2_4 0x2
|
||||
#define GR_LOD_LOG2_2 0x1
|
||||
#define GR_LOD_LOG2_1 0x0
|
||||
|
||||
typedef FxI32 GrTextureFormat_t;
|
||||
#define GR_TEXFMT_ALPHA_8 0x2 /* (0..0xFF) alpha */
|
||||
#define GR_TEXFMT_INTENSITY_8 0x3 /* (0..0xFF) intensity */
|
||||
#define GR_TEXFMT_ALPHA_INTENSITY_44 0x4
|
||||
#define GR_TEXFMT_P_8 0x5 /* 8-bit palette */
|
||||
#define GR_TEXFMT_RGB_565 0xa
|
||||
#define GR_TEXFMT_ARGB_1555 0xb
|
||||
#define GR_TEXFMT_ARGB_4444 0xc
|
||||
#define GR_TEXFMT_ALPHA_INTENSITY_88 0xd
|
||||
#define GR_TEXFMT_AP_88 0xe /* 8-bit alpha 8-bit palette */
|
||||
#define GR_RGBA 0x6 // 32 bit RGBA !
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GrLOD_t smallLodLog2;
|
||||
GrLOD_t largeLodLog2;
|
||||
GrAspectRatio_t aspectRatioLog2;
|
||||
GrTextureFormat_t format;
|
||||
void *data;
|
||||
} GrTexInfo;
|
||||
|
||||
#endif // __GLIDE_H__ (defined in <glide.h>)
|
||||
|
||||
#endif // _GLIDE_H_
|
||||
+12
-80
@@ -1,18 +1,12 @@
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2019 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file
|
||||
/// \brief globals (shared data & code) for hw_ modules
|
||||
@@ -21,78 +15,18 @@
|
||||
#define _HWR_GLOB_H_
|
||||
|
||||
#include "hw_defs.h"
|
||||
#include "hw_main.h"
|
||||
#include "../m_misc.h"
|
||||
|
||||
// the original aspect ratio of Doom graphics isn't square
|
||||
#define ORIGINAL_ASPECT (320.0f/200.0f)
|
||||
#include "../r_defs.h"
|
||||
|
||||
// Uncomment this to enable the OpenGL loading screen
|
||||
//#define HWR_LOADING_SCREEN
|
||||
|
||||
// -----------
|
||||
// structures
|
||||
// -----------
|
||||
|
||||
// a vertex of a Doom 'plane' polygon
|
||||
typedef struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
} polyvertex_t;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4200)
|
||||
#endif
|
||||
|
||||
// a convex 'plane' polygon, clockwise order
|
||||
typedef struct
|
||||
{
|
||||
INT32 numpts;
|
||||
polyvertex_t pts[0];
|
||||
} poly_t;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(default : 4200)
|
||||
#endif
|
||||
|
||||
// holds extra info for 3D render, for each subsector in subsectors[]
|
||||
typedef struct
|
||||
{
|
||||
poly_t *planepoly; // the generated convex polygon
|
||||
} extrasubsector_t;
|
||||
|
||||
// needed for sprite rendering
|
||||
// equivalent of the software renderer's vissprites
|
||||
typedef struct gr_vissprite_s
|
||||
{
|
||||
// Doubly linked list
|
||||
struct gr_vissprite_s *prev;
|
||||
struct gr_vissprite_s *next;
|
||||
float x1, x2;
|
||||
float tz, ty;
|
||||
lumpnum_t patchlumpnum;
|
||||
boolean flip;
|
||||
UINT8 translucency; //alpha level 0-255
|
||||
mobj_t *mobj;
|
||||
boolean precip; // Tails 08-25-2002
|
||||
boolean vflip;
|
||||
//Hurdler: 25/04/2000: now support colormap in hardware mode
|
||||
UINT8 *colormap;
|
||||
INT32 dispoffset; // copy of info->dispoffset, affects ordering but not drawing
|
||||
float z1, z2;
|
||||
} gr_vissprite_t;
|
||||
|
||||
// --------
|
||||
// hw_bsp.c
|
||||
// --------
|
||||
extern extrasubsector_t *extrasubsectors;
|
||||
extern size_t addsubsector;
|
||||
|
||||
void HWR_InitPolyPool(void);
|
||||
void HWR_FreePolyPool(void);
|
||||
|
||||
// --------
|
||||
// hw_cache.c
|
||||
// --------
|
||||
@@ -100,12 +34,14 @@ void HWR_InitTextureCache(void);
|
||||
void HWR_FreeTextureCache(void);
|
||||
void HWR_FreeExtraSubsectors(void);
|
||||
|
||||
void HWR_GetFlat(lumpnum_t flatlumpnum);
|
||||
void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap);
|
||||
// ^ some flats must NOT be remapped to encore, since we remap them as we cache them for ease, adding a toggle here seems wise.
|
||||
|
||||
GLTexture_t *HWR_GetTexture(INT32 tex);
|
||||
void HWR_GetPatch(GLPatch_t *gpatch);
|
||||
void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap);
|
||||
void HWR_MakePatch(patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, boolean makebitmap);
|
||||
void HWR_UnlockCachedPatch(GLPatch_t *gpatch);
|
||||
GLPatch_t *HWR_GetPic(lumpnum_t lumpnum);
|
||||
void HWR_SetPalette(RGBA_t *palette);
|
||||
GLPatch_t *HWR_GetCachedGLPatchPwad(UINT16 wad, UINT16 lump);
|
||||
GLPatch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum);
|
||||
@@ -114,13 +50,9 @@ void HWR_GetFadeMask(lumpnum_t fademasklumpnum);
|
||||
// --------
|
||||
// hw_draw.c
|
||||
// --------
|
||||
extern float gr_patch_scalex;
|
||||
extern float gr_patch_scaley;
|
||||
|
||||
extern consvar_t cv_grrounddown; // on/off
|
||||
|
||||
extern INT32 patchformat;
|
||||
extern INT32 textureformat;
|
||||
extern boolean firetranslucent;
|
||||
|
||||
#endif //_HW_GLOB_
|
||||
#endif //_HW_GLOB_
|
||||
+6
-1355
File diff suppressed because it is too large.
Load diff
+6
-86
@@ -1,17 +1,12 @@
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2019 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file
|
||||
/// \brief Dynamic lighting & coronas add on by Hurdler
|
||||
@@ -22,79 +17,4 @@
|
||||
#include "hw_glob.h"
|
||||
#include "hw_defs.h"
|
||||
|
||||
#define NUMLIGHTFREESLOTS 32 // Free light slots (for SOCs)
|
||||
|
||||
#ifdef ALAM_LIGHTING
|
||||
#define NEWCORONAS
|
||||
|
||||
#define DL_MAX_LIGHT 256 // maximum number of lights (extra lights are ignored)
|
||||
|
||||
void HWR_InitLight(void);
|
||||
void HWR_DL_AddLight(gr_vissprite_t *spr, GLPatch_t *patch);
|
||||
void HWR_PlaneLighting(FOutVector *clVerts, int nrClipVerts);
|
||||
void HWR_WallLighting(FOutVector *wlVerts);
|
||||
void HWR_ResetLights(void);
|
||||
void HWR_SetLights(int viewnumber);
|
||||
|
||||
#ifdef NEWCORONAS
|
||||
void HWR_DrawCoronas(void);
|
||||
#else
|
||||
void HWR_DoCoronasLighting(FOutVector *outVerts, gr_vissprite_t *spr);
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int nb;
|
||||
light_t *p_lspr[DL_MAX_LIGHT];
|
||||
FVector position[DL_MAX_LIGHT]; // actually maximum DL_MAX_LIGHT lights
|
||||
mobj_t *mo[DL_MAX_LIGHT];
|
||||
} dynlights_t;
|
||||
|
||||
#endif
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NOLIGHT = 0,
|
||||
RINGSPARK_L,
|
||||
SUPERSONIC_L, // Cool. =)
|
||||
SUPERSPARK_L,
|
||||
INVINCIBLE_L,
|
||||
GREENSHIELD_L,
|
||||
BLUESHIELD_L,
|
||||
YELLOWSHIELD_L,
|
||||
REDSHIELD_L,
|
||||
BLACKSHIELD_L,
|
||||
WHITESHIELD_L,
|
||||
SMALLREDBALL_L,
|
||||
RINGLIGHT_L,
|
||||
GREENSMALL_L,
|
||||
REDSMALL_L,
|
||||
GREENSHINE_L,
|
||||
ORANGESHINE_L,
|
||||
PINKSHINE_L,
|
||||
BLUESHINE_L,
|
||||
REDSHINE_L,
|
||||
LBLUESHINE_L,
|
||||
GREYSHINE_L,
|
||||
REDBALL_L,
|
||||
GREENBALL_L,
|
||||
BLUEBALL_L,
|
||||
NIGHTSLIGHT_L,
|
||||
JETLIGHT_L,
|
||||
GOOPLIGHT_L,
|
||||
STREETLIGHT_L,
|
||||
|
||||
// free slots for SOCs at run-time --------------------
|
||||
FREESLOT0_L,
|
||||
//
|
||||
// ... 32 free lights here ...
|
||||
//
|
||||
LASTFREESLOT_L = (FREESLOT0_L+NUMLIGHTFREESLOTS-1),
|
||||
// end of freeslots ---------------------------------------------
|
||||
|
||||
NUMLIGHTS
|
||||
} lightspritenum_t;
|
||||
|
||||
extern light_t lspr[NUMLIGHTS];
|
||||
extern light_t *t_lspr[NUMSPRITES];
|
||||
#endif
|
||||
+952
-2832
File diff suppressed because it is too large.
Load diff
+88
-49
@@ -17,9 +17,12 @@
|
||||
/// \file
|
||||
/// \brief 3D render mode functions
|
||||
|
||||
#define GLENCORE
|
||||
|
||||
#ifndef __HWR_MAIN_H__
|
||||
#define __HWR_MAIN_H__
|
||||
|
||||
#include "hw_glob.h"
|
||||
#include "hw_data.h"
|
||||
#include "hw_defs.h"
|
||||
|
||||
@@ -27,38 +30,51 @@
|
||||
#include "../d_player.h"
|
||||
#include "../r_defs.h"
|
||||
|
||||
#define GLENCORE
|
||||
|
||||
// Startup & Shutdown the hardware mode renderer
|
||||
void HWR_Startup(void);
|
||||
void HWR_Shutdown(void);
|
||||
|
||||
void HWR_drawAMline(const fline_t *fl, INT32 color);
|
||||
void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength);
|
||||
void HWR_DrawConsoleBack(UINT32 color, INT32 height);
|
||||
void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player);
|
||||
void HWR_RenderPlayerView(INT32 viewnumber, player_t *player);
|
||||
void HWR_DrawViewBorder(INT32 clearlines);
|
||||
void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum);
|
||||
UINT8 *HWR_GetScreenshot(void);
|
||||
boolean HWR_Screenshot(const char *lbmname);
|
||||
void HWR_InitTextureMapping(void);
|
||||
void HWR_SetViewSize(void);
|
||||
extern float gr_viewwidth, gr_viewheight, gr_baseviewwindowx, gr_baseviewwindowy;
|
||||
|
||||
extern float gr_basewindowcenterx, gr_basewindowcentery;
|
||||
|
||||
extern FTransform atransform;
|
||||
|
||||
// hw_draw.c
|
||||
void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option);
|
||||
void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t scale, INT32 option, const UINT8 *colormap);
|
||||
void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t scale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h);
|
||||
void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, boolean makebitmap);
|
||||
void HWR_CreatePlanePolygons(INT32 bspnum);
|
||||
void HWR_CreateStaticLightmaps(INT32 bspnum);
|
||||
void HWR_PrepLevelCache(size_t pnumtextures);
|
||||
void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h);
|
||||
void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color);
|
||||
void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 options); // Lat: separate flags from color since color needs to be an uint to work right.
|
||||
void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color);
|
||||
void HWR_DrawPic(INT32 x,INT32 y,lumpnum_t lumpnum);
|
||||
void HWR_drawAMline(const fline_t *fl, INT32 color);
|
||||
void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength);
|
||||
void HWR_DrawConsoleBack(UINT32 color, INT32 height);
|
||||
void HWR_DrawViewBorder(INT32 clearlines);
|
||||
void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum);
|
||||
|
||||
UINT8 *HWR_GetScreenshot(void);
|
||||
boolean HWR_Screenshot(const char *lbmname);
|
||||
|
||||
// hw_main.c
|
||||
void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox);
|
||||
void HWR_RenderPlayerView(INT32 viewnumber, player_t *player);
|
||||
void HWR_LoadShaders(UINT16 wadnum, boolean PK3);
|
||||
void HWR_SetViewSize(void);
|
||||
void HWR_AddCommands(void);
|
||||
void HWR_CorrectSWTricks(void);
|
||||
void transform(float *cx, float *cy, float *cz);
|
||||
|
||||
// My original intention was to split hw_main.c
|
||||
// into files like hw_bsp.c, hw_sprites.c...
|
||||
|
||||
// hw_main.c: Lighting and fog
|
||||
void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap);
|
||||
UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap); // Let's see if this can work
|
||||
|
||||
FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf);
|
||||
INT32 HWR_GetTextureUsed(void);
|
||||
|
||||
// hw_main.c: Post-rendering
|
||||
void HWR_DoPostProcessor(player_t *player);
|
||||
void HWR_StartScreenWipe(void);
|
||||
void HWR_EndScreenWipe(void);
|
||||
@@ -67,24 +83,60 @@ void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum);
|
||||
void HWR_MakeScreenFinalTexture(void);
|
||||
void HWR_DrawScreenFinalTexture(int width, int height);
|
||||
|
||||
// This stuff is put here so MD2's can use them
|
||||
UINT32 HWR_Lighting(INT32 light, UINT32 color, UINT32 fadecolor, boolean fogblockpoly, boolean plane);
|
||||
FUNCMATH UINT8 LightLevelToLum(INT32 l);
|
||||
// hw_main.c: Planes
|
||||
void HWR_RenderPlane(extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap);
|
||||
void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap);
|
||||
|
||||
extern CV_PossibleValue_t granisotropicmode_cons_t[];
|
||||
|
||||
#ifdef ALAM_LIGHTING
|
||||
extern consvar_t cv_grdynamiclighting;
|
||||
extern consvar_t cv_grstaticlighting;
|
||||
extern consvar_t cv_grcoronas;
|
||||
extern consvar_t cv_grcoronasize;
|
||||
#ifdef POLYOBJECTS
|
||||
#ifdef POLYOBJECTS_PLANES
|
||||
void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, FBITFIELD blendmode, UINT8 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap);
|
||||
void HWR_AddPolyObjectPlanes(void);
|
||||
void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// hw_main.c: Segs
|
||||
void HWR_ProcessSeg(void); // Sort of like GLWall::Process in GZDoom
|
||||
void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap);
|
||||
void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blendmode, INT32 lightlevel, extracolormap_t *wallcolormap);
|
||||
void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo * pSurf, INT32 texnum, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap);
|
||||
void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfaceInfo* Surf, INT32 cutflag, ffloor_t *pfloor);
|
||||
void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf);
|
||||
void HWR_DrawSkyBackground(float fpov);
|
||||
|
||||
#ifdef POLYOBJECTS
|
||||
void HWR_AddPolyObjectSegs(void);
|
||||
#endif
|
||||
|
||||
// hw_main.c: BSP
|
||||
void HWR_RenderBSPNode(INT32 bspnum);
|
||||
void HWR_Subsector(size_t num);
|
||||
void HWR_AddLine(seg_t *line);
|
||||
boolean HWR_CheckBBox(fixed_t *bspcoord);
|
||||
void HWR_RenderDrawNodes(void);
|
||||
|
||||
// hw_main.c: Sprites
|
||||
void HWR_AddSprites(sector_t *sec);
|
||||
void HWR_ProjectSprite(mobj_t *thing);
|
||||
void HWR_ProjectPrecipitationSprite(precipmobj_t *thing);
|
||||
void HWR_DrawSprites(void);
|
||||
|
||||
// hw_bsp.c
|
||||
void HWR_CreatePlanePolygons(INT32 bspnum);
|
||||
|
||||
// hw_cache.c
|
||||
void HWR_PrepLevelCache(size_t pnumtextures);
|
||||
|
||||
// hw_trick.c
|
||||
void HWR_CorrectSWTricks(void);
|
||||
|
||||
// Console variables
|
||||
extern consvar_t cv_grshaders;
|
||||
extern consvar_t cv_grshearing;
|
||||
extern consvar_t cv_grfov;
|
||||
extern consvar_t cv_grmdls;
|
||||
extern consvar_t cv_grfallbackplayermodel;
|
||||
extern consvar_t cv_grfog;
|
||||
extern consvar_t cv_grfogcolor;
|
||||
extern consvar_t cv_grfogdensity;
|
||||
extern consvar_t cv_grsoftwarefog;
|
||||
extern consvar_t cv_grgammared;
|
||||
extern consvar_t cv_grgammagreen;
|
||||
extern consvar_t cv_grgammablue;
|
||||
@@ -94,22 +146,9 @@ extern consvar_t cv_grcorrecttricks;
|
||||
extern consvar_t cv_grfovchange;
|
||||
extern consvar_t cv_grsolvetjoin;
|
||||
extern consvar_t cv_grspritebillboarding;
|
||||
extern consvar_t cv_grfakecontrast;
|
||||
extern consvar_t cv_grfallbackplayermodel;
|
||||
|
||||
extern float gr_viewwidth, gr_viewheight, gr_baseviewwindowx, gr_baseviewwindowy;
|
||||
|
||||
extern float gr_basewindowcenterx, gr_basewindowcentery;
|
||||
|
||||
// BP: big hack for a test in lighting ref : 1249753487AB
|
||||
extern fixed_t *hwbbox;
|
||||
extern FTransform atransform;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
wallVert3D floorVerts[4];
|
||||
FSurfaceInfo Surf;
|
||||
INT32 texnum;
|
||||
INT32 blend;
|
||||
INT32 drawcount;
|
||||
} floorinfo_t;
|
||||
extern CV_PossibleValue_t granisotropicmode_cons_t[];
|
||||
|
||||
#endif
|
||||
+359
-156
@@ -1,17 +1,12 @@
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2019 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file
|
||||
/// \brief MD2 Handling
|
||||
@@ -90,7 +85,6 @@ static void md2_freeModel (model_t *model)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// load model
|
||||
//
|
||||
@@ -151,7 +145,7 @@ static void PNG_warn(png_structp PNG, png_const_charp pngtext)
|
||||
CONS_Debug(DBG_RENDER, "libpng warning at %p: %s", PNG, pngtext);
|
||||
}
|
||||
|
||||
static GrTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_t *grpatch)
|
||||
static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_t *grpatch)
|
||||
{
|
||||
png_structp png_ptr;
|
||||
png_infop png_info_ptr;
|
||||
@@ -205,7 +199,7 @@ static GrTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_
|
||||
//CONS_Debug(DBG_RENDER, "libpng load error on %s\n", filename);
|
||||
png_destroy_read_struct(&png_ptr, &png_info_ptr, NULL);
|
||||
fclose(png_FILE);
|
||||
Z_Free(grpatch->mipmap.grInfo.data);
|
||||
Z_Free(grpatch->mipmap->grInfo.data);
|
||||
return 0;
|
||||
}
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
@@ -246,7 +240,7 @@ static GrTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_
|
||||
|
||||
{
|
||||
png_uint_32 i, pitch = png_get_rowbytes(png_ptr, png_info_ptr);
|
||||
png_bytep PNG_image = Z_Malloc(pitch*height, PU_HWRCACHE, &grpatch->mipmap.grInfo.data);
|
||||
png_bytep PNG_image = Z_Malloc(pitch*height, PU_HWRCACHE, &grpatch->mipmap->grInfo.data);
|
||||
png_bytepp row_pointers = png_malloc(png_ptr, height * sizeof (png_bytep));
|
||||
for (i = 0; i < height; i++)
|
||||
row_pointers[i] = PNG_image + i*pitch;
|
||||
@@ -285,7 +279,7 @@ typedef struct
|
||||
UINT8 filler[54];
|
||||
} PcxHeader;
|
||||
|
||||
static GrTextureFormat_t PCX_Load(const char *filename, int *w, int *h,
|
||||
static GLTextureFormat_t PCX_Load(const char *filename, int *w, int *h,
|
||||
GLPatch_t *grpatch)
|
||||
{
|
||||
PcxHeader header;
|
||||
@@ -326,7 +320,7 @@ static GrTextureFormat_t PCX_Load(const char *filename, int *w, int *h,
|
||||
|
||||
pw = *w = header.xmax - header.xmin + 1;
|
||||
ph = *h = header.ymax - header.ymin + 1;
|
||||
image = Z_Malloc(pw*ph*4, PU_HWRCACHE, &grpatch->mipmap.grInfo.data);
|
||||
image = Z_Malloc(pw*ph*4, PU_HWRCACHE, &grpatch->mipmap->grInfo.data);
|
||||
|
||||
if (fread(palette, sizeof (UINT8), PALSIZE, file) != PALSIZE)
|
||||
{
|
||||
@@ -374,37 +368,43 @@ static void md2_loadTexture(md2_t *model)
|
||||
if (model->grpatch)
|
||||
{
|
||||
grpatch = model->grpatch;
|
||||
Z_Free(grpatch->mipmap.grInfo.data);
|
||||
Z_Free(grpatch->mipmap->grInfo.data);
|
||||
}
|
||||
else
|
||||
{
|
||||
grpatch = Z_Calloc(sizeof *grpatch, PU_HWRPATCHINFO,
|
||||
&(model->grpatch));
|
||||
grpatch->mipmap = Z_Calloc(sizeof (GLMipmap_t), PU_HWRPATCHINFO, NULL);
|
||||
}
|
||||
|
||||
if (!grpatch->mipmap.downloaded && !grpatch->mipmap.grInfo.data)
|
||||
if (!grpatch->mipmap->downloaded && !grpatch->mipmap->grInfo.data)
|
||||
{
|
||||
int w = 0, h = 0;
|
||||
#ifdef HAVE_PNG
|
||||
grpatch->mipmap.grInfo.format = PNG_Load(filename, &w, &h, grpatch);
|
||||
if (grpatch->mipmap.grInfo.format == 0)
|
||||
grpatch->mipmap->grInfo.format = PNG_Load(filename, &w, &h, grpatch);
|
||||
if (grpatch->mipmap->grInfo.format == 0)
|
||||
#endif
|
||||
grpatch->mipmap.grInfo.format = PCX_Load(filename, &w, &h, grpatch);
|
||||
if (grpatch->mipmap.grInfo.format == 0)
|
||||
grpatch->mipmap->grInfo.format = PCX_Load(filename, &w, &h, grpatch);
|
||||
if (grpatch->mipmap->grInfo.format == 0)
|
||||
{
|
||||
grpatch->notfound = true;// mark it so its not searched for again repeatedly
|
||||
return;
|
||||
}
|
||||
|
||||
grpatch->mipmap.downloaded = 0;
|
||||
grpatch->mipmap.flags = 0;
|
||||
grpatch->mipmap->downloaded = 0;
|
||||
grpatch->mipmap->flags = 0;
|
||||
|
||||
grpatch->width = (INT16)w;
|
||||
grpatch->height = (INT16)h;
|
||||
grpatch->mipmap.width = (UINT16)w;
|
||||
grpatch->mipmap.height = (UINT16)h;
|
||||
grpatch->mipmap->width = (UINT16)w;
|
||||
grpatch->mipmap->height = (UINT16)h;
|
||||
|
||||
// not correct!
|
||||
grpatch->mipmap.grInfo.smallLodLog2 = GR_LOD_LOG2_256;
|
||||
grpatch->mipmap.grInfo.largeLodLog2 = GR_LOD_LOG2_256;
|
||||
grpatch->mipmap.grInfo.aspectRatioLog2 = GR_ASPECT_LOG2_1x1;
|
||||
grpatch->mipmap->grInfo.smallLodLog2 = GR_LOD_LOG2_256;
|
||||
grpatch->mipmap->grInfo.largeLodLog2 = GR_LOD_LOG2_256;
|
||||
grpatch->mipmap->grInfo.aspectRatioLog2 = GR_ASPECT_LOG2_1x1;
|
||||
}
|
||||
HWD.pfnSetTexture(&grpatch->mipmap);
|
||||
HWD.pfnSetTexture(grpatch->mipmap);
|
||||
HWR_UnlockCachedPatch(grpatch);
|
||||
}
|
||||
|
||||
@@ -422,40 +422,44 @@ static void md2_loadBlendTexture(md2_t *model)
|
||||
if (model->blendgrpatch)
|
||||
{
|
||||
grpatch = model->blendgrpatch;
|
||||
Z_Free(grpatch->mipmap.grInfo.data);
|
||||
Z_Free(grpatch->mipmap->grInfo.data);
|
||||
}
|
||||
else
|
||||
{
|
||||
grpatch = Z_Calloc(sizeof *grpatch, PU_HWRPATCHINFO,
|
||||
&(model->blendgrpatch));
|
||||
grpatch->mipmap = Z_Calloc(sizeof (GLMipmap_t), PU_HWRPATCHINFO, NULL);
|
||||
}
|
||||
|
||||
if (!grpatch->mipmap.downloaded && !grpatch->mipmap.grInfo.data)
|
||||
if (!grpatch->mipmap->downloaded && !grpatch->mipmap->grInfo.data)
|
||||
{
|
||||
int w = 0, h = 0;
|
||||
#ifdef HAVE_PNG
|
||||
grpatch->mipmap.grInfo.format = PNG_Load(filename, &w, &h, grpatch);
|
||||
if (grpatch->mipmap.grInfo.format == 0)
|
||||
grpatch->mipmap->grInfo.format = PNG_Load(filename, &w, &h, grpatch);
|
||||
if (grpatch->mipmap->grInfo.format == 0)
|
||||
#endif
|
||||
grpatch->mipmap.grInfo.format = PCX_Load(filename, &w, &h, grpatch);
|
||||
if (grpatch->mipmap.grInfo.format == 0)
|
||||
grpatch->mipmap->grInfo.format = PCX_Load(filename, &w, &h, grpatch);
|
||||
if (grpatch->mipmap->grInfo.format == 0)
|
||||
{
|
||||
grpatch->notfound = true;// mark it so its not searched for again repeatedly
|
||||
Z_Free(filename);
|
||||
return;
|
||||
}
|
||||
|
||||
grpatch->mipmap.downloaded = 0;
|
||||
grpatch->mipmap.flags = 0;
|
||||
grpatch->mipmap->downloaded = 0;
|
||||
grpatch->mipmap->flags = 0;
|
||||
|
||||
grpatch->width = (INT16)w;
|
||||
grpatch->height = (INT16)h;
|
||||
grpatch->mipmap.width = (UINT16)w;
|
||||
grpatch->mipmap.height = (UINT16)h;
|
||||
grpatch->mipmap->width = (UINT16)w;
|
||||
grpatch->mipmap->height = (UINT16)h;
|
||||
|
||||
// not correct!
|
||||
grpatch->mipmap.grInfo.smallLodLog2 = GR_LOD_LOG2_256;
|
||||
grpatch->mipmap.grInfo.largeLodLog2 = GR_LOD_LOG2_256;
|
||||
grpatch->mipmap.grInfo.aspectRatioLog2 = GR_ASPECT_LOG2_1x1;
|
||||
grpatch->mipmap->grInfo.smallLodLog2 = GR_LOD_LOG2_256;
|
||||
grpatch->mipmap->grInfo.largeLodLog2 = GR_LOD_LOG2_256;
|
||||
grpatch->mipmap->grInfo.aspectRatioLog2 = GR_ASPECT_LOG2_1x1;
|
||||
}
|
||||
HWD.pfnSetTexture(&grpatch->mipmap); // We do need to do this so that it can be cleared and knows to recreate it when necessary
|
||||
HWD.pfnSetTexture(grpatch->mipmap); // We do need to do this so that it can be cleared and knows to recreate it when necessary
|
||||
HWR_UnlockCachedPatch(grpatch);
|
||||
|
||||
Z_Free(filename);
|
||||
@@ -544,7 +548,7 @@ void HWR_InitMD2(void)
|
||||
goto md2found;
|
||||
}
|
||||
}
|
||||
// no sprite/player skin name found?!?
|
||||
// no sprite/player skin name found?!?D
|
||||
CONS_Printf("Unknown sprite/player skin %s detected in mdls.dat\n", name);
|
||||
md2found:
|
||||
// move on to next line...
|
||||
@@ -579,7 +583,7 @@ void HWR_AddPlayerMD2(int skin) // For MD2's that were added after startup
|
||||
}
|
||||
}
|
||||
|
||||
// Check for any MD2s that match the names of player skins!
|
||||
// Check for any MD2s that match the names of sprite names!
|
||||
while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4)
|
||||
{
|
||||
if (stricmp(name, skins[skin].name) == 0)
|
||||
@@ -655,18 +659,26 @@ spritemd2found:
|
||||
// 0.0722 to blue
|
||||
// (See this same define in k_kart.c!)
|
||||
#define SETBRIGHTNESS(brightness,r,g,b) \
|
||||
brightness = (UINT8)(((1063*((UINT16)r)/5000) + (3576*((UINT16)g)/5000) + (361*((UINT16)b)/5000)) / 3)
|
||||
brightness = (UINT8)(((1063*(UINT16)(r))/5000) + ((3576*(UINT16)(g))/5000) + ((361*(UINT16)(b))/5000))
|
||||
|
||||
static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, GLMipmap_t *grmip, INT32 skinnum, skincolors_t color)
|
||||
{
|
||||
UINT8 i;
|
||||
UINT16 w = gpatch->width, h = gpatch->height;
|
||||
UINT32 size = w*h;
|
||||
RGBA_t *image, *blendimage, *cur, blendcolor;
|
||||
UINT8 translation[16]; // First the color index
|
||||
UINT8 cutoff[16]; // Brightness cutoff before using the next color
|
||||
UINT8 translen = 0;
|
||||
UINT8 i;
|
||||
UINT8 colorbrightnesses[16];
|
||||
UINT8 color_match_lookup[256]; // optimization attempt
|
||||
|
||||
blendcolor = V_GetColor(0); // initialize
|
||||
memset(translation, 0, sizeof(translation));
|
||||
memset(cutoff, 0, sizeof(cutoff));
|
||||
|
||||
if (grmip->width == 0)
|
||||
{
|
||||
|
||||
grmip->width = gpatch->width;
|
||||
grmip->height = gpatch->height;
|
||||
|
||||
@@ -676,110 +688,323 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch,
|
||||
grmip->grInfo.format = GR_RGBA;
|
||||
}
|
||||
|
||||
Z_Free(grmip->grInfo.data);
|
||||
grmip->grInfo.data = NULL;
|
||||
if (grmip->grInfo.data)
|
||||
{
|
||||
Z_Free(grmip->grInfo.data);
|
||||
grmip->grInfo.data = NULL;
|
||||
}
|
||||
|
||||
cur = Z_Malloc(size*4, PU_HWRCACHE, &grmip->grInfo.data);
|
||||
memset(cur, 0x00, size*4);
|
||||
|
||||
image = gpatch->mipmap.grInfo.data;
|
||||
blendimage = blendgpatch->mipmap.grInfo.data;
|
||||
image = gpatch->mipmap->grInfo.data;
|
||||
blendimage = blendgpatch->mipmap->grInfo.data;
|
||||
|
||||
// Average all of the translation's colors
|
||||
// TC_METALSONIC includes an actual skincolor translation, on top of its flashing.
|
||||
if (skinnum == TC_METALSONIC)
|
||||
color = SKINCOLOR_BLUEBERRY;
|
||||
|
||||
if (color != SKINCOLOR_NONE)
|
||||
{
|
||||
const UINT8 div = 6;
|
||||
const UINT8 start = 4;
|
||||
UINT32 r, g, b;
|
||||
UINT8 numdupes = 1;
|
||||
UINT8 prevdupes = numdupes;
|
||||
|
||||
blendcolor = V_GetColor(colortranslations[color][start]);
|
||||
r = (UINT32)(blendcolor.s.red*blendcolor.s.red);
|
||||
g = (UINT32)(blendcolor.s.green*blendcolor.s.green);
|
||||
b = (UINT32)(blendcolor.s.blue*blendcolor.s.blue);
|
||||
translation[translen] = colortranslations[color][0];
|
||||
cutoff[translen] = 255;
|
||||
|
||||
for (i = 1; i < div; i++)
|
||||
for (i = 1; i < 16; i++)
|
||||
{
|
||||
RGBA_t nextcolor = V_GetColor(colortranslations[color][start+i]);
|
||||
r += (UINT32)(nextcolor.s.red*nextcolor.s.red);
|
||||
g += (UINT32)(nextcolor.s.green*nextcolor.s.green);
|
||||
b += (UINT32)(nextcolor.s.blue*nextcolor.s.blue);
|
||||
if (translation[translen] == colortranslations[color][i])
|
||||
{
|
||||
numdupes++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (translen > 0)
|
||||
{
|
||||
INT16 newcutoff = cutoff[translen-1] - (255 / (16 / prevdupes));
|
||||
|
||||
if (newcutoff < 0)
|
||||
newcutoff = 0;
|
||||
|
||||
cutoff[translen] = (UINT8)newcutoff;
|
||||
}
|
||||
|
||||
prevdupes = numdupes;
|
||||
numdupes = 1;
|
||||
translen++;
|
||||
|
||||
translation[translen] = (UINT8)colortranslations[color][i];
|
||||
}
|
||||
|
||||
blendcolor.s.red = (UINT8)(FixedSqrt((r/div)<<FRACBITS)>>FRACBITS);
|
||||
blendcolor.s.green = (UINT8)(FixedSqrt((g/div)<<FRACBITS)>>FRACBITS);
|
||||
blendcolor.s.blue = (UINT8)(FixedSqrt((b/div)<<FRACBITS)>>FRACBITS);
|
||||
translen++;
|
||||
}
|
||||
|
||||
// rainbow support, could theoretically support boss ones too
|
||||
if (skinnum == TC_RAINBOW)
|
||||
if (skinnum == TC_RAINBOW && translen > 0)
|
||||
{
|
||||
while (size--)
|
||||
UINT16 b;
|
||||
INT32 compare;
|
||||
|
||||
for (i = 0; i < translen; i++) // moved from inside the loop to here
|
||||
{
|
||||
if (image->s.alpha == 0 && blendimage->s.alpha == 0)
|
||||
RGBA_t tempc = V_GetColor(translation[i]);
|
||||
SETBRIGHTNESS(colorbrightnesses[i], tempc.s.red, tempc.s.green, tempc.s.blue); // store brightnesses for comparison
|
||||
}
|
||||
// generate lookup table for color brightness matching
|
||||
for (b = 0; b < 256; b++)
|
||||
{
|
||||
UINT16 brightdif = 256;
|
||||
|
||||
color_match_lookup[i] = 0;
|
||||
for (i = 0; i < translen; i++)
|
||||
{
|
||||
// Don't bother with blending the pixel if the alpha of the blend pixel is 0
|
||||
cur->rgba = image->rgba;
|
||||
if (b > colorbrightnesses[i]) // don't allow greater matches (because calculating a makeshift gradient for this is already a huge mess as is)
|
||||
continue;
|
||||
|
||||
compare = abs((INT16)(colorbrightnesses[i]) - (INT16)(b));
|
||||
|
||||
if (compare < brightdif)
|
||||
{
|
||||
brightdif = (UINT16)compare;
|
||||
color_match_lookup[b] = i; // best matching color that's equal brightness or darker
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (size--)
|
||||
{
|
||||
if (skinnum == TC_BOSS)
|
||||
{
|
||||
// Turn everything below a certain threshold white
|
||||
if ((image->s.red == image->s.green) && (image->s.green == image->s.blue) && image->s.blue < 127)
|
||||
{
|
||||
// Lactozilla: Invert the colors
|
||||
cur->s.red = cur->s.green = cur->s.blue = (255 - image->s.blue);
|
||||
}
|
||||
else
|
||||
{
|
||||
cur->s.red = image->s.red;
|
||||
cur->s.green = image->s.green;
|
||||
cur->s.blue = image->s.blue;
|
||||
}
|
||||
|
||||
cur->s.alpha = image->s.alpha;
|
||||
}
|
||||
else if (skinnum == TC_ALLWHITE)
|
||||
{
|
||||
// Turn everything white
|
||||
cur->s.red = cur->s.green = cur->s.blue = 255;
|
||||
cur->s.alpha = image->s.alpha;
|
||||
}
|
||||
else
|
||||
{
|
||||
// All settings that use skincolors!
|
||||
UINT16 brightness;
|
||||
|
||||
// Everything below requires a blend image
|
||||
if (blendimage == NULL)
|
||||
{
|
||||
cur->rgba = image->rgba;
|
||||
goto skippixel;
|
||||
}
|
||||
|
||||
if (translen <= 0)
|
||||
{
|
||||
cur->rgba = image->rgba;
|
||||
goto skippixel;
|
||||
}
|
||||
|
||||
// Don't bother with blending the pixel if the alpha of the blend pixel is 0
|
||||
if (skinnum == TC_RAINBOW)
|
||||
{
|
||||
if (image->s.alpha == 0 && blendimage->s.alpha == 0)
|
||||
{
|
||||
cur->rgba = image->rgba;
|
||||
goto skippixel;
|
||||
}
|
||||
else
|
||||
{
|
||||
UINT16 imagebright, blendbright;
|
||||
SETBRIGHTNESS(imagebright,image->s.red,image->s.green,image->s.blue);
|
||||
SETBRIGHTNESS(blendbright,blendimage->s.red,blendimage->s.green,blendimage->s.blue);
|
||||
// slightly dumb average between the blend image color and base image colour, usually one or the other will be fully opaque anyway
|
||||
brightness = (imagebright*(255-blendimage->s.alpha))/255 + (blendbright*blendimage->s.alpha)/255;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (blendimage->s.alpha == 0)
|
||||
{
|
||||
cur->rgba = image->rgba;
|
||||
goto skippixel; // for metal sonic blend
|
||||
}
|
||||
else
|
||||
{
|
||||
SETBRIGHTNESS(brightness,blendimage->s.red,blendimage->s.green,blendimage->s.blue);
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate a sort of "gradient" for the skincolor
|
||||
// (Me splitting this into a function didn't work, so I had to ruin this entire function's groove...)
|
||||
{
|
||||
RGBA_t nextcolor;
|
||||
UINT8 firsti, secondi, mul, mulmax;
|
||||
INT32 r, g, b;
|
||||
|
||||
// Rainbow needs to find the closest match to the textures themselves, instead of matching brightnesses to other colors.
|
||||
// Ensue horrible mess.
|
||||
if (skinnum == TC_RAINBOW)
|
||||
{
|
||||
//UINT16 brightdif = 256;
|
||||
INT32 /*compare,*/ m, d;
|
||||
|
||||
// Ignore pure white & pitch black
|
||||
if (brightness > 253 || brightness < 2)
|
||||
{
|
||||
cur->rgba = image->rgba;
|
||||
cur++; image++; blendimage++;
|
||||
continue;
|
||||
}
|
||||
|
||||
firsti = 0;
|
||||
mul = 0;
|
||||
mulmax = 1;
|
||||
|
||||
/*for (i = 0; i < translen; i++)
|
||||
{
|
||||
if (brightness > colorbrightnesses[i]) // don't allow greater matches (because calculating a makeshift gradient for this is already a huge mess as is)
|
||||
continue;
|
||||
|
||||
compare = abs((INT16)(colorbrightnesses[i]) - (INT16)(brightness));
|
||||
|
||||
if (compare < brightdif)
|
||||
{
|
||||
brightdif = (UINT16)compare;
|
||||
firsti = i; // best matching color that's equal brightness or darker
|
||||
}
|
||||
}*/
|
||||
firsti = color_match_lookup[brightness];
|
||||
|
||||
secondi = firsti+1; // next color in line
|
||||
|
||||
m = (INT16)brightness - (INT16)colorbrightnesses[secondi];
|
||||
d = (INT16)colorbrightnesses[firsti] - (INT16)colorbrightnesses[secondi];
|
||||
|
||||
if (m >= d)
|
||||
m = d-1;
|
||||
|
||||
mulmax = 16;
|
||||
|
||||
// calculate the "gradient" multiplier based on how close this color is to the one next in line
|
||||
if (m <= 0 || d <= 0)
|
||||
mul = 0;
|
||||
else
|
||||
mul = (mulmax-1) - ((m * mulmax) / d);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Just convert brightness to a skincolor value, use distance to next position to find the gradient multipler
|
||||
firsti = 0;
|
||||
|
||||
for (i = 1; i < translen; i++)
|
||||
{
|
||||
if (brightness >= cutoff[i])
|
||||
break;
|
||||
firsti = i;
|
||||
}
|
||||
|
||||
secondi = firsti+1;
|
||||
|
||||
mulmax = cutoff[firsti] - cutoff[secondi];
|
||||
mul = cutoff[firsti] - brightness;
|
||||
}
|
||||
|
||||
blendcolor = V_GetColor(translation[firsti]);
|
||||
|
||||
if (mul > 0) // If it's 0, then we only need the first color.
|
||||
{
|
||||
nextcolor = V_GetColor(translation[secondi]);
|
||||
|
||||
// Find difference between points
|
||||
r = (INT32)(nextcolor.s.red - blendcolor.s.red);
|
||||
g = (INT32)(nextcolor.s.green - blendcolor.s.green);
|
||||
b = (INT32)(nextcolor.s.blue - blendcolor.s.blue);
|
||||
|
||||
// Find the gradient of the two points
|
||||
r = ((mul * r) / mulmax);
|
||||
g = ((mul * g) / mulmax);
|
||||
b = ((mul * b) / mulmax);
|
||||
|
||||
// Add gradient value to color
|
||||
blendcolor.s.red += r;
|
||||
blendcolor.s.green += g;
|
||||
blendcolor.s.blue += b;
|
||||
}
|
||||
}
|
||||
|
||||
if (skinnum == TC_RAINBOW)
|
||||
{
|
||||
UINT32 tempcolor;
|
||||
UINT16 imagebright, blendbright, finalbright, colorbright;
|
||||
SETBRIGHTNESS(imagebright,image->s.red,image->s.green,image->s.blue);
|
||||
SETBRIGHTNESS(blendbright,blendimage->s.red,blendimage->s.green,blendimage->s.blue);
|
||||
// slightly dumb average between the blend image color and base image colour, usually one or the other will be fully opaque anyway
|
||||
finalbright = (imagebright*(255-blendimage->s.alpha))/255 + (blendbright*blendimage->s.alpha)/255;
|
||||
SETBRIGHTNESS(colorbright,blendcolor.s.red,blendcolor.s.green,blendcolor.s.blue);
|
||||
UINT16 colorbright;
|
||||
|
||||
tempcolor = (finalbright*blendcolor.s.red)/colorbright;
|
||||
SETBRIGHTNESS(colorbright,blendcolor.s.red,blendcolor.s.green,blendcolor.s.blue);
|
||||
if (colorbright == 0)
|
||||
colorbright = 1; // no dividing by 0 please
|
||||
|
||||
tempcolor = (brightness * blendcolor.s.red) / colorbright;
|
||||
tempcolor = min(255, tempcolor);
|
||||
cur->s.red = (UINT8)tempcolor;
|
||||
tempcolor = (finalbright*blendcolor.s.green)/colorbright;
|
||||
|
||||
tempcolor = (brightness * blendcolor.s.green) / colorbright;
|
||||
tempcolor = min(255, tempcolor);
|
||||
cur->s.green = (UINT8)tempcolor;
|
||||
tempcolor = (finalbright*blendcolor.s.blue)/colorbright;
|
||||
|
||||
tempcolor = (brightness * blendcolor.s.blue) / colorbright;
|
||||
tempcolor = min(255, tempcolor);
|
||||
cur->s.blue = (UINT8)tempcolor;
|
||||
cur->s.alpha = image->s.alpha;
|
||||
}
|
||||
|
||||
cur++; image++; blendimage++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (size--)
|
||||
{
|
||||
if (blendimage->s.alpha == 0)
|
||||
{
|
||||
// Don't bother with blending the pixel if the alpha of the blend pixel is 0
|
||||
cur->rgba = image->rgba;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Color strength depends on image alpha
|
||||
INT32 tempcolor;
|
||||
INT16 tempmult, tempalpha;
|
||||
tempalpha = -(abs(blendimage->s.red-127)-127)*2;
|
||||
if (tempalpha > 255)
|
||||
tempalpha = 255;
|
||||
else if (tempalpha < 0)
|
||||
tempalpha = 0;
|
||||
|
||||
tempmult = (blendimage->s.red-127)*2;
|
||||
if (tempmult > 255)
|
||||
tempmult = 255;
|
||||
else if (tempmult < 0)
|
||||
tempmult = 0;
|
||||
|
||||
tempcolor = (image->s.red*(255-blendimage->s.alpha))/255 + ((tempmult + ((tempalpha*blendcolor.s.red)/255)) * blendimage->s.alpha)/255;
|
||||
tempcolor = ((image->s.red * (255-blendimage->s.alpha)) / 255) + ((blendcolor.s.red * blendimage->s.alpha) / 255);
|
||||
tempcolor = min(255, tempcolor);
|
||||
cur->s.red = (UINT8)tempcolor;
|
||||
tempcolor = (image->s.green*(255-blendimage->s.alpha))/255 + ((tempmult + ((tempalpha*blendcolor.s.green)/255)) * blendimage->s.alpha)/255;
|
||||
|
||||
tempcolor = ((image->s.green * (255-blendimage->s.alpha)) / 255) + ((blendcolor.s.green * blendimage->s.alpha) / 255);
|
||||
tempcolor = min(255, tempcolor);
|
||||
cur->s.green = (UINT8)tempcolor;
|
||||
tempcolor = (image->s.blue*(255-blendimage->s.alpha))/255 + ((tempmult + ((tempalpha*blendcolor.s.blue)/255)) * blendimage->s.alpha)/255;
|
||||
|
||||
tempcolor = ((image->s.blue * (255-blendimage->s.alpha)) / 255) + ((blendcolor.s.blue * blendimage->s.alpha) / 255);
|
||||
tempcolor = min(255, tempcolor);
|
||||
cur->s.blue = (UINT8)tempcolor;
|
||||
cur->s.alpha = image->s.alpha;
|
||||
}
|
||||
|
||||
cur++; image++; blendimage++;
|
||||
skippixel:
|
||||
|
||||
// *Now* we can do Metal Sonic's flashing
|
||||
if (skinnum == TC_METALSONIC)
|
||||
{
|
||||
// Blend dark blue into white
|
||||
if (cur->s.alpha > 0 && cur->s.red == 0 && cur->s.green == 0 && cur->s.blue < 255 && cur->s.blue > 31)
|
||||
{
|
||||
// Sal: Invert non-blue
|
||||
cur->s.red = cur->s.green = (255 - cur->s.blue);
|
||||
cur->s.blue = 255;
|
||||
}
|
||||
|
||||
cur->s.alpha = image->s.alpha;
|
||||
}
|
||||
}
|
||||
|
||||
cur++; image++;
|
||||
|
||||
if (blendimage != NULL)
|
||||
blendimage++;
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -795,13 +1020,13 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT
|
||||
if (colormap == colormaps || colormap == NULL)
|
||||
{
|
||||
// Don't do any blending
|
||||
HWD.pfnSetTexture(&gpatch->mipmap);
|
||||
HWD.pfnSetTexture(gpatch->mipmap);
|
||||
return;
|
||||
}
|
||||
|
||||
// search for the mimmap
|
||||
// skip the first (no colormap translated)
|
||||
for (grmip = &gpatch->mipmap; grmip->nextcolormap; )
|
||||
for (grmip = gpatch->mipmap; grmip->nextcolormap; )
|
||||
{
|
||||
grmip = grmip->nextcolormap;
|
||||
if (grmip->colormap == colormap)
|
||||
@@ -837,35 +1062,19 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT
|
||||
|
||||
// -----------------+
|
||||
// HWR_DrawMD2 : Draw MD2
|
||||
// : (monsters, bonuses, weapons, lights, ...)
|
||||
// :
|
||||
// Returns :
|
||||
// -----------------+
|
||||
/*
|
||||
wait/stand
|
||||
death
|
||||
pain
|
||||
walk
|
||||
shoot/fire
|
||||
|
||||
die?
|
||||
atka?
|
||||
atkb?
|
||||
attacka/b/c/d?
|
||||
res?
|
||||
run?
|
||||
*/
|
||||
#define NORMALFOG 0x00000000
|
||||
#define FADEFOG 0x19000000
|
||||
void HWR_DrawMD2(gr_vissprite_t *spr)
|
||||
{
|
||||
FSurfaceInfo Surf;
|
||||
md2_t *md2;
|
||||
|
||||
char filename[64];
|
||||
INT32 frame = 0;
|
||||
INT32 nextFrame = -1;
|
||||
FTransform p;
|
||||
md2_t *md2;
|
||||
UINT8 color[4];
|
||||
FSurfaceInfo Surf;
|
||||
|
||||
if (!cv_grmdls.value)
|
||||
return;
|
||||
@@ -878,8 +1087,8 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
|
||||
if (spr->mobj->subsector)
|
||||
{
|
||||
sector_t *sector = spr->mobj->subsector->sector;
|
||||
UINT8 lightlevel = 255;
|
||||
extracolormap_t *colormap = sector->extra_colormap;
|
||||
UINT8 lightlevel = 255;
|
||||
|
||||
if (sector->numlights)
|
||||
{
|
||||
@@ -902,14 +1111,11 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
|
||||
colormap = sector->extra_colormap;
|
||||
}
|
||||
|
||||
if (colormap)
|
||||
Surf.FlatColor.rgba = HWR_Lighting(lightlevel, colormap->rgba, colormap->fadergba, false, false);
|
||||
else
|
||||
Surf.FlatColor.rgba = HWR_Lighting(lightlevel, NORMALFOG, FADEFOG, false, false);
|
||||
HWR_Lighting(&Surf, lightlevel, colormap);
|
||||
}
|
||||
else
|
||||
{
|
||||
Surf.FlatColor.rgba = 0xFFFFFFFF;
|
||||
Surf.PolyColor.rgba = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
// Look at HWR_ProjectSprite for more
|
||||
@@ -928,11 +1134,11 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
|
||||
//durs = tics;
|
||||
|
||||
if (spr->mobj->flags2 & MF2_SHADOW)
|
||||
Surf.FlatColor.s.alpha = 0x40;
|
||||
Surf.PolyColor.s.alpha = 0x40;
|
||||
else if (spr->mobj->frame & FF_TRANSMASK)
|
||||
HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf);
|
||||
else
|
||||
Surf.FlatColor.s.alpha = 0xFF;
|
||||
Surf.PolyColor.s.alpha = 0xFF;
|
||||
|
||||
// dont forget to enabled the depth test because we can't do this like
|
||||
// before: polygons models are not sorted
|
||||
@@ -967,22 +1173,23 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
|
||||
return;
|
||||
}
|
||||
}
|
||||
//HWD.pfnSetBlend(blend); // This seems to actually break translucency?
|
||||
finalscale = md2->scale;
|
||||
//Hurdler: arf, I don't like that implementation at all... too much crappy
|
||||
gpatch = md2->grpatch;
|
||||
if (!gpatch || !gpatch->mipmap.grInfo.format || !gpatch->mipmap.downloaded)
|
||||
if (!gpatch || ((!gpatch->mipmap->grInfo.format || !gpatch->mipmap->downloaded) && !gpatch->notfound))
|
||||
md2_loadTexture(md2);
|
||||
gpatch = md2->grpatch; // Load it again, because it isn't being loaded into gpatch after md2_loadtexture...
|
||||
|
||||
if ((gpatch && gpatch->mipmap.grInfo.format) // don't load the blend texture if the base texture isn't available
|
||||
&& (!md2->blendgrpatch || !((GLPatch_t *)md2->blendgrpatch)->mipmap.grInfo.format || !((GLPatch_t *)md2->blendgrpatch)->mipmap.downloaded))
|
||||
if ((gpatch && gpatch->mipmap->grInfo.format) // don't load the blend texture if the base texture isn't available
|
||||
&& (!md2->blendgrpatch
|
||||
|| ((!((GLPatch_t *)md2->blendgrpatch)->mipmap->grInfo.format || !((GLPatch_t *)md2->blendgrpatch)->mipmap->downloaded)
|
||||
&& !((GLPatch_t *)md2->blendgrpatch)->notfound)))
|
||||
md2_loadBlendTexture(md2);
|
||||
|
||||
if (gpatch && gpatch->mipmap.grInfo.format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture
|
||||
if (gpatch && gpatch->mipmap->grInfo.format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture
|
||||
{
|
||||
if ((skincolors_t)spr->mobj->color != SKINCOLOR_NONE &&
|
||||
md2->blendgrpatch && ((GLPatch_t *)md2->blendgrpatch)->mipmap.grInfo.format
|
||||
md2->blendgrpatch && ((GLPatch_t *)md2->blendgrpatch)->mipmap->grInfo.format
|
||||
&& gpatch->width == ((GLPatch_t *)md2->blendgrpatch)->width && gpatch->height == ((GLPatch_t *)md2->blendgrpatch)->height)
|
||||
{
|
||||
INT32 skinnum = TC_DEFAULT;
|
||||
@@ -1013,7 +1220,7 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
|
||||
else
|
||||
{
|
||||
// This is safe, since we know the texture has been downloaded
|
||||
HWD.pfnSetTexture(&gpatch->mipmap);
|
||||
HWD.pfnSetTexture(gpatch->mipmap);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1103,11 +1310,6 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
|
||||
}
|
||||
#endif
|
||||
|
||||
color[0] = Surf.FlatColor.s.red;
|
||||
color[1] = Surf.FlatColor.s.green;
|
||||
color[2] = Surf.FlatColor.s.blue;
|
||||
color[3] = Surf.FlatColor.s.alpha;
|
||||
|
||||
// SRB2CBTODO: MD2 scaling support
|
||||
finalscale *= FIXED_TO_FLOAT(spr->mobj->scale);
|
||||
|
||||
@@ -1116,7 +1318,8 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
|
||||
p.mirror = atransform.mirror; // from Kart
|
||||
#endif
|
||||
|
||||
HWD.pfnDrawModel(md2->model, frame, durs, tics, nextFrame, &p, finalscale, flip, color);
|
||||
HWD.pfnSetShader(4); // model shader
|
||||
HWD.pfnDrawModel(md2->model, frame, durs, tics, nextFrame, &p, finalscale, flip, &Surf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-12
@@ -1,18 +1,12 @@
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2019 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file
|
||||
/// \brief MD2 Handling
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "../doomstat.h"
|
||||
|
||||
#ifdef HWRENDER
|
||||
#include "hw_main.h"
|
||||
#include "hw_glob.h"
|
||||
#include "hw_dll.h"
|
||||
#include "../r_local.h"
|
||||
|
||||
+1566
-450
File diff suppressed because it is too large.
Load diff
@@ -57,23 +57,10 @@
|
||||
#undef DEBUG_TO_FILE // maybe defined in previous *.h
|
||||
#define DEBUG_TO_FILE // output debugging msgs to ogllog.txt
|
||||
|
||||
// todo: find some way of getting SDL to log to ogllog.txt, without
|
||||
// interfering with r_opengl.dll
|
||||
#ifdef HAVE_SDL
|
||||
#undef DEBUG_TO_FILE
|
||||
#endif
|
||||
//#if defined(HAVE_SDL) && !defined(_DEBUG)
|
||||
//#undef DEBUG_TO_FILE
|
||||
//#endif
|
||||
|
||||
#ifdef DEBUG_TO_FILE
|
||||
extern FILE *gllogstream;
|
||||
#endif
|
||||
|
||||
#ifndef DRIVER_STRING
|
||||
#define DRIVER_STRING "HWRAPI Init(): SRB2Kart OpenGL renderer" // Tails
|
||||
#endif
|
||||
|
||||
// ==========================================================================
|
||||
// PROTOS
|
||||
// ==========================================================================
|
||||
@@ -81,13 +68,15 @@ extern FILE *gllogstream;
|
||||
boolean LoadGL(void);
|
||||
void *GetGLFunc(const char *proc);
|
||||
boolean SetupGLfunc(void);
|
||||
boolean SetupGLFunc13(void);
|
||||
void SetupGLFunc4(void);
|
||||
void Flush(void);
|
||||
INT32 isExtAvailable(const char *extension, const GLubyte *start);
|
||||
int SetupPixelFormat(INT32 WantColorBits, INT32 WantStencilBits, INT32 WantDepthBits);
|
||||
void SetModelView(GLint w, GLint h);
|
||||
void SetStates(void);
|
||||
FUNCMATH float byteasfloat(UINT8 fbyte);
|
||||
#ifdef USE_PALETTED_TEXTURE
|
||||
extern PFNGLCOLORTABLEEXTPROC glColorTableEXT;
|
||||
extern GLubyte palette_tex[256*3];
|
||||
#endif
|
||||
|
||||
#ifndef GL_EXT_texture_filter_anisotropic
|
||||
#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
|
||||
@@ -123,12 +112,15 @@ static PFNglEnableClientState pglEnableClientState;
|
||||
// GLOBAL
|
||||
// ==========================================================================
|
||||
|
||||
extern const GLubyte *gl_extensions;
|
||||
extern RGBA_t myPaletteData[];
|
||||
extern GLint screen_width;
|
||||
extern GLint screen_height;
|
||||
extern GLbyte screen_depth;
|
||||
extern GLint maximumAnisotropy;
|
||||
extern const GLubyte *gl_version;
|
||||
extern const GLubyte *gl_renderer;
|
||||
extern const GLubyte *gl_extensions;
|
||||
|
||||
extern RGBA_t myPaletteData[];
|
||||
extern GLint screen_width;
|
||||
extern GLint screen_height;
|
||||
extern GLbyte screen_depth;
|
||||
extern GLint maximumAnisotropy;
|
||||
|
||||
/** \brief OpenGL flags for video driver
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,540 @@
|
||||
// SONIC ROBO BLAST 2 KART
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2020 by James R.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
// \brief HTTP based master server
|
||||
|
||||
/*
|
||||
Documentation available here.
|
||||
|
||||
<https://ms.kartkrew.org/tools/api/2/>
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CURL
|
||||
#include <curl/curl.h>
|
||||
#endif
|
||||
|
||||
#include "doomdef.h"
|
||||
#include "d_clisrv.h"
|
||||
#include "command.h"
|
||||
#include "m_argv.h"
|
||||
#include "m_menu.h"
|
||||
#include "mserv.h"
|
||||
#include "i_tcp.h"/* for current_port */
|
||||
#include "i_threads.h"
|
||||
|
||||
/* reasonable default I guess?? */
|
||||
#define DEFAULT_BUFFER_SIZE (4096)
|
||||
|
||||
/* I just stop myself from making macros anymore. */
|
||||
#define Blame( ... ) \
|
||||
CONS_Printf("\x85" __VA_ARGS__)
|
||||
|
||||
static void MasterServer_Debug_OnChange (void);
|
||||
|
||||
consvar_t cv_masterserver_timeout = {
|
||||
"masterserver_timeout", "5", CV_SAVE, CV_Unsigned,
|
||||
NULL, 0, NULL, NULL, 0, 0, NULL/* C90 moment */
|
||||
};
|
||||
|
||||
consvar_t cv_masterserver_debug = {
|
||||
"masterserver_debug", "Off", CV_SAVE|CV_CALL, CV_OnOff,
|
||||
MasterServer_Debug_OnChange, 0, NULL, NULL, 0, 0, NULL/* C90 moment */
|
||||
};
|
||||
|
||||
consvar_t cv_masterserver_token = {
|
||||
"masterserver_token", "", CV_SAVE, NULL,
|
||||
NULL, 0, NULL, NULL, 0, 0, NULL/* C90 moment */
|
||||
};
|
||||
|
||||
#ifdef MASTERSERVER
|
||||
|
||||
static int hms_started;
|
||||
|
||||
static char *hms_api;
|
||||
#ifdef HAVE_THREADS
|
||||
static I_mutex hms_api_mutex;
|
||||
#endif
|
||||
|
||||
static char *hms_server_token;
|
||||
|
||||
struct HMS_buffer
|
||||
{
|
||||
CURL *curl;
|
||||
char *buffer;
|
||||
int needle;
|
||||
int end;
|
||||
};
|
||||
|
||||
static void
|
||||
Contact_error (void)
|
||||
{
|
||||
CONS_Alert(CONS_ERROR,
|
||||
"There was a problem contacting the master server...\n"
|
||||
);
|
||||
}
|
||||
|
||||
static size_t
|
||||
HMS_on_read (char *s, size_t _1, size_t n, void *userdata)
|
||||
{
|
||||
struct HMS_buffer *buffer;
|
||||
size_t blocks;
|
||||
|
||||
(void)_1;
|
||||
|
||||
buffer = userdata;
|
||||
|
||||
if (n >= (size_t)( buffer->end - buffer->needle ))
|
||||
{
|
||||
/* resize to next multiple of buffer size */
|
||||
blocks = ( n / DEFAULT_BUFFER_SIZE + 1 );
|
||||
buffer->end += ( blocks * DEFAULT_BUFFER_SIZE );
|
||||
|
||||
buffer->buffer = realloc(buffer->buffer, buffer->end);
|
||||
}
|
||||
|
||||
memcpy(&buffer->buffer[buffer->needle], s, n);
|
||||
buffer->needle += n;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static struct HMS_buffer *
|
||||
HMS_connect (const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
CURL *curl;
|
||||
char *url;
|
||||
char *quack_token;
|
||||
size_t seek;
|
||||
size_t token_length;
|
||||
struct HMS_buffer *buffer;
|
||||
|
||||
if (! hms_started)
|
||||
{
|
||||
if (curl_global_init(CURL_GLOBAL_ALL) != 0)
|
||||
{
|
||||
Contact_error();
|
||||
Blame("From curl_global_init.\n");
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
atexit(curl_global_cleanup);
|
||||
hms_started = 1;
|
||||
}
|
||||
}
|
||||
|
||||
curl = curl_easy_init();
|
||||
|
||||
if (! curl)
|
||||
{
|
||||
Contact_error();
|
||||
Blame("From curl_easy_init.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (cv_masterserver_token.string[0])
|
||||
{
|
||||
quack_token = curl_easy_escape(curl, cv_masterserver_token.string, 0);
|
||||
token_length = ( sizeof "&token="-1 )+ strlen(quack_token);
|
||||
}
|
||||
else
|
||||
{
|
||||
quack_token = NULL;
|
||||
token_length = 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
I_lock_mutex(&hms_api_mutex);
|
||||
#endif
|
||||
|
||||
seek = strlen(hms_api) + 1;/* + '/' */
|
||||
|
||||
va_start (ap, format);
|
||||
url = malloc(seek + vsnprintf(0, 0, format, ap) +
|
||||
sizeof "?v=2" - 1 +
|
||||
token_length + 1);
|
||||
va_end (ap);
|
||||
|
||||
sprintf(url, "%s/", hms_api);
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
I_unlock_mutex(hms_api_mutex);
|
||||
#endif
|
||||
|
||||
va_start (ap, format);
|
||||
seek += vsprintf(&url[seek], format, ap);
|
||||
va_end (ap);
|
||||
|
||||
strcpy(&url[seek], "?v=2");
|
||||
seek += sizeof "?v=2" - 1;
|
||||
|
||||
if (quack_token)
|
||||
sprintf(&url[seek], "&token=%s", quack_token);
|
||||
|
||||
CONS_Printf("HMS: connecting '%s'...\n", url);
|
||||
|
||||
buffer = malloc(sizeof *buffer);
|
||||
buffer->curl = curl;
|
||||
buffer->end = DEFAULT_BUFFER_SIZE;
|
||||
buffer->buffer = malloc(buffer->end);
|
||||
buffer->needle = 0;
|
||||
|
||||
if (cv_masterserver_debug.value)
|
||||
{
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_STDERR, logstream);
|
||||
}
|
||||
|
||||
if (M_CheckParm("-bindaddr") && M_IsNextParm())
|
||||
{
|
||||
curl_easy_setopt(curl, CURLOPT_INTERFACE, M_GetNextParm());
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, cv_masterserver_timeout.value);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HMS_on_read);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, buffer);
|
||||
|
||||
curl_free(quack_token);
|
||||
free(url);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static int
|
||||
HMS_do (struct HMS_buffer *buffer)
|
||||
{
|
||||
CURLcode cc;
|
||||
long status;
|
||||
|
||||
char *p;
|
||||
|
||||
cc = curl_easy_perform(buffer->curl);
|
||||
|
||||
if (cc != CURLE_OK)
|
||||
{
|
||||
Contact_error();
|
||||
Blame(
|
||||
"From curl_easy_perform: %s\n",
|
||||
curl_easy_strerror(cc)
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
buffer->buffer[buffer->needle] = '\0';
|
||||
|
||||
curl_easy_getinfo(buffer->curl, CURLINFO_RESPONSE_CODE, &status);
|
||||
|
||||
if (status != 200)
|
||||
{
|
||||
p = strchr(buffer->buffer, '\n');
|
||||
|
||||
if (p)
|
||||
*p = '\0';
|
||||
|
||||
Contact_error();
|
||||
Blame(
|
||||
"Master server error %ld: %s%s\n",
|
||||
status,
|
||||
buffer->buffer,
|
||||
( (p) ? "" : " (malformed)" )
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
HMS_end (struct HMS_buffer *buffer)
|
||||
{
|
||||
curl_easy_cleanup(buffer->curl);
|
||||
free(buffer->buffer);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
int
|
||||
HMS_register (void)
|
||||
{
|
||||
struct HMS_buffer *hms;
|
||||
int ok;
|
||||
|
||||
char post[256];
|
||||
|
||||
char *contact;
|
||||
|
||||
hms = HMS_connect(
|
||||
"games/%s/%d/servers/register", SRB2APPLICATION, MODVERSION);
|
||||
|
||||
if (! hms)
|
||||
return 0;
|
||||
|
||||
contact = curl_easy_escape(hms->curl, cv_server_contact.string, 0);
|
||||
|
||||
snprintf(post, sizeof post,
|
||||
"port=%d&"
|
||||
"contact=%s",
|
||||
|
||||
current_port,
|
||||
|
||||
contact
|
||||
);
|
||||
|
||||
curl_free(contact);
|
||||
|
||||
curl_easy_setopt(hms->curl, CURLOPT_POSTFIELDS, post);
|
||||
|
||||
ok = HMS_do(hms);
|
||||
|
||||
if (ok)
|
||||
{
|
||||
hms_server_token = strdup(strtok(hms->buffer, "\n"));
|
||||
}
|
||||
|
||||
HMS_end(hms);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
int
|
||||
HMS_unlist (void)
|
||||
{
|
||||
struct HMS_buffer *hms;
|
||||
int ok;
|
||||
|
||||
hms = HMS_connect("servers/%s/unlist", hms_server_token);
|
||||
|
||||
if (! hms)
|
||||
return 0;
|
||||
|
||||
curl_easy_setopt(hms->curl, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
|
||||
ok = HMS_do(hms);
|
||||
HMS_end(hms);
|
||||
|
||||
free(hms_server_token);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
int
|
||||
HMS_update (void)
|
||||
{
|
||||
struct HMS_buffer *hms;
|
||||
int ok;
|
||||
|
||||
char post[256];
|
||||
|
||||
char *title;
|
||||
|
||||
hms = HMS_connect("servers/%s/update", hms_server_token);
|
||||
|
||||
if (! hms)
|
||||
return 0;
|
||||
|
||||
title = curl_easy_escape(hms->curl, cv_servername.string, 0);
|
||||
|
||||
snprintf(post, sizeof post,
|
||||
"title=%s",
|
||||
title
|
||||
);
|
||||
|
||||
curl_free(title);
|
||||
|
||||
curl_easy_setopt(hms->curl, CURLOPT_POSTFIELDS, post);
|
||||
|
||||
ok = HMS_do(hms);
|
||||
HMS_end(hms);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
void
|
||||
HMS_list_servers (void)
|
||||
{
|
||||
struct HMS_buffer *hms;
|
||||
|
||||
hms = HMS_connect("games/%s/%d/servers", SRB2APPLICATION, MODVERSION);
|
||||
|
||||
if (! hms)
|
||||
return;
|
||||
|
||||
if (HMS_do(hms))
|
||||
{
|
||||
CONS_Printf("%s\n", hms->buffer);
|
||||
}
|
||||
|
||||
HMS_end(hms);
|
||||
}
|
||||
|
||||
msg_server_t *
|
||||
HMS_fetch_servers (msg_server_t *list, int query_id)
|
||||
{
|
||||
struct HMS_buffer *hms;
|
||||
|
||||
int doing_shit;
|
||||
|
||||
char *address;
|
||||
char *port;
|
||||
char *contact;
|
||||
|
||||
char *end;
|
||||
char *p;
|
||||
|
||||
int i;
|
||||
|
||||
(void)query_id;
|
||||
|
||||
hms = HMS_connect("games/%s/%d/servers", SRB2APPLICATION, MODVERSION);
|
||||
|
||||
if (! hms)
|
||||
return NULL;
|
||||
|
||||
if (HMS_do(hms))
|
||||
{
|
||||
doing_shit = 1;
|
||||
|
||||
p = hms->buffer;
|
||||
i = 0;
|
||||
|
||||
while (i < MAXSERVERLIST && ( end = strchr(p, '\n') ))
|
||||
{
|
||||
*end = '\0';
|
||||
|
||||
address = strtok(p, " ");
|
||||
port = strtok(0, " ");
|
||||
contact = strtok(0, "");
|
||||
|
||||
if (address && port)
|
||||
{
|
||||
#ifdef HAVE_THREADS
|
||||
I_lock_mutex(&ms_QueryId_mutex);
|
||||
{
|
||||
if (query_id != ms_QueryId)
|
||||
doing_shit = 0;
|
||||
}
|
||||
I_unlock_mutex(ms_QueryId_mutex);
|
||||
|
||||
if (! doing_shit)
|
||||
break;
|
||||
#endif
|
||||
|
||||
strlcpy(list[i].ip, address, sizeof list[i].ip);
|
||||
strlcpy(list[i].port, port, sizeof list[i].port);
|
||||
|
||||
if (contact)
|
||||
{
|
||||
strlcpy(list[i].contact, contact, sizeof list[i].contact);
|
||||
}
|
||||
|
||||
list[i].header.buffer[0] = 1;
|
||||
|
||||
i++;
|
||||
|
||||
p = ( end + 1 );/* skip server delimiter */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* malformed so quit the parsing */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (doing_shit)
|
||||
list[i].header.buffer[0] = 0;
|
||||
}
|
||||
else
|
||||
list = NULL;
|
||||
|
||||
HMS_end(hms);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
int
|
||||
HMS_compare_mod_version (char *buffer, size_t buffer_size)
|
||||
{
|
||||
struct HMS_buffer *hms;
|
||||
int ok;
|
||||
|
||||
char *version;
|
||||
char *version_name;
|
||||
|
||||
hms = HMS_connect("games/%s/version", SRB2APPLICATION);
|
||||
|
||||
if (! hms)
|
||||
return 0;
|
||||
|
||||
ok = 0;
|
||||
|
||||
if (HMS_do(hms))
|
||||
{
|
||||
version = strtok(hms->buffer, " ");
|
||||
version_name = strtok(0, "\n");
|
||||
|
||||
if (version && version_name)
|
||||
{
|
||||
if (atoi(version) != MODVERSION)
|
||||
{
|
||||
strlcpy(buffer, version_name, buffer_size);
|
||||
ok = 1;
|
||||
}
|
||||
else
|
||||
ok = -1;
|
||||
}
|
||||
}
|
||||
|
||||
HMS_end(hms);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
static char *
|
||||
Strip_trailing_slashes (char *api)
|
||||
{
|
||||
char * p = &api[strlen(api)];
|
||||
|
||||
while (*--p == '/')
|
||||
;
|
||||
|
||||
p[1] = '\0';
|
||||
|
||||
return api;
|
||||
}
|
||||
|
||||
void
|
||||
HMS_set_api (char *api)
|
||||
{
|
||||
#ifdef HAVE_THREADS
|
||||
I_lock_mutex(&hms_api_mutex);
|
||||
#endif
|
||||
{
|
||||
free(hms_api);
|
||||
hms_api = Strip_trailing_slashes(api);
|
||||
}
|
||||
#ifdef HAVE_THREADS
|
||||
I_unlock_mutex(hms_api_mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif/*MASTERSERVER*/
|
||||
|
||||
static void
|
||||
MasterServer_Debug_OnChange (void)
|
||||
{
|
||||
#ifdef MASTERSERVER
|
||||
/* TODO: change to 'latest-log.txt' for log files revision. */
|
||||
if (cv_masterserver_debug.value)
|
||||
CONS_Printf("Master server debug messages will appear in log.txt\n");
|
||||
#endif
|
||||
}
|
||||
+9
-3
@@ -1482,7 +1482,7 @@ static void HU_drawMiniChat(void)
|
||||
|
||||
for (; i>0; i--)
|
||||
{
|
||||
const char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_mini[i-1]);
|
||||
char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_mini[i-1]);
|
||||
size_t j = 0;
|
||||
INT32 linescount = 0;
|
||||
|
||||
@@ -1524,6 +1524,8 @@ static void HU_drawMiniChat(void)
|
||||
dy = 0;
|
||||
dx = 0;
|
||||
msglines += linescount+1;
|
||||
if (msg)
|
||||
Z_Free(msg);
|
||||
}
|
||||
|
||||
y = chaty - charheight*(msglines+1);
|
||||
@@ -1550,7 +1552,7 @@ static void HU_drawMiniChat(void)
|
||||
INT32 timer = ((cv_chattime.value*TICRATE)-chat_timers[i]) - cv_chattime.value*TICRATE+9; // see below...
|
||||
INT32 transflag = (timer >= 0 && timer <= 9) ? (timer*V_10TRANS) : 0; // you can make bad jokes out of this one.
|
||||
size_t j = 0;
|
||||
const char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_mini[i]); // get the current message, and word wrap it.
|
||||
char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_mini[i]); // get the current message, and word wrap it.
|
||||
UINT8 *colormap = NULL;
|
||||
|
||||
while(msg[j]) // iterate through msg
|
||||
@@ -1596,6 +1598,8 @@ static void HU_drawMiniChat(void)
|
||||
}
|
||||
dy += charheight;
|
||||
dx = 0;
|
||||
if (msg)
|
||||
Z_Free(msg);
|
||||
}
|
||||
|
||||
// decrement addy and make that shit smooth:
|
||||
@@ -1651,7 +1655,7 @@ static void HU_drawChatLog(INT32 offset)
|
||||
{
|
||||
INT32 clrflag = 0;
|
||||
INT32 j = 0;
|
||||
const char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_log[i]); // get the current message, and word wrap it.
|
||||
char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_log[i]); // get the current message, and word wrap it.
|
||||
UINT8 *colormap = NULL;
|
||||
while(msg[j]) // iterate through msg
|
||||
{
|
||||
@@ -1691,6 +1695,8 @@ static void HU_drawChatLog(INT32 offset)
|
||||
}
|
||||
dy += charheight;
|
||||
dx = 0;
|
||||
if (msg)
|
||||
Z_Free(msg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+6
-6
@@ -74,10 +74,10 @@ static int inet_aton(const char *cp, struct in_addr *addr)
|
||||
|
||||
#ifdef USE_WINSOCK2
|
||||
static HMODULE ipv6dll = NULL;
|
||||
typedef int (WSAAPI *p_getaddrinfo) (const char *node, const char *service,
|
||||
const struct my_addrinfo *hints,
|
||||
struct my_addrinfo **res);
|
||||
typedef void (WSAAPI *p_freeaddrinfo) (struct my_addrinfo *res);
|
||||
typedef int (WSAAPI *p_getaddrinfo) (const char *, const char *,
|
||||
const struct my_addrinfo *,
|
||||
struct my_addrinfo **);
|
||||
typedef void (WSAAPI *p_freeaddrinfo) (struct my_addrinfo *);
|
||||
|
||||
static p_getaddrinfo WS_getaddrinfo = NULL;
|
||||
static p_freeaddrinfo WS_freeaddrinfo = NULL;
|
||||
@@ -86,10 +86,10 @@ static HMODULE WS_getfunctions(HMODULE tmp)
|
||||
{
|
||||
if (tmp != NULL)
|
||||
{
|
||||
WS_getaddrinfo = (p_getaddrinfo)((void *)GetProcAddress(tmp, "getaddrinfo"));
|
||||
WS_getaddrinfo = (p_getaddrinfo)(LPVOID)GetProcAddress(tmp, "getaddrinfo");
|
||||
if (WS_getaddrinfo == NULL)
|
||||
return NULL;
|
||||
WS_freeaddrinfo = (p_freeaddrinfo)((void *)GetProcAddress(tmp, "freeaddrinfo"));
|
||||
WS_freeaddrinfo = (p_freeaddrinfo)(LPVOID)GetProcAddress(tmp, "freeaddrinfo");
|
||||
if (WS_freeaddrinfo == NULL)
|
||||
{
|
||||
WS_getaddrinfo = NULL;
|
||||
|
||||
@@ -226,10 +226,6 @@ void I_StartupMouse(void);
|
||||
*/
|
||||
void I_StartupMouse2(void);
|
||||
|
||||
/** \brief keyboard startup, shutdown, handler
|
||||
*/
|
||||
void I_StartupKeyboard(void);
|
||||
|
||||
/** \brief setup timer irq and user timer routine.
|
||||
*/
|
||||
void I_StartupTimer(void);
|
||||
|
||||
+23
-12
@@ -246,7 +246,8 @@ static size_t numbans = 0;
|
||||
static boolean SOCK_bannednode[MAXNETNODES+1]; /// \note do we really need the +1?
|
||||
static boolean init_tcp_driver = false;
|
||||
|
||||
static char port_name[8] = DEFAULTPORT;
|
||||
static const char *serverport_name = DEFAULTPORT;
|
||||
static const char *clientport_name;/* any port */
|
||||
|
||||
#ifndef NONET
|
||||
|
||||
@@ -924,6 +925,7 @@ static boolean UDP_Socket(void)
|
||||
#ifdef HAVE_IPV6
|
||||
const INT32 b_ipv6 = M_CheckParm("-ipv6");
|
||||
#endif
|
||||
const char *serv;
|
||||
|
||||
|
||||
for (s = 0; s < mysocketses; s++)
|
||||
@@ -939,11 +941,16 @@ static boolean UDP_Socket(void)
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
hints.ai_protocol = IPPROTO_UDP;
|
||||
|
||||
if (serverrunning)
|
||||
serv = serverport_name;
|
||||
else
|
||||
serv = clientport_name;
|
||||
|
||||
if (M_CheckParm("-bindaddr"))
|
||||
{
|
||||
while (M_IsNextParm())
|
||||
{
|
||||
gaie = I_getaddrinfo(M_GetNextParm(), port_name, &hints, &ai);
|
||||
gaie = I_getaddrinfo(M_GetNextParm(), serv, &hints, &ai);
|
||||
if (gaie == 0)
|
||||
{
|
||||
runp = ai;
|
||||
@@ -964,7 +971,7 @@ static boolean UDP_Socket(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
gaie = I_getaddrinfo("0.0.0.0", port_name, &hints, &ai);
|
||||
gaie = I_getaddrinfo("0.0.0.0", serv, &hints, &ai);
|
||||
if (gaie == 0)
|
||||
{
|
||||
runp = ai;
|
||||
@@ -979,8 +986,8 @@ static boolean UDP_Socket(void)
|
||||
#ifdef HAVE_MINIUPNPC
|
||||
if (UPNP_support)
|
||||
{
|
||||
I_UPnP_rem(port_name, "UDP");
|
||||
I_UPnP_add(NULL, port_name, "UDP");
|
||||
I_UPnP_rem(serverport_name, "UDP");
|
||||
I_UPnP_add(NULL, serverport_name, "UDP");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -997,7 +1004,7 @@ static boolean UDP_Socket(void)
|
||||
{
|
||||
while (M_IsNextParm())
|
||||
{
|
||||
gaie = I_getaddrinfo(M_GetNextParm(), port_name, &hints, &ai);
|
||||
gaie = I_getaddrinfo(M_GetNextParm(), serv, &hints, &ai);
|
||||
if (gaie == 0)
|
||||
{
|
||||
runp = ai;
|
||||
@@ -1018,7 +1025,7 @@ static boolean UDP_Socket(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
gaie = I_getaddrinfo("::", port_name, &hints, &ai);
|
||||
gaie = I_getaddrinfo("::", serv, &hints, &ai);
|
||||
if (gaie == 0)
|
||||
{
|
||||
runp = ai;
|
||||
@@ -1475,15 +1482,19 @@ boolean I_InitTcpNetwork(void)
|
||||
if (!I_InitTcpDriver())
|
||||
return false;
|
||||
|
||||
if (M_CheckParm("-port"))
|
||||
if (M_CheckParm("-port") || M_CheckParm("-serverport"))
|
||||
// Combined -udpport and -clientport into -port
|
||||
// As it was really redundant having two seperate parms that does the same thing
|
||||
/* Sorry Steel, I'm adding these back. But -udpport is a stupid name. */
|
||||
{
|
||||
if (M_IsNextParm())
|
||||
strcpy(port_name, M_GetNextParm());
|
||||
else
|
||||
strcpy(port_name, "0");
|
||||
/*
|
||||
If it's NULL, that's okay! Because then
|
||||
we'll get a random port from getaddrinfo.
|
||||
*/
|
||||
serverport_name = M_GetNextParm();
|
||||
}
|
||||
if (M_CheckParm("-clientport"))
|
||||
clientport_name = M_GetNextParm();
|
||||
|
||||
// parse network game options,
|
||||
if (M_CheckParm("-server") || dedicated)
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
// SONIC ROBO BLAST 2 KART
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2020 by James R.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file i_threads.h
|
||||
/// \brief Multithreading abstraction
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
|
||||
#ifndef I_THREADS_H
|
||||
#define I_THREADS_H
|
||||
|
||||
typedef void (*I_thread_fn)(void *userdata);
|
||||
|
||||
typedef void * I_mutex;
|
||||
typedef void * I_cond;
|
||||
|
||||
void I_start_threads (void);
|
||||
void I_stop_threads (void);
|
||||
|
||||
void I_spawn_thread (const char *name, I_thread_fn, void *userdata);
|
||||
|
||||
/* check in your thread whether to return early */
|
||||
int I_thread_is_stopped (void);
|
||||
|
||||
void I_lock_mutex (I_mutex *);
|
||||
void I_unlock_mutex (I_mutex);
|
||||
|
||||
void I_hold_cond (I_cond *, I_mutex);
|
||||
|
||||
void I_wake_one_cond (I_cond *);
|
||||
void I_wake_all_cond (I_cond *);
|
||||
|
||||
#endif/*I_THREADS_H*/
|
||||
#endif/*HAVE_THREADS*/
|
||||
+1
-7
@@ -20,9 +20,6 @@
|
||||
#include "z_zone.h"
|
||||
#include "d_player.h"
|
||||
#include "lzf.h"
|
||||
#ifdef HWRENDER
|
||||
#include "hardware/hw_light.h"
|
||||
#endif
|
||||
|
||||
// Hey, moron! If you change this table, don't forget about the sprite enum in info.h and the sprite lights in hw_light.c!
|
||||
char sprnames[NUMSPRITES + 1][5] =
|
||||
@@ -20101,7 +20098,7 @@ void P_PatchInfoTables(void)
|
||||
char *tempname;
|
||||
|
||||
#if NUMSPRITEFREESLOTS > 1000
|
||||
"Update P_PatchInfoTables, you big dumb head"
|
||||
#error "Update P_PatchInfoTables, you big dumb head"
|
||||
#endif
|
||||
|
||||
// empty out free slots
|
||||
@@ -20113,9 +20110,6 @@ void P_PatchInfoTables(void)
|
||||
tempname[2] = (char)('0' + (char)(((i-SPR_FIRSTFREESLOT+1)/10)%10));
|
||||
tempname[3] = (char)('0' + (char)((i-SPR_FIRSTFREESLOT+1)%10));
|
||||
tempname[4] = '\0';
|
||||
#ifdef HWRENDER
|
||||
t_lspr[i] = &lspr[NOLIGHT];
|
||||
#endif
|
||||
}
|
||||
sprnames[i][0] = '\0'; // i == NUMSPRITES
|
||||
memset(&states[S_FIRSTFREESLOT], 0, sizeof (state_t) * NUMSTATEFREESLOTS);
|
||||
|
||||
+2
-2
@@ -226,7 +226,7 @@ void A_NapalmScatter();
|
||||
void A_SpawnFreshCopy();
|
||||
|
||||
// ratio of states to sprites to mobj types is roughly 6 : 1 : 1
|
||||
#define NUMMOBJFREESLOTS 256
|
||||
#define NUMMOBJFREESLOTS 512
|
||||
#define NUMSPRITEFREESLOTS NUMMOBJFREESLOTS
|
||||
#define NUMSTATEFREESLOTS (NUMMOBJFREESLOTS*8)
|
||||
|
||||
@@ -4301,7 +4301,7 @@ typedef enum mobj_type
|
||||
|
||||
// Castle Eggman Scenery
|
||||
MT_CHAIN, // CEZ Chain
|
||||
MT_FLAME, // Flame (has corona)
|
||||
MT_FLAME, // Flame
|
||||
MT_EGGSTATUE, // Eggman Statue
|
||||
MT_MACEPOINT, // Mace rotation point
|
||||
MT_SWINGMACEPOINT, // Mace swinging point
|
||||
|
||||
+279
-124
@@ -409,7 +409,7 @@ UINT8 colortranslations[MAXTRANSLATIONS][16] = {
|
||||
// 0.0722 to blue
|
||||
// (See this same define in hw_md2.c!)
|
||||
#define SETBRIGHTNESS(brightness,r,g,b) \
|
||||
brightness = (UINT8)(((1063*((UINT16)r)/5000) + (3576*((UINT16)g)/5000) + (361*((UINT16)b)/5000)) / 3)
|
||||
brightness = (UINT8)(((1063*(UINT16)(r))/5000) + ((3576*(UINT16)(g))/5000) + ((361*(UINT16)(b))/5000))
|
||||
|
||||
/** \brief Generates the rainbow colourmaps that are used when a player has the invincibility power
|
||||
|
||||
@@ -666,31 +666,31 @@ static INT32 K_KartItemOddsRace[NUMKARTRESULTS][10] =
|
||||
/*Jawz x2*/ { 0, 0, 0, 1, 2, 0, 0, 0, 0, 0 } // Jawz x2
|
||||
};
|
||||
|
||||
static INT32 K_KartItemOddsBattle[NUMKARTRESULTS][6] =
|
||||
static INT32 K_KartItemOddsBattle[NUMKARTRESULTS][2] =
|
||||
{
|
||||
//P-Odds 0 1 2 3 4 5
|
||||
/*Sneaker*/ { 3, 2, 2, 2, 0, 2 }, // Sneaker
|
||||
/*Rocket Sneaker*/ { 0, 0, 0, 0, 0, 0 }, // Rocket Sneaker
|
||||
/*Invincibility*/ { 0, 1, 2, 3, 4, 2 }, // Invincibility
|
||||
/*Banana*/ { 2, 1, 0, 0, 0, 0 }, // Banana
|
||||
/*Eggman Monitor*/ { 1, 1, 0, 0, 0, 0 }, // Eggman Monitor
|
||||
/*Orbinaut*/ { 6, 2, 1, 0, 0, 0 }, // Orbinaut
|
||||
/*Jawz*/ { 3, 3, 3, 2, 0, 2 }, // Jawz
|
||||
/*Mine*/ { 2, 3, 3, 1, 0, 2 }, // Mine
|
||||
/*Ballhog*/ { 0, 1, 2, 1, 0, 2 }, // Ballhog
|
||||
/*Self-Propelled Bomb*/ { 0, 0, 0, 0, 0, 0 }, // Self-Propelled Bomb
|
||||
/*Grow*/ { 0, 0, 1, 2, 4, 2 }, // Grow
|
||||
/*Shrink*/ { 0, 0, 0, 0, 0, 0 }, // Shrink
|
||||
/*Thunder Shield*/ { 0, 0, 0, 0, 0, 0 }, // Thunder Shield
|
||||
/*Hyudoro*/ { 1, 1, 0, 0, 0, 0 }, // Hyudoro
|
||||
/*Pogo Spring*/ { 1, 1, 0, 0, 0, 0 }, // Pogo Spring
|
||||
/*Kitchen Sink*/ { 0, 0, 0, 0, 0, 0 }, // Kitchen Sink
|
||||
/*Sneaker x3*/ { 0, 0, 0, 2, 4, 2 }, // Sneaker x3
|
||||
/*Banana x3*/ { 1, 2, 1, 0, 0, 0 }, // Banana x3
|
||||
/*Banana x10*/ { 0, 0, 1, 1, 0, 2 }, // Banana x10
|
||||
/*Orbinaut x3*/ { 0, 1, 2, 1, 0, 0 }, // Orbinaut x3
|
||||
/*Orbinaut x4*/ { 0, 0, 1, 3, 4, 2 }, // Orbinaut x4
|
||||
/*Jawz x2*/ { 0, 0, 1, 2, 4, 2 } // Jawz x2
|
||||
//P-Odds 0 1
|
||||
/*Sneaker*/ { 2, 1 }, // Sneaker
|
||||
/*Rocket Sneaker*/ { 0, 0 }, // Rocket Sneaker
|
||||
/*Invincibility*/ { 2, 1 }, // Invincibility
|
||||
/*Banana*/ { 1, 0 }, // Banana
|
||||
/*Eggman Monitor*/ { 1, 0 }, // Eggman Monitor
|
||||
/*Orbinaut*/ { 8, 0 }, // Orbinaut
|
||||
/*Jawz*/ { 8, 1 }, // Jawz
|
||||
/*Mine*/ { 4, 1 }, // Mine
|
||||
/*Ballhog*/ { 2, 1 }, // Ballhog
|
||||
/*Self-Propelled Bomb*/ { 0, 0 }, // Self-Propelled Bomb
|
||||
/*Grow*/ { 2, 1 }, // Grow
|
||||
/*Shrink*/ { 0, 0 }, // Shrink
|
||||
/*Thunder Shield*/ { 0, 0 }, // Thunder Shield
|
||||
/*Hyudoro*/ { 2, 0 }, // Hyudoro
|
||||
/*Pogo Spring*/ { 2, 0 }, // Pogo Spring
|
||||
/*Kitchen Sink*/ { 0, 0 }, // Kitchen Sink
|
||||
/*Sneaker x3*/ { 0, 1 }, // Sneaker x3
|
||||
/*Banana x3*/ { 1, 0 }, // Banana x3
|
||||
/*Banana x10*/ { 0, 1 }, // Banana x10
|
||||
/*Orbinaut x3*/ { 2, 0 }, // Orbinaut x3
|
||||
/*Orbinaut x4*/ { 1, 1 }, // Orbinaut x4
|
||||
/*Jawz x2*/ { 2, 1 } // Jawz x2
|
||||
};
|
||||
|
||||
/** \brief Item Roulette for Kart
|
||||
@@ -898,6 +898,7 @@ static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed, boolean sp
|
||||
newodds = 0;
|
||||
else
|
||||
POWERITEMODDS(newodds);
|
||||
break;
|
||||
case KITEM_HYUDORO:
|
||||
if ((hyubgone > 0) || COOLDOWNONSTART)
|
||||
newodds = 0;
|
||||
@@ -922,12 +923,15 @@ static INT32 K_FindUseodds(player_t *player, fixed_t mashed, INT32 pingame, INT3
|
||||
UINT8 distlen = 0;
|
||||
boolean oddsvalid[10];
|
||||
|
||||
// Unused now, oops :V
|
||||
(void)bestbumper;
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
INT32 j;
|
||||
boolean available = false;
|
||||
|
||||
if (G_BattleGametype() && i > 5)
|
||||
if (G_BattleGametype() && i > 1)
|
||||
{
|
||||
oddsvalid[i] = false;
|
||||
break;
|
||||
@@ -961,24 +965,20 @@ static INT32 K_FindUseodds(player_t *player, fixed_t mashed, INT32 pingame, INT3
|
||||
|
||||
if (G_BattleGametype()) // Battle Mode
|
||||
{
|
||||
if (oddsvalid[0]) SETUPDISTTABLE(0,1);
|
||||
if (oddsvalid[1]) SETUPDISTTABLE(1,1);
|
||||
if (oddsvalid[2]) SETUPDISTTABLE(2,1);
|
||||
if (oddsvalid[3]) SETUPDISTTABLE(3,1);
|
||||
if (oddsvalid[4]) SETUPDISTTABLE(4,1);
|
||||
|
||||
if (player->kartstuff[k_roulettetype] == 1 && oddsvalid[5]) // 5 is the extreme odds of player-controlled "Karma" items
|
||||
useodds = 5;
|
||||
if (player->kartstuff[k_roulettetype] == 1 && oddsvalid[1] == true)
|
||||
{
|
||||
// 1 is the extreme odds of player-controlled "Karma" items
|
||||
useodds = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
SINT8 wantedpos = (bestbumper-player->kartstuff[k_bumper]); // 0 is the best player's bumper count, 1 is a bumper below best, 2 is two bumpers below, etc
|
||||
if (K_IsPlayerWanted(player))
|
||||
wantedpos++;
|
||||
if (wantedpos > 4) // Don't run off into karma items
|
||||
wantedpos = 4;
|
||||
if (wantedpos < 0) // Don't go below somehow
|
||||
wantedpos = 0;
|
||||
useodds = disttable[(wantedpos * distlen) / 5];
|
||||
useodds = 0;
|
||||
|
||||
if (oddsvalid[0] == false && oddsvalid[1] == true)
|
||||
{
|
||||
// try to use karma odds as a fallback
|
||||
useodds = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1061,8 +1061,12 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
|
||||
bestbumper = players[i].kartstuff[k_bumper];
|
||||
}
|
||||
|
||||
// No forced SPB in 1v1s, it has to be randomly rolled
|
||||
if (pingame <= 2)
|
||||
dontforcespb = true;
|
||||
|
||||
// This makes the roulette produce the random noises.
|
||||
if ((player->kartstuff[k_itemroulette] % 3) == 1 && P_IsDisplayPlayer(player))
|
||||
if ((player->kartstuff[k_itemroulette] % 3) == 1 && P_IsDisplayPlayer(player) && !demo.freecam)
|
||||
{
|
||||
#define PLAYROULETTESND S_StartSound(NULL, sfx_itrol1 + ((player->kartstuff[k_itemroulette] / 3) % 8))
|
||||
for (i = 0; i <= splitscreen; i++)
|
||||
@@ -1096,7 +1100,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
|
||||
//player->kartstuff[k_itemblinkmode] = 1;
|
||||
player->kartstuff[k_itemroulette] = 0;
|
||||
player->kartstuff[k_roulettetype] = 0;
|
||||
if (P_IsDisplayPlayer(player))
|
||||
if (P_IsDisplayPlayer(player) && !demo.freecam)
|
||||
S_StartSound(NULL, sfx_itrole);
|
||||
return;
|
||||
}
|
||||
@@ -1109,7 +1113,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
|
||||
player->kartstuff[k_itemblinkmode] = 2;
|
||||
player->kartstuff[k_itemroulette] = 0;
|
||||
player->kartstuff[k_roulettetype] = 0;
|
||||
if (P_IsDisplayPlayer(player))
|
||||
if (P_IsDisplayPlayer(player) && !demo.freecam)
|
||||
S_StartSound(NULL, sfx_dbgsal);
|
||||
return;
|
||||
}
|
||||
@@ -1141,7 +1145,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
|
||||
player->kartstuff[k_itemamount] = 1;
|
||||
}
|
||||
|
||||
if (P_IsDisplayPlayer(player))
|
||||
if (P_IsDisplayPlayer(player) && !demo.freecam)
|
||||
S_StartSound(NULL, ((player->kartstuff[k_roulettetype] == 1) ? sfx_itrolk : (mashed ? sfx_itrolm : sfx_itrolf)));
|
||||
|
||||
player->kartstuff[k_itemblink] = TICRATE;
|
||||
@@ -1372,30 +1376,72 @@ void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid)
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief Checks that the player is on an offroad subsector for realsies
|
||||
/** \brief Checks that the player is on an offroad subsector for realsies. Also accounts for line riding to prevent cheese.
|
||||
|
||||
\param mo player mobj object
|
||||
|
||||
\return boolean
|
||||
*/
|
||||
static UINT8 K_CheckOffroadCollide(mobj_t *mo, sector_t *sec)
|
||||
static UINT8 K_CheckOffroadCollide(mobj_t *mo)
|
||||
{
|
||||
UINT8 i;
|
||||
sector_t *sec2;
|
||||
// Check for sectors in touching_sectorlist
|
||||
UINT8 i; // special type iter
|
||||
msecnode_t *node; // touching_sectorlist iter
|
||||
sector_t *s; // main sector shortcut
|
||||
sector_t *s2; // FOF sector shortcut
|
||||
ffloor_t *rover; // FOF
|
||||
|
||||
fixed_t flr;
|
||||
fixed_t cel; // floor & ceiling for height checks to make sure we're touching the offroad sector.
|
||||
|
||||
I_Assert(mo != NULL);
|
||||
I_Assert(!P_MobjWasRemoved(mo));
|
||||
|
||||
sec2 = P_ThingOnSpecial3DFloor(mo);
|
||||
|
||||
for (i = 2; i < 5; i++)
|
||||
for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next)
|
||||
{
|
||||
if ((sec2 && GETSECSPECIAL(sec2->special, 1) == i)
|
||||
|| (P_IsObjectOnRealGround(mo, sec) && GETSECSPECIAL(sec->special, 1) == i))
|
||||
return i-1;
|
||||
}
|
||||
if (!node->m_sector)
|
||||
break; // shouldn't happen.
|
||||
|
||||
return 0;
|
||||
s = node->m_sector;
|
||||
// 1: Check for the main sector, make sure we're on the floor of that sector and see if we can apply offroad.
|
||||
// Make arbitrary Z checks because we want to check for 1 sector in particular, we don't want to affect the player if the offroad sector is way below them and they're lineriding a normal sector above.
|
||||
|
||||
flr = P_MobjFloorZ(mo, s, s, mo->x, mo->y, NULL, false, true);
|
||||
cel = P_MobjCeilingZ(mo, s, s, mo->x, mo->y, NULL, true, true); // get Z coords of both floors and ceilings for this sector (this accounts for slopes properly.)
|
||||
// NOTE: we don't use P_GetZAt with our x/y directly because the mobj won't have the same height because of its hitbox on the slope. Complex garbage but tldr it doesn't work.
|
||||
|
||||
if ( ((s->flags & SF_FLIPSPECIAL_FLOOR) && mo->z == flr) // floor check
|
||||
|| ((mo->eflags & MFE_VERTICALFLIP && (s->flags & SF_FLIPSPECIAL_CEILING) && (mo->z + mo->height) == cel)) ) // ceiling check.
|
||||
|
||||
for (i = 2; i < 5; i++) // check for sector special
|
||||
|
||||
if (GETSECSPECIAL(s->special, 1) == i)
|
||||
return i-1; // return offroad type
|
||||
|
||||
// 2: If we're here, we haven't found anything. So let's try looking for FOFs in the sectors using the same logic.
|
||||
for (rover = s->ffloors; rover; rover = rover->next)
|
||||
{
|
||||
if (!(rover->flags & FF_EXISTS)) // This FOF doesn't exist anymore.
|
||||
continue;
|
||||
|
||||
s2 = §ors[rover->secnum]; // makes things easier for us
|
||||
|
||||
flr = P_GetFOFBottomZ(mo, s, rover, mo->x, mo->y, NULL);
|
||||
cel = P_GetFOFTopZ(mo, s, rover, mo->x, mo->y, NULL); // Z coords for fof top/bottom.
|
||||
|
||||
// we will do essentially the same checks as above instead of bothering with top/bottom height of the FOF.
|
||||
// Reminder that an FOF's floor is its bottom, silly!
|
||||
if ( ((s2->flags & SF_FLIPSPECIAL_FLOOR) && mo->z == cel) // "floor" check
|
||||
|| ((s2->flags & SF_FLIPSPECIAL_CEILING) && (mo->z + mo->height) == flr) ) // "ceiling" check.
|
||||
|
||||
for (i = 2; i < 5; i++) // check for sector special
|
||||
|
||||
if (GETSECSPECIAL(s2->special, 1) == i)
|
||||
return i-1; // return offroad type
|
||||
|
||||
}
|
||||
}
|
||||
return 0; // couldn't find any offroad
|
||||
}
|
||||
|
||||
/** \brief Updates the Player's offroad value once per frame
|
||||
@@ -1407,14 +1453,12 @@ static UINT8 K_CheckOffroadCollide(mobj_t *mo, sector_t *sec)
|
||||
static void K_UpdateOffroad(player_t *player)
|
||||
{
|
||||
fixed_t offroad;
|
||||
sector_t *nextsector = R_PointInSubsector(
|
||||
player->mo->x + player->mo->momx*2, player->mo->y + player->mo->momy*2)->sector;
|
||||
UINT8 offroadstrength = K_CheckOffroadCollide(player->mo, nextsector);
|
||||
UINT8 offroadstrength = K_CheckOffroadCollide(player->mo);
|
||||
|
||||
// If you are in offroad, a timer starts.
|
||||
if (offroadstrength)
|
||||
{
|
||||
if (K_CheckOffroadCollide(player->mo, player->mo->subsector->sector) && player->kartstuff[k_offroad] == 0)
|
||||
if (/*K_CheckOffroadCollide(player->mo) &&*/ player->kartstuff[k_offroad] == 0) // With the way offroad is detected now that first check is no longer necessary. -Lat'
|
||||
player->kartstuff[k_offroad] = (TICRATE/2);
|
||||
|
||||
if (player->kartstuff[k_offroad] > 0)
|
||||
@@ -2893,14 +2937,12 @@ void K_SpawnBoostTrail(player_t *player)
|
||||
{
|
||||
newx = player->mo->x + P_ReturnThrustX(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(24*FRACUNIT, player->mo->scale));
|
||||
newy = player->mo->y + P_ReturnThrustY(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(24*FRACUNIT, player->mo->scale));
|
||||
#ifdef ESLOPE
|
||||
if (player->mo->standingslope)
|
||||
{
|
||||
ground = P_GetZAt(player->mo->standingslope, newx, newy);
|
||||
if (player->mo->eflags & MFE_VERTICALFLIP)
|
||||
ground -= FixedMul(mobjinfo[MT_SNEAKERTRAIL].height, player->mo->scale);
|
||||
}
|
||||
#endif
|
||||
flame = P_SpawnMobj(newx, newy, ground, MT_SNEAKERTRAIL);
|
||||
|
||||
P_SetTarget(&flame->target, player->mo);
|
||||
@@ -3159,11 +3201,11 @@ static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t map
|
||||
if (dir == -1)
|
||||
{
|
||||
// Shoot backward
|
||||
mo = K_SpawnKartMissile(player->mo, mapthing, player->mo->angle + ANGLE_180 - 0x06000000, 0, PROJSPEED/4);
|
||||
K_SpawnKartMissile(player->mo, mapthing, player->mo->angle + ANGLE_180 - 0x03000000, 0, PROJSPEED/4);
|
||||
K_SpawnKartMissile(player->mo, mapthing, player->mo->angle + ANGLE_180, 0, PROJSPEED/4);
|
||||
K_SpawnKartMissile(player->mo, mapthing, player->mo->angle + ANGLE_180 + 0x03000000, 0, PROJSPEED/4);
|
||||
K_SpawnKartMissile(player->mo, mapthing, player->mo->angle + ANGLE_180 + 0x06000000, 0, PROJSPEED/4);
|
||||
mo = K_SpawnKartMissile(player->mo, mapthing, player->mo->angle + ANGLE_180 - 0x06000000, 0, PROJSPEED/16);
|
||||
K_SpawnKartMissile(player->mo, mapthing, player->mo->angle + ANGLE_180 - 0x03000000, 0, PROJSPEED/16);
|
||||
K_SpawnKartMissile(player->mo, mapthing, player->mo->angle + ANGLE_180, 0, PROJSPEED/16);
|
||||
K_SpawnKartMissile(player->mo, mapthing, player->mo->angle + ANGLE_180 + 0x03000000, 0, PROJSPEED/16);
|
||||
K_SpawnKartMissile(player->mo, mapthing, player->mo->angle + ANGLE_180 + 0x06000000, 0, PROJSPEED/16);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3180,7 +3222,7 @@ static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t map
|
||||
if (dir == -1 && mapthing != MT_SPB)
|
||||
{
|
||||
// Shoot backward
|
||||
mo = K_SpawnKartMissile(player->mo, mapthing, player->mo->angle + ANGLE_180, 0, PROJSPEED/2);
|
||||
mo = K_SpawnKartMissile(player->mo, mapthing, player->mo->angle + ANGLE_180, 0, PROJSPEED/8);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3312,7 +3354,8 @@ void K_PuntMine(mobj_t *thismine, mobj_t *punter)
|
||||
if (!thismine || P_MobjWasRemoved(thismine))
|
||||
return;
|
||||
|
||||
if (thismine->type == MT_SSMINE_SHIELD) // Create a new mine
|
||||
//This guarantees you hit a mine being dragged
|
||||
if (thismine->type == MT_SSMINE_SHIELD) // Create a new mine, and clean up the old one
|
||||
{
|
||||
mine = P_SpawnMobj(thismine->x, thismine->y, thismine->z, MT_SSMINE);
|
||||
P_SetTarget(&mine->target, thismine->target);
|
||||
@@ -3320,7 +3363,19 @@ void K_PuntMine(mobj_t *thismine, mobj_t *punter)
|
||||
mine->flags2 = thismine->flags2;
|
||||
mine->floorz = thismine->floorz;
|
||||
mine->ceilingz = thismine->ceilingz;
|
||||
|
||||
//Since we aren't using P_KillMobj, we need to clean up the hnext reference
|
||||
{
|
||||
P_SetTarget(&thismine->target->hnext, NULL); //target is the player who owns the mine
|
||||
thismine->target->player->kartstuff[k_bananadrag] = 0;
|
||||
thismine->target->player->kartstuff[k_itemheld] = 0;
|
||||
|
||||
if (--thismine->target->player->kartstuff[k_itemamount] <= 0)
|
||||
thismine->target->player->kartstuff[k_itemtype] = KITEM_NONE;
|
||||
}
|
||||
|
||||
P_RemoveMobj(thismine);
|
||||
|
||||
}
|
||||
else
|
||||
mine = thismine;
|
||||
@@ -3604,9 +3659,7 @@ void K_DoPogoSpring(mobj_t *mo, fixed_t vertispeed, UINT8 sound)
|
||||
if (mo->eflags & MFE_SPRUNG)
|
||||
return;
|
||||
|
||||
#ifdef ESLOPE
|
||||
mo->standingslope = NULL;
|
||||
#endif
|
||||
|
||||
mo->eflags |= MFE_SPRUNG;
|
||||
|
||||
@@ -3870,6 +3923,62 @@ void K_DropItems(player_t *player)
|
||||
K_StripItems(player);
|
||||
}
|
||||
|
||||
void K_DropRocketSneaker(player_t *player)
|
||||
{
|
||||
mobj_t *shoe = player->mo;
|
||||
fixed_t flingangle;
|
||||
boolean leftshoe = true; //left shoe is first
|
||||
|
||||
if (!(player->mo && !P_MobjWasRemoved(player->mo) && player->mo->hnext && !P_MobjWasRemoved(player->mo->hnext)))
|
||||
return;
|
||||
|
||||
while ((shoe = shoe->hnext) && !P_MobjWasRemoved(shoe))
|
||||
{
|
||||
if (shoe->type != MT_ROCKETSNEAKER)
|
||||
return; //woah, not a rocketsneaker, bail! safeguard in case this gets used when you're holding non-rocketsneakers
|
||||
|
||||
shoe->flags2 &= ~MF2_DONTDRAW;
|
||||
shoe->flags &= ~MF_NOGRAVITY;
|
||||
shoe->angle += ANGLE_45;
|
||||
|
||||
if (shoe->eflags & MFE_VERTICALFLIP)
|
||||
shoe->z -= shoe->height;
|
||||
else
|
||||
shoe->z += shoe->height;
|
||||
|
||||
//left shoe goes off tot eh left, right shoe off to the right
|
||||
if (leftshoe)
|
||||
flingangle = -(ANG60);
|
||||
else
|
||||
flingangle = ANG60;
|
||||
|
||||
S_StartSound(shoe, shoe->info->deathsound);
|
||||
P_SetObjectMomZ(shoe, 8*FRACUNIT, false);
|
||||
P_InstaThrust(shoe, R_PointToAngle2(shoe->target->x, shoe->target->y, shoe->x, shoe->y)+flingangle, 16*FRACUNIT);
|
||||
shoe->momx += shoe->target->momx;
|
||||
shoe->momy += shoe->target->momy;
|
||||
shoe->momz += shoe->target->momz;
|
||||
shoe->extravalue2 = 1;
|
||||
|
||||
leftshoe = false;
|
||||
}
|
||||
P_SetTarget(&player->mo->hnext, NULL);
|
||||
player->kartstuff[k_rocketsneakertimer] = 0;
|
||||
}
|
||||
|
||||
void K_DropKitchenSink(player_t *player)
|
||||
{
|
||||
if (!(player->mo && !P_MobjWasRemoved(player->mo) && player->mo->hnext && !P_MobjWasRemoved(player->mo->hnext)))
|
||||
return;
|
||||
|
||||
if (player->mo->hnext->type != MT_SINK_SHIELD)
|
||||
return; //so we can just call this function regardless of what is being held
|
||||
|
||||
P_KillMobj(player->mo->hnext, NULL, NULL);
|
||||
|
||||
P_SetTarget(&player->mo->hnext, NULL);
|
||||
}
|
||||
|
||||
// When an item in the hnext chain dies.
|
||||
void K_RepairOrbitChain(mobj_t *orbit)
|
||||
{
|
||||
@@ -4292,14 +4401,22 @@ player_t *K_FindJawzTarget(mobj_t *actor, player_t *source)
|
||||
static void K_UpdateEngineSounds(player_t *player, ticcmd_t *cmd)
|
||||
{
|
||||
const INT32 numsnds = 13;
|
||||
|
||||
const fixed_t closedist = 160*FRACUNIT;
|
||||
const fixed_t fardist = 1536*FRACUNIT;
|
||||
|
||||
const UINT8 dampenval = 48; // 255 * 48 = close enough to FRACUNIT/6
|
||||
|
||||
INT32 class, s, w; // engine class number
|
||||
|
||||
UINT8 volume = 255;
|
||||
fixed_t volumedampen = 0;
|
||||
fixed_t volumedampen = FRACUNIT;
|
||||
|
||||
INT32 targetsnd = 0;
|
||||
INT32 i;
|
||||
|
||||
s = (player->kartspeed-1)/3;
|
||||
w = (player->kartweight-1)/3;
|
||||
s = (player->kartspeed - 1) / 3;
|
||||
w = (player->kartweight - 1) / 3;
|
||||
|
||||
#define LOCKSTAT(stat) \
|
||||
if (stat < 0) { stat = 0; } \
|
||||
@@ -4308,81 +4425,114 @@ static void K_UpdateEngineSounds(player_t *player, ticcmd_t *cmd)
|
||||
LOCKSTAT(w);
|
||||
#undef LOCKSTAT
|
||||
|
||||
class = s+(3*w);
|
||||
class = s + (3*w);
|
||||
|
||||
// Silence the engines
|
||||
if (leveltime < 8 || player->spectator || player->exiting)
|
||||
{
|
||||
player->kartstuff[k_enginesnd] = 0; // Reset sound number
|
||||
// Silence the engines, and reset sound number while we're at it.
|
||||
player->kartstuff[k_enginesnd] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if ((leveltime % 8) != ((player-players) % 8)) // Per-player offset, to make engines sound distinct!
|
||||
#else
|
||||
if (leveltime % 8) // .25 seconds of wait time between engine sounds
|
||||
if (leveltime % 8)
|
||||
#endif
|
||||
{
|
||||
// .25 seconds of wait time between each engine sound playback
|
||||
return;
|
||||
}
|
||||
|
||||
if ((leveltime >= starttime-(2*TICRATE) && leveltime <= starttime) || (player->kartstuff[k_respawn] == 1)) // Startup boosts
|
||||
if ((leveltime >= starttime-(2*TICRATE) && leveltime <= starttime) || (player->kartstuff[k_respawn] == 1))
|
||||
{
|
||||
// Startup boosts only want to check for BT_ACCELERATE being pressed.
|
||||
targetsnd = ((cmd->buttons & BT_ACCELERATE) ? 12 : 0);
|
||||
}
|
||||
else
|
||||
targetsnd = (((6*cmd->forwardmove)/25) + ((player->speed / mapobjectscale)/5))/2;
|
||||
{
|
||||
// Average out the value of forwardmove and the speed that you're moving at.
|
||||
targetsnd = (((6 * cmd->forwardmove) / 25) + ((player->speed / mapobjectscale) / 5)) / 2;
|
||||
}
|
||||
|
||||
if (targetsnd < 0)
|
||||
targetsnd = 0;
|
||||
if (targetsnd > 12)
|
||||
targetsnd = 12;
|
||||
if (targetsnd < 0) { targetsnd = 0; }
|
||||
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]--;
|
||||
if (player->kartstuff[k_enginesnd] < targetsnd) { player->kartstuff[k_enginesnd]++; }
|
||||
if (player->kartstuff[k_enginesnd] > targetsnd) { player->kartstuff[k_enginesnd]--; }
|
||||
|
||||
if (player->kartstuff[k_enginesnd] < 0)
|
||||
player->kartstuff[k_enginesnd] = 0;
|
||||
if (player->kartstuff[k_enginesnd] > 12)
|
||||
player->kartstuff[k_enginesnd] = 12;
|
||||
if (player->kartstuff[k_enginesnd] < 0) { player->kartstuff[k_enginesnd] = 0; }
|
||||
if (player->kartstuff[k_enginesnd] > 12) { player->kartstuff[k_enginesnd] = 12; }
|
||||
|
||||
// This code calculates how many players (and thus, how many engine sounds) are within ear shot,
|
||||
// and rebalances the volume of your engine sound based on how far away they are.
|
||||
|
||||
// This results in multiple things:
|
||||
// - When on your own, you will hear your own engine sound extremely clearly.
|
||||
// - When you were alone but someone is gaining on you, yours will go quiet, and you can hear theirs more clearly.
|
||||
// - When around tons of people, engine sounds will try to rebalance to not be as obnoxious.
|
||||
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
UINT8 thisvol = 0;
|
||||
fixed_t dist;
|
||||
|
||||
if (!playeringame[i] || !players[i].mo || players[i].spectator || players[i].exiting)
|
||||
continue;
|
||||
|
||||
if (P_IsDisplayPlayer(&players[i]))
|
||||
if (!playeringame[i] || !players[i].mo)
|
||||
{
|
||||
volumedampen += FRACUNIT; // We already know what this is gonna be, let's not waste our time.
|
||||
// This player doesn't exist.
|
||||
continue;
|
||||
}
|
||||
|
||||
dist = P_AproxDistance(P_AproxDistance(player->mo->x-players[i].mo->x,
|
||||
player->mo->y-players[i].mo->y), player->mo->z-players[i].mo->z) / 2;
|
||||
if (players[i].spectator || players[i].exiting)
|
||||
{
|
||||
// This player isn't playing an engine sound.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (player == &players[i] || P_IsDisplayPlayer(&players[i]))
|
||||
{
|
||||
// Don't dampen yourself!
|
||||
continue;
|
||||
}
|
||||
|
||||
dist = P_AproxDistance(
|
||||
P_AproxDistance(
|
||||
player->mo->x - players[i].mo->x,
|
||||
player->mo->y - players[i].mo->y),
|
||||
player->mo->z - players[i].mo->z) / 2;
|
||||
|
||||
dist = FixedDiv(dist, mapobjectscale);
|
||||
|
||||
if (dist > 1536<<FRACBITS)
|
||||
if (dist > fardist)
|
||||
{
|
||||
// ENEMY OUT OF RANGE !
|
||||
continue;
|
||||
else if (dist < 160<<FRACBITS) // engine sounds' approx. range
|
||||
}
|
||||
else if (dist < closedist)
|
||||
{
|
||||
// engine sounds' approx. range
|
||||
thisvol = 255;
|
||||
}
|
||||
else
|
||||
thisvol = (15 * (((160<<FRACBITS) - dist)>>FRACBITS)) / (((1536<<FRACBITS)-(160<<FRACBITS))>>(FRACBITS+4));
|
||||
{
|
||||
thisvol = (15 * ((closedist - dist) / FRACUNIT)) / ((fardist - closedist) >> (FRACBITS+4));
|
||||
}
|
||||
|
||||
if (thisvol == 0)
|
||||
continue;
|
||||
|
||||
volumedampen += (thisvol * 257); // 255 * 257 = FRACUNIT
|
||||
volumedampen += (thisvol * dampenval);
|
||||
}
|
||||
|
||||
if (volumedampen > FRACUNIT)
|
||||
volume = FixedDiv(volume<<FRACBITS, volumedampen)>>FRACBITS;
|
||||
{
|
||||
volume = FixedDiv(volume * FRACUNIT, volumedampen) / FRACUNIT;
|
||||
}
|
||||
|
||||
if (volume <= 0) // Might as well
|
||||
if (volume <= 0)
|
||||
{
|
||||
// Don't need to play the sound at all.
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
static void K_UpdateInvincibilitySounds(player_t *player)
|
||||
@@ -4490,6 +4640,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
|
||||
fast->momx = 3*player->mo->momx/4;
|
||||
fast->momy = 3*player->mo->momy/4;
|
||||
fast->momz = 3*player->mo->momz/4;
|
||||
P_SetTarget(&fast->target, player->mo); // easier lua access
|
||||
K_MatchGenericExtraFlags(fast, player->mo);
|
||||
}
|
||||
|
||||
@@ -5195,12 +5346,12 @@ void K_KartUpdatePosition(player_t *player)
|
||||
//
|
||||
void K_StripItems(player_t *player)
|
||||
{
|
||||
K_DropRocketSneaker(player);
|
||||
K_DropKitchenSink(player);
|
||||
player->kartstuff[k_itemtype] = KITEM_NONE;
|
||||
player->kartstuff[k_itemamount] = 0;
|
||||
player->kartstuff[k_itemheld] = 0;
|
||||
|
||||
player->kartstuff[k_rocketsneakertimer] = 0;
|
||||
|
||||
if (!player->kartstuff[k_itemroulette] || player->kartstuff[k_roulettetype] != 2)
|
||||
{
|
||||
player->kartstuff[k_itemroulette] = 0;
|
||||
@@ -8637,7 +8788,7 @@ void K_drawKartFreePlay(UINT32 flashtime)
|
||||
return;
|
||||
|
||||
V_DrawKartString((BASEVIDWIDTH - (LAPS_X+1)) - (12*9), // mirror the laps thingy
|
||||
LAPS_Y+3, V_SNAPTOBOTTOM|V_SNAPTORIGHT, "FREE PLAY");
|
||||
LAPS_Y+3, V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_HUDTRANS, "FREE PLAY");
|
||||
}
|
||||
|
||||
static void K_drawDistributionDebugger(void)
|
||||
@@ -8753,6 +8904,7 @@ void K_drawKartHUD(void)
|
||||
{
|
||||
boolean isfreeplay = false;
|
||||
boolean battlefullscreen = false;
|
||||
boolean freecam = demo.freecam; //disable some hud elements w/ freecam
|
||||
UINT8 i;
|
||||
|
||||
// Define the X and Y for each drawn object
|
||||
@@ -8762,7 +8914,7 @@ void K_drawKartHUD(void)
|
||||
// Draw that fun first person HUD! Drawn ASAP so it looks more "real".
|
||||
for (i = 0; i <= splitscreen; i++)
|
||||
{
|
||||
if (stplyr == &players[displayplayers[i]] && !camera[i].chase)
|
||||
if (stplyr == &players[displayplayers[i]] && !camera[i].chase && !freecam)
|
||||
K_drawKartFirstPerson();
|
||||
}
|
||||
|
||||
@@ -8783,8 +8935,11 @@ void K_drawKartHUD(void)
|
||||
if (!demo.title && (!battlefullscreen || splitscreen))
|
||||
{
|
||||
// Draw the CHECK indicator before the other items, so it's overlapped by everything else
|
||||
if (cv_kartcheck.value && !splitscreen && !players[displayplayers[0]].exiting)
|
||||
K_drawKartPlayerCheck();
|
||||
#ifdef HAVE_BLUA
|
||||
if (LUA_HudEnabled(hud_check)) // delete lua when?
|
||||
#endif
|
||||
if (cv_kartcheck.value && !splitscreen && !players[displayplayers[0]].exiting && !freecam)
|
||||
K_drawKartPlayerCheck();
|
||||
|
||||
// Draw WANTED status
|
||||
if (G_BattleGametype())
|
||||
@@ -8804,7 +8959,7 @@ void K_drawKartHUD(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (battlefullscreen)
|
||||
if (battlefullscreen && !freecam)
|
||||
{
|
||||
#ifdef HAVE_BLUA
|
||||
if (LUA_HudEnabled(hud_battlefullscreen))
|
||||
@@ -8815,7 +8970,7 @@ void K_drawKartHUD(void)
|
||||
|
||||
// Draw the item window
|
||||
#ifdef HAVE_BLUA
|
||||
if (LUA_HudEnabled(hud_item))
|
||||
if (LUA_HudEnabled(hud_item) && !freecam)
|
||||
#endif
|
||||
K_drawKartItem();
|
||||
|
||||
@@ -8838,7 +8993,7 @@ void K_drawKartHUD(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (!stplyr->spectator) // Bottom of the screen elements, don't need in spectate mode
|
||||
if (!stplyr->spectator && !demo.freecam) // Bottom of the screen elements, don't need in spectate mode
|
||||
{
|
||||
if (demo.title) // Draw title logo instead in demo.titles
|
||||
{
|
||||
@@ -8913,9 +9068,9 @@ void K_drawKartHUD(void)
|
||||
if (leveltime >= starttime-(3*TICRATE)
|
||||
&& leveltime < starttime+TICRATE)
|
||||
K_drawKartStartCountdown();
|
||||
else if (countdown && (!splitscreen || !stplyr->exiting))
|
||||
else if (racecountdown && (!splitscreen || !stplyr->exiting))
|
||||
{
|
||||
char *countstr = va("%d", countdown/TICRATE);
|
||||
char *countstr = va("%d", racecountdown/TICRATE);
|
||||
|
||||
if (splitscreen > 1)
|
||||
V_DrawCenteredString(BASEVIDWIDTH/4, LAPS_Y+1, K_calcSplitFlags(0), countstr);
|
||||
@@ -8927,7 +9082,7 @@ void K_drawKartHUD(void)
|
||||
}
|
||||
|
||||
// Race overlays
|
||||
if (G_RaceGametype())
|
||||
if (G_RaceGametype() && !freecam)
|
||||
{
|
||||
if (stplyr->exiting)
|
||||
K_drawKartFinish();
|
||||
@@ -8935,7 +9090,7 @@ void K_drawKartHUD(void)
|
||||
K_drawLapStartAnim();
|
||||
}
|
||||
|
||||
if (modeattacking) // everything after here is MP and debug only
|
||||
if (modeattacking || freecam) // everything after here is MP and debug only
|
||||
return;
|
||||
|
||||
if (G_BattleGametype() && !splitscreen && (stplyr->kartstuff[k_yougotem] % 2)) // * YOU GOT EM *
|
||||
|
||||
+3
-1
@@ -11,7 +11,7 @@
|
||||
|
||||
#define KART_FULLTURN 800
|
||||
|
||||
UINT8 colortranslations[MAXTRANSLATIONS][16];
|
||||
extern UINT8 colortranslations[MAXTRANSLATIONS][16];
|
||||
extern const char *KartColor_Names[MAXSKINCOLORS];
|
||||
extern const UINT8 KartColor_Opposite[MAXSKINCOLORS*2];
|
||||
void K_RainbowColormap(UINT8 *dest_colormap, UINT8 skincolor);
|
||||
@@ -55,6 +55,8 @@ INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue);
|
||||
INT32 K_GetKartDriftSparkValue(player_t *player);
|
||||
void K_KartUpdatePosition(player_t *player);
|
||||
void K_DropItems(player_t *player);
|
||||
void K_DropRocketSneaker(player_t *player);
|
||||
void K_DropKitchenSink(player_t *player);
|
||||
void K_StripItems(player_t *player);
|
||||
void K_StripOther(player_t *player);
|
||||
void K_MomentumToFacing(player_t *player);
|
||||
|
||||
+335
-14
@@ -14,9 +14,7 @@
|
||||
#ifdef HAVE_BLUA
|
||||
#include "p_local.h"
|
||||
#include "p_setup.h" // So we can have P_SetupLevelSky
|
||||
#ifdef ESLOPE
|
||||
#include "p_slopes.h" // P_GetZAt
|
||||
#endif
|
||||
#include "z_zone.h"
|
||||
#include "r_main.h"
|
||||
#include "r_things.h"
|
||||
@@ -774,11 +772,14 @@ static int lib_pRestoreMusic(lua_State *L)
|
||||
{
|
||||
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||
NOHUD
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
if (P_IsLocalPlayer(player))
|
||||
if (!player || P_IsLocalPlayer(player))
|
||||
{
|
||||
P_RestoreMusic(player);
|
||||
return 0;
|
||||
lua_pushboolean(L, true);
|
||||
}
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_pSpawnShieldOrb(lua_State *L)
|
||||
@@ -1572,7 +1573,6 @@ static int lib_evCrumbleChain(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef ESLOPE
|
||||
// P_SLOPES
|
||||
////////////
|
||||
|
||||
@@ -1588,7 +1588,6 @@ static int lib_pGetZAt(lua_State *L)
|
||||
lua_pushfixed(L, P_GetZAt(slope, x, y));
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
// R_DEFS
|
||||
////////////
|
||||
@@ -1867,8 +1866,13 @@ static int lib_sChangeMusic(lua_State *L)
|
||||
fadeinms = (UINT32)luaL_optinteger(L, 7, 0);
|
||||
|
||||
if (!player || P_IsLocalPlayer(player))
|
||||
{
|
||||
S_ChangeMusicEx(music_name, music_flags, looping, position, prefadems, fadeinms);
|
||||
return 0;
|
||||
lua_pushboolean(L, true);
|
||||
}
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_sSpeedMusic(lua_State *L)
|
||||
@@ -1884,8 +1888,230 @@ static int lib_sSpeedMusic(lua_State *L)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
}
|
||||
if (!player || P_IsLocalPlayer(player))
|
||||
S_SpeedMusic(speed);
|
||||
return 0;
|
||||
lua_pushboolean(L, S_SpeedMusic(speed));
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_sMusicType(lua_State *L)
|
||||
{
|
||||
player_t *player = NULL;
|
||||
NOHUD
|
||||
if (!lua_isnone(L, 1) && lua_isuserdata(L, 1))
|
||||
{
|
||||
player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
}
|
||||
if (!player || P_IsLocalPlayer(player))
|
||||
lua_pushinteger(L, S_MusicType());
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_sMusicPlaying(lua_State *L)
|
||||
{
|
||||
player_t *player = NULL;
|
||||
NOHUD
|
||||
if (!lua_isnone(L, 1) && lua_isuserdata(L, 1))
|
||||
{
|
||||
player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
}
|
||||
if (!player || P_IsLocalPlayer(player))
|
||||
lua_pushboolean(L, S_MusicPlaying());
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_sMusicPaused(lua_State *L)
|
||||
{
|
||||
player_t *player = NULL;
|
||||
NOHUD
|
||||
if (!lua_isnone(L, 1) && lua_isuserdata(L, 1))
|
||||
{
|
||||
player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
}
|
||||
if (!player || P_IsLocalPlayer(player))
|
||||
lua_pushboolean(L, S_MusicPaused());
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_sMusicName(lua_State *L)
|
||||
{
|
||||
player_t *player = NULL;
|
||||
NOHUD
|
||||
if (!lua_isnone(L, 1) && lua_isuserdata(L, 1))
|
||||
{
|
||||
player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
}
|
||||
if (!player || P_IsLocalPlayer(player))
|
||||
lua_pushstring(L, S_MusicName());
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_sMusicInfo(lua_State *L)
|
||||
{
|
||||
player_t *player = NULL;
|
||||
NOHUD
|
||||
if (!lua_isnone(L, 1) && lua_isuserdata(L, 1))
|
||||
{
|
||||
player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
}
|
||||
if (!player || P_IsLocalPlayer(player))
|
||||
{
|
||||
char mname[7];
|
||||
UINT16 mflags;
|
||||
boolean looping;
|
||||
if (S_MusicInfo(mname, &mflags, &looping))
|
||||
{
|
||||
lua_pushstring(L, mname);
|
||||
lua_pushinteger(L, mflags);
|
||||
lua_pushboolean(L, looping);
|
||||
}
|
||||
else
|
||||
lua_pushboolean(L, false);
|
||||
}
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_sMusicExists(lua_State *L)
|
||||
{
|
||||
boolean checkMIDI = lua_opttrueboolean(L, 2);
|
||||
boolean checkDigi = lua_opttrueboolean(L, 3);
|
||||
#ifdef MUSICSLOT_COMPATIBILITY
|
||||
const char *music_name;
|
||||
UINT32 music_num;
|
||||
char music_compat_name[7];
|
||||
UINT16 music_flags = 0;
|
||||
NOHUD
|
||||
if (lua_isnumber(L, 1))
|
||||
{
|
||||
music_num = (UINT32)luaL_checkinteger(L, 1);
|
||||
music_flags = (UINT16)(music_num & 0x0000FFFF);
|
||||
if (music_flags && music_flags <= 1035)
|
||||
snprintf(music_compat_name, 7, "%sM", G_BuildMapName((INT32)music_flags));
|
||||
else if (music_flags && music_flags <= 1050)
|
||||
strncpy(music_compat_name, compat_special_music_slots[music_flags - 1036], 7);
|
||||
else
|
||||
music_compat_name[0] = 0; // becomes empty string
|
||||
music_compat_name[6] = 0;
|
||||
music_name = (const char *)&music_compat_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
music_num = 0;
|
||||
music_name = luaL_checkstring(L, 1);
|
||||
}
|
||||
#else
|
||||
const char *music_name = luaL_checkstring(L, 1);
|
||||
#endif
|
||||
NOHUD
|
||||
lua_pushboolean(L, S_MusicExists(music_name, checkMIDI, checkDigi));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_sGetMusicLength(lua_State *L)
|
||||
{
|
||||
player_t *player = NULL;
|
||||
NOHUD
|
||||
if (!lua_isnone(L, 1) && lua_isuserdata(L, 1))
|
||||
{
|
||||
player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
}
|
||||
if (!player || P_IsLocalPlayer(player))
|
||||
lua_pushinteger(L, (int)S_GetMusicLength());
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_sSetMusicLoopPoint(lua_State *L)
|
||||
{
|
||||
UINT32 looppoint = (UINT32)luaL_checkinteger(L, 1);
|
||||
player_t *player = NULL;
|
||||
NOHUD
|
||||
if (!lua_isnone(L, 2) && lua_isuserdata(L, 2))
|
||||
{
|
||||
player = *((player_t **)luaL_checkudata(L, 2, META_PLAYER));
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
}
|
||||
if (!player || P_IsLocalPlayer(player))
|
||||
lua_pushboolean(L, S_SetMusicLoopPoint(looppoint));
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_sGetMusicLoopPoint(lua_State *L)
|
||||
{
|
||||
player_t *player = NULL;
|
||||
NOHUD
|
||||
if (!lua_isnone(L, 1) && lua_isuserdata(L, 1))
|
||||
{
|
||||
player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
}
|
||||
if (!player || P_IsLocalPlayer(player))
|
||||
lua_pushinteger(L, (int)S_GetMusicLoopPoint());
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_sSetMusicPosition(lua_State *L)
|
||||
{
|
||||
UINT32 position = (UINT32)luaL_checkinteger(L, 1);
|
||||
player_t *player = NULL;
|
||||
NOHUD
|
||||
if (!lua_isnone(L, 2) && lua_isuserdata(L, 2))
|
||||
{
|
||||
player = *((player_t **)luaL_checkudata(L, 2, META_PLAYER));
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
}
|
||||
if (!player || P_IsLocalPlayer(player))
|
||||
lua_pushboolean(L, S_SetMusicPosition(position));
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_sGetMusicPosition(lua_State *L)
|
||||
{
|
||||
player_t *player = NULL;
|
||||
NOHUD
|
||||
if (!lua_isnone(L, 1) && lua_isuserdata(L, 1))
|
||||
{
|
||||
player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
}
|
||||
if (!player || P_IsLocalPlayer(player))
|
||||
lua_pushinteger(L, (int)S_GetMusicPosition());
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_sStopMusic(lua_State *L)
|
||||
@@ -1899,8 +2125,53 @@ static int lib_sStopMusic(lua_State *L)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
}
|
||||
if (!player || P_IsLocalPlayer(player))
|
||||
{
|
||||
S_StopMusic();
|
||||
return 0;
|
||||
lua_pushboolean(L, true);
|
||||
}
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_sPauseMusic(lua_State *L)
|
||||
{
|
||||
player_t *player = NULL;
|
||||
NOHUD
|
||||
if (!lua_isnone(L, 1) && lua_isuserdata(L, 1))
|
||||
{
|
||||
player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
}
|
||||
if (!player || P_IsLocalPlayer(player))
|
||||
{
|
||||
S_PauseAudio();
|
||||
lua_pushboolean(L, true);
|
||||
}
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_sResumeMusic(lua_State *L)
|
||||
{
|
||||
player_t *player = NULL;
|
||||
NOHUD
|
||||
if (!lua_isnone(L, 1) && lua_isuserdata(L, 1))
|
||||
{
|
||||
player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
}
|
||||
if (!player || P_IsLocalPlayer(player))
|
||||
{
|
||||
S_ResumeAudio();
|
||||
lua_pushboolean(L, true);
|
||||
}
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_sSetInternalMusicVolume(lua_State *L)
|
||||
@@ -2641,6 +2912,41 @@ static int lib_kGetItemPatch(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// sets the remaining time before players blow up
|
||||
static int lib_kSetRaceCountdown(lua_State *L)
|
||||
{
|
||||
tic_t c = (tic_t)luaL_checkinteger(L, 1);
|
||||
racecountdown = c;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// sets the remaining time before the race ends after everyone finishes
|
||||
static int lib_kSetExitCountdown(lua_State *L)
|
||||
{
|
||||
tic_t c = (tic_t)luaL_checkinteger(L, 1);
|
||||
NOHUD
|
||||
exitcountdown = c;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Sets the item cooldown before another shrink / SPB can be rolled
|
||||
static int lib_kSetIndirectItemCountdown(lua_State *L)
|
||||
{
|
||||
tic_t c = (tic_t)luaL_checkinteger(L, 1);
|
||||
NOHUD
|
||||
indirectitemcooldown = c;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Sets the item cooldown before another shrink / SPB can be rolled
|
||||
static int lib_kSetHyuCountdown(lua_State *L)
|
||||
{
|
||||
tic_t c = (tic_t)luaL_checkinteger(L, 1);
|
||||
NOHUD
|
||||
hyubgone = c;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static luaL_Reg lib[] = {
|
||||
{"print", lib_print},
|
||||
{"chatprint", lib_chatprint},
|
||||
@@ -2773,10 +3079,8 @@ static luaL_Reg lib[] = {
|
||||
{"P_StartQuake",lib_pStartQuake},
|
||||
{"EV_CrumbleChain",lib_evCrumbleChain},
|
||||
|
||||
#ifdef ESLOPE
|
||||
// p_slopes
|
||||
{"P_GetZAt",lib_pGetZAt},
|
||||
#endif
|
||||
|
||||
// r_defs
|
||||
{"R_PointToAngle",lib_rPointToAngle},
|
||||
@@ -2802,6 +3106,19 @@ static luaL_Reg lib[] = {
|
||||
{"S_ShowMusicCredit",lib_sShowMusicCredit},
|
||||
{"S_ChangeMusic",lib_sChangeMusic},
|
||||
{"S_SpeedMusic",lib_sSpeedMusic},
|
||||
{"S_MusicType",lib_sMusicType},
|
||||
{"S_MusicPlaying",lib_sMusicPlaying},
|
||||
{"S_MusicPaused",lib_sMusicPaused},
|
||||
{"S_MusicName",lib_sMusicName},
|
||||
{"S_MusicInfo",lib_sMusicInfo},
|
||||
{"S_MusicExists",lib_sMusicExists},
|
||||
{"S_GetMusicLength",lib_sGetMusicLength},
|
||||
{"S_SetMusicLoopPoint",lib_sSetMusicLoopPoint},
|
||||
{"S_GetMusicLoopPoint",lib_sGetMusicLoopPoint},
|
||||
{"S_SetMusicPosition",lib_sSetMusicPosition},
|
||||
{"S_GetMusicPosition",lib_sGetMusicPosition},
|
||||
{"S_PauseMusic",lib_sPauseMusic},
|
||||
{"S_ResumeMusic",lib_sResumeMusic},
|
||||
{"S_StopMusic",lib_sStopMusic},
|
||||
{"S_SetInternalMusicVolume", lib_sSetInternalMusicVolume},
|
||||
{"S_StopFadingMusic",lib_sStopFadingMusic},
|
||||
@@ -2868,6 +3185,10 @@ static luaL_Reg lib[] = {
|
||||
{"K_GetKartAccel",lib_kGetKartAccel},
|
||||
{"K_GetKartFlashing",lib_kGetKartFlashing},
|
||||
{"K_GetItemPatch",lib_kGetItemPatch},
|
||||
{"K_SetRaceCountdown",lib_kSetRaceCountdown},
|
||||
{"K_SetExitCountdown",lib_kSetExitCountdown},
|
||||
{"K_SetIndirectItemCooldown",lib_kSetIndirectItemCountdown},
|
||||
{"K_SetHyudoroCooldown",lib_kSetHyuCountdown},
|
||||
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
@@ -79,9 +79,7 @@ static UINT8 lib_searchBlockmap_Lines(lua_State *L, INT32 x, INT32 y, mobj_t *th
|
||||
{
|
||||
INT32 offset;
|
||||
const INT32 *list; // Big blockmap
|
||||
#ifdef POLYOBJECTS
|
||||
polymaplink_t *plink; // haleyjd 02/22/06
|
||||
#endif
|
||||
line_t *ld;
|
||||
|
||||
if (x < 0 || y < 0 || x >= bmapwidth || y >= bmapheight)
|
||||
@@ -89,7 +87,6 @@ static UINT8 lib_searchBlockmap_Lines(lua_State *L, INT32 x, INT32 y, mobj_t *th
|
||||
|
||||
offset = y*bmapwidth + x;
|
||||
|
||||
#ifdef POLYOBJECTS
|
||||
// haleyjd 02/22/06: consider polyobject lines
|
||||
plink = polyblocklinks[offset];
|
||||
|
||||
@@ -132,7 +129,6 @@ static UINT8 lib_searchBlockmap_Lines(lua_State *L, INT32 x, INT32 y, mobj_t *th
|
||||
}
|
||||
plink = (polymaplink_t *)(plink->link.next);
|
||||
}
|
||||
#endif
|
||||
|
||||
offset = *(blockmap + offset); // offset = blockmap[y*bmapwidth+x];
|
||||
|
||||
|
||||
@@ -413,6 +413,30 @@ static int lib_cvRegisterVar(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// For some reason I couldn't cherry pick this.
|
||||
// Credits for this function go to james. All hail birb. -Lat'
|
||||
|
||||
static int lib_cvFindVar(lua_State *L)
|
||||
{
|
||||
consvar_t *cv;
|
||||
if (( cv = CV_FindVar(luaL_checkstring(L,1)) ))
|
||||
{
|
||||
lua_settop(L,1);/* We only want one argument in the stack. */
|
||||
lua_pushlightuserdata(L, cv);/* Now the second value on stack. */
|
||||
luaL_getmetatable(L, META_CVAR);
|
||||
/*
|
||||
The metatable is the last value on the stack, so this
|
||||
applies it to the second value, which is the cvar.
|
||||
*/
|
||||
lua_setmetatable(L,2);
|
||||
lua_pushvalue(L,2);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// CONS_Printf for a single player
|
||||
// Use 'print' in baselib for a global message.
|
||||
static int lib_consPrintf(lua_State *L)
|
||||
@@ -452,6 +476,7 @@ static luaL_Reg lib[] = {
|
||||
{"COM_BufInsertText", lib_comBufInsertText},
|
||||
{"CV_RegisterVar", lib_cvRegisterVar},
|
||||
{"CONS_Printf", lib_consPrintf},
|
||||
{"CV_FindVar", lib_cvFindVar},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
Loaded 100 of 209 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user