mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-04 15:31:21 +00:00
Merge branch 'next' into fix-exotic-prids
This commit is contained in:
commit
87df46facd
330 changed files with 38682 additions and 26660 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -13,11 +13,11 @@ Win32_LIB_ASM_Release
|
|||
*.dgb
|
||||
*.debug
|
||||
*.debug.txt
|
||||
/bin/VC10/
|
||||
/objs/VC10/
|
||||
*.user
|
||||
*.db
|
||||
*.opendb
|
||||
/.vs
|
||||
/debian
|
||||
/assets/debian
|
||||
/make
|
||||
/bin
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
cmake_minimum_required(VERSION 3.0)
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
# Enable CCache early
|
||||
set(SRB2_USE_CCACHE OFF CACHE BOOL "Use CCache")
|
||||
|
@ -34,12 +34,11 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
|
|||
|
||||
### Useful functions
|
||||
|
||||
# Prepend sources with current source directory
|
||||
function(prepend_sources SOURCE_FILES)
|
||||
foreach(SOURCE_FILE ${${SOURCE_FILES}})
|
||||
set(MODIFIED ${MODIFIED} ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_FILE})
|
||||
endforeach()
|
||||
set(${SOURCE_FILES} ${MODIFIED} PARENT_SCOPE)
|
||||
# Add sources from Sourcefile
|
||||
function(target_sourcefile type)
|
||||
file(STRINGS Sourcefile list
|
||||
REGEX "[-0-9A-Za-z_]+\.${type}")
|
||||
target_sources(SRB2SDL2 PRIVATE ${list})
|
||||
endfunction()
|
||||
|
||||
# Macro to add OSX framework
|
||||
|
|
8
Makefile
Normal file
8
Makefile
Normal file
|
@ -0,0 +1,8 @@
|
|||
ifdef SILENT
|
||||
MAKEFLAGS+=--no-print-directory
|
||||
endif
|
||||
|
||||
all :
|
||||
|
||||
% ::
|
||||
@$(MAKE) -C src $(MAKECMDGOALS)
|
|
@ -1,4 +1,5 @@
|
|||
# Sonic Robo Blast 2
|
||||
[![latest release](https://badgen.net/github/release/STJr/SRB2/stable)](https://github.com/STJr/SRB2/releases/latest)
|
||||
|
||||
[![Build status](https://ci.appveyor.com/api/projects/status/399d4hcw9yy7hg2y?svg=true)](https://ci.appveyor.com/project/STJr/srb2)
|
||||
[![Build status](https://travis-ci.org/STJr/SRB2.svg?branch=master)](https://travis-ci.org/STJr/SRB2)
|
||||
|
|
36
appveyor.yml
36
appveyor.yml
|
@ -1,16 +1,12 @@
|
|||
version: 2.2.8.{branch}-{build}
|
||||
version: 2.2.10.{branch}-{build}
|
||||
os: MinGW
|
||||
|
||||
environment:
|
||||
CC: ccache
|
||||
CCACHE_CC: i686-w64-mingw32-gcc
|
||||
CCACHE_CC_64: x86_64-w64-mingw32-gcc
|
||||
CC: i686-w64-mingw32-gcc
|
||||
WINDRES: windres
|
||||
# c:\mingw-w64 i686 has gcc 6.3.0, so use c:\msys64 7.3.0 instead
|
||||
MINGW_SDK: c:\msys64\mingw32
|
||||
# c:\msys64 x86_64 has gcc 8.2.0, so use c:\mingw-w64 7.3.0 instead
|
||||
MINGW_SDK_64: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64
|
||||
CFLAGS: -Wall -W -Werror -Wno-error=implicit-fallthrough -Wimplicit-fallthrough=3 -Wno-tautological-compare -Wno-error=suggest-attribute=noreturn
|
||||
CFLAGS: -Wno-implicit-fallthrough
|
||||
NASM_ZIP: nasm-2.12.01
|
||||
NASM_URL: http://www.nasm.us/pub/nasm/releasebuilds/2.12.01/win64/nasm-2.12.01-win64.zip
|
||||
UPX_ZIP: upx391w
|
||||
|
@ -19,8 +15,6 @@ environment:
|
|||
CCACHE_URL: http://alam.srb2.org/ccache.exe
|
||||
CCACHE_COMPRESS: true
|
||||
CCACHE_DIR: C:\Users\appveyor\.ccache
|
||||
# Disable UPX by default. The user can override this in their Appveyor project settings
|
||||
NOUPX: 1
|
||||
##############################
|
||||
# DEPLOYER VARIABLES
|
||||
# DPL_ENABLED=1 builds installers for branch names starting with `deployer`.
|
||||
|
@ -53,11 +47,6 @@ cache:
|
|||
- C:\Users\appveyor\srb2_cache
|
||||
|
||||
install:
|
||||
- if [%CONFIGURATION%] == [SDL64] ( set "X86_64=1" )
|
||||
- if [%CONFIGURATION%] == [SDL64] ( set "CONFIGURATION=SDL" )
|
||||
- if [%X86_64%] == [1] ( set "MINGW_SDK=%MINGW_SDK_64%" )
|
||||
- if [%X86_64%] == [1] ( set "CCACHE_CC=%CCACHE_CC_64%" )
|
||||
|
||||
- if not exist "%NASM_ZIP%.zip" appveyor DownloadFile "%NASM_URL%" -FileName "%NASM_ZIP%.zip"
|
||||
- 7z x -y "%NASM_ZIP%.zip" -o%TMP% >null
|
||||
- robocopy /S /xx /ns /nc /nfl /ndl /np /njh /njs "%TMP%\%NASM_ZIP%" "%MINGW_SDK%\bin" nasm.exe || exit 0
|
||||
|
@ -72,43 +61,31 @@ install:
|
|||
|
||||
configuration:
|
||||
- SDL
|
||||
- SDL64
|
||||
|
||||
before_build:
|
||||
- set "Path=%MINGW_SDK%\bin;%Path%"
|
||||
- if [%X86_64%] == [1] ( x86_64-w64-mingw32-gcc --version ) else ( i686-w64-mingw32-gcc --version )
|
||||
- mingw32-make --version
|
||||
- if not [%X86_64%] == [1] ( nasm -v )
|
||||
- nasm -v
|
||||
- if not [%NOUPX%] == [1] ( upx -V )
|
||||
- ccache -V
|
||||
- ccache -s
|
||||
- if [%NOUPX%] == [1] ( set "NOUPX=NOUPX=1" ) else ( set "NOUPX=" )
|
||||
- if defined [%APPVEYOR_PULL_REQUEST_HEAD_COMMIT%] ( set "COMMIT=%APPVEYOR_PULL_REQUEST_HEAD_COMMIT%" ) else ( set "COMMIT=%APPVEYOR_REPO_COMMIT%" )
|
||||
- cmd: git rev-parse --short %COMMIT%>%TMP%/gitshort.txt
|
||||
- cmd: set /P GITSHORT=<%TMP%/gitshort.txt
|
||||
# for pull requests, take the owner's name only, if this isn't the same repo of course
|
||||
- set "REPO=%APPVEYOR_REPO_BRANCH%"
|
||||
- if not [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [] ( if not [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [%APPVEYOR_REPO_NAME%] ( for /f "delims=/" %%a in ("%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%") do set "REPO=%%a-%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%" ) )
|
||||
- set "EXENAME=EXENAME=srb2win-%REPO%-%GITSHORT%.exe"
|
||||
- set "SRB2_MFLAGS=-C src WARNINGMODE=1 CCACHE=1 NOOBJDUMP=1 %NOUPX% %EXENAME%"
|
||||
- if [%X86_64%] == [1] ( set "MINGW_FLAGS=MINGW64=1 X86_64=1 GCC81=1" ) else ( set "MINGW_FLAGS=MINGW=1 GCC91=1" )
|
||||
- set "SRB2_MFLAGS=%SRB2_MFLAGS% %MINGW_FLAGS% %CONFIGURATION%=1"
|
||||
- set "SRB2_MFLAGS=-C src NOECHOFILENAMES=1 CCACHE=1 EXENAME=srb2win-%REPO%-%GITSHORT%.exe"
|
||||
|
||||
build_script:
|
||||
- cmd: mingw32-make.exe %SRB2_MFLAGS% clean
|
||||
- cmd: mingw32-make.exe %SRB2_MFLAGS% ERRORMODE=1 -k
|
||||
|
||||
after_build:
|
||||
- if [%X86_64%] == [1] (
|
||||
set "BUILD_PATH=bin\Mingw64\Release"
|
||||
) else (
|
||||
set "BUILD_PATH=bin\Mingw\Release"
|
||||
)
|
||||
- if [%X86_64%] == [1] ( set "CONFIGURATION=%CONFIGURATION%64" )
|
||||
- ccache -s
|
||||
- set BUILD_ARCHIVE=%REPO%-%GITSHORT%-%CONFIGURATION%.7z
|
||||
- set BUILDSARCHIVE=%REPO%-%CONFIGURATION%.7z
|
||||
- cmd: 7z a %BUILD_ARCHIVE% %BUILD_PATH% -xr!.gitignore
|
||||
- cmd: 7z a %BUILD_ARCHIVE% bin -xr!.gitignore
|
||||
- appveyor PushArtifact %BUILD_ARCHIVE%
|
||||
#- cmd: copy %BUILD_ARCHIVE% %BUILDSARCHIVE%
|
||||
#- appveyor PushArtifact %BUILDSARCHIVE%
|
||||
|
@ -139,3 +116,4 @@ test: off
|
|||
on_finish:
|
||||
#- cmd: echo xfreerdp /u:appveyor /cert-ignore +clipboard /v:<ip>:<port>
|
||||
#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
||||
# vim: et ts=1
|
||||
|
|
|
@ -22,8 +22,7 @@ set(SRB2_ASSET_INSTALL ON
|
|||
set(SRB2_ASSET_HASHED
|
||||
"srb2.pk3;\
|
||||
player.dta;\
|
||||
zones.pk3;\
|
||||
patch.pk3"
|
||||
zones.pk3"
|
||||
CACHE STRING "Asset filenames to apply MD5 checks. No spaces between entries!"
|
||||
)
|
||||
|
||||
|
|
|
@ -1,24 +1,21 @@
|
|||
SONIC ROBO BLAST 2
|
||||
|
||||
Sonic Robo Blast 2 (SRB2) is a 3D Sonic the Hedgehog fangame based on a
|
||||
modified version of Doom Legacy.
|
||||
Sonic Robo Blast 2 (SRB2) is a 3D Sonic the Hedgehog fangame, based on a modified version of Doom Legacy.
|
||||
|
||||
https://www.srb2.org
|
||||
|
||||
LICENSE
|
||||
|
||||
The source code for SRB2 is licensed under the GNU General Public
|
||||
License, Version 2. See LICENSE.txt for the full text of this license.
|
||||
The source code for SRB2 is licensed under the GNU General Public License, Version 2. See LICENSE.txt for the full text of this license.
|
||||
|
||||
SRB2 uses various third-party libraries, including SDL, SDL Mixer, and
|
||||
their dependencies. See LICENSE-3RD-PARTY.txt for the licenses of these
|
||||
libraries.
|
||||
SRB2 uses various third-party libraries, including SDL, SDL Mixer, and their dependencies. See LICENSE-3RD-PARTY.txt for the licenses of these libraries.
|
||||
|
||||
SOURCE CODE
|
||||
|
||||
You may obtain the source code for SRB2, including the source code for
|
||||
specific version releases, at the following web sites:
|
||||
You may obtain the source code for SRB2, including the source code for specific version releases, at the following web sites:
|
||||
|
||||
STJr GitLab:
|
||||
https://git.magicalgirl.moe/STJr/SRB2
|
||||
https://git.do.srb2.org/STJr/SRB2
|
||||
|
||||
GitHub:
|
||||
https://github.com/STJr/SRB2
|
||||
|
@ -27,25 +24,27 @@ CONTACT
|
|||
|
||||
You may contact Sonic Team Junior via the following web sites:
|
||||
|
||||
SRB2.ORG:
|
||||
https://www.srb2.org
|
||||
|
||||
SRB2 Message Board:
|
||||
https://mb.srb2.org
|
||||
|
||||
SRB2 Official Discord:
|
||||
https://discord.gg/pYDXzpX (13+)
|
||||
https://discord.gg/b3BGb8A
|
||||
|
||||
Twitter:
|
||||
https://twitter.com/SonicTeamJr
|
||||
|
||||
Facebook:
|
||||
https://facebook.com/SonicRoboBlast2
|
||||
|
||||
|
||||
COPYRIGHT AND DISCLAIMER
|
||||
|
||||
Design and content on SRB2 is copyright 1998-2019 by Sonic Team Junior.
|
||||
All non-original material on SRB2.ORG is copyrighted by their
|
||||
respective owners, and no copyright infringement is intended. The owner
|
||||
of the SRB2.ORG domain is only acting as an ISP, and is therefore not
|
||||
responsible for any content on SRB2.ORG under the 1998 DMCA. This
|
||||
site, its webmaster, and its staff make no profit whatsoever (in fact,
|
||||
we lose money). Sonic Team Junior assumes no responsibility for the
|
||||
content on any Sonic Team Junior fan sites.
|
||||
Design and content in Sonic Robo Blast 2 is copyright 1998-2022 by Sonic Team Jr.
|
||||
|
||||
Sonic Team Junior is in no way affiliated with SEGA or Sonic Team. We do
|
||||
not claim ownership of any of SEGA's intellectual property used in SRB2.
|
||||
All original material in this game is copyrighted by their respective owners, and no copyright infringement is intended. Sonic Team Jr. is in no way affiliated with SEGA or Sonic Team, and we do not claim ownership of any of SEGA's intellectual property used in SRB2.
|
||||
|
||||
Sonic Robo Blast 2 is not commercial software. If you purchased this game, you have been scammed! Sonic Team Jr.'s staff makes no profit whatsoever (in fact, we lose money).
|
||||
|
||||
The owner of the srb2.org domain is only acting as an ISP, and is therefore not responsible for any content on srb2.org under the 1998 DMCA. Sonic Team Jr. assumes no responsibility for the content on any Sonic Team Jr. fan sites.
|
||||
|
||||
This software is provided as-is with no warranty whatsoever.
|
||||
|
|
2
bin/FreeBSD/Debug/.gitignore
vendored
2
bin/FreeBSD/Debug/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
2
bin/FreeBSD/Release/.gitignore
vendored
2
bin/FreeBSD/Release/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
1
bin/Linux/Debug/.gitignore
vendored
1
bin/Linux/Debug/.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
/lsdlsrb2
|
3
bin/Linux/Release/.gitignore
vendored
3
bin/Linux/Release/.gitignore
vendored
|
@ -1,3 +0,0 @@
|
|||
/lsdlsrb2
|
||||
/pnd
|
||||
/*.mo
|
1
bin/Linux64/Debug/.gitignore
vendored
1
bin/Linux64/Debug/.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
/lsdlsrb2
|
1
bin/Linux64/Release/.gitignore
vendored
1
bin/Linux64/Release/.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
/lsdlsrb2
|
3
bin/Mingw/Debug/.gitignore
vendored
3
bin/Mingw/Debug/.gitignore
vendored
|
@ -1,3 +0,0 @@
|
|||
*.exe
|
||||
*.mo
|
||||
r_opengl.dll
|
4
bin/Mingw/Release/.gitignore
vendored
4
bin/Mingw/Release/.gitignore
vendored
|
@ -1,4 +0,0 @@
|
|||
*.exe
|
||||
*.mo
|
||||
r_opengl.dll
|
||||
*.bat
|
3
bin/Mingw64/Debug/.gitignore
vendored
3
bin/Mingw64/Debug/.gitignore
vendored
|
@ -1,3 +0,0 @@
|
|||
/srb2sdl.exe
|
||||
/srb2win.exe
|
||||
/r_opengl.dll
|
3
bin/Mingw64/Release/.gitignore
vendored
3
bin/Mingw64/Release/.gitignore
vendored
|
@ -1,3 +0,0 @@
|
|||
/srb2sdl.exe
|
||||
/srb2win.exe
|
||||
/r_opengl.dll
|
2
bin/SDL/Debug/.gitignore
vendored
2
bin/SDL/Debug/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
2
bin/SDL/Release/.gitignore
vendored
2
bin/SDL/Release/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
2
bin/VC/.gitignore
vendored
2
bin/VC/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
/Release
|
||||
/Debug
|
2
bin/VC9/.gitignore
vendored
2
bin/VC9/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
/Win32
|
||||
/x64
|
2
bin/dummy/.gitignore
vendored
2
bin/dummy/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
|
@ -78,7 +78,7 @@ NONX86 = $(shell test "`echo $(CROSS_COMPILE_HOST) | grep 'i[3-6]86'`" || echo "
|
|||
MAKEARGS = $(OS) $(NONX86) $(PREFIX) EXENAME=$(EXENAME) DBGNAME=$(DBGNAME) NOOBJDUMP=1 # SDL_PKGCONFIG=sdl2 PNG_PKGCONFIG=libpng
|
||||
MENUFILE1 = ?package($(PACKAGE)):needs="X11" section="$(SECTION)"
|
||||
MENUFILE2 = title="$(TITLE)" command="/$(PKGDIR)/$(PACKAGE)"
|
||||
BINDIR := $(DIR)/bin/Linux/Release
|
||||
BINDIR := $(DIR)/bin/
|
||||
|
||||
# FIXME pkg-config dir hacks
|
||||
# Launchpad doesn't need this; it actually makes i386 builds fail due to cross-compile
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -264,10 +264,10 @@ mapformat_udmf
|
|||
}
|
||||
|
||||
// LINEDEF RENDERSTYLES
|
||||
/*linedefrenderstyles
|
||||
linedefrenderstyles
|
||||
{
|
||||
include("SRB222_misc.cfg", "linedefrenderstyles");
|
||||
}*/
|
||||
}
|
||||
|
||||
// THING FLAGS
|
||||
thingflags
|
||||
|
|
|
@ -1500,6 +1500,161 @@ doom
|
|||
title = "Fog Wall";
|
||||
prefix = "(909)";
|
||||
}
|
||||
910
|
||||
{
|
||||
title = "100% Additive";
|
||||
prefix = "(910)";
|
||||
}
|
||||
911
|
||||
{
|
||||
title = "90% Additive";
|
||||
prefix = "(911)";
|
||||
}
|
||||
912
|
||||
{
|
||||
title = "80% Additive";
|
||||
prefix = "(912)";
|
||||
}
|
||||
913
|
||||
{
|
||||
title = "70% Additive";
|
||||
prefix = "(913)";
|
||||
}
|
||||
914
|
||||
{
|
||||
title = "60% Additive";
|
||||
prefix = "(914)";
|
||||
}
|
||||
915
|
||||
{
|
||||
title = "50% Additive";
|
||||
prefix = "(915)";
|
||||
}
|
||||
916
|
||||
{
|
||||
title = "40% Additive";
|
||||
prefix = "(916)";
|
||||
}
|
||||
917
|
||||
{
|
||||
title = "30% Additive";
|
||||
prefix = "(917)";
|
||||
}
|
||||
918
|
||||
{
|
||||
title = "20% Additive";
|
||||
prefix = "(918)";
|
||||
}
|
||||
919
|
||||
{
|
||||
title = "10% Additive";
|
||||
prefix = "(919)";
|
||||
}
|
||||
920
|
||||
{
|
||||
title = "100% Subtractive";
|
||||
prefix = "(920)";
|
||||
}
|
||||
921
|
||||
{
|
||||
title = "90% Subtractive";
|
||||
prefix = "(921)";
|
||||
}
|
||||
922
|
||||
{
|
||||
title = "80% Subtractive";
|
||||
prefix = "(922)";
|
||||
}
|
||||
923
|
||||
{
|
||||
title = "70% Subtractive";
|
||||
prefix = "(923)";
|
||||
}
|
||||
924
|
||||
{
|
||||
title = "60% Subtractive";
|
||||
prefix = "(924)";
|
||||
}
|
||||
925
|
||||
{
|
||||
title = "50% Subtractive";
|
||||
prefix = "(925)";
|
||||
}
|
||||
926
|
||||
{
|
||||
title = "40% Subtractive";
|
||||
prefix = "(926)";
|
||||
}
|
||||
927
|
||||
{
|
||||
title = "30% Subtractive";
|
||||
prefix = "(927)";
|
||||
}
|
||||
928
|
||||
{
|
||||
title = "20% Subtractive";
|
||||
prefix = "(928)";
|
||||
}
|
||||
929
|
||||
{
|
||||
title = "10% Subtractive";
|
||||
prefix = "(929)";
|
||||
}
|
||||
930
|
||||
{
|
||||
title = "100% Reverse Subtractive";
|
||||
prefix = "(930)";
|
||||
}
|
||||
931
|
||||
{
|
||||
title = "90% Reverse Subtractive";
|
||||
prefix = "(931)";
|
||||
}
|
||||
932
|
||||
{
|
||||
title = "80% Reverse Subtractive";
|
||||
prefix = "(932)";
|
||||
}
|
||||
933
|
||||
{
|
||||
title = "70% Reverse Subtractive";
|
||||
prefix = "(933)";
|
||||
}
|
||||
934
|
||||
{
|
||||
title = "60% Reverse Subtractive";
|
||||
prefix = "(934)";
|
||||
}
|
||||
935
|
||||
{
|
||||
title = "50% Reverse Subtractive";
|
||||
prefix = "(935)";
|
||||
}
|
||||
936
|
||||
{
|
||||
title = "40% Reverse Subtractive";
|
||||
prefix = "(936)";
|
||||
}
|
||||
937
|
||||
{
|
||||
title = "30% Reverse Subtractive";
|
||||
prefix = "(937)";
|
||||
}
|
||||
938
|
||||
{
|
||||
title = "20% Reverse Subtractive";
|
||||
prefix = "(938)";
|
||||
}
|
||||
939
|
||||
{
|
||||
title = "10% Reverse Subtractive";
|
||||
prefix = "(939)";
|
||||
}
|
||||
940
|
||||
{
|
||||
title = "Modulate";
|
||||
prefix = "(940)";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,11 +63,15 @@ linedefflags_udmf
|
|||
transfer = "Transfer Line";
|
||||
}
|
||||
|
||||
/*linedefrenderstyles
|
||||
linedefrenderstyles
|
||||
{
|
||||
translucent = "Translucent";
|
||||
add = "Add";
|
||||
subtract = "Subtract";
|
||||
reversesubtract = "Reverse subtract";
|
||||
modulate = "Modulate";
|
||||
fog = "Fog";
|
||||
}*/
|
||||
}
|
||||
|
||||
sectorflags
|
||||
{
|
||||
|
|
|
@ -1247,6 +1247,7 @@ patterns
|
|||
sprite = "SPHRA0";
|
||||
width = 96;
|
||||
height = 192;
|
||||
}
|
||||
609
|
||||
{
|
||||
title = "Circle of Rings and Spheres (Big)";
|
||||
|
@ -2527,10 +2528,10 @@ dreamhill
|
|||
}
|
||||
1602
|
||||
{
|
||||
title = "Pian";
|
||||
sprite = "NTPNALAR";
|
||||
title = "Nightopian";
|
||||
sprite = "NTPNA1";
|
||||
width = 16;
|
||||
height = 32;
|
||||
height = 40;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
8
objs/.gitignore
vendored
8
objs/.gitignore
vendored
|
@ -1,8 +0,0 @@
|
|||
#All folders
|
||||
SRB2.res
|
||||
depend.dep
|
||||
depend.ped
|
||||
*.o
|
||||
#VC9 folder only
|
||||
/VC9/Win32
|
||||
/VC9/x64
|
2
objs/FreeBSD/SDL/Debug/.gitignore
vendored
2
objs/FreeBSD/SDL/Debug/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
2
objs/FreeBSD/SDL/Release/.gitignore
vendored
2
objs/FreeBSD/SDL/Release/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
2
objs/Linux/SDL/Debug/.gitignore
vendored
2
objs/Linux/SDL/Debug/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
2
objs/Linux/SDL/Release/.gitignore
vendored
2
objs/Linux/SDL/Release/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
2
objs/Linux64/SDL/Debug/.gitignore
vendored
2
objs/Linux64/SDL/Debug/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
2
objs/Linux64/SDL/Release/.gitignore
vendored
2
objs/Linux64/SDL/Release/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
2
objs/MasterClient/.gitignore
vendored
2
objs/MasterClient/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
2
objs/MasterServer/.gitignore
vendored
2
objs/MasterServer/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
2
objs/Mingw/Debug/.gitignore
vendored
2
objs/Mingw/Debug/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
2
objs/Mingw/Release/.gitignore
vendored
2
objs/Mingw/Release/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
2
objs/Mingw/SDL/Debug/.gitignore
vendored
2
objs/Mingw/SDL/Debug/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
2
objs/Mingw/SDL/Release/.gitignore
vendored
2
objs/Mingw/SDL/Release/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
2
objs/Mingw64/Debug/.gitignore
vendored
2
objs/Mingw64/Debug/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
2
objs/Mingw64/Release/.gitignore
vendored
2
objs/Mingw64/Release/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
2
objs/Mingw64/SDL/Debug/.gitignore
vendored
2
objs/Mingw64/SDL/Debug/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
2
objs/Mingw64/SDL/Release/.gitignore
vendored
2
objs/Mingw64/SDL/Release/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
2
objs/SDL/Release/.gitignore
vendored
2
objs/SDL/Release/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
2
objs/VC/.gitignore
vendored
2
objs/VC/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
2
objs/VC9/.gitignore
vendored
2
objs/VC9/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
2
objs/cygwin/Debug/.gitignore
vendored
2
objs/cygwin/Debug/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
2
objs/cygwin/Release/.gitignore
vendored
2
objs/cygwin/Release/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
2
objs/dummy/.gitignore
vendored
2
objs/dummy/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# DON'T REMOVE
|
||||
# This keeps the folder from disappearing
|
|
@ -1,224 +1,14 @@
|
|||
# SRB2 Core
|
||||
|
||||
add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32)
|
||||
|
||||
# Core sources
|
||||
set(SRB2_CORE_SOURCES
|
||||
am_map.c
|
||||
b_bot.c
|
||||
command.c
|
||||
comptime.c
|
||||
console.c
|
||||
d_clisrv.c
|
||||
d_main.c
|
||||
d_net.c
|
||||
d_netcmd.c
|
||||
d_netfil.c
|
||||
dehacked.c
|
||||
f_finale.c
|
||||
f_wipe.c
|
||||
filesrch.c
|
||||
g_demo.c
|
||||
g_game.c
|
||||
g_input.c
|
||||
hu_stuff.c
|
||||
i_tcp.c
|
||||
info.c
|
||||
lzf.c
|
||||
m_aatree.c
|
||||
m_anigif.c
|
||||
m_argv.c
|
||||
m_bbox.c
|
||||
m_cheat.c
|
||||
m_cond.c
|
||||
m_fixed.c
|
||||
m_menu.c
|
||||
m_misc.c
|
||||
m_queue.c
|
||||
m_random.c
|
||||
md5.c
|
||||
mserv.c
|
||||
http-mserv.c
|
||||
s_sound.c
|
||||
screen.c
|
||||
sounds.c
|
||||
st_stuff.c
|
||||
#string.c
|
||||
tables.c
|
||||
v_video.c
|
||||
w_wad.c
|
||||
y_inter.c
|
||||
z_zone.c
|
||||
)
|
||||
target_sourcefile(c)
|
||||
target_sources(SRB2SDL2 PRIVATE comptime.c md5.c config.h.in)
|
||||
|
||||
set(SRB2_CORE_HEADERS
|
||||
am_map.h
|
||||
b_bot.h
|
||||
byteptr.h
|
||||
command.h
|
||||
console.h
|
||||
d_clisrv.h
|
||||
d_event.h
|
||||
d_main.h
|
||||
d_net.h
|
||||
d_netcmd.h
|
||||
d_netfil.h
|
||||
d_player.h
|
||||
d_think.h
|
||||
d_ticcmd.h
|
||||
dehacked.h
|
||||
doomdata.h
|
||||
doomdef.h
|
||||
doomstat.h
|
||||
doomtype.h
|
||||
endian.h
|
||||
f_finale.h
|
||||
fastcmp.h
|
||||
filesrch.h
|
||||
g_demo.h
|
||||
g_game.h
|
||||
g_input.h
|
||||
g_state.h
|
||||
hu_stuff.h
|
||||
i_joy.h
|
||||
i_net.h
|
||||
i_sound.h
|
||||
i_system.h
|
||||
i_tcp.h
|
||||
i_video.h
|
||||
info.h
|
||||
keys.h
|
||||
lzf.h
|
||||
m_aatree.h
|
||||
m_anigif.h
|
||||
m_argv.h
|
||||
m_bbox.h
|
||||
m_cheat.h
|
||||
m_cond.h
|
||||
m_dllist.h
|
||||
m_fixed.h
|
||||
m_menu.h
|
||||
m_misc.h
|
||||
m_queue.h
|
||||
m_random.h
|
||||
m_swap.h
|
||||
md5.h
|
||||
mserv.h
|
||||
p5prof.h
|
||||
s_sound.h
|
||||
screen.h
|
||||
sounds.h
|
||||
st_stuff.h
|
||||
tables.h
|
||||
v_video.h
|
||||
w_wad.h
|
||||
y_inter.h
|
||||
z_zone.h
|
||||
|
||||
config.h.in
|
||||
)
|
||||
|
||||
set(SRB2_CORE_RENDER_SOURCES
|
||||
r_bsp.c
|
||||
r_data.c
|
||||
r_draw.c
|
||||
r_main.c
|
||||
r_plane.c
|
||||
r_segs.c
|
||||
r_skins.c
|
||||
r_sky.c
|
||||
r_splats.c
|
||||
r_things.c
|
||||
r_textures.c
|
||||
r_picformats.c
|
||||
r_portal.c
|
||||
|
||||
r_bsp.h
|
||||
r_data.h
|
||||
r_defs.h
|
||||
r_draw.h
|
||||
r_local.h
|
||||
r_main.h
|
||||
r_plane.h
|
||||
r_segs.h
|
||||
r_skins.h
|
||||
r_sky.h
|
||||
r_splats.h
|
||||
r_state.h
|
||||
r_things.h
|
||||
r_textures.h
|
||||
r_picformats.h
|
||||
r_portal.h
|
||||
)
|
||||
|
||||
set(SRB2_CORE_GAME_SOURCES
|
||||
p_ceilng.c
|
||||
p_enemy.c
|
||||
p_floor.c
|
||||
p_inter.c
|
||||
p_lights.c
|
||||
p_map.c
|
||||
p_maputl.c
|
||||
p_mobj.c
|
||||
p_polyobj.c
|
||||
p_saveg.c
|
||||
p_setup.c
|
||||
p_sight.c
|
||||
p_slopes.c
|
||||
p_spec.c
|
||||
p_telept.c
|
||||
p_tick.c
|
||||
p_user.c
|
||||
|
||||
p_local.h
|
||||
p_maputl.h
|
||||
p_mobj.h
|
||||
p_polyobj.h
|
||||
p_pspr.h
|
||||
p_saveg.h
|
||||
p_setup.h
|
||||
p_slopes.h
|
||||
p_spec.h
|
||||
p_tick.h
|
||||
)
|
||||
|
||||
if(NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
|
||||
set(SRB2_CORE_SOURCES ${SRB2_CORE_SOURCES} string.c)
|
||||
endif()
|
||||
|
||||
prepend_sources(SRB2_CORE_SOURCES)
|
||||
prepend_sources(SRB2_CORE_HEADERS)
|
||||
prepend_sources(SRB2_CORE_RENDER_SOURCES)
|
||||
prepend_sources(SRB2_CORE_GAME_SOURCES)
|
||||
|
||||
set(SRB2_CORE_HEADERS ${SRB2_CORE_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS})
|
||||
source_group("Renderer" FILES ${SRB2_CORE_RENDER_SOURCES})
|
||||
source_group("Game" FILES ${SRB2_CORE_GAME_SOURCES})
|
||||
|
||||
|
||||
set(SRB2_ASM_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vid_copy.s
|
||||
)
|
||||
|
||||
set(SRB2_NASM_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tmap_mmx.nas
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tmap.nas
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
list(APPEND SRB2_NASM_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/tmap_vc.nas)
|
||||
endif()
|
||||
|
||||
set(SRB2_NASM_OBJECTS
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tmap_mmx.obj
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tmap.obj
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
list(APPEND SRB2_NASM_OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/tmap_vc.obj)
|
||||
endif()
|
||||
|
||||
source_group("Assembly" FILES ${SRB2_ASM_SOURCES} ${SRB2_NASM_SOURCES})
|
||||
set(SRB2_ASM_SOURCES vid_copy.s)
|
||||
|
||||
set(SRB2_NASM_SOURCES tmap_mmx.nas tmap.nas)
|
||||
|
||||
### Configuration
|
||||
set(SRB2_CONFIG_HAVE_PNG ON CACHE BOOL
|
||||
|
@ -254,90 +44,7 @@ if(${CMAKE_SYSTEM} MATCHES "Windows") ###set on Windows only
|
|||
"Use SRB2's internal copies of required dependencies (SDL2, PNG, zlib, GME, OpenMPT).")
|
||||
endif()
|
||||
|
||||
set(SRB2_LUA_SOURCES
|
||||
lua_baselib.c
|
||||
lua_blockmaplib.c
|
||||
lua_consolelib.c
|
||||
lua_hooklib.c
|
||||
lua_hudlib.c
|
||||
lua_infolib.c
|
||||
lua_maplib.c
|
||||
lua_mathlib.c
|
||||
lua_mobjlib.c
|
||||
lua_playerlib.c
|
||||
lua_script.c
|
||||
lua_skinlib.c
|
||||
lua_thinkerlib.c
|
||||
)
|
||||
set(SRB2_LUA_HEADERS
|
||||
lua_hook.h
|
||||
lua_hud.h
|
||||
lua_libs.h
|
||||
lua_script.h
|
||||
)
|
||||
|
||||
prepend_sources(SRB2_LUA_SOURCES)
|
||||
prepend_sources(SRB2_LUA_HEADERS)
|
||||
|
||||
source_group("LUA" FILES ${SRB2_LUA_SOURCES} ${SRB2_LUA_HEADERS})
|
||||
|
||||
set(SRB2_BLUA_SOURCES
|
||||
blua/lapi.c
|
||||
blua/lauxlib.c
|
||||
blua/lbaselib.c
|
||||
blua/lcode.c
|
||||
blua/ldebug.c
|
||||
blua/ldo.c
|
||||
blua/ldump.c
|
||||
blua/lfunc.c
|
||||
blua/lgc.c
|
||||
blua/linit.c
|
||||
blua/liolib.c
|
||||
blua/llex.c
|
||||
blua/lmem.c
|
||||
blua/lobject.c
|
||||
blua/lopcodes.c
|
||||
blua/lparser.c
|
||||
blua/lstate.c
|
||||
blua/lstring.c
|
||||
blua/lstrlib.c
|
||||
blua/ltable.c
|
||||
blua/ltablib.c
|
||||
blua/ltm.c
|
||||
blua/lundump.c
|
||||
blua/lvm.c
|
||||
blua/lzio.c
|
||||
)
|
||||
set(SRB2_BLUA_HEADERS
|
||||
blua/lapi.h
|
||||
blua/lauxlib.h
|
||||
blua/lcode.h
|
||||
blua/ldebug.h
|
||||
blua/ldo.h
|
||||
blua/lfunc.h
|
||||
blua/lgc.h
|
||||
blua/llex.h
|
||||
blua/llimits.h
|
||||
blua/lmem.h
|
||||
blua/lobject.h
|
||||
blua/lopcodes.h
|
||||
blua/lparser.h
|
||||
blua/lstate.h
|
||||
blua/lstring.h
|
||||
blua/ltable.h
|
||||
blua/ltm.h
|
||||
blua/lua.h
|
||||
blua/luaconf.h
|
||||
blua/lualib.h
|
||||
blua/lundump.h
|
||||
blua/lvm.h
|
||||
blua/lzio.h
|
||||
)
|
||||
|
||||
prepend_sources(SRB2_BLUA_SOURCES)
|
||||
prepend_sources(SRB2_BLUA_HEADERS)
|
||||
|
||||
source_group("LUA\\Interpreter" FILES ${SRB2_BLUA_SOURCES} ${SRB2_BLUA_HEADERS})
|
||||
add_subdirectory(blua)
|
||||
|
||||
if(${SRB2_CONFIG_HAVE_GME})
|
||||
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
|
||||
|
@ -353,7 +60,7 @@ if(${SRB2_CONFIG_HAVE_GME})
|
|||
endif()
|
||||
if(${GME_FOUND})
|
||||
set(SRB2_HAVE_GME ON)
|
||||
add_definitions(-DHAVE_LIBGME)
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_GME)
|
||||
else()
|
||||
message(WARNING "You have specified that GME is available but it was not found.")
|
||||
endif()
|
||||
|
@ -373,7 +80,7 @@ if(${SRB2_CONFIG_HAVE_OPENMPT})
|
|||
endif()
|
||||
if(${OPENMPT_FOUND})
|
||||
set(SRB2_HAVE_OPENMPT ON)
|
||||
add_definitions(-DHAVE_OPENMPT)
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_OPENMPT)
|
||||
else()
|
||||
message(WARNING "You have specified that OpenMPT is available but it was not found.")
|
||||
endif()
|
||||
|
@ -396,8 +103,7 @@ if(${SRB2_CONFIG_HAVE_MIXERX})
|
|||
endif()
|
||||
if(${MIXERX_FOUND})
|
||||
set(SRB2_HAVE_MIXERX ON)
|
||||
set(SRB2_SDL2_SOUNDIMPL mixer_sound.c)
|
||||
add_definitions(-DHAVE_MIXERX)
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MIXERX)
|
||||
else()
|
||||
message(WARNING "You have specified that SDL Mixer X is available but it was not found.")
|
||||
endif()
|
||||
|
@ -417,7 +123,7 @@ if(${SRB2_CONFIG_HAVE_ZLIB})
|
|||
endif()
|
||||
if(${ZLIB_FOUND})
|
||||
set(SRB2_HAVE_ZLIB ON)
|
||||
add_definitions(-DHAVE_ZLIB)
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_ZLIB)
|
||||
else()
|
||||
message(WARNING "You have specified that ZLIB is available but it was not found. SRB2 may not compile correctly.")
|
||||
endif()
|
||||
|
@ -438,14 +144,9 @@ if(${SRB2_CONFIG_HAVE_PNG} AND ${SRB2_CONFIG_HAVE_ZLIB})
|
|||
endif()
|
||||
if(${PNG_FOUND})
|
||||
set(SRB2_HAVE_PNG ON)
|
||||
add_definitions(-DHAVE_PNG)
|
||||
add_definitions(-D_LARGEFILE64_SOURCE)
|
||||
set(SRB2_PNG_SOURCES apng.c)
|
||||
set(SRB2_PNG_HEADERS apng.h)
|
||||
prepend_sources(SRB2_PNG_SOURCES)
|
||||
prepend_sources(SRB2_PNG_HEADERS)
|
||||
source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS}
|
||||
${SRB2_PNG_SOURCES} ${SRB2_PNG_HEADERS})
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_PNG)
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -D_LARGEFILE64_SOURCE)
|
||||
target_sources(SRB2SDL2 PRIVATE apng.c)
|
||||
else()
|
||||
message(WARNING "You have specified that PNG is available but it was not found. SRB2 may not compile correctly.")
|
||||
endif()
|
||||
|
@ -466,7 +167,7 @@ if(${SRB2_CONFIG_HAVE_CURL})
|
|||
endif()
|
||||
if(${CURL_FOUND})
|
||||
set(SRB2_HAVE_CURL ON)
|
||||
add_definitions(-DHAVE_CURL)
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_CURL)
|
||||
else()
|
||||
message(WARNING "You have specified that CURL is available but it was not found. SRB2 may not compile correctly.")
|
||||
endif()
|
||||
|
@ -474,59 +175,19 @@ endif()
|
|||
|
||||
if(${SRB2_CONFIG_HAVE_THREADS})
|
||||
set(SRB2_HAVE_THREADS ON)
|
||||
set(SRB2_CORE_HEADERS ${SRB2_CORE_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/i_threads.h)
|
||||
add_definitions(-DHAVE_THREADS)
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_THREADS)
|
||||
endif()
|
||||
|
||||
if(${SRB2_CONFIG_HWRENDER})
|
||||
add_definitions(-DHWRENDER)
|
||||
set(SRB2_HWRENDER_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_batching.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_bsp.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_cache.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_draw.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_light.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md3load.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_model.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/u_list.c
|
||||
)
|
||||
|
||||
set (SRB2_HWRENDER_HEADERS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_batching.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_data.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_defs.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_dll.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_drv.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_glob.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_light.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md3load.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_model.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/u_list.h
|
||||
)
|
||||
|
||||
set(SRB2_R_OPENGL_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/r_opengl/r_opengl.c
|
||||
)
|
||||
|
||||
set(SRB2_R_OPENGL_HEADERS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/r_opengl/r_opengl.h
|
||||
)
|
||||
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DHWRENDER)
|
||||
add_subdirectory(hardware)
|
||||
endif()
|
||||
|
||||
if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL})
|
||||
find_package(OpenGL)
|
||||
if(${OPENGL_FOUND})
|
||||
add_definitions(-DHWRENDER)
|
||||
add_definitions(-DSTATIC_OPENGL)
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DHWRENDER)
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DSTATIC_OPENGL)
|
||||
else()
|
||||
message(WARNING "You have specified static opengl but opengl was not found. Not setting HWRENDER.")
|
||||
endif()
|
||||
|
@ -547,12 +208,16 @@ if(${SRB2_CONFIG_USEASM})
|
|||
set(CMAKE_ASM_NASM_FLAGS "${SRB2_ASM_FLAGS}" CACHE STRING "Flags used by the assembler during all build types.")
|
||||
enable_language(ASM_NASM)
|
||||
endif()
|
||||
|
||||
set(SRB2_USEASM ON)
|
||||
add_definitions(-DUSEASM)
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DUSEASM)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse3 -mfpmath=sse")
|
||||
|
||||
target_sources(SRB2SDL2 PRIVATE ${SRB2_ASM_SOURCES}
|
||||
${SRB2_NASM_SOURCES})
|
||||
else()
|
||||
set(SRB2_USEASM OFF)
|
||||
add_definitions(-DNONX86 -DNORUSEASM)
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DNONX86 -DNORUSEASM)
|
||||
endif()
|
||||
|
||||
# Targets
|
||||
|
@ -588,7 +253,9 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|||
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-absolute-value)
|
||||
endif()
|
||||
|
||||
add_definitions(-DCMAKECONFIG)
|
||||
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-trigraphs)
|
||||
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DCMAKECONFIG)
|
||||
|
||||
#add_library(SRB2Core STATIC
|
||||
# ${SRB2_CORE_SOURCES}
|
||||
|
|
1096
src/Makefile
1096
src/Makefile
File diff suppressed because it is too large
Load diff
462
src/Makefile.cfg
462
src/Makefile.cfg
|
@ -1,462 +0,0 @@
|
|||
# vim: ft=make
|
||||
#
|
||||
# Makefile.cfg for SRB2
|
||||
#
|
||||
|
||||
#
|
||||
# GNU compiler & tools' flags
|
||||
# and other things
|
||||
#
|
||||
|
||||
# See the following variable don't start with 'GCC'. This is
|
||||
# to avoid a false positive with the version detection...
|
||||
|
||||
SUPPORTED_GCC_VERSIONS:=\
|
||||
101 102\
|
||||
91 92 93\
|
||||
81 82 83 84\
|
||||
71 72 73 74 75\
|
||||
61 62 63 64\
|
||||
51 52 53 54 55\
|
||||
40 41 42 43 44 45 46 47 48 49
|
||||
|
||||
LATEST_GCC_VERSION=10.2
|
||||
|
||||
# gcc or g++
|
||||
ifdef PREFIX
|
||||
CC=$(PREFIX)-gcc
|
||||
CXX=$(PREFIX)-g++
|
||||
OBJCOPY=$(PREFIX)-objcopy
|
||||
OBJDUMP=$(PREFIX)-objdump
|
||||
STRIP=$(PREFIX)-strip
|
||||
WINDRES=$(PREFIX)-windres
|
||||
else
|
||||
OBJCOPY=objcopy
|
||||
OBJDUMP=objdump
|
||||
STRIP=strip
|
||||
WINDRES=windres
|
||||
endif
|
||||
|
||||
# because Apple screws with us on this
|
||||
# need to get bintools from homebrew
|
||||
ifdef MACOSX
|
||||
CC=clang
|
||||
CXX=clang
|
||||
OBJCOPY=gobjcopy
|
||||
OBJDUMP=gobjdump
|
||||
endif
|
||||
|
||||
# Automatically set version flag, but not if one was manually set
|
||||
ifeq (,$(filter GCC%,$(.VARIABLES)))
|
||||
version:=$(shell $(CC) --version)
|
||||
# check if this is in fact GCC
|
||||
ifneq (,$(or $(findstring gcc,$(version)),$(findstring GCC,$(version))))
|
||||
version:=$(shell $(CC) -dumpversion)
|
||||
|
||||
# Turn version into words of major, minor
|
||||
v:=$(subst ., ,$(version))
|
||||
# concat. major minor
|
||||
v:=$(word 1,$(v))$(word 2,$(v))
|
||||
|
||||
# If this version is not in the list, default to the latest supported
|
||||
ifeq (,$(filter $(v),$(SUPPORTED_GCC_VERSIONS)))
|
||||
$(info\
|
||||
Your compiler version, GCC $(version), is not supported by the Makefile.\
|
||||
The Makefile will assume GCC $(LATEST_GCC_VERSION).)
|
||||
GCC$(subst .,,$(LATEST_GCC_VERSION))=1
|
||||
else
|
||||
$(info Detected GCC $(version) (GCC$(v)))
|
||||
GCC$(v)=1
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef GCC102
|
||||
GCC101=1
|
||||
endif
|
||||
|
||||
ifdef GCC101
|
||||
GCC93=1
|
||||
endif
|
||||
|
||||
ifdef GCC93
|
||||
GCC92=1
|
||||
endif
|
||||
|
||||
ifdef GCC92
|
||||
GCC91=1
|
||||
endif
|
||||
|
||||
ifdef GCC91
|
||||
GCC84=1
|
||||
endif
|
||||
|
||||
ifdef GCC84
|
||||
GCC83=1
|
||||
endif
|
||||
|
||||
ifdef GCC83
|
||||
GCC82=1
|
||||
endif
|
||||
|
||||
ifdef GCC82
|
||||
GCC81=1
|
||||
endif
|
||||
|
||||
ifdef GCC81
|
||||
GCC75=1
|
||||
endif
|
||||
|
||||
ifdef GCC75
|
||||
GCC74=1
|
||||
endif
|
||||
|
||||
ifdef GCC74
|
||||
GCC73=1
|
||||
endif
|
||||
|
||||
ifdef GCC73
|
||||
GCC72=1
|
||||
endif
|
||||
|
||||
ifdef GCC72
|
||||
GCC71=1
|
||||
endif
|
||||
|
||||
ifdef GCC71
|
||||
GCC64=1
|
||||
endif
|
||||
|
||||
ifdef GCC64
|
||||
GCC63=1
|
||||
endif
|
||||
|
||||
ifdef GCC63
|
||||
GCC62=1
|
||||
endif
|
||||
|
||||
ifdef GCC62
|
||||
GCC61=1
|
||||
endif
|
||||
|
||||
ifdef GCC61
|
||||
GCC55=1
|
||||
endif
|
||||
|
||||
ifdef GCC55
|
||||
GCC54=1
|
||||
endif
|
||||
|
||||
ifdef GCC54
|
||||
GCC53=1
|
||||
endif
|
||||
|
||||
ifdef GCC53
|
||||
GCC52=1
|
||||
endif
|
||||
|
||||
ifdef GCC52
|
||||
GCC51=1
|
||||
endif
|
||||
|
||||
ifdef GCC51
|
||||
GCC49=1
|
||||
endif
|
||||
|
||||
ifdef GCC49
|
||||
GCC48=1
|
||||
endif
|
||||
|
||||
ifdef GCC48
|
||||
GCC47=1
|
||||
endif
|
||||
|
||||
ifdef GCC47
|
||||
GCC46=1
|
||||
endif
|
||||
|
||||
ifdef GCC46
|
||||
GCC45=1
|
||||
endif
|
||||
|
||||
ifdef GCC45
|
||||
GCC44=1
|
||||
endif
|
||||
|
||||
ifdef GCC44
|
||||
GCC43=1
|
||||
endif
|
||||
|
||||
ifdef GCC43
|
||||
GCC42=1
|
||||
endif
|
||||
|
||||
ifdef GCC42
|
||||
GCC41=1
|
||||
endif
|
||||
|
||||
ifdef GCC41
|
||||
GCC40=1
|
||||
VCHELP=1
|
||||
endif
|
||||
|
||||
ifdef GCC295
|
||||
GCC29=1
|
||||
endif
|
||||
|
||||
OLDWFLAGS:=$(WFLAGS)
|
||||
# -W -Wno-unused
|
||||
WFLAGS=-Wall
|
||||
ifndef GCC295
|
||||
#WFLAGS+=-Wno-packed
|
||||
endif
|
||||
ifndef RELAXWARNINGS
|
||||
WFLAGS+=-W
|
||||
#WFLAGS+=-Wno-sign-compare
|
||||
ifndef GCC295
|
||||
WFLAGS+=-Wno-div-by-zero
|
||||
endif
|
||||
#WFLAGS+=-Wsystem-headers
|
||||
WFLAGS+=-Wfloat-equal
|
||||
#WFLAGS+=-Wtraditional
|
||||
ifdef VCHELP
|
||||
WFLAGS+=-Wdeclaration-after-statement
|
||||
WFLAGS+=-Wno-error=declaration-after-statement
|
||||
endif
|
||||
WFLAGS+=-Wundef
|
||||
ifndef GCC295
|
||||
WFLAGS+=-Wendif-labels
|
||||
endif
|
||||
ifdef GCC41
|
||||
WFLAGS+=-Wshadow
|
||||
endif
|
||||
#WFLAGS+=-Wlarger-than-%len%
|
||||
WFLAGS+=-Wpointer-arith -Wbad-function-cast
|
||||
ifdef GCC45
|
||||
#WFLAGS+=-Wc++-compat
|
||||
endif
|
||||
WFLAGS+=-Wcast-qual
|
||||
ifndef NOCASTALIGNWARN
|
||||
WFLAGS+=-Wcast-align
|
||||
endif
|
||||
WFLAGS+=-Wwrite-strings
|
||||
ifndef ERRORMODE
|
||||
#WFLAGS+=-Wconversion
|
||||
ifdef GCC43
|
||||
#WFLAGS+=-Wno-sign-conversion
|
||||
endif
|
||||
endif
|
||||
WFLAGS+=-Wsign-compare
|
||||
ifdef GCC91
|
||||
WFLAGS+=-Wno-error=address-of-packed-member
|
||||
endif
|
||||
ifdef GCC45
|
||||
WFLAGS+=-Wlogical-op
|
||||
endif
|
||||
WFLAGS+=-Waggregate-return
|
||||
ifdef HAIKU
|
||||
ifdef GCC41
|
||||
#WFLAGS+=-Wno-attributes
|
||||
endif
|
||||
endif
|
||||
#WFLAGS+=-Wstrict-prototypes
|
||||
ifdef GCC40
|
||||
WFLAGS+=-Wold-style-definition
|
||||
endif
|
||||
WFLAGS+=-Wmissing-prototypes -Wmissing-declarations
|
||||
ifdef GCC40
|
||||
WFLAGS+=-Wmissing-field-initializers
|
||||
endif
|
||||
WFLAGS+=-Wmissing-noreturn
|
||||
#WFLAGS+=-Wmissing-format-attribute
|
||||
#WFLAGS+=-Wno-multichar
|
||||
#WFLAGS+=-Wno-deprecated-declarations
|
||||
#WFLAGS+=-Wpacked
|
||||
#WFLAGS+=-Wpadded
|
||||
#WFLAGS+=-Wredundant-decls
|
||||
WFLAGS+=-Wnested-externs
|
||||
#WFLAGS+=-Wunreachable-code
|
||||
WFLAGS+=-Winline
|
||||
ifdef GCC43
|
||||
WFLAGS+=-funit-at-a-time
|
||||
WFLAGS+=-Wlogical-op
|
||||
endif
|
||||
ifndef GCC295
|
||||
WFLAGS+=-Wdisabled-optimization
|
||||
endif
|
||||
endif
|
||||
WFLAGS+=-Wformat-y2k
|
||||
ifdef GCC71
|
||||
WFLAGS+=-Wno-error=format-overflow=2
|
||||
endif
|
||||
WFLAGS+=-Wformat-security
|
||||
ifndef GCC29
|
||||
#WFLAGS+=-Winit-self
|
||||
endif
|
||||
ifdef GCC46
|
||||
WFLAGS+=-Wno-suggest-attribute=noreturn
|
||||
endif
|
||||
|
||||
ifdef NOLDWARNING
|
||||
LDFLAGS+=-Wl,--as-needed
|
||||
endif
|
||||
|
||||
ifdef ERRORMODE
|
||||
WFLAGS+=-Werror
|
||||
endif
|
||||
|
||||
WFLAGS+=$(OLDWFLAGS)
|
||||
|
||||
ifdef GCC43
|
||||
#WFLAGS+=-Wno-error=clobbered
|
||||
endif
|
||||
ifdef GCC44
|
||||
WFLAGS+=-Wno-error=array-bounds
|
||||
endif
|
||||
ifdef GCC46
|
||||
WFLAGS+=-Wno-error=suggest-attribute=noreturn
|
||||
endif
|
||||
ifdef GCC54
|
||||
WFLAGS+=-Wno-logical-op -Wno-error=logical-op
|
||||
endif
|
||||
ifdef GCC61
|
||||
WFLAGS+=-Wno-tautological-compare -Wno-error=tautological-compare
|
||||
endif
|
||||
ifdef GCC71
|
||||
WFLAGS+=-Wimplicit-fallthrough=4
|
||||
endif
|
||||
ifdef GCC81
|
||||
WFLAGS+=-Wno-error=format-overflow
|
||||
WFLAGS+=-Wno-error=stringop-truncation
|
||||
WFLAGS+=-Wno-error=stringop-overflow
|
||||
WFLAGS+=-Wno-format-overflow
|
||||
WFLAGS+=-Wno-stringop-truncation
|
||||
WFLAGS+=-Wno-stringop-overflow
|
||||
WFLAGS+=-Wno-error=multistatement-macros
|
||||
endif
|
||||
|
||||
|
||||
#indicate platform and what interface use with
|
||||
ifndef LINUX
|
||||
ifndef FREEBSD
|
||||
ifndef CYGWIN32
|
||||
ifndef MINGW
|
||||
ifndef MINGW64
|
||||
ifndef SDL
|
||||
ifndef DUMMY
|
||||
$(error No interface or platform flag defined)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
#determine the interface directory (where you put all i_*.c)
|
||||
i_net_o=$(OBJDIR)/i_net.o
|
||||
i_system_o=$(OBJDIR)/i_system.o
|
||||
i_sound_o=$(OBJDIR)/i_sound.o
|
||||
i_main_o=$(OBJDIR)/i_main.o
|
||||
#set OBJDIR and BIN's starting place
|
||||
OBJDIR=../objs
|
||||
BIN=../bin
|
||||
#Nasm ASM and rm
|
||||
ifdef YASM
|
||||
NASM?=yasm
|
||||
else
|
||||
NASM?=nasm
|
||||
endif
|
||||
REMOVE?=rm -f
|
||||
MKDIR?=mkdir -p
|
||||
GZIP?=gzip
|
||||
GZIP_OPTS?=-9 -f -n
|
||||
GZIP_OPT2=$(GZIP_OPTS) --rsyncable
|
||||
UPX?=upx
|
||||
UPX_OPTS?=--best --preserve-build-id
|
||||
ifndef ECHO
|
||||
UPX_OPTS+=-q
|
||||
endif
|
||||
|
||||
#Interface Setup
|
||||
ifdef DUMMY
|
||||
INTERFACE=dummy
|
||||
OBJDIR:=$(OBJDIR)/dummy
|
||||
BIN:=$(BIN)/dummy
|
||||
else
|
||||
ifdef LINUX
|
||||
NASMFORMAT=elf -DLINUX
|
||||
SDL=1
|
||||
ifdef LINUX64
|
||||
OBJDIR:=$(OBJDIR)/Linux64
|
||||
BIN:=$(BIN)/Linux64
|
||||
else
|
||||
OBJDIR:=$(OBJDIR)/Linux
|
||||
BIN:=$(BIN)/Linux
|
||||
endif
|
||||
else
|
||||
ifdef FREEBSD
|
||||
INTERFACE=sdl
|
||||
NASMFORMAT=elf -DLINUX
|
||||
SDL=1
|
||||
|
||||
OBJDIR:=$(OBJDIR)/FreeBSD
|
||||
BIN:=$(BIN)/FreeBSD
|
||||
else
|
||||
ifdef SOLARIS
|
||||
INTERFACE=sdl
|
||||
NASMFORMAT=elf -DLINUX
|
||||
SDL=1
|
||||
|
||||
OBJDIR:=$(OBJDIR)/Solaris
|
||||
BIN:=$(BIN)/Solaris
|
||||
else
|
||||
ifdef CYGWIN32
|
||||
INTERFACE=sdl
|
||||
NASMFORMAT=win32
|
||||
SDL=1
|
||||
|
||||
OBJDIR:=$(OBJDIR)/cygwin
|
||||
BIN:=$(BIN)/Cygwin
|
||||
else
|
||||
ifdef MINGW64
|
||||
#NASMFORMAT=win64
|
||||
SDL=1
|
||||
OBJDIR:=$(OBJDIR)/Mingw64
|
||||
BIN:=$(BIN)/Mingw64
|
||||
else
|
||||
ifdef MINGW
|
||||
NASMFORMAT=win32
|
||||
SDL=1
|
||||
OBJDIR:=$(OBJDIR)/Mingw
|
||||
BIN:=$(BIN)/Mingw
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef ARCHNAME
|
||||
OBJDIR:=$(OBJDIR)/$(ARCHNAME)
|
||||
BIN:=$(BIN)/$(ARCHNAME)
|
||||
endif
|
||||
|
||||
OBJDUMP_OPTS?=--wide --source --line-numbers
|
||||
LD=$(CC)
|
||||
|
||||
ifdef SDL
|
||||
INTERFACE=sdl
|
||||
OBJDIR:=$(OBJDIR)/SDL
|
||||
endif
|
||||
|
||||
ifndef DUMMY
|
||||
ifdef DEBUGMODE
|
||||
OBJDIR:=$(OBJDIR)/Debug
|
||||
BIN:=$(BIN)/Debug
|
||||
else
|
||||
OBJDIR:=$(OBJDIR)/Release
|
||||
BIN:=$(BIN)/Release
|
||||
endif
|
||||
endif
|
107
src/Makefile.d/detect.mk
Normal file
107
src/Makefile.d/detect.mk
Normal file
|
@ -0,0 +1,107 @@
|
|||
#
|
||||
# Detect the host system and compiler version.
|
||||
#
|
||||
|
||||
# Previously featured:\
|
||||
PANDORA\
|
||||
HAIKU\
|
||||
DUMMY\
|
||||
DJGPPDOS\
|
||||
SOLARIS\
|
||||
MACOSX\
|
||||
|
||||
all_systems:=\
|
||||
LINUX64\
|
||||
MINGW64\
|
||||
MINGW\
|
||||
UNIX\
|
||||
LINUX\
|
||||
FREEBSD\
|
||||
SDL\
|
||||
|
||||
# check for user specified system
|
||||
ifeq (,$(filter $(all_systems),$(.VARIABLES)))
|
||||
ifeq ($(OS),Windows_NT) # all windows are Windows_NT...
|
||||
|
||||
_m=Detected a Windows system,\
|
||||
compiling for 32-bit MinGW SDL...)
|
||||
$(call Print,$(_m))
|
||||
|
||||
# go for a 32-bit sdl mingw exe by default
|
||||
MINGW:=1
|
||||
|
||||
else # if you on the *nix
|
||||
|
||||
system:=$(shell uname -s)
|
||||
|
||||
ifeq ($(system),Linux)
|
||||
new_system:=LINUX
|
||||
else
|
||||
|
||||
$(error \
|
||||
Could not automatically detect your system,\
|
||||
try specifying a system manually)
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(shell getconf LONG_BIT),64)
|
||||
system+=64-bit
|
||||
new_system:=$(new_system)64
|
||||
endif
|
||||
|
||||
$(call Print,Detected $(system) ($(new_system))...)
|
||||
$(new_system):=1
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
# This must have high to low order.
|
||||
gcc_versions:=\
|
||||
102 101\
|
||||
93 92 91\
|
||||
84 83 82 81\
|
||||
75 74 73 72 71\
|
||||
64 63 62 61\
|
||||
55 54 53 52 51\
|
||||
49 48 47 46 45 44 43 42 41 40
|
||||
|
||||
latest_gcc_version:=10.2
|
||||
|
||||
# Automatically set version flag, but not if one was
|
||||
# manually set. And don't bother if this is a clean only
|
||||
# run.
|
||||
ifeq (,$(call Wildvar,GCC% destructive))
|
||||
|
||||
# can't use $(CC) --version here since that uses argv[0] to display the name
|
||||
# also gcc outputs the information to stderr, so I had to do 2>&1
|
||||
# this program really doesn't like identifying itself
|
||||
version:=$(shell $(CC) -v 2>&1)
|
||||
|
||||
# check if this is in fact GCC
|
||||
ifneq (,$(findstring gcc version,$(version)))
|
||||
|
||||
# in stark contrast to the name, gcc will give me a nicely formatted version number for free
|
||||
version:=$(shell $(CC) -dumpfullversion)
|
||||
|
||||
# Turn version into words of major, minor
|
||||
v:=$(subst ., ,$(version))
|
||||
# concat. major minor
|
||||
v:=$(word 1,$(v))$(word 2,$(v))
|
||||
|
||||
# If this version is not in the list,
|
||||
# default to the latest supported
|
||||
ifeq (,$(filter $(v),$(gcc_versions)))
|
||||
define line =
|
||||
Your compiler version, GCC $(version), \
|
||||
is not supported by the Makefile.
|
||||
The Makefile will assume GCC $(latest_gcc_version).
|
||||
endef
|
||||
$(call Print,$(line))
|
||||
GCC$(subst .,,$(latest_gcc_version)):=1
|
||||
else
|
||||
$(call Print,Detected GCC $(version) (GCC$(v)))
|
||||
GCC$(v):=1
|
||||
endif
|
||||
|
||||
endif
|
||||
endif
|
75
src/Makefile.d/features.mk
Normal file
75
src/Makefile.d/features.mk
Normal file
|
@ -0,0 +1,75 @@
|
|||
#
|
||||
# Makefile for feature flags.
|
||||
#
|
||||
|
||||
passthru_opts+=\
|
||||
NONET NO_IPV6 NOHW NOMD5 NOPOSTPROCESSING\
|
||||
MOBJCONSISTANCY PACKETDROP ZDEBUG\
|
||||
HAVE_MINIUPNPC\
|
||||
|
||||
# build with debugging information
|
||||
ifdef DEBUGMODE
|
||||
PACKETDROP=1
|
||||
opts+=-DPARANOIA -DRANGECHECK
|
||||
endif
|
||||
|
||||
ifndef NOHW
|
||||
opts+=-DHWRENDER
|
||||
sources+=$(call List,hardware/Sourcefile)
|
||||
endif
|
||||
|
||||
ifndef NOASM
|
||||
ifndef NONX86
|
||||
sources+=tmap.nas tmap_mmx.nas
|
||||
opts+=-DUSEASM
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef NOMD5
|
||||
sources+=md5.c
|
||||
endif
|
||||
|
||||
ifndef NOZLIB
|
||||
ifndef NOPNG
|
||||
ifdef PNG_PKGCONFIG
|
||||
$(eval $(call Use_pkg_config,PNG_PKGCONFIG))
|
||||
else
|
||||
PNG_CONFIG?=$(call Prefix,libpng-config)
|
||||
$(eval $(call Configure,PNG,$(PNG_CONFIG) \
|
||||
$(if $(PNG_STATIC),--static),,--ldflags))
|
||||
endif
|
||||
ifdef LINUX
|
||||
opts+=-D_LARGEFILE64_SOURCE
|
||||
endif
|
||||
opts+=-DHAVE_PNG
|
||||
sources+=apng.c
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef NONET
|
||||
ifndef NOCURL
|
||||
CURLCONFIG?=curl-config
|
||||
$(eval $(call Configure,CURL,$(CURLCONFIG)))
|
||||
opts+=-DHAVE_CURL
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef HAVE_MINIUPNPC
|
||||
libs+=-lminiupnpc
|
||||
endif
|
||||
|
||||
# (Valgrind is a memory debugger.)
|
||||
ifdef VALGRIND
|
||||
VALGRIND_PKGCONFIG?=valgrind
|
||||
$(eval $(call Use_pkg_config,VALGRIND))
|
||||
ZDEBUG=1
|
||||
opts+=-DHAVE_VALGRIND
|
||||
endif
|
||||
|
||||
default_packages:=\
|
||||
GME/libgme/LIBGME\
|
||||
OPENMPT/libopenmpt/LIBOPENMPT\
|
||||
ZLIB/zlib\
|
||||
|
||||
$(foreach p,$(default_packages),\
|
||||
$(eval $(call Check_pkg_config,$(p))))
|
42
src/Makefile.d/nix.mk
Normal file
42
src/Makefile.d/nix.mk
Normal file
|
@ -0,0 +1,42 @@
|
|||
#
|
||||
# Makefile options for unices (linux, bsd...)
|
||||
#
|
||||
|
||||
EXENAME?=lsdl2srb2
|
||||
|
||||
opts+=-DUNIXCOMMON -DLUA_USE_POSIX
|
||||
# Use -rdynamic so a backtrace log shows function names
|
||||
# instead of addresses
|
||||
libs+=-lm -rdynamic
|
||||
|
||||
ifndef nasm_format
|
||||
nasm_format:=elf -DLINUX
|
||||
endif
|
||||
|
||||
ifndef NOHW
|
||||
opts+=-I/usr/X11R6/include
|
||||
libs+=-L/usr/X11R6/lib
|
||||
endif
|
||||
|
||||
SDL=1
|
||||
|
||||
# In common usage.
|
||||
ifdef LINUX
|
||||
libs+=-lrt
|
||||
passthru_opts+=NOTERMIOS
|
||||
endif
|
||||
|
||||
# Tested by Steel, as of release 2.2.8.
|
||||
ifdef FREEBSD
|
||||
opts+=-I/usr/X11R6/include -DLINUX -DFREEBSD
|
||||
libs+=-L/usr/X11R6/lib -lipx -lkvm
|
||||
endif
|
||||
|
||||
# FIXME: UNTESTED
|
||||
#ifdef SOLARIS
|
||||
#NOIPX=1
|
||||
#NOASM=1
|
||||
#opts+=-I/usr/local/include -I/opt/sfw/include \
|
||||
# -DSOLARIS -DINADDR_NONE=INADDR_ANY -DBSD_COMP
|
||||
#libs+=-L/opt/sfw/lib -lsocket -lnsl
|
||||
#endif
|
16
src/Makefile.d/old.mk
Normal file
16
src/Makefile.d/old.mk
Normal file
|
@ -0,0 +1,16 @@
|
|||
#
|
||||
# Warn about old build directories and offer to purge.
|
||||
#
|
||||
|
||||
_old:=$(wildcard $(addprefix ../bin/,FreeBSD Linux \
|
||||
Linux64 Mingw Mingw64 SDL dummy) ../objs ../dep)
|
||||
|
||||
ifdef _old
|
||||
$(foreach v,$(_old),$(info $(abspath $(v))))
|
||||
$(info )
|
||||
$(info These directories are no longer\
|
||||
required and should be removed.)
|
||||
$(info You may remove them manually or\
|
||||
by using 'make distclean')
|
||||
$(error )
|
||||
endif
|
69
src/Makefile.d/platform.mk
Normal file
69
src/Makefile.d/platform.mk
Normal file
|
@ -0,0 +1,69 @@
|
|||
#
|
||||
# Platform specific options.
|
||||
#
|
||||
|
||||
PKG_CONFIG?=pkg-config
|
||||
|
||||
ifdef WINDOWSHELL
|
||||
rmrf=-2>NUL DEL /S /Q
|
||||
mkdir=-2>NUL MD
|
||||
cat=TYPE
|
||||
else
|
||||
rmrf=rm -rf
|
||||
mkdir=mkdir -p
|
||||
cat=cat
|
||||
endif
|
||||
|
||||
ifdef LINUX64
|
||||
LINUX=1
|
||||
endif
|
||||
|
||||
ifdef MINGW64
|
||||
MINGW=1
|
||||
endif
|
||||
|
||||
ifdef LINUX
|
||||
UNIX=1
|
||||
ifdef LINUX64
|
||||
NONX86=1
|
||||
# LINUX64 does not imply X86_64=1;
|
||||
# could mean ARM64 or Itanium
|
||||
platform=linux/64
|
||||
else
|
||||
platform=linux
|
||||
endif
|
||||
else ifdef FREEBSD
|
||||
UNIX=1
|
||||
platform=freebsd
|
||||
else ifdef SOLARIS # FIXME: UNTESTED
|
||||
UNIX=1
|
||||
platform=solaris
|
||||
else ifdef CYGWIN32 # FIXME: UNTESTED
|
||||
nasm_format=win32
|
||||
platform=cygwin
|
||||
else ifdef MINGW
|
||||
ifdef MINGW64
|
||||
NONX86=1
|
||||
NOASM=1
|
||||
# MINGW64 should not necessarily imply X86_64=1,
|
||||
# but we make that assumption elsewhere
|
||||
# Once that changes, remove this
|
||||
X86_64=1
|
||||
platform=mingw/64
|
||||
else
|
||||
platform=mingw
|
||||
endif
|
||||
include Makefile.d/win32.mk
|
||||
endif
|
||||
|
||||
ifdef platform
|
||||
makedir:=$(makedir)/$(platform)
|
||||
endif
|
||||
|
||||
ifdef UNIX
|
||||
include Makefile.d/nix.mk
|
||||
endif
|
||||
|
||||
ifdef SDL
|
||||
include Makefile.d/sdl.mk
|
||||
endif
|
79
src/Makefile.d/sdl.mk
Normal file
79
src/Makefile.d/sdl.mk
Normal file
|
@ -0,0 +1,79 @@
|
|||
#
|
||||
# Makefile options for SDL2 backend.
|
||||
#
|
||||
|
||||
#
|
||||
# SDL...., *looks at Alam*, THIS IS A MESS!
|
||||
#
|
||||
# ...a little bird flexes its muscles...
|
||||
#
|
||||
|
||||
makedir:=$(makedir)/SDL
|
||||
|
||||
sources+=$(call List,sdl/Sourcefile)
|
||||
opts+=-DDIRECTFULLSCREEN -DHAVE_SDL
|
||||
|
||||
# FIXME: UNTESTED
|
||||
#ifdef PANDORA
|
||||
#include sdl/SRB2Pandora/Makefile.cfg
|
||||
#endif #ifdef PANDORA
|
||||
|
||||
# FIXME: UNTESTED
|
||||
#ifdef CYGWIN32
|
||||
#include sdl/MakeCYG.cfg
|
||||
#endif #ifdef CYGWIN32
|
||||
|
||||
ifndef NOHW
|
||||
sources+=sdl/ogl_sdl.c
|
||||
endif
|
||||
|
||||
ifdef NOMIXER
|
||||
sources+=sdl/sdl_sound.c
|
||||
else
|
||||
opts+=-DHAVE_MIXER
|
||||
sources+=sdl/mixer_sound.c
|
||||
|
||||
ifdef HAVE_MIXERX
|
||||
opts+=-DHAVE_MIXERX
|
||||
libs+=-lSDL2_mixer_ext
|
||||
else
|
||||
libs+=-lSDL2_mixer
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef NOTHREADS
|
||||
opts+=-DHAVE_THREADS
|
||||
sources+=sdl/i_threads.c
|
||||
endif
|
||||
|
||||
ifdef SDL_PKGCONFIG
|
||||
$(eval $(call Use_pkg_config,SDL))
|
||||
else
|
||||
SDL_CONFIG?=$(call Prefix,sdl2-config)
|
||||
SDL_CFLAGS?=$(shell $(SDL_CONFIG) --cflags)
|
||||
SDL_LDFLAGS?=$(shell $(SDL_CONFIG) \
|
||||
$(if $(STATIC),--static-libs,--libs))
|
||||
$(eval $(call Propogate_flags,SDL))
|
||||
endif
|
||||
|
||||
# use the x86 asm code
|
||||
ifndef CYGWIN32
|
||||
ifndef NOASM
|
||||
USEASM=1
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef MINGW
|
||||
ifndef NOSDLMAIN
|
||||
SDLMAIN=1
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef SDLMAIN
|
||||
opts+=-DSDLMAIN
|
||||
else
|
||||
ifdef MINGW
|
||||
opts+=-Umain
|
||||
libs+=-mconsole
|
||||
endif
|
||||
endif
|
93
src/Makefile.d/util.mk
Normal file
93
src/Makefile.d/util.mk
Normal file
|
@ -0,0 +1,93 @@
|
|||
#
|
||||
# Utility macros for the rest of the Makefiles.
|
||||
#
|
||||
|
||||
Ifnot=$(if $(1),$(3),$(2))
|
||||
Ifndef=$(call Ifnot,$($(1)),$(2),$(3))
|
||||
|
||||
# Match and expand a list of variables by pattern.
|
||||
Wildvar=$(foreach v,$(filter $(1),$(.VARIABLES)),$($(v)))
|
||||
|
||||
# Read a list of words from file and prepend each with the
|
||||
# directory of the file.
|
||||
_cat=$(shell $(cat) $(call Windows_path,$(1)))
|
||||
List=$(addprefix $(dir $(1)),$(call _cat,$(1)))
|
||||
|
||||
# Convert path separators to backslash on Windows.
|
||||
Windows_path=$(if $(WINDOWSHELL),$(subst /,\,$(1)),$(1))
|
||||
|
||||
define Propogate_flags =
|
||||
opts+=$$($(1)_CFLAGS)
|
||||
libs+=$$($(1)_LDFLAGS)
|
||||
endef
|
||||
|
||||
# Set library's _CFLAGS and _LDFLAGS from some command.
|
||||
# Automatically propogates the flags too.
|
||||
# 1: variable prefix (e.g. CURL)
|
||||
# 2: start of command (e.g. curl-config)
|
||||
# --- optional ----
|
||||
# 3: CFLAGS command arguments, default '--cflags'
|
||||
# 4: LDFLAGS command arguments, default '--libs'
|
||||
# 5: common command arguments at the end of command
|
||||
define Configure =
|
||||
$(1)_CFLAGS?=$$(shell $(2) $(or $(3),--cflags) $(5))
|
||||
$(1)_LDFLAGS?=$$(shell $(2) $(or $(4),--libs) $(5))
|
||||
$(call Propogate_flags,$(1))
|
||||
endef
|
||||
|
||||
# Configure library with pkg-config. The package name is
|
||||
# taken from a _PKGCONFIG variable.
|
||||
# 1: variable prefix
|
||||
#
|
||||
# LIBGME_PKGCONFIG=libgme
|
||||
# $(eval $(call Use_pkg_config,LIBGME))
|
||||
define Use_pkg_config =
|
||||
$(call Configure,$(1),$(PKG_CONFIG),,,$($(1)_PKGCONFIG))
|
||||
endef
|
||||
|
||||
# Check disabling flag and configure package in one step
|
||||
# according to delimited argument.
|
||||
# (There is only one argument, but it split by slash.)
|
||||
# 1/: short form library name (uppercase). This is
|
||||
# prefixed with 'NO' and 'HAVE_'. E.g. NOGME, HAVE_GME
|
||||
# /2: package name (e.g. libgme)
|
||||
# /3: variable prefix
|
||||
#
|
||||
# The following example would check if NOGME is not
|
||||
# defined before attempting to define LIBGME_CFLAGS and
|
||||
# LIBGME_LDFLAGS as with Use_pkg_config.
|
||||
#
|
||||
# $(eval $(call Check_pkg_config,GME/libgme/LIBGME))
|
||||
define Check_pkg_config =
|
||||
_p:=$(subst /, ,$(1))
|
||||
_v1:=$$(word 1,$$(_p))
|
||||
_v2:=$$(or $$(word 3,$$(_p)),$$(_v1))
|
||||
ifndef NO$$(_v1)
|
||||
$$(_v2)_PKGCONFIG?=$$(word 2,$$(_p))
|
||||
$$(eval $$(call Use_pkg_config,$$(_v2)))
|
||||
opts+=-DHAVE_$$(_v1)
|
||||
endif
|
||||
endef
|
||||
|
||||
# $(call Prefix,gcc)
|
||||
Prefix=$(if $(PREFIX),$(PREFIX)-)$(1)
|
||||
|
||||
Echo=
|
||||
Echo_name=
|
||||
Print=
|
||||
|
||||
ifndef SILENT
|
||||
Echo=@echo $(1)
|
||||
ifndef ECHO
|
||||
ifndef NOECHOFILENAMES
|
||||
Echo_name=$(call Echo,-- $(1) ...)
|
||||
endif
|
||||
endif
|
||||
ifndef MAKE_RESTARTS
|
||||
ifndef destructive
|
||||
Print=$(info $(1))
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
.=$(call Ifndef,ECHO,@)
|
175
src/Makefile.d/versions.mk
Normal file
175
src/Makefile.d/versions.mk
Normal file
|
@ -0,0 +1,175 @@
|
|||
#
|
||||
# Flags to put a sock in GCC!
|
||||
#
|
||||
|
||||
# See the versions list in detect.mk
|
||||
# This will define all version flags going backward.
|
||||
# Yes, it's magic.
|
||||
define _predecessor =
|
||||
ifdef GCC$(firstword $(1))
|
||||
GCC$(lastword $(1)):=1
|
||||
endif
|
||||
endef
|
||||
_n:=$(words $(gcc_versions))
|
||||
$(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\
|
||||
$(addprefix =,$(wordlist 2,$(_n),$(gcc_versions)))),\
|
||||
$(and $(findstring =,$(v)),\
|
||||
$(eval $(call _predecessor,$(subst =, ,$(v))))))
|
||||
|
||||
# -W -Wno-unused
|
||||
WFLAGS:=-Wall -Wno-trigraphs
|
||||
ifndef GCC295
|
||||
#WFLAGS+=-Wno-packed
|
||||
endif
|
||||
ifndef RELAXWARNINGS
|
||||
WFLAGS+=-W
|
||||
#WFLAGS+=-Wno-sign-compare
|
||||
ifndef GCC295
|
||||
WFLAGS+=-Wno-div-by-zero
|
||||
endif
|
||||
#WFLAGS+=-Wsystem-headers
|
||||
WFLAGS+=-Wfloat-equal
|
||||
#WFLAGS+=-Wtraditional
|
||||
WFLAGS+=-Wundef
|
||||
ifndef GCC295
|
||||
WFLAGS+=-Wendif-labels
|
||||
endif
|
||||
ifdef GCC41
|
||||
WFLAGS+=-Wshadow
|
||||
endif
|
||||
#WFLAGS+=-Wlarger-than-%len%
|
||||
WFLAGS+=-Wpointer-arith -Wbad-function-cast
|
||||
ifdef GCC45
|
||||
#WFLAGS+=-Wc++-compat
|
||||
endif
|
||||
WFLAGS+=-Wcast-qual
|
||||
ifndef NOCASTALIGNWARN
|
||||
WFLAGS+=-Wcast-align
|
||||
endif
|
||||
WFLAGS+=-Wwrite-strings
|
||||
ifndef ERRORMODE
|
||||
#WFLAGS+=-Wconversion
|
||||
ifdef GCC43
|
||||
#WFLAGS+=-Wno-sign-conversion
|
||||
endif
|
||||
endif
|
||||
WFLAGS+=-Wsign-compare
|
||||
ifdef GCC91
|
||||
WFLAGS+=-Wno-error=address-of-packed-member
|
||||
endif
|
||||
ifdef GCC45
|
||||
WFLAGS+=-Wlogical-op
|
||||
endif
|
||||
WFLAGS+=-Waggregate-return
|
||||
ifdef HAIKU
|
||||
ifdef GCC41
|
||||
#WFLAGS+=-Wno-attributes
|
||||
endif
|
||||
endif
|
||||
#WFLAGS+=-Wstrict-prototypes
|
||||
ifdef GCC40
|
||||
WFLAGS+=-Wold-style-definition
|
||||
endif
|
||||
WFLAGS+=-Wmissing-prototypes -Wmissing-declarations
|
||||
ifdef GCC40
|
||||
WFLAGS+=-Wmissing-field-initializers
|
||||
endif
|
||||
WFLAGS+=-Wmissing-noreturn
|
||||
#WFLAGS+=-Wmissing-format-attribute
|
||||
#WFLAGS+=-Wno-multichar
|
||||
#WFLAGS+=-Wno-deprecated-declarations
|
||||
#WFLAGS+=-Wpacked
|
||||
#WFLAGS+=-Wpadded
|
||||
#WFLAGS+=-Wredundant-decls
|
||||
WFLAGS+=-Wnested-externs
|
||||
#WFLAGS+=-Wunreachable-code
|
||||
WFLAGS+=-Winline
|
||||
ifdef GCC43
|
||||
WFLAGS+=-funit-at-a-time
|
||||
WFLAGS+=-Wlogical-op
|
||||
endif
|
||||
ifndef GCC295
|
||||
WFLAGS+=-Wdisabled-optimization
|
||||
endif
|
||||
endif
|
||||
WFLAGS+=-Wformat-y2k
|
||||
ifdef GCC71
|
||||
WFLAGS+=-Wno-error=format-overflow=2
|
||||
endif
|
||||
WFLAGS+=-Wformat-security
|
||||
ifndef GCC29
|
||||
#WFLAGS+=-Winit-self
|
||||
endif
|
||||
ifdef GCC46
|
||||
WFLAGS+=-Wno-suggest-attribute=noreturn
|
||||
endif
|
||||
|
||||
ifdef NOLDWARNING
|
||||
LDFLAGS+=-Wl,--as-needed
|
||||
endif
|
||||
|
||||
ifdef ERRORMODE
|
||||
WFLAGS+=-Werror
|
||||
endif
|
||||
|
||||
ifdef GCC43
|
||||
#WFLAGS+=-Wno-error=clobbered
|
||||
endif
|
||||
ifdef GCC44
|
||||
WFLAGS+=-Wno-error=array-bounds
|
||||
endif
|
||||
ifdef GCC46
|
||||
WFLAGS+=-Wno-error=suggest-attribute=noreturn
|
||||
endif
|
||||
ifdef GCC54
|
||||
WFLAGS+=-Wno-logical-op -Wno-error=logical-op
|
||||
endif
|
||||
ifdef GCC61
|
||||
WFLAGS+=-Wno-tautological-compare -Wno-error=tautological-compare
|
||||
endif
|
||||
ifdef GCC71
|
||||
WFLAGS+=-Wimplicit-fallthrough=4
|
||||
endif
|
||||
ifdef GCC81
|
||||
WFLAGS+=-Wno-error=format-overflow
|
||||
WFLAGS+=-Wno-error=stringop-truncation
|
||||
WFLAGS+=-Wno-error=stringop-overflow
|
||||
WFLAGS+=-Wno-format-overflow
|
||||
WFLAGS+=-Wno-stringop-truncation
|
||||
WFLAGS+=-Wno-stringop-overflow
|
||||
WFLAGS+=-Wno-error=multistatement-macros
|
||||
endif
|
||||
|
||||
ifdef NONX86
|
||||
ifdef X86_64 # yeah that SEEMS contradictory
|
||||
opts+=-march=nocona
|
||||
endif
|
||||
else
|
||||
ifndef GCC29
|
||||
opts+=-msse3 -mfpmath=sse
|
||||
else
|
||||
opts+=-mpentium
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef DEBUGMODE
|
||||
ifdef GCC48
|
||||
opts+=-Og
|
||||
else
|
||||
opts+=O0
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef VALGRIND
|
||||
ifdef GCC46
|
||||
WFLAGS+=-Wno-error=unused-but-set-variable
|
||||
WFLAGS+=-Wno-unused-but-set-variable
|
||||
endif
|
||||
endif
|
||||
|
||||
# Lua
|
||||
ifdef GCC43
|
||||
ifndef GCC44
|
||||
WFLAGS+=-Wno-logical-op
|
||||
endif
|
||||
endif
|
104
src/Makefile.d/win32.mk
Normal file
104
src/Makefile.d/win32.mk
Normal file
|
@ -0,0 +1,104 @@
|
|||
#
|
||||
# Mingw, if you don't know, that's Win32/Win64
|
||||
#
|
||||
|
||||
ifndef MINGW64
|
||||
EXENAME?=srb2win.exe
|
||||
else
|
||||
EXENAME?=srb2win64.exe
|
||||
endif
|
||||
|
||||
# disable dynamicbase if under msys2
|
||||
ifdef MSYSTEM
|
||||
libs+=-Wl,--disable-dynamicbase
|
||||
endif
|
||||
|
||||
sources+=win32/Srb2win.rc
|
||||
opts+=-DSTDC_HEADERS
|
||||
libs+=-ladvapi32 -lkernel32 -lmsvcrt -luser32
|
||||
|
||||
nasm_format:=win32
|
||||
|
||||
SDL=1
|
||||
|
||||
ifndef NOHW
|
||||
opts+=-DUSE_WGL_SWAP
|
||||
endif
|
||||
|
||||
ifdef MINGW64
|
||||
libs+=-lws2_32
|
||||
else
|
||||
ifdef NO_IPV6
|
||||
libs+=-lwsock32
|
||||
else
|
||||
libs+=-lws2_32
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef NONET
|
||||
ifndef MINGW64 # miniupnc is broken with MINGW64
|
||||
opts+=-I../libs -DSTATIC_MINIUPNPC
|
||||
libs+=-L../libs/miniupnpc/mingw$(32) -lws2_32 -liphlpapi
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef MINGW64
|
||||
32=32
|
||||
x86=x86
|
||||
i686=i686
|
||||
else
|
||||
32=64
|
||||
x86=x86_64
|
||||
i686=x86_64
|
||||
endif
|
||||
|
||||
mingw:=$(i686)-w64-mingw32
|
||||
|
||||
define _set =
|
||||
$(1)_CFLAGS?=$($(1)_opts)
|
||||
$(1)_LDFLAGS?=$($(1)_libs)
|
||||
endef
|
||||
|
||||
lib:=../libs/gme
|
||||
LIBGME_opts:=-I$(lib)/include
|
||||
LIBGME_libs:=-L$(lib)/win$(32) -lgme
|
||||
$(eval $(call _set,LIBGME))
|
||||
|
||||
lib:=../libs/libopenmpt
|
||||
LIBOPENMPT_opts:=-I$(lib)/inc
|
||||
LIBOPENMPT_libs:=-L$(lib)/lib/$(x86)/mingw -lopenmpt
|
||||
$(eval $(call _set,LIBOPENMPT))
|
||||
|
||||
ifndef NOMIXERX
|
||||
HAVE_MIXERX=1
|
||||
lib:=../libs/SDLMixerX/$(mingw)
|
||||
else
|
||||
lib:=../libs/SDL2_mixer/$(mingw)
|
||||
endif
|
||||
|
||||
mixer_opts:=-I$(lib)/include/SDL2
|
||||
mixer_libs:=-L$(lib)/lib
|
||||
|
||||
lib:=../libs/SDL2/$(mingw)
|
||||
SDL_opts:=-I$(lib)/include/SDL2\
|
||||
$(mixer_opts) -Dmain=SDL_main
|
||||
SDL_libs:=-L$(lib)/lib $(mixer_libs)\
|
||||
-lmingw32 -lSDL2main -lSDL2 -mwindows
|
||||
$(eval $(call _set,SDL))
|
||||
|
||||
lib:=../libs/zlib
|
||||
ZLIB_opts:=-I$(lib)
|
||||
ZLIB_libs:=-L$(lib)/win32 -lz$(32)
|
||||
$(eval $(call _set,ZLIB))
|
||||
|
||||
ifndef PNG_CONFIG
|
||||
lib:=../libs/libpng-src
|
||||
PNG_opts:=-I$(lib)
|
||||
PNG_libs:=-L$(lib)/projects -lpng$(32)
|
||||
$(eval $(call _set,PNG))
|
||||
endif
|
||||
|
||||
lib:=../libs/curl
|
||||
CURL_opts:=-I$(lib)/include
|
||||
CURL_libs:=-L$(lib)/lib$(32) -lcurl
|
||||
$(eval $(call _set,CURL))
|
98
src/Sourcefile
Normal file
98
src/Sourcefile
Normal file
|
@ -0,0 +1,98 @@
|
|||
string.c
|
||||
d_main.c
|
||||
d_clisrv.c
|
||||
d_net.c
|
||||
d_netfil.c
|
||||
d_netcmd.c
|
||||
dehacked.c
|
||||
deh_soc.c
|
||||
deh_lua.c
|
||||
deh_tables.c
|
||||
z_zone.c
|
||||
f_finale.c
|
||||
f_wipe.c
|
||||
g_demo.c
|
||||
g_game.c
|
||||
g_input.c
|
||||
am_map.c
|
||||
command.c
|
||||
console.c
|
||||
hu_stuff.c
|
||||
y_inter.c
|
||||
st_stuff.c
|
||||
m_aatree.c
|
||||
m_anigif.c
|
||||
m_argv.c
|
||||
m_bbox.c
|
||||
m_cheat.c
|
||||
m_cond.c
|
||||
m_easing.c
|
||||
m_fixed.c
|
||||
m_menu.c
|
||||
m_misc.c
|
||||
m_perfstats.c
|
||||
m_random.c
|
||||
m_queue.c
|
||||
info.c
|
||||
p_ceilng.c
|
||||
p_enemy.c
|
||||
p_floor.c
|
||||
p_inter.c
|
||||
p_lights.c
|
||||
p_map.c
|
||||
p_maputl.c
|
||||
p_mobj.c
|
||||
p_polyobj.c
|
||||
p_saveg.c
|
||||
p_setup.c
|
||||
p_sight.c
|
||||
p_spec.c
|
||||
p_telept.c
|
||||
p_tick.c
|
||||
p_user.c
|
||||
p_slopes.c
|
||||
tables.c
|
||||
r_bsp.c
|
||||
r_data.c
|
||||
r_draw.c
|
||||
r_main.c
|
||||
r_plane.c
|
||||
r_segs.c
|
||||
r_skins.c
|
||||
r_sky.c
|
||||
r_splats.c
|
||||
r_things.c
|
||||
r_textures.c
|
||||
r_patch.c
|
||||
r_patchrotation.c
|
||||
r_picformats.c
|
||||
r_portal.c
|
||||
screen.c
|
||||
taglist.c
|
||||
v_video.c
|
||||
s_sound.c
|
||||
sounds.c
|
||||
w_wad.c
|
||||
filesrch.c
|
||||
mserv.c
|
||||
http-mserv.c
|
||||
i_tcp.c
|
||||
lzf.c
|
||||
vid_copy.s
|
||||
b_bot.c
|
||||
lua_script.c
|
||||
lua_baselib.c
|
||||
lua_mathlib.c
|
||||
lua_hooklib.c
|
||||
lua_consolelib.c
|
||||
lua_infolib.c
|
||||
lua_mobjlib.c
|
||||
lua_playerlib.c
|
||||
lua_skinlib.c
|
||||
lua_thinkerlib.c
|
||||
lua_maplib.c
|
||||
lua_taglib.c
|
||||
lua_polyobjlib.c
|
||||
lua_blockmaplib.c
|
||||
lua_hudlib.c
|
||||
lua_inputlib.c
|
|
@ -2,7 +2,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -458,7 +458,7 @@ boolean AM_Responder(event_t *ev)
|
|||
{
|
||||
if (!automapactive)
|
||||
{
|
||||
if (ev->type == ev_keydown && ev->data1 == AM_TOGGLEKEY)
|
||||
if (ev->type == ev_keydown && ev->key == AM_TOGGLEKEY)
|
||||
{
|
||||
//faB: prevent alt-tab in win32 version to activate automap just before
|
||||
// minimizing the app; doesn't do any harm to the DOS version
|
||||
|
@ -473,7 +473,7 @@ boolean AM_Responder(event_t *ev)
|
|||
else if (ev->type == ev_keydown)
|
||||
{
|
||||
rc = true;
|
||||
switch (ev->data1)
|
||||
switch (ev->key)
|
||||
{
|
||||
case AM_PANRIGHTKEY: // pan right
|
||||
if (!followplayer)
|
||||
|
@ -550,7 +550,7 @@ boolean AM_Responder(event_t *ev)
|
|||
else if (ev->type == ev_keyup)
|
||||
{
|
||||
rc = false;
|
||||
switch (ev->data1)
|
||||
switch (ev->key)
|
||||
{
|
||||
case AM_PANRIGHTKEY:
|
||||
if (!followplayer)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
UINT8 cdaudio_started = 0;
|
||||
|
||||
consvar_t cd_volume = {"cd_volume","18",CV_SAVE,soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cdUpdate = {"cd_update","1",CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cd_volume = CVAR_INIT ("cd_volume","18",CV_SAVE,soundvolume_cons_t, NULL);
|
||||
consvar_t cdUpdate = CVAR_INIT ("cd_update","1",CV_SAVE, NULL, NULL);
|
||||
|
||||
|
||||
void I_InitCD(void){}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "utils/Log.h"
|
||||
|
||||
rendermode_t rendermode = render_soft;
|
||||
rendermode_t chosenrendermode = render_none;
|
||||
|
||||
boolean highcolor = false;
|
||||
|
||||
|
@ -16,7 +17,7 @@ boolean allow_fullscreen = false;
|
|||
|
||||
|
||||
|
||||
consvar_t cv_vidwait = {"vid_wait", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_vidwait = CVAR_INIT ("vid_wait", "On", CV_SAVE, CV_OnOff, NULL);
|
||||
|
||||
void I_StartupGraphics(void){}
|
||||
void I_ShutdownGraphics(void){}
|
||||
|
@ -52,8 +53,15 @@ INT32 VID_SetMode(INT32 modenum)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void VID_CheckRenderer(void) {}
|
||||
void VID_CheckGLLoaded(rendermode_t oldrender) {}
|
||||
boolean VID_CheckRenderer(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void VID_CheckGLLoaded(rendermode_t oldrender)
|
||||
{
|
||||
(void)oldrender;
|
||||
}
|
||||
|
||||
const char *VID_GetModeName(INT32 modenum)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2019-2020, James R.
|
||||
Copyright 2019-2022, James R.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2019-2020, James R.
|
||||
Copyright 2019-2022, James R.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
|
291
src/b_bot.c
291
src/b_bot.c
|
@ -1,7 +1,7 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2007-2016 by John "JTE" Muniz.
|
||||
// Copyright (C) 2011-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 2011-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -17,30 +17,45 @@
|
|||
#include "p_local.h"
|
||||
#include "b_bot.h"
|
||||
#include "lua_hook.h"
|
||||
#include "i_system.h" // I_BaseTiccmd
|
||||
|
||||
// If you want multiple bots, variables like this will
|
||||
// have to be stuffed in something accessible through player_t.
|
||||
static boolean lastForward = false;
|
||||
static boolean lastBlocked = false;
|
||||
static boolean blocked = false;
|
||||
|
||||
static boolean jump_last = false;
|
||||
static boolean spin_last = false;
|
||||
static UINT8 anxiety = 0;
|
||||
static boolean panic = false;
|
||||
static UINT8 flymode = 0;
|
||||
static boolean spinmode = false;
|
||||
static boolean thinkfly = false;
|
||||
|
||||
static inline void B_ResetAI(void)
|
||||
void B_UpdateBotleader(player_t *player)
|
||||
{
|
||||
jump_last = false;
|
||||
spin_last = false;
|
||||
anxiety = 0;
|
||||
panic = false;
|
||||
flymode = 0;
|
||||
spinmode = false;
|
||||
thinkfly = false;
|
||||
UINT32 i;
|
||||
fixed_t dist;
|
||||
fixed_t neardist = INT32_MAX;
|
||||
player_t *nearplayer = NULL;
|
||||
//Find new botleader
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
if (players[i].bot || players[i].playerstate != PST_LIVE || players[i].spectator || !players[i].mo)
|
||||
continue;
|
||||
|
||||
if (!player->botleader)
|
||||
{
|
||||
player->botleader = &players[i]; // set default
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player->mo)
|
||||
return;
|
||||
|
||||
//Update best candidate based on nearest distance
|
||||
dist = R_PointToDist2(player->mo->x, player->mo->y, players[i].mo->x, players[i].mo->y);
|
||||
if (neardist > dist)
|
||||
{
|
||||
neardist = dist;
|
||||
nearplayer = &players[i];
|
||||
}
|
||||
}
|
||||
//Set botleader to best candidate (or null if none available)
|
||||
player->botleader = nearplayer;
|
||||
}
|
||||
|
||||
static inline void B_ResetAI(botmem_t *mem)
|
||||
{
|
||||
mem->thinkstate = AI_FOLLOW;
|
||||
mem->catchup_tics = 0;
|
||||
}
|
||||
|
||||
static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
|
||||
|
@ -49,39 +64,47 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
|
|||
|
||||
player_t *player = sonic->player, *bot = tails->player;
|
||||
ticcmd_t *pcmd = &player->cmd;
|
||||
boolean water = tails->eflags & MFE_UNDERWATER;
|
||||
botmem_t *mem = &bot->botmem;
|
||||
boolean water = (tails->eflags & MFE_UNDERWATER);
|
||||
SINT8 flip = P_MobjFlip(tails);
|
||||
boolean _2d = (tails->flags2 & MF2_TWOD) || twodlevel;
|
||||
fixed_t scale = tails->scale;
|
||||
boolean jump_last = (bot->lastbuttons & BT_JUMP);
|
||||
boolean spin_last = (bot->lastbuttons & BT_SPIN);
|
||||
|
||||
fixed_t dist = P_AproxDistance(sonic->x - tails->x, sonic->y - tails->y);
|
||||
fixed_t zdist = flip * (sonic->z - tails->z);
|
||||
angle_t ang = sonic->angle;
|
||||
fixed_t pmom = P_AproxDistance(sonic->momx, sonic->momy);
|
||||
fixed_t bmom = P_AproxDistance(tails->momx, tails->momy);
|
||||
fixed_t followmax = 128 * 8 * scale; // Max follow distance before AI begins to enter "panic" state
|
||||
fixed_t followmax = 128 * 8 * scale; // Max follow distance before AI begins to enter catchup state
|
||||
fixed_t followthres = 92 * scale; // Distance that AI will try to reach
|
||||
fixed_t followmin = 32 * scale;
|
||||
fixed_t comfortheight = 96 * scale;
|
||||
fixed_t touchdist = 24 * scale;
|
||||
boolean stalled = (bmom < scale >> 1) && dist > followthres; // Helps to see if the AI is having trouble catching up
|
||||
boolean samepos = (sonic->x == tails->x && sonic->y == tails->y);
|
||||
|
||||
boolean blocked = bot->blocked;
|
||||
|
||||
if (!samepos)
|
||||
ang = R_PointToAngle2(tails->x, tails->y, sonic->x, sonic->y);
|
||||
|
||||
// We can't follow Sonic if he's not around!
|
||||
if (!sonic || sonic->health <= 0)
|
||||
// Lua can handle it!
|
||||
if (LUA_HookBotAI(sonic, tails, cmd))
|
||||
return;
|
||||
|
||||
// Lua can handle it!
|
||||
if (LUAh_BotAI(sonic, tails, cmd))
|
||||
// We can't follow Sonic if he's not around!
|
||||
if (!sonic || sonic->health <= 0)
|
||||
{
|
||||
mem->thinkstate = AI_STANDBY;
|
||||
return;
|
||||
}
|
||||
else if (mem->thinkstate == AI_STANDBY)
|
||||
mem->thinkstate = AI_FOLLOW;
|
||||
|
||||
if (tails->player->powers[pw_carry] == CR_MACESPIN || tails->player->powers[pw_carry] == CR_GENERIC)
|
||||
{
|
||||
boolean isrelevant = (sonic->player->powers[pw_carry] == CR_MACESPIN || sonic->player->powers[pw_carry] == CR_GENERIC);
|
||||
dist = P_AproxDistance(tails->x-sonic->x, tails->y-sonic->y);
|
||||
if (sonic->player->cmd.buttons & BT_JUMP && (sonic->player->pflags & PF_JUMPED) && isrelevant)
|
||||
cmd->buttons |= BT_JUMP;
|
||||
if (isrelevant)
|
||||
|
@ -103,56 +126,57 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
|
|||
followmin = 0;
|
||||
followthres = 16*scale;
|
||||
followmax >>= 1;
|
||||
thinkfly = false;
|
||||
if (mem->thinkstate == AI_THINKFLY)
|
||||
mem->thinkstate = AI_FOLLOW;
|
||||
}
|
||||
|
||||
// Check anxiety
|
||||
if (spinmode)
|
||||
// Update catchup_tics
|
||||
if (mem->thinkstate == AI_SPINFOLLOW)
|
||||
{
|
||||
anxiety = 0;
|
||||
panic = false;
|
||||
mem->catchup_tics = 0;
|
||||
}
|
||||
else if (dist > followmax || zdist > comfortheight || stalled)
|
||||
{
|
||||
anxiety = min(anxiety + 2, 70);
|
||||
if (anxiety >= 70)
|
||||
panic = true;
|
||||
mem->catchup_tics = min(mem->catchup_tics + 2, 70);
|
||||
if (mem->catchup_tics >= 70)
|
||||
mem->thinkstate = AI_CATCHUP;
|
||||
}
|
||||
else
|
||||
{
|
||||
anxiety = max(anxiety - 1, 0);
|
||||
panic = false;
|
||||
mem->catchup_tics = max(mem->catchup_tics - 1, 0);
|
||||
if (mem->thinkstate == AI_CATCHUP)
|
||||
mem->thinkstate = AI_FOLLOW;
|
||||
}
|
||||
|
||||
// Orientation
|
||||
// cmd->angleturn won't be relative to player angle, since we're not going through G_BuildTiccmd.
|
||||
if (bot->pflags & (PF_SPINNING|PF_STARTDASH))
|
||||
{
|
||||
cmd->angleturn = (sonic->angle - tails->angle) >> 16; // NOT FRACBITS DAMNIT
|
||||
cmd->angleturn = (sonic->angle) >> 16; // NOT FRACBITS DAMNIT
|
||||
}
|
||||
else if (flymode == 2)
|
||||
else if (mem->thinkstate == AI_FLYCARRY)
|
||||
{
|
||||
cmd->angleturn = sonic->player->cmd.angleturn - (tails->angle >> 16);
|
||||
cmd->angleturn = sonic->player->cmd.angleturn;
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd->angleturn = (ang - tails->angle) >> 16; // NOT FRACBITS DAMNIT
|
||||
cmd->angleturn = (ang) >> 16; // NOT FRACBITS DAMNIT
|
||||
}
|
||||
|
||||
// ********
|
||||
// FLY MODE
|
||||
// spinmode check
|
||||
if (spinmode || player->exiting)
|
||||
thinkfly = false;
|
||||
// exiting check
|
||||
if (player->exiting && mem->thinkstate == AI_THINKFLY)
|
||||
mem->thinkstate = AI_FOLLOW;
|
||||
else
|
||||
{
|
||||
// Activate co-op flight
|
||||
if (thinkfly && player->pflags & PF_JUMPED)
|
||||
if (mem->thinkstate == AI_THINKFLY && player->pflags & PF_JUMPED)
|
||||
{
|
||||
if (!jump_last)
|
||||
{
|
||||
jump = true;
|
||||
flymode = 1;
|
||||
thinkfly = false;
|
||||
mem->thinkstate = AI_FLYSTANDBY;
|
||||
bot->pflags |= PF_CANCARRY;
|
||||
}
|
||||
}
|
||||
|
@ -165,20 +189,19 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
|
|||
&& P_IsObjectOnGround(sonic) && P_IsObjectOnGround(tails)
|
||||
&& !(player->pflags & PF_STASIS)
|
||||
&& bot->charability == CA_FLY)
|
||||
thinkfly = true;
|
||||
else
|
||||
thinkfly = false;
|
||||
mem->thinkstate = AI_THINKFLY;
|
||||
else if (mem->thinkstate == AI_THINKFLY)
|
||||
mem->thinkstate = AI_FOLLOW;
|
||||
|
||||
// Set carried state
|
||||
if (player->powers[pw_carry] == CR_PLAYER && sonic->tracer == tails)
|
||||
{
|
||||
flymode = 2;
|
||||
mem->thinkstate = AI_FLYCARRY;
|
||||
}
|
||||
|
||||
// Ready for takeoff
|
||||
if (flymode == 1)
|
||||
if (mem->thinkstate == AI_FLYSTANDBY)
|
||||
{
|
||||
thinkfly = false;
|
||||
if (zdist < -64*scale || (flip * tails->momz) > scale) // Make sure we're not too high up
|
||||
spin = true;
|
||||
else if (!jump_last)
|
||||
|
@ -186,10 +209,10 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
|
|||
|
||||
// Abort if the player moves away or spins
|
||||
if (dist > followthres || player->dashspeed)
|
||||
flymode = 0;
|
||||
mem->thinkstate = AI_FOLLOW;
|
||||
}
|
||||
// Read player inputs while carrying
|
||||
else if (flymode == 2)
|
||||
else if (mem->thinkstate == AI_FLYCARRY)
|
||||
{
|
||||
cmd->forwardmove = pcmd->forwardmove;
|
||||
cmd->sidemove = pcmd->sidemove;
|
||||
|
@ -203,19 +226,19 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
|
|||
// End flymode
|
||||
if (player->powers[pw_carry] != CR_PLAYER)
|
||||
{
|
||||
flymode = 0;
|
||||
mem->thinkstate = AI_FOLLOW;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flymode && P_IsObjectOnGround(tails) && !(pcmd->buttons & BT_JUMP))
|
||||
flymode = 0;
|
||||
if (P_IsObjectOnGround(tails) && !(pcmd->buttons & BT_JUMP) && (mem->thinkstate == AI_FLYSTANDBY || mem->thinkstate == AI_FLYCARRY))
|
||||
mem->thinkstate = AI_FOLLOW;
|
||||
|
||||
// ********
|
||||
// SPINNING
|
||||
if (panic || flymode || !(player->pflags & PF_SPINNING) || (player->pflags & PF_JUMPED))
|
||||
spinmode = false;
|
||||
else
|
||||
if (!(player->pflags & (PF_SPINNING|PF_STARTDASH)) && mem->thinkstate == AI_SPINFOLLOW)
|
||||
mem->thinkstate = AI_FOLLOW;
|
||||
else if (mem->thinkstate == AI_FOLLOW || mem->thinkstate == AI_SPINFOLLOW)
|
||||
{
|
||||
if (!_2d)
|
||||
{
|
||||
|
@ -224,21 +247,21 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
|
|||
{
|
||||
if (dist < followthres && dist > touchdist) // Do positioning
|
||||
{
|
||||
cmd->angleturn = (ang - tails->angle) >> 16; // NOT FRACBITS DAMNIT
|
||||
cmd->angleturn = (ang) >> 16; // NOT FRACBITS DAMNIT
|
||||
cmd->forwardmove = 50;
|
||||
spinmode = true;
|
||||
mem->thinkstate = AI_SPINFOLLOW;
|
||||
}
|
||||
else if (dist < touchdist)
|
||||
{
|
||||
if (!bmom && (!(bot->pflags & PF_SPINNING) || (bot->dashspeed && bot->pflags & PF_SPINNING)))
|
||||
{
|
||||
cmd->angleturn = (sonic->angle - tails->angle) >> 16; // NOT FRACBITS DAMNIT
|
||||
cmd->angleturn = (sonic->angle) >> 16; // NOT FRACBITS DAMNIT
|
||||
spin = true;
|
||||
}
|
||||
spinmode = true;
|
||||
mem->thinkstate = AI_SPINFOLLOW;
|
||||
}
|
||||
else
|
||||
spinmode = false;
|
||||
mem->thinkstate = AI_FOLLOW;
|
||||
}
|
||||
// Spin
|
||||
else if (player->dashspeed == bot->dashspeed && player->pflags & PF_SPINNING)
|
||||
|
@ -246,12 +269,12 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
|
|||
if (bot->pflags & PF_SPINNING || !spin_last)
|
||||
{
|
||||
spin = true;
|
||||
cmd->angleturn = (sonic->angle - tails->angle) >> 16; // NOT FRACBITS DAMNIT
|
||||
cmd->angleturn = (sonic->angle) >> 16; // NOT FRACBITS DAMNIT
|
||||
cmd->forwardmove = MAXPLMOVE;
|
||||
spinmode = true;
|
||||
mem->thinkstate = AI_SPINFOLLOW;
|
||||
}
|
||||
else
|
||||
spinmode = false;
|
||||
mem->thinkstate = AI_FOLLOW;
|
||||
}
|
||||
}
|
||||
// 2D mode
|
||||
|
@ -261,17 +284,19 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
|
|||
&& ((bot->pflags & PF_SPINNING) || !spin_last))
|
||||
{
|
||||
spin = true;
|
||||
spinmode = true;
|
||||
mem->thinkstate = AI_SPINFOLLOW;
|
||||
}
|
||||
else
|
||||
mem->thinkstate = AI_FOLLOW;
|
||||
}
|
||||
}
|
||||
|
||||
// ********
|
||||
// FOLLOW
|
||||
if (!(flymode || spinmode))
|
||||
if (mem->thinkstate == AI_FOLLOW || mem->thinkstate == AI_CATCHUP)
|
||||
{
|
||||
// Too far
|
||||
if (panic || dist > followthres)
|
||||
if (mem->thinkstate == AI_CATCHUP || dist > followthres)
|
||||
{
|
||||
if (!_2d)
|
||||
cmd->forwardmove = MAXPLMOVE;
|
||||
|
@ -281,7 +306,7 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
|
|||
cmd->sidemove = -MAXPLMOVE;
|
||||
}
|
||||
// Within threshold
|
||||
else if (!panic && dist > followmin && abs(zdist) < 192*scale)
|
||||
else if (dist > followmin && abs(zdist) < 192*scale)
|
||||
{
|
||||
if (!_2d)
|
||||
cmd->forwardmove = FixedHypot(pcmd->forwardmove, pcmd->sidemove);
|
||||
|
@ -292,8 +317,7 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
|
|||
else if (dist < followmin)
|
||||
{
|
||||
// Copy inputs
|
||||
cmd->angleturn = (sonic->angle - tails->angle) >> 16; // NOT FRACBITS DAMNIT
|
||||
bot->drawangle = ang;
|
||||
cmd->angleturn = (sonic->angle) >> 16; // NOT FRACBITS DAMNIT
|
||||
cmd->forwardmove = 8 * pcmd->forwardmove / 10;
|
||||
cmd->sidemove = 8 * pcmd->sidemove / 10;
|
||||
}
|
||||
|
@ -301,7 +325,7 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
|
|||
|
||||
// ********
|
||||
// JUMP
|
||||
if (!(flymode || spinmode))
|
||||
if (mem->thinkstate == AI_FOLLOW || mem->thinkstate == AI_CATCHUP || (mem->thinkstate == AI_SPINFOLLOW && player->pflags & PF_JUMPED))
|
||||
{
|
||||
// Flying catch-up
|
||||
if (bot->pflags & PF_THOKKED)
|
||||
|
@ -319,35 +343,36 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
|
|||
// Start jump
|
||||
else if (!jump_last && !(bot->pflags & PF_JUMPED) //&& !(player->pflags & PF_SPINNING)
|
||||
&& ((zdist > 32*scale && player->pflags & PF_JUMPED) // Following
|
||||
|| (zdist > 64*scale && panic) // Vertical catch-up
|
||||
|| (stalled && anxiety > 20 && bot->powers[pw_carry] == CR_NONE)
|
||||
|| (zdist > 64*scale && mem->thinkstate == AI_CATCHUP) // Vertical catch-up
|
||||
|| (stalled && mem->catchup_tics > 20 && bot->powers[pw_carry] == CR_NONE)
|
||||
//|| (bmom < scale>>3 && dist > followthres && !(bot->powers[pw_carry])) // Stopped & not in carry state
|
||||
|| (bot->pflags & PF_SPINNING && !(bot->pflags & PF_JUMPED)))) // Spinning
|
||||
jump = true;
|
||||
// Hold jump
|
||||
else if (bot->pflags & PF_JUMPED && jump_last && tails->momz*flip > 0 && (zdist > 0 || panic))
|
||||
else if (bot->pflags & PF_JUMPED && jump_last && tails->momz*flip > 0 && (zdist > 0 || mem->thinkstate == AI_CATCHUP))
|
||||
jump = true;
|
||||
// Start flying
|
||||
else if (bot->pflags & PF_JUMPED && panic && !jump_last && bot->charability == CA_FLY)
|
||||
else if (bot->pflags & PF_JUMPED && mem->thinkstate == AI_CATCHUP && !jump_last && bot->charability == CA_FLY)
|
||||
jump = true;
|
||||
}
|
||||
|
||||
// ********
|
||||
// HISTORY
|
||||
jump_last = jump;
|
||||
spin_last = spin;
|
||||
//jump_last = jump;
|
||||
//spin_last = spin;
|
||||
|
||||
// Turn the virtual keypresses into ticcmd_t.
|
||||
B_KeysToTiccmd(tails, cmd, forward, backward, left, right, false, false, jump, spin);
|
||||
|
||||
// Update our status
|
||||
lastForward = forward;
|
||||
lastBlocked = blocked;
|
||||
blocked = false;
|
||||
mem->lastForward = forward;
|
||||
mem->lastBlocked = blocked;
|
||||
}
|
||||
|
||||
void B_BuildTiccmd(player_t *player, ticcmd_t *cmd)
|
||||
{
|
||||
G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver
|
||||
|
||||
// Can't build a ticcmd if we aren't spawned...
|
||||
if (!player->mo)
|
||||
return;
|
||||
|
@ -363,25 +388,28 @@ void B_BuildTiccmd(player_t *player, ticcmd_t *cmd)
|
|||
CV_SetValue(&cv_analog[1], false);
|
||||
|
||||
// Let Lua scripts build ticcmds
|
||||
if (LUAh_BotTiccmd(player, cmd))
|
||||
if (LUA_HookTiccmd(player, cmd, HOOK(BotTiccmd)))
|
||||
return;
|
||||
|
||||
// We don't have any main character AI, sorry. D:
|
||||
if (player-players == consoleplayer)
|
||||
// Make sure we have a valid main character to follow
|
||||
B_UpdateBotleader(player);
|
||||
if (!player->botleader)
|
||||
return;
|
||||
|
||||
// Basic Tails AI
|
||||
B_BuildTailsTiccmd(players[consoleplayer].mo, player->mo, cmd);
|
||||
// Single Player Tails AI
|
||||
//B_BuildTailsTiccmd(players[consoleplayer].mo, player->mo, cmd);
|
||||
B_BuildTailsTiccmd(player->botleader->mo, player->mo, cmd);
|
||||
}
|
||||
|
||||
void B_KeysToTiccmd(mobj_t *mo, ticcmd_t *cmd, boolean forward, boolean backward, boolean left, boolean right, boolean strafeleft, boolean straferight, boolean jump, boolean spin)
|
||||
{
|
||||
player_t *player = mo->player;
|
||||
// don't try to do stuff if your sonic is in a minecart or something
|
||||
if (players[consoleplayer].powers[pw_carry] && players[consoleplayer].powers[pw_carry] != CR_PLAYER)
|
||||
if (player->botleader && player->botleader->powers[pw_carry] && player->botleader->powers[pw_carry] != CR_PLAYER)
|
||||
return;
|
||||
// Turn the virtual keypresses into ticcmd_t.
|
||||
if (twodlevel || mo->flags2 & MF2_TWOD) {
|
||||
if (players[consoleplayer].climbing
|
||||
if (player->botleader->climbing
|
||||
|| mo->player->pflags & PF_GLIDING) {
|
||||
// Don't mess with bot inputs during these unhandled movement conditions.
|
||||
// The normal AI doesn't use abilities, so custom AI should be sending us exactly what it wants anyway.
|
||||
|
@ -420,10 +448,10 @@ void B_KeysToTiccmd(mobj_t *mo, ticcmd_t *cmd, boolean forward, boolean backward
|
|||
cmd->forwardmove += MAXPLMOVE<<FRACBITS>>16;
|
||||
if (backward)
|
||||
cmd->forwardmove -= MAXPLMOVE<<FRACBITS>>16;
|
||||
if (left)
|
||||
if (left)
|
||||
cmd->angleturn += 1280;
|
||||
if (right)
|
||||
cmd->angleturn -= 1280;
|
||||
cmd->angleturn -= 1280;
|
||||
if (strafeleft)
|
||||
cmd->sidemove -= MAXPLMOVE<<FRACBITS>>16;
|
||||
if (straferight)
|
||||
|
@ -447,21 +475,26 @@ void B_KeysToTiccmd(mobj_t *mo, ticcmd_t *cmd, boolean forward, boolean backward
|
|||
void B_MoveBlocked(player_t *player)
|
||||
{
|
||||
(void)player;
|
||||
blocked = true;
|
||||
player->blocked = true;
|
||||
}
|
||||
|
||||
boolean B_CheckRespawn(player_t *player)
|
||||
{
|
||||
mobj_t *sonic = players[consoleplayer].mo;
|
||||
mobj_t *sonic;
|
||||
mobj_t *tails = player->mo;
|
||||
|
||||
//We don't have a main player to spawn to!
|
||||
if (!player->botleader)
|
||||
return false;
|
||||
|
||||
sonic = player->botleader->mo;
|
||||
// We can't follow Sonic if he's not around!
|
||||
if (!sonic || sonic->health <= 0)
|
||||
return false;
|
||||
|
||||
// B_RespawnBot doesn't do anything if the condition above this isn't met
|
||||
{
|
||||
UINT8 shouldForce = LUAh_BotRespawn(sonic, tails);
|
||||
UINT8 shouldForce = LUA_Hook2Mobj(sonic, tails, MOBJ_HOOK(BotRespawn));
|
||||
|
||||
if (P_MobjWasRemoved(sonic) || P_MobjWasRemoved(tails))
|
||||
return (shouldForce == 1); // mobj was removed
|
||||
|
@ -505,15 +538,19 @@ void B_RespawnBot(INT32 playernum)
|
|||
{
|
||||
player_t *player = &players[playernum];
|
||||
fixed_t x,y,z;
|
||||
mobj_t *sonic = players[consoleplayer].mo;
|
||||
mobj_t *sonic;
|
||||
mobj_t *tails;
|
||||
|
||||
if (!player->botleader)
|
||||
return;
|
||||
|
||||
sonic = player->botleader->mo;
|
||||
if (!sonic || sonic->health <= 0)
|
||||
return;
|
||||
|
||||
B_ResetAI();
|
||||
B_ResetAI(&player->botmem);
|
||||
|
||||
player->bot = 1;
|
||||
player->bot = BOT_2PAI;
|
||||
P_SpawnPlayer(playernum);
|
||||
tails = player->mo;
|
||||
|
||||
|
@ -540,10 +577,6 @@ void B_RespawnBot(INT32 playernum)
|
|||
player->powers[pw_spacetime] = sonic->player->powers[pw_spacetime];
|
||||
player->powers[pw_gravityboots] = sonic->player->powers[pw_gravityboots];
|
||||
player->powers[pw_nocontrol] = sonic->player->powers[pw_nocontrol];
|
||||
player->acceleration = sonic->player->acceleration;
|
||||
player->accelstart = sonic->player->accelstart;
|
||||
player->thrustfactor = sonic->player->thrustfactor;
|
||||
player->normalspeed = sonic->player->normalspeed;
|
||||
player->pflags |= PF_AUTOBRAKE|(sonic->player->pflags & PF_DIRECTIONCHAR);
|
||||
|
||||
P_TeleportMove(tails, x, y, z);
|
||||
|
@ -561,26 +594,44 @@ void B_RespawnBot(INT32 playernum)
|
|||
void B_HandleFlightIndicator(player_t *player)
|
||||
{
|
||||
mobj_t *tails = player->mo;
|
||||
botmem_t *mem = &player->botmem;
|
||||
boolean shouldExist;
|
||||
|
||||
if (!tails)
|
||||
return;
|
||||
|
||||
if (thinkfly && player->bot == 1 && tails->health)
|
||||
shouldExist = (mem->thinkstate == AI_THINKFLY) && player->botleader
|
||||
&& player->bot == BOT_2PAI && player->playerstate == PST_LIVE;
|
||||
|
||||
// check whether the indicator doesn't exist
|
||||
if (P_MobjWasRemoved(tails->hnext))
|
||||
{
|
||||
if (!tails->hnext)
|
||||
{
|
||||
P_SetTarget(&tails->hnext, P_SpawnMobjFromMobj(tails, 0, 0, 0, MT_OVERLAY));
|
||||
if (tails->hnext)
|
||||
{
|
||||
P_SetTarget(&tails->hnext->target, tails);
|
||||
P_SetTarget(&tails->hnext->hprev, tails);
|
||||
P_SetMobjState(tails->hnext, S_FLIGHTINDICATOR);
|
||||
}
|
||||
}
|
||||
// if it shouldn't exist, everything is fine
|
||||
if (!shouldExist)
|
||||
return;
|
||||
|
||||
// otherwise, spawn it
|
||||
P_SetTarget(&tails->hnext, P_SpawnMobjFromMobj(tails, 0, 0, 0, MT_OVERLAY));
|
||||
P_SetTarget(&tails->hnext->target, tails);
|
||||
P_SetTarget(&tails->hnext->hprev, tails);
|
||||
P_SetMobjState(tails->hnext, S_FLIGHTINDICATOR);
|
||||
}
|
||||
else if (tails->hnext && tails->hnext->type == MT_OVERLAY && tails->hnext->state == states+S_FLIGHTINDICATOR)
|
||||
|
||||
// if the mobj isn't a flight indicator, let's not mess with it
|
||||
if (tails->hnext->type != MT_OVERLAY || (tails->hnext->state != states+S_FLIGHTINDICATOR))
|
||||
return;
|
||||
|
||||
// if it shouldn't exist, remove it
|
||||
if (!shouldExist)
|
||||
{
|
||||
P_RemoveMobj(tails->hnext);
|
||||
P_SetTarget(&tails->hnext, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
// otherwise, update its visibility
|
||||
if (P_IsLocalPlayer(player->botleader))
|
||||
tails->hnext->flags2 &= ~MF2_DONTDRAW;
|
||||
else
|
||||
tails->hnext->flags2 |= MF2_DONTDRAW;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2007-2016 by John "JTE" Muniz.
|
||||
// Copyright (C) 2012-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 2012-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -10,6 +10,7 @@
|
|||
/// \file b_bot.h
|
||||
/// \brief Basic bot handling
|
||||
|
||||
void B_UpdateBotleader(player_t *player);
|
||||
void B_BuildTiccmd(player_t *player, ticcmd_t *cmd);
|
||||
void B_KeysToTiccmd(mobj_t *mo, ticcmd_t *cmd, boolean forward, boolean backward, boolean left, boolean right, boolean strafeleft, boolean straferight, boolean jump, boolean spin);
|
||||
boolean B_CheckRespawn(player_t *player);
|
||||
|
|
1
src/blua/CMakeLists.txt
Normal file
1
src/blua/CMakeLists.txt
Normal file
|
@ -0,0 +1 @@
|
|||
target_sourcefile(c)
|
|
@ -1,51 +0,0 @@
|
|||
ifdef UNIXCOMMON
|
||||
LUA_CFLAGS+=-DLUA_USE_POSIX
|
||||
endif
|
||||
ifdef LINUX
|
||||
LUA_CFLAGS+=-DLUA_USE_POSIX
|
||||
endif
|
||||
ifdef GCC43
|
||||
ifndef GCC44
|
||||
WFLAGS+=-Wno-logical-op
|
||||
endif
|
||||
endif
|
||||
|
||||
OBJS:=$(OBJS) \
|
||||
$(OBJDIR)/lapi.o \
|
||||
$(OBJDIR)/lbaselib.o \
|
||||
$(OBJDIR)/ldo.o \
|
||||
$(OBJDIR)/lfunc.o \
|
||||
$(OBJDIR)/linit.o \
|
||||
$(OBJDIR)/liolib.o \
|
||||
$(OBJDIR)/llex.o \
|
||||
$(OBJDIR)/lmem.o \
|
||||
$(OBJDIR)/lobject.o \
|
||||
$(OBJDIR)/lstate.o \
|
||||
$(OBJDIR)/lstrlib.o \
|
||||
$(OBJDIR)/ltablib.o \
|
||||
$(OBJDIR)/lundump.o \
|
||||
$(OBJDIR)/lzio.o \
|
||||
$(OBJDIR)/lauxlib.o \
|
||||
$(OBJDIR)/lcode.o \
|
||||
$(OBJDIR)/ldebug.o \
|
||||
$(OBJDIR)/ldump.o \
|
||||
$(OBJDIR)/lgc.o \
|
||||
$(OBJDIR)/lopcodes.o \
|
||||
$(OBJDIR)/lparser.o \
|
||||
$(OBJDIR)/lstring.o \
|
||||
$(OBJDIR)/ltable.o \
|
||||
$(OBJDIR)/ltm.o \
|
||||
$(OBJDIR)/lvm.o \
|
||||
$(OBJDIR)/lua_script.o \
|
||||
$(OBJDIR)/lua_baselib.o \
|
||||
$(OBJDIR)/lua_mathlib.o \
|
||||
$(OBJDIR)/lua_hooklib.o \
|
||||
$(OBJDIR)/lua_consolelib.o \
|
||||
$(OBJDIR)/lua_infolib.o \
|
||||
$(OBJDIR)/lua_mobjlib.o \
|
||||
$(OBJDIR)/lua_playerlib.o \
|
||||
$(OBJDIR)/lua_skinlib.o \
|
||||
$(OBJDIR)/lua_thinkerlib.o \
|
||||
$(OBJDIR)/lua_maplib.o \
|
||||
$(OBJDIR)/lua_blockmaplib.o \
|
||||
$(OBJDIR)/lua_hudlib.o
|
25
src/blua/Sourcefile
Normal file
25
src/blua/Sourcefile
Normal file
|
@ -0,0 +1,25 @@
|
|||
lapi.c
|
||||
lbaselib.c
|
||||
ldo.c
|
||||
lfunc.c
|
||||
linit.c
|
||||
liolib.c
|
||||
llex.c
|
||||
lmem.c
|
||||
lobject.c
|
||||
lstate.c
|
||||
lstrlib.c
|
||||
ltablib.c
|
||||
lundump.c
|
||||
lzio.c
|
||||
lauxlib.c
|
||||
lcode.c
|
||||
ldebug.c
|
||||
ldump.c
|
||||
lgc.c
|
||||
lopcodes.c
|
||||
lparser.c
|
||||
lstring.c
|
||||
ltable.c
|
||||
ltm.c
|
||||
lvm.c
|
|
@ -274,7 +274,7 @@ static int luaB_dofile (lua_State *L) {
|
|||
UINT16 lumpnum;
|
||||
int n = lua_gettop(L);
|
||||
|
||||
if (wadfiles[numwadfiles - 1]->type != RET_PK3)
|
||||
if (!W_FileHasFolders(wadfiles[numwadfiles - 1]))
|
||||
luaL_error(L, "dofile() only works with PK3 files");
|
||||
|
||||
snprintf(fullfilename, sizeof(fullfilename), "Lua/%s", filename);
|
||||
|
|
|
@ -686,6 +686,15 @@ static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) {
|
|||
}
|
||||
|
||||
|
||||
static void codeunaryarith (FuncState *fs, OpCode op, expdesc *e) {
|
||||
expdesc e2;
|
||||
e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
|
||||
if (op == OP_LEN || !isnumeral(e))
|
||||
luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */
|
||||
codearith(fs, op, e, &e2);
|
||||
}
|
||||
|
||||
|
||||
static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1,
|
||||
expdesc *e2) {
|
||||
int o1 = luaK_exp2RK(fs, e1);
|
||||
|
@ -703,27 +712,11 @@ static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1,
|
|||
|
||||
|
||||
void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
|
||||
expdesc e2;
|
||||
e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
|
||||
switch (op) {
|
||||
case OPR_MINUS: {
|
||||
if (!isnumeral(e))
|
||||
luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */
|
||||
codearith(fs, OP_UNM, e, &e2);
|
||||
break;
|
||||
}
|
||||
case OPR_BNOT: {
|
||||
if (e->k == VK)
|
||||
luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */
|
||||
codearith(fs, OP_BNOT, e, &e2);
|
||||
break;
|
||||
}
|
||||
case OPR_MINUS: codeunaryarith(fs, OP_UNM, e); break;
|
||||
case OPR_BNOT: codeunaryarith(fs, OP_BNOT, e); break;
|
||||
case OPR_NOT: codenot(fs, e); break;
|
||||
case OPR_LEN: {
|
||||
luaK_exp2anyreg(fs, e); /* cannot operate on constants */
|
||||
codearith(fs, OP_LEN, e, &e2);
|
||||
break;
|
||||
}
|
||||
case OPR_LEN: codeunaryarith(fs, OP_LEN, e); break;
|
||||
default: lua_assert(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -277,6 +277,9 @@ void Got_LuaFile(UINT8 **cp, INT32 playernum)
|
|||
if (!luafiletransfers)
|
||||
I_Error("No Lua file transfer\n");
|
||||
|
||||
lua_settop(gL, 0); // Just in case...
|
||||
lua_pushcfunction(gL, LUA_GetErrorMessage);
|
||||
|
||||
// Retrieve the callback and push it on the stack
|
||||
lua_pushfstring(gL, FMT_FILECALLBACKID, luafiletransfers->id);
|
||||
lua_gettable(gL, LUA_REGISTRYINDEX);
|
||||
|
@ -304,7 +307,8 @@ void Got_LuaFile(UINT8 **cp, INT32 playernum)
|
|||
lua_pushstring(gL, luafiletransfers->filename);
|
||||
|
||||
// Call the callback
|
||||
LUA_Call(gL, 2);
|
||||
LUA_Call(gL, 2, 0, 1);
|
||||
lua_settop(gL, 0);
|
||||
|
||||
if (success)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -150,26 +150,78 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr)
|
|||
|
||||
#undef DEALIGNED
|
||||
|
||||
#define WRITESTRINGN(p,s,n) do { size_t tmp_i = 0; for (; tmp_i < n && s[tmp_i] != '\0'; tmp_i++) WRITECHAR(p, s[tmp_i]); if (tmp_i < n) WRITECHAR(p, '\0');} while (0)
|
||||
#define WRITESTRING(p,s) do { size_t tmp_i = 0; for (; s[tmp_i] != '\0'; tmp_i++) WRITECHAR(p, s[tmp_i]); WRITECHAR(p, '\0');} while (0)
|
||||
#define WRITEMEM(p,s,n) do { memcpy(p, s, n); p += n; } while (0)
|
||||
#define WRITESTRINGN(p, s, n) ({ \
|
||||
size_t tmp_i; \
|
||||
\
|
||||
for (tmp_i = 0; tmp_i < n && s[tmp_i] != '\0'; tmp_i++) \
|
||||
WRITECHAR(p, s[tmp_i]); \
|
||||
\
|
||||
if (tmp_i < n) \
|
||||
WRITECHAR(p, '\0'); \
|
||||
})
|
||||
|
||||
#define SKIPSTRING(p) while (READCHAR(p) != '\0')
|
||||
#define WRITESTRINGL(p, s, n) ({ \
|
||||
size_t tmp_i; \
|
||||
\
|
||||
for (tmp_i = 0; tmp_i < n - 1 && s[tmp_i] != '\0'; tmp_i++) \
|
||||
WRITECHAR(p, s[tmp_i]); \
|
||||
\
|
||||
WRITECHAR(p, '\0'); \
|
||||
})
|
||||
|
||||
#define READSTRINGN(p,s,n) ({ size_t tmp_i = 0; for (; tmp_i < n && (s[tmp_i] = READCHAR(p)) != '\0'; tmp_i++); s[tmp_i] = '\0';})
|
||||
#define READSTRING(p,s) ({ size_t tmp_i = 0; for (; (s[tmp_i] = READCHAR(p)) != '\0'; tmp_i++); s[tmp_i] = '\0';})
|
||||
#define READMEM(p,s,n) ({ memcpy(s, p, n); p += n; })
|
||||
#define WRITESTRING(p, s) ({ \
|
||||
size_t tmp_i; \
|
||||
\
|
||||
for (tmp_i = 0; s[tmp_i] != '\0'; tmp_i++) \
|
||||
WRITECHAR(p, s[tmp_i]); \
|
||||
\
|
||||
WRITECHAR(p, '\0'); \
|
||||
})
|
||||
|
||||
#if 0 // old names
|
||||
#define WRITEBYTE(p,b) WRITEUINT8(p,b)
|
||||
#define WRITESHORT(p,b) WRITEINT16(p,b)
|
||||
#define WRITEUSHORT(p,b) WRITEUINT16(p,b)
|
||||
#define WRITELONG(p,b) WRITEINT32(p,b)
|
||||
#define WRITEULONG(p,b) WRITEUINT32(p,b)
|
||||
#define WRITEMEM(p, s, n) ({ \
|
||||
memcpy(p, s, n); \
|
||||
p += n; \
|
||||
})
|
||||
|
||||
#define READBYTE(p) READUINT8(p)
|
||||
#define READSHORT(p) READINT16(p)
|
||||
#define READUSHORT(p) READUINT16(p)
|
||||
#define READLONG(p) READINT32(p)
|
||||
#define READULONG(p) READUINT32(p)
|
||||
#endif
|
||||
#define SKIPSTRING(p) while (READCHAR(p) != '\0')
|
||||
|
||||
#define SKIPSTRINGN(p, n) ({ \
|
||||
size_t tmp_i = 0; \
|
||||
\
|
||||
while (tmp_i < n && READCHAR(p) != '\0') \
|
||||
tmp_i++; \
|
||||
})
|
||||
|
||||
#define SKIPSTRINGL(p, n) SKIPSTRINGN(p, n)
|
||||
|
||||
#define READSTRINGN(p, s, n) ({ \
|
||||
size_t tmp_i = 0; \
|
||||
\
|
||||
while (tmp_i < n && (s[tmp_i] = READCHAR(p)) != '\0') \
|
||||
tmp_i++; \
|
||||
\
|
||||
s[tmp_i] = '\0'; \
|
||||
})
|
||||
|
||||
#define READSTRINGL(p, s, n) ({ \
|
||||
size_t tmp_i = 0; \
|
||||
\
|
||||
while (tmp_i < n - 1 && (s[tmp_i] = READCHAR(p)) != '\0') \
|
||||
tmp_i++; \
|
||||
\
|
||||
s[tmp_i] = '\0'; \
|
||||
})
|
||||
|
||||
#define READSTRING(p, s) ({ \
|
||||
size_t tmp_i = 0; \
|
||||
\
|
||||
while ((s[tmp_i] = READCHAR(p)) != '\0') \
|
||||
tmp_i++; \
|
||||
\
|
||||
s[tmp_i] = '\0'; \
|
||||
})
|
||||
|
||||
#define READMEM(p, s, n) ({ \
|
||||
memcpy(s, p, n); \
|
||||
p += n; \
|
||||
})
|
||||
|
|
172
src/command.c
172
src/command.c
|
@ -1,7 +1,7 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -79,7 +79,7 @@ CV_PossibleValue_t CV_Natural[] = {{1, "MIN"}, {999999999, "MAX"}, {0, NULL}};
|
|||
// First implementation is 26 (2.1.21), so earlier configs default at 25 (2.1.20)
|
||||
// Also set CV_HIDEN during runtime, after config is loaded
|
||||
static boolean execversion_enabled = false;
|
||||
consvar_t cv_execversion = {"execversion","25",CV_CALL,CV_Unsigned, CV_EnforceExecVersion, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_execversion = CVAR_INIT ("execversion","25",CV_CALL,CV_Unsigned, CV_EnforceExecVersion);
|
||||
|
||||
// for default joyaxis detection
|
||||
static boolean joyaxis_default = false;
|
||||
|
@ -165,6 +165,8 @@ void COM_BufAddTextEx(const char *ptext, int flags)
|
|||
*/
|
||||
void COM_BufInsertTextEx(const char *ptext, int flags)
|
||||
{
|
||||
const INT32 old_wait = com_wait;
|
||||
|
||||
char *temp = NULL;
|
||||
size_t templen;
|
||||
|
||||
|
@ -176,10 +178,14 @@ void COM_BufInsertTextEx(const char *ptext, int flags)
|
|||
VS_Clear(&com_text);
|
||||
}
|
||||
|
||||
com_wait = 0;
|
||||
|
||||
// add the entire text of the file (or alias)
|
||||
COM_BufAddTextEx(ptext, flags);
|
||||
COM_BufExecute(); // do it right away
|
||||
|
||||
com_wait += old_wait;
|
||||
|
||||
// add the copied off data
|
||||
if (templen)
|
||||
{
|
||||
|
@ -560,7 +566,7 @@ static boolean COM_Exists(const char *com_name)
|
|||
* \param partial The partial name of the command (potentially).
|
||||
* \param skips Number of commands to skip.
|
||||
* \return The complete command name, or NULL.
|
||||
* \sa CV_CompleteVar
|
||||
* \sa CV_CompleteAlias, CV_CompleteVar
|
||||
*/
|
||||
const char *COM_CompleteCommand(const char *partial, INT32 skips)
|
||||
{
|
||||
|
@ -581,6 +587,32 @@ const char *COM_CompleteCommand(const char *partial, INT32 skips)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/** Completes the name of an alias.
|
||||
*
|
||||
* \param partial The partial name of the alias (potentially).
|
||||
* \param skips Number of aliases to skip.
|
||||
* \return The complete alias name, or NULL.
|
||||
* \sa CV_CompleteCommand, CV_CompleteVar
|
||||
*/
|
||||
const char *COM_CompleteAlias(const char *partial, INT32 skips)
|
||||
{
|
||||
cmdalias_t *a;
|
||||
size_t len;
|
||||
|
||||
len = strlen(partial);
|
||||
|
||||
if (!len)
|
||||
return NULL;
|
||||
|
||||
// check functions
|
||||
for (a = com_alias; a; a = a->next)
|
||||
if (!strncmp(partial, a->name, len))
|
||||
if (!skips--)
|
||||
return a->name;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** Parses a single line of text into arguments and tries to execute it.
|
||||
* The text can come from the command buffer, a remote client, or stdin.
|
||||
*
|
||||
|
@ -618,7 +650,7 @@ static void COM_ExecuteString(char *ptext)
|
|||
else
|
||||
{ // Monster Iestyn: keep track of how many levels of recursion we're in
|
||||
recursion++;
|
||||
COM_BufInsertText(a->value);
|
||||
COM_BufInsertTextEx(a->value, com_flags);
|
||||
recursion--;
|
||||
}
|
||||
return;
|
||||
|
@ -875,6 +907,9 @@ static void COM_Help_f(void)
|
|||
CONS_Printf(" Current value: %s\n", cvar->string);
|
||||
else
|
||||
CONS_Printf(" Current value: %d\n", cvar->value);
|
||||
|
||||
if (cvar->revert.v.string != NULL && strcmp(cvar->revert.v.string, cvar->string) != 0)
|
||||
CONS_Printf(" Value before netgame: %s\n", cvar->revert.v.string);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1280,6 +1315,7 @@ void CV_RegisterVar(consvar_t *variable)
|
|||
consvar_vars = variable;
|
||||
}
|
||||
variable->string = variable->zstring = NULL;
|
||||
memset(&variable->revert, 0, sizeof variable->revert);
|
||||
variable->changed = 0; // new variable has not been modified by the user
|
||||
|
||||
#ifdef PARANOIA
|
||||
|
@ -1321,7 +1357,7 @@ static const char *CV_StringValue(const char *var_name)
|
|||
* \param partial The partial name of the variable (potentially).
|
||||
* \param skips Number of variables to skip.
|
||||
* \return The complete variable name, or NULL.
|
||||
* \sa COM_CompleteCommand
|
||||
* \sa COM_CompleteCommand, CV_CompleteAlias
|
||||
*/
|
||||
const char *CV_CompleteVar(char *partial, INT32 skips)
|
||||
{
|
||||
|
@ -1392,6 +1428,23 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
|
|||
for (i = MAXVAL+1; var->PossibleValue[i].strvalue; i++)
|
||||
if (v == var->PossibleValue[i].value || !stricmp(var->PossibleValue[i].strvalue, valstr))
|
||||
{
|
||||
if (client && execversion_enabled)
|
||||
{
|
||||
if (var->revert.allocated)
|
||||
{
|
||||
Z_Free(var->revert.v.string);
|
||||
var->revert.allocated = false; // the below value is not allocated in zone memory, don't try to free it!
|
||||
}
|
||||
|
||||
var->revert.v.const_munge = var->PossibleValue[i].strvalue;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// free the old value string
|
||||
Z_Free(var->zstring);
|
||||
var->zstring = NULL;
|
||||
|
||||
var->value = var->PossibleValue[i].value;
|
||||
var->string = var->PossibleValue[i].strvalue;
|
||||
goto finish;
|
||||
|
@ -1452,12 +1505,31 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
|
|||
// ...or not.
|
||||
goto badinput;
|
||||
found:
|
||||
if (client && execversion_enabled)
|
||||
{
|
||||
var->revert.v.const_munge = var->PossibleValue[i].strvalue;
|
||||
return;
|
||||
}
|
||||
|
||||
var->value = var->PossibleValue[i].value;
|
||||
var->string = var->PossibleValue[i].strvalue;
|
||||
goto finish;
|
||||
}
|
||||
}
|
||||
|
||||
if (client && execversion_enabled)
|
||||
{
|
||||
if (var->revert.allocated)
|
||||
{
|
||||
Z_Free(var->revert.v.string);
|
||||
// Z_StrDup creates a new zone memory block, so we can keep the allocated flag on
|
||||
}
|
||||
|
||||
var->revert.v.string = Z_StrDup(valstr);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// free the old value string
|
||||
Z_Free(var->zstring);
|
||||
|
||||
|
@ -1505,7 +1577,7 @@ finish:
|
|||
}
|
||||
var->flags |= CV_MODIFIED;
|
||||
// raise 'on change' code
|
||||
LUA_CVarChanged(var->name); // let consolelib know what cvar this is.
|
||||
LUA_CVarChanged(var); // let consolelib know what cvar this is.
|
||||
if (var->flags & CV_CALL && !stealth)
|
||||
var->func();
|
||||
|
||||
|
@ -1666,6 +1738,8 @@ void CV_SaveVars(UINT8 **p, boolean in_demo)
|
|||
static void CV_LoadVars(UINT8 **p,
|
||||
consvar_t *(*got)(UINT8 **p, char **ret_value, boolean *ret_stealth))
|
||||
{
|
||||
const boolean store = (client || demoplayback);
|
||||
|
||||
consvar_t *cvar;
|
||||
UINT16 count;
|
||||
|
||||
|
@ -1676,8 +1750,19 @@ static void CV_LoadVars(UINT8 **p,
|
|||
serverloading = true;
|
||||
|
||||
for (cvar = consvar_vars; cvar; cvar = cvar->next)
|
||||
{
|
||||
if (cvar->flags & CV_NETVAR)
|
||||
{
|
||||
if (store && cvar->revert.v.string == NULL)
|
||||
{
|
||||
cvar->revert.v.const_munge = cvar->string;
|
||||
cvar->revert.allocated = ( cvar->zstring != NULL );
|
||||
cvar->zstring = NULL;/* don't free this */
|
||||
}
|
||||
|
||||
Setvalue(cvar, cvar->defaultvalue, true);
|
||||
}
|
||||
}
|
||||
|
||||
count = READUINT16(*p);
|
||||
while (count--)
|
||||
|
@ -1691,6 +1776,27 @@ static void CV_LoadVars(UINT8 **p,
|
|||
serverloading = false;
|
||||
}
|
||||
|
||||
void CV_RevertNetVars(void)
|
||||
{
|
||||
consvar_t * cvar;
|
||||
|
||||
for (cvar = consvar_vars; cvar; cvar = cvar->next)
|
||||
{
|
||||
if (cvar->revert.v.string != NULL)
|
||||
{
|
||||
Setvalue(cvar, cvar->revert.v.string, false);
|
||||
|
||||
if (cvar->revert.allocated)
|
||||
{
|
||||
Z_Free(cvar->revert.v.string);
|
||||
cvar->revert.allocated = false; // no value being held now
|
||||
}
|
||||
|
||||
cvar->revert.v.string = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CV_LoadNetVars(UINT8 **p)
|
||||
{
|
||||
CV_LoadVars(p, ReadNetVar);
|
||||
|
@ -1764,6 +1870,14 @@ static void CV_SetCVar(consvar_t *var, const char *value, boolean stealth)
|
|||
// send the value of the variable
|
||||
UINT8 buf[128];
|
||||
UINT8 *p = buf;
|
||||
|
||||
// Loading from a config in a netgame? Set revert value.
|
||||
if (client && execversion_enabled)
|
||||
{
|
||||
Setvalue(var, value, true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(server || (addedtogame && IsPlayerAdmin(consoleplayer))))
|
||||
{
|
||||
CONS_Printf(M_GetText("Only the server or admin can change: %s %s\n"), var->name, var->string);
|
||||
|
@ -2252,7 +2366,10 @@ static boolean CV_Command(void)
|
|||
return false;
|
||||
|
||||
if (( com_flags & COM_SAFE ) && ( v->flags & CV_NOLUA ))
|
||||
return false;
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, "Variable '%s' cannot be changed from Lua.\n", v->name);
|
||||
return true;
|
||||
}
|
||||
|
||||
// perform a variable print or set
|
||||
if (COM_Argc() == 1)
|
||||
|
@ -2297,18 +2414,43 @@ void CV_SaveVariables(FILE *f)
|
|||
{
|
||||
char stringtowrite[MAXTEXTCMD+1];
|
||||
|
||||
// Silly hack for Min/Max vars
|
||||
if (!strcmp(cvar->string, "MAX") || !strcmp(cvar->string, "MIN"))
|
||||
const char * string;
|
||||
|
||||
if (cvar->revert.v.string != NULL)
|
||||
{
|
||||
if (cvar->flags & CV_FLOAT)
|
||||
sprintf(stringtowrite, "%f", FIXED_TO_FLOAT(cvar->value));
|
||||
else
|
||||
sprintf(stringtowrite, "%d", cvar->value);
|
||||
string = cvar->revert.v.string;
|
||||
}
|
||||
else
|
||||
strcpy(stringtowrite, cvar->string);
|
||||
{
|
||||
string = cvar->string;
|
||||
}
|
||||
|
||||
fprintf(f, "%s \"%s\"\n", cvar->name, stringtowrite);
|
||||
// Silly hack for Min/Max vars
|
||||
#define MINVAL 0
|
||||
#define MAXVAL 1
|
||||
if (
|
||||
cvar->PossibleValue != NULL &&
|
||||
cvar->PossibleValue[0].strvalue &&
|
||||
stricmp(cvar->PossibleValue[0].strvalue, "MIN") == 0
|
||||
){ // bounded cvar
|
||||
int which = stricmp(string, "MAX") == 0;
|
||||
|
||||
if (which || stricmp(string, "MIN") == 0)
|
||||
{
|
||||
INT32 value = cvar->PossibleValue[which].value;
|
||||
|
||||
if (cvar->flags & CV_FLOAT)
|
||||
sprintf(stringtowrite, "%f", FIXED_TO_FLOAT(value));
|
||||
else
|
||||
sprintf(stringtowrite, "%d", value);
|
||||
|
||||
string = stringtowrite;
|
||||
}
|
||||
}
|
||||
#undef MINVAL
|
||||
#undef MAXVAL
|
||||
|
||||
fprintf(f, "%s \"%s\"\n", cvar->name, string);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -49,6 +49,8 @@ size_t COM_FirstOption(void);
|
|||
// match existing command or NULL
|
||||
const char *COM_CompleteCommand(const char *partial, INT32 skips);
|
||||
|
||||
const char *COM_CompleteAlias(const char *partial, INT32 skips);
|
||||
|
||||
// insert at queu (at end of other command)
|
||||
#define COM_BufAddText(s) COM_BufAddTextEx(s, 0)
|
||||
void COM_BufAddTextEx(const char *btext, int flags);
|
||||
|
@ -138,12 +140,26 @@ typedef struct consvar_s //NULL, NULL, 0, NULL, NULL |, 0, NULL, NULL, 0, 0, NUL
|
|||
const char *string; // value in string
|
||||
char *zstring; // Either NULL or same as string.
|
||||
// If non-NULL, must be Z_Free'd later.
|
||||
struct
|
||||
{
|
||||
char allocated; // whether to Z_Free
|
||||
union
|
||||
{
|
||||
char * string;
|
||||
const char * const_munge;
|
||||
} v;
|
||||
} revert; // value of netvar before joining netgame
|
||||
|
||||
UINT16 netid; // used internaly : netid for send end receive
|
||||
// used only with CV_NETVAR
|
||||
char changed; // has variable been changed by the user? 0 = no, 1 = yes
|
||||
struct consvar_s *next;
|
||||
} consvar_t;
|
||||
|
||||
/* name, defaultvalue, flags, PossibleValue, func */
|
||||
#define CVAR_INIT( ... ) \
|
||||
{ __VA_ARGS__, 0, NULL, NULL, {0, {NULL}}, 0U, (char)0, NULL }
|
||||
|
||||
#ifdef OLD22DEMOCOMPAT
|
||||
typedef struct old_demo_var old_demo_var_t;
|
||||
|
||||
|
@ -202,6 +218,9 @@ void CV_SaveVars(UINT8 **p, boolean in_demo);
|
|||
#define CV_SaveNetVars(p) CV_SaveVars(p, false)
|
||||
void CV_LoadNetVars(UINT8 **p);
|
||||
|
||||
// then revert after leaving a netgame
|
||||
void CV_RevertNetVars(void);
|
||||
|
||||
#define CV_SaveDemoVars(p) CV_SaveVars(p, true)
|
||||
void CV_LoadDemoVars(UINT8 **p);
|
||||
|
||||
|
|
|
@ -34,12 +34,14 @@
|
|||
* Last updated 2020 / 07 / 10 - v2.2.6 - player.dta & patch.pk3
|
||||
* Last updated 2020 / 09 / 27 - v2.2.7 - patch.pk3
|
||||
* Last updated 2020 / 10 / 02 - v2.2.8 - patch.pk3
|
||||
* Last updated 2021 / 05 / 06 - v2.2.9 - patch.pk3 & zones.pk3
|
||||
* Last updated 2022 / 03 / 06 - v2.2.10 - main assets
|
||||
*/
|
||||
#define ASSET_HASH_SRB2_PK3 "0277c9416756627004e83cbb5b2e3e28"
|
||||
#define ASSET_HASH_ZONES_PK3 "f7e88afb6af7996a834c7d663144bead"
|
||||
#define ASSET_HASH_PLAYER_DTA "49dad7b24634c89728cc3e0b689e12bb"
|
||||
#define ASSET_HASH_SRB2_PK3 "ad911f29a28a18968ee5b2d11c2acb39"
|
||||
#define ASSET_HASH_ZONES_PK3 "86ae55cae4e0a93ceda868635706a093"
|
||||
#define ASSET_HASH_PLAYER_DTA "2e7aaae8a6b1b77d90ffe7606ceadb6c"
|
||||
#ifdef USE_PATCH_DTA
|
||||
#define ASSET_HASH_PATCH_PK3 "466cdf60075262b3f5baa5e07f0999e8"
|
||||
#define ASSET_HASH_PATCH_PK3 "7d467a883f7887b3c311798ee2f56b6a"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
236
src/console.c
236
src/console.c
|
@ -1,7 +1,7 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -56,7 +56,8 @@ I_mutex con_mutex;
|
|||
#endif/*HAVE_THREADS*/
|
||||
|
||||
static boolean con_started = false; // console has been initialised
|
||||
boolean con_startup = false; // true at game startup, screen need refreshing
|
||||
boolean con_startup = false; // true at game startup
|
||||
boolean con_refresh = false; // screen needs refreshing
|
||||
static boolean con_forcepic = true; // at startup toggle console translucency when first off
|
||||
boolean con_recalc; // set true when screen size has changed
|
||||
|
||||
|
@ -124,22 +125,22 @@ static void CONS_backcolor_Change(void);
|
|||
static char con_buffer[CON_BUFFERSIZE];
|
||||
|
||||
// how many seconds the hud messages lasts on the screen
|
||||
static consvar_t cons_msgtimeout = {"con_hudtime", "5", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
static consvar_t cons_msgtimeout = CVAR_INIT ("con_hudtime", "5", CV_SAVE, CV_Unsigned, NULL);
|
||||
|
||||
// number of lines displayed on the HUD
|
||||
static consvar_t cons_hudlines = {"con_hudlines", "5", CV_CALL|CV_SAVE, CV_Unsigned, CONS_hudlines_Change, 0, NULL, NULL, 0, 0, NULL};
|
||||
static consvar_t cons_hudlines = CVAR_INIT ("con_hudlines", "5", CV_CALL|CV_SAVE, CV_Unsigned, CONS_hudlines_Change);
|
||||
|
||||
// number of lines console move per frame
|
||||
// (con_speed needs a limit, apparently)
|
||||
static CV_PossibleValue_t speed_cons_t[] = {{0, "MIN"}, {64, "MAX"}, {0, NULL}};
|
||||
static consvar_t cons_speed = {"con_speed", "8", CV_SAVE, speed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
static consvar_t cons_speed = CVAR_INIT ("con_speed", "8", CV_SAVE, speed_cons_t, NULL);
|
||||
|
||||
// percentage of screen height to use for console
|
||||
static consvar_t cons_height = {"con_height", "50", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
static consvar_t cons_height = CVAR_INIT ("con_height", "50", CV_SAVE, CV_Unsigned, NULL);
|
||||
|
||||
static CV_PossibleValue_t backpic_cons_t[] = {{0, "translucent"}, {1, "picture"}, {0, NULL}};
|
||||
// whether to use console background picture, or translucent mode
|
||||
static consvar_t cons_backpic = {"con_backpic", "translucent", CV_SAVE, backpic_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
static consvar_t cons_backpic = CVAR_INIT ("con_backpic", "translucent", CV_SAVE, backpic_cons_t, NULL);
|
||||
|
||||
static CV_PossibleValue_t backcolor_cons_t[] = {{0, "White"}, {1, "Black"}, {2, "Sepia"},
|
||||
{3, "Brown"}, {4, "Pink"}, {5, "Raspberry"},
|
||||
|
@ -151,7 +152,7 @@ static CV_PossibleValue_t backcolor_cons_t[] = {{0, "White"}, {1, "Black"}, {
|
|||
{0, NULL}};
|
||||
|
||||
|
||||
consvar_t cons_backcolor = {"con_backcolor", "Green", CV_CALL|CV_SAVE, backcolor_cons_t, CONS_backcolor_Change, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cons_backcolor = CVAR_INIT ("con_backcolor", "Green", CV_CALL|CV_SAVE, backcolor_cons_t, CONS_backcolor_Change);
|
||||
|
||||
static void CON_Print(char *msg);
|
||||
|
||||
|
@ -220,7 +221,7 @@ static void CONS_Bind_f(void)
|
|||
for (key = 0; key < NUMINPUTS; key++)
|
||||
if (bindtable[key])
|
||||
{
|
||||
CONS_Printf("%s : \"%s\"\n", G_KeynumToString(key), bindtable[key]);
|
||||
CONS_Printf("%s : \"%s\"\n", G_KeyNumToName(key), bindtable[key]);
|
||||
na = 1;
|
||||
}
|
||||
if (!na)
|
||||
|
@ -228,7 +229,7 @@ static void CONS_Bind_f(void)
|
|||
return;
|
||||
}
|
||||
|
||||
key = G_KeyStringtoNum(COM_Argv(1));
|
||||
key = G_KeyNameToNum(COM_Argv(1));
|
||||
if (key <= 0 || key >= NUMINPUTS)
|
||||
{
|
||||
CONS_Alert(CONS_NOTICE, M_GetText("Invalid key name\n"));
|
||||
|
@ -359,30 +360,48 @@ static void CON_SetupColormaps(void)
|
|||
for (i = 0; i < (256*15); i++, ++memorysrc)
|
||||
*memorysrc = (UINT8)(i & 0xFF); // remap each color to itself...
|
||||
|
||||
#define colset(map, a, b, c) \
|
||||
map[1] = (UINT8)a;\
|
||||
map[3] = (UINT8)b;\
|
||||
map[9] = (UINT8)c
|
||||
#define colset(map, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) \
|
||||
map[0x0] = (UINT8)a;\
|
||||
map[0x1] = (UINT8)b;\
|
||||
map[0x2] = (UINT8)c;\
|
||||
map[0x3] = (UINT8)d;\
|
||||
map[0x4] = (UINT8)e;\
|
||||
map[0x5] = (UINT8)f;\
|
||||
map[0x6] = (UINT8)g;\
|
||||
map[0x7] = (UINT8)h;\
|
||||
map[0x8] = (UINT8)i;\
|
||||
map[0x9] = (UINT8)j;\
|
||||
map[0xA] = (UINT8)k;\
|
||||
map[0xB] = (UINT8)l;\
|
||||
map[0xC] = (UINT8)m;\
|
||||
map[0xD] = (UINT8)n;\
|
||||
map[0xE] = (UINT8)o;\
|
||||
map[0xF] = (UINT8)p;
|
||||
|
||||
colset(magentamap, 177, 178, 184);
|
||||
colset(yellowmap, 82, 73, 66);
|
||||
colset(lgreenmap, 97, 98, 106);
|
||||
colset(bluemap, 146, 147, 155);
|
||||
colset(redmap, 210, 32, 39);
|
||||
colset(graymap, 6, 8, 14);
|
||||
colset(orangemap, 51, 52, 57);
|
||||
colset(skymap, 129, 130, 133);
|
||||
colset(purplemap, 160, 161, 163);
|
||||
colset(aquamap, 120, 121, 123);
|
||||
colset(peridotmap, 88, 188, 190);
|
||||
colset(azuremap, 144, 145, 170);
|
||||
colset(brownmap, 219, 221, 224);
|
||||
colset(rosymap, 200, 201, 203);
|
||||
colset(invertmap, 27, 26, 22);
|
||||
invertmap[26] = (UINT8)3;
|
||||
// Tried to keep the colors vanilla while adding some shades in between them ~SonicX8000
|
||||
|
||||
// 0x1 0x3 0x9 0xF
|
||||
colset(magentamap, 177, 177, 178, 178, 178, 180, 180, 180, 182, 182, 182, 182, 184, 184, 184, 185);
|
||||
colset(yellowmap, 82, 82, 73, 73, 73, 64, 64, 64, 66, 66, 66, 66, 67, 67, 67, 68);
|
||||
colset(lgreenmap, 96, 96, 98, 98, 98, 101, 101, 101, 104, 104, 104, 104, 106, 106, 106, 107);
|
||||
colset(bluemap, 146, 146, 147, 147, 147, 149, 149, 149, 152, 152, 152, 152, 155, 155, 155, 157);
|
||||
colset(redmap, 32, 32, 33, 33, 33, 35, 35, 35, 39, 39, 39, 39, 42, 42, 42, 44);
|
||||
colset(graymap, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23);
|
||||
colset(orangemap, 50, 50, 52, 52, 52, 54, 54, 54, 56, 56, 56, 56, 59, 59, 59, 60);
|
||||
colset(skymap, 129, 129, 130, 130, 130, 131, 131, 131, 133, 133, 133, 133, 135, 135, 135, 136);
|
||||
colset(purplemap, 160, 160, 161, 161, 161, 162, 162, 162, 163, 163, 163, 163, 164, 164, 164, 165);
|
||||
colset(aquamap, 120, 120, 121, 121, 121, 122, 122, 122, 123, 123, 123, 123, 124, 124, 124, 125);
|
||||
colset(peridotmap, 72, 72, 188, 188, 189, 189, 189, 189, 190, 190, 190, 190, 191, 191, 191, 94);
|
||||
colset(azuremap, 144, 144, 145, 145, 145, 146, 146, 146, 170, 170, 170, 170, 171, 171, 171, 172);
|
||||
colset(brownmap, 219, 219, 221, 221, 221, 222, 222, 222, 224, 224, 224, 224, 227, 227, 227, 229);
|
||||
colset(rosymap, 200, 200, 201, 201, 201, 202, 202, 202, 203, 203, 203, 203, 204, 204, 204, 205);
|
||||
|
||||
#undef colset
|
||||
|
||||
// Yeah just straight up invert it like a normal person
|
||||
for (i = 0x00; i <= 0x1F; i++)
|
||||
invertmap[0x1F - i] = i;
|
||||
|
||||
// Init back colormap
|
||||
CON_SetupBackColormap();
|
||||
}
|
||||
|
@ -439,7 +458,8 @@ void CON_Init(void)
|
|||
Lock_state();
|
||||
|
||||
con_started = true;
|
||||
con_startup = true; // need explicit screen refresh until we are in Doom loop
|
||||
con_startup = true;
|
||||
con_refresh = true; // needs explicit screen refresh until we are in the main game loop
|
||||
consoletoggle = false;
|
||||
|
||||
Unlock_state();
|
||||
|
@ -457,12 +477,26 @@ void CON_Init(void)
|
|||
Lock_state();
|
||||
|
||||
con_started = true;
|
||||
con_startup = false; // need explicit screen refresh until we are in Doom loop
|
||||
con_startup = false;
|
||||
con_refresh = false; // disable explicit screen refresh
|
||||
consoletoggle = true;
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
}
|
||||
|
||||
void CON_StartRefresh(void)
|
||||
{
|
||||
if (con_startup)
|
||||
con_refresh = true;
|
||||
}
|
||||
|
||||
void CON_StopRefresh(void)
|
||||
{
|
||||
if (con_startup)
|
||||
con_refresh = false;
|
||||
}
|
||||
|
||||
// Console input initialization
|
||||
//
|
||||
static void CON_InputInit(void)
|
||||
|
@ -805,6 +839,12 @@ static void CON_InputDelSelection(void)
|
|||
|
||||
Lock_state();
|
||||
|
||||
if (!input_cur)
|
||||
{
|
||||
Unlock_state();
|
||||
return;
|
||||
}
|
||||
|
||||
if (input_cur > input_sel)
|
||||
{
|
||||
start = input_sel;
|
||||
|
@ -870,9 +910,14 @@ boolean CON_Responder(event_t *ev)
|
|||
|
||||
// sequential completions a la 4dos
|
||||
static char completion[80];
|
||||
static INT32 comskips, varskips;
|
||||
|
||||
const char *cmd = "";
|
||||
static INT32 skips;
|
||||
|
||||
static INT32 com_skips;
|
||||
static INT32 var_skips;
|
||||
static INT32 alias_skips;
|
||||
|
||||
const char *cmd = NULL;
|
||||
INT32 key;
|
||||
|
||||
if (chat_on)
|
||||
|
@ -881,12 +926,12 @@ boolean CON_Responder(event_t *ev)
|
|||
// let go keyup events, don't eat them
|
||||
if (ev->type != ev_keydown && ev->type != ev_console)
|
||||
{
|
||||
if (ev->data1 == gamecontrol[gc_console][0] || ev->data1 == gamecontrol[gc_console][1])
|
||||
if (ev->key == gamecontrol[GC_CONSOLE][0] || ev->key == gamecontrol[GC_CONSOLE][1])
|
||||
consdown = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
key = ev->data1;
|
||||
key = ev->key;
|
||||
|
||||
// check for console toggle key
|
||||
if (ev->type != ev_console)
|
||||
|
@ -894,7 +939,7 @@ boolean CON_Responder(event_t *ev)
|
|||
if (modeattacking || metalrecording || marathonmode)
|
||||
return false;
|
||||
|
||||
if (key == gamecontrol[gc_console][0] || key == gamecontrol[gc_console][1])
|
||||
if (key == gamecontrol[GC_CONSOLE][0] || key == gamecontrol[GC_CONSOLE][1])
|
||||
{
|
||||
if (consdown) // ignore repeat
|
||||
return true;
|
||||
|
@ -1007,7 +1052,6 @@ boolean CON_Responder(event_t *ev)
|
|||
if (!input_len || input_len >= 40 || strchr(inputlines[inputline], ' '))
|
||||
return true;
|
||||
strcpy(completion, inputlines[inputline]);
|
||||
comskips = varskips = 0;
|
||||
}
|
||||
len = strlen(completion);
|
||||
|
||||
|
@ -1023,6 +1067,14 @@ boolean CON_Responder(event_t *ev)
|
|||
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;
|
||||
|
||||
return true;
|
||||
}
|
||||
// ---
|
||||
|
@ -1091,43 +1143,64 @@ boolean CON_Responder(event_t *ev)
|
|||
if (!input_len || input_len >= 40 || strchr(inputlines[inputline], ' '))
|
||||
return true;
|
||||
strcpy(completion, inputlines[inputline]);
|
||||
comskips = varskips = 0;
|
||||
skips = 0;
|
||||
com_skips = 0;
|
||||
var_skips = 0;
|
||||
alias_skips = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (shiftdown)
|
||||
{
|
||||
if (comskips < 0)
|
||||
{
|
||||
if (--varskips < 0)
|
||||
comskips = -comskips - 2;
|
||||
}
|
||||
else if (comskips > 0) comskips--;
|
||||
if (skips > 0)
|
||||
skips--;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (comskips < 0) varskips++;
|
||||
else comskips++;
|
||||
skips++;
|
||||
}
|
||||
}
|
||||
|
||||
if (comskips >= 0)
|
||||
if (skips <= com_skips)
|
||||
{
|
||||
cmd = COM_CompleteCommand(completion, comskips);
|
||||
if (!cmd) // dirty: make sure if comskips is zero, to have a neg value
|
||||
comskips = -comskips - 1;
|
||||
cmd = COM_CompleteCommand(completion, skips);
|
||||
|
||||
if (cmd && skips == com_skips)
|
||||
{
|
||||
com_skips ++;
|
||||
var_skips ++;
|
||||
alias_skips++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!cmd && skips <= var_skips)
|
||||
{
|
||||
cmd = CV_CompleteVar(completion, skips - com_skips);
|
||||
|
||||
if (cmd && skips == var_skips)
|
||||
{
|
||||
var_skips ++;
|
||||
alias_skips++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!cmd && skips <= alias_skips)
|
||||
{
|
||||
cmd = COM_CompleteAlias(completion, skips - var_skips);
|
||||
|
||||
if (cmd && skips == alias_skips)
|
||||
{
|
||||
alias_skips++;
|
||||
}
|
||||
}
|
||||
if (comskips < 0)
|
||||
cmd = CV_CompleteVar(completion, varskips);
|
||||
|
||||
if (cmd)
|
||||
{
|
||||
CON_InputSetString(va("%s ", cmd));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (comskips > 0)
|
||||
comskips--;
|
||||
else if (varskips > 0)
|
||||
varskips--;
|
||||
skips--;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1243,10 +1316,6 @@ boolean CON_Responder(event_t *ev)
|
|||
if (key < 32 || key > 127)
|
||||
return true;
|
||||
|
||||
// add key to cmd line here
|
||||
if (key >= 'A' && key <= 'Z' && !(shiftdown ^ capslock)) //this is only really necessary for dedicated servers
|
||||
key = key + 'a' - 'A';
|
||||
|
||||
if (input_sel != input_cur)
|
||||
CON_InputDelSelection();
|
||||
CON_InputAddChar(key);
|
||||
|
@ -1405,7 +1474,7 @@ void CONS_Printf(const char *fmt, ...)
|
|||
{
|
||||
va_list argptr;
|
||||
static char *txt = NULL;
|
||||
boolean startup;
|
||||
boolean refresh;
|
||||
|
||||
if (txt == NULL)
|
||||
txt = malloc(8192);
|
||||
|
@ -1427,26 +1496,15 @@ void CONS_Printf(const char *fmt, ...)
|
|||
|
||||
// make sure new text is visible
|
||||
con_scrollup = 0;
|
||||
startup = con_startup;
|
||||
refresh = con_refresh;
|
||||
|
||||
Unlock_state();
|
||||
|
||||
// if not in display loop, force screen update
|
||||
if (startup && (!setrenderneeded))
|
||||
if (refresh)
|
||||
{
|
||||
#ifdef _WINDOWS
|
||||
patch_t *con_backpic = W_CachePatchName("CONSBACK", PU_PATCH);
|
||||
|
||||
// Jimita: CON_DrawBackpic just called V_DrawScaledPatch
|
||||
V_DrawScaledPatch(0, 0, 0, con_backpic);
|
||||
|
||||
W_UnlockCachedPatch(con_backpic);
|
||||
I_LoadingScreen(txt); // Win32/OS2 only
|
||||
#else
|
||||
// here we display the console text
|
||||
CON_Drawer();
|
||||
CON_Drawer(); // here we display the console text
|
||||
I_FinishUpdate(); // page flip or blit buffer
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1508,7 +1566,7 @@ void CONS_Debug(INT32 debugflags, const char *fmt, ...)
|
|||
//
|
||||
void CONS_Error(const char *msg)
|
||||
{
|
||||
#ifdef RPC_NO_WINDOWS_H
|
||||
#if defined(RPC_NO_WINDOWS_H) && defined(_WINDOWS)
|
||||
if (!graphics_started)
|
||||
{
|
||||
MessageBoxA(vid.WndParent, msg, "SRB2 Warning", MB_OK);
|
||||
|
@ -1652,12 +1710,15 @@ static void CON_DrawHudlines(void)
|
|||
{
|
||||
charflags = (*p & 0x7f) << V_CHARCOLORSHIFT;
|
||||
p++;
|
||||
c++;
|
||||
}
|
||||
if (c >= con_width)
|
||||
break;
|
||||
if (*p < HU_FONTSTART)
|
||||
;//charwidth = 4 * con_scalefactor;
|
||||
else
|
||||
{
|
||||
//charwidth = SHORT(hu_font['A'-HU_FONTSTART]->width) * con_scalefactor;
|
||||
//charwidth = (hu_font['A'-HU_FONTSTART]->width) * con_scalefactor;
|
||||
V_DrawCharacter(x, y, (INT32)(*p) | charflags | cv_constextsize.value | V_NOSCALESTART, true);
|
||||
}
|
||||
}
|
||||
|
@ -1686,8 +1747,8 @@ static void CON_DrawBackpic(void)
|
|||
if (piclump == LUMPERROR)
|
||||
piclump = W_GetNumForName("MISSING");
|
||||
|
||||
// Cache the Software patch.
|
||||
con_backpic = W_CacheSoftwarePatchNum(piclump, PU_PATCH);
|
||||
// Cache the patch.
|
||||
con_backpic = W_CachePatchNum(piclump, PU_PATCH);
|
||||
|
||||
// Center the backpic, and draw a vertically cropped patch.
|
||||
w = (con_backpic->width * vid.dupx);
|
||||
|
@ -1698,7 +1759,7 @@ static void CON_DrawBackpic(void)
|
|||
// then fill the sides with a solid color.
|
||||
if (x > 0)
|
||||
{
|
||||
column_t *column = (column_t *)((UINT8 *)(con_backpic) + LONG(con_backpic->columnofs[0]));
|
||||
column_t *column = (column_t *)((UINT8 *)(con_backpic->columns) + (con_backpic->columnofs[0]));
|
||||
if (!column->topdelta)
|
||||
{
|
||||
UINT8 *source = (UINT8 *)(column) + 3;
|
||||
|
@ -1710,10 +1771,9 @@ static void CON_DrawBackpic(void)
|
|||
}
|
||||
}
|
||||
|
||||
// Cache the patch normally.
|
||||
con_backpic = W_CachePatchNum(piclump, PU_PATCH);
|
||||
V_DrawCroppedPatch(x << FRACBITS, 0, FRACUNIT, V_NOSCALESTART, con_backpic,
|
||||
0, ( BASEVIDHEIGHT - h ), BASEVIDWIDTH, h);
|
||||
// Draw the patch.
|
||||
V_DrawCroppedPatch(x << FRACBITS, 0, FRACUNIT, FRACUNIT, V_NOSCALESTART, con_backpic, NULL,
|
||||
0, (BASEVIDHEIGHT - h) << FRACBITS, BASEVIDWIDTH << FRACBITS, h << FRACBITS);
|
||||
|
||||
// Unlock the cached patch.
|
||||
W_UnlockCachedPatch(con_backpic);
|
||||
|
@ -1774,7 +1834,10 @@ static void CON_DrawConsole(void)
|
|||
{
|
||||
charflags = (*p & 0x7f) << V_CHARCOLORSHIFT;
|
||||
p++;
|
||||
c++;
|
||||
}
|
||||
if (c >= con_width)
|
||||
break;
|
||||
V_DrawCharacter(x, y, (INT32)(*p) | charflags | cv_constextsize.value | V_NOSCALESTART, true);
|
||||
}
|
||||
}
|
||||
|
@ -1796,9 +1859,6 @@ void CON_Drawer(void)
|
|||
return;
|
||||
}
|
||||
|
||||
if (needpatchrecache)
|
||||
HU_LoadGraphics();
|
||||
|
||||
if (con_recalc)
|
||||
{
|
||||
CON_RecalcSize();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -16,6 +16,9 @@
|
|||
|
||||
void CON_Init(void);
|
||||
|
||||
void CON_StartRefresh(void);
|
||||
void CON_StopRefresh(void);
|
||||
|
||||
boolean CON_Responder(event_t *ev);
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
|
@ -25,8 +28,12 @@ extern I_mutex con_mutex;
|
|||
// set true when screen size has changed, to adapt console
|
||||
extern boolean con_recalc;
|
||||
|
||||
// console being displayed at game startup
|
||||
extern boolean con_startup;
|
||||
|
||||
// needs explicit screen refresh until we are in the main game loop
|
||||
extern boolean con_refresh;
|
||||
|
||||
// top clip value for view render: do not draw part of view hidden by console
|
||||
extern INT32 con_clipviewtop;
|
||||
|
||||
|
|
2001
src/d_clisrv.c
2001
src/d_clisrv.c
File diff suppressed because it is too large
Load diff
232
src/d_clisrv.h
232
src/d_clisrv.h
|
@ -1,7 +1,7 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -22,11 +22,15 @@
|
|||
#include "mserv.h"
|
||||
|
||||
/*
|
||||
The 'packet version' is used to distinguish packet formats.
|
||||
This version is independent of VERSION and SUBVERSION. Different
|
||||
applications may follow different packet versions.
|
||||
The 'packet version' is used to distinguish packet
|
||||
formats. This version is independent of VERSION and
|
||||
SUBVERSION. Different applications may follow different
|
||||
packet versions.
|
||||
|
||||
If you change the struct or the meaning of a field
|
||||
therein, increment this number.
|
||||
*/
|
||||
#define PACKETVERSION 3
|
||||
#define PACKETVERSION 4
|
||||
|
||||
// Network play related stuff.
|
||||
// There is a data struct that stores network
|
||||
|
@ -64,8 +68,10 @@ typedef enum
|
|||
PT_REQUESTFILE, // Client requests a file transfer
|
||||
PT_ASKINFOVIAMS, // Packet from the MS requesting info be sent to new client.
|
||||
// If this ID changes, update masterserver definition.
|
||||
PT_RESYNCHEND, // Player is now resynched and is being requested to remake the gametic
|
||||
PT_RESYNCHGET, // Player got resynch packet
|
||||
|
||||
PT_WILLRESENDGAMESTATE, // Hey Client, I am about to resend you the gamestate!
|
||||
PT_CANRECEIVEGAMESTATE, // Okay Server, I'm ready to receive it, you can go ahead.
|
||||
PT_RECEIVEDGAMESTATE, // Thank you Server, I am ready to play again!
|
||||
|
||||
PT_SENDINGLUAFILE, // Server telling a client Lua needs to open a file
|
||||
PT_ASKLUAFILE, // Client telling the server they don't have the file
|
||||
|
@ -85,11 +91,12 @@ typedef enum
|
|||
PT_TEXTCMD2, // Splitscreen text commands.
|
||||
PT_CLIENTJOIN, // Client wants to join; used in start game.
|
||||
PT_NODETIMEOUT, // Packet sent to self if the connection times out.
|
||||
PT_RESYNCHING, // Packet sent to resync players.
|
||||
// Blocks game advance until synched.
|
||||
|
||||
PT_LOGIN, // Login attempt from the client.
|
||||
|
||||
PT_TELLFILESNEEDED, // Client, to server: "what other files do I need starting from this number?"
|
||||
PT_MOREFILESNEEDED, // Server, to client: "you need these (+ more on top of those)"
|
||||
|
||||
PT_PING, // Packet sent to tell clients the other client's latency to server.
|
||||
NUMPACKETTYPE
|
||||
} packettype_t;
|
||||
|
@ -139,173 +146,8 @@ typedef struct
|
|||
ticcmd_t cmds[45]; // Normally [BACKUPTIC][MAXPLAYERS] but too large
|
||||
} ATTRPACK servertics_pak;
|
||||
|
||||
// Sent to client when all consistency data
|
||||
// for players has been restored
|
||||
typedef struct
|
||||
{
|
||||
UINT32 randomseed;
|
||||
|
||||
// CTF flag stuff
|
||||
SINT8 flagplayer[2];
|
||||
INT32 flagloose[2];
|
||||
INT32 flagflags[2];
|
||||
fixed_t flagx[2];
|
||||
fixed_t flagy[2];
|
||||
fixed_t flagz[2];
|
||||
|
||||
UINT32 ingame; // Spectator bit for each player
|
||||
UINT32 outofcoop; // outofcoop bit for each player
|
||||
INT32 ctfteam[MAXPLAYERS]; // Which team? (can't be 1 bit, since in regular Match there are no teams)
|
||||
|
||||
// Resynch game scores and the like all at once
|
||||
UINT32 score[MAXPLAYERS]; // Everyone's score
|
||||
INT16 numboxes[MAXPLAYERS];
|
||||
INT16 totalring[MAXPLAYERS];
|
||||
tic_t realtime[MAXPLAYERS];
|
||||
UINT8 laps[MAXPLAYERS];
|
||||
} ATTRPACK resynchend_pak;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Player stuff
|
||||
UINT8 playernum;
|
||||
|
||||
// Do not send anything visual related.
|
||||
// Only send data that we need to know for physics.
|
||||
UINT8 playerstate; // playerstate_t
|
||||
UINT32 pflags; // pflags_t
|
||||
UINT8 panim; // panim_t
|
||||
|
||||
INT16 angleturn;
|
||||
INT16 oldrelangleturn;
|
||||
|
||||
angle_t aiming;
|
||||
INT32 currentweapon;
|
||||
INT32 ringweapons;
|
||||
UINT16 ammoremoval;
|
||||
tic_t ammoremovaltimer;
|
||||
INT32 ammoremovalweapon;
|
||||
UINT16 powers[NUMPOWERS];
|
||||
|
||||
// Score is resynched in the confirm resync packet
|
||||
INT16 rings;
|
||||
INT16 spheres;
|
||||
SINT8 lives;
|
||||
SINT8 continues;
|
||||
UINT8 scoreadd;
|
||||
SINT8 xtralife;
|
||||
SINT8 pity;
|
||||
|
||||
UINT16 skincolor;
|
||||
INT32 skin;
|
||||
UINT32 availabilities;
|
||||
// Just in case Lua does something like
|
||||
// modify these at runtime
|
||||
fixed_t camerascale;
|
||||
fixed_t shieldscale;
|
||||
fixed_t normalspeed;
|
||||
fixed_t runspeed;
|
||||
UINT8 thrustfactor;
|
||||
UINT8 accelstart;
|
||||
UINT8 acceleration;
|
||||
UINT8 charability;
|
||||
UINT8 charability2;
|
||||
UINT32 charflags;
|
||||
UINT32 thokitem; // mobjtype_t
|
||||
UINT32 spinitem; // mobjtype_t
|
||||
UINT32 revitem; // mobjtype_t
|
||||
UINT32 followitem; // mobjtype_t
|
||||
fixed_t actionspd;
|
||||
fixed_t mindash;
|
||||
fixed_t maxdash;
|
||||
fixed_t jumpfactor;
|
||||
fixed_t playerheight;
|
||||
fixed_t playerspinheight;
|
||||
|
||||
fixed_t speed;
|
||||
UINT8 secondjump;
|
||||
UINT8 fly1;
|
||||
tic_t glidetime;
|
||||
UINT8 climbing;
|
||||
INT32 deadtimer;
|
||||
tic_t exiting;
|
||||
UINT8 homing;
|
||||
tic_t dashmode;
|
||||
tic_t skidtime;
|
||||
fixed_t cmomx;
|
||||
fixed_t cmomy;
|
||||
fixed_t rmomx;
|
||||
fixed_t rmomy;
|
||||
|
||||
INT32 weapondelay;
|
||||
INT32 tossdelay;
|
||||
|
||||
INT16 starpostx;
|
||||
INT16 starposty;
|
||||
INT16 starpostz;
|
||||
INT32 starpostnum;
|
||||
tic_t starposttime;
|
||||
angle_t starpostangle;
|
||||
fixed_t starpostscale;
|
||||
|
||||
INT32 maxlink;
|
||||
fixed_t dashspeed;
|
||||
angle_t angle_pos;
|
||||
angle_t old_angle_pos;
|
||||
tic_t bumpertime;
|
||||
INT32 flyangle;
|
||||
tic_t drilltimer;
|
||||
INT32 linkcount;
|
||||
tic_t linktimer;
|
||||
INT32 anotherflyangle;
|
||||
tic_t nightstime;
|
||||
INT32 drillmeter;
|
||||
UINT8 drilldelay;
|
||||
UINT8 bonustime;
|
||||
UINT8 mare;
|
||||
INT16 lastsidehit, lastlinehit;
|
||||
|
||||
tic_t losstime;
|
||||
UINT8 timeshit;
|
||||
INT32 onconveyor;
|
||||
|
||||
//player->mo stuff
|
||||
UINT8 hasmo; // Boolean
|
||||
|
||||
INT32 health;
|
||||
angle_t angle;
|
||||
angle_t rollangle;
|
||||
fixed_t x;
|
||||
fixed_t y;
|
||||
fixed_t z;
|
||||
fixed_t momx;
|
||||
fixed_t momy;
|
||||
fixed_t momz;
|
||||
fixed_t friction;
|
||||
fixed_t movefactor;
|
||||
|
||||
spritenum_t sprite;
|
||||
UINT32 frame;
|
||||
UINT8 sprite2;
|
||||
UINT16 anim_duration;
|
||||
INT32 tics;
|
||||
statenum_t statenum;
|
||||
UINT32 flags;
|
||||
UINT32 flags2;
|
||||
UINT16 eflags;
|
||||
|
||||
fixed_t radius;
|
||||
fixed_t height;
|
||||
fixed_t scale;
|
||||
fixed_t destscale;
|
||||
fixed_t scalespeed;
|
||||
} ATTRPACK resynch_pak;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 version; // Different versions don't work
|
||||
UINT8 subversion; // Contains build version
|
||||
|
||||
// Server launch stuffs
|
||||
UINT8 serverplayer;
|
||||
UINT8 totalslotnum; // "Slots": highest player number in use plus one.
|
||||
|
@ -314,18 +156,10 @@ typedef struct
|
|||
UINT8 clientnode;
|
||||
UINT8 gamestate;
|
||||
|
||||
// 0xFF == not in game; else player skin num
|
||||
UINT8 playerskins[MAXPLAYERS];
|
||||
UINT16 playercolor[MAXPLAYERS];
|
||||
UINT32 playeravailabilities[MAXPLAYERS];
|
||||
|
||||
UINT8 gametype;
|
||||
UINT8 modifiedgame;
|
||||
SINT8 adminplayers[MAXPLAYERS]; // Needs to be signed
|
||||
|
||||
char server_context[8]; // Unique context id, generated at server startup.
|
||||
|
||||
UINT8 varlengthinputs[0]; // Playernames and netvars
|
||||
} ATTRPACK serverconfig_pak;
|
||||
|
||||
typedef struct
|
||||
|
@ -360,16 +194,22 @@ typedef struct
|
|||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 _255;/* see serverinfo_pak */
|
||||
UINT8 packetversion;
|
||||
UINT8 modversion;
|
||||
char application[MAXAPPLICATION];
|
||||
UINT8 version; // Different versions don't work
|
||||
UINT8 subversion; // Contains build version
|
||||
UINT8 localplayers;
|
||||
UINT8 mode;
|
||||
char names[MAXSPLITSCREENPLAYERS][MAXPLAYERNAME];
|
||||
} ATTRPACK clientconfig_pak;
|
||||
|
||||
#define SV_DEDICATED 0x40 // server is dedicated
|
||||
#define SV_LOTSOFADDONS 0x20 // flag used to ask for full file list in d_netfil
|
||||
|
||||
enum {
|
||||
REFUSE_JOINS_DISABLED = 1,
|
||||
REFUSE_SLOTS_FULL,
|
||||
REFUSE_BANNED,
|
||||
};
|
||||
|
||||
#define MAXSERVERNAME 32
|
||||
#define MAXFILENEEDED 915
|
||||
// This packet is too large
|
||||
|
@ -387,11 +227,11 @@ typedef struct
|
|||
UINT8 subversion;
|
||||
UINT8 numberofplayer;
|
||||
UINT8 maxplayer;
|
||||
UINT8 refusereason; // 0: joinable, 1: joins disabled, 2: full
|
||||
UINT8 refusereason; // 0: joinable, REFUSE enum
|
||||
char gametypename[24];
|
||||
UINT8 modifiedgame;
|
||||
UINT8 cheatsenabled;
|
||||
UINT8 isdedicated;
|
||||
UINT8 flags;
|
||||
UINT8 fileneedednum;
|
||||
tic_t time;
|
||||
tic_t leveltime;
|
||||
|
@ -445,6 +285,14 @@ typedef struct
|
|||
UINT8 ctfteam;
|
||||
} ATTRPACK plrconfig;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
INT32 first;
|
||||
UINT8 num;
|
||||
UINT8 more;
|
||||
UINT8 files[MAXFILENEEDED]; // is filled with writexxx (byteptr.h)
|
||||
} ATTRPACK filesneededconfig_pak;
|
||||
|
||||
//
|
||||
// Network packet data
|
||||
//
|
||||
|
@ -462,9 +310,6 @@ typedef struct
|
|||
client2cmd_pak client2pak; // 200 bytes
|
||||
servertics_pak serverpak; // 132495 bytes (more around 360, no?)
|
||||
serverconfig_pak servercfg; // 773 bytes
|
||||
resynchend_pak resynchend; //
|
||||
resynch_pak resynchpak; //
|
||||
UINT8 resynchgot; //
|
||||
UINT8 textcmd[MAXTEXTCMD+1]; // 66049 bytes (wut??? 64k??? More like 257 bytes...)
|
||||
filetx_pak filetxpak; // 139 bytes
|
||||
fileack_pak fileack;
|
||||
|
@ -477,6 +322,8 @@ typedef struct
|
|||
msaskinfo_pak msaskinfo; // 22 bytes
|
||||
plrinfo playerinfo[MAXPLAYERS]; // 576 bytes(?)
|
||||
plrconfig playerconfig[MAXPLAYERS]; // (up to) 528 bytes(?)
|
||||
INT32 filesneedednum; // 4 bytes
|
||||
filesneededconfig_pak filesneededcfg; // ??? bytes
|
||||
UINT32 pingtable[MAXPLAYERS+1]; // 68 bytes
|
||||
} u; // This is needed to pack diff packet types data together
|
||||
} ATTRPACK doomdata_t;
|
||||
|
@ -574,6 +421,7 @@ void CL_Reset(void);
|
|||
void CL_ClearPlayer(INT32 playernum);
|
||||
void CL_QueryServerList(msg_server_t *list);
|
||||
void CL_UpdateServerList(boolean internetsearch, INT32 room);
|
||||
void CL_RemovePlayer(INT32 playernum, kickreason_t reason);
|
||||
// Is there a game running
|
||||
boolean Playing(void);
|
||||
|
||||
|
@ -606,7 +454,7 @@ UINT8 GetFreeXCmdSize(void);
|
|||
|
||||
void D_MD5PasswordPass(const UINT8 *buffer, size_t len, const char *salt, void *dest);
|
||||
|
||||
extern UINT8 hu_resynching;
|
||||
extern UINT8 hu_redownloadinggamestate;
|
||||
|
||||
extern UINT8 adminpassmd5[16];
|
||||
extern boolean adminpasswordset;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -33,9 +33,10 @@ typedef enum
|
|||
typedef struct
|
||||
{
|
||||
evtype_t type;
|
||||
INT32 data1; // keys / mouse/joystick buttons
|
||||
INT32 data2; // mouse/joystick x move
|
||||
INT32 data3; // mouse/joystick y move
|
||||
INT32 key; // keys/mouse/joystick buttons
|
||||
INT32 x; // mouse/joystick x move
|
||||
INT32 y; // mouse/joystick y move
|
||||
boolean repeated; // key repeat
|
||||
} event_t;
|
||||
|
||||
//
|
||||
|
|
417
src/d_main.c
417
src/d_main.c
|
@ -2,7 +2,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -15,7 +15,7 @@
|
|||
/// plus functions to parse command line parameters, configure game
|
||||
/// parameters, and call the startup functions.
|
||||
|
||||
#if (defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)
|
||||
#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON)
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
@ -61,12 +61,13 @@
|
|||
#include "p_local.h" // chasecam
|
||||
#include "mserv.h" // ms_RoomId
|
||||
#include "m_misc.h" // screenshot functionality
|
||||
#include "dehacked.h" // Dehacked list test
|
||||
#include "deh_tables.h" // Dehacked list test
|
||||
#include "m_cond.h" // condition initialization
|
||||
#include "fastcmp.h"
|
||||
#include "keys.h"
|
||||
#include "filesrch.h" // refreshdirmenu, mainwadstally
|
||||
#include "filesrch.h" // refreshdirmenu
|
||||
#include "g_input.h" // tutorial mode control scheming
|
||||
#include "m_perfstats.h"
|
||||
|
||||
#ifdef CMAKECONFIG
|
||||
#include "config.h"
|
||||
|
@ -95,19 +96,14 @@ int SUBVERSION;
|
|||
// platform independant focus loss
|
||||
UINT8 window_notinfocus = false;
|
||||
|
||||
//
|
||||
// DEMO LOOP
|
||||
//
|
||||
static char *startupwadfiles[MAX_WADFILES];
|
||||
static char *startuppwads[MAX_WADFILES];
|
||||
static addfilelist_t startupwadfiles;
|
||||
static addfilelist_t startuppwads;
|
||||
|
||||
boolean devparm = false; // started game with -devparm
|
||||
|
||||
boolean singletics = false; // timedemo
|
||||
boolean lastdraw = false;
|
||||
|
||||
static void D_CheckRendererState(void);
|
||||
|
||||
postimg_t postimgtype = postimg_none;
|
||||
INT32 postimgparam;
|
||||
postimg_t postimgtype2 = postimg_none;
|
||||
|
@ -120,6 +116,9 @@ boolean midi_disabled = false;
|
|||
boolean sound_disabled = false;
|
||||
boolean digital_disabled = false;
|
||||
|
||||
//
|
||||
// DEMO LOOP
|
||||
//
|
||||
boolean advancedemo;
|
||||
#ifdef DEBUGFILE
|
||||
INT32 debugload = 0;
|
||||
|
@ -176,10 +175,53 @@ void D_ProcessEvents(void)
|
|||
|
||||
boolean eaten;
|
||||
|
||||
// Reset possibly stale mouse info
|
||||
G_SetMouseDeltas(0, 0, 1);
|
||||
G_SetMouseDeltas(0, 0, 2);
|
||||
mouse.buttons &= ~(MB_SCROLLUP|MB_SCROLLDOWN);
|
||||
mouse2.buttons &= ~(MB_SCROLLUP|MB_SCROLLDOWN);
|
||||
|
||||
for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1))
|
||||
{
|
||||
boolean hooked = false;
|
||||
|
||||
ev = &events[eventtail];
|
||||
|
||||
// Set mouse buttons early in case event is eaten later
|
||||
if (ev->type == ev_keydown || ev->type == ev_keyup)
|
||||
{
|
||||
// Mouse buttons
|
||||
if ((UINT32)(ev->key - KEY_MOUSE1) < MOUSEBUTTONS)
|
||||
{
|
||||
if (ev->type == ev_keydown)
|
||||
mouse.buttons |= 1 << (ev->key - KEY_MOUSE1);
|
||||
else
|
||||
mouse.buttons &= ~(1 << (ev->key - KEY_MOUSE1));
|
||||
}
|
||||
else if ((UINT32)(ev->key - KEY_2MOUSE1) < MOUSEBUTTONS)
|
||||
{
|
||||
if (ev->type == ev_keydown)
|
||||
mouse2.buttons |= 1 << (ev->key - KEY_2MOUSE1);
|
||||
else
|
||||
mouse2.buttons &= ~(1 << (ev->key - KEY_2MOUSE1));
|
||||
}
|
||||
// Scroll (has no keyup event)
|
||||
else switch (ev->key) {
|
||||
case KEY_MOUSEWHEELUP:
|
||||
mouse.buttons |= MB_SCROLLUP;
|
||||
break;
|
||||
case KEY_MOUSEWHEELDOWN:
|
||||
mouse.buttons |= MB_SCROLLDOWN;
|
||||
break;
|
||||
case KEY_2MOUSEWHEELUP:
|
||||
mouse2.buttons |= MB_SCROLLUP;
|
||||
break;
|
||||
case KEY_2MOUSEWHEELDOWN:
|
||||
mouse2.buttons |= MB_SCROLLDOWN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Screenshots over everything so that they can be taken anywhere.
|
||||
if (M_ScreenshotResponder(ev))
|
||||
continue; // ate the event
|
||||
|
@ -190,6 +232,12 @@ void D_ProcessEvents(void)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!CON_Ready() && !menuactive) {
|
||||
if (G_LuaResponder(ev))
|
||||
continue;
|
||||
hooked = true;
|
||||
}
|
||||
|
||||
// Menu input
|
||||
#ifdef HAVE_THREADS
|
||||
I_lock_mutex(&m_menu_mutex);
|
||||
|
@ -204,6 +252,12 @@ void D_ProcessEvents(void)
|
|||
if (eaten)
|
||||
continue; // menu ate the event
|
||||
|
||||
if (!hooked && !CON_Ready()) {
|
||||
if (G_LuaResponder(ev))
|
||||
continue;
|
||||
hooked = true;
|
||||
}
|
||||
|
||||
// console input
|
||||
#ifdef HAVE_THREADS
|
||||
I_lock_mutex(&con_mutex);
|
||||
|
@ -218,8 +272,16 @@ void D_ProcessEvents(void)
|
|||
if (eaten)
|
||||
continue; // ate the event
|
||||
|
||||
if (!hooked && !CON_Ready() && G_LuaResponder(ev))
|
||||
continue;
|
||||
|
||||
G_Responder(ev);
|
||||
}
|
||||
|
||||
if (mouse.rdx || mouse.rdy)
|
||||
G_SetMouseDeltas(mouse.rdx, mouse.rdy, 1);
|
||||
if (mouse2.rdx || mouse2.rdy)
|
||||
G_SetMouseDeltas(mouse2.rdx, mouse2.rdy, 2);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -236,7 +298,6 @@ INT16 wipetypepost = -1;
|
|||
|
||||
static void D_Display(void)
|
||||
{
|
||||
INT32 setrenderstillneeded = 0;
|
||||
boolean forcerefresh = false;
|
||||
static boolean wipe = false;
|
||||
INT32 wipedefindex = 0;
|
||||
|
@ -259,48 +320,28 @@ static void D_Display(void)
|
|||
// create plane polygons, if necessary.
|
||||
// 3. Functions related to switching video
|
||||
// modes (resolution) are called.
|
||||
// 4. Patch data is freed from memory,
|
||||
// and recached if necessary.
|
||||
// 5. The frame is ready to be drawn!
|
||||
// 4. The frame is ready to be drawn!
|
||||
|
||||
// stop movie if needs to change renderer
|
||||
if (setrenderneeded && (moviemode == MM_APNG))
|
||||
M_StopMovie();
|
||||
|
||||
// check for change of renderer or screen size (video mode)
|
||||
// Check for change of renderer or screen size (video mode)
|
||||
if ((setrenderneeded || setmodeneeded) && !wipe)
|
||||
{
|
||||
if (setrenderneeded)
|
||||
{
|
||||
CONS_Debug(DBG_RENDER, "setrenderneeded set (%d)\n", setrenderneeded);
|
||||
setrenderstillneeded = setrenderneeded;
|
||||
}
|
||||
SCR_SetMode(); // change video mode
|
||||
}
|
||||
|
||||
if (vid.recalc || setrenderstillneeded)
|
||||
{
|
||||
// Recalc the screen
|
||||
if (vid.recalc)
|
||||
SCR_Recalc(); // NOTE! setsizeneeded is set by SCR_Recalc()
|
||||
#ifdef HWRENDER
|
||||
// Shoot! The screen texture was flushed!
|
||||
if ((rendermode == render_opengl) && (gamestate == GS_INTERMISSION))
|
||||
usebuffer = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
// View morph
|
||||
if (rendermode == render_soft && !splitscreen)
|
||||
R_CheckViewMorph();
|
||||
|
||||
// change the view size if needed
|
||||
if (setsizeneeded || setrenderstillneeded)
|
||||
// Change the view size if needed
|
||||
// Set by changing video mode or renderer
|
||||
if (setsizeneeded)
|
||||
{
|
||||
R_ExecuteSetViewSize();
|
||||
forcerefresh = true; // force background redraw
|
||||
}
|
||||
|
||||
// Lactozilla: Renderer switching
|
||||
D_CheckRendererState();
|
||||
|
||||
// draw buffered stuff to screen
|
||||
// Used only by linux GGI version
|
||||
I_UpdateNoBlit();
|
||||
|
@ -435,7 +476,7 @@ static void D_Display(void)
|
|||
|
||||
if (!automapactive && !dedicated && cv_renderview.value)
|
||||
{
|
||||
rs_rendercalltime = I_GetTimeMicros();
|
||||
PS_START_TIMING(ps_rendercalltime);
|
||||
if (players[displayplayer].mo || players[displayplayer].playerstate == PST_DEAD)
|
||||
{
|
||||
topleft = screens[0] + viewwindowy*vid.width + viewwindowx;
|
||||
|
@ -482,7 +523,7 @@ static void D_Display(void)
|
|||
if (postimgtype2)
|
||||
V_DoPostProcessor(1, postimgtype2, postimgparam2);
|
||||
}
|
||||
rs_rendercalltime = I_GetTimeMicros() - rs_rendercalltime;
|
||||
PS_STOP_TIMING(ps_rendercalltime);
|
||||
}
|
||||
|
||||
if (lastdraw)
|
||||
|
@ -496,7 +537,7 @@ static void D_Display(void)
|
|||
lastdraw = false;
|
||||
}
|
||||
|
||||
rs_uitime = I_GetTimeMicros();
|
||||
PS_START_TIMING(ps_uitime);
|
||||
|
||||
if (gamestate == GS_LEVEL)
|
||||
{
|
||||
|
@ -509,7 +550,7 @@ static void D_Display(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
rs_uitime = I_GetTimeMicros();
|
||||
PS_START_TIMING(ps_uitime);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -529,7 +570,7 @@ static void D_Display(void)
|
|||
else
|
||||
py = viewwindowy + 4;
|
||||
patch = W_CachePatchName("M_PAUSE", PU_PATCH);
|
||||
V_DrawScaledPatch(viewwindowx + (BASEVIDWIDTH - SHORT(patch->width))/2, py, 0, patch);
|
||||
V_DrawScaledPatch(viewwindowx + (BASEVIDWIDTH - patch->width)/2, py, 0, patch);
|
||||
#else
|
||||
INT32 y = ((automapactive) ? (32) : (BASEVIDHEIGHT/2));
|
||||
M_DrawTextBox((BASEVIDWIDTH/2) - (60), y - (16), 13, 2);
|
||||
|
@ -551,7 +592,7 @@ static void D_Display(void)
|
|||
|
||||
CON_Drawer();
|
||||
|
||||
rs_uitime = I_GetTimeMicros() - rs_uitime;
|
||||
PS_STOP_TIMING(ps_uitime);
|
||||
|
||||
//
|
||||
// wipe update
|
||||
|
@ -632,111 +673,15 @@ static void D_Display(void)
|
|||
V_DrawRightAlignedString(BASEVIDWIDTH, BASEVIDHEIGHT-ST_HEIGHT-10, V_YELLOWMAP, s);
|
||||
}
|
||||
|
||||
if (cv_renderstats.value)
|
||||
if (cv_perfstats.value)
|
||||
{
|
||||
char s[50];
|
||||
int frametime = I_GetTimeMicros() - rs_prevframetime;
|
||||
int divisor = 1;
|
||||
rs_prevframetime = I_GetTimeMicros();
|
||||
|
||||
if (rs_rendercalltime > 10000) divisor = 1000;
|
||||
|
||||
snprintf(s, sizeof s - 1, "ft %d", frametime / divisor);
|
||||
V_DrawThinString(30, 10, V_MONOSPACE | V_YELLOWMAP, s);
|
||||
snprintf(s, sizeof s - 1, "rtot %d", rs_rendercalltime / divisor);
|
||||
V_DrawThinString(30, 20, V_MONOSPACE | V_YELLOWMAP, s);
|
||||
snprintf(s, sizeof s - 1, "bsp %d", rs_bsptime / divisor);
|
||||
V_DrawThinString(30, 30, V_MONOSPACE | V_YELLOWMAP, s);
|
||||
snprintf(s, sizeof s - 1, "nbsp %d", rs_numbspcalls);
|
||||
V_DrawThinString(80, 10, V_MONOSPACE | V_BLUEMAP, s);
|
||||
snprintf(s, sizeof s - 1, "nspr %d", rs_numsprites);
|
||||
V_DrawThinString(80, 20, V_MONOSPACE | V_BLUEMAP, s);
|
||||
snprintf(s, sizeof s - 1, "nnod %d", rs_numdrawnodes);
|
||||
V_DrawThinString(80, 30, V_MONOSPACE | V_BLUEMAP, s);
|
||||
snprintf(s, sizeof s - 1, "npob %d", rs_numpolyobjects);
|
||||
V_DrawThinString(80, 40, V_MONOSPACE | V_BLUEMAP, s);
|
||||
if (rendermode == render_opengl) // OpenGL specific stats
|
||||
{
|
||||
#ifdef HWRENDER
|
||||
snprintf(s, sizeof s - 1, "nsrt %d", rs_hw_nodesorttime / divisor);
|
||||
V_DrawThinString(30, 40, V_MONOSPACE | V_YELLOWMAP, s);
|
||||
snprintf(s, sizeof s - 1, "ndrw %d", rs_hw_nodedrawtime / divisor);
|
||||
V_DrawThinString(30, 50, V_MONOSPACE | V_YELLOWMAP, s);
|
||||
snprintf(s, sizeof s - 1, "ssrt %d", rs_hw_spritesorttime / divisor);
|
||||
V_DrawThinString(30, 60, V_MONOSPACE | V_YELLOWMAP, s);
|
||||
snprintf(s, sizeof s - 1, "sdrw %d", rs_hw_spritedrawtime / divisor);
|
||||
V_DrawThinString(30, 70, V_MONOSPACE | V_YELLOWMAP, s);
|
||||
snprintf(s, sizeof s - 1, "ui %d", rs_uitime / divisor);
|
||||
V_DrawThinString(30, 80, V_MONOSPACE | V_YELLOWMAP, s);
|
||||
snprintf(s, sizeof s - 1, "fin %d", rs_swaptime / divisor);
|
||||
V_DrawThinString(30, 90, V_MONOSPACE | V_YELLOWMAP, s);
|
||||
snprintf(s, sizeof s - 1, "tic %d", rs_tictime / divisor);
|
||||
V_DrawThinString(30, 105, V_MONOSPACE | V_GRAYMAP, s);
|
||||
if (cv_glbatching.value)
|
||||
{
|
||||
snprintf(s, sizeof s - 1, "bsrt %d", rs_hw_batchsorttime / divisor);
|
||||
V_DrawThinString(80, 55, V_MONOSPACE | V_REDMAP, s);
|
||||
snprintf(s, sizeof s - 1, "bdrw %d", rs_hw_batchdrawtime / divisor);
|
||||
V_DrawThinString(80, 65, V_MONOSPACE | V_REDMAP, s);
|
||||
|
||||
snprintf(s, sizeof s - 1, "npol %d", rs_hw_numpolys);
|
||||
V_DrawThinString(130, 10, V_MONOSPACE | V_PURPLEMAP, s);
|
||||
snprintf(s, sizeof s - 1, "ndc %d", rs_hw_numcalls);
|
||||
V_DrawThinString(130, 20, V_MONOSPACE | V_PURPLEMAP, s);
|
||||
snprintf(s, sizeof s - 1, "nshd %d", rs_hw_numshaders);
|
||||
V_DrawThinString(130, 30, V_MONOSPACE | V_PURPLEMAP, s);
|
||||
snprintf(s, sizeof s - 1, "nvrt %d", rs_hw_numverts);
|
||||
V_DrawThinString(130, 40, V_MONOSPACE | V_PURPLEMAP, s);
|
||||
snprintf(s, sizeof s - 1, "ntex %d", rs_hw_numtextures);
|
||||
V_DrawThinString(185, 10, V_MONOSPACE | V_PURPLEMAP, s);
|
||||
snprintf(s, sizeof s - 1, "npf %d", rs_hw_numpolyflags);
|
||||
V_DrawThinString(185, 20, V_MONOSPACE | V_PURPLEMAP, s);
|
||||
snprintf(s, sizeof s - 1, "ncol %d", rs_hw_numcolors);
|
||||
V_DrawThinString(185, 30, V_MONOSPACE | V_PURPLEMAP, s);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else // software specific stats
|
||||
{
|
||||
snprintf(s, sizeof s - 1, "prtl %d", rs_sw_portaltime / divisor);
|
||||
V_DrawThinString(30, 40, V_MONOSPACE | V_YELLOWMAP, s);
|
||||
snprintf(s, sizeof s - 1, "plns %d", rs_sw_planetime / divisor);
|
||||
V_DrawThinString(30, 50, V_MONOSPACE | V_YELLOWMAP, s);
|
||||
snprintf(s, sizeof s - 1, "mskd %d", rs_sw_maskedtime / divisor);
|
||||
V_DrawThinString(30, 60, V_MONOSPACE | V_YELLOWMAP, s);
|
||||
snprintf(s, sizeof s - 1, "ui %d", rs_uitime / divisor);
|
||||
V_DrawThinString(30, 70, V_MONOSPACE | V_YELLOWMAP, s);
|
||||
snprintf(s, sizeof s - 1, "fin %d", rs_swaptime / divisor);
|
||||
V_DrawThinString(30, 80, V_MONOSPACE | V_YELLOWMAP, s);
|
||||
snprintf(s, sizeof s - 1, "tic %d", rs_tictime / divisor);
|
||||
V_DrawThinString(30, 95, V_MONOSPACE | V_GRAYMAP, s);
|
||||
}
|
||||
M_DrawPerfStats();
|
||||
}
|
||||
|
||||
rs_swaptime = I_GetTimeMicros();
|
||||
PS_START_TIMING(ps_swaptime);
|
||||
I_FinishUpdate(); // page flip or blit buffer
|
||||
rs_swaptime = I_GetTimeMicros() - rs_swaptime;
|
||||
PS_STOP_TIMING(ps_swaptime);
|
||||
}
|
||||
|
||||
needpatchflush = false;
|
||||
needpatchrecache = false;
|
||||
}
|
||||
|
||||
// Check the renderer's state
|
||||
// after a possible renderer switch.
|
||||
void D_CheckRendererState(void)
|
||||
{
|
||||
// flush all patches from memory
|
||||
if (needpatchflush)
|
||||
{
|
||||
Z_FlushCachedPatches();
|
||||
needpatchflush = false;
|
||||
}
|
||||
|
||||
// some patches have been freed,
|
||||
// so cache them again
|
||||
if (needpatchrecache)
|
||||
R_ReloadHUDGraphics();
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
|
@ -763,12 +708,15 @@ void D_SRB2Loop(void)
|
|||
oldentertics = I_GetTime();
|
||||
|
||||
// end of loading screen: CONS_Printf() will no more call FinishUpdate()
|
||||
con_refresh = false;
|
||||
con_startup = false;
|
||||
|
||||
// make sure to do a d_display to init mode _before_ load a level
|
||||
SCR_SetMode(); // change video mode
|
||||
SCR_Recalc();
|
||||
|
||||
chosenrendermode = render_none;
|
||||
|
||||
// Check and print which version is executed.
|
||||
// Use this as the border between setup and the main game loop being entered.
|
||||
CONS_Printf(
|
||||
|
@ -975,35 +923,68 @@ void D_StartTitle(void)
|
|||
tutorialmode = false;
|
||||
}
|
||||
|
||||
//
|
||||
// D_AddFile
|
||||
//
|
||||
static void D_AddFile(char **list, const char *file)
|
||||
{
|
||||
size_t pnumwadfiles;
|
||||
char *newfile;
|
||||
#define REALLOC_FILE_LIST \
|
||||
if (list->files == NULL) \
|
||||
{ \
|
||||
list->files = calloc(sizeof(list->files), 2); \
|
||||
list->numfiles = 1; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
index = list->numfiles; \
|
||||
list->files = realloc(list->files, sizeof(list->files) * ((++list->numfiles) + 1)); \
|
||||
if (list->files == NULL) \
|
||||
I_Error("%s: No more free memory to add file %s", __FUNCTION__, file); \
|
||||
}
|
||||
|
||||
for (pnumwadfiles = 0; list[pnumwadfiles]; pnumwadfiles++)
|
||||
;
|
||||
static void D_AddFile(addfilelist_t *list, const char *file)
|
||||
{
|
||||
char *newfile;
|
||||
size_t index = 0;
|
||||
|
||||
REALLOC_FILE_LIST
|
||||
|
||||
newfile = malloc(strlen(file) + 1);
|
||||
if (!newfile)
|
||||
{
|
||||
I_Error("No more free memory to AddFile %s",file);
|
||||
}
|
||||
strcpy(newfile, file);
|
||||
I_Error("D_AddFile: No more free memory to add file %s", file);
|
||||
|
||||
list[pnumwadfiles] = newfile;
|
||||
strcpy(newfile, file);
|
||||
list->files[index] = newfile;
|
||||
}
|
||||
|
||||
static inline void D_CleanFile(char **list)
|
||||
static void D_AddFolder(addfilelist_t *list, const char *file)
|
||||
{
|
||||
size_t pnumwadfiles;
|
||||
for (pnumwadfiles = 0; list[pnumwadfiles]; pnumwadfiles++)
|
||||
char *newfile;
|
||||
size_t index = 0;
|
||||
|
||||
REALLOC_FILE_LIST
|
||||
|
||||
newfile = malloc(strlen(file) + 2); // Path delimiter + NULL terminator
|
||||
if (!newfile)
|
||||
I_Error("D_AddFolder: No more free memory to add folder %s", file);
|
||||
|
||||
strcpy(newfile, file);
|
||||
strcat(newfile, PATHSEP);
|
||||
|
||||
list->files[index] = newfile;
|
||||
}
|
||||
|
||||
#undef REALLOC_FILE_LIST
|
||||
|
||||
static inline void D_CleanFile(addfilelist_t *list)
|
||||
{
|
||||
if (list->files)
|
||||
{
|
||||
free(list[pnumwadfiles]);
|
||||
list[pnumwadfiles] = NULL;
|
||||
size_t pnumwadfiles = 0;
|
||||
|
||||
for (; pnumwadfiles < list->numfiles; pnumwadfiles++)
|
||||
free(list->files[pnumwadfiles]);
|
||||
|
||||
free(list->files);
|
||||
list->files = NULL;
|
||||
}
|
||||
|
||||
list->numfiles = 0;
|
||||
}
|
||||
|
||||
///\brief Checks if a netgame URL is being handled, and changes working directory to the EXE's if so.
|
||||
|
@ -1049,7 +1030,7 @@ static void IdentifyVersion(void)
|
|||
char *srb2wad;
|
||||
const char *srb2waddir = NULL;
|
||||
|
||||
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
|
||||
#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL)
|
||||
// change to the directory where 'srb2.pk3' is found
|
||||
srb2waddir = I_LocateWad();
|
||||
#endif
|
||||
|
@ -1087,7 +1068,7 @@ static void IdentifyVersion(void)
|
|||
|
||||
// Load the IWAD
|
||||
if (srb2wad != NULL && FIL_ReadFileOK(srb2wad))
|
||||
D_AddFile(startupwadfiles, srb2wad);
|
||||
D_AddFile(&startupwadfiles, srb2wad);
|
||||
else
|
||||
I_Error("srb2.pk3 not found! Expected in %s, ss file: %s\n", srb2waddir, srb2wad);
|
||||
|
||||
|
@ -1098,14 +1079,14 @@ static void IdentifyVersion(void)
|
|||
// checking in D_SRB2Main
|
||||
|
||||
// Add the maps
|
||||
D_AddFile(startupwadfiles, va(pandf,srb2waddir,"zones.pk3"));
|
||||
D_AddFile(&startupwadfiles, va(pandf,srb2waddir, "zones.pk3"));
|
||||
|
||||
// Add the players
|
||||
D_AddFile(startupwadfiles, va(pandf,srb2waddir, "player.dta"));
|
||||
D_AddFile(&startupwadfiles, va(pandf,srb2waddir, "player.dta"));
|
||||
|
||||
#ifdef USE_PATCH_DTA
|
||||
// Add our crappy patches to fix our bugs
|
||||
D_AddFile(startupwadfiles, va(pandf,srb2waddir,"patch.pk3"));
|
||||
D_AddFile(&startupwadfiles, va(pandf,srb2waddir, "patch.pk3"));
|
||||
#endif
|
||||
|
||||
#if !defined (HAVE_SDL) || defined (HAVE_MIXER)
|
||||
|
@ -1113,18 +1094,15 @@ static void IdentifyVersion(void)
|
|||
#define MUSICTEST(str) \
|
||||
{\
|
||||
const char *musicpath = va(pandf,srb2waddir,str);\
|
||||
int ms = W_VerifyNMUSlumps(musicpath); \
|
||||
int ms = W_VerifyNMUSlumps(musicpath, false); \
|
||||
if (ms == 1) \
|
||||
D_AddFile(startupwadfiles, musicpath); \
|
||||
D_AddFile(&startupwadfiles, musicpath); \
|
||||
else if (ms == 0) \
|
||||
I_Error("File "str" has been modified with non-music/sound lumps"); \
|
||||
}
|
||||
|
||||
MUSICTEST("music.dta")
|
||||
MUSICTEST("patch_music.pk3")
|
||||
#ifdef DEVELOP // remove when music_new.dta is merged into music.dta
|
||||
MUSICTEST("music_new.dta")
|
||||
#endif
|
||||
//MUSICTEST("patch_music.pk3")
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -1160,7 +1138,7 @@ void D_SRB2Main(void)
|
|||
// Print GPL notice for our console users (Linux)
|
||||
CONS_Printf(
|
||||
"\n\nSonic Robo Blast 2\n"
|
||||
"Copyright (C) 1998-2020 by Sonic Team Junior\n\n"
|
||||
"Copyright (C) 1998-2022 by Sonic Team Junior\n\n"
|
||||
"This program comes with ABSOLUTELY NO WARRANTY.\n\n"
|
||||
"This is free software, and you are welcome to redistribute it\n"
|
||||
"and/or modify it under the terms of the GNU General Public License\n"
|
||||
|
@ -1187,7 +1165,7 @@ void D_SRB2Main(void)
|
|||
G_LoadGameSettings();
|
||||
|
||||
// Test Dehacked lists
|
||||
DEH_Check();
|
||||
DEH_TableCheck();
|
||||
|
||||
// Netgame URL special case: change working dir to EXE folder.
|
||||
ChangeDirForUrlHandler();
|
||||
|
@ -1222,7 +1200,7 @@ void D_SRB2Main(void)
|
|||
|
||||
if (!userhome)
|
||||
{
|
||||
#if ((defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)) && !defined (__CYGWIN__)
|
||||
#if (defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON)) && !defined (__CYGWIN__)
|
||||
I_Error("Please set $HOME to your home directory\n");
|
||||
#else
|
||||
if (dedicated)
|
||||
|
@ -1289,25 +1267,25 @@ void D_SRB2Main(void)
|
|||
// Do this up here so that WADs loaded through the command line can use ExecCfg
|
||||
COM_Init();
|
||||
|
||||
// add any files specified on the command line with -file wadfile
|
||||
// to the wad list
|
||||
// Add any files specified on the command line with
|
||||
// "-file <file>" or "-folder <folder>" to the add-on list
|
||||
if (!((M_GetUrlProtocolArg() || M_CheckParm("-connect")) && !M_CheckParm("-server")))
|
||||
{
|
||||
if (M_CheckParm("-file"))
|
||||
{
|
||||
// the parms after p are wadfile/lump names,
|
||||
// until end of parms or another - preceded parm
|
||||
while (M_IsNextParm())
|
||||
{
|
||||
const char *s = M_GetNextParm();
|
||||
INT32 addontype = 0;
|
||||
INT32 i;
|
||||
|
||||
if (s) // Check for NULL?
|
||||
{
|
||||
if (!W_VerifyNMUSlumps(s))
|
||||
G_SetGameModified(true);
|
||||
D_AddFile(startuppwads, s);
|
||||
}
|
||||
}
|
||||
for (i = 1; i < myargc; i++)
|
||||
{
|
||||
if (!strcasecmp(myargv[i], "-file"))
|
||||
addontype = 1;
|
||||
else if (!strcasecmp(myargv[i], "-folder"))
|
||||
addontype = 2;
|
||||
else if (myargv[i][0] == '-' || myargv[i][0] == '+')
|
||||
addontype = 0;
|
||||
else if (addontype == 1)
|
||||
D_AddFile(&startuppwads, myargv[i]);
|
||||
else if (addontype == 2)
|
||||
D_AddFolder(&startuppwads, myargv[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1346,8 +1324,8 @@ void D_SRB2Main(void)
|
|||
|
||||
// load wad, including the main wad file
|
||||
CONS_Printf("W_InitMultipleFiles(): Adding IWAD and main PWADs.\n");
|
||||
W_InitMultipleFiles(startupwadfiles);
|
||||
D_CleanFile(startupwadfiles);
|
||||
W_InitMultipleFiles(&startupwadfiles);
|
||||
D_CleanFile(&startupwadfiles);
|
||||
|
||||
#ifndef DEVELOP // md5s last updated 22/02/20 (ddmmyy)
|
||||
|
||||
|
@ -1362,8 +1340,6 @@ void D_SRB2Main(void)
|
|||
// ...except it does if they slip maps in there, and that's what W_VerifyNMUSlumps is for.
|
||||
#endif //ifndef DEVELOP
|
||||
|
||||
mainwadstally = packetsizetally; // technically not accurate atm, remember to port the two-stage -file process from kart in 2.2.x
|
||||
|
||||
cht_Init();
|
||||
|
||||
//---------------------------------------------------- READY SCREEN
|
||||
|
@ -1394,9 +1370,16 @@ void D_SRB2Main(void)
|
|||
|
||||
I_RegisterSysCommands();
|
||||
|
||||
CONS_Printf("W_InitMultipleFiles(): Adding extra PWADs.\n");
|
||||
W_InitMultipleFiles(startuppwads);
|
||||
D_CleanFile(startuppwads);
|
||||
CON_StopRefresh(); // Temporarily stop refreshing the screen for wad loading
|
||||
|
||||
if (startuppwads.numfiles)
|
||||
{
|
||||
CONS_Printf("W_InitMultipleFiles(): Adding extra PWADs.\n");
|
||||
W_InitMultipleFiles(&startuppwads);
|
||||
D_CleanFile(&startuppwads);
|
||||
}
|
||||
|
||||
CON_StartRefresh(); // Restart the refresh!
|
||||
|
||||
CONS_Printf("HU_LoadGraphics()...\n");
|
||||
HU_LoadGraphics();
|
||||
|
@ -1406,31 +1389,13 @@ void D_SRB2Main(void)
|
|||
|
||||
G_LoadGameData();
|
||||
|
||||
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
|
||||
#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL)
|
||||
VID_PrepareModeList(); // Regenerate Modelist according to cv_fullscreen
|
||||
#endif
|
||||
|
||||
// set user default mode or mode set at cmdline
|
||||
SCR_CheckDefaultMode();
|
||||
|
||||
// Lactozilla: Does the render mode need to change?
|
||||
if ((setrenderneeded != 0) && (setrenderneeded != rendermode))
|
||||
{
|
||||
CONS_Printf(M_GetText("Switching the renderer...\n"));
|
||||
Z_PreparePatchFlush();
|
||||
|
||||
// set needpatchflush / needpatchrecache true for D_CheckRendererState
|
||||
needpatchflush = true;
|
||||
needpatchrecache = true;
|
||||
|
||||
// Set cv_renderer to the new render mode
|
||||
VID_CheckRenderer();
|
||||
SCR_ChangeRendererCVars(rendermode);
|
||||
|
||||
// check the renderer's state
|
||||
D_CheckRendererState();
|
||||
}
|
||||
|
||||
wipegamestate = gamestate;
|
||||
|
||||
savedata.lives = 0; // flag this as not-used
|
||||
|
@ -1589,6 +1554,12 @@ void D_SRB2Main(void)
|
|||
ultimatemode = true;
|
||||
}
|
||||
|
||||
if (M_CheckParm("-splitscreen"))
|
||||
{
|
||||
autostart = true;
|
||||
splitscreen = true;
|
||||
}
|
||||
|
||||
// rei/miru: bootmap (Idea: starts the game on a predefined map)
|
||||
if (bootmap && !(M_CheckParm("-warp") && M_IsNextParm()))
|
||||
{
|
||||
|
@ -1667,7 +1638,7 @@ void D_SRB2Main(void)
|
|||
{
|
||||
levelstarttic = gametic;
|
||||
G_SetGamestate(GS_LEVEL);
|
||||
if (!P_LoadLevel(false))
|
||||
if (!P_LoadLevel(false, false))
|
||||
I_Quit(); // fail so reset game stuff
|
||||
}
|
||||
}
|
||||
|
@ -1684,7 +1655,7 @@ const char *D_Home(void)
|
|||
userhome = M_GetNextParm();
|
||||
else
|
||||
{
|
||||
#if !((defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)) && !defined (__APPLE__)
|
||||
#if !(defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON))
|
||||
if (FIL_FileOK(CONFIGFILENAME))
|
||||
usehome = false; // Let's NOT use home
|
||||
else
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -40,10 +40,6 @@ void D_SRB2Main(void);
|
|||
|
||||
// Called by IO functions when input is detected.
|
||||
void D_PostEvent(const event_t *ev);
|
||||
#if defined (PC_DOS) && !defined (DOXYGEN)
|
||||
void D_PostEvent_end(void); // delimiter for locking memory
|
||||
#endif
|
||||
|
||||
void D_ProcessEvents(void);
|
||||
|
||||
const char *D_Home(void);
|
||||
|
|
15
src/d_net.c
15
src/d_net.c
|
@ -2,7 +2,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -798,8 +798,9 @@ static const char *packettypename[NUMPACKETTYPE] =
|
|||
"REQUESTFILE",
|
||||
"ASKINFOVIAMS",
|
||||
|
||||
"RESYNCHEND",
|
||||
"RESYNCHGET",
|
||||
"WILLRESENDGAMESTATE",
|
||||
"CANRECEIVEGAMESTATE",
|
||||
"RECEIVEDGAMESTATE",
|
||||
|
||||
"SENDINGLUAFILE",
|
||||
"ASKLUAFILE",
|
||||
|
@ -813,8 +814,9 @@ static const char *packettypename[NUMPACKETTYPE] =
|
|||
"TEXTCMD2",
|
||||
"CLIENTJOIN",
|
||||
"NODETIMEOUT",
|
||||
"RESYNCHING",
|
||||
"LOGIN",
|
||||
"TELLFILESNEEDED",
|
||||
"MOREFILESNEEDED",
|
||||
"PING"
|
||||
};
|
||||
|
||||
|
@ -1142,8 +1144,9 @@ boolean HGetPacket(void)
|
|||
if (netbuffer->checksum != NetbufferChecksum())
|
||||
{
|
||||
DEBFILE("Bad packet checksum\n");
|
||||
//Net_CloseConnection(nodejustjoined ? (doomcom->remotenode | FORCECLOSE) : doomcom->remotenode);
|
||||
Net_CloseConnection(doomcom->remotenode);
|
||||
// Do not disconnect or anything, just ignore the packet.
|
||||
// Bad checksums with UDP tend to happen very scarcely
|
||||
// so they are not normally an issue.
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
|
728
src/d_netcmd.c
728
src/d_netcmd.c
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,7 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -31,9 +31,7 @@ extern consvar_t cv_defaultskin;
|
|||
extern consvar_t cv_defaultplayercolor2;
|
||||
extern consvar_t cv_defaultskin2;
|
||||
|
||||
#ifdef SEENAMES
|
||||
extern consvar_t cv_seenames, cv_allowseenames;
|
||||
#endif
|
||||
extern consvar_t cv_usemouse;
|
||||
extern consvar_t cv_usejoystick;
|
||||
extern consvar_t cv_usejoystick2;
|
||||
|
@ -47,7 +45,7 @@ extern consvar_t cv_joyscale2;
|
|||
// splitscreen with second mouse
|
||||
extern consvar_t cv_mouse2port;
|
||||
extern consvar_t cv_usemouse2;
|
||||
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON)
|
||||
#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON)
|
||||
extern consvar_t cv_mouse2opt;
|
||||
#endif
|
||||
|
||||
|
@ -75,9 +73,7 @@ extern consvar_t cv_teamscramble;
|
|||
extern consvar_t cv_scrambleonchange;
|
||||
|
||||
extern consvar_t cv_netstat;
|
||||
#ifdef WALLSPLATS
|
||||
extern consvar_t cv_splats;
|
||||
#endif
|
||||
extern consvar_t cv_nettimeout;
|
||||
|
||||
extern consvar_t cv_countdowntime;
|
||||
extern consvar_t cv_runscripts;
|
||||
|
@ -114,11 +110,17 @@ extern consvar_t cv_skipmapcheck;
|
|||
|
||||
extern consvar_t cv_sleep;
|
||||
|
||||
extern consvar_t cv_perfstats;
|
||||
extern consvar_t cv_ps_samplesize;
|
||||
extern consvar_t cv_ps_descriptor;
|
||||
|
||||
extern char timedemo_name[256];
|
||||
extern boolean timedemo_csv;
|
||||
extern char timedemo_csv_id[256];
|
||||
extern boolean timedemo_quit;
|
||||
|
||||
extern consvar_t cv_freedemocamera;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
XD_NAMEANDCOLOR = 1,
|
||||
|
@ -129,16 +131,16 @@ typedef enum
|
|||
XD_MAP, // 6
|
||||
XD_EXITLEVEL, // 7
|
||||
XD_ADDFILE, // 8
|
||||
XD_PAUSE, // 9
|
||||
XD_ADDPLAYER, // 10
|
||||
XD_TEAMCHANGE, // 11
|
||||
XD_CLEARSCORES, // 12
|
||||
// UNUSED 13 (Because I don't want to change these comments)
|
||||
XD_VERIFIED = 14,//14
|
||||
XD_ADDFOLDER, // 9
|
||||
XD_PAUSE, // 10
|
||||
XD_ADDPLAYER, // 11
|
||||
XD_TEAMCHANGE, // 12
|
||||
XD_CLEARSCORES, // 13
|
||||
XD_VERIFIED, // 14
|
||||
XD_RANDOMSEED, // 15
|
||||
XD_RUNSOC, // 16
|
||||
XD_REQADDFILE, // 17
|
||||
XD_DELFILE, // 18 - replace next time we add an XD
|
||||
XD_REQADDFOLDER,// 18
|
||||
XD_SETMOTD, // 19
|
||||
XD_SUICIDE, // 20
|
||||
XD_DEMOTED, // 21
|
||||
|
|
368
src/d_netfil.c
368
src/d_netfil.c
|
@ -1,7 +1,7 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include <time.h>
|
||||
|
||||
#if defined (_WIN32) || defined (__DJGPP__)
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#include <direct.h>
|
||||
#else
|
||||
|
@ -30,10 +30,6 @@
|
|||
#elif defined (_WIN32)
|
||||
#include <sys/utime.h>
|
||||
#endif
|
||||
#ifdef __DJGPP__
|
||||
#include <dir.h>
|
||||
#include <utime.h>
|
||||
#endif
|
||||
|
||||
#include "doomdef.h"
|
||||
#include "doomstat.h"
|
||||
|
@ -56,7 +52,7 @@
|
|||
#include <errno.h>
|
||||
|
||||
// Prototypes
|
||||
static boolean AddFileToSendQueue(INT32 node, const char *filename, UINT8 fileid);
|
||||
static boolean AddFileToSendQueue(INT32 node, UINT8 fileid);
|
||||
|
||||
// Sender structure
|
||||
typedef struct filetx_s
|
||||
|
@ -91,7 +87,7 @@ static filetran_t transfer[MAXNETNODES];
|
|||
|
||||
// Receiver structure
|
||||
INT32 fileneedednum; // Number of files needed to join the server
|
||||
fileneeded_t fileneeded[MAX_WADFILES]; // List of needed files
|
||||
fileneeded_t *fileneeded; // List of needed files
|
||||
static tic_t lasttimeackpacketsent = 0;
|
||||
char downloaddir[512] = "DOWNLOAD";
|
||||
|
||||
|
@ -109,6 +105,10 @@ static pauseddownload_t *pauseddownload = NULL;
|
|||
#ifndef NONET
|
||||
// for cl loading screen
|
||||
INT32 lastfilenum = -1;
|
||||
INT32 downloadcompletednum = 0;
|
||||
UINT32 downloadcompletedsize = 0;
|
||||
INT32 totalfilesrequestednum = 0;
|
||||
UINT32 totalfilesrequestedsize = 0;
|
||||
#endif
|
||||
|
||||
luafiletransfer_t *luafiletransfers = NULL;
|
||||
|
@ -117,29 +117,67 @@ boolean waitingforluafilecommand = false;
|
|||
char luafiledir[256 + 16] = "luafiles";
|
||||
|
||||
|
||||
static UINT16 GetWadNumFromFileNeededId(UINT8 id)
|
||||
{
|
||||
UINT16 wadnum;
|
||||
|
||||
for (wadnum = mainwads; wadnum < numwadfiles; wadnum++)
|
||||
{
|
||||
if (!wadfiles[wadnum]->important)
|
||||
continue;
|
||||
if (id == 0)
|
||||
return wadnum;
|
||||
id--;
|
||||
}
|
||||
|
||||
return UINT16_MAX;
|
||||
}
|
||||
|
||||
/** Fills a serverinfo packet with information about wad files loaded.
|
||||
*
|
||||
* \todo Give this function a better name since it is in global scope.
|
||||
* Used to have size limiting built in - now handled via W_LoadWadFile in w_wad.c
|
||||
* Used to have size limiting built in - now handled via W_InitFile in w_wad.c
|
||||
*
|
||||
*/
|
||||
UINT8 *PutFileNeeded(void)
|
||||
UINT8 *PutFileNeeded(UINT16 firstfile)
|
||||
{
|
||||
size_t i, count = 0;
|
||||
UINT8 *p = netbuffer->u.serverinfo.fileneeded;
|
||||
size_t i;
|
||||
UINT8 count = 0;
|
||||
UINT8 *p_start = netbuffer->packettype == PT_MOREFILESNEEDED ? netbuffer->u.filesneededcfg.files : netbuffer->u.serverinfo.fileneeded;
|
||||
UINT8 *p = p_start;
|
||||
char wadfilename[MAX_WADPATH] = "";
|
||||
UINT8 filestatus;
|
||||
UINT8 filestatus, folder;
|
||||
|
||||
for (i = 0; i < numwadfiles; i++)
|
||||
for (i = mainwads; i < numwadfiles; i++) //mainwads, otherwise we start on the first mainwad
|
||||
{
|
||||
// If it has only music/sound lumps, don't put it in the list
|
||||
if (!wadfiles[i]->important)
|
||||
continue;
|
||||
|
||||
if (firstfile)
|
||||
{ // Skip files until we reach the first file.
|
||||
firstfile--;
|
||||
continue;
|
||||
}
|
||||
|
||||
nameonly(strcpy(wadfilename, wadfiles[i]->filename));
|
||||
|
||||
// Look below at the WRITE macros to understand what these numbers mean.
|
||||
if (p + 1 + 4 + min(strlen(wadfilename) + 1, MAX_WADPATH) + 16 > p_start + MAXFILENEEDED)
|
||||
{
|
||||
// Too many files to send all at once
|
||||
if (netbuffer->packettype == PT_MOREFILESNEEDED)
|
||||
netbuffer->u.filesneededcfg.more = 1;
|
||||
else
|
||||
netbuffer->u.serverinfo.flags |= SV_LOTSOFADDONS;
|
||||
break;
|
||||
}
|
||||
|
||||
filestatus = 1; // Importance - not really used any more, holds 1 by default for backwards compat with MS
|
||||
folder = (wadfiles[i]->type == RET_FOLDER);
|
||||
|
||||
// Store in the upper four bits
|
||||
if (!cv_downloading.value)
|
||||
if (!cv_downloading.value || folder) /// \todo Implement folder downloading.
|
||||
filestatus += (2 << 4); // Won't send
|
||||
else if ((wadfiles[i]->filesize <= (UINT32)cv_maxsend.value * 1024))
|
||||
filestatus += (1 << 4); // Will send if requested
|
||||
|
@ -147,37 +185,60 @@ UINT8 *PutFileNeeded(void)
|
|||
// filestatus += (0 << 4); -- Won't send, too big
|
||||
|
||||
WRITEUINT8(p, filestatus);
|
||||
WRITEUINT8(p, folder);
|
||||
|
||||
count++;
|
||||
WRITEUINT32(p, wadfiles[i]->filesize);
|
||||
nameonly(strcpy(wadfilename, wadfiles[i]->filename));
|
||||
WRITESTRINGN(p, wadfilename, MAX_WADPATH);
|
||||
WRITEMEM(p, wadfiles[i]->md5sum, 16);
|
||||
}
|
||||
netbuffer->u.serverinfo.fileneedednum = (UINT8)count;
|
||||
|
||||
if (netbuffer->packettype == PT_MOREFILESNEEDED)
|
||||
netbuffer->u.filesneededcfg.num = count;
|
||||
else
|
||||
netbuffer->u.serverinfo.fileneedednum = count;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
void AllocFileNeeded(INT32 size)
|
||||
{
|
||||
if (fileneeded == NULL)
|
||||
fileneeded = Z_Calloc(sizeof(fileneeded_t) * size, PU_STATIC, NULL);
|
||||
else
|
||||
fileneeded = Z_Realloc(fileneeded, sizeof(fileneeded_t) * size, PU_STATIC, NULL);
|
||||
}
|
||||
|
||||
void FreeFileNeeded(void)
|
||||
{
|
||||
Z_Free(fileneeded);
|
||||
fileneeded = NULL;
|
||||
}
|
||||
|
||||
/** Parses the serverinfo packet and fills the fileneeded table on client
|
||||
*
|
||||
* \param fileneedednum_parm The number of files needed to join the server
|
||||
* \param fileneededstr The memory block containing the list of needed files
|
||||
*
|
||||
*/
|
||||
void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr)
|
||||
void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr, UINT16 firstfile)
|
||||
{
|
||||
INT32 i;
|
||||
UINT8 *p;
|
||||
UINT8 filestatus;
|
||||
|
||||
fileneedednum = fileneedednum_parm;
|
||||
fileneedednum = firstfile + fileneedednum_parm;
|
||||
p = (UINT8 *)fileneededstr;
|
||||
for (i = 0; i < fileneedednum; i++)
|
||||
|
||||
AllocFileNeeded(fileneedednum);
|
||||
|
||||
for (i = firstfile; i < fileneedednum; i++)
|
||||
{
|
||||
fileneeded[i].status = FS_NOTFOUND; // We haven't even started looking for the file yet
|
||||
fileneeded[i].type = FILENEEDED_WAD;
|
||||
fileneeded[i].status = FS_NOTCHECKED; // We haven't even started looking for the file yet
|
||||
fileneeded[i].justdownloaded = false;
|
||||
filestatus = READUINT8(p); // The first byte is the file status
|
||||
fileneeded[i].folder = READUINT8(p); // The second byte is the folder flag
|
||||
fileneeded[i].willsend = (UINT8)(filestatus >> 4);
|
||||
fileneeded[i].totalsize = READUINT32(p); // The four next bytes are the file size
|
||||
fileneeded[i].file = NULL; // The file isn't open yet
|
||||
|
@ -192,7 +253,11 @@ void CL_PrepareDownloadSaveGame(const char *tmpsave)
|
|||
lastfilenum = -1;
|
||||
#endif
|
||||
|
||||
FreeFileNeeded();
|
||||
AllocFileNeeded(1);
|
||||
|
||||
fileneedednum = 1;
|
||||
fileneeded[0].type = FILENEEDED_SAVEGAME;
|
||||
fileneeded[0].status = FS_REQUESTED;
|
||||
fileneeded[0].justdownloaded = false;
|
||||
fileneeded[0].totalsize = UINT32_MAX;
|
||||
|
@ -323,14 +388,18 @@ boolean CL_SendFileRequest(void)
|
|||
if ((fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD))
|
||||
{
|
||||
totalfreespaceneeded += fileneeded[i].totalsize;
|
||||
nameonly(fileneeded[i].filename);
|
||||
|
||||
WRITEUINT8(p, i); // fileid
|
||||
WRITESTRINGN(p, fileneeded[i].filename, MAX_WADPATH);
|
||||
|
||||
// put it in download dir
|
||||
nameonly(fileneeded[i].filename);
|
||||
strcatbf(fileneeded[i].filename, downloaddir, "/");
|
||||
|
||||
fileneeded[i].status = FS_REQUESTED;
|
||||
}
|
||||
|
||||
WRITEUINT8(p, 0xFF);
|
||||
|
||||
I_GetDiskFreeSpace(&availablefreespace);
|
||||
if (totalfreespaceneeded > availablefreespace)
|
||||
I_Error("To play on this server you must download %s KB,\n"
|
||||
|
@ -346,21 +415,22 @@ boolean CL_SendFileRequest(void)
|
|||
// returns false if a requested file was not found or cannot be sent
|
||||
boolean PT_RequestFile(INT32 node)
|
||||
{
|
||||
char wad[MAX_WADPATH+1];
|
||||
UINT8 *p = netbuffer->u.textcmd;
|
||||
UINT8 id;
|
||||
|
||||
while (p < netbuffer->u.textcmd + MAXTEXTCMD-1) // Don't allow hacked client to overflow
|
||||
{
|
||||
id = READUINT8(p);
|
||||
if (id == 0xFF)
|
||||
break;
|
||||
READSTRINGN(p, wad, MAX_WADPATH);
|
||||
if (!AddFileToSendQueue(node, wad, id))
|
||||
|
||||
if (!AddFileToSendQueue(node, id))
|
||||
{
|
||||
SV_AbortSendFiles(node);
|
||||
return false; // don't read the rest of the files
|
||||
}
|
||||
}
|
||||
|
||||
return true; // no problems with any files
|
||||
}
|
||||
|
||||
|
@ -369,23 +439,16 @@ boolean PT_RequestFile(INT32 node)
|
|||
* \return 0 if some files are missing
|
||||
* 1 if all files exist
|
||||
* 2 if some already loaded files are not requested or are in a different order
|
||||
* 3 too many files, over WADLIMIT
|
||||
* 4 still checking, continuing next tic
|
||||
*
|
||||
*/
|
||||
INT32 CL_CheckFiles(void)
|
||||
{
|
||||
INT32 i, j;
|
||||
char wadfilename[MAX_WADPATH];
|
||||
INT32 ret = 1;
|
||||
size_t packetsize = 0;
|
||||
size_t filestoget = 0;
|
||||
|
||||
// if (M_CheckParm("-nofiles"))
|
||||
// return 1;
|
||||
|
||||
// the first is the iwad (the main wad file)
|
||||
// we don't care if it's called srb2.pk3 or not.
|
||||
// Never download the IWAD, just assume it's there and identical
|
||||
fileneeded[0].status = FS_OPEN;
|
||||
size_t filestoload = 0;
|
||||
boolean downloadrequired = false;
|
||||
|
||||
// Modified game handling -- check for an identical file list
|
||||
// must be identical in files loaded AND in order
|
||||
|
@ -393,7 +456,7 @@ INT32 CL_CheckFiles(void)
|
|||
if (modifiedgame)
|
||||
{
|
||||
CONS_Debug(DBG_NETPLAY, "game is modified; only doing basic checks\n");
|
||||
for (i = 1, j = 1; i < fileneedednum || j < numwadfiles;)
|
||||
for (i = 0, j = mainwads; i < fileneedednum || j < numwadfiles;)
|
||||
{
|
||||
if (j < numwadfiles && !wadfiles[j]->important)
|
||||
{
|
||||
|
@ -420,15 +483,21 @@ INT32 CL_CheckFiles(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
// See W_LoadWadFile in w_wad.c
|
||||
packetsize = packetsizetally;
|
||||
|
||||
for (i = 1; i < fileneedednum; i++)
|
||||
for (i = 0; i < fileneedednum; i++)
|
||||
{
|
||||
if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD)
|
||||
downloadrequired = true;
|
||||
|
||||
if (fileneeded[i].status != FS_OPEN)
|
||||
filestoload++;
|
||||
|
||||
if (fileneeded[i].status != FS_NOTCHECKED) //since we're running this over multiple tics now, its possible for us to come across files checked in previous tics
|
||||
continue;
|
||||
|
||||
CONS_Debug(DBG_NETPLAY, "searching for '%s' ", fileneeded[i].filename);
|
||||
|
||||
// Check in already loaded files
|
||||
for (j = 1; wadfiles[j]; j++)
|
||||
for (j = mainwads; wadfiles[j]; j++)
|
||||
{
|
||||
nameonly(strcpy(wadfilename, wadfiles[j]->filename));
|
||||
if (!stricmp(wadfilename, fileneeded[i].filename) &&
|
||||
|
@ -436,45 +505,46 @@ INT32 CL_CheckFiles(void)
|
|||
{
|
||||
CONS_Debug(DBG_NETPLAY, "already loaded\n");
|
||||
fileneeded[i].status = FS_OPEN;
|
||||
break;
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
if (fileneeded[i].status != FS_NOTFOUND)
|
||||
continue;
|
||||
|
||||
packetsize += nameonlylength(fileneeded[i].filename) + 22;
|
||||
if (fileneeded[i].folder)
|
||||
fileneeded[i].status = findfolder(fileneeded[i].filename);
|
||||
else
|
||||
fileneeded[i].status = findfile(fileneeded[i].filename, fileneeded[i].md5sum, true);
|
||||
|
||||
if ((numwadfiles+filestoget >= MAX_WADFILES)
|
||||
|| (packetsize > MAXFILENEEDED*sizeof(UINT8)))
|
||||
return 3;
|
||||
|
||||
filestoget++;
|
||||
|
||||
fileneeded[i].status = findfile(fileneeded[i].filename, fileneeded[i].md5sum, true);
|
||||
CONS_Debug(DBG_NETPLAY, "found %d\n", fileneeded[i].status);
|
||||
if (fileneeded[i].status != FS_FOUND)
|
||||
ret = 0;
|
||||
return 4;
|
||||
}
|
||||
return ret;
|
||||
|
||||
//now making it here means we've checked the entire list and no FS_NOTCHECKED files remain
|
||||
if (numwadfiles+filestoload > MAX_WADFILES)
|
||||
return 3;
|
||||
else if (downloadrequired)
|
||||
return 0; //some stuff is FS_NOTFOUND, needs download
|
||||
else
|
||||
return 1; //everything is FS_OPEN or FS_FOUND, proceed to loading
|
||||
}
|
||||
|
||||
// Load it now
|
||||
void CL_LoadServerFiles(void)
|
||||
boolean CL_LoadServerFiles(void)
|
||||
{
|
||||
INT32 i;
|
||||
|
||||
// if (M_CheckParm("-nofiles"))
|
||||
// return;
|
||||
|
||||
for (i = 1; i < fileneedednum; i++)
|
||||
for (i = 0; i < fileneedednum; i++)
|
||||
{
|
||||
if (fileneeded[i].status == FS_OPEN)
|
||||
continue; // Already loaded
|
||||
else if (fileneeded[i].status == FS_FOUND)
|
||||
{
|
||||
P_AddWadFile(fileneeded[i].filename);
|
||||
if (fileneeded[i].folder)
|
||||
P_AddFolder(fileneeded[i].filename);
|
||||
else
|
||||
P_AddWadFile(fileneeded[i].filename);
|
||||
G_SetGameModified(true);
|
||||
fileneeded[i].status = FS_OPEN;
|
||||
return false;
|
||||
}
|
||||
else if (fileneeded[i].status == FS_MD5SUMBAD)
|
||||
I_Error("Wrong version of file %s", fileneeded[i].filename);
|
||||
|
@ -500,6 +570,7 @@ void CL_LoadServerFiles(void)
|
|||
fileneeded[i].status, s);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void AddLuaFileTransfer(const char *filename, const char *mode)
|
||||
|
@ -562,7 +633,7 @@ static void SV_PrepareSendLuaFileToNextNode(void)
|
|||
|
||||
// Find a client to send the file to
|
||||
for (i = 1; i < MAXNETNODES; i++)
|
||||
if (nodeingame[i] && luafiletransfers->nodestatus[i] == LFTNS_WAITING) // Node waiting
|
||||
if (luafiletransfers->nodestatus[i] == LFTNS_WAITING) // Node waiting
|
||||
{
|
||||
// Tell the client we're about to send them the file
|
||||
netbuffer->packettype = PT_SENDINGLUAFILE;
|
||||
|
@ -570,6 +641,7 @@ static void SV_PrepareSendLuaFileToNextNode(void)
|
|||
I_Error("Failed to send a PT_SENDINGLUAFILE packet\n"); // !!! Todo: Handle failure a bit better lol
|
||||
|
||||
luafiletransfers->nodestatus[i] = LFTNS_ASKED;
|
||||
luafiletransfers->nodetimeouts[i] = I_GetTime() + 30 * TICRATE;
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -588,7 +660,7 @@ void SV_PrepareSendLuaFile(void)
|
|||
|
||||
// Set status to "waiting" for everyone
|
||||
for (i = 0; i < MAXNETNODES; i++)
|
||||
luafiletransfers->nodestatus[i] = LFTNS_WAITING;
|
||||
luafiletransfers->nodestatus[i] = (nodeingame[i] ? LFTNS_WAITING : LFTNS_NONE);
|
||||
|
||||
if (FIL_ReadFileOK(luafiletransfers->realfilename))
|
||||
{
|
||||
|
@ -649,12 +721,14 @@ void RemoveAllLuaFileTransfers(void)
|
|||
|
||||
void SV_AbortLuaFileTransfer(INT32 node)
|
||||
{
|
||||
if (luafiletransfers
|
||||
&& (luafiletransfers->nodestatus[node] == LFTNS_ASKED
|
||||
|| luafiletransfers->nodestatus[node] == LFTNS_SENDING))
|
||||
if (luafiletransfers)
|
||||
{
|
||||
luafiletransfers->nodestatus[node] = LFTNS_WAITING;
|
||||
SV_PrepareSendLuaFileToNextNode();
|
||||
if (luafiletransfers->nodestatus[node] == LFTNS_ASKED
|
||||
|| luafiletransfers->nodestatus[node] == LFTNS_SENDING)
|
||||
{
|
||||
SV_PrepareSendLuaFileToNextNode();
|
||||
}
|
||||
luafiletransfers->nodestatus[node] = LFTNS_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -678,7 +752,11 @@ void CL_PrepareDownloadLuaFile(void)
|
|||
netbuffer->packettype = PT_ASKLUAFILE;
|
||||
HSendPacket(servernode, true, 0, 0);
|
||||
|
||||
FreeFileNeeded();
|
||||
AllocFileNeeded(1);
|
||||
|
||||
fileneedednum = 1;
|
||||
fileneeded[0].type = FILENEEDED_LUAFILE;
|
||||
fileneeded[0].status = FS_REQUESTED;
|
||||
fileneeded[0].justdownloaded = false;
|
||||
fileneeded[0].totalsize = UINT32_MAX;
|
||||
|
@ -705,15 +783,11 @@ static INT32 filestosend = 0;
|
|||
* \sa AddLuaFileToSendQueue
|
||||
*
|
||||
*/
|
||||
static boolean AddFileToSendQueue(INT32 node, const char *filename, UINT8 fileid)
|
||||
static boolean AddFileToSendQueue(INT32 node, UINT8 fileid)
|
||||
{
|
||||
filetx_t **q; // A pointer to the "next" field of the last file in the list
|
||||
filetx_t *p; // The new file request
|
||||
INT32 i;
|
||||
char wadfilename[MAX_WADPATH];
|
||||
|
||||
if (cv_noticedownload.value)
|
||||
CONS_Printf("Sending file \"%s\" to node %d (%s)\n", filename, node, I_GetNodeAddress(node));
|
||||
UINT16 wadnum;
|
||||
|
||||
// Find the last file in the list and set a pointer to its "next" field
|
||||
q = &transfer[node].txlist;
|
||||
|
@ -733,51 +807,43 @@ static boolean AddFileToSendQueue(INT32 node, const char *filename, UINT8 fileid
|
|||
if (!p->id.filename)
|
||||
I_Error("AddFileToSendQueue: No more memory\n");
|
||||
|
||||
// Set the file name and get rid of the path
|
||||
strlcpy(p->id.filename, filename, MAX_WADPATH);
|
||||
nameonly(p->id.filename);
|
||||
|
||||
// Look for the requested file through all loaded files
|
||||
for (i = 0; wadfiles[i]; i++)
|
||||
{
|
||||
strlcpy(wadfilename, wadfiles[i]->filename, MAX_WADPATH);
|
||||
nameonly(wadfilename);
|
||||
if (!stricmp(wadfilename, p->id.filename))
|
||||
{
|
||||
// Copy file name with full path
|
||||
strlcpy(p->id.filename, wadfiles[i]->filename, MAX_WADPATH);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Find the wad the ID refers to
|
||||
wadnum = GetWadNumFromFileNeededId(fileid);
|
||||
|
||||
// Handle non-loaded file requests
|
||||
if (!wadfiles[i])
|
||||
if (wadnum == UINT16_MAX)
|
||||
{
|
||||
DEBFILE(va("%s not found in wadfiles\n", filename));
|
||||
DEBFILE(va("fileneeded %d not found in wadfiles\n", fileid));
|
||||
// This formerly checked if (!findfile(p->id.filename, NULL, true))
|
||||
|
||||
// Not found
|
||||
// Don't inform client (probably someone who thought they could leak 2.2 ACZ)
|
||||
DEBFILE(va("Client %d request %s: not found\n", node, filename));
|
||||
// Don't inform client
|
||||
DEBFILE(va("Client %d request fileneeded %d: not found\n", node, fileid));
|
||||
free(p->id.filename);
|
||||
free(p);
|
||||
*q = NULL;
|
||||
return false; // cancel the rest of the requests
|
||||
}
|
||||
|
||||
// Set the file name and get rid of the path
|
||||
strlcpy(p->id.filename, wadfiles[wadnum]->filename, MAX_WADPATH);
|
||||
|
||||
// Handle huge file requests (i.e. bigger than cv_maxsend.value KB)
|
||||
if (wadfiles[i]->filesize > (UINT32)cv_maxsend.value * 1024)
|
||||
if (wadfiles[wadnum]->filesize > (UINT32)cv_maxsend.value * 1024)
|
||||
{
|
||||
// Too big
|
||||
// Don't inform client (client sucks, man)
|
||||
DEBFILE(va("Client %d request %s: file too big, not sending\n", node, filename));
|
||||
DEBFILE(va("Client %d request %s: file too big, not sending\n", node, p->id.filename));
|
||||
free(p->id.filename);
|
||||
free(p);
|
||||
*q = NULL;
|
||||
return false; // cancel the rest of the requests
|
||||
}
|
||||
|
||||
DEBFILE(va("Sending file %s (id=%d) to %d\n", filename, fileid, node));
|
||||
if (cv_noticedownload.value)
|
||||
CONS_Printf("Sending file \"%s\" to node %d (%s)\n", p->id.filename, node, I_GetNodeAddress(node));
|
||||
|
||||
DEBFILE(va("Sending file %s (id=%d) to %d\n", p->id.filename, fileid, node));
|
||||
p->ram = SF_FILE; // It's a file, we need to close it and free its name once we're done sending it
|
||||
p->fileid = fileid;
|
||||
p->next = NULL; // End of list
|
||||
|
@ -914,7 +980,6 @@ static void SV_EndFileSend(INT32 node)
|
|||
filestosend--;
|
||||
}
|
||||
|
||||
#define PACKETPERTIC net_bandwidth/(TICRATE*software_MAXPACKETLENGTH)
|
||||
#define FILEFRAGMENTSIZE (software_MAXPACKETLENGTH - (FILETXHEADER + BASEPACKETSIZE))
|
||||
|
||||
/** Handles file transmission
|
||||
|
@ -928,17 +993,26 @@ void FileSendTicker(void)
|
|||
filetx_t *f;
|
||||
INT32 packetsent, ram, i, j;
|
||||
|
||||
// If someone is taking too long to download, kick them with a timeout
|
||||
// to prevent blocking the rest of the server...
|
||||
if (luafiletransfers)
|
||||
{
|
||||
for (i = 1; i < MAXNETNODES; i++)
|
||||
{
|
||||
luafiletransfernodestatus_t status = luafiletransfers->nodestatus[i];
|
||||
|
||||
if (status != LFTNS_NONE && status != LFTNS_WAITING && status != LFTNS_SENT
|
||||
&& I_GetTime() > luafiletransfers->nodetimeouts[i])
|
||||
{
|
||||
Net_ConnectionTimeout(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!filestosend) // No file to send
|
||||
return;
|
||||
|
||||
if (cv_downloadspeed.value) // New behavior
|
||||
packetsent = cv_downloadspeed.value;
|
||||
else // Old behavior
|
||||
{
|
||||
packetsent = PACKETPERTIC;
|
||||
if (!packetsent)
|
||||
packetsent = 1;
|
||||
}
|
||||
packetsent = cv_downloadspeed.value;
|
||||
|
||||
netbuffer->packettype = PT_FILEFRAGMENT;
|
||||
|
||||
|
@ -1215,6 +1289,9 @@ void PT_FileFragment(void)
|
|||
UINT16 boundedfragmentsize = doomcom->datalength - BASEPACKETSIZE - sizeof(netbuffer->u.filetxpak);
|
||||
char *filename;
|
||||
|
||||
if (!file)
|
||||
return;
|
||||
|
||||
filename = va("%s", file->filename);
|
||||
nameonly(filename);
|
||||
|
||||
|
@ -1326,6 +1403,7 @@ void PT_FileFragment(void)
|
|||
// Tell the server we have received the file
|
||||
netbuffer->packettype = PT_HASLUAFILE;
|
||||
HSendPacket(servernode, true, 0, 0);
|
||||
FreeFileNeeded();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1396,32 +1474,37 @@ void CloseNetFile(void)
|
|||
SV_AbortSendFiles(i);
|
||||
|
||||
// Receiving a file?
|
||||
for (i = 0; i < MAX_WADFILES; i++)
|
||||
if (fileneeded[i].status == FS_DOWNLOADING && fileneeded[i].file)
|
||||
{
|
||||
fclose(fileneeded[i].file);
|
||||
free(fileneeded[i].ackpacket);
|
||||
|
||||
if (!pauseddownload && i != 0) // 0 is either srb2.srb or the gamestate...
|
||||
if (fileneeded)
|
||||
{
|
||||
for (i = 0; i < fileneedednum; i++)
|
||||
if (fileneeded[i].status == FS_DOWNLOADING && fileneeded[i].file)
|
||||
{
|
||||
// Don't remove the file, save it for later in case we resume the download
|
||||
pauseddownload = malloc(sizeof(*pauseddownload));
|
||||
if (!pauseddownload)
|
||||
I_Error("CloseNetFile: No more memory\n");
|
||||
fclose(fileneeded[i].file);
|
||||
free(fileneeded[i].ackpacket);
|
||||
|
||||
strcpy(pauseddownload->filename, fileneeded[i].filename);
|
||||
memcpy(pauseddownload->md5sum, fileneeded[i].md5sum, 16);
|
||||
pauseddownload->currentsize = fileneeded[i].currentsize;
|
||||
pauseddownload->receivedfragments = fileneeded[i].receivedfragments;
|
||||
pauseddownload->fragmentsize = fileneeded[i].fragmentsize;
|
||||
if (!pauseddownload && (fileneeded[i].type == FILENEEDED_WAD || i != 0)) // 0 is the gamestate...
|
||||
{
|
||||
// Don't remove the file, save it for later in case we resume the download
|
||||
pauseddownload = malloc(sizeof(*pauseddownload));
|
||||
if (!pauseddownload)
|
||||
I_Error("CloseNetFile: No more memory\n");
|
||||
|
||||
strcpy(pauseddownload->filename, fileneeded[i].filename);
|
||||
memcpy(pauseddownload->md5sum, fileneeded[i].md5sum, 16);
|
||||
pauseddownload->currentsize = fileneeded[i].currentsize;
|
||||
pauseddownload->receivedfragments = fileneeded[i].receivedfragments;
|
||||
pauseddownload->fragmentsize = fileneeded[i].fragmentsize;
|
||||
}
|
||||
else
|
||||
{
|
||||
// File is not complete, delete it.
|
||||
free(fileneeded[i].receivedfragments);
|
||||
remove(fileneeded[i].filename);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
free(fileneeded[i].receivedfragments);
|
||||
// File is not complete delete it
|
||||
remove(fileneeded[i].filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FreeFileNeeded();
|
||||
}
|
||||
|
||||
void Command_Downloads_f(void)
|
||||
|
@ -1556,3 +1639,26 @@ filestatus_t findfile(char *filename, const UINT8 *wantedmd5sum, boolean complet
|
|||
|
||||
return (badmd5 ? FS_MD5SUMBAD : FS_NOTFOUND); // md5 sum bad or file not found
|
||||
}
|
||||
|
||||
// Searches for a folder.
|
||||
// This can be used with a full path, or an incomplete path.
|
||||
// In the latter case, the function will try to find folders in
|
||||
// srb2home, srb2path, and the current directory.
|
||||
filestatus_t findfolder(const char *path)
|
||||
{
|
||||
// Check the path by itself first.
|
||||
if (concatpaths(path, NULL) == 1)
|
||||
return FS_FOUND;
|
||||
|
||||
#define checkpath(startpath) \
|
||||
if (concatpaths(path, startpath) == 1) \
|
||||
return FS_FOUND
|
||||
|
||||
checkpath(srb2home); // Then, look in srb2home.
|
||||
checkpath(srb2path); // Now, look in srb2path.
|
||||
checkpath("."); // Finally, look in the current directory.
|
||||
|
||||
#undef checkpath
|
||||
|
||||
return FS_NOTFOUND;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -27,6 +27,7 @@ typedef enum
|
|||
|
||||
typedef enum
|
||||
{
|
||||
FS_NOTCHECKED,
|
||||
FS_NOTFOUND,
|
||||
FS_FOUND,
|
||||
FS_REQUESTED,
|
||||
|
@ -35,12 +36,21 @@ typedef enum
|
|||
FS_MD5SUMBAD
|
||||
} filestatus_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FILENEEDED_WAD,
|
||||
FILENEEDED_SAVEGAME,
|
||||
FILENEEDED_LUAFILE
|
||||
} fileneededtype_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 willsend; // Is the server willing to send it?
|
||||
char filename[MAX_WADPATH];
|
||||
UINT8 md5sum[16];
|
||||
filestatus_t status; // The value returned by recsearch
|
||||
UINT8 willsend; // Is the server willing to send it?
|
||||
UINT8 folder; // File is a folder
|
||||
fileneededtype_t type;
|
||||
boolean justdownloaded; // To prevent late fragments from causing an I_Error
|
||||
|
||||
// Used only for download
|
||||
|
@ -54,20 +64,28 @@ typedef struct
|
|||
UINT32 ackresendposition; // Used when resuming downloads
|
||||
} fileneeded_t;
|
||||
|
||||
#define FILENEEDEDSIZE 23
|
||||
|
||||
extern INT32 fileneedednum;
|
||||
extern fileneeded_t fileneeded[MAX_WADFILES];
|
||||
extern fileneeded_t *fileneeded;
|
||||
extern char downloaddir[512];
|
||||
|
||||
#ifndef NONET
|
||||
extern INT32 lastfilenum;
|
||||
extern INT32 downloadcompletednum;
|
||||
extern UINT32 downloadcompletedsize;
|
||||
extern INT32 totalfilesrequestednum;
|
||||
extern UINT32 totalfilesrequestedsize;
|
||||
#endif
|
||||
|
||||
UINT8 *PutFileNeeded(void);
|
||||
void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr);
|
||||
void AllocFileNeeded(INT32 size);
|
||||
void FreeFileNeeded(void);
|
||||
UINT8 *PutFileNeeded(UINT16 firstfile);
|
||||
void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr, UINT16 firstfile);
|
||||
void CL_PrepareDownloadSaveGame(const char *tmpsave);
|
||||
|
||||
INT32 CL_CheckFiles(void);
|
||||
void CL_LoadServerFiles(void);
|
||||
boolean CL_LoadServerFiles(void);
|
||||
void AddRamToSendQueue(INT32 node, void *data, size_t size, freemethod_t freemethod,
|
||||
UINT8 fileid);
|
||||
|
||||
|
@ -85,10 +103,11 @@ boolean PT_RequestFile(INT32 node);
|
|||
|
||||
typedef enum
|
||||
{
|
||||
LFTNS_NONE, // This node is not connected
|
||||
LFTNS_WAITING, // This node is waiting for the server to send the file
|
||||
LFTNS_ASKED, // The server has told the node they're ready to send the file
|
||||
LFTNS_ASKED, // The server has told the node they're ready to send the file
|
||||
LFTNS_SENDING, // The server is sending the file to this node
|
||||
LFTNS_SENT // The node already has the file
|
||||
LFTNS_SENT // The node already has the file
|
||||
} luafiletransfernodestatus_t;
|
||||
|
||||
typedef struct luafiletransfer_s
|
||||
|
@ -99,6 +118,7 @@ typedef struct luafiletransfer_s
|
|||
INT32 id; // Callback ID
|
||||
boolean ongoing;
|
||||
luafiletransfernodestatus_t nodestatus[MAXNETNODES];
|
||||
tic_t nodetimeouts[MAXNETNODES];
|
||||
struct luafiletransfer_s *next;
|
||||
} luafiletransfer_t;
|
||||
|
||||
|
@ -133,6 +153,9 @@ filestatus_t findfile(char *filename, const UINT8 *wantedmd5sum,
|
|||
boolean completepath);
|
||||
filestatus_t checkfilemd5(char *filename, const UINT8 *wantedmd5sum);
|
||||
|
||||
// Searches for a folder
|
||||
filestatus_t findfolder(const char *path);
|
||||
|
||||
void nameonly(char *s);
|
||||
size_t nameonlylength(const char *s);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -51,6 +51,9 @@ typedef enum
|
|||
SF_NONIGHTSSUPER = 1<<15, // Disable super colors for NiGHTS (if you have SF_SUPER)
|
||||
SF_NOSUPERSPRITES = 1<<16, // Don't use super sprites while super
|
||||
SF_NOSUPERJUMPBOOST = 1<<17, // Disable the jump boost given while super (i.e. Knuckles)
|
||||
SF_CANBUSTWALLS = 1<<18, // Can naturally bust walls on contact? (i.e. Knuckles)
|
||||
SF_NOSHIELDABILITY = 1<<19, // Disable shield abilities
|
||||
|
||||
// free up to and including 1<<31
|
||||
} skinflags_t;
|
||||
|
||||
|
@ -310,9 +313,43 @@ typedef enum
|
|||
RW_RAIL = 32
|
||||
} ringweapons_t;
|
||||
|
||||
//Bot types
|
||||
typedef enum
|
||||
{
|
||||
BOT_NONE = 0,
|
||||
BOT_2PAI,
|
||||
BOT_2PHUMAN,
|
||||
BOT_MPAI
|
||||
} bottype_t;
|
||||
|
||||
//AI states
|
||||
typedef enum
|
||||
{
|
||||
AI_STANDBY = 0,
|
||||
AI_FOLLOW,
|
||||
AI_CATCHUP,
|
||||
AI_THINKFLY,
|
||||
AI_FLYSTANDBY,
|
||||
AI_FLYCARRY,
|
||||
AI_SPINFOLLOW
|
||||
} aistatetype_t;
|
||||
|
||||
|
||||
// ========================================================================
|
||||
// PLAYER STRUCTURE
|
||||
// ========================================================================
|
||||
|
||||
//Bot memory struct
|
||||
typedef struct botmem_s
|
||||
{
|
||||
boolean lastForward;
|
||||
boolean lastBlocked;
|
||||
boolean blocked;
|
||||
UINT8 catchup_tics;
|
||||
UINT8 thinkstate;
|
||||
} botmem_t;
|
||||
|
||||
//Main struct
|
||||
typedef struct player_s
|
||||
{
|
||||
mobj_t *mo;
|
||||
|
@ -522,8 +559,13 @@ typedef struct player_s
|
|||
|
||||
boolean spectator;
|
||||
boolean outofcoop;
|
||||
boolean removing;
|
||||
UINT8 bot;
|
||||
|
||||
struct player_s *botleader;
|
||||
UINT16 lastbuttons;
|
||||
botmem_t botmem;
|
||||
boolean blocked;
|
||||
|
||||
tic_t jointime; // Timer when player joins game to change skin/color
|
||||
tic_t quittime; // Time elapsed since user disconnected, zero if connected
|
||||
#ifdef HWRENDER
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -21,6 +21,8 @@
|
|||
#pragma interface
|
||||
#endif
|
||||
|
||||
#define MAXPREDICTTICS 12
|
||||
|
||||
// Button/action code definitions.
|
||||
typedef enum
|
||||
{
|
||||
|
@ -63,6 +65,7 @@ typedef struct
|
|||
INT16 angleturn; // <<16 for angle delta - saved as 1 byte into demos
|
||||
INT16 aiming; // vertical aiming, see G_BuildTicCmd
|
||||
UINT16 buttons;
|
||||
UINT8 latency; // Netgames: how many tics ago was this ticcmd generated from this player's end?
|
||||
} ATTRPACK ticcmd_t;
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
|
|
675
src/deh_lua.c
Normal file
675
src/deh_lua.c
Normal file
|
@ -0,0 +1,675 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2022 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 deh_lua.c
|
||||
/// \brief Lua SOC library
|
||||
|
||||
#include "g_game.h"
|
||||
#include "s_sound.h"
|
||||
#include "z_zone.h"
|
||||
#include "m_menu.h"
|
||||
#include "m_misc.h"
|
||||
#include "p_local.h"
|
||||
#include "st_stuff.h"
|
||||
#include "fastcmp.h"
|
||||
#include "lua_script.h"
|
||||
#include "lua_libs.h"
|
||||
|
||||
#include "dehacked.h"
|
||||
#include "deh_lua.h"
|
||||
#include "deh_tables.h"
|
||||
|
||||
// freeslot takes a name (string only!)
|
||||
// and allocates it to the appropriate free slot.
|
||||
// Returns the slot number allocated for it or nil if failed.
|
||||
// ex. freeslot("MT_MYTHING","S_MYSTATE1","S_MYSTATE2")
|
||||
// TODO: Error checking! @.@; There's currently no way to know which ones failed and why!
|
||||
//
|
||||
static inline int lib_freeslot(lua_State *L)
|
||||
{
|
||||
int n = lua_gettop(L);
|
||||
int r = 0; // args returned
|
||||
char *s, *type,*word;
|
||||
|
||||
if (!lua_lumploading)
|
||||
return luaL_error(L, "This function cannot be called from within a hook or coroutine!");
|
||||
|
||||
while (n-- > 0)
|
||||
{
|
||||
s = Z_StrDup(luaL_checkstring(L,1));
|
||||
type = strtok(s, "_");
|
||||
if (type)
|
||||
strupr(type);
|
||||
else {
|
||||
Z_Free(s);
|
||||
return luaL_error(L, "Unknown enum type in '%s'\n", luaL_checkstring(L, 1));
|
||||
}
|
||||
|
||||
word = strtok(NULL, "\n");
|
||||
if (word)
|
||||
strupr(word);
|
||||
else {
|
||||
Z_Free(s);
|
||||
return luaL_error(L, "Missing enum name in '%s'\n", luaL_checkstring(L, 1));
|
||||
}
|
||||
if (fastcmp(type, "SFX")) {
|
||||
sfxenum_t sfx;
|
||||
strlwr(word);
|
||||
CONS_Printf("Sound sfx_%s allocated.\n",word);
|
||||
sfx = S_AddSoundFx(word, false, 0, false);
|
||||
if (sfx != sfx_None) {
|
||||
lua_pushinteger(L, sfx);
|
||||
r++;
|
||||
} else
|
||||
CONS_Alert(CONS_WARNING, "Ran out of free SFX slots!\n");
|
||||
}
|
||||
else if (fastcmp(type, "SPR"))
|
||||
{
|
||||
char wad;
|
||||
spritenum_t j;
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, "WAD");
|
||||
wad = (char)lua_tointeger(L, -1);
|
||||
lua_pop(L, 1);
|
||||
for (j = SPR_FIRSTFREESLOT; j <= SPR_LASTFREESLOT; j++)
|
||||
{
|
||||
if (used_spr[(j-SPR_FIRSTFREESLOT)/8] & (1<<(j%8)))
|
||||
{
|
||||
if (!sprnames[j][4] && memcmp(sprnames[j],word,4)==0)
|
||||
sprnames[j][4] = wad;
|
||||
continue; // Already allocated, next.
|
||||
}
|
||||
// Found a free slot!
|
||||
CONS_Printf("Sprite SPR_%s allocated.\n",word);
|
||||
strncpy(sprnames[j],word,4);
|
||||
//sprnames[j][4] = 0;
|
||||
used_spr[(j-SPR_FIRSTFREESLOT)/8] |= 1<<(j%8); // Okay, this sprite slot has been named now.
|
||||
lua_pushinteger(L, j);
|
||||
r++;
|
||||
break;
|
||||
}
|
||||
if (j > SPR_LASTFREESLOT)
|
||||
CONS_Alert(CONS_WARNING, "Ran out of free sprite slots!\n");
|
||||
}
|
||||
else if (fastcmp(type, "S"))
|
||||
{
|
||||
statenum_t i;
|
||||
for (i = 0; i < NUMSTATEFREESLOTS; i++)
|
||||
if (!FREE_STATES[i]) {
|
||||
CONS_Printf("State S_%s allocated.\n",word);
|
||||
FREE_STATES[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL);
|
||||
strcpy(FREE_STATES[i],word);
|
||||
lua_pushinteger(L, S_FIRSTFREESLOT + i);
|
||||
r++;
|
||||
break;
|
||||
}
|
||||
if (i == NUMSTATEFREESLOTS)
|
||||
CONS_Alert(CONS_WARNING, "Ran out of free State slots!\n");
|
||||
}
|
||||
else if (fastcmp(type, "MT"))
|
||||
{
|
||||
mobjtype_t i;
|
||||
for (i = 0; i < NUMMOBJFREESLOTS; i++)
|
||||
if (!FREE_MOBJS[i]) {
|
||||
CONS_Printf("MobjType MT_%s allocated.\n",word);
|
||||
FREE_MOBJS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL);
|
||||
strcpy(FREE_MOBJS[i],word);
|
||||
lua_pushinteger(L, MT_FIRSTFREESLOT + i);
|
||||
r++;
|
||||
break;
|
||||
}
|
||||
if (i == NUMMOBJFREESLOTS)
|
||||
CONS_Alert(CONS_WARNING, "Ran out of free MobjType slots!\n");
|
||||
}
|
||||
else if (fastcmp(type, "SKINCOLOR"))
|
||||
{
|
||||
skincolornum_t i;
|
||||
for (i = 0; i < NUMCOLORFREESLOTS; i++)
|
||||
if (!FREE_SKINCOLORS[i]) {
|
||||
CONS_Printf("Skincolor SKINCOLOR_%s allocated.\n",word);
|
||||
FREE_SKINCOLORS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL);
|
||||
strcpy(FREE_SKINCOLORS[i],word);
|
||||
M_AddMenuColor(numskincolors++);
|
||||
lua_pushinteger(L, SKINCOLOR_FIRSTFREESLOT + i);
|
||||
r++;
|
||||
break;
|
||||
}
|
||||
if (i == NUMCOLORFREESLOTS)
|
||||
CONS_Alert(CONS_WARNING, "Ran out of free skincolor slots!\n");
|
||||
}
|
||||
else if (fastcmp(type, "SPR2"))
|
||||
{
|
||||
// Search if we already have an SPR2 by that name...
|
||||
playersprite_t i;
|
||||
for (i = SPR2_FIRSTFREESLOT; i < free_spr2; i++)
|
||||
if (memcmp(spr2names[i],word,4) == 0)
|
||||
break;
|
||||
// We don't, so allocate a new one.
|
||||
if (i >= free_spr2) {
|
||||
if (free_spr2 < NUMPLAYERSPRITES)
|
||||
{
|
||||
CONS_Printf("Sprite SPR2_%s allocated.\n",word);
|
||||
strncpy(spr2names[free_spr2],word,4);
|
||||
spr2defaults[free_spr2] = 0;
|
||||
lua_pushinteger(L, free_spr2);
|
||||
r++;
|
||||
spr2names[free_spr2++][4] = 0;
|
||||
} else
|
||||
CONS_Alert(CONS_WARNING, "Ran out of free SPR2 slots!\n");
|
||||
}
|
||||
}
|
||||
else if (fastcmp(type, "TOL"))
|
||||
{
|
||||
// Search if we already have a typeoflevel by that name...
|
||||
int i;
|
||||
for (i = 0; TYPEOFLEVEL[i].name; i++)
|
||||
if (fastcmp(word, TYPEOFLEVEL[i].name))
|
||||
break;
|
||||
|
||||
// We don't, so allocate a new one.
|
||||
if (TYPEOFLEVEL[i].name == NULL) {
|
||||
if (lastcustomtol == (UINT32)MAXTOL) // Unless you have way too many, since they're flags.
|
||||
CONS_Alert(CONS_WARNING, "Ran out of free typeoflevel slots!\n");
|
||||
else {
|
||||
CONS_Printf("TypeOfLevel TOL_%s allocated.\n",word);
|
||||
G_AddTOL(lastcustomtol, word);
|
||||
lua_pushinteger(L, lastcustomtol);
|
||||
lastcustomtol <<= 1;
|
||||
r++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Z_Free(s);
|
||||
lua_remove(L, 1);
|
||||
continue;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
// Wrapper for ALL A_Action functions.
|
||||
// Arguments: mobj_t actor, int var1, int var2
|
||||
static int action_call(lua_State *L)
|
||||
{
|
||||
//actionf_t *action = lua_touserdata(L,lua_upvalueindex(1));
|
||||
actionf_t *action = *((actionf_t **)luaL_checkudata(L, 1, META_ACTION));
|
||||
mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
|
||||
var1 = (INT32)luaL_optinteger(L, 3, 0);
|
||||
var2 = (INT32)luaL_optinteger(L, 4, 0);
|
||||
if (!actor)
|
||||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
action->acp1(actor);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Hardcoded A_Action name to call for super() or NULL if super() would be invalid.
|
||||
// Set in lua_infolib.
|
||||
const char *superactions[MAXRECURSION];
|
||||
UINT8 superstack = 0;
|
||||
|
||||
static int lib_dummysuper(lua_State *L)
|
||||
{
|
||||
return luaL_error(L, "Can't call super() outside of hardcode-replacing A_Action functions being called by state changes!"); // convoluted, I know. @_@;;
|
||||
}
|
||||
|
||||
static inline int lib_getenum(lua_State *L)
|
||||
{
|
||||
const char *word, *p;
|
||||
fixed_t i;
|
||||
boolean mathlib = lua_toboolean(L, lua_upvalueindex(1));
|
||||
if (lua_type(L,2) != LUA_TSTRING)
|
||||
return 0;
|
||||
word = lua_tostring(L,2);
|
||||
if (strlen(word) == 1) { // Assume sprite frame if length 1.
|
||||
if (*word >= 'A' && *word <= '~')
|
||||
{
|
||||
lua_pushinteger(L, *word-'A');
|
||||
return 1;
|
||||
}
|
||||
if (mathlib) return luaL_error(L, "constant '%s' could not be parsed.\n", word);
|
||||
return 0;
|
||||
}
|
||||
else if (fastncmp("MF_", word, 3)) {
|
||||
p = word+3;
|
||||
for (i = 0; MOBJFLAG_LIST[i]; i++)
|
||||
if (fastcmp(p, MOBJFLAG_LIST[i])) {
|
||||
lua_pushinteger(L, ((lua_Integer)1<<i));
|
||||
return 1;
|
||||
}
|
||||
if (mathlib) return luaL_error(L, "mobjflag '%s' could not be found.\n", word);
|
||||
return 0;
|
||||
}
|
||||
else if (fastncmp("MF2_", word, 4)) {
|
||||
p = word+4;
|
||||
for (i = 0; MOBJFLAG2_LIST[i]; i++)
|
||||
if (fastcmp(p, MOBJFLAG2_LIST[i])) {
|
||||
lua_pushinteger(L, ((lua_Integer)1<<i));
|
||||
return 1;
|
||||
}
|
||||
if (mathlib) return luaL_error(L, "mobjflag2 '%s' could not be found.\n", word);
|
||||
return 0;
|
||||
}
|
||||
else if (fastncmp("MFE_", word, 4)) {
|
||||
p = word+4;
|
||||
for (i = 0; MOBJEFLAG_LIST[i]; i++)
|
||||
if (fastcmp(p, MOBJEFLAG_LIST[i])) {
|
||||
lua_pushinteger(L, ((lua_Integer)1<<i));
|
||||
return 1;
|
||||
}
|
||||
if (fastcmp(p, "REVERSESUPER"))
|
||||
{
|
||||
lua_pushinteger(L, (lua_Integer)MFE_REVERSESUPER);
|
||||
return 1;
|
||||
}
|
||||
if (mathlib) return luaL_error(L, "mobjeflag '%s' could not be found.\n", word);
|
||||
return 0;
|
||||
}
|
||||
else if (fastncmp("MTF_", word, 4)) {
|
||||
p = word+4;
|
||||
for (i = 0; i < 4; i++)
|
||||
if (MAPTHINGFLAG_LIST[i] && fastcmp(p, MAPTHINGFLAG_LIST[i])) {
|
||||
lua_pushinteger(L, ((lua_Integer)1<<i));
|
||||
return 1;
|
||||
}
|
||||
if (mathlib) return luaL_error(L, "mapthingflag '%s' could not be found.\n", word);
|
||||
return 0;
|
||||
}
|
||||
else if (fastncmp("PF_", word, 3)) {
|
||||
p = word+3;
|
||||
for (i = 0; PLAYERFLAG_LIST[i]; i++)
|
||||
if (fastcmp(p, PLAYERFLAG_LIST[i])) {
|
||||
lua_pushinteger(L, ((lua_Integer)1<<i));
|
||||
return 1;
|
||||
}
|
||||
if (fastcmp(p, "FULLSTASIS"))
|
||||
{
|
||||
lua_pushinteger(L, (lua_Integer)PF_FULLSTASIS);
|
||||
return 1;
|
||||
}
|
||||
else if (fastcmp(p, "USEDOWN")) // Remove case when 2.3 nears release...
|
||||
{
|
||||
lua_pushinteger(L, (lua_Integer)PF_SPINDOWN);
|
||||
return 1;
|
||||
}
|
||||
if (mathlib) return luaL_error(L, "playerflag '%s' could not be found.\n", word);
|
||||
return 0;
|
||||
}
|
||||
else if (fastncmp("GT_", word, 3)) {
|
||||
p = word;
|
||||
for (i = 0; Gametype_ConstantNames[i]; i++)
|
||||
if (fastcmp(p, Gametype_ConstantNames[i])) {
|
||||
lua_pushinteger(L, i);
|
||||
return 1;
|
||||
}
|
||||
if (mathlib) return luaL_error(L, "gametype '%s' could not be found.\n", word);
|
||||
return 0;
|
||||
}
|
||||
else if (fastncmp("GTR_", word, 4)) {
|
||||
p = word+4;
|
||||
for (i = 0; GAMETYPERULE_LIST[i]; i++)
|
||||
if (fastcmp(p, GAMETYPERULE_LIST[i])) {
|
||||
lua_pushinteger(L, ((lua_Integer)1<<i));
|
||||
return 1;
|
||||
}
|
||||
if (mathlib) return luaL_error(L, "game type rule '%s' could not be found.\n", word);
|
||||
return 0;
|
||||
}
|
||||
else if (fastncmp("TOL_", word, 4)) {
|
||||
p = word+4;
|
||||
for (i = 0; TYPEOFLEVEL[i].name; i++)
|
||||
if (fastcmp(p, TYPEOFLEVEL[i].name)) {
|
||||
lua_pushinteger(L, TYPEOFLEVEL[i].flag);
|
||||
return 1;
|
||||
}
|
||||
if (mathlib) return luaL_error(L, "typeoflevel '%s' could not be found.\n", word);
|
||||
return 0;
|
||||
}
|
||||
else if (fastncmp("ML_", word, 3)) {
|
||||
p = word+3;
|
||||
for (i = 0; i < 16; i++)
|
||||
if (ML_LIST[i] && fastcmp(p, ML_LIST[i])) {
|
||||
lua_pushinteger(L, ((lua_Integer)1<<i));
|
||||
return 1;
|
||||
}
|
||||
if (mathlib) return luaL_error(L, "linedef flag '%s' could not be found.\n", word);
|
||||
return 0;
|
||||
}
|
||||
else if (fastncmp("S_",word,2)) {
|
||||
p = word+2;
|
||||
for (i = 0; i < NUMSTATEFREESLOTS; i++) {
|
||||
if (!FREE_STATES[i])
|
||||
break;
|
||||
if (fastcmp(p, FREE_STATES[i])) {
|
||||
lua_pushinteger(L, S_FIRSTFREESLOT+i);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < S_FIRSTFREESLOT; i++)
|
||||
if (fastcmp(p, STATE_LIST[i]+2)) {
|
||||
lua_pushinteger(L, i);
|
||||
return 1;
|
||||
}
|
||||
return luaL_error(L, "state '%s' does not exist.\n", word);
|
||||
}
|
||||
else if (fastncmp("MT_",word,3)) {
|
||||
p = word+3;
|
||||
for (i = 0; i < NUMMOBJFREESLOTS; i++) {
|
||||
if (!FREE_MOBJS[i])
|
||||
break;
|
||||
if (fastcmp(p, FREE_MOBJS[i])) {
|
||||
lua_pushinteger(L, MT_FIRSTFREESLOT+i);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < MT_FIRSTFREESLOT; i++)
|
||||
if (fastcmp(p, MOBJTYPE_LIST[i]+3)) {
|
||||
lua_pushinteger(L, i);
|
||||
return 1;
|
||||
}
|
||||
return luaL_error(L, "mobjtype '%s' does not exist.\n", word);
|
||||
}
|
||||
else if (fastncmp("SPR_",word,4)) {
|
||||
p = word+4;
|
||||
for (i = 0; i < NUMSPRITES; i++)
|
||||
if (!sprnames[i][4] && fastncmp(p,sprnames[i],4)) {
|
||||
lua_pushinteger(L, i);
|
||||
return 1;
|
||||
}
|
||||
if (mathlib) return luaL_error(L, "sprite '%s' could not be found.\n", word);
|
||||
return 0;
|
||||
}
|
||||
else if (fastncmp("SPR2_",word,5)) {
|
||||
p = word+5;
|
||||
for (i = 0; i < (fixed_t)free_spr2; i++)
|
||||
if (!spr2names[i][4])
|
||||
{
|
||||
// special 3-char cases, e.g. SPR2_RUN
|
||||
// the spr2names entry will have "_" on the end, as in "RUN_"
|
||||
if (spr2names[i][3] == '_' && !p[3]) {
|
||||
if (fastncmp(p,spr2names[i],3)) {
|
||||
lua_pushinteger(L, i);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (fastncmp(p,spr2names[i],4)) {
|
||||
lua_pushinteger(L, i);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (mathlib) return luaL_error(L, "player sprite '%s' could not be found.\n", word);
|
||||
return 0;
|
||||
}
|
||||
else if (!mathlib && fastncmp("sfx_",word,4)) {
|
||||
p = word+4;
|
||||
for (i = 0; i < NUMSFX; i++)
|
||||
if (S_sfx[i].name && fastcmp(p, S_sfx[i].name)) {
|
||||
lua_pushinteger(L, i);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else if (mathlib && fastncmp("SFX_",word,4)) { // SOCs are ALL CAPS!
|
||||
p = word+4;
|
||||
for (i = 0; i < NUMSFX; i++)
|
||||
if (S_sfx[i].name && fasticmp(p, S_sfx[i].name)) {
|
||||
lua_pushinteger(L, i);
|
||||
return 1;
|
||||
}
|
||||
return luaL_error(L, "sfx '%s' could not be found.\n", word);
|
||||
}
|
||||
else if (mathlib && fastncmp("DS",word,2)) {
|
||||
p = word+2;
|
||||
for (i = 0; i < NUMSFX; i++)
|
||||
if (S_sfx[i].name && fasticmp(p, S_sfx[i].name)) {
|
||||
lua_pushinteger(L, i);
|
||||
return 1;
|
||||
}
|
||||
if (mathlib) return luaL_error(L, "sfx '%s' could not be found.\n", word);
|
||||
return 0;
|
||||
}
|
||||
else if (!mathlib && fastncmp("pw_",word,3)) {
|
||||
p = word+3;
|
||||
for (i = 0; i < NUMPOWERS; i++)
|
||||
if (fasticmp(p, POWERS_LIST[i])) {
|
||||
lua_pushinteger(L, i);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else if (mathlib && fastncmp("PW_",word,3)) { // SOCs are ALL CAPS!
|
||||
p = word+3;
|
||||
for (i = 0; i < NUMPOWERS; i++)
|
||||
if (fastcmp(p, POWERS_LIST[i])) {
|
||||
lua_pushinteger(L, i);
|
||||
return 1;
|
||||
}
|
||||
return luaL_error(L, "power '%s' could not be found.\n", word);
|
||||
}
|
||||
else if (fastncmp("HUD_",word,4)) {
|
||||
p = word+4;
|
||||
for (i = 0; i < NUMHUDITEMS; i++)
|
||||
if (fastcmp(p, HUDITEMS_LIST[i])) {
|
||||
lua_pushinteger(L, i);
|
||||
return 1;
|
||||
}
|
||||
if (mathlib) return luaL_error(L, "huditem '%s' could not be found.\n", word);
|
||||
return 0;
|
||||
}
|
||||
else if (fastncmp("SKINCOLOR_",word,10)) {
|
||||
p = word+10;
|
||||
for (i = 0; i < NUMCOLORFREESLOTS; i++) {
|
||||
if (!FREE_SKINCOLORS[i])
|
||||
break;
|
||||
if (fastcmp(p, FREE_SKINCOLORS[i])) {
|
||||
lua_pushinteger(L, SKINCOLOR_FIRSTFREESLOT+i);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < SKINCOLOR_FIRSTFREESLOT; i++)
|
||||
if (fastcmp(p, COLOR_ENUMS[i])) {
|
||||
lua_pushinteger(L, i);
|
||||
return 1;
|
||||
}
|
||||
return luaL_error(L, "skincolor '%s' could not be found.\n", word);
|
||||
}
|
||||
else if (fastncmp("GRADE_",word,6))
|
||||
{
|
||||
p = word+6;
|
||||
for (i = 0; NIGHTSGRADE_LIST[i]; i++)
|
||||
if (*p == NIGHTSGRADE_LIST[i])
|
||||
{
|
||||
lua_pushinteger(L, i);
|
||||
return 1;
|
||||
}
|
||||
if (mathlib) return luaL_error(L, "NiGHTS grade '%s' could not be found.\n", word);
|
||||
return 0;
|
||||
}
|
||||
else if (fastncmp("MN_",word,3)) {
|
||||
p = word+3;
|
||||
for (i = 0; i < NUMMENUTYPES; i++)
|
||||
if (fastcmp(p, MENUTYPES_LIST[i])) {
|
||||
lua_pushinteger(L, i);
|
||||
return 1;
|
||||
}
|
||||
if (mathlib) return luaL_error(L, "menutype '%s' could not be found.\n", word);
|
||||
return 0;
|
||||
}
|
||||
else if (!mathlib && fastncmp("A_",word,2)) {
|
||||
char *caps;
|
||||
// Try to get a Lua action first.
|
||||
/// \todo Push a closure that sets superactions[] and superstack.
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, LREG_ACTIONS);
|
||||
// actions are stored in all uppercase.
|
||||
caps = Z_StrDup(word);
|
||||
strupr(caps);
|
||||
lua_getfield(L, -1, caps);
|
||||
Z_Free(caps);
|
||||
if (!lua_isnil(L, -1))
|
||||
return 1; // Success! :D That was easy.
|
||||
// Welp, that failed.
|
||||
lua_pop(L, 2); // pop nil and LREG_ACTIONS
|
||||
|
||||
// Hardcoded actions as callable Lua functions!
|
||||
// Retrieving them from this metatable allows them to be case-insensitive!
|
||||
for (i = 0; actionpointers[i].name; i++)
|
||||
if (fasticmp(word, actionpointers[i].name)) {
|
||||
// We push the actionf_t* itself as userdata!
|
||||
LUA_PushUserdata(L, &actionpointers[i].action, META_ACTION);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else if (!mathlib && fastcmp("super",word))
|
||||
{
|
||||
if (!superstack)
|
||||
{
|
||||
lua_pushcfunction(L, lib_dummysuper);
|
||||
return 1;
|
||||
}
|
||||
for (i = 0; actionpointers[i].name; i++)
|
||||
if (fasticmp(superactions[superstack-1], actionpointers[i].name)) {
|
||||
LUA_PushUserdata(L, &actionpointers[i].action, META_ACTION);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (fastcmp(word, "BT_USE")) // Remove case when 2.3 nears release...
|
||||
{
|
||||
lua_pushinteger(L, (lua_Integer)BT_SPIN);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 0; INT_CONST[i].n; i++)
|
||||
if (fastcmp(word,INT_CONST[i].n)) {
|
||||
lua_pushinteger(L, INT_CONST[i].v);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (mathlib) return luaL_error(L, "constant '%s' could not be parsed.\n", word);
|
||||
|
||||
// DYNAMIC variables too!!
|
||||
// Try not to add anything that would break netgames or timeattack replays here.
|
||||
// You know, like consoleplayer, displayplayer, secondarydisplayplayer, or gametime.
|
||||
return LUA_PushGlobals(L, word);
|
||||
}
|
||||
|
||||
int LUA_EnumLib(lua_State *L)
|
||||
{
|
||||
if (lua_gettop(L) == 0)
|
||||
lua_pushboolean(L, 0);
|
||||
|
||||
// Set the global metatable
|
||||
lua_createtable(L, 0, 1);
|
||||
lua_pushvalue(L, 1); // boolean passed to LUA_EnumLib as first argument.
|
||||
lua_pushcclosure(L, lib_getenum, 1);
|
||||
lua_setfield(L, -2, "__index");
|
||||
lua_setmetatable(L, LUA_GLOBALSINDEX);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// getActionName(action) -> return action's string name
|
||||
static int lib_getActionName(lua_State *L)
|
||||
{
|
||||
if (lua_isuserdata(L, 1)) // arg 1 is built-in action, expect action userdata
|
||||
{
|
||||
actionf_t *action = *((actionf_t **)luaL_checkudata(L, 1, META_ACTION));
|
||||
const char *name = NULL;
|
||||
if (!action)
|
||||
return luaL_error(L, "not a valid action?");
|
||||
name = LUA_GetActionName(action);
|
||||
if (!name) // that can't be right?
|
||||
return luaL_error(L, "no name string could be found for this action");
|
||||
lua_pushstring(L, name);
|
||||
return 1;
|
||||
}
|
||||
else if (lua_isfunction(L, 1)) // arg 1 is a function (either C or Lua)
|
||||
{
|
||||
lua_settop(L, 1); // set top of stack to 1 (removing any extra args, which there shouldn't be)
|
||||
// get the name for this action, if possible.
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, LREG_ACTIONS);
|
||||
lua_pushnil(L);
|
||||
// Lua stack at this point:
|
||||
// 1 ... -2 -1
|
||||
// arg ... LREG_ACTIONS nil
|
||||
while (lua_next(L, -2))
|
||||
{
|
||||
// Lua stack at this point:
|
||||
// 1 ... -3 -2 -1
|
||||
// arg ... LREG_ACTIONS "A_ACTION" function
|
||||
if (lua_rawequal(L, -1, 1)) // is this the same as the arg?
|
||||
{
|
||||
// make sure the key (i.e. "A_ACTION") is a string first
|
||||
// (note: we don't use lua_isstring because it also returns true for numbers)
|
||||
if (lua_type(L, -2) == LUA_TSTRING)
|
||||
{
|
||||
lua_pushvalue(L, -2); // push "A_ACTION" string to top of stack
|
||||
return 1;
|
||||
}
|
||||
lua_pop(L, 2); // pop the name and function
|
||||
break; // probably should have succeeded but we didn't, so end the loop
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
lua_pop(L, 1); // pop LREG_ACTIONS
|
||||
return 0; // return nothing (don't error)
|
||||
}
|
||||
|
||||
return luaL_typerror(L, 1, "action userdata or Lua function");
|
||||
}
|
||||
|
||||
|
||||
|
||||
int LUA_SOCLib(lua_State *L)
|
||||
{
|
||||
lua_register(L,"freeslot",lib_freeslot);
|
||||
lua_register(L,"getActionName",lib_getActionName);
|
||||
|
||||
luaL_newmetatable(L, META_ACTION);
|
||||
lua_pushcfunction(L, action_call);
|
||||
lua_setfield(L, -2, "__call");
|
||||
lua_pop(L, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *LUA_GetActionName(void *action)
|
||||
{
|
||||
actionf_t *act = (actionf_t *)action;
|
||||
size_t z;
|
||||
for (z = 0; actionpointers[z].name; z++)
|
||||
{
|
||||
if (actionpointers[z].action.acv == act->acv)
|
||||
return actionpointers[z].name;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void LUA_SetActionByName(void *state, const char *actiontocompare)
|
||||
{
|
||||
state_t *st = (state_t *)state;
|
||||
size_t z;
|
||||
for (z = 0; actionpointers[z].name; z++)
|
||||
{
|
||||
if (fasticmp(actiontocompare, actionpointers[z].name))
|
||||
{
|
||||
st->action = actionpointers[z].action;
|
||||
st->action.acv = actionpointers[z].action.acv; // assign
|
||||
st->action.acp1 = actionpointers[z].action.acp1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum actionnum LUA_GetActionNumByName(const char *actiontocompare)
|
||||
{
|
||||
size_t z;
|
||||
for (z = 0; actionpointers[z].name; z++)
|
||||
if (fasticmp(actiontocompare, actionpointers[z].name))
|
||||
return z;
|
||||
return z;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue