Merge branch 'next' into cv-can-change

This commit is contained in:
Logan Aerl Arias 2023-12-31 12:06:27 -05:00
commit b700c3a8bf
125 changed files with 5786 additions and 4079 deletions

1
.gitattributes vendored
View file

@ -10,6 +10,7 @@
/src/Make*.cfg text=auto /src/Make*.cfg text=auto
/src/CMakeLists.txt text=auto /src/CMakeLists.txt text=auto
*.mk -whitespace text=auto *.mk -whitespace text=auto
/comptime.sh text eol=lf
# Windows EOL # Windows EOL
*.cs -crlf -whitespace *.cs -crlf -whitespace
*.bat -crlf -whitespace *.bat -crlf -whitespace

View file

@ -3,7 +3,7 @@ variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_CONCURRENT_ID/$CI_PROJECT_PATH GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_CONCURRENT_ID/$CI_PROJECT_PATH
default: default:
image: debian:stable-slim image: git.do.srb2.org:5050/stjr/srb2ci/srb2ci:stable
cache: cache:
- key: ccache-$CI_PROJECT_PATH_SLUG-$CI_JOB_NAME_SLUG - key: ccache-$CI_PROJECT_PATH_SLUG-$CI_JOB_NAME_SLUG
@ -19,6 +19,11 @@ default:
- apt-cache - apt-cache
unprotect: true unprotect: true
- key: apk-$CI_JOB_IMAGE
paths:
- apk-cache
unprotect: true
before_script: before_script:
- - | - - |
# debconf # debconf
@ -159,11 +164,18 @@ stages:
Debian testing GCC: Debian testing GCC:
stage: build stage: build
when: manual
image: debian:testing-slim image: debian:testing-slim
allow_failure: true allow_failure: true
artifacts: artifacts:
paths:
- "bin/"
- "src/comptime.h"
expose_as: "testing-gcc"
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-testing-gcc" name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-testing-gcc"
variables: variables:
@ -198,6 +210,8 @@ Debian testing GCC:
Windows x86: Windows x86:
stage: build stage: build
when: on_success
artifacts: artifacts:
paths: paths:
- "bin/" - "bin/"
@ -228,6 +242,8 @@ Windows x86:
Debian stable:amd64: Debian stable:amd64:
stage: build stage: build
when: on_success
artifacts: artifacts:
paths: paths:
- "bin/" - "bin/"
@ -270,6 +286,8 @@ Debian stable:amd64:
Debian stable:i386: Debian stable:i386:
stage: build stage: build
when: manual
artifacts: artifacts:
paths: paths:
- "bin/" - "bin/"
@ -311,6 +329,8 @@ Debian stable:i386:
Debian stable:arm64: Debian stable:arm64:
stage: build stage: build
when: manual
artifacts: artifacts:
paths: paths:
- "bin/" - "bin/"
@ -345,7 +365,7 @@ Debian stable:arm64:
- - | - - |
# make # make
echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2" echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
- make --directory=src --keep-going CCACHE=1 ERRORMODE=1 LINUX64=1 ERRORMODE=1 NONX86=1C || make --directory=src --keep-going CCACHE=1 ERRORMODE=1 LINUX64=1 NONX86=1 ARM64=1 - make --directory=src --keep-going CCACHE=1 ERRORMODE=1 LINUX64=1 ERRORMODE=1 NONX86=1 ARM64=1 || make --directory=src --keep-going CCACHE=1 ERRORMODE=1 LINUX64=1 NONX86=1 ARM64=1
- | - |
# make # make
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K" echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
@ -353,6 +373,8 @@ Debian stable:arm64:
Windows x64: Windows x64:
stage: build stage: build
when: manual
artifacts: artifacts:
paths: paths:
- "bin/" - "bin/"
@ -383,9 +405,15 @@ Windows x64:
Debian stable Clang: Debian stable Clang:
stage: build stage: build
when: manual
allow_failure: true allow_failure: true
artifacts: artifacts:
paths:
- "bin/"
- "src/comptime.h"
expose_as: "clang"
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-clang" name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-clang"
variables: variables:
@ -422,9 +450,15 @@ Debian stable Clang:
Debian stable musl: Debian stable musl:
stage: build stage: build
when: manual
allow_failure: true allow_failure: true
artifacts: artifacts:
paths:
- "bin/"
- "src/comptime.h"
expose_as: "musl"
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-musl" name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-musl"
variables: variables:
@ -459,9 +493,15 @@ Debian stable musl:
Debian testing Clang: Debian testing Clang:
extends: Debian stable Clang extends: Debian stable Clang
when: manual
image: debian:testing-slim image: debian:testing-slim
artifacts: artifacts:
paths:
- "bin/"
- "src/comptime.h"
expose_as: "testing-clang"
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-testing-clang" name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-testing-clang"
variables: variables:
@ -473,12 +513,148 @@ Debian testing Clang:
Debian testing musl: Debian testing musl:
extends: Debian stable musl extends: Debian stable musl
when: manual
image: debian:testing-slim image: debian:testing-slim
artifacts: artifacts:
paths:
- "bin/"
- "src/comptime.h"
expose_as: "testing-musl"
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-testing-musl" name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-testing-musl"
variables: variables:
CC: musl-gcc CC: musl-gcc
LDD: musl-ldd LDD: musl-ldd
LDFLAGS: -Wl,-fuse-ld=gold LDFLAGS: -Wl,-fuse-ld=gold
Alpine 3 GCC:
stage: build
when: on_success
image: alpine:3
allow_failure: true
artifacts:
paths:
- "bin/"
- "src/comptime.h"
expose_as: "Apline-3"
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-Apline-3"
before_script:
- - |
# apk_cache
echo -e "\e[0Ksection_start:`date +%s`:apk_cache[collapsed=true]\r\e[0KUpdating APK listing"
- export APK_CACHE_DIR=`pwd`/apk-cache
- mkdir --parents --verbose $APK_CACHE_DIR/
- ln -sf /etc/apk/cache $APK_CACHE_DIR
- |
# apk_cache
echo -e "\e[0Ksection_end:`date +%s`:apk_cache\r\e[0K"
- - |
# apk_update
echo -e "\e[0Ksection_start:`date +%s`:apk_update[collapsed=true]\r\e[0KUpdating APK listing"
- apk update
- |
# apk_update
echo -e "\e[0Ksection_end:`date +%s`:apk_update\r\e[0K"
- - |
# apk_upgrade
echo -e "\e[0Ksection_start:`date +%s`:apk_upgrade[collapsed=true]\r\e[0KUpdating existing packages"
- apk upgrade
- |
# apk_update
echo -e "\e[0Ksection_end:`date +%s`:apk_upgrade\r\e[0K"
- - |
# apk_common
echo -e "\e[0Ksection_start:`date +%s`:apk_common[collapsed=true]\r\e[0KInstalling common packages"
- apk add make git ccache nasm
- |
# apk_common
echo -e "\e[0Ksection_end:`date +%s`:apk_common\r\e[0K"
- - |
# ccache_config
echo -e "\e[0Ksection_start:`date +%s`:ccache_config[collapsed=true]\r\e[0KSetting up ccache config"
- mkdir --parents --verbose ~/.ccache/
- touch ~/.ccache/ccache.conf
- |
# cache.conf
echo Adding ccache configution option
- |
# base_dir
echo base_dir = $PWD | tee -a ~/.ccache/ccache.conf
- |
# cache_dir
echo cache_dir = $PWD/ccache | tee -a ~/.ccache/ccache.conf
- |
# compiler_check
echo compiler_check = content | tee -a ~/.ccache/ccache.conf
- |
# stats_log
echo stats_log = $PWD/ccache_statslog | tee -a ~/.ccache/ccache.conf
- |
# max_size
echo max_size = 50M | tee -a ~/.ccache/ccache.conf
- |
# ccache_config
echo -e "\e[0Ksection_end:`date +%s`:ccache_config\r\e[0K"
- - |
# cache_reset
echo -e "\e[0Ksection_start:`date +%s`:ccache_reset[collapsed=true]\r\e[0KResetting ccache statistics"
- ccache --zero-stats
- ccache --show-stats
- |
# ccache_reset
echo -e "\e[0Ksection_end:`date +%s`:ccache_reset\r\e[0K"
script:
- - |
# apk_toolchain
echo -e "\e[0Ksection_start:`date +%s`:apk_toolchain[collapsed=true]\r\e[0KInstalling toolchain packages"
- apk add gcc
- |
# apk_toolchain
echo -e "\e[0Ksection_end:`date +%s`:apk_toolchain\r\e[0K"
- - |
# apk_development
echo -e "\e[0Ksection_start:`date +%s`:apk_development[collapsed=true]\r\e[0KInstalling development packages"
- apk add musl-dev sdl2_mixer-dev libpng-dev curl-dev libgme-dev libopenmpt-dev
- |
# apk_development
echo -e "\e[0Ksection_end:`date +%s`:apk_development\r\e[0K"
- - |
# make
echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
- make --directory=src --keep-going CCACHE=1 ERRORMODE=1 NONX86=1 NOEXECINFO=1 || make --directory=src --keep-going CCACHE=1 ERRORMODE=1 NONX86=1 NOEXECINFO=1
- |
# make
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
after_script:
- - |
# apk_clean
echo -e "\e[0Ksection_start:`date +%s`:apk_clean[collapsed=true]\r\e[0KCleaning of unneeded APK packages"
- apk cache clean
- |
# apk_clean
echo -e "\e[0Ksection_end:`date +%s`:apk_clean\r\e[0K"
- - |
# ccache_stats
echo -e "\e[0Ksection_start:`date +%s`:ccache_stats[collapsed=true]\r\e[0Kccache statistics:"
- ccache --show-stats --verbose
- ccache --show-log-stats --verbose
- |
# ccahe_stats
echo -e "\e[0Ksection_end:`date +%s`:ccache_stats\r\e[0K"

View file

@ -75,6 +75,7 @@ option(SRB2_CONFIG_ERRORMODE "Compile C code with warnings treated as errors." O
option(SRB2_CONFIG_DEBUGMODE "Compile with PARANOIA, ZDEBUG, RANGECHECK and PACKETDROP defined." OFF) option(SRB2_CONFIG_DEBUGMODE "Compile with PARANOIA, ZDEBUG, RANGECHECK and PACKETDROP defined." OFF)
option(SRB2_CONFIG_MOBJCONSISTANCY "Compile with MOBJCONSISTANCY defined." OFF) option(SRB2_CONFIG_MOBJCONSISTANCY "Compile with MOBJCONSISTANCY defined." OFF)
option(SRB2_CONFIG_PACKETDROP "Compile with PACKETDROP defined." OFF) option(SRB2_CONFIG_PACKETDROP "Compile with PACKETDROP defined." OFF)
option(SRB2_CONFIG_EXECINFO "Enable stack trace dump support." ON)
option(SRB2_CONFIG_ZDEBUG "Compile with ZDEBUG defined." OFF) option(SRB2_CONFIG_ZDEBUG "Compile with ZDEBUG defined." OFF)
# SRB2_CONFIG_PROFILEMODE is probably superceded by some CMake setting. # SRB2_CONFIG_PROFILEMODE is probably superceded by some CMake setting.
option(SRB2_CONFIG_PROFILEMODE "Compile for profiling (GCC only)." OFF) option(SRB2_CONFIG_PROFILEMODE "Compile for profiling (GCC only)." OFF)

View file

@ -1,4 +1,4 @@
version: 2.2.13.{branch}-{build} version: 2.2.14.{branch}-{build}
os: MinGW os: MinGW
environment: environment:

View file

@ -1,6 +1,7 @@
@echo off @echo off
set BRA=Unknown set BRA=Unknown
set REV=illegal set REV=illegal
set GL1=Dummy
copy nul: /b +%1\comptime.c tmp.$$$ > nul copy nul: /b +%1\comptime.c tmp.$$$ > nul
move tmp.$$$ %1\comptime.c > nul move tmp.$$$ %1\comptime.c > nul
@ -13,8 +14,9 @@ goto filwri
:gitrev :gitrev
set GIT=%2 set GIT=%2
if "%GIT%"=="" set GIT=git if "%GIT%"=="" set GIT=git
for /f "usebackq" %%s in (`%GIT% rev-parse --abbrev-ref HEAD`) do @set BRA=%%s for /f "tokens=* usebackq" %%s in (`%GIT% rev-parse --abbrev-ref HEAD`) do @set BRA=%%s
for /f "usebackq" %%s in (`%GIT% rev-parse HEAD`) do @set REV=%%s for /f "tokens=* usebackq" %%s in (`%GIT% rev-parse HEAD`) do @set REV=%%s
for /f "tokens=* usebackq" %%s in (`%GIT% log -1 --format^=%%f`) do @set GL1=%%s
set REV=%REV:~0,8% set REV=%REV:~0,8%
goto filwri goto filwri
@ -30,3 +32,4 @@ echo // by the %0 batch file >> %1\comptime.h
echo // >> %1\comptime.h echo // >> %1\comptime.h
echo const char* compbranch = "%BRA%"; >> %1\comptime.h echo const char* compbranch = "%BRA%"; >> %1\comptime.h
echo const char* comprevision = "%REV%"; >> %1\comptime.h echo const char* comprevision = "%REV%"; >> %1\comptime.h
echo const char* compnote = "%GL1%"; >> %1\comptime.h

View file

@ -12,24 +12,26 @@ version() {
// //
const char* compbranch = "$1"; const char* compbranch = "$1";
const char* comprevision = "$2"; const char* comprevision = "$2";
const char* compnote = "$3";
EOF EOF
} }
versiongit() { versiongit() {
gitbranch="$(git rev-parse --abbrev-ref HEAD)" gitbranch="$(git rev-parse --abbrev-ref HEAD)"
gitversion="$(git rev-parse HEAD | cut -c -8)" gitversion="$(git rev-parse HEAD | cut -c -8)"
version "$gitbranch" "$gitversion"; gitsubject="$(git log -1 --format=%f)"
version "$gitbranch" "$gitversion" "$gitsubject";
exit 0 exit 0
} }
versionsvn() { versionsvn() {
svnrevision="$(svnversion -n "$1")" svnrevision="$(svnversion -n "$1")"
version "Subversion" "r$svnrevision"; version "Subversion" "r$svnrevision" "dummy";
exit 0 exit 0
} }
versionfake() { versionfake() {
version "Unknown" "illegal"; version "Unknown" "illegal" "dummy";
} }
compversion() { compversion() {

View file

@ -99,6 +99,7 @@ add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32
lua_blockmaplib.c lua_blockmaplib.c
lua_hudlib.c lua_hudlib.c
lua_hudlib_drawlist.c lua_hudlib_drawlist.c
lua_colorlib.c
lua_inputlib.c lua_inputlib.c
) )
@ -253,6 +254,7 @@ target_compile_options(SRB2SDL2 PRIVATE
-Winline -Winline
-Wformat-y2k -Wformat-y2k
-Wformat-security -Wformat-security
-fwrapv
$<$<VERSION_LESS:$<C_COMPILER_VERSION>,2.9.5>: $<$<VERSION_LESS:$<C_COMPILER_VERSION>,2.9.5>:
-Wno-div-by-zero -Wno-div-by-zero
@ -276,7 +278,7 @@ target_compile_options(SRB2SDL2 PRIVATE
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.5.0>: $<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.5.0>:
-Wlogical-op -Wlogical-op
-Wno-error=array-bounds #-Wno-error=array-bounds
> >
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.6.0>: $<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.6.0>:
@ -322,6 +324,7 @@ target_compile_options(SRB2SDL2 PRIVATE
-Wno-error=non-literal-null-conversion -Wno-error=non-literal-null-conversion
-Wno-error=constant-conversion -Wno-error=constant-conversion
-Wno-error=unused-but-set-variable -Wno-error=unused-but-set-variable
-fwrapv
> >
# C, MSVC # C, MSVC
@ -375,6 +378,11 @@ endif()
if(SRB2_CONFIG_PACKETDROP) if(SRB2_CONFIG_PACKETDROP)
target_compile_definitions(SRB2SDL2 PRIVATE -DPACKETDROP) target_compile_definitions(SRB2SDL2 PRIVATE -DPACKETDROP)
endif() endif()
if(SRB2_CONFIG_EXECINFO)
else()
target_compile_definitions(SRB2SDL2 PRIVATE -DNOEXECINFO)
message(STATUS "You have disabled stack trace dump support")
endif()
if(SRB2_CONFIG_ZDEBUG) if(SRB2_CONFIG_ZDEBUG)
target_compile_definitions(SRB2SDL2 PRIVATE -DZDEBUG) target_compile_definitions(SRB2SDL2 PRIVATE -DZDEBUG)
endif() endif()

View file

@ -66,6 +66,7 @@
# NOPOSTPROCESSING=1 - ? # NOPOSTPROCESSING=1 - ?
# MOBJCONSISTANCY=1 - ?? # MOBJCONSISTANCY=1 - ??
# PACKETDROP=1 - ?? # PACKETDROP=1 - ??
# NOEXECINFO=1 - Disable stack trace dump support
# DEBUGMODE=1 - Enable various debugging capabilities. # DEBUGMODE=1 - Enable various debugging capabilities.
# Also disables optimizations. # Also disables optimizations.
# NOZLIB=1 - Disable some compression capability. Implies # NOZLIB=1 - Disable some compression capability. Implies
@ -164,7 +165,7 @@ sources:=
makedir:=../make makedir:=../make
# -DCOMPVERSION: flag to use comptime.h # -DCOMPVERSION: flag to use comptime.h
opts:=-DCOMPVERSION -g opts:=-DCOMPVERSION -g -fwrapv
libs:= libs:=
# This is a list of variables names, of which if defined, # This is a list of variables names, of which if defined,

View file

@ -5,7 +5,7 @@
passthru_opts+=\ passthru_opts+=\
NO_IPV6 NOHW NOMD5 NOPOSTPROCESSING\ NO_IPV6 NOHW NOMD5 NOPOSTPROCESSING\
MOBJCONSISTANCY PACKETDROP ZDEBUG\ MOBJCONSISTANCY PACKETDROP ZDEBUG\
HAVE_MINIUPNPC\ HAVE_MINIUPNPC NOEXECINFO\
# build with debugging information # build with debugging information
ifdef DEBUGMODE ifdef DEBUGMODE

View file

@ -116,7 +116,7 @@ ifdef GCC43
#WFLAGS+=-Wno-error=clobbered #WFLAGS+=-Wno-error=clobbered
endif endif
ifdef GCC44 ifdef GCC44
WFLAGS+=-Wno-error=array-bounds #WFLAGS+=-Wno-error=array-bounds
endif endif
ifdef GCC46 ifdef GCC46
WFLAGS+=-Wno-error=suggest-attribute=noreturn WFLAGS+=-Wno-error=suggest-attribute=noreturn

View file

@ -94,3 +94,4 @@ lua_blockmaplib.c
lua_hudlib.c lua_hudlib.c
lua_hudlib_drawlist.c lua_hudlib_drawlist.c
lua_inputlib.c lua_inputlib.c
lua_colorlib.c

View file

@ -239,7 +239,8 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
// SPINNING // SPINNING
if (!(player->pflags & (PF_SPINNING|PF_STARTDASH)) && mem->thinkstate == AI_SPINFOLLOW) if (!(player->pflags & (PF_SPINNING|PF_STARTDASH)) && mem->thinkstate == AI_SPINFOLLOW)
mem->thinkstate = AI_FOLLOW; mem->thinkstate = AI_FOLLOW;
else if (mem->thinkstate == AI_FOLLOW || mem->thinkstate == AI_SPINFOLLOW) else if ((mem->thinkstate == AI_FOLLOW || mem->thinkstate == AI_SPINFOLLOW)
&& bot->charability2 == CA2_SPINDASH)
{ {
if (!_2d) if (!_2d)
{ {
@ -329,7 +330,7 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
if (mem->thinkstate == AI_FOLLOW || mem->thinkstate == AI_CATCHUP || (mem->thinkstate == AI_SPINFOLLOW && player->pflags & PF_JUMPED)) if (mem->thinkstate == AI_FOLLOW || mem->thinkstate == AI_CATCHUP || (mem->thinkstate == AI_SPINFOLLOW && player->pflags & PF_JUMPED))
{ {
// Flying catch-up // Flying catch-up
if (bot->pflags & PF_THOKKED) if (bot->charability == CA_FLY && bot->pflags & PF_THOKKED)
{ {
cmd->forwardmove = min(MAXPLMOVE, (dist/scale)>>3); cmd->forwardmove = min(MAXPLMOVE, (dist/scale)>>3);
if (zdist < -64*scale) if (zdist < -64*scale)
@ -583,11 +584,11 @@ void B_RespawnBot(INT32 playernum)
P_SetOrigin(tails, x, y, z); P_SetOrigin(tails, x, y, z);
if (player->charability == CA_FLY) if (player->charability == CA_FLY)
{ {
P_SetPlayerMobjState(tails, S_PLAY_FLY); P_SetMobjState(tails, S_PLAY_FLY);
tails->player->powers[pw_tailsfly] = (UINT16)-1; tails->player->powers[pw_tailsfly] = (UINT16)-1;
} }
else else
P_SetPlayerMobjState(tails, S_PLAY_FALL); P_SetMobjState(tails, S_PLAY_FALL);
P_SetScale(tails, sonic->scale); P_SetScale(tails, sonic->scale);
tails->destscale = sonic->destscale; tails->destscale = sonic->destscale;
} }
@ -613,6 +614,9 @@ void B_HandleFlightIndicator(player_t *player)
// otherwise, spawn it // otherwise, spawn it
P_SetTarget(&tails->hnext, P_SpawnMobjFromMobj(tails, 0, 0, 0, MT_OVERLAY)); P_SetTarget(&tails->hnext, P_SpawnMobjFromMobj(tails, 0, 0, 0, MT_OVERLAY));
if (P_MobjWasRemoved(tails->hnext))
return; // we can't spawn one, so it can't exist
P_SetTarget(&tails->hnext->target, tails); P_SetTarget(&tails->hnext->target, tails);
P_SetTarget(&tails->hnext->hprev, tails); P_SetTarget(&tails->hnext->hprev, tails);
P_SetMobjState(tails->hnext, S_FLIGHTINDICATOR); P_SetMobjState(tails->hnext, S_FLIGHTINDICATOR);

View file

@ -275,18 +275,36 @@ static int luaB_dofile (lua_State *L) {
int n = lua_gettop(L); int n = lua_gettop(L);
if (!W_FileHasFolders(wadfiles[numwadfiles - 1])) if (!W_FileHasFolders(wadfiles[numwadfiles - 1]))
luaL_error(L, "dofile() only works with PK3 files"); luaL_error(L, "dofile() only works with PK3 files and folders");
snprintf(fullfilename, sizeof(fullfilename), "Lua/%s", filename); snprintf(fullfilename, sizeof(fullfilename), "Lua/%s", filename);
lumpnum = W_CheckNumForFullNamePK3(fullfilename, numwadfiles - 1, 0); lumpnum = W_CheckNumForFullNamePK3(fullfilename, numwadfiles - 1, 0);
if (lumpnum == INT16_MAX) if (lumpnum == INT16_MAX)
luaL_error(L, "can't find script " LUA_QS, fullfilename); luaL_error(L, "can't find script " LUA_QS, fullfilename);
LUA_LoadLump(numwadfiles - 1, lumpnum, false); LUA_DoLump(numwadfiles - 1, lumpnum, false);
return lua_gettop(L) - n; return lua_gettop(L) - n;
} }
// Edited to load PK3 entries instead
static int luaB_loadfile (lua_State *L) {
const char *filename = luaL_checkstring(L, 1);
char fullfilename[256];
UINT16 lumpnum;
if (!W_FileHasFolders(wadfiles[numwadfiles - 1]))
luaL_error(L, "loadfile() only works with PK3 files and folders");
snprintf(fullfilename, sizeof(fullfilename), "Lua/%s", filename);
lumpnum = W_CheckNumForFullNamePK3(fullfilename, numwadfiles - 1, 0);
if (lumpnum == INT16_MAX)
luaL_error(L, "can't find script " LUA_QS, fullfilename);
LUA_LoadLump(numwadfiles - 1, lumpnum);
return 1;
}
static int luaB_assert (lua_State *L) { static int luaB_assert (lua_State *L) {
luaL_checkany(L, 1); luaL_checkany(L, 1);
@ -406,6 +424,7 @@ static const luaL_Reg base_funcs[] = {
{"collectgarbage", luaB_collectgarbage}, {"collectgarbage", luaB_collectgarbage},
{"error", luaB_error}, {"error", luaB_error},
{"dofile", luaB_dofile}, {"dofile", luaB_dofile},
{"loadfile", luaB_loadfile},
{"gcinfo", luaB_gcinfo}, {"gcinfo", luaB_gcinfo},
{"getfenv", luaB_getfenv}, {"getfenv", luaB_getfenv},
{"getmetatable", luaB_getmetatable}, {"getmetatable", luaB_getmetatable},

View file

@ -51,9 +51,11 @@ static void COM_CEchoDuration_f(void);
static void COM_Exec_f(void); static void COM_Exec_f(void);
static void COM_Wait_f(void); static void COM_Wait_f(void);
static void COM_Help_f(void); static void COM_Help_f(void);
static void COM_Find_f(void);
static void COM_Toggle_f(void); static void COM_Toggle_f(void);
static void COM_Add_f(void); static void COM_Add_f(void);
static void CV_EnforceExecVersion(void); static void CV_EnforceExecVersion(void);
static boolean CV_FilterVarByVersion(consvar_t *v, const char *valstr); static boolean CV_FilterVarByVersion(consvar_t *v, const char *valstr);
static boolean CV_Command(void); static boolean CV_Command(void);
@ -344,6 +346,7 @@ void COM_Init(void)
COM_AddCommand("exec", COM_Exec_f, 0); COM_AddCommand("exec", COM_Exec_f, 0);
COM_AddCommand("wait", COM_Wait_f, 0); COM_AddCommand("wait", COM_Wait_f, 0);
COM_AddCommand("help", COM_Help_f, COM_LUA); COM_AddCommand("help", COM_Help_f, COM_LUA);
COM_AddCommand("find", COM_Find_f, COM_LUA);
COM_AddCommand("toggle", COM_Toggle_f, COM_LUA); COM_AddCommand("toggle", COM_Toggle_f, COM_LUA);
COM_AddCommand("add", COM_Add_f, COM_LUA); COM_AddCommand("add", COM_Add_f, COM_LUA);
RegisterNetXCmd(XD_NETVAR, Got_NetVar); RegisterNetXCmd(XD_NETVAR, Got_NetVar);
@ -879,7 +882,7 @@ static void COM_Help_f(void)
boolean floatmode = false; boolean floatmode = false;
const char *cvalue = NULL; const char *cvalue = NULL;
CONS_Printf("\x82""Variable %s:\n", cvar->name); CONS_Printf("\x82""Variable %s:\n", cvar->name);
CONS_Printf(M_GetText(" flags :")); CONS_Printf(M_GetText(" flags: "));
if (cvar->flags & CV_SAVE) if (cvar->flags & CV_SAVE)
CONS_Printf("AUTOSAVE "); CONS_Printf("AUTOSAVE ");
if (cvar->flags & CV_FLOAT) if (cvar->flags & CV_FLOAT)
@ -976,31 +979,8 @@ static void COM_Help_f(void)
return; return;
} }
CONS_Printf("No exact match, searching...\n"); CONS_Printf("No variable or command named %s", help);
CONS_Printf("\x82""\nCheck wiki.srb2.org for more or try typing help without arguments\n");
// variables
CONS_Printf("\x82""Variables:\n");
for (cvar = consvar_vars; cvar; cvar = cvar->next)
{
if ((cvar->flags & CV_NOSHOWHELP) || (!strstr(cvar->name, help)))
continue;
CONS_Printf("%s ", cvar->name);
i++;
}
// commands
CONS_Printf("\x82""\nCommands:\n");
for (cmd = com_commands; cmd; cmd = cmd->next)
{
if (!strstr(cmd->name, help))
continue;
CONS_Printf("%s ",cmd->name);
i++;
}
CONS_Printf("\x82""\nCheck wiki.srb2.org for more or type help <command or variable>\n");
CONS_Debug(DBG_GAMELOGIC, "\x87Total : %d\n", i);
} }
return; return;
} }
@ -1030,6 +1010,76 @@ static void COM_Help_f(void)
} }
} }
static void COM_Find_f(void)
{
static char prefix[80];
xcommand_t *cmd;
consvar_t *cvar;
cmdalias_t *alias;
const char *match;
const char *help;
size_t helplen;
boolean matchesany;
if (COM_Argc() != 2)
{
CONS_Printf(M_GetText("find <text>: Search for variables, commands and aliases containing <text>\n"));
return;
}
help = COM_Argv(1);
helplen = strlen(help);
CONS_Printf("\x82""Variables:\n");
matchesany = false;
for (cvar = consvar_vars; cvar; cvar = cvar->next)
{
if (cvar->flags & CV_NOSHOWHELP)
continue;
match = strstr(cvar->name, help);
if (match != NULL)
{
memcpy(prefix, cvar->name, match - cvar->name);
prefix[match - cvar->name] = '\0';
CONS_Printf(" %s\x83%s\x80%s\n", prefix, help, &match[helplen]);
matchesany = true;
}
}
if (!matchesany)
CONS_Printf(" (none)\n");
CONS_Printf("\x82""Commands:\n");
matchesany = false;
for (cmd = com_commands; cmd; cmd = cmd->next)
{
match = strstr(cmd->name, help);
if (match != NULL)
{
memcpy(prefix, cmd->name, match - cmd->name);
prefix[match - cmd->name] = '\0';
CONS_Printf(" %s\x83%s\x80%s\n", prefix, help, &match[helplen]);
matchesany = true;
}
}
if (!matchesany)
CONS_Printf(" (none)\n");
CONS_Printf("\x82""Aliases:\n");
matchesany = false;
for (alias = com_alias; alias; alias = alias->next)
{
match = strstr(alias->name, help);
if (match != NULL)
{
memcpy(prefix, alias->name, match - alias->name);
prefix[match - alias->name] = '\0';
CONS_Printf(" %s\x83%s\x80%s\n", prefix, help, &match[helplen]);
matchesany = true;
}
}
if (!matchesany)
CONS_Printf(" (none)\n");
}
/** Toggles a console variable. Useful for on/off values. /** Toggles a console variable. Useful for on/off values.
* *
* This works on on/off, yes/no values only * This works on on/off, yes/no values only

View file

@ -220,13 +220,16 @@ static char *bindtable[NUMINPUTS];
static void CONS_Bind_f(void) static void CONS_Bind_f(void)
{ {
size_t na; size_t na;
char *newcmd;
//size_t newlen = 0;
unsigned int i;
INT32 key; INT32 key;
na = COM_Argc(); na = COM_Argc();
if (na != 2 && na != 3) if (na < 2)
{ {
CONS_Printf(M_GetText("bind <keyname> [<command>]: create shortcut keys to command(s)\n")); CONS_Printf(M_GetText("bind <keyname> [<command>] [<arg1>] [...]: create shortcut keys to command(s)\n"));
CONS_Printf("\x82%s", M_GetText("Bind table :\n")); CONS_Printf("\x82%s", M_GetText("Bind table :\n"));
na = 0; na = 0;
for (key = 0; key < NUMINPUTS; key++) for (key = 0; key < NUMINPUTS; key++)
@ -250,8 +253,36 @@ static void CONS_Bind_f(void)
Z_Free(bindtable[key]); Z_Free(bindtable[key]);
bindtable[key] = NULL; bindtable[key] = NULL;
if (na == 3) if (na < 3)
bindtable[key] = Z_StrDup(COM_Argv(2)); return;
for (i = 2; i < na; ++i)
{
const char *arg = COM_Argv(i);
// on the second iteration, and after
if (i > 2)
{
size_t newlen = strlen(bindtable[key]) + strlen(arg) + 1; // new length, allow space for ' ' and '\0'
size_t curpos = newcmd - bindtable[key]; // offset from newcmd to original pointer
newcmd = bindtable[key] = Z_Realloc(bindtable[key], newlen, PU_STATIC, NULL);
newcmd += curpos; // reapply offset
newcmd[0] = ' '; // replace previous '\0' w/ ' '
++newcmd; // make sure later strcpy doesnt overwrite ' '
}
// first iteration
else
// allocate space for argument and a ' ' or '\0'
newcmd = bindtable[key] = Z_Calloc(strlen(arg) + 1, PU_STATIC, NULL);
// the copy
strcpy(newcmd, arg);
// move window past copied argument for next iteration
newcmd += strlen(arg);
}
} }
//====================================================================== //======================================================================
@ -921,7 +952,8 @@ boolean CON_Responder(event_t *ev)
static UINT8 consdown = false; // console is treated differently due to rare usage static UINT8 consdown = false; // console is treated differently due to rare usage
// sequential completions a la 4dos // sequential completions a la 4dos
static char completion[80]; static char completioncmd[80 + sizeof("find ")] = "find ";
static char *completion = &completioncmd[sizeof("find ")-1];
static INT32 skips; static INT32 skips;
@ -936,7 +968,7 @@ boolean CON_Responder(event_t *ev)
return false; return false;
// 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_text && ev->type != ev_console)
{ {
if (ev->key == gamecontrol[GC_CONSOLE][0] || ev->key == gamecontrol[GC_CONSOLE][1]) if (ev->key == gamecontrol[GC_CONSOLE][0] || ev->key == gamecontrol[GC_CONSOLE][1])
consdown = false; consdown = false;
@ -951,7 +983,7 @@ boolean CON_Responder(event_t *ev)
if (modeattacking || metalrecording || marathonmode) if (modeattacking || metalrecording || marathonmode)
return false; return false;
if (key == gamecontrol[GC_CONSOLE][0] || key == gamecontrol[GC_CONSOLE][1]) if ((key == gamecontrol[GC_CONSOLE][0] || key == gamecontrol[GC_CONSOLE][1]) && !shiftdown)
{ {
if (consdown) // ignore repeat if (consdown) // ignore repeat
return true; return true;
@ -963,7 +995,7 @@ boolean CON_Responder(event_t *ev)
// check other keys only if console prompt is active // check other keys only if console prompt is active
if (!consoleready && key < NUMINPUTS) // metzgermeister: boundary check!! if (!consoleready && key < NUMINPUTS) // metzgermeister: boundary check!!
{ {
if (! menuactive && bindtable[key]) if (ev->type == ev_keydown && !menuactive && bindtable[key])
{ {
COM_BufAddText(bindtable[key]); COM_BufAddText(bindtable[key]);
COM_BufAddText("\n"); COM_BufAddText("\n");
@ -980,6 +1012,13 @@ boolean CON_Responder(event_t *ev)
} }
} }
if (ev->type == ev_text)
{
if (!consoletoggle)
CON_InputAddChar(key);
return true;
}
// Always eat ctrl/shift/alt if console open, so the menu doesn't get ideas // 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 || key == KEY_LCTRL || key == KEY_RCTRL
@ -1057,36 +1096,14 @@ boolean CON_Responder(event_t *ev)
// show all cvars/commands that match what we have inputted // show all cvars/commands that match what we have inputted
if (key == KEY_TAB) if (key == KEY_TAB)
{ {
size_t i, len;
if (!completion[0]) if (!completion[0])
{ {
if (!input_len || input_len >= 40 || strchr(inputlines[inputline], ' ')) if (!input_len || input_len >= 40 || strchr(inputlines[inputline], ' '))
return true; return true;
strcpy(completion, inputlines[inputline]); strcpy(completion, inputlines[inputline]);
} }
len = strlen(completion); COM_BufInsertText(completioncmd);
//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");
//and finally aliases
CONS_Printf("Aliases:\n");
for (i = 0, cmd = COM_CompleteAlias(completion, i); cmd; cmd = COM_CompleteAlias(completion, ++i))
CONS_Printf(" \x83" "%s" "\x80" "%s\n", completion, cmd+len);
if (i == 0) CONS_Printf(" (none)\n");
completion[0] = 0; completion[0] = 0;
return true; return true;
} }
// --- // ---
@ -1316,21 +1333,12 @@ boolean CON_Responder(event_t *ev)
else if (key == KEY_KPADSLASH) else if (key == KEY_KPADSLASH)
key = '/'; key = '/';
if (key >= 'a' && key <= 'z')
{
if (capslock ^ shiftdown)
key = shiftxform[key];
}
else if (shiftdown)
key = shiftxform[key];
// enter a char into the command prompt // enter a char into the command prompt
if (key < 32 || key > 127) if (key < 32 || key > 127)
return true; return true;
if (input_sel != input_cur) if (input_sel != input_cur)
CON_InputDelSelection(); CON_InputDelSelection();
CON_InputAddChar(key);
return true; return true;
} }

View file

@ -22,6 +22,7 @@ typedef enum
{ {
ev_keydown, ev_keydown,
ev_keyup, ev_keyup,
ev_text,
ev_console, ev_console,
ev_mouse, ev_mouse,
ev_joystick, ev_joystick,

View file

@ -192,19 +192,19 @@ void D_ProcessEvents(void)
ev = &events[eventtail]; ev = &events[eventtail];
// Set mouse buttons early in case event is eaten later // Set mouse buttons early in case event is eaten later
if (ev->type == ev_keydown || ev->type == ev_keyup) if (ev->type == ev_keydown || ev->type == ev_keyup || ev->type == ev_text)
{ {
// Mouse buttons // Mouse buttons
if ((UINT32)(ev->key - KEY_MOUSE1) < MOUSEBUTTONS) if ((UINT32)(ev->key - KEY_MOUSE1) < MOUSEBUTTONS)
{ {
if (ev->type == ev_keydown) if (ev->type == ev_keydown || ev->type == ev_text)
mouse.buttons |= 1 << (ev->key - KEY_MOUSE1); mouse.buttons |= 1 << (ev->key - KEY_MOUSE1);
else else
mouse.buttons &= ~(1 << (ev->key - KEY_MOUSE1)); mouse.buttons &= ~(1 << (ev->key - KEY_MOUSE1));
} }
else if ((UINT32)(ev->key - KEY_2MOUSE1) < MOUSEBUTTONS) else if ((UINT32)(ev->key - KEY_2MOUSE1) < MOUSEBUTTONS)
{ {
if (ev->type == ev_keydown) if (ev->type == ev_keydown || ev->type == ev_text)
mouse2.buttons |= 1 << (ev->key - KEY_2MOUSE1); mouse2.buttons |= 1 << (ev->key - KEY_2MOUSE1);
else else
mouse2.buttons &= ~(1 << (ev->key - KEY_2MOUSE1)); mouse2.buttons &= ~(1 << (ev->key - KEY_2MOUSE1));
@ -1614,6 +1614,9 @@ void D_SRB2Main(void)
if (D_CheckNetGame()) if (D_CheckNetGame())
autostart = true; autostart = true;
if (!dedicated)
pickedchar = R_SkinAvailable(cv_defaultskin.string);
// check for a driver that wants intermission stats // check for a driver that wants intermission stats
// start the apropriate game based on parms // start the apropriate game based on parms
if (M_CheckParm("-metal")) if (M_CheckParm("-metal"))
@ -1627,8 +1630,6 @@ void D_SRB2Main(void)
autostart = true; autostart = true;
} }
pickedchar = R_SkinAvailable(cv_defaultskin.string);
// user settings come before "+" parameters. // user settings come before "+" parameters.
if (dedicated) if (dedicated)
COM_ImmedExecute(va("exec \"%s"PATHSEP"adedserv.cfg\"\n", srb2home)); COM_ImmedExecute(va("exec \"%s"PATHSEP"adedserv.cfg\"\n", srb2home));

View file

@ -159,6 +159,10 @@ typedef enum
PF_CANCARRY = 1<<29, // Can carry another player? PF_CANCARRY = 1<<29, // Can carry another player?
PF_FINISHED = 1<<30, // The player finished the level. NOT the same as exiting PF_FINISHED = 1<<30, // The player finished the level. NOT the same as exiting
// True if shield button down last tic
// This may be the final flag, but 2.3 could free up the others
PF_SHIELDDOWN = 1<<31,
// up to 1<<31 is free // up to 1<<31 is free
} pflags_t; } pflags_t;
@ -607,6 +611,7 @@ typedef struct player_s
tic_t jointime; // Timer when player joins game to change skin/color tic_t jointime; // Timer when player joins game to change skin/color
tic_t quittime; // Time elapsed since user disconnected, zero if connected tic_t quittime; // Time elapsed since user disconnected, zero if connected
tic_t lastinputtime; // the last tic the player has made any input
#ifdef HWRENDER #ifdef HWRENDER
fixed_t fovadd; // adjust FOV for hw rendering fixed_t fovadd; // adjust FOV for hw rendering
#endif #endif

View file

@ -51,6 +51,7 @@ typedef struct thinker_s
// killough 11/98: count of how many other objects reference // killough 11/98: count of how many other objects reference
// this one using pointers. Used for garbage collection. // this one using pointers. Used for garbage collection.
INT32 references; INT32 references;
boolean cachable;
#ifdef PARANOIA #ifdef PARANOIA
INT32 debug_mobjtype; INT32 debug_mobjtype;

View file

@ -26,20 +26,23 @@
// Button/action code definitions. // Button/action code definitions.
typedef enum typedef enum
{ {
// First 4 bits are weapon change info, DO NOT USE! // First 3 bits are weapon change info, DO NOT USE!
BT_WEAPONMASK = 0x0F, //our first four bits. BT_WEAPONMASK = 0x07, //our first three bits.
BT_WEAPONNEXT = 1<<4, BT_SHIELD = 1<<3, // shield or super action
BT_WEAPONPREV = 1<<5,
BT_ATTACK = 1<<6, // shoot rings BT_WEAPONNEXT = 1<<4, // select next weapon
BT_SPIN = 1<<7, BT_WEAPONPREV = 1<<5, // select previous weapon
BT_CAMLEFT = 1<<8, // turn camera left
BT_CAMRIGHT = 1<<9, // turn camera right
BT_TOSSFLAG = 1<<10,
BT_JUMP = 1<<11,
BT_FIRENORMAL = 1<<12, // Fire a normal ring no matter what
BT_ATTACK = 1<<6, // shoot rings
BT_SPIN = 1<<7, // spin action
BT_CAMLEFT = 1<<8, // turn camera left
BT_CAMRIGHT = 1<<9, // turn camera right
BT_TOSSFLAG = 1<<10, // toss flag or emeralds
BT_JUMP = 1<<11, // jump action
BT_FIRENORMAL = 1<<12, // fire a normal ring no matter what
// custom lua buttons
BT_CUSTOM1 = 1<<13, BT_CUSTOM1 = 1<<13,
BT_CUSTOM2 = 1<<14, BT_CUSTOM2 = 1<<14,
BT_CUSTOM3 = 1<<15, BT_CUSTOM3 = 1<<15,

View file

@ -297,7 +297,8 @@ static int ScanConstants(lua_State *L, boolean mathlib, const char *word)
CacheAndPushConstant(L, word, (lua_Integer)PF_FULLSTASIS); CacheAndPushConstant(L, word, (lua_Integer)PF_FULLSTASIS);
return 1; return 1;
} }
else if (fastcmp(p, "USEDOWN")) // Remove case when 2.3 nears release... // TODO: 2.3: Delete this alias
else if (fastcmp(p, "USEDOWN"))
{ {
CacheAndPushConstant(L, word, (lua_Integer)PF_SPINDOWN); CacheAndPushConstant(L, word, (lua_Integer)PF_SPINDOWN);
return 1; return 1;
@ -583,7 +584,8 @@ static int ScanConstants(lua_State *L, boolean mathlib, const char *word)
return 0; return 0;
} }
if (fastcmp(word, "BT_USE")) // Remove case when 2.3 nears release... // TODO: 2.3: Delete this alias
if (fastcmp(word, "BT_USE"))
{ {
CacheAndPushConstant(L, word, (lua_Integer)BT_SPIN); CacheAndPushConstant(L, word, (lua_Integer)BT_SPIN);
return 1; return 1;
@ -771,8 +773,7 @@ int LUA_SOCLib(lua_State *L)
lua_register(L,"getActionName",lib_getActionName); lua_register(L,"getActionName",lib_getActionName);
luaL_newmetatable(L, META_ACTION); luaL_newmetatable(L, META_ACTION);
lua_pushcfunction(L, action_call); LUA_SetCFunctionField(L, "__call", action_call);
lua_setfield(L, -2, "__call");
lua_pop(L, 1); lua_pop(L, 1);
return 0; return 0;

View file

@ -911,6 +911,7 @@ static void readspriteframe(MYFILE *f, spriteinfo_t *sprinfo, UINT8 frame)
sprinfo->pivot[frame].x = value; sprinfo->pivot[frame].x = value;
else if (fastcmp(word, "YPIVOT")) else if (fastcmp(word, "YPIVOT"))
sprinfo->pivot[frame].y = value; sprinfo->pivot[frame].y = value;
// TODO: 2.3: Delete
else if (fastcmp(word, "ROTAXIS")) else if (fastcmp(word, "ROTAXIS"))
deh_warning("SpriteInfo: ROTAXIS is deprecated and will be removed."); deh_warning("SpriteInfo: ROTAXIS is deprecated and will be removed.");
else else
@ -1617,6 +1618,7 @@ void readlevelheader(MYFILE *f, INT32 num)
sizeof(mapheaderinfo[num-1]->musname), va("Level header %d: music", num)); sizeof(mapheaderinfo[num-1]->musname), va("Level header %d: music", num));
} }
} }
// TODO: 2.3: Delete
else if (fastcmp(word, "MUSICSLOT")) else if (fastcmp(word, "MUSICSLOT"))
deh_warning("Level header %d: MusicSlot parameter is deprecated and will be removed.\nUse \"Music\" instead.", num); deh_warning("Level header %d: MusicSlot parameter is deprecated and will be removed.\nUse \"Music\" instead.", num);
else if (fastcmp(word, "MUSICTRACK")) else if (fastcmp(word, "MUSICTRACK"))

View file

@ -370,8 +370,9 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi
"S_XDEATHSTATE", "S_XDEATHSTATE",
"S_RAISESTATE", "S_RAISESTATE",
// Thok // Thok effect and spin trail
"S_THOK", "S_THOK",
"S_THOKEFFECT",
// Player // Player
"S_PLAY_STND", "S_PLAY_STND",
@ -3560,7 +3561,8 @@ const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity t
"MT_NULL", "MT_NULL",
"MT_UNKNOWN", "MT_UNKNOWN",
"MT_THOK", // Thok! mobj "MT_THOK", // Spin trail mobj
"MT_THOKEFFECT", // Thok boom effect
"MT_PLAYER", "MT_PLAYER",
"MT_TAILSOVERLAY", // c: "MT_TAILSOVERLAY", // c:
"MT_METALJETFUME", "MT_METALJETFUME",
@ -5576,7 +5578,8 @@ struct int_const_s const INT_CONST[] = {
{"ROTAXIS_Z",ROTAXIS_Z}, {"ROTAXIS_Z",ROTAXIS_Z},
// Buttons (ticcmd_t) // Buttons (ticcmd_t)
{"BT_WEAPONMASK",BT_WEAPONMASK}, //our first four bits. {"BT_WEAPONMASK",BT_WEAPONMASK}, //our first three bits.
{"BT_SHIELD",BT_SHIELD},
{"BT_WEAPONNEXT",BT_WEAPONNEXT}, {"BT_WEAPONNEXT",BT_WEAPONNEXT},
{"BT_WEAPONPREV",BT_WEAPONPREV}, {"BT_WEAPONPREV",BT_WEAPONPREV},
{"BT_ATTACK",BT_ATTACK}, // shoot rings {"BT_ATTACK",BT_ATTACK}, // shoot rings
@ -5756,9 +5759,7 @@ struct int_const_s const INT_CONST[] = {
{"GC_WEPSLOT5",GC_WEPSLOT5}, {"GC_WEPSLOT5",GC_WEPSLOT5},
{"GC_WEPSLOT6",GC_WEPSLOT6}, {"GC_WEPSLOT6",GC_WEPSLOT6},
{"GC_WEPSLOT7",GC_WEPSLOT7}, {"GC_WEPSLOT7",GC_WEPSLOT7},
{"GC_WEPSLOT8",GC_WEPSLOT8}, {"GC_SHIELD",GC_SHIELD},
{"GC_WEPSLOT9",GC_WEPSLOT9},
{"GC_WEPSLOT10",GC_WEPSLOT10},
{"GC_FIRE",GC_FIRE}, {"GC_FIRE",GC_FIRE},
{"GC_FIRENORMAL",GC_FIRENORMAL}, {"GC_FIRENORMAL",GC_FIRENORMAL},
{"GC_TOSSFLAG",GC_TOSSFLAG}, {"GC_TOSSFLAG",GC_TOSSFLAG},

View file

@ -533,7 +533,7 @@ extern char liveeventbackup[256];
#define M_GetText(x) (x) #define M_GetText(x) (x)
#endif #endif
void M_StartupLocale(void); void M_StartupLocale(void);
extern void *(*M_Memcpy)(void* dest, const void* src, size_t n) FUNCNONNULL; void *M_Memcpy(void* dest, const void* src, size_t n);
char *va(const char *format, ...) FUNCPRINTF; char *va(const char *format, ...) FUNCPRINTF;
char *M_GetToken(const char *inputString); char *M_GetToken(const char *inputString);
void M_UnGetToken(void); void M_UnGetToken(void);

View file

@ -164,7 +164,7 @@ void I_SetMusicVolume(UINT8 volume)
(void)volume; (void)volume;
} }
boolean I_SetSongTrack(int track) boolean I_SetSongTrack(INT32 track)
{ {
(void)track; (void)track;
return false; return false;

View file

@ -1,6 +1,7 @@
#include "../doomdef.h" #include "../doomdef.h"
#include "../doomtype.h" #include "../doomtype.h"
#include "../i_system.h" #include "../i_system.h"
#include "../i_time.h"
FILE *logstream = NULL; FILE *logstream = NULL;
@ -19,6 +20,11 @@ void I_Sleep(UINT32 ms)
(void)ms; (void)ms;
} }
void I_SleepDuration(precise_t duration)
{
(void)duration;
}
precise_t I_GetPreciseTime(void) precise_t I_GetPreciseTime(void)
{ {
return 0; return 0;

View file

@ -4524,7 +4524,7 @@ void F_TextPromptDrawer(void)
if (players[j].mo->state == states+S_PLAY_STND && players[j].mo->tics != -1)\ if (players[j].mo->state == states+S_PLAY_STND && players[j].mo->tics != -1)\
players[j].mo->tics++;\ players[j].mo->tics++;\
else if (players[j].mo->state == states+S_PLAY_WAIT)\ else if (players[j].mo->state == states+S_PLAY_WAIT)\
P_SetPlayerMobjState(players[j].mo, S_PLAY_STND);\ P_SetMobjState(players[j].mo, S_PLAY_STND);\
}\ }\
} }

View file

@ -433,9 +433,19 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want
// okay, now we actually want searchpath to incorporate d_name // okay, now we actually want searchpath to incorporate d_name
strcpy(&searchpath[searchpathindex[depthleft]],dent->d_name); strcpy(&searchpath[searchpathindex[depthleft]],dent->d_name);
#if defined(__linux__) || defined(__FreeBSD__)
if (dent->d_type == DT_UNKNOWN)
if (lstat(searchpath,&fsstat) == 0 && S_ISDIR(fsstat.st_mode))
dent->d_type = DT_DIR;
// Linux and FreeBSD has a special field for file type on dirent, so use that to speed up lookups.
// FIXME: should we also follow symlinks?
if (dent->d_type == DT_DIR && depthleft)
#else
if (stat(searchpath,&fsstat) < 0) // do we want to follow symlinks? if not: change it to lstat if (stat(searchpath,&fsstat) < 0) // do we want to follow symlinks? if not: change it to lstat
; // was the file (re)moved? can't stat it ; // was the file (re)moved? can't stat it
else if (S_ISDIR(fsstat.st_mode) && depthleft) else if (S_ISDIR(fsstat.st_mode) && depthleft)
#endif
{ {
searchpathindex[--depthleft] = strlen(searchpath) + 1; searchpathindex[--depthleft] = strlen(searchpath) + 1;
dirhandle[depthleft] = opendir(searchpath); dirhandle[depthleft] = opendir(searchpath);

View file

@ -798,32 +798,53 @@ void G_GhostTicker(void)
if (type == MT_GHOST) if (type == MT_GHOST)
{ {
mobj = P_SpawnGhostMobj(g->mo); // does a large portion of the work for us mobj = P_SpawnGhostMobj(g->mo); // does a large portion of the work for us
mobj->frame = (mobj->frame & ~FF_FRAMEMASK)|tr_trans60<<FF_TRANSSHIFT; // P_SpawnGhostMobj sets trans50, we want trans60 if (!P_MobjWasRemoved(mobj))
mobj->frame = (mobj->frame & ~FF_FRAMEMASK)|tr_trans60<<FF_TRANSSHIFT; // P_SpawnGhostMobj sets trans50, we want trans60
} }
else if (type == MT_THOKEFFECT)
{
mobj = P_SpawnMobjFromMobj(g->mo, 0, 0, FixedDiv(g->mo->height, g->mo->scale)*3/4, type);
mobj->angle = g->mo->angle + ANGLE_90;
mobj->fuse = 7;
mobj->scale = g->mo->scale / 3;
mobj->destscale = 10 * g->mo->scale;
mobj->colorized = true;
mobj->color = g->mo->color;
mobj->momx = -g->mo->momx / 2;
mobj->momy = -g->mo->momy / 2;
}
else else
{ {
mobj = P_SpawnMobjFromMobj(g->mo, 0, 0, -FixedDiv(FixedMul(g->mo->info->height, g->mo->scale) - g->mo->height,3*FRACUNIT), MT_THOK); mobj = P_SpawnMobjFromMobj(g->mo, 0, 0, -FixedDiv(FixedMul(g->mo->info->height, g->mo->scale) - g->mo->height,3*FRACUNIT), MT_THOK);
mobj->sprite = states[mobjinfo[type].spawnstate].sprite; if (!P_MobjWasRemoved(mobj))
mobj->frame = (states[mobjinfo[type].spawnstate].frame & FF_FRAMEMASK) | tr_trans60<<FF_TRANSSHIFT;
mobj->color = g->mo->color;
mobj->skin = g->mo->skin;
P_SetScale(mobj, (mobj->destscale = g->mo->scale));
if (type == MT_THOK) // spintrail-specific modification for MT_THOK
{ {
mobj->frame = FF_TRANS80; mobj->sprite = states[mobjinfo[type].spawnstate].sprite;
mobj->fuse = mobj->tics; mobj->frame = (states[mobjinfo[type].spawnstate].frame & FF_FRAMEMASK) | tr_trans60<<FF_TRANSSHIFT;
mobj->color = g->mo->color;
mobj->skin = g->mo->skin;
P_SetScale(mobj, (mobj->destscale = g->mo->scale));
if (type == MT_THOK) // spintrail-specific modification for MT_THOK
{
mobj->frame = FF_TRANS80;
mobj->fuse = mobj->tics;
}
mobj->tics = -1; // nope.
} }
mobj->tics = -1; // nope.
} }
mobj->floorz = mobj->z;
mobj->ceilingz = mobj->z+mobj->height; if (!P_MobjWasRemoved(mobj))
P_UnsetThingPosition(mobj); {
mobj->flags = MF_NOBLOCKMAP|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY; // make an ATTEMPT to curb crazy SOCs fucking stuff up... mobj->floorz = mobj->z;
P_SetThingPosition(mobj); mobj->ceilingz = mobj->z+mobj->height;
if (!mobj->fuse) P_UnsetThingPosition(mobj);
mobj->fuse = 8; mobj->flags = MF_NOBLOCKMAP|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY; // make an ATTEMPT to curb crazy SOCs fucking stuff up...
P_SetTarget(&mobj->target, g->mo); P_SetThingPosition(mobj);
if (!mobj->fuse)
mobj->fuse = 8;
P_SetTarget(&mobj->target, g->mo);
}
} }
} }
if (xziptic & EZT_HIT) if (xziptic & EZT_HIT)
@ -847,6 +868,8 @@ void G_GhostTicker(void)
|| health != 0 || i >= 4) // only spawn for the first 4 hits per frame, to prevent ghosts from splode-spamming too bad. || health != 0 || i >= 4) // only spawn for the first 4 hits per frame, to prevent ghosts from splode-spamming too bad.
continue; continue;
poof = P_SpawnMobj(x, y, z, MT_GHOST); poof = P_SpawnMobj(x, y, z, MT_GHOST);
if (P_MobjWasRemoved(poof))
continue;
poof->angle = angle; poof->angle = angle;
poof->flags = MF_NOBLOCKMAP|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY; // make an ATTEMPT to curb crazy SOCs fucking stuff up... poof->flags = MF_NOBLOCKMAP|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY; // make an ATTEMPT to curb crazy SOCs fucking stuff up...
poof->health = 0; poof->health = 0;
@ -892,19 +915,22 @@ void G_GhostTicker(void)
if (follow) if (follow)
P_RemoveMobj(follow); P_RemoveMobj(follow);
P_SetTarget(&follow, P_SpawnMobjFromMobj(g->mo, 0, 0, 0, MT_GHOST)); P_SetTarget(&follow, P_SpawnMobjFromMobj(g->mo, 0, 0, 0, MT_GHOST));
P_SetTarget(&follow->tracer, g->mo); if (!P_MobjWasRemoved(follow))
follow->tics = -1; {
temp = READINT16(g->p)<<FRACBITS; P_SetTarget(&follow->tracer, g->mo);
follow->height = FixedMul(follow->scale, temp); follow->tics = -1;
temp = READINT16(g->p)<<FRACBITS;
follow->height = FixedMul(follow->scale, temp);
if (followtic & FZT_LINKDRAW) if (followtic & FZT_LINKDRAW)
follow->flags2 |= MF2_LINKDRAW; follow->flags2 |= MF2_LINKDRAW;
if (followtic & FZT_COLORIZED) if (followtic & FZT_COLORIZED)
follow->colorized = true; follow->colorized = true;
if (followtic & FZT_SKIN) if (followtic & FZT_SKIN)
follow->skin = &skins[READUINT8(g->p)]; follow->skin = &skins[READUINT8(g->p)];
}
} }
if (follow) if (follow)
{ {
@ -1094,31 +1120,50 @@ void G_ReadMetalTic(mobj_t *metal)
{ {
mobj = P_SpawnGhostMobj(metal); // does a large portion of the work for us mobj = P_SpawnGhostMobj(metal); // does a large portion of the work for us
} }
else if (type == MT_THOKEFFECT)
{
mobj = P_SpawnMobjFromMobj(metal, 0, 0, FixedDiv(metal->height, metal->scale)*3/4, type);
mobj->angle = metal->angle + ANGLE_90;
mobj->fuse = 7;
mobj->scale = metal->scale / 3;
mobj->destscale = 10 * metal->scale;
mobj->colorized = true;
mobj->color = metal->color;
mobj->momx = -metal->momx / 2;
mobj->momy = -metal->momy / 2;
}
else else
{ {
mobj = P_SpawnMobjFromMobj(metal, 0, 0, -FixedDiv(FixedMul(metal->info->height, metal->scale) - metal->height,3*FRACUNIT), MT_THOK); mobj = P_SpawnMobjFromMobj(metal, 0, 0, -FixedDiv(FixedMul(metal->info->height, metal->scale) - metal->height,3*FRACUNIT), MT_THOK);
mobj->sprite = states[mobjinfo[type].spawnstate].sprite; if (!P_MobjWasRemoved(mobj))
mobj->frame = states[mobjinfo[type].spawnstate].frame;
mobj->angle = metal->angle;
mobj->color = metal->color;
mobj->skin = metal->skin;
P_SetScale(mobj, (mobj->destscale = metal->scale));
if (type == MT_THOK) // spintrail-specific modification for MT_THOK
{ {
mobj->frame = FF_TRANS70; mobj->sprite = states[mobjinfo[type].spawnstate].sprite;
mobj->fuse = mobj->tics; mobj->frame = states[mobjinfo[type].spawnstate].frame;
mobj->angle = metal->angle;
mobj->color = metal->color;
mobj->skin = metal->skin;
P_SetScale(mobj, (mobj->destscale = metal->scale));
if (type == MT_THOK) // spintrail-specific modification for MT_THOK
{
mobj->frame = FF_TRANS70;
mobj->fuse = mobj->tics;
}
mobj->tics = -1; // nope.
} }
mobj->tics = -1; // nope.
} }
mobj->floorz = mobj->z;
mobj->ceilingz = mobj->z+mobj->height; if (!P_MobjWasRemoved(mobj))
P_UnsetThingPosition(mobj); {
mobj->flags = MF_NOBLOCKMAP|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY; // make an ATTEMPT to curb crazy SOCs fucking stuff up... mobj->floorz = mobj->z;
P_SetThingPosition(mobj); mobj->ceilingz = mobj->z+mobj->height;
if (!mobj->fuse) P_UnsetThingPosition(mobj);
mobj->fuse = 8; mobj->flags = MF_NOBLOCKMAP|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY; // make an ATTEMPT to curb crazy SOCs fucking stuff up...
P_SetTarget(&mobj->target, metal); P_SetThingPosition(mobj);
if (!mobj->fuse)
mobj->fuse = 8;
P_SetTarget(&mobj->target, metal);
}
} }
} }
if (xziptic & EZT_SPRITE) if (xziptic & EZT_SPRITE)
@ -1140,19 +1185,22 @@ void G_ReadMetalTic(mobj_t *metal)
if (follow) if (follow)
P_RemoveMobj(follow); P_RemoveMobj(follow);
P_SetTarget(&follow, P_SpawnMobjFromMobj(metal, 0, 0, 0, MT_GHOST)); P_SetTarget(&follow, P_SpawnMobjFromMobj(metal, 0, 0, 0, MT_GHOST));
P_SetTarget(&follow->tracer, metal); if (!P_MobjWasRemoved(follow))
follow->tics = -1; {
temp = READINT16(metal_p)<<FRACBITS; P_SetTarget(&follow->tracer, metal);
follow->height = FixedMul(follow->scale, temp); follow->tics = -1;
temp = READINT16(metal_p)<<FRACBITS;
follow->height = FixedMul(follow->scale, temp);
if (followtic & FZT_LINKDRAW) if (followtic & FZT_LINKDRAW)
follow->flags2 |= MF2_LINKDRAW; follow->flags2 |= MF2_LINKDRAW;
if (followtic & FZT_COLORIZED) if (followtic & FZT_COLORIZED)
follow->colorized = true; follow->colorized = true;
if (followtic & FZT_SKIN) if (followtic & FZT_SKIN)
follow->skin = &skins[READUINT8(metal_p)]; follow->skin = &skins[READUINT8(metal_p)];
}
} }
if (follow) if (follow)
{ {
@ -1492,8 +1540,9 @@ void G_BeginRecording(void)
demo_p += 16; demo_p += 16;
// Skin // Skin
for (i = 0; i < 16 && cv_skin.string[i]; i++) const char *skinname = skins[players[0].skin].name;
name[i] = cv_skin.string[i]; for (i = 0; i < 16 && skinname[i]; i++)
name[i] = skinname[i];
for (; i < 16; i++) for (; i < 16; i++)
name[i] = '\0'; name[i] = '\0';
M_Memcpy(demo_p,name,16); M_Memcpy(demo_p,name,16);
@ -2534,7 +2583,9 @@ void G_AddGhost(char *defdemoname)
{ // A bit more complex than P_SpawnPlayer because ghosts aren't solid and won't just push themselves out of the ceiling. { // A bit more complex than P_SpawnPlayer because ghosts aren't solid and won't just push themselves out of the ceiling.
fixed_t z,f,c; fixed_t z,f,c;
fixed_t offset = mthing->z << FRACBITS; fixed_t offset = mthing->z << FRACBITS;
gh->mo = P_SpawnMobj(mthing->x << FRACBITS, mthing->y << FRACBITS, 0, MT_GHOST); P_SetTarget(&gh->mo, P_SpawnMobj(mthing->x << FRACBITS, mthing->y << FRACBITS, 0, MT_GHOST));
if (P_MobjWasRemoved(gh->mo))
return;
gh->mo->angle = FixedAngle(mthing->angle << FRACBITS); gh->mo->angle = FixedAngle(mthing->angle << FRACBITS);
f = gh->mo->floorz; f = gh->mo->floorz;
c = gh->mo->ceilingz - mobjinfo[MT_PLAYER].height; c = gh->mo->ceilingz - mobjinfo[MT_PLAYER].height;

View file

@ -51,6 +51,7 @@
#include "r_fps.h" // frame interpolation/uncapped #include "r_fps.h" // frame interpolation/uncapped
#include "lua_hud.h" #include "lua_hud.h"
#include "lua_libs.h"
gameaction_t gameaction; gameaction_t gameaction;
gamestate_t gamestate = GS_NULL; gamestate_t gamestate = GS_NULL;
@ -307,7 +308,9 @@ consvar_t cv_chatheight= CVAR_INIT ("chatheight", "8", CV_SAVE, chatheight_cons_
consvar_t cv_chatnotifications= CVAR_INIT ("chatnotifications", "On", CV_SAVE, CV_OnOff, NULL); consvar_t cv_chatnotifications= CVAR_INIT ("chatnotifications", "On", CV_SAVE, CV_OnOff, NULL);
// chat spam protection (why would you want to disable that???) // chat spam protection (why would you want to disable that???)
consvar_t cv_chatspamprotection= CVAR_INIT ("chatspamprotection", "On", CV_SAVE, CV_OnOff, NULL); consvar_t cv_chatspamprotection= CVAR_INIT ("chatspamprotection", "On", CV_SAVE|CV_NETVAR, CV_OnOff, NULL);
consvar_t cv_chatspamspeed= CVAR_INIT ("chatspamspeed", "35", CV_SAVE|CV_NETVAR, CV_Unsigned, NULL);
consvar_t cv_chatspamburst= CVAR_INIT ("chatspamburst", "3", CV_SAVE|CV_NETVAR, CV_Unsigned, NULL);
// minichat text background // minichat text background
consvar_t cv_chatbacktint = CVAR_INIT ("chatbacktint", "On", CV_SAVE, CV_OnOff, NULL); consvar_t cv_chatbacktint = CVAR_INIT ("chatbacktint", "On", CV_SAVE, CV_OnOff, NULL);
@ -1170,7 +1173,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
// why build a ticcmd if we're paused? // why build a ticcmd if we're paused?
// Or, for that matter, if we're being reborn. // Or, for that matter, if we're being reborn.
// ...OR if we're blindfolded. No looking into the floor. // ...OR if we're blindfolded. No looking into the floor.
if (paused || P_AutoPause() || (gamestate == GS_LEVEL && (player->playerstate == PST_REBORN || ((gametyperules & GTR_TAG) if (ignoregameinputs || paused || P_AutoPause() || (gamestate == GS_LEVEL && (player->playerstate == PST_REBORN || ((gametyperules & GTR_TAG)
&& (leveltime < hidetime * TICRATE) && (player->pflags & PF_TAGIT))))) && (leveltime < hidetime * TICRATE) && (player->pflags & PF_TAGIT)))))
{//@TODO splitscreen player {//@TODO splitscreen player
cmd->angleturn = ticcmd_oldangleturn[forplayer]; cmd->angleturn = ticcmd_oldangleturn[forplayer];
@ -1334,7 +1337,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
#if NUM_WEAPONS > 10 #if NUM_WEAPONS > 10
"Add extra inputs to g_input.h/gamecontrols_e" "Add extra inputs to g_input.h/gamecontrols_e"
#endif #endif
//use the four avaliable bits to determine the weapon. //use the three avaliable bits to determine the weapon.
cmd->buttons &= ~BT_WEAPONMASK; cmd->buttons &= ~BT_WEAPONMASK;
for (i = 0; i < NUM_WEAPONS; ++i) for (i = 0; i < NUM_WEAPONS; ++i)
if (PLAYERINPUTDOWN(ssplayer, GC_WEPSLOT1 + i)) if (PLAYERINPUTDOWN(ssplayer, GC_WEPSLOT1 + i))
@ -1353,9 +1356,14 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
if (PLAYERINPUTDOWN(ssplayer, GC_FIRENORMAL) || (usejoystick && axis > 0)) if (PLAYERINPUTDOWN(ssplayer, GC_FIRENORMAL) || (usejoystick && axis > 0))
cmd->buttons |= BT_FIRENORMAL; cmd->buttons |= BT_FIRENORMAL;
// Toss flag button
if (PLAYERINPUTDOWN(ssplayer, GC_TOSSFLAG)) if (PLAYERINPUTDOWN(ssplayer, GC_TOSSFLAG))
cmd->buttons |= BT_TOSSFLAG; cmd->buttons |= BT_TOSSFLAG;
// Shield button
if (PLAYERINPUTDOWN(ssplayer, GC_SHIELD))
cmd->buttons |= BT_SHIELD;
// Lua scriptable buttons // Lua scriptable buttons
if (PLAYERINPUTDOWN(ssplayer, GC_CUSTOM1)) if (PLAYERINPUTDOWN(ssplayer, GC_CUSTOM1))
cmd->buttons |= BT_CUSTOM1; cmd->buttons |= BT_CUSTOM1;
@ -2747,6 +2755,7 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps)
p->pflags |= PF_SPINDOWN; p->pflags |= PF_SPINDOWN;
p->pflags |= PF_ATTACKDOWN; p->pflags |= PF_ATTACKDOWN;
p->pflags |= PF_JUMPDOWN; p->pflags |= PF_JUMPDOWN;
p->pflags |= PF_SHIELDDOWN;
p->playerstate = PST_LIVE; p->playerstate = PST_LIVE;
p->panim = PA_IDLE; // standing animation p->panim = PA_IDLE; // standing animation
@ -4346,7 +4355,7 @@ void G_LoadGameSettings(void)
} }
#define GAMEDATA_ID 0x86E4A27C // Change every major version, as usual #define GAMEDATA_ID 0x86E4A27C // Change every major version, as usual
#define COMPAT_GAMEDATA_ID 0xFCAFE211 // Can be removed entirely for 2.3 #define COMPAT_GAMEDATA_ID 0xFCAFE211 // TODO: 2.3: Delete
// G_LoadGameData // G_LoadGameData
// Loads the main data file, which stores information such as emblems found, etc. // Loads the main data file, which stores information such as emblems found, etc.
@ -5373,16 +5382,29 @@ void G_FreeMapSearch(mapsearchfreq_t *freq, INT32 freqc)
INT32 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep) INT32 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep)
{ {
boolean usemapcode = false; boolean usemapcode = false;
INT32 newmapnum; INT32 newmapnum;
size_t mapnamelen = strlen(mapname);
size_t mapnamelen;
char *p; char *p;
mapnamelen = strlen(mapname); if (mapnamelen == 1)
{
if (mapnamelen == 2)/* maybe two digit code */ if (mapname[0] == '*') // current map
{
usemapcode = true;
newmapnum = gamemap;
}
else if (mapname[0] == '+' && mapheaderinfo[gamemap-1]) // next map
{
usemapcode = true;
newmapnum = mapheaderinfo[gamemap-1]->nextlevel;
if (newmapnum < 1 || newmapnum > NUMMAPS)
{
CONS_Alert(CONS_ERROR, M_GetText("NextLevel (%d) is not a valid map.\n"), newmapnum);
return 0;
}
}
}
else if (mapnamelen == 2)/* maybe two digit code */
{ {
if (( newmapnum = M_MapNumber(mapname[0], mapname[1]) )) if (( newmapnum = M_MapNumber(mapname[0], mapname[1]) ))
usemapcode = true; usemapcode = true;

View file

@ -53,7 +53,7 @@ extern consvar_t cv_instantretry;
// used in game menu // used in game menu
extern consvar_t cv_tutorialprompt; extern consvar_t cv_tutorialprompt;
extern consvar_t cv_chatwidth, cv_chatnotifications, cv_chatheight, cv_chattime, cv_consolechat, cv_chatbacktint, cv_chatspamprotection, cv_compactscoreboard; extern consvar_t cv_chatwidth, cv_chatnotifications, cv_chatheight, cv_chattime, cv_consolechat, cv_chatbacktint, cv_chatspamprotection, cv_chatspamspeed, cv_chatspamburst, cv_compactscoreboard;
extern consvar_t cv_crosshair, cv_crosshair2; extern consvar_t cv_crosshair, cv_crosshair2;
extern consvar_t cv_invertmouse, cv_alwaysfreelook, cv_chasefreelook, cv_mousemove; extern consvar_t cv_invertmouse, cv_alwaysfreelook, cv_chasefreelook, cv_mousemove;
extern consvar_t cv_invertmouse2, cv_alwaysfreelook2, cv_chasefreelook2, cv_mousemove2; extern consvar_t cv_invertmouse2, cv_alwaysfreelook2, cv_chasefreelook2, cv_mousemove2;

View file

@ -18,6 +18,8 @@
#include "hu_stuff.h" // need HUFONT start & end #include "hu_stuff.h" // need HUFONT start & end
#include "netcode/d_net.h" #include "netcode/d_net.h"
#include "console.h" #include "console.h"
#include "lua_script.h"
#include "lua_libs.h"
#define MAXMOUSESENSITIVITY 100 // sensitivity steps #define MAXMOUSESENSITIVITY 100 // sensitivity steps
@ -116,7 +118,10 @@ void G_MapEventsToControls(event_t *ev)
{ {
case ev_keydown: case ev_keydown:
if (ev->key < NUMINPUTS) if (ev->key < NUMINPUTS)
gamekeydown[ev->key] = 1; {
if (!ignoregameinputs)
gamekeydown[ev->key] = 1;
}
#ifdef PARANOIA #ifdef PARANOIA
else else
{ {
@ -144,7 +149,7 @@ void G_MapEventsToControls(event_t *ev)
case ev_joystick: // buttons are virtual keys case ev_joystick: // buttons are virtual keys
i = ev->key; i = ev->key;
if (i >= JOYAXISSET || menuactive || CON_Ready() || chat_on) if (i >= JOYAXISSET || menuactive || CON_Ready() || chat_on || ignoregameinputs)
break; break;
if (ev->x != INT32_MAX) joyxmove[i] = ev->x; if (ev->x != INT32_MAX) joyxmove[i] = ev->x;
if (ev->y != INT32_MAX) joyymove[i] = ev->y; if (ev->y != INT32_MAX) joyymove[i] = ev->y;
@ -152,7 +157,7 @@ void G_MapEventsToControls(event_t *ev)
case ev_joystick2: // buttons are virtual keys case ev_joystick2: // buttons are virtual keys
i = ev->key; i = ev->key;
if (i >= JOYAXISSET || menuactive || CON_Ready() || chat_on) if (i >= JOYAXISSET || menuactive || CON_Ready() || chat_on || ignoregameinputs)
break; break;
if (ev->x != INT32_MAX) joy2xmove[i] = ev->x; if (ev->x != INT32_MAX) joy2xmove[i] = ev->x;
if (ev->y != INT32_MAX) joy2ymove[i] = ev->y; if (ev->y != INT32_MAX) joy2ymove[i] = ev->y;
@ -571,9 +576,7 @@ static const char *gamecontrolname[NUM_GAMECONTROLS] =
"weapon5", "weapon5",
"weapon6", "weapon6",
"weapon7", "weapon7",
"weapon8", "shield",
"weapon9",
"weapon10",
"fire", "fire",
"firenormal", "firenormal",
"tossflag", "tossflag",
@ -688,6 +691,7 @@ void G_DefineDefaultControls(void)
gamecontroldefault[gcs_fps][GC_CENTERVIEW ][0] = KEY_LCTRL; gamecontroldefault[gcs_fps][GC_CENTERVIEW ][0] = KEY_LCTRL;
gamecontroldefault[gcs_fps][GC_JUMP ][0] = KEY_SPACE; gamecontroldefault[gcs_fps][GC_JUMP ][0] = KEY_SPACE;
gamecontroldefault[gcs_fps][GC_SPIN ][0] = KEY_LSHIFT; gamecontroldefault[gcs_fps][GC_SPIN ][0] = KEY_LSHIFT;
gamecontroldefault[gcs_fps][GC_SHIELD ][0] = KEY_LALT;
gamecontroldefault[gcs_fps][GC_FIRE ][0] = KEY_RCTRL; gamecontroldefault[gcs_fps][GC_FIRE ][0] = KEY_RCTRL;
gamecontroldefault[gcs_fps][GC_FIRE ][1] = KEY_MOUSE1+0; gamecontroldefault[gcs_fps][GC_FIRE ][1] = KEY_MOUSE1+0;
gamecontroldefault[gcs_fps][GC_FIRENORMAL ][0] = KEY_RALT; gamecontroldefault[gcs_fps][GC_FIRENORMAL ][0] = KEY_RALT;
@ -708,6 +712,7 @@ void G_DefineDefaultControls(void)
gamecontroldefault[gcs_platform][GC_CENTERVIEW ][0] = KEY_END; gamecontroldefault[gcs_platform][GC_CENTERVIEW ][0] = KEY_END;
gamecontroldefault[gcs_platform][GC_JUMP ][0] = KEY_SPACE; gamecontroldefault[gcs_platform][GC_JUMP ][0] = KEY_SPACE;
gamecontroldefault[gcs_platform][GC_SPIN ][0] = KEY_LSHIFT; gamecontroldefault[gcs_platform][GC_SPIN ][0] = KEY_LSHIFT;
gamecontroldefault[gcs_platform][GC_SHIELD ][0] = KEY_LALT;
gamecontroldefault[gcs_platform][GC_FIRE ][0] = 's'; gamecontroldefault[gcs_platform][GC_FIRE ][0] = 's';
gamecontroldefault[gcs_platform][GC_FIRE ][1] = KEY_MOUSE1+0; gamecontroldefault[gcs_platform][GC_FIRE ][1] = KEY_MOUSE1+0;
gamecontroldefault[gcs_platform][GC_FIRENORMAL ][0] = 'w'; gamecontroldefault[gcs_platform][GC_FIRENORMAL ][0] = 'w';
@ -723,9 +728,6 @@ void G_DefineDefaultControls(void)
gamecontroldefault[i][GC_WEPSLOT5 ][0] = '5'; gamecontroldefault[i][GC_WEPSLOT5 ][0] = '5';
gamecontroldefault[i][GC_WEPSLOT6 ][0] = '6'; gamecontroldefault[i][GC_WEPSLOT6 ][0] = '6';
gamecontroldefault[i][GC_WEPSLOT7 ][0] = '7'; gamecontroldefault[i][GC_WEPSLOT7 ][0] = '7';
gamecontroldefault[i][GC_WEPSLOT8 ][0] = '8';
gamecontroldefault[i][GC_WEPSLOT9 ][0] = '9';
gamecontroldefault[i][GC_WEPSLOT10 ][0] = '0';
gamecontroldefault[i][GC_TOSSFLAG ][0] = '\''; gamecontroldefault[i][GC_TOSSFLAG ][0] = '\'';
gamecontroldefault[i][GC_CAMTOGGLE ][0] = 'v'; gamecontroldefault[i][GC_CAMTOGGLE ][0] = 'v';
gamecontroldefault[i][GC_CAMRESET ][0] = 'r'; gamecontroldefault[i][GC_CAMRESET ][0] = 'r';
@ -744,15 +746,15 @@ void G_DefineDefaultControls(void)
gamecontroldefault[i][GC_CUSTOM1 ][1] = KEY_JOY1+1; // B gamecontroldefault[i][GC_CUSTOM1 ][1] = KEY_JOY1+1; // B
gamecontroldefault[i][GC_CUSTOM2 ][1] = KEY_JOY1+3; // Y gamecontroldefault[i][GC_CUSTOM2 ][1] = KEY_JOY1+3; // Y
gamecontroldefault[i][GC_CUSTOM3 ][1] = KEY_JOY1+8; // Left Stick gamecontroldefault[i][GC_CUSTOM3 ][1] = KEY_JOY1+8; // Left Stick
gamecontroldefault[i][GC_CAMTOGGLE ][1] = KEY_JOY1+4; // LB gamecontroldefault[i][GC_SHIELD ][1] = KEY_JOY1+4; // LB
gamecontroldefault[i][GC_CENTERVIEW ][1] = KEY_JOY1+5; // RB gamecontroldefault[i][GC_CENTERVIEW ][1] = KEY_JOY1+5; // RB
gamecontroldefault[i][GC_SCREENSHOT ][1] = KEY_JOY1+6; // Back gamecontroldefault[i][GC_SCORES ][1] = KEY_JOY1+6; // Back
gamecontroldefault[i][GC_SYSTEMMENU ][0] = KEY_JOY1+7; // Start gamecontroldefault[i][GC_SYSTEMMENU ][0] = KEY_JOY1+7; // Start
gamecontroldefault[i][GC_WEAPONPREV ][1] = KEY_HAT1+2; // D-Pad Left gamecontroldefault[i][GC_WEAPONPREV ][1] = KEY_HAT1+2; // D-Pad Left
gamecontroldefault[i][GC_WEAPONNEXT ][1] = KEY_HAT1+3; // D-Pad Right gamecontroldefault[i][GC_WEAPONNEXT ][1] = KEY_HAT1+3; // D-Pad Right
gamecontroldefault[i][GC_VIEWPOINTNEXT][1] = KEY_JOY1+9; // Right Stick gamecontroldefault[i][GC_VIEWPOINTNEXT][1] = KEY_JOY1+9; // Right Stick
gamecontroldefault[i][GC_TOSSFLAG ][1] = KEY_HAT1+0; // D-Pad Up gamecontroldefault[i][GC_TOSSFLAG ][1] = KEY_HAT1+0; // D-Pad Up
gamecontroldefault[i][GC_SCORES ][1] = KEY_HAT1+1; // D-Pad Down gamecontroldefault[i][GC_CAMTOGGLE ][1] = KEY_HAT1+1; // D-Pad Down
// Second player controls only have joypad defaults // Second player controls only have joypad defaults
gamecontrolbisdefault[i][GC_JUMP ][1] = KEY_2JOY1+0; // A gamecontrolbisdefault[i][GC_JUMP ][1] = KEY_2JOY1+0; // A
@ -760,15 +762,15 @@ void G_DefineDefaultControls(void)
gamecontrolbisdefault[i][GC_CUSTOM1 ][1] = KEY_2JOY1+1; // B gamecontrolbisdefault[i][GC_CUSTOM1 ][1] = KEY_2JOY1+1; // B
gamecontrolbisdefault[i][GC_CUSTOM2 ][1] = KEY_2JOY1+3; // Y gamecontrolbisdefault[i][GC_CUSTOM2 ][1] = KEY_2JOY1+3; // Y
gamecontrolbisdefault[i][GC_CUSTOM3 ][1] = KEY_2JOY1+8; // Left Stick gamecontrolbisdefault[i][GC_CUSTOM3 ][1] = KEY_2JOY1+8; // Left Stick
gamecontrolbisdefault[i][GC_CAMTOGGLE ][1] = KEY_2JOY1+4; // LB gamecontrolbisdefault[i][GC_SHIELD ][1] = KEY_2JOY1+4; // LB
gamecontrolbisdefault[i][GC_CENTERVIEW ][1] = KEY_2JOY1+5; // RB gamecontrolbisdefault[i][GC_CENTERVIEW ][1] = KEY_2JOY1+5; // RB
gamecontrolbisdefault[i][GC_SCREENSHOT ][1] = KEY_2JOY1+6; // Back //gamecontrolbisdefault[i][GC_SCORES ][1] = KEY_2JOY1+6; // Back
//gamecontrolbisdefault[i][GC_SYSTEMMENU ][0] = KEY_2JOY1+7; // Start //gamecontrolbisdefault[i][GC_SYSTEMMENU ][0] = KEY_2JOY1+7; // Start
gamecontrolbisdefault[i][GC_WEAPONPREV ][1] = KEY_2HAT1+2; // D-Pad Left gamecontrolbisdefault[i][GC_WEAPONPREV ][1] = KEY_2HAT1+2; // D-Pad Left
gamecontrolbisdefault[i][GC_WEAPONNEXT ][1] = KEY_2HAT1+3; // D-Pad Right gamecontrolbisdefault[i][GC_WEAPONNEXT ][1] = KEY_2HAT1+3; // D-Pad Right
gamecontrolbisdefault[i][GC_VIEWPOINTNEXT][1] = KEY_2JOY1+9; // Right Stick gamecontrolbisdefault[i][GC_VIEWPOINTNEXT][1] = KEY_2JOY1+9; // Right Stick
gamecontrolbisdefault[i][GC_TOSSFLAG ][1] = KEY_2HAT1+0; // D-Pad Up gamecontrolbisdefault[i][GC_TOSSFLAG ][1] = KEY_2HAT1+0; // D-Pad Up
//gamecontrolbisdefault[i][GC_SCORES ][1] = KEY_2HAT1+1; // D-Pad Down gamecontrolbisdefault[i][GC_CAMTOGGLE ][1] = KEY_2HAT1+1; // D-Pad Down
} }
} }
@ -997,9 +999,10 @@ static void setcontrol(INT32 (*gc)[2])
INT32 player = ((void*)gc == (void*)&gamecontrolbis ? 1 : 0); INT32 player = ((void*)gc == (void*)&gamecontrolbis ? 1 : 0);
boolean nestedoverride = false; boolean nestedoverride = false;
// Update me for 2.3 // TODO: 2.3: Delete the "use" alias
namectrl = (stricmp(COM_Argv(1), "use")) ? COM_Argv(1) : "spin"; namectrl = (stricmp(COM_Argv(1), "use")) ? COM_Argv(1) : "spin";
for (numctrl = 0; numctrl < NUM_GAMECONTROLS && stricmp(namectrl, gamecontrolname[numctrl]); for (numctrl = 0; numctrl < NUM_GAMECONTROLS && stricmp(namectrl, gamecontrolname[numctrl]);
numctrl++) numctrl++)
; ;

View file

@ -74,9 +74,7 @@ typedef enum
GC_WEPSLOT5, GC_WEPSLOT5,
GC_WEPSLOT6, GC_WEPSLOT6,
GC_WEPSLOT7, GC_WEPSLOT7,
GC_WEPSLOT8, GC_SHIELD,
GC_WEPSLOT9,
GC_WEPSLOT10,
GC_FIRE, GC_FIRE,
GC_FIRENORMAL, GC_FIRENORMAL,
GC_TOSSFLAG, GC_TOSSFLAG,

View file

@ -276,9 +276,6 @@ struct FSurfaceInfo
}; };
typedef struct FSurfaceInfo FSurfaceInfo; typedef struct FSurfaceInfo FSurfaceInfo;
#define GL_DEFAULTMIX 0x00000000
#define GL_DEFAULTFOG 0xFF000000
//Hurdler: added for backward compatibility //Hurdler: added for backward compatibility
enum hwdsetspecialstate enum hwdsetspecialstate
{ {
@ -286,6 +283,7 @@ enum hwdsetspecialstate
HWD_SET_SHADERS, HWD_SET_SHADERS,
HWD_SET_TEXTUREFILTERMODE, HWD_SET_TEXTUREFILTERMODE,
HWD_SET_TEXTUREANISOTROPICMODE, HWD_SET_TEXTUREANISOTROPICMODE,
HWD_SET_WIREFRAME,
HWD_NUMSTATE HWD_NUMSTATE
}; };

View file

@ -138,6 +138,7 @@ light_t *t_lspr[NUMSPRITES] =
&lspr[NOLIGHT], // SPR_UNKN &lspr[NOLIGHT], // SPR_UNKN
&lspr[NOLIGHT], // SPR_THOK &lspr[NOLIGHT], // SPR_THOK
&lspr[NOLIGHT], // SPR_THKE
&lspr[SUPERSONIC_L],// SPR_PLAY &lspr[SUPERSONIC_L],// SPR_PLAY
// Enemies // Enemies

View file

@ -169,7 +169,6 @@ ps_metric_t ps_hw_batchdrawtime = {0};
boolean gl_init = false; boolean gl_init = false;
boolean gl_maploaded = false; boolean gl_maploaded = false;
boolean gl_sessioncommandsadded = false;
boolean gl_shadersavailable = true; boolean gl_shadersavailable = true;
// ========================================================================== // ==========================================================================
@ -181,13 +180,18 @@ static boolean HWR_UseShader(void)
return (cv_glshaders.value && gl_shadersavailable); return (cv_glshaders.value && gl_shadersavailable);
} }
static boolean HWR_IsWireframeMode(void)
{
return (cv_glwireframe.value && cv_debug);
}
void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap) void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap)
{ {
RGBA_t poly_color, tint_color, fade_color; RGBA_t poly_color, tint_color, fade_color;
poly_color.rgba = 0xFFFFFFFF; poly_color.rgba = 0xFFFFFFFF;
tint_color.rgba = (colormap != NULL) ? (UINT32)colormap->rgba : GL_DEFAULTMIX; tint_color.rgba = (colormap != NULL) ? (UINT32)colormap->rgba : 0x00000000;
fade_color.rgba = (colormap != NULL) ? (UINT32)colormap->fadergba : GL_DEFAULTFOG; fade_color.rgba = (colormap != NULL) ? (UINT32)colormap->fadergba : 0xFF000000;
// Crappy backup coloring if you can't do shaders // Crappy backup coloring if you can't do shaders
if (!HWR_UseShader()) if (!HWR_UseShader())
@ -201,7 +205,7 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col
blue = (float)poly_color.s.blue; blue = (float)poly_color.s.blue;
// 48 is just an arbritrary value that looked relatively okay. // 48 is just an arbritrary value that looked relatively okay.
tint_alpha = (float)(sqrt(tint_color.s.alpha) * 48) / 255.0f; tint_alpha = (float)(sqrt((float)tint_color.s.alpha / 10.2) * 48) / 255.0f;
// 8 is roughly the brightness of the "close" color in Software, and 16 the brightness of the "far" color. // 8 is roughly the brightness of the "close" color in Software, and 16 the brightness of the "far" color.
// 8 is too bright for dark levels, and 16 is too dark for bright levels. // 8 is too bright for dark levels, and 16 is too dark for bright levels.
@ -244,7 +248,7 @@ UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap) // Let's see if
RGBA_t realcolor, surfcolor; RGBA_t realcolor, surfcolor;
INT32 alpha; INT32 alpha;
realcolor.rgba = (colormap != NULL) ? colormap->rgba : GL_DEFAULTMIX; realcolor.rgba = (colormap != NULL) ? colormap->rgba : 0x00000000;
if (cv_glshaders.value && gl_shadersavailable) if (cv_glshaders.value && gl_shadersavailable)
{ {
@ -373,11 +377,9 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
INT32 i; INT32 i;
float height; // constant y for all points on the convex flat polygon float height; // constant y for all points on the convex flat polygon
float flatxref, flatyref, anglef = 0.0f; float anglef = 0.0f;
float fflatwidth = 64.0f, fflatheight = 64.0f; float fflatwidth = 64.0f, fflatheight = 64.0f;
UINT16 flatflag = 63; float xscale = 1.0f, yscale = 1.0f;
boolean texflat = false;
float tempxsow, tempytow; float tempxsow, tempytow;
float scrollx = 0.0f, scrolly = 0.0f; float scrollx = 0.0f, scrolly = 0.0f;
@ -412,11 +414,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
slope = gl_frontsector->c_slope; slope = gl_frontsector->c_slope;
} }
// Set fixedheight to the slope's height from our viewpoint, if we have a slope height = FixedToFloat(fixedheight);
if (slope)
fixedheight = P_GetSlopeZAt(slope, viewx, viewy);
height = FIXED_TO_FLOAT(fixedheight);
// Allocate plane-vertex buffer if we need to // Allocate plane-vertex buffer if we need to
if (!planeVerts || nrPlaneVerts > numAllocedPlaneVerts) if (!planeVerts || nrPlaneVerts > numAllocedPlaneVerts)
@ -432,8 +430,8 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
if (levelflat->type == LEVELFLAT_FLAT) if (levelflat->type == LEVELFLAT_FLAT)
{ {
size_t len = W_LumpLength(levelflat->u.flat.lumpnum); size_t len = W_LumpLength(levelflat->u.flat.lumpnum);
flatflag = R_GetFlatSize(len) - 1; unsigned flatflag = R_GetFlatSize(len);
fflatwidth = fflatheight = (float)(flatflag + 1); fflatwidth = fflatheight = (float)flatflag;
} }
else else
{ {
@ -447,29 +445,28 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
fflatwidth = levelflat->width; fflatwidth = levelflat->width;
fflatheight = levelflat->height; fflatheight = levelflat->height;
} }
texflat = true;
} }
} }
else // set no texture else // set no texture
HWR_SetCurrentTexture(NULL); HWR_SetCurrentTexture(NULL);
// reference point for flat texture coord for each vertex around the polygon
flatxref = (float)(((fixed_t)pv->x & (~flatflag)) / fflatwidth);
flatyref = (float)(((fixed_t)pv->y & (~flatflag)) / fflatheight);
// transform // transform
if (FOFsector != NULL) if (FOFsector != NULL)
{ {
if (!isceiling) // it's a floor if (!isceiling) // it's a floor
{ {
scrollx = FIXED_TO_FLOAT(FOFsector->floorxoffset)/fflatwidth; xscale = FixedToFloat(FOFsector->floorxscale);
scrolly = FIXED_TO_FLOAT(FOFsector->flooryoffset)/fflatheight; yscale = FixedToFloat(FOFsector->flooryscale);
scrollx = FixedToFloat(FOFsector->floorxoffset) / fflatwidth;
scrolly = FixedToFloat(FOFsector->flooryoffset) / fflatheight;
angle = FOFsector->floorangle; angle = FOFsector->floorangle;
} }
else // it's a ceiling else // it's a ceiling
{ {
scrollx = FIXED_TO_FLOAT(FOFsector->ceilingxoffset)/fflatwidth; xscale = FixedToFloat(FOFsector->ceilingxscale);
scrolly = FIXED_TO_FLOAT(FOFsector->ceilingyoffset)/fflatheight; yscale = FixedToFloat(FOFsector->ceilingyscale);
scrollx = FixedToFloat(FOFsector->ceilingxoffset) / fflatwidth;
scrolly = FixedToFloat(FOFsector->ceilingyoffset) / fflatheight;
angle = FOFsector->ceilingangle; angle = FOFsector->ceilingangle;
} }
} }
@ -477,41 +474,28 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
{ {
if (!isceiling) // it's a floor if (!isceiling) // it's a floor
{ {
scrollx = FIXED_TO_FLOAT(gl_frontsector->floorxoffset)/fflatwidth; xscale = FixedToFloat(gl_frontsector->floorxscale);
scrolly = FIXED_TO_FLOAT(gl_frontsector->flooryoffset)/fflatheight; yscale = FixedToFloat(gl_frontsector->flooryscale);
scrollx = FixedToFloat(gl_frontsector->floorxoffset) / fflatwidth;
scrolly = FixedToFloat(gl_frontsector->flooryoffset) / fflatheight;
angle = gl_frontsector->floorangle; angle = gl_frontsector->floorangle;
} }
else // it's a ceiling else // it's a ceiling
{ {
scrollx = FIXED_TO_FLOAT(gl_frontsector->ceilingxoffset)/fflatwidth; xscale = FixedToFloat(gl_frontsector->ceilingxscale);
scrolly = FIXED_TO_FLOAT(gl_frontsector->ceilingyoffset)/fflatheight; yscale = FixedToFloat(gl_frontsector->ceilingyscale);
scrollx = FixedToFloat(gl_frontsector->ceilingxoffset) / fflatwidth;
scrolly = FixedToFloat(gl_frontsector->ceilingyoffset) / fflatheight;
angle = gl_frontsector->ceilingangle; angle = gl_frontsector->ceilingangle;
} }
} }
if (angle) // Only needs to be done if there's an altered angle anglef = ANG2RAD(InvAngle(angle));
{
tempxsow = flatxref;
tempytow = flatyref;
anglef = ANG2RAD(InvAngle(angle));
flatxref = (tempxsow * cos(anglef)) - (tempytow * sin(anglef));
flatyref = (tempxsow * sin(anglef)) + (tempytow * cos(anglef));
}
#define SETUP3DVERT(vert, vx, vy) {\ #define SETUP3DVERT(vert, vx, vy) {\
/* Hurdler: add scrolling texture on floor/ceiling */\ /* Hurdler: add scrolling texture on floor/ceiling */\
if (texflat)\ vert->s = ((vx) / fflatwidth) + (scrollx / xscale);\
{\ vert->t = -((vy) / fflatheight) + (scrolly / yscale);\
vert->s = (float)((vx) / fflatwidth) + scrollx;\
vert->t = -(float)((vy) / fflatheight) + scrolly;\
}\
else\
{\
vert->s = (float)(((vx) / fflatwidth) - flatxref + scrollx);\
vert->t = (float)(flatyref - ((vy) / fflatheight) + scrolly);\
}\
\ \
/* Need to rotate before translate */\ /* Need to rotate before translate */\
if (angle) /* Only needs to be done if there's an altered angle */\ if (angle) /* Only needs to be done if there's an altered angle */\
@ -522,15 +506,18 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
vert->t = (tempxsow * sin(anglef)) + (tempytow * cos(anglef));\ vert->t = (tempxsow * sin(anglef)) + (tempytow * cos(anglef));\
}\ }\
\ \
vert->x = (vx);\ vert->s *= xscale;\
vert->y = height;\ vert->t *= yscale;\
vert->z = (vy);\
\ \
if (slope)\ if (slope)\
{\ {\
fixedheight = P_GetSlopeZAt(slope, FLOAT_TO_FIXED((vx)), FLOAT_TO_FIXED((vy)));\ fixedheight = P_GetSlopeZAt(slope, FloatToFixed((vx)), FloatToFixed((vy)));\
vert->y = FIXED_TO_FLOAT(fixedheight);\ height = FixedToFloat(fixedheight);\
}\ }\
\
vert->x = (vx);\
vert->y = height;\
vert->z = (vy);\
} }
for (i = 0, v3d = planeVerts; i < (INT32)nrPlaneVerts; i++,v3d++,pv++) for (i = 0, v3d = planeVerts; i < (INT32)nrPlaneVerts; i++,v3d++,pv++)
@ -584,10 +571,26 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
P_ClosestPointOnLine(viewx, viewy, line->linedef, &v); P_ClosestPointOnLine(viewx, viewy, line->linedef, &v);
dist = FIXED_TO_FLOAT(R_PointToDist(v.x, v.y)); dist = FIXED_TO_FLOAT(R_PointToDist(v.x, v.y));
x1 = ((polyvertex_t *)line->pv1)->x; if (line->pv1)
y1 = ((polyvertex_t *)line->pv1)->y; {
xd = ((polyvertex_t *)line->pv2)->x - x1; x1 = ((polyvertex_t *)line->pv1)->x;
yd = ((polyvertex_t *)line->pv2)->y - y1; y1 = ((polyvertex_t *)line->pv1)->y;
}
else
{
x1 = FIXED_TO_FLOAT(line->v1->x);
y1 = FIXED_TO_FLOAT(line->v1->x);
}
if (line->pv2)
{
xd = ((polyvertex_t *)line->pv2)->x - x1;
yd = ((polyvertex_t *)line->pv2)->y - y1;
}
else
{
xd = FIXED_TO_FLOAT(line->v2->x) - x1;
yd = FIXED_TO_FLOAT(line->v2->y) - y1;
}
// Based on the seg length and the distance from the line, split horizon into multiple poly sets to reduce distortion // Based on the seg length and the distance from the line, split horizon into multiple poly sets to reduce distortion
dist = sqrtf((xd*xd) + (yd*yd)) / dist / 16.0f; dist = sqrtf((xd*xd) + (yd*yd)) / dist / 16.0f;
@ -1066,14 +1069,31 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
fixed_t h, l; // 3D sides and 2s middle textures fixed_t h, l; // 3D sides and 2s middle textures
fixed_t hS, lS; fixed_t hS, lS;
float xscale, yscale;
gl_sidedef = gl_curline->sidedef; gl_sidedef = gl_curline->sidedef;
gl_linedef = gl_curline->linedef; gl_linedef = gl_curline->linedef;
vs.x = ((polyvertex_t *)gl_curline->pv1)->x; if (gl_curline->pv1)
vs.y = ((polyvertex_t *)gl_curline->pv1)->y; {
ve.x = ((polyvertex_t *)gl_curline->pv2)->x; vs.x = ((polyvertex_t *)gl_curline->pv1)->x;
ve.y = ((polyvertex_t *)gl_curline->pv2)->y; vs.y = ((polyvertex_t *)gl_curline->pv1)->y;
}
else
{
vs.x = FIXED_TO_FLOAT(gl_curline->v1->x);
vs.y = FIXED_TO_FLOAT(gl_curline->v1->y);
}
if (gl_curline->pv2)
{
ve.x = ((polyvertex_t *)gl_curline->pv2)->x;
ve.y = ((polyvertex_t *)gl_curline->pv2)->y;
}
else
{
ve.x = FIXED_TO_FLOAT(gl_curline->v2->x);
ve.y = FIXED_TO_FLOAT(gl_curline->v2->y);
}
v1x = FLOAT_TO_FIXED(vs.x); v1x = FLOAT_TO_FIXED(vs.x);
v1y = FLOAT_TO_FIXED(vs.y); v1y = FLOAT_TO_FIXED(vs.y);
@ -1148,47 +1168,53 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
// check TOP TEXTURE // check TOP TEXTURE
if ((worldhighslope < worldtopslope || worldhigh < worldtop) && gl_toptexture) if ((worldhighslope < worldtopslope || worldhigh < worldtop) && gl_toptexture)
{ {
grTex = HWR_GetTexture(gl_toptexture);
xscale = FixedToFloat(gl_sidedef->scalex_top);
yscale = FixedToFloat(gl_sidedef->scaley_top);
fixed_t texheight = FixedDiv(textureheight[gl_toptexture], gl_sidedef->scaley_top);
// PEGGING // PEGGING
if (gl_linedef->flags & ML_DONTPEGTOP) if (gl_linedef->flags & ML_DONTPEGTOP)
texturevpeg = 0; texturevpeg = 0;
else if (gl_linedef->flags & ML_SKEWTD) else if (gl_linedef->flags & ML_SKEWTD)
texturevpeg = worldhigh + textureheight[gl_toptexture] - worldtop; texturevpeg = worldhigh + texheight - worldtop;
else else
texturevpeg = gl_backsector->ceilingheight + textureheight[gl_toptexture] - gl_frontsector->ceilingheight; texturevpeg = gl_backsector->ceilingheight + texheight - gl_frontsector->ceilingheight;
texturevpeg *= yscale;
texturevpeg += gl_sidedef->rowoffset + gl_sidedef->offsety_top; texturevpeg += gl_sidedef->rowoffset + gl_sidedef->offsety_top;
// 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
texturevpeg %= textureheight[gl_toptexture]; texturevpeg %= texheight;
grTex = HWR_GetTexture(gl_toptexture);
wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY;
wallVerts[0].t = wallVerts[1].t = (texturevpeg + gl_frontsector->ceilingheight - gl_backsector->ceilingheight) * grTex->scaleY; wallVerts[0].t = wallVerts[1].t = (texturevpeg + (gl_frontsector->ceilingheight - gl_backsector->ceilingheight) * yscale) * grTex->scaleY;
wallVerts[0].s = wallVerts[3].s = (cliplow + gl_sidedef->offsetx_top) * grTex->scaleX; wallVerts[0].s = wallVerts[3].s = ((cliplow * xscale) + gl_sidedef->offsetx_top) * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = (cliphigh + gl_sidedef->offsetx_top) * grTex->scaleX; wallVerts[2].s = wallVerts[1].s = ((cliphigh * xscale) + gl_sidedef->offsetx_top) * grTex->scaleX;
// Adjust t value for sloped walls // Adjust t value for sloped walls
if (!(gl_linedef->flags & ML_SKEWTD)) if (!(gl_linedef->flags & ML_SKEWTD))
{ {
// Unskewed // Unskewed
wallVerts[3].t -= (worldtop - gl_frontsector->ceilingheight) * grTex->scaleY; wallVerts[3].t -= (worldtop - gl_frontsector->ceilingheight) * yscale * grTex->scaleY;
wallVerts[2].t -= (worldtopslope - gl_frontsector->ceilingheight) * grTex->scaleY; wallVerts[2].t -= (worldtopslope - gl_frontsector->ceilingheight) * yscale * grTex->scaleY;
wallVerts[0].t -= (worldhigh - gl_backsector->ceilingheight) * grTex->scaleY; wallVerts[0].t -= (worldhigh - gl_backsector->ceilingheight) * yscale * grTex->scaleY;
wallVerts[1].t -= (worldhighslope - gl_backsector->ceilingheight) * grTex->scaleY; wallVerts[1].t -= (worldhighslope - gl_backsector->ceilingheight) * yscale * grTex->scaleY;
} }
else if (gl_linedef->flags & ML_DONTPEGTOP) else if (gl_linedef->flags & ML_DONTPEGTOP)
{ {
// Skewed by top // Skewed by top
wallVerts[0].t = (texturevpeg + worldtop - worldhigh) * grTex->scaleY; wallVerts[0].t = (texturevpeg + (worldtop - worldhigh) * yscale) * grTex->scaleY;
wallVerts[1].t = (texturevpeg + worldtopslope - worldhighslope) * grTex->scaleY; wallVerts[1].t = (texturevpeg + (worldtopslope - worldhighslope) * yscale) * grTex->scaleY;
} }
else else
{ {
// Skewed by bottom // Skewed by bottom
wallVerts[0].t = wallVerts[1].t = (texturevpeg + worldtop - worldhigh) * grTex->scaleY; wallVerts[0].t = wallVerts[1].t = (texturevpeg + (worldtop - worldhigh) * yscale) * grTex->scaleY;
wallVerts[3].t = wallVerts[0].t - (worldtop - worldhigh) * grTex->scaleY; wallVerts[3].t = wallVerts[0].t - (worldtop - worldhigh) * yscale * grTex->scaleY;
wallVerts[2].t = wallVerts[1].t - (worldtopslope - worldhighslope) * grTex->scaleY; wallVerts[2].t = wallVerts[1].t - (worldtopslope - worldhighslope) * yscale * grTex->scaleY;
} }
// set top/bottom coords // set top/bottom coords
@ -1208,6 +1234,10 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
// check BOTTOM TEXTURE // check BOTTOM TEXTURE
if ((worldlowslope > worldbottomslope || worldlow > worldbottom) && gl_bottomtexture) if ((worldlowslope > worldbottomslope || worldlow > worldbottom) && gl_bottomtexture)
{ {
grTex = HWR_GetTexture(gl_bottomtexture);
xscale = FixedToFloat(gl_sidedef->scalex_bottom);
yscale = FixedToFloat(gl_sidedef->scaley_bottom);
// PEGGING // PEGGING
if (!(gl_linedef->flags & ML_DONTPEGBOTTOM)) if (!(gl_linedef->flags & ML_DONTPEGBOTTOM))
texturevpeg = 0; texturevpeg = 0;
@ -1216,38 +1246,38 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
else else
texturevpeg = gl_frontsector->floorheight - gl_backsector->floorheight; texturevpeg = gl_frontsector->floorheight - gl_backsector->floorheight;
texturevpeg += gl_sidedef->rowoffset + gl_sidedef->offsety_bot; texturevpeg *= yscale;
texturevpeg += gl_sidedef->rowoffset + gl_sidedef->offsety_bottom;
// 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
texturevpeg %= textureheight[gl_bottomtexture]; texturevpeg %= FixedDiv(textureheight[gl_bottomtexture], gl_sidedef->scaley_bottom);
grTex = HWR_GetTexture(gl_bottomtexture);
wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY;
wallVerts[0].t = wallVerts[1].t = (texturevpeg + gl_backsector->floorheight - gl_frontsector->floorheight) * grTex->scaleY; wallVerts[0].t = wallVerts[1].t = (texturevpeg + (gl_backsector->floorheight - gl_frontsector->floorheight) * yscale) * grTex->scaleY;
wallVerts[0].s = wallVerts[3].s = (cliplow + gl_sidedef->offsetx_bot) * grTex->scaleX; wallVerts[0].s = wallVerts[3].s = ((cliplow * xscale) + gl_sidedef->offsetx_bottom) * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = (cliphigh + gl_sidedef->offsetx_bot) * grTex->scaleX; wallVerts[2].s = wallVerts[1].s = ((cliphigh * xscale) + gl_sidedef->offsetx_bottom) * grTex->scaleX;
// Adjust t value for sloped walls // Adjust t value for sloped walls
if (!(gl_linedef->flags & ML_SKEWTD)) if (!(gl_linedef->flags & ML_SKEWTD))
{ {
// Unskewed // Unskewed
wallVerts[0].t -= (worldbottom - gl_frontsector->floorheight) * grTex->scaleY; wallVerts[0].t -= (worldbottom - gl_frontsector->floorheight) * yscale * grTex->scaleY;
wallVerts[1].t -= (worldbottomslope - gl_frontsector->floorheight) * grTex->scaleY; wallVerts[1].t -= (worldbottomslope - gl_frontsector->floorheight) * yscale * grTex->scaleY;
wallVerts[3].t -= (worldlow - gl_backsector->floorheight) * grTex->scaleY; wallVerts[3].t -= (worldlow - gl_backsector->floorheight) * yscale * grTex->scaleY;
wallVerts[2].t -= (worldlowslope - gl_backsector->floorheight) * grTex->scaleY; wallVerts[2].t -= (worldlowslope - gl_backsector->floorheight) * yscale * grTex->scaleY;
} }
else if (gl_linedef->flags & ML_DONTPEGBOTTOM) else if (gl_linedef->flags & ML_DONTPEGBOTTOM)
{ {
// Skewed by bottom // Skewed by bottom
wallVerts[0].t = wallVerts[1].t = (texturevpeg + worldlow - worldbottom) * grTex->scaleY; wallVerts[0].t = wallVerts[1].t = (texturevpeg + (worldlow - worldbottom) * yscale) * grTex->scaleY;
wallVerts[2].t = wallVerts[1].t - (worldlowslope - worldbottomslope) * grTex->scaleY; wallVerts[2].t = wallVerts[1].t - (worldlowslope - worldbottomslope) * yscale * grTex->scaleY;
} }
else else
{ {
// Skewed by top // Skewed by top
wallVerts[0].t = (texturevpeg + worldlow - worldbottom) * grTex->scaleY; wallVerts[0].t = (texturevpeg + (worldlow - worldbottom) * yscale) * grTex->scaleY;
wallVerts[1].t = (texturevpeg + worldlowslope - worldbottomslope) * grTex->scaleY; wallVerts[1].t = (texturevpeg + (worldlowslope - worldbottomslope) * yscale) * grTex->scaleY;
} }
// set top/bottom coords // set top/bottom coords
@ -1268,6 +1298,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
if (gl_midtexture && HWR_BlendMidtextureSurface(&Surf)) if (gl_midtexture && HWR_BlendMidtextureSurface(&Surf))
{ {
sector_t *front, *back; sector_t *front, *back;
fixed_t texheight = FixedDiv(textureheight[gl_midtexture], gl_sidedef->scaley_mid);
INT32 repeats; INT32 repeats;
if (gl_linedef->frontsector->heightsec != -1) if (gl_linedef->frontsector->heightsec != -1)
@ -1296,13 +1327,17 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
else else
low = back->floorheight; low = back->floorheight;
repeats = (high - low) / textureheight[gl_midtexture]; repeats = (high - low) / texheight;
if ((high - low) % textureheight[gl_midtexture]) if ((high - low) % texheight)
repeats++; // tile an extra time to fill the gap -- Monster Iestyn repeats++; // tile an extra time to fill the gap -- Monster Iestyn
} }
else else
repeats = 1; repeats = 1;
grTex = HWR_GetTexture(gl_midtexture);
xscale = FixedToFloat(gl_sidedef->scalex_mid);
yscale = FixedToFloat(gl_sidedef->scaley_mid);
// SoM: a little note: popentop and popenbottom // SoM: a little note: popentop and popenbottom
// record the limits the texture can be displayed in. // record the limits the texture can be displayed in.
// polytop and polybottom, are the ideal (i.e. unclipped) // polytop and polybottom, are the ideal (i.e. unclipped)
@ -1320,7 +1355,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
popenbottom = popenbottomslope = back->floorheight; popenbottom = popenbottomslope = back->floorheight;
} }
else else
{ {
popentop = min(worldtop, worldhigh); popentop = min(worldtop, worldhigh);
popenbottom = max(worldbottom, worldlow); popenbottom = max(worldbottom, worldlow);
popentopslope = min(worldtopslope, worldhighslope); popentopslope = min(worldtopslope, worldhighslope);
@ -1328,7 +1363,9 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
} }
// Find the wall's coordinates // Find the wall's coordinates
fixed_t midtexheight = textureheight[gl_midtexture] * repeats; fixed_t midtexheight = texheight * repeats;
fixed_t rowoffset = FixedDiv(gl_sidedef->rowoffset + gl_sidedef->offsety_mid, gl_sidedef->scaley_mid);
// Texture is not skewed // Texture is not skewed
if (gl_linedef->flags & ML_NOSKEW) if (gl_linedef->flags & ML_NOSKEW)
@ -1336,13 +1373,13 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
// Peg it to the floor // Peg it to the floor
if (gl_linedef->flags & ML_MIDPEG) if (gl_linedef->flags & ML_MIDPEG)
{ {
polybottom = max(front->floorheight, back->floorheight) + gl_sidedef->rowoffset + gl_sidedef->offsety_mid; polybottom = max(front->floorheight, back->floorheight) + rowoffset;
polytop = polybottom + midtexheight; polytop = polybottom + midtexheight;
} }
// Peg it to the ceiling // Peg it to the ceiling
else else
{ {
polytop = min(front->ceilingheight, back->ceilingheight) + gl_sidedef->rowoffset + gl_sidedef->offsety_mid; polytop = min(front->ceilingheight, back->ceilingheight) + rowoffset;
polybottom = polytop - midtexheight; polybottom = polytop - midtexheight;
} }
@ -1353,17 +1390,17 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
// Skew the texture, but peg it to the floor // Skew the texture, but peg it to the floor
else if (gl_linedef->flags & ML_MIDPEG) else if (gl_linedef->flags & ML_MIDPEG)
{ {
polybottom = popenbottom + gl_sidedef->rowoffset + gl_sidedef->offsety_mid; polybottom = popenbottom + rowoffset;
polytop = polybottom + midtexheight; polytop = polybottom + midtexheight;
polybottomslope = popenbottomslope + gl_sidedef->rowoffset + gl_sidedef->offsety_mid; polybottomslope = popenbottomslope + rowoffset;
polytopslope = polybottomslope + midtexheight; polytopslope = polybottomslope + midtexheight;
} }
// Skew it according to the ceiling's slope // Skew it according to the ceiling's slope
else else
{ {
polytop = popentop + gl_sidedef->rowoffset; polytop = popentop + rowoffset;
polybottom = polytop - midtexheight; polybottom = polytop - midtexheight;
polytopslope = popentopslope + gl_sidedef->rowoffset; polytopslope = popentopslope + rowoffset;
polybottomslope = polytopslope - midtexheight; polybottomslope = polytopslope - midtexheight;
} }
@ -1405,17 +1442,15 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
texturevpegslope = polytopslope - hS; texturevpegslope = polytopslope - hS;
} }
grTex = HWR_GetTexture(gl_midtexture);
// Left side // Left side
wallVerts[3].t = texturevpeg * grTex->scaleY; wallVerts[3].t = texturevpeg * yscale * grTex->scaleY;
wallVerts[0].t = (h - l + texturevpeg) * grTex->scaleY; wallVerts[0].t = (h - l + texturevpeg) * yscale * grTex->scaleY;
wallVerts[0].s = wallVerts[3].s = (cliplow + gl_sidedef->offsetx_mid) * grTex->scaleX; wallVerts[0].s = wallVerts[3].s = ((cliplow * xscale) + gl_sidedef->offsetx_mid) * grTex->scaleX;
// Right side // Right side
wallVerts[2].t = texturevpegslope * grTex->scaleY; wallVerts[2].t = texturevpegslope * yscale * grTex->scaleY;
wallVerts[1].t = (hS - lS + texturevpegslope) * grTex->scaleY; wallVerts[1].t = (hS - lS + texturevpegslope) * yscale * grTex->scaleY;
wallVerts[2].s = wallVerts[1].s = (cliphigh + gl_sidedef->offsetx_mid) * grTex->scaleX; wallVerts[2].s = wallVerts[1].s = ((cliphigh * xscale) + gl_sidedef->offsetx_mid) * grTex->scaleX;
// set top/bottom coords // set top/bottom coords
// Take the texture peg into account, rather than changing the offsets past // Take the texture peg into account, rather than changing the offsets past
@ -1473,36 +1508,40 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
// Single sided line... Deal only with the middletexture (if one exists) // Single sided line... Deal only with the middletexture (if one exists)
if (gl_midtexture && gl_linedef->special != HORIZONSPECIAL) // (Ignore horizon line for OGL) if (gl_midtexture && gl_linedef->special != HORIZONSPECIAL) // (Ignore horizon line for OGL)
{ {
grTex = HWR_GetTexture(gl_midtexture);
xscale = FixedToFloat(gl_sidedef->scalex_mid);
yscale = FixedToFloat(gl_sidedef->scaley_mid);
fixed_t texturevpeg; fixed_t texturevpeg;
// PEGGING // PEGGING
if ((gl_linedef->flags & (ML_DONTPEGBOTTOM|ML_NOSKEW)) == (ML_DONTPEGBOTTOM|ML_NOSKEW)) if ((gl_linedef->flags & (ML_DONTPEGBOTTOM|ML_NOSKEW)) == (ML_DONTPEGBOTTOM|ML_NOSKEW))
texturevpeg = gl_frontsector->floorheight + textureheight[gl_sidedef->midtexture] - gl_frontsector->ceilingheight + gl_sidedef->rowoffset + gl_sidedef->offsety_mid; texturevpeg = (gl_frontsector->floorheight + textureheight[gl_sidedef->midtexture] - gl_frontsector->ceilingheight) * yscale;
else if (gl_linedef->flags & ML_DONTPEGBOTTOM) else if (gl_linedef->flags & ML_DONTPEGBOTTOM)
texturevpeg = worldbottom + textureheight[gl_sidedef->midtexture] - worldtop + gl_sidedef->rowoffset + gl_sidedef->offsety_mid; texturevpeg = (worldbottom + textureheight[gl_sidedef->midtexture] - worldtop) * yscale;
else else
// top of texture at top // top of texture at top
texturevpeg = gl_sidedef->rowoffset + gl_sidedef->offsety_mid; texturevpeg = 0;
grTex = HWR_GetTexture(gl_midtexture); texturevpeg += gl_sidedef->rowoffset + gl_sidedef->offsety_mid;
wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY;
wallVerts[0].t = wallVerts[1].t = (texturevpeg + gl_frontsector->ceilingheight - gl_frontsector->floorheight) * grTex->scaleY; wallVerts[0].t = wallVerts[1].t = (texturevpeg + gl_frontsector->ceilingheight - gl_frontsector->floorheight) * grTex->scaleY;
wallVerts[0].s = wallVerts[3].s = (cliplow + gl_sidedef->offsetx_mid) * grTex->scaleX; wallVerts[0].s = wallVerts[3].s = ((cliplow * xscale) + gl_sidedef->offsetx_mid) * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = (cliphigh + gl_sidedef->offsetx_mid) * grTex->scaleX; wallVerts[2].s = wallVerts[1].s = ((cliphigh * xscale) + gl_sidedef->offsetx_mid) * grTex->scaleX;
// Texture correction for slopes // Texture correction for slopes
if (gl_linedef->flags & ML_NOSKEW) { if (gl_linedef->flags & ML_NOSKEW) {
wallVerts[3].t += (gl_frontsector->ceilingheight - worldtop) * grTex->scaleY; wallVerts[3].t += (gl_frontsector->ceilingheight - worldtop) * yscale * grTex->scaleY;
wallVerts[2].t += (gl_frontsector->ceilingheight - worldtopslope) * grTex->scaleY; wallVerts[2].t += (gl_frontsector->ceilingheight - worldtopslope) * yscale * grTex->scaleY;
wallVerts[0].t += (gl_frontsector->floorheight - worldbottom) * grTex->scaleY; wallVerts[0].t += (gl_frontsector->floorheight - worldbottom) * yscale * grTex->scaleY;
wallVerts[1].t += (gl_frontsector->floorheight - worldbottomslope) * grTex->scaleY; wallVerts[1].t += (gl_frontsector->floorheight - worldbottomslope) * yscale * yscale;
} else if (gl_linedef->flags & ML_DONTPEGBOTTOM) { } else if (gl_linedef->flags & ML_DONTPEGBOTTOM) {
wallVerts[3].t = wallVerts[0].t + (worldbottom-worldtop) * grTex->scaleY; wallVerts[3].t = wallVerts[0].t + ((worldbottom - worldtop) * yscale) * grTex->scaleY;
wallVerts[2].t = wallVerts[1].t + (worldbottomslope-worldtopslope) * grTex->scaleY; wallVerts[2].t = wallVerts[1].t + ((worldbottomslope - worldtopslope) * yscale) * grTex->scaleY;
} else { } else {
wallVerts[0].t = wallVerts[3].t - (worldbottom-worldtop) * grTex->scaleY; wallVerts[0].t = wallVerts[3].t - ((worldbottom - worldtop) * yscale) * grTex->scaleY;
wallVerts[1].t = wallVerts[2].t - (worldbottomslope-worldtopslope) * grTex->scaleY; wallVerts[1].t = wallVerts[2].t - ((worldbottomslope - worldtopslope) * yscale) * grTex->scaleY;
} }
//Set textures properly on single sided walls that are sloped //Set textures properly on single sided walls that are sloped
@ -1587,15 +1626,17 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope)) if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope))
continue; continue;
texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); side_t *side = &sides[rover->master->sidenum[0]];
if (rover->master->flags & ML_TFERLINE) if (rover->master->flags & ML_TFERLINE)
{ {
size_t linenum = gl_curline->linedef-gl_backsector->lines[0]; size_t linenum = gl_curline->linedef-gl_backsector->lines[0];
newline = rover->master->frontsector->lines[0] + linenum; newline = rover->master->frontsector->lines[0] + linenum;
texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); side = &sides[newline->sidenum[0]];
} }
texnum = R_GetTextureNum(side->midtexture);
h = P_GetFFloorTopZAt (rover, v1x, v1y); h = P_GetFFloorTopZAt (rover, v1x, v1y);
hS = P_GetFFloorTopZAt (rover, v2x, v2y); hS = P_GetFFloorTopZAt (rover, v2x, v2y);
l = P_GetFFloorBottomZAt(rover, v1x, v1y); l = P_GetFFloorBottomZAt(rover, v1x, v1y);
@ -1611,14 +1652,13 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
l = lowcut; l = lowcut;
lS = lowcutslope; lS = lowcutslope;
} }
//Hurdler: HW code starts here
//FIXME: check if peging is correct
// set top/bottom coords
// set top/bottom coords
wallVerts[3].y = FIXED_TO_FLOAT(h); wallVerts[3].y = FIXED_TO_FLOAT(h);
wallVerts[2].y = FIXED_TO_FLOAT(hS); wallVerts[2].y = FIXED_TO_FLOAT(hS);
wallVerts[0].y = FIXED_TO_FLOAT(l); wallVerts[0].y = FIXED_TO_FLOAT(l);
wallVerts[1].y = FIXED_TO_FLOAT(lS); wallVerts[1].y = FIXED_TO_FLOAT(lS);
if (rover->fofflags & FOF_FOG) if (rover->fofflags & FOF_FOG)
{ {
wallVerts[3].t = wallVerts[2].t = 0; wallVerts[3].t = wallVerts[2].t = 0;
@ -1628,56 +1668,46 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
} }
else else
{ {
fixed_t texturevpeg;
boolean attachtobottom = false;
boolean slopeskew = false; // skew FOF walls with slopes?
// Wow, how was this missing from OpenGL for so long? // Wow, how was this missing from OpenGL for so long?
// ...Oh well, anyway, Lower Unpegged now changes pegging of FOFs like in software // ...Oh well, anyway, Lower Unpegged now changes pegging of FOFs like in software
// -- Monster Iestyn 26/06/18 // -- Monster Iestyn 26/06/18
if (newline) fixed_t texturevpeg = side->rowoffset + side->offsety_mid;
{ boolean attachtobottom = !!(rover->master->flags & ML_DONTPEGBOTTOM);
texturevpeg = sides[newline->sidenum[0]].rowoffset + sides[newline->sidenum[0]].offsety_mid;
attachtobottom = !!(newline->flags & ML_DONTPEGBOTTOM);
slopeskew = !!(newline->flags & ML_SKEWTD);
}
else
{
texturevpeg = sides[rover->master->sidenum[0]].rowoffset + sides[rover->master->sidenum[0]].offsety_mid;
attachtobottom = !!(gl_linedef->flags & ML_DONTPEGBOTTOM);
slopeskew = !!(rover->master->flags & ML_SKEWTD);
}
grTex = HWR_GetTexture(texnum); grTex = HWR_GetTexture(texnum);
xscale = FixedToFloat(side->scalex_mid);
yscale = FixedToFloat(side->scaley_mid);
if (!slopeskew) // no skewing if (!(rover->master->flags & ML_SKEWTD)) // no skewing
{ {
if (attachtobottom) if (attachtobottom)
texturevpeg -= *rover->topheight - *rover->bottomheight; texturevpeg -= (*rover->topheight - *rover->bottomheight) * yscale;
wallVerts[3].t = (*rover->topheight - h + texturevpeg) * grTex->scaleY;
wallVerts[2].t = (*rover->topheight - hS + texturevpeg) * grTex->scaleY; wallVerts[3].t = (((*rover->topheight - h) * yscale) + texturevpeg) * grTex->scaleY;
wallVerts[0].t = (*rover->topheight - l + texturevpeg) * grTex->scaleY; wallVerts[2].t = (((*rover->topheight - hS) * yscale) + texturevpeg) * grTex->scaleY;
wallVerts[1].t = (*rover->topheight - lS + texturevpeg) * grTex->scaleY; wallVerts[0].t = (((*rover->topheight - l) * yscale) + texturevpeg) * grTex->scaleY;
wallVerts[1].t = (((*rover->topheight - lS) * yscale) + texturevpeg) * grTex->scaleY;
} }
else else
{ {
if (!attachtobottom) // skew by top if (!attachtobottom) // skew by top
{ {
wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY;
wallVerts[0].t = (h - l + texturevpeg) * grTex->scaleY; wallVerts[0].t = (((h - l) * yscale) + texturevpeg) * grTex->scaleY;
wallVerts[1].t = (hS - lS + texturevpeg) * grTex->scaleY; wallVerts[1].t = (((hS - lS) * yscale) + texturevpeg) * grTex->scaleY;
} }
else // skew by bottom else // skew by bottom
{ {
wallVerts[0].t = wallVerts[1].t = texturevpeg * grTex->scaleY; wallVerts[0].t = wallVerts[1].t = texturevpeg * grTex->scaleY;
wallVerts[3].t = wallVerts[0].t - (h - l) * grTex->scaleY; wallVerts[3].t = wallVerts[0].t - ((h - l) * yscale) * grTex->scaleY;
wallVerts[2].t = wallVerts[1].t - (hS - lS) * grTex->scaleY; wallVerts[2].t = wallVerts[1].t - ((hS - lS) * yscale) * grTex->scaleY;
} }
} }
wallVerts[0].s = wallVerts[3].s = (cliplow + gl_sidedef->offsetx_mid) * grTex->scaleX; wallVerts[0].s = wallVerts[3].s = ((cliplow * xscale) + side->offsetx_mid) * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = (cliphigh + gl_sidedef->offsetx_mid) * grTex->scaleX; wallVerts[2].s = wallVerts[1].s = ((cliphigh * xscale) + side->offsetx_mid) * grTex->scaleX;
} }
if (rover->fofflags & FOF_FOG) if (rover->fofflags & FOF_FOG)
{ {
FBITFIELD blendmode; FBITFIELD blendmode;
@ -1744,14 +1774,17 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope)) if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope))
continue; continue;
texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); side_t *side = &sides[rover->master->sidenum[0]];
if (rover->master->flags & ML_TFERLINE) if (rover->master->flags & ML_TFERLINE)
{ {
size_t linenum = gl_curline->linedef-gl_backsector->lines[0]; size_t linenum = gl_curline->linedef-gl_backsector->lines[0];
newline = rover->master->frontsector->lines[0] + linenum; newline = rover->master->frontsector->lines[0] + linenum;
texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); side = &sides[newline->sidenum[0]];
} }
texnum = R_GetTextureNum(side->midtexture);
h = P_GetFFloorTopZAt (rover, v1x, v1y); h = P_GetFFloorTopZAt (rover, v1x, v1y);
hS = P_GetFFloorTopZAt (rover, v2x, v2y); hS = P_GetFFloorTopZAt (rover, v2x, v2y);
l = P_GetFFloorBottomZAt(rover, v1x, v1y); l = P_GetFFloorBottomZAt(rover, v1x, v1y);
@ -1785,20 +1818,16 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
else else
{ {
grTex = HWR_GetTexture(texnum); grTex = HWR_GetTexture(texnum);
xscale = FixedToFloat(side->scalex_mid);
yscale = FixedToFloat(side->scaley_mid);
if (newline) fixed_t diff = (*rover->topheight - h) * yscale;
{
wallVerts[3].t = wallVerts[2].t = (*rover->topheight - h + sides[newline->sidenum[0]].rowoffset + sides[newline->sidenum[0]].offsety_mid) * grTex->scaleY;
wallVerts[0].t = wallVerts[1].t = (h - l + (*rover->topheight - h + sides[newline->sidenum[0]].rowoffset) + sides[newline->sidenum[0]].offsety_mid) * grTex->scaleY;
}
else
{
wallVerts[3].t = wallVerts[2].t = (*rover->topheight - h + sides[rover->master->sidenum[0]].rowoffset + sides[rover->master->sidenum[0]].offsety_mid) * grTex->scaleY;
wallVerts[0].t = wallVerts[1].t = (h - l + (*rover->topheight - h + sides[rover->master->sidenum[0]].rowoffset + sides[rover->master->sidenum[0]].offsety_mid)) * grTex->scaleY;
}
wallVerts[0].s = wallVerts[3].s = (cliplow + gl_sidedef->offsetx_mid) * grTex->scaleX; wallVerts[3].t = wallVerts[2].t = (diff + side->rowoffset + side->offsety_mid) * grTex->scaleY;
wallVerts[2].s = wallVerts[1].s = (cliphigh + gl_sidedef->offsetx_mid) * grTex->scaleX; wallVerts[0].t = wallVerts[1].t = (((h - l) * yscale) + (diff + side->rowoffset + side->offsety_mid)) * grTex->scaleY;
wallVerts[0].s = wallVerts[3].s = ((cliplow * xscale) + side->offsetx_mid) * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = ((cliphigh * xscale) + side->offsetx_mid) * grTex->scaleX;
} }
if (rover->fofflags & FOF_FOG) if (rover->fofflags & FOF_FOG)
@ -1868,10 +1897,26 @@ static boolean CheckClip(seg_t * seg, sector_t * afrontsector, sector_t * abacks
if (afrontsector->f_slope || afrontsector->c_slope || abacksector->f_slope || abacksector->c_slope) if (afrontsector->f_slope || afrontsector->c_slope || abacksector->f_slope || abacksector->c_slope)
{ {
fixed_t v1x, v1y, v2x, v2y; // the seg's vertexes as fixed_t fixed_t v1x, v1y, v2x, v2y; // the seg's vertexes as fixed_t
v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x); if (gl_curline->pv1)
v1y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y); {
v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x); v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x);
v2y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y); v1y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y);
}
else
{
v1x = gl_curline->v1->x;
v1y = gl_curline->v1->y;
}
if (gl_curline->pv2)
{
v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x);
v2y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y);
}
else
{
v2x = gl_curline->v2->x;
v2y = gl_curline->v2->y;
}
#define SLOPEPARAMS(slope, end1, end2, normalheight) \ #define SLOPEPARAMS(slope, end1, end2, normalheight) \
end1 = P_GetZAt(slope, v1x, v1y, normalheight); \ end1 = P_GetZAt(slope, v1x, v1y, normalheight); \
end2 = P_GetZAt(slope, v2x, v2y, normalheight); end2 = P_GetZAt(slope, v2x, v2y, normalheight);
@ -2244,10 +2289,26 @@ static void HWR_AddLine(seg_t * line)
gl_curline = line; gl_curline = line;
v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x); if (gl_curline->pv1)
v1y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y); {
v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x); v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x);
v2y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y); v1y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y);
}
else
{
v1x = gl_curline->v1->x;
v1y = gl_curline->v1->y;
}
if (gl_curline->pv2)
{
v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x);
v2y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y);
}
else
{
v2x = gl_curline->v2->x;
v2y = gl_curline->v2->y;
}
// OPTIMIZE: quickly reject orthogonal back sides. // OPTIMIZE: quickly reject orthogonal back sides.
angle1 = R_PointToAngle64(v1x, v1y); angle1 = R_PointToAngle64(v1x, v1y);
@ -2652,11 +2713,8 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
INT32 i; INT32 i;
float height = FIXED_TO_FLOAT(fixedheight); // constant y for all points on the convex flat polygon float height = FIXED_TO_FLOAT(fixedheight); // constant y for all points on the convex flat polygon
float flatxref, flatyref;
float fflatwidth = 64.0f, fflatheight = 64.0f; float fflatwidth = 64.0f, fflatheight = 64.0f;
UINT16 flatflag = 63; float xscale = 1.0f, yscale = 1.0f;
boolean texflat = false;
float scrollx = 0.0f, scrolly = 0.0f; float scrollx = 0.0f, scrolly = 0.0f;
float tempxsow, tempytow, anglef = 0.0f; float tempxsow, tempytow, anglef = 0.0f;
@ -2687,8 +2745,8 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
if (levelflat->type == LEVELFLAT_FLAT) if (levelflat->type == LEVELFLAT_FLAT)
{ {
size_t len = W_LumpLength(levelflat->u.flat.lumpnum); size_t len = W_LumpLength(levelflat->u.flat.lumpnum);
flatflag = R_GetFlatSize(len) - 1; unsigned flatflag = R_GetFlatSize(len);
fflatwidth = fflatheight = (float)(flatflag + 1); fflatwidth = fflatheight = (float)flatflag;
} }
else else
{ {
@ -2702,19 +2760,11 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
fflatwidth = levelflat->width; fflatwidth = levelflat->width;
fflatheight = levelflat->height; fflatheight = levelflat->height;
} }
texflat = true;
} }
} }
else // set no texture else // set no texture
HWR_SetCurrentTexture(NULL); HWR_SetCurrentTexture(NULL);
// reference point for flat texture coord for each vertex around the polygon
flatxref = FIXED_TO_FLOAT(polysector->origVerts[0].x);
flatyref = FIXED_TO_FLOAT(polysector->origVerts[0].y);
flatxref = (float)(((fixed_t)flatxref & (~flatflag)) / fflatwidth);
flatyref = (float)(((fixed_t)flatyref & (~flatflag)) / fflatheight);
// transform // transform
v3d = planeVerts; v3d = planeVerts;
@ -2722,14 +2772,18 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
{ {
if (!isceiling) // it's a floor if (!isceiling) // it's a floor
{ {
scrollx = FIXED_TO_FLOAT(FOFsector->floorxoffset)/fflatwidth; xscale = FixedToFloat(FOFsector->floorxscale);
scrolly = FIXED_TO_FLOAT(FOFsector->flooryoffset)/fflatheight; yscale = FixedToFloat(FOFsector->flooryscale);
scrollx = FixedToFloat(FOFsector->floorxoffset) / fflatwidth;
scrolly = FixedToFloat(FOFsector->flooryoffset) / fflatheight;
angle = FOFsector->floorangle; angle = FOFsector->floorangle;
} }
else // it's a ceiling else // it's a ceiling
{ {
scrollx = FIXED_TO_FLOAT(FOFsector->ceilingxoffset)/fflatwidth; xscale = FixedToFloat(FOFsector->ceilingxscale);
scrolly = FIXED_TO_FLOAT(FOFsector->ceilingyoffset)/fflatheight; yscale = FixedToFloat(FOFsector->ceilingyscale);
scrollx = FixedToFloat(FOFsector->ceilingxoffset) / fflatwidth;
scrolly = FixedToFloat(FOFsector->ceilingyoffset) / fflatheight;
angle = FOFsector->ceilingangle; angle = FOFsector->ceilingangle;
} }
} }
@ -2737,43 +2791,30 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
{ {
if (!isceiling) // it's a floor if (!isceiling) // it's a floor
{ {
scrollx = FIXED_TO_FLOAT(gl_frontsector->floorxoffset)/fflatwidth; xscale = FixedToFloat(gl_frontsector->floorxscale);
scrolly = FIXED_TO_FLOAT(gl_frontsector->flooryoffset)/fflatheight; yscale = FixedToFloat(gl_frontsector->flooryscale);
scrollx = FixedToFloat(gl_frontsector->floorxoffset) / fflatwidth;
scrolly = FixedToFloat(gl_frontsector->flooryoffset) / fflatheight;
angle = gl_frontsector->floorangle; angle = gl_frontsector->floorangle;
} }
else // it's a ceiling else // it's a ceiling
{ {
scrollx = FIXED_TO_FLOAT(gl_frontsector->ceilingxoffset)/fflatwidth; xscale = FixedToFloat(gl_frontsector->ceilingxscale);
scrolly = FIXED_TO_FLOAT(gl_frontsector->ceilingyoffset)/fflatheight; yscale = FixedToFloat(gl_frontsector->ceilingyscale);
scrollx = FixedToFloat(gl_frontsector->ceilingxoffset) / fflatwidth;
scrolly = FixedToFloat(gl_frontsector->ceilingyoffset) / fflatheight;
angle = gl_frontsector->ceilingangle; angle = gl_frontsector->ceilingangle;
} }
} }
if (angle) // Only needs to be done if there's an altered angle anglef = ANG2RAD(InvAngle(angle));
{
tempxsow = flatxref;
tempytow = flatyref;
anglef = ANG2RAD(InvAngle(angle));
flatxref = (tempxsow * cos(anglef)) - (tempytow * sin(anglef));
flatyref = (tempxsow * sin(anglef)) + (tempytow * cos(anglef));
}
for (i = 0; i < (INT32)nrPlaneVerts; i++,v3d++) for (i = 0; i < (INT32)nrPlaneVerts; i++,v3d++)
{ {
// Go from the polysector's original vertex locations // Go from the polysector's original vertex locations
// Means the flat is offset based on the original vertex locations // Means the flat is offset based on the original vertex locations
if (texflat) v3d->s = (FixedToFloat(polysector->origVerts[i].x) / fflatwidth) + (scrollx / xscale);
{ v3d->t = -(FixedToFloat(polysector->origVerts[i].y) / fflatheight) + (scrolly / yscale);
v3d->s = (float)(FIXED_TO_FLOAT(polysector->origVerts[i].x) / fflatwidth) + scrollx;
v3d->t = -(float)(FIXED_TO_FLOAT(polysector->origVerts[i].y) / fflatheight) + scrolly;
}
else
{
v3d->s = (float)((FIXED_TO_FLOAT(polysector->origVerts[i].x) / fflatwidth) - flatxref + scrollx);
v3d->t = (float)(flatyref - (FIXED_TO_FLOAT(polysector->origVerts[i].y) / fflatheight) + scrolly);
}
// Need to rotate before translate // Need to rotate before translate
if (angle) // Only needs to be done if there's an altered angle if (angle) // Only needs to be done if there's an altered angle
@ -2785,6 +2826,9 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
v3d->t = (tempxsow * sin(anglef)) + (tempytow * cos(anglef)); v3d->t = (tempxsow * sin(anglef)) + (tempytow * cos(anglef));
} }
v3d->s *= xscale;
v3d->t *= yscale;
v3d->x = FIXED_TO_FLOAT(polysector->vertices[i]->x); v3d->x = FIXED_TO_FLOAT(polysector->vertices[i]->x);
v3d->y = height; v3d->y = height;
v3d->z = FIXED_TO_FLOAT(polysector->vertices[i]->y); v3d->z = FIXED_TO_FLOAT(polysector->vertices[i]->y);
@ -5258,7 +5302,7 @@ static void HWR_ProjectSprite(mobj_t *thing)
rollangle = R_GetRollAngle(spriterotangle); rollangle = R_GetRollAngle(spriterotangle);
} }
rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, false, sprinfo, rollangle); rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, sprinfo, rollangle);
if (rotsprite != NULL) if (rotsprite != NULL)
{ {
@ -5876,6 +5920,9 @@ void HWR_BuildSkyDome(void)
static void HWR_DrawSkyBackground(player_t *player) static void HWR_DrawSkyBackground(player_t *player)
{ {
if (HWR_IsWireframeMode())
return;
HWD.pfnSetBlend(PF_Translucent|PF_NoDepthTest|PF_Modulated); HWD.pfnSetBlend(PF_Translucent|PF_NoDepthTest|PF_Modulated);
if (cv_glskydome.value) if (cv_glskydome.value)
@ -6232,6 +6279,9 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player)
// Reset the shader state. // Reset the shader state.
HWR_SetShaderState(); HWR_SetShaderState();
if (HWR_IsWireframeMode())
HWD.pfnSetSpecialState(HWD_SET_WIREFRAME, 1);
validcount++; validcount++;
if (cv_glbatching.value) if (cv_glbatching.value)
@ -6294,6 +6344,9 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player)
HWR_CreateDrawNodes(); HWR_CreateDrawNodes();
} }
if (HWR_IsWireframeMode())
HWD.pfnSetSpecialState(HWD_SET_WIREFRAME, 0);
HWD.pfnSetTransform(NULL); HWD.pfnSetTransform(NULL);
HWD.pfnUnSetShader(); HWD.pfnUnSetShader();
@ -6448,6 +6501,9 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
// Reset the shader state. // Reset the shader state.
HWR_SetShaderState(); HWR_SetShaderState();
if (HWR_IsWireframeMode())
HWD.pfnSetSpecialState(HWD_SET_WIREFRAME, 1);
ps_numbspcalls.value.i = 0; ps_numbspcalls.value.i = 0;
ps_numpolyobjects.value.i = 0; ps_numpolyobjects.value.i = 0;
PS_START_TIMING(ps_bsptime); PS_START_TIMING(ps_bsptime);
@ -6524,6 +6580,9 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
HWR_CreateDrawNodes(); HWR_CreateDrawNodes();
} }
if (HWR_IsWireframeMode())
HWD.pfnSetSpecialState(HWD_SET_WIREFRAME, 0);
HWD.pfnSetTransform(NULL); HWD.pfnSetTransform(NULL);
HWD.pfnUnSetShader(); HWD.pfnUnSetShader();
@ -6595,12 +6654,14 @@ consvar_t cv_glfakecontrast = CVAR_INIT ("gr_fakecontrast", "Smooth", CV_SAVE, g
consvar_t cv_glslopecontrast = CVAR_INIT ("gr_slopecontrast", "Off", CV_SAVE, CV_OnOff, NULL); consvar_t cv_glslopecontrast = CVAR_INIT ("gr_slopecontrast", "Off", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_glfiltermode = CVAR_INIT ("gr_filtermode", "Nearest", CV_SAVE|CV_CALL, glfiltermode_cons_t, CV_glfiltermode_OnChange); consvar_t cv_glfiltermode = CVAR_INIT ("gr_filtermode", "Nearest", CV_SAVE|CV_CALL, glfiltermode_cons_t, CV_glfiltermode_OnChange);
consvar_t cv_glanisotropicmode = CVAR_INIT ("gr_anisotropicmode", "1", CV_CALL, glanisotropicmode_cons_t, CV_glanisotropic_OnChange); consvar_t cv_glanisotropicmode = CVAR_INIT ("gr_anisotropicmode", "1", CV_SAVE|CV_CALL, glanisotropicmode_cons_t, CV_glanisotropic_OnChange);
consvar_t cv_glsolvetjoin = CVAR_INIT ("gr_solvetjoin", "On", 0, CV_OnOff, NULL); consvar_t cv_glsolvetjoin = CVAR_INIT ("gr_solvetjoin", "On", 0, CV_OnOff, NULL);
consvar_t cv_glbatching = CVAR_INIT ("gr_batching", "On", 0, CV_OnOff, NULL); consvar_t cv_glbatching = CVAR_INIT ("gr_batching", "On", 0, CV_OnOff, NULL);
consvar_t cv_glwireframe = CVAR_INIT ("gr_wireframe", "Off", 0, CV_OnOff, NULL);
static void CV_glfiltermode_OnChange(void) static void CV_glfiltermode_OnChange(void)
{ {
if (rendermode == render_opengl) if (rendermode == render_opengl)
@ -6637,23 +6698,18 @@ void HWR_AddCommands(void)
CV_RegisterVar(&cv_glallowshaders); CV_RegisterVar(&cv_glallowshaders);
CV_RegisterVar(&cv_glfiltermode); CV_RegisterVar(&cv_glfiltermode);
CV_RegisterVar(&cv_glanisotropicmode);
CV_RegisterVar(&cv_glsolvetjoin); CV_RegisterVar(&cv_glsolvetjoin);
CV_RegisterVar(&cv_glbatching); CV_RegisterVar(&cv_glbatching);
CV_RegisterVar(&cv_glwireframe);
#ifndef NEWCLIP #ifndef NEWCLIP
CV_RegisterVar(&cv_glclipwalls); CV_RegisterVar(&cv_glclipwalls);
#endif #endif
} }
void HWR_AddSessionCommands(void)
{
if (gl_sessioncommandsadded)
return;
CV_RegisterVar(&cv_glanisotropicmode);
gl_sessioncommandsadded = true;
}
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Setup the hardware renderer // Setup the hardware renderer
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
@ -6664,7 +6720,6 @@ void HWR_Startup(void)
CONS_Printf("HWR_Startup()...\n"); CONS_Printf("HWR_Startup()...\n");
HWR_InitPolyPool(); HWR_InitPolyPool();
HWR_AddSessionCommands();
HWR_InitMapTextures(); HWR_InitMapTextures();
HWR_InitModels(); HWR_InitModels();
#ifdef ALAM_LIGHTING #ifdef ALAM_LIGHTING
@ -6687,10 +6742,6 @@ void HWR_Startup(void)
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
void HWR_Switch(void) void HWR_Switch(void)
{ {
// Add session commands
if (!gl_sessioncommandsadded)
HWR_AddSessionCommands();
// Set special states from CVARs // Set special states from CVARs
HWD.pfnSetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_glfiltermode.value); HWD.pfnSetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_glfiltermode.value);
HWD.pfnSetSpecialState(HWD_SET_TEXTUREANISOTROPICMODE, cv_glanisotropicmode.value); HWD.pfnSetSpecialState(HWD_SET_TEXTUREANISOTROPICMODE, cv_glanisotropicmode.value);

View file

@ -54,7 +54,6 @@ UINT8 *HWR_GetScreenshot(void);
boolean HWR_Screenshot(const char *pathname); boolean HWR_Screenshot(const char *pathname);
void HWR_AddCommands(void); void HWR_AddCommands(void);
void HWR_AddSessionCommands(void);
void transform(float *cx, float *cy, float *cz); void transform(float *cx, float *cy, float *cz);
INT32 HWR_GetTextureUsed(void); INT32 HWR_GetTextureUsed(void);
void HWR_DoPostProcessor(player_t *player); void HWR_DoPostProcessor(player_t *player);
@ -108,6 +107,8 @@ extern consvar_t cv_glslopecontrast;
extern consvar_t cv_glbatching; extern consvar_t cv_glbatching;
extern consvar_t cv_glwireframe;
extern float gl_viewwidth, gl_viewheight, gl_baseviewwindowy; extern float gl_viewwidth, gl_viewheight, gl_baseviewwindowy;
extern float gl_viewwindowx, gl_basewindowcentery; extern float gl_viewwindowx, gl_basewindowcentery;

View file

@ -1140,9 +1140,6 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendpatch, INT32 ski
Z_ChangeTag(newMipmap->data, PU_HWRMODELTEXTURE_UNLOCKED); Z_ChangeTag(newMipmap->data, PU_HWRMODELTEXTURE_UNLOCKED);
} }
#define NORMALFOG 0x00000000
#define FADEFOG 0x19000000
static boolean HWR_AllowModel(mobj_t *mobj) static boolean HWR_AllowModel(mobj_t *mobj)
{ {
// Signpost overlay. Not needed. // Signpost overlay. Not needed.

View file

@ -302,6 +302,8 @@ typedef void (APIENTRY * PFNglDisable) (GLenum cap);
static PFNglDisable pglDisable; static PFNglDisable pglDisable;
typedef void (APIENTRY * PFNglGetFloatv) (GLenum pname, GLfloat *params); typedef void (APIENTRY * PFNglGetFloatv) (GLenum pname, GLfloat *params);
static PFNglGetFloatv pglGetFloatv; static PFNglGetFloatv pglGetFloatv;
typedef void (APIENTRY * PFNglPolygonMode) (GLenum, GLenum);
static PFNglPolygonMode pglPolygonMode;
/* Depth Buffer */ /* Depth Buffer */
typedef void (APIENTRY * PFNglClearDepth) (GLclampd depth); typedef void (APIENTRY * PFNglClearDepth) (GLclampd depth);
@ -476,6 +478,7 @@ boolean SetupGLfunc(void)
GETOPENGLFUNC(pglGetFloatv, glGetFloatv) GETOPENGLFUNC(pglGetFloatv, glGetFloatv)
GETOPENGLFUNC(pglGetIntegerv, glGetIntegerv) GETOPENGLFUNC(pglGetIntegerv, glGetIntegerv)
GETOPENGLFUNC(pglGetString, glGetString) GETOPENGLFUNC(pglGetString, glGetString)
GETOPENGLFUNC(pglPolygonMode, glPolygonMode)
GETOPENGLFUNC(pglClearDepth, glClearDepth) GETOPENGLFUNC(pglClearDepth, glClearDepth)
GETOPENGLFUNC(pglDepthFunc, glDepthFunc) GETOPENGLFUNC(pglDepthFunc, glDepthFunc)
@ -697,7 +700,7 @@ static GLRGBAFloat shader_defaultcolor = {1.0f, 1.0f, 1.0f, 1.0f};
#define GLSL_SOFTWARE_TINT_EQUATION \ #define GLSL_SOFTWARE_TINT_EQUATION \
"if (tint_color.a > 0.0) {\n" \ "if (tint_color.a > 0.0) {\n" \
"float color_bright = sqrt((base_color.r * base_color.r) + (base_color.g * base_color.g) + (base_color.b * base_color.b));\n" \ "float color_bright = sqrt((base_color.r * base_color.r) + (base_color.g * base_color.g) + (base_color.b * base_color.b));\n" \
"float strength = sqrt(9.0 * tint_color.a);\n" \ "float strength = sqrt(tint_color.a);\n" \
"final_color.r = clamp((color_bright * (tint_color.r * strength)) + (base_color.r * (1.0 - strength)), 0.0, 1.0);\n" \ "final_color.r = clamp((color_bright * (tint_color.r * strength)) + (base_color.r * (1.0 - strength)), 0.0, 1.0);\n" \
"final_color.g = clamp((color_bright * (tint_color.g * strength)) + (base_color.g * (1.0 - strength)), 0.0, 1.0);\n" \ "final_color.g = clamp((color_bright * (tint_color.g * strength)) + (base_color.g * (1.0 - strength)), 0.0, 1.0);\n" \
"final_color.b = clamp((color_bright * (tint_color.b * strength)) + (base_color.b * (1.0 - strength)), 0.0, 1.0);\n" \ "final_color.b = clamp((color_bright * (tint_color.b * strength)) + (base_color.b * (1.0 - strength)), 0.0, 1.0);\n" \
@ -2474,6 +2477,10 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value)
Flush(); //??? if we want to change filter mode by texture, remove this Flush(); //??? if we want to change filter mode by texture, remove this
break; break;
case HWD_SET_WIREFRAME:
pglPolygonMode(GL_FRONT_AND_BACK, Value ? GL_LINE : GL_FILL);
break;
default: default:
break; break;
} }

View file

@ -79,6 +79,7 @@ patch_t *nto_font[NT_FONTSIZE];
static player_t *plr; static player_t *plr;
boolean chat_on; // entering a chat message? boolean chat_on; // entering a chat message?
boolean chat_on_first_event; // blocker for first chat input event
static char w_chat[HU_MAXMSGLEN + 1]; static char w_chat[HU_MAXMSGLEN + 1];
static size_t c_input = 0; // let's try to make the chat input less shitty. static size_t c_input = 0; // let's try to make the chat input less shitty.
static boolean headsupactive = false; static boolean headsupactive = false;
@ -618,7 +619,9 @@ static void Command_CSay_f(void)
DoSayCommand(0, 1, HU_CSAY); DoSayCommand(0, 1, HU_CSAY);
} }
static tic_t stop_spamming[MAXPLAYERS];
static tic_t spam_tokens[MAXPLAYERS];
static tic_t spam_tics[MAXPLAYERS];
/** Receives a message, processing an ::XD_SAY command. /** Receives a message, processing an ::XD_SAY command.
* \sa DoSayCommand * \sa DoSayCommand
@ -670,14 +673,14 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
// before we do anything, let's verify the guy isn't spamming, get this easier on us. // before we do anything, let's verify the guy isn't spamming, get this easier on us.
//if (stop_spamming[playernum] != 0 && cv_chatspamprotection.value && !(flags & HU_CSAY)) //if (stop_spamming[playernum] != 0 && cv_chatspamprotection.value && !(flags & HU_CSAY))
if (stop_spamming[playernum] != 0 && consoleplayer != playernum && cv_chatspamprotection.value && !(flags & HU_CSAY)) if (spam_tokens[playernum] <= 0 && cv_chatspamprotection.value && !(flags & HU_CSAY))
{ {
CONS_Debug(DBG_NETPLAY,"Received SAY cmd too quickly from Player %d (%s), assuming as spam and blocking message.\n", playernum+1, player_names[playernum]); CONS_Debug(DBG_NETPLAY,"Received SAY cmd too quickly from Player %d (%s), assuming as spam and blocking message.\n", playernum+1, player_names[playernum]);
stop_spamming[playernum] = 4; spam_tics[playernum] = 0;
spam_eatmsg = 1; spam_eatmsg = 1;
} }
else else
stop_spamming[playernum] = 4; // you can hold off for 4 tics, can you? spam_tokens[playernum] -= 1;
// run the lua hook even if we were supposed to eat the msg, netgame consistency goes first. // run the lua hook even if we were supposed to eat the msg, netgame consistency goes first.
@ -857,6 +860,25 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
// //
void HU_Ticker(void) void HU_Ticker(void)
{ {
// do this server-side, too
if (netgame)
{
size_t i = 0;
// handle spam while we're at it:
for(; (i<MAXPLAYERS); i++)
{
if (spam_tokens[i] < (tic_t)cv_chatspamburst.value)
{
if (++spam_tics[i] >= (tic_t)cv_chatspamspeed.value)
{
spam_tokens[i]++;
spam_tics[i] = 0;
}
}
}
}
if (dedicated) if (dedicated)
return; return;
@ -879,13 +901,6 @@ void HU_Ticker(void)
{ {
size_t i = 0; size_t i = 0;
// handle spam while we're at it:
for(; (i<MAXPLAYERS); i++)
{
if (stop_spamming[i] > 0)
stop_spamming[i]--;
}
// handle chat timers // handle chat timers
for (i=0; (i<chat_nummsg_min); i++) for (i=0; (i<chat_nummsg_min); i++)
{ {
@ -1025,7 +1040,7 @@ boolean HU_Responder(event_t *ev)
{ {
INT32 c=0; INT32 c=0;
if (ev->type != ev_keydown) if (ev->type != ev_keydown && ev->type != ev_text)
return false; return false;
// only KeyDown events now... // only KeyDown events now...
@ -1054,11 +1069,15 @@ boolean HU_Responder(event_t *ev)
if (!chat_on) if (!chat_on)
{ {
if (ev->type == ev_text)
return false;
// enter chat mode // enter chat mode
if ((ev->key == gamecontrol[GC_TALKKEY][0] || ev->key == gamecontrol[GC_TALKKEY][1]) if ((ev->key == gamecontrol[GC_TALKKEY][0] || ev->key == gamecontrol[GC_TALKKEY][1])
&& netgame && !OLD_MUTE) // check for old chat mute, still let the players open the chat incase they want to scroll otherwise. && netgame && !OLD_MUTE) // check for old chat mute, still let the players open the chat incase they want to scroll otherwise.
{ {
chat_on = true; chat_on = true;
chat_on_first_event = false;
w_chat[0] = 0; w_chat[0] = 0;
teamtalk = false; teamtalk = false;
chat_scrollmedown = true; chat_scrollmedown = true;
@ -1069,6 +1088,7 @@ boolean HU_Responder(event_t *ev)
&& netgame && !OLD_MUTE) && netgame && !OLD_MUTE)
{ {
chat_on = true; chat_on = true;
chat_on_first_event = false;
w_chat[0] = 0; w_chat[0] = 0;
teamtalk = G_GametypeHasTeams(); // Don't teamtalk if we don't have teams. teamtalk = G_GametypeHasTeams(); // Don't teamtalk if we don't have teams.
chat_scrollmedown = true; chat_scrollmedown = true;
@ -1078,6 +1098,31 @@ boolean HU_Responder(event_t *ev)
} }
else // if chat_on else // if chat_on
{ {
if (!chat_on_first_event)
{
// since the text event is sent immediately after the keydown event,
// we need to make sure that nothing is displayed once the chat
// opens, otherwise a 't' would be outputted.
chat_on_first_event = true;
return true;
}
if (ev->type == ev_text)
{
if ((c < HU_FONTSTART || c > HU_FONTEND || !hu_font[c-HU_FONTSTART])
&& c != ' ') // Allow spaces, of course
{
return false;
}
if (CHAT_MUTE || strlen(w_chat) >= HU_MAXMSGLEN)
return true;
memmove(&w_chat[c_input + 1], &w_chat[c_input], strlen(w_chat) - c_input + 1);
w_chat[c_input] = c;
c_input++;
return true;
}
// Ignore modifier keys // Ignore modifier keys
// Note that we do this here so users can still set // Note that we do this here so users can still set
@ -1087,23 +1132,8 @@ boolean HU_Responder(event_t *ev)
|| ev->key == KEY_LALT || ev->key == KEY_RALT) || ev->key == KEY_LALT || ev->key == KEY_RALT)
return true; return true;
c = (INT32)ev->key;
// I know this looks very messy but this works. If it ain't broke, don't fix it!
// shift LETTERS to uppercase if we have capslock or are holding shift
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
{
if (shiftdown ^ capslock)
c = shiftxform[c];
}
else // if we're holding shift we should still shift non letter symbols
{
if (shiftdown)
c = shiftxform[c];
}
// pasting. pasting is cool. chat is a bit limited, though :( // pasting. pasting is cool. chat is a bit limited, though :(
if ((c == 'v' || c == 'V') && ctrldown) if (c == 'v' && ctrldown)
{ {
const char *paste; const char *paste;
size_t chatlen; size_t chatlen;
@ -1171,16 +1201,6 @@ boolean HU_Responder(event_t *ev)
else else
c_input++; c_input++;
} }
else if ((c >= HU_FONTSTART && c <= HU_FONTEND && hu_font[c-HU_FONTSTART])
|| c == ' ') // Allow spaces, of course
{
if (CHAT_MUTE || strlen(w_chat) >= HU_MAXMSGLEN)
return true;
memmove(&w_chat[c_input + 1], &w_chat[c_input], strlen(w_chat) - c_input + 1);
w_chat[c_input] = c;
c_input++;
}
else if (c == KEY_BACKSPACE) else if (c == KEY_BACKSPACE)
{ {
if (CHAT_MUTE || c_input <= 0) if (CHAT_MUTE || c_input <= 0)

View file

@ -30,12 +30,6 @@ static precise_t enterprecise, oldenterprecise;
static fixed_t entertic, oldentertics; static fixed_t entertic, oldentertics;
static double tictimer; static double tictimer;
// A little more than the minimum sleep duration on Windows.
// May be incorrect for other platforms, but we don't currently have a way to
// query the scheduler granularity. SDL will do what's needed to make this as
// low as possible though.
#define MIN_SLEEP_DURATION_MS 2.1
tic_t I_GetTime(void) tic_t I_GetTime(void)
{ {
return g_time.time; return g_time.time;
@ -88,38 +82,3 @@ void I_UpdateTime(fixed_t timescale)
g_time.timefrac = FLOAT_TO_FIXED(fractional); g_time.timefrac = FLOAT_TO_FIXED(fractional);
} }
} }
void I_SleepDuration(precise_t duration)
{
UINT64 precision = I_GetPrecisePrecision();
INT32 sleepvalue = cv_sleep.value;
UINT64 delaygranularity;
precise_t cur;
precise_t dest;
{
double gran = round(((double)(precision / 1000) * sleepvalue * MIN_SLEEP_DURATION_MS));
delaygranularity = (UINT64)gran;
}
cur = I_GetPreciseTime();
dest = cur + duration;
// the reason this is not dest > cur is because the precise counter may wrap
// two's complement arithmetic is our friend here, though!
// e.g. cur 0xFFFFFFFFFFFFFFFE = -2, dest 0x0000000000000001 = 1
// 0x0000000000000001 - 0xFFFFFFFFFFFFFFFE = 3
while ((INT64)(dest - cur) > 0)
{
// If our cv_sleep value exceeds the remaining sleep duration, use the
// hard sleep function.
if (sleepvalue > 0 && (dest - cur) > delaygranularity)
{
I_Sleep(sleepvalue);
}
// Otherwise, this is a spinloop.
cur = I_GetPreciseTime();
}
}

View file

@ -33,7 +33,8 @@ char sprnames[NUMSPRITES + 1][5] =
"NULL", // invisible object "NULL", // invisible object
"UNKN", "UNKN",
"THOK", // Thok! mobj "THOK", // Spin trail mobj
"THKE", // Thok boom effect
"PLAY", "PLAY",
// Enemies // Enemies
@ -703,8 +704,9 @@ state_t states[NUMSTATES] =
{SPR_UNKN, FF_FULLBRIGHT, -1, {A_InfoState}, 5, 0, S_NULL}, // S_XDEATHSTATE {SPR_UNKN, FF_FULLBRIGHT, -1, {A_InfoState}, 5, 0, S_NULL}, // S_XDEATHSTATE
{SPR_UNKN, FF_FULLBRIGHT, -1, {A_InfoState}, 6, 0, S_NULL}, // S_RAISESTATE {SPR_UNKN, FF_FULLBRIGHT, -1, {A_InfoState}, 6, 0, S_NULL}, // S_RAISESTATE
// Thok // Spin trail and thok boom effect
{SPR_THOK, FF_TRANS50, 8, {NULL}, 0, 0, S_NULL}, // S_THOK {SPR_THOK, FF_TRANS50, 8, {NULL}, 0, 0, S_NULL}, // S_THOK
{SPR_THKE, FF_TRANS50|FF_PAPERSPRITE, 8, {NULL}, 0, 0, S_NULL}, // S_THOKEFFECT
// Player // Player
{SPR_PLAY, SPR2_STND|FF_ANIMATE, 105, {NULL}, 0, 7, S_PLAY_WAIT}, // S_PLAY_STND {SPR_PLAY, SPR2_STND|FF_ANIMATE, 105, {NULL}, 0, 7, S_PLAY_WAIT}, // S_PLAY_STND
@ -4079,6 +4081,33 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] =
S_NULL // raisestate S_NULL // raisestate
}, },
{ // MT_THOKEFFECT
-1, // doomednum
S_THOKEFFECT, // spawnstate
1000, // spawnhealth
S_NULL, // seestate
sfx_None, // seesound
8, // reactiontime
sfx_None, // attacksound
S_NULL, // painstate
0, // painchance
sfx_None, // painsound
S_NULL, // meleestate
S_NULL, // missilestate
S_NULL, // deathstate
S_NULL, // xdeathstate
sfx_None, // deathsound
8, // speed
32*FRACUNIT, // radius
64*FRACUNIT, // height
0, // display offset
16, // mass
0, // damage
sfx_None, // activesound
MF_NOBLOCKMAP|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_SCENERY, // flags
S_NULL // raisestate
},
{ // MT_PLAYER { // MT_PLAYER
-1, // doomednum -1, // doomednum
S_PLAY_STND, // spawnstate S_PLAY_STND, // spawnstate

View file

@ -580,7 +580,8 @@ typedef enum sprite
SPR_NULL, // invisible object SPR_NULL, // invisible object
SPR_UNKN, SPR_UNKN,
SPR_THOK, // Thok! mobj SPR_THOK, // Spin trail mobj
SPR_THKE, // Thok boom effect
SPR_PLAY, SPR_PLAY,
// Enemies // Enemies
@ -1182,8 +1183,9 @@ typedef enum state
S_XDEATHSTATE, S_XDEATHSTATE,
S_RAISESTATE, S_RAISESTATE,
// Thok // Thok boom effect and spin trail
S_THOK, S_THOK,
S_THOKEFFECT,
// Player // Player
S_PLAY_STND, S_PLAY_STND,
@ -4392,7 +4394,8 @@ typedef enum mobj_type
MT_NULL, MT_NULL,
MT_UNKNOWN, MT_UNKNOWN,
MT_THOK, // Thok! mobj MT_THOK, // Spin trail mobj
MT_THOKEFFECT, // Thok boom effect
MT_PLAYER, MT_PLAYER,
MT_TAILSOVERLAY, // c: MT_TAILSOVERLAY, // c:
MT_METALJETFUME, MT_METALJETFUME,

View file

@ -213,6 +213,8 @@ static const struct {
{META_HUDINFO, "hudinfo_t"}, {META_HUDINFO, "hudinfo_t"},
{META_PATCH, "patch_t"}, {META_PATCH, "patch_t"},
{META_COLORMAP, "colormap"}, {META_COLORMAP, "colormap"},
{META_EXTRACOLORMAP,"extracolormap_t"},
{META_LIGHTTABLE, "lighttable_t"},
{META_CAMERA, "camera_t"}, {META_CAMERA, "camera_t"},
{META_ACTION, "action"}, {META_ACTION, "action"},
@ -1031,6 +1033,20 @@ static int lib_pRailThinker(lua_State *L)
return 1; return 1;
} }
static int lib_pCheckSkyHit(lua_State *L)
{
mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
line_t *line = *((line_t **)luaL_checkudata(L, 2, META_LINE));
//HUDSAFE
INLEVEL
if (!mobj)
return LUA_ErrInvalid(L, "mobj_t");
if (!line)
return LUA_ErrInvalid(L, "line_t");
lua_pushboolean(L, P_CheckSkyHit(mobj, line));
return 1;
}
static int lib_pXYMovement(lua_State *L) static int lib_pXYMovement(lua_State *L)
{ {
mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
@ -1425,6 +1441,18 @@ static int lib_pGivePlayerRings(lua_State *L)
return 0; return 0;
} }
static int lib_pGivePlayerSpheres(lua_State *L)
{
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
INT32 num_spheres = (INT32)luaL_checkinteger(L, 2);
NOHUD
INLEVEL
if (!player)
return LUA_ErrInvalid(L, "player_t");
P_GivePlayerSpheres(player, num_spheres);
return 0;
}
static int lib_pGivePlayerLives(lua_State *L) static int lib_pGivePlayerLives(lua_State *L)
{ {
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
@ -1660,11 +1688,12 @@ static int lib_pHomingAttack(lua_State *L)
static int lib_pSuperReady(lua_State *L) static int lib_pSuperReady(lua_State *L)
{ {
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
boolean transform = (boolean)lua_opttrueboolean(L, 2);
//HUDSAFE //HUDSAFE
INLEVEL INLEVEL
if (!player) if (!player)
return LUA_ErrInvalid(L, "player_t"); return LUA_ErrInvalid(L, "player_t");
lua_pushboolean(L, P_SuperReady(player)); lua_pushboolean(L, P_SuperReady(player, transform));
return 1; return 1;
} }
@ -1680,6 +1709,17 @@ static int lib_pDoJump(lua_State *L)
return 0; return 0;
} }
static int lib_pDoSpinDashDust(lua_State *L)
{
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
NOHUD
INLEVEL
if (!player)
return LUA_ErrInvalid(L, "player_t");
P_DoSpinDashDust(player);
return 0;
}
static int lib_pSpawnThokMobj(lua_State *L) static int lib_pSpawnThokMobj(lua_State *L)
{ {
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
@ -1730,6 +1770,48 @@ static int lib_pSwitchShield(lua_State *L)
return 0; return 0;
} }
static int lib_pDoTailsOverlay(lua_State *L)
{
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
mobj_t *tails = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
NOHUD
INLEVEL
if (!player)
return LUA_ErrInvalid(L, "player_t");
if (!tails)
return LUA_ErrInvalid(L, "mobj_t");
P_DoTailsOverlay(player, tails);
return 0;
}
static int lib_pDoMetalJetFume(lua_State *L)
{
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
mobj_t *fume = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
NOHUD
INLEVEL
if (!player)
return LUA_ErrInvalid(L, "player_t");
if (!fume)
return LUA_ErrInvalid(L, "mobj_t");
P_DoMetalJetFume(player, fume);
return 0;
}
static int lib_pDoFollowMobj(lua_State *L)
{
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
mobj_t *followmobj = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
NOHUD
INLEVEL
if (!player)
return LUA_ErrInvalid(L, "player_t");
if (!followmobj)
return LUA_ErrInvalid(L, "mobj_t");
P_DoFollowMobj(player, followmobj);
return 0;
}
static int lib_pPlayerCanEnterSpinGaps(lua_State *L) static int lib_pPlayerCanEnterSpinGaps(lua_State *L)
{ {
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
@ -1801,6 +1883,7 @@ static int lib_pMove(lua_State *L)
return 2; return 2;
} }
// TODO: 2.3: Delete
static int lib_pTeleportMove(lua_State *L) static int lib_pTeleportMove(lua_State *L)
{ {
mobj_t *ptmthing = tmthing; mobj_t *ptmthing = tmthing;
@ -1941,6 +2024,30 @@ static int lib_pCeilingzAtPos(lua_State *L)
return 1; return 1;
} }
static int lib_pGetSectorColormapAt(lua_State *L)
{
boolean has_sector = false;
sector_t *sector = NULL;
if (!lua_isnoneornil(L, 1))
{
has_sector = true;
sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR));
}
fixed_t x = luaL_checkfixed(L, 2);
fixed_t y = luaL_checkfixed(L, 3);
fixed_t z = luaL_checkfixed(L, 4);
INLEVEL
if (has_sector && !sector)
return LUA_ErrInvalid(L, "sector_t");
extracolormap_t *exc;
if (sector)
exc = P_GetColormapFromSectorAt(sector, x, y, z);
else
exc = P_GetSectorColormapAt(x, y, z);
LUA_PushUserdata(L, exc, META_EXTRACOLORMAP);
return 1;
}
static int lib_pDoSpring(lua_State *L) static int lib_pDoSpring(lua_State *L)
{ {
mobj_t *spring = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); mobj_t *spring = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
@ -2211,6 +2318,21 @@ static int lib_pDoMatchSuper(lua_State *L)
return 0; return 0;
} }
static int lib_pTouchSpecialThing(lua_State *L)
{
mobj_t *special = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobj_t *toucher = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
boolean heightcheck = lua_optboolean(L, 3);
NOHUD
INLEVEL
if (!special || !toucher)
return LUA_ErrInvalid(L, "mobj_t");
if (!toucher->player)
return luaL_error(L, "P_TouchSpecialThing requires a valid toucher.player.");
P_TouchSpecialThing(special, toucher, heightcheck);
return 0;
}
// P_SPEC // P_SPEC
//////////// ////////////
@ -2313,6 +2435,7 @@ static int lib_pMobjTouchingSectorSpecial(lua_State *L)
return 1; return 1;
} }
// TODO: 2.3: Delete
static int lib_pThingOnSpecial3DFloor(lua_State *L) static int lib_pThingOnSpecial3DFloor(lua_State *L)
{ {
mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
@ -3617,6 +3740,7 @@ static int lib_gAddPlayer(lua_State *L)
newplayer->jointime = 0; newplayer->jointime = 0;
newplayer->quittime = 0; newplayer->quittime = 0;
newplayer->lastinputtime = 0;
// Read the skin argument (defaults to Sonic) // Read the skin argument (defaults to Sonic)
if (!lua_isnoneornil(L, 1)) if (!lua_isnoneornil(L, 1))
@ -4126,6 +4250,7 @@ static luaL_Reg lib[] = {
{"P_CreateFloorSpriteSlope",lib_pCreateFloorSpriteSlope}, {"P_CreateFloorSpriteSlope",lib_pCreateFloorSpriteSlope},
{"P_RemoveFloorSpriteSlope",lib_pRemoveFloorSpriteSlope}, {"P_RemoveFloorSpriteSlope",lib_pRemoveFloorSpriteSlope},
{"P_RailThinker",lib_pRailThinker}, {"P_RailThinker",lib_pRailThinker},
{"P_CheckSkyHit",lib_pCheckSkyHit},
{"P_XYMovement",lib_pXYMovement}, {"P_XYMovement",lib_pXYMovement},
{"P_RingXYMovement",lib_pRingXYMovement}, {"P_RingXYMovement",lib_pRingXYMovement},
{"P_SceneryXYMovement",lib_pSceneryXYMovement}, {"P_SceneryXYMovement",lib_pSceneryXYMovement},
@ -4158,6 +4283,7 @@ static luaL_Reg lib[] = {
{"P_SpawnShieldOrb",lib_pSpawnShieldOrb}, {"P_SpawnShieldOrb",lib_pSpawnShieldOrb},
{"P_SpawnGhostMobj",lib_pSpawnGhostMobj}, {"P_SpawnGhostMobj",lib_pSpawnGhostMobj},
{"P_GivePlayerRings",lib_pGivePlayerRings}, {"P_GivePlayerRings",lib_pGivePlayerRings},
{"P_GivePlayerSpheres",lib_pGivePlayerSpheres},
{"P_GivePlayerLives",lib_pGivePlayerLives}, {"P_GivePlayerLives",lib_pGivePlayerLives},
{"P_GiveCoopLives",lib_pGiveCoopLives}, {"P_GiveCoopLives",lib_pGiveCoopLives},
{"P_ResetScore",lib_pResetScore}, {"P_ResetScore",lib_pResetScore},
@ -4179,10 +4305,14 @@ static luaL_Reg lib[] = {
{"P_HomingAttack",lib_pHomingAttack}, {"P_HomingAttack",lib_pHomingAttack},
{"P_SuperReady",lib_pSuperReady}, {"P_SuperReady",lib_pSuperReady},
{"P_DoJump",lib_pDoJump}, {"P_DoJump",lib_pDoJump},
{"P_DoSpinDashDust",lib_pDoSpinDashDust},
{"P_SpawnThokMobj",lib_pSpawnThokMobj}, {"P_SpawnThokMobj",lib_pSpawnThokMobj},
{"P_SpawnSpinMobj",lib_pSpawnSpinMobj}, {"P_SpawnSpinMobj",lib_pSpawnSpinMobj},
{"P_Telekinesis",lib_pTelekinesis}, {"P_Telekinesis",lib_pTelekinesis},
{"P_SwitchShield",lib_pSwitchShield}, {"P_SwitchShield",lib_pSwitchShield},
{"P_DoTailsOverlay",lib_pDoTailsOverlay},
{"P_DoMetalJetFume",lib_pDoMetalJetFume},
{"P_DoFollowMobj",lib_pDoFollowMobj},
{"P_PlayerCanEnterSpinGaps",lib_pPlayerCanEnterSpinGaps}, {"P_PlayerCanEnterSpinGaps",lib_pPlayerCanEnterSpinGaps},
{"P_PlayerShouldUseSpinHeight",lib_pPlayerShouldUseSpinHeight}, {"P_PlayerShouldUseSpinHeight",lib_pPlayerShouldUseSpinHeight},
@ -4200,7 +4330,9 @@ static luaL_Reg lib[] = {
{"P_RadiusAttack",lib_pRadiusAttack}, {"P_RadiusAttack",lib_pRadiusAttack},
{"P_FloorzAtPos",lib_pFloorzAtPos}, {"P_FloorzAtPos",lib_pFloorzAtPos},
{"P_CeilingzAtPos",lib_pCeilingzAtPos}, {"P_CeilingzAtPos",lib_pCeilingzAtPos},
{"P_GetSectorColormapAt",lib_pGetSectorColormapAt},
{"P_DoSpring",lib_pDoSpring}, {"P_DoSpring",lib_pDoSpring},
{"P_TouchSpecialThing",lib_pTouchSpecialThing},
{"P_TryCameraMove", lib_pTryCameraMove}, {"P_TryCameraMove", lib_pTryCameraMove},
{"P_TeleportCameraMove", lib_pTeleportCameraMove}, {"P_TeleportCameraMove", lib_pTeleportCameraMove},
@ -4350,8 +4482,7 @@ int LUA_BaseLib(lua_State *L)
// Set metatable for string // Set metatable for string
lua_pushliteral(L, ""); // dummy string lua_pushliteral(L, ""); // dummy string
lua_getmetatable(L, -1); // get string metatable lua_getmetatable(L, -1); // get string metatable
lua_pushcfunction(L,lib_concat); // push concatination function LUA_SetCFunctionField(L, "__add", lib_concat);
lua_setfield(L,-2,"__add"); // ... store it as mathematical addition
lua_pop(L, 2); // pop metatable and dummy string lua_pop(L, 2); // pop metatable and dummy string
lua_newtable(L); lua_newtable(L);

332
src/lua_colorlib.c Normal file
View file

@ -0,0 +1,332 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 2021-2022 by "Lactozilla".
// Copyright (C) 2014-2023 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 lua_colorlib.c
/// \brief color and colormap libraries for Lua scripting
#include "doomdef.h"
#include "fastcmp.h"
#include "r_data.h"
#include "lua_script.h"
#include "lua_libs.h"
#define IS_HEX_CHAR(x) ((x >= '0' && x <= '9') || (x >= 'a' && x <= 'f') || (x >= 'A' && x <= 'F'))
#define ARE_HEX_CHARS(str, i) IS_HEX_CHAR(str[i]) && IS_HEX_CHAR(str[i + 1])
static UINT32 hex2int(char x)
{
if (x >= '0' && x <= '9')
return x - '0';
else if (x >= 'a' && x <= 'f')
return x - 'a' + 10;
else if (x >= 'A' && x <= 'F')
return x - 'A' + 10;
return 0;
}
static UINT8 ParseHTMLColor(const char *str, UINT8 *rgba, size_t numc)
{
const char *hex = str;
if (hex[0] == '#')
hex++;
else if (!IS_HEX_CHAR(hex[0]))
return 0;
size_t len = strlen(hex);
if (len == 3)
{
// Shorthand like #09C
for (unsigned i = 0; i < 3; i++)
{
if (!IS_HEX_CHAR(hex[i]))
return 0;
UINT32 hx = hex2int(hex[i]);
*rgba++ = (hx * 16) + hx;
}
return 3;
}
else if (len == 6 || len == 8)
{
if (numc != 4)
len = 6;
// A triplet like #0099CC
for (unsigned i = 0; i < len; i += 2)
{
if (!ARE_HEX_CHARS(hex, i))
return false;
*rgba++ = (hex2int(hex[i]) * 16) + hex2int(hex[i + 1]);
}
return len;
}
return 0;
}
/////////////////////////
// extracolormap userdata
/////////////////////////
enum extracolormap_e {
extracolormap_red = 0,
extracolormap_green,
extracolormap_blue,
extracolormap_alpha,
extracolormap_color,
extracolormap_fade_red,
extracolormap_fade_green,
extracolormap_fade_blue,
extracolormap_fade_alpha,
extracolormap_fade_color,
extracolormap_fade_start,
extracolormap_fade_end,
extracolormap_colormap
};
static const char *const extracolormap_opt[] = {
"red",
"green",
"blue",
"alpha",
"color",
"fade_red",
"fade_green",
"fade_blue",
"fade_alpha",
"fade_color",
"fade_start",
"fade_end",
"colormap",
NULL};
static int extracolormap_get(lua_State *L)
{
extracolormap_t *exc = *((extracolormap_t **)luaL_checkudata(L, 1, META_EXTRACOLORMAP));
enum extracolormap_e field = luaL_checkoption(L, 2, NULL, extracolormap_opt);
switch (field)
{
case extracolormap_red:
lua_pushinteger(L, R_GetRgbaR(exc->rgba));
break;
case extracolormap_green:
lua_pushinteger(L, R_GetRgbaG(exc->rgba));
break;
case extracolormap_blue:
lua_pushinteger(L, R_GetRgbaB(exc->rgba));
break;
case extracolormap_alpha:
lua_pushinteger(L, R_GetRgbaA(exc->rgba));
break;
case extracolormap_color:
lua_pushinteger(L, R_GetRgbaR(exc->rgba));
lua_pushinteger(L, R_GetRgbaG(exc->rgba));
lua_pushinteger(L, R_GetRgbaB(exc->rgba));
lua_pushinteger(L, R_GetRgbaA(exc->rgba));
return 4;
case extracolormap_fade_red:
lua_pushinteger(L, R_GetRgbaR(exc->fadergba));
break;
case extracolormap_fade_green:
lua_pushinteger(L, R_GetRgbaG(exc->fadergba));
break;
case extracolormap_fade_blue:
lua_pushinteger(L, R_GetRgbaB(exc->fadergba));
break;
case extracolormap_fade_alpha:
lua_pushinteger(L, R_GetRgbaA(exc->fadergba));
break;
case extracolormap_fade_color:
lua_pushinteger(L, R_GetRgbaR(exc->fadergba));
lua_pushinteger(L, R_GetRgbaG(exc->fadergba));
lua_pushinteger(L, R_GetRgbaB(exc->fadergba));
lua_pushinteger(L, R_GetRgbaA(exc->fadergba));
return 4;
case extracolormap_fade_start:
lua_pushinteger(L, exc->fadestart);
break;
case extracolormap_fade_end:
lua_pushinteger(L, exc->fadeend);
break;
case extracolormap_colormap:
LUA_PushUserdata(L, exc->colormap, META_LIGHTTABLE);
break;
}
return 1;
}
static void GetExtraColormapRGBA(lua_State *L, UINT8 *rgba, int arg)
{
if (lua_type(L, arg) == LUA_TSTRING)
{
const char *str = lua_tostring(L, arg);
UINT8 parsed = ParseHTMLColor(str, rgba, 4);
if (!parsed)
luaL_error(L, "Malformed HTML color '%s'", str);
}
else
{
UINT32 colors = lua_tointeger(L, arg);
if (colors > 0xFFFFFF)
{
rgba[0] = (colors >> 24) & 0xFF;
rgba[1] = (colors >> 16) & 0xFF;
rgba[2] = (colors >> 8) & 0xFF;
rgba[3] = colors & 0xFF;
}
else
{
rgba[0] = (colors >> 16) & 0xFF;
rgba[1] = (colors >> 8) & 0xFF;
rgba[2] = colors & 0xFF;
rgba[3] = 0xFF;
}
}
}
static int extracolormap_set(lua_State *L)
{
extracolormap_t *exc = *((extracolormap_t **)luaL_checkudata(L, 1, META_EXTRACOLORMAP));
enum extracolormap_e field = luaL_checkoption(L, 2, NULL, extracolormap_opt);
UINT8 r = R_GetRgbaR(exc->rgba);
UINT8 g = R_GetRgbaG(exc->rgba);
UINT8 b = R_GetRgbaB(exc->rgba);
UINT8 a = R_GetRgbaA(exc->rgba);
UINT8 fr = R_GetRgbaR(exc->fadergba);
UINT8 fg = R_GetRgbaG(exc->fadergba);
UINT8 fb = R_GetRgbaB(exc->fadergba);
UINT8 fa = R_GetRgbaA(exc->fadergba);
UINT8 rgba[4];
INT32 old_rgba = exc->rgba, old_fade_rgba = exc->fadergba; // It's not unsigned?
UINT8 old_fade_start = exc->fadestart, old_fade_end = exc->fadeend;
#define val luaL_checkinteger(L, 3)
switch(field)
{
case extracolormap_red:
exc->rgba = R_PutRgbaRGBA(val, g, b, a);
break;
case extracolormap_green:
exc->rgba = R_PutRgbaRGBA(r, val, b, a);
break;
case extracolormap_blue:
exc->rgba = R_PutRgbaRGBA(r, g, val, a);
break;
case extracolormap_alpha:
exc->rgba = R_PutRgbaRGBA(r, g, b, val);
break;
case extracolormap_color:
rgba[0] = r;
rgba[1] = g;
rgba[2] = b;
rgba[3] = a;
GetExtraColormapRGBA(L, rgba, 3);
exc->rgba = R_PutRgbaRGBA(rgba[0], rgba[1], rgba[2], rgba[3]);
break;
case extracolormap_fade_red:
exc->fadergba = R_PutRgbaRGBA(val, fg, fb, fa);
break;
case extracolormap_fade_green:
exc->fadergba = R_PutRgbaRGBA(fr, val, fb, fa);
break;
case extracolormap_fade_blue:
exc->fadergba = R_PutRgbaRGBA(fr, fg, val, fa);
break;
case extracolormap_fade_alpha:
exc->fadergba = R_PutRgbaRGBA(fr, fg, fb, val);
break;
case extracolormap_fade_color:
rgba[0] = fr;
rgba[1] = fg;
rgba[2] = fb;
rgba[3] = fa;
GetExtraColormapRGBA(L, rgba, 3);
exc->fadergba = R_PutRgbaRGBA(rgba[0], rgba[1], rgba[2], rgba[3]);
break;
case extracolormap_fade_start:
if (val > 31)
return luaL_error(L, "fade start %d out of range (0 - 31)", val);
exc->fadestart = val;
break;
case extracolormap_fade_end:
if (val > 31)
return luaL_error(L, "fade end %d out of range (0 - 31)", val);
exc->fadeend = val;
break;
case extracolormap_colormap:
return luaL_error(L, LUA_QL("extracolormap_t") " field " LUA_QS " should not be set directly.", extracolormap_opt[field]);
}
#undef val
if (exc->rgba != old_rgba
|| exc->fadergba != old_fade_rgba
|| exc->fadestart != old_fade_start
|| exc->fadeend != old_fade_end)
R_GenerateLightTable(exc, true);
return 0;
}
static int lighttable_get(lua_State *L)
{
void **userdata;
lighttable_t *table = *((lighttable_t **)luaL_checkudata(L, 1, META_LIGHTTABLE));
UINT32 row = luaL_checkinteger(L, 2);
if (row < 1 || row > 34)
return luaL_error(L, "lighttable row %d out of range (1 - %d)", row, 34);
userdata = lua_newuserdata(L, sizeof(void *));
*userdata = &table[256 * (row - 1)];
luaL_getmetatable(L, META_COLORMAP);
lua_setmetatable(L, -2);
return 1;
}
static int lighttable_len(lua_State *L)
{
lua_pushinteger(L, NUM_PALETTE_ENTRIES);
return 1;
}
int LUA_ColorLib(lua_State *L)
{
luaL_newmetatable(L, META_EXTRACOLORMAP);
lua_pushcfunction(L, extracolormap_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, extracolormap_set);
lua_setfield(L, -2, "__newindex");
lua_pop(L, 1);
luaL_newmetatable(L, META_LIGHTTABLE);
lua_pushcfunction(L, lighttable_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lighttable_len);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
return 0;
}

View file

@ -194,6 +194,7 @@ static int lib_comAddCommand(lua_State *L)
if (lua_gettop(L) >= 3) if (lua_gettop(L) >= 3)
{ // For the third argument, only take a boolean or a number. { // For the third argument, only take a boolean or a number.
lua_settop(L, 3); lua_settop(L, 3);
// TODO: 2.3: Remove boolean option
if (lua_type(L, 3) == LUA_TBOOLEAN) if (lua_type(L, 3) == LUA_TBOOLEAN)
{ {
CONS_Alert(CONS_WARNING, CONS_Alert(CONS_WARNING,
@ -696,10 +697,7 @@ static int cvar_get(lua_State *L)
int LUA_ConsoleLib(lua_State *L) int LUA_ConsoleLib(lua_State *L)
{ {
// Metatable for consvar_t // Metatable for consvar_t
luaL_newmetatable(L, META_CVAR); LUA_RegisterUserdataMetatable(L, META_CVAR, cvar_get, NULL, NULL);
lua_pushcfunction(L, cvar_get);
lua_setfield(L, -2, "__index");
lua_pop(L,1);
cvar_fields_ref = Lua_CreateFieldTable(L, cvar_opt); cvar_fields_ref = Lua_CreateFieldTable(L, cvar_opt);

View file

@ -76,12 +76,12 @@ static boolean mobj_hook_available(int hook_type, mobjtype_t mobj_type)
); );
} }
static int hook_in_list static unsigned hook_in_list
( (
const char * const name, const char * const name,
const char * const * const list const char * const * const list
){ ){
int type; unsigned type;
for (type = 0; list[type] != NULL; ++type) for (type = 0; list[type] != NULL; ++type)
{ {
@ -200,7 +200,7 @@ static void add_hook_ref(lua_State *L, int idx)
static int lib_addHook(lua_State *L) static int lib_addHook(lua_State *L)
{ {
const char * name; const char * name;
int type; unsigned type;
if (!lua_lumploading) if (!lua_lumploading)
return luaL_error(L, "This function cannot be called from within a hook or coroutine!"); return luaL_error(L, "This function cannot be called from within a hook or coroutine!");

View file

@ -517,7 +517,7 @@ static int libd_getSpritePatch(lua_State *L)
INT32 rot = R_GetRollAngle(rollangle); INT32 rot = R_GetRollAngle(rollangle);
if (rot) { if (rot) {
patch_t *rotsprite = Patch_GetRotatedSprite(sprframe, frame, angle, sprframe->flip & (1<<angle), true, &spriteinfo[i], rot); patch_t *rotsprite = Patch_GetRotatedSprite(sprframe, frame, angle, sprframe->flip & (1<<angle), &spriteinfo[i], rot);
LUA_PushUserdata(L, rotsprite, META_PATCH); LUA_PushUserdata(L, rotsprite, META_PATCH);
lua_pushboolean(L, false); lua_pushboolean(L, false);
lua_pushboolean(L, true); lua_pushboolean(L, true);
@ -629,7 +629,7 @@ static int libd_getSprite2Patch(lua_State *L)
INT32 rot = R_GetRollAngle(rollangle); INT32 rot = R_GetRollAngle(rollangle);
if (rot) { if (rot) {
patch_t *rotsprite = Patch_GetRotatedSprite(sprframe, frame, angle, sprframe->flip & (1<<angle), true, &skins[i].sprinfo[j], rot); patch_t *rotsprite = Patch_GetRotatedSprite(sprframe, frame, angle, sprframe->flip & (1<<angle), &skins[i].sprinfo[j], rot);
LUA_PushUserdata(L, rotsprite, META_PATCH); LUA_PushUserdata(L, rotsprite, META_PATCH);
lua_pushboolean(L, false); lua_pushboolean(L, false);
lua_pushboolean(L, true); lua_pushboolean(L, true);
@ -1396,52 +1396,16 @@ int LUA_HudLib(lua_State *L)
luaL_register(L, NULL, lib_draw); luaL_register(L, NULL, lib_draw);
lib_draw_ref = luaL_ref(L, LUA_REGISTRYINDEX); lib_draw_ref = luaL_ref(L, LUA_REGISTRYINDEX);
luaL_newmetatable(L, META_HUDINFO); LUA_RegisterUserdataMetatable(L, META_HUDINFO, hudinfo_get, hudinfo_set, hudinfo_num);
lua_pushcfunction(L, hudinfo_get); LUA_RegisterUserdataMetatable(L, META_COLORMAP, colormap_get, NULL, NULL);
lua_setfield(L, -2, "__index"); LUA_RegisterUserdataMetatable(L, META_PATCH, patch_get, patch_set, NULL);
LUA_RegisterUserdataMetatable(L, META_CAMERA, camera_get, camera_set, NULL);
lua_pushcfunction(L, hudinfo_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, hudinfo_num);
lua_setfield(L, -2, "__len");
lua_pop(L,1);
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getHudInfo);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_hudinfolen);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "hudinfo");
luaL_newmetatable(L, META_COLORMAP);
lua_pushcfunction(L, colormap_get);
lua_setfield(L, -2, "__index");
lua_pop(L,1);
luaL_newmetatable(L, META_PATCH);
lua_pushcfunction(L, patch_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, patch_set);
lua_setfield(L, -2, "__newindex");
lua_pop(L,1);
patch_fields_ref = Lua_CreateFieldTable(L, patch_opt); patch_fields_ref = Lua_CreateFieldTable(L, patch_opt);
luaL_newmetatable(L, META_CAMERA);
lua_pushcfunction(L, camera_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, camera_set);
lua_setfield(L, -2, "__newindex");
lua_pop(L,1);
camera_fields_ref = Lua_CreateFieldTable(L, camera_opt); camera_fields_ref = Lua_CreateFieldTable(L, camera_opt);
LUA_RegisterGlobalUserdata(L, "hudinfo", lib_getHudInfo, NULL, lib_hudinfolen);
luaL_register(L, "hud", lib_hud); luaL_register(L, "hud", lib_hud);
return 0; return 0;
} }

View file

@ -318,6 +318,7 @@ static int PopPivotSubTable(spriteframepivot_t *pivot, lua_State *L, int stk, in
pivot[idx].x = (INT32)value; pivot[idx].x = (INT32)value;
else if (ikey == 2 || (key && fastcmp(key, "y"))) else if (ikey == 2 || (key && fastcmp(key, "y")))
pivot[idx].y = (INT32)value; pivot[idx].y = (INT32)value;
// TODO: 2.3: Delete
else if (ikey == 3 || (key && fastcmp(key, "rotaxis"))) else if (ikey == 3 || (key && fastcmp(key, "rotaxis")))
LUA_UsageWarning(L, "\"rotaxis\" is deprecated and will be removed.") LUA_UsageWarning(L, "\"rotaxis\" is deprecated and will be removed.")
else if (ikey == -1 && (key != NULL)) else if (ikey == -1 && (key != NULL))
@ -571,6 +572,7 @@ static int framepivot_get(lua_State *L)
lua_pushinteger(L, framepivot->x); lua_pushinteger(L, framepivot->x);
else if (fastcmp("y", field)) else if (fastcmp("y", field))
lua_pushinteger(L, framepivot->y); lua_pushinteger(L, framepivot->y);
// TODO: 2.3: Delete
else if (fastcmp("rotaxis", field)) else if (fastcmp("rotaxis", field))
{ {
LUA_UsageWarning(L, "\"rotaxis\" is deprecated and will be removed."); LUA_UsageWarning(L, "\"rotaxis\" is deprecated and will be removed.");
@ -600,6 +602,7 @@ static int framepivot_set(lua_State *L)
framepivot->x = luaL_checkinteger(L, 3); framepivot->x = luaL_checkinteger(L, 3);
else if (fastcmp("y", field)) else if (fastcmp("y", field))
framepivot->y = luaL_checkinteger(L, 3); framepivot->y = luaL_checkinteger(L, 3);
// TODO: 2.3: delete
else if (fastcmp("rotaxis", field)) else if (fastcmp("rotaxis", field))
LUA_UsageWarning(L, "\"rotaxis\" is deprecated and will be removed.") LUA_UsageWarning(L, "\"rotaxis\" is deprecated and will be removed.")
else else
@ -1914,206 +1917,28 @@ int LUA_InfoLib(lua_State *L)
lua_newtable(L); lua_newtable(L);
lua_setfield(L, LUA_REGISTRYINDEX, LREG_ACTIONS); lua_setfield(L, LUA_REGISTRYINDEX, LREG_ACTIONS);
luaL_newmetatable(L, META_STATE); LUA_RegisterUserdataMetatable(L, META_STATE, state_get, state_set, state_num);
lua_pushcfunction(L, state_get); LUA_RegisterUserdataMetatable(L, META_MOBJINFO, mobjinfo_get, mobjinfo_set, mobjinfo_num);
lua_setfield(L, -2, "__index"); LUA_RegisterUserdataMetatable(L, META_SKINCOLOR, skincolor_get, skincolor_set, skincolor_num);
LUA_RegisterUserdataMetatable(L, META_COLORRAMP, colorramp_get, colorramp_set, colorramp_len);
lua_pushcfunction(L, state_set); LUA_RegisterUserdataMetatable(L, META_SFXINFO, sfxinfo_get, sfxinfo_set, sfxinfo_num);
lua_setfield(L, -2, "__newindex"); LUA_RegisterUserdataMetatable(L, META_SPRITEINFO, spriteinfo_get, spriteinfo_set, spriteinfo_num);
LUA_RegisterUserdataMetatable(L, META_PIVOTLIST, pivotlist_get, pivotlist_set, pivotlist_num);
lua_pushcfunction(L, state_num); LUA_RegisterUserdataMetatable(L, META_FRAMEPIVOT, framepivot_get, framepivot_set, framepivot_num);
lua_setfield(L, -2, "__len"); LUA_RegisterUserdataMetatable(L, META_LUABANKS, lib_getluabanks, lib_setluabanks, lib_luabankslen);
lua_pop(L, 1);
luaL_newmetatable(L, META_MOBJINFO);
lua_pushcfunction(L, mobjinfo_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, mobjinfo_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, mobjinfo_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
mobjinfo_fields_ref = Lua_CreateFieldTable(L, mobjinfo_opt); mobjinfo_fields_ref = Lua_CreateFieldTable(L, mobjinfo_opt);
luaL_newmetatable(L, META_SKINCOLOR); LUA_RegisterGlobalUserdata(L, "sprnames", lib_getSprname, NULL, lib_sprnamelen);
lua_pushcfunction(L, skincolor_get); LUA_RegisterGlobalUserdata(L, "spr2names", lib_getSpr2name, NULL, lib_spr2namelen);
lua_setfield(L, -2, "__index"); LUA_RegisterGlobalUserdata(L, "spr2defaults", lib_getSpr2default, lib_setSpr2default, lib_spr2namelen);
LUA_RegisterGlobalUserdata(L, "states", lib_getState, lib_setState, lib_statelen);
lua_pushcfunction(L, skincolor_set); LUA_RegisterGlobalUserdata(L, "mobjinfo", lib_getMobjInfo, lib_setMobjInfo, lib_mobjinfolen);
lua_setfield(L, -2, "__newindex"); LUA_RegisterGlobalUserdata(L, "skincolors", lib_getSkinColor, lib_setSkinColor, lib_skincolorslen);
LUA_RegisterGlobalUserdata(L, "spriteinfo", lib_getSpriteInfo, lib_setSpriteInfo, lib_spriteinfolen);
lua_pushcfunction(L, skincolor_num); LUA_RegisterGlobalUserdata(L, "sfxinfo", lib_getSfxInfo, lib_setSfxInfo, lib_sfxlen);
lua_setfield(L, -2, "__len"); // TODO: 2.3: Delete this alias
lua_pop(L, 1); LUA_RegisterGlobalUserdata(L, "S_sfx", lib_getSfxInfo, lib_setSfxInfo, lib_sfxlen);
luaL_newmetatable(L, META_COLORRAMP);
lua_pushcfunction(L, colorramp_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, colorramp_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, colorramp_len);
lua_setfield(L, -2, "__len");
lua_pop(L,1);
luaL_newmetatable(L, META_SFXINFO);
lua_pushcfunction(L, sfxinfo_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, sfxinfo_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, sfxinfo_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_SPRITEINFO);
lua_pushcfunction(L, spriteinfo_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, spriteinfo_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, spriteinfo_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_PIVOTLIST);
lua_pushcfunction(L, pivotlist_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, pivotlist_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, pivotlist_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_FRAMEPIVOT);
lua_pushcfunction(L, framepivot_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, framepivot_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, framepivot_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getSprname);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_sprnamelen);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "sprnames");
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getSpr2name);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_spr2namelen);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "spr2names");
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getSpr2default);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_setSpr2default);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, lib_spr2namelen);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "spr2defaults");
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getState);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_setState);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, lib_statelen);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "states");
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getMobjInfo);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_setMobjInfo);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, lib_mobjinfolen);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "mobjinfo");
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getSkinColor);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_setSkinColor);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, lib_skincolorslen);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "skincolors");
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getSfxInfo);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_setSfxInfo);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, lib_sfxlen);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_pushvalue(L, -1);
lua_setglobal(L, "S_sfx");
lua_setglobal(L, "sfxinfo");
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getSpriteInfo);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_setSpriteInfo);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, lib_spriteinfolen);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "spriteinfo");
luaL_newmetatable(L, META_LUABANKS);
lua_pushcfunction(L, lib_getluabanks);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_setluabanks);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, lib_luabankslen);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
return 0; return 0;
} }

View file

@ -20,6 +20,7 @@
#include "lua_libs.h" #include "lua_libs.h"
boolean mousegrabbedbylua = true; boolean mousegrabbedbylua = true;
boolean ignoregameinputs = false;
/////////////// ///////////////
// FUNCTIONS // // FUNCTIONS //
@ -145,6 +146,51 @@ static luaL_Reg lib[] = {
{NULL, NULL} {NULL, NULL}
}; };
///////////////
// VARIABLES //
///////////////
static int lib_get(lua_State *L)
{
const char *field = luaL_checkstring(L, 2);
if (fastcmp(field, "mouse"))
{
LUA_PushUserdata(L, &mouse, META_MOUSE);
return 1;
}
else if (fastcmp(field, "mouse2"))
{
LUA_PushUserdata(L, &mouse2, META_MOUSE);
return 1;
}
else if (fastcmp(field, "ignoregameinputs"))
{
lua_pushboolean(L, ignoregameinputs);
return 1;
}
else
{
return 0;
}
}
static int lib_set(lua_State *L)
{
const char *field = luaL_checkstring(L, 2);
if (fastcmp(field, "ignoregameinputs"))
{
ignoregameinputs = luaL_checkboolean(L, 3);
}
else
{
lua_rawset(L, 1);
}
return 0;
}
/////////////////// ///////////////////
// gamekeydown[] // // gamekeydown[] //
/////////////////// ///////////////////
@ -239,32 +285,18 @@ static int mouse_num(lua_State *L)
int LUA_InputLib(lua_State *L) int LUA_InputLib(lua_State *L)
{ {
lua_newuserdata(L, 0); LUA_RegisterUserdataMetatable(L, META_KEYEVENT, keyevent_get, NULL, NULL);
lua_createtable(L, 0, 2); LUA_RegisterUserdataMetatable(L, META_MOUSE, mouse_get, NULL, mouse_num);
lua_pushcfunction(L, lib_getGameKeyDown);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_setGameKeyDown);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, lib_lenGameKeyDown);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "gamekeydown");
luaL_newmetatable(L, META_KEYEVENT);
lua_pushcfunction(L, keyevent_get);
lua_setfield(L, -2, "__index");
lua_pop(L, 1);
luaL_newmetatable(L, META_MOUSE);
lua_pushcfunction(L, mouse_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, mouse_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
// Register the library, then add __index and __newindex
// metamethods to it to allow global variables
luaL_register(L, "input", lib); luaL_register(L, "input", lib);
LUA_CreateAndSetMetatable(L, lib_get, lib_set, NULL, false);
LUA_CreateAndSetUserdataField(L, -1, "gamekeydown", lib_getGameKeyDown, lib_setGameKeyDown, lib_lenGameKeyDown, false);
// TODO: 2.3: Delete this alias (moved to input library)
LUA_RegisterGlobalUserdata(L, "gamekeydown", lib_getGameKeyDown, lib_setGameKeyDown, lib_lenGameKeyDown);
lua_pop(L, 1);
return 0; return 0;
} }

View file

@ -13,6 +13,7 @@
extern lua_State *gL; extern lua_State *gL;
extern boolean mousegrabbedbylua; extern boolean mousegrabbedbylua;
extern boolean ignoregameinputs;
#define MUTABLE_TAGS #define MUTABLE_TAGS
@ -84,6 +85,8 @@ extern boolean mousegrabbedbylua;
#define META_HUDINFO "HUDINFO_T*" #define META_HUDINFO "HUDINFO_T*"
#define META_PATCH "PATCH_T*" #define META_PATCH "PATCH_T*"
#define META_COLORMAP "COLORMAP" #define META_COLORMAP "COLORMAP"
#define META_EXTRACOLORMAP "EXTRACOLORMAP_T*"
#define META_LIGHTTABLE "LIGHTTABLE_T*"
#define META_CAMERA "CAMERA_T*" #define META_CAMERA "CAMERA_T*"
#define META_ACTION "ACTIONF_T*" #define META_ACTION "ACTIONF_T*"
@ -111,4 +114,5 @@ int LUA_TagLib(lua_State *L);
int LUA_PolyObjLib(lua_State *L); int LUA_PolyObjLib(lua_State *L);
int LUA_BlockmapLib(lua_State *L); int LUA_BlockmapLib(lua_State *L);
int LUA_HudLib(lua_State *L); int LUA_HudLib(lua_State *L);
int LUA_ColorLib(lua_State *L);
int LUA_InputLib(lua_State *L); int LUA_InputLib(lua_State *L);

View file

@ -35,10 +35,14 @@ enum sector_e {
sector_floorpic, sector_floorpic,
sector_floorxoffset, sector_floorxoffset,
sector_flooryoffset, sector_flooryoffset,
sector_floorxscale,
sector_flooryscale,
sector_floorangle, sector_floorangle,
sector_ceilingpic, sector_ceilingpic,
sector_ceilingxoffset, sector_ceilingxoffset,
sector_ceilingyoffset, sector_ceilingyoffset,
sector_ceilingxscale,
sector_ceilingyscale,
sector_ceilingangle, sector_ceilingangle,
sector_lightlevel, sector_lightlevel,
sector_floorlightlevel, sector_floorlightlevel,
@ -57,6 +61,7 @@ enum sector_e {
sector_ffloors, sector_ffloors,
sector_fslope, sector_fslope,
sector_cslope, sector_cslope,
sector_colormap,
sector_flags, sector_flags,
sector_specialflags, sector_specialflags,
sector_damagetype, sector_damagetype,
@ -73,10 +78,14 @@ static const char *const sector_opt[] = {
"floorpic", "floorpic",
"floorxoffset", "floorxoffset",
"flooryoffset", "flooryoffset",
"floorxscale",
"flooryscale",
"floorangle", "floorangle",
"ceilingpic", "ceilingpic",
"ceilingxoffset", "ceilingxoffset",
"ceilingyoffset", "ceilingyoffset",
"ceilingxscale",
"ceilingyscale",
"ceilingangle", "ceilingangle",
"lightlevel", "lightlevel",
"floorlightlevel", "floorlightlevel",
@ -95,6 +104,7 @@ static const char *const sector_opt[] = {
"ffloors", "ffloors",
"f_slope", "f_slope",
"c_slope", "c_slope",
"colormap",
"flags", "flags",
"specialflags", "specialflags",
"damagetype", "damagetype",
@ -186,8 +196,16 @@ enum side_e {
side_offsety_top, side_offsety_top,
side_offsetx_mid, side_offsetx_mid,
side_offsety_mid, side_offsety_mid,
side_offsetx_bottom,
side_offsetx_bot, side_offsetx_bot,
side_offsety_bottom,
side_offsety_bot, side_offsety_bot,
side_scalex_top,
side_scaley_top,
side_scalex_mid,
side_scaley_mid,
side_scalex_bottom,
side_scaley_bottom,
side_toptexture, side_toptexture,
side_bottomtexture, side_bottomtexture,
side_midtexture, side_midtexture,
@ -206,8 +224,16 @@ static const char *const side_opt[] = {
"offsety_top", "offsety_top",
"offsetx_mid", "offsetx_mid",
"offsety_mid", "offsety_mid",
"offsetx_bottom",
"offsetx_bot", "offsetx_bot",
"offsety_bottom",
"offsety_bot", "offsety_bot",
"scalex_top",
"scaley_top",
"scalex_mid",
"scaley_mid",
"scalex_bottom",
"scaley_bottom",
"toptexture", "toptexture",
"bottomtexture", "bottomtexture",
"midtexture", "midtexture",
@ -247,8 +273,16 @@ enum ffloor_e {
ffloor_topheight, ffloor_topheight,
ffloor_toppic, ffloor_toppic,
ffloor_toplightlevel, ffloor_toplightlevel,
ffloor_topxoffs,
ffloor_topyoffs,
ffloor_topxscale,
ffloor_topyscale,
ffloor_bottomheight, ffloor_bottomheight,
ffloor_bottompic, ffloor_bottompic,
ffloor_bottomxoffs,
ffloor_bottomyoffs,
ffloor_bottomxscale,
ffloor_bottomyscale,
ffloor_tslope, ffloor_tslope,
ffloor_bslope, ffloor_bslope,
ffloor_sector, ffloor_sector,
@ -273,8 +307,16 @@ static const char *const ffloor_opt[] = {
"topheight", "topheight",
"toppic", "toppic",
"toplightlevel", "toplightlevel",
"topxoffs",
"topyoffs",
"topxscale",
"topyscale",
"bottomheight", "bottomheight",
"bottompic", "bottompic",
"bottomxoffs",
"bottomyoffs",
"bottomxscale",
"bottomyscale",
"t_slope", "t_slope",
"b_slope", "b_slope",
"sector", // secnum pushed as control sector userdata "sector", // secnum pushed as control sector userdata
@ -654,20 +696,20 @@ static int sector_get(lua_State *L)
return 1; return 1;
} }
case sector_floorxoffset: case sector_floorxoffset:
{
lua_pushfixed(L, sector->floorxoffset); lua_pushfixed(L, sector->floorxoffset);
return 1; return 1;
}
case sector_flooryoffset: case sector_flooryoffset:
{
lua_pushfixed(L, sector->flooryoffset); lua_pushfixed(L, sector->flooryoffset);
return 1; return 1;
} case sector_floorxscale:
lua_pushfixed(L, sector->floorxscale);
return 1;
case sector_flooryscale:
lua_pushfixed(L, sector->flooryscale);
return 1;
case sector_floorangle: case sector_floorangle:
{
lua_pushangle(L, sector->floorangle); lua_pushangle(L, sector->floorangle);
return 1; return 1;
}
case sector_ceilingpic: // ceilingpic case sector_ceilingpic: // ceilingpic
{ {
levelflat_t *levelflat = &levelflats[sector->ceilingpic]; levelflat_t *levelflat = &levelflats[sector->ceilingpic];
@ -678,20 +720,20 @@ static int sector_get(lua_State *L)
return 1; return 1;
} }
case sector_ceilingxoffset: case sector_ceilingxoffset:
{
lua_pushfixed(L, sector->ceilingxoffset); lua_pushfixed(L, sector->ceilingxoffset);
return 1; return 1;
}
case sector_ceilingyoffset: case sector_ceilingyoffset:
{
lua_pushfixed(L, sector->ceilingyoffset); lua_pushfixed(L, sector->ceilingyoffset);
return 1; return 1;
} case sector_ceilingxscale:
lua_pushfixed(L, sector->ceilingxscale);
return 1;
case sector_ceilingyscale:
lua_pushfixed(L, sector->ceilingyscale);
return 1;
case sector_ceilingangle: case sector_ceilingangle:
{
lua_pushangle(L, sector->ceilingangle); lua_pushangle(L, sector->ceilingangle);
return 1; return 1;
}
case sector_lightlevel: case sector_lightlevel:
lua_pushinteger(L, sector->lightlevel); lua_pushinteger(L, sector->lightlevel);
return 1; return 1;
@ -751,6 +793,9 @@ static int sector_get(lua_State *L)
case sector_cslope: // c_slope case sector_cslope: // c_slope
LUA_PushUserdata(L, sector->c_slope, META_SLOPE); LUA_PushUserdata(L, sector->c_slope, META_SLOPE);
return 1; return 1;
case sector_colormap: // extra_colormap
LUA_PushUserdata(L, sector->extra_colormap, META_EXTRACOLORMAP);
return 1;
case sector_flags: // flags case sector_flags: // flags
lua_pushinteger(L, sector->flags); lua_pushinteger(L, sector->flags);
return 1; return 1;
@ -840,6 +885,12 @@ static int sector_set(lua_State *L)
case sector_flooryoffset: case sector_flooryoffset:
sector->flooryoffset = luaL_checkfixed(L, 3); sector->flooryoffset = luaL_checkfixed(L, 3);
break; break;
case sector_floorxscale:
sector->floorxscale = luaL_checkfixed(L, 3);
break;
case sector_flooryscale:
sector->flooryscale = luaL_checkfixed(L, 3);
break;
case sector_floorangle: case sector_floorangle:
sector->floorangle = luaL_checkangle(L, 3); sector->floorangle = luaL_checkangle(L, 3);
break; break;
@ -852,6 +903,12 @@ static int sector_set(lua_State *L)
case sector_ceilingyoffset: case sector_ceilingyoffset:
sector->ceilingyoffset = luaL_checkfixed(L, 3); sector->ceilingyoffset = luaL_checkfixed(L, 3);
break; break;
case sector_ceilingxscale:
sector->ceilingxscale = luaL_checkfixed(L, 3);
break;
case sector_ceilingyscale:
sector->ceilingyscale = luaL_checkfixed(L, 3);
break;
case sector_ceilingangle: case sector_ceilingangle:
sector->ceilingangle = luaL_checkangle(L, 3); sector->ceilingangle = luaL_checkangle(L, 3);
break; break;
@ -1043,17 +1100,7 @@ static int line_get(lua_State *L)
lua_pushinteger(L, line->special); lua_pushinteger(L, line->special);
return 1; return 1;
case line_tag: case line_tag:
// HELLO // TODO: 2.3: Always return a unsigned value
// THIS IS LJ SONIC
// HOW IS YOUR DAY?
// BY THE WAY WHEN 2.3 OR 3.0 OR 4.0 OR SRB3 OR SRB4 OR WHATEVER IS OUT
// YOU SHOULD REMEMBER TO CHANGE THIS SO IT ALWAYS RETURNS A UNSIGNED VALUE
// HAVE A NICE DAY
//
//
//
//
// you are ugly
lua_pushinteger(L, Tag_FGet(&line->tags)); lua_pushinteger(L, Tag_FGet(&line->tags));
return 1; return 1;
case line_taglist: case line_taglist:
@ -1072,7 +1119,7 @@ static int line_get(lua_State *L)
LUA_PushUserdata(L, &sides[line->sidenum[0]], META_SIDE); LUA_PushUserdata(L, &sides[line->sidenum[0]], META_SIDE);
return 1; return 1;
case line_backside: // backside case line_backside: // backside
if (line->sidenum[1] == 0xffff) if (line->sidenum[1] == NO_SIDEDEF)
return 0; return 0;
LUA_PushUserdata(L, &sides[line->sidenum[1]], META_SIDE); LUA_PushUserdata(L, &sides[line->sidenum[1]], META_SIDE);
return 1; return 1;
@ -1108,6 +1155,7 @@ static int line_get(lua_State *L)
case line_polyobj: case line_polyobj:
LUA_PushUserdata(L, line->polyobj, META_POLYOBJ); LUA_PushUserdata(L, line->polyobj, META_POLYOBJ);
return 1; return 1;
// TODO: 2.3: Delete
case line_text: case line_text:
{ {
if (udmf) if (udmf)
@ -1214,11 +1262,31 @@ static int side_get(lua_State *L)
case side_offsety_mid: case side_offsety_mid:
lua_pushfixed(L, side->offsety_mid); lua_pushfixed(L, side->offsety_mid);
return 1; return 1;
case side_offsetx_bottom:
case side_offsetx_bot: case side_offsetx_bot:
lua_pushfixed(L, side->offsetx_bot); lua_pushfixed(L, side->offsetx_bottom);
return 1; return 1;
case side_offsety_bottom:
case side_offsety_bot: case side_offsety_bot:
lua_pushfixed(L, side->offsety_bot); lua_pushfixed(L, side->offsety_bottom);
return 1;
case side_scalex_top:
lua_pushfixed(L, side->scalex_top);
return 1;
case side_scaley_top:
lua_pushfixed(L, side->scaley_top);
return 1;
case side_scalex_mid:
lua_pushfixed(L, side->scalex_mid);
return 1;
case side_scaley_mid:
lua_pushfixed(L, side->scaley_mid);
return 1;
case side_scalex_bottom:
lua_pushfixed(L, side->scalex_bottom);
return 1;
case side_scaley_bottom:
lua_pushfixed(L, side->scaley_bottom);
return 1; return 1;
case side_toptexture: case side_toptexture:
lua_pushinteger(L, side->toptexture); lua_pushinteger(L, side->toptexture);
@ -1241,8 +1309,12 @@ static int side_get(lua_State *L)
case side_repeatcnt: case side_repeatcnt:
lua_pushinteger(L, side->repeatcnt); lua_pushinteger(L, side->repeatcnt);
return 1; return 1;
// TODO: 2.3: Delete
case side_text: case side_text:
{ {
boolean isfrontside;
size_t sidei = side-sides;
if (udmf) if (udmf)
{ {
LUA_Deprecated(L, "(sidedef_t).text", "(sidedef_t).line.stringargs"); LUA_Deprecated(L, "(sidedef_t).text", "(sidedef_t).line.stringargs");
@ -1250,7 +1322,7 @@ static int side_get(lua_State *L)
return 1; return 1;
} }
boolean isfrontside = side->line->sidenum[0] == side-sides; isfrontside = side->line->sidenum[0] == sidei;
lua_pushstring(L, side->line->stringargs[isfrontside ? 0 : 1]); lua_pushstring(L, side->line->stringargs[isfrontside ? 0 : 1]);
return 1; return 1;
@ -1302,10 +1374,30 @@ static int side_set(lua_State *L)
side->offsety_mid = luaL_checkfixed(L, 3); side->offsety_mid = luaL_checkfixed(L, 3);
break; break;
case side_offsetx_bot: case side_offsetx_bot:
side->offsetx_bot = luaL_checkfixed(L, 3); case side_offsetx_bottom:
side->offsetx_bottom = luaL_checkfixed(L, 3);
break; break;
case side_offsety_bot: case side_offsety_bot:
side->offsety_bot = luaL_checkfixed(L, 3); case side_offsety_bottom:
side->offsety_bottom = luaL_checkfixed(L, 3);
break;
case side_scalex_top:
side->scalex_top = luaL_checkfixed(L, 3);
break;
case side_scaley_top:
side->scaley_top = luaL_checkfixed(L, 3);
break;
case side_scalex_mid:
side->scalex_mid = luaL_checkfixed(L, 3);
break;
case side_scaley_mid:
side->scaley_mid = luaL_checkfixed(L, 3);
break;
case side_scalex_bottom:
side->scalex_bottom = luaL_checkfixed(L, 3);
break;
case side_scaley_bottom:
side->scaley_bottom = luaL_checkfixed(L, 3);
break; break;
case side_toptexture: case side_toptexture:
side->toptexture = luaL_checkinteger(L, 3); side->toptexture = luaL_checkinteger(L, 3);
@ -2122,6 +2214,18 @@ static int ffloor_get(lua_State *L)
case ffloor_toplightlevel: case ffloor_toplightlevel:
lua_pushinteger(L, *ffloor->toplightlevel); lua_pushinteger(L, *ffloor->toplightlevel);
return 1; return 1;
case ffloor_topxoffs:
lua_pushfixed(L, *ffloor->topxoffs);
return 1;
case ffloor_topyoffs:
lua_pushfixed(L, *ffloor->topyoffs);
return 1;
case ffloor_topxscale:
lua_pushfixed(L, *ffloor->topxscale);
return 1;
case ffloor_topyscale:
lua_pushfixed(L, *ffloor->topyscale);
return 1;
case ffloor_bottomheight: case ffloor_bottomheight:
lua_pushfixed(L, *ffloor->bottomheight); lua_pushfixed(L, *ffloor->bottomheight);
return 1; return 1;
@ -2133,6 +2237,18 @@ static int ffloor_get(lua_State *L)
lua_pushlstring(L, levelflat->name, i); lua_pushlstring(L, levelflat->name, i);
return 1; return 1;
} }
case ffloor_bottomxoffs:
lua_pushfixed(L, *ffloor->bottomxoffs);
return 1;
case ffloor_bottomyoffs:
lua_pushfixed(L, *ffloor->bottomyoffs);
return 1;
case ffloor_bottomxscale:
lua_pushfixed(L, *ffloor->bottomxscale);
return 1;
case ffloor_bottomyscale:
lua_pushfixed(L, *ffloor->bottomyscale);
return 1;
case ffloor_tslope: case ffloor_tslope:
LUA_PushUserdata(L, *ffloor->t_slope, META_SLOPE); LUA_PushUserdata(L, *ffloor->t_slope, META_SLOPE);
return 1; return 1;
@ -2317,6 +2433,18 @@ static int ffloor_set(lua_State *L)
case ffloor_toplightlevel: case ffloor_toplightlevel:
*ffloor->toplightlevel = (INT16)luaL_checkinteger(L, 3); *ffloor->toplightlevel = (INT16)luaL_checkinteger(L, 3);
break; break;
case ffloor_topxoffs:
*ffloor->topxoffs = luaL_checkfixed(L, 3);
break;
case ffloor_topyoffs:
*ffloor->topyoffs = luaL_checkfixed(L, 3);
break;
case ffloor_topxscale:
*ffloor->topxscale = luaL_checkfixed(L, 3);
break;
case ffloor_topyscale:
*ffloor->topyscale = luaL_checkfixed(L, 3);
break;
case ffloor_bottomheight: { // bottomheight case ffloor_bottomheight: { // bottomheight
boolean flag; boolean flag;
fixed_t lastpos = *ffloor->bottomheight; fixed_t lastpos = *ffloor->bottomheight;
@ -2335,6 +2463,18 @@ static int ffloor_set(lua_State *L)
case ffloor_bottompic: case ffloor_bottompic:
*ffloor->bottompic = P_AddLevelFlatRuntime(luaL_checkstring(L, 3)); *ffloor->bottompic = P_AddLevelFlatRuntime(luaL_checkstring(L, 3));
break; break;
case ffloor_bottomxoffs:
*ffloor->bottomxoffs = luaL_checkfixed(L, 3);
break;
case ffloor_bottomyoffs:
*ffloor->bottomyoffs = luaL_checkfixed(L, 3);
break;
case ffloor_bottomxscale:
*ffloor->bottomxscale = luaL_checkfixed(L, 3);
break;
case ffloor_bottomyscale:
*ffloor->bottomyscale = luaL_checkfixed(L, 3);
break;
case ffloor_fofflags: { case ffloor_fofflags: {
ffloortype_e oldflags = ffloor->fofflags; // store FOF's old flags ffloortype_e oldflags = ffloor->fofflags; // store FOF's old flags
ffloor->fofflags = luaL_checkinteger(L, 3); ffloor->fofflags = luaL_checkinteger(L, 3);
@ -2843,170 +2983,36 @@ static int mapheaderinfo_get(lua_State *L)
int LUA_MapLib(lua_State *L) int LUA_MapLib(lua_State *L)
{ {
luaL_newmetatable(L, META_SECTORLINES); LUA_RegisterUserdataMetatable(L, META_SECTORLINES, sectorlines_get, NULL, sectorlines_num);
lua_pushcfunction(L, sectorlines_get); LUA_RegisterUserdataMetatable(L, META_SECTOR, sector_get, sector_set, sector_num);
lua_setfield(L, -2, "__index"); LUA_RegisterUserdataMetatable(L, META_SUBSECTOR, subsector_get, NULL, subsector_num);
LUA_RegisterUserdataMetatable(L, META_LINE, line_get, NULL, line_num);
lua_pushcfunction(L, sectorlines_num); LUA_RegisterUserdataMetatable(L, META_LINEARGS, lineargs_get, NULL, lineargs_len);
lua_setfield(L, -2, "__len"); LUA_RegisterUserdataMetatable(L, META_LINESTRINGARGS, linestringargs_get, NULL, linestringargs_len);
lua_pop(L, 1); LUA_RegisterUserdataMetatable(L, META_SIDENUM, sidenum_get, NULL, NULL);
LUA_RegisterUserdataMetatable(L, META_SIDE, side_get, side_set, side_num);
luaL_newmetatable(L, META_SECTOR); LUA_RegisterUserdataMetatable(L, META_VERTEX, vertex_get, NULL, vertex_num);
lua_pushcfunction(L, sector_get); LUA_RegisterUserdataMetatable(L, META_FFLOOR, ffloor_get, ffloor_set, NULL);
lua_setfield(L, -2, "__index"); LUA_RegisterUserdataMetatable(L, META_BBOX, bbox_get, NULL, NULL);
LUA_RegisterUserdataMetatable(L, META_SLOPE, slope_get, slope_set, NULL);
lua_pushcfunction(L, sector_set); LUA_RegisterUserdataMetatable(L, META_VECTOR2, vector2_get, NULL, NULL);
lua_setfield(L, -2, "__newindex"); LUA_RegisterUserdataMetatable(L, META_VECTOR3, vector3_get, NULL, NULL);
LUA_RegisterUserdataMetatable(L, META_MAPHEADER, mapheaderinfo_get, NULL, NULL);
lua_pushcfunction(L, sector_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
sector_fields_ref = Lua_CreateFieldTable(L, sector_opt); sector_fields_ref = Lua_CreateFieldTable(L, sector_opt);
luaL_newmetatable(L, META_SUBSECTOR);
lua_pushcfunction(L, subsector_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, subsector_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
subsector_fields_ref = Lua_CreateFieldTable(L, subsector_opt); subsector_fields_ref = Lua_CreateFieldTable(L, subsector_opt);
luaL_newmetatable(L, META_LINE);
lua_pushcfunction(L, line_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, line_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
line_fields_ref = Lua_CreateFieldTable(L, line_opt); line_fields_ref = Lua_CreateFieldTable(L, line_opt);
luaL_newmetatable(L, META_LINEARGS);
lua_pushcfunction(L, lineargs_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lineargs_len);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_LINESTRINGARGS);
lua_pushcfunction(L, linestringargs_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, linestringargs_len);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_SIDENUM);
lua_pushcfunction(L, sidenum_get);
lua_setfield(L, -2, "__index");
lua_pop(L, 1);
luaL_newmetatable(L, META_SIDE);
lua_pushcfunction(L, side_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, side_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, side_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
side_fields_ref = Lua_CreateFieldTable(L, side_opt); side_fields_ref = Lua_CreateFieldTable(L, side_opt);
luaL_newmetatable(L, META_VERTEX);
lua_pushcfunction(L, vertex_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, vertex_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
vertex_fields_ref = Lua_CreateFieldTable(L, vertex_opt); vertex_fields_ref = Lua_CreateFieldTable(L, vertex_opt);
luaL_newmetatable(L, META_FFLOOR);
lua_pushcfunction(L, ffloor_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, ffloor_set);
lua_setfield(L, -2, "__newindex");
lua_pop(L, 1);
ffloor_fields_ref = Lua_CreateFieldTable(L, ffloor_opt); ffloor_fields_ref = Lua_CreateFieldTable(L, ffloor_opt);
#ifdef HAVE_LUA_SEGS
luaL_newmetatable(L, META_SEG);
lua_pushcfunction(L, seg_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, seg_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
seg_fields_ref = Lua_CreateFieldTable(L, seg_opt);
luaL_newmetatable(L, META_NODE);
lua_pushcfunction(L, node_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, node_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
node_fields_ref = Lua_CreateFieldTable(L, node_opt);
luaL_newmetatable(L, META_NODEBBOX);
//lua_pushcfunction(L, nodebbox_get);
//lua_setfield(L, -2, "__index");
lua_pushcfunction(L, nodebbox_call);
lua_setfield(L, -2, "__call");
lua_pop(L, 1);
luaL_newmetatable(L, META_NODECHILDREN);
lua_pushcfunction(L, nodechildren_get);
lua_setfield(L, -2, "__index");
lua_pop(L, 1);
#endif
luaL_newmetatable(L, META_BBOX);
lua_pushcfunction(L, bbox_get);
lua_setfield(L, -2, "__index");
lua_pop(L, 1);
luaL_newmetatable(L, META_SLOPE);
lua_pushcfunction(L, slope_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, slope_set);
lua_setfield(L, -2, "__newindex");
lua_pop(L, 1);
slope_fields_ref = Lua_CreateFieldTable(L, slope_opt); slope_fields_ref = Lua_CreateFieldTable(L, slope_opt);
luaL_newmetatable(L, META_VECTOR2);
lua_pushcfunction(L, vector2_get);
lua_setfield(L, -2, "__index");
lua_pop(L, 1);
luaL_newmetatable(L, META_VECTOR3);
lua_pushcfunction(L, vector3_get);
lua_setfield(L, -2, "__index");
lua_pop(L, 1);
luaL_newmetatable(L, META_MAPHEADER);
lua_pushcfunction(L, mapheaderinfo_get);
lua_setfield(L, -2, "__index");
//lua_pushcfunction(L, mapheaderinfo_num);
//lua_setfield(L, -2, "__len");
lua_pop(L, 1);
mapheaderinfo_fields_ref = Lua_CreateFieldTable(L, mapheaderinfo_opt); mapheaderinfo_fields_ref = Lua_CreateFieldTable(L, mapheaderinfo_opt);
LUA_RegisterGlobalUserdata(L, "subsectors", lib_getSubsector, NULL, lib_numsubsectors);
LUA_RegisterGlobalUserdata(L, "sides", lib_getSide, NULL, lib_numsides);
LUA_RegisterGlobalUserdata(L, "vertexes", lib_getVertex, NULL, lib_numvertexes);
LUA_RegisterGlobalUserdata(L, "mapheaderinfo", lib_getMapheaderinfo, NULL, lib_nummapheaders);
LUA_PushTaggableObjectArray(L, "sectors", LUA_PushTaggableObjectArray(L, "sectors",
lib_iterateSectors, lib_iterateSectors,
lib_getSector, lib_getSector,
@ -3015,16 +3021,6 @@ int LUA_MapLib(lua_State *L)
&numsectors, &sectors, &numsectors, &sectors,
sizeof (sector_t), META_SECTOR); sizeof (sector_t), META_SECTOR);
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getSubsector);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_numsubsectors);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "subsectors");
LUA_PushTaggableObjectArray(L, "lines", LUA_PushTaggableObjectArray(L, "lines",
lib_iterateLines, lib_iterateLines,
lib_getLine, lib_getLine,
@ -3033,56 +3029,22 @@ int LUA_MapLib(lua_State *L)
&numlines, &lines, &numlines, &lines,
sizeof (line_t), META_LINE); sizeof (line_t), META_LINE);
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getSide);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_numsides);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "sides");
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getVertex);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_numvertexes);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "vertexes");
#ifdef HAVE_LUA_SEGS #ifdef HAVE_LUA_SEGS
lua_newuserdata(L, 0); LUA_RegisterUserdataMetatable(L, META_SEG, seg_get, NULL, seg_num);
lua_createtable(L, 0, 2); LUA_RegisterUserdataMetatable(L, META_NODE, node_get, NULL, node_num);
lua_pushcfunction(L, lib_getSeg); LUA_RegisterUserdataMetatable(L, META_NODECHILDREN, nodechildren_get, NULL, NULL);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_numsegs); seg_fields_ref = Lua_CreateFieldTable(L, seg_opt);
lua_setfield(L, -2, "__len"); node_fields_ref = Lua_CreateFieldTable(L, node_opt);
lua_setmetatable(L, -2);
lua_setglobal(L, "segs");
lua_newuserdata(L, 0); luaL_newmetatable(L, META_NODEBBOX);
lua_createtable(L, 0, 2); //LUA_SetCFunctionField(L, "__index", nodebbox_get);
lua_pushcfunction(L, lib_getNode); LUA_SetCFunctionField(L, "__call", nodebbox_call);
lua_setfield(L, -2, "__index"); lua_pop(L, 1);
lua_pushcfunction(L, lib_numnodes); LUA_RegisterGlobalUserdata(L, "segs", lib_getSeg, NULL, lib_numsegs);
lua_setfield(L, -2, "__len"); LUA_RegisterGlobalUserdata(L, "nodes", lib_getNode, NULL, lib_numnodes);
lua_setmetatable(L, -2);
lua_setglobal(L, "nodes");
#endif #endif
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getMapheaderinfo);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_nummapheaders);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "mapheaderinfo");
return 0; return 0;
} }

View file

@ -125,6 +125,7 @@ static int lib_fixeddiv(lua_State *L)
return 1; return 1;
} }
// TODO: 2.3: Delete
static int lib_fixedrem(lua_State *L) static int lib_fixedrem(lua_State *L)
{ {
LUA_Deprecated(L, "FixedRem(a, b)", "a % b"); LUA_Deprecated(L, "FixedRem(a, b)", "a % b");

View file

@ -641,10 +641,7 @@ static int mobj_set(lua_State *L)
mo->tics = luaL_checkinteger(L, 3); mo->tics = luaL_checkinteger(L, 3);
break; break;
case mobj_state: // set state by enum case mobj_state: // set state by enum
if (mo->player) P_SetMobjState(mo, luaL_checkinteger(L, 3));
P_SetPlayerMobjState(mo, luaL_checkinteger(L, 3));
else
P_SetMobjState(mo, luaL_checkinteger(L, 3));
break; break;
case mobj_flags: // special handling for MF_NOBLOCKMAP and MF_NOSECTOR case mobj_flags: // special handling for MF_NOBLOCKMAP and MF_NOSECTOR
{ {
@ -1163,43 +1160,12 @@ static int lib_nummapthings(lua_State *L)
int LUA_MobjLib(lua_State *L) int LUA_MobjLib(lua_State *L)
{ {
luaL_newmetatable(L, META_MOBJ); LUA_RegisterUserdataMetatable(L, META_MOBJ, mobj_get, mobj_set, NULL);
lua_pushcfunction(L, mobj_get); LUA_RegisterUserdataMetatable(L, META_THINGARGS, thingargs_get, NULL, thingargs_len);
lua_setfield(L, -2, "__index"); LUA_RegisterUserdataMetatable(L, META_THINGSTRINGARGS, thingstringargs_get, NULL, thingstringargs_len);
LUA_RegisterUserdataMetatable(L, META_MAPTHING, mapthing_get, mapthing_set, mapthing_num);
lua_pushcfunction(L, mobj_set);
lua_setfield(L, -2, "__newindex");
lua_pop(L,1);
mobj_fields_ref = Lua_CreateFieldTable(L, mobj_opt); mobj_fields_ref = Lua_CreateFieldTable(L, mobj_opt);
luaL_newmetatable(L, META_THINGARGS);
lua_pushcfunction(L, thingargs_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, thingargs_len);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_THINGSTRINGARGS);
lua_pushcfunction(L, thingstringargs_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, thingstringargs_len);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_MAPTHING);
lua_pushcfunction(L, mapthing_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, mapthing_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, mapthing_num);
lua_setfield(L, -2, "__len");
lua_pop(L,1);
mapthing_fields_ref = Lua_CreateFieldTable(L, mapthing_opt); mapthing_fields_ref = Lua_CreateFieldTable(L, mapthing_opt);
LUA_PushTaggableObjectArray(L, "mapthings", LUA_PushTaggableObjectArray(L, "mapthings",

View file

@ -223,6 +223,7 @@ enum player_e
player_blocked, player_blocked,
player_jointime, player_jointime,
player_quittime, player_quittime,
player_lastinputtime,
player_ping, player_ping,
#ifdef HWRENDER #ifdef HWRENDER
player_fovadd, player_fovadd,
@ -371,6 +372,7 @@ static const char *const player_opt[] = {
"blocked", "blocked",
"jointime", "jointime",
"quittime", "quittime",
"lastinputtime",
"ping", "ping",
#ifdef HWRENDER #ifdef HWRENDER
"fovadd", "fovadd",
@ -407,7 +409,7 @@ static int player_get(lua_State *L)
case player_realmo: case player_realmo:
LUA_PushUserdata(L, plr->mo, META_MOBJ); LUA_PushUserdata(L, plr->mo, META_MOBJ);
break; break;
// Kept for backward-compatibility // TODO: 2.3: Kept for backward-compatibility
// Should be fixed to work like "realmo" later // Should be fixed to work like "realmo" later
case player_mo: case player_mo:
if (plr->spectator) if (plr->spectator)
@ -826,6 +828,9 @@ static int player_get(lua_State *L)
case player_quittime: case player_quittime:
lua_pushinteger(L, plr->quittime); lua_pushinteger(L, plr->quittime);
break; break;
case player_lastinputtime:
lua_pushinteger(L, plr->lastinputtime);
break;
case player_ping: case player_ping:
lua_pushinteger(L, playerpingtable[plr - players]); lua_pushinteger(L, playerpingtable[plr - players]);
break; break;
@ -1349,6 +1354,9 @@ static int player_set(lua_State *L)
case player_quittime: case player_quittime:
plr->quittime = (tic_t)luaL_checkinteger(L, 3); plr->quittime = (tic_t)luaL_checkinteger(L, 3);
break; break;
case player_lastinputtime:
plr->lastinputtime = (tic_t)luaL_checkinteger(L, 3);
break;
#ifdef HWRENDER #ifdef HWRENDER
case player_fovadd: case player_fovadd:
plr->fovadd = luaL_checkfixed(L, 3); plr->fovadd = luaL_checkfixed(L, 3);
@ -1523,48 +1531,13 @@ static int ticcmd_set(lua_State *L)
int LUA_PlayerLib(lua_State *L) int LUA_PlayerLib(lua_State *L)
{ {
luaL_newmetatable(L, META_PLAYER); LUA_RegisterUserdataMetatable(L, META_PLAYER, player_get, player_set, player_num);
lua_pushcfunction(L, player_get); LUA_RegisterUserdataMetatable(L, META_POWERS, power_get, power_set, power_len);
lua_setfield(L, -2, "__index"); LUA_RegisterUserdataMetatable(L, META_TICCMD, ticcmd_get, ticcmd_set, NULL);
lua_pushcfunction(L, player_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, player_num);
lua_setfield(L, -2, "__len");
lua_pop(L,1);
player_fields_ref = Lua_CreateFieldTable(L, player_opt); player_fields_ref = Lua_CreateFieldTable(L, player_opt);
luaL_newmetatable(L, META_POWERS);
lua_pushcfunction(L, power_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, power_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, power_len);
lua_setfield(L, -2, "__len");
lua_pop(L,1);
luaL_newmetatable(L, META_TICCMD);
lua_pushcfunction(L, ticcmd_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, ticcmd_set);
lua_setfield(L, -2, "__newindex");
lua_pop(L,1);
ticcmd_fields_ref = Lua_CreateFieldTable(L, ticcmd_opt); ticcmd_fields_ref = Lua_CreateFieldTable(L, ticcmd_opt);
lua_newuserdata(L, 0); LUA_RegisterGlobalUserdata(L, "players", lib_getPlayer, NULL, lib_lenPlayer);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getPlayer);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_lenPlayer);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "players");
return 0; return 0;
} }

View file

@ -447,41 +447,10 @@ static int lib_numPolyObjects(lua_State *L)
int LUA_PolyObjLib(lua_State *L) int LUA_PolyObjLib(lua_State *L)
{ {
luaL_newmetatable(L, META_POLYOBJVERTICES); LUA_RegisterUserdataMetatable(L, META_POLYOBJVERTICES, polyobjvertices_get, NULL, polyobjvertices_num);
lua_pushcfunction(L, polyobjvertices_get); LUA_RegisterUserdataMetatable(L, META_POLYOBJLINES, polyobjlines_get, NULL, polyobjlines_num);
lua_setfield(L, -2, "__index"); LUA_RegisterUserdataMetatable(L, META_POLYOBJ, polyobj_get, polyobj_set, polyobj_num);
lua_pushcfunction(L, polyobjvertices_num); LUA_RegisterGlobalUserdata(L, "polyobjects", lib_getPolyObject, NULL, lib_numPolyObjects);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_POLYOBJLINES);
lua_pushcfunction(L, polyobjlines_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, polyobjlines_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_POLYOBJ);
lua_pushcfunction(L, polyobj_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, polyobj_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, polyobj_num);
lua_setfield(L, -2, "__len");
lua_pop(L,1);
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getPolyObject);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_numPolyObjects);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "polyobjects");
return 0; return 0;
} }

View file

@ -58,6 +58,7 @@ static lua_CFunction liblist[] = {
LUA_PolyObjLib, // polyobj_t LUA_PolyObjLib, // polyobj_t
LUA_BlockmapLib, // blockmap stuff LUA_BlockmapLib, // blockmap stuff
LUA_HudLib, // HUD stuff LUA_HudLib, // HUD stuff
LUA_ColorLib, // general color functions
LUA_InputLib, // inputs LUA_InputLib, // inputs
NULL NULL
}; };
@ -415,9 +416,11 @@ int LUA_PushGlobals(lua_State *L, const char *word)
} else if (fastcmp(word, "stagefailed")) { } else if (fastcmp(word, "stagefailed")) {
lua_pushboolean(L, stagefailed); lua_pushboolean(L, stagefailed);
return 1; return 1;
// TODO: 2.3: Deprecated (moved to the input library)
} else if (fastcmp(word, "mouse")) { } else if (fastcmp(word, "mouse")) {
LUA_PushUserdata(L, &mouse, META_MOUSE); LUA_PushUserdata(L, &mouse, META_MOUSE);
return 1; return 1;
// TODO: 2.3: Deprecated (moved to the input library)
} else if (fastcmp(word, "mouse2")) { } else if (fastcmp(word, "mouse2")) {
LUA_PushUserdata(L, &mouse2, META_MOUSE); LUA_PushUserdata(L, &mouse2, META_MOUSE);
return 1; return 1;
@ -576,8 +579,7 @@ static void LUA_ClearState(void)
// lock the global namespace // lock the global namespace
lua_getmetatable(L, LUA_GLOBALSINDEX); lua_getmetatable(L, LUA_GLOBALSINDEX);
lua_pushcfunction(L, setglobals); LUA_SetCFunctionField(L, "__newindex", setglobals);
lua_setfield(L, -2, "__newindex");
lua_newtable(L); lua_newtable(L);
lua_setfield(L, -2, "__metatable"); lua_setfield(L, -2, "__metatable");
lua_pop(L, 1); lua_pop(L, 1);
@ -602,64 +604,114 @@ void LUA_ClearExtVars(void)
INT32 lua_lumploading = 0; INT32 lua_lumploading = 0;
// Load a script from a MYFILE // Load a script from a MYFILE
static inline void LUA_LoadFile(MYFILE *f, char *name, boolean noresults) static inline boolean LUA_LoadFile(MYFILE *f, char *name)
{ {
int errorhandlerindex; int errorhandlerindex;
boolean success;
if (!name) if (!name)
name = wadfiles[f->wad]->filename; name = wadfiles[f->wad]->filename;
CONS_Printf("Loading Lua script from %s\n", name); CONS_Printf("Loading Lua script from %s\n", name);
if (!gL) // Lua needs to be initialized if (!gL) // Lua needs to be initialized
LUA_ClearState(); LUA_ClearState();
lua_pushinteger(gL, f->wad); lua_pushinteger(gL, f->wad);
lua_setfield(gL, LUA_REGISTRYINDEX, "WAD"); lua_setfield(gL, LUA_REGISTRYINDEX, "WAD");
lua_pushcfunction(gL, LUA_GetErrorMessage);
errorhandlerindex = lua_gettop(gL);
success = !luaL_loadbuffer(gL, f->data, f->size, va("@%s",name));
if (!success) {
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL,-1));
lua_pop(gL,1);
}
lua_gc(gL, LUA_GCCOLLECT, 0);
lua_remove(gL, errorhandlerindex);
return success;
}
// Runs a script loaded by LUA_LoadFile.
static inline void LUA_DoFile(boolean noresults)
{
int errorhandlerindex;
if (!gL) // LUA_LoadFile should've allocated gL for us!
return;
lua_lumploading++; // turn on loading flag lua_lumploading++; // turn on loading flag
lua_pushcfunction(gL, LUA_GetErrorMessage); lua_pushcfunction(gL, LUA_GetErrorMessage);
errorhandlerindex = lua_gettop(gL); lua_insert(gL, -2); // move the function we're calling to the top.
if (luaL_loadbuffer(gL, f->data, f->size, va("@%s",name)) || lua_pcall(gL, 0, noresults ? 0 : LUA_MULTRET, lua_gettop(gL) - 1)) { errorhandlerindex = lua_gettop(gL) - 1;
if (lua_pcall(gL, 0, noresults ? 0 : LUA_MULTRET, lua_gettop(gL) - 1)) {
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL,-1)); CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL,-1));
lua_pop(gL,1); lua_pop(gL,1);
} }
lua_gc(gL, LUA_GCCOLLECT, 0); lua_gc(gL, LUA_GCCOLLECT, 0);
lua_remove(gL, errorhandlerindex); lua_remove(gL, errorhandlerindex);
lua_lumploading--; // turn off again lua_lumploading--; // turn off again
} }
// Load a script from a lump static inline MYFILE *LUA_GetFile(UINT16 wad, UINT16 lump, char **name)
void LUA_LoadLump(UINT16 wad, UINT16 lump, boolean noresults)
{ {
MYFILE f; MYFILE *f = Z_Malloc(sizeof(MYFILE), PU_LUA, NULL);
char *name;
size_t len; size_t len;
f.wad = wad;
f.size = W_LumpLengthPwad(wad, lump); f->wad = wad;
f.data = Z_Malloc(f.size, PU_LUA, NULL); f->size = W_LumpLengthPwad(wad, lump);
W_ReadLumpPwad(wad, lump, f.data); f->data = Z_Malloc(f->size, PU_LUA, NULL);
f.curpos = f.data; W_ReadLumpPwad(wad, lump, f->data);
f->curpos = f->data;
len = strlen(wadfiles[wad]->filename); // length of file name len = strlen(wadfiles[wad]->filename); // length of file name
if (wadfiles[wad]->type == RET_LUA) if (wadfiles[wad]->type == RET_LUA)
{ {
name = malloc(len+1); *name = malloc(len+1);
strcpy(name, wadfiles[wad]->filename); strcpy(*name, wadfiles[wad]->filename);
} }
else // If it's not a .lua file, copy the lump name in too. else // If it's not a .lua file, copy the lump name in too.
{ {
lumpinfo_t *lump_p = &wadfiles[wad]->lumpinfo[lump]; lumpinfo_t *lump_p = &wadfiles[wad]->lumpinfo[lump];
len += 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name len += 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name
name = malloc(len+1); *name = malloc(len+1);
sprintf(name, "%s|%s", wadfiles[wad]->filename, lump_p->fullname); sprintf(*name, "%s|%s", wadfiles[wad]->filename, lump_p->fullname);
name[len] = '\0'; (*name)[len] = '\0'; // annoying that index takes priority over dereference, but w/e
} }
LUA_LoadFile(&f, name, noresults); // actually load file! return f;
}
// Load a script from a lump
boolean LUA_LoadLump(UINT16 wad, UINT16 lump)
{
char *name = NULL;
MYFILE *f = LUA_GetFile(wad, lump, &name);
boolean success = LUA_LoadFile(f, name); // actually load file!
free(name); free(name);
Z_Free(f.data);
Z_Free(f->data);
Z_Free(f);
return success;
}
void LUA_DoLump(UINT16 wad, UINT16 lump, boolean noresults)
{
boolean success = LUA_LoadLump(wad, lump);
if (success)
LUA_DoFile(noresults); // run it
} }
#ifdef LUA_ALLOW_BYTECODE #ifdef LUA_ALLOW_BYTECODE
@ -1813,20 +1865,107 @@ void LUA_PushTaggableObjectArray
lua_newuserdata(L, 0); lua_newuserdata(L, 0);
lua_createtable(L, 0, 2); lua_createtable(L, 0, 2);
lua_createtable(L, 0, 2); lua_createtable(L, 0, 2);
lua_pushcfunction(L, iterator); LUA_SetCFunctionField(L, "iterate", iterator);
lua_setfield(L, -2, "iterate");
LUA_InsertTaggroupIterator(L, garray, LUA_InsertTaggroupIterator(L, garray,
max_elements, element_array, sizeof_element, meta); max_elements, element_array, sizeof_element, meta);
lua_createtable(L, 0, 1); lua_createtable(L, 0, 1);
lua_pushcfunction(L, indexer); LUA_SetCFunctionField(L, "__index", indexer);
lua_setfield(L, -2, "__index");
lua_setmetatable(L, -2); lua_setmetatable(L, -2);
lua_setfield(L, -2, "__index"); lua_setfield(L, -2, "__index");
lua_pushcfunction(L, counter); LUA_SetCFunctionField(L, "__len", counter);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2); lua_setmetatable(L, -2);
lua_setglobal(L, field); lua_setglobal(L, field);
} }
static void SetBasicMetamethods(
lua_State *L,
lua_CFunction get,
lua_CFunction set,
lua_CFunction len
)
{
if (get)
LUA_SetCFunctionField(L, "__index", get);
if (set)
LUA_SetCFunctionField(L, "__newindex", set);
if (len)
LUA_SetCFunctionField(L, "__len", len);
}
void LUA_SetCFunctionField(lua_State *L, const char *name, lua_CFunction value)
{
lua_pushcfunction(L, value);
lua_setfield(L, -2, name);
}
void LUA_RegisterUserdataMetatable(
lua_State *L,
const char *name,
lua_CFunction get,
lua_CFunction set,
lua_CFunction len
)
{
luaL_newmetatable(L, name);
SetBasicMetamethods(L, get, set, len);
lua_pop(L, 1);
}
// If keep is true, leaves the metatable on the stack.
// Otherwise, the stack size remains unchanged.
void LUA_CreateAndSetMetatable(
lua_State *L,
lua_CFunction get,
lua_CFunction set,
lua_CFunction len,
boolean keep
)
{
lua_newtable(L);
SetBasicMetamethods(L, get, set, len);
lua_pushvalue(L, -1);
lua_setmetatable(L, -3);
if (!keep)
lua_pop(L, 1);
}
// If keep is true, leaves the userdata and metatable on the stack.
// Otherwise, the stack size remains unchanged.
void LUA_CreateAndSetUserdataField(
lua_State *L,
int index,
const char *name,
lua_CFunction get,
lua_CFunction set,
lua_CFunction len,
boolean keep
)
{
if (index < 0 && index > LUA_REGISTRYINDEX)
index -= 3;
lua_newuserdata(L, 0);
LUA_CreateAndSetMetatable(L, get, set, len, true);
lua_pushvalue(L, -2);
lua_setfield(L, index, name);
if (!keep)
lua_pop(L, 2);
}
void LUA_RegisterGlobalUserdata(
lua_State *L,
const char *name,
lua_CFunction get,
lua_CFunction set,
lua_CFunction len
)
{
LUA_CreateAndSetUserdataField(L, LUA_GLOBALSINDEX, name, get, set, len, false);
}

View file

@ -45,7 +45,8 @@ extern INT32 lua_lumploading; // is LUA_LoadLump being called?
int LUA_GetErrorMessage(lua_State *L); int LUA_GetErrorMessage(lua_State *L);
int LUA_Call(lua_State *L, int nargs, int nresults, int errorhandlerindex); int LUA_Call(lua_State *L, int nargs, int nresults, int errorhandlerindex);
void LUA_LoadLump(UINT16 wad, UINT16 lump, boolean noresults); boolean LUA_LoadLump(UINT16 wad, UINT16 lump);
void LUA_DoLump(UINT16 wad, UINT16 lump, boolean noresults);
#ifdef LUA_ALLOW_BYTECODE #ifdef LUA_ALLOW_BYTECODE
void LUA_DumpFile(const char *filename); void LUA_DumpFile(const char *filename);
#endif #endif
@ -73,6 +74,42 @@ void LUA_PushTaggableObjectArray
size_t sizeof_element, size_t sizeof_element,
const char *meta); const char *meta);
void LUA_SetCFunctionField(lua_State *L, const char *name, lua_CFunction value);
void LUA_RegisterUserdataMetatable(
lua_State *L,
const char *name,
lua_CFunction get,
lua_CFunction set,
lua_CFunction len
);
void LUA_CreateAndSetMetatable(
lua_State *L,
lua_CFunction get,
lua_CFunction set,
lua_CFunction len,
boolean keep
);
void LUA_CreateAndSetUserdataField(
lua_State *L,
int index,
const char *name,
lua_CFunction get,
lua_CFunction set,
lua_CFunction len,
boolean keep
);
void LUA_RegisterGlobalUserdata(
lua_State *L,
const char *name,
lua_CFunction get,
lua_CFunction set,
lua_CFunction len
);
void LUA_InsertTaggroupIterator void LUA_InsertTaggroupIterator
( lua_State *L, ( lua_State *L,
taggroup_t *garray[], taggroup_t *garray[],

View file

@ -373,49 +373,14 @@ static int sprite_get(lua_State *L)
int LUA_SkinLib(lua_State *L) int LUA_SkinLib(lua_State *L)
{ {
luaL_newmetatable(L, META_SKIN); LUA_RegisterUserdataMetatable(L, META_SKIN, skin_get, skin_set, skin_num);
lua_pushcfunction(L, skin_get); LUA_RegisterUserdataMetatable(L, META_SOUNDSID, soundsid_get, NULL, soundsid_num);
lua_setfield(L, -2, "__index"); LUA_RegisterUserdataMetatable(L, META_SKINSPRITES, lib_getSkinSprite, NULL, lib_numSkinsSprites);
LUA_RegisterUserdataMetatable(L, META_SKINSPRITESLIST, sprite_get, NULL, NULL);
lua_pushcfunction(L, skin_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, skin_num);
lua_setfield(L, -2, "__len");
lua_pop(L,1);
skin_fields_ref = Lua_CreateFieldTable(L, skin_opt); skin_fields_ref = Lua_CreateFieldTable(L, skin_opt);
luaL_newmetatable(L, META_SOUNDSID); LUA_RegisterGlobalUserdata(L, "skins", lib_getSkin, NULL, lib_numSkins);
lua_pushcfunction(L, soundsid_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, soundsid_num);
lua_setfield(L, -2, "__len");
lua_pop(L,1);
luaL_newmetatable(L, META_SKINSPRITES);
lua_pushcfunction(L, lib_getSkinSprite);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_numSkinsSprites);
lua_setfield(L, -2, "__len");
lua_pop(L,1);
luaL_newmetatable(L, META_SKINSPRITESLIST);
lua_pushcfunction(L, sprite_get);
lua_setfield(L, -2, "__index");
lua_pop(L,1);
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getSkin);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_numSkins);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "skins");
return 0; return 0;
} }

View file

@ -228,7 +228,7 @@ static int taglist_get(lua_State *L)
} }
else else
{ {
lua_getmetatable(L, 1); lua_getglobal(L, "taglist");
lua_replace(L, 1); lua_replace(L, 1);
lua_rawget(L, 1); lua_rawget(L, 1);
return 1; return 1;
@ -372,8 +372,7 @@ void LUA_InsertTaggroupIterator
lua_pushcclosure(L, lib_numTaggroupElements, 2); lua_pushcclosure(L, lib_numTaggroupElements, 2);
lua_setfield(L, -2, "__len"); lua_setfield(L, -2, "__len");
lua_pushcfunction(L, element_iterator); LUA_SetCFunctionField(L, "__call", element_iterator);
lua_setfield(L, -2, "__call");
lua_pushcclosure(L, lib_getTaggroup, 1); lua_pushcclosure(L, lib_getTaggroup, 1);
lua_setfield(L, -2, "tagged"); lua_setfield(L, -2, "tagged");
} }
@ -414,11 +413,9 @@ set_taglist_metatable(lua_State *L, const char *meta)
lua_setfenv(L, -2); lua_setfenv(L, -2);
lua_setfield(L, -2, "__index"); lua_setfield(L, -2, "__index");
lua_pushcfunction(L, taglist_len); LUA_SetCFunctionField(L, "__len", taglist_len);
lua_setfield(L, -2, "__len");
lua_pushcfunction(L, taglist_equal); LUA_SetCFunctionField(L, "__eq", taglist_equal);
lua_setfield(L, -2, "__eq");
#ifdef MUTABLE_TAGS #ifdef MUTABLE_TAGS
return luaL_ref(L, LUA_REGISTRYINDEX); return luaL_ref(L, LUA_REGISTRYINDEX);
#endif #endif
@ -426,17 +423,11 @@ set_taglist_metatable(lua_State *L, const char *meta)
int LUA_TagLib(lua_State *L) int LUA_TagLib(lua_State *L)
{ {
lua_newuserdata(L, 0); LUA_CreateAndSetUserdataField(L, LUA_GLOBALSINDEX, "tags", NULL, NULL, lib_numTags, true);
lua_createtable(L, 0, 2); lua_createtable(L, 0, 1);
lua_createtable(L, 0, 1); LUA_SetCFunctionField(L, "iterate", lib_iterateTags);
lua_pushcfunction(L, lib_iterateTags); lua_setfield(L, -2, "__index");
lua_setfield(L, -2, "iterate"); lua_pop(L, 2);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_numTags);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "tags");
open_taglist(L); open_taglist(L);

View file

@ -127,8 +127,7 @@ static int lib_startIterate(lua_State *L)
int LUA_ThinkerLib(lua_State *L) int LUA_ThinkerLib(lua_State *L)
{ {
luaL_newmetatable(L, META_ITERATIONSTATE); luaL_newmetatable(L, META_ITERATIONSTATE);
lua_pushcfunction(L, iterationState_gc); LUA_SetCFunctionField(L, "__gc", iterationState_gc);
lua_setfield(L, -2, "__gc");
lua_pop(L, 1); lua_pop(L, 1);
lua_createtable(L, 0, 1); lua_createtable(L, 0, 1);

View file

@ -1019,7 +1019,7 @@ static void OP_CycleThings(INT32 amt)
if (players[0].mo->eflags & MFE_VERTICALFLIP) // correct z when flipped if (players[0].mo->eflags & MFE_VERTICALFLIP) // correct z when flipped
players[0].mo->z += players[0].mo->height - FixedMul(mobjinfo[op_currentthing].height, players[0].mo->scale); players[0].mo->z += players[0].mo->height - FixedMul(mobjinfo[op_currentthing].height, players[0].mo->scale);
players[0].mo->height = FixedMul(mobjinfo[op_currentthing].height, players[0].mo->scale); players[0].mo->height = FixedMul(mobjinfo[op_currentthing].height, players[0].mo->scale);
P_SetPlayerMobjState(players[0].mo, S_OBJPLACE_DUMMY); P_SetMobjState(players[0].mo, S_OBJPLACE_DUMMY);
op_currentdoomednum = mobjinfo[op_currentthing].doomednum; op_currentdoomednum = mobjinfo[op_currentthing].doomednum;
} }
@ -1528,7 +1528,7 @@ void Command_ObjectPlace_f(void)
else else
OP_CycleThings(0); // sets all necessary height values without cycling op_currentthing OP_CycleThings(0); // sets all necessary height values without cycling op_currentthing
P_SetPlayerMobjState(players[0].mo, S_OBJPLACE_DUMMY); P_SetMobjState(players[0].mo, S_OBJPLACE_DUMMY);
} }
// Or are we leaving it instead? // Or are we leaving it instead?
else else
@ -1542,7 +1542,7 @@ void Command_ObjectPlace_f(void)
// If still in dummy state, get out of it. // If still in dummy state, get out of it.
if (players[0].mo->state == &states[S_OBJPLACE_DUMMY]) if (players[0].mo->state == &states[S_OBJPLACE_DUMMY])
P_SetPlayerMobjState(players[0].mo, op_oldstate); P_SetMobjState(players[0].mo, op_oldstate);
// Reset everything back to how it was before we entered objectplace. // Reset everything back to how it was before we entered objectplace.
P_UnsetThingPosition(players[0].mo); P_UnsetThingPosition(players[0].mo);

View file

@ -34,6 +34,7 @@
*/ */
typedef INT32 fixed_t; typedef INT32 fixed_t;
typedef UINT32 ufixed_t;
/*! /*!
\brief convert fixed_t into floating number \brief convert fixed_t into floating number
@ -106,7 +107,7 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedInt(fixed_t a)
*/ */
FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedDiv(fixed_t a, fixed_t b) FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedDiv(fixed_t a, fixed_t b)
{ {
if ((abs(a) >> (FRACBITS-2)) >= abs(b)) if (((ufixed_t)abs(a) >> (FRACBITS-2)) >= (ufixed_t)abs(b))
return (a^b) < 0 ? INT32_MIN : INT32_MAX; return (a^b) < 0 ? INT32_MIN : INT32_MAX;
return FixedDiv2(a, b); return FixedDiv2(a, b);

View file

@ -1068,6 +1068,7 @@ static menuitem_t OP_ChangeControlsMenu[] =
{IT_CALL | IT_STRING2, NULL, "Move Right", M_ChangeControl, GC_STRAFERIGHT }, {IT_CALL | IT_STRING2, NULL, "Move Right", M_ChangeControl, GC_STRAFERIGHT },
{IT_CALL | IT_STRING2, NULL, "Jump", M_ChangeControl, GC_JUMP }, {IT_CALL | IT_STRING2, NULL, "Jump", M_ChangeControl, GC_JUMP },
{IT_CALL | IT_STRING2, NULL, "Spin", M_ChangeControl, GC_SPIN }, {IT_CALL | IT_STRING2, NULL, "Spin", M_ChangeControl, GC_SPIN },
{IT_CALL | IT_STRING2, NULL, "Shield", M_ChangeControl, GC_SHIELD },
{IT_HEADER, NULL, "Camera", NULL, 0}, {IT_HEADER, NULL, "Camera", NULL, 0},
{IT_SPACE, NULL, NULL, NULL, 0}, // padding {IT_SPACE, NULL, NULL, NULL, 0}, // padding
{IT_CALL | IT_STRING2, NULL, "Look Up", M_ChangeControl, GC_LOOKUP }, {IT_CALL | IT_STRING2, NULL, "Look Up", M_ChangeControl, GC_LOOKUP },
@ -3176,40 +3177,42 @@ boolean M_Responder(event_t *ev)
} }
else if (menuactive) else if (menuactive)
{ {
if (ev->type == ev_keydown) if (ev->type == ev_keydown || ev->type == ev_text)
{ {
keydown++;
ch = ev->key; ch = ev->key;
if (ev->type == ev_keydown)
// added 5-2-98 remap virtual keys (mouse & joystick buttons)
switch (ch)
{ {
case KEY_MOUSE1: keydown++;
case KEY_JOY1: // added 5-2-98 remap virtual keys (mouse & joystick buttons)
ch = KEY_ENTER; switch (ch)
break; {
case KEY_JOY1 + 3: case KEY_MOUSE1:
ch = 'n'; case KEY_JOY1:
break; ch = KEY_ENTER;
case KEY_MOUSE1 + 1: break;
case KEY_JOY1 + 1: case KEY_JOY1 + 3:
ch = KEY_ESCAPE; ch = 'n';
break; break;
case KEY_JOY1 + 2: case KEY_MOUSE1 + 1:
ch = KEY_BACKSPACE; case KEY_JOY1 + 1:
break; ch = KEY_ESCAPE;
case KEY_HAT1: break;
ch = KEY_UPARROW; case KEY_JOY1 + 2:
break; ch = KEY_BACKSPACE;
case KEY_HAT1 + 1: break;
ch = KEY_DOWNARROW; case KEY_HAT1:
break; ch = KEY_UPARROW;
case KEY_HAT1 + 2: break;
ch = KEY_LEFTARROW; case KEY_HAT1 + 1:
break; ch = KEY_DOWNARROW;
case KEY_HAT1 + 3: break;
ch = KEY_RIGHTARROW; case KEY_HAT1 + 2:
break; ch = KEY_LEFTARROW;
break;
case KEY_HAT1 + 3:
ch = KEY_RIGHTARROW;
break;
}
} }
} }
else if (ev->type == ev_joystick && ev->key == 0 && joywait < I_GetTime()) else if (ev->type == ev_joystick && ev->key == 0 && joywait < I_GetTime())
@ -3371,8 +3374,11 @@ boolean M_Responder(event_t *ev)
// Handle menuitems which need a specific key handling // Handle menuitems which need a specific key handling
if (routine && (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_KEYHANDLER) if (routine && (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_KEYHANDLER)
{ {
if (shiftdown && ch >= 32 && ch <= 127) // ignore ev_keydown events if the key maps to a character, since
ch = shiftxform[ch]; // the ev_text event will follow immediately after in that case.
if (ev->type == ev_keydown && ch >= 32 && ch <= 127)
return true;
routine(ch); routine(ch);
return true; return true;
} }
@ -3414,6 +3420,11 @@ boolean M_Responder(event_t *ev)
{ {
if ((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_STRING) if ((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_STRING)
{ {
// ignore ev_keydown events if the key maps to a character, since
// the ev_text event will follow immediately after in that case.
if (ev->type == ev_keydown && ch >= 32 && ch <= 127)
return false;
if (M_ChangeStringCvar(ch)) if (M_ChangeStringCvar(ch))
return true; return true;
else else
@ -11254,6 +11265,8 @@ static void M_DrawConnectMenu(void)
V_DrawSmallString(currentMenu->x+202, S_LINEY(i)+8, globalflags, "\x85" "Mod"); V_DrawSmallString(currentMenu->x+202, S_LINEY(i)+8, globalflags, "\x85" "Mod");
if (serverlist[slindex].info.cheatsenabled) if (serverlist[slindex].info.cheatsenabled)
V_DrawSmallString(currentMenu->x+222, S_LINEY(i)+8, globalflags, "\x83" "Cheats"); V_DrawSmallString(currentMenu->x+222, S_LINEY(i)+8, globalflags, "\x83" "Cheats");
if (Net_IsNodeIPv6(serverlist[slindex].node))
V_DrawSmallString(currentMenu->x+252, S_LINEY(i)+8, globalflags, "\x84" "IPv6");
V_DrawSmallString(currentMenu->x, S_LINEY(i)+8, globalflags, V_DrawSmallString(currentMenu->x, S_LINEY(i)+8, globalflags,
va("Ping: %u", (UINT32)LONG(serverlist[slindex].info.time))); va("Ping: %u", (UINT32)LONG(serverlist[slindex].info.time)));
@ -11947,7 +11960,7 @@ static void M_HandleConnectIP(INT32 choice)
// Rudimentary number and period enforcing - also allows letters so hostnames can be used instead // Rudimentary number and period enforcing - also allows letters so hostnames can be used instead
// and square brackets for RFC 2732 IPv6 addresses // and square brackets for RFC 2732 IPv6 addresses
if ((choice >= '-' && choice <= ':') || if ((choice >= '-' && choice <= ':') ||
(choice == '[' || choice == ']') || (choice == '[' || choice == ']' || choice == '%') ||
(choice >= 'A' && choice <= 'Z') || (choice >= 'A' && choice <= 'Z') ||
(choice >= 'a' && choice <= 'z')) (choice >= 'a' && choice <= 'z'))
{ {
@ -13167,23 +13180,23 @@ static void M_Setup1PControlsMenu(INT32 choice)
currentMenu->lastOn = itemOn; currentMenu->lastOn = itemOn;
// Unhide the nine non-P2 controls and their headers // Unhide the nine non-P2 controls and their headers
//OP_ChangeControlsMenu[18+0].status = IT_HEADER; //OP_ChangeControlsMenu[19+0].status = IT_HEADER;
//OP_ChangeControlsMenu[18+1].status = IT_SPACE; //OP_ChangeControlsMenu[19+1].status = IT_SPACE;
// ... // ...
OP_ChangeControlsMenu[18+2].status = IT_CALL|IT_STRING2; OP_ChangeControlsMenu[19+2].status = IT_CALL|IT_STRING2;
OP_ChangeControlsMenu[18+3].status = IT_CALL|IT_STRING2; OP_ChangeControlsMenu[19+3].status = IT_CALL|IT_STRING2;
OP_ChangeControlsMenu[18+4].status = IT_CALL|IT_STRING2; OP_ChangeControlsMenu[19+4].status = IT_CALL|IT_STRING2;
OP_ChangeControlsMenu[18+5].status = IT_CALL|IT_STRING2; OP_ChangeControlsMenu[19+5].status = IT_CALL|IT_STRING2;
OP_ChangeControlsMenu[18+6].status = IT_CALL|IT_STRING2; OP_ChangeControlsMenu[19+6].status = IT_CALL|IT_STRING2;
//OP_ChangeControlsMenu[18+7].status = IT_CALL|IT_STRING2; //OP_ChangeControlsMenu[19+7].status = IT_CALL|IT_STRING2;
//OP_ChangeControlsMenu[18+8].status = IT_CALL|IT_STRING2; //OP_ChangeControlsMenu[19+8].status = IT_CALL|IT_STRING2;
OP_ChangeControlsMenu[18+9].status = IT_CALL|IT_STRING2; OP_ChangeControlsMenu[19+9].status = IT_CALL|IT_STRING2;
// ... // ...
OP_ChangeControlsMenu[28+0].status = IT_HEADER; OP_ChangeControlsMenu[29+0].status = IT_HEADER;
OP_ChangeControlsMenu[28+1].status = IT_SPACE; OP_ChangeControlsMenu[29+1].status = IT_SPACE;
// ... // ...
OP_ChangeControlsMenu[28+2].status = IT_CALL|IT_STRING2; OP_ChangeControlsMenu[29+2].status = IT_CALL|IT_STRING2;
OP_ChangeControlsMenu[28+3].status = IT_CALL|IT_STRING2; OP_ChangeControlsMenu[29+3].status = IT_CALL|IT_STRING2;
OP_ChangeControlsDef.prevMenu = &OP_P1ControlsDef; OP_ChangeControlsDef.prevMenu = &OP_P1ControlsDef;
OP_ChangeControlsDef.menuid &= ~(((1 << MENUBITS) - 1) << MENUBITS); // remove second level OP_ChangeControlsDef.menuid &= ~(((1 << MENUBITS) - 1) << MENUBITS); // remove second level
@ -13199,23 +13212,23 @@ static void M_Setup2PControlsMenu(INT32 choice)
currentMenu->lastOn = itemOn; currentMenu->lastOn = itemOn;
// Hide the nine non-P2 controls and their headers // Hide the nine non-P2 controls and their headers
//OP_ChangeControlsMenu[18+0].status = IT_GRAYEDOUT2; //OP_ChangeControlsMenu[19+0].status = IT_GRAYEDOUT2;
//OP_ChangeControlsMenu[18+1].status = IT_GRAYEDOUT2; //OP_ChangeControlsMenu[19+1].status = IT_GRAYEDOUT2;
// ... // ...
OP_ChangeControlsMenu[18+2].status = IT_GRAYEDOUT2; OP_ChangeControlsMenu[19+2].status = IT_GRAYEDOUT2;
OP_ChangeControlsMenu[18+3].status = IT_GRAYEDOUT2; OP_ChangeControlsMenu[19+3].status = IT_GRAYEDOUT2;
OP_ChangeControlsMenu[18+4].status = IT_GRAYEDOUT2; OP_ChangeControlsMenu[19+4].status = IT_GRAYEDOUT2;
OP_ChangeControlsMenu[18+5].status = IT_GRAYEDOUT2; OP_ChangeControlsMenu[19+5].status = IT_GRAYEDOUT2;
OP_ChangeControlsMenu[18+6].status = IT_GRAYEDOUT2; OP_ChangeControlsMenu[19+6].status = IT_GRAYEDOUT2;
//OP_ChangeControlsMenu[18+7].status = IT_GRAYEDOUT2; //OP_ChangeControlsMenu[19+7].status = IT_GRAYEDOUT2;
//OP_ChangeControlsMenu[18+8].status = IT_GRAYEDOUT2; //OP_ChangeControlsMenu[19+8].status = IT_GRAYEDOUT2;
OP_ChangeControlsMenu[18+9].status = IT_GRAYEDOUT2; OP_ChangeControlsMenu[19+9].status = IT_GRAYEDOUT2;
// ... // ...
OP_ChangeControlsMenu[28+0].status = IT_GRAYEDOUT2; OP_ChangeControlsMenu[29+0].status = IT_GRAYEDOUT2;
OP_ChangeControlsMenu[28+1].status = IT_GRAYEDOUT2; OP_ChangeControlsMenu[29+1].status = IT_GRAYEDOUT2;
// ... // ...
OP_ChangeControlsMenu[28+2].status = IT_GRAYEDOUT2; OP_ChangeControlsMenu[29+2].status = IT_GRAYEDOUT2;
OP_ChangeControlsMenu[28+3].status = IT_GRAYEDOUT2; OP_ChangeControlsMenu[29+3].status = IT_GRAYEDOUT2;
OP_ChangeControlsDef.prevMenu = &OP_P2ControlsDef; OP_ChangeControlsDef.prevMenu = &OP_P2ControlsDef;
OP_ChangeControlsDef.menuid &= ~(((1 << MENUBITS) - 1) << MENUBITS); // remove second level OP_ChangeControlsDef.menuid &= ~(((1 << MENUBITS) - 1) << MENUBITS); // remove second level

View file

@ -2207,430 +2207,11 @@ char *sizeu5(size_t num)
return sizeu5_buf; return sizeu5_buf;
} }
#if defined (__GNUC__) && defined (__i386__) // from libkwave, under GPL void *M_Memcpy(void *dest, const void *src, size_t n)
// Alam: note libkwave memcpy code comes from mplayer's libvo/aclib_template.c, r699
/* for small memory blocks (<256 bytes) this version is faster */
#define small_memcpy(dest,src,n)\
{\
register unsigned long int dummy;\
__asm__ __volatile__(\
"cld\n\t"\
"rep; movsb"\
:"=&D"(dest), "=&S"(src), "=&c"(dummy)\
:"0" (dest), "1" (src),"2" (n)\
: "memory", "cc");\
}
/* linux kernel __memcpy (from: /include/asm/string.h) */
ATTRINLINE static FUNCINLINE void *__memcpy (void *dest, const void * src, size_t n)
{ {
int d0, d1, d2;
if ( n < 4 )
{
small_memcpy(dest, src, n);
}
else
{
__asm__ __volatile__ (
"rep ; movsl;"
"testb $2,%b4;"
"je 1f;"
"movsw;"
"1:\ttestb $1,%b4;"
"je 2f;"
"movsb;"
"2:"
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
:"0" (n/4), "q" (n),"1" ((long) dest),"2" ((long) src)
: "memory");
}
return dest;
}
#define SSE_MMREG_SIZE 16
#define MMX_MMREG_SIZE 8
#define MMX1_MIN_LEN 0x800 /* 2K blocks */
#define MIN_LEN 0x40 /* 64-byte blocks */
/* SSE note: i tried to move 128 bytes a time instead of 64 but it
didn't make any measureable difference. i'm using 64 for the sake of
simplicity. [MF] */
static /*FUNCTARGET("sse2")*/ void *sse_cpy(void * dest, const void * src, size_t n)
{
void *retval = dest;
size_t i;
/* PREFETCH has effect even for MOVSB instruction ;) */
__asm__ __volatile__ (
"prefetchnta (%0);"
"prefetchnta 32(%0);"
"prefetchnta 64(%0);"
"prefetchnta 96(%0);"
"prefetchnta 128(%0);"
"prefetchnta 160(%0);"
"prefetchnta 192(%0);"
"prefetchnta 224(%0);"
"prefetchnta 256(%0);"
"prefetchnta 288(%0);"
: : "r" (src) );
if (n >= MIN_LEN)
{
register unsigned long int delta;
/* Align destinition to MMREG_SIZE -boundary */
delta = ((unsigned long int)dest)&(SSE_MMREG_SIZE-1);
if (delta)
{
delta=SSE_MMREG_SIZE-delta;
n -= delta;
small_memcpy(dest, src, delta);
}
i = n >> 6; /* n/64 */
n&=63;
if (((unsigned long)src) & 15)
/* if SRC is misaligned */
for (; i>0; i--)
{
__asm__ __volatile__ (
"prefetchnta 320(%0);"
"prefetchnta 352(%0);"
"movups (%0), %%xmm0;"
"movups 16(%0), %%xmm1;"
"movups 32(%0), %%xmm2;"
"movups 48(%0), %%xmm3;"
"movntps %%xmm0, (%1);"
"movntps %%xmm1, 16(%1);"
"movntps %%xmm2, 32(%1);"
"movntps %%xmm3, 48(%1);"
:: "r" (src), "r" (dest) : "memory");
src = (const unsigned char *)src + 64;
dest = (unsigned char *)dest + 64;
}
else
/*
Only if SRC is aligned on 16-byte boundary.
It allows to use movaps instead of movups, which required data
to be aligned or a general-protection exception (#GP) is generated.
*/
for (; i>0; i--)
{
__asm__ __volatile__ (
"prefetchnta 320(%0);"
"prefetchnta 352(%0);"
"movaps (%0), %%xmm0;"
"movaps 16(%0), %%xmm1;"
"movaps 32(%0), %%xmm2;"
"movaps 48(%0), %%xmm3;"
"movntps %%xmm0, (%1);"
"movntps %%xmm1, 16(%1);"
"movntps %%xmm2, 32(%1);"
"movntps %%xmm3, 48(%1);"
:: "r" (src), "r" (dest) : "memory");
src = ((const unsigned char *)src) + 64;
dest = ((unsigned char *)dest) + 64;
}
/* since movntq is weakly-ordered, a "sfence"
* is needed to become ordered again. */
__asm__ __volatile__ ("sfence":::"memory");
/* enables to use FPU */
__asm__ __volatile__ ("emms":::"memory");
}
/*
* Now do the tail of the block
*/
if (n) __memcpy(dest, src, n);
return retval;
}
static FUNCTARGET("mmx") void *mmx2_cpy(void *dest, const void *src, size_t n)
{
void *retval = dest;
size_t i;
/* PREFETCH has effect even for MOVSB instruction ;) */
__asm__ __volatile__ (
"prefetchnta (%0);"
"prefetchnta 32(%0);"
"prefetchnta 64(%0);"
"prefetchnta 96(%0);"
"prefetchnta 128(%0);"
"prefetchnta 160(%0);"
"prefetchnta 192(%0);"
"prefetchnta 224(%0);"
"prefetchnta 256(%0);"
"prefetchnta 288(%0);"
: : "r" (src));
if (n >= MIN_LEN)
{
register unsigned long int delta;
/* Align destinition to MMREG_SIZE -boundary */
delta = ((unsigned long int)dest)&(MMX_MMREG_SIZE-1);
if (delta)
{
delta=MMX_MMREG_SIZE-delta;
n -= delta;
small_memcpy(dest, src, delta);
}
i = n >> 6; /* n/64 */
n&=63;
for (; i>0; i--)
{
__asm__ __volatile__ (
"prefetchnta 320(%0);"
"prefetchnta 352(%0);"
"movq (%0), %%mm0;"
"movq 8(%0), %%mm1;"
"movq 16(%0), %%mm2;"
"movq 24(%0), %%mm3;"
"movq 32(%0), %%mm4;"
"movq 40(%0), %%mm5;"
"movq 48(%0), %%mm6;"
"movq 56(%0), %%mm7;"
"movntq %%mm0, (%1);"
"movntq %%mm1, 8(%1);"
"movntq %%mm2, 16(%1);"
"movntq %%mm3, 24(%1);"
"movntq %%mm4, 32(%1);"
"movntq %%mm5, 40(%1);"
"movntq %%mm6, 48(%1);"
"movntq %%mm7, 56(%1);"
:: "r" (src), "r" (dest) : "memory");
src = ((const unsigned char *)src) + 64;
dest = ((unsigned char *)dest) + 64;
}
/* since movntq is weakly-ordered, a "sfence"
* is needed to become ordered again. */
__asm__ __volatile__ ("sfence":::"memory");
__asm__ __volatile__ ("emms":::"memory");
}
/*
* Now do the tail of the block
*/
if (n) __memcpy(dest, src, n);
return retval;
}
static FUNCTARGET("mmx") void *mmx1_cpy(void *dest, const void *src, size_t n) //3DNOW
{
void *retval = dest;
size_t i;
/* PREFETCH has effect even for MOVSB instruction ;) */
__asm__ __volatile__ (
"prefetch (%0);"
"prefetch 32(%0);"
"prefetch 64(%0);"
"prefetch 96(%0);"
"prefetch 128(%0);"
"prefetch 160(%0);"
"prefetch 192(%0);"
"prefetch 224(%0);"
"prefetch 256(%0);"
"prefetch 288(%0);"
: : "r" (src));
if (n >= MMX1_MIN_LEN)
{
register unsigned long int delta;
/* Align destinition to MMREG_SIZE -boundary */
delta = ((unsigned long int)dest)&(MMX_MMREG_SIZE-1);
if (delta)
{
delta=MMX_MMREG_SIZE-delta;
n -= delta;
small_memcpy(dest, src, delta);
}
i = n >> 6; /* n/64 */
n&=63;
for (; i>0; i--)
{
__asm__ __volatile__ (
"prefetch 320(%0);"
"prefetch 352(%0);"
"movq (%0), %%mm0;"
"movq 8(%0), %%mm1;"
"movq 16(%0), %%mm2;"
"movq 24(%0), %%mm3;"
"movq 32(%0), %%mm4;"
"movq 40(%0), %%mm5;"
"movq 48(%0), %%mm6;"
"movq 56(%0), %%mm7;"
"movq %%mm0, (%1);"
"movq %%mm1, 8(%1);"
"movq %%mm2, 16(%1);"
"movq %%mm3, 24(%1);"
"movq %%mm4, 32(%1);"
"movq %%mm5, 40(%1);"
"movq %%mm6, 48(%1);"
"movq %%mm7, 56(%1);"
:: "r" (src), "r" (dest) : "memory");
src = ((const unsigned char *)src) + 64;
dest = ((unsigned char *)dest) + 64;
}
__asm__ __volatile__ ("femms":::"memory"); // same as mmx_cpy() but with a femms
}
/*
* Now do the tail of the block
*/
if (n) __memcpy(dest, src, n);
return retval;
}
#endif
// Alam: why? memcpy may be __cdecl/_System and our code may be not the same type
static void *cpu_cpy(void *dest, const void *src, size_t n)
{
if (src == NULL)
{
CONS_Debug(DBG_MEMORY, "Memcpy from 0x0?!: %p %p %s\n", dest, src, sizeu1(n));
return dest;
}
if(dest == NULL)
{
CONS_Debug(DBG_MEMORY, "Memcpy to 0x0?!: %p %p %s\n", dest, src, sizeu1(n));
return dest;
}
return memcpy(dest, src, n); return memcpy(dest, src, n);
} }
static /*FUNCTARGET("mmx")*/ void *mmx_cpy(void *dest, const void *src, size_t n)
{
#if defined (_MSC_VER) && defined (_X86_)
_asm
{
mov ecx, [n]
mov esi, [src]
mov edi, [dest]
shr ecx, 6 // mit mmx: 64bytes per iteration
jz lower_64 // if lower than 64 bytes
loop_64: // MMX transfers multiples of 64bytes
movq mm0, 0[ESI] // read sources
movq mm1, 8[ESI]
movq mm2, 16[ESI]
movq mm3, 24[ESI]
movq mm4, 32[ESI]
movq mm5, 40[ESI]
movq mm6, 48[ESI]
movq mm7, 56[ESI]
movq 0[EDI], mm0 // write destination
movq 8[EDI], mm1
movq 16[EDI], mm2
movq 24[EDI], mm3
movq 32[EDI], mm4
movq 40[EDI], mm5
movq 48[EDI], mm6
movq 56[EDI], mm7
add esi, 64
add edi, 64
dec ecx
jnz loop_64
emms // close mmx operation
lower_64:// transfer rest of buffer
mov ebx,esi
sub ebx,src
mov ecx,[n]
sub ecx,ebx
shr ecx, 3 // multiples of 8 bytes
jz lower_8
loop_8:
movq mm0, [esi] // read source
movq [edi], mm0 // write destination
add esi, 8
add edi, 8
dec ecx
jnz loop_8
emms // close mmx operation
lower_8:
mov ebx,esi
sub ebx,src
mov ecx,[n]
sub ecx,ebx
rep movsb
mov eax, [dest] // return dest
}
#elif defined (__GNUC__) && defined (__i386__)
void *retval = dest;
size_t i;
if (n >= MMX1_MIN_LEN)
{
register unsigned long int delta;
/* Align destinition to MMREG_SIZE -boundary */
delta = ((unsigned long int)dest)&(MMX_MMREG_SIZE-1);
if (delta)
{
delta=MMX_MMREG_SIZE-delta;
n -= delta;
small_memcpy(dest, src, delta);
}
i = n >> 6; /* n/64 */
n&=63;
for (; i>0; i--)
{
__asm__ __volatile__ (
"movq (%0), %%mm0;"
"movq 8(%0), %%mm1;"
"movq 16(%0), %%mm2;"
"movq 24(%0), %%mm3;"
"movq 32(%0), %%mm4;"
"movq 40(%0), %%mm5;"
"movq 48(%0), %%mm6;"
"movq 56(%0), %%mm7;"
"movq %%mm0, (%1);"
"movq %%mm1, 8(%1);"
"movq %%mm2, 16(%1);"
"movq %%mm3, 24(%1);"
"movq %%mm4, 32(%1);"
"movq %%mm5, 40(%1);"
"movq %%mm6, 48(%1);"
"movq %%mm7, 56(%1);"
:: "r" (src), "r" (dest) : "memory");
src = ((const unsigned char *)src) + 64;
dest = ((unsigned char *)dest) + 64;
}
__asm__ __volatile__ ("emms":::"memory");
}
/*
* Now do the tail of the block
*/
if (n) __memcpy(dest, src, n);
return retval;
#else
return cpu_cpy(dest, src, n);
#endif
}
void *(*M_Memcpy)(void* dest, const void* src, size_t n) = cpu_cpy;
/** Memcpy that uses MMX, 3DNow, MMXExt or even SSE
* Do not use on overlapped memory, use memmove for that
*/
void M_SetupMemcpy(void)
{
#if defined (__GNUC__) && defined (__i386__)
if (R_SSE2)
M_Memcpy = sse_cpy;
else if (R_MMXExt)
M_Memcpy = mmx2_cpy;
else if (R_3DNow)
M_Memcpy = mmx1_cpy;
else
#endif
if (R_MMX)
M_Memcpy = mmx_cpy;
#if 0
M_Memcpy = cpu_cpy;
#endif
}
/** Return the appropriate message for a file error or end of file. /** Return the appropriate message for a file error or end of file.
*/ */
const char *M_FileError(FILE *fp) const char *M_FileError(FILE *fp)
@ -2805,3 +2386,17 @@ boolean M_IsStringEmpty(const char *s)
return true; return true;
} }
// Rounds off floating numbers and checks for 0 - 255 bounds
int M_RoundUp(double number)
{
if (number > 255.0l)
return 255;
if (number < 0.0l)
return 0;
if ((int)number <= (int)(number - 0.5f))
return (int)number + 1;
return (int)number;
}

View file

@ -112,6 +112,9 @@ boolean M_IsStringEmpty(const char *s);
// 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);
// Rounds off floating numbers and checks for 0 - 255 bounds
int M_RoundUp(double number);
#include "w_wad.h" #include "w_wad.h"
extern char configfile[MAX_WADPATH]; extern char configfile[MAX_WADPATH];

View file

@ -79,7 +79,7 @@ static void Ban_Clear(void)
void Ban_Load_File(boolean warning) void Ban_Load_File(boolean warning)
{ {
FILE *f; FILE *f;
const char *address, *mask; char *address, *mask;
char buffer[MAX_WADPATH]; char buffer[MAX_WADPATH];
if (!I_ClearBans) if (!I_ClearBans)
@ -100,6 +100,14 @@ void Ban_Load_File(boolean warning)
{ {
address = strtok(buffer, " \t\r\n"); address = strtok(buffer, " \t\r\n");
mask = strtok(NULL, " \t\r\n"); mask = strtok(NULL, " \t\r\n");
if (address[0] == '[')
{
size_t len;
address++;
len = strlen(address);
if (address[len-1] == ']')
address[len-1] = '\0';
}
I_SetBanAddress(address, mask); I_SetBanAddress(address, mask);

View file

@ -90,8 +90,8 @@ INT16 consistancy[BACKUPTICS];
// true when a player is connecting or disconnecting so that the gameplay has stopped in its tracks // true when a player is connecting or disconnecting so that the gameplay has stopped in its tracks
boolean hu_stopped = false; boolean hu_stopped = false;
UINT8 adminpassmd5[16]; UINT8 (*adminpassmd5)[16];
boolean adminpasswordset = false; UINT32 adminpasscount = 0;
tic_t neededtic; tic_t neededtic;
SINT8 servernode = 0; // the number of the server node SINT8 servernode = 0; // the number of the server node
@ -113,6 +113,7 @@ consvar_t cv_blamecfail = CVAR_INIT ("blamecfail", "Off", CV_SAVE|CV_NETVAR, CV_
static CV_PossibleValue_t playbackspeed_cons_t[] = {{1, "MIN"}, {10, "MAX"}, {0, NULL}}; static CV_PossibleValue_t playbackspeed_cons_t[] = {{1, "MIN"}, {10, "MAX"}, {0, NULL}};
consvar_t cv_playbackspeed = CVAR_INIT ("playbackspeed", "1", 0, playbackspeed_cons_t, NULL); consvar_t cv_playbackspeed = CVAR_INIT ("playbackspeed", "1", 0, playbackspeed_cons_t, NULL);
consvar_t cv_idletime = CVAR_INIT ("idletime", "0", CV_SAVE, CV_Unsigned, NULL);
consvar_t cv_dedicatedidletime = CVAR_INIT ("dedicatedidletime", "10", CV_SAVE, CV_Unsigned, NULL); consvar_t cv_dedicatedidletime = CVAR_INIT ("dedicatedidletime", "10", CV_SAVE, CV_Unsigned, NULL);
void ResetNode(INT32 node) void ResetNode(INT32 node)
@ -226,6 +227,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum)
newplayer->jointime = 0; newplayer->jointime = 0;
newplayer->quittime = 0; newplayer->quittime = 0;
newplayer->lastinputtime = 0;
READSTRINGN(*p, player_names[newplayernum], MAXPLAYERNAME); READSTRINGN(*p, player_names[newplayernum], MAXPLAYERNAME);
@ -492,6 +494,10 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum)
HU_AddChatText(va("\x82*%s has been banned (%s)", player_names[pnum], reason), false); HU_AddChatText(va("\x82*%s has been banned (%s)", player_names[pnum], reason), false);
kickreason = KR_BAN; kickreason = KR_BAN;
break; break;
case KICK_MSG_IDLE:
HU_AddChatText(va("\x82*%s has left the game (Inactive for too long)", player_names[pnum]), false);
kickreason = KR_TIMEOUT;
break;
} }
if (pnum == consoleplayer) if (pnum == consoleplayer)
@ -507,6 +513,8 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum)
M_StartMessage(M_GetText("Server closed connection\n(synch failure)\nPress ESC\n"), NULL, MM_NOTHING); M_StartMessage(M_GetText("Server closed connection\n(synch failure)\nPress ESC\n"), NULL, MM_NOTHING);
else if (msg == KICK_MSG_PING_HIGH) else if (msg == KICK_MSG_PING_HIGH)
M_StartMessage(M_GetText("Server closed connection\n(Broke ping limit)\nPress ESC\n"), NULL, MM_NOTHING); M_StartMessage(M_GetText("Server closed connection\n(Broke ping limit)\nPress ESC\n"), NULL, MM_NOTHING);
else if (msg == KICK_MSG_IDLE)
M_StartMessage(M_GetText("Server closed connection\n(Inactive for too long)\nPress ESC\n"), NULL, MM_NOTHING);
else if (msg == KICK_MSG_BANNED) else if (msg == KICK_MSG_BANNED)
M_StartMessage(M_GetText("You have been banned by the server\n\nPress ESC\n"), NULL, MM_NOTHING); M_StartMessage(M_GetText("You have been banned by the server\n\nPress ESC\n"), NULL, MM_NOTHING);
else if (msg == KICK_MSG_CUSTOM_KICK) else if (msg == KICK_MSG_CUSTOM_KICK)
@ -854,26 +862,31 @@ static void PT_Login(SINT8 node, INT32 netconsole)
#ifndef NOMD5 #ifndef NOMD5
UINT8 finalmd5[16];/* Well, it's the cool thing to do? */ UINT8 finalmd5[16];/* Well, it's the cool thing to do? */
UINT32 i;
if (doomcom->datalength < 16)/* ignore partial sends */ if (doomcom->datalength < 16)/* ignore partial sends */
return; return;
if (!adminpasswordset) if (adminpasscount == 0)
{ {
CONS_Printf(M_GetText("Password from %s failed (no password set).\n"), player_names[netconsole]); CONS_Printf(M_GetText("Password from %s failed (no password set).\n"), player_names[netconsole]);
return; return;
} }
// Do the final pass to compare with the sent md5 for (i = 0; i < adminpasscount; i++)
D_MD5PasswordPass(adminpassmd5, 16, va("PNUM%02d", netconsole), &finalmd5);
if (!memcmp(netbuffer->u.md5sum, finalmd5, 16))
{ {
CONS_Printf(M_GetText("%s passed authentication.\n"), player_names[netconsole]); // Do the final pass to compare with the sent md5
COM_BufInsertText(va("promote %d\n", netconsole)); // do this immediately D_MD5PasswordPass(adminpassmd5[i], 16, va("PNUM%02d", netconsole), &finalmd5);
if (!memcmp(netbuffer->u.md5sum, finalmd5, 16))
{
CONS_Printf(M_GetText("%s passed authentication.\n"), player_names[netconsole]);
COM_BufInsertText(va("promote %d\n", netconsole)); // do this immediately
return;
}
} }
else
CONS_Printf(M_GetText("Password from %s failed.\n"), player_names[netconsole]); CONS_Printf(M_GetText("Password from %s failed.\n"), player_names[netconsole]);
#else #else
(void)netconsole; (void)netconsole;
#endif #endif
@ -1267,6 +1280,32 @@ static void UpdatePingTable(void)
} }
} }
static void IdleUpdate(void)
{
INT32 i;
if (!server || !netgame)
return;
for (i = 1; i < MAXPLAYERS; i++)
{
if (cv_idletime.value && playeringame[i] && playernode[i] != UINT8_MAX && !players[i].quittime && !players[i].spectator && !players[i].bot && !IsPlayerAdmin(i) && i != serverplayer)
{
if (players[i].cmd.forwardmove || players[i].cmd.sidemove || players[i].cmd.buttons)
players[i].lastinputtime = 0;
else
players[i].lastinputtime++;
if (players[i].lastinputtime > (tic_t)cv_idletime.value * TICRATE * 60)
{
players[i].lastinputtime = 0;
SendKick(i, KICK_MSG_IDLE | KICK_MSG_KEEP_BODY);
}
}
else
players[i].lastinputtime = 0;
}
}
// Handle timeouts to prevent definitive freezes from happenning // Handle timeouts to prevent definitive freezes from happenning
static void HandleNodeTimeouts(void) static void HandleNodeTimeouts(void)
{ {
@ -1299,6 +1338,8 @@ void NetKeepAlive(void)
GetPackets(); GetPackets();
IdleUpdate();
#ifdef MASTERSERVER #ifdef MASTERSERVER
MasterClient_Ticker(); MasterClient_Ticker();
#endif #endif
@ -1419,6 +1460,8 @@ void NetUpdate(void)
GetPackets(); // get packet from client or from server GetPackets(); // get packet from client or from server
IdleUpdate();
// The client sends the command after receiving from the server // The client sends the command after receiving from the server
// The server sends it before because this is better in single player // The server sends it before because this is better in single player
@ -1580,6 +1623,17 @@ INT32 D_NumPlayers(void)
return num; return num;
} }
/** Returns the number of nodes on the server.
*/
INT32 D_NumNodes(void)
{
INT32 num = 0;
for (INT32 ix = 0; ix < MAXNETNODES; ix++)
if (netnodes[ix].ingame)
num++;
return num;
}
/** Similar to the above, but counts only bots. /** Similar to the above, but counts only bots.
* Purpose is to remove bots from both the player count and the * Purpose is to remove bots from both the player count and the
* max player count on the server view * max player count on the server view

View file

@ -48,7 +48,7 @@ typedef enum
KR_TIMEOUT = 4, //Connection Timeout KR_TIMEOUT = 4, //Connection Timeout
KR_BAN = 5, //Banned by server KR_BAN = 5, //Banned by server
KR_LEAVE = 6, //Quit the game KR_LEAVE = 6, //Quit the game
KR_IDLE = 7, //Remained still for too long
} kickreason_t; } kickreason_t;
/* the max number of name changes in some time period */ /* the max number of name changes in some time period */
@ -73,7 +73,7 @@ extern UINT32 realpingtable[MAXPLAYERS];
extern UINT32 playerpingtable[MAXPLAYERS]; extern UINT32 playerpingtable[MAXPLAYERS];
extern tic_t servermaxping; extern tic_t servermaxping;
extern consvar_t cv_netticbuffer, cv_resynchattempts, cv_blamecfail, cv_playbackspeed, cv_dedicatedidletime; extern consvar_t cv_netticbuffer, cv_resynchattempts, cv_blamecfail, cv_playbackspeed, cv_idletime, cv_dedicatedidletime;
// Used in d_net, the only dependence // Used in d_net, the only dependence
void D_ClientServerInit(void); void D_ClientServerInit(void);
@ -121,14 +121,15 @@ extern char motd[254], server_context[8];
extern UINT8 playernode[MAXPLAYERS]; extern UINT8 playernode[MAXPLAYERS];
INT32 D_NumPlayers(void); INT32 D_NumPlayers(void);
INT32 D_NumNodes(void);
INT32 D_NumBots(void); INT32 D_NumBots(void);
tic_t GetLag(INT32 node); tic_t GetLag(INT32 node);
void D_MD5PasswordPass(const UINT8 *buffer, size_t len, const char *salt, void *dest); void D_MD5PasswordPass(const UINT8 *buffer, size_t len, const char *salt, void *dest);
extern UINT8 adminpassmd5[16]; extern UINT8 (*adminpassmd5)[16];
extern boolean adminpasswordset; extern UINT32 adminpasscount;
extern boolean hu_stopped; extern boolean hu_stopped;

View file

@ -313,9 +313,9 @@ static void RemoveAck(INT32 i)
} }
// 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 int Processackpak(void)
{ {
boolean goodpacket = true; int goodpacket = 0;
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
@ -340,7 +340,7 @@ 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 = 1; // Discard packet (duplicate)
} }
else else
{ {
@ -350,10 +350,10 @@ static boolean Processackpak(void)
{ {
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 = 1; // Discard packet (duplicate)
break; break;
} }
if (goodpacket) if (goodpacket == 0)
{ {
// 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
@ -414,12 +414,13 @@ static boolean Processackpak(void)
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 = 2;
} }
} }
} }
} }
} }
// return values: 0 = ok, 1 = duplicate, 2 = out of order
return goodpacket; return goodpacket;
} }
@ -1069,6 +1070,7 @@ boolean HGetPacket(void)
while(true) while(true)
{ {
//nodejustjoined = I_NetGet(); //nodejustjoined = I_NetGet();
int goodpacket;
I_NetGet(); I_NetGet();
if (doomcom->remotenode == -1) // No packet received if (doomcom->remotenode == -1) // No packet received
@ -1114,8 +1116,15 @@ boolean HGetPacket(void)
}*/ }*/
// Proceed the ack and ackreturn field // Proceed the ack and ackreturn field
if (!Processackpak()) goodpacket = Processackpak();
if (goodpacket != 0)
{
// resend the ACK in case the previous ACK didn't reach the client.
// prevents the client's netbuffer from locking up.
if (goodpacket == 1)
Net_SendAcks(doomcom->remotenode);
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)

View file

@ -70,6 +70,7 @@ boolean HGetPacket(void);
void D_SetDoomcom(void); void D_SetDoomcom(void);
boolean D_CheckNetGame(void); boolean D_CheckNetGame(void);
void D_CloseConnection(void); void D_CloseConnection(void);
boolean Net_IsNodeIPv6(INT32 node);
void Net_UnAcknowledgePacket(INT32 node); void Net_UnAcknowledgePacket(INT32 node);
void Net_CloseConnection(INT32 node); void Net_CloseConnection(INT32 node);
void Net_ConnectionTimeout(INT32 node); void Net_ConnectionTimeout(INT32 node);

View file

@ -153,6 +153,7 @@ static void Command_Clearscores_f(void);
// Remote Administration // Remote Administration
static void Command_Changepassword_f(void); static void Command_Changepassword_f(void);
static void Command_Clearpassword_f(void);
static void Command_Login_f(void); static void Command_Login_f(void);
static void Got_Verification(UINT8 **cp, INT32 playernum); static void Got_Verification(UINT8 **cp, INT32 playernum);
static void Got_Removal(UINT8 **cp, INT32 playernum); static void Got_Removal(UINT8 **cp, INT32 playernum);
@ -470,6 +471,7 @@ void D_RegisterServerCommands(void)
// Remote Administration // Remote Administration
COM_AddCommand("password", Command_Changepassword_f, COM_LUA); COM_AddCommand("password", Command_Changepassword_f, COM_LUA);
COM_AddCommand("clearpassword", Command_Clearpassword_f, COM_LUA);
COM_AddCommand("login", Command_Login_f, COM_LUA); // useful in dedicated to kick off remote admin COM_AddCommand("login", Command_Login_f, COM_LUA); // useful in dedicated to kick off remote admin
COM_AddCommand("promote", Command_Verify_f, COM_LUA); COM_AddCommand("promote", Command_Verify_f, COM_LUA);
RegisterNetXCmd(XD_VERIFIED, Got_Verification); RegisterNetXCmd(XD_VERIFIED, Got_Verification);
@ -603,6 +605,7 @@ void D_RegisterServerCommands(void)
CV_RegisterVar(&cv_showjoinaddress); CV_RegisterVar(&cv_showjoinaddress);
CV_RegisterVar(&cv_blamecfail); CV_RegisterVar(&cv_blamecfail);
CV_RegisterVar(&cv_dedicatedidletime); CV_RegisterVar(&cv_dedicatedidletime);
CV_RegisterVar(&cv_idletime);
COM_AddCommand("ping", Command_Ping_f, COM_LUA); COM_AddCommand("ping", Command_Ping_f, COM_LUA);
CV_RegisterVar(&cv_nettimeout); CV_RegisterVar(&cv_nettimeout);
@ -621,6 +624,10 @@ void D_RegisterServerCommands(void)
CV_RegisterVar(&cv_addons_folder); CV_RegisterVar(&cv_addons_folder);
CV_RegisterVar(&cv_dummyconsvar); CV_RegisterVar(&cv_dummyconsvar);
CV_RegisterVar(&cv_chatspamprotection);
CV_RegisterVar(&cv_chatspamspeed);
CV_RegisterVar(&cv_chatspamburst);
} }
// ========================================================================= // =========================================================================
@ -764,7 +771,6 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_chatheight); CV_RegisterVar(&cv_chatheight);
CV_RegisterVar(&cv_chatwidth); CV_RegisterVar(&cv_chatwidth);
CV_RegisterVar(&cv_chattime); CV_RegisterVar(&cv_chattime);
CV_RegisterVar(&cv_chatspamprotection);
CV_RegisterVar(&cv_chatbacktint); CV_RegisterVar(&cv_chatbacktint);
CV_RegisterVar(&cv_consolechat); CV_RegisterVar(&cv_consolechat);
CV_RegisterVar(&cv_chatnotifications); CV_RegisterVar(&cv_chatnotifications);
@ -2842,8 +2848,15 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum)
void D_SetPassword(const char *pw) void D_SetPassword(const char *pw)
{ {
D_MD5PasswordPass((const UINT8 *)pw, strlen(pw), BASESALT, &adminpassmd5); adminpassmd5 = Z_Realloc(adminpassmd5, sizeof(*adminpassmd5) * ++adminpasscount, PU_STATIC, NULL);
adminpasswordset = true; D_MD5PasswordPass((const UINT8 *)pw, strlen(pw), BASESALT, &adminpassmd5[adminpasscount-1]);
}
void D_ClearPassword(void)
{
Z_Free(adminpassmd5);
adminpassmd5 = NULL;
adminpasscount = 0;
} }
// Remote Administration // Remote Administration
@ -2861,12 +2874,30 @@ static void Command_Changepassword_f(void)
if (COM_Argc() != 2) if (COM_Argc() != 2)
{ {
CONS_Printf(M_GetText("password <password>: change remote admin password\n")); CONS_Printf(M_GetText("password <password>: add remote admin password\n"));
return; return;
} }
D_SetPassword(COM_Argv(1)); D_SetPassword(COM_Argv(1));
CONS_Printf(M_GetText("Password set.\n")); CONS_Printf(M_GetText("Password added.\n"));
#endif
}
// Remote Administration
static void Command_Clearpassword_f(void)
{
#ifdef NOMD5
// If we have no MD5 support then completely disable XD_LOGIN responses for security.
CONS_Alert(CONS_NOTICE, "Remote administration commands are not supported in this build.\n");
#else
if (client) // cannot change remotely
{
CONS_Printf(M_GetText("Only the server can use this.\n"));
return;
}
D_ClearPassword();
CONS_Printf(M_GetText("Passwords cleared.\n"));
#endif #endif
} }

View file

@ -209,6 +209,7 @@ void ClearAdminPlayers(void);
void RemoveAdminPlayer(INT32 playernum); void RemoveAdminPlayer(INT32 playernum);
void ItemFinder_OnChange(void); void ItemFinder_OnChange(void);
void D_SetPassword(const char *pw); void D_SetPassword(const char *pw);
void D_ClearPassword(void);
// used for the player setup menu // used for the player setup menu
UINT8 CanChangeSkin(INT32 playernum); UINT8 CanChangeSkin(INT32 playernum);

View file

@ -35,6 +35,10 @@ Documentation available here.
#define Blame( ... ) \ #define Blame( ... ) \
CONS_Printf("\x85" __VA_ARGS__) CONS_Printf("\x85" __VA_ARGS__)
#define PROTO_ANY 0
#define PROTO_V4 1
#define PROTO_V6 2
static void MasterServer_Debug_OnChange (void); static void MasterServer_Debug_OnChange (void);
consvar_t cv_masterserver_timeout = CVAR_INIT consvar_t cv_masterserver_timeout = CVAR_INIT
@ -59,12 +63,17 @@ consvar_t cv_masterserver_token = CVAR_INIT
static int hms_started; static int hms_started;
static boolean hms_allow_ipv6;
static char *hms_api; static char *hms_api;
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
static I_mutex hms_api_mutex; static I_mutex hms_api_mutex;
#endif #endif
static char *hms_server_token; static char *hms_server_token;
#ifndef NO_IPV6
static char *hms_server_token_ipv6;
#endif
static char hms_useragent[512]; static char hms_useragent[512];
@ -126,7 +135,7 @@ HMS_on_read (char *s, size_t _1, size_t n, void *userdata)
} }
static struct HMS_buffer * static struct HMS_buffer *
HMS_connect (const char *format, ...) HMS_connect (int proto, const char *format, ...)
{ {
va_list ap; va_list ap;
CURL *curl; CURL *curl;
@ -136,8 +145,14 @@ HMS_connect (const char *format, ...)
size_t token_length; size_t token_length;
struct HMS_buffer *buffer; struct HMS_buffer *buffer;
#ifdef NO_IPV6
if (proto == PROTO_V6)
return NULL;
#endif
if (! hms_started) if (! hms_started)
{ {
hms_allow_ipv6 = !M_CheckParm("-noipv6");
if (curl_global_init(CURL_GLOBAL_ALL) != 0) if (curl_global_init(CURL_GLOBAL_ALL) != 0)
{ {
Contact_error(); Contact_error();
@ -219,7 +234,9 @@ HMS_connect (const char *format, ...)
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
#ifndef NO_IPV6 #ifndef NO_IPV6
if (M_CheckParm("-noipv6")) if (proto == PROTO_V6)
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6);
if (proto == PROTO_V4)
#endif #endif
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
@ -309,7 +326,7 @@ HMS_fetch_rooms (int joining, int query_id)
(void)query_id; (void)query_id;
hms = HMS_connect("rooms"); hms = HMS_connect(PROTO_ANY, "rooms");
if (! hms) if (! hms)
return 0; return 0;
@ -409,7 +426,7 @@ HMS_register (void)
char *title; char *title;
hms = HMS_connect("rooms/%d/register", ms_RoomId); hms = HMS_connect(PROTO_V4, "rooms/%d/register", ms_RoomId);
if (! hms) if (! hms)
return 0; return 0;
@ -441,6 +458,27 @@ HMS_register (void)
HMS_end(hms); HMS_end(hms);
#ifndef NO_IPV6
if (!hms_allow_ipv6)
return ok;
hms = HMS_connect(PROTO_V6, "rooms/%d/register", ms_RoomId);
if (! hms)
return 0;
curl_easy_setopt(hms->curl, CURLOPT_POSTFIELDS, post);
ok = HMS_do(hms);
if (ok)
{
hms_server_token_ipv6 = strdup(strtok(hms->buffer, "\n"));
}
HMS_end(hms);
#endif
return ok; return ok;
} }
@ -450,7 +488,7 @@ HMS_unlist (void)
struct HMS_buffer *hms; struct HMS_buffer *hms;
int ok; int ok;
hms = HMS_connect("servers/%s/unlist", hms_server_token); hms = HMS_connect(PROTO_V4, "servers/%s/unlist", hms_server_token);
if (! hms) if (! hms)
return 0; return 0;
@ -462,6 +500,23 @@ HMS_unlist (void)
free(hms_server_token); free(hms_server_token);
#ifndef NO_IPV6
if (hms_server_token_ipv6 && hms_allow_ipv6)
{
hms = HMS_connect(PROTO_V6, "servers/%s/unlist", hms_server_token_ipv6);
if (! hms)
return 0;
curl_easy_setopt(hms->curl, CURLOPT_CUSTOMREQUEST, "POST");
ok = HMS_do(hms);
HMS_end(hms);
free(hms_server_token_ipv6);
}
#endif
return ok; return ok;
} }
@ -475,7 +530,7 @@ HMS_update (void)
char *title; char *title;
hms = HMS_connect("servers/%s/update", hms_server_token); hms = HMS_connect(PROTO_V4, "servers/%s/update", hms_server_token);
if (! hms) if (! hms)
return 0; return 0;
@ -494,6 +549,21 @@ HMS_update (void)
ok = HMS_do(hms); ok = HMS_do(hms);
HMS_end(hms); HMS_end(hms);
#ifndef NO_IPV6
if (hms_server_token_ipv6 && hms_allow_ipv6)
{
hms = HMS_connect(PROTO_V6, "servers/%s/update", hms_server_token_ipv6);
if (! hms)
return ok;
curl_easy_setopt(hms->curl, CURLOPT_POSTFIELDS, post);
ok = HMS_do(hms);
HMS_end(hms);
}
#endif
return ok; return ok;
} }
@ -505,7 +575,7 @@ HMS_list_servers (void)
char *list; char *list;
char *p; char *p;
hms = HMS_connect("servers"); hms = HMS_connect(PROTO_ANY, "servers");
if (! hms) if (! hms)
return; return;
@ -554,10 +624,10 @@ HMS_fetch_servers (msg_server_t *list, int room_number, int query_id)
if (room_number > 0) if (room_number > 0)
{ {
hms = HMS_connect("rooms/%d/servers", room_number); hms = HMS_connect(PROTO_ANY, "rooms/%d/servers", room_number);
} }
else else
hms = HMS_connect("servers"); hms = HMS_connect(PROTO_ANY, "servers");
if (! hms) if (! hms)
return NULL; return NULL;
@ -661,7 +731,7 @@ HMS_compare_mod_version (char *buffer, size_t buffer_size)
char *version; char *version;
char *version_name; char *version_name;
hms = HMS_connect("versions/%d", MODID); hms = HMS_connect(PROTO_ANY, "versions/%d", MODID);
if (! hms) if (! hms)
return 0; return 0;

View file

@ -83,6 +83,10 @@
#undef ETIMEDOUT #undef ETIMEDOUT
#endif #endif
#define ETIMEDOUT WSAETIMEDOUT #define ETIMEDOUT WSAETIMEDOUT
#ifdef EHOSTUNREACH
#undef EHOSTUNREACH
#endif
#define EHOSTUNREACH WSAEHOSTUNREACH
#ifndef IOC_VENDOR #ifndef IOC_VENDOR
#define IOC_VENDOR 0x18000000 #define IOC_VENDOR 0x18000000
#endif #endif
@ -154,6 +158,8 @@ typedef union
#define ERRSOCKET (-1) #define ERRSOCKET (-1)
#endif #endif
#define IPV6_MULTICAST_ADDRESS "ff15::57e1:1a12"
// define socklen_t in DOS/Windows if it is not already defined // define socklen_t in DOS/Windows if it is not already defined
#ifdef USE_WINSOCK1 #ifdef USE_WINSOCK1
typedef int socklen_t; typedef int socklen_t;
@ -402,6 +408,20 @@ static const char *SOCK_GetBanMask(size_t ban)
return NULL; return NULL;
} }
#ifdef HAVE_IPV6
static boolean SOCK_cmpipv6(mysockaddr_t *a, mysockaddr_t *b, UINT8 mask)
{
UINT8 bitmask;
I_Assert(mask <= 128);
if (memcmp(&a->ip6.sin6_addr, &b->ip6.sin6_addr, mask / 8) != 0)
return false;
if (mask % 8 == 0)
return true;
bitmask = 255 << (mask % 8);
return (a->ip6.sin6_addr.s6_addr[mask / 8] & bitmask) == (b->ip6.sin6_addr.s6_addr[mask / 8] & bitmask);
}
#endif
static boolean SOCK_cmpaddr(mysockaddr_t *a, mysockaddr_t *b, UINT8 mask) static boolean SOCK_cmpaddr(mysockaddr_t *a, mysockaddr_t *b, UINT8 mask)
{ {
UINT32 bitmask = INADDR_NONE; UINT32 bitmask = INADDR_NONE;
@ -414,7 +434,7 @@ static boolean SOCK_cmpaddr(mysockaddr_t *a, mysockaddr_t *b, UINT8 mask)
&& (b->ip4.sin_port == 0 || (a->ip4.sin_port == b->ip4.sin_port)); && (b->ip4.sin_port == 0 || (a->ip4.sin_port == b->ip4.sin_port));
#ifdef HAVE_IPV6 #ifdef HAVE_IPV6
else if (b->any.sa_family == AF_INET6) else if (b->any.sa_family == AF_INET6)
return !memcmp(&a->ip6.sin6_addr, &b->ip6.sin6_addr, sizeof(b->ip6.sin6_addr)) return SOCK_cmpipv6(a, b, mask)
&& (b->ip6.sin6_port == 0 || (a->ip6.sin6_port == b->ip6.sin6_port)); && (b->ip6.sin6_port == 0 || (a->ip6.sin6_port == b->ip6.sin6_port));
#endif #endif
else else
@ -621,6 +641,7 @@ static inline ssize_t SOCK_SendToAddr(SOCKET_TYPE socket, mysockaddr_t *sockaddr
socklen_t d6 = (socklen_t)sizeof(struct sockaddr_in6); socklen_t d6 = (socklen_t)sizeof(struct sockaddr_in6);
#endif #endif
socklen_t d, da = (socklen_t)sizeof(mysockaddr_t); socklen_t d, da = (socklen_t)sizeof(mysockaddr_t);
ssize_t status;
switch (sockaddr->any.sa_family) switch (sockaddr->any.sa_family)
{ {
@ -631,7 +652,12 @@ static inline ssize_t SOCK_SendToAddr(SOCKET_TYPE socket, mysockaddr_t *sockaddr
default: d = da; break; default: d = da; break;
} }
return sendto(socket, (char *)&doomcom->data, doomcom->datalength, 0, &sockaddr->any, d); status = sendto(socket, (char *)&doomcom->data, doomcom->datalength, 0, &sockaddr->any, d);
if (status == -1)
{
CONS_Alert(CONS_WARNING, "Unable to send packet to %s: %s\n", SOCK_AddrToStr(sockaddr), strerror(errno));
}
return status;
} }
static void SOCK_Send(void) static void SOCK_Send(void)
@ -670,7 +696,7 @@ static void SOCK_Send(void)
if (c == ERRSOCKET) if (c == ERRSOCKET)
{ {
int e = errno; // save error code so it can't be modified later int e = errno; // save error code so it can't be modified later
if (e != ECONNREFUSED && e != EWOULDBLOCK) if (e != ECONNREFUSED && e != EWOULDBLOCK && e != EHOSTUNREACH)
I_Error("SOCK_Send, error sending to node %d (%s) #%u: %s", doomcom->remotenode, I_Error("SOCK_Send, error sending to node %d (%s) #%u: %s", doomcom->remotenode,
SOCK_GetNodeAddress(doomcom->remotenode), e, strerror(e)); SOCK_GetNodeAddress(doomcom->remotenode), e, strerror(e));
} }
@ -770,6 +796,24 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen
return (SOCKET_TYPE)ERRSOCKET; return (SOCKET_TYPE)ERRSOCKET;
} }
#ifdef HAVE_IPV6
if (family == AF_INET6)
{
// we need to set all of this *after* binding to an address!
if (memcmp(&straddr.ip6.sin6_addr, &in6addr_any, sizeof(in6addr_any)) == 0) //IN6_ARE_ADDR_EQUAL
{
struct ipv6_mreq maddr;
inet_pton(AF_INET6, IPV6_MULTICAST_ADDRESS, &maddr.ipv6mr_multiaddr);
maddr.ipv6mr_interface = 0;
if (setsockopt(s, IPPROTO_IPV6, IPV6_JOIN_GROUP, (const char *)&maddr, sizeof(maddr)) != 0)
{
CONS_Alert(CONS_WARNING, M_GetText("Could not register multicast address\n"));
}
}
}
#endif
#ifdef FIONBIO #ifdef FIONBIO
// make it non blocking // make it non blocking
opt = true; opt = true;
@ -950,65 +994,28 @@ static boolean UDP_Socket(void)
// ip + udp // ip + udp
packetheaderlength = 20 + 8; // for stats packetheaderlength = 20 + 8; // for stats
hints.ai_family = AF_INET; clientaddress[s].any.sa_family = AF_INET;
gaie = I_getaddrinfo("127.0.0.1", "0", &hints, &ai); clientaddress[s].ip4.sin_port = htons(0);
if (gaie == 0) clientaddress[s].ip4.sin_addr.s_addr = htonl(INADDR_LOOPBACK); //GetLocalAddress(); // my own ip
{ s++;
runp = ai;
while (runp != NULL && s < MAXNETNODES+1)
{
memcpy(&clientaddress[s], runp->ai_addr, runp->ai_addrlen);
s++;
runp = runp->ai_next;
}
I_freeaddrinfo(ai);
}
else
{
clientaddress[s].any.sa_family = AF_INET;
clientaddress[s].ip4.sin_port = htons(0);
clientaddress[s].ip4.sin_addr.s_addr = htonl(INADDR_LOOPBACK); //GetLocalAddress(); // my own ip
s++;
}
s = 0; s = 0;
// setup broadcast adress to BROADCASTADDR entry // setup broadcast adress to BROADCASTADDR entry
gaie = I_getaddrinfo("255.255.255.255", "0", &hints, &ai); broadcastaddress[s].any.sa_family = AF_INET;
if (gaie == 0) broadcastaddress[s].ip4.sin_port = htons(atoi(DEFAULTPORT));
{ broadcastaddress[s].ip4.sin_addr.s_addr = htonl(INADDR_BROADCAST);
runp = ai; s++;
while (runp != NULL && s < MAXNETNODES+1)
{
memcpy(&broadcastaddress[s], runp->ai_addr, runp->ai_addrlen);
s++;
runp = runp->ai_next;
}
I_freeaddrinfo(ai);
}
else
{
broadcastaddress[s].any.sa_family = AF_INET;
broadcastaddress[s].ip4.sin_port = htons(0);
broadcastaddress[s].ip4.sin_addr.s_addr = htonl(INADDR_BROADCAST);
s++;
}
#ifdef HAVE_IPV6 #ifdef HAVE_IPV6
if (b_ipv6) if (b_ipv6)
{ {
hints.ai_family = AF_INET6; broadcastaddress[s].any.sa_family = AF_INET6;
gaie = I_getaddrinfo("ff02::1", "0", &hints, &ai); broadcastaddress[s].ip6.sin6_port = htons(atoi(DEFAULTPORT));
if (gaie == 0) broadcastaddress[s].ip6.sin6_flowinfo = 0;
{ inet_pton(AF_INET6, IPV6_MULTICAST_ADDRESS, &broadcastaddress[s].ip6.sin6_addr);
runp = ai; broadcastaddress[s].ip6.sin6_scope_id = 0;
while (runp != NULL && s < MAXNETNODES+1) s++;
{
memcpy(&broadcastaddress[s], runp->ai_addr, runp->ai_addrlen);
s++;
runp = runp->ai_next;
}
I_freeaddrinfo(ai);
}
} }
#endif #endif
@ -1373,4 +1380,13 @@ boolean I_InitTcpNetwork(void)
return ret; return ret;
} }
boolean Net_IsNodeIPv6(INT32 node)
{
#ifdef NO_IPV6
return false;
#else
return clientaddress[node].any.sa_family == AF_INET6;
#endif
}
#include "i_addrinfo.c" #include "i_addrinfo.c"

View file

@ -60,7 +60,7 @@ static CV_PossibleValue_t masterserver_update_rate_cons_t[] = {
{0,NULL} {0,NULL}
}; };
consvar_t cv_masterserver = CVAR_INIT ("masterserver", "https://mb.srb2.org/MS/0", CV_SAVE|CV_CALL, NULL, MasterServer_OnChange); consvar_t cv_masterserver = CVAR_INIT ("masterserver", "https://ds.ms.srb2.org/MS/0", CV_SAVE|CV_CALL, NULL, MasterServer_OnChange);
consvar_t cv_servername = CVAR_INIT ("servername", "SRB2 server", CV_SAVE|CV_NETVAR|CV_CALL|CV_NOINIT|CV_ALLOWLUA, NULL, Update_parameters); consvar_t cv_servername = CVAR_INIT ("servername", "SRB2 server", CV_SAVE|CV_NETVAR|CV_CALL|CV_NOINIT|CV_ALLOWLUA, NULL, Update_parameters);
consvar_t cv_masterserver_update_rate = CVAR_INIT ("masterserver_update_rate", "15", CV_SAVE|CV_CALL|CV_NOINIT, masterserver_update_rate_cons_t, Update_parameters); consvar_t cv_masterserver_update_rate = CVAR_INIT ("masterserver_update_rate", "15", CV_SAVE|CV_CALL|CV_NOINIT, masterserver_update_rate_cons_t, Update_parameters);
@ -539,6 +539,13 @@ static void MasterServer_OnChange(void)
CV_StealthSet(&cv_masterserver, cv_masterserver.defaultvalue); CV_StealthSet(&cv_masterserver, cv_masterserver.defaultvalue);
} }
if (
! cv_masterserver.changed &&
strcmp(cv_masterserver.string, "https://mb.srb2.org/MS/0") == 0
){
CV_StealthSet(&cv_masterserver, cv_masterserver.defaultvalue);
}
Set_api(cv_masterserver.string); Set_api(cv_masterserver.string);
if (Online()) if (Online())

View file

@ -331,6 +331,7 @@ typedef struct
#define KICK_MSG_PING_HIGH 6 #define KICK_MSG_PING_HIGH 6
#define KICK_MSG_CUSTOM_KICK 7 #define KICK_MSG_CUSTOM_KICK 7
#define KICK_MSG_CUSTOM_BAN 8 #define KICK_MSG_CUSTOM_BAN 8
#define KICK_MSG_IDLE 9
#define KICK_MSG_KEEP_BODY 0x80 #define KICK_MSG_KEEP_BODY 0x80
#endif #endif

View file

@ -109,7 +109,7 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime)
netbuffer->u.serverinfo.leveltime = (tic_t)LONG(leveltime); netbuffer->u.serverinfo.leveltime = (tic_t)LONG(leveltime);
// Exclude bots from both counts // Exclude bots from both counts
netbuffer->u.serverinfo.numberofplayer = (UINT8)(D_NumPlayers() - D_NumBots()); netbuffer->u.serverinfo.numberofplayer = (UINT8)(D_NumNodes() - (dedicated ? 1 : 0));
netbuffer->u.serverinfo.maxplayer = (UINT8)(cv_maxplayers.value - D_NumBots()); netbuffer->u.serverinfo.maxplayer = (UINT8)(cv_maxplayers.value - D_NumBots());
netbuffer->u.serverinfo.refusereason = GetRefuseReason(node); netbuffer->u.serverinfo.refusereason = GetRefuseReason(node);
@ -164,7 +164,7 @@ static void SV_SendPlayerInfo(INT32 node)
for (UINT8 i = 0; i < MAXPLAYERS; i++) for (UINT8 i = 0; i < MAXPLAYERS; i++)
{ {
if (!playeringame[i]) if (playernode[i] == UINT8_MAX || !netnodes[playernode[i]].ingame)
{ {
netbuffer->u.playerinfo[i].num = 255; // This slot is empty. netbuffer->u.playerinfo[i].num = 255; // This slot is empty.
continue; continue;

File diff suppressed because it is too large Load diff

View file

@ -1921,6 +1921,9 @@ void EV_CrumbleChain(sector_t *sec, ffloor_t *rover)
for (c = topz; c > bottomz; c -= spacing) for (c = topz; c > bottomz; c -= spacing)
{ {
spawned = P_SpawnMobj(a, b, c, type); spawned = P_SpawnMobj(a, b, c, type);
if (P_MobjWasRemoved(spawned))
continue;
spawned->angle += P_RandomKey(36)*ANG10; // irrelevant for default objects but might make sense for some custom ones spawned->angle += P_RandomKey(36)*ANG10; // irrelevant for default objects but might make sense for some custom ones
if (fromcenter) if (fromcenter)

View file

@ -256,6 +256,9 @@ void P_DoNightsScore(player_t *player)
player->linktimer = nightslinktics; player->linktimer = nightslinktics;
} }
if (P_MobjWasRemoved(dummymo))
return;
// Award 10-100 score, doubled if bonus time is active // Award 10-100 score, doubled if bonus time is active
P_AddPlayerScore(player, min(player->linkcount,10)*(player->bonustime ? 20 : 10)); P_AddPlayerScore(player, min(player->linkcount,10)*(player->bonustime ? 20 : 10));
P_SetMobjState(dummymo, (player->bonustime ? dummymo->info->xdeathstate : dummymo->info->spawnstate) + min(player->linkcount,10)-1); P_SetMobjState(dummymo, (player->bonustime ? dummymo->info->xdeathstate : dummymo->info->spawnstate) + min(player->linkcount,10)-1);
@ -526,7 +529,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
else if (player->pflags & PF_GLIDING && !P_IsObjectOnGround(toucher)) else if (player->pflags & PF_GLIDING && !P_IsObjectOnGround(toucher))
{ {
player->pflags &= ~(PF_GLIDING|PF_JUMPED|PF_NOJUMPDAMAGE); player->pflags &= ~(PF_GLIDING|PF_JUMPED|PF_NOJUMPDAMAGE);
P_SetPlayerMobjState(toucher, S_PLAY_FALL); P_SetMobjState(toucher, S_PLAY_FALL);
toucher->momz += P_MobjFlip(toucher) * (player->speed >> 3); toucher->momz += P_MobjFlip(toucher) * (player->speed >> 3);
toucher->momx = 7*toucher->momx>>3; toucher->momx = 7*toucher->momx>>3;
toucher->momy = 7*toucher->momy>>3; toucher->momy = 7*toucher->momy>>3;
@ -1246,7 +1249,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
P_ResetPlayer(player); P_ResetPlayer(player);
P_SetPlayerMobjState(toucher, S_PLAY_FALL); P_SetMobjState(toucher, S_PLAY_FALL);
} }
} }
return; return;
@ -1301,7 +1304,8 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
{ {
// A flicky orbits us now // A flicky orbits us now
mobj_t *flickyobj = P_SpawnMobj(toucher->x, toucher->y, toucher->z + toucher->info->height, MT_NIGHTOPIANHELPER); mobj_t *flickyobj = P_SpawnMobj(toucher->x, toucher->y, toucher->z + toucher->info->height, MT_NIGHTOPIANHELPER);
P_SetTarget(&flickyobj->target, toucher); if (!P_MobjWasRemoved(flickyobj))
P_SetTarget(&flickyobj->target, toucher);
player->powers[pw_nights_helper] = (UINT16)special->info->speed; player->powers[pw_nights_helper] = (UINT16)special->info->speed;
} }
@ -1312,7 +1316,8 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
if (playeringame[i] && players[i].mo && players[i].powers[pw_carry] == CR_NIGHTSMODE) { if (playeringame[i] && players[i].mo && players[i].powers[pw_carry] == CR_NIGHTSMODE) {
players[i].powers[pw_nights_helper] = (UINT16)special->info->speed; players[i].powers[pw_nights_helper] = (UINT16)special->info->speed;
flickyobj = P_SpawnMobj(players[i].mo->x, players[i].mo->y, players[i].mo->z + players[i].mo->info->height, MT_NIGHTOPIANHELPER); flickyobj = P_SpawnMobj(players[i].mo->x, players[i].mo->y, players[i].mo->z + players[i].mo->info->height, MT_NIGHTOPIANHELPER);
P_SetTarget(&flickyobj->target, players[i].mo); if (!P_MobjWasRemoved(flickyobj))
P_SetTarget(&flickyobj->target, players[i].mo);
} }
if (special->info->deathsound != sfx_None) if (special->info->deathsound != sfx_None)
S_StartSound(NULL, special->info->deathsound); S_StartSound(NULL, special->info->deathsound);
@ -1553,7 +1558,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
if (player->pflags & PF_GLIDING && !P_IsObjectOnGround(toucher)) if (player->pflags & PF_GLIDING && !P_IsObjectOnGround(toucher))
{ {
player->pflags &= ~(PF_GLIDING|PF_JUMPED|PF_NOJUMPDAMAGE); player->pflags &= ~(PF_GLIDING|PF_JUMPED|PF_NOJUMPDAMAGE);
P_SetPlayerMobjState(toucher, S_PLAY_FALL); P_SetMobjState(toucher, S_PLAY_FALL);
toucher->momz += P_MobjFlip(toucher) * (player->speed >> 3); toucher->momz += P_MobjFlip(toucher) * (player->speed >> 3);
toucher->momx = 7*toucher->momx>>3; toucher->momx = 7*toucher->momx>>3;
toucher->momy = 7*toucher->momy>>3; toucher->momy = 7*toucher->momy>>3;
@ -1604,7 +1609,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
if (player->pflags & PF_GLIDING && !P_IsObjectOnGround(toucher)) if (player->pflags & PF_GLIDING && !P_IsObjectOnGround(toucher))
{ {
player->pflags &= ~(PF_GLIDING|PF_JUMPED|PF_NOJUMPDAMAGE); player->pflags &= ~(PF_GLIDING|PF_JUMPED|PF_NOJUMPDAMAGE);
P_SetPlayerMobjState(toucher, S_PLAY_FALL); P_SetMobjState(toucher, S_PLAY_FALL);
toucher->momz += P_MobjFlip(toucher) * (player->speed >> 3); toucher->momz += P_MobjFlip(toucher) * (player->speed >> 3);
toucher->momx = 7*toucher->momx>>3; toucher->momx = 7*toucher->momx>>3;
toucher->momy = 7*toucher->momy>>3; toucher->momy = 7*toucher->momy>>3;
@ -1640,7 +1645,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
special->momx = special->momy = 0; special->momx = special->momy = 0;
// Buenos Dias Mandy // Buenos Dias Mandy
P_SetPlayerMobjState(toucher, S_PLAY_STUN); P_SetMobjState(toucher, S_PLAY_STUN);
player->pflags &= ~PF_APPLYAUTOBRAKE; player->pflags &= ~PF_APPLYAUTOBRAKE;
P_ResetPlayer(player); P_ResetPlayer(player);
player->drawangle = special->angle + ANGLE_180; player->drawangle = special->angle + ANGLE_180;
@ -1719,7 +1724,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
{ {
player->powers[pw_carry] = CR_MACESPIN; player->powers[pw_carry] = CR_MACESPIN;
S_StartSound(toucher, sfx_spin); S_StartSound(toucher, sfx_spin);
P_SetPlayerMobjState(toucher, S_PLAY_ROLL); P_SetMobjState(toucher, S_PLAY_ROLL);
} }
else else
player->powers[pw_carry] = CR_GENERIC; player->powers[pw_carry] = CR_GENERIC;
@ -1780,7 +1785,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
{ {
if (player->bot && player->bot != BOT_MPAI && toucher->state-states != S_PLAY_GASP) if (player->bot && player->bot != BOT_MPAI && toucher->state-states != S_PLAY_GASP)
S_StartSound(toucher, special->info->deathsound); // Force it to play a sound for bots S_StartSound(toucher, special->info->deathsound); // Force it to play a sound for bots
P_SetPlayerMobjState(toucher, S_PLAY_GASP); P_SetMobjState(toucher, S_PLAY_GASP);
P_ResetPlayer(player); P_ResetPlayer(player);
} }
@ -1821,9 +1826,12 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
if (!player->bot && player->bot != BOT_MPAI && special->fuse <= TICRATE && player->powers[pw_carry] != CR_MINECART && !(player->powers[pw_ignorelatch] & (1<<15))) if (!player->bot && player->bot != BOT_MPAI && special->fuse <= TICRATE && player->powers[pw_carry] != CR_MINECART && !(player->powers[pw_ignorelatch] & (1<<15)))
{ {
mobj_t *mcart = P_SpawnMobj(special->x, special->y, special->z, MT_MINECART); mobj_t *mcart = P_SpawnMobj(special->x, special->y, special->z, MT_MINECART);
P_SetTarget(&mcart->target, toucher); if (!P_MobjWasRemoved(mcart))
mcart->angle = toucher->angle = player->drawangle = special->angle; {
mcart->friction = FRACUNIT; P_SetTarget(&mcart->target, toucher);
mcart->angle = toucher->angle = player->drawangle = special->angle;
mcart->friction = FRACUNIT;
}
P_ResetPlayer(player); P_ResetPlayer(player);
player->pflags |= PF_JUMPDOWN; player->pflags |= PF_JUMPDOWN;
@ -1847,7 +1855,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
toucher->momz = toucher->tracer->momz + P_AproxDistance(toucher->tracer->momx, toucher->tracer->momy)/2; toucher->momz = toucher->tracer->momz + P_AproxDistance(toucher->tracer->momx, toucher->tracer->momy)/2;
P_ResetPlayer(player); P_ResetPlayer(player);
player->pflags &= ~PF_APPLYAUTOBRAKE; player->pflags &= ~PF_APPLYAUTOBRAKE;
P_SetPlayerMobjState(toucher, S_PLAY_FALL); P_SetMobjState(toucher, S_PLAY_FALL);
P_SetTarget(&toucher->tracer->target, NULL); P_SetTarget(&toucher->tracer->target, NULL);
P_KillMobj(toucher->tracer, toucher, special, 0); P_KillMobj(toucher->tracer, toucher, special, 0);
P_SetTarget(&toucher->tracer, NULL); P_SetTarget(&toucher->tracer, NULL);
@ -2593,7 +2601,8 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
break; break;
} }
P_SetMobjState(scoremobj, scorestate); if (!P_MobjWasRemoved(scoremobj))
P_SetMobjState(scoremobj, scorestate);
source->player->scoreadd = locscoreadd; source->player->scoreadd = locscoreadd;
} }
@ -2754,6 +2763,8 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
mo = P_SpawnMobj(inflictor->x + inflictor->momx, inflictor->y + inflictor->momy, inflictor->z + (inflictor->height / 2) + inflictor->momz, MT_EXTRALARGEBUBBLE); mo = P_SpawnMobj(inflictor->x + inflictor->momx, inflictor->y + inflictor->momy, inflictor->z + (inflictor->height / 2) + inflictor->momz, MT_EXTRALARGEBUBBLE);
else else
mo = P_SpawnMobj(target->x, target->y, target->z, MT_EXTRALARGEBUBBLE); mo = P_SpawnMobj(target->x, target->y, target->z, MT_EXTRALARGEBUBBLE);
if (P_MobjWasRemoved(mo))
break;
mo->destscale = target->scale; mo->destscale = target->scale;
P_SetScale(mo, mo->destscale); P_SetScale(mo, mo->destscale);
P_SetMobjState(mo, mo->info->raisestate); P_SetMobjState(mo, mo->info->raisestate);
@ -2832,8 +2843,11 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
mo->angle = FixedAngle((P_RandomKey(36)*10)<<FRACBITS); mo->angle = FixedAngle((P_RandomKey(36)*10)<<FRACBITS);
mo2 = P_SpawnMobjFromMobj(mo, 0, 0, 0, MT_BOSSJUNK); mo2 = P_SpawnMobjFromMobj(mo, 0, 0, 0, MT_BOSSJUNK);
mo2->angle = mo->angle; if (!P_MobjWasRemoved(mo2))
P_SetMobjState(mo2, S_BOSSSEBH2); {
mo2->angle = mo->angle;
P_SetMobjState(mo2, S_BOSSSEBH2);
}
if (++i == 2) // we've already removed 2 of these, let's stop now if (++i == 2) // we've already removed 2 of these, let's stop now
break; break;
@ -2932,7 +2946,10 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
if (flip) if (flip)
momz *= -1; momz *= -1;
#define makechunk(angtweak, xmov, ymov) \ #define makechunk(angtweak, xmov, ymov) \
do {\
chunk = P_SpawnMobjFromMobj(target, 0, 0, 0, MT_SPIKE);\ chunk = P_SpawnMobjFromMobj(target, 0, 0, 0, MT_SPIKE);\
if (P_MobjWasRemoved(chunk))\
break;\
P_SetMobjState(chunk, target->info->xdeathstate);\ P_SetMobjState(chunk, target->info->xdeathstate);\
chunk->health = 0;\ chunk->health = 0;\
chunk->angle = angtweak;\ chunk->angle = angtweak;\
@ -2942,7 +2959,8 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
chunk->y += ymov;\ chunk->y += ymov;\
P_SetThingPosition(chunk);\ P_SetThingPosition(chunk);\
P_InstaThrust(chunk,chunk->angle, 4*scale);\ P_InstaThrust(chunk,chunk->angle, 4*scale);\
chunk->momz = momz chunk->momz = momz;\
} while (0)
makechunk(ang + ANGLE_180, -xoffs, -yoffs); makechunk(ang + ANGLE_180, -xoffs, -yoffs);
makechunk(ang, xoffs, yoffs); makechunk(ang, xoffs, yoffs);
@ -2955,20 +2973,23 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
momz *= -1; momz *= -1;
chunk = P_SpawnMobjFromMobj(target, 0, 0, 0, MT_SPIKE); chunk = P_SpawnMobjFromMobj(target, 0, 0, 0, MT_SPIKE);
P_SetMobjState(chunk, target->info->deathstate); if (!P_MobjWasRemoved(chunk))
chunk->health = 0; {
chunk->angle = ang + ANGLE_180; P_SetMobjState(chunk, target->info->deathstate);
P_UnsetThingPosition(chunk); chunk->health = 0;
chunk->flags = MF_NOCLIP; chunk->angle = ang + ANGLE_180;
chunk->x -= xoffs; P_UnsetThingPosition(chunk);
chunk->y -= yoffs; chunk->flags = MF_NOCLIP;
if (flip) chunk->x -= xoffs;
chunk->z -= 12*scale; chunk->y -= yoffs;
else if (flip)
chunk->z += 12*scale; chunk->z -= 12*scale;
P_SetThingPosition(chunk); else
P_InstaThrust(chunk, chunk->angle, 2*scale); chunk->z += 12*scale;
chunk->momz = momz; P_SetThingPosition(chunk);
P_InstaThrust(chunk, chunk->angle, 2*scale);
chunk->momz = momz;
}
P_SetMobjState(target, target->info->deathstate); P_SetMobjState(target, target->info->deathstate);
target->health = 0; target->health = 0;
@ -2977,7 +2998,10 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
target->flags = MF_NOCLIP; target->flags = MF_NOCLIP;
target->x += xoffs; target->x += xoffs;
target->y += yoffs; target->y += yoffs;
target->z = chunk->z; if (flip)
target->z -= 12*scale;
else
target->z += 12*scale;
P_SetThingPosition(target); P_SetThingPosition(target);
P_InstaThrust(target, target->angle, 2*scale); P_InstaThrust(target, target->angle, 2*scale);
target->momz = momz; target->momz = momz;
@ -3000,21 +3024,25 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
sprflip = P_RandomChance(FRACUNIT/2); sprflip = P_RandomChance(FRACUNIT/2);
#define makechunk(angtweak, xmov, ymov) \ #define makechunk(angtweak, xmov, ymov) \
chunk = P_SpawnMobjFromMobj(target, 0, 0, 0, MT_WALLSPIKE);\ do {\
P_SetMobjState(chunk, target->info->xdeathstate);\ chunk = P_SpawnMobjFromMobj(target, 0, 0, 0, MT_WALLSPIKE);\
chunk->health = 0;\ if (P_MobjWasRemoved(chunk))\
chunk->angle = target->angle;\ break;\
P_UnsetThingPosition(chunk);\ P_SetMobjState(chunk, target->info->xdeathstate);\
chunk->flags = MF_NOCLIP;\ chunk->health = 0;\
chunk->x += xmov - forwardxoffs;\ chunk->angle = target->angle;\
chunk->y += ymov - forwardyoffs;\ P_UnsetThingPosition(chunk);\
P_SetThingPosition(chunk);\ chunk->flags = MF_NOCLIP;\
P_InstaThrust(chunk, angtweak, 4*scale);\ chunk->x += xmov - forwardxoffs;\
chunk->momz = P_RandomRange(5, 7)*scale;\ chunk->y += ymov - forwardyoffs;\
if (flip)\ P_SetThingPosition(chunk);\
chunk->momz *= -1;\ P_InstaThrust(chunk, angtweak, 4*scale);\
if (sprflip)\ chunk->momz = P_RandomRange(5, 7)*scale;\
chunk->frame |= FF_VERTICALFLIP if (flip)\
chunk->momz *= -1;\
if (sprflip)\
chunk->frame |= FF_VERTICALFLIP;\
} while (0)
makechunk(ang + ANGLE_180, -xoffs, -yoffs); makechunk(ang + ANGLE_180, -xoffs, -yoffs);
sprflip = !sprflip; sprflip = !sprflip;
@ -3026,21 +3054,23 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
sprflip = P_RandomChance(FRACUNIT/2); sprflip = P_RandomChance(FRACUNIT/2);
chunk = P_SpawnMobjFromMobj(target, 0, 0, 0, MT_WALLSPIKE); chunk = P_SpawnMobjFromMobj(target, 0, 0, 0, MT_WALLSPIKE);
if (!P_MobjWasRemoved(chunk))
P_SetMobjState(chunk, target->info->deathstate); {
chunk->health = 0; P_SetMobjState(chunk, target->info->deathstate);
chunk->angle = target->angle; chunk->health = 0;
P_UnsetThingPosition(chunk); chunk->angle = target->angle;
chunk->flags = MF_NOCLIP; P_UnsetThingPosition(chunk);
chunk->x += forwardxoffs - xoffs; chunk->flags = MF_NOCLIP;
chunk->y += forwardyoffs - yoffs; chunk->x += forwardxoffs - xoffs;
P_SetThingPosition(chunk); chunk->y += forwardyoffs - yoffs;
P_InstaThrust(chunk, ang + ANGLE_180, 2*scale); P_SetThingPosition(chunk);
chunk->momz = P_RandomRange(5, 7)*scale; P_InstaThrust(chunk, ang + ANGLE_180, 2*scale);
if (flip) chunk->momz = P_RandomRange(5, 7)*scale;
chunk->momz *= -1; if (flip)
if (sprflip) chunk->momz *= -1;
chunk->frame |= FF_VERTICALFLIP; if (sprflip)
chunk->frame |= FF_VERTICALFLIP;
}
P_SetMobjState(target, target->info->deathstate); P_SetMobjState(target, target->info->deathstate);
target->health = 0; target->health = 0;
@ -3059,9 +3089,9 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
else if (target->player) else if (target->player)
{ {
if (damagetype == DMG_DROWNED || damagetype == DMG_SPACEDROWN) if (damagetype == DMG_DROWNED || damagetype == DMG_SPACEDROWN)
P_SetPlayerMobjState(target, target->info->xdeathstate); P_SetMobjState(target, target->info->xdeathstate);
else else
P_SetPlayerMobjState(target, target->info->deathstate); P_SetMobjState(target, target->info->deathstate);
} }
else else
#ifdef DEBUG_NULL_DEATHSTATE #ifdef DEBUG_NULL_DEATHSTATE
@ -3115,7 +3145,7 @@ static void P_NiGHTSDamage(mobj_t *target, mobj_t *source)
} }
player->powers[pw_flashing] = flashingtics; player->powers[pw_flashing] = flashingtics;
P_SetPlayerMobjState(target, S_PLAY_NIGHTS_STUN); P_SetMobjState(target, S_PLAY_NIGHTS_STUN);
S_StartSound(target, sfx_nghurt); S_StartSound(target, sfx_nghurt);
player->mo->spriteroll = 0; player->mo->spriteroll = 0;
@ -3336,7 +3366,7 @@ static void P_KillPlayer(player_t *player, mobj_t *source, INT32 damage)
if (!player->spectator) if (!player->spectator)
player->mo->flags2 &= ~MF2_DONTDRAW; player->mo->flags2 &= ~MF2_DONTDRAW;
P_SetPlayerMobjState(player->mo, player->mo->info->deathstate); P_SetMobjState(player->mo, player->mo->info->deathstate);
if ((gametyperules & GTR_TEAMFLAGS) && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG))) if ((gametyperules & GTR_TEAMFLAGS) && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG)))
{ {
P_PlayerFlagBurst(player, false); P_PlayerFlagBurst(player, false);
@ -3410,7 +3440,7 @@ static void P_SuperDamage(player_t *player, mobj_t *inflictor, mobj_t *source, I
P_InstaThrust(player->mo, ang, fallbackspeed); P_InstaThrust(player->mo, ang, fallbackspeed);
P_SetPlayerMobjState(player->mo, S_PLAY_STUN); P_SetMobjState(player->mo, S_PLAY_STUN);
P_ResetPlayer(player); P_ResetPlayer(player);
@ -3921,6 +3951,8 @@ void P_PlayerRingBurst(player_t *player, INT32 num_rings)
z += player->mo->height - mobjinfo[objType].height; z += player->mo->height - mobjinfo[objType].height;
mo = P_SpawnMobj(player->mo->x, player->mo->y, z, objType); mo = P_SpawnMobj(player->mo->x, player->mo->y, z, objType);
if (P_MobjWasRemoved(mo))
continue;
mo->fuse = 8*TICRATE; mo->fuse = 8*TICRATE;
P_SetTarget(&mo->target, player->mo); P_SetTarget(&mo->target, player->mo);
@ -4054,6 +4086,9 @@ void P_PlayerWeaponPanelBurst(player_t *player)
z += player->mo->height - mobjinfo[weptype].height; z += player->mo->height - mobjinfo[weptype].height;
mo = P_SpawnMobj(player->mo->x, player->mo->y, z, weptype); mo = P_SpawnMobj(player->mo->x, player->mo->y, z, weptype);
if (P_MobjWasRemoved(mo))
continue;
mo->reactiontime = ammoamt; mo->reactiontime = ammoamt;
mo->flags2 |= MF2_DONTRESPAWN; mo->flags2 |= MF2_DONTRESPAWN;
mo->flags &= ~(MF_NOGRAVITY|MF_NOCLIPHEIGHT); mo->flags &= ~(MF_NOGRAVITY|MF_NOCLIPHEIGHT);
@ -4087,13 +4122,13 @@ void P_PlayerWeaponAmmoBurst(player_t *player)
mobj_t *mo; mobj_t *mo;
angle_t fa; angle_t fa;
fixed_t ns; fixed_t ns;
INT32 i = 0; INT32 i;
fixed_t z; fixed_t z;
mobjtype_t weptype = 0; mobjtype_t weptype = 0;
powertype_t power = 0; powertype_t power = 0;
while (true) for (i = 0;; i++)
{ {
if (player->powers[pw_bouncering]) if (player->powers[pw_bouncering])
{ {
@ -4138,6 +4173,8 @@ void P_PlayerWeaponAmmoBurst(player_t *player)
z += player->mo->height - mobjinfo[weptype].height; z += player->mo->height - mobjinfo[weptype].height;
mo = P_SpawnMobj(player->mo->x, player->mo->y, z, weptype); mo = P_SpawnMobj(player->mo->x, player->mo->y, z, weptype);
if (P_MobjWasRemoved(mo))
continue;
mo->health = player->powers[power]; mo->health = player->powers[power];
mo->flags2 |= MF2_DONTRESPAWN; mo->flags2 |= MF2_DONTRESPAWN;
mo->flags &= ~(MF_NOGRAVITY|MF_NOCLIPHEIGHT); mo->flags &= ~(MF_NOGRAVITY|MF_NOCLIPHEIGHT);
@ -4163,8 +4200,6 @@ void P_PlayerWeaponAmmoBurst(player_t *player)
if (i & 1) if (i & 1)
P_SetObjectMomZ(mo, 3*FRACUNIT, true); P_SetObjectMomZ(mo, 3*FRACUNIT, true);
i++;
} }
} }
@ -4189,45 +4224,50 @@ void P_PlayerWeaponPanelOrAmmoBurst(player_t *player)
player->ringweapons &= ~rwflag; \ player->ringweapons &= ~rwflag; \
SETUP_DROP(pickup) \ SETUP_DROP(pickup) \
mo = P_SpawnMobj(player->mo->x, player->mo->y, z, pickup); \ mo = P_SpawnMobj(player->mo->x, player->mo->y, z, pickup); \
mo->reactiontime = 0; \ if (!P_MobjWasRemoved(mo)) \
mo->flags2 |= MF2_DONTRESPAWN; \ { \
mo->flags &= ~(MF_NOGRAVITY|MF_NOCLIPHEIGHT); \ mo->reactiontime = 0; \
P_SetTarget(&mo->target, player->mo); \ mo->flags2 |= MF2_DONTRESPAWN; \
mo->fuse = 12*TICRATE; \ mo->flags &= ~(MF_NOGRAVITY|MF_NOCLIPHEIGHT); \
mo->destscale = player->mo->scale; \ P_SetTarget(&mo->target, player->mo); \
P_SetScale(mo, player->mo->scale); \ mo->fuse = 12*TICRATE; \
mo->momx = FixedMul(FINECOSINE(fa),ns); \ mo->destscale = player->mo->scale; \
if (!(twodlevel || (player->mo->flags2 & MF2_TWOD))) \ P_SetScale(mo, player->mo->scale); \
mo->momy = FixedMul(FINESINE(fa),ns); \ mo->momx = FixedMul(FINECOSINE(fa),ns); \
P_SetObjectMomZ(mo, 4*FRACUNIT, false); \ if (!(twodlevel || (player->mo->flags2 & MF2_TWOD))) \
if (i & 1) \ mo->momy = FixedMul(FINESINE(fa),ns); \
P_SetObjectMomZ(mo, 4*FRACUNIT, true); \ P_SetObjectMomZ(mo, 4*FRACUNIT, false); \
if (player->mo->eflags & MFE_VERTICALFLIP) \ if (i & 1) \
mo->flags2 |= MF2_OBJECTFLIP; \ P_SetObjectMomZ(mo, 4*FRACUNIT, true); \
++i; \ if (player->mo->eflags & MFE_VERTICALFLIP) \
mo->flags2 |= MF2_OBJECTFLIP; \
} \
} \ } \
else if (player->powers[power] > 0) \ else if (player->powers[power] > 0) \
{ \ { \
SETUP_DROP(ammo) \ SETUP_DROP(ammo) \
mo = P_SpawnMobj(player->mo->x, player->mo->y, z, ammo); \ mo = P_SpawnMobj(player->mo->x, player->mo->y, z, ammo); \
mo->health = player->powers[power]; \ if (!P_MobjWasRemoved(mo)) \
mo->flags2 |= MF2_DONTRESPAWN; \ { \
mo->flags &= ~(MF_NOGRAVITY|MF_NOCLIPHEIGHT); \ mo->health = player->powers[power]; \
P_SetTarget(&mo->target, player->mo); \ mo->flags2 |= MF2_DONTRESPAWN; \
mo->fuse = 12*TICRATE; \ mo->flags &= ~(MF_NOGRAVITY|MF_NOCLIPHEIGHT); \
mo->destscale = player->mo->scale; \ P_SetTarget(&mo->target, player->mo); \
P_SetScale(mo, player->mo->scale); \ mo->fuse = 12*TICRATE; \
mo->momx = FixedMul(FINECOSINE(fa),ns); \ mo->destscale = player->mo->scale; \
if (!(twodlevel || (player->mo->flags2 & MF2_TWOD))) \ P_SetScale(mo, player->mo->scale); \
mo->momy = FixedMul(FINESINE(fa),ns); \ mo->momx = FixedMul(FINECOSINE(fa),ns); \
P_SetObjectMomZ(mo, 3*FRACUNIT, false); \ if (!(twodlevel || (player->mo->flags2 & MF2_TWOD))) \
if (i & 1) \ mo->momy = FixedMul(FINESINE(fa),ns); \
P_SetObjectMomZ(mo, 3*FRACUNIT, true); \ P_SetObjectMomZ(mo, 3*FRACUNIT, false); \
if (player->mo->eflags & MFE_VERTICALFLIP) \ if (i & 1) \
mo->flags2 |= MF2_OBJECTFLIP; \ P_SetObjectMomZ(mo, 3*FRACUNIT, true); \
player->powers[power] = 0; \ if (player->mo->eflags & MFE_VERTICALFLIP) \
++i; \ mo->flags2 |= MF2_OBJECTFLIP; \
} player->powers[power] = 0; \
} \
} \
++i
DROP_WEAPON(RW_BOUNCE, MT_BOUNCEPICKUP, MT_BOUNCERING, pw_bouncering); DROP_WEAPON(RW_BOUNCE, MT_BOUNCEPICKUP, MT_BOUNCERING, pw_bouncering);
DROP_WEAPON(RW_RAIL, MT_RAILPICKUP, MT_RAILRING, pw_railring); DROP_WEAPON(RW_RAIL, MT_RAILPICKUP, MT_RAILRING, pw_railring);
@ -4351,23 +4391,26 @@ void P_PlayerEmeraldBurst(player_t *player, boolean toss)
momy = 0; momy = 0;
mo = P_SpawnMobj(player->mo->x, player->mo->y, z, MT_FLINGEMERALD); mo = P_SpawnMobj(player->mo->x, player->mo->y, z, MT_FLINGEMERALD);
mo->health = 1; if (!P_MobjWasRemoved(mo))
mo->threshold = stoneflag;
mo->flags2 |= (MF2_DONTRESPAWN|MF2_SLIDEPUSH);
mo->flags &= ~(MF_NOGRAVITY|MF_NOCLIPHEIGHT);
P_SetTarget(&mo->target, player->mo);
mo->fuse = 12*TICRATE;
P_SetMobjState(mo, statenum);
mo->momx = momx;
mo->momy = momy;
P_SetObjectMomZ(mo, 3*FRACUNIT, false);
if (player->mo->eflags & MFE_VERTICALFLIP)
{ {
mo->momz = -mo->momz; mo->health = 1;
mo->flags2 |= MF2_OBJECTFLIP; mo->threshold = stoneflag;
mo->flags2 |= (MF2_DONTRESPAWN|MF2_SLIDEPUSH);
mo->flags &= ~(MF_NOGRAVITY|MF_NOCLIPHEIGHT);
P_SetTarget(&mo->target, player->mo);
mo->fuse = 12*TICRATE;
P_SetMobjState(mo, statenum);
mo->momx = momx;
mo->momy = momy;
P_SetObjectMomZ(mo, 3*FRACUNIT, false);
if (player->mo->eflags & MFE_VERTICALFLIP)
{
mo->momz = -mo->momz;
mo->flags2 |= MF2_OBJECTFLIP;
}
} }
if (toss) if (toss)
@ -4395,6 +4438,8 @@ void P_PlayerFlagBurst(player_t *player, boolean toss)
type = MT_BLUEFLAG; type = MT_BLUEFLAG;
flag = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, type); flag = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, type);
if (P_MobjWasRemoved(flag))
return;
if (player->mo->eflags & MFE_VERTICALFLIP) if (player->mo->eflags & MFE_VERTICALFLIP)
{ {

View file

@ -71,6 +71,7 @@ typedef enum
NUM_THINKERLISTS NUM_THINKERLISTS
} thinklistnum_t; /**< Thinker lists. */ } thinklistnum_t; /**< Thinker lists. */
extern thinker_t thlist[]; extern thinker_t thlist[];
extern mobj_t *mobjcache;
void P_InitThinkers(void); void P_InitThinkers(void);
void P_AddThinker(const thinklistnum_t n, thinker_t *thinker); void P_AddThinker(const thinklistnum_t n, thinker_t *thinker);
@ -202,8 +203,9 @@ mobj_t *P_LookForEnemies(player_t *player, boolean nonenemies, boolean bullet);
void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius); void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius);
void P_Earthquake(mobj_t *inflictor, mobj_t *source, fixed_t radius); void P_Earthquake(mobj_t *inflictor, mobj_t *source, fixed_t radius);
boolean P_HomingAttack(mobj_t *source, mobj_t *enemy); /// \todo doesn't belong in p_user boolean P_HomingAttack(mobj_t *source, mobj_t *enemy); /// \todo doesn't belong in p_user
boolean P_SuperReady(player_t *player); boolean P_SuperReady(player_t *player, boolean transform);
void P_DoJump(player_t *player, boolean soundandstate); void P_DoJump(player_t *player, boolean soundandstate);
void P_DoSpinDashDust(player_t *player);
#define P_AnalogMove(player) (P_ControlStyle(player) == CS_LMAOGALOG) #define P_AnalogMove(player) (P_ControlStyle(player) == CS_LMAOGALOG)
boolean P_TransferToNextMare(player_t *player); boolean P_TransferToNextMare(player_t *player);
UINT8 P_FindLowestMare(void); UINT8 P_FindLowestMare(void);
@ -214,6 +216,10 @@ void P_SpawnThokMobj(player_t *player);
void P_SpawnSpinMobj(player_t *player, mobjtype_t type); void P_SpawnSpinMobj(player_t *player, mobjtype_t type);
void P_Telekinesis(player_t *player, fixed_t thrust, fixed_t range); void P_Telekinesis(player_t *player, fixed_t thrust, fixed_t range);
void P_DoTailsOverlay(player_t *player, mobj_t *tails);
void P_DoMetalJetFume(player_t *player, mobj_t *fume);
void P_DoFollowMobj(player_t *player, mobj_t *followmobj);
void P_PlayLivesJingle(player_t *player); void P_PlayLivesJingle(player_t *player);
#define P_PlayRinglossSound(s) S_StartSound(s, (mariomode) ? sfx_mario8 : sfx_altow1 + P_RandomKey(4)); #define P_PlayRinglossSound(s) S_StartSound(s, (mariomode) ? sfx_mario8 : sfx_altow1 + P_RandomKey(4));
#define P_PlayDeathSound(s) S_StartSound(s, sfx_altdi1 + P_RandomKey(4)); #define P_PlayDeathSound(s) S_StartSound(s, sfx_altdi1 + P_RandomKey(4));
@ -283,7 +289,7 @@ mobjtype_t P_GetMobjtype(UINT16 mthingtype);
void P_RespawnSpecials(void); void P_RespawnSpecials(void);
mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type); mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type, ...);
void P_RecalcPrecipInSector(sector_t *sector); void P_RecalcPrecipInSector(sector_t *sector);
void P_PrecipitationEffects(void); void P_PrecipitationEffects(void);
@ -291,13 +297,13 @@ void P_PrecipitationEffects(void);
void P_RemoveMobj(mobj_t *th); void P_RemoveMobj(mobj_t *th);
boolean P_MobjWasRemoved(mobj_t *th); boolean P_MobjWasRemoved(mobj_t *th);
void P_RemoveSavegameMobj(mobj_t *th); void P_RemoveSavegameMobj(mobj_t *th);
boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state);
boolean P_SetMobjState(mobj_t *mobj, statenum_t state); boolean P_SetMobjState(mobj_t *mobj, statenum_t state);
void P_RunShields(void); void P_RunShields(void);
void P_RunOverlays(void); void P_RunOverlays(void);
void P_HandleMinecartSegments(mobj_t *mobj); void P_HandleMinecartSegments(mobj_t *mobj);
void P_MobjThinker(mobj_t *mobj); void P_MobjThinker(mobj_t *mobj);
boolean P_RailThinker(mobj_t *mobj); boolean P_RailThinker(mobj_t *mobj);
boolean P_CheckSkyHit(mobj_t *mo, line_t *line);
void P_PushableThinker(mobj_t *mobj); void P_PushableThinker(mobj_t *mobj);
void P_SceneryThinker(mobj_t *mobj); void P_SceneryThinker(mobj_t *mobj);
@ -439,6 +445,10 @@ boolean PIT_PushableMoved(mobj_t *thing);
boolean P_DoSpring(mobj_t *spring, mobj_t *object); boolean P_DoSpring(mobj_t *spring, mobj_t *object);
INT32 P_GetSectorLightAt(sector_t *sector, fixed_t x, fixed_t y, fixed_t z);
extracolormap_t *P_GetColormapFromSectorAt(sector_t *sector, fixed_t x, fixed_t y, fixed_t z);
extracolormap_t *P_GetSectorColormapAt(fixed_t x, fixed_t y, fixed_t z);
// //
// P_SETUP // P_SETUP
// //

View file

@ -264,7 +264,7 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object)
UINT8 secondjump = object->player->secondjump; UINT8 secondjump = object->player->secondjump;
UINT16 tailsfly = object->player->powers[pw_tailsfly]; UINT16 tailsfly = object->player->powers[pw_tailsfly];
if (object->player->pflags & PF_GLIDING) if (object->player->pflags & PF_GLIDING)
P_SetPlayerMobjState(object, S_PLAY_FALL); P_SetMobjState(object, S_PLAY_FALL);
P_ResetPlayer(object->player); P_ResetPlayer(object->player);
object->player->pflags |= pflags; object->player->pflags |= pflags;
object->player->secondjump = secondjump; object->player->secondjump = secondjump;
@ -403,7 +403,7 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object)
} }
if (object->player->pflags & PF_GLIDING) if (object->player->pflags & PF_GLIDING)
P_SetPlayerMobjState(object, S_PLAY_FALL); P_SetMobjState(object, S_PLAY_FALL);
if ((spring->info->painchance == 3)) if ((spring->info->painchance == 3))
{ {
if (!(pflags = (object->player->pflags & PF_SPINNING)) && if (!(pflags = (object->player->pflags & PF_SPINNING)) &&
@ -411,11 +411,11 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object)
|| (spring->flags2 & MF2_AMBUSH))) || (spring->flags2 & MF2_AMBUSH)))
{ {
pflags = PF_SPINNING; pflags = PF_SPINNING;
P_SetPlayerMobjState(object, S_PLAY_ROLL); P_SetMobjState(object, S_PLAY_ROLL);
S_StartSound(object, sfx_spin); S_StartSound(object, sfx_spin);
} }
else else
P_SetPlayerMobjState(object, S_PLAY_ROLL); P_SetMobjState(object, S_PLAY_ROLL);
} }
else else
{ {
@ -424,7 +424,7 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object)
pflags = object->player->pflags & (PF_STARTJUMP | PF_JUMPED | PF_NOJUMPDAMAGE | PF_SPINNING | PF_THOKKED | PF_BOUNCING); // I still need these. pflags = object->player->pflags & (PF_STARTJUMP | PF_JUMPED | PF_NOJUMPDAMAGE | PF_SPINNING | PF_THOKKED | PF_BOUNCING); // I still need these.
if (wasSpindashing) // Ensure we're in the rolling state, and not spindash. if (wasSpindashing) // Ensure we're in the rolling state, and not spindash.
P_SetPlayerMobjState(object, S_PLAY_ROLL); P_SetMobjState(object, S_PLAY_ROLL);
if (object->player->charability == CA_GLIDEANDCLIMB && object->player->skidtime && (pflags & PF_JUMPED)) if (object->player->charability == CA_GLIDEANDCLIMB && object->player->skidtime && (pflags & PF_JUMPED))
{ {
@ -439,7 +439,7 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object)
if (spring->info->painchance == 1) // For all those ancient, SOC'd abilities. if (spring->info->painchance == 1) // For all those ancient, SOC'd abilities.
{ {
object->player->pflags |= P_GetJumpFlags(object->player); object->player->pflags |= P_GetJumpFlags(object->player);
P_SetPlayerMobjState(object, S_PLAY_JUMP); P_SetMobjState(object, S_PLAY_JUMP);
} }
else if ((spring->info->painchance == 2) || ((spring->info->painchance != 3) && (pflags & PF_BOUNCING))) // Adding momentum only. else if ((spring->info->painchance == 2) || ((spring->info->painchance != 3) && (pflags & PF_BOUNCING))) // Adding momentum only.
{ {
@ -456,16 +456,16 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object)
object->player->secondjump = secondjump; object->player->secondjump = secondjump;
} }
else if (object->player->dashmode >= DASHMODE_THRESHOLD) else if (object->player->dashmode >= DASHMODE_THRESHOLD)
P_SetPlayerMobjState(object, S_PLAY_DASH); P_SetMobjState(object, S_PLAY_DASH);
else if (P_IsObjectOnGround(object)) else if (P_IsObjectOnGround(object))
P_SetPlayerMobjState(object, (horizspeed >= FixedMul(object->player->runspeed, object->scale)) ? S_PLAY_RUN : S_PLAY_WALK); P_SetMobjState(object, (horizspeed >= FixedMul(object->player->runspeed, object->scale)) ? S_PLAY_RUN : S_PLAY_WALK);
else else
P_SetPlayerMobjState(object, (object->momz > 0) ? S_PLAY_SPRING : S_PLAY_FALL); P_SetMobjState(object, (object->momz > 0) ? S_PLAY_SPRING : S_PLAY_FALL);
} }
else if (P_MobjFlip(object)*vertispeed > 0) else if (P_MobjFlip(object)*vertispeed > 0)
P_SetPlayerMobjState(object, S_PLAY_SPRING); P_SetMobjState(object, S_PLAY_SPRING);
else else
P_SetPlayerMobjState(object, S_PLAY_FALL); P_SetMobjState(object, S_PLAY_FALL);
} }
else if (horizspeed else if (horizspeed
&& object->tracer && object->tracer
@ -547,7 +547,7 @@ static void P_DoFanAndGasJet(mobj_t *spring, mobj_t *object)
if (p && !p->powers[pw_tailsfly] && !p->powers[pw_carry]) // doesn't reset anim for Tails' flight if (p && !p->powers[pw_tailsfly] && !p->powers[pw_carry]) // doesn't reset anim for Tails' flight
{ {
P_ResetPlayer(p); P_ResetPlayer(p);
P_SetPlayerMobjState(object, S_PLAY_FALL); P_SetMobjState(object, S_PLAY_FALL);
P_SetTarget(&object->tracer, spring); P_SetTarget(&object->tracer, spring);
p->powers[pw_carry] = CR_FAN; p->powers[pw_carry] = CR_FAN;
} }
@ -565,7 +565,7 @@ static void P_DoFanAndGasJet(mobj_t *spring, mobj_t *object)
{ {
P_ResetPlayer(p); P_ResetPlayer(p);
if (p->panim != PA_FALL) if (p->panim != PA_FALL)
P_SetPlayerMobjState(object, S_PLAY_FALL); P_SetMobjState(object, S_PLAY_FALL);
} }
break; break;
default: default:
@ -1047,7 +1047,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
thing->flags2 &= ~MF2_DONTDRAW; // don't leave the rock invisible if it was flashing prior to boarding thing->flags2 &= ~MF2_DONTDRAW; // don't leave the rock invisible if it was flashing prior to boarding
P_SetTarget(&thing->tracer, tmthing); P_SetTarget(&thing->tracer, tmthing);
P_ResetPlayer(tmthing->player); P_ResetPlayer(tmthing->player);
P_SetPlayerMobjState(tmthing, S_PLAY_WALK); P_SetMobjState(tmthing, S_PLAY_WALK);
tmthing->player->powers[pw_carry] = CR_ROLLOUT; tmthing->player->powers[pw_carry] = CR_ROLLOUT;
P_SetTarget(&tmthing->tracer, thing); P_SetTarget(&tmthing->tracer, thing);
if (!P_IsObjectOnGround(thing)) if (!P_IsObjectOnGround(thing))
@ -2865,6 +2865,8 @@ boolean P_CheckMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
{ {
boolean moveok; boolean moveok;
mobj_t *hack = P_SpawnMobjFromMobj(thing, 0, 0, 0, MT_RAY); mobj_t *hack = P_SpawnMobjFromMobj(thing, 0, 0, 0, MT_RAY);
if (P_MobjWasRemoved(hack))
return false;
hack->radius = thing->radius; hack->radius = thing->radius;
hack->height = thing->height; hack->height = thing->height;
@ -3073,11 +3075,14 @@ static boolean P_ThingHeightClip(mobj_t *thing)
if (!rover || ((rover->fofflags & FOF_EXISTS) && (rover->fofflags & FOF_SOLID))) if (!rover || ((rover->fofflags & FOF_EXISTS) && (rover->fofflags & FOF_SOLID)))
{ {
hitfloor = bouncing; hitfloor = bouncing;
if (thing->eflags & MFE_VERTICALFLIP) if (!(thing->player) || !(thing->player->pflags & PF_JUMPED || bouncing))
thing->pmomz = thing->ceilingz - (thing->z + thing->height); {
else if (thing->eflags & MFE_VERTICALFLIP)
thing->pmomz = thing->floorz - thing->z; thing->pmomz = thing->ceilingz - (thing->z + thing->height);
thing->eflags |= MFE_APPLYPMOMZ; else
thing->pmomz = thing->floorz - thing->z;
thing->eflags |= MFE_APPLYPMOMZ;
}
if (thing->eflags & MFE_VERTICALFLIP) if (thing->eflags & MFE_VERTICALFLIP)
thing->z = thing->ceilingz - thing->height; thing->z = thing->ceilingz - thing->height;
@ -3902,7 +3907,7 @@ retry:
P_PathTraverse(leadx, traily, leadx + mo->momx, traily + mo->momy, P_PathTraverse(leadx, traily, leadx + mo->momx, traily + mo->momy,
PT_ADDLINES, PTR_SlideTraverse); PT_ADDLINES, PTR_SlideTraverse);
if (bestslideline && mo->player && bestslideline->sidenum[1] != 0xffff) if (bestslideline && mo->player && bestslideline->sidenum[1] != NO_SIDEDEF)
{ {
sector_t *sec = P_PointOnLineSide(mo->x, mo->y, bestslideline) ? bestslideline->frontsector : bestslideline->backsector; sector_t *sec = P_PointOnLineSide(mo->x, mo->y, bestslideline) ? bestslideline->frontsector : bestslideline->backsector;
P_CheckLavaWall(mo, sec); P_CheckLavaWall(mo, sec);
@ -5068,3 +5073,35 @@ fixed_t P_CeilingzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height)
return ceilingz; return ceilingz;
} }
INT32 P_GetSectorLightAt(sector_t *sector, fixed_t x, fixed_t y, fixed_t z)
{
if (!sector->numlights)
return -1;
INT32 light = sector->numlights - 1;
// R_GetPlaneLight won't work on sloped lights!
for (INT32 lightnum = 1; lightnum < sector->numlights; lightnum++) {
fixed_t h = P_GetLightZAt(&sector->lightlist[lightnum], x, y);
if (h <= z) {
light = lightnum - 1;
break;
}
}
return light;
}
extracolormap_t *P_GetColormapFromSectorAt(sector_t *sector, fixed_t x, fixed_t y, fixed_t z)
{
if (sector->numlights)
return *sector->lightlist[P_GetSectorLightAt(sector, x, y, z)].extra_colormap;
else
return sector->extra_colormap;
}
extracolormap_t *P_GetSectorColormapAt(fixed_t x, fixed_t y, fixed_t z)
{
return P_GetColormapFromSectorAt(R_PointInSubsector(x, y)->sector, x, y, z);
}

View file

@ -290,7 +290,7 @@ void P_CameraLineOpening(line_t *linedef)
sector_t *back; sector_t *back;
fixed_t frontfloor, frontceiling, backfloor, backceiling; fixed_t frontfloor, frontceiling, backfloor, backceiling;
if (linedef->sidenum[1] == 0xffff) if (linedef->sidenum[1] == NO_SIDEDEF)
{ {
// single sided line // single sided line
openrange = 0; openrange = 0;
@ -426,7 +426,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
{ {
sector_t *front, *back; sector_t *front, *back;
if (linedef->sidenum[1] == 0xffff) if (linedef->sidenum[1] == NO_SIDEDEF)
{ {
// single sided line // single sided line
openrange = 0; openrange = 0;

File diff suppressed because it is too large Load diff

View file

@ -1243,6 +1243,8 @@ boolean Polyobj_rotate(polyobj_t *po, angle_t delta, boolean turnplayers, boolea
// Returns NULL if no such polyobject exists. // Returns NULL if no such polyobject exists.
polyobj_t *Polyobj_GetForNum(INT32 id) polyobj_t *Polyobj_GetForNum(INT32 id)
{ {
if (numPolyObjects == 0)
return NULL;
INT32 curidx = PolyObjects[id % numPolyObjects].first; INT32 curidx = PolyObjects[id % numPolyObjects].first;
while (curidx != numPolyObjects && PolyObjects[curidx].id != id) while (curidx != numPolyObjects && PolyObjects[curidx].id != id)

View file

@ -867,24 +867,47 @@ static void P_NetUnArchiveWaypoints(void)
#define SD_TRIGGERTAG 0x02 #define SD_TRIGGERTAG 0x02
#define SD_TRIGGERER 0x04 #define SD_TRIGGERER 0x04
#define SD_GRAVITY 0x08 #define SD_GRAVITY 0x08
#define SD_FXSCALE 0x10
#define SD_FYSCALE 0x20
#define SD_CXSCALE 0x40
#define SD_CYSCALE 0x80
#define LD_FLAG 0x01 #define LD_FLAG 0x01
#define LD_SPECIAL 0x02 #define LD_SPECIAL 0x02
#define LD_CLLCOUNT 0x04 #define LD_CLLCOUNT 0x04
#define LD_S1TEXOFF 0x08 #define LD_ARGS 0x08
#define LD_S1TOPTEX 0x10 #define LD_STRINGARGS 0x10
#define LD_S1BOTTEX 0x20 #define LD_EXECUTORDELAY 0x20
#define LD_S1MIDTEX 0x40 #define LD_SIDE1 0x40
#define LD_DIFF2 0x80 #define LD_SIDE2 0x80
// diff2 flags // sidedef flags
#define LD_S2TEXOFF 0x01 enum
#define LD_S2TOPTEX 0x02 {
#define LD_S2BOTTEX 0x04 LD_SDTEXOFFX = 1,
#define LD_S2MIDTEX 0x08 LD_SDTEXOFFY = 1<<1,
#define LD_ARGS 0x10 LD_SDTOPTEX = 1<<2,
#define LD_STRINGARGS 0x20 LD_SDBOTTEX = 1<<3,
#define LD_EXECUTORDELAY 0x40 LD_SDMIDTEX = 1<<4,
LD_SDTOPOFFX = 1<<5,
LD_SDTOPOFFY = 1<<6,
LD_SDMIDOFFX = 1<<7,
LD_SDMIDOFFY = 1<<8,
LD_SDBOTOFFX = 1<<9,
LD_SDBOTOFFY = 1<<10,
LD_SDTOPSCALEX = 1<<11,
LD_SDTOPSCALEY = 1<<12,
LD_SDMIDSCALEX = 1<<13,
LD_SDMIDSCALEY = 1<<14,
LD_SDBOTSCALEX = 1<<15,
LD_SDBOTSCALEY = 1<<16,
LD_SDLIGHT = 1<<17,
LD_SDTOPLIGHT = 1<<18,
LD_SDMIDLIGHT = 1<<19,
LD_SDBOTLIGHT = 1<<20,
LD_SDREPEATCNT = 1<<21,
LD_SDFLAGS = 1<<22
};
static boolean P_AreArgsEqual(const line_t *li, const line_t *spawnli) static boolean P_AreArgsEqual(const line_t *li, const line_t *spawnli)
{ {
@ -1035,6 +1058,14 @@ static void ArchiveSectors(void)
diff2 |= SD_CXOFFS; diff2 |= SD_CXOFFS;
if (ss->ceilingyoffset != spawnss->ceilingyoffset) if (ss->ceilingyoffset != spawnss->ceilingyoffset)
diff2 |= SD_CYOFFS; diff2 |= SD_CYOFFS;
if (ss->floorxscale != spawnss->floorxscale)
diff2 |= SD_FXSCALE;
if (ss->flooryscale != spawnss->flooryscale)
diff2 |= SD_FYSCALE;
if (ss->ceilingxscale != spawnss->ceilingxscale)
diff2 |= SD_CXSCALE;
if (ss->ceilingyscale != spawnss->ceilingyscale)
diff2 |= SD_CYSCALE;
if (ss->floorangle != spawnss->floorangle) if (ss->floorangle != spawnss->floorangle)
diff2 |= SD_FLOORANG; diff2 |= SD_FLOORANG;
if (ss->ceilingangle != spawnss->ceilingangle) if (ss->ceilingangle != spawnss->ceilingangle)
@ -1079,7 +1110,7 @@ static void ArchiveSectors(void)
if (diff) if (diff)
{ {
WRITEUINT16(save_p, i); WRITEUINT32(save_p, i);
WRITEUINT8(save_p, diff); WRITEUINT8(save_p, diff);
if (diff & SD_DIFF2) if (diff & SD_DIFF2)
WRITEUINT8(save_p, diff2); WRITEUINT8(save_p, diff2);
@ -1145,23 +1176,32 @@ static void ArchiveSectors(void)
WRITEUINT8(save_p, ss->triggerer); WRITEUINT8(save_p, ss->triggerer);
if (diff4 & SD_GRAVITY) if (diff4 & SD_GRAVITY)
WRITEFIXED(save_p, ss->gravity); WRITEFIXED(save_p, ss->gravity);
if (diff4 & SD_FXSCALE)
WRITEFIXED(save_p, ss->floorxscale);
if (diff4 & SD_FYSCALE)
WRITEFIXED(save_p, ss->flooryscale);
if (diff4 & SD_CXSCALE)
WRITEFIXED(save_p, ss->ceilingxscale);
if (diff4 & SD_CYSCALE)
WRITEFIXED(save_p, ss->ceilingyscale);
if (diff & SD_FFLOORS) if (diff & SD_FFLOORS)
ArchiveFFloors(ss); ArchiveFFloors(ss);
} }
} }
WRITEUINT16(save_p, 0xffff); WRITEUINT32(save_p, 0xffffffff);
} }
static void UnArchiveSectors(void) static void UnArchiveSectors(void)
{ {
UINT16 i, j; UINT32 i;
UINT16 j;
UINT8 diff, diff2, diff3, diff4; UINT8 diff, diff2, diff3, diff4;
for (;;) for (;;)
{ {
i = READUINT16(save_p); i = READUINT32(save_p);
if (i == 0xffff) if (i == 0xffffffff)
break; break;
if (i > numsectors) if (i > numsectors)
@ -1265,24 +1305,117 @@ static void UnArchiveSectors(void)
sectors[i].triggerer = READUINT8(save_p); sectors[i].triggerer = READUINT8(save_p);
if (diff4 & SD_GRAVITY) if (diff4 & SD_GRAVITY)
sectors[i].gravity = READFIXED(save_p); sectors[i].gravity = READFIXED(save_p);
if (diff4 & SD_FXSCALE)
sectors[i].floorxscale = READFIXED(save_p);
if (diff4 & SD_FYSCALE)
sectors[i].flooryscale = READFIXED(save_p);
if (diff4 & SD_CXSCALE)
sectors[i].ceilingxscale = READFIXED(save_p);
if (diff4 & SD_CYSCALE)
sectors[i].ceilingyscale = READFIXED(save_p);
if (diff & SD_FFLOORS) if (diff & SD_FFLOORS)
UnArchiveFFloors(&sectors[i]); UnArchiveFFloors(&sectors[i]);
} }
} }
static UINT32 GetSideDiff(const side_t *si, const side_t *spawnsi)
{
UINT32 diff = 0;
if (si->textureoffset != spawnsi->textureoffset)
diff |= LD_SDTEXOFFX;
if (si->rowoffset != spawnsi->rowoffset)
diff |= LD_SDTEXOFFY;
//SoM: 4/1/2000: Some textures are colormaps. Don't worry about invalid textures.
if (si->toptexture != spawnsi->toptexture)
diff |= LD_SDTOPTEX;
if (si->bottomtexture != spawnsi->bottomtexture)
diff |= LD_SDBOTTEX;
if (si->midtexture != spawnsi->midtexture)
diff |= LD_SDMIDTEX;
if (si->offsetx_top != spawnsi->offsetx_top)
diff |= LD_SDTOPOFFX;
if (si->offsetx_mid != spawnsi->offsetx_mid)
diff |= LD_SDMIDOFFX;
if (si->offsetx_bottom != spawnsi->offsetx_bottom)
diff |= LD_SDBOTOFFX;
if (si->offsety_top != spawnsi->offsety_top)
diff |= LD_SDTOPOFFY;
if (si->offsety_mid != spawnsi->offsety_mid)
diff |= LD_SDMIDOFFY;
if (si->offsety_bottom != spawnsi->offsety_bottom)
diff |= LD_SDBOTOFFY;
if (si->scalex_top != spawnsi->scalex_top)
diff |= LD_SDTOPSCALEX;
if (si->scalex_mid != spawnsi->scalex_mid)
diff |= LD_SDMIDSCALEX;
if (si->scalex_bottom != spawnsi->scalex_bottom)
diff |= LD_SDBOTSCALEX;
if (si->scaley_top != spawnsi->scaley_top)
diff |= LD_SDTOPSCALEY;
if (si->scaley_mid != spawnsi->scaley_mid)
diff |= LD_SDMIDSCALEY;
if (si->scaley_bottom != spawnsi->scaley_bottom)
diff |= LD_SDBOTSCALEY;
if (si->repeatcnt != spawnsi->repeatcnt)
diff |= LD_SDREPEATCNT;
return diff;
}
static void ArchiveSide(const side_t *si, UINT32 diff)
{
WRITEUINT32(save_p, diff);
if (diff & LD_SDTEXOFFX)
WRITEFIXED(save_p, si->textureoffset);
if (diff & LD_SDTEXOFFY)
WRITEFIXED(save_p, si->rowoffset);
if (diff & LD_SDTOPTEX)
WRITEINT32(save_p, si->toptexture);
if (diff & LD_SDBOTTEX)
WRITEINT32(save_p, si->bottomtexture);
if (diff & LD_SDMIDTEX)
WRITEINT32(save_p, si->midtexture);
if (diff & LD_SDTOPOFFX)
WRITEFIXED(save_p, si->offsetx_top);
if (diff & LD_SDMIDOFFX)
WRITEFIXED(save_p, si->offsetx_mid);
if (diff & LD_SDBOTOFFX)
WRITEFIXED(save_p, si->offsetx_bottom);
if (diff & LD_SDTOPOFFY)
WRITEFIXED(save_p, si->offsety_top);
if (diff & LD_SDMIDOFFY)
WRITEFIXED(save_p, si->offsety_mid);
if (diff & LD_SDBOTOFFY)
WRITEFIXED(save_p, si->offsety_bottom);
if (diff & LD_SDTOPSCALEX)
WRITEFIXED(save_p, si->scalex_top);
if (diff & LD_SDMIDSCALEX)
WRITEFIXED(save_p, si->scalex_mid);
if (diff & LD_SDBOTSCALEX)
WRITEFIXED(save_p, si->scalex_bottom);
if (diff & LD_SDTOPSCALEY)
WRITEFIXED(save_p, si->scaley_top);
if (diff & LD_SDMIDSCALEY)
WRITEFIXED(save_p, si->scaley_mid);
if (diff & LD_SDBOTSCALEY)
WRITEFIXED(save_p, si->scaley_bottom);
if (diff & LD_SDREPEATCNT)
WRITEINT16(save_p, si->repeatcnt);
}
static void ArchiveLines(void) static void ArchiveLines(void)
{ {
size_t i; size_t i;
const line_t *li = lines; const line_t *li = lines;
const line_t *spawnli = spawnlines; const line_t *spawnli = spawnlines;
const side_t *si; UINT8 diff;
const side_t *spawnsi; UINT32 diff2;
UINT8 diff, diff2; // no diff3 UINT32 diff3;
for (i = 0; i < numlines; i++, spawnli++, li++) for (i = 0; i < numlines; i++, spawnli++, li++)
{ {
diff = diff2 = 0; diff = diff2 = diff3 = 0;
if (li->special != spawnli->special) if (li->special != spawnli->special)
diff |= LD_SPECIAL; diff |= LD_SPECIAL;
@ -1291,84 +1424,44 @@ static void ArchiveLines(void)
diff |= LD_CLLCOUNT; diff |= LD_CLLCOUNT;
if (!P_AreArgsEqual(li, spawnli)) if (!P_AreArgsEqual(li, spawnli))
diff2 |= LD_ARGS; diff |= LD_ARGS;
if (!P_AreStringArgsEqual(li, spawnli)) if (!P_AreStringArgsEqual(li, spawnli))
diff2 |= LD_STRINGARGS; diff |= LD_STRINGARGS;
if (li->executordelay != spawnli->executordelay) if (li->executordelay != spawnli->executordelay)
diff2 |= LD_EXECUTORDELAY; diff |= LD_EXECUTORDELAY;
if (li->sidenum[0] != 0xffff) if (li->sidenum[0] != NO_SIDEDEF)
{ {
si = &sides[li->sidenum[0]]; diff2 = GetSideDiff(&sides[li->sidenum[0]], &spawnsides[li->sidenum[0]]);
spawnsi = &spawnsides[li->sidenum[0]]; if (diff2)
if (si->textureoffset != spawnsi->textureoffset) diff |= LD_SIDE1;
diff |= LD_S1TEXOFF;
//SoM: 4/1/2000: Some textures are colormaps. Don't worry about invalid textures.
if (si->toptexture != spawnsi->toptexture)
diff |= LD_S1TOPTEX;
if (si->bottomtexture != spawnsi->bottomtexture)
diff |= LD_S1BOTTEX;
if (si->midtexture != spawnsi->midtexture)
diff |= LD_S1MIDTEX;
} }
if (li->sidenum[1] != 0xffff) if (li->sidenum[1] != NO_SIDEDEF)
{ {
si = &sides[li->sidenum[1]]; diff3 = GetSideDiff(&sides[li->sidenum[1]], &spawnsides[li->sidenum[1]]);
spawnsi = &spawnsides[li->sidenum[1]]; if (diff3)
if (si->textureoffset != spawnsi->textureoffset) diff |= LD_SIDE2;
diff2 |= LD_S2TEXOFF;
if (si->toptexture != spawnsi->toptexture)
diff2 |= LD_S2TOPTEX;
if (si->bottomtexture != spawnsi->bottomtexture)
diff2 |= LD_S2BOTTEX;
if (si->midtexture != spawnsi->midtexture)
diff2 |= LD_S2MIDTEX;
} }
if (diff2)
diff |= LD_DIFF2;
if (diff) if (diff)
{ {
WRITEINT16(save_p, i); WRITEUINT32(save_p, i);
WRITEUINT8(save_p, diff); WRITEUINT8(save_p, diff);
if (diff & LD_DIFF2)
WRITEUINT8(save_p, diff2);
if (diff & LD_FLAG) if (diff & LD_FLAG)
WRITEINT16(save_p, li->flags); WRITEINT16(save_p, li->flags);
if (diff & LD_SPECIAL) if (diff & LD_SPECIAL)
WRITEINT16(save_p, li->special); WRITEINT16(save_p, li->special);
if (diff & LD_CLLCOUNT) if (diff & LD_CLLCOUNT)
WRITEINT16(save_p, li->callcount); WRITEINT16(save_p, li->callcount);
if (diff & LD_ARGS)
si = &sides[li->sidenum[0]];
if (diff & LD_S1TEXOFF)
WRITEFIXED(save_p, si->textureoffset);
if (diff & LD_S1TOPTEX)
WRITEINT32(save_p, si->toptexture);
if (diff & LD_S1BOTTEX)
WRITEINT32(save_p, si->bottomtexture);
if (diff & LD_S1MIDTEX)
WRITEINT32(save_p, si->midtexture);
si = &sides[li->sidenum[1]];
if (diff2 & LD_S2TEXOFF)
WRITEFIXED(save_p, si->textureoffset);
if (diff2 & LD_S2TOPTEX)
WRITEINT32(save_p, si->toptexture);
if (diff2 & LD_S2BOTTEX)
WRITEINT32(save_p, si->bottomtexture);
if (diff2 & LD_S2MIDTEX)
WRITEINT32(save_p, si->midtexture);
if (diff2 & LD_ARGS)
{ {
UINT8 j; UINT8 j;
for (j = 0; j < NUMLINEARGS; j++) for (j = 0; j < NUMLINEARGS; j++)
WRITEINT32(save_p, li->args[j]); WRITEINT32(save_p, li->args[j]);
} }
if (diff2 & LD_STRINGARGS) if (diff & LD_STRINGARGS)
{ {
UINT8 j; UINT8 j;
for (j = 0; j < NUMLINESTRINGARGS; j++) for (j = 0; j < NUMLINESTRINGARGS; j++)
@ -1387,25 +1480,70 @@ static void ArchiveLines(void)
WRITECHAR(save_p, li->stringargs[j][k]); WRITECHAR(save_p, li->stringargs[j][k]);
} }
} }
if (diff2 & LD_EXECUTORDELAY) if (diff & LD_EXECUTORDELAY)
WRITEINT32(save_p, li->executordelay); WRITEINT32(save_p, li->executordelay);
if (diff & LD_SIDE1)
ArchiveSide(&sides[li->sidenum[0]], diff2);
if (diff & LD_SIDE2)
ArchiveSide(&sides[li->sidenum[1]], diff3);
} }
} }
WRITEUINT16(save_p, 0xffff); WRITEUINT32(save_p, 0xffffffff);
}
static void UnArchiveSide(side_t *si)
{
UINT32 diff = READUINT32(save_p);
if (diff & LD_SDTEXOFFX)
si->textureoffset = READFIXED(save_p);
if (diff & LD_SDTEXOFFY)
si->rowoffset = READFIXED(save_p);
if (diff & LD_SDTOPTEX)
si->toptexture = READINT32(save_p);
if (diff & LD_SDBOTTEX)
si->bottomtexture = READINT32(save_p);
if (diff & LD_SDMIDTEX)
si->midtexture = READINT32(save_p);
if (diff & LD_SDTOPOFFX)
si->offsetx_top = READFIXED(save_p);
if (diff & LD_SDMIDOFFX)
si->offsetx_mid = READFIXED(save_p);
if (diff & LD_SDBOTOFFX)
si->offsetx_bottom = READFIXED(save_p);
if (diff & LD_SDTOPOFFY)
si->offsety_top = READFIXED(save_p);
if (diff & LD_SDMIDOFFY)
si->offsety_mid = READFIXED(save_p);
if (diff & LD_SDBOTOFFY)
si->offsety_bottom = READFIXED(save_p);
if (diff & LD_SDTOPSCALEX)
si->scalex_top = READFIXED(save_p);
if (diff & LD_SDMIDSCALEX)
si->scalex_mid = READFIXED(save_p);
if (diff & LD_SDBOTSCALEX)
si->scalex_bottom = READFIXED(save_p);
if (diff & LD_SDTOPSCALEY)
si->scaley_top = READFIXED(save_p);
if (diff & LD_SDMIDSCALEY)
si->scaley_mid = READFIXED(save_p);
if (diff & LD_SDBOTSCALEY)
si->scaley_bottom = READFIXED(save_p);
if (diff & LD_SDREPEATCNT)
si->repeatcnt = READINT16(save_p);
} }
static void UnArchiveLines(void) static void UnArchiveLines(void)
{ {
UINT16 i; UINT32 i;
line_t *li; line_t *li;
side_t *si; UINT8 diff;
UINT8 diff, diff2; // no diff3
for (;;) for (;;)
{ {
i = READUINT16(save_p); i = READUINT32(save_p);
if (i == 0xffff) if (i == 0xffffffff)
break; break;
if (i > numlines) if (i > numlines)
I_Error("Invalid line number %u from server", i); I_Error("Invalid line number %u from server", i);
@ -1413,44 +1551,19 @@ static void UnArchiveLines(void)
diff = READUINT8(save_p); diff = READUINT8(save_p);
li = &lines[i]; li = &lines[i];
if (diff & LD_DIFF2)
diff2 = READUINT8(save_p);
else
diff2 = 0;
if (diff & LD_FLAG) if (diff & LD_FLAG)
li->flags = READINT16(save_p); li->flags = READINT16(save_p);
if (diff & LD_SPECIAL) if (diff & LD_SPECIAL)
li->special = READINT16(save_p); li->special = READINT16(save_p);
if (diff & LD_CLLCOUNT) if (diff & LD_CLLCOUNT)
li->callcount = READINT16(save_p); li->callcount = READINT16(save_p);
if (diff & LD_ARGS)
si = &sides[li->sidenum[0]];
if (diff & LD_S1TEXOFF)
si->textureoffset = READFIXED(save_p);
if (diff & LD_S1TOPTEX)
si->toptexture = READINT32(save_p);
if (diff & LD_S1BOTTEX)
si->bottomtexture = READINT32(save_p);
if (diff & LD_S1MIDTEX)
si->midtexture = READINT32(save_p);
si = &sides[li->sidenum[1]];
if (diff2 & LD_S2TEXOFF)
si->textureoffset = READFIXED(save_p);
if (diff2 & LD_S2TOPTEX)
si->toptexture = READINT32(save_p);
if (diff2 & LD_S2BOTTEX)
si->bottomtexture = READINT32(save_p);
if (diff2 & LD_S2MIDTEX)
si->midtexture = READINT32(save_p);
if (diff2 & LD_ARGS)
{ {
UINT8 j; UINT8 j;
for (j = 0; j < NUMLINEARGS; j++) for (j = 0; j < NUMLINEARGS; j++)
li->args[j] = READINT32(save_p); li->args[j] = READINT32(save_p);
} }
if (diff2 & LD_STRINGARGS) if (diff & LD_STRINGARGS)
{ {
UINT8 j; UINT8 j;
for (j = 0; j < NUMLINESTRINGARGS; j++) for (j = 0; j < NUMLINESTRINGARGS; j++)
@ -1471,9 +1584,12 @@ static void UnArchiveLines(void)
li->stringargs[j][len] = '\0'; li->stringargs[j][len] = '\0';
} }
} }
if (diff2 & LD_EXECUTORDELAY) if (diff & LD_EXECUTORDELAY)
li->executordelay = READINT32(save_p); li->executordelay = READINT32(save_p);
if (diff & LD_SIDE1)
UnArchiveSide(&sides[li->sidenum[0]]);
if (diff & LD_SIDE2)
UnArchiveSide(&sides[li->sidenum[1]]);
} }
} }

View file

@ -18,7 +18,7 @@
#pragma interface #pragma interface
#endif #endif
#define NEWSKINSAVES (INT16_MAX) // Purely for backwards compatibility, remove this for 2.3 #define NEWSKINSAVES (INT16_MAX) // TODO: 2.3: Delete (Purely for backwards compatibility)
// Persistent storage/archiving. // Persistent storage/archiving.
// These are the load / save game routines. // These are the load / save game routines.

View file

@ -1055,6 +1055,9 @@ static void P_LoadSectors(UINT8 *data)
ss->floorxoffset = ss->flooryoffset = 0; ss->floorxoffset = ss->flooryoffset = 0;
ss->ceilingxoffset = ss->ceilingyoffset = 0; ss->ceilingxoffset = ss->ceilingyoffset = 0;
ss->floorxscale = ss->flooryscale = FRACUNIT;
ss->ceilingxscale = ss->ceilingyscale = FRACUNIT;
ss->floorangle = ss->ceilingangle = 0; ss->floorangle = ss->ceilingangle = 0;
ss->floorlightlevel = ss->ceilinglightlevel = 0; ss->floorlightlevel = ss->ceilinglightlevel = 0;
@ -1111,40 +1114,40 @@ static void P_InitializeLinedef(line_t *ld)
// cph 2006/09/30 - fix sidedef errors right away. // cph 2006/09/30 - fix sidedef errors right away.
// cph 2002/07/20 - these errors are fatal if not fixed, so apply them // cph 2002/07/20 - these errors are fatal if not fixed, so apply them
for (j = 0; j < 2; j++) for (j = 0; j < 2; j++)
if (ld->sidenum[j] != 0xffff && ld->sidenum[j] >= (UINT16)numsides) if (ld->sidenum[j] != NO_SIDEDEF && ld->sidenum[j] >= (UINT32)numsides)
{ {
ld->sidenum[j] = 0xffff; ld->sidenum[j] = NO_SIDEDEF;
CONS_Debug(DBG_SETUP, "P_InitializeLinedef: Linedef %s has out-of-range sidedef number\n", sizeu1((size_t)(ld - lines))); CONS_Debug(DBG_SETUP, "P_InitializeLinedef: Linedef %s has out-of-range sidedef number\n", sizeu1((size_t)(ld - lines)));
} }
// killough 11/98: fix common wad errors (missing sidedefs): // killough 11/98: fix common wad errors (missing sidedefs):
if (ld->sidenum[0] == 0xffff) if (ld->sidenum[0] == NO_SIDEDEF)
{ {
ld->sidenum[0] = 0; // Substitute dummy sidedef for missing right side ld->sidenum[0] = 0; // Substitute dummy sidedef for missing right side
// cph - print a warning about the bug // cph - print a warning about the bug
CONS_Debug(DBG_SETUP, "P_InitializeLinedef: Linedef %s missing first sidedef\n", sizeu1((size_t)(ld - lines))); CONS_Debug(DBG_SETUP, "P_InitializeLinedef: Linedef %s missing first sidedef\n", sizeu1((size_t)(ld - lines)));
} }
if ((ld->sidenum[1] == 0xffff) && (ld->flags & ML_TWOSIDED)) if ((ld->sidenum[1] == NO_SIDEDEF) && (ld->flags & ML_TWOSIDED))
{ {
ld->flags &= ~ML_TWOSIDED; // Clear 2s flag for missing left side ld->flags &= ~ML_TWOSIDED; // Clear 2s flag for missing left side
// cph - print a warning about the bug // cph - print a warning about the bug
CONS_Debug(DBG_SETUP, "P_InitializeLinedef: Linedef %s has two-sided flag set, but no second sidedef\n", sizeu1((size_t)(ld - lines))); CONS_Debug(DBG_SETUP, "P_InitializeLinedef: Linedef %s has two-sided flag set, but no second sidedef\n", sizeu1((size_t)(ld - lines)));
} }
if (ld->sidenum[0] != 0xffff) if (ld->sidenum[0] != NO_SIDEDEF)
{ {
sides[ld->sidenum[0]].special = ld->special; sides[ld->sidenum[0]].special = ld->special;
sides[ld->sidenum[0]].line = ld; sides[ld->sidenum[0]].line = ld;
} }
if (ld->sidenum[1] != 0xffff) if (ld->sidenum[1] != NO_SIDEDEF)
{ {
sides[ld->sidenum[1]].special = ld->special; sides[ld->sidenum[1]].special = ld->special;
sides[ld->sidenum[1]].line = ld; sides[ld->sidenum[1]].line = ld;
} }
} }
static void P_SetLinedefV1(size_t i, UINT16 vertex_num) static void P_SetLinedefV1(size_t i, UINT32 vertex_num)
{ {
if (vertex_num >= numvertexes) if (vertex_num >= numvertexes)
{ {
@ -1154,7 +1157,7 @@ static void P_SetLinedefV1(size_t i, UINT16 vertex_num)
lines[i].v1 = &vertexes[vertex_num]; lines[i].v1 = &vertexes[vertex_num];
} }
static void P_SetLinedefV2(size_t i, UINT16 vertex_num) static void P_SetLinedefV2(size_t i, UINT32 vertex_num)
{ {
if (vertex_num >= numvertexes) if (vertex_num >= numvertexes)
{ {
@ -1179,17 +1182,22 @@ static void P_LoadLinedefs(UINT8 *data)
memset(ld->stringargs, 0x00, NUMLINESTRINGARGS*sizeof(*ld->stringargs)); memset(ld->stringargs, 0x00, NUMLINESTRINGARGS*sizeof(*ld->stringargs));
ld->alpha = FRACUNIT; ld->alpha = FRACUNIT;
ld->executordelay = 0; ld->executordelay = 0;
P_SetLinedefV1(i, SHORT(mld->v1)); P_SetLinedefV1(i, (UINT16)SHORT(mld->v1));
P_SetLinedefV2(i, SHORT(mld->v2)); P_SetLinedefV2(i, (UINT16)SHORT(mld->v2));
ld->sidenum[0] = SHORT(mld->sidenum[0]); ld->sidenum[0] = (UINT16)SHORT(mld->sidenum[0]);
ld->sidenum[1] = SHORT(mld->sidenum[1]); ld->sidenum[1] = (UINT16)SHORT(mld->sidenum[1]);
if (ld->sidenum[0] == 0xffff)
ld->sidenum[0] = NO_SIDEDEF;
if (ld->sidenum[1] == 0xffff)
ld->sidenum[1] = NO_SIDEDEF;
P_InitializeLinedef(ld); P_InitializeLinedef(ld);
} }
} }
static void P_SetSidedefSector(size_t i, UINT16 sector_num) static void P_SetSidedefSector(size_t i, UINT32 sector_num)
{ {
// cph 2006/09/30 - catch out-of-range sector numbers; use sector 0 instead // cph 2006/09/30 - catch out-of-range sector numbers; use sector 0 instead
if (sector_num >= numsectors) if (sector_num >= numsectors)
@ -1347,10 +1355,13 @@ static void P_LoadSidedefs(UINT8 *data)
} }
sd->rowoffset = SHORT(msd->rowoffset)<<FRACBITS; sd->rowoffset = SHORT(msd->rowoffset)<<FRACBITS;
sd->offsetx_top = sd->offsetx_mid = sd->offsetx_bot = 0; sd->offsetx_top = sd->offsetx_mid = sd->offsetx_bottom = 0;
sd->offsety_top = sd->offsety_mid = sd->offsety_bot = 0; sd->offsety_top = sd->offsety_mid = sd->offsety_bottom = 0;
P_SetSidedefSector(i, SHORT(msd->sector)); sd->scalex_top = sd->scalex_mid = sd->scalex_bottom = FRACUNIT;
sd->scaley_top = sd->scaley_mid = sd->scaley_bottom = FRACUNIT;
P_SetSidedefSector(i, (UINT16)SHORT(msd->sector));
// Special info stored in texture fields! // Special info stored in texture fields!
switch (sd->special) switch (sd->special)
@ -1688,6 +1699,14 @@ static void ParseTextmapSectorParameter(UINT32 i, const char *param, const char
sectors[i].ceilingxoffset = FLOAT_TO_FIXED(atof(val)); sectors[i].ceilingxoffset = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "ypanningceiling")) else if (fastcmp(param, "ypanningceiling"))
sectors[i].ceilingyoffset = FLOAT_TO_FIXED(atof(val)); sectors[i].ceilingyoffset = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "xscalefloor"))
sectors[i].floorxscale = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "yscalefloor"))
sectors[i].flooryscale = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "xscaleceiling"))
sectors[i].ceilingxscale = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "yscaleceiling"))
sectors[i].ceilingyscale = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "rotationfloor")) else if (fastcmp(param, "rotationfloor"))
sectors[i].floorangle = FixedAngle(FLOAT_TO_FIXED(atof(val))); sectors[i].floorangle = FixedAngle(FLOAT_TO_FIXED(atof(val)));
else if (fastcmp(param, "rotationceiling")) else if (fastcmp(param, "rotationceiling"))
@ -1883,13 +1902,25 @@ static void ParseTextmapSidedefParameter(UINT32 i, const char *param, const char
else if (fastcmp(param, "offsetx_mid")) else if (fastcmp(param, "offsetx_mid"))
sides[i].offsetx_mid = atol(val) << FRACBITS; sides[i].offsetx_mid = atol(val) << FRACBITS;
else if (fastcmp(param, "offsetx_bottom")) else if (fastcmp(param, "offsetx_bottom"))
sides[i].offsetx_bot = atol(val) << FRACBITS; sides[i].offsetx_bottom = atol(val) << FRACBITS;
else if (fastcmp(param, "offsety_top")) else if (fastcmp(param, "offsety_top"))
sides[i].offsety_top = atol(val) << FRACBITS; sides[i].offsety_top = atol(val) << FRACBITS;
else if (fastcmp(param, "offsety_mid")) else if (fastcmp(param, "offsety_mid"))
sides[i].offsety_mid = atol(val) << FRACBITS; sides[i].offsety_mid = atol(val) << FRACBITS;
else if (fastcmp(param, "offsety_bottom")) else if (fastcmp(param, "offsety_bottom"))
sides[i].offsety_bot = atol(val) << FRACBITS; sides[i].offsety_bottom = atol(val) << FRACBITS;
else if (fastcmp(param, "scalex_top"))
sides[i].scalex_top = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "scalex_mid"))
sides[i].scalex_mid = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "scalex_bottom"))
sides[i].scalex_bottom = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "scaley_top"))
sides[i].scaley_top = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "scaley_mid"))
sides[i].scaley_mid = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "scaley_bottom"))
sides[i].scaley_bottom = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "texturetop")) else if (fastcmp(param, "texturetop"))
sides[i].toptexture = R_TextureNumForName(val); sides[i].toptexture = R_TextureNumForName(val);
else if (fastcmp(param, "texturebottom")) else if (fastcmp(param, "texturebottom"))
@ -2489,7 +2520,7 @@ static void P_WriteTextmap(void)
fprintf(f, "v1 = %s;\n", sizeu1(wlines[i].v1 - vertexes)); fprintf(f, "v1 = %s;\n", sizeu1(wlines[i].v1 - vertexes));
fprintf(f, "v2 = %s;\n", sizeu1(wlines[i].v2 - vertexes)); fprintf(f, "v2 = %s;\n", sizeu1(wlines[i].v2 - vertexes));
fprintf(f, "sidefront = %d;\n", wlines[i].sidenum[0]); fprintf(f, "sidefront = %d;\n", wlines[i].sidenum[0]);
if (wlines[i].sidenum[1] != 0xffff) if (wlines[i].sidenum[1] != NO_SIDEDEF)
fprintf(f, "sideback = %d;\n", wlines[i].sidenum[1]); fprintf(f, "sideback = %d;\n", wlines[i].sidenum[1]);
firsttag = Tag_FGet(&wlines[i].tags); firsttag = Tag_FGet(&wlines[i].tags);
if (firsttag != 0) if (firsttag != 0)
@ -2594,10 +2625,22 @@ static void P_WriteTextmap(void)
fprintf(f, "offsetx_mid = %d;\n", wsides[i].offsetx_mid >> FRACBITS); fprintf(f, "offsetx_mid = %d;\n", wsides[i].offsetx_mid >> FRACBITS);
if (wsides[i].offsety_mid != 0) if (wsides[i].offsety_mid != 0)
fprintf(f, "offsety_mid = %d;\n", wsides[i].offsety_mid >> FRACBITS); fprintf(f, "offsety_mid = %d;\n", wsides[i].offsety_mid >> FRACBITS);
if (wsides[i].offsetx_bot != 0) if (wsides[i].offsetx_bottom != 0)
fprintf(f, "offsetx_bottom = %d;\n", wsides[i].offsetx_bot >> FRACBITS); fprintf(f, "offsetx_bottom = %d;\n", wsides[i].offsetx_bottom >> FRACBITS);
if (wsides[i].offsety_bot != 0) if (wsides[i].offsety_bottom != 0)
fprintf(f, "offsety_bottom = %d;\n", wsides[i].offsety_bot >> FRACBITS); fprintf(f, "offsety_bottom = %d;\n", wsides[i].offsety_bottom >> FRACBITS);
if (wsides[i].scalex_top != FRACUNIT)
fprintf(f, "scalex_top = %f;\n", FIXED_TO_FLOAT(wsides[i].scalex_top));
if (wsides[i].scaley_top != FRACUNIT)
fprintf(f, "scaley_top = %f;\n", FIXED_TO_FLOAT(wsides[i].scaley_top));
if (wsides[i].scalex_mid != FRACUNIT)
fprintf(f, "scalex_mid = %f;\n", FIXED_TO_FLOAT(wsides[i].scalex_mid));
if (wsides[i].scaley_mid != FRACUNIT)
fprintf(f, "scaley_mid = %f;\n", FIXED_TO_FLOAT(wsides[i].scaley_mid));
if (wsides[i].scalex_bottom != FRACUNIT)
fprintf(f, "scalex_bottom = %f;\n", FIXED_TO_FLOAT(wsides[i].scalex_bottom));
if (wsides[i].scaley_bottom != FRACUNIT)
fprintf(f, "scaley_bottom = %f;\n", FIXED_TO_FLOAT(wsides[i].scaley_bottom));
if (wsides[i].toptexture > 0 && wsides[i].toptexture < numtextures) if (wsides[i].toptexture > 0 && wsides[i].toptexture < numtextures)
fprintf(f, "texturetop = \"%.*s\";\n", 8, textures[wsides[i].toptexture]->name); fprintf(f, "texturetop = \"%.*s\";\n", 8, textures[wsides[i].toptexture]->name);
if (wsides[i].bottomtexture > 0 && wsides[i].bottomtexture < numtextures) if (wsides[i].bottomtexture > 0 && wsides[i].bottomtexture < numtextures)
@ -2653,6 +2696,14 @@ static void P_WriteTextmap(void)
fprintf(f, "xpanningceiling = %f;\n", FIXED_TO_FLOAT(tempsec.ceilingxoffset)); fprintf(f, "xpanningceiling = %f;\n", FIXED_TO_FLOAT(tempsec.ceilingxoffset));
if (tempsec.ceilingyoffset != 0) if (tempsec.ceilingyoffset != 0)
fprintf(f, "ypanningceiling = %f;\n", FIXED_TO_FLOAT(tempsec.ceilingyoffset)); fprintf(f, "ypanningceiling = %f;\n", FIXED_TO_FLOAT(tempsec.ceilingyoffset));
if (tempsec.floorxscale != 0)
fprintf(f, "xscalefloor = %f;\n", FIXED_TO_FLOAT(tempsec.floorxscale));
if (tempsec.flooryscale != 0)
fprintf(f, "yscalefloor = %f;\n", FIXED_TO_FLOAT(tempsec.flooryscale));
if (tempsec.ceilingxscale != 0)
fprintf(f, "xscaleceiling = %f;\n", FIXED_TO_FLOAT(tempsec.ceilingxscale));
if (tempsec.ceilingyscale != 0)
fprintf(f, "yscaleceiling = %f;\n", FIXED_TO_FLOAT(tempsec.ceilingyscale));
if (wsectors[i].floorangle != 0) if (wsectors[i].floorangle != 0)
fprintf(f, "rotationfloor = %f;\n", FIXED_TO_FLOAT(AngleFixed(wsectors[i].floorangle))); fprintf(f, "rotationfloor = %f;\n", FIXED_TO_FLOAT(AngleFixed(wsectors[i].floorangle)));
if (wsectors[i].ceilingangle != 0) if (wsectors[i].ceilingangle != 0)
@ -2888,6 +2939,9 @@ static void P_LoadTextmap(void)
sc->floorxoffset = sc->flooryoffset = 0; sc->floorxoffset = sc->flooryoffset = 0;
sc->ceilingxoffset = sc->ceilingyoffset = 0; sc->ceilingxoffset = sc->ceilingyoffset = 0;
sc->floorxscale = sc->flooryscale = FRACUNIT;
sc->ceilingxscale = sc->ceilingyscale = FRACUNIT;
sc->floorangle = sc->ceilingangle = 0; sc->floorangle = sc->ceilingangle = 0;
sc->floorlightlevel = sc->ceilinglightlevel = 0; sc->floorlightlevel = sc->ceilinglightlevel = 0;
@ -2922,22 +2976,26 @@ static void P_LoadTextmap(void)
P_InitializeSector(sc); P_InitializeSector(sc);
if (textmap_colormap.used) if (textmap_colormap.used)
{ {
INT32 rgba = P_ColorToRGBA(textmap_colormap.lightcolor, textmap_colormap.lightalpha); // Convert alpha values from old 0-25 (A-Z) range to 0-255 range
INT32 fadergba = P_ColorToRGBA(textmap_colormap.fadecolor, textmap_colormap.fadealpha); UINT8 lightalpha = (textmap_colormap.lightalpha * 102) / 10;
UINT8 fadealpha = (textmap_colormap.fadealpha * 102) / 10;
INT32 rgba = P_ColorToRGBA(textmap_colormap.lightcolor, lightalpha);
INT32 fadergba = P_ColorToRGBA(textmap_colormap.fadecolor, fadealpha);
sc->extra_colormap = sc->spawn_extra_colormap = R_CreateColormap(rgba, fadergba, textmap_colormap.fadestart, textmap_colormap.fadeend, textmap_colormap.flags); sc->extra_colormap = sc->spawn_extra_colormap = R_CreateColormap(rgba, fadergba, textmap_colormap.fadestart, textmap_colormap.fadeend, textmap_colormap.flags);
} }
if (textmap_planefloor.defined == (PD_A|PD_B|PD_C|PD_D)) if (textmap_planefloor.defined == (PD_A|PD_B|PD_C|PD_D))
{ {
sc->f_slope = MakeViaEquationConstants(textmap_planefloor.a, textmap_planefloor.b, textmap_planefloor.c, textmap_planefloor.d); sc->f_slope = MakeViaEquationConstants(textmap_planefloor.a, textmap_planefloor.b, textmap_planefloor.c, textmap_planefloor.d);
sc->hasslope = true; sc->hasslope = true;
} }
if (textmap_planeceiling.defined == (PD_A|PD_B|PD_C|PD_D)) if (textmap_planeceiling.defined == (PD_A|PD_B|PD_C|PD_D))
{ {
sc->c_slope = MakeViaEquationConstants(textmap_planeceiling.a, textmap_planeceiling.b, textmap_planeceiling.c, textmap_planeceiling.d); sc->c_slope = MakeViaEquationConstants(textmap_planeceiling.a, textmap_planeceiling.b, textmap_planeceiling.c, textmap_planeceiling.d);
sc->hasslope = true; sc->hasslope = true;
} }
TextmapFixFlatOffsets(sc); TextmapFixFlatOffsets(sc);
} }
@ -2954,8 +3012,8 @@ static void P_LoadTextmap(void)
memset(ld->stringargs, 0x00, NUMLINESTRINGARGS*sizeof(*ld->stringargs)); memset(ld->stringargs, 0x00, NUMLINESTRINGARGS*sizeof(*ld->stringargs));
ld->alpha = FRACUNIT; ld->alpha = FRACUNIT;
ld->executordelay = 0; ld->executordelay = 0;
ld->sidenum[0] = 0xffff; ld->sidenum[0] = NO_SIDEDEF;
ld->sidenum[1] = 0xffff; ld->sidenum[1] = NO_SIDEDEF;
TextmapParse(linesPos[i], i, ParseTextmapLinedefParameter); TextmapParse(linesPos[i], i, ParseTextmapLinedefParameter);
@ -2963,7 +3021,7 @@ static void P_LoadTextmap(void)
I_Error("P_LoadTextmap: linedef %s has no v1 value set!\n", sizeu1(i)); I_Error("P_LoadTextmap: linedef %s has no v1 value set!\n", sizeu1(i));
if (!ld->v2) if (!ld->v2)
I_Error("P_LoadTextmap: linedef %s has no v2 value set!\n", sizeu1(i)); I_Error("P_LoadTextmap: linedef %s has no v2 value set!\n", sizeu1(i));
if (ld->sidenum[0] == 0xffff) if (ld->sidenum[0] == NO_SIDEDEF)
I_Error("P_LoadTextmap: linedef %s has no sidefront value set!\n", sizeu1(i)); I_Error("P_LoadTextmap: linedef %s has no sidefront value set!\n", sizeu1(i));
P_InitializeLinedef(ld); P_InitializeLinedef(ld);
@ -2974,8 +3032,10 @@ static void P_LoadTextmap(void)
// Defaults. // Defaults.
sd->textureoffset = 0; sd->textureoffset = 0;
sd->rowoffset = 0; sd->rowoffset = 0;
sd->offsetx_top = sd->offsetx_mid = sd->offsetx_bot = 0; sd->offsetx_top = sd->offsetx_mid = sd->offsetx_bottom = 0;
sd->offsety_top = sd->offsety_mid = sd->offsety_bot = 0; sd->offsety_top = sd->offsety_mid = sd->offsety_bottom = 0;
sd->scalex_top = sd->scalex_mid = sd->scalex_bottom = FRACUNIT;
sd->scaley_top = sd->scaley_mid = sd->scaley_bottom = FRACUNIT;
sd->toptexture = R_TextureNumForName("-"); sd->toptexture = R_TextureNumForName("-");
sd->midtexture = R_TextureNumForName("-"); sd->midtexture = R_TextureNumForName("-");
sd->bottomtexture = R_TextureNumForName("-"); sd->bottomtexture = R_TextureNumForName("-");
@ -3017,7 +3077,7 @@ static void P_ProcessLinedefsAfterSidedefs(void)
for (; i--; ld++) for (; i--; ld++)
{ {
ld->frontsector = sides[ld->sidenum[0]].sector; //e6y: Can't be -1 here ld->frontsector = sides[ld->sidenum[0]].sector; //e6y: Can't be -1 here
ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : 0; ld->backsector = ld->sidenum[1] != NO_SIDEDEF ? sides[ld->sidenum[1]].sector : 0;
if (udmf) if (udmf)
continue; continue;
@ -3256,10 +3316,10 @@ static void P_InitializeSeg(seg_t *seg)
{ {
if (seg->linedef) if (seg->linedef)
{ {
UINT16 side = seg->linedef->sidenum[seg->side]; UINT32 side = seg->linedef->sidenum[seg->side];
if (side == 0xffff) if (side == NO_SIDEDEF)
I_Error("P_InitializeSeg: Seg %s refers to side %d of linedef %s, which doesn't exist!\n", sizeu1((size_t)(seg - segs)), seg->side, sizeu1((size_t)(seg->linedef - lines))); I_Error("P_InitializeSeg: Seg %s refers to side %d of linedef %s, which doesn't exist!\n", sizeu1((size_t)(seg - segs)), seg->side, sizeu2((size_t)(seg->linedef - lines)));
seg->sidedef = &sides[side]; seg->sidedef = &sides[side];
@ -3301,7 +3361,7 @@ static void P_LoadSegs(UINT8 *data)
seg->length = P_SegLength(seg); seg->length = P_SegLength(seg);
#ifdef HWRENDER #ifdef HWRENDER
seg->flength = (rendermode == render_opengl) ? P_SegLengthFloat(seg) : 0; seg->flength = P_SegLengthFloat(seg);
#endif #endif
seg->glseg = false; seg->glseg = false;
@ -3443,7 +3503,7 @@ static boolean P_LoadExtraVertices(UINT8 **data)
static boolean P_LoadExtendedSubsectorsAndSegs(UINT8 **data, nodetype_t nodetype) static boolean P_LoadExtendedSubsectorsAndSegs(UINT8 **data, nodetype_t nodetype)
{ {
size_t i, k; size_t i, k;
INT16 m; size_t m;
seg_t *seg; seg_t *seg;
// Subsectors // Subsectors
@ -3466,23 +3526,33 @@ static boolean P_LoadExtendedSubsectorsAndSegs(UINT8 **data, nodetype_t nodetype
{ {
case NT_XGLN: case NT_XGLN:
case NT_XGL3: case NT_XGL3:
for (m = 0; m < subsectors[i].numlines; m++, k++) for (m = 0; m < (size_t)subsectors[i].numlines; m++, k++)
{ {
UINT32 vertexnum = READUINT32((*data)); UINT32 vertexnum = READUINT32((*data));
UINT16 linenum;
if (vertexnum >= numvertexes) if (vertexnum >= numvertexes)
I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %d has invalid vertex %d!\n", sizeu1(k), m, vertexnum); I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %s has invalid vertex %d!\n", sizeu1(k), sizeu2(m), vertexnum);
segs[k - 1 + ((m == 0) ? subsectors[i].numlines : 0)].v2 = segs[k].v1 = &vertexes[vertexnum]; segs[k - 1 + ((m == 0) ? subsectors[i].numlines : 0)].v2 = segs[k].v1 = &vertexes[vertexnum];
READUINT32((*data)); // partner, can be ignored by software renderer READUINT32((*data)); // partner, can be ignored by software renderer
linenum = (nodetype == NT_XGL3) ? READUINT32((*data)) : READUINT16((*data)); if (nodetype == NT_XGL3)
if (linenum != 0xFFFF && linenum >= numlines) {
I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %s has invalid linedef %d!\n", sizeu1(k), sizeu2(i), linenum); UINT32 linenum = READUINT32((*data));
segs[k].glseg = (linenum == 0xFFFF); if (linenum != 0xFFFFFFFF && linenum >= numlines)
segs[k].linedef = (linenum == 0xFFFF) ? NULL : &lines[linenum]; I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %s has invalid linedef %d!\n", sizeu1(k), sizeu2(i), linenum);
segs[k].glseg = linenum == 0xFFFFFFFF;
segs[k].linedef = linenum == 0xFFFFFFFF ? NULL : &lines[linenum];
}
else
{
UINT16 linenum = READUINT16((*data));
if (linenum != 0xFFFF && linenum >= numlines)
I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %s has invalid linedef %d!\n", sizeu1(k), sizeu2(i), linenum);
segs[k].glseg = linenum == 0xFFFF;
segs[k].linedef = linenum == 0xFFFF ? NULL : &lines[linenum];
}
segs[k].side = READUINT8((*data)); segs[k].side = READUINT8((*data));
} }
while (segs[subsectors[i].firstline].glseg) while (segs[subsectors[i].firstline].glseg)
@ -3494,18 +3564,18 @@ static boolean P_LoadExtendedSubsectorsAndSegs(UINT8 **data, nodetype_t nodetype
break; break;
case NT_XNOD: case NT_XNOD:
for (m = 0; m < subsectors[i].numlines; m++, k++) for (m = 0; m < (size_t)subsectors[i].numlines; m++, k++)
{ {
UINT32 v1num = READUINT32((*data)); UINT32 v1num = READUINT32((*data));
UINT32 v2num = READUINT32((*data)); UINT32 v2num = READUINT32((*data));
UINT16 linenum = READUINT16((*data)); UINT16 linenum = READUINT16((*data));
if (v1num >= numvertexes) if (v1num >= numvertexes)
I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %d has invalid v1 %d!\n", sizeu1(k), m, v1num); I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %s has invalid v1 %d!\n", sizeu1(k), sizeu2(m), v1num);
if (v2num >= numvertexes) if (v2num >= numvertexes)
I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %d has invalid v2 %d!\n", sizeu1(k), m, v2num); I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %s has invalid v2 %d!\n", sizeu1(k), sizeu2(m), v2num);
if (linenum >= numlines) if (linenum >= numlines)
I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %d has invalid linedef %d!\n", sizeu1(k), m, linenum); I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %s has invalid linedef %d!\n", sizeu1(k), sizeu2(m), linenum);
segs[k].v1 = &vertexes[v1num]; segs[k].v1 = &vertexes[v1num];
segs[k].v2 = &vertexes[v2num]; segs[k].v2 = &vertexes[v2num];
@ -3533,7 +3603,7 @@ static boolean P_LoadExtendedSubsectorsAndSegs(UINT8 **data, nodetype_t nodetype
} }
seg->length = P_SegLength(seg); seg->length = P_SegLength(seg);
#ifdef HWRENDER #ifdef HWRENDER
seg->flength = (rendermode == render_opengl) ? P_SegLengthFloat(seg) : 0; seg->flength = P_SegLengthFloat(seg);
#endif #endif
} }
@ -3990,14 +4060,14 @@ static void P_LinkMapData(void)
if (!seg->sidedef) if (!seg->sidedef)
CorruptMapError(va("P_LinkMapData: seg->sidedef is NULL " CorruptMapError(va("P_LinkMapData: seg->sidedef is NULL "
"(subsector %s, firstline is %d)", sizeu1(i), ss->firstline)); "(subsector %s, firstline is %d)", sizeu1(i), ss->firstline));
if (seg->sidedef - sides < 0 || seg->sidedef - sides > (UINT16)numsides) if (seg->sidedef - sides < 0 || sidei > numsides)
CorruptMapError(va("P_LinkMapData: seg->sidedef refers to sidedef %s of %s " CorruptMapError(va("P_LinkMapData: seg->sidedef refers to sidedef %s of %s "
"(subsector %s, firstline is %d)", sizeu1(sidei), sizeu2(numsides), "(subsector %s, firstline is %d)", sizeu1(sidei), sizeu2(numsides),
sizeu3(i), ss->firstline)); sizeu3(i), ss->firstline));
if (!seg->sidedef->sector) if (!seg->sidedef->sector)
CorruptMapError(va("P_LinkMapData: seg->sidedef->sector is NULL " CorruptMapError(va("P_LinkMapData: seg->sidedef->sector is NULL "
"(subsector %s, firstline is %d, sidedef is %s)", sizeu1(i), ss->firstline, "(subsector %s, firstline is %d, sidedef is %s)", sizeu1(i), ss->firstline,
sizeu1(sidei))); sizeu2(sidei)));
ss->sector = seg->sidedef->sector; ss->sector = seg->sidedef->sector;
} }
@ -4915,7 +4985,7 @@ static void P_ConvertBinaryLinedefTypes(void)
break; break;
case 259: //Custom FOF case 259: //Custom FOF
if (lines[i].sidenum[1] == 0xffff) if (lines[i].sidenum[1] == NO_SIDEDEF)
I_Error("Custom FOF (tag %d) found without a linedef back side!", tag); I_Error("Custom FOF (tag %d) found without a linedef back side!", tag);
lines[i].args[0] = tag; lines[i].args[0] = tag;
@ -5269,8 +5339,8 @@ static void P_ConvertBinaryLinedefTypes(void)
lines[i].args[1] = sides[lines[i].sidenum[0]].midtexture; lines[i].args[1] = sides[lines[i].sidenum[0]].midtexture;
lines[i].args[2] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS; lines[i].args[2] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS;
lines[i].args[3] = sides[lines[i].sidenum[0]].rowoffset >> FRACBITS; lines[i].args[3] = sides[lines[i].sidenum[0]].rowoffset >> FRACBITS;
lines[i].args[4] = (lines[i].sidenum[1] != 0xffff) ? sides[lines[i].sidenum[1]].textureoffset >> FRACBITS : 0; lines[i].args[4] = (lines[i].sidenum[1] != NO_SIDEDEF) ? sides[lines[i].sidenum[1]].textureoffset >> FRACBITS : 0;
lines[i].args[5] = (lines[i].sidenum[1] != 0xffff) ? sides[lines[i].sidenum[1]].rowoffset >> FRACBITS : -1; lines[i].args[5] = (lines[i].sidenum[1] != NO_SIDEDEF) ? sides[lines[i].sidenum[1]].rowoffset >> FRACBITS : -1;
lines[i].args[6] = sides[lines[i].sidenum[0]].bottomtexture; lines[i].args[6] = sides[lines[i].sidenum[0]].bottomtexture;
break; break;
case 414: //Play sound effect case 414: //Play sound effect
@ -5374,7 +5444,7 @@ static void P_ConvertBinaryLinedefTypes(void)
lines[i].args[1] = max(sides[lines[i].sidenum[0]].textureoffset >> FRACBITS, 0); lines[i].args[1] = max(sides[lines[i].sidenum[0]].textureoffset >> FRACBITS, 0);
// failsafe: if user specifies Back Y Offset and NOT Front Y Offset, use the Back Offset // failsafe: if user specifies Back Y Offset and NOT Front Y Offset, use the Back Offset
// to be consistent with other light and fade specials // to be consistent with other light and fade specials
lines[i].args[2] = ((lines[i].sidenum[1] != 0xFFFF && !(sides[lines[i].sidenum[0]].rowoffset >> FRACBITS)) ? lines[i].args[2] = ((lines[i].sidenum[1] != NO_SIDEDEF && !(sides[lines[i].sidenum[0]].rowoffset >> FRACBITS)) ?
max(min(sides[lines[i].sidenum[1]].rowoffset >> FRACBITS, 255), 0) max(min(sides[lines[i].sidenum[1]].rowoffset >> FRACBITS, 255), 0)
: max(min(sides[lines[i].sidenum[0]].rowoffset >> FRACBITS, 255), 0)); : max(min(sides[lines[i].sidenum[0]].rowoffset >> FRACBITS, 255), 0));
} }
@ -5479,7 +5549,7 @@ static void P_ConvertBinaryLinedefTypes(void)
break; break;
case 442: //Change object type state case 442: //Change object type state
lines[i].args[0] = tag; lines[i].args[0] = tag;
lines[i].args[1] = (lines[i].sidenum[1] == 0xffff) ? 1 : 0; lines[i].args[1] = (lines[i].sidenum[1] == NO_SIDEDEF) ? 1 : 0;
break; break;
case 443: //Call Lua function case 443: //Call Lua function
if (lines[i].stringargs[0] == NULL) if (lines[i].stringargs[0] == NULL)
@ -5547,7 +5617,7 @@ static void P_ConvertBinaryLinedefTypes(void)
case 452: //Set FOF translucency case 452: //Set FOF translucency
lines[i].args[0] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS; lines[i].args[0] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS;
lines[i].args[1] = sides[lines[i].sidenum[0]].rowoffset >> FRACBITS; lines[i].args[1] = sides[lines[i].sidenum[0]].rowoffset >> FRACBITS;
lines[i].args[2] = lines[i].sidenum[1] != 0xffff ? (sides[lines[i].sidenum[1]].textureoffset >> FRACBITS) : (P_AproxDistance(lines[i].dx, lines[i].dy) >> FRACBITS); lines[i].args[2] = lines[i].sidenum[1] != NO_SIDEDEF ? (sides[lines[i].sidenum[1]].textureoffset >> FRACBITS) : (P_AproxDistance(lines[i].dx, lines[i].dy) >> FRACBITS);
if (lines[i].flags & ML_MIDPEG) if (lines[i].flags & ML_MIDPEG)
lines[i].args[3] |= TMST_RELATIVE; lines[i].args[3] |= TMST_RELATIVE;
if (lines[i].flags & ML_NOCLIMB) if (lines[i].flags & ML_NOCLIMB)
@ -5556,8 +5626,8 @@ static void P_ConvertBinaryLinedefTypes(void)
case 453: //Fade FOF case 453: //Fade FOF
lines[i].args[0] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS; lines[i].args[0] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS;
lines[i].args[1] = sides[lines[i].sidenum[0]].rowoffset >> FRACBITS; lines[i].args[1] = sides[lines[i].sidenum[0]].rowoffset >> FRACBITS;
lines[i].args[2] = lines[i].sidenum[1] != 0xffff ? (sides[lines[i].sidenum[1]].textureoffset >> FRACBITS) : (lines[i].dx >> FRACBITS); lines[i].args[2] = lines[i].sidenum[1] != NO_SIDEDEF ? (sides[lines[i].sidenum[1]].textureoffset >> FRACBITS) : (lines[i].dx >> FRACBITS);
lines[i].args[3] = lines[i].sidenum[1] != 0xffff ? (sides[lines[i].sidenum[1]].rowoffset >> FRACBITS) : (abs(lines[i].dy) >> FRACBITS); lines[i].args[3] = lines[i].sidenum[1] != NO_SIDEDEF ? (sides[lines[i].sidenum[1]].rowoffset >> FRACBITS) : (abs(lines[i].dy) >> FRACBITS);
if (lines[i].flags & ML_MIDPEG) if (lines[i].flags & ML_MIDPEG)
lines[i].args[4] |= TMFT_RELATIVE; lines[i].args[4] |= TMFT_RELATIVE;
if (lines[i].flags & ML_WRAPMIDTEX) if (lines[i].flags & ML_WRAPMIDTEX)
@ -5584,7 +5654,7 @@ static void P_ConvertBinaryLinedefTypes(void)
break; break;
case 455: //Fade colormap case 455: //Fade colormap
{ {
INT32 speed = (INT32)((((lines[i].flags & ML_DONTPEGBOTTOM) || !sides[lines[i].sidenum[0]].rowoffset) && lines[i].sidenum[1] != 0xFFFF) ? INT32 speed = (INT32)((((lines[i].flags & ML_DONTPEGBOTTOM) || !sides[lines[i].sidenum[0]].rowoffset) && lines[i].sidenum[1] != NO_SIDEDEF) ?
abs(sides[lines[i].sidenum[1]].rowoffset >> FRACBITS) abs(sides[lines[i].sidenum[1]].rowoffset >> FRACBITS)
: abs(sides[lines[i].sidenum[0]].rowoffset >> FRACBITS)); : abs(sides[lines[i].sidenum[0]].rowoffset >> FRACBITS));
@ -5614,7 +5684,7 @@ static void P_ConvertBinaryLinedefTypes(void)
lines[i].args[0] = tag; lines[i].args[0] = tag;
lines[i].args[1] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS; lines[i].args[1] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS;
lines[i].args[2] = sides[lines[i].sidenum[0]].rowoffset >> FRACBITS; lines[i].args[2] = sides[lines[i].sidenum[0]].rowoffset >> FRACBITS;
lines[i].args[3] = (lines[i].sidenum[1] != 0xffff) ? sides[lines[i].sidenum[1]].textureoffset >> FRACBITS : 0; lines[i].args[3] = (lines[i].sidenum[1] != NO_SIDEDEF) ? sides[lines[i].sidenum[1]].textureoffset >> FRACBITS : 0;
lines[i].args[4] = !!(lines[i].flags & ML_NOSKEW); lines[i].args[4] = !!(lines[i].flags & ML_NOSKEW);
break; break;
case 459: //Control text prompt case 459: //Control text prompt
@ -5634,7 +5704,7 @@ static void P_ConvertBinaryLinedefTypes(void)
lines[i].args[2] |= TMP_ALLPLAYERS; lines[i].args[2] |= TMP_ALLPLAYERS;
if (lines[i].flags & ML_MIDSOLID) if (lines[i].flags & ML_MIDSOLID)
lines[i].args[2] |= TMP_FREEZETHINKERS;*/ lines[i].args[2] |= TMP_FREEZETHINKERS;*/
lines[i].args[3] = (lines[i].sidenum[1] != 0xFFFF) ? sides[lines[i].sidenum[1]].textureoffset >> FRACBITS : tag; lines[i].args[3] = (lines[i].sidenum[1] != NO_SIDEDEF) ? sides[lines[i].sidenum[1]].textureoffset >> FRACBITS : tag;
break; break;
case 460: //Award rings case 460: //Award rings
lines[i].args[0] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS; lines[i].args[0] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS;
@ -5647,7 +5717,7 @@ static void P_ConvertBinaryLinedefTypes(void)
lines[i].args[3] = (lines[i].flags & ML_SKEWTD) ? AngleFixed(R_PointToAngle2(lines[i].v1->x, lines[i].v1->y, lines[i].v2->x, lines[i].v2->y)) >> FRACBITS : 0; lines[i].args[3] = (lines[i].flags & ML_SKEWTD) ? AngleFixed(R_PointToAngle2(lines[i].v1->x, lines[i].v1->y, lines[i].v2->x, lines[i].v2->y)) >> FRACBITS : 0;
if (lines[i].flags & ML_NOCLIMB) if (lines[i].flags & ML_NOCLIMB)
{ {
if (lines[i].sidenum[1] != 0xffff) // Make sure the linedef has a back side if (lines[i].sidenum[1] != NO_SIDEDEF) // Make sure the linedef has a back side
{ {
lines[i].args[4] = 1; lines[i].args[4] = 1;
lines[i].args[5] = sides[lines[i].sidenum[1]].textureoffset >> FRACBITS; lines[i].args[5] = sides[lines[i].sidenum[1]].textureoffset >> FRACBITS;
@ -5681,7 +5751,7 @@ static void P_ConvertBinaryLinedefTypes(void)
lines[i].args[0] = tag; lines[i].args[0] = tag;
lines[i].args[1] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS; lines[i].args[1] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS;
lines[i].args[2] = sides[lines[i].sidenum[0]].rowoffset >> FRACBITS; lines[i].args[2] = sides[lines[i].sidenum[0]].rowoffset >> FRACBITS;
if (lines[i].sidenum[1] != 0xffff) if (lines[i].sidenum[1] != NO_SIDEDEF)
lines[i].args[3] = sides[lines[i].sidenum[1]].textureoffset >> FRACBITS; lines[i].args[3] = sides[lines[i].sidenum[1]].textureoffset >> FRACBITS;
break; break;
case 482: //Polyobject - move case 482: //Polyobject - move
@ -5753,7 +5823,7 @@ static void P_ConvertBinaryLinedefTypes(void)
if (!(lines[i].flags & ML_DONTPEGBOTTOM)) if (!(lines[i].flags & ML_DONTPEGBOTTOM))
lines[i].args[1] /= 100; lines[i].args[1] /= 100;
// allow Back Y Offset to be consistent with other fade specials // allow Back Y Offset to be consistent with other fade specials
lines[i].args[2] = (lines[i].sidenum[1] != 0xffff && !sides[lines[i].sidenum[0]].rowoffset) ? lines[i].args[2] = (lines[i].sidenum[1] != NO_SIDEDEF && !sides[lines[i].sidenum[0]].rowoffset) ?
abs(sides[lines[i].sidenum[1]].rowoffset >> FRACBITS) abs(sides[lines[i].sidenum[1]].rowoffset >> FRACBITS)
: abs(sides[lines[i].sidenum[0]].rowoffset >> FRACBITS); : abs(sides[lines[i].sidenum[0]].rowoffset >> FRACBITS);
if (lines[i].flags & ML_MIDPEG) if (lines[i].flags & ML_MIDPEG)
@ -5780,7 +5850,7 @@ static void P_ConvertBinaryLinedefTypes(void)
lines[i].args[0] = tag; lines[i].args[0] = tag;
if (lines[i].flags & ML_MIDPEG) if (lines[i].flags & ML_MIDPEG)
{ {
if (lines[i].sidenum[1] == 0xffff) if (lines[i].sidenum[1] == NO_SIDEDEF)
{ {
CONS_Debug(DBG_GAMELOGIC, "Line special %d (line #%s) missing back side!\n", lines[i].special, sizeu1(i)); CONS_Debug(DBG_GAMELOGIC, "Line special %d (line #%s) missing back side!\n", lines[i].special, sizeu1(i));
lines[i].special = 0; lines[i].special = 0;
@ -5810,7 +5880,7 @@ static void P_ConvertBinaryLinedefTypes(void)
lines[i].args[0] = lines[i].special >= 507; lines[i].args[0] = lines[i].special >= 507;
if (lines[i].special % 2 == 0) if (lines[i].special % 2 == 0)
{ {
if (lines[i].sidenum[1] == 0xffff) if (lines[i].sidenum[1] == NO_SIDEDEF)
{ {
CONS_Debug(DBG_GAMELOGIC, "Line special %d (line #%s) missing back side!\n", lines[i].special, sizeu1(i)); CONS_Debug(DBG_GAMELOGIC, "Line special %d (line #%s) missing back side!\n", lines[i].special, sizeu1(i));
lines[i].special = 0; lines[i].special = 0;
@ -5966,7 +6036,7 @@ static void P_ConvertBinaryLinedefTypes(void)
{ {
UINT8 side = lines[i].special >= 714; UINT8 side = lines[i].special >= 714;
if (side == 1 && lines[i].sidenum[1] == 0xffff) if (side == 1 && lines[i].sidenum[1] == NO_SIDEDEF)
CONS_Debug(DBG_GAMELOGIC, "P_ConvertBinaryMap: Line special %d (line #%s) missing 2nd side!\n", lines[i].special, sizeu1(i)); CONS_Debug(DBG_GAMELOGIC, "P_ConvertBinaryMap: Line special %d (line #%s) missing 2nd side!\n", lines[i].special, sizeu1(i));
else else
{ {
@ -6132,6 +6202,7 @@ static void P_ConvertBinarySectorTypes(void)
case 14: //Non-ramp sector case 14: //Non-ramp sector
sectors[i].specialflags |= SSF_NOSTEPDOWN; sectors[i].specialflags |= SSF_NOSTEPDOWN;
break; break;
// TODO: 2.3: Delete
case 15: //Bouncy FOF case 15: //Bouncy FOF
CONS_Alert(CONS_WARNING, M_GetText("Deprecated bouncy FOF sector type detected. Please use linedef type 76 instead.\n")); CONS_Alert(CONS_WARNING, M_GetText("Deprecated bouncy FOF sector type detected. Please use linedef type 76 instead.\n"));
break; break;
@ -6166,12 +6237,14 @@ static void P_ConvertBinarySectorTypes(void)
sectors[i].flags |= MSF_TRIGGERLINE_PLANE; sectors[i].flags |= MSF_TRIGGERLINE_PLANE;
sectors[i].triggerer = TO_PLAYER; sectors[i].triggerer = TO_PLAYER;
break; break;
// TODO: 2.3: Delete
case 6: //Trigger linedef executor (Emerald check) case 6: //Trigger linedef executor (Emerald check)
CONS_Alert(CONS_WARNING, M_GetText("Deprecated emerald check sector type detected. Please use linedef types 337-339 instead.\n")); CONS_Alert(CONS_WARNING, M_GetText("Deprecated emerald check sector type detected. Please use linedef types 337-339 instead.\n"));
sectors[i].triggertag = tag; sectors[i].triggertag = tag;
sectors[i].flags &= ~MSF_TRIGGERLINE_PLANE; sectors[i].flags &= ~MSF_TRIGGERLINE_PLANE;
sectors[i].triggerer = TO_PLAYEREMERALDS; sectors[i].triggerer = TO_PLAYEREMERALDS;
break; break;
// TODO: 2.3: Delete
case 7: //Trigger linedef executor (NiGHTS mare) case 7: //Trigger linedef executor (NiGHTS mare)
CONS_Alert(CONS_WARNING, M_GetText("Deprecated NiGHTS mare sector type detected. Please use linedef types 340-342 instead.\n")); CONS_Alert(CONS_WARNING, M_GetText("Deprecated NiGHTS mare sector type detected. Please use linedef types 340-342 instead.\n"));
sectors[i].triggertag = tag; sectors[i].triggertag = tag;
@ -6181,9 +6254,11 @@ static void P_ConvertBinarySectorTypes(void)
case 8: //Check for linedef executor on FOFs case 8: //Check for linedef executor on FOFs
sectors[i].flags |= MSF_TRIGGERLINE_MOBJ; sectors[i].flags |= MSF_TRIGGERLINE_MOBJ;
break; break;
// TODO: 2.3: Delete
case 10: //Special stage time/spheres requirements case 10: //Special stage time/spheres requirements
CONS_Alert(CONS_WARNING, M_GetText("Deprecated sector type for special stage requirements detected. Please use the SpecialStageTime and SpecialStageSpheres level header options instead.\n")); CONS_Alert(CONS_WARNING, M_GetText("Deprecated sector type for special stage requirements detected. Please use the SpecialStageTime and SpecialStageSpheres level header options instead.\n"));
break; break;
// TODO: 2.3: Delete
case 11: //Custom global gravity case 11: //Custom global gravity
CONS_Alert(CONS_WARNING, M_GetText("Deprecated sector type for global gravity detected. Please use the Gravity level header option instead.\n")); CONS_Alert(CONS_WARNING, M_GetText("Deprecated sector type for global gravity detected. Please use the Gravity level header option instead.\n"));
break; break;
@ -7801,6 +7876,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
Patch_FreeTag(PU_PATCH_LOWPRIORITY); Patch_FreeTag(PU_PATCH_LOWPRIORITY);
Patch_FreeTag(PU_PATCH_ROTATED); Patch_FreeTag(PU_PATCH_ROTATED);
Z_FreeTags(PU_LEVEL, PU_PURGELEVEL - 1); Z_FreeTags(PU_LEVEL, PU_PURGELEVEL - 1);
mobjcache = NULL;
R_InitializeLevelInterpolators(); R_InitializeLevelInterpolators();

View file

@ -557,7 +557,7 @@ static inline sector_t *getSector(INT32 currentSector, INT32 line, INT32 side)
*/ */
static inline boolean twoSided(INT32 sector, INT32 line) static inline boolean twoSided(INT32 sector, INT32 line)
{ {
return (sectors[sector].lines[line])->sidenum[1] != 0xffff; return (sectors[sector].lines[line])->sidenum[1] != NO_SIDEDEF;
} }
#endif #endif
@ -1796,7 +1796,7 @@ void P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller)
if (trigid < 0 || trigid > 31) // limited by 32 bit variable if (trigid < 0 || trigid > 31) // limited by 32 bit variable
{ {
CONS_Debug(DBG_GAMELOGIC, "Unlockable trigger (sidedef %hu): bad trigger ID %d\n", triggerline->sidenum[0], trigid); CONS_Debug(DBG_GAMELOGIC, "Unlockable trigger (sidedef %u): bad trigger ID %d\n", triggerline->sidenum[0], trigid);
return; return;
} }
else if (!(unlocktriggers & (1 << trigid))) else if (!(unlocktriggers & (1 << trigid)))
@ -1809,7 +1809,7 @@ void P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller)
if (unlockid <= 0 || unlockid > MAXUNLOCKABLES) // limited by unlockable count if (unlockid <= 0 || unlockid > MAXUNLOCKABLES) // limited by unlockable count
{ {
CONS_Debug(DBG_GAMELOGIC, "Unlockable check (sidedef %hu): bad unlockable ID %d\n", triggerline->sidenum[0], unlockid); CONS_Debug(DBG_GAMELOGIC, "Unlockable check (sidedef %u): bad unlockable ID %d\n", triggerline->sidenum[0], unlockid);
return; return;
} }
else if (!(serverGamedata->unlocked[unlockid-1])) else if (!(serverGamedata->unlocked[unlockid-1]))
@ -2607,7 +2607,15 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
if (lumpnum == LUMPERROR || W_LumpLength(lumpnum) == 0) if (lumpnum == LUMPERROR || W_LumpLength(lumpnum) == 0)
CONS_Debug(DBG_SETUP, "Line type 415 Executor: script lump %s not found/not valid.\n", line->stringargs[0]); CONS_Debug(DBG_SETUP, "Line type 415 Executor: script lump %s not found/not valid.\n", line->stringargs[0]);
else else
COM_BufInsertText(W_CacheLumpNum(lumpnum, PU_CACHE)); {
void *lump = W_CacheLumpNum(lumpnum, PU_CACHE);
size_t len = W_LumpLength(lumpnum);
char *text = Z_Malloc(len + 1, PU_CACHE, NULL);
memcpy(text, lump, len);
text[len] = '\0';
COM_BufInsertText(text);
Z_Free(text);
}
} }
break; break;
@ -2727,7 +2735,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
mo->player->rmomx = mo->player->rmomy = 1; mo->player->rmomx = mo->player->rmomy = 1;
mo->player->cmomx = mo->player->cmomy = 0; mo->player->cmomx = mo->player->cmomy = 0;
P_ResetPlayer(mo->player); P_ResetPlayer(mo->player);
P_SetPlayerMobjState(mo, S_PLAY_STND); P_SetMobjState(mo, S_PLAY_STND);
// Reset bot too. // Reset bot too.
if (bot) { if (bot) {
@ -2738,7 +2746,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
bot->player->rmomx = bot->player->rmomy = 1; bot->player->rmomx = bot->player->rmomy = 1;
bot->player->cmomx = bot->player->cmomy = 0; bot->player->cmomx = bot->player->cmomy = 0;
P_ResetPlayer(bot->player); P_ResetPlayer(bot->player);
P_SetPlayerMobjState(bot, S_PLAY_STND); P_SetMobjState(bot, S_PLAY_STND);
} }
} }
break; break;
@ -2897,7 +2905,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
{ {
size_t linenum; size_t linenum;
side_t *setfront = &sides[line->sidenum[0]]; side_t *setfront = &sides[line->sidenum[0]];
side_t *setback = (line->args[3] && line->sidenum[1] != 0xffff) ? &sides[line->sidenum[1]] : setfront; side_t *setback = (line->args[3] && line->sidenum[1] != NO_SIDEDEF) ? &sides[line->sidenum[1]] : setfront;
side_t *this; side_t *this;
boolean always = !(line->args[2]); // If args[2] is set: Only change mid texture if mid texture already exists on tagged lines, etc. boolean always = !(line->args[2]); // If args[2] is set: Only change mid texture if mid texture already exists on tagged lines, etc.
@ -2919,7 +2927,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
} }
// Back side // Back side
if (line->args[1] != TMSD_FRONT && lines[linenum].sidenum[1] != 0xffff) if (line->args[1] != TMSD_FRONT && lines[linenum].sidenum[1] != NO_SIDEDEF)
{ {
this = &sides[lines[linenum].sidenum[1]]; this = &sides[lines[linenum].sidenum[1]];
if (always || this->toptexture) this->toptexture = setback->toptexture; if (always || this->toptexture) this->toptexture = setback->toptexture;
@ -2940,7 +2948,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
INT32 trigid = line->args[0]; INT32 trigid = line->args[0];
if (trigid < 0 || trigid > 31) // limited by 32 bit variable if (trigid < 0 || trigid > 31) // limited by 32 bit variable
CONS_Debug(DBG_GAMELOGIC, "Unlockable trigger (sidedef %hu): bad trigger ID %d\n", line->sidenum[0], trigid); CONS_Debug(DBG_GAMELOGIC, "Unlockable trigger (sidedef %u): bad trigger ID %d\n", line->sidenum[0], trigid);
else else
{ {
unlocktriggers |= 1 << trigid; unlocktriggers |= 1 << trigid;
@ -3153,7 +3161,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
if (line->args[2] & TMCF_RELATIVE) if (line->args[2] & TMCF_RELATIVE)
{ {
extracolormap_t *target = (!udmf && (line->flags & ML_TFERLINE) && line->sidenum[1] != 0xFFFF) ? extracolormap_t *target = (!udmf && (line->flags & ML_TFERLINE) && line->sidenum[1] != NO_SIDEDEF) ?
sides[line->sidenum[1]].colormap_data : sectors[secnum].extra_colormap; // use back colormap instead of target sector sides[line->sidenum[1]].colormap_data : sectors[secnum].extra_colormap; // use back colormap instead of target sector
extracolormap_t *exc = R_AddColormaps( extracolormap_t *exc = R_AddColormaps(
@ -3482,7 +3490,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
} }
if (!udmf && (line->flags & ML_TFERLINE)) // use back colormap instead of target sector if (!udmf && (line->flags & ML_TFERLINE)) // use back colormap instead of target sector
sectors[secnum].extra_colormap = (line->sidenum[1] != 0xFFFF) ? sectors[secnum].extra_colormap = (line->sidenum[1] != NO_SIDEDEF) ?
sides[line->sidenum[1]].colormap_data : NULL; sides[line->sidenum[1]].colormap_data : NULL;
exc = sectors[secnum].extra_colormap; exc = sectors[secnum].extra_colormap;
@ -4178,6 +4186,7 @@ sector_t *P_MobjTouchingSectorSpecial(mobj_t *mo, INT32 section, INT32 number)
return NULL; return NULL;
} }
// TODO: 2.3: Delete
// Deprecated in favor of P_MobjTouchingSectorSpecial // Deprecated in favor of P_MobjTouchingSectorSpecial
// Kept for Lua backwards compatibility only // Kept for Lua backwards compatibility only
sector_t *P_ThingOnSpecial3DFloor(mobj_t *mo) sector_t *P_ThingOnSpecial3DFloor(mobj_t *mo)
@ -4557,7 +4566,7 @@ static void P_ProcessSpeedPad(player_t *player, sector_t *sector, sector_t *rove
if (!(player->pflags & PF_SPINNING)) if (!(player->pflags & PF_SPINNING))
player->pflags |= PF_SPINNING; player->pflags |= PF_SPINNING;
P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); P_SetMobjState(player->mo, S_PLAY_ROLL);
} }
player->powers[pw_flashing] = TICRATE/3; player->powers[pw_flashing] = TICRATE/3;
@ -4735,7 +4744,7 @@ static void P_ProcessZoomTube(player_t *player, mtag_t sectag, boolean end)
if (player->mo->state-states != S_PLAY_ROLL) if (player->mo->state-states != S_PLAY_ROLL)
{ {
P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); P_SetMobjState(player->mo, S_PLAY_ROLL);
S_StartSound(player->mo, sfx_spin); S_StartSound(player->mo, sfx_spin);
} }
} }
@ -4949,7 +4958,7 @@ static void P_ProcessRopeHang(player_t *player, mtag_t sectag)
player->pflags &= ~(PF_JUMPED|PF_NOJUMPDAMAGE|PF_GLIDING|PF_BOUNCING|PF_SLIDING|PF_CANCARRY); player->pflags &= ~(PF_JUMPED|PF_NOJUMPDAMAGE|PF_GLIDING|PF_BOUNCING|PF_SLIDING|PF_CANCARRY);
player->climbing = 0; player->climbing = 0;
P_SetThingPosition(player->mo); P_SetThingPosition(player->mo);
P_SetPlayerMobjState(player->mo, S_PLAY_RIDE); P_SetMobjState(player->mo, S_PLAY_RIDE);
} }
static boolean P_SectorHasSpecial(sector_t *sec) static boolean P_SectorHasSpecial(sector_t *sec)
@ -5008,7 +5017,7 @@ static void P_EvaluateSpecialFlags(player_t *player, sector_t *sector, sector_t
if (!player->powers[pw_carry]) if (!player->powers[pw_carry])
{ {
P_ResetPlayer(player); P_ResetPlayer(player);
P_SetPlayerMobjState(player->mo, S_PLAY_FALL); P_SetMobjState(player->mo, S_PLAY_FALL);
P_SetTarget(&player->mo->tracer, player->mo); P_SetTarget(&player->mo->tracer, player->mo);
player->powers[pw_carry] = CR_FAN; player->powers[pw_carry] = CR_FAN;
} }
@ -5023,7 +5032,7 @@ static void P_EvaluateSpecialFlags(player_t *player, sector_t *sector, sector_t
if (!(player->pflags & PF_SPINNING)) if (!(player->pflags & PF_SPINNING))
{ {
player->pflags |= PF_SPINNING; player->pflags |= PF_SPINNING;
P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); P_SetMobjState(player->mo, S_PLAY_ROLL);
S_StartAttackSound(player->mo, sfx_spin); S_StartAttackSound(player->mo, sfx_spin);
if (abs(player->rmomx) < FixedMul(5*FRACUNIT, player->mo->scale) if (abs(player->rmomx) < FixedMul(5*FRACUNIT, player->mo->scale)
@ -5596,6 +5605,8 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, I
fflr->bottompic = &sec2->floorpic; fflr->bottompic = &sec2->floorpic;
fflr->bottomxoffs = &sec2->floorxoffset; fflr->bottomxoffs = &sec2->floorxoffset;
fflr->bottomyoffs = &sec2->flooryoffset; fflr->bottomyoffs = &sec2->flooryoffset;
fflr->bottomxscale = &sec2->floorxscale;
fflr->bottomyscale = &sec2->flooryscale;
fflr->bottomangle = &sec2->floorangle; fflr->bottomangle = &sec2->floorangle;
// Add the ceiling // Add the ceiling
@ -5604,6 +5615,8 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, I
fflr->toplightlevel = &sec2->lightlevel; fflr->toplightlevel = &sec2->lightlevel;
fflr->topxoffs = &sec2->ceilingxoffset; fflr->topxoffs = &sec2->ceilingxoffset;
fflr->topyoffs = &sec2->ceilingyoffset; fflr->topyoffs = &sec2->ceilingyoffset;
fflr->topxscale = &sec2->ceilingxscale;
fflr->topyscale = &sec2->ceilingyscale;
fflr->topangle = &sec2->ceilingangle; fflr->topangle = &sec2->ceilingangle;
// Add slopes // Add slopes
@ -6229,6 +6242,7 @@ void P_SpawnSpecials(boolean fromnetsave)
sector->flags |= MSF_TRIGGERSPECIAL_TOUCH; sector->flags |= MSF_TRIGGERSPECIAL_TOUCH;
} }
// TODO: 2.3: Delete everything below
// Process deprecated binary sector specials // Process deprecated binary sector specials
if (udmf || !sector->special) if (udmf || !sector->special)
continue; continue;
@ -7598,7 +7612,7 @@ static void P_SpawnScrollers(void)
{ {
if (l->args[1] != TMSD_BACK) if (l->args[1] != TMSD_BACK)
Add_Scroller(sc_side, l->args[2] << (FRACBITS - SCROLL_SHIFT), l->args[3] << (FRACBITS - SCROLL_SHIFT), control, lines[s].sidenum[0], accel, 0); Add_Scroller(sc_side, l->args[2] << (FRACBITS - SCROLL_SHIFT), l->args[3] << (FRACBITS - SCROLL_SHIFT), control, lines[s].sidenum[0], accel, 0);
if (l->args[1] != TMSD_FRONT && lines[s].sidenum[1] != 0xffff) if (l->args[1] != TMSD_FRONT && lines[s].sidenum[1] != NO_SIDEDEF)
Add_Scroller(sc_side, l->args[2] << (FRACBITS - SCROLL_SHIFT), l->args[3] << (FRACBITS - SCROLL_SHIFT), control, lines[s].sidenum[1], accel, 0); Add_Scroller(sc_side, l->args[2] << (FRACBITS - SCROLL_SHIFT), l->args[3] << (FRACBITS - SCROLL_SHIFT), control, lines[s].sidenum[1], accel, 0);
} }
break; break;
@ -7609,7 +7623,7 @@ static void P_SpawnScrollers(void)
Add_Scroller(sc_side, -l->args[1] << FRACBITS, l->args[2] << FRACBITS, -1, l->sidenum[0], accel, 0); Add_Scroller(sc_side, -l->args[1] << FRACBITS, l->args[2] << FRACBITS, -1, l->sidenum[0], accel, 0);
if (l->args[0] != TMSD_FRONT) if (l->args[0] != TMSD_FRONT)
{ {
if (l->sidenum[1] != 0xffff) if (l->sidenum[1] != NO_SIDEDEF)
Add_Scroller(sc_side, -l->args[1] << FRACBITS, l->args[2] << FRACBITS, -1, l->sidenum[1], accel, 0); Add_Scroller(sc_side, -l->args[1] << FRACBITS, l->args[2] << FRACBITS, -1, l->sidenum[1], accel, 0);
else else
CONS_Debug(DBG_GAMELOGIC, "Line special 500 (line #%s) missing back side!\n", sizeu1(i)); CONS_Debug(DBG_GAMELOGIC, "Line special 500 (line #%s) missing back side!\n", sizeu1(i));

View file

@ -96,7 +96,7 @@ void P_MixUp(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle,
P_ClearStarPost(starpostnum); P_ClearStarPost(starpostnum);
P_ResetPlayer(thing->player); P_ResetPlayer(thing->player);
P_SetPlayerMobjState(thing, S_PLAY_STND); P_SetMobjState(thing, S_PLAY_STND);
P_FlashPal(thing->player, PAL_MIXUP, 10); P_FlashPal(thing->player, PAL_MIXUP, 10);
} }
@ -153,7 +153,7 @@ boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle
thing->player->rmomx = thing->player->rmomy = 0; thing->player->rmomx = thing->player->rmomy = 0;
thing->player->speed = 0; thing->player->speed = 0;
P_ResetPlayer(thing->player); P_ResetPlayer(thing->player);
P_SetPlayerMobjState(thing, S_PLAY_STND); P_SetMobjState(thing, S_PLAY_STND);
thing->reactiontime = TICRATE/2; // don't move for about half a second thing->reactiontime = TICRATE/2; // don't move for about half a second
thing->player->drawangle = angle; thing->player->drawangle = angle;

View file

@ -217,6 +217,7 @@ void P_AddThinker(const thinklistnum_t n, thinker_t *thinker)
thlist[n].prev = thinker; thlist[n].prev = thinker;
thinker->references = 0; // killough 11/98: init reference counter to 0 thinker->references = 0; // killough 11/98: init reference counter to 0
thinker->cachable = n == THINK_MOBJ;
#ifdef PARANOIA #ifdef PARANOIA
thinker->debug_mobjtype = MT_NULL; thinker->debug_mobjtype = MT_NULL;
@ -226,21 +227,22 @@ void P_AddThinker(const thinklistnum_t n, thinker_t *thinker)
#ifdef PARANOIA #ifdef PARANOIA
static const char *MobjTypeName(const mobj_t *mobj) static const char *MobjTypeName(const mobj_t *mobj)
{ {
mobjtype_t type;
actionf_p1 p1 = mobj->thinker.function.acp1; actionf_p1 p1 = mobj->thinker.function.acp1;
if (p1 == (actionf_p1)P_MobjThinker) if (p1 == (actionf_p1)P_MobjThinker)
{ type = mobj->type;
return MOBJTYPE_LIST[mobj->type]; else if (p1 == (actionf_p1)P_RemoveThinkerDelayed && mobj->thinker.debug_mobjtype != MT_NULL)
} type = mobj->thinker.debug_mobjtype;
else if (p1 == (actionf_p1)P_RemoveThinkerDelayed) else
{ return "<Not a mobj>";
if (mobj->thinker.debug_mobjtype != MT_NULL)
{
return MOBJTYPE_LIST[mobj->thinker.debug_mobjtype];
}
}
return "<Not a mobj>"; if (type < 0 || type >= NUMMOBJTYPES || (type >= MT_FIRSTFREESLOT && !FREE_MOBJS[type - MT_FIRSTFREESLOT]))
return "<Invalid mobj type>";
else if (type >= MT_FIRSTFREESLOT)
return FREE_MOBJS[type - MT_FIRSTFREESLOT]; // This doesn't include "MT_"...
else
return MOBJTYPE_LIST[type];
} }
static const char *MobjThinkerName(const mobj_t *mobj) static const char *MobjThinkerName(const mobj_t *mobj)
@ -319,7 +321,16 @@ void P_RemoveThinkerDelayed(thinker_t *thinker)
(next->prev = currentthinker = thinker->prev)->next = next; (next->prev = currentthinker = thinker->prev)->next = next;
R_DestroyLevelInterpolators(thinker); R_DestroyLevelInterpolators(thinker);
Z_Free(thinker); if (thinker->cachable)
{
// put cachable thinkers in the mobj cache, so we can avoid allocations
((mobj_t *)thinker)->hnext = mobjcache;
mobjcache = (mobj_t *)thinker;
}
else
{
Z_Free(thinker);
}
} }
// //
@ -843,16 +854,7 @@ void P_Ticker(boolean run)
countdown2--; countdown2--;
if (quake.time) if (quake.time)
{
fixed_t ir = quake.intensity>>1;
/// \todo Calculate distance from epicenter if set and modulate the intensity accordingly based on radius.
quake.x = M_RandomRange(-ir,ir);
quake.y = M_RandomRange(-ir,ir);
quake.z = M_RandomRange(-ir,ir);
--quake.time; --quake.time;
}
else
quake.x = quake.y = quake.z = 0;
if (metalplayback) if (metalplayback)
G_ReadMetalTic(metalplayback); G_ReadMetalTic(metalplayback);

File diff suppressed because it is too large Load diff

View file

@ -267,18 +267,17 @@ static boolean is_tangible (mobj_t *thing)
boolean R_ThingBoundingBoxVisible(mobj_t *thing) boolean R_ThingBoundingBoxVisible(mobj_t *thing)
{ {
INT32 cvmode = cv_renderhitbox.value; INT32 cvmode = cv_renderhitbox.value;
boolean ring = false;
if (multiplayer) // No hitboxes in multiplayer to avoid cheating if (multiplayer) // No hitboxes in multiplayer to avoid cheating
return false; return false;
// Do not render bbox for these
switch (thing->type) switch (thing->type)
{ {
default: default:
// First person / awayviewmobj -- rendering // First person / awayviewmobj -- rendering a bbox
// a bbox too close to the viewpoint causes // too close to the viewpoint causes anomalies
// anomalies and these are exactly on the // and these are exactly on the viewpoint!
// viewpoint!
if (thing != r_viewmobj) if (thing != r_viewmobj)
{ {
break; break;
@ -290,6 +289,17 @@ boolean R_ThingBoundingBoxVisible(mobj_t *thing)
// are rendered using portals in Software, // are rendered using portals in Software,
// r_viewmobj does not point here. // r_viewmobj does not point here.
return false; return false;
case MT_RING:
case MT_BLUESPHERE:
case MT_NIGHTSSTAR:
case MT_NIGHTSCHIP:
case MT_COIN:
// Rings and similar objects are often placed
// in large amounts, so they are handled
// separately from other tangible objects.
ring = true;
break;
} }
switch (cvmode) switch (cvmode)
@ -304,16 +314,10 @@ boolean R_ThingBoundingBoxVisible(mobj_t *thing)
return !is_tangible(thing); return !is_tangible(thing);
case RENDERHITBOX_TANGIBLE: case RENDERHITBOX_TANGIBLE:
// Exclude rings from here, lots of them! return !ring && is_tangible(thing);
if (thing->type == MT_RING)
{
return false;
}
return is_tangible(thing);
case RENDERHITBOX_RINGS: case RENDERHITBOX_RINGS:
return (thing->type == MT_RING || thing->type == MT_BLUESPHERE); return ring;
default: default:
return false; return false;

View file

@ -277,6 +277,8 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel,
tempsec->floorpic = s->floorpic; tempsec->floorpic = s->floorpic;
tempsec->floorxoffset = s->floorxoffset; tempsec->floorxoffset = s->floorxoffset;
tempsec->flooryoffset = s->flooryoffset; tempsec->flooryoffset = s->flooryoffset;
tempsec->floorxscale = s->floorxscale;
tempsec->flooryscale = s->flooryscale;
tempsec->floorangle = s->floorangle; tempsec->floorangle = s->floorangle;
if (underwater) if (underwater)
@ -287,6 +289,8 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel,
tempsec->ceilingpic = tempsec->floorpic; tempsec->ceilingpic = tempsec->floorpic;
tempsec->ceilingxoffset = tempsec->floorxoffset; tempsec->ceilingxoffset = tempsec->floorxoffset;
tempsec->ceilingyoffset = tempsec->flooryoffset; tempsec->ceilingyoffset = tempsec->flooryoffset;
tempsec->ceilingxscale = tempsec->floorxscale;
tempsec->ceilingyscale = tempsec->flooryscale;
tempsec->ceilingangle = tempsec->floorangle; tempsec->ceilingangle = tempsec->floorangle;
} }
else else
@ -294,6 +298,8 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel,
tempsec->ceilingpic = s->ceilingpic; tempsec->ceilingpic = s->ceilingpic;
tempsec->ceilingxoffset = s->ceilingxoffset; tempsec->ceilingxoffset = s->ceilingxoffset;
tempsec->ceilingyoffset = s->ceilingyoffset; tempsec->ceilingyoffset = s->ceilingyoffset;
tempsec->ceilingxscale = s->ceilingxscale;
tempsec->ceilingyscale = s->ceilingyscale;
tempsec->ceilingangle = s->ceilingangle; tempsec->ceilingangle = s->ceilingangle;
} }
} }
@ -317,6 +323,8 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel,
tempsec->floorpic = tempsec->ceilingpic = s->ceilingpic; tempsec->floorpic = tempsec->ceilingpic = s->ceilingpic;
tempsec->floorxoffset = tempsec->ceilingxoffset = s->ceilingxoffset; tempsec->floorxoffset = tempsec->ceilingxoffset = s->ceilingxoffset;
tempsec->flooryoffset = tempsec->ceilingyoffset = s->ceilingyoffset; tempsec->flooryoffset = tempsec->ceilingyoffset = s->ceilingyoffset;
tempsec->floorxscale = tempsec->ceilingxscale = s->ceilingxscale;
tempsec->flooryscale = tempsec->ceilingyscale = s->ceilingyscale;
tempsec->floorangle = tempsec->ceilingangle = s->ceilingangle; tempsec->floorangle = tempsec->ceilingangle = s->ceilingangle;
if (s->floorpic == skyflatnum) // SKYFIX? if (s->floorpic == skyflatnum) // SKYFIX?
@ -325,6 +333,8 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel,
tempsec->floorpic = tempsec->ceilingpic; tempsec->floorpic = tempsec->ceilingpic;
tempsec->floorxoffset = tempsec->ceilingxoffset; tempsec->floorxoffset = tempsec->ceilingxoffset;
tempsec->flooryoffset = tempsec->ceilingyoffset; tempsec->flooryoffset = tempsec->ceilingyoffset;
tempsec->floorxscale = tempsec->ceilingxscale;
tempsec->flooryscale = tempsec->ceilingyscale;
tempsec->floorangle = tempsec->ceilingangle; tempsec->floorangle = tempsec->ceilingangle;
} }
else else
@ -333,6 +343,8 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel,
tempsec->floorpic = s->floorpic; tempsec->floorpic = s->floorpic;
tempsec->floorxoffset = s->floorxoffset; tempsec->floorxoffset = s->floorxoffset;
tempsec->flooryoffset = s->flooryoffset; tempsec->flooryoffset = s->flooryoffset;
tempsec->floorxscale = s->floorxscale;
tempsec->flooryscale = s->flooryscale;
tempsec->floorangle = s->floorangle; tempsec->floorangle = s->floorangle;
} }
@ -362,12 +374,16 @@ boolean R_IsEmptyLine(seg_t *line, sector_t *front, sector_t *back)
&& back->c_slope == front->c_slope && back->c_slope == front->c_slope
&& back->lightlevel == front->lightlevel && back->lightlevel == front->lightlevel
&& !line->sidedef->midtexture && !line->sidedef->midtexture
// Check offsets too! // Check offsets and scale too!
&& back->floorxoffset == front->floorxoffset && back->floorxoffset == front->floorxoffset
&& back->flooryoffset == front->flooryoffset && back->flooryoffset == front->flooryoffset
&& back->floorxscale == front->floorxscale
&& back->flooryscale == front->flooryscale
&& back->floorangle == front->floorangle && back->floorangle == front->floorangle
&& back->ceilingxoffset == front->ceilingxoffset && back->ceilingxoffset == front->ceilingxoffset
&& back->ceilingyoffset == front->ceilingyoffset && back->ceilingyoffset == front->ceilingyoffset
&& back->ceilingxscale == front->ceilingxscale
&& back->ceilingyscale == front->ceilingyscale
&& back->ceilingangle == front->ceilingangle && back->ceilingangle == front->ceilingangle
// Consider altered lighting. // Consider altered lighting.
&& back->floorlightlevel == front->floorlightlevel && back->floorlightlevel == front->floorlightlevel
@ -909,7 +925,9 @@ static void R_Subsector(size_t num)
|| (frontsector->heightsec != -1 && sectors[frontsector->heightsec].ceilingpic == skyflatnum)) || (frontsector->heightsec != -1 && sectors[frontsector->heightsec].ceilingpic == skyflatnum))
{ {
floorplane = R_FindPlane(frontsector->floorheight, frontsector->floorpic, floorlightlevel, floorplane = R_FindPlane(frontsector->floorheight, frontsector->floorpic, floorlightlevel,
frontsector->floorxoffset, frontsector->flooryoffset, frontsector->floorangle, floorcolormap, NULL, NULL, frontsector->f_slope); frontsector->floorxoffset, frontsector->flooryoffset,
frontsector->floorxscale, frontsector->flooryscale, frontsector->floorangle,
floorcolormap, NULL, NULL, frontsector->f_slope);
} }
else else
floorplane = NULL; floorplane = NULL;
@ -918,8 +936,9 @@ static void R_Subsector(size_t num)
|| frontsector->ceilingpic == skyflatnum || frontsector->ceilingpic == skyflatnum
|| (frontsector->heightsec != -1 && sectors[frontsector->heightsec].floorpic == skyflatnum)) || (frontsector->heightsec != -1 && sectors[frontsector->heightsec].floorpic == skyflatnum))
{ {
ceilingplane = R_FindPlane(frontsector->ceilingheight, frontsector->ceilingpic, ceilingplane = R_FindPlane(frontsector->ceilingheight, frontsector->ceilingpic, ceilinglightlevel,
ceilinglightlevel, frontsector->ceilingxoffset, frontsector->ceilingyoffset, frontsector->ceilingangle, frontsector->ceilingxoffset, frontsector->ceilingyoffset,
frontsector->ceilingxscale, frontsector->ceilingyscale, frontsector->ceilingangle,
ceilingcolormap, NULL, NULL, frontsector->c_slope); ceilingcolormap, NULL, NULL, frontsector->c_slope);
} }
else else
@ -962,8 +981,9 @@ static void R_Subsector(size_t num)
viewz < heightcheck); viewz < heightcheck);
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->bottomyoffs, *rover->bottomangle, *frontsector->lightlist[light].extra_colormap, rover, NULL, *rover->b_slope); *rover->bottomxscale, *rover->bottomyscale, *rover->bottomangle,
*frontsector->lightlist[light].extra_colormap, rover, NULL, *rover->b_slope);
ffloor[numffloors].slope = *rover->b_slope; ffloor[numffloors].slope = *rover->b_slope;
@ -991,7 +1011,8 @@ static void R_Subsector(size_t num)
light = R_GetPlaneLight(frontsector, planecenterz, viewz < heightcheck); light = R_GetPlaneLight(frontsector, planecenterz, viewz < heightcheck);
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->topxscale, *rover->topyscale, *rover->topangle,
*frontsector->lightlist[light].extra_colormap, rover, NULL, *rover->t_slope); *frontsector->lightlist[light].extra_colormap, rover, NULL, *rover->t_slope);
ffloor[numffloors].slope = *rover->t_slope; ffloor[numffloors].slope = *rover->t_slope;
@ -1033,7 +1054,9 @@ static void R_Subsector(size_t num)
{ {
light = R_GetPlaneLight(frontsector, polysec->floorheight, viewz < polysec->floorheight); light = R_GetPlaneLight(frontsector, polysec->floorheight, viewz < polysec->floorheight);
ffloor[numffloors].plane = R_FindPlane(polysec->floorheight, polysec->floorpic, ffloor[numffloors].plane = R_FindPlane(polysec->floorheight, polysec->floorpic,
(light == -1 ? frontsector->lightlevel : *frontsector->lightlist[light].lightlevel), polysec->floorxoffset, polysec->flooryoffset, (light == -1 ? frontsector->lightlevel : *frontsector->lightlist[light].lightlevel),
polysec->floorxoffset, polysec->flooryoffset,
polysec->floorxscale, polysec->flooryscale,
polysec->floorangle-po->angle, polysec->floorangle-po->angle,
(light == -1 ? frontsector->extra_colormap : *frontsector->lightlist[light].extra_colormap), NULL, po, (light == -1 ? frontsector->extra_colormap : *frontsector->lightlist[light].extra_colormap), NULL, po,
NULL); // will ffloors be slopable eventually? NULL); // will ffloors be slopable eventually?
@ -1057,7 +1080,10 @@ static void R_Subsector(size_t num)
{ {
light = R_GetPlaneLight(frontsector, polysec->floorheight, viewz < polysec->floorheight); light = R_GetPlaneLight(frontsector, polysec->floorheight, viewz < polysec->floorheight);
ffloor[numffloors].plane = R_FindPlane(polysec->ceilingheight, polysec->ceilingpic, ffloor[numffloors].plane = R_FindPlane(polysec->ceilingheight, polysec->ceilingpic,
(light == -1 ? frontsector->lightlevel : *frontsector->lightlist[light].lightlevel), polysec->ceilingxoffset, polysec->ceilingyoffset, polysec->ceilingangle-po->angle, (light == -1 ? frontsector->lightlevel : *frontsector->lightlist[light].lightlevel),
polysec->ceilingxoffset, polysec->ceilingyoffset,
polysec->ceilingxscale, polysec->ceilingyscale,
polysec->ceilingangle-po->angle,
(light == -1 ? frontsector->extra_colormap : *frontsector->lightlist[light].extra_colormap), NULL, po, (light == -1 ? frontsector->extra_colormap : *frontsector->lightlist[light].extra_colormap), NULL, po,
NULL); // will ffloors be slopable eventually? NULL); // will ffloors be slopable eventually?

View file

@ -438,7 +438,7 @@ extracolormap_t *R_CreateDefaultColormap(boolean lighttable)
exc->fadeend = 31; exc->fadeend = 31;
exc->flags = 0; exc->flags = 0;
exc->rgba = 0; exc->rgba = 0;
exc->fadergba = 0x19000000; exc->fadergba = 0xFF000000;
exc->colormap = lighttable ? R_CreateLightTable(exc) : NULL; exc->colormap = lighttable ? R_CreateLightTable(exc) : NULL;
#ifdef EXTRACOLORMAPLUMPS #ifdef EXTRACOLORMAPLUMPS
exc->lump = LUMPERROR; exc->lump = LUMPERROR;
@ -553,7 +553,7 @@ boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba,
&& !flags) && !flags)
) )
&& (!checkrgba ? true : rgba == 0) && (!checkrgba ? true : rgba == 0)
&& (!checkfadergba ? true : fadergba == 0x19000000) && (!checkfadergba ? true : (unsigned)fadergba == 0xFF000000)
#ifdef EXTRACOLORMAPLUMPS #ifdef EXTRACOLORMAPLUMPS
&& lump == LUMPERROR && lump == LUMPERROR
&& extra_colormap->lumpname[0] == 0 && extra_colormap->lumpname[0] == 0
@ -654,7 +654,7 @@ extracolormap_t *R_ColormapForName(char *name)
if (lump == LUMPERROR) if (lump == LUMPERROR)
I_Error("R_ColormapForName: Cannot find colormap lump %.8s\n", name); I_Error("R_ColormapForName: Cannot find colormap lump %.8s\n", name);
exc = R_GetColormapFromListByValues(0, 0x19000000, 0, 31, 0, lump); exc = R_GetColormapFromListByValues(0, 0xFF000000, 0, 31, 0, lump);
if (exc) if (exc)
return exc; return exc;
@ -674,7 +674,7 @@ extracolormap_t *R_ColormapForName(char *name)
exc->fadeend = 31; exc->fadeend = 31;
exc->flags = 0; exc->flags = 0;
exc->rgba = 0; exc->rgba = 0;
exc->fadergba = 0x19000000; exc->fadergba = 0xFF000000;
R_AddColormapToList(exc); R_AddColormapToList(exc);
@ -692,9 +692,26 @@ extracolormap_t *R_ColormapForName(char *name)
// //
static double deltas[256][3], map[256][3]; static double deltas[256][3], map[256][3];
static int RoundUp(double number); static colorlookup_t lighttable_lut;
static UINT8 LightTableNearest(UINT8 r, UINT8 g, UINT8 b)
{
return NearestColor(r, g, b);
}
static UINT8 LightTableNearest_LUT(UINT8 r, UINT8 g, UINT8 b)
{
return GetColorLUT(&lighttable_lut, r, g, b);
}
lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap)
{
extra_colormap->colormap = Z_MallocAlign((256 * 34) + 10, PU_LEVEL, NULL, 8);
R_GenerateLightTable(extra_colormap, false);
return extra_colormap->colormap;
}
void R_GenerateLightTable(extracolormap_t *extra_colormap, boolean uselookup)
{ {
double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb; double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb;
double maskamt = 0, othermask = 0; double maskamt = 0, othermask = 0;
@ -711,7 +728,6 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap)
UINT8 fadestart = extra_colormap->fadestart, UINT8 fadestart = extra_colormap->fadestart,
fadedist = extra_colormap->fadeend - extra_colormap->fadestart; fadedist = extra_colormap->fadeend - extra_colormap->fadestart;
lighttable_t *lighttable = NULL;
size_t i; size_t i;
///////////////////// /////////////////////
@ -721,7 +737,7 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap)
cmaskg = cg; cmaskg = cg;
cmaskb = cb; cmaskb = cb;
maskamt = (double)(ca/24.0l); maskamt = (double)(ca/255.0l);
othermask = 1 - maskamt; othermask = 1 - maskamt;
maskamt /= 0xff; maskamt /= 0xff;
@ -737,7 +753,7 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap)
cdestb = cfb; cdestb = cfb;
// fade alpha unused in software // fade alpha unused in software
// maskamt = (double)(cfa/24.0l); // maskamt = (double)(cfa/255.0l);
// othermask = 1 - maskamt; // othermask = 1 - maskamt;
// maskamt /= 0xff; // maskamt /= 0xff;
@ -753,6 +769,16 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap)
int p; int p;
char *colormap_p; char *colormap_p;
UINT8 (*NearestColorFunc)(UINT8, UINT8, UINT8);
if (uselookup)
{
InitColorLUT(&lighttable_lut, pMasterPalette, false);
NearestColorFunc = LightTableNearest_LUT;
}
else
NearestColorFunc = LightTableNearest;
// Initialise the map and delta arrays // Initialise the map and delta arrays
// map[i] stores an RGB color (as double) for index i, // map[i] stores an RGB color (as double) for index i,
// which is then converted to SRB2's palette later // which is then converted to SRB2's palette later
@ -783,8 +809,7 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap)
// Now allocate memory for the actual colormap array itself! // Now allocate memory for the actual colormap array itself!
// aligned on 8 bit for asm code // aligned on 8 bit for asm code
colormap_p = Z_MallocAlign((256 * 34) + 10, PU_LEVEL, NULL, 8); colormap_p = (char *)extra_colormap->colormap;
lighttable = (UINT8 *)colormap_p;
// Calculate the palette index for each palette index, for each light level // Calculate the palette index for each palette index, for each light level
// (as well as the two unused colormap lines we inherited from Doom) // (as well as the two unused colormap lines we inherited from Doom)
@ -792,9 +817,9 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap)
{ {
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
{ {
*colormap_p = NearestColor((UINT8)RoundUp(map[i][0]), *colormap_p = NearestColorFunc((UINT8)M_RoundUp(map[i][0]),
(UINT8)RoundUp(map[i][1]), (UINT8)M_RoundUp(map[i][1]),
(UINT8)RoundUp(map[i][2])); (UINT8)M_RoundUp(map[i][2]));
colormap_p++; colormap_p++;
if ((UINT32)p < fadestart) if ((UINT32)p < fadestart)
@ -818,8 +843,6 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap)
} }
} }
} }
return lighttable;
} }
extracolormap_t *R_CreateColormapFromLinedef(char *p1, char *p2, char *p3) extracolormap_t *R_CreateColormapFromLinedef(char *p1, char *p2, char *p3)
@ -828,7 +851,7 @@ extracolormap_t *R_CreateColormapFromLinedef(char *p1, char *p2, char *p3)
UINT8 cr = 0, cg = 0, cb = 0, ca = 0, cfr = 0, cfg = 0, cfb = 0, cfa = 25; UINT8 cr = 0, cg = 0, cb = 0, ca = 0, cfr = 0, cfg = 0, cfb = 0, cfa = 25;
UINT32 fadestart = 0, fadeend = 31; UINT32 fadestart = 0, fadeend = 31;
UINT8 flags = 0; UINT8 flags = 0;
INT32 rgba = 0, fadergba = 0x19000000; INT32 rgba = 0, fadergba = 0xFF000000;
#define HEX2INT(x) (UINT32)(x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) #define HEX2INT(x) (UINT32)(x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0)
#define ALPHA2INT(x) (x >= 'a' && x <= 'z' ? x - 'a' : x >= 'A' && x <= 'Z' ? x - 'A' : x >= '0' && x <= '9' ? 25 : 0) #define ALPHA2INT(x) (x >= 'a' && x <= 'z' ? x - 'a' : x >= 'A' && x <= 'Z' ? x - 'A' : x >= '0' && x <= '9' ? 25 : 0)
@ -836,13 +859,13 @@ extracolormap_t *R_CreateColormapFromLinedef(char *p1, char *p2, char *p3)
// Get base colormap value // Get base colormap value
// First alpha-only, then full value // First alpha-only, then full value
if (p1[0] >= 'a' && p1[0] <= 'z' && !p1[1]) if (p1[0] >= 'a' && p1[0] <= 'z' && !p1[1])
ca = (p1[0] - 'a'); ca = ((p1[0] - 'a') * 102) / 10;
else if (p1[0] == '#' && p1[1] >= 'a' && p1[1] <= 'z' && !p1[2]) else if (p1[0] == '#' && p1[1] >= 'a' && p1[1] <= 'z' && !p1[2])
ca = (p1[1] - 'a'); ca = ((p1[1] - 'a') * 102) / 10;
else if (p1[0] >= 'A' && p1[0] <= 'Z' && !p1[1]) else if (p1[0] >= 'A' && p1[0] <= 'Z' && !p1[1])
ca = (p1[0] - 'A'); ca = ((p1[0] - 'A') * 102) / 10;
else if (p1[0] == '#' && p1[1] >= 'A' && p1[1] <= 'Z' && !p1[2]) else if (p1[0] == '#' && p1[1] >= 'A' && p1[1] <= 'Z' && !p1[2])
ca = (p1[1] - 'A'); ca = ((p1[1] - 'A') * 102) / 10;
else if (p1[0] == '#') else if (p1[0] == '#')
{ {
// For each subsequent value, the value before it must exist // For each subsequent value, the value before it must exist
@ -858,20 +881,20 @@ extracolormap_t *R_CreateColormapFromLinedef(char *p1, char *p2, char *p3)
cb = ((HEX2INT(p1[5]) * 16) + HEX2INT(p1[6])); cb = ((HEX2INT(p1[5]) * 16) + HEX2INT(p1[6]));
if (p1[7] >= 'a' && p1[7] <= 'z') if (p1[7] >= 'a' && p1[7] <= 'z')
ca = (p1[7] - 'a'); ca = ((p1[7] - 'a') * 102) / 10;
else if (p1[7] >= 'A' && p1[7] <= 'Z') else if (p1[7] >= 'A' && p1[7] <= 'Z')
ca = (p1[7] - 'A'); ca = ((p1[7] - 'A') * 102) / 10;
else else
ca = 25; ca = 255;
} }
else else
ca = 25; ca = 255;
} }
else else
ca = 25; ca = 255;
} }
else else
ca = 25; ca = 255;
} }
#define NUMFROMCHAR(c) (c >= '0' && c <= '9' ? c - '0' : 0) #define NUMFROMCHAR(c) (c >= '0' && c <= '9' ? c - '0' : 0)
@ -901,13 +924,13 @@ extracolormap_t *R_CreateColormapFromLinedef(char *p1, char *p2, char *p3)
// Get fade (dark) colormap value // Get fade (dark) colormap value
// First alpha-only, then full value // First alpha-only, then full value
if (p3[0] >= 'a' && p3[0] <= 'z' && !p3[1]) if (p3[0] >= 'a' && p3[0] <= 'z' && !p3[1])
cfa = (p3[0] - 'a'); cfa = ((p3[0] - 'a') * 102) / 10;
else if (p3[0] == '#' && p3[1] >= 'a' && p3[1] <= 'z' && !p3[2]) else if (p3[0] == '#' && p3[1] >= 'a' && p3[1] <= 'z' && !p3[2])
cfa = (p3[1] - 'a'); cfa = ((p3[1] - 'a') * 102) / 10;
else if (p3[0] >= 'A' && p3[0] <= 'Z' && !p3[1]) else if (p3[0] >= 'A' && p3[0] <= 'Z' && !p3[1])
cfa = (p3[0] - 'A'); cfa = ((p3[0] - 'A') * 102) / 10;
else if (p3[0] == '#' && p3[1] >= 'A' && p3[1] <= 'Z' && !p3[2]) else if (p3[0] == '#' && p3[1] >= 'A' && p3[1] <= 'Z' && !p3[2])
cfa = (p3[1] - 'A'); cfa = ((p3[1] - 'A') * 102) / 10;
else if (p3[0] == '#') else if (p3[0] == '#')
{ {
// For each subsequent value, the value before it must exist // For each subsequent value, the value before it must exist
@ -923,20 +946,20 @@ extracolormap_t *R_CreateColormapFromLinedef(char *p1, char *p2, char *p3)
cfb = ((HEX2INT(p3[5]) * 16) + HEX2INT(p3[6])); cfb = ((HEX2INT(p3[5]) * 16) + HEX2INT(p3[6]));
if (p3[7] >= 'a' && p3[7] <= 'z') if (p3[7] >= 'a' && p3[7] <= 'z')
cfa = (p3[7] - 'a'); cfa = ((p3[7] - 'a') * 102) / 10;
else if (p3[7] >= 'A' && p3[7] <= 'Z') else if (p3[7] >= 'A' && p3[7] <= 'Z')
cfa = (p3[7] - 'A'); cfa = ((p3[7] - 'A') * 102) / 10;
else else
cfa = 25; cfa = 255;
} }
else else
cfa = 25; cfa = 255;
} }
else else
cfa = 25; cfa = 255;
} }
else else
cfa = 25; cfa = 255;
} }
#undef ALPHA2INT #undef ALPHA2INT
#undef HEX2INT #undef HEX2INT
@ -1133,20 +1156,6 @@ UINT8 NearestPaletteColor(UINT8 r, UINT8 g, UINT8 b, RGBA_t *palette)
return (UINT8)bestcolor; return (UINT8)bestcolor;
} }
// Rounds off floating numbers and checks for 0 - 255 bounds
static int RoundUp(double number)
{
if (number > 255.0l)
return 255;
if (number < 0.0l)
return 0;
if ((int)number <= (int)(number - 0.5f))
return (int)number + 1;
return (int)number;
}
#ifdef EXTRACOLORMAPLUMPS #ifdef EXTRACOLORMAPLUMPS
const char *R_NameForColormap(extracolormap_t *extra_colormap) const char *R_NameForColormap(extracolormap_t *extra_colormap)
{ {

View file

@ -92,6 +92,7 @@ typedef enum
TMCF_OVERRIDE = 1<<13, TMCF_OVERRIDE = 1<<13,
} textmapcolormapflags_t; } textmapcolormapflags_t;
void R_GenerateLightTable(extracolormap_t *extra_colormap, boolean uselookup);
lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap);
extracolormap_t * R_CreateColormapFromLinedef(char *p1, char *p2, char *p3); extracolormap_t * R_CreateColormapFromLinedef(char *p1, char *p2, char *p3);
extracolormap_t* R_CreateColormap(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags); extracolormap_t* R_CreateColormap(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags);

View file

@ -53,6 +53,9 @@ typedef struct
// Could even use more than 32 levels. // Could even use more than 32 levels.
typedef UINT8 lighttable_t; typedef UINT8 lighttable_t;
#define NUM_PALETTE_ENTRIES 256
#define DEFAULT_STARTTRANSCOLOR 96
#define CMF_FADEFULLBRIGHTSPRITES 1 #define CMF_FADEFULLBRIGHTSPRITES 1
#define CMF_FOG 4 #define CMF_FOG 4
@ -215,12 +218,16 @@ typedef struct ffloor_s
INT16 *toplightlevel; INT16 *toplightlevel;
fixed_t *topxoffs; fixed_t *topxoffs;
fixed_t *topyoffs; fixed_t *topyoffs;
fixed_t *topxscale;
fixed_t *topyscale;
angle_t *topangle; angle_t *topangle;
fixed_t *bottomheight; fixed_t *bottomheight;
INT32 *bottompic; INT32 *bottompic;
fixed_t *bottomxoffs; fixed_t *bottomxoffs;
fixed_t *bottomyoffs; fixed_t *bottomyoffs;
fixed_t *bottomxscale;
fixed_t *bottomyscale;
angle_t *bottomangle; angle_t *bottomangle;
// Pointers to pointers. Yup. // Pointers to pointers. Yup.
@ -426,6 +433,10 @@ typedef struct sector_s
fixed_t floorxoffset, flooryoffset; fixed_t floorxoffset, flooryoffset;
fixed_t ceilingxoffset, ceilingyoffset; fixed_t ceilingxoffset, ceilingyoffset;
// floor and ceiling texture scale
fixed_t floorxscale, flooryscale;
fixed_t ceilingxscale, ceilingyscale;
// flat angle // flat angle
angle_t floorangle; angle_t floorangle;
angle_t ceilingangle; angle_t ceilingangle;
@ -512,6 +523,8 @@ typedef enum
#define NUMLINEARGS 10 #define NUMLINEARGS 10
#define NUMLINESTRINGARGS 2 #define NUMLINESTRINGARGS 2
#define NO_SIDEDEF 0xFFFFFFFF
typedef struct line_s typedef struct line_s
{ {
// Vertices, from v1 to v2. // Vertices, from v1 to v2.
@ -529,7 +542,7 @@ typedef struct line_s
char *stringargs[NUMLINESTRINGARGS]; char *stringargs[NUMLINESTRINGARGS];
// Visual appearance: sidedefs. // Visual appearance: sidedefs.
UINT16 sidenum[2]; // sidenum[1] will be 0xffff if one-sided UINT32 sidenum[2]; // sidenum[1] will be NO_SIDEDEF if one-sided
fixed_t alpha; // translucency fixed_t alpha; // translucency
UINT8 blendmode; // blendmode UINT8 blendmode; // blendmode
INT32 executordelay; INT32 executordelay;
@ -559,8 +572,11 @@ typedef struct
fixed_t rowoffset; fixed_t rowoffset;
// per-texture offsets for UDMF // per-texture offsets for UDMF
fixed_t offsetx_top, offsetx_mid, offsetx_bot; fixed_t offsetx_top, offsetx_mid, offsetx_bottom;
fixed_t offsety_top, offsety_mid, offsety_bot; fixed_t offsety_top, offsety_mid, offsety_bottom;
fixed_t scalex_top, scalex_mid, scalex_bottom;
fixed_t scaley_top, scaley_mid, scaley_bottom;
// Texture indices. // Texture indices.
// We do not maintain names here. // We do not maintain names here.
@ -754,10 +770,13 @@ typedef struct drawseg_s
fixed_t bsilheight; // do not clip sprites above this fixed_t bsilheight; // do not clip sprites above this
fixed_t tsilheight; // do not clip sprites below this fixed_t tsilheight; // do not clip sprites below this
fixed_t offsetx;
// Pointers to lists for sprite clipping, all three adjusted so [x1] is first value. // Pointers to lists for sprite clipping, all three adjusted so [x1] is first value.
INT16 *sprtopclip; INT16 *sprtopclip;
INT16 *sprbottomclip; INT16 *sprbottomclip;
fixed_t *maskedtexturecol; fixed_t *maskedtexturecol;
fixed_t *invscale;
struct visplane_s *ffloorplanes[MAXFFLOORS]; struct visplane_s *ffloorplanes[MAXFFLOORS];
INT32 numffloorplanes; INT32 numffloorplanes;
@ -922,7 +941,7 @@ typedef struct
UINT16 flip; UINT16 flip;
#ifdef ROTSPRITE #ifdef ROTSPRITE
rotsprite_t *rotated[2][16]; // Rotated patches rotsprite_t *rotated[16]; // Rotated patches
#endif #endif
} spriteframe_t; } spriteframe_t;

View file

@ -106,14 +106,13 @@ fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep;
INT32 ds_waterofs, ds_bgofs; INT32 ds_waterofs, ds_bgofs;
UINT16 ds_flatwidth, ds_flatheight; UINT16 ds_flatwidth, ds_flatheight;
boolean ds_powersoftwo, ds_solidcolor; boolean ds_powersoftwo, ds_solidcolor, ds_fog;
UINT8 *ds_source; // points to the start of a flat UINT8 *ds_source; // points to the start of a flat
UINT8 *ds_transmap; // one of the translucency tables UINT8 *ds_transmap; // one of the translucency tables
// Vectors for Software's tilted slope drawers // Vectors for Software's tilted slope drawers
floatv3_t *ds_su, *ds_sv, *ds_sz; floatv3_t ds_su, ds_sv, ds_sz, ds_slopelight;
floatv3_t *ds_sup, *ds_svp, *ds_szp;
float focallengthf, zeroheight; float focallengthf, zeroheight;
/** \brief Variable flat sizes /** \brief Variable flat sizes
@ -132,8 +131,6 @@ UINT32 nflatxshift, nflatyshift, nflatshiftup, nflatmask;
#define RAINBOW_TT_CACHE_INDEX (MAXSKINS + 4) #define RAINBOW_TT_CACHE_INDEX (MAXSKINS + 4)
#define BLINK_TT_CACHE_INDEX (MAXSKINS + 5) #define BLINK_TT_CACHE_INDEX (MAXSKINS + 5)
#define DASHMODE_TT_CACHE_INDEX (MAXSKINS + 6) #define DASHMODE_TT_CACHE_INDEX (MAXSKINS + 6)
#define DEFAULT_STARTTRANSCOLOR 96
#define NUM_PALETTE_ENTRIES 256
static UINT8 **translationtablecache[MAXSKINS + 7] = {NULL}; static UINT8 **translationtablecache[MAXSKINS + 7] = {NULL};
UINT8 skincolor_modified[MAXSKINCOLORS]; UINT8 skincolor_modified[MAXSKINCOLORS];
@ -908,13 +905,15 @@ static void R_CalcTiltedLighting(fixed_t start, fixed_t end)
} }
} }
#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / zeroheight / 21.0f * FIXED_TO_FLOAT(fovtan))
// Lighting is simple. It's just linear interpolation from start to end // Lighting is simple. It's just linear interpolation from start to end
#define CALC_SLOPE_LIGHT { \ static void R_CalcSlopeLight(void)
float planelightfloat = PLANELIGHTFLOAT; \ {
float lightstart, lightend; \ float iz = ds_slopelight.z + ds_slopelight.y * (centery - ds_y) + ds_slopelight.x * (ds_x1 - centerx);
lightend = (iz + ds_szp->x*width) * planelightfloat; \ float lightstart = iz * PLANELIGHTFLOAT;
lightstart = iz * planelightfloat; \ float lightend = (iz + ds_slopelight.x * (ds_x2 - ds_x1)) * PLANELIGHTFLOAT;
R_CalcTiltedLighting(FloatToFixed(lightstart), FloatToFixed(lightend)); \ R_CalcTiltedLighting(FloatToFixed(lightstart), FloatToFixed(lightend));
} }
// ========================================================================== // ==========================================================================

View file

@ -61,7 +61,7 @@ extern fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep;
extern INT32 ds_waterofs, ds_bgofs; extern INT32 ds_waterofs, ds_bgofs;
extern UINT16 ds_flatwidth, ds_flatheight; extern UINT16 ds_flatwidth, ds_flatheight;
extern boolean ds_powersoftwo, ds_solidcolor; extern boolean ds_powersoftwo, ds_solidcolor, ds_fog;
extern UINT8 *ds_source; extern UINT8 *ds_source;
extern UINT8 *ds_transmap; extern UINT8 *ds_transmap;
@ -71,8 +71,7 @@ typedef struct {
} floatv3_t; } floatv3_t;
// Vectors for Software's tilted slope drawers // Vectors for Software's tilted slope drawers
extern floatv3_t *ds_su, *ds_sv, *ds_sz; extern floatv3_t ds_su, ds_sv, ds_sz, ds_slopelight;
extern floatv3_t *ds_sup, *ds_svp, *ds_szp;
extern float focallengthf, zeroheight; extern float focallengthf, zeroheight;
// Variable flat sizes // Variable flat sizes
@ -178,8 +177,6 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void);
void R_DrawFogColumn_8(void); void R_DrawFogColumn_8(void);
void R_DrawColumnShadowed_8(void); void R_DrawColumnShadowed_8(void);
#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / zeroheight / 21.0f * FIXED_TO_FLOAT(fovtan))
void R_DrawSpan_8(void); void R_DrawSpan_8(void);
void R_DrawTranslucentSpan_8(void); void R_DrawTranslucentSpan_8(void);
void R_DrawTiltedSpan_8(void); void R_DrawTiltedSpan_8(void);

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