Merge branch 'upstream/next' into zarrotsu_vanillamerge

# Conflicts:
#	src/Makefile
#	src/doomdef.h
#	src/hardware/hw_main.c
#	src/p_mobj.c
#	src/p_user.c
#	src/r_segs.c
#	src/sdl/i_video.c
#	src/win32/win_sys.c
This commit is contained in:
Sryder 2017-02-17 20:14:55 +00:00
commit 68d439a783
137 changed files with 8083 additions and 9617 deletions

2
.gitignore vendored
View file

@ -17,4 +17,4 @@ Win32_LIB_ASM_Release
/objs/VC10/ /objs/VC10/
*.user *.user
*.db *.db
*.opendb *.opendb

View file

@ -2,19 +2,199 @@ language: c
sudo: required sudo: required
dist: trusty dist: trusty
env: matrix:
- CFLAGS=-Wall -W -Werror include:
- os: linux
os: addons:
- linux apt:
- osx packages:
- libsdl2-mixer-dev
compiler: - libpng-dev
- gcc - libgl1-mesa-dev
- clang - libgme-dev
- p7zip-full
- gcc-4.4
compiler: gcc-4.4
#gcc-4.4 (Ubuntu/Linaro 4.4.7-8ubuntu1) 4.4.7
- os: linux
addons:
apt:
packages:
- libsdl2-mixer-dev
- libpng-dev
- libgl1-mesa-dev
- libgme-dev
- p7zip-full
- gcc-4.6
compiler: gcc-4.6
#gcc-4.6 (Ubuntu/Linaro 4.6.4-6ubuntu2) 4.6.4
- os: linux
addons:
apt:
packages:
- libsdl2-mixer-dev
- libpng-dev
- libgl1-mesa-dev
- libgme-dev
- p7zip-full
- gcc-4.7
compiler: gcc-4.7
#gcc-4.7
- os: linux
compiler: gcc
#gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libsdl2-mixer-dev
- libpng-dev
- libgl1-mesa-dev
- libgme-dev
- p7zip-full
- gcc-4.8
compiler: gcc-4.8
#gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libsdl2-mixer-dev
- libpng-dev
- libgl1-mesa-dev
- libgme-dev
- p7zip-full
- gcc-4.9
compiler: gcc-4.9
#gcc-4.9 (Ubuntu 4.9.3-8ubuntu2~14.04) 4.9.3
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libsdl2-mixer-dev
- libpng-dev
- libgl1-mesa-dev
- libgme-dev
- p7zip-full
- gcc-5
compiler: gcc-5
#gcc-5 (Ubuntu 5.3.0-3ubuntu1~14.04) 5.3.0 20151204
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libsdl2-mixer-dev
- libpng-dev
- libgl1-mesa-dev
- libgme-dev
- p7zip-full
- gcc-6
compiler: gcc-6
env: WFLAGS="-Wno-tautological-compare"
#gcc-6 (Ubuntu 6.1.1-3ubuntu11~14.04.1) 6.1.1 20160511
- os: linux
compiler: clang
#clang version 3.5.0 (tags/RELEASE_350/final)
- os: linux
addons:
apt:
sources:
- llvm-toolchain-precise-3.5
packages:
- libsdl2-mixer-dev
- libpng-dev
- libgl1-mesa-dev
- libgme-dev
- p7zip-full
- clang-3.5
compiler: clang-3.5
#Ubuntu clang version 3.5.0-4ubuntu2~trusty2 (tags/RELEASE_350/final) (based on LLVM 3.5.0)
- os: linux
addons:
apt:
sources:
- llvm-toolchain-precise-3.6
- ubuntu-toolchain-r-test
packages:
- libsdl2-mixer-dev
- libpng-dev
- libgl1-mesa-dev
- libgme-dev
- p7zip-full
- clang-3.6
compiler: clang-3.6
#Ubuntu clang version 3.6.2-svn240577-1~exp1 (branches/release_36) (based on LLVM 3.6.2)
- os: linux
addons:
apt:
sources:
- llvm-toolchain-precise-3.7
- ubuntu-toolchain-r-test
packages:
- libsdl2-mixer-dev
- libpng-dev
- libgl1-mesa-dev
- libgme-dev
- p7zip-full
- clang-3.7
compiler: clang-3.7
#Ubuntu clang version 3.7.1-svn253571-1~exp1 (branches/release_37) (based on LLVM 3.7.1)
- os: linux
addons:
apt:
sources:
- llvm-toolchain-precise-3.8
- ubuntu-toolchain-r-test
packages:
- libsdl2-mixer-dev
- libpng-dev
- libgl1-mesa-dev
- libgme-dev
- p7zip-full
- clang-3.8
compiler: clang-3.8
#clang version 3.8.1-svn271127-1~exp1 (branches/release_38)
# - os: osx
# osx_image: beta-xcode6.1
# #Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
# - os: osx
# osx_image: beta-xcode6.2
# compiler: gcc
# #Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
## - os: osx
## osx_image: beta-xcode6.3
## #I think xcode.6.3 VM is broken, it does not boot
# - os: osx
# osx_image: xcode6.4
# #Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
# - os: osx
# osx_image: xcode7
# #Apple LLVM version 7.0.0 (clang-700.0.72)
# - os: osx
# osx_image: xcode7.1
# #Apple LLVM version 7.0.0 (clang-700.1.76)
# - os: osx
# osx_image: xcode7.2
# #Apple LLVM version 7.0.2 (clang-700.1.81)
- os: osx
osx_image: xcode7.3
#Apple LLVM version 7.3.0 (clang-703.0.31)
allow_failures:
- compiler: clang-3.5
- compiler: clang-3.6
- compiler: clang-3.7
- compiler: clang-3.8
cache: cache:
apt: true apt: true
ccache: true ccache: true
directories: directories:
- $HOME/srb2_cache - $HOME/srb2_cache
@ -33,13 +213,16 @@ before_script:
- 7z x $HOME/srb2_cache/SRB2-v2115-assets-2.7z -oassets - 7z x $HOME/srb2_cache/SRB2-v2115-assets-2.7z -oassets
- mkdir build - mkdir build
- cd build - cd build
- cmake .. - export CFLAGS="-Wall -W -Werror $WFLAGS"
- export CCACHE_COMPRESS=true
- cmake .. -DCMAKE_BUILD_TYPE=Release
before_install: before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install sdl2_mixer game-music-emu p7zip ; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install sdl2_mixer game-music-emu p7zip; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install cmake||true; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -O -L https://www.libsdl.org/release/SDL2-2.0.4.dmg; hdiutil attach SDL2-2.0.4.dmg; sudo cp -a /Volumes/SDL2/SDL2.framework /Library/Frameworks/; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -O -L https://www.libsdl.org/release/SDL2-2.0.4.dmg; hdiutil attach SDL2-2.0.4.dmg; sudo cp -a /Volumes/SDL2/SDL2.framework /Library/Frameworks/; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -O -L https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.1.dmg; hdiutil attach SDL2_mixer-2.0.1.dmg; sudo cp -a /Volumes/SDL2_mixer/SDL2_mixer.framework /Library/Frameworks/; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -O -L https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.1.dmg; hdiutil attach SDL2_mixer-2.0.1.dmg; sudo cp -a /Volumes/SDL2_mixer/SDL2_mixer.framework /Library/Frameworks/; fi
- mkdir -p $HOME/srb2_cache - mkdir -p $HOME/srb2_cache
script: make script: make -k

View file

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project(SRB2 project(SRB2
VERSION 2.1.14 VERSION 2.1.17
LANGUAGES C) LANGUAGES C)
if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR})

22
README.md Normal file
View file

@ -0,0 +1,22 @@
# Sonic Robo Blast 2
[![Build status](https://ci.appveyor.com/api/projects/status/399d4hcw9yy7hg2y?svg=true)](https://ci.appveyor.com/project/STJr/srb2)
[![Build status](https://travis-ci.org/STJr/SRB2.svg?branch=master)](https://travis-ci.org/STJr/SRB2)
[Sonic Robo Blast 2](https://srb2.org/) is a 3D Sonic the Hedgehog fangame based on a modified version of [Doom Legacy](http://doomlegacy.sourceforge.net/).
## Dependencies
- NASM (x86 builds only)
- SDL2 (Linux/OS X only)
- SDL2-Mixer (Linux/OS X only)
- libupnp (Linux/OS X only)
- libgme (Linux/OS X only)
Warning: 64-bit builds are not netgame compatible with 32-bit builds. Use at your own risk.
## Compiling
See [SRB2 Wiki/Source code compiling](http://wiki.srb2.org/wiki/Source_code_compiling)
## Disclaimer
Sonic Team Junior is in no way affiliated with SEGA or Sonic Team. We do not claim ownership of any of SEGA's intellectual property used in SRB2.

2973
SRB2.cbp

File diff suppressed because it is too large Load diff

28
SRB2_Debug.props Normal file
View file

@ -0,0 +1,28 @@
<?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>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<ClCompile>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<AssemblerOutput>All</AssemblerOutput>
<SmallerTypeCheck>true</SmallerTypeCheck>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
</ClCompile>
<Link>
<GenerateDebugInformation>Debug</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

30
SRB2_Release.props Normal file
View file

@ -0,0 +1,30 @@
<?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>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<StringPooling>true</StringPooling>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization>Full</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Link>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<GenerateDebugInformation>DebugFastLink</GenerateDebugInformation>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

46
SRB2_common.props Normal file
View file

@ -0,0 +1,46 @@
<?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>
<OutDir>$(SolutionDir)bin\VC10\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)objs\VC10\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>HAVE_PNG;COMPVERSION;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<CompileAs>CompileAsC</CompileAs>
<BrowseInformation>true</BrowseInformation>
<TreatWarningAsError>true</TreatWarningAsError>
<EnablePREfast>false</EnablePREfast>
<SDLCheck>true</SDLCheck>
<DisableSpecificWarnings>4244;4267</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Windows</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(PlatformTarget)'=='x86'">
<ClCompile>
<PreprocessorDefinitions>USEASM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
</Link>
<CustomBuild>
<Command>nasm -g -o $(IntDir)%(Filename).obj -f win32 "%(FullPath)"</Command>
<Message>Compiling %(Filename).nas with NASM...</Message>
<Outputs>$(IntDir)%(Filename).obj;%(Outputs)</Outputs>
</CustomBuild>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(PlatformTarget)'!='x86'">
<CustomBuild>
<LinkObjects>false</LinkObjects>
</CustomBuild>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

View file

@ -1,4 +1,4 @@
version: 2.1.14.{branch}-{build} version: 2.1.17.{branch}-{build}
os: MinGW os: MinGW
environment: environment:
@ -51,7 +51,7 @@ before_build:
build_script: build_script:
- cmd: mingw32-make.exe %SRB2_MFLAGS% %CONFIGURATION%=1 clean - cmd: mingw32-make.exe %SRB2_MFLAGS% %CONFIGURATION%=1 clean
- cmd: mingw32-make.exe %SRB2_MFLAGS% %CONFIGURATION%=1 ERRORMODE=1 - cmd: mingw32-make.exe %SRB2_MFLAGS% %CONFIGURATION%=1 ERRORMODE=1 -k
after_build: after_build:
- ccache -s - ccache -s
@ -75,6 +75,9 @@ deploy:
folder: appveyor folder: appveyor
application: application:
active_mode: false active_mode: false
on:
branch: master
appveyor_repo_tag: true
on_finish: on_finish:

13
comptime.props Normal file
View file

@ -0,0 +1,13 @@
<?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 />
<ItemDefinitionGroup>
<PreBuildEvent>
<Command>"$(SolutionDir)comptime.bat" "$(ProjectDir).."</Command>
<Message>Getting revision number from the SCM system</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

3
debian/docs vendored
View file

@ -1,2 +1 @@
readme.txt README.md
readme.txt

21
libs/FMOD.props Normal file
View file

@ -0,0 +1,21 @@
<?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>
<IncludePath>$(SolutionDir)libs\fmodex\inc;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)libs\fmodex\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup />
<ItemDefinitionGroup Condition="'$(PlatformTarget)'=='x64'">
<Link>
<AdditionalDependencies>fmodexL64_vc.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(PlatformTarget)'=='x86'">
<Link>
<AdditionalDependencies>fmodexL_vc.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

15
libs/SDL2.props Normal file
View file

@ -0,0 +1,15 @@
<?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>
<IncludePath>$(SolutionDir)libs\SDL2\include;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)libs\SDL2\lib\$(PlatformTarget);$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup>
<Link>
<AdditionalDependencies>SDL2.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

15
libs/SDL_mixer.props Normal file
View file

@ -0,0 +1,15 @@
<?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>
<IncludePath>$(SolutionDir)libs\SDL2_mixer\include;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)libs\SDL2_mixer\lib\$(PlatformTarget);$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup>
<Link>
<AdditionalDependencies>SDL2_mixer.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

View file

@ -3,8 +3,7 @@
<ImportGroup Label="PropertySheets" /> <ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<PropertyGroup> <PropertyGroup>
<IncludePath>..\..\libs\fmodex\inc;$(IncludePath)</IncludePath> <IncludePath>$(SolutionDir)libs\libpng-src;$(IncludePath)</IncludePath>
<LibraryPath>..\..\libs\fmodex\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup /> <ItemDefinitionGroup />
<ItemGroup /> <ItemGroup />

10
libs/zlib.props Normal file
View file

@ -0,0 +1,10 @@
<?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>
<IncludePath>$(SolutionDir)libs\zlib;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup />
<ItemGroup />
</Project>

View file

@ -1,155 +0,0 @@
Here it is! SRB2 v2.1.14 source code!
(why do we keep the version number up to date
when everything else in this file is hilariously old?
- Inuyasha)
Win32 with Visual C (6SP6+Processor Pack OR 7)
~~~
2 VC++ 6.0 project files are included:
Win32/DirectX/FMOD
src\win32\wLegacy.dsw
You'll need FMOD to compile this version (www.fmod.org)
or
Win32/SDL/SDL_mixer
src\sdl\Win32SDL.dsp
You'll need SDL and SDL_mixer for this version (www.libsdl.org)
Both needs NASM (http://sourceforge.net/projects/nasm)
For PNG screenshot, libPNG, and Zlib (from http://gnuwin32.sourceforge.net/)
No warranty, support, etc. of any kind is offered,
just plain old as is.
Some bits of code are still really scary.
Go nuts!
Win32 with Dev-C++ (http://bloodshed.net/ free!)
~~~
2 Dev-C++ project files are included:
Win32/DirectX/FMOD
src\win32\SRB2.dev
or
Win32/SDL/SDL_mixer
src\sdl\Win32SDL.dev
You'll need SDL and SDL_mixer for this version (www.libsdl.org)
libPNG and Zlib (from http://gnuwin32.sourceforge.net/)
Note there are precompiled libpng.a and libz.a for Mingw
you will need NASM for both SDL/SDL_mixer and DirectX/FMOD
and you need DirectX 6 (or up) Dev-Paks to compile DirectX version
GNU/Linux
~~~
Dependencies:
SDL 1.2.7 or better (from libsdl.org)
SDL_Mixer 1.2.2(.7 for file-less music playback) (from libsdl.org)
Nasm (use NOASM=1 if you don't have it or have an non-i386 system, I think)
libPNG 1.2.7
Zlib 1.2.3
The Xiph.org libogg and libvorbis libraries
The OpenGL headers (from Mesa, usually shipped with your X.org or XFree
installation, so you needn't worry, most likely)
GCC 3.x toolchain and binutils
GNU Make
Build instructions:
make -C src LINUX=1
Build instructions (64 bit):
make -C src LINUX64=1
Build instructions to build for Wii Linux/SRB2Wii on a PowerPC system,
follow cross-compiling instructions for cross-compiling on a x86 system:
make -C src LINUX=1 WIILINUX=1
Build instructions to build for Pandora (Linux) on a ARM system,
follow cross-compiling instructions for cross-compiling on a x86 system:
make -C src PANDORA=1
Solaris
~~~
Dependencies:
SDL 1.2.5 or better (from libsdl.org)
SDL_Mixer 1.2.2(.7 for file-less music playback) (from libsdl.org)
libPNG 1.2.7
Zlib 1.2.3
The Xiph.org libogg and libvorbis libraries
The OpenGL headers (from Mesa, usually shipped with your X.org or XFree
installation, so you needn't worry, most likely)
GCC 3.x toolchain and binutils
GNU Make
You can get all these programs/libraries from the Companion CD (except SDL_mixer and OpenGL)
Build instructions:
gmake -C src SOLARIS=1
FreeBSD
~~~
Dependencies:
SDL 1.2.7 or better (from libsdl.org)
SDL_Mixer 1.2.2(.7 for file-less music playback) (from libsdl.org)
Nasm (use NOASM=1 if you don't have it or have an non-i386 system, I think)
libPNG 1.2.7
Zlib 1.2.3
The Xiph.org libogg and libvorbis libraries
The OpenGL headers (from Mesa, usually shipped with your X.org or XFree
installation, so you needn't worry, most likely)
GCC 3.x toolchain and binutils
GNU Make
Build instructions:
gmake -C src FREEBSD=1
DJGPP/DOS
~~~
Dependencies:
Allegro 3.12 game programming library, (from
http://alleg.sourceforge.net/index.html)
Nasm (use NOASM=1 if you don't have it)
libsocket (from http://homepages.nildram.co.uk/~phekda/richdawe/lsck/) or
Watt-32 (from http://www.bgnett.no/~giva/)
GCC 3.x toolchain and binutils
GNU Make
Build instructions:
make -C src # to link with Watt-32, add WATTCP=1
# for remote debugging over the COM port, add RDB=1
Notes:
use tools\djgpp\all313.diff to update Allegro to a "more usable" version ;)
Example: E:\djgpp\allegro>patch -p# < D:\SRB2Code\1.1\srb2\tools\djgpp\all313.diff
Windows CE
~~~
Dependencies:
SDL 1.27
Build instructions:
use src\SDL\WinCE\SRB2CE.vcw
-------------------------------------------------------------------------------
binaries will turn in up in bin/
note: read the src/makefile for more options
- Sonic Team Junior
http://www.srb2.org

View file

@ -22,6 +22,7 @@ set(SRB2_CORE_SOURCES
i_tcp.c i_tcp.c
info.c info.c
lzf.c lzf.c
m_aatree.c
m_anigif.c m_anigif.c
m_argv.c m_argv.c
m_bbox.c m_bbox.c
@ -83,6 +84,7 @@ set(SRB2_CORE_HEADERS
info.h info.h
keys.h keys.h
lzf.h lzf.h
m_aatree.h
m_anigif.h m_anigif.h
m_argv.h m_argv.h
m_bbox.h m_bbox.h
@ -388,18 +390,25 @@ if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL})
endif() endif()
if(${SRB2_CONFIG_USEASM}) if(${SRB2_CONFIG_USEASM})
#SRB2_ASM_FLAGS can be used to pass flags to either nasm or yasm.
if(${CMAKE_SYSTEM} MATCHES "Linux")
set(SRB2_ASM_FLAGS "-DLINUX ${SRB2_ASM_FLAGS}")
endif()
if(${SRB2_CONFIG_YASM}) if(${SRB2_CONFIG_YASM})
set(CMAKE_ASM_YASM_SOURCE_FILE_EXTENSIONS ${CMAKE_ASM_YASM_SOURCE_FILE_EXTENSIONS} nas) set(CMAKE_ASM_YASM_SOURCE_FILE_EXTENSIONS ${CMAKE_ASM_YASM_SOURCE_FILE_EXTENSIONS} nas)
set(CMAKE_ASM_YASM_FLAGS "${SRB2_ASM_FLAGS}" CACHE STRING "Flags used by the assembler during all build types.")
enable_language(ASM_YASM) enable_language(ASM_YASM)
else() else()
set(CMAKE_ASM_NASM_SOURCE_FILE_EXTENSIONS ${CMAKE_ASM_NASM_SOURCE_FILE_EXTENSIONS} nas) set(CMAKE_ASM_NASM_SOURCE_FILE_EXTENSIONS ${CMAKE_ASM_NASM_SOURCE_FILE_EXTENSIONS} nas)
set(CMAKE_ASM_NASM_FLAGS "${SRB2_ASM_FLAGS}" CACHE STRING "Flags used by the assembler during all build types.")
enable_language(ASM_NASM) enable_language(ASM_NASM)
endif() endif()
set(SRB2_USEASM ON) set(SRB2_USEASM ON)
add_definitions(-DUSEASM) add_definitions(-DUSEASM)
else() else()
set(SRB2_USEASM OFF) set(SRB2_USEASM OFF)
add_definitions(-DNOASM -DNONX86) add_definitions(-DNONX86 -DNORUSEASM)
endif() endif()
# Targets # Targets

View file

@ -179,6 +179,9 @@ endif
ifdef LINUX ifdef LINUX
UNIXCOMMON=1 UNIXCOMMON=1
ifndef NOGME
HAVE_LIBGME=1
endif
endif endif
ifdef SOLARIS ifdef SOLARIS
@ -189,6 +192,10 @@ ifdef FREEBSD
UNIXCOMMON=1 UNIXCOMMON=1
endif endif
ifdef MACOSX
UNIXCOMMON=1
endif
ifdef NDS ifdef NDS
NOPNG=1 NOPNG=1
NONET=1 NONET=1
@ -311,6 +318,13 @@ LIBS+=$(PNG_LDFLAGS)
CFLAGS+=$(PNG_CFLAGS) CFLAGS+=$(PNG_CFLAGS)
endif endif
ZLIB_PKGCONFIG?=zlib
ZLIB_CFLAGS?=$(shell $(PKG_CONFIG) $(ZLIB_PKGCONFIG) --cflags)
ZLIB_LDFLAGS?=$(shell $(PKG_CONFIG) $(ZLIB_PKGCONFIG) --libs)
LIBS+=$(ZLIB_LDFLAGS)
CFLAGS+=$(ZLIB_CFLAGS)
ifdef HAVE_LIBGME ifdef HAVE_LIBGME
OPTS+=-DHAVE_LIBGME OPTS+=-DHAVE_LIBGME
@ -362,6 +376,14 @@ endif
OPTS:=-fno-exceptions $(OPTS) OPTS:=-fno-exceptions $(OPTS)
ifdef MOBJCONSISTANCY
OPTS+=-DMOBJCONSISTANCY
endif
ifdef PACKETDROP
OPTS+=-DPACKETDROP
endif
ifdef DEBUGMODE ifdef DEBUGMODE
# build with debugging information # build with debugging information
@ -371,13 +393,13 @@ ifdef GCC48
else else
CFLAGS+=-O0 CFLAGS+=-O0
endif endif
CFLAGS+= -Wall -DPARANOIA -DRANGECHECK CFLAGS+= -Wall -DPARANOIA -DRANGECHECK -DPACKETDROP -DMOBJCONSISTANCY
else else
# build a normal optimised version # build a normal optimised version
WINDRESFLAGS = -DNDEBUG WINDRESFLAGS = -DNDEBUG
#CFLAGS+=-O2 CFLAGS+=-O3
endif endif
CFLAGS+=-g $(OPTS) $(M5) $(WINDRESFLAGS) CFLAGS+=-g $(OPTS) $(M5) $(WINDRESFLAGS)
@ -431,6 +453,7 @@ OBJS:=$(i_main_o) \
$(OBJDIR)/y_inter.o \ $(OBJDIR)/y_inter.o \
$(OBJDIR)/st_stuff.o \ $(OBJDIR)/st_stuff.o \
$(OBJDIR)/k_kart.o \ $(OBJDIR)/k_kart.o \
$(OBJDIR)/m_aatree.o \
$(OBJDIR)/m_anigif.o \ $(OBJDIR)/m_anigif.o \
$(OBJDIR)/m_argv.o \ $(OBJDIR)/m_argv.o \
$(OBJDIR)/m_bbox.o \ $(OBJDIR)/m_bbox.o \
@ -595,11 +618,15 @@ ifndef WINDOWSHELL
-$(GZIP) $(GZIP_OPT2) $(BIN)/$(DBGNAME).txt -$(GZIP) $(GZIP_OPT2) $(BIN)/$(DBGNAME).txt
endif endif
endif endif
# mac os x lsdlsrb2 does not like objcopy
ifndef MACOSX
ifndef PSP ifndef PSP
$(OBJCOPY) $(BIN)/$(EXENAME) $(BIN)/$(DBGNAME) $(OBJCOPY) $(BIN)/$(EXENAME) $(BIN)/$(DBGNAME)
$(OBJCOPY) --strip-debug $(BIN)/$(EXENAME) $(OBJCOPY) --strip-debug $(BIN)/$(EXENAME)
-$(OBJCOPY) --add-gnu-debuglink=$(BIN)/$(DBGNAME) $(BIN)/$(EXENAME) -$(OBJCOPY) --add-gnu-debuglink=$(BIN)/$(DBGNAME) $(BIN)/$(EXENAME)
endif endif
endif
ifndef NOUPX ifndef NOUPX
-$(UPX) $(UPX_OPTS) $(BIN)/$(EXENAME) -$(UPX) $(UPX_OPTS) $(BIN)/$(EXENAME)
endif endif
@ -747,6 +774,11 @@ $(OBJDIR)/%.o: %.c
$(OBJDIR)/%.o: $(INTERFACE)/%.c $(OBJDIR)/%.o: $(INTERFACE)/%.c
$(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@
ifdef MACOSX
$(OBJDIR)/%.o: sdl/macosx/%.c
$(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@
endif
$(OBJDIR)/%.o: hardware/%.c $(OBJDIR)/%.o: hardware/%.c
$(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@

View file

@ -406,6 +406,15 @@ else
WINDRES=windres WINDRES=windres
endif 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 OBJDUMP_OPTS?=--wide --source --line-numbers
LD=$(CC) LD=$(CC)

View file

@ -999,7 +999,7 @@ static inline void AM_drawWalls(void)
static mline_t l; static mline_t l;
#ifdef ESLOPE #ifdef ESLOPE
fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends
fixed_t backf1, backf2, backc1, backc2; // back floor ceiling ends fixed_t backf1 = 0, backf2 = 0, backc1 = 0, backc2 = 0; // back floor ceiling ends
#endif #endif
for (i = 0; i < numlines; i++) for (i = 0; i < numlines; i++)

View file

@ -258,6 +258,18 @@ INT32 I_PutEnv(char *variable)
return -1; return -1;
} }
INT32 I_ClipboardCopy(const char *data, size_t size)
{
(void)data;
(void)size;
return -1;
}
char *I_ClipboardPaste(void)
{
return NULL;
}
void I_RegisterSysCommands(void) {} void I_RegisterSysCommands(void) {}
#include "../sdl/dosstr.c" #include "../sdl/dosstr.c"

View file

@ -732,7 +732,8 @@ void luaV_execute (lua_State *L, int nexeccalls) {
luaG_runerror(L, LUA_QL("for") " limit must be a number"); luaG_runerror(L, LUA_QL("for") " limit must be a number");
else if (!tonumber(pstep, ra+2)) else if (!tonumber(pstep, ra+2))
luaG_runerror(L, LUA_QL("for") " step must be a number"); luaG_runerror(L, LUA_QL("for") " step must be a number");
setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep))); if (ra && pstep)
setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep)));
dojump(L, pc, GETARG_sBx(i)); dojump(L, pc, GETARG_sBx(i));
continue; continue;
} }

View file

@ -974,9 +974,11 @@ void CV_RegisterVar(consvar_t *variable)
// check net variables // check net variables
if (variable->flags & CV_NETVAR) if (variable->flags & CV_NETVAR)
{ {
const consvar_t *netvar;
variable->netid = CV_ComputeNetid(variable->name); variable->netid = CV_ComputeNetid(variable->name);
if (CV_FindNetVar(variable->netid)) netvar = CV_FindNetVar(variable->netid);
I_Error("Variables %s and %s have same netid\n", variable->name, CV_FindNetVar(variable->netid)->name); if (netvar)
I_Error("Variables %s and %s have same netid\n", variable->name, netvar->name);
} }
// link the variable in // link the variable in

View file

@ -84,19 +84,23 @@ UINT32 con_scalefactor; // text size scale factor
// hold 32 last lines of input for history // hold 32 last lines of input for history
#define CON_MAXPROMPTCHARS 256 #define CON_MAXPROMPTCHARS 256
#define CON_PROMPTCHAR '>' #define CON_PROMPTCHAR '$'
static char inputlines[32][CON_MAXPROMPTCHARS]; // hold last 32 prompt lines static char inputlines[32][CON_MAXPROMPTCHARS]; // hold last 32 prompt lines
static INT32 inputline; // current input line number static INT32 inputline; // current input line number
static INT32 inputhist; // line number of history input line to restore static INT32 inputhist; // line number of history input line to restore
static size_t input_cx; // position in current input line static size_t input_cur; // position of cursor in line
static size_t input_sel; // position of selection marker (I.E.: anything between this and input_cur is "selected")
static size_t input_len; // length of current line, used to bound cursor and such
// notice: input does NOT include the "$" at the start of the line. - 11/3/16
// protos. // protos.
static void CON_InputInit(void); static void CON_InputInit(void);
static void CON_RecalcSize(void); static void CON_RecalcSize(void);
static void CONS_hudlines_Change(void); static void CONS_hudlines_Change(void);
static void CONS_backcolor_Change(void);
static void CON_DrawBackpic(patch_t *pic, INT32 startx, INT32 destwidth); static void CON_DrawBackpic(patch_t *pic, INT32 startx, INT32 destwidth);
//static void CON_DrawBackpic2(pic_t *pic, INT32 startx, INT32 destwidth); //static void CON_DrawBackpic2(pic_t *pic, INT32 startx, INT32 destwidth);
@ -129,10 +133,11 @@ static CV_PossibleValue_t backpic_cons_t[] = {{0, "translucent"}, {1, "picture"}
// whether to use console background picture, or translucent mode // whether to use console background picture, or translucent mode
static consvar_t cons_backpic = {"con_backpic", "translucent", CV_SAVE, backpic_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static consvar_t cons_backpic = {"con_backpic", "translucent", CV_SAVE, backpic_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t backcolor_cons_t[] = {{0, "White"}, {1, "Orange"}, static CV_PossibleValue_t backcolor_cons_t[] = {{0, "White"}, {1, "Gray"}, {2, "Brown"},
{2, "Blue"}, {3, "Green"}, {4, "Gray"}, {3, "Red"}, {4, "Orange"}, {5, "Yellow"},
{5, "Red"}, {0, NULL}}; {6, "Green"}, {7, "Blue"}, {8, "Cyan"},
consvar_t cons_backcolor = {"con_backcolor", "3", CV_SAVE, backcolor_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; {0, NULL}};
consvar_t cons_backcolor = {"con_backcolor", "Green", CV_CALL|CV_SAVE, backcolor_cons_t, CONS_backcolor_Change, 0, NULL, NULL, 0, 0, NULL};
static void CON_Print(char *msg); static void CON_Print(char *msg);
@ -219,8 +224,9 @@ static void CONS_Bind_f(void)
// CONSOLE SETUP // CONSOLE SETUP
//====================================================================== //======================================================================
// Prepare a colormap for GREEN ONLY translucency over background // Font colormap colors
// // TODO: This could probably be improved somehow...
// These colormaps are 99% identical, with just a few changed bytes
UINT8 *yellowmap; UINT8 *yellowmap;
UINT8 *purplemap; UINT8 *purplemap;
UINT8 *lgreenmap; UINT8 *lgreenmap;
@ -229,44 +235,49 @@ UINT8 *graymap;
UINT8 *redmap; UINT8 *redmap;
UINT8 *orangemap; UINT8 *orangemap;
// Console BG colors // Console BG color
UINT8 *cwhitemap; UINT8 *consolebgmap = NULL;
UINT8 *corangemap;
UINT8 *cbluemap;
UINT8 *cgreenmap;
UINT8 *cgraymap;
UINT8 *credmap;
void CON_ReSetupBackColormap(UINT16 num) void CON_SetupBackColormap(void)
{ {
UINT16 i, j; UINT16 i, palsum;
UINT8 k; UINT8 j, palindex;
UINT8 *pal = W_CacheLumpName(R_GetPalname(num), PU_CACHE); UINT8 *pal = W_CacheLumpName(GetPalette(), PU_CACHE);
// setup the green translucent background colormaps if (!consolebgmap)
for (i = 0, k = 0; i < 768; i += 3, k++) consolebgmap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL);
switch (cons_backcolor.value)
{ {
j = pal[i] + pal[i+1] + pal[i+2]; case 0: palindex = 15; break; // White
cwhitemap[k] = (UINT8)(15 - (j>>6)); case 1: palindex = 31; break; // Gray
corangemap[k] = (UINT8)(95 - (j>>6)); case 2: palindex = 63; break; // Brown
cbluemap[k] = (UINT8)(239 - (j>>6)); case 3: palindex = 143; break; // Red
cgreenmap[k] = (UINT8)(175 - (j>>6)); case 4: palindex = 95; break; // Orange
cgraymap[k] = (UINT8)(31 - (j>>6)); case 5: palindex = 111; break; // Yellow
credmap[k] = (UINT8)(143 - (j>>6)); case 6: palindex = 175; break; // Green
case 7: palindex = 239; break; // Blue
case 8: palindex = 219; break; // Cyan
// Default green
default: palindex = 175; break;
}
// setup background colormap
for (i = 0, j = 0; i < 768; i += 3, j++)
{
palsum = (pal[i] + pal[i+1] + pal[i+2]) >> 6;
consolebgmap[j] = (UINT8)(palindex - palsum);
} }
} }
static void CON_SetupBackColormap(void) static void CONS_backcolor_Change(void)
{ {
INT32 i, j, k; CON_SetupBackColormap();
UINT8 *pal; }
cwhitemap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL); static void CON_SetupColormaps(void)
corangemap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL); {
cbluemap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL); INT32 i;
cgreenmap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL);
cgraymap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL);
credmap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL);
yellowmap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL); yellowmap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL);
graymap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL); graymap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL);
@ -276,20 +287,6 @@ static void CON_SetupBackColormap(void)
redmap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL); redmap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL);
orangemap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL); orangemap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL);
pal = W_CacheLumpName("PLAYPAL", PU_CACHE);
// setup the green translucent background colormaps
for (i = 0, k = 0; i < 768; i += 3, k++)
{
j = pal[i] + pal[i+1] + pal[i+2];
cwhitemap[k] = (UINT8)(15 - (j>>6));
corangemap[k] = (UINT8)(95 - (j>>6));
cbluemap[k] = (UINT8)(239 - (j>>6));
cgreenmap[k] = (UINT8)(175 - (j>>6));
cgraymap[k] = (UINT8)(31 - (j>>6));
credmap[k] = (UINT8)(143 - (j>>6));
}
// setup the other colormaps, for console text // setup the other colormaps, for console text
// these don't need to be aligned, unless you convert the // these don't need to be aligned, unless you convert the
@ -320,6 +317,9 @@ static void CON_SetupBackColormap(void)
redmap[9] = (UINT8)127; redmap[9] = (UINT8)127;
orangemap[3] = (UINT8)85; orangemap[3] = (UINT8)85;
orangemap[9] = (UINT8)90; orangemap[9] = (UINT8)90;
// Init back colormap
CON_SetupBackColormap();
} }
// Setup the console text buffer // Setup the console text buffer
@ -343,7 +343,7 @@ void CON_Init(void)
con_width = 0; con_width = 0;
CON_RecalcSize(); CON_RecalcSize();
CON_SetupBackColormap(); CON_SetupColormaps();
//note: CON_Ticker should always execute at least once before D_Display() //note: CON_Ticker should always execute at least once before D_Display()
con_clipviewtop = -1; // -1 does not clip con_clipviewtop = -1; // -1 does not clip
@ -386,14 +386,10 @@ void CON_Init(void)
// //
static void CON_InputInit(void) static void CON_InputInit(void)
{ {
INT32 i;
// prepare the first prompt line // prepare the first prompt line
memset(inputlines, 0, sizeof (inputlines)); memset(inputlines, 0, sizeof (inputlines));
for (i = 0; i < 32; i++)
inputlines[i][0] = CON_PROMPTCHAR;
inputline = 0; inputline = 0;
input_cx = 1; input_cur = input_sel = input_len = 0;
} }
//====================================================================== //======================================================================
@ -618,13 +614,91 @@ void CON_Ticker(void)
} }
} }
//
// ----
//
// Shortcuts for adding and deleting characters, strings, and sections
// Necessary due to moving cursor
//
static void CON_InputClear(void)
{
memset(inputlines[inputline], 0, CON_MAXPROMPTCHARS);
input_cur = input_sel = input_len = 0;
}
static void CON_InputSetString(const char *c)
{
memset(inputlines[inputline], 0, CON_MAXPROMPTCHARS);
strcpy(inputlines[inputline], c);
input_cur = input_sel = input_len = strlen(c);
}
static void CON_InputAddString(const char *c)
{
size_t csize = strlen(c);
if (input_len + csize > CON_MAXPROMPTCHARS-1)
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);
}
static void CON_InputDelSelection(void)
{
size_t start, end, len;
if (input_cur > input_sel)
{
start = input_sel;
end = input_cur;
}
else
{
start = input_cur;
end = input_sel;
}
len = (end - start);
if (end != input_len)
memmove(&inputlines[inputline][start], &inputlines[inputline][end], input_len-end);
memset(&inputlines[inputline][input_len - len], 0, len);
input_len -= len;
input_sel = input_cur = start;
}
static void CON_InputAddChar(char c)
{
if (input_len >= CON_MAXPROMPTCHARS-1)
return;
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;
}
static void CON_InputDelChar(void)
{
if (!input_cur)
return;
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;
}
//
// ----
//
// Handles console key input // Handles console key input
// //
boolean CON_Responder(event_t *ev) boolean CON_Responder(event_t *ev)
{ {
static boolean consdown; static UINT8 consdown = false; // console is treated differently due to rare usage
static boolean shiftdown;
static boolean ctrldown;
// sequential completions a la 4dos // sequential completions a la 4dos
static char completion[80]; static char completion[80];
@ -639,13 +713,8 @@ boolean CON_Responder(event_t *ev)
// let go keyup events, don't eat them // let go keyup events, don't eat them
if (ev->type != ev_keydown && ev->type != ev_console) if (ev->type != ev_keydown && ev->type != ev_console)
{ {
if (ev->data1 == KEY_LSHIFT || ev->data1 == KEY_RSHIFT) if (ev->data1 == gamecontrol[gc_console][0] || ev->data1 == gamecontrol[gc_console][1])
shiftdown = false;
else if (ev->data1 == KEY_LCTRL || ev->data1 == KEY_RCTRL)
ctrldown = false;
else if (ev->data1 == gamecontrol[gc_console][0] || ev->data1 == gamecontrol[gc_console][1])
consdown = false; consdown = false;
return false; return false;
} }
@ -684,94 +753,110 @@ boolean CON_Responder(event_t *ev)
consoletoggle = true; consoletoggle = true;
return true; return true;
} }
} }
// eat shift only if console active // Always eat ctrl/shift/alt if console open, so the menu doesn't get ideas
if (key == KEY_LSHIFT || key == KEY_RSHIFT) if (key == KEY_LSHIFT || key == KEY_RSHIFT
{ || key == KEY_LCTRL || key == KEY_RCTRL
shiftdown = true; || key == KEY_LALT || key == KEY_RALT)
return true; return true;
}
// same for ctrl // ctrl modifier -- changes behavior, adds shortcuts
if (key == KEY_LCTRL || key == KEY_RCTRL) if (ctrldown)
{ {
ctrldown = true; // show all cvars/commands that match what we have inputted
return true; if (key == KEY_TAB)
{
size_t i, len;
if (!completion[0])
{
if (!input_len || input_len >= 40 || strchr(inputlines[inputline], ' '))
return true;
strcpy(completion, inputlines[inputline]);
comskips = varskips = 0;
}
len = strlen(completion);
//first check commands
CONS_Printf("\nCommands:\n");
for (i = 0, cmd = COM_CompleteCommand(completion, i); cmd; cmd = COM_CompleteCommand(completion, ++i))
CONS_Printf(" \x83" "%s" "\x80" "%s\n", completion, cmd+len);
if (i == 0) CONS_Printf(" (none)\n");
//now we move on to CVARs
CONS_Printf("Variables:\n");
for (i = 0, cmd = CV_CompleteVar(completion, i); cmd; cmd = CV_CompleteVar(completion, ++i))
CONS_Printf(" \x83" "%s" "\x80" "%s\n", completion, cmd+len);
if (i == 0) CONS_Printf(" (none)\n");
return true;
}
// ---
if (key == KEY_HOME) // oldest text in buffer
{
con_scrollup = (con_totallines-((con_curlines-16)>>3));
return true;
}
else if (key == KEY_END) // most recent text in buffer
{
con_scrollup = 0;
return true;
}
if (key == 'x' || key == 'X')
{
if (input_sel > input_cur)
I_ClipboardCopy(&inputlines[inputline][input_cur], input_sel-input_cur);
else
I_ClipboardCopy(&inputlines[inputline][input_sel], input_cur-input_sel);
CON_InputDelSelection();
completion[0] = 0;
return true;
}
else if (key == 'c' || key == 'C')
{
if (input_sel > input_cur)
I_ClipboardCopy(&inputlines[inputline][input_cur], input_sel-input_cur);
else
I_ClipboardCopy(&inputlines[inputline][input_sel], input_cur-input_sel);
return true;
}
else if (key == 'v' || key == 'V')
{
const char *paste = I_ClipboardPaste();
if (input_sel != input_cur)
CON_InputDelSelection();
if (paste != NULL)
CON_InputAddString(paste);
completion[0] = 0;
return true;
}
// Select all
if (key == 'a' || key == 'A')
{
input_sel = 0;
input_cur = input_len;
return true;
}
// don't eat the key
return false;
} }
// command completion forward (tab) and backward (shift-tab) // command completion forward (tab) and backward (shift-tab)
if (key == KEY_TAB) if (key == KEY_TAB)
{ {
// show all cvars/commands that match what we have inputted
if (ctrldown)
{
UINT32 i;
size_t stop = input_cx - 1;
char nameremainder[255];
if (input_cx < 2 || strlen(inputlines[inputline]+1) >= 80)
return true;
strcpy(completion, inputlines[inputline]+1);
// trimming: stop at the first newline
for (i = 0; i < input_cx - 1; ++i)
{
if (completion[i] == ' ')
{
completion[i] = '\0';
stop = i;
break;
}
}
i = 0;
//first check commands
CONS_Printf("\nCommands:\n");
for (cmd = COM_CompleteCommand(completion, i); cmd; cmd = COM_CompleteCommand(completion, i))
{
strncpy(nameremainder, cmd+(stop), strlen(cmd)-(stop));
nameremainder[strlen(cmd)-(stop)] = '\0';
CONS_Printf(" \x83" "%s" "\x80" "%s\n", completion, nameremainder);
++i;
}
if (i == 0)
CONS_Printf(" (none)\n");
i = 0;
//now we move on to CVARs
CONS_Printf("Variables:\n");
for (cmd = CV_CompleteVar(completion, i); cmd; cmd = CV_CompleteVar(completion, i))
{
strncpy(nameremainder, cmd+(stop), strlen(cmd)-(stop));
nameremainder[strlen(cmd)-(stop)] = '\0';
CONS_Printf(" \x83" "%s" "\x80" "%s\n", completion, nameremainder);
++i;
}
if (i == 0)
CONS_Printf(" (none)\n");
return true;
}
// sequential command completion forward and backward // sequential command completion forward and backward
// remember typing for several completions (a-la-4dos) // remember typing for several completions (a-la-4dos)
if (inputlines[inputline][input_cx-1] != ' ') if (!completion[0])
{ {
if (strlen(inputlines[inputline]+1) < 80) if (!input_len || input_len >= 40 || strchr(inputlines[inputline], ' '))
strcpy(completion, inputlines[inputline]+1); return true;
else strcpy(completion, inputlines[inputline]);
completion[0] = 0;
comskips = varskips = 0; comskips = varskips = 0;
} }
else else
@ -783,37 +868,26 @@ boolean CON_Responder(event_t *ev)
if (--varskips < 0) if (--varskips < 0)
comskips = -comskips - 2; comskips = -comskips - 2;
} }
else if (comskips > 0) else if (comskips > 0) comskips--;
comskips--;
} }
else else
{ {
if (comskips < 0) if (comskips < 0) varskips++;
varskips++; else comskips++;
else
comskips++;
} }
} }
if (comskips >= 0) if (comskips >= 0)
{ {
cmd = COM_CompleteCommand(completion, comskips); cmd = COM_CompleteCommand(completion, comskips);
if (!cmd) if (!cmd) // dirty: make sure if comskips is zero, to have a neg value
// dirty: make sure if comskips is zero, to have a neg value
comskips = -comskips - 1; comskips = -comskips - 1;
} }
if (comskips < 0) if (comskips < 0)
cmd = CV_CompleteVar(completion, varskips); cmd = CV_CompleteVar(completion, varskips);
if (cmd) if (cmd)
{ CON_InputSetString(va("%s ", cmd));
memset(inputlines[inputline]+1, 0, CON_MAXPROMPTCHARS-1);
strcpy(inputlines[inputline]+1, cmd);
input_cx = strlen(cmd) + 1;
inputlines[inputline][input_cx] = ' ';
input_cx++;
inputlines[inputline][input_cx] = 0;
}
else else
{ {
if (comskips > 0) if (comskips > 0)
@ -839,47 +913,80 @@ boolean CON_Responder(event_t *ev)
return true; return true;
} }
if (key == KEY_HOME) // oldest text in buffer if (key == KEY_LEFTARROW)
{ {
con_scrollup = (con_totallines-((con_curlines-16)>>3)); if (input_cur != 0)
--input_cur;
if (!shiftdown)
input_sel = input_cur;
return true; return true;
} }
else if (key == KEY_END) // most recent text in buffer else if (key == KEY_RIGHTARROW)
{ {
con_scrollup = 0; if (input_cur < input_len)
++input_cur;
if (!shiftdown)
input_sel = input_cur;
return true; return true;
} }
else if (key == KEY_HOME)
{
input_cur = 0;
if (!shiftdown)
input_sel = input_cur;
return true;
}
else if (key == KEY_END)
{
input_cur = input_len;
if (!shiftdown)
input_sel = input_cur;
return true;
}
// At this point we're messing with input
// Clear completion
completion[0] = 0;
// command enter // command enter
if (key == KEY_ENTER) if (key == KEY_ENTER)
{ {
if (input_cx < 2) if (!input_len)
return true; return true;
// push the command // push the command
COM_BufAddText(inputlines[inputline]+1); COM_BufAddText(inputlines[inputline]);
COM_BufAddText("\n"); COM_BufAddText("\n");
CONS_Printf("%s\n", inputlines[inputline]); CONS_Printf("\x86""%c""\x80""%s\n", CON_PROMPTCHAR, inputlines[inputline]);
inputline = (inputline+1) & 31; inputline = (inputline+1) & 31;
inputhist = inputline; inputhist = inputline;
CON_InputClear();
memset(inputlines[inputline], 0, CON_MAXPROMPTCHARS);
inputlines[inputline][0] = CON_PROMPTCHAR;
input_cx = 1;
return true; return true;
} }
// backspace command prompt // backspace and delete command prompt
if (key == KEY_BACKSPACE) if (input_sel != input_cur)
{ {
if (input_cx > 1) if (key == KEY_BACKSPACE || key == KEY_DEL)
{ {
input_cx--; CON_InputDelSelection();
inputlines[inputline][input_cx] = 0; return true;
} }
}
else if (key == KEY_BACKSPACE)
{
CON_InputDelChar();
return true;
}
else if (key == KEY_DEL)
{
if (input_cur == input_len)
return true;
++input_cur;
CON_InputDelChar();
return true; return true;
} }
@ -888,18 +995,15 @@ boolean CON_Responder(event_t *ev)
{ {
// copy one of the previous inputlines to the current // copy one of the previous inputlines to the current
do do
{
inputhist = (inputhist - 1) & 31; // cycle back inputhist = (inputhist - 1) & 31; // cycle back
} while (inputhist != inputline && !inputlines[inputhist][1]); while (inputhist != inputline && !inputlines[inputhist][0]);
// stop at the last history input line, which is the // stop at the last history input line, which is the
// current line + 1 because we cycle through the 32 input lines // current line + 1 because we cycle through the 32 input lines
if (inputhist == inputline) if (inputhist == inputline)
inputhist = (inputline + 1) & 31; inputhist = (inputline + 1) & 31;
M_Memcpy(inputlines[inputline], inputlines[inputhist], CON_MAXPROMPTCHARS); CON_InputSetString(inputlines[inputhist]);
input_cx = strlen(inputlines[inputline]);
return true; return true;
} }
@ -909,23 +1013,14 @@ boolean CON_Responder(event_t *ev)
if (inputhist == inputline) if (inputhist == inputline)
return true; return true;
do do
{
inputhist = (inputhist + 1) & 31; inputhist = (inputhist + 1) & 31;
} while (inputhist != inputline && !inputlines[inputhist][1]); while (inputhist != inputline && !inputlines[inputhist][0]);
memset(inputlines[inputline], 0, CON_MAXPROMPTCHARS);
// back to currentline // back to currentline
if (inputhist == inputline) if (inputhist == inputline)
{ CON_InputClear();
inputlines[inputline][0] = CON_PROMPTCHAR;
input_cx = 1;
}
else else
{ CON_InputSetString(inputlines[inputhist]);
strcpy(inputlines[inputline], inputlines[inputhist]);
input_cx = strlen(inputlines[inputline]);
}
return true; return true;
} }
@ -950,15 +1045,12 @@ boolean CON_Responder(event_t *ev)
return false; return false;
// add key to cmd line here // add key to cmd line here
if (input_cx < CON_MAXPROMPTCHARS) if (key >= 'A' && key <= 'Z' && !shiftdown) //this is only really necessary for dedicated servers
{ key = key + 'a' - 'A';
if (key >= 'A' && key <= 'Z' && !shiftdown) //this is only really necessary for dedicated servers
key = key + 'a' - 'A';
inputlines[inputline][input_cx] = (char)key; if (input_sel != input_cur)
inputlines[inputline][input_cx + 1] = 0; CON_InputDelSelection();
input_cx++; CON_InputAddChar(key);
}
return true; return true;
} }
@ -1242,26 +1334,89 @@ void CONS_Error(const char *msg)
// //
static void CON_DrawInput(void) static void CON_DrawInput(void)
{ {
char *p;
size_t c;
INT32 x, y;
INT32 charwidth = (INT32)con_scalefactor << 3; INT32 charwidth = (INT32)con_scalefactor << 3;
const char *p = inputlines[inputline];
// input line scrolls left if it gets too long size_t c, clen, cend;
p = inputlines[inputline]; UINT8 lellip = 0, rellip = 0;
if (input_cx >= con_width-11) INT32 x, y, i;
p += input_cx - (con_width-11) + 1;
y = con_curlines - 12 * con_scalefactor; y = con_curlines - 12 * con_scalefactor;
x = charwidth*2;
for (c = 0, x = charwidth; c < con_width-11; c++, x += charwidth) clen = con_width-13;
V_DrawCharacter(x, y, p[c] | cv_constextsize.value | V_NOSCALESTART, !cv_allcaps.value);
// draw the blinking cursor if (input_len <= clen)
// {
x = ((input_cx >= con_width-11) ? (INT32)(con_width-11) : (INT32)((input_cx + 1)) * charwidth); c = 0;
if (con_tick < 4) clen = input_len;
V_DrawCharacter(x, y, '_' | cv_constextsize.value | V_NOSCALESTART, !cv_allcaps.value); }
else // input line scrolls left if it gets too long
{
clen -= 2; // There will always be some extra truncation -- but where is what we'll find out
if (input_cur <= clen/2)
{
// Close enough to right edge to show all
c = 0;
// Always will truncate right side from this position, so always draw right ellipsis
rellip = 1;
}
else
{
// Cursor in the middle (or right side) of input
// Move over for the ellipsis
c = input_cur - (clen/2) + 2;
x += charwidth*2;
lellip = 1;
if (c + clen >= input_len)
{
// Cursor in the right side of input
// We were too far over, so move back
c = input_len - clen;
}
else
{
// Cursor in the middle -- ellipses on both sides
clen -= 2;
rellip = 1;
}
}
}
if (lellip)
{
x -= charwidth*3;
if (input_sel < c)
V_DrawFill(x, y, charwidth*3, (10 * con_scalefactor), 107 | V_NOSCALESTART);
for (i = 0; i < 3; ++i, x += charwidth)
V_DrawCharacter(x, y, '.' | cv_constextsize.value | V_GRAYMAP | V_NOSCALESTART, !cv_allcaps.value);
}
else
V_DrawCharacter(x-charwidth, y, CON_PROMPTCHAR | cv_constextsize.value | V_GRAYMAP | V_NOSCALESTART, !cv_allcaps.value);
for (cend = c + clen; c < cend; ++c, x += charwidth)
{
if ((input_sel > c && input_cur <= c) || (input_sel <= c && input_cur > c))
{
V_DrawFill(x, y, charwidth, (10 * con_scalefactor), 107 | V_NOSCALESTART);
V_DrawCharacter(x, y, p[c] | cv_constextsize.value | V_YELLOWMAP | V_NOSCALESTART, !cv_allcaps.value);
}
else
V_DrawCharacter(x, y, p[c] | cv_constextsize.value | V_NOSCALESTART, !cv_allcaps.value);
if (c == input_cur && con_tick >= 4)
V_DrawCharacter(x, y + (con_scalefactor*2), '_' | cv_constextsize.value | V_NOSCALESTART, !cv_allcaps.value);
}
if (cend == input_cur && con_tick >= 4)
V_DrawCharacter(x, y + (con_scalefactor*2), '_' | cv_constextsize.value | V_NOSCALESTART, !cv_allcaps.value);
if (rellip)
{
if (input_sel > cend)
V_DrawFill(x, y, charwidth*3, (10 * con_scalefactor), 107 | V_NOSCALESTART);
for (i = 0; i < 3; ++i, x += charwidth)
V_DrawCharacter(x, y, '.' | cv_constextsize.value | V_GRAYMAP | V_NOSCALESTART, !cv_allcaps.value);
}
} }
// draw the last lines of console text to the top of the screen // draw the last lines of console text to the top of the screen
@ -1417,7 +1572,7 @@ static void CON_DrawConsole(void)
{ {
// inu: no more width (was always 0 and vid.width) // inu: no more width (was always 0 and vid.width)
if (rendermode != render_none) if (rendermode != render_none)
V_DrawFadeConsBack(con_curlines, cons_backcolor.value); // translucent background V_DrawFadeConsBack(con_curlines); // translucent background
} }
// draw console text lines from top to bottom // draw console text lines from top to bottom

View file

@ -40,11 +40,10 @@ extern consvar_t cons_backcolor;
extern UINT8 *yellowmap, *purplemap, *lgreenmap, *bluemap, *graymap, *redmap, *orangemap; extern UINT8 *yellowmap, *purplemap, *lgreenmap, *bluemap, *graymap, *redmap, *orangemap;
// Console bg colors: // Console bg color (auto updated to match)
extern UINT8 *cwhitemap, *corangemap, *cbluemap, *cgreenmap, *cgraymap, extern UINT8 *consolebgmap;
*credmap;
void CON_ReSetupBackColormap(UINT16 num); void CON_SetupBackColormap(void);
void CON_ClearHUD(void); // clear heads up messages void CON_ClearHUD(void); // clear heads up messages
void CON_Ticker(void); void CON_Ticker(void);

File diff suppressed because it is too large Load diff

View file

@ -59,7 +59,7 @@ typedef enum
// Add non-PT_CANFAIL packet types here to avoid breaking MS compatibility. // Add non-PT_CANFAIL packet types here to avoid breaking MS compatibility.
PT_CANFAIL, // This is kind of a priority. Anything bigger than CANFAIL PT_CANFAIL, // This is kind of a priority. Anything bigger than CANFAIL
// allows HSendPacket(,true,,) to return false. // allows HSendPacket(*, true, *, *) to return false.
// In addition, this packet can't occupy all the available slots. // In addition, this packet can't occupy all the available slots.
PT_FILEFRAGMENT = PT_CANFAIL, // A part of a file. PT_FILEFRAGMENT = PT_CANFAIL, // A part of a file.
@ -76,11 +76,19 @@ typedef enum
NUMPACKETTYPE NUMPACKETTYPE
} packettype_t; } packettype_t;
#ifdef PACKETDROP
void Command_Drop(void);
void Command_Droprate(void);
#endif
#ifdef _DEBUG
void Command_Numnodes(void);
#endif
#if defined(_MSC_VER) #if defined(_MSC_VER)
#pragma pack(1) #pragma pack(1)
#endif #endif
// client to server packet // Client to server packet
typedef struct typedef struct
{ {
UINT8 client_tic; UINT8 client_tic;
@ -89,7 +97,7 @@ typedef struct
ticcmd_t cmd; ticcmd_t cmd;
} ATTRPACK clientcmd_pak; } ATTRPACK clientcmd_pak;
// splitscreen packet // Splitscreen packet
// WARNING: must have the same format of clientcmd_pak, for more easy use // WARNING: must have the same format of clientcmd_pak, for more easy use
typedef struct typedef struct
{ {
@ -110,16 +118,16 @@ typedef struct
UINT8 starttic; UINT8 starttic;
UINT8 numtics; UINT8 numtics;
UINT8 numslots; // "Slots filled": Highest player number in use plus one. UINT8 numslots; // "Slots filled": Highest player number in use plus one.
ticcmd_t cmds[45]; // normally [BACKUPTIC][MAXPLAYERS] but too large ticcmd_t cmds[45]; // Normally [BACKUPTIC][MAXPLAYERS] but too large
} ATTRPACK servertics_pak; } ATTRPACK servertics_pak;
// sent to client when all consistency data // Sent to client when all consistency data
// for players has been restored // for players has been restored
typedef struct typedef struct
{ {
UINT32 randomseed; UINT32 randomseed;
//ctf flag stuff // CTF flag stuff
SINT8 flagplayer[2]; SINT8 flagplayer[2];
INT32 flagloose[2]; INT32 flagloose[2];
INT32 flagflags[2]; INT32 flagflags[2];
@ -127,11 +135,11 @@ typedef struct
fixed_t flagy[2]; fixed_t flagy[2];
fixed_t flagz[2]; fixed_t flagz[2];
UINT32 ingame; // spectator bit for each player UINT32 ingame; // Spectator bit for each player
UINT32 ctfteam; // if not spectator, then which team? INT32 ctfteam[MAXPLAYERS]; // Which team? (can't be 1 bit, since in regular Match there are no teams)
// Resynch game scores and the like all at once // Resynch game scores and the like all at once
UINT32 score[MAXPLAYERS]; // Everyone's score. UINT32 score[MAXPLAYERS]; // Everyone's score
INT16 numboxes[MAXPLAYERS]; INT16 numboxes[MAXPLAYERS];
INT16 totalring[MAXPLAYERS]; INT16 totalring[MAXPLAYERS];
tic_t realtime[MAXPLAYERS]; tic_t realtime[MAXPLAYERS];
@ -140,14 +148,14 @@ typedef struct
typedef struct typedef struct
{ {
//player stuff // Player stuff
UINT8 playernum; UINT8 playernum;
// Do not send anything visual related. // Do not send anything visual related.
// Only send data that we need to know for physics. // Only send data that we need to know for physics.
UINT8 playerstate; //playerstate_t UINT8 playerstate; // playerstate_t
UINT32 pflags; //pflags_t UINT32 pflags; // pflags_t
UINT8 panim; //panim_t UINT8 panim; // panim_t
angle_t aiming; angle_t aiming;
INT32 currentweapon; INT32 currentweapon;
@ -180,9 +188,9 @@ typedef struct
UINT8 charability; UINT8 charability;
UINT8 charability2; UINT8 charability2;
UINT32 charflags; UINT32 charflags;
UINT32 thokitem; //mobjtype_t UINT32 thokitem; // mobjtype_t
UINT32 spinitem; //mobjtype_t UINT32 spinitem; // mobjtype_t
UINT32 revitem; //mobjtype_t UINT32 revitem; // mobjtype_t
fixed_t actionspd; fixed_t actionspd;
fixed_t mindash; fixed_t mindash;
fixed_t maxdash; fixed_t maxdash;
@ -236,7 +244,7 @@ typedef struct
INT32 onconveyor; INT32 onconveyor;
//player->mo stuff //player->mo stuff
UINT8 hasmo; //boolean UINT8 hasmo; // Boolean
angle_t angle; angle_t angle;
fixed_t x; fixed_t x;
@ -263,10 +271,10 @@ typedef struct
typedef struct typedef struct
{ {
UINT8 version; // different versions don't work UINT8 version; // Different versions don't work
UINT8 subversion; // contains build version UINT8 subversion; // Contains build version
// server launch stuffs // Server launch stuffs
UINT8 serverplayer; UINT8 serverplayer;
UINT8 totalslotnum; // "Slots": highest player number in use plus one. UINT8 totalslotnum; // "Slots": highest player number in use plus one.
@ -280,18 +288,18 @@ typedef struct
UINT8 gametype; UINT8 gametype;
UINT8 modifiedgame; UINT8 modifiedgame;
SINT8 adminplayer; // needs to be signed SINT8 adminplayer; // Needs to be signed
char server_context[8]; // unique context id, generated at server startup. char server_context[8]; // Unique context id, generated at server startup.
UINT8 varlengthinputs[0]; // playernames and netvars UINT8 varlengthinputs[0]; // Playernames and netvars
} ATTRPACK serverconfig_pak; } ATTRPACK serverconfig_pak;
typedef struct { typedef struct {
UINT8 fileid; UINT8 fileid;
UINT32 position; UINT32 position;
UINT16 size; UINT16 size;
UINT8 data[0]; // size is variable using hardware_MAXPACKETLENGTH UINT8 data[0]; // Size is variable using hardware_MAXPACKETLENGTH
} ATTRPACK filetx_pak; } ATTRPACK filetx_pak;
#ifdef _MSC_VER #ifdef _MSC_VER
@ -300,14 +308,14 @@ typedef struct {
typedef struct typedef struct
{ {
UINT8 version; // different versions don't work UINT8 version; // Different versions don't work
UINT8 subversion; // contains build version UINT8 subversion; // Contains build version
UINT8 localplayers; UINT8 localplayers;
UINT8 mode; UINT8 mode;
} ATTRPACK clientconfig_pak; } ATTRPACK clientconfig_pak;
#define MAXSERVERNAME 32 #define MAXSERVERNAME 32
// this packet is too large // This packet is too large
typedef struct typedef struct
{ {
UINT8 version; UINT8 version;
@ -373,45 +381,45 @@ typedef struct
} ATTRPACK plrconfig; } ATTRPACK plrconfig;
// //
// Network packet data. // Network packet data
// //
typedef struct typedef struct
{ {
UINT32 checksum; UINT32 checksum;
UINT8 ack; // if not null the node asks for acknowledgement, the receiver must resend the ack UINT8 ack; // If not zero the node asks for acknowledgement, the receiver must resend the ack
UINT8 ackreturn; // the return of the ack number UINT8 ackreturn; // The return of the ack number
UINT8 packettype; UINT8 packettype;
UINT8 reserved; // padding UINT8 reserved; // Padding
union union
{ {
clientcmd_pak clientpak; // 144 bytes clientcmd_pak clientpak; // 144 bytes
client2cmd_pak client2pak; // 200 bytes client2cmd_pak client2pak; // 200 bytes
servertics_pak serverpak; // 132495 bytes servertics_pak serverpak; // 132495 bytes (more around 360, no?)
serverconfig_pak servercfg; // 773 bytes serverconfig_pak servercfg; // 773 bytes
resynchend_pak resynchend; // resynchend_pak resynchend; //
resynch_pak resynchpak; // resynch_pak resynchpak; //
UINT8 resynchgot; // UINT8 resynchgot; //
UINT8 textcmd[MAXTEXTCMD+1]; // 66049 bytes UINT8 textcmd[MAXTEXTCMD+1]; // 66049 bytes (wut??? 64k??? More like 257 bytes...)
filetx_pak filetxpak; // 139 bytes filetx_pak filetxpak; // 139 bytes
clientconfig_pak clientcfg; // 136 bytes clientconfig_pak clientcfg; // 136 bytes
serverinfo_pak serverinfo; // 1024 bytes serverinfo_pak serverinfo; // 1024 bytes
serverrefuse_pak serverrefuse; // 65025 bytes serverrefuse_pak serverrefuse; // 65025 bytes (somehow I feel like those values are garbage...)
askinfo_pak askinfo; // 61 bytes askinfo_pak askinfo; // 61 bytes
msaskinfo_pak msaskinfo; // 22 bytes msaskinfo_pak msaskinfo; // 22 bytes
plrinfo playerinfo[MAXPLAYERS]; // 1152 bytes plrinfo playerinfo[MAXPLAYERS]; // 1152 bytes (I'd say 36~38)
plrconfig playerconfig[MAXPLAYERS]; // (up to) 896 bytes plrconfig playerconfig[MAXPLAYERS]; // (up to) 896 bytes (welp they ARE)
#ifdef NEWPING #ifdef NEWPING
UINT32 pingtable[MAXPLAYERS]; // 128 bytes UINT32 pingtable[MAXPLAYERS]; // 128 bytes
#endif #endif
} u; // this is needed to pack diff packet types data together } u; // This is needed to pack diff packet types data together
} ATTRPACK doomdata_t; } ATTRPACK doomdata_t;
#if defined(_MSC_VER) #if defined(_MSC_VER)
#pragma pack() #pragma pack()
#endif #endif
#define MAXSERVERLIST 64 // depends only on the display #define MAXSERVERLIST 64 // Depends only on the display
typedef struct typedef struct
{ {
SINT8 node; SINT8 node;
@ -422,7 +430,7 @@ extern serverelem_t serverlist[MAXSERVERLIST];
extern UINT32 serverlistcount; extern UINT32 serverlistcount;
extern INT32 mapchangepending; extern INT32 mapchangepending;
// points inside doomcom // Points inside doomcom
extern doomdata_t *netbuffer; extern doomdata_t *netbuffer;
extern consvar_t cv_playbackspeed; extern consvar_t cv_playbackspeed;
@ -443,26 +451,28 @@ extern consvar_t cv_playbackspeed;
#define KICK_MSG_CUSTOM_BAN 8 #define KICK_MSG_CUSTOM_BAN 8
extern boolean server; extern boolean server;
extern boolean dedicated; // for dedicated server #define client (!server)
extern boolean dedicated; // For dedicated server
extern UINT16 software_MAXPACKETLENGTH; extern UINT16 software_MAXPACKETLENGTH;
extern boolean acceptnewnode; extern boolean acceptnewnode;
extern SINT8 servernode; extern SINT8 servernode;
void Command_Ping_f(void); void Command_Ping_f(void);
extern tic_t connectiontimeout; extern tic_t connectiontimeout;
extern tic_t jointimeout;
#ifdef NEWPING #ifdef NEWPING
extern UINT16 pingmeasurecount; extern UINT16 pingmeasurecount;
extern UINT32 realpingtable[MAXPLAYERS]; extern UINT32 realpingtable[MAXPLAYERS];
extern UINT32 playerpingtable[MAXPLAYERS]; extern UINT32 playerpingtable[MAXPLAYERS];
#endif #endif
extern consvar_t cv_joinnextround, cv_allownewplayer, cv_maxplayers, cv_resynchattempts, cv_blamecfail, cv_maxsend; extern consvar_t cv_joinnextround, cv_allownewplayer, cv_maxplayers, cv_resynchattempts, cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed;
// used in d_net, the only dependence // Used in d_net, the only dependence
tic_t ExpandTics(INT32 low); tic_t ExpandTics(INT32 low);
void D_ClientServerInit(void); void D_ClientServerInit(void);
// initialise the other field // Initialise the other field
void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(UINT8 **p, INT32 playernum)); void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(UINT8 **p, INT32 playernum));
void SendNetXCmd(netxcmd_t id, const void *param, size_t nparam); void SendNetXCmd(netxcmd_t id, const void *param, size_t nparam);
void SendNetXCmd2(netxcmd_t id, const void *param, size_t nparam); // splitsreen player void SendNetXCmd2(netxcmd_t id, const void *param, size_t nparam); // splitsreen player
@ -480,14 +490,14 @@ void CL_RemoveSplitscreenPlayer(void);
void CL_Reset(void); void CL_Reset(void);
void CL_ClearPlayer(INT32 playernum); void CL_ClearPlayer(INT32 playernum);
void CL_UpdateServerList(boolean internetsearch, INT32 room); void CL_UpdateServerList(boolean internetsearch, INT32 room);
// is there a game running // Is there a game running
boolean Playing(void); boolean Playing(void);
// Broadcasts special packets to other players // Broadcasts special packets to other players
// to notify of game exit // to notify of game exit
void D_QuitNetGame(void); void D_QuitNetGame(void);
//? how many ticks to run? //? How many ticks to run?
void TryRunTics(tic_t realtic); void TryRunTics(tic_t realtic);
// extra data for lmps // extra data for lmps

View file

@ -73,6 +73,7 @@ int snprintf(char *str, size_t n, const char *fmt, ...);
#include "dehacked.h" // Dehacked list test #include "dehacked.h" // Dehacked list test
#include "m_cond.h" // condition initialization #include "m_cond.h" // condition initialization
#include "fastcmp.h" #include "fastcmp.h"
#include "keys.h"
#ifdef CMAKECONFIG #ifdef CMAKECONFIG
#include "config.h" #include "config.h"
@ -176,6 +177,38 @@ void D_PostEvent(const event_t *ev)
void D_PostEvent_end(void) {}; void D_PostEvent_end(void) {};
#endif #endif
// modifier keys
UINT8 shiftdown = 0; // 0x1 left, 0x2 right
UINT8 ctrldown = 0; // 0x1 left, 0x2 right
UINT8 altdown = 0; // 0x1 left, 0x2 right
//
// 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;
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 // D_ProcessEvents
// Send all the events of the given timestamp down the responder chain // Send all the events of the given timestamp down the responder chain
@ -188,6 +221,9 @@ void D_ProcessEvents(void)
{ {
ev = &events[eventtail]; 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. // Screenshots over everything so that they can be taken anywhere.
if (M_ScreenshotResponder(ev)) if (M_ScreenshotResponder(ev))
continue; // ate the event continue; // ate the event
@ -1067,10 +1103,11 @@ void D_SRB2Main(void)
if (M_CheckParm("-warp") && M_IsNextParm()) if (M_CheckParm("-warp") && M_IsNextParm())
{ {
const char *word = M_GetNextParm(); const char *word = M_GetNextParm();
if (fastncmp(word, "MAP", 3)) char ch; // use this with sscanf to catch non-digits with
if (fastncmp(word, "MAP", 3)) // MAPxx name
pstartmap = M_MapNumber(word[3], word[4]); pstartmap = M_MapNumber(word[3], word[4]);
else else if (sscanf(word, "%d%c", &pstartmap, &ch) != 1) // a plain number
pstartmap = atoi(word); I_Error("Cannot warp to map %s (invalid map name)\n", word);
// Don't check if lump exists just yet because the wads haven't been loaded! // Don't check if lump exists just yet because the wads haven't been loaded!
// Just do a basic range check here. // Just do a basic range check here.
if (pstartmap < 1 || pstartmap > NUMMAPS) if (pstartmap < 1 || pstartmap > NUMMAPS)

View file

@ -41,7 +41,7 @@ void D_SRB2Main(void);
// Called by IO functions when input is detected. // Called by IO functions when input is detected.
void D_PostEvent(const event_t *ev); void D_PostEvent(const event_t *ev);
#ifndef DOXYGEN #ifndef DOXYGEN
void D_PostEvent_end(void); // delimiter for locking memory FUNCMATH void D_PostEvent_end(void); // delimiter for locking memory
#endif #endif
void D_ProcessEvents(void); void D_ProcessEvents(void);

View file

@ -31,18 +31,18 @@
// //
// NETWORKING // NETWORKING
// //
// gametic is the tic about to be (or currently being) run // gametic is the tic about to (or currently being) run
// server: // Server:
// maketic is the tic that hasn't had control made for it yet // maketic is the tic that hasn't had control made for it yet
// nettics: is the tic for each node // nettics is the tic for each node
// firsttictosend: is the lowest value of nettics // firstticstosend is the lowest value of nettics
// client: // Client:
// neededtic: is the tic needed by the client to run the game // neededtic is the tic needed by the client to run the game
// firsttictosend: is used to optimize a condition // firstticstosend is used to optimize a condition
// normally maketic >= gametic > 0 // Normally maketic >= gametic > 0
#define FORCECLOSE 0x8000 #define FORCECLOSE 0x8000
tic_t connectiontimeout = (15*TICRATE); tic_t connectiontimeout = (10*TICRATE);
/// \brief network packet /// \brief network packet
doomcom_t *doomcom = NULL; doomcom_t *doomcom = NULL;
@ -62,7 +62,7 @@ INT32 net_bandwidth;
/// \brief max length per packet /// \brief max length per packet
INT16 hardware_MAXPACKETLENGTH; INT16 hardware_MAXPACKETLENGTH;
void (*I_NetGet)(void) = NULL; boolean (*I_NetGet)(void) = NULL;
void (*I_NetSend)(void) = NULL; void (*I_NetSend)(void) = NULL;
boolean (*I_NetCanSend)(void) = NULL; boolean (*I_NetCanSend)(void) = NULL;
boolean (*I_NetCanGet)(void) = NULL; boolean (*I_NetCanGet)(void) = NULL;
@ -129,9 +129,9 @@ boolean Net_GetNetStat(void)
// ----------------------------------------------------------------- // -----------------------------------------------------------------
// Some structs and functions for acknowledgement of packets // Some structs and functions for acknowledgement of packets
// ----------------------------------------------------------------- // -----------------------------------------------------------------
#define MAXACKPACKETS 96 // minimum number of nodes #define MAXACKPACKETS 96 // Minimum number of nodes (wat)
#define MAXACKTOSEND 96 #define MAXACKTOSEND 96
#define URGENTFREESLOTENUM 10 #define URGENTFREESLOTNUM 10
#define ACKTOSENDTIMEOUT (TICRATE/11) #define ACKTOSENDTIMEOUT (TICRATE/11)
#ifndef NONET #ifndef NONET
@ -139,10 +139,10 @@ typedef struct
{ {
UINT8 acknum; UINT8 acknum;
UINT8 nextacknum; UINT8 nextacknum;
UINT8 destinationnode; UINT8 destinationnode; // The node to send the ack to
tic_t senttime; tic_t senttime; // The time when the ack was sent
UINT16 length; UINT16 length; // The packet size
UINT16 resentnum; UINT16 resentnum; // The number of times the ack has been resent
union { union {
SINT8 raw[MAXPACKETLENGTH]; SINT8 raw[MAXPACKETLENGTH];
doomdata_t data; doomdata_t data;
@ -152,11 +152,12 @@ typedef struct
typedef enum typedef enum
{ {
CLOSE = 1, // flag is set when connection is closing NF_CLOSE = 1, // Flag is set when connection is closing
NF_TIMEOUT = 2, // Flag is set when the node got a timeout
} node_flags_t; } node_flags_t;
#ifndef NONET #ifndef NONET
// table of packet that was not acknowleged can be resend (the sender window) // Table of packets that were not acknowleged can be resent (the sender window)
static ackpak_t ackpak[MAXACKPACKETS]; static ackpak_t ackpak[MAXACKPACKETS];
#endif #endif
@ -212,11 +213,16 @@ FUNCMATH static INT32 cmpack(UINT8 a, UINT8 b)
return d; return d;
} }
// return a free acknum and copy netbuffer in the ackpak table /** Sets freeack to a free acknum and copies the netbuffer in the ackpak table
*
* \param freeack The address to store the free acknum at
* \param lowtimer ???
* \return True if a free acknum was found
*/
static boolean GetFreeAcknum(UINT8 *freeack, boolean lowtimer) static boolean GetFreeAcknum(UINT8 *freeack, boolean lowtimer)
{ {
node_t *node = &nodes[doomcom->remotenode]; node_t *node = &nodes[doomcom->remotenode];
INT32 i, numfreeslote = 0; INT32 i, numfreeslot = 0;
if (cmpack((UINT8)((node->remotefirstack + MAXACKTOSEND) % 256), node->nextacknum) < 0) if (cmpack((UINT8)((node->remotefirstack + MAXACKTOSEND) % 256), node->nextacknum) < 0)
{ {
@ -227,10 +233,13 @@ static boolean GetFreeAcknum(UINT8 *freeack, boolean lowtimer)
for (i = 0; i < MAXACKPACKETS; i++) for (i = 0; i < MAXACKPACKETS; i++)
if (!ackpak[i].acknum) if (!ackpak[i].acknum)
{ {
// for low priority packet, make sure let freeslotes so urgents packets can be sent // For low priority packets, make sure to let freeslots so urgent packets can be sent
numfreeslote++; if (netbuffer->packettype >= PT_CANFAIL)
if (netbuffer->packettype >= PT_CANFAIL && numfreeslote < URGENTFREESLOTENUM) {
continue; numfreeslot++;
if (numfreeslot <= URGENTFREESLOTNUM)
continue;
}
ackpak[i].acknum = node->nextacknum; ackpak[i].acknum = node->nextacknum;
ackpak[i].nextacknum = node->nextacknum; ackpak[i].nextacknum = node->nextacknum;
@ -241,7 +250,7 @@ static boolean GetFreeAcknum(UINT8 *freeack, boolean lowtimer)
ackpak[i].length = doomcom->datalength; ackpak[i].length = doomcom->datalength;
if (lowtimer) if (lowtimer)
{ {
// lowtime mean can't be sent now so try it soon as possible // Lowtime means can't be sent now so try it as soon as possible
ackpak[i].senttime = 0; ackpak[i].senttime = 0;
ackpak[i].resentnum = 1; ackpak[i].resentnum = 1;
} }
@ -254,7 +263,7 @@ static boolean GetFreeAcknum(UINT8 *freeack, boolean lowtimer)
*freeack = ackpak[i].acknum; *freeack = ackpak[i].acknum;
sendackpacket++; // for stat sendackpacket++; // For stat
return true; return true;
} }
@ -266,14 +275,46 @@ static boolean GetFreeAcknum(UINT8 *freeack, boolean lowtimer)
return false; return false;
} }
// Get a ack to send in the queu of this node /** Counts how many acks are free
*
* \param urgent True if the type of the packet meant to
* use an ack is lower than PT_CANFAIL
* If for some reason you don't want use it
* for any packet type in particular,
* just set to false
* \return The number of free acks
*
*/
INT32 Net_GetFreeAcks(boolean urgent)
{
INT32 i, numfreeslot = 0;
INT32 n = 0; // Number of free acks found
for (i = 0; i < MAXACKPACKETS; i++)
if (!ackpak[i].acknum)
{
// For low priority packets, make sure to let freeslots so urgent packets can be sent
if (!urgent)
{
numfreeslot++;
if (numfreeslot <= URGENTFREESLOTNUM)
continue;
}
n++;
}
return n;
}
// Get a ack to send in the queue of this node
static UINT8 GetAcktosend(INT32 node) static UINT8 GetAcktosend(INT32 node)
{ {
nodes[node].lasttimeacktosend_sent = I_GetTime(); nodes[node].lasttimeacktosend_sent = I_GetTime();
return nodes[node].firstacktosend; return nodes[node].firstacktosend;
} }
static void Removeack(INT32 i) static void RemoveAck(INT32 i)
{ {
INT32 node = ackpak[i].destinationnode; INT32 node = ackpak[i].destinationnode;
#ifndef NEWPING #ifndef NEWPING
@ -290,31 +331,31 @@ static void Removeack(INT32 i)
DEBFILE(va("Remove ack %d\n",ackpak[i].acknum)); DEBFILE(va("Remove ack %d\n",ackpak[i].acknum));
#endif #endif
ackpak[i].acknum = 0; ackpak[i].acknum = 0;
if (nodes[node].flags & CLOSE) if (nodes[node].flags & NF_CLOSE)
Net_CloseConnection(node); Net_CloseConnection(node);
} }
// we have got a packet proceed the ack request and ack return // We have got a packet, proceed the ack request and ack return
static boolean Processackpak(void) static boolean Processackpak(void)
{ {
INT32 i; INT32 i;
boolean goodpacket = true; boolean goodpacket = true;
node_t *node = &nodes[doomcom->remotenode]; node_t *node = &nodes[doomcom->remotenode];
// received an ack return, so remove the ack in the list // Received an ack return, so remove the ack in the list
if (netbuffer->ackreturn && cmpack(node->remotefirstack, netbuffer->ackreturn) < 0) if (netbuffer->ackreturn && cmpack(node->remotefirstack, netbuffer->ackreturn) < 0)
{ {
node->remotefirstack = netbuffer->ackreturn; node->remotefirstack = netbuffer->ackreturn;
// search the ackbuffer and free it // Search the ackbuffer and free it
for (i = 0; i < MAXACKPACKETS; i++) for (i = 0; i < MAXACKPACKETS; i++)
if (ackpak[i].acknum && ackpak[i].destinationnode == node - nodes if (ackpak[i].acknum && ackpak[i].destinationnode == node - nodes
&& cmpack(ackpak[i].acknum, netbuffer->ackreturn) <= 0) && cmpack(ackpak[i].acknum, netbuffer->ackreturn) <= 0)
{ {
Removeack(i); RemoveAck(i);
} }
} }
// received a packet with ack, queue it to send the ack back // Received a packet with ack, queue it to send the ack back
if (netbuffer->ack) if (netbuffer->ack)
{ {
UINT8 ack = netbuffer->ack; UINT8 ack = netbuffer->ack;
@ -323,23 +364,23 @@ static boolean Processackpak(void)
{ {
DEBFILE(va("Discard(1) ack %d (duplicated)\n", ack)); DEBFILE(va("Discard(1) ack %d (duplicated)\n", ack));
duppacket++; duppacket++;
goodpacket = false; // discard packet (duplicate) goodpacket = false; // Discard packet (duplicate)
} }
else else
{ {
// check if it is not already in the queue // Check if it is not already in the queue
for (i = node->acktosend_tail; i != node->acktosend_head; i = (i+1) % MAXACKTOSEND) for (i = node->acktosend_tail; i != node->acktosend_head; i = (i+1) % MAXACKTOSEND)
if (node->acktosend[i] == ack) if (node->acktosend[i] == ack)
{ {
DEBFILE(va("Discard(2) ack %d (duplicated)\n", ack)); DEBFILE(va("Discard(2) ack %d (duplicated)\n", ack));
duppacket++; duppacket++;
goodpacket = false; // discard packet (duplicate) goodpacket = false; // Discard packet (duplicate)
break; break;
} }
if (goodpacket) if (goodpacket)
{ {
// is a good packet so increment the acknowledge number, // Is a good packet so increment the acknowledge number,
// then search for a "hole" in the queue // Then search for a "hole" in the queue
UINT8 nextfirstack = (UINT8)(node->firstacktosend + 1); UINT8 nextfirstack = (UINT8)(node->firstacktosend + 1);
if (!nextfirstack) if (!nextfirstack)
nextfirstack = 1; nextfirstack = 1;
@ -383,10 +424,10 @@ static boolean Processackpak(void)
} }
} }
} }
else // out of order packet else // Out of order packet
{ {
// don't increment firsacktosend, put it in asktosend queue // Don't increment firsacktosend, put it in asktosend queue
// will be incremented when the nextfirstack comes (code above) // Will be incremented when the nextfirstack comes (code above)
UINT8 newhead = (UINT8)((node->acktosend_head+1) % MAXACKTOSEND); UINT8 newhead = (UINT8)((node->acktosend_head+1) % MAXACKTOSEND);
DEBFILE(va("out of order packet (%d expected)\n", nextfirstack)); DEBFILE(va("out of order packet (%d expected)\n", nextfirstack));
if (newhead != node->acktosend_tail) if (newhead != node->acktosend_tail)
@ -394,8 +435,8 @@ static boolean Processackpak(void)
node->acktosend[node->acktosend_head] = ack; node->acktosend[node->acktosend_head] = ack;
node->acktosend_head = newhead; node->acktosend_head = newhead;
} }
else // buffer full discard packet, sender will resend it else // Buffer full discard packet, sender will resend it
{ // we can admit the packet but we will not detect the duplication after :( { // We can admit the packet but we will not detect the duplication after :(
DEBFILE("no more freeackret\n"); DEBFILE("no more freeackret\n");
goodpacket = false; goodpacket = false;
} }
@ -430,25 +471,29 @@ static void GotAcks(void)
if (ackpak[i].acknum && ackpak[i].destinationnode == doomcom->remotenode) if (ackpak[i].acknum && ackpak[i].destinationnode == doomcom->remotenode)
{ {
if (ackpak[i].acknum == netbuffer->u.textcmd[j]) if (ackpak[i].acknum == netbuffer->u.textcmd[j])
Removeack(i); RemoveAck(i);
else // nextacknum is first equal to acknum, then when receiving bigger ack
// nextacknum is first equal to acknum, then when receiving bigger ack // there is big chance the packet is lost
// there is big chance the packet is lost // When resent, nextacknum = nodes[node].nextacknum
// when resent, nextacknum = nodes[node].nextacknum // will redo the same but with different value
// will redo the same but with different value else if (cmpack(ackpak[i].nextacknum, netbuffer->u.textcmd[j]) <= 0
if (cmpack(ackpak[i].nextacknum, netbuffer->u.textcmd[j]) <= 0 && ackpak[i].senttime > 0)
&& ackpak[i].senttime > 0) {
{ ackpak[i].senttime--; // hurry up
ackpak[i].senttime--; // hurry up }
}
} }
} }
#endif #endif
static inline void Net_ConnectionTimeout(INT32 node) void Net_ConnectionTimeout(INT32 node)
{ {
// send a very special packet to self (hack the reboundstore queue) // Don't timeout several times
// main code will handle it if (nodes[node].flags & NF_TIMEOUT)
return;
nodes[node].flags |= NF_TIMEOUT;
// Send a very special packet to self (hack the reboundstore queue)
// Main code will handle it
reboundstore[rebound_head].packettype = PT_NODETIMEOUT; reboundstore[rebound_head].packettype = PT_NODETIMEOUT;
reboundstore[rebound_head].ack = 0; reboundstore[rebound_head].ack = 0;
reboundstore[rebound_head].ackreturn = 0; reboundstore[rebound_head].ackreturn = 0;
@ -456,12 +501,12 @@ static inline void Net_ConnectionTimeout(INT32 node)
reboundsize[rebound_head] = (INT16)(BASEPACKETSIZE + 1); reboundsize[rebound_head] = (INT16)(BASEPACKETSIZE + 1);
rebound_head = (rebound_head+1) % MAXREBOUND; rebound_head = (rebound_head+1) % MAXREBOUND;
// do not redo it quickly (if we do not close connection it is // Do not redo it quickly (if we do not close connection it is
// for a good reason!) // for a good reason!)
nodes[node].lasttimepacketreceived = I_GetTime(); nodes[node].lasttimepacketreceived = I_GetTime();
} }
// resend the data if needed // Resend the data if needed
void Net_AckTicker(void) void Net_AckTicker(void)
{ {
#ifndef NONET #ifndef NONET
@ -477,7 +522,7 @@ void Net_AckTicker(void)
if (ackpak[i].acknum && ackpak[i].senttime + node->timeout < I_GetTime()) if (ackpak[i].acknum && ackpak[i].senttime + node->timeout < I_GetTime())
#endif #endif
{ {
if (ackpak[i].resentnum > 10 && (node->flags & CLOSE)) if (ackpak[i].resentnum > 10 && (node->flags & NF_CLOSE))
{ {
DEBFILE(va("ack %d sent 10 times so connection is supposed lost: node %d\n", DEBFILE(va("ack %d sent 10 times so connection is supposed lost: node %d\n",
i, nodei)); i, nodei));
@ -497,7 +542,7 @@ void Net_AckTicker(void)
ackpak[i].senttime = I_GetTime(); ackpak[i].senttime = I_GetTime();
ackpak[i].resentnum++; ackpak[i].resentnum++;
ackpak[i].nextacknum = node->nextacknum; ackpak[i].nextacknum = node->nextacknum;
retransmit++; // for stat retransmit++; // For stat
HSendPacket((INT32)(node - nodes), false, ackpak[i].acknum, HSendPacket((INT32)(node - nodes), false, ackpak[i].acknum,
(size_t)(ackpak[i].length - BASEPACKETSIZE)); (size_t)(ackpak[i].length - BASEPACKETSIZE));
} }
@ -505,15 +550,15 @@ void Net_AckTicker(void)
for (i = 1; i < MAXNETNODES; i++) for (i = 1; i < MAXNETNODES; i++)
{ {
// this is something like node open flag // This is something like node open flag
if (nodes[i].firstacktosend) if (nodes[i].firstacktosend)
{ {
// we haven't sent a packet for a long time // We haven't sent a packet for a long time
// acknowledge packet if needed // Acknowledge packet if needed
if (nodes[i].lasttimeacktosend_sent + ACKTOSENDTIMEOUT < I_GetTime()) if (nodes[i].lasttimeacktosend_sent + ACKTOSENDTIMEOUT < I_GetTime())
Net_SendAcks(i); Net_SendAcks(i);
if (!(nodes[i].flags & CLOSE) if (!(nodes[i].flags & NF_CLOSE)
&& nodes[i].lasttimepacketreceived + connectiontimeout < I_GetTime()) && nodes[i].lasttimepacketreceived + connectiontimeout < I_GetTime())
{ {
Net_ConnectionTimeout(i); Net_ConnectionTimeout(i);
@ -523,9 +568,9 @@ void Net_AckTicker(void)
#endif #endif
} }
// remove last packet received ack before resending the ackret // Remove last packet received ack before resending the ackreturn
// (the higher layer doesn't have room, or something else ....) // (the higher layer doesn't have room, or something else ....)
void Net_UnAcknowledgPacket(INT32 node) void Net_UnAcknowledgePacket(INT32 node)
{ {
#ifdef NONET #ifdef NONET
(void)node; (void)node;
@ -564,20 +609,29 @@ void Net_UnAcknowledgPacket(INT32 node)
#endif #endif
} }
boolean Net_AllAckReceived(void)
{
#ifndef NONET #ifndef NONET
/** Checks if all acks have been received
*
* \return True if all acks have been received
*
*/
static boolean Net_AllAcksReceived(void)
{
INT32 i; INT32 i;
for (i = 0; i < MAXACKPACKETS; i++) for (i = 0; i < MAXACKPACKETS; i++)
if (ackpak[i].acknum) if (ackpak[i].acknum)
return false; return false;
#endif
return true; return true;
} }
#endif
// wait for all ackreturns with timeout in seconds /** Waits for all ackreturns
*
* \param timeout Timeout in seconds
*
*/
void Net_WaitAllAckReceived(UINT32 timeout) void Net_WaitAllAckReceived(UINT32 timeout)
{ {
#ifdef NONET #ifdef NONET
@ -587,7 +641,7 @@ void Net_WaitAllAckReceived(UINT32 timeout)
timeout = tictac + timeout*NEWTICRATE; timeout = tictac + timeout*NEWTICRATE;
HGetPacket(); HGetPacket();
while (timeout > I_GetTime() && !Net_AllAckReceived()) while (timeout > I_GetTime() && !Net_AllAcksReceived())
{ {
while (tictac == I_GetTime()) while (tictac == I_GetTime())
I_Sleep(); I_Sleep();
@ -598,18 +652,18 @@ void Net_WaitAllAckReceived(UINT32 timeout)
#endif #endif
} }
static void InitNode(INT32 node) static void InitNode(node_t *node)
{ {
nodes[node].acktosend_head = nodes[node].acktosend_tail = 0; node->acktosend_head = node->acktosend_tail = 0;
#ifndef NEWPING #ifndef NEWPING
nodes[node].ping = PINGDEFAULT; node->ping = PINGDEFAULT;
nodes[node].varping = VARPINGDEFAULT; node->varping = VARPINGDEFAULT;
nodes[node].timeout = TIMEOUT(nodes[node].ping,nodes[node].varping); node->timeout = TIMEOUT(node->ping, node->varping);
#endif #endif
nodes[node].firstacktosend = 0; node->firstacktosend = 0;
nodes[node].nextacknum = 1; node->nextacknum = 1;
nodes[node].remotefirstack = 0; node->remotefirstack = 0;
nodes[node].flags = 0; node->flags = 0;
} }
static void InitAck(void) static void InitAck(void)
@ -622,9 +676,14 @@ static void InitAck(void)
#endif #endif
for (i = 0; i < MAXNETNODES; i++) for (i = 0; i < MAXNETNODES; i++)
InitNode(i); InitNode(&nodes[i]);
} }
/** Removes all acks of a given packet type
*
* \param packettype The packet type to forget
*
*/
void Net_AbortPacketType(UINT8 packettype) void Net_AbortPacketType(UINT8 packettype)
{ {
#ifdef NONET #ifdef NONET
@ -657,7 +716,7 @@ void Net_CloseConnection(INT32 node)
if (!node) if (!node)
return; return;
nodes[node].flags |= CLOSE; nodes[node].flags |= NF_CLOSE;
// try to Send ack back (two army problem) // try to Send ack back (two army problem)
if (GetAcktosend(node)) if (GetAcktosend(node))
@ -676,8 +735,8 @@ void Net_CloseConnection(INT32 node)
ackpak[i].acknum = 0; ackpak[i].acknum = 0;
} }
InitNode(node); InitNode(&nodes[node]);
AbortSendFiles(node); SV_AbortSendFiles(node);
I_NetFreeNodenum(node); I_NetFreeNodenum(node);
#endif #endif
} }
@ -729,9 +788,15 @@ static void fprintfstring(char *s, size_t len)
} }
if (mode) if (mode)
fprintf(debugfile, "]"); fprintf(debugfile, "]");
}
static void fprintfstringnewline(char *s, size_t len)
{
fprintfstring(s, len);
fprintf(debugfile, "\n"); fprintf(debugfile, "\n");
} }
/// \warning Keep this up-to-date if you add/remove/rename packet types
static const char *packettypename[NUMPACKETTYPE] = static const char *packettypename[NUMPACKETTYPE] =
{ {
"NOTHING", "NOTHING",
@ -749,15 +814,22 @@ static const char *packettypename[NUMPACKETTYPE] =
"ASKINFO", "ASKINFO",
"SERVERINFO", "SERVERINFO",
"PLAYERINFO",
"REQUESTFILE", "REQUESTFILE",
"ASKINFOVIAMS", "ASKINFOVIAMS",
"PLAYERCONFIGS", "RESYNCHEND",
"RESYNCHGET",
"FILEFRAGMENT", "FILEFRAGMENT",
"TEXTCMD", "TEXTCMD",
"TEXTCMD2", "TEXTCMD2",
"CLIENTJOIN", "CLIENTJOIN",
"NODETIMEOUT", "NODETIMEOUT",
"RESYNCHING",
#ifdef NEWPING
"PING"
#endif
}; };
static void DebugPrintpacket(const char *header) static void DebugPrintpacket(const char *header)
@ -770,20 +842,31 @@ static void DebugPrintpacket(const char *header)
{ {
case PT_ASKINFO: case PT_ASKINFO:
case PT_ASKINFOVIAMS: case PT_ASKINFOVIAMS:
fprintf(debugfile, " time %u\n", (tic_t)LONG(netbuffer->u.askinfo.time) ); fprintf(debugfile, " time %u\n", (tic_t)LONG(netbuffer->u.askinfo.time));
break; break;
case PT_CLIENTJOIN: case PT_CLIENTJOIN:
fprintf(debugfile, " number %d mode %d\n", netbuffer->u.clientcfg.localplayers, fprintf(debugfile, " number %d mode %d\n", netbuffer->u.clientcfg.localplayers,
netbuffer->u.clientcfg.mode); netbuffer->u.clientcfg.mode);
break; break;
case PT_SERVERTICS: case PT_SERVERTICS:
{
servertics_pak *serverpak = &netbuffer->u.serverpak;
UINT8 *cmd = (UINT8 *)(&serverpak->cmds[serverpak->numslots * serverpak->numtics]);
size_t ntxtcmd = &((UINT8 *)netbuffer)[doomcom->datalength] - cmd;
fprintf(debugfile, " firsttic %u ply %d tics %d ntxtcmd %s\n ", fprintf(debugfile, " firsttic %u ply %d tics %d ntxtcmd %s\n ",
(UINT32)ExpandTics(netbuffer->u.serverpak.starttic), netbuffer->u.serverpak.numslots, (UINT32)ExpandTics(serverpak->starttic), serverpak->numslots, serverpak->numtics, sizeu1(ntxtcmd));
netbuffer->u.serverpak.numtics, /// \todo Display more readable information about net commands
sizeu1((size_t)(&((UINT8 *)netbuffer)[doomcom->datalength] - (UINT8 *)&netbuffer->u.serverpak.cmds[netbuffer->u.serverpak.numslots*netbuffer->u.serverpak.numtics]))); fprintfstringnewline((char *)cmd, ntxtcmd);
fprintfstring((char *)&netbuffer->u.serverpak.cmds[netbuffer->u.serverpak.numslots*netbuffer->u.serverpak.numtics],(size_t)( /*fprintfstring((char *)cmd, 3);
&((UINT8 *)netbuffer)[doomcom->datalength] - (UINT8 *)&netbuffer->u.serverpak.cmds[netbuffer->u.serverpak.numslots*netbuffer->u.serverpak.numtics])); if (ntxtcmd > 4)
{
fprintf(debugfile, "[%s]", netxcmdnames[*((cmd) + 3) - 1]);
fprintfstring(((char *)cmd) + 4, ntxtcmd - 4);
}
fprintf(debugfile, "\n");*/
break; break;
}
case PT_CLIENTCMD: case PT_CLIENTCMD:
case PT_CLIENT2CMD: case PT_CLIENT2CMD:
case PT_CLIENTMIS: case PT_CLIENTMIS:
@ -797,7 +880,8 @@ static void DebugPrintpacket(const char *header)
case PT_TEXTCMD: case PT_TEXTCMD:
case PT_TEXTCMD2: case PT_TEXTCMD2:
fprintf(debugfile, " length %d\n ", netbuffer->u.textcmd[0]); fprintf(debugfile, " length %d\n ", netbuffer->u.textcmd[0]);
fprintfstring((char *)netbuffer->u.textcmd+1, netbuffer->u.textcmd[0]); fprintf(debugfile, "[%s]", netxcmdnames[netbuffer->u.textcmd[1] - 1]);
fprintfstringnewline((char *)netbuffer->u.textcmd + 2, netbuffer->u.textcmd[0] - 1);
break; break;
case PT_SERVERCFG: case PT_SERVERCFG:
fprintf(debugfile, " playerslots %d clientnode %d serverplayer %d " fprintf(debugfile, " playerslots %d clientnode %d serverplayer %d "
@ -813,7 +897,7 @@ static void DebugPrintpacket(const char *header)
netbuffer->u.serverinfo.maxplayer, netbuffer->u.serverinfo.mapname, netbuffer->u.serverinfo.maxplayer, netbuffer->u.serverinfo.mapname,
netbuffer->u.serverinfo.fileneedednum, netbuffer->u.serverinfo.fileneedednum,
(UINT32)LONG(netbuffer->u.serverinfo.time)); (UINT32)LONG(netbuffer->u.serverinfo.time));
fprintfstring((char *)netbuffer->u.serverinfo.fileneeded, fprintfstringnewline((char *)netbuffer->u.serverinfo.fileneeded,
(UINT8)((UINT8 *)netbuffer + doomcom->datalength (UINT8)((UINT8 *)netbuffer + doomcom->datalength
- (UINT8 *)netbuffer->u.serverinfo.fileneeded)); - (UINT8 *)netbuffer->u.serverinfo.fileneeded));
break; break;
@ -827,20 +911,100 @@ static void DebugPrintpacket(const char *header)
break; break;
case PT_REQUESTFILE: case PT_REQUESTFILE:
default: // write as a raw packet default: // write as a raw packet
fprintfstring((char *)netbuffer->u.textcmd, fprintfstringnewline((char *)netbuffer->u.textcmd,
(UINT8)((UINT8 *)netbuffer + doomcom->datalength - (UINT8 *)netbuffer->u.textcmd)); (UINT8)((UINT8 *)netbuffer + doomcom->datalength - (UINT8 *)netbuffer->u.textcmd));
break; break;
} }
} }
#endif #endif
#ifdef PACKETDROP
static INT32 packetdropquantity[NUMPACKETTYPE] = {0};
static INT32 packetdroprate = 0;
void Command_Drop(void)
{
INT32 packetquantity;
const char *packetname;
size_t i;
if (COM_Argc() < 2)
{
CONS_Printf("drop <packettype> [quantity]: drop packets\n"
"drop reset: cancel all packet drops\n");
return;
}
if (!(stricmp(COM_Argv(1), "reset") && stricmp(COM_Argv(1), "cancel") && stricmp(COM_Argv(1), "stop")))
{
memset(packetdropquantity, 0, sizeof(packetdropquantity));
return;
}
if (COM_Argc() >= 3)
{
packetquantity = atoi(COM_Argv(2));
if (packetquantity <= 0 && COM_Argv(2)[0] != '0')
{
CONS_Printf("Invalid quantity\n");
return;
}
}
else
packetquantity = -1;
packetname = COM_Argv(1);
if (!(stricmp(packetname, "all") && stricmp(packetname, "any")))
for (i = 0; i < NUMPACKETTYPE; i++)
packetdropquantity[i] = packetquantity;
else
{
for (i = 0; i < NUMPACKETTYPE; i++)
if (!stricmp(packetname, packettypename[i]))
{
packetdropquantity[i] = packetquantity;
return;
}
CONS_Printf("Unknown packet name\n");
}
}
void Command_Droprate(void)
{
INT32 droprate;
if (COM_Argc() < 2)
{
CONS_Printf("Packet drop rate: %d%%\n", packetdroprate);
return;
}
droprate = atoi(COM_Argv(1));
if ((droprate <= 0 && COM_Argv(1)[0] != '0') || droprate > 100)
{
CONS_Printf("Packet drop rate must be between 0 and 100!\n");
return;
}
packetdroprate = droprate;
}
static boolean ShouldDropPacket(void)
{
return (packetdropquantity[netbuffer->packettype])
|| (packetdroprate != 0 && rand() < (RAND_MAX * (packetdroprate / 100.f))) || packetdroprate == 100;
}
#endif
// //
// HSendPacket // HSendPacket
// //
boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlength) boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlength)
{ {
doomcom->datalength = (INT16)(packetlength + BASEPACKETSIZE); doomcom->datalength = (INT16)(packetlength + BASEPACKETSIZE);
if (node == 0) // packet is to go back to us if (node == 0) // Packet is to go back to us
{ {
if ((rebound_head+1) % MAXREBOUND == rebound_tail) if ((rebound_head+1) % MAXREBOUND == rebound_tail)
{ {
@ -871,7 +1035,7 @@ boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlen
(void)reliable; (void)reliable;
(void)acknum; (void)acknum;
#else #else
// do this before GetFreeAcknum because this function backup // do this before GetFreeAcknum because this function backups
// the current packet // the current packet
doomcom->remotenode = (INT16)node; doomcom->remotenode = (INT16)node;
if (doomcom->datalength <= 0) if (doomcom->datalength <= 0)
@ -884,7 +1048,7 @@ boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlen
return false; return false;
} }
if (node < MAXNETNODES) // can be a broadcast if (node < MAXNETNODES) // Can be a broadcast
netbuffer->ackreturn = GetAcktosend(node); netbuffer->ackreturn = GetAcktosend(node);
else else
netbuffer->ackreturn = 0; netbuffer->ackreturn = 0;
@ -905,20 +1069,30 @@ boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlen
netbuffer->ack = acknum; netbuffer->ack = acknum;
netbuffer->checksum = NetbufferChecksum(); netbuffer->checksum = NetbufferChecksum();
sendbytes += packetheaderlength + doomcom->datalength; // for stat sendbytes += packetheaderlength + doomcom->datalength; // For stat
// simulate internet :) #ifdef PACKETDROP
if (true || rand()<(INT32)RAND_MAX/5) // Simulate internet :)
//if (rand() >= (INT32)(RAND_MAX * (PACKETLOSSRATE / 100.f)))
if (!ShouldDropPacket())
{ {
#endif
#ifdef DEBUGFILE #ifdef DEBUGFILE
if (debugfile) if (debugfile)
DebugPrintpacket("SEND"); DebugPrintpacket("SENT");
#endif #endif
I_NetSend(); I_NetSend();
#ifdef PACKETDROP
} }
else
{
if (packetdropquantity[netbuffer->packettype] > 0)
packetdropquantity[netbuffer->packettype]--;
#ifdef DEBUGFILE #ifdef DEBUGFILE
else if (debugfile) if (debugfile)
DebugPrintpacket("NOTSEND"); DebugPrintpacket("NOT SENT");
#endif
}
#endif #endif
#endif // ndef NONET #endif // ndef NONET
@ -933,7 +1107,9 @@ boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlen
// //
boolean HGetPacket(void) boolean HGetPacket(void)
{ {
// get a packet from self //boolean nodejustjoined;
// Get a packet from self
if (rebound_tail != rebound_head) if (rebound_tail != rebound_head)
{ {
M_Memcpy(netbuffer, &reboundstore[rebound_tail], reboundsize[rebound_tail]); M_Memcpy(netbuffer, &reboundstore[rebound_tail], reboundsize[rebound_tail]);
@ -958,16 +1134,17 @@ boolean HGetPacket(void)
while(true) while(true)
{ {
//nodejustjoined = I_NetGet();
I_NetGet(); I_NetGet();
if (doomcom->remotenode == -1) if (doomcom->remotenode == -1) // No packet received
return false; return false;
getbytes += packetheaderlength + doomcom->datalength; // for stat getbytes += packetheaderlength + doomcom->datalength; // For stat
if (doomcom->remotenode >= MAXNETNODES) if (doomcom->remotenode >= MAXNETNODES)
{ {
DEBFILE(va("receive packet from node %d !\n", doomcom->remotenode)); DEBFILE(va("Received packet from node %d!\n", doomcom->remotenode));
continue; continue;
} }
@ -976,6 +1153,7 @@ boolean HGetPacket(void)
if (netbuffer->checksum != NetbufferChecksum()) if (netbuffer->checksum != NetbufferChecksum())
{ {
DEBFILE("Bad packet checksum\n"); DEBFILE("Bad packet checksum\n");
//Net_CloseConnection(nodejustjoined ? (doomcom->remotenode | FORCECLOSE) : doomcom->remotenode);
Net_CloseConnection(doomcom->remotenode); Net_CloseConnection(doomcom->remotenode);
continue; continue;
} }
@ -985,11 +1163,26 @@ boolean HGetPacket(void)
DebugPrintpacket("GET"); DebugPrintpacket("GET");
#endif #endif
// proceed the ack and ackreturn field /*// If a new node sends an unexpected packet, just ignore it
if (nodejustjoined && server
&& !(netbuffer->packettype == PT_ASKINFO
|| netbuffer->packettype == PT_SERVERINFO
|| netbuffer->packettype == PT_PLAYERINFO
|| netbuffer->packettype == PT_REQUESTFILE
|| netbuffer->packettype == PT_ASKINFOVIAMS
|| netbuffer->packettype == PT_CLIENTJOIN))
{
DEBFILE(va("New node sent an unexpected %s packet\n", packettypename[netbuffer->packettype]));
//CONS_Alert(CONS_NOTICE, "New node sent an unexpected %s packet\n", packettypename[netbuffer->packettype]);
Net_CloseConnection(doomcom->remotenode | FORCECLOSE);
continue;
}*/
// Proceed the ack and ackreturn field
if (!Processackpak()) if (!Processackpak())
continue; // discarded (duplicated) continue; // discarded (duplicated)
// a packet with just ackreturn // A packet with just ackreturn
if (netbuffer->packettype == PT_NOTHING) if (netbuffer->packettype == PT_NOTHING)
{ {
GotAcks(); GotAcks();
@ -1002,9 +1195,10 @@ boolean HGetPacket(void)
return true; return true;
} }
static void Internal_Get(void) static boolean Internal_Get(void)
{ {
doomcom->remotenode = -1; doomcom->remotenode = -1;
return false;
} }
FUNCNORETURN static ATTRNORETURN void Internal_Send(void) FUNCNORETURN static ATTRNORETURN void Internal_Send(void)
@ -1089,7 +1283,7 @@ boolean D_CheckNetGame(void)
if (netgame) if (netgame)
ret = true; ret = true;
if (!server && netgame) if (client && netgame)
netgame = false; netgame = false;
server = true; // WTF? server always true??? server = true; // WTF? server always true???
// no! The deault mode is server. Client is set elsewhere // no! The deault mode is server. Client is set elsewhere
@ -1230,4 +1424,6 @@ void D_CloseConnection(void)
netgame = false; netgame = false;
addedtogame = false; addedtogame = false;
} }
D_ResetTiccmds();
} }

View file

@ -18,10 +18,10 @@
#ifndef __D_NET__ #ifndef __D_NET__
#define __D_NET__ #define __D_NET__
// Max computers in a game. // Max computers in a game
#define MAXNETNODES 32 #define MAXNETNODES 32
#define BROADCASTADDR MAXNETNODES #define BROADCASTADDR MAXNETNODES
#define MAXSPLITSCREENPLAYERS 2 // max number of players on a single computer #define MAXSPLITSCREENPLAYERS 2 // Max number of players on a single computer
#define STATLENGTH (TICRATE*2) #define STATLENGTH (TICRATE*2)
@ -32,17 +32,17 @@ extern float lostpercent, duppercent, gamelostpercent;
extern INT32 packetheaderlength; extern INT32 packetheaderlength;
boolean Net_GetNetStat(void); boolean Net_GetNetStat(void);
extern INT32 getbytes; extern INT32 getbytes;
extern INT64 sendbytes; // realtime updated extern INT64 sendbytes; // Realtime updated
extern SINT8 nodetoplayer[MAXNETNODES]; extern SINT8 nodetoplayer[MAXNETNODES];
extern SINT8 nodetoplayer2[MAXNETNODES]; // say the numplayer for this node if any (splitscreen) extern SINT8 nodetoplayer2[MAXNETNODES]; // Say the numplayer for this node if any (splitscreen)
extern UINT8 playerpernode[MAXNETNODES]; // used specialy for scplitscreen extern UINT8 playerpernode[MAXNETNODES]; // Used specially for splitscreen
extern boolean nodeingame[MAXNETNODES]; // set false as nodes leave game extern boolean nodeingame[MAXNETNODES]; // Set false as nodes leave game
INT32 Net_GetFreeAcks(boolean urgent);
void Net_AckTicker(void); void Net_AckTicker(void);
boolean Net_AllAckReceived(void);
// if reliable return true if packet sent, 0 else // If reliable return true if packet sent, 0 else
boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum,
size_t packetlength); size_t packetlength);
boolean HGetPacket(void); boolean HGetPacket(void);
@ -52,9 +52,11 @@ void D_SaveBan(void);
#endif #endif
boolean D_CheckNetGame(void); boolean D_CheckNetGame(void);
void D_CloseConnection(void); void D_CloseConnection(void);
void Net_UnAcknowledgPacket(INT32 node); void Net_UnAcknowledgePacket(INT32 node);
void Net_CloseConnection(INT32 node); void Net_CloseConnection(INT32 node);
void Net_ConnectionTimeout(INT32 node);
void Net_AbortPacketType(UINT8 packettype); void Net_AbortPacketType(UINT8 packettype);
void Net_SendAcks(INT32 node); void Net_SendAcks(INT32 node);
void Net_WaitAllAckReceived(UINT32 timeout); void Net_WaitAllAckReceived(UINT32 timeout);
#endif #endif

View file

@ -83,6 +83,7 @@ static void AutoBalance_OnChange(void);
static void TeamScramble_OnChange(void); static void TeamScramble_OnChange(void);
static void NetTimeout_OnChange(void); static void NetTimeout_OnChange(void);
static void JoinTimeout_OnChange(void);
static void Ringslinger_OnChange(void); static void Ringslinger_OnChange(void);
static void Gravity_OnChange(void); static void Gravity_OnChange(void);
@ -367,7 +368,9 @@ consvar_t cv_killingdead = {"killingdead", "Off", CV_NETVAR, CV_OnOff, NULL, 0,
consvar_t cv_netstat = {"netstat", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // show bandwidth statistics consvar_t cv_netstat = {"netstat", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // show bandwidth statistics
static CV_PossibleValue_t nettimeout_cons_t[] = {{TICRATE/7, "MIN"}, {60*TICRATE, "MAX"}, {0, NULL}}; static CV_PossibleValue_t nettimeout_cons_t[] = {{TICRATE/7, "MIN"}, {60*TICRATE, "MAX"}, {0, NULL}};
consvar_t cv_nettimeout = {"nettimeout", "525", CV_CALL|CV_SAVE, nettimeout_cons_t, NetTimeout_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_nettimeout = {"nettimeout", "350", CV_CALL|CV_SAVE, nettimeout_cons_t, NetTimeout_OnChange, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t jointimeout_cons_t[] = {{5*TICRATE, "MIN"}, {60*TICRATE, "MAX"}, {0, NULL}};
consvar_t cv_jointimeout = {"jointimeout", "350", CV_CALL|CV_SAVE, jointimeout_cons_t, JoinTimeout_OnChange, 0, NULL, NULL, 0, 0, NULL};
#ifdef NEWPING #ifdef NEWPING
consvar_t cv_maxping = {"maxping", "0", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_maxping = {"maxping", "0", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
#endif #endif
@ -392,6 +395,35 @@ boolean splitscreen = false;
boolean circuitmap = true; // SRB2kart boolean circuitmap = true; // SRB2kart
INT32 adminplayer = -1; INT32 adminplayer = -1;
/// \warning Keep this up-to-date if you add/remove/rename net text commands
const char *netxcmdnames[MAXNETXCMD - 1] =
{
"NAMEANDCOLOR",
"WEAPONPREF",
"KICK",
"NETVAR",
"SAY",
"MAP",
"EXITLEVEL",
"ADDFILE",
"PAUSE",
"ADDPLAYER",
"TEAMCHANGE",
"CLEARSCORES",
"LOGIN",
"VERIFIED",
"RANDOMSEED",
"RUNSOC",
"REQADDFILE",
"DELFILE",
"SETMOTD",
"SUICIDE",
#ifdef HAVE_BLUA
"LUACMD",
"LUAVAR"
#endif
};
// ========================================================================= // =========================================================================
// SERVER STARTUP // SERVER STARTUP
// ========================================================================= // =========================================================================
@ -546,9 +578,12 @@ void D_RegisterServerCommands(void)
// d_clisrv // d_clisrv
CV_RegisterVar(&cv_maxplayers); CV_RegisterVar(&cv_maxplayers);
CV_RegisterVar(&cv_maxsend); CV_RegisterVar(&cv_maxsend);
CV_RegisterVar(&cv_noticedownload);
CV_RegisterVar(&cv_downloadspeed);
COM_AddCommand("ping", Command_Ping_f); COM_AddCommand("ping", Command_Ping_f);
CV_RegisterVar(&cv_nettimeout); CV_RegisterVar(&cv_nettimeout);
CV_RegisterVar(&cv_jointimeout);
CV_RegisterVar(&cv_skipmapcheck); CV_RegisterVar(&cv_skipmapcheck);
CV_RegisterVar(&cv_sleep); CV_RegisterVar(&cv_sleep);
@ -1005,7 +1040,7 @@ UINT8 CanChangeSkin(INT32 playernum)
return true; return true;
// Force skin in effect. // Force skin in effect.
if (!server && (cv_forceskin.value != -1) && !(adminplayer == playernum && serverplayer == -1)) if (client && (cv_forceskin.value != -1) && !(adminplayer == playernum && serverplayer == -1))
return false; return false;
// Can change skin in intermission and whatnot. // Can change skin in intermission and whatnot.
@ -1616,7 +1651,7 @@ static void Command_Map_f(void)
return; return;
} }
if (!server && !(adminplayer == consoleplayer)) if (client && !(adminplayer == consoleplayer))
{ {
CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n")); CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n"));
return; return;
@ -1943,7 +1978,7 @@ static void Got_Suicide(UINT8 **cp, INT32 playernum)
// You can't suicide someone else. Nice try, there. // You can't suicide someone else. Nice try, there.
if (suicideplayer != playernum || (!G_PlatformGametype())) if (suicideplayer != playernum || (!G_PlatformGametype()))
{ {
CONS_Alert(CONS_WARNING, M_GetText("Illegal suicide command recieved from %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal suicide command received from %s\n"), player_names[playernum]);
if (server) if (server)
{ {
XBOXSTATIC UINT8 buf[2]; XBOXSTATIC UINT8 buf[2];
@ -2658,7 +2693,7 @@ static void Command_Changepassword_f(void)
// If we have no MD5 support then completely disable XD_LOGIN responses for security. // 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"); CONS_Alert(CONS_NOTICE, "Remote administration commands are not supported in this build.\n");
#else #else
if (!server) // cannot change remotely if (client) // cannot change remotely
{ {
CONS_Printf(M_GetText("Only the server can use this.\n")); CONS_Printf(M_GetText("Only the server can use this.\n"));
return; return;
@ -2717,7 +2752,7 @@ static void Got_Login(UINT8 **cp, INT32 playernum)
READMEM(*cp, sentmd5, 16); READMEM(*cp, sentmd5, 16);
if (!server) if (client)
return; return;
// Do the final pass to compare with the sent md5 // Do the final pass to compare with the sent md5
@ -2739,7 +2774,7 @@ static void Command_Verify_f(void)
char *temp; char *temp;
INT32 playernum; INT32 playernum;
if (!server) if (client)
{ {
CONS_Printf(M_GetText("Only the server can use this.\n")); CONS_Printf(M_GetText("Only the server can use this.\n"));
return; return;
@ -2823,7 +2858,7 @@ static void Command_MotD_f(void)
return; return;
} }
if ((netgame || multiplayer) && !server) if ((netgame || multiplayer) && client)
SendNetXCmd(XD_SETMOTD, mymotd, sizeof(motd)); SendNetXCmd(XD_SETMOTD, mymotd, sizeof(motd));
else else
{ {
@ -3080,7 +3115,7 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum)
READMEM(*cp, md5sum, 16); READMEM(*cp, md5sum, 16);
// Only the server processes this message. // Only the server processes this message.
if (!server) if (client)
return; return;
// Disallow non-printing characters and semicolons. // Disallow non-printing characters and semicolons.
@ -3347,6 +3382,11 @@ static void NetTimeout_OnChange(void)
connectiontimeout = (tic_t)cv_nettimeout.value; connectiontimeout = (tic_t)cv_nettimeout.value;
} }
static void JoinTimeout_OnChange(void)
{
jointimeout = (tic_t)cv_jointimeout.value;
}
UINT32 timelimitintics = 0; UINT32 timelimitintics = 0;
/** Deals with a timelimit change by printing the change to the console. /** Deals with a timelimit change by printing the change to the console.
@ -3989,7 +4029,7 @@ static void Command_Archivetest_f(void)
} }
// assign mobjnum // assign mobjnum
i = 0; i = 1;
for (th = thinkercap.next; th != &thinkercap; th = th->next) for (th = thinkercap.next; th != &thinkercap; th = th->next)
if (th->function.acp1 == (actionf_p1)P_MobjThinker) if (th->function.acp1 == (actionf_p1)P_MobjThinker)
((mobj_t *)th)->mobjnum = i++; ((mobj_t *)th)->mobjnum = i++;
@ -4091,8 +4131,7 @@ static void Skin_OnChange(void)
if (!Playing()) if (!Playing())
return; // do whatever you want return; // do whatever you want
if (!(cv_debug || devparm) && !(multiplayer || netgame) // In single player. if (!(cv_debug || devparm) && !(multiplayer || netgame)) // In single player.
&& (gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_CONTINUING))
{ {
CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin].name); CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin].name);
return; return;

View file

@ -172,6 +172,8 @@ typedef enum
MAXNETXCMD MAXNETXCMD
} netxcmd_t; } netxcmd_t;
extern const char *netxcmdnames[MAXNETXCMD - 1];
#if defined(_MSC_VER) #if defined(_MSC_VER)
#pragma pack(1) #pragma pack(1)
#endif #endif

View file

@ -62,44 +62,48 @@
#include <errno.h> #include <errno.h>
static void SendFile(INT32 node, const char *filename, UINT8 fileid); static void SV_SendFile(INT32 node, const char *filename, UINT8 fileid);
// sender structure // Sender structure
typedef struct filetx_s typedef struct filetx_s
{ {
INT32 ram; INT32 ram;
char *filename; // name of the file or ptr of the data in ram union {
UINT32 size; char *filename; // Name of the file
char *ram; // Pointer to the data in RAM
} id;
UINT32 size; // Size of the file
UINT8 fileid; UINT8 fileid;
INT32 node; // destination INT32 node; // Destination
struct filetx_s *next; // a queue struct filetx_s *next; // Next file in the list
} filetx_t; } filetx_t;
// current transfers (one for each node) // Current transfers (one for each node)
typedef struct filetran_s typedef struct filetran_s
{ {
filetx_t *txlist; filetx_t *txlist; // Linked list of all files for the node
UINT32 position; UINT32 position; // The current position in the file
FILE *currentfile; FILE *currentfile; // The file currently being sent/received
} filetran_t; } filetran_t;
static filetran_t transfer[MAXNETNODES]; static filetran_t transfer[MAXNETNODES];
// read time of file: stat _stmtime // Read time of file: stat _stmtime
// write time of file: utime // Write time of file: utime
// receiver structure // Receiver structure
INT32 fileneedednum; INT32 fileneedednum; // Number of files needed to join the server
fileneeded_t fileneeded[MAX_WADFILES]; fileneeded_t fileneeded[MAX_WADFILES]; // List of needed files
char downloaddir[256] = "DOWNLOAD"; char downloaddir[256] = "DOWNLOAD";
#ifdef CLIENT_LOADINGSCREEN #ifdef CLIENT_LOADINGSCREEN
// for cl loading screen // for cl loading screen
INT32 lastfilenum = 0; INT32 lastfilenum = -1;
#endif #endif
/** Fills a serverinfo packet with information about wad files loaded. /** Fills a serverinfo packet with information about wad files loaded.
* *
* \todo Give this function a better name since it is in global scope. * \todo Give this function a better name since it is in global scope.
*
*/ */
UINT8 *PutFileNeeded(void) UINT8 *PutFileNeeded(void)
{ {
@ -111,19 +115,19 @@ UINT8 *PutFileNeeded(void)
for (i = 0; i < numwadfiles; i++) for (i = 0; i < numwadfiles; i++)
{ {
// if it has only music/sound lumps, mark it as unimportant // If it has only music/sound lumps, mark it as unimportant
if (W_VerifyNMUSlumps(wadfiles[i]->filename)) if (W_VerifyNMUSlumps(wadfiles[i]->filename))
filestatus = 0; filestatus = 0;
else else
filestatus = 1; // important filestatus = 1; // Important
// Store in the upper four bits // Store in the upper four bits
if (!cv_downloading.value) if (!cv_downloading.value)
filestatus += (2 << 4); // won't send filestatus += (2 << 4); // Won't send
else if ((wadfiles[i]->filesize > (UINT32)cv_maxsend.value * 1024)) else if ((wadfiles[i]->filesize > (UINT32)cv_maxsend.value * 1024))
filestatus += (0 << 4); // won't send filestatus += (0 << 4); // Won't send
else else
filestatus += (1 << 4); // will send if requested filestatus += (1 << 4); // Will send if requested
bytesused += (nameonlylength(wadfilename) + 22); bytesused += (nameonlylength(wadfilename) + 22);
@ -144,7 +148,12 @@ UINT8 *PutFileNeeded(void)
return p; return p;
} }
// parse the serverinfo packet and fill fileneeded table on client /** Parses the serverinfo packet and fills the fileneeded table on client
*
* \param fileneedednum_parm The number of files needed to join the server
* \param fileneededstr The memory block containing the list of needed files
*
*/
void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr) void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr)
{ {
INT32 i; INT32 i;
@ -155,14 +164,14 @@ void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr)
p = (UINT8 *)fileneededstr; p = (UINT8 *)fileneededstr;
for (i = 0; i < fileneedednum; i++) for (i = 0; i < fileneedednum; i++)
{ {
fileneeded[i].status = FS_NOTFOUND; fileneeded[i].status = FS_NOTFOUND; // We haven't even started looking for the file yet
filestatus = READUINT8(p); filestatus = READUINT8(p); // The first byte is the file status
fileneeded[i].important = (UINT8)(filestatus & 3); fileneeded[i].important = (UINT8)(filestatus & 3);
fileneeded[i].willsend = (UINT8)(filestatus >> 4); fileneeded[i].willsend = (UINT8)(filestatus >> 4);
fileneeded[i].totalsize = READUINT32(p); fileneeded[i].totalsize = READUINT32(p); // The four next bytes are the file size
fileneeded[i].phandle = NULL; fileneeded[i].file = NULL; // The file isn't open yet
READSTRINGN(p, fileneeded[i].filename, MAX_WADPATH); READSTRINGN(p, fileneeded[i].filename, MAX_WADPATH); // The next bytes are the file name
READMEM(p, fileneeded[i].md5sum, 16); READMEM(p, fileneeded[i].md5sum, 16); // The last 16 bytes are the file checksum
} }
} }
@ -171,13 +180,16 @@ void CL_PrepareDownloadSaveGame(const char *tmpsave)
fileneedednum = 1; fileneedednum = 1;
fileneeded[0].status = FS_REQUESTED; fileneeded[0].status = FS_REQUESTED;
fileneeded[0].totalsize = UINT32_MAX; fileneeded[0].totalsize = UINT32_MAX;
fileneeded[0].phandle = NULL; fileneeded[0].file = NULL;
memset(fileneeded[0].md5sum, 0, 16); memset(fileneeded[0].md5sum, 0, 16);
strcpy(fileneeded[0].filename, tmpsave); strcpy(fileneeded[0].filename, tmpsave);
} }
/** Checks the server to see if we CAN download all the files, /** Checks the server to see if we CAN download all the files,
* before starting to create them and requesting. * before starting to create them and requesting.
*
* \return True if we can download all the files
*
*/ */
boolean CL_CheckDownloadable(void) boolean CL_CheckDownloadable(void)
{ {
@ -239,8 +251,12 @@ boolean CL_CheckDownloadable(void)
return false; return false;
} }
/** Send requests for files in the ::fileneeded table with a status of /** Sends requests for files in the ::fileneeded table with a status of
* ::FS_NOTFOUND. * ::FS_NOTFOUND.
*
* \return True if the packet was successfully sent
* \note Sends a PT_REQUESTFILE packet
*
*/ */
boolean CL_SendRequestFile(void) boolean CL_SendRequestFile(void)
{ {
@ -298,11 +314,17 @@ void Got_RequestFilePak(INT32 node)
if (id == 0xFF) if (id == 0xFF)
break; break;
READSTRINGN(p, wad, MAX_WADPATH); READSTRINGN(p, wad, MAX_WADPATH);
SendFile(node, wad, id); SV_SendFile(node, wad, id);
} }
} }
// client check if the fileneeded aren't already loaded or on the disk /** Checks if the files needed aren't already loaded or on the disk
*
* \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
*
*/
INT32 CL_CheckFiles(void) INT32 CL_CheckFiles(void)
{ {
INT32 i, j; INT32 i, j;
@ -333,7 +355,7 @@ INT32 CL_CheckFiles(void)
} }
if (j < numwadfiles && W_VerifyNMUSlumps(wadfiles[j]->filename)) if (j < numwadfiles && W_VerifyNMUSlumps(wadfiles[j]->filename))
{ {
// unimportant on our side. still don't care. // Unimportant on our side. still don't care.
++j; ++j;
continue; continue;
} }
@ -343,11 +365,11 @@ INT32 CL_CheckFiles(void)
if (i >= fileneedednum || j >= numwadfiles) if (i >= fileneedednum || j >= numwadfiles)
return 2; return 2;
// for the sake of speed, only bother with a md5 check // For the sake of speed, only bother with a md5 check
if (memcmp(wadfiles[j]->md5sum, fileneeded[i].md5sum, 16)) if (memcmp(wadfiles[j]->md5sum, fileneeded[i].md5sum, 16))
return 2; return 2;
// it's accounted for! let's keep going. // It's accounted for! let's keep going.
CONS_Debug(DBG_NETPLAY, "'%s' accounted for\n", fileneeded[i].filename); CONS_Debug(DBG_NETPLAY, "'%s' accounted for\n", fileneeded[i].filename);
fileneeded[i].status = FS_OPEN; fileneeded[i].status = FS_OPEN;
++i; ++i;
@ -360,7 +382,7 @@ INT32 CL_CheckFiles(void)
{ {
CONS_Debug(DBG_NETPLAY, "searching for '%s' ", fileneeded[i].filename); CONS_Debug(DBG_NETPLAY, "searching for '%s' ", fileneeded[i].filename);
// check in allready loaded files // Check in already loaded files
for (j = 1; wadfiles[j]; j++) for (j = 1; wadfiles[j]; j++)
{ {
nameonly(strcpy(wadfilename, wadfiles[j]->filename)); nameonly(strcpy(wadfilename, wadfiles[j]->filename));
@ -383,7 +405,7 @@ INT32 CL_CheckFiles(void)
return ret; return ret;
} }
// load it now // Load it now
void CL_LoadServerFiles(void) void CL_LoadServerFiles(void)
{ {
INT32 i; INT32 i;
@ -394,7 +416,7 @@ void CL_LoadServerFiles(void)
for (i = 1; i < fileneedednum; i++) for (i = 1; i < fileneedednum; i++)
{ {
if (fileneeded[i].status == FS_OPEN) if (fileneeded[i].status == FS_OPEN)
continue; // already loaded continue; // Already loaded
else if (fileneeded[i].status == FS_FOUND) else if (fileneeded[i].status == FS_FOUND)
{ {
P_AddWadFile(fileneeded[i].filename, NULL); P_AddWadFile(fileneeded[i].filename, NULL);
@ -423,172 +445,269 @@ void CL_LoadServerFiles(void)
DEBFILE(va("File %s found but with different md5sum\n", fileneeded[i].filename)); DEBFILE(va("File %s found but with different md5sum\n", fileneeded[i].filename));
} }
else if (fileneeded[i].important) else if (fileneeded[i].important)
I_Error("Try to load file %s with status of %d\n", fileneeded[i].filename, {
fileneeded[i].status); const char *s;
switch(fileneeded[i].status)
{
case FS_NOTFOUND:
s = "FS_NOTFOUND";
break;
case FS_REQUESTED:
s = "FS_REQUESTED";
break;
case FS_DOWNLOADING:
s = "FS_DOWNLOADING";
break;
default:
s = "unknown";
break;
}
I_Error("Try to load file \"%s\" with status of %d (%s)\n", fileneeded[i].filename,
fileneeded[i].status, s);
}
} }
} }
// little optimization to test if there is a file in the queue // Number of files to send
static INT32 filetosend = 0; // Little optimization to quickly test if there is a file in the queue
static INT32 filestosend = 0;
static void SendFile(INT32 node, const char *filename, UINT8 fileid) /** Adds a file to the file list for a node
*
* \param node The node to send the file to
* \param filename The file to send
* \param fileid ???
* \sa SV_SendRam
*
*/
static void SV_SendFile(INT32 node, const char *filename, UINT8 fileid)
{ {
filetx_t **q; filetx_t **q; // A pointer to the "next" field of the last file in the list
filetx_t *p; filetx_t *p; // The new file request
INT32 i; INT32 i;
char wadfilename[MAX_WADPATH]; char wadfilename[MAX_WADPATH];
if (cv_noticedownload.value)
CONS_Printf("Sending file \"%s\" to node %d\n", filename, node);
// Find the last file in the list and set a pointer to its "next" field
q = &transfer[node].txlist; q = &transfer[node].txlist;
while (*q) while (*q)
q = &((*q)->next); q = &((*q)->next);
// Allocate a file request and append it to the file list
p = *q = (filetx_t *)malloc(sizeof (filetx_t)); p = *q = (filetx_t *)malloc(sizeof (filetx_t));
if (p) if (!p)
memset(p, 0, sizeof (filetx_t)); I_Error("SV_SendFile: No more memory\n");
else
I_Error("SendFile: No more ram\n");
p->filename = (char *)malloc(MAX_WADPATH);
if (!p->filename)
I_Error("SendFile: No more ram\n");
// a minimum of security, can get only file in srb2 direcory // Initialise with zeros
strlcpy(p->filename, filename, MAX_WADPATH); memset(p, 0, sizeof (filetx_t));
nameonly(p->filename);
// check first in wads loaded the majority of case // Allocate the file name
p->id.filename = (char *)malloc(MAX_WADPATH);
if (!p->id.filename)
I_Error("SV_SendFile: No more memory\n");
// Set the file name and get rid of the path
strlcpy(p->id.filename, filename, MAX_WADPATH);
nameonly(p->id.filename);
// Look for the requested file through all loaded files
for (i = 0; wadfiles[i]; i++) for (i = 0; wadfiles[i]; i++)
{ {
strlcpy(wadfilename, wadfiles[i]->filename, MAX_WADPATH); strlcpy(wadfilename, wadfiles[i]->filename, MAX_WADPATH);
nameonly(wadfilename); nameonly(wadfilename);
if (!stricmp(wadfilename, p->filename)) if (!stricmp(wadfilename, p->id.filename))
{ {
// copy filename with full path // Copy file name with full path
strlcpy(p->filename, wadfiles[i]->filename, MAX_WADPATH); strlcpy(p->id.filename, wadfiles[i]->filename, MAX_WADPATH);
break; break;
} }
} }
// Handle non-loaded file requests
if (!wadfiles[i]) if (!wadfiles[i])
{ {
DEBFILE(va("%s not found in wadfiles\n", filename)); DEBFILE(va("%s not found in wadfiles\n", filename));
// this formerly checked if (!findfile(p->filename, NULL, true)) // This formerly checked if (!findfile(p->id.filename, NULL, true))
// not found // Not found
// don't inform client (probably hacker) // Don't inform client (probably someone who thought they could leak 2.2 ACZ)
DEBFILE(va("Client %d request %s: not found\n", node, filename)); DEBFILE(va("Client %d request %s: not found\n", node, filename));
free(p->filename); free(p->id.filename);
free(p); free(p);
*q = NULL; *q = NULL;
return; return;
} }
// Handle huge file requests (i.e. bigger than cv_maxsend.value KB)
if (wadfiles[i]->filesize > (UINT32)cv_maxsend.value * 1024) if (wadfiles[i]->filesize > (UINT32)cv_maxsend.value * 1024)
{ {
// too big // Too big
// don't inform client (client sucks, man) // Don't inform client (client sucks, man)
DEBFILE(va("Client %d request %s: file too big, not sending\n", node, filename)); DEBFILE(va("Client %d request %s: file too big, not sending\n", node, filename));
free(p->filename); free(p->id.filename);
free(p); free(p);
*q = NULL; *q = NULL;
return; return;
} }
DEBFILE(va("Sending file %s (id=%d) to %d\n", filename, fileid, node)); DEBFILE(va("Sending file %s (id=%d) to %d\n", filename, fileid, node));
p->ram = SF_FILE; p->ram = SF_FILE; // It's a file, we need to close it and free its name once we're done sending it
p->fileid = fileid; p->fileid = fileid;
p->next = NULL; // end of list p->next = NULL; // End of list
filetosend++; filestosend++;
} }
void SendRam(INT32 node, void *data, size_t size, freemethod_t freemethod, UINT8 fileid) /** Adds a memory block to the file list for a node
*
* \param node The node to send the memory block to
* \param data The memory block to send
* \param size The size of the block in bytes
* \param freemethod How to free the block after it has been sent
* \param fileid ???
* \sa SV_SendFile
*
*/
void SV_SendRam(INT32 node, void *data, size_t size, freemethod_t freemethod, UINT8 fileid)
{ {
filetx_t **q; filetx_t **q; // A pointer to the "next" field of the last file in the list
filetx_t *p; filetx_t *p; // The new file request
// Find the last file in the list and set a pointer to its "next" field
q = &transfer[node].txlist; q = &transfer[node].txlist;
while (*q) while (*q)
q = &((*q)->next); q = &((*q)->next);
// Allocate a file request and append it to the file list
p = *q = (filetx_t *)malloc(sizeof (filetx_t)); p = *q = (filetx_t *)malloc(sizeof (filetx_t));
if (p) if (!p)
memset(p, 0, sizeof (filetx_t)); I_Error("SV_SendRam: No more memory\n");
else
I_Error("SendRam: No more ram\n"); // Initialise with zeros
p->ram = freemethod; memset(p, 0, sizeof (filetx_t));
p->filename = data;
p->ram = freemethod; // Remember how to free the memory block for when we're done sending it
p->id.ram = data;
p->size = (UINT32)size; p->size = (UINT32)size;
p->fileid = fileid; p->fileid = fileid;
p->next = NULL; // end of list p->next = NULL; // End of list
DEBFILE(va("Sending ram %p(size:%u) to %d (id=%u)\n",p->filename,p->size,node,fileid)); DEBFILE(va("Sending ram %p(size:%u) to %d (id=%u)\n",p->id.ram,p->size,node,fileid));
filetosend++; filestosend++;
} }
static void EndSend(INT32 node) /** Stops sending a file for a node, and removes the file request from the list,
* either because the file has been fully sent or because the node was disconnected
*
* \param node The destination
*
*/
static void SV_EndFileSend(INT32 node)
{ {
filetx_t *p = transfer[node].txlist; filetx_t *p = transfer[node].txlist;
// Free the file request according to the freemethod parameter used with SV_SendFile/Ram
switch (p->ram) switch (p->ram)
{ {
case SF_FILE: case SF_FILE: // It's a file, close it and free its filename
if (cv_noticedownload.value)
CONS_Printf("Ending file transfer for node %d\n", node);
if (transfer[node].currentfile) if (transfer[node].currentfile)
fclose(transfer[node].currentfile); fclose(transfer[node].currentfile);
free(p->filename); free(p->id.filename);
break; break;
case SF_Z_RAM: case SF_Z_RAM: // It's a memory block allocated with Z_Alloc or the likes, use Z_Free
Z_Free(p->filename); Z_Free(p->id.ram);
break; break;
case SF_RAM: case SF_RAM: // It's a memory block allocated with malloc, use free
free(p->filename); free(p->id.ram);
case SF_NOFREERAM: case SF_NOFREERAM: // Nothing to free
break; break;
} }
// Remove the file request from the list
transfer[node].txlist = p->next; transfer[node].txlist = p->next;
transfer[node].currentfile = NULL;
free(p); free(p);
filetosend--;
// Indicate that the transmission is over
transfer[node].currentfile = NULL;
filestosend--;
} }
#define PACKETPERTIC net_bandwidth/(TICRATE*software_MAXPACKETLENGTH) #define PACKETPERTIC net_bandwidth/(TICRATE*software_MAXPACKETLENGTH)
void FiletxTicker(void) /** Handles file transmission
*
* \todo Use an acknowledging method more adapted to file transmission
* The current download speed suffers from lack of ack packets,
* especially when the one downloading has high latency
*
*/
void SV_FileSendTicker(void)
{ {
static INT32 currentnode = 0; static INT32 currentnode = 0;
filetx_pak *p; filetx_pak *p;
size_t size; size_t size;
filetx_t *f; filetx_t *f;
INT32 packetsent = PACKETPERTIC, ram, i; INT32 packetsent, ram, i, j;
INT32 maxpacketsent;
if (!filetosend) if (!filestosend) // No file to send
return; return;
if (!packetsent)
packetsent++; if (cv_downloadspeed.value) // New (and experimental) behavior
// (((sendbytes-nowsentbyte)*TICRATE)/(I_GetTime()-starttime)<(UINT32)net_bandwidth)
while (packetsent-- && filetosend != 0)
{ {
for (i = currentnode, ram = 0; ram < MAXNETNODES; packetsent = cv_downloadspeed.value;
i = (i+1) % MAXNETNODES, ram++) // Don't send more packets than we have free acks
#ifndef NONET
maxpacketsent = Net_GetFreeAcks(false) - 5; // Let 5 extra acks just in case
#else
maxpacketsent = 1;
#endif
if (packetsent > maxpacketsent && maxpacketsent > 0) // Send at least one packet
packetsent = maxpacketsent;
}
else // Old behavior
{
packetsent = PACKETPERTIC;
if (!packetsent)
packetsent = 1;
}
netbuffer->packettype = PT_FILEFRAGMENT;
// (((sendbytes-nowsentbyte)*TICRATE)/(I_GetTime()-starttime)<(UINT32)net_bandwidth)
while (packetsent-- && filestosend != 0)
{
for (i = currentnode, j = 0; j < MAXNETNODES;
i = (i+1) % MAXNETNODES, j++)
{ {
if (transfer[i].txlist) if (transfer[i].txlist)
goto found; goto found;
} }
// no transfer to do // no transfer to do
I_Error("filetosend=%d but no filetosend found\n", filetosend); I_Error("filestosend=%d but no file to send found\n", filestosend);
found: found:
currentnode = (i+1) % MAXNETNODES; currentnode = (i+1) % MAXNETNODES;
f = transfer[i].txlist; f = transfer[i].txlist;
ram = f->ram; ram = f->ram;
if (!transfer[i].currentfile) // file not already open // Open the file if it isn't open yet, or
if (!transfer[i].currentfile)
{ {
if (!ram) if (!ram) // Sending a file
{ {
long filesize; long filesize;
transfer[i].currentfile = transfer[i].currentfile =
fopen(f->filename, "rb"); fopen(f->id.filename, "rb");
if (!transfer[i].currentfile) if (!transfer[i].currentfile)
I_Error("File %s does not exist", I_Error("File %s does not exist",
f->filename); f->id.filename);
fseek(transfer[i].currentfile, 0, SEEK_END); fseek(transfer[i].currentfile, 0, SEEK_END);
filesize = ftell(transfer[i].currentfile); filesize = ftell(transfer[i].currentfile);
@ -596,45 +715,47 @@ void FiletxTicker(void)
// Nobody wants to transfer a file bigger // Nobody wants to transfer a file bigger
// than 4GB! // than 4GB!
if (filesize >= LONG_MAX) if (filesize >= LONG_MAX)
I_Error("filesize of %s is too large", f->filename); I_Error("filesize of %s is too large", f->id.filename);
if (-1 == filesize) if (filesize == -1)
I_Error("Error getting filesize of %s", f->filename); I_Error("Error getting filesize of %s", f->id.filename);
f->size = (UINT32)filesize; f->size = (UINT32)filesize;
fseek(transfer[i].currentfile, 0, SEEK_SET); fseek(transfer[i].currentfile, 0, SEEK_SET);
} }
else else // Sending RAM
transfer[i].currentfile = (FILE *)1; transfer[i].currentfile = (FILE *)1; // Set currentfile to a non-null value to indicate that it is open
transfer[i].position = 0; transfer[i].position = 0;
} }
// Build a packet containing a file fragment
p = &netbuffer->u.filetxpak; p = &netbuffer->u.filetxpak;
size = software_MAXPACKETLENGTH - (FILETXHEADER + BASEPACKETSIZE); size = software_MAXPACKETLENGTH - (FILETXHEADER + BASEPACKETSIZE);
if (f->size-transfer[i].position < size) if (f->size-transfer[i].position < size)
size = f->size-transfer[i].position; size = f->size-transfer[i].position;
if (ram) if (ram)
M_Memcpy(p->data, &f->filename[transfer[i].position], size); M_Memcpy(p->data, &f->id.ram[transfer[i].position], size);
else if (fread(p->data, 1, size, transfer[i].currentfile) != size) else if (fread(p->data, 1, size, transfer[i].currentfile) != size)
I_Error("FiletxTicker: can't read %s byte on %s at %d because %s", sizeu1(size), f->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, strerror(ferror(transfer[i].currentfile)));
p->position = LONG(transfer[i].position); p->position = LONG(transfer[i].position);
// put flag so receiver know the totalsize // Put flag so receiver knows the total size
if (transfer[i].position + size == f->size) if (transfer[i].position + size == f->size)
p->position |= LONG(0x80000000); p->position |= LONG(0x80000000);
p->fileid = f->fileid; p->fileid = f->fileid;
p->size = SHORT((UINT16)size); p->size = SHORT((UINT16)size);
netbuffer->packettype = PT_FILEFRAGMENT;
if (!HSendPacket(i, true, 0, FILETXHEADER + size)) // reliable SEND // Send the packet
{ // not sent for some odd reason, retry at next call if (HSendPacket(i, true, 0, FILETXHEADER + size)) // Reliable SEND
if (!ram) { // Success
fseek(transfer[i].currentfile,transfer[i].position,SEEK_SET); transfer[i].position = (UINT32)(transfer[i].position + size);
// exit the while (can't send this one so why should i send the next?) if (transfer[i].position == f->size) // Finish?
break; SV_EndFileSend(i);
} }
else // success else
{ { // Not sent for some odd reason, retry at next call
transfer[i].position = (UINT32)(size+transfer[i].position); if (!ram)
if (transfer[i].position == f->size) // finish ? fseek(transfer[i].currentfile,transfer[i].position, SEEK_SET);
EndSend(i); // Exit the while (can't send this one so why should i send the next?)
break;
} }
} }
} }
@ -642,55 +763,90 @@ void FiletxTicker(void)
void Got_Filetxpak(void) void Got_Filetxpak(void)
{ {
INT32 filenum = netbuffer->u.filetxpak.fileid; INT32 filenum = netbuffer->u.filetxpak.fileid;
fileneeded_t *file = &fileneeded[filenum];
char *filename = file->filename;
static INT32 filetime = 0; static INT32 filetime = 0;
if (!(strcmp(filename, "srb2.srb")
&& strcmp(filename, "srb2.wad")
&& strcmp(filename, "zones.dta")
&& strcmp(filename, "player.dta")
&& strcmp(filename, "rings.dta")
&& strcmp(filename, "patch.dta")
&& strcmp(filename, "music.dta")
))
I_Error("Tried to download \"%s\"", filename);
if (filenum >= fileneedednum) if (filenum >= fileneedednum)
{ {
DEBFILE(va("fileframent not needed %d>%d\n",filenum, fileneedednum)); DEBFILE(va("fileframent not needed %d>%d\n", filenum, fileneedednum));
//I_Error("Received an unneeded file fragment (file id received: %d, file id needed: %d)\n", filenum, fileneedednum);
return; return;
} }
if (fileneeded[filenum].status == FS_REQUESTED) if (file->status == FS_REQUESTED)
{ {
if (fileneeded[filenum].phandle) I_Error("Got_Filetxpak: allready open file\n"); if (file->file)
fileneeded[filenum].phandle = fopen(fileneeded[filenum].filename, "wb"); I_Error("Got_Filetxpak: already open file\n");
if (!fileneeded[filenum].phandle) I_Error("Can't create file %s: %s",fileneeded[filenum].filename, strerror(errno)); file->file = fopen(filename, "wb");
CONS_Printf("\r%s...\n",fileneeded[filenum].filename); if (!file->file)
fileneeded[filenum].currentsize = 0; I_Error("Can't create file %s: %s", filename, strerror(errno));
fileneeded[filenum].status = FS_DOWNLOADING; CONS_Printf("\r%s...\n",filename);
file->currentsize = 0;
file->status = FS_DOWNLOADING;
} }
if (fileneeded[filenum].status == FS_DOWNLOADING) if (file->status == FS_DOWNLOADING)
{ {
UINT32 pos = LONG(netbuffer->u.filetxpak.position); UINT32 pos = LONG(netbuffer->u.filetxpak.position);
UINT16 size = SHORT(netbuffer->u.filetxpak.size); UINT16 size = SHORT(netbuffer->u.filetxpak.size);
// use a special tric to know when file is finished (not allways used) // Use a special trick to know when the file is complete (not always used)
// WARNING: filepak can arrive out of order so don't stop now ! // WARNING: file fragments can arrive out of order so don't stop yet!
if (pos & 0x80000000) if (pos & 0x80000000)
{ {
pos &= ~0x80000000; pos &= ~0x80000000;
fileneeded[filenum].totalsize = pos + size; file->totalsize = pos + size;
} }
// we can receive packet in the wrong order, anyway all os support gaped file // We can receive packet in the wrong order, anyway all os support gaped file
fseek(fileneeded[filenum].phandle,pos,SEEK_SET); fseek(file->file, pos, SEEK_SET);
if (fwrite(netbuffer->u.filetxpak.data,size,1,fileneeded[filenum].phandle)!=1) if (fwrite(netbuffer->u.filetxpak.data,size,1,file->file) != 1)
I_Error("Can't write to %s: %s\n",fileneeded[filenum].filename, strerror(ferror(fileneeded[filenum].phandle))); I_Error("Can't write to %s: %s\n",filename, strerror(ferror(file->file)));
fileneeded[filenum].currentsize += size; file->currentsize += size;
// finished? // Finished?
if (fileneeded[filenum].currentsize == fileneeded[filenum].totalsize) if (file->currentsize == file->totalsize)
{ {
fclose(fileneeded[filenum].phandle); fclose(file->file);
fileneeded[filenum].phandle = NULL; file->file = NULL;
fileneeded[filenum].status = FS_FOUND; file->status = FS_FOUND;
CONS_Printf(M_GetText("Downloading %s...(done)\n"), CONS_Printf(M_GetText("Downloading %s...(done)\n"),
fileneeded[filenum].filename); filename);
} }
} }
else else
I_Error("Received a file not requested\n"); {
// send ack back quickly const char *s;
switch(file->status)
{
case FS_NOTFOUND:
s = "FS_NOTFOUND";
break;
case FS_FOUND:
s = "FS_FOUND";
break;
case FS_OPEN:
s = "FS_OPEN";
break;
case FS_MD5SUMBAD:
s = "FS_MD5SUMBAD";
break;
default:
s = "unknown";
break;
}
I_Error("Received a file not requested (file id: %d, file status: %s)\n", filenum, s);
}
// Send ack back quickly
if (++filetime == 3) if (++filetime == 3)
{ {
Net_SendAcks(servernode); Net_SendAcks(servernode);
@ -702,33 +858,50 @@ void Got_Filetxpak(void)
#endif #endif
} }
void AbortSendFiles(INT32 node) /** \brief Checks if a node is downloading a file
*
* \param node The node to check for
* \return True if the node is downloading a file
*
*/
boolean SV_SendingFile(INT32 node)
{
return transfer[node].txlist != NULL;
}
/** Cancels all file requests for a node
*
* \param node The destination
* \sa SV_EndFileSend
*
*/
void SV_AbortSendFiles(INT32 node)
{ {
while (transfer[node].txlist) while (transfer[node].txlist)
EndSend(node); SV_EndFileSend(node);
} }
void CloseNetFile(void) void CloseNetFile(void)
{ {
INT32 i; INT32 i;
// is sending? // Is sending?
for (i = 0; i < MAXNETNODES; i++) for (i = 0; i < MAXNETNODES; i++)
AbortSendFiles(i); SV_AbortSendFiles(i);
// receiving a file? // Receiving a file?
for (i = 0; i < MAX_WADFILES; i++) for (i = 0; i < MAX_WADFILES; i++)
if (fileneeded[i].status == FS_DOWNLOADING && fileneeded[i].phandle) if (fileneeded[i].status == FS_DOWNLOADING && fileneeded[i].file)
{ {
fclose(fileneeded[i].phandle); fclose(fileneeded[i].file);
// file is not complete delete it // File is not complete delete it
remove(fileneeded[i].filename); remove(fileneeded[i].filename);
} }
// remove FILEFRAGMENT from acknledge list // Remove PT_FILEFRAGMENT from acknowledge list
Net_AbortPacketType(PT_FILEFRAGMENT); Net_AbortPacketType(PT_FILEFRAGMENT);
} }
// functions cut and pasted from doomatic :) // Functions cut and pasted from Doomatic :)
void nameonly(char *s) void nameonly(char *s)
{ {

View file

@ -29,21 +29,21 @@ typedef enum
FS_FOUND, FS_FOUND,
FS_REQUESTED, FS_REQUESTED,
FS_DOWNLOADING, FS_DOWNLOADING,
FS_OPEN, // is opened and used in w_wad FS_OPEN, // Is opened and used in w_wad
FS_MD5SUMBAD FS_MD5SUMBAD
} filestatus_t; } filestatus_t;
typedef struct typedef struct
{ {
UINT8 important; UINT8 important;
UINT8 willsend; // is the server willing to send it? UINT8 willsend; // Is the server willing to send it?
char filename[MAX_WADPATH]; char filename[MAX_WADPATH];
UINT8 md5sum[16]; UINT8 md5sum[16];
// used only for download // Used only for download
FILE *phandle; FILE *file;
UINT32 currentsize; UINT32 currentsize;
UINT32 totalsize; UINT32 totalsize;
filestatus_t status; // the value returned by recsearch filestatus_t status; // The value returned by recsearch
} fileneeded_t; } fileneeded_t;
extern INT32 fileneedednum; extern INT32 fileneedednum;
@ -58,28 +58,25 @@ UINT8 *PutFileNeeded(void);
void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr); void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr);
void CL_PrepareDownloadSaveGame(const char *tmpsave); void CL_PrepareDownloadSaveGame(const char *tmpsave);
// check file list in wadfiles return 0 when a file is not found
// 1 if all file are found
// 2 if you cannot connect (different wad version or
// no enought space to download files)
INT32 CL_CheckFiles(void); INT32 CL_CheckFiles(void);
void CL_LoadServerFiles(void); void CL_LoadServerFiles(void);
void SendRam(INT32 node, void *data, size_t size, freemethod_t freemethod, void SV_SendRam(INT32 node, void *data, size_t size, freemethod_t freemethod,
UINT8 fileid); UINT8 fileid);
void FiletxTicker(void); void SV_FileSendTicker(void);
void Got_Filetxpak(void); void Got_Filetxpak(void);
boolean SV_SendingFile(INT32 node);
boolean CL_CheckDownloadable(void); boolean CL_CheckDownloadable(void);
boolean CL_SendRequestFile(void); boolean CL_SendRequestFile(void);
void Got_RequestFilePak(INT32 node); void Got_RequestFilePak(INT32 node);
void AbortSendFiles(INT32 node); void SV_AbortSendFiles(INT32 node);
void CloseNetFile(void); void CloseNetFile(void);
boolean fileexist(char *filename, time_t ptime); boolean fileexist(char *filename, time_t ptime);
// search a file in the wadpath, return FS_FOUND when found // Search a file in the wadpath, return FS_FOUND when found
filestatus_t findfile(char *filename, const UINT8 *wantedmd5sum, filestatus_t findfile(char *filename, const UINT8 *wantedmd5sum,
boolean completepath); boolean completepath);
filestatus_t checkfilemd5(char *filename, const UINT8 *wantedmd5sum); filestatus_t checkfilemd5(char *filename, const UINT8 *wantedmd5sum);

View file

@ -6754,12 +6754,14 @@ static const char *const MOBJEFLAG_LIST[] = {
NULL NULL
}; };
#ifdef HAVE_BLUA
static const char *const MAPTHINGFLAG_LIST[4] = { static const char *const MAPTHINGFLAG_LIST[4] = {
NULL, NULL,
"OBJECTFLIP", // Reverse gravity flag for objects. "OBJECTFLIP", // Reverse gravity flag for objects.
"OBJECTSPECIAL", // Special flag used with certain objects. "OBJECTSPECIAL", // Special flag used with certain objects.
"AMBUSH" // Deaf monsters/do not react to sound. "AMBUSH" // Deaf monsters/do not react to sound.
}; };
#endif
static const char *const PLAYERFLAG_LIST[] = { static const char *const PLAYERFLAG_LIST[] = {
// Flip camera angle with gravity flip prefrence. // Flip camera angle with gravity flip prefrence.
@ -6832,6 +6834,7 @@ static const char *const PLAYERFLAG_LIST[] = {
NULL // stop loop here. NULL // stop loop here.
}; };
#ifdef HAVE_BLUA
// Linedef flags // Linedef flags
static const char *const ML_LIST[16] = { static const char *const ML_LIST[16] = {
"IMPASSIBLE", "IMPASSIBLE",
@ -6851,6 +6854,7 @@ static const char *const ML_LIST[16] = {
"BOUNCY", "BOUNCY",
"TFERLINE" "TFERLINE"
}; };
#endif
// This DOES differ from r_draw's Color_Names, unfortunately. // This DOES differ from r_draw's Color_Names, unfortunately.
// Also includes Super colors // Also includes Super colors
@ -7838,7 +7842,7 @@ fixed_t get_number(const char *word)
#endif #endif
} }
void DEH_Check(void) void FUNCMATH DEH_Check(void)
{ {
#if defined(_DEBUG) || defined(PARANOIA) #if defined(_DEBUG) || defined(PARANOIA)
const size_t dehstates = sizeof(STATE_LIST)/sizeof(const char*); const size_t dehstates = sizeof(STATE_LIST)/sizeof(const char*);
@ -8352,6 +8356,9 @@ static inline int lib_getenum(lua_State *L)
} else if (fastcmp(word,"VERSIONSTRING")) { } else if (fastcmp(word,"VERSIONSTRING")) {
lua_pushstring(L, VERSIONSTRING); lua_pushstring(L, VERSIONSTRING);
return 1; return 1;
} else if (fastcmp(word, "token")) {
lua_pushinteger(L, token);
return 1;
} }
return 0; return 0;

View file

@ -1721,6 +1721,18 @@ INT32 I_PutEnv(char *variable)
return putenv(variable); return putenv(variable);
} }
INT32 I_ClipboardCopy(const char *data, size_t size)
{
(void)data;
(void)size;
return -1;
}
char *I_ClipboardPaste(void)
{
return NULL;
}
const CPUInfoFlags *I_CPUInfo(void) const CPUInfoFlags *I_CPUInfo(void)
{ {
static CPUInfoFlags DOS_CPUInfo; static CPUInfoFlags DOS_CPUInfo;

View file

@ -60,6 +60,7 @@
#endif #endif
#ifdef _WINDOWS #ifdef _WINDOWS
#define NONET
#if !defined (HWRENDER) && !defined (NOHW) #if !defined (HWRENDER) && !defined (NOHW)
#define HWRENDER #define HWRENDER
#endif #endif
@ -431,6 +432,9 @@ extern INT32 cv_debug;
// Misc stuff for later... // Misc stuff for later...
// ======================= // =======================
// Modifier key variables, accessible anywhere
extern UINT8 shiftdown, ctrldown, altdown;
// if we ever make our alloc stuff... // if we ever make our alloc stuff...
#define ZZ_Alloc(x) Z_Malloc(x, PU_STATIC, NULL) #define ZZ_Alloc(x) Z_Malloc(x, PU_STATIC, NULL)
@ -469,6 +473,12 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
/// Kalaron/Eternity Engine slope code (SRB2CB ported) /// Kalaron/Eternity Engine slope code (SRB2CB ported)
#define ESLOPE #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. /// Delete file while the game is running.
/// \note EXTREMELY buggy, tends to crash game. /// \note EXTREMELY buggy, tends to crash game.
//#define DELFILE //#define DELFILE

View file

@ -92,7 +92,7 @@ typedef long ssize_t;
#endif #endif
#ifdef __APPLE_CC__ #ifdef __APPLE_CC__
#define DIRECTFULLSCREEN #define DIRECTFULLSCREEN 1
#define DEBUG_LOG #define DEBUG_LOG
#define NOIPX #define NOIPX
#endif #endif

View file

@ -162,6 +162,18 @@ INT32 I_PutEnv(char *variable)
return -1; return -1;
} }
INT32 I_ClipboardCopy(const char *data, size_t size)
{
(void)data;
(void)size;
return -1;
}
char *I_ClipboardPaste(void)
{
return NULL;
}
void I_RegisterSysCommands(void) {} void I_RegisterSysCommands(void) {}
#include "../sdl/dosstr.c" #include "../sdl/dosstr.c"

View file

@ -974,7 +974,7 @@ static const char *credits[] = {
"Scott \"Graue\" Feeney", "Scott \"Graue\" Feeney",
"Nathan \"Jazz\" Giroux", "Nathan \"Jazz\" Giroux",
"Thomas \"Shadow Hog\" Igoe", "Thomas \"Shadow Hog\" Igoe",
"\"Monster\" Iestyn Jealous", "Iestyn \"Monster Iestyn\" Jealous",
"Ronald \"Furyhunter\" Kinard", // The SDL2 port "Ronald \"Furyhunter\" Kinard", // The SDL2 port
"John \"JTE\" Muniz", "John \"JTE\" Muniz",
"Ehab \"Wolfy\" Saeed", "Ehab \"Wolfy\" Saeed",
@ -986,6 +986,8 @@ static const char *credits[] = {
"\"chi.miru\"", // Red's secret weapon, the REAL reason slopes exist (also helped port drawing code from ZDoom) "\"chi.miru\"", // Red's secret weapon, the REAL reason slopes exist (also helped port drawing code from ZDoom)
"Andrew \"orospakr\" Clunis", "Andrew \"orospakr\" Clunis",
"Gregor \"Oogaland\" Dick", "Gregor \"Oogaland\" Dick",
"Louis-Antoine \"LJSonic\" de Moulins", // for fixing 2.1's netcode (de Rochefort doesn't quite fit on the screen sorry lol)
"Vivian \"toaster\" Grannell",
"Julio \"Chaos Zero 64\" Guir", "Julio \"Chaos Zero 64\" Guir",
"\"Kalaron\"", // Coded some of Sryder13's collection of OpenGL fixes, especially fog "\"Kalaron\"", // Coded some of Sryder13's collection of OpenGL fixes, especially fog
"Matthew \"Shuffle\" Marsalko", "Matthew \"Shuffle\" Marsalko",
@ -1019,7 +1021,7 @@ static const char *credits[] = {
"Paul \"Boinciel\" Clempson", "Paul \"Boinciel\" Clempson",
"Cyan Helkaraxe", "Cyan Helkaraxe",
"Kepa \"Nev3r\" Iceta", "Kepa \"Nev3r\" Iceta",
"\"Monster\" Iestyn Jealous", "Iestyn \"Monster Iestyn\" Jealous",
"Jarel \"Arrow\" Jones", "Jarel \"Arrow\" Jones",
"Stefan \"Stuf\" Rimalia", "Stefan \"Stuf\" Rimalia",
"Shane Mychal Sexton", "Shane Mychal Sexton",
@ -1724,6 +1726,7 @@ static void F_AdvanceToNextScene(void)
void F_EndCutScene(void) void F_EndCutScene(void)
{ {
cutsceneover = true; // do this first, just in case Y_EndGame or something wants to turn it back false later
if (runningprecutscene) if (runningprecutscene)
{ {
if (server) if (server)
@ -1740,7 +1743,6 @@ void F_EndCutScene(void)
else else
Y_EndGame(); Y_EndGame();
} }
cutsceneover = true;
} }
void F_StartCustomCutscene(INT32 cutscenenum, boolean precutscene, boolean resetplayer) void F_StartCustomCutscene(INT32 cutscenenum, boolean precutscene, boolean resetplayer)

View file

@ -35,7 +35,7 @@ void F_CutsceneTicker(void);
void F_TitleDemoTicker(void); void F_TitleDemoTicker(void);
// Called by main loop. // Called by main loop.
void F_GameEndDrawer(void); FUNCMATH void F_GameEndDrawer(void);
void F_IntroDrawer(void); void F_IntroDrawer(void);
void F_TitleScreenDrawer(void); void F_TitleScreenDrawer(void);

View file

@ -702,6 +702,10 @@ void G_SetGameModified(boolean silent)
if (!silent) if (!silent)
CONS_Alert(CONS_NOTICE, M_GetText("Game must be restarted to record statistics.\n")); CONS_Alert(CONS_NOTICE, M_GetText("Game must be restarted to record statistics.\n"));
// If in record attack recording, cancel it.
if (modeattacking)
M_EndModeAttackRun();
} }
/** Builds an original game map name from a map number. /** Builds an original game map name from a map number.
@ -3024,7 +3028,7 @@ static void G_DoCompleted(void)
if (nextmap < NUMMAPS && !mapheaderinfo[nextmap]) if (nextmap < NUMMAPS && !mapheaderinfo[nextmap])
P_AllocMapHeader(nextmap); P_AllocMapHeader(nextmap);
if (skipstats) if (skipstats && !modeattacking) // Don't skip stats if we're in record attack
G_AfterIntermission(); G_AfterIntermission();
else else
{ {
@ -5734,7 +5738,7 @@ boolean G_CheckDemoStatus(void)
WRITEUINT8(demo_p, DEMOMARKER); // add the demo end marker WRITEUINT8(demo_p, DEMOMARKER); // add the demo end marker
md5_buffer((char *)p+16, demo_p - (p+16), p); // make a checksum of everything after the checksum in the file. md5_buffer((char *)p+16, demo_p - (p+16), p); // make a checksum of everything after the checksum in the file.
#endif #endif
saved = FIL_WriteFile(demoname, demobuffer, demo_p - demobuffer); // finally output the file. saved = FIL_WriteFile(va(pandf, srb2home, demoname), demobuffer, demo_p - demobuffer); // finally output the file.
free(demobuffer); free(demobuffer);
demorecording = false; demorecording = false;

View file

@ -54,7 +54,7 @@
#endif #endif
#endif #endif
typedef void (*I_Error_t) (const char *error, ...); typedef void (*I_Error_t) (const char *error, ...) FUNCIERROR;
// ========================================================================== // ==========================================================================
// MATHS // MATHS

View file

@ -656,6 +656,7 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
{ {
FOutVector v[4]; FOutVector v[4];
FSurfaceInfo Surf; FSurfaceInfo Surf;
float sdupx, sdupy;
if (w < 0 || h < 0) if (w < 0 || h < 0)
return; // consistency w/ software return; // consistency w/ software
@ -664,10 +665,16 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
// | /| // | /|
// |/ | // |/ |
// 0--1 // 0--1
v[0].x = v[3].x = (x - 160.0f)/160.0f; sdupx = FIXED_TO_FLOAT(vid.fdupx)*2.0f;
v[2].x = v[1].x = ((x+w) - 160.0f)/160.0f; sdupy = FIXED_TO_FLOAT(vid.fdupy)*2.0f;
v[0].y = v[1].y = -(y - 100.0f)/100.0f;
v[2].y = v[3].y = -((y+h) - 100.0f)/100.0f; if (color & V_NOSCALESTART)
sdupx = sdupy = 2.0f;
v[0].x = v[3].x = (x*sdupx)/vid.width - 1;
v[2].x = v[1].x = (x*sdupx + w*sdupx)/vid.width - 1;
v[0].y = v[1].y = 1-(y*sdupy)/vid.height;
v[2].y = v[3].y = 1-(y*sdupy + h*sdupy)/vid.height;
//Hurdler: do we still use this argb color? if not, we should remove it //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].argb = v[1].argb = v[2].argb = v[3].argb = 0xff00ff00; //;

View file

@ -45,7 +45,7 @@
#include "hw_md2.h" #include "hw_md2.h"
#define R_FAKEFLOORS #define R_FAKEFLOORS
//#define HWPRECIP #define HWPRECIP
#define SORTING #define SORTING
//#define POLYSKY //#define POLYSKY
@ -66,9 +66,9 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing);
#endif #endif
#ifdef SORTING #ifdef SORTING
void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, fixed_t fixedheight, 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); INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap);
void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, fixed_t fixedheight, 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); INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap);
#else #else
static void HWR_Add3DWater(lumpnum_t lumpnum, extrasubsector_t *xsub, fixed_t fixedheight, static void HWR_Add3DWater(lumpnum_t lumpnum, extrasubsector_t *xsub, fixed_t fixedheight,
@ -521,7 +521,7 @@ static UINT8 HWR_FogBlockAlpha(INT32 light, UINT32 color, UINT32 fadecolor) // L
// -----------------+ // -----------------+
// HWR_RenderPlane : Render a floor or ceiling convex polygon // HWR_RenderPlane : Render a floor or ceiling convex polygon
// -----------------+ // -----------------+
static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, fixed_t fixedheight, static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight,
FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, boolean fogplane, extracolormap_t *planecolormap) FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, boolean fogplane, extracolormap_t *planecolormap)
{ {
polyvertex_t * pv; polyvertex_t * pv;
@ -554,17 +554,16 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, fixed_t fi
// Get the slope pointer to simplify future code // Get the slope pointer to simplify future code
if (FOFsector) if (FOFsector)
{ {
if (FOFsector->f_slope && FOFsector->floorheight == fixedheight) if (FOFsector->f_slope && !isceiling)
slope = FOFsector->f_slope; slope = FOFsector->f_slope;
else if (FOFsector->c_slope && FOFsector->ceilingheight == fixedheight) else if (FOFsector->c_slope && isceiling)
slope = FOFsector->c_slope; slope = FOFsector->c_slope;
} }
else else
{ {
// Use fixedheight to determine whether to check floor or ceiling because I hate my life if (gr_frontsector->f_slope && !isceiling)
if (gr_frontsector->f_slope && gr_frontsector->floorheight == fixedheight)
slope = gr_frontsector->f_slope; slope = gr_frontsector->f_slope;
else if (gr_frontsector->c_slope && gr_frontsector->ceilingheight == fixedheight) else if (gr_frontsector->c_slope && isceiling)
slope = gr_frontsector->c_slope; slope = gr_frontsector->c_slope;
} }
@ -638,12 +637,7 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, fixed_t fi
if (FOFsector != NULL) if (FOFsector != NULL)
{ {
#ifdef ESLOPE if (!isceiling) // it's a floor
if ((slope && slope == FOFsector->f_slope)
|| fixedheight == FOFsector->floorheight) // it's a floor
#else
if (fixedheight == FOFsector->floorheight) // it's a floor
#endif
{ {
scrollx = FIXED_TO_FLOAT(FOFsector->floor_xoffs)/fflatsize; scrollx = FIXED_TO_FLOAT(FOFsector->floor_xoffs)/fflatsize;
scrolly = FIXED_TO_FLOAT(FOFsector->floor_yoffs)/fflatsize; scrolly = FIXED_TO_FLOAT(FOFsector->floor_yoffs)/fflatsize;
@ -658,12 +652,7 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, fixed_t fi
} }
else if (gr_frontsector) else if (gr_frontsector)
{ {
#ifdef ESLOPE if (!isceiling) // it's a floor
if ((slope && slope == gr_frontsector->f_slope)
|| fixedheight == gr_frontsector->floorheight) // it's a floor
#else
if (fixedheight < dup_viewz) // it's a floor
#endif
{ {
scrollx = FIXED_TO_FLOAT(gr_frontsector->floor_xoffs)/fflatsize; scrollx = FIXED_TO_FLOAT(gr_frontsector->floor_xoffs)/fflatsize;
scrolly = FIXED_TO_FLOAT(gr_frontsector->floor_yoffs)/fflatsize; scrolly = FIXED_TO_FLOAT(gr_frontsector->floor_yoffs)/fflatsize;
@ -1569,6 +1558,7 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
if (gr_backsector) if (gr_backsector)
{ {
INT32 gr_toptexture, gr_bottomtexture;
// two sided line // two sided line
if (gr_backsector->heightsec != -1) if (gr_backsector->heightsec != -1)
{ {
@ -1619,19 +1609,22 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
#endif #endif
} }
gr_toptexture = R_GetTextureNum(gr_sidedef->toptexture);
gr_bottomtexture = R_GetTextureNum(gr_sidedef->bottomtexture);
// check TOP TEXTURE // check TOP TEXTURE
if (( if ((
#ifdef ESLOPE #ifdef ESLOPE
worldhighslope < worldtopslope || worldhighslope < worldtopslope ||
#endif #endif
worldhigh < worldtop worldhigh < worldtop
) && texturetranslation[gr_sidedef->toptexture]) ) && gr_toptexture)
{ {
if (drawtextured) if (drawtextured)
{ {
fixed_t texturevpegtop; // top fixed_t texturevpegtop; // top
grTex = HWR_GetTexture(texturetranslation[gr_sidedef->toptexture]); grTex = HWR_GetTexture(gr_toptexture);
// PEGGING // PEGGING
if (gr_linedef->flags & ML_DONTPEGTOP) if (gr_linedef->flags & ML_DONTPEGTOP)
@ -1649,7 +1642,7 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
texturevpegtop += gr_sidedef->rowoffset; texturevpegtop += gr_sidedef->rowoffset;
// This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway // This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway
texturevpegtop %= SHORT(textures[texturetranslation[gr_sidedef->toptexture]]->height)<<FRACBITS; texturevpegtop %= SHORT(textures[gr_toptexture]->height)<<FRACBITS;
wallVerts[3].t = wallVerts[2].t = texturevpegtop * grTex->scaleY; wallVerts[3].t = wallVerts[2].t = texturevpegtop * grTex->scaleY;
wallVerts[0].t = wallVerts[1].t = (texturevpegtop + gr_frontsector->ceilingheight - gr_backsector->ceilingheight) * grTex->scaleY; wallVerts[0].t = wallVerts[1].t = (texturevpegtop + gr_frontsector->ceilingheight - gr_backsector->ceilingheight) * grTex->scaleY;
@ -1675,9 +1668,9 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
else else
{ {
// Skewed by bottom // Skewed by bottom
wallVerts[0].t = (texturevpegtop + worldhigh - worldtop) * grTex->scaleY; wallVerts[0].t = wallVerts[1].t = (texturevpegtop + worldtop - worldhigh) * grTex->scaleY;
wallVerts[2].t = wallVerts[3].t - (worldhighslope - worldhigh) * grTex->scaleY; wallVerts[3].t = wallVerts[0].t - (worldtop - worldhigh) * grTex->scaleY;
wallVerts[1].t = wallVerts[2].t - (worldhighslope - worldtopslope) * grTex->scaleY; wallVerts[2].t = wallVerts[1].t - (worldtopslope - worldhighslope) * grTex->scaleY;
} }
#endif #endif
} }
@ -1694,9 +1687,9 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
#endif #endif
if (gr_frontsector->numlights) if (gr_frontsector->numlights)
HWR_SplitWall(gr_frontsector, wallVerts, texturetranslation[gr_sidedef->toptexture], &Surf, FF_CUTSOLIDS); HWR_SplitWall(gr_frontsector, wallVerts, gr_toptexture, &Surf, FF_CUTSOLIDS);
else if (grTex->mipmap.flags & TF_TRANSPARENT) else if (grTex->mipmap.flags & TF_TRANSPARENT)
HWR_AddTransparentWall(wallVerts, &Surf, texturetranslation[gr_sidedef->toptexture], PF_Environment, false, lightnum, colormap); HWR_AddTransparentWall(wallVerts, &Surf, gr_toptexture, PF_Environment, false, lightnum, colormap);
else else
HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap);
} }
@ -1706,22 +1699,22 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
#ifdef ESLOPE #ifdef ESLOPE
worldlowslope > worldbottomslope || worldlowslope > worldbottomslope ||
#endif #endif
worldlow > worldbottom) && texturetranslation[gr_sidedef->bottomtexture]) //only if VISIBLE!!! worldlow > worldbottom) && gr_bottomtexture) //only if VISIBLE!!!
{ {
if (drawtextured) if (drawtextured)
{ {
fixed_t texturevpegbottom = 0; // bottom fixed_t texturevpegbottom = 0; // bottom
grTex = HWR_GetTexture(texturetranslation[gr_sidedef->bottomtexture]); grTex = HWR_GetTexture(gr_bottomtexture);
// PEGGING // PEGGING
#ifdef ESLOPE #ifdef ESLOPE
if (!(gr_linedef->flags & ML_DONTPEGBOTTOM)) if (!(gr_linedef->flags & ML_DONTPEGBOTTOM))
texturevpegbottom = 0; texturevpegbottom = 0;
else if (gr_linedef->flags & ML_EFFECT1) else if (gr_linedef->flags & ML_EFFECT1)
texturevpegbottom = worldtop - worldlow; texturevpegbottom = worldbottom - worldlow;
else else
texturevpegbottom = gr_frontsector->ceilingheight - gr_backsector->floorheight; texturevpegbottom = gr_frontsector->floorheight - gr_backsector->floorheight;
#else #else
if (gr_linedef->flags & ML_DONTPEGBOTTOM) if (gr_linedef->flags & ML_DONTPEGBOTTOM)
texturevpegbottom = worldbottom - worldlow; texturevpegbottom = worldbottom - worldlow;
@ -1732,7 +1725,7 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
texturevpegbottom += gr_sidedef->rowoffset; texturevpegbottom += gr_sidedef->rowoffset;
// This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway // This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway
texturevpegbottom %= SHORT(textures[texturetranslation[gr_sidedef->bottomtexture]]->height)<<FRACBITS; texturevpegbottom %= SHORT(textures[gr_bottomtexture]->height)<<FRACBITS;
wallVerts[3].t = wallVerts[2].t = texturevpegbottom * grTex->scaleY; wallVerts[3].t = wallVerts[2].t = texturevpegbottom * grTex->scaleY;
wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + gr_backsector->floorheight - gr_frontsector->floorheight) * grTex->scaleY; wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + gr_backsector->floorheight - gr_frontsector->floorheight) * grTex->scaleY;
@ -1752,9 +1745,9 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
else if (gr_linedef->flags & ML_DONTPEGBOTTOM) else if (gr_linedef->flags & ML_DONTPEGBOTTOM)
{ {
// Skewed by bottom // Skewed by bottom
wallVerts[0].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY; wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY;
wallVerts[2].t = wallVerts[3].t - (worldlowslope - worldlow) * grTex->scaleY; //wallVerts[3].t = wallVerts[0].t - (worldlow - worldbottom) * grTex->scaleY; // no need, [3] is already this
wallVerts[1].t = wallVerts[2].t - (worldbottomslope - worldlowslope) * grTex->scaleY; wallVerts[2].t = wallVerts[1].t - (worldlowslope - worldbottomslope) * grTex->scaleY;
} }
else else
{ {
@ -1777,13 +1770,13 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
#endif #endif
if (gr_frontsector->numlights) if (gr_frontsector->numlights)
HWR_SplitWall(gr_frontsector, wallVerts, texturetranslation[gr_sidedef->bottomtexture], &Surf, FF_CUTSOLIDS); HWR_SplitWall(gr_frontsector, wallVerts, gr_bottomtexture, &Surf, FF_CUTSOLIDS);
else if (grTex->mipmap.flags & TF_TRANSPARENT) else if (grTex->mipmap.flags & TF_TRANSPARENT)
HWR_AddTransparentWall(wallVerts, &Surf, texturetranslation[gr_sidedef->bottomtexture], PF_Environment, false, lightnum, colormap); HWR_AddTransparentWall(wallVerts, &Surf, gr_bottomtexture, PF_Environment, false, lightnum, colormap);
else else
HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap);
} }
gr_midtexture = texturetranslation[gr_sidedef->midtexture]; gr_midtexture = R_GetTextureNum(gr_sidedef->midtexture);
if (gr_midtexture) if (gr_midtexture)
{ {
FBITFIELD blendmode; FBITFIELD blendmode;
@ -2145,7 +2138,7 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
else else
{ {
// Single sided line... Deal only with the middletexture (if one exists) // Single sided line... Deal only with the middletexture (if one exists)
gr_midtexture = texturetranslation[gr_sidedef->midtexture]; gr_midtexture = R_GetTextureNum(gr_sidedef->midtexture);
if (gr_midtexture) if (gr_midtexture)
{ {
if (drawtextured) if (drawtextured)
@ -2243,13 +2236,13 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
if (*rover->topheight < lowcut || *rover->bottomheight > highcut) if (*rover->topheight < lowcut || *rover->bottomheight > highcut)
continue; continue;
texnum = texturetranslation[sides[rover->master->sidenum[0]].midtexture]; texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture);
if (rover->master->flags & ML_TFERLINE) if (rover->master->flags & ML_TFERLINE)
{ {
size_t linenum = gr_curline->linedef-gr_backsector->lines[0]; size_t linenum = gr_curline->linedef-gr_backsector->lines[0];
newline = rover->master->frontsector->lines[0] + linenum; newline = rover->master->frontsector->lines[0] + linenum;
texnum = texturetranslation[sides[newline->sidenum[0]].midtexture]; texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture);
} }
#ifdef ESLOPE #ifdef ESLOPE
@ -2292,7 +2285,7 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
else if (drawtextured) else if (drawtextured)
{ {
#ifdef ESLOPE // P.S. this is better-organized than the old version #ifdef ESLOPE // P.S. this is better-organized than the old version
fixed_t offs = sides[(newline ?: rover->master)->sidenum[0]].rowoffset; fixed_t offs = sides[(newline ? newline : rover->master)->sidenum[0]].rowoffset;
grTex = HWR_GetTexture(texnum); grTex = HWR_GetTexture(texnum);
wallVerts[3].t = (*rover->topheight - h + offs) * grTex->scaleY; wallVerts[3].t = (*rover->topheight - h + offs) * grTex->scaleY;
@ -2377,13 +2370,13 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
if (*rover->topheight < lowcut || *rover->bottomheight > highcut) if (*rover->topheight < lowcut || *rover->bottomheight > highcut)
continue; continue;
texnum = texturetranslation[sides[rover->master->sidenum[0]].midtexture]; texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture);
if (rover->master->flags & ML_TFERLINE) if (rover->master->flags & ML_TFERLINE)
{ {
size_t linenum = gr_curline->linedef-gr_backsector->lines[0]; size_t linenum = gr_curline->linedef-gr_backsector->lines[0];
newline = rover->master->frontsector->lines[0] + linenum; newline = rover->master->frontsector->lines[0] + linenum;
texnum = texturetranslation[sides[newline->sidenum[0]].midtexture]; texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture);
} }
#ifdef ESLOPE //backsides #ifdef ESLOPE //backsides
h = *rover->t_slope ? P_GetZAt(*rover->t_slope, v1x, v1y) : *rover->topheight; h = *rover->t_slope ? P_GetZAt(*rover->t_slope, v1x, v1y) : *rover->topheight;
@ -3111,7 +3104,7 @@ static inline void HWR_AddPolyObjectSegs(void)
} }
#ifdef POLYOBJECTS_PLANES #ifdef POLYOBJECTS_PLANES
static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, fixed_t fixedheight, static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t fixedheight,
FBITFIELD blendmode, UINT8 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, FBITFIELD blendmode, UINT8 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector,
UINT8 alpha, extracolormap_t *planecolormap) UINT8 alpha, extracolormap_t *planecolormap)
{ {
@ -3195,7 +3188,7 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, fixed_t fixedheight
if (FOFsector != NULL) if (FOFsector != NULL)
{ {
if (fixedheight == FOFsector->floorheight) // it's a floor if (!isceiling) // it's a floor
{ {
scrollx = FIXED_TO_FLOAT(FOFsector->floor_xoffs)/fflatsize; scrollx = FIXED_TO_FLOAT(FOFsector->floor_xoffs)/fflatsize;
scrolly = FIXED_TO_FLOAT(FOFsector->floor_yoffs)/fflatsize; scrolly = FIXED_TO_FLOAT(FOFsector->floor_yoffs)/fflatsize;
@ -3210,7 +3203,7 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, fixed_t fixedheight
} }
else if (gr_frontsector) else if (gr_frontsector)
{ {
if (fixedheight < dup_viewz) // it's a floor if (!isceiling) // it's a floor
{ {
scrollx = FIXED_TO_FLOAT(gr_frontsector->floor_xoffs)/fflatsize; scrollx = FIXED_TO_FLOAT(gr_frontsector->floor_xoffs)/fflatsize;
scrolly = FIXED_TO_FLOAT(gr_frontsector->floor_yoffs)/fflatsize; scrolly = FIXED_TO_FLOAT(gr_frontsector->floor_yoffs)/fflatsize;
@ -3303,13 +3296,13 @@ static void HWR_AddPolyObjectPlanes(void)
{ {
FSurfaceInfo Surf; FSurfaceInfo Surf;
FBITFIELD blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); FBITFIELD blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf);
HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->floorpic].lumpnum, po_ptrs[i], polyobjsector->floorheight, HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->floorpic].lumpnum, po_ptrs[i], false, polyobjsector->floorheight,
polyobjsector->lightlevel, Surf.FlatColor.s.alpha, polyobjsector, blendmode, NULL); polyobjsector->lightlevel, Surf.FlatColor.s.alpha, polyobjsector, blendmode, NULL);
} }
else else
{ {
HWR_GetFlat(levelflats[polyobjsector->floorpic].lumpnum); HWR_GetFlat(levelflats[polyobjsector->floorpic].lumpnum);
HWR_RenderPolyObjectPlane(po_ptrs[i], polyobjsector->floorheight, PF_Occlude, HWR_RenderPolyObjectPlane(po_ptrs[i], false, polyobjsector->floorheight, PF_Occlude,
polyobjsector->lightlevel, levelflats[polyobjsector->floorpic].lumpnum, polyobjsector->lightlevel, levelflats[polyobjsector->floorpic].lumpnum,
polyobjsector, 255, NULL); polyobjsector, 255, NULL);
} }
@ -3325,13 +3318,13 @@ static void HWR_AddPolyObjectPlanes(void)
FBITFIELD blendmode; FBITFIELD blendmode;
memset(&Surf, 0x00, sizeof(Surf)); memset(&Surf, 0x00, sizeof(Surf));
blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf);
HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->ceilingpic].lumpnum, po_ptrs[i], polyobjsector->ceilingheight, HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->ceilingpic].lumpnum, po_ptrs[i], true, polyobjsector->ceilingheight,
polyobjsector->lightlevel, Surf.FlatColor.s.alpha, polyobjsector, blendmode, NULL); polyobjsector->lightlevel, Surf.FlatColor.s.alpha, polyobjsector, blendmode, NULL);
} }
else else
{ {
HWR_GetFlat(levelflats[polyobjsector->ceilingpic].lumpnum); HWR_GetFlat(levelflats[polyobjsector->ceilingpic].lumpnum);
HWR_RenderPolyObjectPlane(po_ptrs[i], polyobjsector->ceilingheight, PF_Occlude, HWR_RenderPolyObjectPlane(po_ptrs[i], true, polyobjsector->ceilingheight, PF_Occlude,
polyobjsector->lightlevel, levelflats[polyobjsector->floorpic].lumpnum, polyobjsector->lightlevel, levelflats[polyobjsector->floorpic].lumpnum,
polyobjsector, 255, NULL); polyobjsector, 255, NULL);
} }
@ -3485,7 +3478,7 @@ static void HWR_Subsector(size_t num)
if (sub->validcount != validcount) if (sub->validcount != validcount)
{ {
HWR_GetFlat(levelflats[gr_frontsector->floorpic].lumpnum); HWR_GetFlat(levelflats[gr_frontsector->floorpic].lumpnum);
HWR_RenderPlane(gr_frontsector, &extrasubsectors[num], HWR_RenderPlane(gr_frontsector, &extrasubsectors[num], false,
// Hack to make things continue to work around slopes. // Hack to make things continue to work around slopes.
locFloorHeight == cullFloorHeight ? locFloorHeight : gr_frontsector->floorheight, locFloorHeight == cullFloorHeight ? locFloorHeight : gr_frontsector->floorheight,
// We now return you to your regularly scheduled rendering. // We now return you to your regularly scheduled rendering.
@ -3507,7 +3500,7 @@ static void HWR_Subsector(size_t num)
if (sub->validcount != validcount) if (sub->validcount != validcount)
{ {
HWR_GetFlat(levelflats[gr_frontsector->ceilingpic].lumpnum); HWR_GetFlat(levelflats[gr_frontsector->ceilingpic].lumpnum);
HWR_RenderPlane(NULL, &extrasubsectors[num], HWR_RenderPlane(NULL, &extrasubsectors[num], true,
// Hack to make things continue to work around slopes. // Hack to make things continue to work around slopes.
locCeilingHeight == cullCeilingHeight ? locCeilingHeight : gr_frontsector->ceilingheight, locCeilingHeight == cullCeilingHeight ? locCeilingHeight : gr_frontsector->ceilingheight,
// We now return you to your regularly scheduled rendering. // We now return you to your regularly scheduled rendering.
@ -3576,6 +3569,7 @@ static void HWR_Subsector(size_t num)
HWR_AddTransparentFloor(0, HWR_AddTransparentFloor(0,
&extrasubsectors[num], &extrasubsectors[num],
false,
*rover->bottomheight, *rover->bottomheight,
*gr_frontsector->lightlist[light].lightlevel, *gr_frontsector->lightlist[light].lightlevel,
alpha, rover->master->frontsector, PF_Translucent|PF_NoTexture, alpha, rover->master->frontsector, PF_Translucent|PF_NoTexture,
@ -3593,6 +3587,7 @@ static void HWR_Subsector(size_t num)
#else #else
HWR_AddTransparentFloor(levelflats[*rover->bottompic].lumpnum, HWR_AddTransparentFloor(levelflats[*rover->bottompic].lumpnum,
&extrasubsectors[num], &extrasubsectors[num],
false,
*rover->bottomheight, *rover->bottomheight,
*gr_frontsector->lightlist[light].lightlevel, *gr_frontsector->lightlist[light].lightlevel,
rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, PF_Translucent, rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, PF_Translucent,
@ -3603,7 +3598,7 @@ static void HWR_Subsector(size_t num)
{ {
HWR_GetFlat(levelflats[*rover->bottompic].lumpnum); HWR_GetFlat(levelflats[*rover->bottompic].lumpnum);
light = R_GetPlaneLight(gr_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); light = R_GetPlaneLight(gr_frontsector, centerHeight, dup_viewz < cullHeight ? true : false);
HWR_RenderPlane(NULL, &extrasubsectors[num], *rover->bottomheight, PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->bottompic].lumpnum, HWR_RenderPlane(NULL, &extrasubsectors[num], false, *rover->bottomheight, PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->bottompic].lumpnum,
rover->master->frontsector, 255, false, gr_frontsector->lightlist[light].extra_colormap); rover->master->frontsector, 255, false, gr_frontsector->lightlist[light].extra_colormap);
} }
} }
@ -3637,6 +3632,7 @@ static void HWR_Subsector(size_t num)
HWR_AddTransparentFloor(0, HWR_AddTransparentFloor(0,
&extrasubsectors[num], &extrasubsectors[num],
true,
*rover->topheight, *rover->topheight,
*gr_frontsector->lightlist[light].lightlevel, *gr_frontsector->lightlist[light].lightlevel,
alpha, rover->master->frontsector, PF_Translucent|PF_NoTexture, alpha, rover->master->frontsector, PF_Translucent|PF_NoTexture,
@ -3654,6 +3650,7 @@ static void HWR_Subsector(size_t num)
#else #else
HWR_AddTransparentFloor(levelflats[*rover->toppic].lumpnum, HWR_AddTransparentFloor(levelflats[*rover->toppic].lumpnum,
&extrasubsectors[num], &extrasubsectors[num],
true,
*rover->topheight, *rover->topheight,
*gr_frontsector->lightlist[light].lightlevel, *gr_frontsector->lightlist[light].lightlevel,
rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, PF_Translucent, rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, PF_Translucent,
@ -3665,7 +3662,7 @@ static void HWR_Subsector(size_t num)
{ {
HWR_GetFlat(levelflats[*rover->toppic].lumpnum); HWR_GetFlat(levelflats[*rover->toppic].lumpnum);
light = R_GetPlaneLight(gr_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); light = R_GetPlaneLight(gr_frontsector, centerHeight, dup_viewz < cullHeight ? true : false);
HWR_RenderPlane(NULL, &extrasubsectors[num], *rover->topheight, PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum, HWR_RenderPlane(NULL, &extrasubsectors[num], true, *rover->topheight, PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum,
rover->master->frontsector, 255, false, gr_frontsector->lightlist[light].extra_colormap); rover->master->frontsector, 255, false, gr_frontsector->lightlist[light].extra_colormap);
} }
} }
@ -4408,7 +4405,6 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr)
FOutVector *wv; FOutVector *wv;
GLPatch_t *gpatch; // sprite patch converted to hardware GLPatch_t *gpatch; // sprite patch converted to hardware
FSurfaceInfo Surf; FSurfaceInfo Surf;
sector_t *sector;
if (!spr->mobj) if (!spr->mobj)
return; return;
@ -4462,19 +4458,38 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr)
//Hurdler: 25/04/2000: now support colormap in hardware mode //Hurdler: 25/04/2000: now support colormap in hardware mode
HWR_GetMappedPatch(gpatch, spr->colormap); HWR_GetMappedPatch(gpatch, spr->colormap);
sector = spr->mobj->subsector->sector; // colormap test
if (sector->ffloors)
{ {
ffloor_t *caster = sector->lightlist[R_GetPlaneLight(sector, spr->mobj->z, false)].caster; sector_t *sector = spr->mobj->subsector->sector;
sector = caster ? &sectors[caster->secnum] : sector; UINT8 lightlevel = 255;
} extracolormap_t *colormap = sector->extra_colormap;
// sprite lighting by modulating the RGB components if (sector->numlights)
if (sector->extra_colormap) {
Surf.FlatColor.rgba = HWR_Lighting(spr->sectorlight,sector->extra_colormap->rgba,sector->extra_colormap->fadergba, false, false); INT32 light;
light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false); // Always use the light at the top instead of whatever I was doing before
if (!(spr->mobj->frame & FF_FULLBRIGHT))
lightlevel = *sector->lightlist[light].lightlevel;
if (sector->lightlist[light].extra_colormap)
colormap = sector->lightlist[light].extra_colormap;
}
else else
Surf.FlatColor.rgba = HWR_Lighting(spr->sectorlight,NORMALFOG,FADEFOG, false, false); {
if (!(spr->mobj->frame & FF_FULLBRIGHT))
lightlevel = sector->lightlevel;
if (sector->extra_colormap)
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);
}
if (spr->mobj->flags2 & MF2_SHADOW) if (spr->mobj->flags2 & MF2_SHADOW)
{ {
@ -4508,8 +4523,8 @@ static void HWR_SortVisSprites(void)
gr_vissprite_t *ds, *dsprev, *dsnext, *dsfirst; gr_vissprite_t *ds, *dsprev, *dsnext, *dsfirst;
gr_vissprite_t *best = NULL; gr_vissprite_t *best = NULL;
gr_vissprite_t unsorted; gr_vissprite_t unsorted;
float bestdist; float bestdist = 0.0f;
INT32 bestdispoffset; INT32 bestdispoffset = 0;
if (!gr_visspritecount) if (!gr_visspritecount)
return; return;
@ -4529,7 +4544,8 @@ static void HWR_SortVisSprites(void)
// Fix first and last. ds still points to the last one after the loop // Fix first and last. ds still points to the last one after the loop
dsfirst->prev = &unsorted; dsfirst->prev = &unsorted;
unsorted.next = dsfirst; unsorted.next = dsfirst;
ds->next = &unsorted; if (ds)
ds->next = &unsorted;
unsorted.prev = ds; unsorted.prev = ds;
// pull the vissprites out by scale // pull the vissprites out by scale
@ -4552,10 +4568,13 @@ static void HWR_SortVisSprites(void)
best = ds; best = ds;
} }
} }
best->next->prev = best->prev; if (best)
best->prev->next = best->next; {
best->next = &gr_vsprsortedhead; best->next->prev = best->prev;
best->prev = gr_vsprsortedhead.prev; best->prev->next = best->next;
best->next = &gr_vsprsortedhead;
best->prev = gr_vsprsortedhead.prev;
}
gr_vsprsortedhead.prev->next = best; gr_vsprsortedhead.prev->next = best;
gr_vsprsortedhead.prev = best; gr_vsprsortedhead.prev = best;
} }
@ -4588,6 +4607,7 @@ static void HWR_RenderWall(wallVert3D *wallVerts, FSurfaceInfo *pSurf, FBITFIE
typedef struct typedef struct
{ {
extrasubsector_t *xsub; extrasubsector_t *xsub;
boolean isceiling;
fixed_t fixedheight; fixed_t fixedheight;
INT32 lightlevel; INT32 lightlevel;
lumpnum_t lumpnum; lumpnum_t lumpnum;
@ -4605,6 +4625,7 @@ static planeinfo_t *planeinfo = NULL;
typedef struct typedef struct
{ {
polyobj_t *polysector; polyobj_t *polysector;
boolean isceiling;
fixed_t fixedheight; fixed_t fixedheight;
INT32 lightlevel; INT32 lightlevel;
lumpnum_t lumpnum; lumpnum_t lumpnum;
@ -4640,7 +4661,7 @@ static INT32 drawcount = 0;
#define MAX_TRANSPARENTFLOOR 512 #define MAX_TRANSPARENTFLOOR 512
// This will likely turn into a copy of HWR_Add3DWater and replace it. // This will likely turn into a copy of HWR_Add3DWater and replace it.
void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, 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) fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap)
{ {
static size_t allocedplanes = 0; static size_t allocedplanes = 0;
@ -4655,6 +4676,7 @@ void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub,
Z_Realloc(planeinfo, allocedplanes * sizeof (*planeinfo), PU_LEVEL, &planeinfo); Z_Realloc(planeinfo, allocedplanes * sizeof (*planeinfo), PU_LEVEL, &planeinfo);
} }
planeinfo[numplanes].isceiling = isceiling;
planeinfo[numplanes].fixedheight = fixedheight; planeinfo[numplanes].fixedheight = fixedheight;
planeinfo[numplanes].lightlevel = lightlevel; planeinfo[numplanes].lightlevel = lightlevel;
planeinfo[numplanes].lumpnum = lumpnum; planeinfo[numplanes].lumpnum = lumpnum;
@ -4665,12 +4687,13 @@ void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub,
planeinfo[numplanes].fogplane = fogplane; planeinfo[numplanes].fogplane = fogplane;
planeinfo[numplanes].planecolormap = planecolormap; planeinfo[numplanes].planecolormap = planecolormap;
planeinfo[numplanes].drawcount = drawcount++; planeinfo[numplanes].drawcount = drawcount++;
numplanes++; numplanes++;
} }
// Adding this for now until I can create extrasubsector info for polyobjects // Adding this for now until I can create extrasubsector info for polyobjects
// When that happens it'll just be done through HWR_AddTransparentFloor and HWR_RenderPlane // When that happens it'll just be done through HWR_AddTransparentFloor and HWR_RenderPlane
void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, 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) fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap)
{ {
static size_t allocedpolyplanes = 0; static size_t allocedpolyplanes = 0;
@ -4685,6 +4708,7 @@ void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector,
Z_Realloc(polyplaneinfo, allocedpolyplanes * sizeof (*polyplaneinfo), PU_LEVEL, &polyplaneinfo); Z_Realloc(polyplaneinfo, allocedpolyplanes * sizeof (*polyplaneinfo), PU_LEVEL, &polyplaneinfo);
} }
polyplaneinfo[numpolyplanes].isceiling = isceiling;
polyplaneinfo[numpolyplanes].fixedheight = fixedheight; polyplaneinfo[numpolyplanes].fixedheight = fixedheight;
polyplaneinfo[numpolyplanes].lightlevel = lightlevel; polyplaneinfo[numpolyplanes].lightlevel = lightlevel;
polyplaneinfo[numpolyplanes].lumpnum = lumpnum; polyplaneinfo[numpolyplanes].lumpnum = lumpnum;
@ -4850,7 +4874,7 @@ static void HWR_CreateDrawNodes(void)
if (!(sortnode[sortindex[i]].plane->blend & PF_NoTexture)) if (!(sortnode[sortindex[i]].plane->blend & PF_NoTexture))
HWR_GetFlat(sortnode[sortindex[i]].plane->lumpnum); HWR_GetFlat(sortnode[sortindex[i]].plane->lumpnum);
HWR_RenderPlane(NULL, sortnode[sortindex[i]].plane->xsub, sortnode[sortindex[i]].plane->fixedheight, sortnode[sortindex[i]].plane->blend, sortnode[sortindex[i]].plane->lightlevel, HWR_RenderPlane(NULL, sortnode[sortindex[i]].plane->xsub, sortnode[sortindex[i]].plane->isceiling, sortnode[sortindex[i]].plane->fixedheight, sortnode[sortindex[i]].plane->blend, sortnode[sortindex[i]].plane->lightlevel,
sortnode[sortindex[i]].plane->lumpnum, sortnode[sortindex[i]].plane->FOFSector, sortnode[sortindex[i]].plane->alpha, sortnode[sortindex[i]].plane->fogplane, sortnode[sortindex[i]].plane->planecolormap); sortnode[sortindex[i]].plane->lumpnum, sortnode[sortindex[i]].plane->FOFSector, sortnode[sortindex[i]].plane->alpha, sortnode[sortindex[i]].plane->fogplane, sortnode[sortindex[i]].plane->planecolormap);
} }
else if (sortnode[sortindex[i]].polyplane) else if (sortnode[sortindex[i]].polyplane)
@ -4860,7 +4884,7 @@ static void HWR_CreateDrawNodes(void)
if (!(sortnode[sortindex[i]].polyplane->blend & PF_NoTexture)) if (!(sortnode[sortindex[i]].polyplane->blend & PF_NoTexture))
HWR_GetFlat(sortnode[sortindex[i]].polyplane->lumpnum); HWR_GetFlat(sortnode[sortindex[i]].polyplane->lumpnum);
HWR_RenderPolyObjectPlane(sortnode[sortindex[i]].polyplane->polysector, sortnode[sortindex[i]].polyplane->fixedheight, sortnode[sortindex[i]].polyplane->blend, sortnode[sortindex[i]].polyplane->lightlevel, HWR_RenderPolyObjectPlane(sortnode[sortindex[i]].polyplane->polysector, sortnode[sortindex[i]].polyplane->isceiling, sortnode[sortindex[i]].polyplane->fixedheight, sortnode[sortindex[i]].polyplane->blend, sortnode[sortindex[i]].polyplane->lightlevel,
sortnode[sortindex[i]].polyplane->lumpnum, sortnode[sortindex[i]].polyplane->FOFSector, sortnode[sortindex[i]].polyplane->alpha, sortnode[sortindex[i]].polyplane->planecolormap); sortnode[sortindex[i]].polyplane->lumpnum, sortnode[sortindex[i]].polyplane->FOFSector, sortnode[sortindex[i]].polyplane->alpha, sortnode[sortindex[i]].polyplane->planecolormap);
} }
else if (sortnode[sortindex[i]].wall) else if (sortnode[sortindex[i]].wall)
@ -5287,6 +5311,11 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
// //
vis = HWR_NewVisSprite(); vis = HWR_NewVisSprite();
vis->x1 = x1; vis->x1 = x1;
#if 0
vis->x2 = x2;
#else
(void)x2;
#endif
vis->x2 = tx; vis->x2 = tx;
vis->tz = tz; vis->tz = tz;
vis->dispoffset = 0; // Monster Iestyn: 23/11/15: HARDWARE SUPPORT AT LAST vis->dispoffset = 0; // Monster Iestyn: 23/11/15: HARDWARE SUPPORT AT LAST
@ -5299,7 +5328,6 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
// set top/bottom coords // set top/bottom coords
vis->ty = FIXED_TO_FLOAT(thing->z + spritecachedinfo[lumpoff].topoffset) - gr_viewz; vis->ty = FIXED_TO_FLOAT(thing->z + spritecachedinfo[lumpoff].topoffset) - gr_viewz;
vis->sectorlight = 0xff;
vis->precip = true; vis->precip = true;
} }
#endif #endif
@ -6157,7 +6185,7 @@ static void HWR_Render3DWater(void)
for (i = 0; i < numfloors; i++) for (i = 0; i < numfloors; i++)
{ {
HWR_GetFlat(planeinfo[i].lumpnum); HWR_GetFlat(planeinfo[i].lumpnum);
HWR_RenderPlane(NULL, planeinfo[i].xsub, planeinfo[i].fixedheight, PF_Translucent, planeinfo[i].lightlevel, planeinfo[i].lumpnum, HWR_RenderPlane(NULL, planeinfo[i].xsub, planeinfo[i].isceiling, planeinfo[i].fixedheight, PF_Translucent, planeinfo[i].lightlevel, planeinfo[i].lumpnum,
planeinfo[i].FOFSector, planeinfo[i].alpha, planeinfo[i].fogplane, planeinfo[i].planecolormap); planeinfo[i].FOFSector, planeinfo[i].alpha, planeinfo[i].fogplane, planeinfo[i].planecolormap);
} }
numfloors = 0; numfloors = 0;

View file

@ -308,6 +308,23 @@ static md2_model_t *md2_readModel(const char *filename)
model->header.numSkins = 1; model->header.numSkins = 1;
#define MD2LIMITCHECK(field, max, msgname) \
if (field > max) \
{ \
CONS_Alert(CONS_ERROR, "md2_readModel: %s has too many " msgname " (# found: %d, maximum: %d)\n", filename, field, max); \
md2_freeModel (model); \
return 0; \
}
// Uncomment if these are actually needed
// MD2LIMITCHECK(model->header.numSkins, MD2_MAX_SKINS, "skins")
// MD2LIMITCHECK(model->header.numTexCoords, MD2_MAX_TEXCOORDS, "texture coordinates")
MD2LIMITCHECK(model->header.numTriangles, MD2_MAX_TRIANGLES, "triangles")
MD2LIMITCHECK(model->header.numFrames, MD2_MAX_FRAMES, "frames")
MD2LIMITCHECK(model->header.numVertices, MD2_MAX_VERTICES, "vertices")
#undef MD2LIMITCHECK
// read skins // read skins
fseek(file, model->header.offsetSkins, SEEK_SET); fseek(file, model->header.offsetSkins, SEEK_SET);
if (model->header.numSkins > 0) if (model->header.numSkins > 0)
@ -319,8 +336,6 @@ static md2_model_t *md2_readModel(const char *filename)
md2_freeModel (model); md2_freeModel (model);
return 0; return 0;
} }
;
} }
// read texture coordinates // read texture coordinates
@ -334,8 +349,6 @@ static md2_model_t *md2_readModel(const char *filename)
md2_freeModel (model); md2_freeModel (model);
return 0; return 0;
} }
} }
// read triangles // read triangles
@ -769,6 +782,7 @@ void HWR_InitMD2(void)
md2_playermodels[s].grpatch = NULL; md2_playermodels[s].grpatch = NULL;
md2_playermodels[s].skin = -1; md2_playermodels[s].skin = -1;
md2_playermodels[s].notfound = true; md2_playermodels[s].notfound = true;
md2_playermodels[s].error = false;
} }
for (i = 0; i < NUMSPRITES; i++) for (i = 0; i < NUMSPRITES; i++)
{ {
@ -777,6 +791,7 @@ void HWR_InitMD2(void)
md2_models[i].grpatch = NULL; md2_models[i].grpatch = NULL;
md2_models[i].skin = -1; md2_models[i].skin = -1;
md2_models[i].notfound = true; md2_models[i].notfound = true;
md2_models[i].error = false;
} }
// read the md2.dat file // read the md2.dat file
@ -1276,6 +1291,8 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
else else
md2 = &md2_models[spr->mobj->sprite]; md2 = &md2_models[spr->mobj->sprite];
if (md2->error)
return; // we already failed loading this before :(
if (!md2->model) if (!md2->model)
{ {
//CONS_Debug(DBG_RENDER, "Loading MD2... (%s)", sprnames[spr->mobj->sprite]); //CONS_Debug(DBG_RENDER, "Loading MD2... (%s)", sprnames[spr->mobj->sprite]);
@ -1289,6 +1306,7 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
else else
{ {
//CONS_Debug(DBG_RENDER, " FAILED\n"); //CONS_Debug(DBG_RENDER, " FAILED\n");
md2->error = true; // prevent endless fail
return; return;
} }
} }

View file

@ -123,6 +123,7 @@ typedef struct
void *blendgrpatch; void *blendgrpatch;
boolean notfound; boolean notfound;
INT32 skin; INT32 skin;
boolean error;
} md2_t; } md2_t;
extern md2_t md2_models[NUMSPRITES]; extern md2_t md2_models[NUMSPRITES];

View file

@ -1836,10 +1836,7 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value)
} }
} }
// -----------------+ static inline void DrawMD2Ex(INT32 *gl_cmd_buffer, md2_frame_t *frame, UINT32 duration, UINT32 tics, md2_frame_t *nextframe, FTransform *pos, float scale, UINT8 flipped, UINT8 *color)
// HWRAPI DrawMD2 : Draw an MD2 model with glcommands
// -----------------+
EXPORT void HWRAPI(DrawMD2i) (INT32 *gl_cmd_buffer, md2_frame_t *frame, UINT32 duration, UINT32 tics, md2_frame_t *nextframe, FTransform *pos, float scale, UINT8 flipped, UINT8 *color)
{ {
INT32 val, count, pindex; INT32 val, count, pindex;
GLfloat s, t; GLfloat s, t;
@ -1931,7 +1928,7 @@ EXPORT void HWRAPI(DrawMD2i) (INT32 *gl_cmd_buffer, md2_frame_t *frame, UINT32 d
//pglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // alpha = level of transparency //pglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // alpha = level of transparency
// Remove depth mask when the model is transparent so it doesn't cut thorugh sprites // SRB2CBTODO: For all stuff too?! // Remove depth mask when the model is transparent so it doesn't cut thorugh sprites // SRB2CBTODO: For all stuff too?!
if (color[3] < 255) if (color && color[3] < 255)
{ {
pglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // alpha = level of transparency pglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // alpha = level of transparency
pglDepthMask(GL_FALSE); pglDepthMask(GL_FALSE);
@ -2007,11 +2004,20 @@ EXPORT void HWRAPI(DrawMD2i) (INT32 *gl_cmd_buffer, md2_frame_t *frame, UINT32 d
pglDisable(GL_CULL_FACE); pglDisable(GL_CULL_FACE);
} }
// -----------------+
// HWRAPI DrawMD2 : Draw an MD2 model with glcommands
// -----------------+
EXPORT void HWRAPI(DrawMD2i) (INT32 *gl_cmd_buffer, md2_frame_t *frame, UINT32 duration, UINT32 tics, md2_frame_t *nextframe, FTransform *pos, float scale, UINT8 flipped, UINT8 *color)
{
DrawMD2Ex(gl_cmd_buffer, frame, duration, tics, nextframe, pos, scale, flipped, color);
}
EXPORT void HWRAPI(DrawMD2) (INT32 *gl_cmd_buffer, md2_frame_t *frame, FTransform *pos, float scale) EXPORT void HWRAPI(DrawMD2) (INT32 *gl_cmd_buffer, md2_frame_t *frame, FTransform *pos, float scale)
{ {
DrawMD2i(gl_cmd_buffer, frame, 0, 0, NULL, pos, scale, false, NULL); DrawMD2Ex(gl_cmd_buffer, frame, 0, 0, NULL, pos, scale, false, NULL);
} }
// -----------------+ // -----------------+
// SetTransform : // SetTransform :
// -----------------+ // -----------------+

View file

@ -484,7 +484,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
boolean action = false; boolean action = false;
char *ptr; char *ptr;
CONS_Debug(DBG_NETPLAY,"Recieved SAY cmd from Player %d (%s)\n", playernum+1, player_names[playernum]); CONS_Debug(DBG_NETPLAY,"Received SAY cmd from Player %d (%s)\n", playernum+1, player_names[playernum]);
target = READSINT8(*p); target = READSINT8(*p);
flags = READUINT8(*p); flags = READUINT8(*p);
@ -771,15 +771,8 @@ void HU_clearChatChars(void)
// //
boolean HU_Responder(event_t *ev) boolean HU_Responder(event_t *ev)
{ {
static boolean shiftdown = false;
UINT8 c; UINT8 c;
if (ev->data1 == KEY_LSHIFT || ev->data1 == KEY_RSHIFT)
{
shiftdown = (ev->type == ev_keydown);
return chat_on;
}
if (ev->type != ev_keydown) if (ev->type != ev_keydown)
return false; return false;
@ -811,6 +804,14 @@ boolean HU_Responder(event_t *ev)
} }
else // if chat_on else // if chat_on
{ {
// Ignore modifier keys
// Note that we do this here so users can still set
// their chat keys to one of these, if they so desire.
if (ev->data1 == KEY_LSHIFT || ev->data1 == KEY_RSHIFT
|| ev->data1 == KEY_LCTRL || ev->data1 == KEY_RCTRL
|| ev->data1 == KEY_LALT || ev->data1 == KEY_RALT)
return true;
c = (UINT8)ev->data1; c = (UINT8)ev->data1;
// use console translations // use console translations
@ -1188,7 +1189,19 @@ void HU_Drawer(void)
// draw desynch text // draw desynch text
if (hu_resynching) if (hu_resynching)
V_DrawCenteredString(BASEVIDWIDTH/2, 180, V_YELLOWMAP, "Resynching..."); {
static UINT32 resynch_ticker = 0;
char resynch_text[14];
UINT32 i;
// Animate the dots
resynch_ticker++;
strcpy(resynch_text, "Resynching");
for (i = 0; i < (resynch_ticker / 16) % 4; i++)
strcat(resynch_text, ".");
V_DrawCenteredString(BASEVIDWIDTH/2, 180, V_YELLOWMAP | V_ALLOWLOWERCASE, resynch_text);
}
} }
//====================================================================== //======================================================================

View file

@ -94,7 +94,7 @@ void HU_Init(void);
void HU_LoadGraphics(void); void HU_LoadGraphics(void);
// reset heads up when consoleplayer respawns. // reset heads up when consoleplayer respawns.
void HU_Start(void); FUNCMATH void HU_Start(void);
boolean HU_Responder(event_t *ev); boolean HU_Responder(event_t *ev);

View file

@ -85,7 +85,7 @@ extern doomcom_t *doomcom;
/** \brief return packet in doomcom struct /** \brief return packet in doomcom struct
*/ */
extern void (*I_NetGet)(void); extern boolean (*I_NetGet)(void);
/** \brief ask to driver if there is data waiting /** \brief ask to driver if there is data waiting
*/ */

View file

@ -296,6 +296,14 @@ char *I_GetEnv(const char *name);
INT32 I_PutEnv(char *variable); INT32 I_PutEnv(char *variable);
/** \brief Put data in system clipboard
*/
INT32 I_ClipboardCopy(const char *data, size_t size);
/** \brief Retrieve data from system clipboard
*/
const char *I_ClipboardPaste(void);
void I_RegisterSysCommands(void); void I_RegisterSysCommands(void);
#endif #endif

View file

@ -56,7 +56,9 @@
//#define NONET //#define NONET
#endif #endif
#ifndef NONET #ifdef NONET
#undef HAVE_MINIUPNPC
#else
#ifdef USE_WINSOCK1 #ifdef USE_WINSOCK1
#include <winsock.h> #include <winsock.h>
#elif !defined (SCOUW2) && !defined (SCOUW7) && !defined (__OS2__) #elif !defined (SCOUW2) && !defined (SCOUW7) && !defined (__OS2__)
@ -177,6 +179,7 @@ static UINT8 UPNP_support = TRUE;
#include "i_system.h" #include "i_system.h"
#include "i_net.h" #include "i_net.h"
#include "d_net.h" #include "d_net.h"
#include "d_netfil.h"
#include "i_tcp.h" #include "i_tcp.h"
#include "m_argv.h" #include "m_argv.h"
@ -480,21 +483,12 @@ static boolean SOCK_cmpaddr(mysockaddr_t *a, mysockaddr_t *b, UINT8 mask)
return false; return false;
} }
static SINT8 getfreenode(void)
{
SINT8 j;
for (j = 0; j < MAXNETNODES; j++)
if (!nodeconnected[j])
{
nodeconnected[j] = true;
return j;
}
return -1;
}
// This is a hack. For some reason, nodes aren't being freed properly. // This is a hack. For some reason, nodes aren't being freed properly.
// This goes through and cleans up what nodes were supposed to be freed. // This goes through and cleans up what nodes were supposed to be freed.
/** \warning This function causes the file downloading to stop if someone joins.
* How? Because it removes nodes that are connected but not in game,
* which is exactly what clients downloading a file are.
*/
static void cleanupnodes(void) static void cleanupnodes(void)
{ {
SINT8 j; SINT8 j;
@ -504,13 +498,81 @@ static void cleanupnodes(void)
// Why can't I start at zero? // Why can't I start at zero?
for (j = 1; j < MAXNETNODES; j++) for (j = 1; j < MAXNETNODES; j++)
//if (!(nodeingame[j] || SV_SendingFile(j)))
if (!nodeingame[j]) if (!nodeingame[j])
nodeconnected[j] = false; nodeconnected[j] = false;
} }
static SINT8 getfreenode(void)
{
SINT8 j;
cleanupnodes();
for (j = 0; j < MAXNETNODES; j++)
if (!nodeconnected[j])
{
nodeconnected[j] = true;
return j;
}
/** \warning No free node? Just in case a node might not have been freed properly,
* look if there are connected nodes that aren't in game, and forget them.
* It's dirty, and might result in a poor guy having to restart
* downloading a needed wad, but it's better than not letting anyone join...
*/
/*I_Error("No more free nodes!!1!11!11!!1111\n");
for (j = 1; j < MAXNETNODES; j++)
if (!nodeingame[j])
return j;*/
return -1;
}
#ifdef _DEBUG
void Command_Numnodes(void)
{
INT32 connected = 0;
INT32 ingame = 0;
INT32 i;
for (i = 1; i < MAXNETNODES; i++)
{
if (!(nodeconnected[i] || nodeingame[i]))
continue;
if (nodeconnected[i])
connected++;
if (nodeingame[i])
ingame++;
CONS_Printf("%2d - ", i);
if (nodetoplayer[i] != -1)
CONS_Printf("player %.2d", nodetoplayer[i]);
else
CONS_Printf(" ");
if (nodeconnected[i])
CONS_Printf(" - connected");
else
CONS_Printf(" - ");
if (nodeingame[i])
CONS_Printf(" - ingame");
else
CONS_Printf(" - ");
CONS_Printf(" - %s\n", I_GetNodeAddress(i));
}
CONS_Printf("\n"
"Connected: %d\n"
"Ingame: %d\n",
connected, ingame);
}
#endif
#endif #endif
#ifndef NONET #ifndef NONET
static void SOCK_Get(void) // Returns true if a packet was received from a new node, false in all other cases
static boolean SOCK_Get(void)
{ {
size_t i, n; size_t i, n;
int j; int j;
@ -533,13 +595,12 @@ static void SOCK_Get(void)
doomcom->remotenode = (INT16)j; // good packet from a game player doomcom->remotenode = (INT16)j; // good packet from a game player
doomcom->datalength = (INT16)c; doomcom->datalength = (INT16)c;
nodesocket[j] = mysockets[n]; nodesocket[j] = mysockets[n];
return; return false;
} }
} }
// not found // not found
// find a free slot // find a free slot
cleanupnodes();
j = getfreenode(); j = getfreenode();
if (j > 0) if (j > 0)
{ {
@ -562,14 +623,15 @@ static void SOCK_Get(void)
} }
if (i == numbans) if (i == numbans)
SOCK_bannednode[j] = false; SOCK_bannednode[j] = false;
return; return true;
} }
else else
DEBFILE("New node detected: No more free slots\n"); DEBFILE("New node detected: No more free slots\n");
} }
} }
doomcom->remotenode = -1; // no packet doomcom->remotenode = -1; // no packet
return false;
} }
#endif #endif
@ -1254,7 +1316,6 @@ static SINT8 SOCK_NetMakeNodewPort(const char *address, const char *port)
gaie = I_getaddrinfo(address, port, &hints, &ai); gaie = I_getaddrinfo(address, port, &hints, &ai);
if (gaie == 0) if (gaie == 0)
{ {
cleanupnodes();
newnode = getfreenode(); newnode = getfreenode();
} }
if (newnode == -1) if (newnode == -1)

View file

@ -16,6 +16,7 @@
#include "st_stuff.h" #include "st_stuff.h"
#include "v_video.h" #include "v_video.h"
#include "z_zone.h" #include "z_zone.h"
#include "m_misc.h"
//{ SRB2kart Color Code //{ SRB2kart Color Code
@ -98,14 +99,14 @@ const char *KartColor_Names[MAXSKINCOLORS] =
\return INT32 Returns the pulled value of the sixteen fed to it \return INT32 Returns the pulled value of the sixteen fed to it
*/ */
static INT32 R_KartColorSetter(UINT8 i, static INT32 R_KartColorSetter(UINT8 i,
INT32 cZero, INT32 cOne, INT32 cTwo, INT32 cThree, INT32 cZero, INT32 cOne, INT32 cTwo, INT32 cThree,
INT32 cFour, INT32 cFive, INT32 cSix, INT32 cSeven, INT32 cFour, INT32 cFive, INT32 cSix, INT32 cSeven,
INT32 cEight, INT32 cNine, INT32 cTen, INT32 cEleven, INT32 cEight, INT32 cNine, INT32 cTen, INT32 cEleven,
INT32 cTwelve, INT32 cThirteen, INT32 cFourteen, INT32 cFifteen) INT32 cTwelve, INT32 cThirteen, INT32 cFourteen, INT32 cFifteen)
{ {
INT32 ThisColorIs = 0; INT32 ThisColorIs = 0;
switch (i) switch (i)
{ {
case 0: ThisColorIs = cZero; break; case 0: ThisColorIs = cZero; break;
@ -124,8 +125,8 @@ static INT32 R_KartColorSetter(UINT8 i,
case 13: ThisColorIs = cThirteen; break; case 13: ThisColorIs = cThirteen; break;
case 14: ThisColorIs = cFourteen; break; case 14: ThisColorIs = cFourteen; break;
case 15: ThisColorIs = cFifteen; break; case 15: ThisColorIs = cFifteen; break;
} }
return ThisColorIs; return ThisColorIs;
} }
@ -236,7 +237,7 @@ void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color)
case SKINCOLOR_LAVENDER: dest_colormap[starttranscolor + i] = R_KartColorSetter(i, 248, 248, 249, 249, 250, 250, 251, 251, 252, 252, 253, 253, 254, 254, 255, 255); break; case SKINCOLOR_LAVENDER: dest_colormap[starttranscolor + i] = R_KartColorSetter(i, 248, 248, 249, 249, 250, 250, 251, 251, 252, 252, 253, 253, 254, 254, 255, 255); break;
case SKINCOLOR_BYZANTIUM: dest_colormap[starttranscolor + i] = R_KartColorSetter(i, 192, 248, 249, 250, 251, 252, 253, 254, 255, 255, 29, 29, 30, 30, 31, 31); break; case SKINCOLOR_BYZANTIUM: dest_colormap[starttranscolor + i] = R_KartColorSetter(i, 192, 248, 249, 250, 251, 252, 253, 254, 255, 255, 29, 29, 30, 30, 31, 31); break;
case SKINCOLOR_INDIGO: dest_colormap[starttranscolor + i] = R_KartColorSetter(i, 192, 193, 194, 195, 196, 197, 198, 199, 255, 255, 29, 29, 30, 30, 31, 31); break; case SKINCOLOR_INDIGO: dest_colormap[starttranscolor + i] = R_KartColorSetter(i, 192, 193, 194, 195, 196, 197, 198, 199, 255, 255, 29, 29, 30, 30, 31, 31); break;
/* /*
* Removed Colors: * Removed Colors:
* case SKINCOLOR_DUSK: dest_colormap[starttranscolor + i] = R_KartColorSetter(i, 192, 192, 248, 249, 250, 251, 229, 204, 230, 205, 206, 239, 240, 241, 242, 243); break; * case SKINCOLOR_DUSK: dest_colormap[starttranscolor + i] = R_KartColorSetter(i, 192, 192, 248, 249, 250, 251, 229, 204, 230, 205, 206, 239, 240, 241, 242, 243); break;
* case SKINCOLOR_RAINBOW: dest_colormap[starttranscolor + i] = R_KartColorSetter(i, 1, 145, 125, 73, 83, 114, 106, 180, 187, 168, 219, 205, 236, 206, 199, 255); break; * case SKINCOLOR_RAINBOW: dest_colormap[starttranscolor + i] = R_KartColorSetter(i, 1, 145, 125, 73, 83, 114, 106, 180, 187, 168, 219, 205, 236, 206, 199, 255); break;
@ -759,9 +760,9 @@ static void K_KartSetItemResult(fixed_t position, fixed_t giveitem)
{ {
prevchance = chance; prevchance = chance;
basechance = K_KartItemOdds_Retro[pingame-1][giveitem][position]; // Number of slots in the array, based on odds basechance = K_KartItemOdds_Retro[pingame-1][giveitem][position]; // Number of slots in the array, based on odds
for (; chance < prevchance + basechance; chance++) for (; chance < prevchance + basechance; chance++)
{ {
spawnchance[chance] = giveitem; spawnchance[chance] = giveitem;
numchoices++; numchoices++;
} }
@ -780,7 +781,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
player->kartstuff[k_itemroulette]++; player->kartstuff[k_itemroulette]++;
else else
return; return;
// This makes the roulette produce the random noises. // This makes the roulette produce the random noises.
if ((player->kartstuff[k_itemroulette] % 3) == 1 && P_IsLocalPlayer(player)) if ((player->kartstuff[k_itemroulette] % 3) == 1 && P_IsLocalPlayer(player))
S_StartSound(NULL,sfx_mkitm1 + ((player->kartstuff[k_itemroulette] / 3) % 8)); S_StartSound(NULL,sfx_mkitm1 + ((player->kartstuff[k_itemroulette] / 3) % 8));
@ -790,17 +791,17 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
// Finally, if you get past this check, now you can actually start calculating what item you get. // Finally, if you get past this check, now you can actually start calculating what item you get.
if (!(player->kartstuff[k_itemroulette] > (TICRATE*3)-1 || ((cmd->buttons & BT_ATTACK) && player->kartstuff[k_itemroulette] > ((TICRATE*2)/3)-1))) if (!(player->kartstuff[k_itemroulette] > (TICRATE*3)-1 || ((cmd->buttons & BT_ATTACK) && player->kartstuff[k_itemroulette] > ((TICRATE*2)/3)-1)))
return; return;
// Initializes existing values // Initializes existing values
basechance = chance = prevchance = 0; basechance = chance = prevchance = 0;
numchoices = pingame = pexiting = 0; numchoices = pingame = pexiting = 0;
INT32 i; INT32 i;
// Initializes existing spawnchance values // Initializes existing spawnchance values
for (i = 0; i < (NUMKARTITEMS * NUMKARTODDS); i++) for (i = 0; i < (NUMKARTITEMS * NUMKARTODDS); i++)
spawnchance[i] = 0; spawnchance[i] = 0;
// Gotta check how many players are active at this moment. // Gotta check how many players are active at this moment.
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ {
@ -809,19 +810,19 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
if (players[i].exiting) if (players[i].exiting)
pexiting++; pexiting++;
} }
if (cmd->buttons & BT_ATTACK) if (cmd->buttons & BT_ATTACK)
player->pflags |= PF_ATTACKDOWN; player->pflags |= PF_ATTACKDOWN;
player->kartstuff[k_itemclose] = 0; // Reset the item window closer. player->kartstuff[k_itemclose] = 0; // Reset the item window closer.
// Yes I know I'm defining variables half-way into the function, but they aren't needed until now :/ // Yes I know I'm defining variables half-way into the function, but they aren't needed until now :/
fixed_t prandom = P_RandomFixed(); fixed_t prandom = P_RandomFixed();
fixed_t ppos = player->kartstuff[k_position] - 1; fixed_t ppos = player->kartstuff[k_position] - 1;
// Tiny catcher in case player position is unset. // Tiny catcher in case player position is unset.
if (ppos < 0) ppos = 0; if (ppos < 0) ppos = 0;
// Check the game type to differentiate odds. // Check the game type to differentiate odds.
//if (gametype == GT_RETRO) //if (gametype == GT_RETRO)
//{ //{
@ -843,7 +844,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
if (cv_fireflower.value) K_KartSetItemResult(ppos, 16); // Fire Flower if (cv_fireflower.value) K_KartSetItemResult(ppos, 16); // Fire Flower
if (cv_tripleredshell.value) K_KartSetItemResult(ppos, 17); // Triple Red Shell if (cv_tripleredshell.value) K_KartSetItemResult(ppos, 17); // Triple Red Shell
if (cv_lightning.value && pingame > pexiting) K_KartSetItemResult(ppos, 18); // Lightning if (cv_lightning.value && pingame > pexiting) K_KartSetItemResult(ppos, 18); // Lightning
// Award the player whatever power is rolled // Award the player whatever power is rolled
if (numchoices > 0) if (numchoices > 0)
K_KartGetItemResult(player, spawnchance[prandom%numchoices], true); K_KartGetItemResult(player, spawnchance[prandom%numchoices], true);
@ -870,7 +871,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
if (cv_blueshell.value && pexiting == 0) K_KartSetItemResult(ppos, 16) // Deton if (cv_blueshell.value && pexiting == 0) K_KartSetItemResult(ppos, 16) // Deton
if (cv_jaws.value) K_KartSetItemResult(ppos, 17) // 2x Jaws if (cv_jaws.value) K_KartSetItemResult(ppos, 17) // 2x Jaws
if (cv_lightning.value && pingame > pexiting) K_KartSetItemResult(ppos, 18) // Size-Down Monitor if (cv_lightning.value && pingame > pexiting) K_KartSetItemResult(ppos, 18) // Size-Down Monitor
// Award the player whatever power is rolled // Award the player whatever power is rolled
if (numchoices > 0) if (numchoices > 0)
K_KartGetItemResult(player, spawnchance[prandom%numchoices], false) K_KartGetItemResult(player, spawnchance[prandom%numchoices], false)
@ -880,9 +881,9 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
else else
CONS_Printf("ERROR: P_KartItemRoulette - There's no applicable game type!\n"); CONS_Printf("ERROR: P_KartItemRoulette - There's no applicable game type!\n");
*/ */
player->kartstuff[k_itemroulette] = 0; // Since we're done, clear the roulette number player->kartstuff[k_itemroulette] = 0; // Since we're done, clear the roulette number
if (P_IsLocalPlayer(player)) if (P_IsLocalPlayer(player))
S_StartSound(NULL, sfx_mkitmF); S_StartSound(NULL, sfx_mkitmF);
} }
@ -936,75 +937,75 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
K_UpdateOffroad(player); K_UpdateOffroad(player);
// This spawns the drift sparks when k_driftcharge hits 30. Its own AI handles life/death and color // This spawns the drift sparks when k_driftcharge hits 30. Its own AI handles life/death and color
if ((player->kartstuff[k_drift] >= 1 || player->kartstuff[k_drift] <= -1) if ((player->kartstuff[k_drift] >= 1 || player->kartstuff[k_drift] <= -1)
&& player->kartstuff[k_driftcharge] == 30) && player->kartstuff[k_driftcharge] == 30)
P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_DRIFT)->target = player->mo; P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_DRIFT)->target = player->mo;
if (player->kartstuff[k_itemclose]) if (player->kartstuff[k_itemclose])
player->kartstuff[k_itemclose]--; player->kartstuff[k_itemclose]--;
if (player->kartstuff[k_spinout]) if (player->kartstuff[k_spinout])
player->kartstuff[k_spinout]--; player->kartstuff[k_spinout]--;
if (player->kartstuff[k_spinouttimer]) if (player->kartstuff[k_spinouttimer])
player->kartstuff[k_spinouttimer]--; player->kartstuff[k_spinouttimer]--;
if (player->kartstuff[k_spinout] == 0 && player->kartstuff[k_spinouttimer] == 0 && player->powers[pw_flashing] == flashingtics) if (player->kartstuff[k_spinout] == 0 && player->kartstuff[k_spinouttimer] == 0 && player->powers[pw_flashing] == flashingtics)
player->powers[pw_flashing]--; player->powers[pw_flashing]--;
if (player->kartstuff[k_magnettimer]) if (player->kartstuff[k_magnettimer])
player->kartstuff[k_magnettimer]--; player->kartstuff[k_magnettimer]--;
if (player->kartstuff[k_mushroomtimer]) if (player->kartstuff[k_mushroomtimer])
player->kartstuff[k_mushroomtimer]--; player->kartstuff[k_mushroomtimer]--;
if (player->kartstuff[k_floorboost]) if (player->kartstuff[k_floorboost])
player->kartstuff[k_floorboost]--; player->kartstuff[k_floorboost]--;
if (player->kartstuff[k_startimer]) if (player->kartstuff[k_startimer])
player->kartstuff[k_startimer]--; player->kartstuff[k_startimer]--;
if (player->kartstuff[k_growshrinktimer] > 0) if (player->kartstuff[k_growshrinktimer] > 0)
player->kartstuff[k_growshrinktimer]--; player->kartstuff[k_growshrinktimer]--;
if (player->kartstuff[k_growshrinktimer] < 0) if (player->kartstuff[k_growshrinktimer] < 0)
player->kartstuff[k_growshrinktimer]++; player->kartstuff[k_growshrinktimer]++;
if (player->kartstuff[k_growshrinktimer] == 1 || player->kartstuff[k_growshrinktimer] == -1) if (player->kartstuff[k_growshrinktimer] == 1 || player->kartstuff[k_growshrinktimer] == -1)
{ {
player->mo->destscale = FRACUNIT; player->mo->destscale = FRACUNIT;
P_RestoreMusic(player); P_RestoreMusic(player);
} }
if (player->kartstuff[k_bootaketimer] == 0 && player->kartstuff[k_boostolentimer] == 0 if (player->kartstuff[k_bootaketimer] == 0 && player->kartstuff[k_boostolentimer] == 0
&& player->kartstuff[k_goldshroomtimer]) && player->kartstuff[k_goldshroomtimer])
player->kartstuff[k_goldshroomtimer]--; player->kartstuff[k_goldshroomtimer]--;
if (player->kartstuff[k_bootaketimer] == 0 && player->kartstuff[k_boostolentimer] == 0 if (player->kartstuff[k_bootaketimer] == 0 && player->kartstuff[k_boostolentimer] == 0
&& player->kartstuff[k_fireflowertimer]) && player->kartstuff[k_fireflowertimer])
player->kartstuff[k_fireflowertimer]--; player->kartstuff[k_fireflowertimer]--;
if (player->kartstuff[k_bootaketimer]) if (player->kartstuff[k_bootaketimer])
player->kartstuff[k_bootaketimer]--; player->kartstuff[k_bootaketimer]--;
if (player->kartstuff[k_boostolentimer]) if (player->kartstuff[k_boostolentimer])
player->kartstuff[k_boostolentimer]--; player->kartstuff[k_boostolentimer]--;
if (player->kartstuff[k_squishedtimer]) if (player->kartstuff[k_squishedtimer])
player->kartstuff[k_squishedtimer]--; player->kartstuff[k_squishedtimer]--;
if (player->kartstuff[k_laserwisptimer]) if (player->kartstuff[k_laserwisptimer])
player->kartstuff[k_laserwisptimer]--; player->kartstuff[k_laserwisptimer]--;
if (player->kartstuff[k_sounds]) if (player->kartstuff[k_sounds])
player->kartstuff[k_sounds]--; player->kartstuff[k_sounds]--;
// Restores music if too many sounds are playing (?) // Restores music if too many sounds are playing (?)
//if (player->kartstuff[k_sounds] >= 1 && player->kartstuff[k_sounds] < 120) //if (player->kartstuff[k_sounds] >= 1 && player->kartstuff[k_sounds] < 120)
// player->kartstuff[k_sounds] += 1; // player->kartstuff[k_sounds] += 1;
//if (player->kartstuff[k_sounds] < 120 && player->kartstuff[k_sounds] > 116) //&& P_IsLocalPlayer(player)) //if (player->kartstuff[k_sounds] < 120 && player->kartstuff[k_sounds] > 116) //&& P_IsLocalPlayer(player))
// P_RestoreMusic(player); // P_RestoreMusic(player);
// ??? // ???
/* /*
if (player->kartstuff[k_jmp] > 1 && onground) if (player->kartstuff[k_jmp] > 1 && onground)
@ -1018,11 +1019,11 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
if (cmd->buttons & BT_JUMP) if (cmd->buttons & BT_JUMP)
player->kartstuff[k_jmp] = 1; player->kartstuff[k_jmp] = 1;
else else
player->kartstuff[k_jmp] = 0; player->kartstuff[k_jmp] = 0;
K_KartItemRoulette(player, cmd); // Roulette Code K_KartItemRoulette(player, cmd); // Roulette Code
// Looping and stopping of the horrible horrible star SFX ~Sryder // Looping and stopping of the horrible horrible star SFX ~Sryder
if (player->mo->health > 0 && player->mo->player->kartstuff[k_startimer])// If you have invincibility if (player->mo->health > 0 && player->mo->player->kartstuff[k_startimer])// If you have invincibility
{ {
@ -1074,20 +1075,20 @@ fixed_t K_GetKartBoostPower(player_t *player)
{ {
fixed_t boostpower = FRACUNIT; fixed_t boostpower = FRACUNIT;
if (!(player->kartstuff[k_startimer] || player->kartstuff[k_bootaketimer] || player->kartstuff[k_mushroomtimer] || player->kartstuff[k_growshrinktimer] > 1) if (!(player->kartstuff[k_startimer] || player->kartstuff[k_bootaketimer] || player->kartstuff[k_mushroomtimer] || player->kartstuff[k_growshrinktimer] > 1)
&& player->kartstuff[k_offroad] >= 0) && player->kartstuff[k_offroad] >= 0)
boostpower = FixedDiv(boostpower, player->kartstuff[k_offroad] + FRACUNIT); boostpower = FixedDiv(boostpower, player->kartstuff[k_offroad] + FRACUNIT);
if (player->kartstuff[k_growshrinktimer] < -1) if (player->kartstuff[k_growshrinktimer] < -1)
boostpower = FixedMul(boostpower, 6*FRACUNIT/8); // Shrink boostpower = FixedMul(boostpower, 6*FRACUNIT/8); // Shrink
if (player->kartstuff[k_squishedtimer] > 0) if (player->kartstuff[k_squishedtimer] > 0)
boostpower = FixedMul(boostpower, 7*FRACUNIT/8); // Squished boostpower = FixedMul(boostpower, 7*FRACUNIT/8); // Squished
if (player->powers[pw_sneakers]) if (player->powers[pw_sneakers])
boostpower = FixedMul(boostpower, 10*FRACUNIT/8); // Slide Boost boostpower = FixedMul(boostpower, 10*FRACUNIT/8); // Slide Boost
if (player->kartstuff[k_growshrinktimer] > 1) if (player->kartstuff[k_growshrinktimer] > 1)
boostpower = FixedMul(boostpower, 10*FRACUNIT/8); // Mega Mushroom boostpower = FixedMul(boostpower, 10*FRACUNIT/8); // Mega Mushroom
if (player->kartstuff[k_startimer]) if (player->kartstuff[k_startimer])
boostpower = FixedMul(boostpower, 11*FRACUNIT/8); // Star boostpower = FixedMul(boostpower, 11*FRACUNIT/8); // Star
if (player->kartstuff[k_mushroomtimer]) if (player->kartstuff[k_mushroomtimer])
boostpower = FixedMul(boostpower, 12*FRACUNIT/8); // Mushroom boostpower = FixedMul(boostpower, 12*FRACUNIT/8); // Mushroom
return boostpower; return boostpower;
@ -1174,7 +1175,7 @@ void K_SquishPlayer(player_t *player, mobj_t *source)
if (player->health <= 0) if (player->health <= 0)
return; return;
if (player->powers[pw_flashing] > 0 || player->kartstuff[k_squishedtimer] > 0 if (player->powers[pw_flashing] > 0 || player->kartstuff[k_squishedtimer] > 0
|| player->kartstuff[k_startimer] > 0 || player->kartstuff[k_growshrinktimer] > 0 || player->kartstuff[k_bootaketimer] > 0) || player->kartstuff[k_startimer] > 0 || player->kartstuff[k_growshrinktimer] > 0 || player->kartstuff[k_bootaketimer] > 0)
return; return;
@ -1548,7 +1549,7 @@ static void K_DoBooSteal(player_t * player)
&& !players[i].exiting && !players[i].powers[pw_super] && !((netgame || multiplayer) && players[i].spectator) && !players[i].exiting && !players[i].powers[pw_super] && !((netgame || multiplayer) && players[i].spectator)
&& players[i].kartstuff[k_position] < player->kartstuff[k_position] && player != &players[i] && players[i].kartstuff[k_position] < player->kartstuff[k_position] && player != &players[i]
&& (players[i].kartstuff[k_star] || players[i].kartstuff[k_mushroom] || players[i].kartstuff[k_goldshroom] && (players[i].kartstuff[k_star] || players[i].kartstuff[k_mushroom] || players[i].kartstuff[k_goldshroom]
|| players[i].kartstuff[k_megashroom] || players[i].kartstuff[k_lightning] || players[i].kartstuff[k_blueshell] || players[i].kartstuff[k_megashroom] || players[i].kartstuff[k_lightning] || players[i].kartstuff[k_blueshell]
|| players[i].kartstuff[k_greenshell] & 2 || players[i].kartstuff[k_triplegreenshell] & 8 || players[i].kartstuff[k_greenshell] & 2 || players[i].kartstuff[k_triplegreenshell] & 8
|| players[i].kartstuff[k_redshell] & 2 || players[i].kartstuff[k_tripleredshell] & 8 || players[i].kartstuff[k_redshell] & 2 || players[i].kartstuff[k_tripleredshell] & 8
@ -1716,7 +1717,7 @@ void K_KartDrift(player_t *player, ticcmd_t *cmd, boolean onground)
player->kartstuff[k_turndir] = 0; player->kartstuff[k_turndir] = 0;
// Drift Release (Moved here so you can't "chain" drifts) // Drift Release (Moved here so you can't "chain" drifts)
if ((player->kartstuff[k_drift] == 0) if ((player->kartstuff[k_drift] == 0)
// || (player->kartstuff[k_drift] >= 1 && player->kartstuff[k_turndir] != 1) || (player->kartstuff[k_drift] <= -1 && player->kartstuff[k_turndir] != -1)) // || (player->kartstuff[k_drift] >= 1 && player->kartstuff[k_turndir] != 1) || (player->kartstuff[k_drift] <= -1 && player->kartstuff[k_turndir] != -1))
&& player->kartstuff[k_driftcharge] < 30 && player->kartstuff[k_driftcharge] < 30
&& onground) && onground)
@ -1724,7 +1725,7 @@ void K_KartDrift(player_t *player, ticcmd_t *cmd, boolean onground)
player->kartstuff[k_drift] = 0; player->kartstuff[k_drift] = 0;
player->kartstuff[k_driftcharge] = 0; player->kartstuff[k_driftcharge] = 0;
} }
else if ((player->kartstuff[k_drift] == 0) else if ((player->kartstuff[k_drift] == 0)
// || (player->kartstuff[k_drift] >= 1 && player->kartstuff[k_turndir] != 1) || (player->kartstuff[k_drift] <= -1 && player->kartstuff[k_turndir] != -1)) // || (player->kartstuff[k_drift] >= 1 && player->kartstuff[k_turndir] != 1) || (player->kartstuff[k_drift] <= -1 && player->kartstuff[k_turndir] != -1))
&& (player->kartstuff[k_driftcharge] >= 30 && player->kartstuff[k_driftcharge] < 60) && (player->kartstuff[k_driftcharge] >= 30 && player->kartstuff[k_driftcharge] < 60)
&& onground) && onground)
@ -1734,7 +1735,7 @@ void K_KartDrift(player_t *player, ticcmd_t *cmd, boolean onground)
player->kartstuff[k_drift] = 0; player->kartstuff[k_drift] = 0;
player->kartstuff[k_driftcharge] = 0; player->kartstuff[k_driftcharge] = 0;
} }
else if ((player->kartstuff[k_drift] == 0) else if ((player->kartstuff[k_drift] == 0)
// || (player->kartstuff[k_drift] >= 1 && player->kartstuff[k_turndir] != 1) || (player->kartstuff[k_drift] <= -1 && player->kartstuff[k_turndir] != -1)) // || (player->kartstuff[k_drift] >= 1 && player->kartstuff[k_turndir] != 1) || (player->kartstuff[k_drift] <= -1 && player->kartstuff[k_turndir] != -1))
&& player->kartstuff[k_driftcharge] >= 60 && player->kartstuff[k_driftcharge] >= 60
&& onground) && onground)
@ -1766,7 +1767,7 @@ void K_KartDrift(player_t *player, ticcmd_t *cmd, boolean onground)
player->kartstuff[k_drift]++; player->kartstuff[k_drift]++;
if (player->kartstuff[k_drift] > 3) if (player->kartstuff[k_drift] > 3)
player->kartstuff[k_drift] = 3; player->kartstuff[k_drift] = 3;
// Left = +450 Right = -450 // Left = +450 Right = -450
// Player 1 // Player 1
if (player == &players[consoleplayer]) if (player == &players[consoleplayer])
@ -1782,7 +1783,7 @@ void K_KartDrift(player_t *player, ticcmd_t *cmd, boolean onground)
// Player 2 // Player 2
if (splitscreen && player == &players[secondarydisplayplayer]) if (splitscreen && player == &players[secondarydisplayplayer])
{ {
} }
} }
else if (player->kartstuff[k_drift] <= -1) // Drifting to the Left else if (player->kartstuff[k_drift] <= -1) // Drifting to the Left
@ -1790,7 +1791,7 @@ void K_KartDrift(player_t *player, ticcmd_t *cmd, boolean onground)
player->kartstuff[k_drift]--; player->kartstuff[k_drift]--;
if (player->kartstuff[k_drift] < -3) if (player->kartstuff[k_drift] < -3)
player->kartstuff[k_drift] = -3; player->kartstuff[k_drift] = -3;
// Left = +450 Right = -450 // Left = +450 Right = -450
// Player 1 // Player 1
if (player == &players[consoleplayer]) if (player == &players[consoleplayer])
@ -1828,36 +1829,36 @@ static void K_KartUpdatePosition(player_t *player)
fixed_t i, ppcd, pncd, ipcd, incd; fixed_t i, ppcd, pncd, ipcd, incd;
fixed_t pmo, imo; fixed_t pmo, imo;
thinker_t *th; thinker_t *th;
mobj_t *mo; mobj_t *mo;
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ {
if (playeringame[i] && !players[i].spectator && if (playeringame[i] && !players[i].spectator &&
(((players[i].starpostnum) + (numstarposts + 1) * players[i].laps) > (((players[i].starpostnum) + (numstarposts + 1) * players[i].laps) >
((player->starpostnum) + (numstarposts + 1) * player->laps))) ((player->starpostnum) + (numstarposts + 1) * player->laps)))
position++; position++;
else if (playeringame[i] && !players[i].spectator else if (playeringame[i] && !players[i].spectator
&& (((players[i].starpostnum) + (numstarposts+1)*players[i].laps) == && (((players[i].starpostnum) + (numstarposts+1)*players[i].laps) ==
((player->starpostnum) + (numstarposts+1)*player->laps))) ((player->starpostnum) + (numstarposts+1)*player->laps)))
{ {
ppcd = pncd = ipcd = incd = 0; ppcd = pncd = ipcd = incd = 0;
player->kartstuff[k_prevcheck] = players[i].kartstuff[k_prevcheck] = 0; player->kartstuff[k_prevcheck] = players[i].kartstuff[k_prevcheck] = 0;
player->kartstuff[k_nextcheck] = players[i].kartstuff[k_nextcheck] = 0; player->kartstuff[k_nextcheck] = players[i].kartstuff[k_nextcheck] = 0;
// This checks every thing on the map, and looks for MT_BOSS3WAYPOINT (the thing we're using for checkpoint wp's, for now) // This checks every thing on the map, and looks for MT_BOSS3WAYPOINT (the thing we're using for checkpoint wp's, for now)
for (th = thinkercap.next; th != &thinkercap; th = th->next) for (th = thinkercap.next; th != &thinkercap; th = th->next)
{ {
if (th->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj at all, shoo if (th->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj at all, shoo
continue; continue;
mo = (mobj_t *)th; mo = (mobj_t *)th;
pmo = P_AproxDistance(P_AproxDistance( mo->x - player->mo->x, pmo = P_AproxDistance(P_AproxDistance( mo->x - player->mo->x,
mo->y - player->mo->y), mo->y - player->mo->y),
mo->z - player->mo->z) / FRACUNIT; mo->z - player->mo->z) / FRACUNIT;
imo = P_AproxDistance(P_AproxDistance( mo->x - players[i].mo->x, imo = P_AproxDistance(P_AproxDistance( mo->x - players[i].mo->x,
mo->y - players[i].mo->y), mo->y - players[i].mo->y),
mo->z - players[i].mo->z) / FRACUNIT; mo->z - players[i].mo->z) / FRACUNIT;
if (mo->type != MT_BOSS3WAYPOINT) // TODO: Change to 'MT_WAYPOINT'? if (mo->type != MT_BOSS3WAYPOINT) // TODO: Change to 'MT_WAYPOINT'?
@ -1892,7 +1893,7 @@ static void K_KartUpdatePosition(player_t *player)
if ((players[i].kartstuff[k_nextcheck] > 0 || player->kartstuff[k_nextcheck] > 0) && !player->exiting) if ((players[i].kartstuff[k_nextcheck] > 0 || player->kartstuff[k_nextcheck] > 0) && !player->exiting)
{ {
if ((players[i].kartstuff[k_nextcheck] - players[i].kartstuff[k_prevcheck]) < if ((players[i].kartstuff[k_nextcheck] - players[i].kartstuff[k_prevcheck]) <
(player->kartstuff[k_nextcheck] - player->kartstuff[k_prevcheck])) (player->kartstuff[k_nextcheck] - player->kartstuff[k_prevcheck]))
position++; position++;
} }
@ -1953,7 +1954,7 @@ void K_MoveKartPlayer(player_t *player, ticcmd_t *cmd, boolean onground)
player->pflags &= ~PF_ATTACKDOWN; player->pflags &= ~PF_ATTACKDOWN;
else if (cmd->buttons & BT_ATTACK) else if (cmd->buttons & BT_ATTACK)
player->pflags |= PF_ATTACKDOWN; player->pflags |= PF_ATTACKDOWN;
if (player && player->health > 0 && !player->spectator && !player->exiting && player->kartstuff[k_spinouttimer] == 0) if (player && player->health > 0 && !player->spectator && !player->exiting && player->kartstuff[k_spinouttimer] == 0)
{ {
// GoldenMushroom power // GoldenMushroom power
@ -2327,11 +2328,11 @@ void K_MoveKartPlayer(player_t *player, ticcmd_t *cmd, boolean onground)
} }
else if (player->kartstuff[k_mushroomtimer] == 0 && player->kartstuff[k_boosting] == 1) else if (player->kartstuff[k_mushroomtimer] == 0 && player->kartstuff[k_boosting] == 1)
player->kartstuff[k_boosting] = 0; player->kartstuff[k_boosting] = 0;
if (player->kartstuff[k_bootaketimer] > 0) if (player->kartstuff[k_bootaketimer] > 0)
{ {
if ((player == &players[displayplayer] || (splitscreen && player == &players[secondarydisplayplayer])) if ((player == &players[displayplayer] || (splitscreen && player == &players[secondarydisplayplayer]))
|| (!(player == &players[displayplayer] || (splitscreen && player == &players[secondarydisplayplayer])) || (!(player == &players[displayplayer] || (splitscreen && player == &players[secondarydisplayplayer]))
&& (player->kartstuff[k_bootaketimer] < 1*TICRATE/2 || player->kartstuff[k_bootaketimer] > bootime-(1*TICRATE/2)))) && (player->kartstuff[k_bootaketimer] < 1*TICRATE/2 || player->kartstuff[k_bootaketimer] > bootime-(1*TICRATE/2))))
{ {
if (leveltime & 1) if (leveltime & 1)
@ -2349,7 +2350,7 @@ void K_MoveKartPlayer(player_t *player, ticcmd_t *cmd, boolean onground)
player->mo->flags2 &= ~MF2_DONTDRAW; player->mo->flags2 &= ~MF2_DONTDRAW;
} }
} }
if (player->kartstuff[k_growshrinktimer] > 1) if (player->kartstuff[k_growshrinktimer] > 1)
player->powers[pw_flashing] = 2; player->powers[pw_flashing] = 2;
@ -2434,7 +2435,7 @@ void K_MoveKartPlayer(player_t *player, ticcmd_t *cmd, boolean onground)
} }
} }
*/ */
// Play the stop light's sounds // Play the stop light's sounds
if ((leveltime == (TICRATE-4)*2) || (leveltime == (TICRATE-2)*3)) if ((leveltime == (TICRATE-4)*2) || (leveltime == (TICRATE-2)*3))
S_StartSound(NULL, sfx_lkt1); S_StartSound(NULL, sfx_lkt1);
@ -2591,7 +2592,7 @@ void K_MoveKartPlayer(player_t *player, ticcmd_t *cmd, boolean onground)
//{ SRB2kart HUD Code //{ SRB2kart HUD Code
#define NUMPOSNUMS 10 #define NUMPOSNUMS 10
#define NUMPOSFRAMES 7 // White, three blues, three reds #define NUMPOSFRAMES 7 // White, three blues, three reds
//{ Patch Definitions //{ Patch Definitions
static patch_t *kp_nodraw; static patch_t *kp_nodraw;
@ -2674,18 +2675,18 @@ void K_LoadKartHUDGraphics(void)
{ {
INT32 i, j; INT32 i, j;
char buffer[9]; char buffer[9];
// Null Stuff // Null Stuff
kp_nodraw = W_CachePatchName("K_TRNULL", PU_HUDGFX); kp_nodraw = W_CachePatchName("K_TRNULL", PU_HUDGFX);
kp_noitem = W_CachePatchName("K_ITNULL", PU_HUDGFX); kp_noitem = W_CachePatchName("K_ITNULL", PU_HUDGFX);
//kp_neonoitem = W_CachePatchName("KNITNULL", PU_HUDGFX); //kp_neonoitem = W_CachePatchName("KNITNULL", PU_HUDGFX);
// Stickers // Stickers
kp_timesticker = W_CachePatchName("K_STTIME", PU_HUDGFX); kp_timesticker = W_CachePatchName("K_STTIME", PU_HUDGFX);
kp_timestickerwide = W_CachePatchName("K_STTIMW", PU_HUDGFX); kp_timestickerwide = W_CachePatchName("K_STTIMW", PU_HUDGFX);
kp_lapsticker = W_CachePatchName("K_STLAPS", PU_HUDGFX); kp_lapsticker = W_CachePatchName("K_STLAPS", PU_HUDGFX);
kp_lapstickernarrow = W_CachePatchName("K_STLAPN", PU_HUDGFX); kp_lapstickernarrow = W_CachePatchName("K_STLAPN", PU_HUDGFX);
// Position numbers // Position numbers
for (i = 0; i < NUMPOSNUMS; i++) for (i = 0; i < NUMPOSNUMS; i++)
{ {
@ -2701,7 +2702,7 @@ void K_LoadKartHUDGraphics(void)
kp_facesecond = W_CachePatchName("K_PFACE2", PU_HUDGFX); kp_facesecond = W_CachePatchName("K_PFACE2", PU_HUDGFX);
kp_facethird = W_CachePatchName("K_PFACE3", PU_HUDGFX); kp_facethird = W_CachePatchName("K_PFACE3", PU_HUDGFX);
kp_facefourth = W_CachePatchName("K_PFACE4", PU_HUDGFX); kp_facefourth = W_CachePatchName("K_PFACE4", PU_HUDGFX);
// Kart Item Windows // Kart Item Windows
kp_magnet = W_CachePatchName("K_ITMAGN", PU_HUDGFX); kp_magnet = W_CachePatchName("K_ITMAGN", PU_HUDGFX);
kp_boo = W_CachePatchName("K_ITBOO1", PU_HUDGFX); kp_boo = W_CachePatchName("K_ITBOO1", PU_HUDGFX);
@ -2724,14 +2725,14 @@ void K_LoadKartHUDGraphics(void)
kp_tripleredshell = W_CachePatchName("K_ITTRED", PU_HUDGFX); kp_tripleredshell = W_CachePatchName("K_ITTRED", PU_HUDGFX);
kp_lightning = W_CachePatchName("K_ITLIGH", PU_HUDGFX); kp_lightning = W_CachePatchName("K_ITLIGH", PU_HUDGFX);
kp_kitchensink = W_CachePatchName("K_ITSINK", PU_HUDGFX); kp_kitchensink = W_CachePatchName("K_ITSINK", PU_HUDGFX);
// Item-used - Closing the item window after an item is used // Item-used - Closing the item window after an item is used
kp_itemused1 = W_CachePatchName("K_ITUSE1", PU_HUDGFX); kp_itemused1 = W_CachePatchName("K_ITUSE1", PU_HUDGFX);
kp_itemused2 = W_CachePatchName("K_ITUSE2", PU_HUDGFX); kp_itemused2 = W_CachePatchName("K_ITUSE2", PU_HUDGFX);
kp_itemused3 = W_CachePatchName("K_ITUSE3", PU_HUDGFX); kp_itemused3 = W_CachePatchName("K_ITUSE3", PU_HUDGFX);
kp_itemused4 = W_CachePatchName("K_ITUSE4", PU_HUDGFX); kp_itemused4 = W_CachePatchName("K_ITUSE4", PU_HUDGFX);
kp_itemused5 = W_CachePatchName("K_ITUSE5", PU_HUDGFX); kp_itemused5 = W_CachePatchName("K_ITUSE5", PU_HUDGFX);
// Triple-item HUD icons // Triple-item HUD icons
kp_singlebananaicon = W_CachePatchName("K_TRBAN1", PU_HUDGFX); kp_singlebananaicon = W_CachePatchName("K_TRBAN1", PU_HUDGFX);
kp_doublebananaicon = W_CachePatchName("K_TRBAN2", PU_HUDGFX); kp_doublebananaicon = W_CachePatchName("K_TRBAN2", PU_HUDGFX);
@ -2764,7 +2765,7 @@ void K_LoadKartHUDGraphics(void)
kp_laserwisp = W_CachePatchName("KTITLASE", PU_HUDGFX); kp_laserwisp = W_CachePatchName("KTITLASE", PU_HUDGFX);
kp_doublejaws = W_CachePatchName("KTITDJAW", PU_HUDGFX); kp_doublejaws = W_CachePatchName("KTITDJAW", PU_HUDGFX);
kp_sizedownmonitor = W_CachePatchName("KTITSDOW", PU_HUDGFX); kp_sizedownmonitor = W_CachePatchName("KTITSDOW", PU_HUDGFX);
// Item-used - Closing the item window after an item is used (Neo-Kart) // Item-used - Closing the item window after an item is used (Neo-Kart)
kp_neoitemused1 = W_CachePatchName("KNITUSE1", PU_HUDGFX); kp_neoitemused1 = W_CachePatchName("KNITUSE1", PU_HUDGFX);
kp_neoitemused2 = W_CachePatchName("KNITUSE2", PU_HUDGFX); kp_neoitemused2 = W_CachePatchName("KNITUSE2", PU_HUDGFX);
@ -2806,37 +2807,37 @@ static void K_initKartHUD(void)
/* /*
BASEVIDWIDTH = 320 BASEVIDWIDTH = 320
BASEVIDHEIGHT = 200 BASEVIDHEIGHT = 200
Item window graphic is 41 x 33 Item window graphic is 41 x 33
Time Sticker graphic is 116 x 11 Time Sticker graphic is 116 x 11
Time Font is a solid block of (8 x [12) x 14], equal to 96 x 14 Time Font is a solid block of (8 x [12) x 14], equal to 96 x 14
Therefore, timestamp is 116 x 14 altogether Therefore, timestamp is 116 x 14 altogether
Lap Sticker is 80 x 11 Lap Sticker is 80 x 11
Lap flag is 22 x 20 Lap flag is 22 x 20
Lap Font is a solid block of (3 x [12) x 14], equal to 36 x 14 Lap Font is a solid block of (3 x [12) x 14], equal to 36 x 14
Therefore, lapstamp is 80 x 20 altogether Therefore, lapstamp is 80 x 20 altogether
Position numbers are 43 x 53 Position numbers are 43 x 53
Faces are 32 x 32 Faces are 32 x 32
Faces draw downscaled at 16 x 16 Faces draw downscaled at 16 x 16
Therefore, the allocated space for them is 16 x 67 altogether Therefore, the allocated space for them is 16 x 67 altogether
---- ----
ORIGINAL CZ64 SPLITSCREEN: ORIGINAL CZ64 SPLITSCREEN:
Item window: Item window:
if (!splitscreen) { ICONX = 139; ICONY = 20; } if (!splitscreen) { ICONX = 139; ICONY = 20; }
else { ICONX = BASEVIDWIDTH-315; ICONY = 60; } else { ICONX = BASEVIDWIDTH-315; ICONY = 60; }
Time: 236, STRINGY( 12) Time: 236, STRINGY( 12)
Lap: BASEVIDWIDTH-304, STRINGY(BASEVIDHEIGHT-189) Lap: BASEVIDWIDTH-304, STRINGY(BASEVIDHEIGHT-189)
*/ */
if (!splitscreen) // Local Single-Player if (!splitscreen) // Local Single-Player
{ {
switch (cv_karthud.value) // Item Window switch (cv_karthud.value) // Item Window
@ -2867,19 +2868,19 @@ static void K_initKartHUD(void)
{ {
ITEM_X = 9; // 9 ITEM_X = 9; // 9
ITEM_Y = 48; // 48 ITEM_Y = 48; // 48
TRIP_X = 143; // 143 TRIP_X = 143; // 143
TRIP_Y = BASEVIDHEIGHT- 34; // 166 TRIP_Y = BASEVIDHEIGHT- 34; // 166
TIME_X = BASEVIDWIDTH -114; // 206 / Sticker is 196 (Base - 124) - Inside the boundry by 8px TIME_X = BASEVIDWIDTH -114; // 206 / Sticker is 196 (Base - 124) - Inside the boundry by 8px
TIME_Y = 6; // 6 / Sticker is +2 TIME_Y = 6; // 6 / Sticker is +2
LAPS_X = 9; // 9 LAPS_X = 9; // 9
LAPS_Y = BASEVIDHEIGHT- 31; // 169 LAPS_Y = BASEVIDHEIGHT- 31; // 169
POSI_X = BASEVIDWIDTH - 51; // 269 POSI_X = BASEVIDWIDTH - 51; // 269
POSI_Y = BASEVIDHEIGHT-128; // 72 POSI_Y = BASEVIDHEIGHT-128; // 72
FACE_X = 15; // 15 FACE_X = 15; // 15
FACE_Y = 72; // 72 FACE_Y = 72; // 72
} }
@ -2893,11 +2894,11 @@ static void K_drawKartItemClose(void)
{ {
// ITEM_X = BASEVIDWIDTH-50; // 270 // ITEM_X = BASEVIDWIDTH-50; // 270
// ITEM_Y = 24; // 24 // ITEM_Y = 24; // 24
// Why write V_DrawScaledPatch calls over and over when they're all the same? // Why write V_DrawScaledPatch calls over and over when they're all the same?
// Set to 'no draw' just in case. // Set to 'no draw' just in case.
patch_t *localpatch = kp_nodraw; patch_t *localpatch = kp_nodraw;
/*if () /*if ()
switch (stplyr->kartstuff[k_itemclose]) switch (stplyr->kartstuff[k_itemclose])
{ {
@ -2918,7 +2919,7 @@ static void K_drawKartItemClose(void)
case 9: localpatch = kp_itemused1; break; case 9: localpatch = kp_itemused1; break;
default: break; default: break;
} }
if (localpatch != kp_nodraw) if (localpatch != kp_nodraw)
V_DrawScaledPatch(ITEM_X, STRINGY(ITEM_Y), V_SNAPTORIGHT|V_SNAPTOTOP, localpatch); V_DrawScaledPatch(ITEM_X, STRINGY(ITEM_Y), V_SNAPTORIGHT|V_SNAPTOTOP, localpatch);
} }
@ -2927,11 +2928,11 @@ static void K_drawKartItemRoulette(void)
{ {
// ITEM_X = BASEVIDWIDTH-50; // 270 // ITEM_X = BASEVIDWIDTH-50; // 270
// ITEM_Y = 24; // 24 // ITEM_Y = 24; // 24
// Why write V_DrawScaledPatch calls over and over when they're all the same? // Why write V_DrawScaledPatch calls over and over when they're all the same?
// Set to 'no item' just in case. // Set to 'no item' just in case.
patch_t *localpatch = kp_nodraw; patch_t *localpatch = kp_nodraw;
/*if () /*if ()
switch(stplyr->kartstuff[k_itemroulette] % 53) switch(stplyr->kartstuff[k_itemroulette] % 53)
{ {
@ -2955,7 +2956,7 @@ static void K_drawKartItemRoulette(void)
case 45: case 46: case 47: localpatch = kp_jaws; break; // 1x Jaws case 45: case 46: case 47: localpatch = kp_jaws; break; // 1x Jaws
case 48: case 49: case 50: localpatch = kp_deton; break; // Deton case 48: case 49: case 50: localpatch = kp_deton; break; // Deton
case 51: case 52: case 53: localpatch = kp_sizedownmonitor; break; // Size-Down Monitor case 51: case 52: case 53: localpatch = kp_sizedownmonitor; break; // Size-Down Monitor
default: break; default: break;
} }
else*/ else*/
switch(stplyr->kartstuff[k_itemroulette] % 53) switch(stplyr->kartstuff[k_itemroulette] % 53)
@ -2980,9 +2981,9 @@ static void K_drawKartItemRoulette(void)
case 45: case 46: case 47: localpatch = kp_redshell; break; // Red Shell case 45: case 46: case 47: localpatch = kp_redshell; break; // Red Shell
case 48: case 49: case 50: localpatch = kp_blueshell; break; // Blue Shell case 48: case 49: case 50: localpatch = kp_blueshell; break; // Blue Shell
case 51: case 52: case 53: localpatch = kp_lightning; break; // Lightning case 51: case 52: case 53: localpatch = kp_lightning; break; // Lightning
default: break; default: break;
} }
V_DrawScaledPatch(ITEM_X, STRINGY(ITEM_Y), V_SNAPTORIGHT|V_SNAPTOTOP, localpatch); V_DrawScaledPatch(ITEM_X, STRINGY(ITEM_Y), V_SNAPTORIGHT|V_SNAPTOTOP, localpatch);
} }
@ -2990,16 +2991,16 @@ static void K_drawKartRetroItem(void)
{ {
// ITEM_X = BASEVIDWIDTH-50; // 270 // ITEM_X = BASEVIDWIDTH-50; // 270
// ITEM_Y = 24; // 24 // ITEM_Y = 24; // 24
// Why write V_DrawScaledPatch calls over and over when they're all the same? // Why write V_DrawScaledPatch calls over and over when they're all the same?
// Set to 'no item' just in case. // Set to 'no item' just in case.
patch_t *localpatch = kp_nodraw; patch_t *localpatch = kp_nodraw;
// I'm doing this a little weird and drawing mostly in reverse order // I'm doing this a little weird and drawing mostly in reverse order
// The only actual reason is to make triple/double/single mushrooms line up this way in the code below // The only actual reason is to make triple/double/single mushrooms line up this way in the code below
// This shouldn't have any actual baring over how it functions // This shouldn't have any actual baring over how it functions
// Boo is first, because we're drawing it on top of the player's current item // Boo is first, because we're drawing it on top of the player's current item
if ((stplyr->kartstuff[k_bootaketimer] > 0 if ((stplyr->kartstuff[k_bootaketimer] > 0
|| stplyr->kartstuff[k_boostolentimer] > 0) && (leveltime & 2)) localpatch = kp_boosteal; || stplyr->kartstuff[k_boostolentimer] > 0) && (leveltime & 2)) localpatch = kp_boosteal;
else if (stplyr->kartstuff[k_boostolentimer] > 0 && !(leveltime & 2)) localpatch = kp_noitem; else if (stplyr->kartstuff[k_boostolentimer] > 0 && !(leveltime & 2)) localpatch = kp_noitem;
else if (stplyr->kartstuff[k_kitchensink] == 1) localpatch = kp_kitchensink; else if (stplyr->kartstuff[k_kitchensink] == 1) localpatch = kp_kitchensink;
@ -3015,10 +3016,10 @@ static void K_drawKartRetroItem(void)
else if (stplyr->kartstuff[k_fakeitem] & 2) localpatch = kp_fakeitem; else if (stplyr->kartstuff[k_fakeitem] & 2) localpatch = kp_fakeitem;
else if (stplyr->kartstuff[k_triplebanana] & 8) localpatch = kp_triplebanana; else if (stplyr->kartstuff[k_triplebanana] & 8) localpatch = kp_triplebanana;
else if (stplyr->kartstuff[k_star] == 1) localpatch = kp_star; else if (stplyr->kartstuff[k_star] == 1) localpatch = kp_star;
else if (stplyr->kartstuff[k_goldshroom] == 1 else if (stplyr->kartstuff[k_goldshroom] == 1
|| (stplyr->kartstuff[k_goldshroomtimer] > 1 && (leveltime & 1))) localpatch = kp_goldshroom; || (stplyr->kartstuff[k_goldshroomtimer] > 1 && (leveltime & 1))) localpatch = kp_goldshroom;
else if (stplyr->kartstuff[k_goldshroomtimer] > 1 && !(leveltime & 1)) localpatch = kp_noitem; else if (stplyr->kartstuff[k_goldshroomtimer] > 1 && !(leveltime & 1)) localpatch = kp_noitem;
else if (stplyr->kartstuff[k_megashroom] == 1 else if (stplyr->kartstuff[k_megashroom] == 1
|| (stplyr->kartstuff[k_growshrinktimer] > 1 && (leveltime & 1))) localpatch = kp_megashroom; || (stplyr->kartstuff[k_growshrinktimer] > 1 && (leveltime & 1))) localpatch = kp_megashroom;
else if (stplyr->kartstuff[k_growshrinktimer] > 1 && !(leveltime & 1)) localpatch = kp_noitem; else if (stplyr->kartstuff[k_growshrinktimer] > 1 && !(leveltime & 1)) localpatch = kp_noitem;
else if (stplyr->kartstuff[k_mushroom] & 4) localpatch = kp_triplemushroom; else if (stplyr->kartstuff[k_mushroom] & 4) localpatch = kp_triplemushroom;
@ -3026,7 +3027,7 @@ static void K_drawKartRetroItem(void)
else if (stplyr->kartstuff[k_mushroom] == 1) localpatch = kp_mushroom; else if (stplyr->kartstuff[k_mushroom] == 1) localpatch = kp_mushroom;
else if (stplyr->kartstuff[k_boo] == 1) localpatch = kp_boo; else if (stplyr->kartstuff[k_boo] == 1) localpatch = kp_boo;
else if (stplyr->kartstuff[k_magnet] == 1) localpatch = kp_magnet; else if (stplyr->kartstuff[k_magnet] == 1) localpatch = kp_magnet;
V_DrawScaledPatch(ITEM_X, STRINGY(ITEM_Y), V_SNAPTORIGHT|V_SNAPTOTOP, localpatch); V_DrawScaledPatch(ITEM_X, STRINGY(ITEM_Y), V_SNAPTORIGHT|V_SNAPTOTOP, localpatch);
} }
@ -3035,16 +3036,16 @@ static void K_drawKartNeoItem(void)
{ {
// ITEM_X = BASEVIDWIDTH-50; // 270 // ITEM_X = BASEVIDWIDTH-50; // 270
// ITEM_Y = 24; // 24 // ITEM_Y = 24; // 24
// Why write V_DrawScaledPatch calls over and over when they're all the same? // Why write V_DrawScaledPatch calls over and over when they're all the same?
// Set to 'no item' just in case. // Set to 'no item' just in case.
patch_t *localpatch = kp_noitem; patch_t *localpatch = kp_noitem;
// I'm doing this a little weird and drawing mostly in reverse order // I'm doing this a little weird and drawing mostly in reverse order
// The only actual reason is to make triple/double/single mushrooms line up this way in the code below // The only actual reason is to make triple/double/single mushrooms line up this way in the code below
// This shouldn't have any actual baring over how it functions // This shouldn't have any actual baring over how it functions
// Boo is first, because we're drawing it on top of the player's current item // Boo is first, because we're drawing it on top of the player's current item
if ((stplyr->kartstuff[k_bootaketimer] > 0 if ((stplyr->kartstuff[k_bootaketimer] > 0
|| stplyr->kartstuff[k_boostolentimer] > 0) && (leveltime & 2)) localpatch = kp_skghoststeal; || stplyr->kartstuff[k_boostolentimer] > 0) && (leveltime & 2)) localpatch = kp_skghoststeal;
else if (stplyr->kartstuff[k_boostolentimer] > 0 && !(leveltime & 2)) localpatch = kp_neonoitem; else if (stplyr->kartstuff[k_boostolentimer] > 0 && !(leveltime & 2)) localpatch = kp_neonoitem;
else if (stplyr->kartstuff[k_lightning] == 1) localpatch = kp_sizedownmonitor; else if (stplyr->kartstuff[k_lightning] == 1) localpatch = kp_sizedownmonitor;
@ -3059,10 +3060,10 @@ static void K_drawKartNeoItem(void)
else if (stplyr->kartstuff[k_fakeitem] & 2) localpatch = kp_eggmanmonitor; else if (stplyr->kartstuff[k_fakeitem] & 2) localpatch = kp_eggmanmonitor;
else if (stplyr->kartstuff[k_triplebanana] & 8) localpatch = kp_neotriplebanana; else if (stplyr->kartstuff[k_triplebanana] & 8) localpatch = kp_neotriplebanana;
else if (stplyr->kartstuff[k_star] == 1) localpatch = kp_invincibility; else if (stplyr->kartstuff[k_star] == 1) localpatch = kp_invincibility;
else if (stplyr->kartstuff[k_goldshroom] == 1 else if (stplyr->kartstuff[k_goldshroom] == 1
|| (stplyr->kartstuff[k_goldshroomtimer] > 1 && (leveltime & 1))) localpatch = kp_rocketshoe; || (stplyr->kartstuff[k_goldshroomtimer] > 1 && (leveltime & 1))) localpatch = kp_rocketshoe;
else if (stplyr->kartstuff[k_goldshroomtimer] > 1 && !(leveltime & 1)) localpatch = kp_neonoitem; else if (stplyr->kartstuff[k_goldshroomtimer] > 1 && !(leveltime & 1)) localpatch = kp_neonoitem;
else if (stplyr->kartstuff[k_megashroom] == 1 else if (stplyr->kartstuff[k_megashroom] == 1
|| (stplyr->kartstuff[k_growshrinktimer] > 1 && (leveltime & 1))) localpatch = kp_sizeupmonitor; || (stplyr->kartstuff[k_growshrinktimer] > 1 && (leveltime & 1))) localpatch = kp_sizeupmonitor;
else if (stplyr->kartstuff[k_growshrinktimer] > 1 && !(leveltime & 1)) localpatch = kp_neonoitem; else if (stplyr->kartstuff[k_growshrinktimer] > 1 && !(leveltime & 1)) localpatch = kp_neonoitem;
else if (stplyr->kartstuff[k_mushroom] & 4) localpatch = kp_triplespeedshoe; else if (stplyr->kartstuff[k_mushroom] & 4) localpatch = kp_triplespeedshoe;
@ -3070,7 +3071,7 @@ static void K_drawKartNeoItem(void)
else if (stplyr->kartstuff[k_mushroom] == 1) localpatch = kp_speedshoe; else if (stplyr->kartstuff[k_mushroom] == 1) localpatch = kp_speedshoe;
else if (stplyr->kartstuff[k_boo] & 8) localpatch = kp_skghost; else if (stplyr->kartstuff[k_boo] & 8) localpatch = kp_skghost;
else if (stplyr->kartstuff[k_magnet] & 8) localpatch = kp_electroshield; else if (stplyr->kartstuff[k_magnet] & 8) localpatch = kp_electroshield;
V_DrawScaledPatch(ITEM_X, STRINGY(ITEM_Y), V_SNAPTORIGHT|V_TRANSLUCENT, localpatch); V_DrawScaledPatch(ITEM_X, STRINGY(ITEM_Y), V_SNAPTORIGHT|V_TRANSLUCENT, localpatch);
} }
*/ */
@ -3079,24 +3080,24 @@ static void K_DrawKartTripleItem(void)
{ {
// TRIP_X = 143; // 143 // TRIP_X = 143; // 143
// TRIP_Y = BASEVIDHEIGHT-34; // 166 // TRIP_Y = BASEVIDHEIGHT-34; // 166
// Why write V_DrawScaledPatch calls over and over when they're all the same? // Why write V_DrawScaledPatch calls over and over when they're all the same?
// Set to 'no draw' just in case. // Set to 'no draw' just in case.
patch_t *localpatch = kp_nodraw; patch_t *localpatch = kp_nodraw;
INT32 thisitem; INT32 thisitem;
/*if () /*if ()
{ {
thisitem = stplyr->kartstuff[k_triplebanana]; thisitem = stplyr->kartstuff[k_triplebanana];
if (thisitem & 1) localpatch = kp_singleneobananaicon; if (thisitem & 1) localpatch = kp_singleneobananaicon;
else if (thisitem & 2) localpatch = kp_doubleneobananaicon; else if (thisitem & 2) localpatch = kp_doubleneobananaicon;
else if (thisitem & 4) localpatch = kp_tripleneobananaicon; else if (thisitem & 4) localpatch = kp_tripleneobananaicon;
thisitem = stplyr->kartstuff[k_triplegreenshell]; thisitem = stplyr->kartstuff[k_triplegreenshell];
if (thisitem & 1) localpatch = kp_singleorbitauricon; if (thisitem & 1) localpatch = kp_singleorbitauricon;
else if (thisitem & 2) localpatch = kp_doubleorbitauricon; else if (thisitem & 2) localpatch = kp_doubleorbitauricon;
else if (thisitem & 4) localpatch = kp_tripleorbitauricon; else if (thisitem & 4) localpatch = kp_tripleorbitauricon;
thisitem = stplyr->kartstuff[k_jaws]; thisitem = stplyr->kartstuff[k_jaws];
if (thisitem & 1) localpatch = kp_singlejawsicon; if (thisitem & 1) localpatch = kp_singlejawsicon;
else if (thisitem & 2) localpatch = kp_doublejawsicon; else if (thisitem & 2) localpatch = kp_doublejawsicon;
@ -3107,18 +3108,18 @@ static void K_DrawKartTripleItem(void)
if (thisitem & 1) localpatch = kp_singlebananaicon; if (thisitem & 1) localpatch = kp_singlebananaicon;
else if (thisitem & 2) localpatch = kp_doublebananaicon; else if (thisitem & 2) localpatch = kp_doublebananaicon;
else if (thisitem & 4) localpatch = kp_triplebananaicon; else if (thisitem & 4) localpatch = kp_triplebananaicon;
thisitem = stplyr->kartstuff[k_triplegreenshell]; thisitem = stplyr->kartstuff[k_triplegreenshell];
if (thisitem & 1) localpatch = kp_singlegreenshellicon; if (thisitem & 1) localpatch = kp_singlegreenshellicon;
else if (thisitem & 2) localpatch = kp_doublegreenshellicon; else if (thisitem & 2) localpatch = kp_doublegreenshellicon;
else if (thisitem & 4) localpatch = kp_triplegreenshellicon; else if (thisitem & 4) localpatch = kp_triplegreenshellicon;
thisitem = stplyr->kartstuff[k_tripleredshell]; thisitem = stplyr->kartstuff[k_tripleredshell];
if (thisitem & 1) localpatch = kp_singleredshellicon; if (thisitem & 1) localpatch = kp_singleredshellicon;
else if (thisitem & 2) localpatch = kp_doubleredshellicon; else if (thisitem & 2) localpatch = kp_doubleredshellicon;
else if (thisitem & 4) localpatch = kp_tripleredshellicon; else if (thisitem & 4) localpatch = kp_tripleredshellicon;
//} //}
if (localpatch != kp_nodraw) if (localpatch != kp_nodraw)
V_DrawScaledPatch(TRIP_X, STRINGY(TRIP_Y), V_SNAPTORIGHT|V_TRANSLUCENT, localpatch); V_DrawScaledPatch(TRIP_X, STRINGY(TRIP_Y), V_SNAPTORIGHT|V_TRANSLUCENT, localpatch);
} }
@ -3183,11 +3184,11 @@ static void K_DrawKartPositionNum(INT32 num)
{ {
// POSI_X = BASEVIDWIDTH - 51; // 269 // POSI_X = BASEVIDWIDTH - 51; // 269
// POSI_Y = BASEVIDHEIGHT- 64; // 136 // POSI_Y = BASEVIDHEIGHT- 64; // 136
INT32 X = POSI_X+SCX(43); // +43 to offset where it's being drawn if there are more than one INT32 X = POSI_X+SCX(43); // +43 to offset where it's being drawn if there are more than one
INT32 W = SHORT(kp_positionnum[0][0]->width); INT32 W = SHORT(kp_positionnum[0][0]->width);
patch_t *localpatch = kp_positionnum[0][0]; patch_t *localpatch = kp_positionnum[0][0];
// Special case for 0 // Special case for 0
if (!num) if (!num)
{ {
@ -3196,12 +3197,12 @@ static void K_DrawKartPositionNum(INT32 num)
} }
I_Assert(num >= 0); // This function does not draw negative numbers I_Assert(num >= 0); // This function does not draw negative numbers
// Draw the number // Draw the number
while (num) while (num)
{ {
X -= (W*vid.dupx); X -= (W*vid.dupx);
// Check for the final lap // Check for the final lap
if (stplyr->laps+1 == cv_numlaps.value) if (stplyr->laps+1 == cv_numlaps.value)
{ {
@ -3233,7 +3234,7 @@ static void K_DrawKartPositionNum(INT32 num)
} }
else else
localpatch = kp_positionnum[num % 10][0]; localpatch = kp_positionnum[num % 10][0];
V_DrawTranslucentPatch(X, POSI_Y, V_NOSCALESTART|V_TRANSLUCENT|V_SNAPTORIGHT|V_SNAPTOBOTTOM, localpatch); V_DrawTranslucentPatch(X, POSI_Y, V_NOSCALESTART|V_TRANSLUCENT|V_SNAPTORIGHT|V_SNAPTOBOTTOM, localpatch);
num /= 10; num /= 10;
} }
@ -3243,7 +3244,7 @@ static void K_DrawKartPositionFaces(void)
{ {
// FACE_X = 15; // 15 // FACE_X = 15; // 15
// FACE_Y = 72; // 72 // FACE_Y = 72; // 72
INT32 Y = FACE_Y+9; // +9 to offset where it's being drawn if there are more than one INT32 Y = FACE_Y+9; // +9 to offset where it's being drawn if there are more than one
INT32 i, j, ranklines; INT32 i, j, ranklines;
boolean completed[MAXPLAYERS]; boolean completed[MAXPLAYERS];
@ -3252,16 +3253,16 @@ static void K_DrawKartPositionFaces(void)
UINT32 myplayer; UINT32 myplayer;
UINT8 *colormap; UINT8 *colormap;
patch_t *localpatch = kp_facenull; patch_t *localpatch = kp_facenull;
ranklines = 0; ranklines = 0;
memset(completed, 0, sizeof (completed)); memset(completed, 0, sizeof (completed));
memset(rankplayer, 0, sizeof (rankplayer)); memset(rankplayer, 0, sizeof (rankplayer));
memset(rankcolor, 0, sizeof (rankcolor)); memset(rankcolor, 0, sizeof (rankcolor));
myplayer = demoplayback ? displayplayer : consoleplayer; myplayer = demoplayback ? displayplayer : consoleplayer;
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
rankplayer[i] = -1; rankplayer[i] = -1;
for (j = 0; j < MAXPLAYERS; j++) for (j = 0; j < MAXPLAYERS; j++)
{ {
if (!playeringame[j]) if (!playeringame[j])
@ -3269,7 +3270,7 @@ static void K_DrawKartPositionFaces(void)
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ {
if (playeringame[i] && completed[i] == false if (playeringame[i] && completed[i] == false
&& (rankplayer[ranklines] < 0 || players[i].kartstuff[k_position] < players[rankplayer[ranklines]].kartstuff[k_position])) && (rankplayer[ranklines] < 0 || players[i].kartstuff[k_position] < players[rankplayer[ranklines]].kartstuff[k_position]))
{ {
rankplayer[ranklines] = i; rankplayer[ranklines] = i;
@ -3279,7 +3280,7 @@ static void K_DrawKartPositionFaces(void)
completed[rankplayer[ranklines]] = true; completed[rankplayer[ranklines]] = true;
ranklines++; ranklines++;
} }
if (ranklines > 4) ranklines = 4; // Only draw the top 4 players if (ranklines > 4) ranklines = 4; // Only draw the top 4 players
Y -= (9*ranklines); Y -= (9*ranklines);
@ -3326,12 +3327,12 @@ void K_drawKartHUD(void)
// Define the X and Y for each drawn object // Define the X and Y for each drawn object
// This is handled by console/menu values // This is handled by console/menu values
K_initKartHUD(); K_initKartHUD();
// If the item window is closing, draw it closing! // If the item window is closing, draw it closing!
if (stplyr->kartstuff[k_itemclose]) if (stplyr->kartstuff[k_itemclose])
K_drawKartItemClose(); K_drawKartItemClose();
// If the item-roulette is going, draw that // If the item-roulette is going, draw that
// Otherwise, draw the item window normally (separated for retro/neo, to prevent this block from becoming a mess // Otherwise, draw the item window normally (separated for retro/neo, to prevent this block from becoming a mess
if (stplyr->kartstuff[k_itemroulette]) if (stplyr->kartstuff[k_itemroulette])
K_drawKartItemRoulette(); K_drawKartItemRoulette();
@ -3339,27 +3340,27 @@ void K_drawKartHUD(void)
// K_drawKartNeoItem(); // K_drawKartNeoItem();
else else
K_drawKartRetroItem(); K_drawKartRetroItem();
// Draw the little triple-item icons at the bottom // Draw the little triple-item icons at the bottom
if (!splitscreen) if (!splitscreen)
{ {
K_DrawKartTripleItem(); K_DrawKartTripleItem();
K_DrawKartPositionFaces(); K_DrawKartPositionFaces();
} }
// Draw the timestamp // Draw the timestamp
K_drawKartTimestamp(); K_drawKartTimestamp();
// Draw the lap counter // Draw the lap counter
V_DrawScaledPatch(LAPS_X, STRINGY(LAPS_Y), 0, kp_lapsticker); V_DrawScaledPatch(LAPS_X, STRINGY(LAPS_Y), 0, kp_lapsticker);
if (stplyr->exiting) if (stplyr->exiting)
V_DrawKartString(LAPS_X+33, STRINGY(LAPS_Y+3), 0, "FIN"); V_DrawKartString(LAPS_X+33, STRINGY(LAPS_Y+3), 0, "FIN");
else else
V_DrawKartString(LAPS_X+33, STRINGY(LAPS_Y+3), 0, va("%d/%d", stplyr->laps+1, cv_numlaps.value)); V_DrawKartString(LAPS_X+33, STRINGY(LAPS_Y+3), 0, va("%d/%d", stplyr->laps+1, cv_numlaps.value));
// Draw the numerical position // Draw the numerical position
K_DrawKartPositionNum(stplyr->kartstuff[k_position]); K_DrawKartPositionNum(stplyr->kartstuff[k_position]);
// Plays the music after the starting countdown. This is here since it checks every frame regularly. // Plays the music after the starting countdown. This is here since it checks every frame regularly.
if (leveltime > 157 && leveltime < (TICRATE+1)*7) if (leveltime > 157 && leveltime < (TICRATE+1)*7)
S_ChangeMusicInternal(mapmusname, true); S_ChangeMusicInternal(mapmusname, true);

View file

@ -437,6 +437,16 @@ static int lib_pMobjFlip(lua_State *L)
return 1; return 1;
} }
static int lib_pGetMobjGravity(lua_State *L)
{
mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
//HUDSAFE
if (!mobj)
return LUA_ErrInvalid(L, "mobj_t");
lua_pushfixed(L, P_GetMobjGravity(mobj));
return 1;
}
static int lib_pWeaponOrPanel(lua_State *L) static int lib_pWeaponOrPanel(lua_State *L)
{ {
mobjtype_t type = luaL_checkinteger(L, 1); mobjtype_t type = luaL_checkinteger(L, 1);
@ -2008,6 +2018,7 @@ static luaL_Reg lib[] = {
{"P_SPMAngle",lib_pSPMAngle}, {"P_SPMAngle",lib_pSPMAngle},
{"P_SpawnPlayerMissile",lib_pSpawnPlayerMissile}, {"P_SpawnPlayerMissile",lib_pSpawnPlayerMissile},
{"P_MobjFlip",lib_pMobjFlip}, {"P_MobjFlip",lib_pMobjFlip},
{"P_GetMobjGravity",lib_pGetMobjGravity},
{"P_WeaponOrPanel",lib_pWeaponOrPanel}, {"P_WeaponOrPanel",lib_pWeaponOrPanel},
{"P_FlashPal",lib_pFlashPal}, {"P_FlashPal",lib_pFlashPal},
{"P_GetClosestAxis",lib_pGetClosestAxis}, {"P_GetClosestAxis",lib_pGetClosestAxis},

View file

@ -60,7 +60,7 @@ UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which);
#define LUAh_MobjMoveCollide(thing1, thing2) LUAh_MobjCollideHook(thing1, thing2, hook_MobjMoveCollide) // Hook for PIT_CheckThing by (tmthing) mobj type #define LUAh_MobjMoveCollide(thing1, thing2) LUAh_MobjCollideHook(thing1, thing2, hook_MobjMoveCollide) // Hook for PIT_CheckThing by (tmthing) mobj type
boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher); // Hook for P_TouchSpecialThing by mobj type boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher); // Hook for P_TouchSpecialThing by mobj type
#define LUAh_MobjFuse(mo) LUAh_MobjHook(mo, hook_MobjFuse) // Hook for mobj->fuse == 0 by mobj type #define LUAh_MobjFuse(mo) LUAh_MobjHook(mo, hook_MobjFuse) // Hook for mobj->fuse == 0 by mobj type
#define LUAh_MobjThinker(mo) LUAh_MobjHook(mo, hook_MobjThinker) // Hook for P_MobjThinker or P_SceneryThinker by mobj type boolean LUAh_MobjThinker(mobj_t *mo); // Hook for P_MobjThinker or P_SceneryThinker by mobj type
#define LUAh_BossThinker(mo) LUAh_MobjHook(mo, hook_BossThinker) // Hook for P_GenericBossThinker by mobj type #define LUAh_BossThinker(mo) LUAh_MobjHook(mo, hook_BossThinker) // Hook for P_GenericBossThinker by mobj type
UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage); // Hook for P_DamageMobj by mobj type (Should mobj take damage?) UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage); // Hook for P_DamageMobj by mobj type (Should mobj take damage?)
boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage); // Hook for P_DamageMobj by mobj type (Mobj actually takes damage!) boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage); // Hook for P_DamageMobj by mobj type (Mobj actually takes damage!)

View file

@ -74,12 +74,30 @@ typedef struct hook_s* hook_p;
#define FMT_HOOKID "hook_%d" #define FMT_HOOKID "hook_%d"
// For each mobj type, a linked list to its thinker and collision hooks.
// That way, we don't have to iterate through all the hooks.
// We could do that with all other mobj hooks, but it would probably just be
// a waste of memory since they are only called occasionally. Probably...
static hook_p mobjthinkerhooks[NUMMOBJTYPES];
static hook_p mobjcollidehooks[NUMMOBJTYPES];
// For each mobj type, a linked list for other mobj hooks
static hook_p mobjhooks[NUMMOBJTYPES];
// A linked list for player hooks
static hook_p playerhooks;
// A linked list for linedef executor hooks
static hook_p linedefexecutorhooks;
// For other hooks, a unique linked list
hook_p roothook; hook_p roothook;
// Takes hook, function, and additional arguments (mobj type to act on, etc.) // Takes hook, function, and additional arguments (mobj type to act on, etc.)
static int lib_addHook(lua_State *L) static int lib_addHook(lua_State *L)
{ {
static struct hook_s hook = {NULL, 0, 0, {0}, false}; static struct hook_s hook = {NULL, 0, 0, {0}, false};
static UINT32 nextid;
hook_p hookp, *lastp; hook_p hookp, *lastp;
hook.type = luaL_checkoption(L, 1, NULL, hookNames); hook.type = luaL_checkoption(L, 1, NULL, hookNames);
@ -109,6 +127,7 @@ static int lib_addHook(lua_State *L)
hook.s.mt = MT_NULL; hook.s.mt = MT_NULL;
if (lua_isnumber(L, 2)) if (lua_isnumber(L, 2))
hook.s.mt = lua_tonumber(L, 2); hook.s.mt = lua_tonumber(L, 2);
luaL_argcheck(L, hook.s.mt < NUMMOBJTYPES, 2, "invalid mobjtype_t");
break; break;
case hook_BotAI: case hook_BotAI:
hook.s.skinname = NULL; hook.s.skinname = NULL;
@ -141,18 +160,49 @@ static int lib_addHook(lua_State *L)
hooksAvailable[hook.type/8] |= 1<<(hook.type%8); hooksAvailable[hook.type/8] |= 1<<(hook.type%8);
// iterate the hook metadata structs
// set hook.id to the highest id + 1 // set hook.id to the highest id + 1
// set lastp to the last hook struct's "next" pointer. hook.id = nextid++;
lastp = &roothook;
hook.id = 0; // Special cases for some hook types (see the comments above mobjthinkerhooks declaration)
for (hookp = roothook; hookp; hookp = hookp->next) switch(hook.type)
{ {
if (hookp->id >= hook.id) case hook_MobjThinker:
hook.id = hookp->id+1; lastp = &mobjthinkerhooks[hook.s.mt];
lastp = &hookp->next; break;
case hook_MobjCollide:
case hook_MobjMoveCollide:
lastp = &mobjcollidehooks[hook.s.mt];
break;
case hook_MobjSpawn:
case hook_TouchSpecial:
case hook_MobjFuse:
case hook_BossThinker:
case hook_ShouldDamage:
case hook_MobjDamage:
case hook_MobjDeath:
case hook_BossDeath:
case hook_MobjRemoved:
lastp = &mobjhooks[hook.s.mt];
break;
case hook_JumpSpecial:
case hook_AbilitySpecial:
case hook_SpinSpecial:
case hook_JumpSpinSpecial:
case hook_PlayerSpawn:
lastp = &playerhooks;
break;
case hook_LinedefExecute:
lastp = &linedefexecutorhooks;
break;
default:
lastp = &roothook;
break;
} }
// iterate the hook metadata structs
// set lastp to the last hook struct's "next" pointer.
for (hookp = *lastp; hookp; hookp = hookp->next)
lastp = &hookp->next;
// allocate a permanent memory struct to stuff hook. // allocate a permanent memory struct to stuff hook.
hookp = ZZ_Alloc(sizeof(struct hook_s)); hookp = ZZ_Alloc(sizeof(struct hook_s));
memcpy(hookp, &hook, sizeof(struct hook_s)); memcpy(hookp, &hook, sizeof(struct hook_s));
@ -183,9 +233,29 @@ boolean LUAh_MobjHook(mobj_t *mo, enum hook which)
lua_settop(gL, 0); lua_settop(gL, 0);
for (hookp = roothook; hookp; hookp = hookp->next) // Look for all generic mobj hooks
if (hookp->type == which for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next)
&& (hookp->s.mt == MT_NULL || hookp->s.mt == mo->type)) if (hookp->type == which)
{
if (lua_gettop(gL) == 0)
LUA_PushUserdata(gL, mo, META_MOBJ);
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
lua_pushvalue(gL, -2);
if (lua_pcall(gL, 1, 1, 0)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
hookp->error = true;
continue;
}
if (lua_toboolean(gL, -1))
hooked = true;
lua_pop(gL, 1);
}
for (hookp = mobjhooks[mo->type]; hookp; hookp = hookp->next)
if (hookp->type == which)
{ {
if (lua_gettop(gL) == 0) if (lua_gettop(gL) == 0)
LUA_PushUserdata(gL, mo, META_MOBJ); LUA_PushUserdata(gL, mo, META_MOBJ);
@ -217,7 +287,7 @@ boolean LUAh_PlayerHook(player_t *plr, enum hook which)
lua_settop(gL, 0); lua_settop(gL, 0);
for (hookp = roothook; hookp; hookp = hookp->next) for (hookp = playerhooks; hookp; hookp = hookp->next)
if (hookp->type == which) if (hookp->type == which)
{ {
if (lua_gettop(gL) == 0) if (lua_gettop(gL) == 0)
@ -338,9 +408,38 @@ UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which)
lua_settop(gL, 0); lua_settop(gL, 0);
for (hookp = roothook; hookp; hookp = hookp->next) // Look for all generic mobj collision hooks
if (hookp->type == which for (hookp = mobjcollidehooks[MT_NULL]; hookp; hookp = hookp->next)
&& (hookp->s.mt == MT_NULL || hookp->s.mt == thing1->type)) if (hookp->type == which)
{
if (lua_gettop(gL) == 0)
{
LUA_PushUserdata(gL, thing1, META_MOBJ);
LUA_PushUserdata(gL, thing2, META_MOBJ);
}
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
lua_pushvalue(gL, -3);
lua_pushvalue(gL, -3);
if (lua_pcall(gL, 2, 1, 0)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
hookp->error = true;
continue;
}
if (!lua_isnil(gL, -1))
{ // if nil, leave shouldCollide = 0.
if (lua_toboolean(gL, -1))
shouldCollide = 1; // Force yes
else
shouldCollide = 2; // Force no
}
lua_pop(gL, 1);
}
for (hookp = mobjcollidehooks[thing1->type]; hookp; hookp = hookp->next)
if (hookp->type == which)
{ {
if (lua_gettop(gL) == 0) if (lua_gettop(gL) == 0)
{ {
@ -372,6 +471,59 @@ UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which)
return shouldCollide; return shouldCollide;
} }
// Hook for mobj thinkers
boolean LUAh_MobjThinker(mobj_t *mo)
{
hook_p hookp;
boolean hooked = false;
if (!gL || !(hooksAvailable[hook_MobjThinker/8] & (1<<(hook_MobjThinker%8))))
return false;
lua_settop(gL, 0);
// Look for all generic mobj thinker hooks
for (hookp = mobjthinkerhooks[MT_NULL]; hookp; hookp = hookp->next)
{
if (lua_gettop(gL) == 0)
LUA_PushUserdata(gL, mo, META_MOBJ);
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
lua_pushvalue(gL, -2);
if (lua_pcall(gL, 1, 1, 0)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
hookp->error = true;
continue;
}
if (lua_toboolean(gL, -1))
hooked = true;
lua_pop(gL, 1);
}
for (hookp = mobjthinkerhooks[mo->type]; hookp; hookp = hookp->next)
{
if (lua_gettop(gL) == 0)
LUA_PushUserdata(gL, mo, META_MOBJ);
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
lua_pushvalue(gL, -2);
if (lua_pcall(gL, 1, 1, 0)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
hookp->error = true;
continue;
}
if (lua_toboolean(gL, -1))
hooked = true;
lua_pop(gL, 1);
}
lua_settop(gL, 0);
return hooked;
}
// Hook for P_TouchSpecialThing by mobj type // Hook for P_TouchSpecialThing by mobj type
boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher) boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher)
{ {
@ -382,9 +534,33 @@ boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher)
lua_settop(gL, 0); lua_settop(gL, 0);
for (hookp = roothook; hookp; hookp = hookp->next) // Look for all generic touch special hooks
if (hookp->type == hook_TouchSpecial for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next)
&& (hookp->s.mt == MT_NULL || hookp->s.mt == special->type)) if (hookp->type == hook_TouchSpecial)
{
if (lua_gettop(gL) == 0)
{
LUA_PushUserdata(gL, special, META_MOBJ);
LUA_PushUserdata(gL, toucher, META_MOBJ);
}
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
lua_pushvalue(gL, -3);
lua_pushvalue(gL, -3);
if (lua_pcall(gL, 2, 1, 0)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
hookp->error = true;
continue;
}
if (lua_toboolean(gL, -1))
hooked = true;
lua_pop(gL, 1);
}
for (hookp = mobjhooks[special->type]; hookp; hookp = hookp->next)
if (hookp->type == hook_TouchSpecial)
{ {
if (lua_gettop(gL) == 0) if (lua_gettop(gL) == 0)
{ {
@ -421,9 +597,42 @@ UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32
lua_settop(gL, 0); lua_settop(gL, 0);
for (hookp = roothook; hookp; hookp = hookp->next) // Look for all generic should damage hooks
if (hookp->type == hook_ShouldDamage for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next)
&& (hookp->s.mt == MT_NULL || hookp->s.mt == target->type)) if (hookp->type == hook_ShouldDamage)
{
if (lua_gettop(gL) == 0)
{
LUA_PushUserdata(gL, target, META_MOBJ);
LUA_PushUserdata(gL, inflictor, META_MOBJ);
LUA_PushUserdata(gL, source, META_MOBJ);
lua_pushinteger(gL, damage);
}
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
lua_pushvalue(gL, -5);
lua_pushvalue(gL, -5);
lua_pushvalue(gL, -5);
lua_pushvalue(gL, -5);
if (lua_pcall(gL, 4, 1, 0)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
hookp->error = true;
continue;
}
if (!lua_isnil(gL, -1))
{
if (lua_toboolean(gL, -1))
shouldDamage = 1; // Force yes
else
shouldDamage = 2; // Force no
}
lua_pop(gL, 1);
}
for (hookp = mobjhooks[target->type]; hookp; hookp = hookp->next)
if (hookp->type == hook_ShouldDamage)
{ {
if (lua_gettop(gL) == 0) if (lua_gettop(gL) == 0)
{ {
@ -469,9 +678,37 @@ boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32
lua_settop(gL, 0); lua_settop(gL, 0);
for (hookp = roothook; hookp; hookp = hookp->next) // Look for all generic mobj damage hooks
if (hookp->type == hook_MobjDamage for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next)
&& (hookp->s.mt == MT_NULL || hookp->s.mt == target->type)) if (hookp->type == hook_MobjDamage)
{
if (lua_gettop(gL) == 0)
{
LUA_PushUserdata(gL, target, META_MOBJ);
LUA_PushUserdata(gL, inflictor, META_MOBJ);
LUA_PushUserdata(gL, source, META_MOBJ);
lua_pushinteger(gL, damage);
}
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
lua_pushvalue(gL, -5);
lua_pushvalue(gL, -5);
lua_pushvalue(gL, -5);
lua_pushvalue(gL, -5);
if (lua_pcall(gL, 4, 1, 0)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
hookp->error = true;
continue;
}
if (lua_toboolean(gL, -1))
hooked = true;
lua_pop(gL, 1);
}
for (hookp = mobjhooks[target->type]; hookp; hookp = hookp->next)
if (hookp->type == hook_MobjDamage)
{ {
if (lua_gettop(gL) == 0) if (lua_gettop(gL) == 0)
{ {
@ -512,9 +749,35 @@ boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source)
lua_settop(gL, 0); lua_settop(gL, 0);
for (hookp = roothook; hookp; hookp = hookp->next) // Look for all generic mobj death hooks
if (hookp->type == hook_MobjDeath for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next)
&& (hookp->s.mt == MT_NULL || hookp->s.mt == target->type)) if (hookp->type == hook_MobjDeath)
{
if (lua_gettop(gL) == 0)
{
LUA_PushUserdata(gL, target, META_MOBJ);
LUA_PushUserdata(gL, inflictor, META_MOBJ);
LUA_PushUserdata(gL, source, META_MOBJ);
}
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
lua_pushvalue(gL, -4);
lua_pushvalue(gL, -4);
lua_pushvalue(gL, -4);
if (lua_pcall(gL, 3, 1, 0)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
hookp->error = true;
continue;
}
if (lua_toboolean(gL, -1))
hooked = true;
lua_pop(gL, 1);
}
for (hookp = mobjhooks[target->type]; hookp; hookp = hookp->next)
if (hookp->type == hook_MobjDeath)
{ {
if (lua_gettop(gL) == 0) if (lua_gettop(gL) == 0)
{ {
@ -652,9 +915,8 @@ boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector)
lua_settop(gL, 0); lua_settop(gL, 0);
for (hookp = roothook; hookp; hookp = hookp->next) for (hookp = linedefexecutorhooks; hookp; hookp = hookp->next)
if (hookp->type == hook_LinedefExecute if (!strcmp(hookp->s.funcname, line->text))
&& !strcmp(hookp->s.funcname, line->text))
{ {
if (lua_gettop(gL) == 0) if (lua_gettop(gL) == 0)
{ {

View file

@ -18,6 +18,9 @@ enum hud {
hud_time, hud_time,
hud_rings, hud_rings,
hud_lives, hud_lives,
// Match / CTF / Tag / Ringslinger
hud_weaponrings,
hud_powerstones,
// NiGHTS mode // NiGHTS mode
hud_nightslink, hud_nightslink,
hud_nightsdrill, hud_nightsdrill,

View file

@ -44,6 +44,9 @@ static const char *const hud_disable_options[] = {
"rings", "rings",
"lives", "lives",
"weaponrings",
"powerstones",
"nightslink", "nightslink",
"nightsdrill", "nightsdrill",
"nightsrings", "nightsrings",
@ -366,6 +369,8 @@ static int libd_drawScaled(lua_State *L)
x = luaL_checkinteger(L, 1); x = luaL_checkinteger(L, 1);
y = luaL_checkinteger(L, 2); y = luaL_checkinteger(L, 2);
scale = luaL_checkinteger(L, 3); scale = luaL_checkinteger(L, 3);
if (scale < 0)
return luaL_error(L, "negative scale");
patch = *((patch_t **)luaL_checkudata(L, 4, META_PATCH)); patch = *((patch_t **)luaL_checkudata(L, 4, META_PATCH));
flags = luaL_optinteger(L, 5, 0); flags = luaL_optinteger(L, 5, 0);
if (!lua_isnoneornil(L, 6)) if (!lua_isnoneornil(L, 6))

View file

@ -348,22 +348,12 @@ static int sector_get(lua_State *L)
case sector_ceilingheight: case sector_ceilingheight:
lua_pushfixed(L, sector->ceilingheight); lua_pushfixed(L, sector->ceilingheight);
return 1; return 1;
case sector_floorpic: { // floorpic case sector_floorpic: // floorpic
levelflat_t *levelflat; lua_pushlstring(L, levelflats[sector->floorpic].name, 8);
INT16 i;
for (i = 0, levelflat = levelflats; i != sector->floorpic; i++, levelflat++)
;
lua_pushlstring(L, levelflat->name, 8);
return 1; return 1;
} case sector_ceilingpic: // ceilingpic
case sector_ceilingpic: { // ceilingpic lua_pushlstring(L, levelflats[sector->ceilingpic].name, 8);
levelflat_t *levelflat;
INT16 i;
for (i = 0, levelflat = levelflats; i != sector->ceilingpic; i++, levelflat++)
;
lua_pushlstring(L, levelflat->name, 8);
return 1; return 1;
}
case sector_lightlevel: case sector_lightlevel:
lua_pushinteger(L, sector->lightlevel); lua_pushinteger(L, sector->lightlevel);
return 1; return 1;
@ -400,46 +390,6 @@ static int sector_get(lua_State *L)
return 0; return 0;
} }
// help function for P_LoadSectors, find a flat in the active wad files,
// allocate an id for it, and set the levelflat (to speedup search)
//
static INT32 P_AddLevelFlatRuntime(const char *flatname)
{
size_t i;
levelflat_t *levelflat = levelflats;
//
// first scan through the already found flats
//
for (i = 0; i < numlevelflats; i++, levelflat++)
if (strnicmp(levelflat->name,flatname,8)==0)
break;
// that flat was already found in the level, return the id
if (i == numlevelflats)
{
// allocate new flat memory
levelflats = Z_Realloc(levelflats, (numlevelflats + 1) * sizeof(*levelflats), PU_LEVEL, NULL);
levelflat = levelflats+i;
// store the name
strlcpy(levelflat->name, flatname, sizeof (levelflat->name));
strupr(levelflat->name);
// store the flat lump number
levelflat->lumpnum = R_GetFlatNumForName(flatname);
#ifndef ZDEBUG
CONS_Debug(DBG_SETUP, "flat #%03d: %s\n", atoi(sizeu1(numlevelflats)), levelflat->name);
#endif
numlevelflats++;
}
// level flat id
return (INT32)i;
}
static int sector_set(lua_State *L) static int sector_set(lua_State *L)
{ {
sector_t *sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); sector_t *sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR));

View file

@ -59,7 +59,11 @@
* Unconditionally aligning does not cost very much, so do it if unsure * Unconditionally aligning does not cost very much, so do it if unsure
*/ */
#ifndef STRICT_ALIGN #ifndef STRICT_ALIGN
# define STRICT_ALIGN !(defined(__i386) || defined (__amd64)) || defined (__clang__) #if !(defined(__i386) || defined (__amd64)) || defined (__clang__)
#define STRICT_ALIGN 1
#else
#define STRICT_ALIGN 0
#endif
#endif #endif
/* /*

167
src/m_aatree.c Normal file
View file

@ -0,0 +1,167 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2016 by Sonic Team Junior.
//
// 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 m_aatree.h
/// \brief AA trees code
#include "m_aatree.h"
#include "z_zone.h"
// A partial implementation of AA trees,
// according to the algorithms given on Wikipedia.
// http://en.wikipedia.org/wiki/AA_tree
typedef struct aatree_node_s
{
INT32 level;
INT32 key;
void* value;
struct aatree_node_s *left, *right;
} aatree_node_t;
struct aatree_s
{
aatree_node_t *root;
UINT32 flags;
};
aatree_t *M_AATreeAlloc(UINT32 flags)
{
aatree_t *aatree = Z_Malloc(sizeof (aatree_t), PU_STATIC, NULL);
aatree->root = NULL;
aatree->flags = flags;
return aatree;
}
static void M_AATreeFree_Node(aatree_node_t *node)
{
if (node->left) M_AATreeFree_Node(node->left);
if (node->right) M_AATreeFree_Node(node->right);
Z_Free(node);
}
void M_AATreeFree(aatree_t *aatree)
{
if (aatree->root)
M_AATreeFree_Node(aatree->root);
Z_Free(aatree);
}
static aatree_node_t *M_AATreeSkew(aatree_node_t *node)
{
if (node && node->left && node->left->level == node->level)
{
// Not allowed: horizontal left-link. Reverse the
// horizontal link and hook the orphan back in.
aatree_node_t *oldleft = node->left;
node->left = oldleft->right;
oldleft->right = node;
return oldleft;
}
// No change needed.
return node;
}
static aatree_node_t *M_AATreeSplit(aatree_node_t *node)
{
if (node && node->right && node->right->right && node->level == node->right->right->level)
{
// Not allowed: two consecutive horizontal right-links.
// The middle one becomes the new root at this point,
// with suitable adjustments below.
aatree_node_t *oldright = node->right;
node->right = oldright->left;
oldright->left = node;
oldright->level++;
return oldright;
}
// No change needed.
return node;
}
static aatree_node_t *M_AATreeSet_Node(aatree_node_t *node, UINT32 flags, INT32 key, void* value)
{
if (!node)
{
// Nothing here, so just add where we are
node = Z_Malloc(sizeof (aatree_node_t), PU_STATIC, NULL);
node->level = 1;
node->key = key;
if (value && (flags & AATREE_ZUSER)) Z_SetUser(value, &node->value);
else node->value = value;
node->left = node->right = NULL;
}
else
{
if (key < node->key)
node->left = M_AATreeSet_Node(node->left, flags, key, value);
else if (key > node->key)
node->right = M_AATreeSet_Node(node->right, flags, key, value);
else
{
if (value && (flags & AATREE_ZUSER)) Z_SetUser(value, &node->value);
else node->value = value;
}
node = M_AATreeSkew(node);
node = M_AATreeSplit(node);
}
return node;
}
void M_AATreeSet(aatree_t *aatree, INT32 key, void* value)
{
aatree->root = M_AATreeSet_Node(aatree->root, aatree->flags, key, value);
}
// Caveat: we don't distinguish between nodes that don't exists
// and nodes with value == NULL.
static void *M_AATreeGet_Node(aatree_node_t *node, INT32 key)
{
if (node)
{
if (node->key == key)
return node->value;
else if(node->key < key)
return M_AATreeGet_Node(node->right, key);
else
return M_AATreeGet_Node(node->left, key);
}
return NULL;
}
void *M_AATreeGet(aatree_t *aatree, INT32 key)
{
return M_AATreeGet_Node(aatree->root, key);
}
static void M_AATreeIterate_Node(aatree_node_t *node, aatree_iter_t callback)
{
if (node->left) M_AATreeIterate_Node(node->left, callback);
callback(node->key, node->value);
if (node->right) M_AATreeIterate_Node(node->right, callback);
}
void M_AATreeIterate(aatree_t *aatree, aatree_iter_t callback)
{
if (aatree->root)
M_AATreeIterate_Node(aatree->root, callback);
}

31
src/m_aatree.h Normal file
View file

@ -0,0 +1,31 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2016 by Sonic Team Junior.
//
// 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 m_aatree.h
/// \brief AA trees code
#ifndef __M_AATREE__
#define __M_AATREE__
#include "doomtype.h"
// Flags for AA trees.
#define AATREE_ZUSER 1 // Treat values as z_zone-allocated blocks and set their user fields
typedef struct aatree_s aatree_t;
typedef void (*aatree_iter_t)(INT32 key, void *value);
aatree_t *M_AATreeAlloc(UINT32 flags);
void M_AATreeFree(aatree_t *aatree);
void M_AATreeSet(aatree_t *aatree, INT32 key, void* value);
void *M_AATreeGet(aatree_t *aatree, INT32 key);
void M_AATreeIterate(aatree_t *aatree, aatree_iter_t callback);
#endif

View file

@ -452,7 +452,7 @@ void Command_RTeleport_f(void)
else else
inty = 0; inty = 0;
ss = R_PointInSubsector(p->mo->x + intx*FRACUNIT, p->mo->y + inty*FRACUNIT); ss = R_IsPointInSubsector(p->mo->x + intx*FRACUNIT, p->mo->y + inty*FRACUNIT);
if (!ss || ss->sector->ceilingheight - ss->sector->floorheight < p->mo->height) if (!ss || ss->sector->ceilingheight - ss->sector->floorheight < p->mo->height)
{ {
CONS_Alert(CONS_NOTICE, M_GetText("Not a valid location.\n")); CONS_Alert(CONS_NOTICE, M_GetText("Not a valid location.\n"));

View file

@ -46,41 +46,6 @@ typedef INT32 fixed_t;
#define FLOAT_TO_FIXED(f) (fixed_t)((f) * ((float)FRACUNIT)) #define FLOAT_TO_FIXED(f) (fixed_t)((f) * ((float)FRACUNIT))
/** \brief The TMulScale16 function
\param a a parameter of type fixed_t
\param b a parameter of type fixed_t
\param c a parameter of type fixed_t
\param d a parameter of type fixed_t
\param e a parameter of type fixed_t
\param f a parameter of type fixed_t
\return fixed_t
*/
FUNCMATH FUNCINLINE static ATTRINLINE fixed_t TMulScale16(fixed_t a, fixed_t b, fixed_t c, fixed_t d, fixed_t e, fixed_t f) \
{ \
return (fixed_t)((((INT64)a * (INT64)b) + ((INT64)c * (INT64)d) \
+ ((INT64)e * (INT64)f)) >> 16); \
}
/** \brief The DMulScale16 function
\param a a parameter of type fixed_t
\param b a parameter of type fixed_t
\param c a parameter of type fixed_t
\param d a parameter of type fixed_t
\return fixed_t
*/
FUNCMATH FUNCINLINE static ATTRINLINE fixed_t DMulScale16(fixed_t a, fixed_t b, fixed_t c, fixed_t d) \
{ \
return (fixed_t)((((INT64)a * (INT64)b) + ((INT64)c * (INT64)d)) >> 16); \
}
#if defined (__WATCOMC__) && FRACBITS == 16 #if defined (__WATCOMC__) && FRACBITS == 16
#pragma aux FixedMul = \ #pragma aux FixedMul = \
"imul ebx", \ "imul ebx", \
@ -283,9 +248,16 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedFloor(fixed_t x)
{ {
const fixed_t a = abs(x); //absolute of x const fixed_t a = abs(x); //absolute of x
const fixed_t i = (a>>FRACBITS)<<FRACBITS; // cut out the fractional part const fixed_t i = (a>>FRACBITS)<<FRACBITS; // cut out the fractional part
const fixed_t f = i-a; // cut out the integral part const fixed_t f = a-i; // cut out the integral part
if (f == 0)
return x;
if (x != INT32_MIN) if (x != INT32_MIN)
return x-f; // return largest integral value not greater than argument { // return rounded down to nearest whole number
if (x > 0)
return x-f;
else
return x-(FRACUNIT-f);
}
return INT32_MIN; return INT32_MIN;
} }
@ -301,7 +273,7 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedTrunc(fixed_t x)
{ {
const fixed_t a = abs(x); //absolute of x const fixed_t a = abs(x); //absolute of x
const fixed_t i = (a>>FRACBITS)<<FRACBITS; // cut out the fractional part const fixed_t i = (a>>FRACBITS)<<FRACBITS; // cut out the fractional part
const fixed_t f = i-a; // cut out the integral part const fixed_t f = a-i; // cut out the integral part
if (x != INT32_MIN) if (x != INT32_MIN)
{ // return rounded to nearest whole number, towards zero { // return rounded to nearest whole number, towards zero
if (x > 0) if (x > 0)
@ -324,11 +296,18 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedCeil(fixed_t x)
{ {
const fixed_t a = abs(x); //absolute of x const fixed_t a = abs(x); //absolute of x
const fixed_t i = (a>>FRACBITS)<<FRACBITS; // cut out the fractional part const fixed_t i = (a>>FRACBITS)<<FRACBITS; // cut out the fractional part
const fixed_t f = i-a; // cut out the integral part const fixed_t f = a-i; // cut out the integral part
if (f == 0)
return x;
if (x == INT32_MIN) if (x == INT32_MIN)
return INT32_MIN; return INT32_MIN;
else if (x < FixedFloor(INT32_MAX)) else if (x < FixedFloor(INT32_MAX))
return x+(FRACUNIT-f); // return smallest integral value not less than argument { // return rounded up to nearest whole number
if (x > 0)
return x+(FRACUNIT-f);
else
return x+f;
}
return INT32_MAX; return INT32_MAX;
} }
@ -344,7 +323,9 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedRound(fixed_t x)
{ {
const fixed_t a = abs(x); //absolute of x const fixed_t a = abs(x); //absolute of x
const fixed_t i = (a>>FRACBITS)<<FRACBITS; // cut out the fractional part const fixed_t i = (a>>FRACBITS)<<FRACBITS; // cut out the fractional part
const fixed_t f = i-a; // cut out the integral part const fixed_t f = a-i; // cut out the integral part
if (f == 0)
return x;
if (x == INT32_MIN) if (x == INT32_MIN)
return INT32_MIN; return INT32_MIN;
else if (x < FixedFloor(INT32_MAX)) else if (x < FixedFloor(INT32_MAX))

View file

@ -183,9 +183,6 @@ static INT32 vidm_selected = 0;
static INT32 vidm_nummodes; static INT32 vidm_nummodes;
static INT32 vidm_column_size; static INT32 vidm_column_size;
// what a headache.
static boolean shiftdown = false;
// //
// PROTOTYPES // PROTOTYPES
// //
@ -710,7 +707,7 @@ static menuitem_t SP_TimeAttackMenu[] =
{IT_DISABLED, NULL, "Guest Option...", &SP_GuestReplayDef, 100}, {IT_DISABLED, NULL, "Guest Option...", &SP_GuestReplayDef, 100},
{IT_DISABLED, NULL, "Replay...", &SP_ReplayDef, 110}, {IT_DISABLED, NULL, "Replay...", &SP_ReplayDef, 110},
{IT_DISABLED, NULL, "Ghosts...", &SP_GhostDef, 120}, {IT_DISABLED, NULL, "Ghosts...", &SP_GhostDef, 120},
{IT_WHITESTRING|IT_CALL, NULL, "Start", M_ChooseTimeAttack, 130}, {IT_WHITESTRING|IT_CALL|IT_CALL_NOTMODIFIED, NULL, "Start", M_ChooseTimeAttack, 130},
}; };
enum enum
@ -802,7 +799,7 @@ static menuitem_t SP_NightsAttackMenu[] =
{IT_DISABLED, NULL, "Guest Option...", &SP_NightsGuestReplayDef, 108}, {IT_DISABLED, NULL, "Guest Option...", &SP_NightsGuestReplayDef, 108},
{IT_DISABLED, NULL, "Replay...", &SP_NightsReplayDef, 118}, {IT_DISABLED, NULL, "Replay...", &SP_NightsReplayDef, 118},
{IT_DISABLED, NULL, "Ghosts...", &SP_NightsGhostDef, 128}, {IT_DISABLED, NULL, "Ghosts...", &SP_NightsGhostDef, 128},
{IT_WHITESTRING|IT_CALL, NULL, "Start", M_ChooseNightsAttack, 138}, {IT_WHITESTRING|IT_CALL|IT_CALL_NOTMODIFIED, NULL, "Start", M_ChooseNightsAttack, 138},
}; };
enum enum
@ -2085,11 +2082,6 @@ boolean M_Responder(event_t *ev)
|| gamestate == GS_CREDITS || gamestate == GS_EVALUATION) || gamestate == GS_CREDITS || gamestate == GS_EVALUATION)
return false; return false;
if (ev->type == ev_keyup && (ev->data1 == KEY_LSHIFT || ev->data1 == KEY_RSHIFT))
{
shiftdown = false;
return false;
}
if (noFurtherInput) if (noFurtherInput)
{ {
// Ignore input after enter/escape/other buttons // Ignore input after enter/escape/other buttons
@ -2103,10 +2095,6 @@ boolean M_Responder(event_t *ev)
// added 5-2-98 remap virtual keys (mouse & joystick buttons) // added 5-2-98 remap virtual keys (mouse & joystick buttons)
switch (ch) switch (ch)
{ {
case KEY_LSHIFT:
case KEY_RSHIFT:
shiftdown = true;
break; //return false;
case KEY_MOUSE1: case KEY_MOUSE1:
case KEY_JOY1: case KEY_JOY1:
case KEY_JOY1 + 2: case KEY_JOY1 + 2:
@ -3707,6 +3695,11 @@ static void M_DrawMessageMenu(void)
mlines = currentMenu->lastOn>>8; mlines = currentMenu->lastOn>>8;
max = (INT16)((UINT8)(currentMenu->lastOn & 0xFF)*8); max = (INT16)((UINT8)(currentMenu->lastOn & 0xFF)*8);
// hack: draw RA background in RA menus
if (gamestate == GS_TIMEATTACK)
V_DrawPatchFill(W_CachePatchName("SRB2BACK", PU_CACHE));
M_DrawTextBox(currentMenu->x, y - 8, (max+7)>>3, mlines); M_DrawTextBox(currentMenu->x, y - 8, (max+7)>>3, mlines);
while (*(msg+start)) while (*(msg+start))
@ -4315,9 +4308,9 @@ static void M_SinglePlayerMenu(INT32 choice)
{ {
(void)choice; (void)choice;
SP_MainMenu[sprecordattack].status = SP_MainMenu[sprecordattack].status =
(M_SecretUnlocked(SECRET_RECORDATTACK)) ? IT_CALL|IT_STRING|IT_CALL_NOTMODIFIED : IT_SECRET; (M_SecretUnlocked(SECRET_RECORDATTACK)) ? IT_CALL|IT_STRING : IT_SECRET;
SP_MainMenu[spnightsmode].status = SP_MainMenu[spnightsmode].status =
(M_SecretUnlocked(SECRET_NIGHTSMODE)) ? IT_CALL|IT_STRING|IT_CALL_NOTMODIFIED : IT_SECRET; (M_SecretUnlocked(SECRET_NIGHTSMODE)) ? IT_CALL|IT_STRING : IT_SECRET;
M_SetupNextMenu(&SP_MainDef); M_SetupNextMenu(&SP_MainDef);
} }

View file

@ -1675,6 +1675,7 @@ char *M_GetToken(const char *inputString)
|| stringToUse[startPos] == '\r' || stringToUse[startPos] == '\r'
|| stringToUse[startPos] == '\n' || stringToUse[startPos] == '\n'
|| stringToUse[startPos] == '\0' || stringToUse[startPos] == '\0'
|| stringToUse[startPos] == '"' // we're treating this as whitespace because SLADE likes adding it for no good reason
|| inComment != 0) || inComment != 0)
&& startPos < stringLength) && startPos < stringLength)
{ {
@ -1742,6 +1743,7 @@ char *M_GetToken(const char *inputString)
&& stringToUse[endPos] != ',' && stringToUse[endPos] != ','
&& stringToUse[endPos] != '{' && stringToUse[endPos] != '{'
&& stringToUse[endPos] != '}' && stringToUse[endPos] != '}'
&& stringToUse[endPos] != '"' // see above
&& inComment == 0) && inComment == 0)
&& endPos < stringLength) && endPos < stringLength)
{ {
@ -2323,158 +2325,3 @@ void M_SetupMemcpy(void)
M_Memcpy = cpu_cpy; M_Memcpy = cpu_cpy;
#endif #endif
} }
// A partial implementation of AA trees,
// according to the algorithms given on Wikipedia.
// http://en.wikipedia.org/wiki/AA_tree
typedef struct aatree_node_s
{
INT32 level;
INT32 key;
void* value;
struct aatree_node_s *left, *right;
} aatree_node_t;
struct aatree_s
{
aatree_node_t *root;
UINT32 flags;
};
aatree_t *M_AATreeAlloc(UINT32 flags)
{
aatree_t *aatree = Z_Malloc(sizeof (aatree_t), PU_STATIC, NULL);
aatree->root = NULL;
aatree->flags = flags;
return aatree;
}
static void M_AATreeFree_Node(aatree_node_t *node)
{
if (node->left) M_AATreeFree_Node(node->left);
if (node->right) M_AATreeFree_Node(node->right);
Z_Free(node);
}
void M_AATreeFree(aatree_t *aatree)
{
if (aatree->root)
M_AATreeFree_Node(aatree->root);
Z_Free(aatree);
}
static aatree_node_t *M_AATreeSkew(aatree_node_t *node)
{
if (node && node->left && node->left->level == node->level)
{
// Not allowed: horizontal left-link. Reverse the
// horizontal link and hook the orphan back in.
aatree_node_t *oldleft = node->left;
node->left = oldleft->right;
oldleft->right = node;
return oldleft;
}
// No change needed.
return node;
}
static aatree_node_t *M_AATreeSplit(aatree_node_t *node)
{
if (node && node->right && node->right->right && node->level == node->right->right->level)
{
// Not allowed: two consecutive horizontal right-links.
// The middle one becomes the new root at this point,
// with suitable adjustments below.
aatree_node_t *oldright = node->right;
node->right = oldright->left;
oldright->left = node;
oldright->level++;
return oldright;
}
// No change needed.
return node;
}
static aatree_node_t *M_AATreeSet_Node(aatree_node_t *node, UINT32 flags, INT32 key, void* value)
{
if (!node)
{
// Nothing here, so just add where we are
node = Z_Malloc(sizeof (aatree_node_t), PU_STATIC, NULL);
node->level = 1;
node->key = key;
if (value && (flags & AATREE_ZUSER)) Z_SetUser(value, &node->value);
else node->value = value;
node->left = node->right = NULL;
}
else
{
if (key < node->key)
node->left = M_AATreeSet_Node(node->left, flags, key, value);
else if (key > node->key)
node->right = M_AATreeSet_Node(node->right, flags, key, value);
else
{
if (value && (flags & AATREE_ZUSER)) Z_SetUser(value, &node->value);
else node->value = value;
}
node = M_AATreeSkew(node);
node = M_AATreeSplit(node);
}
return node;
}
void M_AATreeSet(aatree_t *aatree, INT32 key, void* value)
{
aatree->root = M_AATreeSet_Node(aatree->root, aatree->flags, key, value);
}
// Caveat: we don't distinguish between nodes that don't exists
// and nodes with value == NULL.
static void *M_AATreeGet_Node(aatree_node_t *node, INT32 key)
{
if (node)
{
if (node->key == key)
return node->value;
else if(node->key < key)
return M_AATreeGet_Node(node->right, key);
else
return M_AATreeGet_Node(node->left, key);
}
return NULL;
}
void *M_AATreeGet(aatree_t *aatree, INT32 key)
{
return M_AATreeGet_Node(aatree->root, key);
}
static void M_AATreeIterate_Node(aatree_node_t *node, aatree_iter_t callback)
{
if (node->left) M_AATreeIterate_Node(node->left, callback);
callback(node->key, node->value);
if (node->right) M_AATreeIterate_Node(node->right, callback);
}
void M_AATreeIterate(aatree_t *aatree, aatree_iter_t callback)
{
if (aatree->root)
M_AATreeIterate_Node(aatree->root, callback);
}

View file

@ -96,19 +96,6 @@ void M_SetupMemcpy(void);
// counting bits, for weapon ammo code, usually // counting bits, for weapon ammo code, usually
FUNCMATH UINT8 M_CountBits(UINT32 num, UINT8 size); FUNCMATH UINT8 M_CountBits(UINT32 num, UINT8 size);
// Flags for AA trees.
#define AATREE_ZUSER 1 // Treat values as z_zone-allocated blocks and set their user fields
typedef struct aatree_s aatree_t;
typedef void (*aatree_iter_t)(INT32 key, void *value);
aatree_t *M_AATreeAlloc(UINT32 flags);
void M_AATreeFree(aatree_t *aatree);
void M_AATreeSet(aatree_t *aatree, INT32 key, void* value);
void *M_AATreeGet(aatree_t *aatree, INT32 key);
void M_AATreeIterate(aatree_t *aatree, aatree_iter_t callback);
// Nasty cyclic dependency workaround. This must come after aatree stuff.
#include "w_wad.h" #include "w_wad.h"
extern char configfile[MAX_WADPATH]; extern char configfile[MAX_WADPATH];

View file

@ -269,6 +269,18 @@ INT32 I_PutEnv(char *variable)
return -1; return -1;
} }
INT32 I_ClipboardCopy(const char *data, size_t size)
{
(void)data;
(void)size;
return -1;
}
char *I_ClipboardPaste(void)
{
return NULL;
}
void I_RegisterSysCommands(void) {} void I_RegisterSysCommands(void) {}
#include "../sdl/dosstr.c" #include "../sdl/dosstr.c"

View file

@ -7717,7 +7717,7 @@ void A_SetObjectFlags(mobj_t *actor)
else if (locvar2 == 1) else if (locvar2 == 1)
locvar1 = actor->flags & ~locvar1; locvar1 = actor->flags & ~locvar1;
if ((locvar1 & (MF_NOBLOCKMAP|MF_NOSECTOR)) != (actor->flags & (MF_NOBLOCKMAP|MF_NOSECTOR))) // Blockmap/sector status has changed, so reset the links if ((UINT32)(locvar1 & (MF_NOBLOCKMAP|MF_NOSECTOR)) != (actor->flags & (MF_NOBLOCKMAP|MF_NOSECTOR))) // Blockmap/sector status has changed, so reset the links
unlinkthings = true; unlinkthings = true;
if (unlinkthings) { if (unlinkthings) {

View file

@ -1164,7 +1164,7 @@ void T_SpikeSector(levelspecthink_t *spikes)
node = spikes->sector->touching_thinglist; // things touching this sector node = spikes->sector->touching_thinglist; // things touching this sector
for (; node; node = node->m_snext) for (; node; node = node->m_thinglist_next)
{ {
thing = node->m_thing; thing = node->m_thing;
if (!thing->player) if (!thing->player)
@ -1317,7 +1317,7 @@ void T_BridgeThinker(levelspecthink_t *bridge)
controlsec = &sectors[k]; controlsec = &sectors[k];
// Is a player standing on me? // Is a player standing on me?
for (node = sector->touching_thinglist; node; node = node->m_snext) for (node = sector->touching_thinglist; node; node = node->m_thinglist_next)
{ {
thing = node->m_thing; thing = node->m_thing;
@ -1740,7 +1740,7 @@ wegotit:
static mobj_t *SearchMarioNode(msecnode_t *node) static mobj_t *SearchMarioNode(msecnode_t *node)
{ {
mobj_t *thing = NULL; mobj_t *thing = NULL;
for (; node; node = node->m_snext) for (; node; node = node->m_thinglist_next)
{ {
// Things which should NEVER be ejected from a MarioBlock, by type. // Things which should NEVER be ejected from a MarioBlock, by type.
switch (node->m_thing->type) switch (node->m_thing->type)
@ -2004,7 +2004,7 @@ void T_NoEnemiesSector(levelspecthink_t *nobaddies)
goto foundenemy; goto foundenemy;
} }
node = node->m_snext; node = node->m_thinglist_next;
} }
} }
} }
@ -2289,7 +2289,7 @@ void T_RaiseSector(levelspecthink_t *raise)
sector = &sectors[i]; sector = &sectors[i];
// Is a player standing on me? // Is a player standing on me?
for (node = sector->touching_thinglist; node; node = node->m_snext) for (node = sector->touching_thinglist; node; node = node->m_thinglist_next)
{ {
thing = node->m_thing; thing = node->m_thing;

View file

@ -1769,7 +1769,7 @@ void P_CheckTimeLimit(void)
return; return;
//Tagmode round end but only on the tic before the //Tagmode round end but only on the tic before the
//XD_EXITLEVEL packet is recieved by all players. //XD_EXITLEVEL packet is received by all players.
if (G_TagGametype()) if (G_TagGametype())
{ {
if (leveltime == (timelimitintics + 1)) if (leveltime == (timelimitintics + 1))
@ -1780,7 +1780,7 @@ void P_CheckTimeLimit(void)
|| (players[i].pflags & PF_TAGGED) || (players[i].pflags & PF_TAGIT)) || (players[i].pflags & PF_TAGGED) || (players[i].pflags & PF_TAGIT))
continue; continue;
CONS_Printf(M_GetText("%s recieved double points for surviving the round.\n"), player_names[i]); CONS_Printf(M_GetText("%s received double points for surviving the round.\n"), player_names[i]);
P_AddPlayerScore(&players[i], players[i].score); P_AddPlayerScore(&players[i], players[i].score);
} }
} }
@ -3819,7 +3819,7 @@ void P_PlayerFlagBurst(player_t *player, boolean toss)
// Flag text // Flag text
{ {
char plname[MAXPLAYERNAME+4]; char plname[MAXPLAYERNAME+4];
char *flagtext; const char *flagtext;
char flagcolor; char flagcolor;
snprintf(plname, sizeof(plname), "%s%s%s", snprintf(plname, sizeof(plname), "%s%s%s",

View file

@ -251,7 +251,8 @@ mobj_t *P_SPMAngle(mobj_t *source, mobjtype_t type, angle_t angle, UINT8 aimtype
#endif #endif
void P_ColorTeamMissile(mobj_t *missile, player_t *source); void P_ColorTeamMissile(mobj_t *missile, player_t *source);
SINT8 P_MobjFlip(mobj_t *mobj); SINT8 P_MobjFlip(mobj_t *mobj);
boolean P_WeaponOrPanel(mobjtype_t type); fixed_t P_GetMobjGravity(mobj_t *mo);
FUNCMATH boolean P_WeaponOrPanel(mobjtype_t type);
boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled); boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled);

View file

@ -130,6 +130,10 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object)
return false; return false;
} }
#ifdef ESLOPE
object->standingslope = NULL; // Okay, now we can't return - no launching off at silly angles for you.
#endif
object->eflags |= MFE_SPRUNG; // apply this flag asap! object->eflags |= MFE_SPRUNG; // apply this flag asap!
spring->flags &= ~(MF_SOLID|MF_SPECIAL); // De-solidify spring->flags &= ~(MF_SOLID|MF_SPECIAL); // De-solidify
@ -235,20 +239,24 @@ static void P_DoFanAndGasJet(mobj_t *spring, mobj_t *object)
if (p && object->state == &states[object->info->painstate]) // can't use fans and gas jets when player is in pain! if (p && object->state == &states[object->info->painstate]) // can't use fans and gas jets when player is in pain!
return; return;
// is object below thruster's position? if not, calculate distance between their bottoms // is object's top below thruster's position? if not, calculate distance between their bottoms
if (spring->eflags & MFE_VERTICALFLIP) if (spring->eflags & MFE_VERTICALFLIP)
{ {
if (object->z + object->height > spring->z + spring->height) if (object->z > spring->z + spring->height)
return; return;
zdist = (spring->z + spring->height) - (object->z + object->height); zdist = (spring->z + spring->height) - (object->z + object->height);
} }
else else
{ {
if (object->z < spring->z) if (object->z + object->height < spring->z)
return; return;
zdist = object->z - spring->z; zdist = object->z - spring->z;
} }
#ifdef ESLOPE
object->standingslope = NULL; // No launching off at silly angles for you.
#endif
switch (spring->type) switch (spring->type)
{ {
case MT_FAN: // fan case MT_FAN: // fan
@ -1515,18 +1523,24 @@ static boolean PIT_CheckThing(mobj_t *thing)
return true; return true;
} }
topz = thing->z - FixedMul(FRACUNIT, thing->scale); topz = thing->z - thing->scale; // FixedMul(FRACUNIT, thing->scale), but thing->scale == FRACUNIT in base scale anyways
// block only when jumping not high enough, // block only when jumping not high enough,
// (dont climb max. 24units while already in air) // (dont climb max. 24units while already in air)
// if not in air, let P_TryMove() decide if it's not too high // since return false doesn't handle momentum properly,
// we lie to P_TryMove() so it's always too high
if (tmthing->player && tmthing->z + tmthing->height > topz if (tmthing->player && tmthing->z + tmthing->height > topz
&& tmthing->z + tmthing->height < tmthing->ceilingz) && tmthing->z + tmthing->height < tmthing->ceilingz)
return false; // block while in air {
tmfloorz = tmceilingz = topz; // block while in air
if (thing->flags & MF_SPRING) #ifdef ESLOPE
tmceilingslope = NULL;
#endif
tmfloorthing = thing; // needed for side collision
}
else if (thing->flags & MF_SPRING)
; ;
else if (topz < tmceilingz && tmthing->z+tmthing->height <= thing->z+thing->height) else if (topz < tmceilingz && tmthing->z <= thing->z+thing->height)
{ {
tmceilingz = topz; tmceilingz = topz;
#ifdef ESLOPE #ifdef ESLOPE
@ -1552,17 +1566,24 @@ static boolean PIT_CheckThing(mobj_t *thing)
return true; return true;
} }
topz = thing->z + thing->height + FixedMul(FRACUNIT, thing->scale); topz = thing->z + thing->height + thing->scale; // FixedMul(FRACUNIT, thing->scale), but thing->scale == FRACUNIT in base scale anyways
// block only when jumping not high enough, // block only when jumping not high enough,
// (dont climb max. 24units while already in air) // (dont climb max. 24units while already in air)
// if not in air, let P_TryMove() decide if it's not too high // since return false doesn't handle momentum properly,
if (tmthing->player && tmthing->z < topz && tmthing->z > tmthing->floorz) // we lie to P_TryMove() so it's always too high
return false; // block while in air if (tmthing->player && tmthing->z < topz
&& tmthing->z > tmthing->floorz)
if (thing->flags & MF_SPRING) {
tmfloorz = tmceilingz = topz; // block while in air
#ifdef ESLOPE
tmfloorslope = NULL;
#endif
tmfloorthing = thing; // needed for side collision
}
else if (thing->flags & MF_SPRING)
; ;
else if (topz > tmfloorz && tmthing->z >= thing->z) else if (topz > tmfloorz && tmthing->z+tmthing->height >= thing->z)
{ {
tmfloorz = topz; tmfloorz = topz;
#ifdef ESLOPE #ifdef ESLOPE
@ -1683,7 +1704,7 @@ static boolean PIT_CheckLine(line_t *ld)
} }
// set openrange, opentop, openbottom // set openrange, opentop, openbottom
P_LineOpening(ld); P_LineOpening(ld, tmthing);
// adjust floor / ceiling heights // adjust floor / ceiling heights
if (opentop < tmceilingz) if (opentop < tmceilingz)
@ -1801,7 +1822,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
topheight = P_GetFOFTopZ(thing, newsubsec->sector, rover, x, y, NULL); topheight = P_GetFOFTopZ(thing, newsubsec->sector, rover, x, y, NULL);
bottomheight = P_GetFOFBottomZ(thing, newsubsec->sector, rover, x, y, NULL); bottomheight = P_GetFOFBottomZ(thing, newsubsec->sector, rover, x, y, NULL);
if (rover->flags & FF_GOOWATER && !(thing->flags & MF_NOGRAVITY)) if ((rover->flags & (FF_SWIMMABLE|FF_GOOWATER)) == (FF_SWIMMABLE|FF_GOOWATER) && !(thing->flags & MF_NOGRAVITY))
{ {
// If you're inside goowater and slowing down // If you're inside goowater and slowing down
fixed_t sinklevel = FixedMul(thing->info->height/6, thing->scale); fixed_t sinklevel = FixedMul(thing->info->height/6, thing->scale);
@ -2502,8 +2523,12 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
} }
// Ramp test // Ramp test
if (thing->player && maxstep > 0 if (maxstep > 0 && !(
&& !(P_PlayerTouchingSectorSpecial(thing->player, 1, 14) || GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 14)) thing->player && (
P_PlayerTouchingSectorSpecial(thing->player, 1, 14)
|| GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 14)
)
)
{ {
// If the floor difference is MAXSTEPMOVE or less, and the sector isn't Section1:14, ALWAYS // If the floor difference is MAXSTEPMOVE or less, and the sector isn't Section1:14, ALWAYS
// step down! Formerly required a Section1:13 sector for the full MAXSTEPMOVE, but no more. // step down! Formerly required a Section1:13 sector for the full MAXSTEPMOVE, but no more.
@ -2963,6 +2988,8 @@ isblocking:
// //
// P_IsClimbingValid // P_IsClimbingValid
// //
// Unlike P_DoClimbing, don't use when up against a one-sided linedef.
//
static boolean P_IsClimbingValid(player_t *player, angle_t angle) static boolean P_IsClimbingValid(player_t *player, angle_t angle)
{ {
fixed_t platx, platy; fixed_t platx, platy;
@ -3111,7 +3138,7 @@ static boolean PTR_SlideTraverse(intercept_t *in)
} }
// set openrange, opentop, openbottom // set openrange, opentop, openbottom
P_LineOpening(li); P_LineOpening(li, slidemo);
if (openrange < slidemo->height) if (openrange < slidemo->height)
goto isblocking; // doesn't fit goto isblocking; // doesn't fit
@ -3187,6 +3214,7 @@ isblocking:
// see about climbing on the wall // see about climbing on the wall
if (!(checkline->flags & ML_NOCLIMB)) if (!(checkline->flags & ML_NOCLIMB))
{ {
boolean canclimb;
angle_t climbangle, climbline; angle_t climbangle, climbline;
INT32 whichside = P_PointOnLineSide(slidemo->x, slidemo->y, li); INT32 whichside = P_PointOnLineSide(slidemo->x, slidemo->y, li);
@ -3197,9 +3225,11 @@ isblocking:
climbangle += (ANGLE_90 * (whichside ? -1 : 1)); climbangle += (ANGLE_90 * (whichside ? -1 : 1));
canclimb = (li->backsector ? P_IsClimbingValid(slidemo->player, climbangle) : true);
if (((!slidemo->player->climbing && abs((signed)(slidemo->angle - ANGLE_90 - climbline)) < ANGLE_45) if (((!slidemo->player->climbing && abs((signed)(slidemo->angle - ANGLE_90 - climbline)) < ANGLE_45)
|| (slidemo->player->climbing == 1 && abs((signed)(slidemo->angle - climbline)) < ANGLE_135)) || (slidemo->player->climbing == 1 && abs((signed)(slidemo->angle - climbline)) < ANGLE_135))
&& P_IsClimbingValid(slidemo->player, climbangle)) && canclimb)
{ {
slidemo->angle = climbangle; slidemo->angle = climbangle;
if (!demoplayback || P_AnalogMove(slidemo->player)) if (!demoplayback || P_AnalogMove(slidemo->player))
@ -3911,7 +3941,7 @@ boolean P_CheckSector(sector_t *sector, boolean crunch)
for (i = 0; i < sector->numattached; i++) for (i = 0; i < sector->numattached; i++)
{ {
sec = &sectors[sector->attached[i]]; sec = &sectors[sector->attached[i]];
for (n = sec->touching_thinglist; n; n = n->m_snext) for (n = sec->touching_thinglist; n; n = n->m_thinglist_next)
n->visited = false; n->visited = false;
sec->moved = true; sec->moved = true;
@ -3923,7 +3953,7 @@ boolean P_CheckSector(sector_t *sector, boolean crunch)
do do
{ {
for (n = sec->touching_thinglist; n; n = n->m_snext) for (n = sec->touching_thinglist; n; n = n->m_thinglist_next)
if (!n->visited) if (!n->visited)
{ {
n->visited = true; n->visited = true;
@ -3944,12 +3974,12 @@ boolean P_CheckSector(sector_t *sector, boolean crunch)
// Mark all things invalid // Mark all things invalid
sector->moved = true; sector->moved = true;
for (n = sector->touching_thinglist; n; n = n->m_snext) for (n = sector->touching_thinglist; n; n = n->m_thinglist_next)
n->visited = false; n->visited = false;
do do
{ {
for (n = sector->touching_thinglist; n; n = n->m_snext) // go through list for (n = sector->touching_thinglist; n; n = n->m_thinglist_next) // go through list
if (!n->visited) // unprocessed thing found if (!n->visited) // unprocessed thing found
{ {
n->visited = true; // mark thing as processed n->visited = true; // mark thing as processed
@ -3973,7 +4003,7 @@ boolean P_CheckSector(sector_t *sector, boolean crunch)
for (i = 0; i < sector->numattached; i++) for (i = 0; i < sector->numattached; i++)
{ {
sec = &sectors[sector->attached[i]]; sec = &sectors[sector->attached[i]];
for (n = sec->touching_thinglist; n; n = n->m_snext) for (n = sec->touching_thinglist; n; n = n->m_thinglist_next)
n->visited = false; n->visited = false;
sec->moved = true; sec->moved = true;
@ -3985,7 +4015,7 @@ boolean P_CheckSector(sector_t *sector, boolean crunch)
do do
{ {
for (n = sec->touching_thinglist; n; n = n->m_snext) for (n = sec->touching_thinglist; n; n = n->m_thinglist_next)
if (!n->visited) if (!n->visited)
{ {
n->visited = true; n->visited = true;
@ -4003,12 +4033,12 @@ boolean P_CheckSector(sector_t *sector, boolean crunch)
// Mark all things invalid // Mark all things invalid
sector->moved = true; sector->moved = true;
for (n = sector->touching_thinglist; n; n = n->m_snext) for (n = sector->touching_thinglist; n; n = n->m_thinglist_next)
n->visited = false; n->visited = false;
do do
{ {
for (n = sector->touching_thinglist; n; n = n->m_snext) // go through list for (n = sector->touching_thinglist; n; n = n->m_thinglist_next) // go through list
if (!n->visited) // unprocessed thing found if (!n->visited) // unprocessed thing found
{ {
n->visited = true; // mark thing as processed n->visited = true; // mark thing as processed
@ -4048,7 +4078,7 @@ static msecnode_t *P_GetSecnode(void)
if (headsecnode) if (headsecnode)
{ {
node = headsecnode; node = headsecnode;
headsecnode = headsecnode->m_snext; headsecnode = headsecnode->m_thinglist_next;
} }
else else
node = Z_Calloc(sizeof (*node), PU_LEVEL, NULL); node = Z_Calloc(sizeof (*node), PU_LEVEL, NULL);
@ -4062,7 +4092,7 @@ static mprecipsecnode_t *P_GetPrecipSecnode(void)
if (headprecipsecnode) if (headprecipsecnode)
{ {
node = headprecipsecnode; node = headprecipsecnode;
headprecipsecnode = headprecipsecnode->m_snext; headprecipsecnode = headprecipsecnode->m_thinglist_next;
} }
else else
node = Z_Calloc(sizeof (*node), PU_LEVEL, NULL); node = Z_Calloc(sizeof (*node), PU_LEVEL, NULL);
@ -4073,14 +4103,14 @@ static mprecipsecnode_t *P_GetPrecipSecnode(void)
static inline void P_PutSecnode(msecnode_t *node) static inline void P_PutSecnode(msecnode_t *node)
{ {
node->m_snext = headsecnode; node->m_thinglist_next = headsecnode;
headsecnode = node; headsecnode = node;
} }
// Tails 08-25-2002 // Tails 08-25-2002
static inline void P_PutPrecipSecnode(mprecipsecnode_t *node) static inline void P_PutPrecipSecnode(mprecipsecnode_t *node)
{ {
node->m_snext = headprecipsecnode; node->m_thinglist_next = headprecipsecnode;
headprecipsecnode = node; headprecipsecnode = node;
} }
@ -4101,7 +4131,7 @@ static msecnode_t *P_AddSecnode(sector_t *s, mobj_t *thing, msecnode_t *nextnode
node->m_thing = thing; // Yes. Setting m_thing says 'keep it'. node->m_thing = thing; // Yes. Setting m_thing says 'keep it'.
return nextnode; return nextnode;
} }
node = node->m_tnext; node = node->m_sectorlist_next;
} }
// Couldn't find an existing node for this sector. Add one at the head // Couldn't find an existing node for this sector. Add one at the head
@ -4114,17 +4144,17 @@ static msecnode_t *P_AddSecnode(sector_t *s, mobj_t *thing, msecnode_t *nextnode
node->m_sector = s; // sector node->m_sector = s; // sector
node->m_thing = thing; // mobj node->m_thing = thing; // mobj
node->m_tprev = NULL; // prev node on Thing thread node->m_sectorlist_prev = NULL; // prev node on Thing thread
node->m_tnext = nextnode; // next node on Thing thread node->m_sectorlist_next = nextnode; // next node on Thing thread
if (nextnode) if (nextnode)
nextnode->m_tprev = node; // set back link on Thing nextnode->m_sectorlist_prev = node; // set back link on Thing
// Add new node at head of sector thread starting at s->touching_thinglist // Add new node at head of sector thread starting at s->touching_thinglist
node->m_sprev = NULL; // prev node on sector thread node->m_thinglist_prev = NULL; // prev node on sector thread
node->m_snext = s->touching_thinglist; // next node on sector thread node->m_thinglist_next = s->touching_thinglist; // next node on sector thread
if (s->touching_thinglist) if (s->touching_thinglist)
node->m_snext->m_sprev = node; node->m_thinglist_next->m_thinglist_prev = node;
s->touching_thinglist = node; s->touching_thinglist = node;
return node; return node;
} }
@ -4142,7 +4172,7 @@ static mprecipsecnode_t *P_AddPrecipSecnode(sector_t *s, precipmobj_t *thing, mp
node->m_thing = thing; // Yes. Setting m_thing says 'keep it'. node->m_thing = thing; // Yes. Setting m_thing says 'keep it'.
return nextnode; return nextnode;
} }
node = node->m_tnext; node = node->m_sectorlist_next;
} }
// Couldn't find an existing node for this sector. Add one at the head // Couldn't find an existing node for this sector. Add one at the head
@ -4155,17 +4185,17 @@ static mprecipsecnode_t *P_AddPrecipSecnode(sector_t *s, precipmobj_t *thing, mp
node->m_sector = s; // sector node->m_sector = s; // sector
node->m_thing = thing; // mobj node->m_thing = thing; // mobj
node->m_tprev = NULL; // prev node on Thing thread node->m_sectorlist_prev = NULL; // prev node on Thing thread
node->m_tnext = nextnode; // next node on Thing thread node->m_sectorlist_next = nextnode; // next node on Thing thread
if (nextnode) if (nextnode)
nextnode->m_tprev = node; // set back link on Thing nextnode->m_sectorlist_prev = node; // set back link on Thing
// Add new node at head of sector thread starting at s->touching_thinglist // Add new node at head of sector thread starting at s->touching_thinglist
node->m_sprev = NULL; // prev node on sector thread node->m_thinglist_prev = NULL; // prev node on sector thread
node->m_snext = s->touching_preciplist; // next node on sector thread node->m_thinglist_next = s->touching_preciplist; // next node on sector thread
if (s->touching_preciplist) if (s->touching_preciplist)
node->m_snext->m_sprev = node; node->m_thinglist_next->m_thinglist_prev = node;
s->touching_preciplist = node; s->touching_preciplist = node;
return node; return node;
} }
@ -4187,24 +4217,24 @@ static msecnode_t *P_DelSecnode(msecnode_t *node)
// Unlink from the Thing thread. The Thing thread begins at // Unlink from the Thing thread. The Thing thread begins at
// sector_list and not from mobj_t->touching_sectorlist. // sector_list and not from mobj_t->touching_sectorlist.
tp = node->m_tprev; tp = node->m_sectorlist_prev;
tn = node->m_tnext; tn = node->m_sectorlist_next;
if (tp) if (tp)
tp->m_tnext = tn; tp->m_sectorlist_next = tn;
if (tn) if (tn)
tn->m_tprev = tp; tn->m_sectorlist_prev = tp;
// Unlink from the sector thread. This thread begins at // Unlink from the sector thread. This thread begins at
// sector_t->touching_thinglist. // sector_t->touching_thinglist.
sp = node->m_sprev; sp = node->m_thinglist_prev;
sn = node->m_snext; sn = node->m_thinglist_next;
if (sp) if (sp)
sp->m_snext = sn; sp->m_thinglist_next = sn;
else else
node->m_sector->touching_thinglist = sn; node->m_sector->touching_thinglist = sn;
if (sn) if (sn)
sn->m_sprev = sp; sn->m_thinglist_prev = sp;
// Return this node to the freelist // Return this node to the freelist
@ -4226,24 +4256,24 @@ static mprecipsecnode_t *P_DelPrecipSecnode(mprecipsecnode_t *node)
// Unlink from the Thing thread. The Thing thread begins at // Unlink from the Thing thread. The Thing thread begins at
// sector_list and not from mobj_t->touching_sectorlist. // sector_list and not from mobj_t->touching_sectorlist.
tp = node->m_tprev; tp = node->m_sectorlist_prev;
tn = node->m_tnext; tn = node->m_sectorlist_next;
if (tp) if (tp)
tp->m_tnext = tn; tp->m_sectorlist_next = tn;
if (tn) if (tn)
tn->m_tprev = tp; tn->m_sectorlist_prev = tp;
// Unlink from the sector thread. This thread begins at // Unlink from the sector thread. This thread begins at
// sector_t->touching_thinglist. // sector_t->touching_thinglist.
sp = node->m_sprev; sp = node->m_thinglist_prev;
sn = node->m_snext; sn = node->m_thinglist_next;
if (sp) if (sp)
sp->m_snext = sn; sp->m_thinglist_next = sn;
else else
node->m_sector->touching_preciplist = sn; node->m_sector->touching_preciplist = sn;
if (sn) if (sn)
sn->m_sprev = sp; sn->m_thinglist_prev = sp;
// Return this node to the freelist // Return this node to the freelist
@ -4358,7 +4388,7 @@ void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y)
while (node) while (node)
{ {
node->m_thing = NULL; node->m_thing = NULL;
node = node->m_tnext; node = node->m_sectorlist_next;
} }
P_SetTarget(&tmthing, thing); P_SetTarget(&tmthing, thing);
@ -4396,11 +4426,11 @@ void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y)
if (!node->m_thing) if (!node->m_thing)
{ {
if (node == sector_list) if (node == sector_list)
sector_list = node->m_tnext; sector_list = node->m_sectorlist_next;
node = P_DelSecnode(node); node = P_DelSecnode(node);
} }
else else
node = node->m_tnext; node = node->m_sectorlist_next;
} }
/* cph - /* cph -
@ -4441,7 +4471,7 @@ void P_CreatePrecipSecNodeList(precipmobj_t *thing,fixed_t x,fixed_t y)
while (node) while (node)
{ {
node->m_thing = NULL; node->m_thing = NULL;
node = node->m_tnext; node = node->m_sectorlist_next;
} }
tmprecipthing = thing; tmprecipthing = thing;
@ -4475,11 +4505,11 @@ void P_CreatePrecipSecNodeList(precipmobj_t *thing,fixed_t x,fixed_t y)
if (!node->m_thing) if (!node->m_thing)
{ {
if (node == precipsector_list) if (node == precipsector_list)
precipsector_list = node->m_tnext; precipsector_list = node->m_sectorlist_next;
node = P_DelPrecipSecnode(node); node = P_DelPrecipSecnode(node);
} }
else else
node = node->m_tnext; node = node->m_sectorlist_next;
} }
/* cph - /* cph -

View file

@ -489,7 +489,7 @@ void P_CameraLineOpening(line_t *linedef)
} }
} }
void P_LineOpening(line_t *linedef) void P_LineOpening(line_t *linedef, mobj_t *mobj)
{ {
sector_t *front, *back; sector_t *front, *back;
@ -520,8 +520,8 @@ void P_LineOpening(line_t *linedef)
{ // Set open and high/low values here { // Set open and high/low values here
fixed_t frontheight, backheight; fixed_t frontheight, backheight;
frontheight = P_GetCeilingZ(tmthing, front, tmx, tmy, linedef); frontheight = P_GetCeilingZ(mobj, front, tmx, tmy, linedef);
backheight = P_GetCeilingZ(tmthing, back, tmx, tmy, linedef); backheight = P_GetCeilingZ(mobj, back, tmx, tmy, linedef);
if (frontheight < backheight) if (frontheight < backheight)
{ {
@ -540,8 +540,8 @@ void P_LineOpening(line_t *linedef)
#endif #endif
} }
frontheight = P_GetFloorZ(tmthing, front, tmx, tmy, linedef); frontheight = P_GetFloorZ(mobj, front, tmx, tmy, linedef);
backheight = P_GetFloorZ(tmthing, back, tmx, tmy, linedef); backheight = P_GetFloorZ(mobj, back, tmx, tmy, linedef);
if (frontheight > backheight) if (frontheight > backheight)
{ {
@ -561,52 +561,65 @@ void P_LineOpening(line_t *linedef)
} }
} }
if (tmthing) if (mobj)
{ {
fixed_t thingtop = tmthing->z + tmthing->height; fixed_t thingtop = mobj->z + mobj->height;
// Check for collision with front side's midtexture if Effect 4 is set // Check for collision with front side's midtexture if Effect 4 is set
if (linedef->flags & ML_EFFECT4) { if (linedef->flags & ML_EFFECT4
&& !linedef->polyobj // don't do anything for polyobjects! ...for now
) {
side_t *side = &sides[linedef->sidenum[0]]; side_t *side = &sides[linedef->sidenum[0]];
fixed_t textop, texbottom, texheight; fixed_t textop, texbottom, texheight;
fixed_t texmid, delta1, delta2; fixed_t texmid, delta1, delta2;
INT32 texnum = R_GetTextureNum(side->midtexture); // make sure the texture is actually valid
// Get the midtexture's height if (texnum) {
texheight = textures[texturetranslation[side->midtexture]]->height << FRACBITS; // Get the midtexture's height
texheight = textures[texnum]->height << FRACBITS;
// Set texbottom and textop to the Z coordinates of the texture's boundaries // Set texbottom and textop to the Z coordinates of the texture's boundaries
#ifdef POLYOBJECTS #if 0 // #ifdef POLYOBJECTS
if (linedef->polyobj && (linedef->polyobj->flags & POF_TESTHEIGHT)) { // don't remove this code unless solid midtextures
if (linedef->flags & ML_DONTPEGBOTTOM) { // on non-solid polyobjects should NEVER happen in the future
texbottom = back->floorheight + side->rowoffset; if (linedef->polyobj && (linedef->polyobj->flags & POF_TESTHEIGHT)) {
textop = texbottom + texheight*(side->repeatcnt+1); if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) { // "infinite" repeat
} else { texbottom = back->floorheight + side->rowoffset;
textop = back->ceilingheight - side->rowoffset; textop = back->ceilingheight + side->rowoffset;
texbottom = textop - texheight*(side->repeatcnt+1); } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) {
} texbottom = back->floorheight + side->rowoffset;
} else textop = texbottom + texheight*(side->repeatcnt+1);
} else {
textop = back->ceilingheight + side->rowoffset;
texbottom = textop - texheight*(side->repeatcnt+1);
}
} else
#endif #endif
{ {
if (linedef->flags & ML_DONTPEGBOTTOM) { if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) { // "infinite" repeat
texbottom = openbottom + side->rowoffset; texbottom = openbottom + side->rowoffset;
textop = texbottom + texheight*(side->repeatcnt+1); textop = opentop + side->rowoffset;
} else { } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) {
textop = opentop - side->rowoffset; texbottom = openbottom + side->rowoffset;
texbottom = textop - texheight*(side->repeatcnt+1); textop = texbottom + texheight*(side->repeatcnt+1);
} else {
textop = opentop + side->rowoffset;
texbottom = textop - texheight*(side->repeatcnt+1);
}
} }
}
texmid = texbottom+(textop-texbottom)/2; texmid = texbottom+(textop-texbottom)/2;
delta1 = abs(tmthing->z - texmid); delta1 = abs(mobj->z - texmid);
delta2 = abs(thingtop - texmid); delta2 = abs(thingtop - texmid);
if (delta1 > delta2) { // Below if (delta1 > delta2) { // Below
if (opentop > texbottom) if (opentop > texbottom)
opentop = texbottom; opentop = texbottom;
} else { // Above } else { // Above
if (openbottom < textop) if (openbottom < textop)
openbottom = textop; openbottom = textop;
}
} }
} }
@ -636,16 +649,16 @@ void P_LineOpening(line_t *linedef)
if (!(rover->flags & FF_EXISTS)) if (!(rover->flags & FF_EXISTS))
continue; continue;
if (tmthing->player && (P_CheckSolidLava(tmthing, rover) || P_CanRunOnWater(tmthing->player, rover))) if (mobj->player && (P_CheckSolidLava(mobj, rover) || P_CanRunOnWater(mobj->player, rover)))
; ;
else if (!((rover->flags & FF_BLOCKPLAYER && tmthing->player) else if (!((rover->flags & FF_BLOCKPLAYER && mobj->player)
|| (rover->flags & FF_BLOCKOTHERS && !tmthing->player))) || (rover->flags & FF_BLOCKOTHERS && !mobj->player)))
continue; continue;
topheight = P_GetFOFTopZ(tmthing, front, rover, tmx, tmy, linedef); topheight = P_GetFOFTopZ(mobj, front, rover, tmx, tmy, linedef);
bottomheight = P_GetFOFBottomZ(tmthing, front, rover, tmx, tmy, linedef); bottomheight = P_GetFOFBottomZ(mobj, front, rover, tmx, tmy, linedef);
delta1 = abs(tmthing->z - (bottomheight + ((topheight - bottomheight)/2))); delta1 = abs(mobj->z - (bottomheight + ((topheight - bottomheight)/2)));
delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2)));
if (delta1 >= delta2 && !(rover->flags & FF_PLATFORM)) // thing is below FOF if (delta1 >= delta2 && !(rover->flags & FF_PLATFORM)) // thing is below FOF
@ -680,16 +693,16 @@ void P_LineOpening(line_t *linedef)
if (!(rover->flags & FF_EXISTS)) if (!(rover->flags & FF_EXISTS))
continue; continue;
if (tmthing->player && (P_CheckSolidLava(tmthing, rover) || P_CanRunOnWater(tmthing->player, rover))) if (mobj->player && (P_CheckSolidLava(mobj, rover) || P_CanRunOnWater(mobj->player, rover)))
; ;
else if (!((rover->flags & FF_BLOCKPLAYER && tmthing->player) else if (!((rover->flags & FF_BLOCKPLAYER && mobj->player)
|| (rover->flags & FF_BLOCKOTHERS && !tmthing->player))) || (rover->flags & FF_BLOCKOTHERS && !mobj->player)))
continue; continue;
topheight = P_GetFOFTopZ(tmthing, back, rover, tmx, tmy, linedef); topheight = P_GetFOFTopZ(mobj, back, rover, tmx, tmy, linedef);
bottomheight = P_GetFOFBottomZ(tmthing, back, rover, tmx, tmy, linedef); bottomheight = P_GetFOFBottomZ(mobj, back, rover, tmx, tmy, linedef);
delta1 = abs(tmthing->z - (bottomheight + ((topheight - bottomheight)/2))); delta1 = abs(mobj->z - (bottomheight + ((topheight - bottomheight)/2)));
delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2)));
if (delta1 >= delta2 && !(rover->flags & FF_PLATFORM)) // thing is below FOF if (delta1 >= delta2 && !(rover->flags & FF_PLATFORM)) // thing is below FOF
@ -723,7 +736,7 @@ void P_LineOpening(line_t *linedef)
{ {
const sector_t *polysec = linedef->backsector; const sector_t *polysec = linedef->backsector;
delta1 = abs(tmthing->z - (polysec->floorheight + ((polysec->ceilingheight - polysec->floorheight)/2))); delta1 = abs(mobj->z - (polysec->floorheight + ((polysec->ceilingheight - polysec->floorheight)/2)));
delta2 = abs(thingtop - (polysec->floorheight + ((polysec->ceilingheight - polysec->floorheight)/2))); delta2 = abs(thingtop - (polysec->floorheight + ((polysec->ceilingheight - polysec->floorheight)/2)));
if (polysec->floorheight < lowestceiling && delta1 >= delta2) { if (polysec->floorheight < lowestceiling && delta1 >= delta2) {
lowestceiling = polysec->floorheight; lowestceiling = polysec->floorheight;

View file

@ -59,7 +59,7 @@ extern fixed_t opentop, openbottom, openrange, lowfloor, highceiling;
extern pslope_t *opentopslope, *openbottomslope; extern pslope_t *opentopslope, *openbottomslope;
#endif #endif
void P_LineOpening(line_t *plinedef); void P_LineOpening(line_t *plinedef, mobj_t *mobj);
boolean P_BlockLinesIterator(INT32 x, INT32 y, boolean(*func)(line_t *)); boolean P_BlockLinesIterator(INT32 x, INT32 y, boolean(*func)(line_t *));
boolean P_BlockThingsIterator(INT32 x, INT32 y, boolean(*func)(mobj_t *)); boolean P_BlockThingsIterator(INT32 x, INT32 y, boolean(*func)(mobj_t *));

View file

@ -890,7 +890,7 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t
testy += y; testy += y;
// If the highest point is in the sector, then we have it easy! Just get the Z at that point // If the highest point is in the sector, then we have it easy! Just get the Z at that point
if (R_PointInSubsector(testx, testy)->sector == (boundsec ?: sector)) if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector))
return P_GetZAt(slope, testx, testy); return P_GetZAt(slope, testx, testy);
// If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point
@ -978,7 +978,7 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed
testy += y; testy += y;
// If the highest point is in the sector, then we have it easy! Just get the Z at that point // If the highest point is in the sector, then we have it easy! Just get the Z at that point
if (R_PointInSubsector(testx, testy)->sector == (boundsec ?: sector)) if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector))
return P_GetZAt(slope, testx, testy); return P_GetZAt(slope, testx, testy);
// If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point
@ -1067,7 +1067,7 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix
testy += y; testy += y;
// If the highest point is in the sector, then we have it easy! Just get the Z at that point // If the highest point is in the sector, then we have it easy! Just get the Z at that point
if (R_PointInSubsector(testx, testy)->sector == (boundsec ?: sector)) if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector))
return P_GetZAt(slope, testx, testy); return P_GetZAt(slope, testx, testy);
// If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point
@ -1155,7 +1155,7 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f
testy += y; testy += y;
// If the highest point is in the sector, then we have it easy! Just get the Z at that point // If the highest point is in the sector, then we have it easy! Just get the Z at that point
if (R_PointInSubsector(testx, testy)->sector == (boundsec ?: sector)) if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector))
return P_GetZAt(slope, testx, testy); return P_GetZAt(slope, testx, testy);
// If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point
@ -1251,13 +1251,12 @@ static void P_PlayerFlip(mobj_t *mo)
} }
// //
// P_CheckGravity // P_GetMobjGravity
// //
// Checks the current gravity state // Returns the current gravity
// of the object. If affect is true, // value of the object.
// a gravity force will be applied.
// //
void P_CheckGravity(mobj_t *mo, boolean affect) fixed_t P_GetMobjGravity(mobj_t *mo)
{ {
fixed_t gravityadd = 0; fixed_t gravityadd = 0;
boolean no3dfloorgrav = true; // Custom gravity boolean no3dfloorgrav = true; // Custom gravity
@ -1278,25 +1277,23 @@ void P_CheckGravity(mobj_t *mo, boolean affect)
for (rover = mo->subsector->sector->ffloors; rover; rover = rover->next) for (rover = mo->subsector->sector->ffloors; rover; rover = rover->next)
{ {
if (!(rover->flags & FF_EXISTS)) if (!(rover->flags & FF_EXISTS) || !P_InsideANonSolidFFloor(mo, rover)) // P_InsideANonSolidFFloor checks for FF_EXISTS itself, but let's not always call this function
continue; continue;
if (P_InsideANonSolidFFloor(mo, rover)) if ((rover->flags & (FF_SWIMMABLE|FF_GOOWATER)) == (FF_SWIMMABLE|FF_GOOWATER))
{ goopgravity = true;
if ((rover->flags & (FF_SWIMMABLE|FF_GOOWATER)) == (FF_SWIMMABLE|FF_GOOWATER))
goopgravity = true;
if (rover->master->frontsector->gravity)
{
gravityadd = -FixedMul(gravity,
(FixedDiv(*rover->master->frontsector->gravity>>FRACBITS, 1000)));
if (rover->master->frontsector->verticalflip && gravityadd > 0) if (!(rover->master->frontsector->gravity))
mo->eflags |= MFE_VERTICALFLIP; continue;
no3dfloorgrav = false; gravityadd = -FixedMul(gravity,
break; (FixedDiv(*rover->master->frontsector->gravity>>FRACBITS, 1000)));
}
} if (rover->master->frontsector->verticalflip && gravityadd > 0)
mo->eflags |= MFE_VERTICALFLIP;
no3dfloorgrav = false;
break;
} }
} }
@ -1316,33 +1313,22 @@ void P_CheckGravity(mobj_t *mo, boolean affect)
if (mo->eflags & MFE_UNDERWATER && !goopgravity) if (mo->eflags & MFE_UNDERWATER && !goopgravity)
gravityadd = gravityadd/3; gravityadd = gravityadd/3;
if (!mo->momz) // mobj at stop, no floor, so feel the push of gravity!
gravityadd <<= 1;
if (mo->player) if (mo->player)
{ {
//if (mo->player->charability == CA_FLY && (mo->player->powers[pw_tailsfly] // SRB2kart //if ((mo->player->pflags & PF_GLIDING)
//|| (mo->state >= &states[S_PLAY_SPC1] && mo->state <= &states[S_PLAY_SPC4]))) //|| (mo->player->charability == CA_FLY && (mo->player->powers[pw_tailsfly]
// gravityadd = gravityadd/3; // less gravity while flying // || (mo->state >= &states[S_PLAY_SPC1] && mo->state <= &states[S_PLAY_SPC4]))))
//if (mo->player->pflags & PF_GLIDING) // gravityadd = gravityadd/3; // less gravity while flying/gliding
// gravityadd = gravityadd/3; // less gravity while gliding if (mo->player->climbing || (mo->player->pflags & PF_NIGHTSMODE))
if (mo->player->climbing)
gravityadd = 0;
if (mo->player->pflags & PF_NIGHTSMODE)
gravityadd = 0; gravityadd = 0;
if (!(mo->flags2 & MF2_OBJECTFLIP) != !(mo->player->powers[pw_gravityboots])) // negated to turn numeric into bool - would be double negated, but not needed if both would be
{ {
UINT8 bits = 0; gravityadd = -gravityadd;
if (mo->flags2 & MF2_OBJECTFLIP) mo->eflags ^= MFE_VERTICALFLIP;
bits ^= 1;
if (mo->player->powers[pw_gravityboots])
bits ^= 1;
if (bits & 1)
{
gravityadd = -gravityadd;
mo->eflags ^= MFE_VERTICALFLIP;
}
} }
if (wasflip == !(mo->eflags & MFE_VERTICALFLIP)) // note!! == ! is not equivalent to != here - turns numeric into bool this way
P_PlayerFlip(mo);
} }
else else
{ {
@ -1350,10 +1336,10 @@ void P_CheckGravity(mobj_t *mo, boolean affect)
if (mo->flags2 & MF2_OBJECTFLIP) if (mo->flags2 & MF2_OBJECTFLIP)
{ {
mo->eflags |= MFE_VERTICALFLIP; mo->eflags |= MFE_VERTICALFLIP;
if (gravityadd < 0) // Don't sink, only rise up
gravityadd *= -1;
if (mo->z + mo->height >= mo->ceilingz) if (mo->z + mo->height >= mo->ceilingz)
gravityadd = 0; gravityadd = 0;
else if (gravityadd < 0) // Don't sink, only rise up
gravityadd *= -1;
} }
else //Otherwise, sort through the other exceptions. else //Otherwise, sort through the other exceptions.
{ {
@ -1399,11 +1385,27 @@ void P_CheckGravity(mobj_t *mo, boolean affect)
if (goopgravity) if (goopgravity)
gravityadd = -gravityadd/5; gravityadd = -gravityadd/5;
if (affect) gravityadd = FixedMul(gravityadd, mo->scale);
mo->momz += FixedMul(gravityadd, mo->scale);
if (mo->player && !!(mo->eflags & MFE_VERTICALFLIP) != wasflip) return gravityadd;
P_PlayerFlip(mo); }
//
// P_CheckGravity
//
// Checks the current gravity state
// of the object. If affect is true,
// a gravity force will be applied.
//
void P_CheckGravity(mobj_t *mo, boolean affect)
{
fixed_t gravityadd = P_GetMobjGravity(mo);
if (!mo->momz) // mobj at stop, no floor, so feel the push of gravity!
gravityadd <<= 1;
if (affect)
mo->momz += gravityadd;
if (mo->type == MT_SKIM && mo->z + mo->momz <= mo->watertop && mo->z >= mo->watertop) if (mo->type == MT_SKIM && mo->z + mo->momz <= mo->watertop && mo->z >= mo->watertop)
{ {
@ -1479,7 +1481,7 @@ static void P_XYFriction(mobj_t *mo, fixed_t oldx, fixed_t oldy)
&& abs(player->rmomy) < FixedMul(STOPSPEED, mo->scale) && abs(player->rmomy) < FixedMul(STOPSPEED, mo->scale)
&& (!(player->cmd.forwardmove && !(twodlevel || mo->flags2 & MF2_TWOD)) && !player->cmd.sidemove && !(player->pflags & PF_SPINNING)) && (!(player->cmd.forwardmove && !(twodlevel || mo->flags2 & MF2_TWOD)) && !player->cmd.sidemove && !(player->pflags & PF_SPINNING))
#ifdef ESLOPE #ifdef ESLOPE
&& !(player->mo->standingslope && abs(player->mo->standingslope->zdelta) >= FRACUNIT/2) && !(player->mo->standingslope && (!(player->mo->standingslope->flags & SL_NOPHYSICS)) && (abs(player->mo->standingslope->zdelta) >= FRACUNIT/2))
#endif #endif
) )
{ {
@ -1529,7 +1531,7 @@ static void P_PushableCheckBustables(mobj_t *mo)
mo->y += mo->momy; mo->y += mo->momy;
P_SetThingPosition(mo); P_SetThingPosition(mo);
for (node = mo->touching_sectorlist; node; node = node->m_snext) for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next)
{ {
if (!node->m_sector) if (!node->m_sector)
break; break;
@ -1537,6 +1539,7 @@ static void P_PushableCheckBustables(mobj_t *mo)
if (node->m_sector->ffloors) if (node->m_sector->ffloors)
{ {
ffloor_t *rover; ffloor_t *rover;
fixed_t topheight, bottomheight;
for (rover = node->m_sector->ffloors; rover; rover = rover->next) for (rover = node->m_sector->ffloors; rover; rover = rover->next)
{ {
@ -1549,37 +1552,39 @@ static void P_PushableCheckBustables(mobj_t *mo)
if (!rover->master->frontsector->crumblestate) if (!rover->master->frontsector->crumblestate)
{ {
topheight = P_GetFOFTopZ(mo, node->m_sector, rover, mo->x, mo->y, NULL);
bottomheight = P_GetFOFBottomZ(mo, node->m_sector, rover, mo->x, mo->y, NULL);
// Height checks // Height checks
if (rover->flags & FF_SHATTERBOTTOM) if (rover->flags & FF_SHATTERBOTTOM)
{ {
if (mo->z+mo->momz + mo->height < *rover->bottomheight) if (mo->z+mo->momz + mo->height < bottomheight)
continue; continue;
if (mo->z+mo->height > *rover->bottomheight) if (mo->z+mo->height > bottomheight)
continue; continue;
} }
else if (rover->flags & FF_SPINBUST) else if (rover->flags & FF_SPINBUST)
{ {
if (mo->z+mo->momz > *rover->topheight) if (mo->z+mo->momz > topheight)
continue; continue;
if (mo->z+mo->height < *rover->bottomheight) if (mo->z+mo->height < bottomheight)
continue; continue;
} }
else if (rover->flags & FF_SHATTER) else if (rover->flags & FF_SHATTER)
{ {
if (mo->z+mo->momz > *rover->topheight) if (mo->z+mo->momz > topheight)
continue; continue;
if (mo->z+mo->momz + mo->height < *rover->bottomheight) if (mo->z+mo->momz + mo->height < bottomheight)
continue; continue;
} }
else else
{ {
if (mo->z >= *rover->topheight) if (mo->z >= topheight)
continue; continue;
if (mo->z+mo->height < *rover->bottomheight) if (mo->z+mo->height < bottomheight)
continue; continue;
} }
@ -1634,8 +1639,6 @@ void P_XYMovement(mobj_t *mo)
I_Assert(mo != NULL); I_Assert(mo != NULL);
I_Assert(!P_MobjWasRemoved(mo)); I_Assert(!P_MobjWasRemoved(mo));
moved = true;
// if it's stopped // if it's stopped
if (!mo->momx && !mo->momy) if (!mo->momx && !mo->momy)
{ {
@ -1692,9 +1695,9 @@ void P_XYMovement(mobj_t *mo)
if (!P_TryMove(mo, mo->x + xmove, mo->y + ymove, true) && !(mo->eflags & MFE_SPRUNG)) if (!P_TryMove(mo, mo->x + xmove, mo->y + ymove, true) && !(mo->eflags & MFE_SPRUNG))
{ {
// blocked move // blocked move
moved = false;
if (player) { if (player) {
moved = false;
if (player->bot) if (player->bot)
B_MoveBlocked(player); B_MoveBlocked(player);
} }
@ -1799,7 +1802,7 @@ void P_XYMovement(mobj_t *mo)
else else
mo->momx = mo->momy = 0; mo->momx = mo->momy = 0;
} }
else if (player) else
moved = true; moved = true;
if (P_MobjWasRemoved(mo)) // MF_SPECIAL touched a player! O_o;; if (P_MobjWasRemoved(mo)) // MF_SPECIAL touched a player! O_o;;
@ -2020,12 +2023,14 @@ static void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motyp
delta1 = mo->z - (bottomheight + ((topheight - bottomheight)/2)); delta1 = mo->z - (bottomheight + ((topheight - bottomheight)/2));
delta2 = thingtop - (bottomheight + ((topheight - bottomheight)/2)); delta2 = thingtop - (bottomheight + ((topheight - bottomheight)/2));
if (topheight > mo->floorz && abs(delta1) < abs(delta2) if (topheight > mo->floorz && abs(delta1) < abs(delta2)
&& !(rover->flags & FF_REVERSEPLATFORM)) && !(rover->flags & FF_REVERSEPLATFORM)
&& ((P_MobjFlip(mo)*mo->momz >= 0) || (!(rover->flags & FF_PLATFORM)))) // In reverse gravity, only clip for FOFs that are intangible from their bottom (the "top" you're falling through) if you're coming from above ("below" in your frame of reference)
{ {
mo->floorz = topheight; mo->floorz = topheight;
} }
if (bottomheight < mo->ceilingz && abs(delta1) >= abs(delta2) if (bottomheight < mo->ceilingz && abs(delta1) >= abs(delta2)
&& !(rover->flags & FF_PLATFORM)) && !(rover->flags & FF_PLATFORM)
&& ((P_MobjFlip(mo)*mo->momz >= 0) || (!(rover->flags & FF_REVERSEPLATFORM)))) // In normal gravity, only clip for FOFs that are intangible from the top if you're coming from below
{ {
mo->ceilingz = bottomheight; mo->ceilingz = bottomheight;
} }
@ -2159,16 +2164,6 @@ static boolean P_ZMovement(mobj_t *mo)
I_Assert(mo != NULL); I_Assert(mo != NULL);
I_Assert(!P_MobjWasRemoved(mo)); I_Assert(!P_MobjWasRemoved(mo));
#ifdef ESLOPE
if (mo->standingslope)
{
if (mo->flags & MF_NOCLIPHEIGHT)
mo->standingslope = NULL;
else if (!P_IsObjectOnGround(mo))
P_SlopeLaunch(mo);
}
#endif
// Intercept the stupid 'fall through 3dfloors' bug // Intercept the stupid 'fall through 3dfloors' bug
if (mo->subsector->sector->ffloors) if (mo->subsector->sector->ffloors)
P_AdjustMobjFloorZ_FFloors(mo, mo->subsector->sector, 0); P_AdjustMobjFloorZ_FFloors(mo, mo->subsector->sector, 0);
@ -2183,6 +2178,16 @@ static boolean P_ZMovement(mobj_t *mo)
} }
mo->z += mo->momz; mo->z += mo->momz;
#ifdef ESLOPE
if (mo->standingslope)
{
if (mo->flags & MF_NOCLIPHEIGHT)
mo->standingslope = NULL;
else if (!P_IsObjectOnGround(mo))
P_SlopeLaunch(mo);
}
#endif
switch (mo->type) switch (mo->type)
{ {
case MT_THROWNBOUNCE: case MT_THROWNBOUNCE:
@ -2252,6 +2257,7 @@ static boolean P_ZMovement(mobj_t *mo)
case MT_BLUETEAMRING: case MT_BLUETEAMRING:
case MT_FLINGRING: case MT_FLINGRING:
case MT_FLINGCOIN: case MT_FLINGCOIN:
case MT_FLINGEMERALD:
case MT_RANDOMITEM: case MT_RANDOMITEM:
// Remove flinged stuff from death pits. // Remove flinged stuff from death pits.
if (P_CheckDeathPitCollide(mo)) if (P_CheckDeathPitCollide(mo))
@ -2284,7 +2290,6 @@ static boolean P_ZMovement(mobj_t *mo)
if (!(mo->momx || mo->momy || mo->momz)) if (!(mo->momx || mo->momy || mo->momz))
return true; return true;
break; break;
case MT_FLINGEMERALD:
case MT_NIGHTSWING: case MT_NIGHTSWING:
if (!(mo->momx || mo->momy || mo->momz)) if (!(mo->momx || mo->momy || mo->momz))
return true; return true;
@ -2366,14 +2371,17 @@ static boolean P_ZMovement(mobj_t *mo)
mo->z = mo->floorz; mo->z = mo->floorz;
#ifdef ESLOPE #ifdef ESLOPE
P_CheckPosition(mo, mo->x, mo->y); // Sets mo->standingslope correctly if (mo->standingslope) // You're still on the ground; why are we here?
if ((mo->eflags & MFE_VERTICALFLIP) ? tmceilingslope : tmfloorslope) { {
mo->standingslope = (mo->eflags & MFE_VERTICALFLIP) ? tmceilingslope : tmfloorslope; mo->momz = 0;
return true;
}
// Reverse quantizing might could use its own function later P_CheckPosition(mo, mo->x, mo->y); // Sets mo->standingslope correctly
mo->standingslope->zangle = ANGLE_MAX-mo->standingslope->zangle; if (((mo->eflags & MFE_VERTICALFLIP) ? tmceilingslope : tmfloorslope) && (mo->type != MT_STEAM))
P_QuantizeMomentumToSlope(&mom, mo->standingslope); {
mo->standingslope->zangle = ANGLE_MAX-mo->standingslope->zangle; mo->standingslope = (mo->eflags & MFE_VERTICALFLIP) ? tmceilingslope : tmfloorslope;
P_ReverseQuantizeMomentumToSlope(&mom, mo->standingslope);
} }
#endif #endif
@ -2526,7 +2534,7 @@ static boolean P_ZMovement(mobj_t *mo)
mom.z = tmfloorthing->momz; mom.z = tmfloorthing->momz;
#ifdef ESLOPE #ifdef ESLOPE
if (mo->standingslope) { if (mo->standingslope) { // MT_STEAM will never have a standingslope, see above.
P_QuantizeMomentumToSlope(&mom, mo->standingslope); P_QuantizeMomentumToSlope(&mom, mo->standingslope);
} }
#endif #endif
@ -2719,7 +2727,7 @@ static void P_PlayerZMovement(mobj_t *mo)
msecnode_t *node; msecnode_t *node;
boolean stopmovecut = false; boolean stopmovecut = false;
for (node = mo->touching_sectorlist; node; node = node->m_snext) for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next)
{ {
sector_t *sec = node->m_sector; sector_t *sec = node->m_sector;
subsector_t *newsubsec; subsector_t *newsubsec;
@ -2925,7 +2933,7 @@ nightsdone:
if (CheckForMarioBlocks && !(netgame && mo->player->spectator)) // Only let the player punch if (CheckForMarioBlocks && !(netgame && mo->player->spectator)) // Only let the player punch
{ {
// Search the touching sectors, from side-to-side... // Search the touching sectors, from side-to-side...
for (node = mo->touching_sectorlist; node; node = node->m_snext) for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next)
{ {
ffloor_t *rover; ffloor_t *rover;
if (!node->m_sector->ffloors) if (!node->m_sector->ffloors)
@ -3697,7 +3705,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj)
if (!(netgame && mobj->player->spectator)) if (!(netgame && mobj->player->spectator))
{ {
// Crumbling platforms // Crumbling platforms
for (node = mobj->touching_sectorlist; node; node = node->m_snext) for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next)
{ {
fixed_t topheight, bottomheight; fixed_t topheight, bottomheight;
ffloor_t *rover; ffloor_t *rover;
@ -3722,7 +3730,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj)
{ {
boolean thereiswater = false; boolean thereiswater = false;
for (node = mobj->touching_sectorlist; node; node = node->m_snext) for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next)
{ {
if (node->m_sector->ffloors) if (node->m_sector->ffloors)
{ {
@ -3743,7 +3751,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj)
} }
if (thereiswater) if (thereiswater)
{ {
for (node = mobj->touching_sectorlist; node; node = node->m_snext) for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next)
{ {
if (node->m_sector->ffloors) if (node->m_sector->ffloors)
{ {
@ -3856,7 +3864,7 @@ void P_RecalcPrecipInSector(sector_t *sector)
sector->moved = true; // Recalc lighting and things too, maybe sector->moved = true; // Recalc lighting and things too, maybe
for (psecnode = sector->touching_preciplist; psecnode; psecnode = psecnode->m_snext) for (psecnode = sector->touching_preciplist; psecnode; psecnode = psecnode->m_thinglist_next)
CalculatePrecipFloor(psecnode->m_thing); CalculatePrecipFloor(psecnode->m_thing);
} }
@ -4477,7 +4485,7 @@ static void P_Boss4MoveSpikeballs(mobj_t *mobj, angle_t angle, fixed_t fz)
{ {
INT32 s; INT32 s;
mobj_t *base = mobj, *seg; mobj_t *base = mobj, *seg;
fixed_t dist, bz = (mobj->spawnpoint->z+16)<<FRACBITS; fixed_t dist, bz = mobj->watertop+(16<<FRACBITS);
while ((base = base->tracer)) while ((base = base->tracer))
{ {
for (seg = base, dist = 172*FRACUNIT, s = 9; seg; seg = seg->hnext, dist += 124*FRACUNIT, --s) for (seg = base, dist = 172*FRACUNIT, s = 9; seg; seg = seg->hnext, dist += 124*FRACUNIT, --s)
@ -4491,7 +4499,7 @@ static void P_Boss4PinchSpikeballs(mobj_t *mobj, angle_t angle, fixed_t fz)
{ {
INT32 s; INT32 s;
mobj_t *base = mobj, *seg; mobj_t *base = mobj, *seg;
fixed_t dist, bz = (mobj->spawnpoint->z+16)<<FRACBITS; fixed_t dist, bz = mobj->watertop+(16<<FRACBITS);
while ((base = base->tracer)) while ((base = base->tracer))
{ {
for (seg = base, dist = 112*FRACUNIT, s = 9; seg; seg = seg->hnext, dist += 132*FRACUNIT, --s) for (seg = base, dist = 112*FRACUNIT, s = 9; seg; seg = seg->hnext, dist += 132*FRACUNIT, --s)
@ -4607,7 +4615,7 @@ static void P_Boss4Thinker(mobj_t *mobj)
INT32 i, arm; INT32 i, arm;
mobj_t *seg, *base = mobj; mobj_t *seg, *base = mobj;
// First frame init, spawn all the things. // First frame init, spawn all the things.
mobj->spawnpoint->z = mobj->z>>FRACBITS; mobj->watertop = mobj->z;
z = mobj->z + mobj->height/2 - mobjinfo[MT_EGGMOBILE4_MACE].height/2; z = mobj->z + mobj->height/2 - mobjinfo[MT_EGGMOBILE4_MACE].height/2;
for (arm = 0; arm <3 ; arm++) for (arm = 0; arm <3 ; arm++)
{ {
@ -4663,7 +4671,7 @@ static void P_Boss4Thinker(mobj_t *mobj)
case 3: case 3:
{ {
fixed_t z; fixed_t z;
if (mobj->z < (mobj->spawnpoint->z+512)<<FRACBITS) if (mobj->z < mobj->watertop+(512<<FRACBITS))
mobj->momz = 8*FRACUNIT; mobj->momz = 8*FRACUNIT;
else else
{ {
@ -4672,7 +4680,7 @@ static void P_Boss4Thinker(mobj_t *mobj)
} }
mobj->movecount += 400<<(FRACBITS>>1); mobj->movecount += 400<<(FRACBITS>>1);
mobj->movecount %= 360*FRACUNIT; mobj->movecount %= 360*FRACUNIT;
z = mobj->z - (mobj->spawnpoint->z<<FRACBITS) - mobjinfo[MT_EGGMOBILE4_MACE].height - mobj->height/2; z = mobj->z - mobj->watertop - mobjinfo[MT_EGGMOBILE4_MACE].height - mobj->height/2;
if (z < 0) // We haven't risen high enough to pull the spikeballs along yet if (z < 0) // We haven't risen high enough to pull the spikeballs along yet
P_Boss4MoveSpikeballs(mobj, FixedAngle(mobj->movecount), 0); // So don't pull the spikeballs along yet. P_Boss4MoveSpikeballs(mobj, FixedAngle(mobj->movecount), 0); // So don't pull the spikeballs along yet.
else else
@ -4682,13 +4690,13 @@ static void P_Boss4Thinker(mobj_t *mobj)
// Pinch phase! // Pinch phase!
case 4: case 4:
{ {
if (mobj->z < (mobj->spawnpoint->z+512+128*(mobj->info->damage-mobj->health))<<FRACBITS) if (mobj->z < (mobj->watertop + ((512+128*(mobj->info->damage-mobj->health))<<FRACBITS)))
mobj->momz = 8*FRACUNIT; mobj->momz = 8*FRACUNIT;
else else
mobj->momz = 0; mobj->momz = 0;
mobj->movecount += (800+800*(mobj->info->damage-mobj->health))<<(FRACBITS>>1); mobj->movecount += (800+800*(mobj->info->damage-mobj->health))<<(FRACBITS>>1);
mobj->movecount %= 360*FRACUNIT; mobj->movecount %= 360*FRACUNIT;
P_Boss4PinchSpikeballs(mobj, FixedAngle(mobj->movecount), mobj->z - (mobj->spawnpoint->z<<FRACBITS) - mobjinfo[MT_EGGMOBILE4_MACE].height - mobj->height/2); P_Boss4PinchSpikeballs(mobj, FixedAngle(mobj->movecount), mobj->z - mobj->watertop - mobjinfo[MT_EGGMOBILE4_MACE].height - mobj->height/2);
if (!mobj->target || !mobj->target->health) if (!mobj->target || !mobj->target->health)
P_SupermanLook4Players(mobj); P_SupermanLook4Players(mobj);
@ -6089,6 +6097,8 @@ void P_RunOverlays(void)
P_UnsetThingPosition(mo); P_UnsetThingPosition(mo);
mo->x = destx; mo->x = destx;
mo->y = desty; mo->y = desty;
mo->radius = mo->target->radius;
mo->height = mo->target->height;
if (mo->eflags & MFE_VERTICALFLIP) if (mo->eflags & MFE_VERTICALFLIP)
mo->z = (mo->target->z + mo->target->height - mo->height) - zoffs; mo->z = (mo->target->z + mo->target->height - mo->height) - zoffs;
else else
@ -7127,6 +7137,7 @@ void P_MobjThinker(mobj_t *mobj)
{ {
mobj->flags &= ~MF_NOGRAVITY; mobj->flags &= ~MF_NOGRAVITY;
P_SetMobjState(mobj, S_NIGHTSDRONE1); P_SetMobjState(mobj, S_NIGHTSDRONE1);
mobj->flags2 |= MF2_DONTDRAW;
} }
} }
else if (mobj->tracer && mobj->tracer->player) else if (mobj->tracer && mobj->tracer->player)
@ -7886,6 +7897,10 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
if (mobj->type == MT_UNIDUS) if (mobj->type == MT_UNIDUS)
mobj->z -= FixedMul(mobj->info->mass, mobj->scale); mobj->z -= FixedMul(mobj->info->mass, mobj->scale);
// defaults onground
if (mobj->z + mobj->height == mobj->ceilingz)
mobj->eflags |= MFE_ONGROUND;
} }
else else
mobj->z = z; mobj->z = z;

View file

@ -441,7 +441,7 @@ boolean P_SupermanLook4Players(mobj_t *actor);
void P_DestroyRobots(void); void P_DestroyRobots(void);
void P_SnowThinker(precipmobj_t *mobj); void P_SnowThinker(precipmobj_t *mobj);
void P_RainThinker(precipmobj_t *mobj); void P_RainThinker(precipmobj_t *mobj);
void P_NullPrecipThinker(precipmobj_t *mobj); FUNCMATH void P_NullPrecipThinker(precipmobj_t *mobj);
void P_RemovePrecipMobj(precipmobj_t *mobj); void P_RemovePrecipMobj(precipmobj_t *mobj);
void P_SetScale(mobj_t *mobj, fixed_t newscale); void P_SetScale(mobj_t *mobj, fixed_t newscale);
void P_XYMovement(mobj_t *mo); void P_XYMovement(mobj_t *mo);

View file

@ -468,6 +468,7 @@ static void P_NetUnArchivePlayers(void)
#define SD_TAG 0x10 #define SD_TAG 0x10
#define SD_FLOORANG 0x20 #define SD_FLOORANG 0x20
#define SD_CEILANG 0x40 #define SD_CEILANG 0x40
#define SD_TAGLIST 0x80
#define LD_FLAG 0x01 #define LD_FLAG 0x01
#define LD_SPECIAL 0x02 #define LD_SPECIAL 0x02
@ -517,10 +518,9 @@ static void P_NetArchiveWorld(void)
// //
// flats // flats
// //
// P_AddLevelFlat should not add but just return the number if (ss->floorpic != P_CheckLevelFlat(ms->floorpic))
if (ss->floorpic != P_AddLevelFlat(ms->floorpic, levelflats))
diff |= SD_FLOORPIC; diff |= SD_FLOORPIC;
if (ss->ceilingpic != P_AddLevelFlat(ms->ceilingpic, levelflats)) if (ss->ceilingpic != P_CheckLevelFlat(ms->ceilingpic))
diff |= SD_CEILPIC; diff |= SD_CEILPIC;
if (ss->lightlevel != SHORT(ms->lightlevel)) if (ss->lightlevel != SHORT(ms->lightlevel))
@ -543,6 +543,8 @@ static void P_NetArchiveWorld(void)
if (ss->tag != SHORT(ms->tag)) if (ss->tag != SHORT(ms->tag))
diff2 |= SD_TAG; diff2 |= SD_TAG;
if (ss->nexttag != ss->spawn_nexttag || ss->firsttag != ss->spawn_firsttag)
diff2 |= SD_TAGLIST;
// Check if any of the sector's FOFs differ from how they spawned // Check if any of the sector's FOFs differ from how they spawned
if (ss->ffloors) if (ss->ffloors)
@ -590,16 +592,17 @@ static void P_NetArchiveWorld(void)
WRITEFIXED(put, ss->ceiling_xoffs); WRITEFIXED(put, ss->ceiling_xoffs);
if (diff2 & SD_CYOFFS) if (diff2 & SD_CYOFFS)
WRITEFIXED(put, ss->ceiling_yoffs); WRITEFIXED(put, ss->ceiling_yoffs);
if (diff2 & SD_TAG) if (diff2 & SD_TAG) // save only the tag
{
WRITEINT16(put, ss->tag); WRITEINT16(put, ss->tag);
WRITEINT32(put, ss->firsttag);
WRITEINT32(put, ss->nexttag);
}
if (diff2 & SD_FLOORANG) if (diff2 & SD_FLOORANG)
WRITEANGLE(put, ss->floorpic_angle); WRITEANGLE(put, ss->floorpic_angle);
if (diff2 & SD_CEILANG) if (diff2 & SD_CEILANG)
WRITEANGLE(put, ss->ceilingpic_angle); WRITEANGLE(put, ss->ceilingpic_angle);
if (diff2 & SD_TAGLIST) // save both firsttag and nexttag
{ // either of these could be changed even if tag isn't
WRITEINT32(put, ss->firsttag);
WRITEINT32(put, ss->nexttag);
}
// Special case: save the stats of all modified ffloors along with their ffloor "number"s // Special case: save the stats of all modified ffloors along with their ffloor "number"s
// we don't bother with ffloors that haven't changed, that would just add to savegame even more than is really needed // we don't bother with ffloors that haven't changed, that would just add to savegame even more than is really needed
@ -760,12 +763,12 @@ static void P_NetUnArchiveWorld(void)
sectors[i].ceilingheight = READFIXED(get); sectors[i].ceilingheight = READFIXED(get);
if (diff & SD_FLOORPIC) if (diff & SD_FLOORPIC)
{ {
sectors[i].floorpic = P_AddLevelFlat((char *)get, levelflats); sectors[i].floorpic = P_AddLevelFlatRuntime((char *)get);
get += 8; get += 8;
} }
if (diff & SD_CEILPIC) if (diff & SD_CEILPIC)
{ {
sectors[i].ceilingpic = P_AddLevelFlat((char *)get, levelflats); sectors[i].ceilingpic = P_AddLevelFlatRuntime((char *)get);
get += 8; get += 8;
} }
if (diff & SD_LIGHT) if (diff & SD_LIGHT)
@ -782,12 +785,11 @@ static void P_NetUnArchiveWorld(void)
if (diff2 & SD_CYOFFS) if (diff2 & SD_CYOFFS)
sectors[i].ceiling_yoffs = READFIXED(get); sectors[i].ceiling_yoffs = READFIXED(get);
if (diff2 & SD_TAG) if (diff2 & SD_TAG)
sectors[i].tag = READINT16(get); // DON'T use P_ChangeSectorTag
if (diff2 & SD_TAGLIST)
{ {
INT16 tag;
tag = READINT16(get);
sectors[i].firsttag = READINT32(get); sectors[i].firsttag = READINT32(get);
sectors[i].nexttag = READINT32(get); sectors[i].nexttag = READINT32(get);
P_ChangeSectorTag(i, tag);
} }
if (diff2 & SD_FLOORANG) if (diff2 & SD_FLOORANG)
sectors[i].floorpic_angle = READANGLE(get); sectors[i].floorpic_angle = READANGLE(get);
@ -2615,6 +2617,7 @@ static void P_NetUnArchiveThinkers(void)
thinker_t *next; thinker_t *next;
UINT8 tclass; UINT8 tclass;
UINT8 restoreNum = false; UINT8 restoreNum = false;
UINT32 i;
if (READUINT32(save_p) != ARCHIVEBLOCK_THINKERS) if (READUINT32(save_p) != ARCHIVEBLOCK_THINKERS)
I_Error("Bad $$$.sav at archive block Thinkers"); I_Error("Bad $$$.sav at archive block Thinkers");
@ -2635,6 +2638,12 @@ static void P_NetUnArchiveThinkers(void)
iquetail = iquehead = 0; iquetail = iquehead = 0;
P_InitThinkers(); P_InitThinkers();
// clear sector thinker pointers so they don't point to non-existant thinkers for all of eternity
for (i = 0; i < numsectors; i++)
{
sectors[i].floordata = sectors[i].ceilingdata = sectors[i].lightingdata = NULL;
}
// read in saved thinkers // read in saved thinkers
for (;;) for (;;)
{ {
@ -3293,7 +3302,7 @@ void P_SaveNetGame(void)
{ {
thinker_t *th; thinker_t *th;
mobj_t *mobj; mobj_t *mobj;
INT32 i = 0; INT32 i = 1; // don't start from 0, it'd be confused with a blank pointer otherwise
CV_SaveNetVars(&save_p); CV_SaveNetVars(&save_p);
P_NetArchiveMisc(); P_NetArchiveMisc();

View file

@ -574,6 +574,69 @@ INT32 P_AddLevelFlat(const char *flatname, levelflat_t *levelflat)
return (INT32)i; return (INT32)i;
} }
// help function for Lua and $$$.sav reading
// same as P_AddLevelFlat, except this is not setup so we must realloc levelflats to fit in the new flat
// no longer a static func in lua_maplib.c because p_saveg.c also needs it
//
INT32 P_AddLevelFlatRuntime(const char *flatname)
{
size_t i;
levelflat_t *levelflat = levelflats;
//
// first scan through the already found flats
//
for (i = 0; i < numlevelflats; i++, levelflat++)
if (strnicmp(levelflat->name,flatname,8)==0)
break;
// that flat was already found in the level, return the id
if (i == numlevelflats)
{
// allocate new flat memory
levelflats = Z_Realloc(levelflats, (numlevelflats + 1) * sizeof(*levelflats), PU_LEVEL, NULL);
levelflat = levelflats+i;
// store the name
strlcpy(levelflat->name, flatname, sizeof (levelflat->name));
strupr(levelflat->name);
// store the flat lump number
levelflat->lumpnum = R_GetFlatNumForName(flatname);
#ifndef ZDEBUG
CONS_Debug(DBG_SETUP, "flat #%03d: %s\n", atoi(sizeu1(numlevelflats)), levelflat->name);
#endif
numlevelflats++;
}
// level flat id
return (INT32)i;
}
// help function for $$$.sav checking
// this simply returns the flat # for the name given
//
INT32 P_CheckLevelFlat(const char *flatname)
{
size_t i;
levelflat_t *levelflat = levelflats;
//
// scan through the already found flats
//
for (i = 0; i < numlevelflats; i++, levelflat++)
if (strnicmp(levelflat->name,flatname,8)==0)
break;
if (i == numlevelflats)
return 0; // ??? flat was not found, this should not happen!
// level flat id
return (INT32)i;
}
static void P_LoadSectors(lumpnum_t lumpnum) static void P_LoadSectors(lumpnum_t lumpnum)
{ {
UINT8 *data; UINT8 *data;
@ -614,6 +677,7 @@ static void P_LoadSectors(lumpnum_t lumpnum)
ss->special = SHORT(ms->special); ss->special = SHORT(ms->special);
ss->tag = SHORT(ms->tag); ss->tag = SHORT(ms->tag);
ss->nexttag = ss->firsttag = -1; ss->nexttag = ss->firsttag = -1;
ss->spawn_nexttag = ss->spawn_firsttag = -1;
memset(&ss->soundorg, 0, sizeof(ss->soundorg)); memset(&ss->soundorg, 0, sizeof(ss->soundorg));
ss->validcount = 0; ss->validcount = 0;
@ -1931,10 +1995,18 @@ static void P_GroupLines(void)
// allocate linebuffers for each sector // allocate linebuffers for each sector
for (i = 0, sector = sectors; i < numsectors; i++, sector++) for (i = 0, sector = sectors; i < numsectors; i++, sector++)
{ {
sector->lines = Z_Calloc(sector->linecount * sizeof(line_t*), PU_LEVEL, NULL); if (sector->linecount == 0) // no lines found?
{
sector->lines = NULL;
CONS_Debug(DBG_SETUP, "P_GroupLines: sector %s has no lines\n", sizeu1(i));
}
else
{
sector->lines = Z_Calloc(sector->linecount * sizeof(line_t*), PU_LEVEL, NULL);
// zero the count, since we'll later use this to track how many we've recorded // zero the count, since we'll later use this to track how many we've recorded
sector->linecount = 0; sector->linecount = 0;
}
} }
// iterate through lines, assigning them to sectors' linebuffers, // iterate through lines, assigning them to sectors' linebuffers,
@ -1952,11 +2024,14 @@ static void P_GroupLines(void)
{ {
M_ClearBox(bbox); M_ClearBox(bbox);
for (j = 0; j < sector->linecount; j++) if (sector->linecount != 0)
{ {
li = sector->lines[j]; for (j = 0; j < sector->linecount; j++)
M_AddToBox(bbox, li->v1->x, li->v1->y); {
M_AddToBox(bbox, li->v2->x, li->v2->y); li = sector->lines[j];
M_AddToBox(bbox, li->v1->x, li->v1->y);
M_AddToBox(bbox, li->v2->x, li->v2->y);
}
} }
// set the degenmobj_t to the middle of the bounding box // set the degenmobj_t to the middle of the bounding box
@ -1966,6 +2041,35 @@ static void P_GroupLines(void)
} }
} }
//
// P_LoadReject
//
// Detect if the REJECT lump is valid,
// if not, rejectmatrix will be NULL
static void P_LoadReject(lumpnum_t lumpnum)
{
size_t count;
const char *lumpname = W_CheckNameForNum(lumpnum);
// Check if the lump exists, and if it's named "REJECT"
if (!lumpname || memcmp(lumpname, "REJECT\0\0", 8) != 0)
{
rejectmatrix = NULL;
CONS_Debug(DBG_SETUP, "P_LoadReject: No valid REJECT lump found\n");
return;
}
count = W_LumpLength(lumpnum);
if (!count) // zero length, someone probably used ZDBSP
{
rejectmatrix = NULL;
CONS_Debug(DBG_SETUP, "P_LoadReject: REJECT lump has size 0, will not be loaded\n");
}
else
rejectmatrix = W_CacheLumpNum(lumpnum, PU_LEVEL);
}
#if 0 #if 0
static char *levellumps[] = static char *levellumps[] =
{ {
@ -2549,11 +2653,7 @@ boolean P_SetupLevel(boolean skipprecip)
lastloadedmaplumpnum = W_GetNumForName(maplumpname = G_BuildMapName(gamemap)); lastloadedmaplumpnum = W_GetNumForName(maplumpname = G_BuildMapName(gamemap));
R_ReInitColormaps(mapheaderinfo[gamemap-1]->palette); R_ReInitColormaps(mapheaderinfo[gamemap-1]->palette);
CON_ReSetupBackColormap(mapheaderinfo[gamemap-1]->palette); CON_SetupBackColormap();
// now part of level loading since in future each level may have
// its own anim texture sequences, switches etc.
P_InitPicAnims();
// SRB2 determines the sky texture to be used depending on the map header. // SRB2 determines the sky texture to be used depending on the map header.
P_SetupLevelSky(mapheaderinfo[gamemap-1]->skynum, true); P_SetupLevelSky(mapheaderinfo[gamemap-1]->skynum, true);
@ -2578,7 +2678,7 @@ boolean P_SetupLevel(boolean skipprecip)
P_LoadSubsectors(lastloadedmaplumpnum + ML_SSECTORS); P_LoadSubsectors(lastloadedmaplumpnum + ML_SSECTORS);
P_LoadNodes(lastloadedmaplumpnum + ML_NODES); P_LoadNodes(lastloadedmaplumpnum + ML_NODES);
P_LoadSegs(lastloadedmaplumpnum + ML_SEGS); P_LoadSegs(lastloadedmaplumpnum + ML_SEGS);
rejectmatrix = W_CacheLumpNum(lastloadedmaplumpnum + ML_REJECT, PU_LEVEL); P_LoadReject(lastloadedmaplumpnum + ML_REJECT);
P_GroupLines(); P_GroupLines();
numdmstarts = numredctfstarts = numbluectfstarts = 0; numdmstarts = numredctfstarts = numbluectfstarts = 0;
@ -2965,6 +3065,9 @@ boolean P_AddWadFile(const char *wadfilename, char **firstmapname)
else else
R_FlushTextureCache(); // just reload it from file R_FlushTextureCache(); // just reload it from file
// Reload ANIMATED / ANIMDEFS
P_InitPicAnims();
// Flush and reload HUD graphics // Flush and reload HUD graphics
ST_UnloadGraphics(); ST_UnloadGraphics();
HU_LoadGraphics(); HU_LoadGraphics();

View file

@ -47,6 +47,8 @@ typedef struct
extern size_t numlevelflats; extern size_t numlevelflats;
extern levelflat_t *levelflats; extern levelflat_t *levelflats;
INT32 P_AddLevelFlat(const char *flatname, levelflat_t *levelflat); INT32 P_AddLevelFlat(const char *flatname, levelflat_t *levelflat);
INT32 P_AddLevelFlatRuntime(const char *flatname);
INT32 P_CheckLevelFlat(const char *flatname);
extern size_t nummapthings; extern size_t nummapthings;
extern mapthing_t *mapthings; extern mapthing_t *mapthings;

View file

@ -325,9 +325,12 @@ boolean P_CheckSight(mobj_t *t1, mobj_t *t2)
s2 = t2->subsector->sector; s2 = t2->subsector->sector;
pnum = (s1-sectors)*numsectors + (s2-sectors); pnum = (s1-sectors)*numsectors + (s2-sectors);
// Check in REJECT table. if (rejectmatrix != NULL)
if (rejectmatrix[pnum>>3] & (1 << (pnum&7))) // can't possibly be connected {
return false; // Check in REJECT table.
if (rejectmatrix[pnum>>3] & (1 << (pnum&7))) // can't possibly be connected
return false;
}
// killough 11/98: shortcut for melee situations // killough 11/98: shortcut for melee situations
// same subsector? obviously visible // same subsector? obviously visible

View file

@ -90,7 +90,7 @@ static void P_ReconfigureVertexSlope(pslope_t *slope)
// Get angles // Get angles
slope->xydirection = R_PointToAngle2(0, 0, slope->d.x, slope->d.y)+ANGLE_180; slope->xydirection = R_PointToAngle2(0, 0, slope->d.x, slope->d.y)+ANGLE_180;
slope->zangle = -R_PointToAngle2(0, 0, FRACUNIT, slope->zdelta); slope->zangle = InvAngle(R_PointToAngle2(0, 0, FRACUNIT, slope->zdelta));
} }
} }
@ -199,7 +199,6 @@ static fixed_t P_GetExtent(sector_t *sector, line_t *line)
// Find furthest vertex from the reference line. It, along with the two ends // Find furthest vertex from the reference line. It, along with the two ends
// of the line, will define the plane. // of the line, will define the plane.
// SRB2CBTODO: Use a formula to get the slope to slide objects depending on how steep
for(i = 0; i < sector->linecount; i++) for(i = 0; i < sector->linecount; i++)
{ {
line_t *li = sector->lines[i]; line_t *li = sector->lines[i];
@ -231,7 +230,6 @@ static fixed_t P_GetExtent(sector_t *sector, line_t *line)
// //
// Creates one or more slopes based on the given line type and front/back // Creates one or more slopes based on the given line type and front/back
// sectors. // sectors.
// Kalaron: Check if dynamic slopes need recalculation
// //
void P_SpawnSlope_Line(int linenum) void P_SpawnSlope_Line(int linenum)
{ {
@ -276,7 +274,6 @@ void P_SpawnSlope_Line(int linenum)
ny = -FixedDiv(line->dx, len); ny = -FixedDiv(line->dx, len);
} }
// SRB2CBTODO: Transform origin relative to the bounds of an individual FOF
origin.x = line->v1->x + (line->v2->x - line->v1->x)/2; origin.x = line->v1->x + (line->v2->x - line->v1->x)/2;
origin.y = line->v1->y + (line->v2->y - line->v1->y)/2; origin.y = line->v1->y + (line->v2->y - line->v1->y)/2;
@ -327,7 +324,7 @@ void P_SpawnSlope_Line(int linenum)
// fslope->normal is a 3D line perpendicular to the 3D vector // fslope->normal is a 3D line perpendicular to the 3D vector
// Sync the linedata of the line that started this slope // Sync the linedata of the line that started this slope
// SRB2CBTODO: Anything special for remote(control sector)-based slopes later? // TODO: Anything special for control sector based slopes later?
fslope->sourceline = line; fslope->sourceline = line;
// To find the real highz/lowz of a slope, you need to check all the vertexes // To find the real highz/lowz of a slope, you need to check all the vertexes
@ -379,7 +376,7 @@ void P_SpawnSlope_Line(int linenum)
cslope->refpos = 2; cslope->refpos = 2;
// Sync the linedata of the line that started this slope // Sync the linedata of the line that started this slope
// SRB2CBTODO: Anything special for remote(control sector)-based slopes later? // TODO: Anything special for control sector based slopes later?
cslope->sourceline = line; cslope->sourceline = line;
// Remember the way the slope is formed // Remember the way the slope is formed
@ -445,7 +442,7 @@ void P_SpawnSlope_Line(int linenum)
fslope->refpos = 3; fslope->refpos = 3;
// Sync the linedata of the line that started this slope // Sync the linedata of the line that started this slope
// SRB2CBTODO: Anything special for remote(control sector)-based slopes later? // TODO: Anything special for control sector based slopes later?
fslope->sourceline = line; fslope->sourceline = line;
// Remember the way the slope is formed // Remember the way the slope is formed
@ -488,7 +485,7 @@ void P_SpawnSlope_Line(int linenum)
cslope->refpos = 4; cslope->refpos = 4;
// Sync the linedata of the line that started this slope // Sync the linedata of the line that started this slope
// SRB2CBTODO: Anything special for remote(control sector)-based slopes later? // TODO: Anything special for control sector based slopes later?
cslope->sourceline = line; cslope->sourceline = line;
// Remember the way the slope is formed // Remember the way the slope is formed
@ -554,16 +551,11 @@ static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag
ret->vertices[2] = mt; ret->vertices[2] = mt;
} }
if (!ret->vertices[0])
CONS_Printf("PANIC 0\n");
if (!ret->vertices[1])
CONS_Printf("PANIC 1\n");
if (!ret->vertices[2])
CONS_Printf("PANIC 2\n");
// Now set heights for each vertex, because they haven't been set yet // Now set heights for each vertex, because they haven't been set yet
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
mt = ret->vertices[i]; mt = ret->vertices[i];
if (!mt) // If a vertex wasn't found, it's game over. There's nothing you can do to recover (except maybe try and kill the slope instead - TODO?)
I_Error("P_NewVertexSlope: Slope vertex %s (for linedef tag %d) not found!", sizeu1(i), tag1);
if (mt->extrainfo) if (mt->extrainfo)
mt->z = mt->options; mt->z = mt->options;
else else
@ -623,265 +615,10 @@ pslope_t *P_SlopeById(UINT16 id)
return ret; return ret;
} }
#ifdef SPRINGCLEAN
#include "byteptr.h"
#include "p_setup.h"
#include "p_local.h"
//==========================================================================
//
// P_SetSlopesFromVertexHeights
//
//==========================================================================
void P_SetSlopesFromVertexHeights(lumpnum_t lumpnum)
{
mapthing_t *mt;
boolean vt_found = false;
size_t i, j, k, l, q;
//size_t i;
//mapthing_t *mt;
char *data;
char *datastart;
// SRB2CBTODO: WHAT IS (5 * sizeof (short))?! It = 10
// anything else seems to make a map not load properly,
// but this hard-coded value MUST have some reason for being what it is
size_t snummapthings = W_LumpLength(lumpnum) / (5 * sizeof (short));
mapthing_t *smapthings = Z_Calloc(snummapthings * sizeof (*smapthings), PU_LEVEL, NULL);
fixed_t x, y;
sector_t *sector;
// Spawn axis points first so they are
// at the front of the list for fast searching.
data = datastart = W_CacheLumpNum(lumpnum, PU_LEVEL);
mt = smapthings;
for (i = 0; i < snummapthings; i++, mt++)
{
mt->x = READINT16(data);
mt->y = READINT16(data);
mt->angle = READINT16(data);
mt->type = READINT16(data);
mt->options = READINT16(data);
// mt->z hasn't been set yet!
//mt->extrainfo = (byte)(mt->type >> 12); // slope things are special, they have a bigger range of types
//mt->type &= 4095; // SRB2CBTODO: WHAT IS THIS???? Mobj type limits?!!!!
x = mt->x*FRACUNIT;
y = mt->y*FRACUNIT;
sector = R_PointInSubsector(x, y)->sector;
// Z for objects
#ifdef ESLOPE
if (sector->f_slope)
mt->z = (short)(P_GetZAt(sector->f_slope, x, y)>>FRACBITS);
else
#endif
mt->z = (short)(sector->floorheight>>FRACBITS);
mt->z = mt->z + (mt->options >> ZSHIFT);
if (mt->type == THING_VertexFloorZ || mt->type == THING_VertexCeilingZ) // THING_VertexFloorZ
{
for(l = 0; l < numvertexes; l++)
{
if (vertexes[l].x == mt->x*FRACUNIT && vertexes[l].y == mt->y*FRACUNIT)
{
if (mt->type == THING_VertexFloorZ)
{
vertexes[l].z = mt->z*FRACUNIT;
//I_Error("Z value: %i", vertexes[l].z/FRACUNIT);
}
else
{
vertexes[l].z = mt->z*FRACUNIT; // celing floor
}
vt_found = true;
}
}
//mt->type = 0; // VPHYSICS: Dynamic slopes
if (vt_found)
{
for (k = 0; k < numsectors; k++)
{
sector_t *sec = &sectors[k];
if (sec->linecount != 3) continue; // only works with triangular sectors
v3float_t vt1, vt2, vt3; // cross = ret->normalf
v3float_t vec1, vec2;
int vi1, vi2, vi3;
vi1 = (int)(sec->lines[0]->v1 - vertexes);
vi2 = (int)(sec->lines[0]->v2 - vertexes);
vi3 = (sec->lines[1]->v1 == sec->lines[0]->v1 || sec->lines[1]->v1 == sec->lines[0]->v2)?
(int)(sec->lines[1]->v2 - vertexes) : (int)(sec->lines[1]->v1 - vertexes);
//if (vertexes[vi1].z)
// I_Error("OSNAP %i", vertexes[vi1].z/FRACUNIT);
//if (vertexes[vi2].z)
// I_Error("OSNAP %i", vertexes[vi2].z/FRACUNIT);
//if (vertexes[vi3].z)
// I_Error("OSNAP %i", vertexes[vi3].z/FRACUNIT);
//I_Error("%i, %i", mt->z*FRACUNIT, vertexes[vi1].z);
//I_Error("%i, %i, %i", mt->x, mt->y, mt->z);
//P_SpawnMobj(mt->x*FRACUNIT, mt->y*FRACUNIT, mt->z*FRACUNIT, MT_RING);
// TODO: Make sure not to spawn in the same place 2x! (we need an object in every vertex of the
// triangle sector to setup the real vertex slopes
// Check for the vertexes of all sectors
for(q = 0; q < numvertexes; q++)
{
if (vertexes[q].x == mt->x*FRACUNIT && vertexes[q].y == mt->y*FRACUNIT)
{
//I_Error("yeah %i", vertexes[q].z);
P_SpawnMobj(vertexes[q].x, vertexes[q].y, vertexes[q].z, MT_RING);
#if 0
if ((mt->y*FRACUNIT == vertexes[vi1].y && mt->x*FRACUNIT == vertexes[vi1].x && mt->z*FRACUNIT == vertexes[vi1].z)
&& !(mt->y*FRACUNIT == vertexes[vi2].y && mt->x*FRACUNIT == vertexes[vi2].x && mt->z*FRACUNIT == vertexes[vi2].z)
&& !(mt->y*FRACUNIT == vertexes[vi3].y && mt->x*FRACUNIT == vertexes[vi3].x && mt->z*FRACUNIT == vertexes[vi3].z))
P_SpawnMobj(vertexes[vi1].x, vertexes[vi1].y, vertexes[vi1].z, MT_RING);
else if ((mt->y*FRACUNIT == vertexes[vi2].y && mt->x*FRACUNIT == vertexes[vi2].x && mt->z*FRACUNIT == vertexes[vi2].z)
&& !(mt->y*FRACUNIT == vertexes[vi1].y && mt->x*FRACUNIT == vertexes[vi1].x && mt->z*FRACUNIT == vertexes[vi1].z)
&& !(mt->y*FRACUNIT == vertexes[vi3].y && mt->x*FRACUNIT == vertexes[vi3].x && mt->z*FRACUNIT == vertexes[vi3].z))
P_SpawnMobj(vertexes[vi2].x, vertexes[vi2].y, vertexes[vi2].z, MT_BOUNCETV);
else if ((mt->y*FRACUNIT == vertexes[vi3].y && mt->x*FRACUNIT == vertexes[vi3].x && mt->z*FRACUNIT == vertexes[vi3].z)
&& !(mt->y*FRACUNIT == vertexes[vi2].y && mt->x*FRACUNIT == vertexes[vi2].x && mt->z*FRACUNIT == vertexes[vi2].z)
&& !(mt->y*FRACUNIT == vertexes[vi1].y && mt->x*FRACUNIT == vertexes[vi1].x && mt->z*FRACUNIT == vertexes[vi1].z))
P_SpawnMobj(vertexes[vi3].x, vertexes[vi3].y, vertexes[vi3].z, MT_GFZFLOWER1);
else
#endif
continue;
}
}
vt1.x = FIXED_TO_FLOAT(vertexes[vi1].x);
vt1.y = FIXED_TO_FLOAT(vertexes[vi1].y);
vt2.x = FIXED_TO_FLOAT(vertexes[vi2].x);
vt2.y = FIXED_TO_FLOAT(vertexes[vi2].y);
vt3.x = FIXED_TO_FLOAT(vertexes[vi3].x);
vt3.y = FIXED_TO_FLOAT(vertexes[vi3].y);
for(j = 0; j < 2; j++)
{
fixed_t z3;
//I_Error("Lo hicimos");
vt1.z = mt->z;//FIXED_TO_FLOAT(j==0 ? sec->floorheight : sec->ceilingheight);
vt2.z = mt->z;//FIXED_TO_FLOAT(j==0? sec->floorheight : sec->ceilingheight);
z3 = mt->z;//j==0? sec->floorheight : sec->ceilingheight; // Destination height
vt3.z = FIXED_TO_FLOAT(z3);
if (P_PointOnLineSide(vertexes[vi3].x, vertexes[vi3].y, sec->lines[0]) == 0)
{
vec1.x = vt2.x - vt3.x;
vec1.y = vt2.y - vt3.y;
vec1.z = vt2.z - vt3.z;
vec2.x = vt1.x - vt3.x;
vec2.y = vt1.y - vt3.y;
vec2.z = vt1.z - vt3.z;
}
else
{
vec1.x = vt1.x - vt3.x;
vec1.y = vt1.y - vt3.y;
vec1.z = vt1.z - vt3.z;
vec2.x = vt2.x - vt3.x;
vec2.y = vt2.y - vt3.y;
vec2.z = vt2.z - vt3.z;
}
pslope_t *ret = Z_Malloc(sizeof(pslope_t), PU_LEVEL, NULL);
memset(ret, 0, sizeof(*ret));
{
M_CrossProduct3f(&ret->normalf, &vec1, &vec2);
// Cross product length
float len = (float)sqrt(ret->normalf.x * ret->normalf.x +
ret->normalf.y * ret->normalf.y +
ret->normalf.z * ret->normalf.z);
if (len == 0)
{
// Only happens when all vertices in this sector are on the same line.
// Let's just ignore this case.
//CONS_Printf("Slope thing at (%d,%d) lies directly on its target line.\n", (int)(x>>16), (int)(y>>16));
return;
}
// cross/len
ret->normalf.x /= len;
ret->normalf.y /= len;
ret->normalf.z /= len;
// ZDoom cross = ret->normalf
// Fix backward normals
if ((ret->normalf.z < 0 && j == 0) || (ret->normalf.z > 0 && j == 1))
{
// cross = -cross
ret->normalf.x = -ret->normalf.x;
ret->normalf.y = -ret->normalf.x;
ret->normalf.z = -ret->normalf.x;
}
}
secplane_t *srcplane = Z_Calloc(sizeof(*srcplane), PU_LEVEL, NULL);
srcplane->a = FLOAT_TO_FIXED (ret->normalf.x);
srcplane->b = FLOAT_TO_FIXED (ret->normalf.y);
srcplane->c = FLOAT_TO_FIXED (ret->normalf.z);
//srcplane->ic = FixedDiv(FRACUNIT, srcplane->c);
srcplane->d = -TMulScale16 (srcplane->a, vertexes[vi3].x,
srcplane->b, vertexes[vi3].y,
srcplane->c, z3);
if (j == 0)
{
sec->f_slope = ret;
sec->f_slope->secplane = *srcplane;
}
else if (j == 1)
{
sec->c_slope = ret;
sec->c_slope->secplane = *srcplane;
}
}
}
}
}
}
Z_Free(datastart);
}
#endif
// Reset the dynamic slopes pointer, and read all of the fancy schmancy slopes // Reset the dynamic slopes pointer, and read all of the fancy schmancy slopes
void P_ResetDynamicSlopes(void) { void P_ResetDynamicSlopes(void) {
size_t i; size_t i;
#if 1 // Rewrite old specials to new ones, and give a console warning #ifdef ESLOPE_TYPESHIM // Rewrite old specials to new ones, and give a console warning
boolean warned = false; boolean warned = false;
#endif #endif
@ -894,7 +631,7 @@ void P_ResetDynamicSlopes(void) {
{ {
switch (lines[i].special) switch (lines[i].special)
{ {
#if 1 // Rewrite old specials to new ones, and give a console warning #ifdef ESLOPE_TYPESHIM // Rewrite old specials to new ones, and give a console warning
#define WARNME if (!warned) {warned = true; CONS_Alert(CONS_WARNING, "This level uses old slope specials.\nA conversion will be needed before 2.2's release.\n");} #define WARNME if (!warned) {warned = true; CONS_Alert(CONS_WARNING, "This level uses old slope specials.\nA conversion will be needed before 2.2's release.\n");}
case 386: case 386:
case 387: case 387:
@ -1018,7 +755,11 @@ fixed_t P_GetZAt(pslope_t *slope, fixed_t x, fixed_t y)
// When given a vector, rotates it and aligns it to a slope // When given a vector, rotates it and aligns it to a slope
void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope) void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope)
{ {
vector3_t axis; vector3_t axis; // Fuck you, C90.
if (slope->flags & SL_NOPHYSICS)
return; // No physics, no quantizing.
axis.x = -slope->d.y; axis.x = -slope->d.y;
axis.y = slope->d.x; axis.y = slope->d.x;
axis.z = 0; axis.z = 0;
@ -1026,24 +767,38 @@ void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope)
FV3_Rotate(momentum, &axis, slope->zangle >> ANGLETOFINESHIFT); FV3_Rotate(momentum, &axis, slope->zangle >> ANGLETOFINESHIFT);
} }
//
// P_ReverseQuantizeMomentumToSlope
//
// When given a vector, rotates and aligns it to a flat surface (from being relative to a given slope)
void P_ReverseQuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope)
{
slope->zangle = InvAngle(slope->zangle);
P_QuantizeMomentumToSlope(momentum, slope);
slope->zangle = InvAngle(slope->zangle);
}
// //
// P_SlopeLaunch // P_SlopeLaunch
// //
// Handles slope ejection for objects // Handles slope ejection for objects
void P_SlopeLaunch(mobj_t *mo) void P_SlopeLaunch(mobj_t *mo)
{ {
// Double the pre-rotation Z, then halve the post-rotation Z. This reduces the if (!(mo->standingslope->flags & SL_NOPHYSICS)) // If there's physics, time for launching.
// vertical launch given from slopes while increasing the horizontal launch {
// given. Good for SRB2's gravity and horizontal speeds. // Double the pre-rotation Z, then halve the post-rotation Z. This reduces the
vector3_t slopemom; // vertical launch given from slopes while increasing the horizontal launch
slopemom.x = mo->momx; // given. Good for SRB2's gravity and horizontal speeds.
slopemom.y = mo->momy; vector3_t slopemom;
slopemom.z = mo->momz*2; slopemom.x = mo->momx;
P_QuantizeMomentumToSlope(&slopemom, mo->standingslope); slopemom.y = mo->momy;
slopemom.z = mo->momz*2;
P_QuantizeMomentumToSlope(&slopemom, mo->standingslope);
mo->momx = slopemom.x; mo->momx = slopemom.x;
mo->momy = slopemom.y; mo->momy = slopemom.y;
mo->momz = slopemom.z/2; mo->momz = slopemom.z/2;
}
//CONS_Printf("Launched off of slope.\n"); //CONS_Printf("Launched off of slope.\n");
mo->standingslope = NULL; mo->standingslope = NULL;
@ -1052,17 +807,21 @@ void P_SlopeLaunch(mobj_t *mo)
// Function to help handle landing on slopes // Function to help handle landing on slopes
void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope)
{ {
vector3_t mom; vector3_t mom; // Ditto.
if (slope->flags & SL_NOPHYSICS) { // No physics, no need to make anything complicated.
if (P_MobjFlip(thing)*(thing->momz) < 0) { // falling, land on slope
thing->momz = -P_MobjFlip(thing);
thing->standingslope = slope;
}
return;
}
mom.x = thing->momx; mom.x = thing->momx;
mom.y = thing->momy; mom.y = thing->momy;
mom.z = thing->momz*2; mom.z = thing->momz*2;
//CONS_Printf("langing on slope\n"); P_ReverseQuantizeMomentumToSlope(&mom, slope);
// Reverse quantizing might could use its own function later
slope->zangle = ANGLE_MAX-slope->zangle;
P_QuantizeMomentumToSlope(&mom, slope);
slope->zangle = ANGLE_MAX-slope->zangle;
if (P_MobjFlip(thing)*mom.z < 0) { // falling, land on slope if (P_MobjFlip(thing)*mom.z < 0) { // falling, land on slope
thing->momx = mom.x; thing->momx = mom.x;
@ -1082,6 +841,9 @@ void P_ButteredSlope(mobj_t *mo)
if (!mo->standingslope) if (!mo->standingslope)
return; return;
if (mo->standingslope->flags & SL_NOPHYSICS)
return; // No physics, no butter.
if (mo->flags & (MF_NOCLIPHEIGHT|MF_NOGRAVITY)) if (mo->flags & (MF_NOCLIPHEIGHT|MF_NOGRAVITY))
return; // don't slide down slopes if you can't touch them or you're not affected by gravity return; // don't slide down slopes if you can't touch them or you're not affected by gravity
@ -1106,8 +868,6 @@ void P_ButteredSlope(mobj_t *mo)
mult = FINECOSINE(angle >> ANGLETOFINESHIFT); mult = FINECOSINE(angle >> ANGLETOFINESHIFT);
} }
//CONS_Printf("%d\n", mult);
thrust = FixedMul(thrust, FRACUNIT*2/3 + mult/8); thrust = FixedMul(thrust, FRACUNIT*2/3 + mult/8);
} }
@ -1115,10 +875,11 @@ void P_ButteredSlope(mobj_t *mo)
thrust = FixedMul(thrust, FRACUNIT+P_AproxDistance(mo->momx, mo->momy)/16); thrust = FixedMul(thrust, FRACUNIT+P_AproxDistance(mo->momx, mo->momy)/16);
// This makes it harder to zigzag up steep slopes, as well as allows greater top speed when rolling down // This makes it harder to zigzag up steep slopes, as well as allows greater top speed when rolling down
// Multiply by gravity // Let's get the gravity strength for the object...
thrust = FixedMul(thrust, gravity); // TODO account for per-sector gravity etc thrust = FixedMul(thrust, abs(P_GetMobjGravity(mo)));
// Multiply by scale (gravity strength depends on mobj scale)
thrust = FixedMul(thrust, mo->scale); // ... and its friction against the ground for good measure (divided by original friction to keep behaviour for normal slopes the same).
thrust = FixedMul(thrust, FixedDiv(mo->friction, ORIG_FRICTION));
P_Thrust(mo, mo->standingslope->xydirection, thrust); P_Thrust(mo, mo->standingslope->xydirection, thrust);
} }

View file

@ -21,26 +21,6 @@ void P_RunDynamicSlopes(void);
// sectors. // sectors.
void P_SpawnSlope_Line(int linenum); void P_SpawnSlope_Line(int linenum);
#ifdef SPRINGCLEAN
// Loads just map objects that make slopes,
// terrain affecting objects have to be spawned first
void P_SetSlopesFromVertexHeights(lumpnum_t lumpnum);
typedef enum
{
THING_SlopeFloorPointLine = 9500,
THING_SlopeCeilingPointLine = 9501,
THING_SetFloorSlope = 9502,
THING_SetCeilingSlope = 9503,
THING_CopyFloorPlane = 9510,
THING_CopyCeilingPlane = 9511,
THING_VavoomFloor=1500,
THING_VavoomCeiling=1501,
THING_VertexFloorZ=1504,
THING_VertexCeilingZ=1505,
} slopething_e;
#endif
// //
// P_CopySectorSlope // P_CopySectorSlope
// //
@ -55,6 +35,7 @@ fixed_t P_GetZAt(pslope_t *slope, fixed_t x, fixed_t y);
// Lots of physics-based bullshit // Lots of physics-based bullshit
void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope); void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope);
void P_ReverseQuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope);
void P_SlopeLaunch(mobj_t *mo); void P_SlopeLaunch(mobj_t *mo);
void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope); void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope);
void P_ButteredSlope(mobj_t *mo); void P_ButteredSlope(mobj_t *mo);

View file

@ -226,8 +226,8 @@ static animdef_t harddefs[] =
static animdef_t *animdefs = NULL; static animdef_t *animdefs = NULL;
// A prototype; here instead of p_spec.h, so they're "private" // A prototype; here instead of p_spec.h, so they're "private"
void P_ParseANIMDEFSLump(INT32 wadNum, UINT16 lumpnum, INT32 *i); void P_ParseANIMDEFSLump(INT32 wadNum, UINT16 lumpnum);
void P_ParseAnimationDefintion(SINT8 istexture, INT32 *i); void P_ParseAnimationDefintion(SINT8 istexture);
/** Sets up texture and flat animations. /** Sets up texture and flat animations.
* *
@ -237,24 +237,21 @@ void P_ParseAnimationDefintion(SINT8 istexture, INT32 *i);
* Issues an error if any animation cycles are invalid. * Issues an error if any animation cycles are invalid.
* *
* \sa P_FindAnimatedFlat, P_SetupLevelFlatAnims * \sa P_FindAnimatedFlat, P_SetupLevelFlatAnims
* \author Steven McGranahan (original), Shadow Hog (had to rewrite it to handle multiple WADs) * \author Steven McGranahan (original), Shadow Hog (had to rewrite it to handle multiple WADs), JTE (had to rewrite it to handle multiple WADs _correctly_)
*/ */
void P_InitPicAnims(void) void P_InitPicAnims(void)
{ {
// Init animation // Init animation
INT32 i; // Position in the animdefs array
INT32 w; // WAD INT32 w; // WAD
UINT8 *wadAnimdefs; // not to be confused with animdefs, the combined total of every ANIMATED lump in every WAD, or ANIMDEFS, the ZDoom lump I intend to implement later UINT8 *animatedLump;
UINT8 *currentPos; UINT8 *currentPos;
size_t i;
I_Assert(animdefs == NULL);
if (W_CheckNumForName("ANIMATED") != LUMPERROR || W_CheckNumForName("ANIMDEFS") != LUMPERROR) if (W_CheckNumForName("ANIMATED") != LUMPERROR || W_CheckNumForName("ANIMDEFS") != LUMPERROR)
{ {
if (animdefs) for (w = numwadfiles-1, maxanims = 0; w >= 0; w--)
{
Z_Free(animdefs);
animdefs = NULL;
}
for (w = 0, i = 0, maxanims = 0; w < numwadfiles; w++)
{ {
UINT16 animatedLumpNum; UINT16 animatedLumpNum;
UINT16 animdefsLumpNum; UINT16 animdefsLumpNum;
@ -263,20 +260,20 @@ void P_InitPicAnims(void)
animatedLumpNum = W_CheckNumForNamePwad("ANIMATED", w, 0); animatedLumpNum = W_CheckNumForNamePwad("ANIMATED", w, 0);
if (animatedLumpNum != INT16_MAX) if (animatedLumpNum != INT16_MAX)
{ {
wadAnimdefs = (UINT8 *)W_CacheLumpNumPwad(w, animatedLumpNum, PU_STATIC); animatedLump = (UINT8 *)W_CacheLumpNumPwad(w, animatedLumpNum, PU_STATIC);
// Get the number of animations in the file // Get the number of animations in the file
for (currentPos = wadAnimdefs; *currentPos != UINT8_MAX; maxanims++, currentPos+=23); i = maxanims;
for (currentPos = animatedLump; *currentPos != UINT8_MAX; maxanims++, currentPos+=23);
// Resize animdefs (or if it hasn't been created, create it) // Resize animdefs (or if it hasn't been created, create it)
animdefs = (animdef_t *)Z_Realloc(animdefs, sizeof(animdef_t)*(maxanims + 1), PU_STATIC, NULL); animdefs = (animdef_t *)Z_Realloc(animdefs, sizeof(animdef_t)*(maxanims + 1), PU_STATIC, NULL);
// Sanity check it // Sanity check it
if (!animdefs) { if (!animdefs)
I_Error("Not enough free memory for ANIMATED data"); I_Error("Not enough free memory for ANIMATED data");
}
// Populate the new array // Populate the new array
for (currentPos = wadAnimdefs; *currentPos != UINT8_MAX; i++, currentPos+=23) for (currentPos = animatedLump; *currentPos != UINT8_MAX; i++, currentPos+=23)
{ {
M_Memcpy(&(animdefs[i].istexture), currentPos, 1); // istexture, 1 byte M_Memcpy(&(animdefs[i].istexture), currentPos, 1); // istexture, 1 byte
M_Memcpy(animdefs[i].endname, (currentPos + 1), 9); // endname, 9 bytes M_Memcpy(animdefs[i].endname, (currentPos + 1), 9); // endname, 9 bytes
@ -284,15 +281,13 @@ void P_InitPicAnims(void)
M_Memcpy(&(animdefs[i].speed), (currentPos + 19), 4); // speed, 4 bytes M_Memcpy(&(animdefs[i].speed), (currentPos + 19), 4); // speed, 4 bytes
} }
Z_Free(wadAnimdefs); Z_Free(animatedLump);
} }
// Now find ANIMDEFS // Now find ANIMDEFS
animdefsLumpNum = W_CheckNumForNamePwad("ANIMDEFS", w, 0); animdefsLumpNum = W_CheckNumForNamePwad("ANIMDEFS", w, 0);
if (animdefsLumpNum != INT16_MAX) if (animdefsLumpNum != INT16_MAX)
{ P_ParseANIMDEFSLump(w, animdefsLumpNum);
P_ParseANIMDEFSLump(w, animdefsLumpNum, &i);
}
} }
// Define the last one // Define the last one
animdefs[maxanims].istexture = -1; animdefs[maxanims].istexture = -1;
@ -352,16 +347,20 @@ void P_InitPicAnims(void)
lastanim->istexture = -1; lastanim->istexture = -1;
R_ClearTextureNumCache(false); R_ClearTextureNumCache(false);
// Clear animdefs now that we're done with it.
// We'll only be using anims from now on.
if (animdefs != harddefs) if (animdefs != harddefs)
Z_ChangeTag(animdefs, PU_CACHE); Z_Free(animdefs);
animdefs = NULL;
} }
void P_ParseANIMDEFSLump(INT32 wadNum, UINT16 lumpnum, INT32 *i) void P_ParseANIMDEFSLump(INT32 wadNum, UINT16 lumpnum)
{ {
char *animdefsLump; char *animdefsLump;
size_t animdefsLumpLength; size_t animdefsLumpLength;
char *animdefsText; char *animdefsText;
char *animdefsToken; char *animdefsToken;
char *p;
// Since lumps AREN'T \0-terminated like I'd assumed they should be, I'll // Since lumps AREN'T \0-terminated like I'd assumed they should be, I'll
// need to make a space of memory where I can ensure that it will terminate // need to make a space of memory where I can ensure that it will terminate
@ -381,18 +380,19 @@ void P_ParseANIMDEFSLump(INT32 wadNum, UINT16 lumpnum, INT32 *i)
Z_Free(animdefsLump); Z_Free(animdefsLump);
// Now, let's start parsing this thing // Now, let's start parsing this thing
animdefsToken = M_GetToken(animdefsText); p = animdefsText;
animdefsToken = M_GetToken(p);
while (animdefsToken != NULL) while (animdefsToken != NULL)
{ {
if (stricmp(animdefsToken, "TEXTURE") == 0) if (stricmp(animdefsToken, "TEXTURE") == 0)
{ {
Z_Free(animdefsToken); Z_Free(animdefsToken);
P_ParseAnimationDefintion(1, i); P_ParseAnimationDefintion(1);
} }
else if (stricmp(animdefsToken, "FLAT") == 0) else if (stricmp(animdefsToken, "FLAT") == 0)
{ {
Z_Free(animdefsToken); Z_Free(animdefsToken);
P_ParseAnimationDefintion(0, i); P_ParseAnimationDefintion(0);
} }
else if (stricmp(animdefsToken, "OSCILLATE") == 0) else if (stricmp(animdefsToken, "OSCILLATE") == 0)
{ {
@ -403,23 +403,22 @@ void P_ParseANIMDEFSLump(INT32 wadNum, UINT16 lumpnum, INT32 *i)
{ {
I_Error("Error parsing ANIMDEFS lump: Expected \"TEXTURE\" or \"FLAT\", got \"%s\"",animdefsToken); I_Error("Error parsing ANIMDEFS lump: Expected \"TEXTURE\" or \"FLAT\", got \"%s\"",animdefsToken);
} }
animdefsToken = M_GetToken(NULL); // parse next line
while (*p != '\0' && *p != '\n') ++p;
if (*p == '\n') ++p;
animdefsToken = M_GetToken(p);
} }
Z_Free(animdefsToken); Z_Free(animdefsToken);
Z_Free((void *)animdefsText); Z_Free((void *)animdefsText);
} }
void P_ParseAnimationDefintion(SINT8 istexture, INT32 *i) void P_ParseAnimationDefintion(SINT8 istexture)
{ {
char *animdefsToken; char *animdefsToken;
size_t animdefsTokenLength; size_t animdefsTokenLength;
char *endPos; char *endPos;
INT32 animSpeed; INT32 animSpeed;
size_t i;
// Increase the size to make room for the new animation definition
maxanims++;
animdefs = (animdef_t *)Z_Realloc(animdefs, sizeof(animdef_t)*(maxanims + 1), PU_STATIC, NULL);
animdefs[*i].istexture = istexture;
// Startname // Startname
animdefsToken = M_GetToken(NULL); animdefsToken = M_GetToken(NULL);
@ -453,14 +452,39 @@ void P_ParseAnimationDefintion(SINT8 istexture, INT32 *i)
{ {
I_Error("Error parsing ANIMDEFS lump: lump name \"%s\" exceeds 8 characters", animdefsToken); I_Error("Error parsing ANIMDEFS lump: lump name \"%s\" exceeds 8 characters", animdefsToken);
} }
strncpy(animdefs[*i].startname, animdefsToken, 9);
// Search for existing animdef
for (i = 0; i < maxanims; i++)
if (stricmp(animdefsToken, animdefs[i].startname) == 0)
{
//CONS_Alert(CONS_NOTICE, "Duplicate animation: %s\n", animdefsToken);
// If we weren't parsing in reverse order, we would `break` here and parse the new data into the existing slot we found.
// Instead, we're just going to skip parsing the rest of this line entirely.
Z_Free(animdefsToken);
return;
}
// Not found
if (i == maxanims)
{
// Increase the size to make room for the new animation definition
maxanims++;
animdefs = (animdef_t *)Z_Realloc(animdefs, sizeof(animdef_t)*(maxanims + 1), PU_STATIC, NULL);
strncpy(animdefs[i].startname, animdefsToken, 9);
}
// animdefs[i].startname is now set to animdefsToken either way.
Z_Free(animdefsToken); Z_Free(animdefsToken);
// set texture type
animdefs[i].istexture = istexture;
// "RANGE" // "RANGE"
animdefsToken = M_GetToken(NULL); animdefsToken = M_GetToken(NULL);
if (animdefsToken == NULL) if (animdefsToken == NULL)
{ {
I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where \"RANGE\" after \"%s\"'s startname should be", animdefs[*i].startname); I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where \"RANGE\" after \"%s\"'s startname should be", animdefs[i].startname);
} }
if (stricmp(animdefsToken, "ALLOWDECALS") == 0) if (stricmp(animdefsToken, "ALLOWDECALS") == 0)
{ {
@ -475,7 +499,7 @@ void P_ParseAnimationDefintion(SINT8 istexture, INT32 *i)
} }
if (stricmp(animdefsToken, "RANGE") != 0) if (stricmp(animdefsToken, "RANGE") != 0)
{ {
I_Error("Error parsing ANIMDEFS lump: Expected \"RANGE\" after \"%s\"'s startname, got \"%s\"", animdefs[*i].startname, animdefsToken); I_Error("Error parsing ANIMDEFS lump: Expected \"RANGE\" after \"%s\"'s startname, got \"%s\"", animdefs[i].startname, animdefsToken);
} }
Z_Free(animdefsToken); Z_Free(animdefsToken);
@ -483,21 +507,21 @@ void P_ParseAnimationDefintion(SINT8 istexture, INT32 *i)
animdefsToken = M_GetToken(NULL); animdefsToken = M_GetToken(NULL);
if (animdefsToken == NULL) if (animdefsToken == NULL)
{ {
I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where \"%s\"'s end texture/flat name should be", animdefs[*i].startname); I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where \"%s\"'s end texture/flat name should be", animdefs[i].startname);
} }
animdefsTokenLength = strlen(animdefsToken); animdefsTokenLength = strlen(animdefsToken);
if (animdefsTokenLength>8) if (animdefsTokenLength>8)
{ {
I_Error("Error parsing ANIMDEFS lump: lump name \"%s\" exceeds 8 characters", animdefsToken); I_Error("Error parsing ANIMDEFS lump: lump name \"%s\" exceeds 8 characters", animdefsToken);
} }
strncpy(animdefs[*i].endname, animdefsToken, 9); strncpy(animdefs[i].endname, animdefsToken, 9);
Z_Free(animdefsToken); Z_Free(animdefsToken);
// "TICS" // "TICS"
animdefsToken = M_GetToken(NULL); animdefsToken = M_GetToken(NULL);
if (animdefsToken == NULL) if (animdefsToken == NULL)
{ {
I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where \"%s\"'s \"TICS\" should be", animdefs[*i].startname); I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where \"%s\"'s \"TICS\" should be", animdefs[i].startname);
} }
if (stricmp(animdefsToken, "RAND") == 0) if (stricmp(animdefsToken, "RAND") == 0)
{ {
@ -506,7 +530,7 @@ void P_ParseAnimationDefintion(SINT8 istexture, INT32 *i)
} }
if (stricmp(animdefsToken, "TICS") != 0) if (stricmp(animdefsToken, "TICS") != 0)
{ {
I_Error("Error parsing ANIMDEFS lump: Expected \"TICS\" in animation definition for \"%s\", got \"%s\"", animdefs[*i].startname, animdefsToken); I_Error("Error parsing ANIMDEFS lump: Expected \"TICS\" in animation definition for \"%s\", got \"%s\"", animdefs[i].startname, animdefsToken);
} }
Z_Free(animdefsToken); Z_Free(animdefsToken);
@ -514,7 +538,7 @@ void P_ParseAnimationDefintion(SINT8 istexture, INT32 *i)
animdefsToken = M_GetToken(NULL); animdefsToken = M_GetToken(NULL);
if (animdefsToken == NULL) if (animdefsToken == NULL)
{ {
I_Error("Error parsing TEXTURES lump: Unexpected end of file where \"%s\"'s animation speed should be", animdefs[*i].startname); I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where \"%s\"'s animation speed should be", animdefs[i].startname);
} }
endPos = NULL; endPos = NULL;
#ifndef AVOID_ERRNO #ifndef AVOID_ERRNO
@ -528,13 +552,10 @@ void P_ParseAnimationDefintion(SINT8 istexture, INT32 *i)
#endif #endif
|| animSpeed < 0) // Number is not positive || animSpeed < 0) // Number is not positive
{ {
I_Error("Error parsing TEXTURES lump: Expected a positive integer for \"%s\"'s animation speed, got \"%s\"", animdefs[*i].startname, animdefsToken); I_Error("Error parsing ANIMDEFS lump: Expected a positive integer for \"%s\"'s animation speed, got \"%s\"", animdefs[i].startname, animdefsToken);
} }
animdefs[*i].speed = animSpeed; animdefs[i].speed = animSpeed;
Z_Free(animdefsToken); Z_Free(animdefsToken);
// Increment i before we go, so this doesn't cause issues later
(*i)++;
} }
@ -1193,7 +1214,12 @@ INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start)
{ {
start++; start++;
while (lines[start].special != special) // This redundant check stops the compiler from complaining about function expansion
// elsewhere for some reason and everything is awful
if (start >= (INT32)numlines)
return -1;
while (start < (INT32)numlines && lines[start].special != special)
start++; start++;
if (start >= (INT32)numlines) if (start >= (INT32)numlines)
@ -1498,6 +1524,8 @@ static inline void P_InitTagLists(void)
size_t j = (unsigned)sectors[i].tag % numsectors; size_t j = (unsigned)sectors[i].tag % numsectors;
sectors[i].nexttag = sectors[j].firsttag; sectors[i].nexttag = sectors[j].firsttag;
sectors[j].firsttag = (INT32)i; sectors[j].firsttag = (INT32)i;
sectors[i].spawn_nexttag = sectors[i].nexttag;
sectors[j].spawn_firsttag = sectors[j].firsttag;
} }
for (i = numlines - 1; i != (size_t)-1; i--) for (i = numlines - 1; i != (size_t)-1; i--)
@ -1647,7 +1675,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller
mo = node->m_thing; mo = node->m_thing;
if (mo->flags & MF_PUSHABLE) if (mo->flags & MF_PUSHABLE)
numpush++; numpush++;
node = node->m_snext; node = node->m_thinglist_next;
} }
if (triggerline->flags & ML_NOCLIMB) // Need at least or more if (triggerline->flags & ML_NOCLIMB) // Need at least or more
@ -2439,10 +2467,10 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
if (rover->master->frontsector->tag != line->tag) if (rover->master->frontsector->tag != line->tag)
continue; continue;
if (mo->z > *rover->topheight) if (mo->z > P_GetSpecialTopZ(mo, sectors + rover->secnum, mo->subsector->sector))
continue; continue;
if (mo->z + mo->height < *rover->bottomheight) if (mo->z + mo->height < P_GetSpecialBottomZ(mo, sectors + rover->secnum, mo->subsector->sector))
continue; continue;
foundit = true; foundit = true;
@ -3149,7 +3177,7 @@ void P_SetupSignExit(player_t *player)
thinker_t *think; thinker_t *think;
INT32 numfound = 0; INT32 numfound = 0;
for (; node; node = node->m_snext) for (; node; node = node->m_thinglist_next)
{ {
thing = node->m_thing; thing = node->m_thing;
if (thing->type != MT_SIGN) if (thing->type != MT_SIGN)
@ -3232,8 +3260,8 @@ boolean P_IsFlagAtBase(mobjtype_t flag)
if (GETSECSPECIAL(rover->master->frontsector->special, 4) != specialnum) if (GETSECSPECIAL(rover->master->frontsector->special, 4) != specialnum)
continue; continue;
if (mo->z <= *rover->topheight if (mo->z <= P_GetSpecialTopZ(mo, sectors + rover->secnum, mo->subsector->sector)
&& mo->z >= *rover->bottomheight) && mo->z >= P_GetSpecialBottomZ(mo, sectors + rover->secnum, mo->subsector->sector))
return true; return true;
} }
} }
@ -3267,12 +3295,17 @@ sector_t *P_PlayerTouchingSectorSpecial(player_t *player, INT32 section, INT32 n
// Hmm.. maybe there's a FOF that has it... // Hmm.. maybe there's a FOF that has it...
for (rover = player->mo->subsector->sector->ffloors; rover; rover = rover->next) for (rover = player->mo->subsector->sector->ffloors; rover; rover = rover->next)
{ {
fixed_t topheight, bottomheight;
if (GETSECSPECIAL(rover->master->frontsector->special, section) != number) if (GETSECSPECIAL(rover->master->frontsector->special, section) != number)
continue; continue;
if (!(rover->flags & FF_EXISTS)) if (!(rover->flags & FF_EXISTS))
continue; continue;
topheight = P_GetSpecialTopZ(player->mo, sectors + rover->secnum, player->mo->subsector->sector);
bottomheight = P_GetSpecialBottomZ(player->mo, sectors + rover->secnum, player->mo->subsector->sector);
// Check the 3D floor's type... // Check the 3D floor's type...
if (rover->flags & FF_BLOCKPLAYER) if (rover->flags & FF_BLOCKPLAYER)
{ {
@ -3280,27 +3313,27 @@ sector_t *P_PlayerTouchingSectorSpecial(player_t *player, INT32 section, INT32 n
if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR) if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR)
&& !(rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING)) && !(rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING))
{ {
if ((player->mo->eflags & MFE_VERTICALFLIP) || player->mo->z != *rover->topheight) if ((player->mo->eflags & MFE_VERTICALFLIP) || player->mo->z != topheight)
continue; continue;
} }
else if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING) else if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING)
&& !(rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR)) && !(rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR))
{ {
if (!(player->mo->eflags & MFE_VERTICALFLIP) if (!(player->mo->eflags & MFE_VERTICALFLIP)
|| player->mo->z + player->mo->height != *rover->bottomheight) || player->mo->z + player->mo->height != bottomheight)
continue; continue;
} }
else if (rover->master->frontsector->flags & SF_FLIPSPECIAL_BOTH) else if (rover->master->frontsector->flags & SF_FLIPSPECIAL_BOTH)
{ {
if (!((player->mo->eflags & MFE_VERTICALFLIP && player->mo->z + player->mo->height == *rover->bottomheight) if (!((player->mo->eflags & MFE_VERTICALFLIP && player->mo->z + player->mo->height == bottomheight)
|| (!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z == *rover->topheight))) || (!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z == topheight)))
continue; continue;
} }
} }
else else
{ {
// Water and DEATH FOG!!! heh // Water and DEATH FOG!!! heh
if (player->mo->z > *rover->topheight || (player->mo->z + player->mo->height) < *rover->bottomheight) if (player->mo->z > topheight || (player->mo->z + player->mo->height) < bottomheight)
continue; continue;
} }
@ -3308,7 +3341,7 @@ sector_t *P_PlayerTouchingSectorSpecial(player_t *player, INT32 section, INT32 n
return rover->master->frontsector; return rover->master->frontsector;
} }
for (node = player->mo->touching_sectorlist; node; node = node->m_snext) for (node = player->mo->touching_sectorlist; node; node = node->m_sectorlist_next)
{ {
if (GETSECSPECIAL(node->m_sector->special, section) == number) if (GETSECSPECIAL(node->m_sector->special, section) == number)
{ {
@ -3322,12 +3355,17 @@ sector_t *P_PlayerTouchingSectorSpecial(player_t *player, INT32 section, INT32 n
// Hmm.. maybe there's a FOF that has it... // Hmm.. maybe there's a FOF that has it...
for (rover = node->m_sector->ffloors; rover; rover = rover->next) for (rover = node->m_sector->ffloors; rover; rover = rover->next)
{ {
fixed_t topheight, bottomheight;
if (GETSECSPECIAL(rover->master->frontsector->special, section) != number) if (GETSECSPECIAL(rover->master->frontsector->special, section) != number)
continue; continue;
if (!(rover->flags & FF_EXISTS)) if (!(rover->flags & FF_EXISTS))
continue; continue;
topheight = P_GetSpecialTopZ(player->mo, sectors + rover->secnum, player->mo->subsector->sector);
bottomheight = P_GetSpecialBottomZ(player->mo, sectors + rover->secnum, player->mo->subsector->sector);
// Check the 3D floor's type... // Check the 3D floor's type...
if (rover->flags & FF_BLOCKPLAYER) if (rover->flags & FF_BLOCKPLAYER)
{ {
@ -3335,27 +3373,27 @@ sector_t *P_PlayerTouchingSectorSpecial(player_t *player, INT32 section, INT32 n
if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR) if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR)
&& !(rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING)) && !(rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING))
{ {
if ((player->mo->eflags & MFE_VERTICALFLIP) || player->mo->z != *rover->topheight) if ((player->mo->eflags & MFE_VERTICALFLIP) || player->mo->z != topheight)
continue; continue;
} }
else if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING) else if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING)
&& !(rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR)) && !(rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR))
{ {
if (!(player->mo->eflags & MFE_VERTICALFLIP) if (!(player->mo->eflags & MFE_VERTICALFLIP)
|| player->mo->z + player->mo->height != *rover->bottomheight) || player->mo->z + player->mo->height != bottomheight)
continue; continue;
} }
else if (rover->master->frontsector->flags & SF_FLIPSPECIAL_BOTH) else if (rover->master->frontsector->flags & SF_FLIPSPECIAL_BOTH)
{ {
if (!((player->mo->eflags & MFE_VERTICALFLIP && player->mo->z + player->mo->height == *rover->bottomheight) if (!((player->mo->eflags & MFE_VERTICALFLIP && player->mo->z + player->mo->height == bottomheight)
|| (!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z == *rover->topheight))) || (!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z == topheight)))
continue; continue;
} }
} }
else else
{ {
// Water and DEATH FOG!!! heh // Water and DEATH FOG!!! heh
if (player->mo->z > *rover->topheight || (player->mo->z + player->mo->height) < *rover->bottomheight) if (player->mo->z > topheight || (player->mo->z + player->mo->height) < bottomheight)
continue; continue;
} }
@ -4408,12 +4446,17 @@ sector_t *P_ThingOnSpecial3DFloor(mobj_t *mo)
for (rover = sector->ffloors; rover; rover = rover->next) for (rover = sector->ffloors; rover; rover = rover->next)
{ {
fixed_t topheight, bottomheight;
if (!rover->master->frontsector->special) if (!rover->master->frontsector->special)
continue; continue;
if (!(rover->flags & FF_EXISTS)) if (!(rover->flags & FF_EXISTS))
continue; continue;
topheight = P_GetSpecialTopZ(mo, sectors + rover->secnum, sector);
bottomheight = P_GetSpecialBottomZ(mo, sectors + rover->secnum, sector);
// Check the 3D floor's type... // Check the 3D floor's type...
if (((rover->flags & FF_BLOCKPLAYER) && mo->player) if (((rover->flags & FF_BLOCKPLAYER) && mo->player)
|| ((rover->flags & FF_BLOCKOTHERS) && !mo->player)) || ((rover->flags & FF_BLOCKOTHERS) && !mo->player))
@ -4422,27 +4465,27 @@ sector_t *P_ThingOnSpecial3DFloor(mobj_t *mo)
if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR) if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR)
&& !(rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING)) && !(rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING))
{ {
if ((mo->eflags & MFE_VERTICALFLIP) || mo->z != *rover->topheight) if ((mo->eflags & MFE_VERTICALFLIP) || mo->z != topheight)
continue; continue;
} }
else if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING) else if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING)
&& !(rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR)) && !(rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR))
{ {
if (!(mo->eflags & MFE_VERTICALFLIP) if (!(mo->eflags & MFE_VERTICALFLIP)
|| mo->z + mo->height != *rover->bottomheight) || mo->z + mo->height != bottomheight)
continue; continue;
} }
else if (rover->master->frontsector->flags & SF_FLIPSPECIAL_BOTH) else if (rover->master->frontsector->flags & SF_FLIPSPECIAL_BOTH)
{ {
if (!((mo->eflags & MFE_VERTICALFLIP && mo->z + mo->height == *rover->bottomheight) if (!((mo->eflags & MFE_VERTICALFLIP && mo->z + mo->height == bottomheight)
|| (!(mo->eflags & MFE_VERTICALFLIP) && mo->z == *rover->topheight))) || (!(mo->eflags & MFE_VERTICALFLIP) && mo->z == topheight)))
continue; continue;
} }
} }
else else
{ {
// Water and intangible FOFs // Water and intangible FOFs
if (mo->z > *rover->topheight || (mo->z + mo->height) < *rover->bottomheight) if (mo->z > topheight || (mo->z + mo->height) < bottomheight)
continue; continue;
} }
@ -4464,12 +4507,17 @@ static void P_PlayerOnSpecial3DFloor(player_t *player, sector_t *sector)
for (rover = sector->ffloors; rover; rover = rover->next) for (rover = sector->ffloors; rover; rover = rover->next)
{ {
fixed_t topheight, bottomheight;
if (!rover->master->frontsector->special) if (!rover->master->frontsector->special)
continue; continue;
if (!(rover->flags & FF_EXISTS)) if (!(rover->flags & FF_EXISTS))
continue; continue;
topheight = P_GetSpecialTopZ(player->mo, sectors + rover->secnum, sector);
bottomheight = P_GetSpecialBottomZ(player->mo, sectors + rover->secnum, sector);
// Check the 3D floor's type... // Check the 3D floor's type...
if (rover->flags & FF_BLOCKPLAYER) if (rover->flags & FF_BLOCKPLAYER)
{ {
@ -4477,27 +4525,27 @@ static void P_PlayerOnSpecial3DFloor(player_t *player, sector_t *sector)
if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR) if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR)
&& !(rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING)) && !(rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING))
{ {
if ((player->mo->eflags & MFE_VERTICALFLIP) || player->mo->z != P_GetSpecialTopZ(player->mo, sectors + rover->secnum, sector)) if ((player->mo->eflags & MFE_VERTICALFLIP) || player->mo->z != topheight)
continue; continue;
} }
else if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING) else if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING)
&& !(rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR)) && !(rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR))
{ {
if (!(player->mo->eflags & MFE_VERTICALFLIP) if (!(player->mo->eflags & MFE_VERTICALFLIP)
|| player->mo->z + player->mo->height != P_GetSpecialBottomZ(player->mo, sectors + rover->secnum, sector)) || player->mo->z + player->mo->height != bottomheight)
continue; continue;
} }
else if (rover->master->frontsector->flags & SF_FLIPSPECIAL_BOTH) else if (rover->master->frontsector->flags & SF_FLIPSPECIAL_BOTH)
{ {
if (!((player->mo->eflags & MFE_VERTICALFLIP && player->mo->z + player->mo->height == P_GetSpecialBottomZ(player->mo, sectors + rover->secnum, sector)) if (!((player->mo->eflags & MFE_VERTICALFLIP && player->mo->z + player->mo->height == bottomheight)
|| (!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z == P_GetSpecialTopZ(player->mo, sectors + rover->secnum, sector)))) || (!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z == topheight)))
continue; continue;
} }
} }
else else
{ {
// Water and DEATH FOG!!! heh // Water and DEATH FOG!!! heh
if (player->mo->z > P_GetSpecialTopZ(player->mo, sectors + rover->secnum, sector) || (player->mo->z + player->mo->height) < P_GetSpecialBottomZ(player->mo, sectors + rover->secnum, sector)) if (player->mo->z > topheight || (player->mo->z + player->mo->height) < bottomheight)
continue; continue;
} }
@ -4710,7 +4758,7 @@ void P_PlayerInSpecialSector(player_t *player)
P_RunSpecialSectorCheck(player, sector); P_RunSpecialSectorCheck(player, sector);
// Iterate through touching_sectorlist // Iterate through touching_sectorlist
for (node = player->mo->touching_sectorlist; node; node = node->m_snext) for (node = player->mo->touching_sectorlist; node; node = node->m_sectorlist_next)
{ {
sector = node->m_sector; sector = node->m_sector;
@ -5349,11 +5397,19 @@ void T_LaserFlash(laserthink_t *flash)
sourcesec = ffloor->master->frontsector; // Less to type! sourcesec = ffloor->master->frontsector; // Less to type!
#ifdef ESLOPE
top = (*ffloor->t_slope) ? P_GetZAt(*ffloor->t_slope, sector->soundorg.x, sector->soundorg.y)
: *ffloor->topheight;
bottom = (*ffloor->b_slope) ? P_GetZAt(*ffloor->b_slope, sector->soundorg.x, sector->soundorg.y)
: *ffloor->bottomheight;
sector->soundorg.z = (top + bottom)/2;
#else
sector->soundorg.z = (*ffloor->topheight + *ffloor->bottomheight)/2; sector->soundorg.z = (*ffloor->topheight + *ffloor->bottomheight)/2;
#endif
S_StartSound(&sector->soundorg, sfx_laser); S_StartSound(&sector->soundorg, sfx_laser);
// Seek out objects to DESTROY! MUAHAHHAHAHAA!!!*cough* // Seek out objects to DESTROY! MUAHAHHAHAHAA!!!*cough*
for (node = sector->touching_thinglist; node && node->m_thing; node = node->m_snext) for (node = sector->touching_thinglist; node && node->m_thing; node = node->m_thinglist_next)
{ {
thing = node->m_thing; thing = node->m_thing;
@ -5361,6 +5417,10 @@ void T_LaserFlash(laserthink_t *flash)
&& thing->flags & MF_BOSS) && thing->flags & MF_BOSS)
continue; // Don't hurt bosses continue; // Don't hurt bosses
// Don't endlessly kill egg guard shields (or anything else for that matter)
if (thing->health <= 0)
continue;
top = P_GetSpecialTopZ(thing, sourcesec, sector); top = P_GetSpecialTopZ(thing, sourcesec, sector);
bottom = P_GetSpecialBottomZ(thing, sourcesec, sector); bottom = P_GetSpecialBottomZ(thing, sourcesec, sector);
@ -6623,7 +6683,7 @@ void T_Scroll(scroll_t *s)
sector_t *psec; sector_t *psec;
psec = sectors + sect; psec = sectors + sect;
for (node = psec->touching_thinglist; node; node = node->m_snext) for (node = psec->touching_thinglist; node; node = node->m_thinglist_next)
{ {
thing = node->m_thing; thing = node->m_thing;
@ -6645,7 +6705,7 @@ void T_Scroll(scroll_t *s)
if (!is3dblock) if (!is3dblock)
{ {
for (node = sec->touching_thinglist; node; node = node->m_snext) for (node = sec->touching_thinglist; node; node = node->m_thinglist_next)
{ {
thing = node->m_thing; thing = node->m_thing;
@ -6686,7 +6746,7 @@ void T_Scroll(scroll_t *s)
sector_t *psec; sector_t *psec;
psec = sectors + sect; psec = sectors + sect;
for (node = psec->touching_thinglist; node; node = node->m_snext) for (node = psec->touching_thinglist; node; node = node->m_thinglist_next)
{ {
thing = node->m_thing; thing = node->m_thing;
@ -6708,7 +6768,7 @@ void T_Scroll(scroll_t *s)
if (!is3dblock) if (!is3dblock)
{ {
for (node = sec->touching_thinglist; node; node = node->m_snext) for (node = sec->touching_thinglist; node; node = node->m_thinglist_next)
{ {
thing = node->m_thing; thing = node->m_thing;
@ -6947,6 +7007,11 @@ void T_Disappear(disappear_t *d)
if (!(lines[d->sourceline].flags & ML_NOCLIMB)) if (!(lines[d->sourceline].flags & ML_NOCLIMB))
{ {
#ifdef ESLOPE
if (*rover->t_slope)
sectors[s].soundorg.z = P_GetZAt(*rover->t_slope, sectors[s].soundorg.x, sectors[s].soundorg.y);
else
#endif
sectors[s].soundorg.z = *rover->topheight; sectors[s].soundorg.z = *rover->topheight;
S_StartSound(&sectors[s].soundorg, sfx_appear); S_StartSound(&sectors[s].soundorg, sfx_appear);
} }
@ -7055,7 +7120,7 @@ void T_Friction(friction_t *f)
{ {
if (thing->floorz != P_GetSpecialTopZ(thing, referrer, sec)) if (thing->floorz != P_GetSpecialTopZ(thing, referrer, sec))
{ {
node = node->m_snext; node = node->m_thinglist_next;
continue; continue;
} }
@ -7075,7 +7140,7 @@ void T_Friction(friction_t *f)
thing->movefactor = f->movefactor; thing->movefactor = f->movefactor;
} }
} }
node = node->m_snext; node = node->m_thinglist_next;
} }
} }
@ -7422,7 +7487,7 @@ void T_Pusher(pusher_t *p)
// constant pushers p_wind and p_current // constant pushers p_wind and p_current
node = sec->touching_thinglist; // things touching this sector node = sec->touching_thinglist; // things touching this sector
for (; node; node = node->m_snext) for (; node; node = node->m_thinglist_next)
{ {
thing = node->m_thing; thing = node->m_thing;
if (thing->flags & (MF_NOGRAVITY | MF_NOCLIP) if (thing->flags & (MF_NOGRAVITY | MF_NOCLIP)
@ -7473,7 +7538,7 @@ void T_Pusher(pusher_t *p)
} }
else else
{ {
if (top < thing->z || referrer->floorheight > (thing->z + (thing->height >> 1))) if (top < thing->z || bottom > (thing->z + (thing->height >> 1)))
continue; continue;
if (thing->z + thing->height > top) if (thing->z + thing->height > top)
touching = true; touching = true;

File diff suppressed because it is too large Load diff

View file

@ -859,6 +859,7 @@ static void R_Subsector(size_t num)
static sector_t tempsec; // Deep water hack static sector_t tempsec; // Deep water hack
extracolormap_t *floorcolormap; extracolormap_t *floorcolormap;
extracolormap_t *ceilingcolormap; extracolormap_t *ceilingcolormap;
fixed_t floorcenterz, ceilingcenterz;
#ifdef RANGECHECK #ifdef RANGECHECK
if (num >= numsubsectors) if (num >= numsubsectors)
@ -879,6 +880,18 @@ static void R_Subsector(size_t num)
floorcolormap = ceilingcolormap = frontsector->extra_colormap; floorcolormap = ceilingcolormap = frontsector->extra_colormap;
floorcenterz =
#ifdef ESLOPE
frontsector->f_slope ? P_GetZAt(frontsector->f_slope, frontsector->soundorg.x, frontsector->soundorg.y) :
#endif
frontsector->floorheight;
ceilingcenterz =
#ifdef ESLOPE
frontsector->c_slope ? P_GetZAt(frontsector->c_slope, frontsector->soundorg.x, frontsector->soundorg.y) :
#endif
frontsector->ceilingheight;
// Check and prep all 3D floors. Set the sector floor/ceiling light levels and colormaps. // Check and prep all 3D floors. Set the sector floor/ceiling light levels and colormaps.
if (frontsector->ffloors) if (frontsector->ffloors)
{ {
@ -891,19 +904,11 @@ static void R_Subsector(size_t num)
sub->sector->moved = frontsector->moved = false; sub->sector->moved = frontsector->moved = false;
} }
light = R_GetPlaneLight(frontsector, light = R_GetPlaneLight(frontsector, floorcenterz, false);
#ifdef ESLOPE
frontsector->f_slope ? P_GetZAt(frontsector->f_slope, frontsector->soundorg.x, frontsector->soundorg.y) :
#endif
frontsector->floorheight, false);
if (frontsector->floorlightsec == -1) if (frontsector->floorlightsec == -1)
floorlightlevel = *frontsector->lightlist[light].lightlevel; floorlightlevel = *frontsector->lightlist[light].lightlevel;
floorcolormap = frontsector->lightlist[light].extra_colormap; floorcolormap = frontsector->lightlist[light].extra_colormap;
light = R_GetPlaneLight(frontsector, light = R_GetPlaneLight(frontsector, ceilingcenterz, false);
#ifdef ESLOPE
frontsector->c_slope ? P_GetZAt(frontsector->c_slope, frontsector->soundorg.x, frontsector->soundorg.y) :
#endif
frontsector->ceilingheight, false);
if (frontsector->ceilinglightsec == -1) if (frontsector->ceilinglightsec == -1)
ceilinglightlevel = *frontsector->lightlist[light].lightlevel; ceilinglightlevel = *frontsector->lightlist[light].lightlevel;
ceilingcolormap = frontsector->lightlist[light].extra_colormap; ceilingcolormap = frontsector->lightlist[light].extra_colormap;
@ -920,6 +925,9 @@ static void R_Subsector(size_t num)
{ {
floorplane = R_FindPlane(frontsector->floorheight, frontsector->floorpic, floorlightlevel, floorplane = R_FindPlane(frontsector->floorheight, frontsector->floorpic, floorlightlevel,
frontsector->floor_xoffs, frontsector->floor_yoffs, frontsector->floorpic_angle, floorcolormap, NULL frontsector->floor_xoffs, frontsector->floor_yoffs, frontsector->floorpic_angle, floorcolormap, NULL
#ifdef POLYOBJECTS_PLANES
, NULL
#endif
#ifdef ESLOPE #ifdef ESLOPE
, frontsector->f_slope , frontsector->f_slope
#endif #endif
@ -939,6 +947,9 @@ static void R_Subsector(size_t num)
ceilingplane = R_FindPlane(frontsector->ceilingheight, frontsector->ceilingpic, ceilingplane = R_FindPlane(frontsector->ceilingheight, frontsector->ceilingpic,
ceilinglightlevel, frontsector->ceiling_xoffs, frontsector->ceiling_yoffs, frontsector->ceilingpic_angle, ceilinglightlevel, frontsector->ceiling_xoffs, frontsector->ceiling_yoffs, frontsector->ceilingpic_angle,
ceilingcolormap, NULL ceilingcolormap, NULL
#ifdef POLYOBJECTS_PLANES
, NULL
#endif
#ifdef ESLOPE #ifdef ESLOPE
, frontsector->c_slope , frontsector->c_slope
#endif #endif
@ -956,7 +967,7 @@ static void R_Subsector(size_t num)
if (frontsector->ffloors) if (frontsector->ffloors)
{ {
ffloor_t *rover; ffloor_t *rover;
fixed_t heightcheck, planecenterz, floorcenterz, ceilingcenterz; fixed_t heightcheck, planecenterz;
for (rover = frontsector->ffloors; rover && numffloors < MAXFFLOORS; rover = rover->next) for (rover = frontsector->ffloors; rover && numffloors < MAXFFLOORS; rover = rover->next)
{ {
@ -975,18 +986,6 @@ static void R_Subsector(size_t num)
ffloor[numffloors].plane = NULL; ffloor[numffloors].plane = NULL;
ffloor[numffloors].polyobj = NULL; ffloor[numffloors].polyobj = NULL;
floorcenterz =
#ifdef ESLOPE
frontsector->f_slope ? P_GetZAt(frontsector->f_slope, frontsector->soundorg.x, frontsector->soundorg.y) :
#endif
frontsector->floorheight;
ceilingcenterz =
#ifdef ESLOPE
frontsector->c_slope ? P_GetZAt(frontsector->c_slope, frontsector->soundorg.x, frontsector->soundorg.y) :
#endif
frontsector->ceilingheight;
heightcheck = heightcheck =
#ifdef ESLOPE #ifdef ESLOPE
*rover->b_slope ? P_GetZAt(*rover->b_slope, viewx, viewy) : *rover->b_slope ? P_GetZAt(*rover->b_slope, viewx, viewy) :
@ -1009,6 +1008,9 @@ static void R_Subsector(size_t num)
ffloor[numffloors].plane = R_FindPlane(*rover->bottomheight, *rover->bottompic, ffloor[numffloors].plane = R_FindPlane(*rover->bottomheight, *rover->bottompic,
*frontsector->lightlist[light].lightlevel, *rover->bottomxoffs, *frontsector->lightlist[light].lightlevel, *rover->bottomxoffs,
*rover->bottomyoffs, *rover->bottomangle, frontsector->lightlist[light].extra_colormap, rover *rover->bottomyoffs, *rover->bottomangle, frontsector->lightlist[light].extra_colormap, rover
#ifdef POLYOBJECTS_PLANES
, NULL
#endif
#ifdef ESLOPE #ifdef ESLOPE
, *rover->b_slope , *rover->b_slope
#endif #endif
@ -1052,6 +1054,9 @@ static void R_Subsector(size_t num)
ffloor[numffloors].plane = R_FindPlane(*rover->topheight, *rover->toppic, ffloor[numffloors].plane = R_FindPlane(*rover->topheight, *rover->toppic,
*frontsector->lightlist[light].lightlevel, *rover->topxoffs, *rover->topyoffs, *rover->topangle, *frontsector->lightlist[light].lightlevel, *rover->topxoffs, *rover->topyoffs, *rover->topangle,
frontsector->lightlist[light].extra_colormap, rover frontsector->lightlist[light].extra_colormap, rover
#ifdef POLYOBJECTS_PLANES
, NULL
#endif
#ifdef ESLOPE #ifdef ESLOPE
, *rover->t_slope , *rover->t_slope
#endif #endif
@ -1093,8 +1098,8 @@ static void R_Subsector(size_t num)
polysec = po->lines[0]->backsector; polysec = po->lines[0]->backsector;
ffloor[numffloors].plane = NULL; ffloor[numffloors].plane = NULL;
if (polysec->floorheight <= frontsector->ceilingheight if (polysec->floorheight <= ceilingcenterz
&& polysec->floorheight >= frontsector->floorheight && polysec->floorheight >= floorcenterz
&& (viewz < polysec->floorheight)) && (viewz < polysec->floorheight))
{ {
fixed_t xoff, yoff; fixed_t xoff, yoff;
@ -1118,11 +1123,13 @@ static void R_Subsector(size_t num)
polysec->floorpic_angle-po->angle, polysec->floorpic_angle-po->angle,
NULL, NULL,
NULL NULL
#ifdef POLYOBJECTS_PLANES
, po
#endif
#ifdef ESLOPE #ifdef ESLOPE
, NULL // will ffloors be slopable eventually? , NULL // will ffloors be slopable eventually?
#endif #endif
); );
//ffloor[numffloors].plane->polyobj = po;
ffloor[numffloors].height = polysec->floorheight; ffloor[numffloors].height = polysec->floorheight;
ffloor[numffloors].polyobj = po; ffloor[numffloors].polyobj = po;
@ -1139,8 +1146,8 @@ static void R_Subsector(size_t num)
ffloor[numffloors].plane = NULL; ffloor[numffloors].plane = NULL;
if (polysec->ceilingheight >= frontsector->floorheight if (polysec->ceilingheight >= floorcenterz
&& polysec->ceilingheight <= frontsector->ceilingheight && polysec->ceilingheight <= ceilingcenterz
&& (viewz > polysec->ceilingheight)) && (viewz > polysec->ceilingheight))
{ {
fixed_t xoff, yoff; fixed_t xoff, yoff;
@ -1162,11 +1169,13 @@ static void R_Subsector(size_t num)
ffloor[numffloors].plane = R_FindPlane(polysec->ceilingheight, polysec->ceilingpic, ffloor[numffloors].plane = R_FindPlane(polysec->ceilingheight, polysec->ceilingpic,
polysec->lightlevel, xoff, yoff, polysec->ceilingpic_angle-po->angle, polysec->lightlevel, xoff, yoff, polysec->ceilingpic_angle-po->angle,
NULL, NULL NULL, NULL
#ifdef POLYOBJECTS_PLANES
, po
#endif
#ifdef ESLOPE #ifdef ESLOPE
, NULL // will ffloors be slopable eventually? , NULL // will ffloors be slopable eventually?
#endif #endif
); );
//ffloor[numffloors].plane->polyobj = po;
ffloor[numffloors].polyobj = po; ffloor[numffloors].polyobj = po;
ffloor[numffloors].height = polysec->ceilingheight; ffloor[numffloors].height = polysec->ceilingheight;
@ -1232,7 +1241,7 @@ void R_Prep3DFloors(sector_t *sector)
INT32 count, i, mapnum; INT32 count, i, mapnum;
sector_t *sec; sector_t *sec;
#ifdef ESLOPE #ifdef ESLOPE
pslope_t *bestslope; pslope_t *bestslope = NULL;
fixed_t heighttest; // I think it's better to check the Z height at the sector's center fixed_t heighttest; // I think it's better to check the Z height at the sector's center
// than assume unsloped heights are accurate indicators of order in sloped sectors. -Red // than assume unsloped heights are accurate indicators of order in sloped sectors. -Red
#endif #endif

View file

@ -303,6 +303,32 @@ done:
return blocktex; return blocktex;
} }
//
// R_GetTextureNum
//
// Returns the actual texture id that we should use.
// This can either be texnum, the current frame for texnum's anim (if animated),
// or 0 if not valid.
//
INT32 R_GetTextureNum(INT32 texnum)
{
if (texnum < 0 || texnum >= numtextures)
return 0;
return texturetranslation[texnum];
}
//
// R_CheckTextureCache
//
// Use this if you need to make sure the texture is cached before R_GetColumn calls
// e.g.: midtextures and FOF walls
//
void R_CheckTextureCache(INT32 tex)
{
if (!texturecache[tex])
R_GenerateTexture(tex);
}
// //
// R_GetColumn // R_GetColumn
// //
@ -1499,6 +1525,9 @@ void R_InitData(void)
CONS_Printf("R_LoadTextures()...\n"); CONS_Printf("R_LoadTextures()...\n");
R_LoadTextures(); R_LoadTextures();
CONS_Printf("P_InitPicAnims()...\n");
P_InitPicAnims();
CONS_Printf("R_InitSprites()...\n"); CONS_Printf("R_InitSprites()...\n");
R_InitSpriteLumps(); R_InitSpriteLumps();
R_InitSprites(); R_InitSprites();

View file

@ -30,7 +30,7 @@ typedef struct
{ {
// Block origin (always UL), which has already accounted for the internal origin of the patch. // Block origin (always UL), which has already accounted for the internal origin of the patch.
INT16 originx, originy; INT16 originx, originy;
INT16 wad, lump; UINT16 wad, lump;
} texpatch_t; } texpatch_t;
// A maptexturedef_t describes a rectangular texture, // A maptexturedef_t describes a rectangular texture,
@ -65,6 +65,9 @@ extern CV_PossibleValue_t Color_cons_t[];
void R_LoadTextures(void); void R_LoadTextures(void);
void R_FlushTextureCache(void); void R_FlushTextureCache(void);
INT32 R_GetTextureNum(INT32 texnum);
void R_CheckTextureCache(INT32 tex);
// Retrieve column data for span blitting. // Retrieve column data for span blitting.
UINT8 *R_GetColumn(fixed_t tex, INT32 col); UINT8 *R_GetColumn(fixed_t tex, INT32 col);

View file

@ -203,6 +203,7 @@ typedef struct r_lightlist_s
fixed_t heightstep; fixed_t heightstep;
fixed_t botheight; fixed_t botheight;
fixed_t botheightstep; fixed_t botheightstep;
fixed_t startheight; // for repeating midtextures
INT16 lightlevel; INT16 lightlevel;
extracolormap_t *extra_colormap; extracolormap_t *extra_colormap;
lighttable_t *rcolormap; lighttable_t *rcolormap;
@ -224,15 +225,6 @@ typedef struct linechain_s
// ZDoom C++ to Legacy C conversion Tails 04-29-2002 (for slopes)
typedef struct secplane_t
{
// the plane is defined as a*x + b*y + c*z + d = 0
// ic is 1/c, for faster Z calculations
fixed_t a, b, c, d, ic;
} secplane_t;
// Slopes // Slopes
#ifdef ESLOPE #ifdef ESLOPE
typedef enum { typedef enum {
@ -392,6 +384,7 @@ typedef struct sector_s
#endif #endif
// these are saved for netgames, so do not let Lua touch these! // these are saved for netgames, so do not let Lua touch these!
INT32 spawn_nexttag, spawn_firsttag; // the actual nexttag/firsttag values may differ if the sector's tag was changed
// offsets sector spawned with (via linedef type 7) // offsets sector spawned with (via linedef type 7)
fixed_t spawn_flr_xoffs, spawn_flr_yoffs; fixed_t spawn_flr_xoffs, spawn_flr_yoffs;
@ -500,10 +493,10 @@ typedef struct subsector_s
// Sector list node showing all sectors an object appears in. // Sector list node showing all sectors an object appears in.
// //
// There are two threads that flow through these nodes. The first thread // There are two threads that flow through these nodes. The first thread
// starts at touching_thinglist in a sector_t and flows through the m_snext // starts at touching_thinglist in a sector_t and flows through the m_thinglist_next
// links to find all mobjs that are entirely or partially in the sector. // links to find all mobjs that are entirely or partially in the sector.
// The second thread starts at touching_sectorlist in an mobj_t and flows // The second thread starts at touching_sectorlist in an mobj_t and flows
// through the m_tnext links to find all sectors a thing touches. This is // through the m_sectorlist_next links to find all sectors a thing touches. This is
// useful when applying friction or push effects to sectors. These effects // useful when applying friction or push effects to sectors. These effects
// can be done as thinkers that act upon all objects touching their sectors. // can be done as thinkers that act upon all objects touching their sectors.
// As an mobj moves through the world, these nodes are created and // As an mobj moves through the world, these nodes are created and
@ -515,10 +508,10 @@ typedef struct msecnode_s
{ {
sector_t *m_sector; // a sector containing this object sector_t *m_sector; // a sector containing this object
struct mobj_s *m_thing; // this object struct mobj_s *m_thing; // this object
struct msecnode_s *m_tprev; // prev msecnode_t for this thing struct msecnode_s *m_sectorlist_prev; // prev msecnode_t for this thing
struct msecnode_s *m_tnext; // next msecnode_t for this thing struct msecnode_s *m_sectorlist_next; // next msecnode_t for this thing
struct msecnode_s *m_sprev; // prev msecnode_t for this sector struct msecnode_s *m_thinglist_prev; // prev msecnode_t for this sector
struct msecnode_s *m_snext; // next msecnode_t for this sector struct msecnode_s *m_thinglist_next; // next msecnode_t for this sector
boolean visited; // used in search algorithms boolean visited; // used in search algorithms
} msecnode_t; } msecnode_t;
@ -526,10 +519,10 @@ typedef struct mprecipsecnode_s
{ {
sector_t *m_sector; // a sector containing this object sector_t *m_sector; // a sector containing this object
struct precipmobj_s *m_thing; // this object struct precipmobj_s *m_thing; // this object
struct mprecipsecnode_s *m_tprev; // prev msecnode_t for this thing struct mprecipsecnode_s *m_sectorlist_prev; // prev msecnode_t for this thing
struct mprecipsecnode_s *m_tnext; // next msecnode_t for this thing struct mprecipsecnode_s *m_sectorlist_next; // next msecnode_t for this thing
struct mprecipsecnode_s *m_sprev; // prev msecnode_t for this sector struct mprecipsecnode_s *m_thinglist_prev; // prev msecnode_t for this sector
struct mprecipsecnode_s *m_snext; // next msecnode_t for this sector struct mprecipsecnode_s *m_thinglist_next; // next msecnode_t for this sector
boolean visited; // used in search algorithms boolean visited; // used in search algorithms
} mprecipsecnode_t; } mprecipsecnode_t;

View file

@ -874,9 +874,9 @@ void R_DrawTiltedSplat_8(void)
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
val = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]]; val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
*dest = val; *dest = colormap[val];
dest++; dest++;
iz += ds_sz.x; iz += ds_sz.x;
uz += ds_su.x; uz += ds_su.x;
@ -913,9 +913,9 @@ void R_DrawTiltedSplat_8(void)
for (i = SPANSIZE-1; i >= 0; i--) for (i = SPANSIZE-1; i >= 0; i--)
{ {
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
val = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]]; val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
*dest = val; *dest = colormap[val];
dest++; dest++;
u += stepu; u += stepu;
v += stepv; v += stepv;
@ -931,9 +931,9 @@ void R_DrawTiltedSplat_8(void)
u = (INT64)(startu); u = (INT64)(startu);
v = (INT64)(startv); v = (INT64)(startv);
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
val = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]]; val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
*dest = val; *dest = colormap[val];
} }
else else
{ {
@ -954,9 +954,9 @@ void R_DrawTiltedSplat_8(void)
for (; width != 0; width--) for (; width != 0; width--)
{ {
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
val = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]]; val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
*dest = val; *dest = colormap[val];
dest++; dest++;
u += stepu; u += stepu;
v += stepv; v += stepv;
@ -1124,49 +1124,49 @@ void R_DrawTranslucentSplat_8 (void)
// need! // need!
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]; val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
dest[0] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + dest[0])]; dest[0] = colormap[*(ds_transmap + (val << 8) + dest[0])];
xposition += xstep; xposition += xstep;
yposition += ystep; yposition += ystep;
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]; val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
dest[1] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + dest[1])]; dest[1] = colormap[*(ds_transmap + (val << 8) + dest[1])];
xposition += xstep; xposition += xstep;
yposition += ystep; yposition += ystep;
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]; val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
dest[2] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + dest[2])]; dest[2] = colormap[*(ds_transmap + (val << 8) + dest[2])];
xposition += xstep; xposition += xstep;
yposition += ystep; yposition += ystep;
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]; val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
dest[3] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + dest[3])]; dest[3] = colormap[*(ds_transmap + (val << 8) + dest[3])];
xposition += xstep; xposition += xstep;
yposition += ystep; yposition += ystep;
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]; val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
dest[4] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + dest[4])]; dest[4] = colormap[*(ds_transmap + (val << 8) + dest[4])];
xposition += xstep; xposition += xstep;
yposition += ystep; yposition += ystep;
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]; val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
dest[5] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + dest[5])]; dest[5] = colormap[*(ds_transmap + (val << 8) + dest[5])];
xposition += xstep; xposition += xstep;
yposition += ystep; yposition += ystep;
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]; val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
dest[6] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + dest[6])]; dest[6] = colormap[*(ds_transmap + (val << 8) + dest[6])];
xposition += xstep; xposition += xstep;
yposition += ystep; yposition += ystep;
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]; val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
dest[7] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + dest[7])]; dest[7] = colormap[*(ds_transmap + (val << 8) + dest[7])];
xposition += xstep; xposition += xstep;
yposition += ystep; yposition += ystep;
@ -1175,9 +1175,9 @@ void R_DrawTranslucentSplat_8 (void)
} }
while (count--) while (count--)
{ {
val =colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]]; val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
*dest = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dest)]; *dest = colormap[*(ds_transmap + (val << 8) + *dest)];
dest++; dest++;
xposition += xstep; xposition += xstep;
@ -1363,7 +1363,19 @@ void R_DrawColumnShadowed_8(void)
height = dc_lightlist[i].height >> LIGHTSCALESHIFT; height = dc_lightlist[i].height >> LIGHTSCALESHIFT;
if (solid) if (solid)
{
bheight = dc_lightlist[i].botheight >> LIGHTSCALESHIFT; bheight = dc_lightlist[i].botheight >> LIGHTSCALESHIFT;
if (bheight < height)
{
// confounded slopes sometimes allow partial invertedness,
// even including cases where the top and bottom heights
// should actually be the same!
// swap the height values as a workaround for this quirk
INT32 temp = height;
height = bheight;
bheight = temp;
}
}
if (height <= dc_yl) if (height <= dc_yl)
{ {
dc_colormap = dc_lightlist[i].rcolormap; dc_colormap = dc_lightlist[i].rcolormap;

View file

@ -366,69 +366,6 @@ fixed_t R_PointToDist(fixed_t x, fixed_t y)
return R_PointToDist2(viewx, viewy, x, y); return R_PointToDist2(viewx, viewy, x, y);
} }
/***************************************
*** Zdoom C++ to Legacy C conversion ***
****************************************/
// Utility to find the Z height at an XY location in a sector (for slopes)
fixed_t R_SecplaneZatPoint(secplane_t *secplane, fixed_t x, fixed_t y)
{
return FixedMul(secplane->ic, -secplane->d - DMulScale16(secplane->a, x, secplane->b, y));
}
// Returns the value of z at (x,y) if d is equal to dist
fixed_t R_SecplaneZatPointDist (secplane_t *secplane, fixed_t x, fixed_t y, fixed_t dist)
{
return FixedMul(secplane->ic, -dist - DMulScale16(secplane->a, x, secplane->b, y));
}
// Flips the plane's vertical orientiation, so that if it pointed up,
// it will point down, and vice versa.
void R_SecplaneFlipVert(secplane_t *secplane)
{
secplane->a = -secplane->a;
secplane->b = -secplane->b;
secplane->c = -secplane->c;
secplane->d = -secplane->d;
secplane->ic = -secplane->ic;
}
// Returns true if 2 planes are the same
boolean R_ArePlanesSame(secplane_t *original, secplane_t *other)
{
return original->a == other->a && original->b == other->b
&& original->c == other->c && original->d == other->d;
}
// Returns true if 2 planes are different
boolean R_ArePlanesDifferent(secplane_t *original, secplane_t *other)
{
return original->a != other->a || original->b != other->b
|| original->c != other->c || original->d != other->d;
}
// Moves a plane up/down by hdiff units
void R_SecplaneChangeHeight(secplane_t *secplane, fixed_t hdiff)
{
secplane->d = secplane->d - FixedMul(hdiff, secplane->c);
}
// Returns how much this plane's height would change if d were set to oldd
fixed_t R_SecplaneHeightDiff(secplane_t *secplane, fixed_t oldd)
{
return FixedMul(oldd - secplane->d, secplane->ic);
}
fixed_t R_SecplanePointToDist(secplane_t *secplane, fixed_t x, fixed_t y, fixed_t z)
{
return -TMulScale16(secplane->a, x, y, secplane->b, z, secplane->c);
}
fixed_t R_SecplanePointToDist2(secplane_t *secplane, fixed_t x, fixed_t y, fixed_t z)
{
return -TMulScale16(secplane->a, x, secplane->b, y, z, secplane->c);
}
// //
// R_ScaleFromGlobalAngle // R_ScaleFromGlobalAngle
// Returns the texture mapping scale for the current line (horizontal span) // Returns the texture mapping scale for the current line (horizontal span)
@ -795,7 +732,8 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y)
ret = &subsectors[nodenum & ~NF_SUBSECTOR]; ret = &subsectors[nodenum & ~NF_SUBSECTOR];
for (i = 0; i < ret->numlines; i++) for (i = 0; i < ret->numlines; i++)
if (R_PointOnSegSide(x, y, &segs[ret->firstline + i])) //if (R_PointOnSegSide(x, y, &segs[ret->firstline + i])) -- breaks in ogl because polyvertex_t cast over vertex pointers
if (P_PointOnLineSide(x, y, segs[ret->firstline + i].linedef) != segs[ret->firstline + i].side)
return 0; return 0;
return ret; return ret;
@ -919,9 +857,9 @@ void R_SkyboxFrame(player_t *player)
} }
} }
if (mh->skybox_scalez > 0) if (mh->skybox_scalez > 0)
viewz += player->awayviewmobj->z / mh->skybox_scalez; viewz += (player->awayviewmobj->z + 20*FRACUNIT) / mh->skybox_scalez;
else if (mh->skybox_scalez < 0) else if (mh->skybox_scalez < 0)
viewz += player->awayviewmobj->z * -mh->skybox_scalez; viewz += (player->awayviewmobj->z + 20*FRACUNIT) * -mh->skybox_scalez;
} }
else if (thiscam->chase) else if (thiscam->chase)
{ {
@ -966,9 +904,9 @@ void R_SkyboxFrame(player_t *player)
} }
} }
if (mh->skybox_scalez > 0) if (mh->skybox_scalez > 0)
viewz += thiscam->z / mh->skybox_scalez; viewz += (thiscam->z + (thiscam->height>>1)) / mh->skybox_scalez;
else if (mh->skybox_scalez < 0) else if (mh->skybox_scalez < 0)
viewz += thiscam->z * -mh->skybox_scalez; viewz += (thiscam->z + (thiscam->height>>1)) * -mh->skybox_scalez;
} }
else else
{ {

View file

@ -61,18 +61,6 @@ angle_t R_PointToAngle2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1);
fixed_t R_PointToDist(fixed_t x, fixed_t y); fixed_t R_PointToDist(fixed_t x, fixed_t y);
fixed_t R_PointToDist2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1); fixed_t R_PointToDist2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1);
// ZDoom C++ to Legacy C conversion Tails 04-29-2002
fixed_t R_SecplaneZatPoint(secplane_t *secplane, fixed_t x, fixed_t y);
fixed_t R_SecplaneZatPointDist(secplane_t *secplane, fixed_t x, fixed_t y,
fixed_t dist);
void R_SecplaneFlipVert(secplane_t *secplane);
boolean R_ArePlanesSame(secplane_t *original, secplane_t *other);
boolean R_ArePlanesDifferent(secplane_t *original, secplane_t *other);
void R_SecplaneChangeHeight(secplane_t *secplane, fixed_t hdiff);
fixed_t R_SecplaneHeightDiff(secplane_t *secplane, fixed_t oldd);
fixed_t R_SecplanePointToDist(secplane_t *secplane, fixed_t x, fixed_t y, fixed_t z);
fixed_t R_SecplanePointToDist2(secplane_t *secplane, fixed_t x, fixed_t y, fixed_t z);
fixed_t R_ScaleFromGlobalAngle(angle_t visangle); fixed_t R_ScaleFromGlobalAngle(angle_t visangle);
subsector_t *R_PointInSubsector(fixed_t x, fixed_t y); subsector_t *R_PointInSubsector(fixed_t x, fixed_t y);
subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y); subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y);

View file

@ -431,6 +431,9 @@ static visplane_t *new_visplane(unsigned hash)
visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
fixed_t xoff, fixed_t yoff, angle_t plangle, extracolormap_t *planecolormap, fixed_t xoff, fixed_t yoff, angle_t plangle, extracolormap_t *planecolormap,
ffloor_t *pfloor ffloor_t *pfloor
#ifdef POLYOBJECTS_PLANES
, polyobj_t *polyobj
#endif
#ifdef ESLOPE #ifdef ESLOPE
, pslope_t *slope , pslope_t *slope
#endif #endif
@ -470,6 +473,8 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
#ifdef POLYOBJECTS_PLANES #ifdef POLYOBJECTS_PLANES
if (check->polyobj && pfloor) if (check->polyobj && pfloor)
continue; continue;
if (polyobj != check->polyobj)
continue;
#endif #endif
if (height == check->height && picnum == check->picnum if (height == check->height && picnum == check->picnum
&& lightlevel == check->lightlevel && lightlevel == check->lightlevel
@ -504,7 +509,7 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
check->viewangle = viewangle; check->viewangle = viewangle;
check->plangle = plangle; check->plangle = plangle;
#ifdef POLYOBJECTS_PLANES #ifdef POLYOBJECTS_PLANES
check->polyobj = NULL; check->polyobj = polyobj;
#endif #endif
#ifdef ESLOPE #ifdef ESLOPE
check->slope = slope; check->slope = slope;
@ -719,7 +724,11 @@ void R_DrawPlanes(void)
continue; continue;
} }
if (pl->ffloor != NULL) if (pl->ffloor != NULL
#ifdef POLYOBJECTS_PLANES
|| pl->polyobj != NULL
#endif
)
continue; continue;
R_DrawSinglePlane(pl); R_DrawSinglePlane(pl);
@ -955,8 +964,8 @@ void R_DrawSinglePlane(visplane_t *pl)
// Okay, look, don't ask me why this works, but without this setup there's a disgusting-looking misalignment with the textures. -Red // Okay, look, don't ask me why this works, but without this setup there's a disgusting-looking misalignment with the textures. -Red
fudge = ((1<<nflatshiftup)+1.0f)/(1<<nflatshiftup); fudge = ((1<<nflatshiftup)+1.0f)/(1<<nflatshiftup);
xoffs *= fudge; xoffs = (fixed_t)(xoffs*fudge);
yoffs /= fudge; yoffs = (fixed_t)(yoffs/fudge);
vx = FIXED_TO_FLOAT(pl->viewx+xoffs); vx = FIXED_TO_FLOAT(pl->viewx+xoffs);
vy = FIXED_TO_FLOAT(pl->viewy-yoffs); vy = FIXED_TO_FLOAT(pl->viewy-yoffs);

View file

@ -87,7 +87,7 @@ extern lighttable_t **planezlight;
extern fixed_t *yslope; extern fixed_t *yslope;
extern fixed_t distscale[MAXVIDWIDTH]; extern fixed_t distscale[MAXVIDWIDTH];
void R_InitPlanes(void); FUNCMATH void R_InitPlanes(void);
void R_PortalStoreClipValues(INT32 start, INT32 end, INT16 *ceil, INT16 *floor, fixed_t *scale); void R_PortalStoreClipValues(INT32 start, INT32 end, INT16 *ceil, INT16 *floor, fixed_t *scale);
void R_PortalRestoreClipValues(INT32 start, INT32 end, INT16 *ceil, INT16 *floor, fixed_t *scale); void R_PortalRestoreClipValues(INT32 start, INT32 end, INT16 *ceil, INT16 *floor, fixed_t *scale);
void R_ClearPlanes(void); void R_ClearPlanes(void);
@ -97,6 +97,9 @@ void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2);
void R_DrawPlanes(void); void R_DrawPlanes(void);
visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, fixed_t xoff, fixed_t yoff, angle_t plangle, visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, fixed_t xoff, fixed_t yoff, angle_t plangle,
extracolormap_t *planecolormap, ffloor_t *ffloor extracolormap_t *planecolormap, ffloor_t *ffloor
#ifdef POLYOBJECTS_PLANES
, polyobj_t *polyobj
#endif
#ifdef ESLOPE #ifdef ESLOPE
, pslope_t *slope , pslope_t *slope
#endif #endif

View file

@ -300,7 +300,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
curline = ds->curline; curline = ds->curline;
frontsector = curline->frontsector; frontsector = curline->frontsector;
backsector = curline->backsector; backsector = curline->backsector;
texnum = texturetranslation[curline->sidedef->midtexture]; texnum = R_GetTextureNum(curline->sidedef->midtexture);
windowbottom = windowtop = sprbotscreen = INT32_MAX; windowbottom = windowtop = sprbotscreen = INT32_MAX;
// hack translucent linedef types (900-909 for transtables 1-9) // hack translucent linedef types (900-909 for transtables 1-9)
@ -344,6 +344,9 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
rw_scalestep = ds->scalestep; rw_scalestep = ds->scalestep;
spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep; spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep;
// Texture must be cached before setting colfunc_2s,
// otherwise texture[texnum]->holes may be false when it shouldn't be
R_CheckTextureCache(texnum);
// handle case where multipatch texture is drawn on a 2sided wall, multi-patch textures // handle case where multipatch texture is drawn on a 2sided wall, multi-patch textures
// are not stored per-column with post info in SRB2 // are not stored per-column with post info in SRB2
if (textures[texnum]->holes) if (textures[texnum]->holes)
@ -391,6 +394,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
rlight->height = (centeryfrac) - FixedMul((light->height - viewz), spryscale); rlight->height = (centeryfrac) - FixedMul((light->height - viewz), spryscale);
rlight->heightstep = -FixedMul(rw_scalestep, (light->height - viewz)); rlight->heightstep = -FixedMul(rw_scalestep, (light->height - viewz));
#endif #endif
rlight->startheight = rlight->height; // keep starting value here to reset for each repeat
rlight->lightlevel = *light->lightlevel; rlight->lightlevel = *light->lightlevel;
rlight->extra_colormap = light->extra_colormap; rlight->extra_colormap = light->extra_colormap;
rlight->flags = light->flags; rlight->flags = light->flags;
@ -484,6 +488,14 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
{ {
rw_scalestep = ds->scalestep; rw_scalestep = ds->scalestep;
spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep; spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep;
if (dc_numlights)
{ // reset all lights to their starting heights
for (i = 0; i < dc_numlights; i++)
{
rlight = &dc_lightlist[i];
rlight->height = rlight->startheight;
}
}
} }
#ifndef ESLOPE #ifndef ESLOPE
@ -694,10 +706,13 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
// Loop through R_DrawMaskedColumn calls // Loop through R_DrawMaskedColumn calls
static void R_DrawRepeatMaskedColumn(column_t *col) static void R_DrawRepeatMaskedColumn(column_t *col)
{ {
do { while (sprtopscreen < sprbotscreen) {
R_DrawMaskedColumn(col); R_DrawMaskedColumn(col);
sprtopscreen += dc_texheight*spryscale; if ((INT64)sprtopscreen + dc_texheight*spryscale > (INT64)INT32_MAX) // prevent overflow
} while (sprtopscreen < sprbotscreen); sprtopscreen = INT32_MAX;
else
sprtopscreen += dc_texheight*spryscale;
}
} }
// //
@ -740,7 +755,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
curline = ds->curline; curline = ds->curline;
backsector = pfloor->target; backsector = pfloor->target;
frontsector = curline->frontsector == pfloor->target ? curline->backsector : curline->frontsector; frontsector = curline->frontsector == pfloor->target ? curline->backsector : curline->frontsector;
texnum = texturetranslation[sides[pfloor->master->sidenum[0]].midtexture]; texnum = R_GetTextureNum(sides[pfloor->master->sidenum[0]].midtexture);
colfunc = wallcolfunc; colfunc = wallcolfunc;
@ -748,7 +763,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
{ {
size_t linenum = curline->linedef-backsector->lines[0]; size_t linenum = curline->linedef-backsector->lines[0];
newline = pfloor->master->frontsector->lines[0] + linenum; newline = pfloor->master->frontsector->lines[0] + linenum;
texnum = texturetranslation[sides[newline->sidenum[0]].midtexture]; texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture);
} }
if (pfloor->flags & FF_TRANSLUCENT) if (pfloor->flags & FF_TRANSLUCENT)
@ -979,6 +994,9 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
dc_texturemid += offsetvalue; dc_texturemid += offsetvalue;
// Texture must be cached before setting colfunc_2s,
// otherwise texture[texnum]->holes may be false when it shouldn't be
R_CheckTextureCache(texnum);
//faB: handle case where multipatch texture is drawn on a 2sided wall, multi-patch textures //faB: handle case where multipatch texture is drawn on a 2sided wall, multi-patch textures
// are not stored per-column with post info anymore in Doom Legacy // are not stored per-column with post info anymore in Doom Legacy
if (textures[texnum]->holes) if (textures[texnum]->holes)
@ -1499,7 +1517,7 @@ static void R_RenderSegLoop (void)
{ {
// note: don't use min/max macros, since casting from INT32 to INT16 is involved here // note: don't use min/max macros, since casting from INT32 to INT16 is involved here
if (markceiling) if (markceiling)
ceilingclip[rw_x] = (yh >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1; ceilingclip[rw_x] = (yl >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1;
if (markfloor) if (markfloor)
floorclip[rw_x] = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight; floorclip[rw_x] = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight;
} }
@ -1534,10 +1552,10 @@ static void R_RenderSegLoop (void)
ceilingclip[rw_x] = -1; ceilingclip[rw_x] = -1;
} }
else else
ceilingclip[rw_x] = (yh >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1; ceilingclip[rw_x] = (yl >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1;
} }
else if (markceiling) // no top wall else if (markceiling) // no top wall
ceilingclip[rw_x] = (yh >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1; ceilingclip[rw_x] = (yl >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1;
if (bottomtexture) if (bottomtexture)
{ {
@ -1889,25 +1907,28 @@ void R_StoreWallRange(INT32 start, INT32 stop)
if (!backsector) if (!backsector)
{ {
fixed_t texheight;
// single sided line // single sided line
midtexture = texturetranslation[sidedef->midtexture]; midtexture = R_GetTextureNum(sidedef->midtexture);
texheight = textureheight[midtexture];
// a single sided line is terminal, so it must mark ends // a single sided line is terminal, so it must mark ends
markfloor = markceiling = true; markfloor = markceiling = true;
#ifdef ESLOPE #ifdef ESLOPE
if (!(linedef->flags & ML_EFFECT1)) { if (linedef->flags & ML_EFFECT2) {
if (linedef->flags & ML_DONTPEGBOTTOM) if (linedef->flags & ML_DONTPEGBOTTOM)
rw_midtexturemid = frontsector->floorheight + textureheight[sidedef->midtexture] - viewz; rw_midtexturemid = frontsector->floorheight + texheight - viewz;
else else
rw_midtexturemid = frontsector->ceilingheight; rw_midtexturemid = frontsector->ceilingheight - viewz;
} }
else
#endif #endif
if (linedef->flags & ML_DONTPEGBOTTOM) if (linedef->flags & ML_DONTPEGBOTTOM)
{ {
#ifdef ESLOPE #ifdef ESLOPE
rw_midtexturemid = worldbottom + textureheight[sidedef->midtexture]; rw_midtexturemid = worldbottom + texheight;
rw_midtextureslide = floorfrontslide; rw_midtextureslide = floorfrontslide;
#else #else
vtop = frontsector->floorheight + textureheight[sidedef->midtexture]; vtop = frontsector->floorheight + texheight;
// bottom of texture at bottom // bottom of texture at bottom
rw_midtexturemid = vtop - viewz; rw_midtexturemid = vtop - viewz;
#endif #endif
@ -2139,76 +2160,50 @@ void R_StoreWallRange(INT32 start, INT32 stop)
#endif #endif
) )
{ {
fixed_t texheight;
// top texture // top texture
if ((linedef->flags & (ML_DONTPEGTOP) && (linedef->flags & ML_DONTPEGBOTTOM)) if ((linedef->flags & (ML_DONTPEGTOP) && (linedef->flags & ML_DONTPEGBOTTOM))
&& linedef->sidenum[1] != 0xffff) && linedef->sidenum[1] != 0xffff)
{ {
// Special case... use offsets from 2nd side but only if it has a texture. // Special case... use offsets from 2nd side but only if it has a texture.
side_t *def = &sides[linedef->sidenum[1]]; side_t *def = &sides[linedef->sidenum[1]];
toptexture = texturetranslation[def->toptexture]; toptexture = R_GetTextureNum(def->toptexture);
if (!toptexture) //Second side has no texture, use the first side's instead. if (!toptexture) //Second side has no texture, use the first side's instead.
toptexture = texturetranslation[sidedef->toptexture]; toptexture = R_GetTextureNum(sidedef->toptexture);
texheight = textureheight[toptexture];
#ifdef ESLOPE
if (!(linedef->flags & ML_EFFECT1)) { // Ignore slopes for lower/upper textures unless flag is checked
if (linedef->flags & ML_DONTPEGTOP)
rw_toptexturemid = frontsector->ceilingheight - viewz;
else
rw_toptexturemid = backsector->ceilingheight - viewz;
} else
#endif
if (linedef->flags & ML_DONTPEGTOP)
{
// top of texture at top
rw_toptexturemid = worldtop;
#ifdef ESLOPE
rw_toptextureslide = ceilingfrontslide;
#endif
}
else
{
#ifdef ESLOPE
rw_toptexturemid = worldhigh + textureheight[def->toptexture];
rw_toptextureslide = ceilingbackslide;
#else
vtop = backsector->ceilingheight + textureheight[def->toptexture];
// bottom of texture
rw_toptexturemid = vtop - viewz;
#endif
}
} }
else else
{ {
toptexture = texturetranslation[sidedef->toptexture]; toptexture = R_GetTextureNum(sidedef->toptexture);
texheight = textureheight[toptexture];
}
#ifdef ESLOPE #ifdef ESLOPE
if (!(linedef->flags & ML_EFFECT1)) { // Ignore slopes for lower/upper textures unless flag is checked if (!(linedef->flags & ML_EFFECT1)) { // Ignore slopes for lower/upper textures unless flag is checked
if (linedef->flags & ML_DONTPEGTOP)
rw_toptexturemid = frontsector->ceilingheight - viewz;
else
rw_toptexturemid = backsector->ceilingheight - viewz;
} else
#endif
if (linedef->flags & ML_DONTPEGTOP) if (linedef->flags & ML_DONTPEGTOP)
{ rw_toptexturemid = frontsector->ceilingheight - viewz;
// top of texture at top
rw_toptexturemid = worldtop;
#ifdef ESLOPE
rw_toptextureslide = ceilingfrontslide;
#endif
}
else else
{ rw_toptexturemid = backsector->ceilingheight - viewz;
#ifdef ESLOPE } else
rw_toptexturemid = worldhigh + textureheight[sidedef->toptexture]; #endif
rw_toptextureslide = ceilingbackslide; if (linedef->flags & ML_DONTPEGTOP)
#else {
vtop = backsector->ceilingheight + textureheight[sidedef->toptexture]; // top of texture at top
// bottom of texture rw_toptexturemid = worldtop;
rw_toptexturemid = vtop - viewz; #ifdef ESLOPE
rw_toptextureslide = ceilingfrontslide;
#endif
}
else
{
#ifdef ESLOPE
rw_toptexturemid = worldhigh + texheight;
rw_toptextureslide = ceilingbackslide;
#else
vtop = backsector->ceilingheight + texheight;
// bottom of texture
rw_toptexturemid = vtop - viewz;
#endif #endif
}
} }
} }
// check BOTTOM TEXTURE // check BOTTOM TEXTURE
@ -2219,7 +2214,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
) //seulement si VISIBLE!!! ) //seulement si VISIBLE!!!
{ {
// bottom texture // bottom texture
bottomtexture = texturetranslation[sidedef->bottomtexture]; bottomtexture = R_GetTextureNum(sidedef->bottomtexture);
#ifdef ESLOPE #ifdef ESLOPE
if (!(linedef->flags & ML_EFFECT1)) { // Ignore slopes for lower/upper textures unless flag is checked if (!(linedef->flags & ML_EFFECT1)) { // Ignore slopes for lower/upper textures unless flag is checked
@ -2504,7 +2499,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
ds_p->numthicksides = numthicksides = i; ds_p->numthicksides = numthicksides = i;
} }
if (sidedef->midtexture) if (sidedef->midtexture > 0 && sidedef->midtexture < numtextures)
{ {
// masked midtexture // masked midtexture
if (!ds_p->thicksidecol) if (!ds_p->thicksidecol)
@ -2516,8 +2511,17 @@ void R_StoreWallRange(INT32 start, INT32 stop)
ds_p->maskedtexturecol = ds_p->thicksidecol; ds_p->maskedtexturecol = ds_p->thicksidecol;
#ifdef ESLOPE #ifdef ESLOPE
maskedtextureheight = &(ds_p->maskedtextureheight[0]); // ???? maskedtextureheight = ds_p->maskedtextureheight; // note to red, this == &(ds_p->maskedtextureheight[0])
#ifdef POLYOBJECTS
if (curline->polyseg) { // use REAL front and back floors please, so midtexture rendering isn't mucked up
rw_midtextureslide = rw_midtexturebackslide = 0;
if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3))
rw_midtexturemid = rw_midtextureback = max(curline->frontsector->floorheight, curline->backsector->floorheight) - viewz;
else
rw_midtexturemid = rw_midtextureback = min(curline->frontsector->ceilingheight, curline->backsector->ceilingheight) - viewz;
} else
#endif
// Set midtexture starting height // Set midtexture starting height
if (linedef->flags & ML_EFFECT2) { // Ignore slopes when texturing if (linedef->flags & ML_EFFECT2) { // Ignore slopes when texturing
rw_midtextureslide = rw_midtexturebackslide = 0; rw_midtextureslide = rw_midtexturebackslide = 0;
@ -3102,12 +3106,12 @@ void R_StoreWallRange(INT32 start, INT32 stop)
if (maskedtexture && !(ds_p->silhouette & SIL_TOP)) if (maskedtexture && !(ds_p->silhouette & SIL_TOP))
{ {
ds_p->silhouette |= SIL_TOP; ds_p->silhouette |= SIL_TOP;
ds_p->tsilheight = sidedef->midtexture ? INT32_MIN: INT32_MAX; ds_p->tsilheight = (sidedef->midtexture > 0 && sidedef->midtexture < numtextures) ? INT32_MIN: INT32_MAX;
} }
if (maskedtexture && !(ds_p->silhouette & SIL_BOTTOM)) if (maskedtexture && !(ds_p->silhouette & SIL_BOTTOM))
{ {
ds_p->silhouette |= SIL_BOTTOM; ds_p->silhouette |= SIL_BOTTOM;
ds_p->bsilheight = sidedef->midtexture ? INT32_MAX: INT32_MIN; ds_p->bsilheight = (sidedef->midtexture > 0 && sidedef->midtexture < numtextures) ? INT32_MAX: INT32_MIN;
} }
ds_p++; ds_p++;
} }

View file

@ -63,7 +63,11 @@ typedef struct floorsplat_s
fixed_t P_SegLength(seg_t *seg); fixed_t P_SegLength(seg_t *seg);
// call at P_SetupLevel() // call at P_SetupLevel()
#if !(defined (WALLSPLATS) || defined (FLOORSPLATS))
FUNCMATH void R_ClearLevelSplats(void);
#else
void R_ClearLevelSplats(void); void R_ClearLevelSplats(void);
#endif
#ifdef WALLSPLATS #ifdef WALLSPLATS
void R_AddWallSplat(line_t *wallline, INT16 sectorside, const char *patchname, fixed_t top, void R_AddWallSplat(line_t *wallline, INT16 sectorside, const char *patchname, fixed_t top,

View file

@ -281,7 +281,7 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef,
{ {
case 0xff: case 0xff:
// no rotations were found for that frame at all // no rotations were found for that frame at all
I_Error("R_AddSingleSpriteDef: No patches found for %s frame %c", sprname, R_Frame2Char(frame)); I_Error("R_AddSingleSpriteDef: No patches found for %.4s frame %c", sprname, R_Frame2Char(frame));
break; break;
case 0: case 0:
@ -294,7 +294,7 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef,
// we test the patch lump, or the id lump whatever // we test the patch lump, or the id lump whatever
// if it was not loaded the two are LUMPERROR // if it was not loaded the two are LUMPERROR
if (sprtemp[frame].lumppat[rotation] == LUMPERROR) if (sprtemp[frame].lumppat[rotation] == LUMPERROR)
I_Error("R_AddSingleSpriteDef: Sprite %s frame %c is missing rotations", I_Error("R_AddSingleSpriteDef: Sprite %.4s frame %c is missing rotations",
sprname, R_Frame2Char(frame)); sprname, R_Frame2Char(frame));
break; break;
} }
@ -1635,7 +1635,8 @@ void R_SortVisSprites(void)
// Fix first and last. ds still points to the last one after the loop // Fix first and last. ds still points to the last one after the loop
dsfirst->prev = &unsorted; dsfirst->prev = &unsorted;
unsorted.next = dsfirst; unsorted.next = dsfirst;
ds->next = &unsorted; if (ds)
ds->next = &unsorted;
unsorted.prev = ds; unsorted.prev = ds;
// pull the vissprites out by scale // pull the vissprites out by scale
@ -1699,21 +1700,25 @@ static void R_CreateDrawNodes(void)
entry->ffloor = ds->thicksides[i]; entry->ffloor = ds->thicksides[i];
} }
} }
#ifdef POLYOBJECTS_PLANES
// Check for a polyobject plane, but only if this is a front line
if (ds->curline->polyseg && ds->curline->polyseg->visplane && !ds->curline->side) {
plane = ds->curline->polyseg->visplane;
R_PlaneBounds(plane);
if (plane->low < con_clipviewtop || plane->high > vid.height || plane->high > plane->low)
;
else {
// Put it in!
entry = R_CreateDrawNode(&nodehead);
entry->plane = plane;
entry->seg = ds;
}
ds->curline->polyseg->visplane = NULL;
}
#endif
if (ds->maskedtexturecol) if (ds->maskedtexturecol)
{ {
#ifdef POLYOBJECTS_PLANES
// Check for a polyobject plane, but only if this is a front line
if (ds->curline->polyseg && ds->curline->polyseg->visplane && !ds->curline->side) {
// Put it in!
entry = R_CreateDrawNode(&nodehead);
entry->plane = ds->curline->polyseg->visplane;
entry->seg = ds;
ds->curline->polyseg->visplane->polyobj = ds->curline->polyseg;
ds->curline->polyseg->visplane = NULL;
}
#endif
entry = R_CreateDrawNode(&nodehead); entry = R_CreateDrawNode(&nodehead);
entry->seg = ds; entry->seg = ds;
} }
@ -1756,6 +1761,29 @@ static void R_CreateDrawNodes(void)
} }
} }
#ifdef POLYOBJECTS_PLANES
// find all the remaining polyobject planes and add them on the end of the list
// probably this is a terrible idea if we wanted them to be sorted properly
// but it works getting them in for now
for (i = 0; i < numPolyObjects; i++)
{
if (!PolyObjects[i].visplane)
continue;
plane = PolyObjects[i].visplane;
R_PlaneBounds(plane);
if (plane->low < con_clipviewtop || plane->high > vid.height || plane->high > plane->low)
{
PolyObjects[i].visplane = NULL;
continue;
}
entry = R_CreateDrawNode(&nodehead);
entry->plane = plane;
// note: no seg is set, for what should be obvious reasons
PolyObjects[i].visplane = NULL;
}
#endif
if (visspritecount == 0) if (visspritecount == 0)
return; return;
@ -1812,13 +1840,16 @@ static void R_CreateDrawNodes(void)
if (x1 < r2->plane->minx) x1 = r2->plane->minx; if (x1 < r2->plane->minx) x1 = r2->plane->minx;
if (x2 > r2->plane->maxx) x2 = r2->plane->maxx; if (x2 > r2->plane->maxx) x2 = r2->plane->maxx;
for (i = x1; i <= x2; i++) if (r2->seg) // if no seg set, assume the whole thing is in front or something stupid
{ {
if (r2->seg->frontscale[i] > rover->scale) for (i = x1; i <= x2; i++)
break; {
if (r2->seg->frontscale[i] > rover->scale)
break;
}
if (i > x2)
continue;
} }
if (i > x2)
continue;
entry = R_CreateDrawNode(NULL); entry = R_CreateDrawNode(NULL);
(entry->prev = r2->prev)->next = entry; (entry->prev = r2->prev)->next = entry;

Some files were not shown because too many files have changed in this diff Show more