diff --git a/.circleci/config.yml b/.circleci/config.yml index b5c43d01..ca910568 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -58,6 +58,3 @@ jobs: key: v1-SRB2-{{ .Branch }}-{{ checksum "objs/Linux/SDL/Release/depend.dep" }} paths: - /root/.ccache - - - diff --git a/.travis.yml b/.travis.yml index e5dbb58e..4648ae56 100644 --- a/.travis.yml +++ b/.travis.yml @@ -100,6 +100,21 @@ matrix: compiler: gcc-6 env: WFLAGS="-Wno-tautological-compare" #gcc-6 (Ubuntu 6.1.1-3ubuntu11~14.04.1) 6.1.1 20160511 + - os: linux + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - libsdl2-mixer-dev + - libpng-dev + - libgl1-mesa-dev + - libgme-dev + - p7zip-full + - gcc-7 + compiler: gcc-7 + env: WFLAGS="-Wno-tautological-compare -Wno-error=implicit-fallthrough -Wimplicit-fallthrough=3" + #gcc-7 (Ubuntu 7.2.0-1ubuntu1~14.04) 7.2.0 20170802 - os: linux compiler: clang #clang version 3.5.0 (tags/RELEASE_350/final) @@ -162,6 +177,51 @@ matrix: - clang-3.8 compiler: clang-3.8 #clang version 3.8.1-svn271127-1~exp1 (branches/release_38) + - os: linux + addons: + apt: + sources: + - llvm-toolchain-precise-3.9 + - ubuntu-toolchain-r-test + packages: + - libsdl2-mixer-dev + - libpng-dev + - libgl1-mesa-dev + - libgme-dev + - p7zip-full + - clang-3.9 + compiler: clang-3.9 + #clang version 3.9.X +# - os: linux +# addons: +# apt: +# sources: +# - llvm-toolchain-precise-4.0 +# - ubuntu-toolchain-r-test +# packages: +# - libsdl2-mixer-dev +# - libpng-dev +# - libgl1-mesa-dev +# - libgme-dev +# - p7zip-full +# - clang-4.0 +# compiler: clang-4.0 +# #clang version 4.0.X +# - os: linux +# addons: +# apt: +# sources: +# - llvm-toolchain-precise-5.0 +# - ubuntu-toolchain-r-test +# packages: +# - libsdl2-mixer-dev +# - libpng-dev +# - libgl1-mesa-dev +# - libgme-dev +# - p7zip-full +# - clang-5.0 +# compiler: clang-5.0 +# #clang version 5.0.X # - os: osx # osx_image: beta-xcode6.1 # #Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn) @@ -192,6 +252,9 @@ matrix: - compiler: clang-3.6 - compiler: clang-3.7 - compiler: clang-3.8 + - compiler: clang-3.9 + - compiler: clang-4.0 + - compiler: clang-5.0 cache: apt: true @@ -219,9 +282,9 @@ before_script: before_install: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install sdl2_mixer game-music-emu p7zip; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install sdl2 sdl2_mixer game-music-emu p7zip; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install cmake||true; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -O -L https://www.libsdl.org/release/SDL2-2.0.4.dmg; hdiutil attach SDL2-2.0.4.dmg; sudo cp -a /Volumes/SDL2/SDL2.framework /Library/Frameworks/; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -O -L https://www.libsdl.org/release/SDL2-2.0.6.dmg; hdiutil attach SDL2-2.0.6.dmg; sudo cp -a /Volumes/SDL2/SDL2.framework /Library/Frameworks/; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -O -L https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.1.dmg; hdiutil attach SDL2_mixer-2.0.1.dmg; sudo cp -a /Volumes/SDL2_mixer/SDL2_mixer.framework /Library/Frameworks/; fi - mkdir -p $HOME/srb2_cache diff --git a/CMakeLists.txt b/CMakeLists.txt index 23b768a7..f9364fdd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.0) project(SRB2 - VERSION 2.1.18 + VERSION 2.1.19 LANGUAGES C) if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) diff --git a/appveyor.yml b/appveyor.yml index 76e1261f..23b9b628 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 2.1.18.{branch}-{build} +version: 2.1.19.{branch}-{build} os: MinGW environment: @@ -47,7 +47,7 @@ before_build: - upx -V - ccache -V - ccache -s -- set SRB2_MFLAGS=-C src MINGW=1 WARNINGMODE=1 GCC63=1 CCACHE=1 +- set SRB2_MFLAGS=-C src MINGW=1 WARNINGMODE=1 GCC63=1 CCACHE=1 NOOBJDUMP=1 build_script: - cmd: mingw32-make.exe %SRB2_MFLAGS% %CONFIGURATION%=1 clean @@ -58,26 +58,29 @@ after_build: - cmd: git rev-parse --short %APPVEYOR_REPO_COMMIT%>%TMP%/gitshort.txt - cmd: set /P GITSHORT=<%TMP%/gitshort.txt - set BUILD_ARCHIVE=%APPVEYOR_REPO_BRANCH%-%GITSHORT%-%CONFIGURATION%.7z +- set BUILDSARCHIVE=%APPVEYOR_REPO_BRANCH%-%CONFIGURATION%.7z - cmd: 7z a %BUILD_ARCHIVE% bin\Mingw\Release -xr!.gitignore - appveyor PushArtifact %BUILD_ARCHIVE% +- cmd: copy %BUILD_ARCHIVE% %BUILDSARCHIVE% +- appveyor PushArtifact %BUILDSARCHIVE% test: off -deploy: - - provider: FTP - protocol: ftps - host: - secure: NsLJEPIBvmwCOj8Tg8RoRQ== - username: - secure: ejxi5mvk7oLYu7QtbYojajEPigMy0mokaKhuEVuDZcA= - password: - secure: Hbn6Uy3lT0YZ88yFJ3aW4w== - folder: appveyor - application: - active_mode: false - on: - branch: master - appveyor_repo_tag: true +#deploy: +# - provider: FTP +# protocol: ftps +# host: +# secure: NsLJEPIBvmwCOj8Tg8RoRQ== +# username: +# secure: ejxi5mvk7oLYu7QtbYojajEPigMy0mokaKhuEVuDZcA= +# password: +# secure: Hbn6Uy3lT0YZ88yFJ3aW4w== +# folder: appveyor +# application: +# active_mode: false +# on: +# branch: master +# appveyor_repo_tag: true on_finish: diff --git a/bin/DC/.gitignore b/bin/DC/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/DC/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/Dos/Debug/.gitignore b/bin/Dos/Debug/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/Dos/Debug/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/Dos/Release/.gitignore b/bin/Dos/Release/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/Dos/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/FreeBSD/Debug/.gitignore b/bin/FreeBSD/Debug/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/FreeBSD/Debug/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/FreeBSD/Release/.gitignore b/bin/FreeBSD/Release/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/FreeBSD/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/SDL/Debug/.gitignore b/bin/SDL/Debug/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/SDL/Debug/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/SDL/Release/.gitignore b/bin/SDL/Release/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/SDL/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/WinCE/ARMV4Dbg/.gitignore b/bin/WinCE/ARMV4Dbg/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/WinCE/ARMV4Dbg/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/WinCE/ARMV4IDbg/.gitignore b/bin/WinCE/ARMV4IDbg/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/WinCE/ARMV4IDbg/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/WinCE/ARMV4IRel/.gitignore b/bin/WinCE/ARMV4IRel/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/WinCE/ARMV4IRel/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/WinCE/ARMV4Rel/.gitignore b/bin/WinCE/ARMV4Rel/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/WinCE/ARMV4Rel/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/WinCE/ARMV4TDbg/.gitignore b/bin/WinCE/ARMV4TDbg/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/WinCE/ARMV4TDbg/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/WinCE/ARMV4TRel/.gitignore b/bin/WinCE/ARMV4TRel/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/WinCE/ARMV4TRel/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/WinCE/MIPS16Dbg/.gitignore b/bin/WinCE/MIPS16Dbg/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/WinCE/MIPS16Dbg/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/WinCE/MIPS16Rel/.gitignore b/bin/WinCE/MIPS16Rel/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/WinCE/MIPS16Rel/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/WinCE/MIPSIIDbg/.gitignore b/bin/WinCE/MIPSIIDbg/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/WinCE/MIPSIIDbg/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/WinCE/MIPSIIRel/.gitignore b/bin/WinCE/MIPSIIRel/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/WinCE/MIPSIIRel/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/WinCE/MIPSII_FPDbg/.gitignore b/bin/WinCE/MIPSII_FPDbg/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/WinCE/MIPSII_FPDbg/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/WinCE/MIPSII_FPRel/.gitignore b/bin/WinCE/MIPSII_FPRel/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/WinCE/MIPSII_FPRel/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/WinCE/MIPSIVDbg/.gitignore b/bin/WinCE/MIPSIVDbg/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/WinCE/MIPSIVDbg/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/WinCE/MIPSIVRel/.gitignore b/bin/WinCE/MIPSIVRel/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/WinCE/MIPSIVRel/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/WinCE/MIPSIV_FPDbg/.gitignore b/bin/WinCE/MIPSIV_FPDbg/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/WinCE/MIPSIV_FPDbg/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/WinCE/MIPSIV_FPRel/.gitignore b/bin/WinCE/MIPSIV_FPRel/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/WinCE/MIPSIV_FPRel/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/WinCE/Release/.gitignore b/bin/WinCE/Release/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/WinCE/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/WinCE/SH3Dbg/.gitignore b/bin/WinCE/SH3Dbg/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/WinCE/SH3Dbg/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/WinCE/SH3Rel/.gitignore b/bin/WinCE/SH3Rel/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/WinCE/SH3Rel/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/WinCE/SH4Dbg/.gitignore b/bin/WinCE/SH4Dbg/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/WinCE/SH4Dbg/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/WinCE/SH4Rel/.gitignore b/bin/WinCE/SH4Rel/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/WinCE/SH4Rel/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/WinCE/X86Dbg/.gitignore b/bin/WinCE/X86Dbg/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/WinCE/X86Dbg/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/WinCE/X86Rel/.gitignore b/bin/WinCE/X86Rel/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/WinCE/X86Rel/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/WinCE/emulatorDbg/.gitignore b/bin/WinCE/emulatorDbg/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/WinCE/emulatorDbg/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/WinCE/emulatorRel/.gitignore b/bin/WinCE/emulatorRel/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/WinCE/emulatorRel/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/bin/dummy/.gitignore b/bin/dummy/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/bin/dummy/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/FreeBSD/SDL/Debug/.gitignore b/objs/FreeBSD/SDL/Debug/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/FreeBSD/SDL/Debug/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/FreeBSD/SDL/Release/.gitignore b/objs/FreeBSD/SDL/Release/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/FreeBSD/SDL/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/MasterClient/.gitignore b/objs/MasterClient/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/MasterClient/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/MasterServer/.gitignore b/objs/MasterServer/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/MasterServer/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/XBOX/SDL/Debug/.gitignore b/objs/XBOX/SDL/Debug/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/XBOX/SDL/Debug/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/XBOX/SDL/Release/.gitignore b/objs/XBOX/SDL/Release/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/XBOX/SDL/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/cygwin/Debug/.gitignore b/objs/cygwin/Debug/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/cygwin/Debug/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/cygwin/Release/.gitignore b/objs/cygwin/Release/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/cygwin/Release/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/objs/dummy/.gitignore b/objs/dummy/.gitignore new file mode 100644 index 00000000..42c6dc2c --- /dev/null +++ b/objs/dummy/.gitignore @@ -0,0 +1,2 @@ +# DON'T REMOVE +# This keeps the folder from disappearing diff --git a/src/Makefile b/src/Makefile index b257097c..3f3184c3 100644 --- a/src/Makefile +++ b/src/Makefile @@ -209,7 +209,13 @@ LIBS+=-lm endif ifdef SDL -include sdl/Makefile.cfg +#SDL 2.0 +ifndef SDL12 + include sdl/Makefile.cfg +#SDL 1.2 +else + include sdl12/Makefile.cfg +endif #ifndef SDL12 endif #ifdef SDL ifdef DISTCC @@ -513,13 +519,11 @@ OBJS:=$(i_main_o) \ # For reference, this is the command I use to build a srb2.pot file from the source code. # (The listed source files are the ones containing translated strings). # FILES=""; for file in `find ./ | grep "\.c" | grep -v svn`; do [ "`grep "M_GetText(" $file`" ] && FILES="$FILES $file"; done; xgettext -d srb2 -o locale/srb2.pot -kM_GetText -F --no-wrap $FILES -ifndef NOGETTEXT ifdef GETTEXT POS:=$(BIN)/en.mo OPTS+=-DGETTEXT endif -endif ifdef DJGPPDOS all: pre-build $(BIN)/$(EXENAME) diff --git a/src/Makefile.cfg b/src/Makefile.cfg index 80d018c4..31721839 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -7,6 +7,21 @@ # and other things # +ifdef GCC80 +GCC72=1 +endif + +ifdef GCC72 +GCC71=1 +endif + +ifdef GCC71 +GCC64=1 +endif + +ifdef GCC64 +GCC64=1 +endif ifdef GCC63 GCC62=1 @@ -283,9 +298,6 @@ else ifdef LINUX NASMFORMAT=elf -DLINUX SDL=1 -ifndef NOGETTEXT - GETTEXT=1 -endif ifdef LINUX64 OBJDIR:=$(OBJDIR)/Linux64 BIN:=$(BIN)/Linux64 @@ -321,29 +333,28 @@ else ifdef MINGW64 INTERFACE=win32 #NASMFORMAT=win64 -ifndef NOGETTEXT - #GETTEXT=1 -endif OBJDIR:=$(OBJDIR)/Mingw64 BIN:=$(BIN)/Mingw64 else ifdef WII - INTERFACE=sdl + INTERFACE=sdl12 NONX86=1 STATIC=1 PREFIX?=powerpc-eabi SDL=1 + SDL12=1 SDLMAIN=1 OBJDIR:=$(OBJDIR)/Wii BIN:=$(BIN)/Wii NOUPX=1 else ifdef PS3N - INTERFACE=sdl + INTERFACE=sdl12 NONX86=1 STATIC=1 PREFIX?=ppu SDL=1 + SDL12=1 # unsure? #SDLMAIN=1 # can't compile SDL_mixer for ps3... @@ -354,41 +365,42 @@ else ifdef MINGW INTERFACE=win32 NASMFORMAT=win32 -ifndef NOGETTEXT - GETTEXT=1 -endif OBJDIR:=$(OBJDIR)/Mingw BIN:=$(BIN)/Mingw else ifdef XBOX - INTERFACE=sdl + INTERFACE=sdl12 NASMFORMAT=win32 PREFIX?=/usr/local/openxdk/bin/i386-pc-xbox SDL=1 + SDL12=1 OBJDIR:=$(OBJDIR)/XBOX BIN:=$(BIN)/XBOX else ifdef PSP - INTERFACE=sdl + INTERFACE=sdl12 NONX86=1 SDL=1 + SDL12=1 OBJDIR:=$(OBJDIR)/PSP BIN:=$(BIN)/PSP NOUPX=1 else ifdef DC - INTERFACE=sdl + INTERFACE=sdl12 NONX86=1 SDL=1 + SDL12=1 OBJDIR:=$(OBJDIR)/DC BIN:=$(BIN)/DC NOUPX=1 else ifdef WINCE - INTERFACE=sdl + INTERFACE=sdl12 NONX86=1 PREFIX?=arm-wince-pe SDL=1 + SDL12=1 OBJDIR:=$(OBJDIR)/WinCE BIN:=$(BIN)/WinCE else @@ -413,6 +425,12 @@ endif endif endif +ifdef GP2X +ifdef SDL + SDL12=1 +endif +endif + ifdef ARCHNAME OBJDIR:=$(OBJDIR)/$(ARCHNAME) BIN:=$(BIN)/$(ARCHNAME) @@ -446,7 +464,13 @@ OBJDUMP_OPTS?=--wide --source --line-numbers LD=$(CC) ifdef SDL +# SDL 2.0 +ifndef SDL12 INTERFACE=sdl +# SDL 1.2 +else + INTERFACE=sdl12 +endif OBJDIR:=$(OBJDIR)/SDL endif diff --git a/src/blua/ldebug.c b/src/blua/ldebug.c index 497d5498..542e209a 100644 --- a/src/blua/ldebug.c +++ b/src/blua/ldebug.c @@ -412,7 +412,7 @@ static Instruction symbexec (const Proto *pt, int lastpc, int reg) { case OP_FORLOOP: case OP_FORPREP: checkreg(pt, a+3); - /* go through */ + /* FALLTHRU */ case OP_JMP: { int dest = pc+1+b; /* not full check and jump is forward and do not skip `lastpc'? */ diff --git a/src/blua/llex.c b/src/blua/llex.c index 0b328dca..9e3dc292 100644 --- a/src/blua/llex.c +++ b/src/blua/llex.c @@ -306,11 +306,12 @@ static void read_string (LexState *ls, int del, SemInfo *seminfo) { save_and_next(ls); /* skip $ */ seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + 1, luaZ_bufflen(ls->buff) - 2); - ls->refstr++; /* expect '\' anytime soon */ + ls->refstr++; /* expect '\' anytime soon */ lua_assert(ls->lookahead.token == TK_EOS); - ls->lookahead.token = TK_CONCAT; - return; - } + ls->lookahead.token = TK_CONCAT; + return; + } + /* FALLTHRU */ default: { if (!isdigit(ls->current)) save_and_next(ls); /* handles \\, \", \', and \? */ @@ -340,7 +341,8 @@ static void read_string (LexState *ls, int del, SemInfo *seminfo) { }; switch (i) { - case 4: save( ls, (c>>8) & 0xff ); // pass-through.. + case 4: save( ls, (c>>8) & 0xff ); + /* FALLTHRU */ case 2: save( ls, c&0xff ); break; case 5: @@ -350,7 +352,7 @@ static void read_string (LexState *ls, int del, SemInfo *seminfo) { } continue; - // "\u0000".."\x10FFFF": UTF-8 encoded Unicode + // "\u0000".."\x10FFFF": UTF-8 encoded Unicode // // Note that although codes are entered like this (must have min. four digit, // just to tease you!) the actual outcome in the string will vary between @@ -482,20 +484,22 @@ static int llex (LexState *ls, SemInfo *seminfo) { else if (sep == -1) return '['; else luaX_lexerror(ls, "invalid long string delimiter", TK_STRING); } + /* FALLTHRU */ case '=': { next(ls); if (ls->current != '=') return '='; else { next(ls); return TK_EQ; } } + /* FALLTHRU */ case '<': { next(ls); - if (ls->current == '<') { next(ls); return TK_SHL; } + if (ls->current == '<') { next(ls); return TK_SHL; } if (ls->current != '=') return '<'; else { next(ls); return TK_LE; } } case '>': { next(ls); - if (ls->current == '>') { next(ls); return TK_SHR; } + if (ls->current == '>') { next(ls); return TK_SHR; } if (ls->current != '=') return '>'; else { next(ls); return TK_GE; } } @@ -547,9 +551,10 @@ static int llex (LexState *ls, SemInfo *seminfo) { } case '\\': if (ls->refstr) { ls->refstr--; - ls->current = '"'; /* whacky! */ - return TK_CONCAT; + ls->current = '"'; /* whacky! */ + return TK_CONCAT; } + /* FALLTHRU */ default: { if (isspace(ls->current)) { lua_assert(!currIsNewline(ls)); diff --git a/src/blua/ltable.c b/src/blua/ltable.c index 9f4d91ff..0ddd9ef4 100644 --- a/src/blua/ltable.c +++ b/src/blua/ltable.c @@ -478,6 +478,7 @@ static TValue *newkey (lua_State *L, Table *t, const TValue *key) { return luaH_getnum(t, k); /* use specialized version */ /* else go through */ } + /* FALLTHRU */ default: { Node *n = mainposition(t, key); do { /* check whether `key' is somewhere in the chain */ diff --git a/src/command.c b/src/command.c index 758157a8..bc1750eb 100644 --- a/src/command.c +++ b/src/command.c @@ -1188,7 +1188,10 @@ finish: CONS_Printf(M_GetText("%s set to %s\n"), var->name, var->string); var->flags &= ~CV_SHOWMODIFONETIME; } - DEBFILE(va("%s set to %s\n", var->name, var->string)); + else // display message in debug file only + { + DEBFILE(va("%s set to %s\n", var->name, var->string)); + } var->flags |= CV_MODIFIED; // raise 'on change' code #ifdef HAVE_BLUA diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 569b63b2..95e74469 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -51,7 +51,7 @@ #endif #ifdef _XBOX -#include "sdl/SRB2XBOX/xboxhelp.h" +#include "sdl12/SRB2XBOX/xboxhelp.h" #endif // @@ -1748,9 +1748,7 @@ static boolean CL_ServerConnectionSearchTicker(boolean viams, tic_t *asksent) { #ifndef NONET INT32 i; -#endif -#ifndef NONET // serverlist is updated by GetPacket function if (serverlistcount > 0) { @@ -1784,7 +1782,20 @@ static boolean CL_ServerConnectionSearchTicker(boolean viams, tic_t *asksent) serverlist[i].info.fileneeded); CONS_Printf(M_GetText("Checking files...\n")); i = CL_CheckFiles(); - if (i == 2) // cannot join for some reason + if (i == 3) // too many files + { + D_QuitNetGame(); + CL_Reset(); + D_StartTitle(); + M_StartMessage(M_GetText( + "You have too many WAD files loaded\n" + "to add ones the server is using.\n" + "Please restart SRB2 before connecting.\n\n" + "Press ESC\n" + ), NULL, MM_NOTHING); + return false; + } + else if (i == 2) // cannot join for some reason { D_QuitNetGame(); CL_Reset(); @@ -1887,6 +1898,7 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic break; // exit the case cl_mode = CL_ASKJOIN; // don't break case continue to cljoin request now + /* FALLTHRU */ case CL_ASKJOIN: CL_LoadServerFiles(); @@ -2529,12 +2541,18 @@ static void Command_Nodes(void) static void Command_Ban(void) { - if (COM_Argc() == 1) + if (COM_Argc() < 2) { CONS_Printf(M_GetText("Ban : ban and kick a player\n")); return; } + if (!netgame) // Don't kick Tails in splitscreen! + { + CONS_Printf(M_GetText("This only works in a netgame.\n")); + return; + } + if (server || adminplayer == consoleplayer) { XBOXSTATIC UINT8 buf[3 + MAX_REASONLENGTH]; @@ -2544,8 +2562,9 @@ static void Command_Ban(void) if (pn == -1 || pn == 0) return; - else - WRITEUINT8(p, pn); + + WRITEUINT8(p, pn); + if (server && I_Ban && !I_Ban(node)) // only the server is allowed to do this right now { CONS_Alert(CONS_WARNING, M_GetText("Too many bans! Geez, that's a lot of people you're excluding...\n")); @@ -2588,21 +2607,27 @@ static void Command_Ban(void) static void Command_Kick(void) { - XBOXSTATIC UINT8 buf[3 + MAX_REASONLENGTH]; - UINT8 *p = buf; - - if (COM_Argc() == 1) + if (COM_Argc() < 2) { CONS_Printf(M_GetText("kick : kick a player\n")); return; } + if (!netgame) // Don't kick Tails in splitscreen! + { + CONS_Printf(M_GetText("This only works in a netgame.\n")); + return; + } + if (server || adminplayer == consoleplayer) { + XBOXSTATIC UINT8 buf[3 + MAX_REASONLENGTH]; + UINT8 *p = buf; const SINT8 pn = nametonum(COM_Argv(1)); - WRITESINT8(p, pn); + if (pn == -1 || pn == 0) return; + // Special case if we are trying to kick a player who is downloading the game state: // trigger a timeout instead of kicking them, because a kick would only // take effect after they have finished downloading @@ -2611,6 +2636,9 @@ static void Command_Kick(void) Net_ConnectionTimeout(playernode[pn]); return; } + + WRITESINT8(p, pn); + if (COM_Argc() == 2) { WRITEUINT8(p, KICK_MSG_GO_AWAY); @@ -3417,17 +3445,42 @@ static void HandlePacketFromAwayNode(SINT8 node) if (node != servernode) DEBFILE(va("Received packet from unknown host %d\n", node)); +// macro for packets that should only be sent by the server +// if it is NOT from the server, bail out and close the connection! +#define SERVERONLY \ + if (node != servernode) \ + { \ + Net_CloseConnection(node); \ + break; \ + } switch (netbuffer->packettype) { case PT_ASKINFOVIAMS: +#if 0 if (server && serverrunning) { - INT32 clientnode = I_NetMakeNode(netbuffer->u.msaskinfo.clientaddr); - SV_SendServerInfo(clientnode, (tic_t)LONG(netbuffer->u.msaskinfo.time)); - SV_SendPlayerInfo(clientnode); // Send extra info - Net_CloseConnection(clientnode); - // Don't close connection to MS. + INT32 clientnode; + if (ms_RoomId < 0) // ignore if we're not actually on the MS right now + { + Net_CloseConnection(node); // and yes, close connection + return; + } + clientnode = I_NetMakeNode(netbuffer->u.msaskinfo.clientaddr); + if (clientnode != -1) + { + SV_SendServerInfo(clientnode, (tic_t)LONG(netbuffer->u.msaskinfo.time)); + SV_SendPlayerInfo(clientnode); // Send extra info + Net_CloseConnection(clientnode); + // Don't close connection to MS... + } + else + Net_CloseConnection(node); // ...unless the IP address is not valid } + else + Net_CloseConnection(node); // you're not supposed to get it, so ignore it +#else + Net_CloseConnection(node); +#endif break; case PT_ASKINFO: @@ -3435,8 +3488,8 @@ static void HandlePacketFromAwayNode(SINT8 node) { SV_SendServerInfo(node, (tic_t)LONG(netbuffer->u.askinfo.time)); SV_SendPlayerInfo(node); // Send extra info - Net_CloseConnection(node); } + Net_CloseConnection(node); break; case PT_SERVERREFUSE: // Negative response of client join request @@ -3445,6 +3498,7 @@ static void HandlePacketFromAwayNode(SINT8 node) Net_CloseConnection(node); break; } + SERVERONLY if (cl_mode == CL_WAITJOINRESPONSE) { // Save the reason so it can be displayed after quitting the netgame @@ -3476,6 +3530,7 @@ static void HandlePacketFromAwayNode(SINT8 node) Net_CloseConnection(node); break; } + SERVERONLY /// \note how would this happen? and is it doing the right thing if it does? if (cl_mode != CL_WAITJOINRESPONSE) break; @@ -3539,13 +3594,18 @@ static void HandlePacketFromAwayNode(SINT8 node) Net_CloseConnection(node); break; } - else - Got_Filetxpak(); + SERVERONLY + Got_Filetxpak(); break; case PT_REQUESTFILE: if (server) - Got_RequestFilePak(node); + { + if (!cv_downloading.value || !Got_RequestFilePak(node)) + Net_CloseConnection(node); // close connection if one of the requested files could not be sent, or you disabled downloading anyway + } + else + Net_CloseConnection(node); // nope break; case PT_NODETIMEOUT: @@ -3561,6 +3621,7 @@ static void HandlePacketFromAwayNode(SINT8 node) // Do not remove my own server (we have just get a out of order packet) if (node == servernode) break; + /* FALLTHRU */ default: DEBFILE(va("unknown packet received (%d) from unknown host\n",netbuffer->packettype)); @@ -3568,6 +3629,7 @@ static void HandlePacketFromAwayNode(SINT8 node) break; // Ignore it } +#undef SERVERONLY } /** Handles a packet received from a node that is in game @@ -3600,6 +3662,8 @@ FILESTAMP { // -------------------------------------------- SERVER RECEIVE ---------- case PT_RESYNCHGET: + if (client) + break; SV_AcknowledgeResynchAck(netconsole, netbuffer->u.resynchgot); break; case PT_CLIENTCMD: @@ -3666,7 +3730,8 @@ FILESTAMP } // Splitscreen cmd - if (netbuffer->packettype == PT_CLIENT2CMD && nodetoplayer2[node] >= 0) + if ((netbuffer->packettype == PT_CLIENT2CMD || netbuffer->packettype == PT_CLIENT2MIS) + && nodetoplayer2[node] >= 0) G_MoveTiccmd(&netcmds[maketic%BACKUPTICS][(UINT8)nodetoplayer2[node]], &netbuffer->u.client2pak.cmd2, 1); @@ -3713,6 +3778,7 @@ FILESTAMP break; case PT_TEXTCMD2: // splitscreen special netconsole = nodetoplayer2[node]; + /* FALLTHRU */ case PT_TEXTCMD: if (client) break; @@ -3725,6 +3791,27 @@ FILESTAMP tic_t tic = maketic; UINT8 *textcmd; + // ignore if the textcmd has a reported size of zero + // this shouldn't be sent at all + if (!netbuffer->u.textcmd[0]) + { + DEBFILE(va("GetPacket: Textcmd with size 0 detected! (node %u, player %d)\n", + node, netconsole)); + Net_UnAcknowledgePacket(node); + break; + } + + // ignore if the textcmd size var is actually larger than it should be + // BASEPACKETSIZE + 1 (for size) + textcmd[0] should == datalength + if (netbuffer->u.textcmd[0] > (size_t)doomcom->datalength-BASEPACKETSIZE-1) + { + DEBFILE(va("GetPacket: Bad Textcmd packet size! (expected %d, actual %s, node %u, player %d)\n", + netbuffer->u.textcmd[0], sizeu1((size_t)doomcom->datalength-BASEPACKETSIZE-1), + node, netconsole)); + Net_UnAcknowledgePacket(node); + break; + } + // check if tic that we are making isn't too large else we cannot send it :( // doomcom->numslots+1 "+1" since doomcom->numslots can change within this time and sent time j = software_MAXPACKETLENGTH @@ -3918,7 +4005,7 @@ FILESTAMP if (client) { INT32 i; - for (i = 0; i < MAXNETNODES; i++) + for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i]) playerpingtable[i] = (tic_t)netbuffer->u.pingtable[i]; } @@ -3928,6 +4015,21 @@ FILESTAMP case PT_SERVERCFG: break; case PT_FILEFRAGMENT: + // Only accept PT_FILEFRAGMENT from the server. + if (node != servernode) + { + CONS_Alert(CONS_WARNING, M_GetText("%s received from non-host %d\n"), "PT_FILEFRAGMENT", node); + + if (server) + { + XBOXSTATIC UINT8 buf[2]; + buf[0] = (UINT8)node; + buf[1] = KICK_MSG_CON_FAIL; + SendNetXCmd(XD_KICK, &buf, 2); + } + + break; + } if (client) Got_Filetxpak(); break; @@ -4031,7 +4133,10 @@ static INT16 Consistancy(void) #ifdef MOBJCONSISTANCY if (!thinkercap.next) + { + DEBFILE(va("Consistancy = %u\n", ret)); return ret; + } for (th = thinkercap.next; th != &thinkercap; th = th->next) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) @@ -4100,6 +4205,8 @@ static INT16 Consistancy(void) } #endif + DEBFILE(va("Consistancy = %u\n", (ret & 0xFFFF))); + return (INT16)(ret & 0xFFFF); } @@ -4461,8 +4568,8 @@ static inline void PingUpdate(void) } //send out our ping packets - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) + for (i = 0; i < MAXNETNODES; i++) + if (nodeingame[i]) HSendPacket(i, true, 0, sizeof(INT32) * MAXPLAYERS); pingmeasurecount = 1; //Reset count @@ -4492,20 +4599,15 @@ void NetUpdate(void) gametime = nowtime; - if (!(gametime % 255) && netgame && server) - { -#ifdef NEWPING - PingUpdate(); -#endif - } - #ifdef NEWPING if (server) { + if (netgame && !(gametime % 255)) + PingUpdate(); // update node latency values so we can take an average later. - for (i = 0; i < MAXNETNODES; i++) + for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i]) - realpingtable[i] += G_TicsToMilliseconds(GetLag(i)); + realpingtable[i] += G_TicsToMilliseconds(GetLag(playernode[i])); pingmeasurecount++; } #endif diff --git a/src/d_main.c b/src/d_main.c index f44c3f6d..2ac28b32 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -82,7 +82,7 @@ int snprintf(char *str, size_t n, const char *fmt, ...); #endif #ifdef _XBOX -#include "sdl/SRB2XBOX/xboxhelp.h" +#include "sdl12/SRB2XBOX/xboxhelp.h" #endif #ifdef HWRENDER diff --git a/src/d_net.c b/src/d_net.c index 70cdc5f1..643c41ac 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -711,6 +711,13 @@ void Net_CloseConnection(INT32 node) #else INT32 i; boolean forceclose = (node & FORCECLOSE) != 0; + + if (node == -1) + { + DEBFILE(M_GetText("Net_CloseConnection: node -1 detected!\n")); + return; // nope, just ignore it + } + node &= ~FORCECLOSE; if (!node) @@ -718,7 +725,7 @@ void Net_CloseConnection(INT32 node) if (node < 0 || node >= MAXNETNODES) // prevent invalid nodes from crashing the game { - CONS_Alert(CONS_WARNING, M_GetText("Net_CloseConnection: invalid node %d detected!\n"), node); + DEBFILE(va(M_GetText("Net_CloseConnection: invalid node %d detected!\n"), node)); return; } @@ -1021,6 +1028,7 @@ boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlen #endif return false; } + netbuffer->ack = netbuffer->ackreturn = 0; // don't hold over values from last packet sent/received M_Memcpy(&reboundstore[rebound_head], netbuffer, doomcom->datalength); reboundsize[rebound_head] = doomcom->datalength; @@ -1356,7 +1364,7 @@ boolean D_CheckNetGame(void) #else if (M_CheckParm("-debugfile")) { - char filename[20]; + char filename[21]; INT32 k = doomcom->consoleplayer - 1; if (M_IsNextParm()) k = atoi(M_GetNextParm()) - 1; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 1ef525e3..8093758d 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1606,8 +1606,13 @@ void D_MapChange(INT32 mapnum, INT32 newgametype, boolean pultmode, boolean rese mapchangepending = 0; // spawn the server if needed // reset players if there is a new one - if (!(adminplayer == consoleplayer) && SV_SpawnServer()) - buf[0] &= ~(1<<1); + if (!(adminplayer == consoleplayer)) + { + if (SV_SpawnServer()) + buf[0] &= ~(1<<1); + if (!Playing()) // you failed to start a server somehow, so cancel the map change + return; + } // Kick bot from special stages if (botskin) @@ -2485,7 +2490,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) error = true; break; } - //fall down + /* FALLTHRU */ case GT_TAG: switch (NetPacket.packet.newteam) { @@ -3115,7 +3120,13 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) filestatus_t ncs = FS_NOTFOUND; UINT8 md5sum[16]; boolean kick = false; + boolean toomany = false; INT32 i; + size_t packetsize = 0; + serverinfo_pak *dummycheck = NULL; + + // Shut the compiler up. + (void)dummycheck; READSTRINGN(*cp, filename, 240); READMEM(*cp, md5sum, 16); @@ -3141,13 +3152,25 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) return; } - ncs = findfile(filename,md5sum,true); + // See W_LoadWadFile in w_wad.c + for (i = 0; i < numwadfiles; i++) + packetsize += nameonlylength(wadfiles[i]->filename) + 22; - if (ncs != FS_FOUND) + packetsize += nameonlylength(filename) + 22; + + if ((numwadfiles >= MAX_WADFILES) + || (packetsize > sizeof(dummycheck->fileneeded))) + toomany = true; + else + ncs = findfile(filename,md5sum,true); + + if (ncs != FS_FOUND || toomany) { char message[256]; - if (ncs == FS_NOTFOUND) + if (toomany) + sprintf(message, M_GetText("Too many files loaded to add %s\n"), filename); + else if (ncs == FS_NOTFOUND) sprintf(message, M_GetText("The server doesn't have %s\n"), filename); else if (ncs == FS_MD5SUMBAD) sprintf(message, M_GetText("Checksum mismatch on %s\n"), filename); @@ -3217,10 +3240,15 @@ static void Got_Addfilecmd(UINT8 **cp, INT32 playernum) ncs = findfile(filename,md5sum,true); - if (ncs != FS_FOUND) + if (ncs != FS_FOUND || !P_AddWadFile(filename, NULL)) { Command_ExitGame_f(); - if (ncs == FS_NOTFOUND) + if (ncs == FS_FOUND) + { + CONS_Printf(M_GetText("The server tried to add %s,\nbut you have too many files added.\nRestart the game to clear loaded files\nand play on this server."), filename); + M_StartMessage(va("The server added a file \n(%s)\nbut you have too many files added.\nRestart the game to clear loaded files.\n\nPress ESC\n",filename), NULL, MM_NOTHING); + } + else if (ncs == FS_NOTFOUND) { CONS_Printf(M_GetText("The server tried to add %s,\nbut you don't have this file.\nYou need to find it in order\nto play on this server."), filename); M_StartMessage(va("The server added a file \n(%s)\nthat you do not have.\n\nPress ESC\n",filename), NULL, MM_NOTHING); @@ -3238,7 +3266,6 @@ static void Got_Addfilecmd(UINT8 **cp, INT32 playernum) return; } - P_AddWadFile(filename, NULL); G_SetGameModified(true); } diff --git a/src/d_netfil.c b/src/d_netfil.c index bf4e5987..172624ad 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -62,7 +62,8 @@ #include -static void SV_SendFile(INT32 node, const char *filename, UINT8 fileid); +// Prototypes +static boolean SV_SendFile(INT32 node, const char *filename, UINT8 fileid); // Sender structure typedef struct filetx_s @@ -303,7 +304,8 @@ boolean CL_SendRequestFile(void) } // get request filepak and put it on the send queue -void Got_RequestFilePak(INT32 node) +// returns false if a requested file was not found or cannot be sent +boolean Got_RequestFilePak(INT32 node) { char wad[MAX_WADPATH+1]; UINT8 *p = netbuffer->u.textcmd; @@ -314,8 +316,13 @@ void Got_RequestFilePak(INT32 node) if (id == 0xFF) break; READSTRINGN(p, wad, MAX_WADPATH); - SV_SendFile(node, wad, id); + if (!SV_SendFile(node, wad, id)) + { + SV_AbortSendFiles(node); + return false; // don't read the rest of the files + } } + return true; // no problems with any files } /** Checks if the files needed aren't already loaded or on the disk @@ -330,6 +337,12 @@ INT32 CL_CheckFiles(void) INT32 i, j; char wadfilename[MAX_WADPATH]; INT32 ret = 1; + size_t packetsize = 0; + size_t filestoget = 0; + serverinfo_pak *dummycheck = NULL; + + // Shut the compiler up. + (void)dummycheck; // if (M_CheckParm("-nofiles")) // return 1; @@ -378,6 +391,10 @@ INT32 CL_CheckFiles(void) return 1; } + // See W_LoadWadFile in w_wad.c + for (i = 0; i < numwadfiles; i++) + packetsize += nameonlylength(wadfiles[i]->filename) + 22; + for (i = 1; i < fileneedednum; i++) { CONS_Debug(DBG_NETPLAY, "searching for '%s' ", fileneeded[i].filename); @@ -397,6 +414,14 @@ INT32 CL_CheckFiles(void) if (fileneeded[i].status != FS_NOTFOUND || !fileneeded[i].important) continue; + packetsize += nameonlylength(fileneeded[i].filename) + 22; + + if ((numwadfiles+filestoget >= MAX_WADFILES) + || (packetsize > sizeof(dummycheck->fileneeded))) + 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) @@ -480,7 +505,7 @@ static INT32 filestosend = 0; * \sa SV_SendRam * */ -static void SV_SendFile(INT32 node, const char *filename, UINT8 fileid) +static boolean SV_SendFile(INT32 node, const char *filename, 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 @@ -488,7 +513,7 @@ static void SV_SendFile(INT32 node, const char *filename, UINT8 fileid) char wadfilename[MAX_WADPATH]; if (cv_noticedownload.value) - CONS_Printf("Sending file \"%s\" to node %d\n", filename, node); + CONS_Printf("Sending file \"%s\" to node %d (%s)\n", filename, node, I_GetNodeAddress(node)); // Find the last file in the list and set a pointer to its "next" field q = &transfer[node].txlist; @@ -537,7 +562,7 @@ static void SV_SendFile(INT32 node, const char *filename, UINT8 fileid) free(p->id.filename); free(p); *q = NULL; - return; + return false; // cancel the rest of the requests } // Handle huge file requests (i.e. bigger than cv_maxsend.value KB) @@ -549,7 +574,7 @@ static void SV_SendFile(INT32 node, const char *filename, UINT8 fileid) free(p->id.filename); free(p); *q = NULL; - return; + return false; // cancel the rest of the requests } DEBFILE(va("Sending file %s (id=%d) to %d\n", filename, fileid, node)); @@ -557,6 +582,7 @@ static void SV_SendFile(INT32 node, const char *filename, UINT8 fileid) p->fileid = fileid; p->next = NULL; // End of list filestosend++; + return true; } /** Adds a memory block to the file list for a node diff --git a/src/d_netfil.h b/src/d_netfil.h index c9085a5b..b9b7b2f2 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -69,7 +69,7 @@ boolean SV_SendingFile(INT32 node); boolean CL_CheckDownloadable(void); boolean CL_SendRequestFile(void); -void Got_RequestFilePak(INT32 node); +boolean Got_RequestFilePak(INT32 node); void SV_AbortSendFiles(INT32 node); void CloseNetFile(void); diff --git a/src/dehacked.c b/src/dehacked.c index 4d1cd41b..3d024955 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -11,6 +11,7 @@ /// \brief Load dehacked file and change tables and text #include "doomdef.h" +#include "d_main.h" // for srb2home #include "g_game.h" #include "sounds.h" #include "info.h" @@ -3081,6 +3082,8 @@ static void readmaincfg(MYFILE *f) strncpy(savegamename, timeattackfolder, sizeof (timeattackfolder)); strlcat(savegamename, "%u.ssg", sizeof(savegamename)); + // can't use sprintf since there is %u in savegamename + strcatbf(savegamename, srb2home, PATHSEP); gamedataadded = true; } diff --git a/src/doomdef.h b/src/doomdef.h index 53442ac2..49af9a9f 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -536,4 +536,8 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// \note You should leave this enabled unless you're working with a future SRB2 version. #define MUSICSLOT_COMPATIBILITY +/// Handle touching sector specials in P_PlayerAfterThink instead of P_PlayerThink. +/// \note Required for proper collision with moving sloped surfaces that have sector specials on them. +#define SECTORSPECIALSAFTERTHINK + #endif // __DOOMDEF__ diff --git a/src/f_wipe.c b/src/f_wipe.c index a0b685a3..e45f2e85 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -94,7 +94,7 @@ static fixed_t paldiv; * \return fademask_t for lump */ static fademask_t *F_GetFadeMask(UINT8 masknum, UINT8 scrnnum) { - static char lumpname[9] = "FADEmmss"; + static char lumpname[10] = "FADEmmss"; static fademask_t fm = {NULL,0,0,0,0,0}; lumpnum_t lumpnum; UINT8 *lump, *mask; diff --git a/src/filesrch.c b/src/filesrch.c index acc176d6..2463e717 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -22,7 +22,7 @@ #include #endif #ifdef _WIN32_WCE -#include "sdl/SRB2CE/cehelp.h" +#include "sdl12/SRB2CE/cehelp.h" #else #include #endif diff --git a/src/g_game.c b/src/g_game.c index 104159c0..da3c91cf 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -717,7 +717,7 @@ void G_SetGameModified(boolean silent) */ const char *G_BuildMapName(INT32 map) { - static char mapname[9] = "MAPXX"; // internal map name (wad resource name) + static char mapname[10] = "MAPXX"; // internal map name (wad resource name) I_Assert(map > 0); I_Assert(map <= NUMMAPS); @@ -2420,6 +2420,9 @@ void G_SpawnPlayer(INT32 playernum, boolean starpost) if (starpost) //Don't even bother with looking for a place to spawn. { P_MovePlayerToStarpost(playernum); +#ifdef HAVE_BLUA + LUAh_PlayerSpawn(&players[playernum]); // Lua hook for player spawning :) +#endif return; } @@ -4009,7 +4012,7 @@ void G_GhostAddColor(ghostcolor_t color) ghostext.color = (UINT8)color; } -void G_GhostAddScale(UINT16 scale) +void G_GhostAddScale(fixed_t scale) { if (!demorecording || !(demoflags & DF_GHOST)) return; diff --git a/src/g_game.h b/src/g_game.h index 6d412551..ada82404 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -139,7 +139,7 @@ void G_GhostAddSpin(void); void G_GhostAddRev(void); void G_GhostAddColor(ghostcolor_t color); void G_GhostAddFlip(void); -void G_GhostAddScale(UINT16 scale); +void G_GhostAddScale(fixed_t scale); void G_GhostAddHit(mobj_t *victim); void G_WriteGhostTic(mobj_t *ghost); void G_ConsGhostTic(void); diff --git a/src/hardware/hw_data.h b/src/hardware/hw_data.h index a6525a2f..d76fcc1c 100644 --- a/src/hardware/hw_data.h +++ b/src/hardware/hw_data.h @@ -64,7 +64,7 @@ typedef struct GLMipmap_s GLMipmap_t; // struct GLTexture_s { - GLMipmap_t mipmap; + GLMipmap_t mipmap; float scaleX; //used for scaling textures on walls float scaleY; }; @@ -88,7 +88,7 @@ struct GLPatch_s UINT16 wadnum; // the software patch lump num for when the hardware patch UINT16 lumpnum; // was flushed, and we need to re-create it GLMipmap_t mipmap; -} ATTRPACK; +}; typedef struct GLPatch_s GLPatch_t; #endif //_HWR_DATA_ diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index a40a2827..15753fb4 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1084,9 +1084,9 @@ static void HWR_SplitWall(sector_t *sector, wallVert3D *wallVerts, INT32 texnum, float endheight = 0.0f, endbheight = 0.0f; fixed_t v1x = FLOAT_TO_FIXED(wallVerts[0].x); - fixed_t v1y = FLOAT_TO_FIXED(wallVerts[0].y); + fixed_t v1y = FLOAT_TO_FIXED(wallVerts[0].z); // not a typo fixed_t v2x = FLOAT_TO_FIXED(wallVerts[1].x); - fixed_t v2y = FLOAT_TO_FIXED(wallVerts[1].y); + fixed_t v2y = FLOAT_TO_FIXED(wallVerts[1].z); // not a typo // compiler complains when P_GetZAt is used in FLOAT_TO_FIXED directly // use this as a temp var to store P_GetZAt's return value each time fixed_t temp; @@ -3722,6 +3722,9 @@ static void HWR_Subsector(size_t num) while (count--) { +#ifdef POLYOBJECTS + if (!line->polyseg) // ignore segs that belong to polyobjects +#endif HWR_AddLine(line); line++; } diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 3a0bf705..e6ff83e8 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -244,6 +244,7 @@ FUNCPRINTF void DBG_Printf(const char *lpFmt, ...) #define pglMaterialfv glMaterialfv /* Raster functions */ +#define pglPixelStorei glPixelStorei #define pglReadPixels glReadPixels /* Texture mapping */ @@ -262,15 +263,8 @@ FUNCPRINTF void DBG_Printf(const char *lpFmt, ...) /* texture mapping */ //GL_EXT_copy_texture #ifndef KOS_GL_COMPATIBILITY #define pglCopyTexImage2D glCopyTexImage2D +#endif -/* GLU functions */ -#define pgluBuild2DMipmaps gluBuild2DMipmaps -#endif -#ifndef MINI_GL_COMPATIBILITY -/* 1.3 functions for multitexturing */ -#define pglActiveTexture glActiveTexture -#define pglMultiTexCoord2f glMultiTexCoord2f -#endif #else //!STATIC_OPENGL /* 1.0 functions */ @@ -365,6 +359,8 @@ typedef void (APIENTRY * PFNglMaterialfv) (GLint face, GLenum pname, GLfloat *pa static PFNglMaterialfv pglMaterialfv; /* Raster functions */ +typedef void (APIENTRY * PFNglPixelStorei) (GLenum pname, GLint param); +static PFNglPixelStorei pglPixelStorei; typedef void (APIENTRY * PFNglReadPixels) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); static PFNglReadPixels pglReadPixels; @@ -391,7 +387,7 @@ static PFNglBindTexture pglBindTexture; /* texture mapping */ //GL_EXT_copy_texture typedef void (APIENTRY * PFNglCopyTexImage2D) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); static PFNglCopyTexImage2D pglCopyTexImage2D; - +#endif /* GLU functions */ typedef GLint (APIENTRY * PFNgluBuild2DMipmaps) (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *data); static PFNgluBuild2DMipmaps pgluBuild2DMipmaps; @@ -403,7 +399,6 @@ static PFNglActiveTexture pglActiveTexture; typedef void (APIENTRY *PFNglMultiTexCoord2f) (GLenum, GLfloat, GLfloat); static PFNglMultiTexCoord2f pglMultiTexCoord2f; #endif -#endif #ifndef MINI_GL_COMPATIBILITY /* 1.2 Parms */ @@ -494,6 +489,7 @@ boolean SetupGLfunc(void) GETOPENGLFUNC(pglLightModelfv , glLightModelfv) GETOPENGLFUNC(pglMaterialfv , glMaterialfv) + GETOPENGLFUNC(pglPixelStorei , glPixelStorei) GETOPENGLFUNC(pglReadPixels , glReadPixels) GETOPENGLFUNC(pglTexEnvi , glTexEnvi) @@ -519,35 +515,23 @@ boolean SetupGLfunc(void) // This has to be done after the context is created so the version number can be obtained boolean SetupGLFunc13(void) { +#ifdef MINI_GL_COMPATIBILITY + return false; +#else const GLubyte *version = pglGetString(GL_VERSION); int glmajor, glminor; gl13 = false; -#ifdef MINI_GL_COMPATIBILITY - return false; -#else -#ifdef STATIC_OPENGL - gl13 = true; -#else - // Parse the GL version if (version != NULL) { if (sscanf((const char*)version, "%d.%d", &glmajor, &glminor) == 2) { // Look, we gotta prepare for the inevitable arrival of GL 2.0 code... - switch (glmajor) - { - case 1: - if (glminor == 3) gl13 = true; - break; - case 2: - case 3: - case 4: - gl13 = true; - default: - break; - } + if (glmajor == 1 && glminor >= 3) + gl13 = true; + else if (glmajor > 1) + gl13 = true; } } @@ -568,9 +552,6 @@ boolean SetupGLFunc13(void) } else DBG_Printf("GL_ARB_multitexture support: disabled\n"); -#undef GETOPENGLFUNC - -#endif return true; #endif } @@ -897,7 +878,9 @@ EXPORT void HWRAPI(ReadRect) (INT32 x, INT32 y, INT32 width, INT32 height, GLubyte*top = (GLvoid*)dst_data, *bottom = top + dst_stride * (height - 1); GLubyte *row = malloc(dst_stride); if (!row) return; + pglPixelStorei(GL_PACK_ALIGNMENT, 1); pglReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, dst_data); + pglPixelStorei(GL_UNPACK_ALIGNMENT, 1); for(i = 0; i < height/2; i++) { memcpy(row, top, dst_stride); @@ -913,7 +896,9 @@ EXPORT void HWRAPI(ReadRect) (INT32 x, INT32 y, INT32 width, INT32 height, INT32 j; GLubyte *image = malloc(width*height*3*sizeof (*image)); if (!image) return; + pglPixelStorei(GL_PACK_ALIGNMENT, 1); pglReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, image); + pglPixelStorei(GL_UNPACK_ALIGNMENT, 1); for (i = height-1; i >= 0; i--) { for (j = 0; j < width; j++) @@ -1815,13 +1800,11 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value) min_filter = GL_NEAREST; #endif } -#ifndef STATIC_OPENGL if (!pgluBuild2DMipmaps) { MipMap = GL_FALSE; min_filter = GL_LINEAR; } -#endif Flush(); //??? if we want to change filter mode by texture, remove this break; diff --git a/src/i_tcp.c b/src/i_tcp.c index c65a536a..5681a9d4 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -97,7 +97,7 @@ #include #ifdef _arch_dreamcast -#include "sdl/SRB2DC/dchelp.h" +#include "sdl12/SRB2DC/dchelp.h" #endif #if (defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON) @@ -192,7 +192,7 @@ static UINT8 UPNP_support = TRUE; #define close closesocket #ifdef _WIN32_WCE - #include "sdl/SRB2CE/cehelp.h" + #include "sdl12/SRB2CE/cehelp.h" #endif #endif diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index 28cc9176..566e7374 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -391,12 +391,21 @@ static int lib_cvRegisterVar(lua_State *L) // stack: cvar table, cvar userdata lua_getfield(L, LUA_REGISTRYINDEX, "CV_Vars"); I_Assert(lua_istable(L, 3)); + + lua_getfield(L, 3, cvar->name); + if (lua_type(L, -1) != LUA_TNIL) + return luaL_error(L, M_GetText("Variable %s is already defined\n"), cvar->name); + lua_pop(L, 1); + lua_pushvalue(L, 2); lua_setfield(L, 3, cvar->name); lua_pop(L, 1); // actually time to register it to the console now! Finally! + cvar->flags |= CV_MODIFIED; CV_RegisterVar(cvar); + if (cvar->flags & CV_MODIFIED) + return luaL_error(L, "failed to register cvar (probable conflict with internal variable/command names)"); // return cvar userdata return 1; diff --git a/src/lua_script.c b/src/lua_script.c index 42ca0507..9ba7ce7f 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -568,14 +568,14 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) { mobjinfo_t *info = *((mobjinfo_t **)lua_touserdata(gL, myindex)); WRITEUINT8(save_p, ARCH_MOBJINFO); - WRITEUINT8(save_p, info - mobjinfo); + WRITEUINT16(save_p, info - mobjinfo); break; } case ARCH_STATE: { state_t *state = *((state_t **)lua_touserdata(gL, myindex)); WRITEUINT8(save_p, ARCH_STATE); - WRITEUINT8(save_p, state - states); + WRITEUINT16(save_p, state - states); break; } case ARCH_MOBJ: diff --git a/src/lua_thinkerlib.c b/src/lua_thinkerlib.c index d5251425..aaa8435e 100644 --- a/src/lua_thinkerlib.c +++ b/src/lua_thinkerlib.c @@ -16,84 +16,118 @@ #include "lua_script.h" #include "lua_libs.h" +#define META_ITERATIONSTATE "iteration state" + static const char *const iter_opt[] = { "all", "mobj", NULL}; +static const actionf_p1 iter_funcs[] = { + NULL, + (actionf_p1)P_MobjThinker +}; + +struct iterationState { + actionf_p1 filter; + int next; +}; + +static int iterationState_gc(lua_State *L) +{ + struct iterationState *it = luaL_checkudata(L, -1, META_ITERATIONSTATE); + if (it->next != LUA_REFNIL) + { + luaL_unref(L, LUA_REGISTRYINDEX, it->next); + it->next = LUA_REFNIL; + } + return 0; +} + +#define push_thinker(th) {\ + if ((th)->function.acp1 == (actionf_p1)P_MobjThinker) \ + LUA_PushUserdata(L, (th), META_MOBJ); \ + else \ + lua_pushlightuserdata(L, (th)); \ +} + static int lib_iterateThinkers(lua_State *L) { - int state = luaL_checkoption(L, 1, "mobj", iter_opt); - - thinker_t *th = NULL; - actionf_p1 searchFunc; - const char *searchMeta; - + thinker_t *th = NULL, *next = NULL; + struct iterationState *it = luaL_checkudata(L, 1, META_ITERATIONSTATE); lua_settop(L, 2); - lua_remove(L, 1); // remove state now. - switch(state) + if (lua_isnil(L, 2)) + th = &thinkercap; + else if (lua_isuserdata(L, 2)) { - case 0: - searchFunc = NULL; - searchMeta = NULL; - break; - case 1: - default: - searchFunc = (actionf_p1)P_MobjThinker; - searchMeta = META_MOBJ; - break; + if (lua_islightuserdata(L, 2)) + th = lua_touserdata(L, 2); + else + { + th = *(thinker_t **)lua_touserdata(L, -1); + if (!th) + { + if (it->next == LUA_REFNIL) + return 0; + + lua_rawgeti(L, LUA_REGISTRYINDEX, it->next); + if (lua_islightuserdata(L, -1)) + next = lua_touserdata(L, -1); + else + next = *(thinker_t **)lua_touserdata(L, -1); + } + } } - if (!lua_isnil(L, 1)) { - if (lua_islightuserdata(L, 1)) - th = (thinker_t *)lua_touserdata(L, 1); - else if (searchMeta) - th = *((thinker_t **)luaL_checkudata(L, 1, searchMeta)); - else - th = *((thinker_t **)lua_touserdata(L, 1)); - } else - th = &thinkercap; + luaL_unref(L, LUA_REGISTRYINDEX, it->next); + it->next = LUA_REFNIL; - if (!th) // something got our userdata invalidated! - return 0; + if (th && !next) + next = th->next; + if (!next) + return luaL_error(L, "next thinker invalidated during iteration"); - if (searchFunc == NULL) - { - if ((th = th->next) != &thinkercap) + for (; next != &thinkercap; next = next->next) + if (!it->filter || next->function.acp1 == it->filter) { - if (th->function.acp1 == (actionf_p1)P_MobjThinker) - LUA_PushUserdata(L, th, META_MOBJ); - else - lua_pushlightuserdata(L, th); + push_thinker(next); + if (next->next != &thinkercap) + { + push_thinker(next->next); + it->next = luaL_ref(L, LUA_REGISTRYINDEX); + } return 1; } - return 0; - } - - for (th = th->next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != searchFunc) - continue; - - LUA_PushUserdata(L, th, searchMeta); - return 1; - } return 0; } static int lib_startIterate(lua_State *L) { - luaL_checkoption(L, 1, iter_opt[0], iter_opt); - lua_pushcfunction(L, lib_iterateThinkers); - lua_pushvalue(L, 1); + struct iterationState *it; + + lua_pushvalue(L, lua_upvalueindex(1)); + it = lua_newuserdata(L, sizeof(struct iterationState)); + luaL_getmetatable(L, META_ITERATIONSTATE); + lua_setmetatable(L, -2); + + it->filter = iter_funcs[luaL_checkoption(L, 1, "mobj", iter_opt)]; + it->next = LUA_REFNIL; return 2; } +#undef push_thinker + int LUA_ThinkerLib(lua_State *L) { + luaL_newmetatable(L, META_ITERATIONSTATE); + lua_pushcfunction(L, iterationState_gc); + lua_setfield(L, -2, "__gc"); + lua_pop(L, 1); + lua_createtable(L, 0, 1); - lua_pushcfunction(L, lib_startIterate); + lua_pushcfunction(L, lib_iterateThinkers); + lua_pushcclosure(L, lib_startIterate, 1); lua_setfield(L, -2, "iterate"); lua_setglobal(L, "thinkers"); return 0; diff --git a/src/m_fixed.h b/src/m_fixed.h index 1cf9abba..77382398 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -20,9 +20,10 @@ #include #endif -#ifdef _WIN32_WCE -#include "sdl/SRB2CE/cehelp.h" -#endif +// Was this just for the #define USEASM? +//#ifdef _WIN32_WCE +//#include "sdl12/SRB2CE/cehelp.h" +//#endif /*! \brief bits of the fraction diff --git a/src/m_menu.c b/src/m_menu.c index 306bb98b..73138e80 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3027,6 +3027,7 @@ static void M_DrawGenericMenu(void) W_CachePatchName(currentMenu->menuitems[i].patch, PU_CACHE)); } } + /* FALLTHRU */ case IT_NOTHING: case IT_DYBIGSPACE: y += LINEHEIGHT; @@ -3078,6 +3079,7 @@ static void M_DrawGenericMenu(void) break; case IT_STRING2: V_DrawString(x, y, 0, currentMenu->menuitems[i].text); + /* FALLTHRU */ case IT_DYLITLSPACE: y += SMALLLINEHEIGHT; break; @@ -3090,6 +3092,7 @@ static void M_DrawGenericMenu(void) case IT_TRANSTEXT: if (currentMenu->menuitems[i].alphaKey) y = currentMenu->y+currentMenu->menuitems[i].alphaKey; + /* FALLTHRU */ case IT_TRANSTEXT2: V_DrawString(x, y, V_TRANSLUCENT, currentMenu->menuitems[i].text); y += SMALLLINEHEIGHT; @@ -3302,6 +3305,7 @@ static void M_DrawCenteredMenu(void) W_CachePatchName(currentMenu->menuitems[i].patch, PU_CACHE)); } } + /* FALLTHRU */ case IT_NOTHING: case IT_DYBIGSPACE: y += LINEHEIGHT; @@ -3352,6 +3356,7 @@ static void M_DrawCenteredMenu(void) break; case IT_STRING2: V_DrawCenteredString(x, y, 0, currentMenu->menuitems[i].text); + /* FALLTHRU */ case IT_DYLITLSPACE: y += SMALLLINEHEIGHT; break; @@ -4625,7 +4630,7 @@ static void M_ReadSavegameInfo(UINT32 slot) savegameinfo[slot].botskin = 0; if (savegameinfo[slot].botskin) - snprintf(savegameinfo[slot].playername, 32, "%s & %s", + snprintf(savegameinfo[slot].playername, 36, "%s & %s", skins[savegameinfo[slot].skinnum].realname, skins[savegameinfo[slot].botskin-1].realname); else diff --git a/src/m_menu.h b/src/m_menu.h index 2ff1cea9..4d6e2fac 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -190,7 +190,7 @@ typedef struct // savegame struct for save game menu typedef struct { - char playername[32]; + char playername[37]; char levelname[32]; UINT8 actnum; UINT8 skincolor; diff --git a/src/m_misc.c b/src/m_misc.c index df3f2abb..0259e04b 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1080,7 +1080,7 @@ void M_StartMovie(void) moviemode = M_StartMovieGIF(pathname); break; } - // fall thru + /* FALLTHRU */ case MM_APNG: moviemode = M_StartMovieAPNG(pathname); break; diff --git a/src/mserv.c b/src/mserv.c index 339df853..78c42e55 100644 --- a/src/mserv.c +++ b/src/mserv.c @@ -65,7 +65,7 @@ #endif #ifdef _arch_dreamcast -#include "sdl/SRB2DC/dchelp.h" +#include "sdl12/SRB2DC/dchelp.h" #endif #include // timeval,... (TIMEOUT) @@ -92,7 +92,7 @@ #include "m_misc.h" // GetRevisionString() #ifdef _WIN32_WCE -#include "sdl/SRB2CE/cehelp.h" +#include "sdl12/SRB2CE/cehelp.h" #endif #include "i_addrinfo.h" diff --git a/src/p_ceilng.c b/src/p_ceilng.c index db30b5ca..27d73941 100644 --- a/src/p_ceilng.c +++ b/src/p_ceilng.c @@ -79,7 +79,7 @@ void T_MoveCeiling(ceiling_t *ceiling) P_LinedefExecute((INT16)(ceiling->texture + INT16_MAX + 2), NULL, NULL); if (ceiling->texture > -1) // flat changing ceiling->sector->ceilingpic = ceiling->texture; - // don't break + /* FALLTHRU */ case raiseToHighest: // case raiseCeilingByLine: case moveCeilingByFrontTexture: @@ -182,6 +182,7 @@ void T_MoveCeiling(ceiling_t *ceiling) // except generalized ones, reset speed, start back up case crushAndRaise: ceiling->speed = CEILSPEED; + /* FALLTHRU */ case fastCrushAndRaise: ceiling->direction = 1; break; @@ -200,6 +201,7 @@ void T_MoveCeiling(ceiling_t *ceiling) if (ceiling->texture > -1) // flat changing ceiling->sector->ceilingpic = ceiling->texture; // don't break + /* FALLTHRU */ // in all other cases, just remove the active ceiling case lowerAndCrush: @@ -427,6 +429,7 @@ INT32 EV_DoCeiling(line_t *line, ceiling_e type) case crushAndRaise: ceiling->crush = true; ceiling->topheight = sec->ceilingheight; + /* FALLTHRU */ case lowerAndCrush: ceiling->bottomheight = sec->floorheight; ceiling->bottomheight += 4*FRACUNIT; diff --git a/src/p_enemy.c b/src/p_enemy.c index c3cdafcd..6ab7d79b 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -4894,9 +4894,11 @@ void A_UnidusBall(mobj_t *actor) case 0: // at least one frame where not dashing if (!skull) ++actor->extravalue2; else break; + /* FALLTHRU */ case 1: // at least one frame where ARE dashing if (skull) ++actor->extravalue2; else break; + /* FALLTHRU */ case 2: // not dashing again? if (skull) break; // launch. @@ -6251,7 +6253,7 @@ void A_Boss7Chase(mobj_t *actor) break; } actor->threshold++; - // fall into... + /* FALLTHRU */ case 1: // Chaingun Goop A_FaceTarget(actor); P_SetMobjState(actor, S_BLACKEGG_SHOOT1); diff --git a/src/p_floor.c b/src/p_floor.c index 8af961c7..3695072d 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -313,6 +313,7 @@ void T_MoveFloor(floormove_t *movefloor) case moveFloorByFrontSector: if (movefloor->texture < -1) // chained linedef executing P_LinedefExecute((INT16)(movefloor->texture + INT16_MAX + 2), NULL, NULL); + /* FALLTHRU */ case instantMoveFloorByFrontSector: if (movefloor->texture > -1) // flat changing movefloor->sector->floorpic = movefloor->texture; @@ -361,6 +362,7 @@ void T_MoveFloor(floormove_t *movefloor) case moveFloorByFrontSector: if (movefloor->texture < -1) // chained linedef executing P_LinedefExecute((INT16)(movefloor->texture + INT16_MAX + 2), NULL, NULL); + /* FALLTHRU */ case instantMoveFloorByFrontSector: if (movefloor->texture > -1) // flat changing movefloor->sector->floorpic = movefloor->texture; @@ -2035,6 +2037,33 @@ foundenemy: P_RemoveThinker(&nobaddies->thinker); } +// +// P_IsObjectOnRealGround +// +// Helper function for T_EachTimeThinker +// Like P_IsObjectOnGroundIn, except ONLY THE REAL GROUND IS CONSIDERED, NOT FOFS +// I'll consider whether to make this a more globally accessible function or whatever in future +// -- Monster Iestyn +// +static boolean P_IsObjectOnRealGround(mobj_t *mo, sector_t *sec) +{ + // Is the object in reverse gravity? + if (mo->eflags & MFE_VERTICALFLIP) + { + // Detect if the player is on the ceiling. + if (mo->z+mo->height >= P_GetSpecialTopZ(mo, sec, sec)) + return true; + } + // Nope! + else + { + // Detect if the player is on the floor. + if (mo->z <= P_GetSpecialBottomZ(mo, sec, sec)) + return true; + } + return false; +} + // // P_HavePlayersEnteredArea // @@ -2087,6 +2116,7 @@ void T_EachTimeThinker(levelspecthink_t *eachtime) boolean inAndOut = false; boolean floortouch = false; fixed_t bottomheight, topheight; + msecnode_t *node; for (i = 0; i < MAXPLAYERS; i++) { @@ -2148,7 +2178,23 @@ void T_EachTimeThinker(levelspecthink_t *eachtime) if ((netgame || multiplayer) && players[j].spectator) continue; - if (players[j].mo->subsector->sector != targetsec) + if (players[j].mo->subsector->sector == targetsec) + ; + else if (sec->flags & SF_TRIGGERSPECIAL_TOUCH) + { + boolean insector = false; + for (node = players[j].mo->touching_sectorlist; node; node = node->m_sectorlist_next) + { + if (node->m_sector == targetsec) + { + insector = true; + break; + } + } + if (!insector) + continue; + } + else continue; topheight = P_GetSpecialTopZ(players[j].mo, sec, targetsec); @@ -2198,10 +2244,30 @@ void T_EachTimeThinker(levelspecthink_t *eachtime) if ((netgame || multiplayer) && players[i].spectator) continue; - if (players[i].mo->subsector->sector != sec) + if (players[i].mo->subsector->sector == sec) + ; + else if (sec->flags & SF_TRIGGERSPECIAL_TOUCH) + { + boolean insector = false; + for (node = players[i].mo->touching_sectorlist; node; node = node->m_sectorlist_next) + { + if (node->m_sector == sec) + { + insector = true; + break; + } + } + if (!insector) + continue; + } + else continue; - if (floortouch == true && P_IsObjectOnGroundIn(players[i].mo, sec)) + if (!(players[i].mo->subsector->sector == sec + || P_PlayerTouchingSectorSpecial(&players[i], 2, (GETSECSPECIAL(sec->special, 2))) == sec)) + continue; + + if (floortouch == true && P_IsObjectOnRealGround(players[i].mo, sec)) { if (i & 1) eachtime->var2s[i/2] |= 1; diff --git a/src/p_inter.c b/src/p_inter.c index 07382c69..13546ad7 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -400,9 +400,11 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) case MT_REDTEAMRING: if (player->ctfteam != 1) return; + /* FALLTHRU */ case MT_BLUETEAMRING: // Yes, I'm lazy. Oh well, deal with it. if (special->type == MT_BLUETEAMRING && player->ctfteam != 2) return; + /* FALLTHRU */ case MT_RING: case MT_FLINGRING: if (!(P_CanPickupItem(player, false))) @@ -3270,7 +3272,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da P_SetMobjState(target, target->info->meleestate); // go to pinch pain state break; } - // fallthrough + /* FALLTHRU */ default: P_SetMobjState(target, target->info->painstate); break; diff --git a/src/p_map.c b/src/p_map.c index 1fe1b987..c071b160 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1604,6 +1604,8 @@ static boolean PIT_CheckThing(mobj_t *thing) if (iwassprung) // this spring caused you to gain MFE_SPRUNG just now... return false; // "cancel" P_TryMove via blocking so you keep your current position } + else if (tmthing->flags & MF_SPRING && (thing->player || thing->flags & MF_PUSHABLE)) + ; // Fix a few nasty spring-jumping bugs that happen sometimes. // Monitors are not treated as solid to players who are jumping, spinning or gliding, // unless it's a CTF team monitor and you're on the wrong team else if (thing->flags & MF_MONITOR && tmthing->player && tmthing->player->pflags & (PF_JUMPED|PF_SPINNING|PF_GLIDING) @@ -1635,11 +1637,13 @@ static boolean PIT_CheckThing(mobj_t *thing) topz = thing->z - thing->scale; // FixedMul(FRACUNIT, thing->scale), but thing->scale == FRACUNIT in base scale anyways + if (thing->flags & MF_SPRING) + ; // block only when jumping not high enough, // (dont climb max. 24units while already in air) // since return false doesn't handle momentum properly, // we lie to P_TryMove() so it's always too high - if (tmthing->player && tmthing->z + tmthing->height > topz + else if (tmthing->player && tmthing->z + tmthing->height > topz && tmthing->z + tmthing->height < tmthing->ceilingz) { tmfloorz = tmceilingz = topz; // block while in air @@ -1648,8 +1652,6 @@ static boolean PIT_CheckThing(mobj_t *thing) #endif tmfloorthing = thing; // needed for side collision } - else if (thing->flags & MF_SPRING) - ; else if (topz < tmceilingz && tmthing->z <= thing->z+thing->height) { tmceilingz = topz; @@ -1678,11 +1680,13 @@ static boolean PIT_CheckThing(mobj_t *thing) topz = thing->z + thing->height + thing->scale; // FixedMul(FRACUNIT, thing->scale), but thing->scale == FRACUNIT in base scale anyways + if (thing->flags & MF_SPRING) + ; // block only when jumping not high enough, // (dont climb max. 24units while already in air) // since return false doesn't handle momentum properly, // we lie to P_TryMove() so it's always too high - if (tmthing->player && tmthing->z < topz + else if (tmthing->player && tmthing->z < topz && tmthing->z > tmthing->floorz) { tmfloorz = tmceilingz = topz; // block while in air @@ -1691,8 +1695,6 @@ static boolean PIT_CheckThing(mobj_t *thing) #endif tmfloorthing = thing; // needed for side collision } - else if (thing->flags & MF_SPRING) - ; else if (topz > tmfloorz && tmthing->z+tmthing->height >= thing->z) { tmfloorz = topz; @@ -4668,6 +4670,11 @@ fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height) sector_t *sec = R_PointInSubsector(x, y)->sector; fixed_t floorz = sec->floorheight; +#ifdef ESLOPE + if (sec->f_slope) + floorz = P_GetZAt(sec->f_slope, x, y); +#endif + // Intercept the stupid 'fall through 3dfloors' bug Tails 03-17-2002 if (sec->ffloors) { diff --git a/src/p_mobj.c b/src/p_mobj.c index 9c480773..6701e8a3 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2194,10 +2194,18 @@ boolean P_CheckSolidLava(mobj_t *mo, ffloor_t *rover) I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); - if (rover->flags & FF_SWIMMABLE && GETSECSPECIAL(rover->master->frontsector->special, 1) == 3 - && !(rover->master->flags & ML_BLOCKMONSTERS) - && ((rover->master->flags & ML_EFFECT3) || mo->z-mo->momz > *rover->topheight - FixedMul(16*FRACUNIT, mo->scale))) - return true; + { + fixed_t topheight = + #ifdef ESLOPE + *rover->t_slope ? P_GetZAt(*rover->t_slope, mo->x, mo->y) : + #endif + *rover->topheight; + + if (rover->flags & FF_SWIMMABLE && GETSECSPECIAL(rover->master->frontsector->special, 1) == 3 + && !(rover->master->flags & ML_BLOCKMONSTERS) + && ((rover->master->flags & ML_EFFECT3) || mo->z-mo->momz > topheight - FixedMul(16*FRACUNIT, mo->scale))) + return true; + } return false; } @@ -2427,7 +2435,7 @@ static boolean P_ZMovement(mobj_t *mo) mo->z = mo->floorz; #ifdef ESLOPE - if (mo->standingslope) // You're still on the ground; why are we here? + if (!(mo->flags & MF_MISSILE) && mo->standingslope) // You're still on the ground; why are we here? { mo->momz = 0; return true; @@ -3178,11 +3186,17 @@ static boolean P_SceneryZMovement(mobj_t *mo) // boolean P_CanRunOnWater(player_t *player, ffloor_t *rover) { + fixed_t topheight = +#ifdef ESLOPE + *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : +#endif + *rover->topheight; + if (!(player->pflags & PF_NIGHTSMODE) && !player->homing - && (((player->charability == CA_SWIM) || player->powers[pw_super] || player->charflags & SF_RUNONWATER) && player->mo->ceilingz-*rover->topheight >= player->mo->height) + && (((player->charability == CA_SWIM) || player->powers[pw_super] || player->charflags & SF_RUNONWATER) && player->mo->ceilingz-topheight >= player->mo->height) && (rover->flags & FF_SWIMMABLE) && !(player->pflags & PF_SPINNING) && player->speed > FixedMul(player->runspeed, player->mo->scale) && !(player->pflags & PF_SLIDING) - && abs(player->mo->z - *rover->topheight) < FixedMul(30*FRACUNIT, player->mo->scale)) + && abs(player->mo->z - topheight) < FixedMul(30*FRACUNIT, player->mo->scale)) return true; return false; @@ -7650,7 +7664,7 @@ void P_MobjThinker(mobj_t *mobj) mobj->z = mobj->ceilingz - mobj->height; else mobj->z = mobj->floorz; - // THERE IS NO BREAK HERE ON PURPOSE + /* FALLTHRU */ default: // check mobj against possible water content, before movement code P_MobjCheckWater(mobj); @@ -8316,6 +8330,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) break; case MT_EGGCAPSULE: mobj->extravalue1 = -1; // timer for how long a player has been at the capsule + break; case MT_REDTEAMRING: mobj->color = skincolor_redteam; break; @@ -8821,6 +8836,7 @@ void P_PrecipitationEffects(void) { case PRECIP_RAIN: // no lightning or thunder whatsoever sounds_thunder = false; + /* FALLTHRU */ case PRECIP_STORM_NOSTRIKES: // no lightning strikes specifically effects_lightning = false; break; diff --git a/src/p_saveg.c b/src/p_saveg.c index d715c2be..e04ee39c 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1669,12 +1669,18 @@ static inline void SaveWhatThinker(const thinker_t *th, const UINT8 type) static void P_NetArchiveThinkers(void) { const thinker_t *th; + UINT32 numsaved = 0; WRITEUINT32(save_p, ARCHIVEBLOCK_THINKERS); // save off the current thinkers for (th = thinkercap.next; th != &thinkercap; th = th->next) { + if (!(th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed + || th->function.acp1 == (actionf_p1)P_RainThinker + || th->function.acp1 == (actionf_p1)P_SnowThinker)) + numsaved++; + if (th->function.acp1 == (actionf_p1)P_MobjThinker) { SaveMobjThinker(th, tc_mobj); @@ -1862,6 +1868,8 @@ static void P_NetArchiveThinkers(void) #endif } + CONS_Debug(DBG_NETPLAY, "%u thinkers saved\n", numsaved); + WRITEUINT8(save_p, tc_end); } @@ -2626,6 +2634,7 @@ static void P_NetUnArchiveThinkers(void) UINT8 tclass; UINT8 restoreNum = false; UINT32 i; + UINT32 numloaded = 0; if (READUINT32(save_p) != ARCHIVEBLOCK_THINKERS) I_Error("Bad $$$.sav at archive block Thinkers"); @@ -2659,6 +2668,7 @@ static void P_NetUnArchiveThinkers(void) if (tclass == tc_end) break; // leave the saved thinker reading loop + numloaded++; switch (tclass) { @@ -2810,6 +2820,8 @@ static void P_NetUnArchiveThinkers(void) } } + CONS_Debug(DBG_NETPLAY, "%u thinkers loaded\n", numloaded); + if (restoreNum) { executor_t *delay = NULL; diff --git a/src/p_spec.c b/src/p_spec.c index aadd212b..a3ff99db 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1747,7 +1747,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller case 305: // continuous case 306: // each time case 307: // once - if (!(actor && actor->player && actor->player->charability != dist/10)) + if (!(actor && actor->player && actor->player->charability == dist/10)) return false; break; case 309: // continuous @@ -2442,73 +2442,81 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 414: // Play SFX { - fixed_t sfxnum; + INT32 sfxnum; sfxnum = sides[line->sidenum[0]].toptexture; //P_AproxDistance(line->dx, line->dy)>>FRACBITS; - if (line->tag != 0 && line->flags & ML_EFFECT5) + if (sfxnum == sfx_None) + return; // Do nothing! + if (sfxnum < sfx_None || sfxnum >= NUMSFX) { - sector_t *sec; - - while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) + CONS_Debug(DBG_GAMELOGIC, "Line type 414 Executor: sfx number %d is invalid!\n", sfxnum); + return; + } + if (line->tag != 0) // Do special stuff only if a non-zero linedef tag is set + { + if (line->flags & ML_EFFECT5) // Repeat Midtexture { - sec = §ors[secnum]; - S_StartSound(&sec->soundorg, sfxnum); + // Additionally play the sound from tagged sectors' soundorgs + sector_t *sec; + + while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) + { + sec = §ors[secnum]; + S_StartSound(&sec->soundorg, sfxnum); + } + } + else if (mo) // A mobj must have triggered the executor + { + // Only trigger if mobj is touching the tag + ffloor_t *rover; + boolean foundit = false; + + for(rover = mo->subsector->sector->ffloors; rover; rover = rover->next) + { + if (rover->master->frontsector->tag != line->tag) + continue; + + if (mo->z > P_GetSpecialTopZ(mo, sectors + rover->secnum, mo->subsector->sector)) + continue; + + if (mo->z + mo->height < P_GetSpecialBottomZ(mo, sectors + rover->secnum, mo->subsector->sector)) + continue; + + foundit = true; + } + + if (mo->subsector->sector->tag == line->tag) + foundit = true; + + if (!foundit) + return; } } - else if (line->tag != 0 && mo) + + if (line->flags & ML_NOCLIMB) { - // Only trigger if mobj is touching the tag - ffloor_t *rover; - boolean foundit = false; - - for(rover = mo->subsector->sector->ffloors; rover; rover = rover->next) - { - if (rover->master->frontsector->tag != line->tag) - continue; - - if (mo->z > P_GetSpecialTopZ(mo, sectors + rover->secnum, mo->subsector->sector)) - continue; - - if (mo->z + mo->height < P_GetSpecialBottomZ(mo, sectors + rover->secnum, mo->subsector->sector)) - continue; - - foundit = true; - } - - if (mo->subsector->sector->tag == line->tag) - foundit = true; - - if (!foundit) - return; - } - - if (sfxnum < NUMSFX && sfxnum > sfx_None) - { - if (line->flags & ML_NOCLIMB) - { - // play the sound from nowhere, but only if display player triggered it - if (mo && mo->player && (mo->player == &players[displayplayer] || mo->player == &players[secondarydisplayplayer])) - S_StartSound(NULL, sfxnum); - } - else if (line->flags & ML_EFFECT4) - { - // play the sound from nowhere + // play the sound from nowhere, but only if display player triggered it + if (mo && mo->player && (mo->player == &players[displayplayer] || mo->player == &players[secondarydisplayplayer])) S_StartSound(NULL, sfxnum); - } - else if (line->flags & ML_BLOCKMONSTERS) - { - // play the sound from calling sector's soundorg - if (callsec) - S_StartSound(&callsec->soundorg, sfxnum); - else if (mo) - S_StartSound(&mo->subsector->sector->soundorg, sfxnum); - } + } + else if (line->flags & ML_EFFECT4) + { + // play the sound from nowhere + S_StartSound(NULL, sfxnum); + } + else if (line->flags & ML_BLOCKMONSTERS) + { + // play the sound from calling sector's soundorg + if (callsec) + S_StartSound(&callsec->soundorg, sfxnum); else if (mo) - { - // play the sound from mobj that triggered it - S_StartSound(mo, sfxnum); - } + S_StartSound(&mo->subsector->sector->soundorg, sfxnum); + } + else if (mo) + { + // play the sound from mobj that triggered it + S_StartSound(mo, sfxnum); } } break; @@ -3481,7 +3489,7 @@ static boolean P_ThingIsOnThe3DFloor(mobj_t *mo, sector_t *sector, sector_t *tar // // Is player standing on the sector's "ground"? // -static inline boolean P_MobjReadyToTrigger(mobj_t *mo, sector_t *sec) +static boolean P_MobjReadyToTrigger(mobj_t *mo, sector_t *sec) { if (mo->eflags & MFE_VERTICALFLIP) return (mo->z+mo->height == P_GetSpecialTopZ(mo, sec, sec) && sec->flags & SF_FLIPSPECIAL_CEILING); @@ -3608,20 +3616,56 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers { if (roversector) { - if (players[i].mo->subsector->sector != roversector) + if (players[i].mo->subsector->sector == roversector) + ; + else if (sector->flags & SF_TRIGGERSPECIAL_TOUCH) + { + boolean insector = false; + msecnode_t *node; + for (node = players[i].mo->touching_sectorlist; node; node = node->m_sectorlist_next) + { + if (node->m_sector == roversector) + { + insector = true; + break; + } + } + if (!insector) + goto DoneSection2; + } + else goto DoneSection2; + if (!P_ThingIsOnThe3DFloor(players[i].mo, sector, roversector)) goto DoneSection2; } else { - if (players[i].mo->subsector->sector != sector) + if (players[i].mo->subsector->sector == sector) + ; + else if (sector->flags & SF_TRIGGERSPECIAL_TOUCH) + { + boolean insector = false; + msecnode_t *node; + for (node = players[i].mo->touching_sectorlist; node; node = node->m_sectorlist_next) + { + if (node->m_sector == sector) + { + insector = true; + break; + } + } + if (!insector) + goto DoneSection2; + } + else goto DoneSection2; if (special == 3 && !P_MobjReadyToTrigger(players[i].mo, sector)) goto DoneSection2; } } + /* FALLTHRU */ case 4: // Linedef executor that doesn't require touching floor case 5: // Linedef executor case 6: // Linedef executor (7 Emeralds) @@ -4407,6 +4451,7 @@ sector_t *P_ThingOnSpecial3DFloor(mobj_t *mo) { sector_t *sector; ffloor_t *rover; + fixed_t topheight, bottomheight; sector = mo->subsector->sector; if (!sector->ffloors) @@ -4414,8 +4459,6 @@ sector_t *P_ThingOnSpecial3DFloor(mobj_t *mo) for (rover = sector->ffloors; rover; rover = rover->next) { - fixed_t topheight, bottomheight; - if (!rover->master->frontsector->special) continue; @@ -4463,6 +4506,8 @@ sector_t *P_ThingOnSpecial3DFloor(mobj_t *mo) return NULL; } +#define TELEPORTED (player->mo->subsector->sector != originalsector) + /** Checks if a player is standing on or is inside a 3D floor (e.g. water) and * applies any specials. * @@ -4471,12 +4516,12 @@ sector_t *P_ThingOnSpecial3DFloor(mobj_t *mo) */ static void P_PlayerOnSpecial3DFloor(player_t *player, sector_t *sector) { + sector_t *originalsector = player->mo->subsector->sector; ffloor_t *rover; + fixed_t topheight, bottomheight; for (rover = sector->ffloors; rover; rover = rover->next) { - fixed_t topheight, bottomheight; - if (!rover->master->frontsector->special) continue; @@ -4520,7 +4565,10 @@ static void P_PlayerOnSpecial3DFloor(player_t *player, sector_t *sector) // This FOF has the special we're looking for, but are we allowed to touch it? if (sector == player->mo->subsector->sector || (rover->master->frontsector->flags & SF_TRIGGERSPECIAL_TOUCH)) + { P_ProcessSpecialSector(player, rover->master->frontsector, sector); + if TELEPORTED return; + } } // Allow sector specials to be applied to polyobjects! @@ -4531,7 +4579,7 @@ static void P_PlayerOnSpecial3DFloor(player_t *player, sector_t *sector) boolean touching = false; boolean inside = false; - while(po) + while (po) { if (po->flags & POF_NOSPECIALS) { @@ -4607,6 +4655,7 @@ static void P_PlayerOnSpecial3DFloor(player_t *player, sector_t *sector) } P_ProcessSpecialSector(player, polysec, sector); + if TELEPORTED return; po = (polyobj_t *)(po->link.next); } @@ -4670,6 +4719,8 @@ static void P_RunSpecialSectorCheck(player_t *player, sector_t *sector) // requires touching floor. break; } + /* FALLTHRU */ + case 1: // Starpost activator case 5: // Fan sector case 6: // Super Sonic Transform @@ -4711,40 +4762,43 @@ static void P_RunSpecialSectorCheck(player_t *player, sector_t *sector) */ void P_PlayerInSpecialSector(player_t *player) { - sector_t *sector; + sector_t *originalsector; + sector_t *loopsector; msecnode_t *node; if (!player->mo) return; - // Do your ->subsector->sector first - sector = player->mo->subsector->sector; - P_PlayerOnSpecial3DFloor(player, sector); - // After P_PlayerOnSpecial3DFloor, recheck if the player is in that sector, - // because the player can be teleported in between these times. - if (sector == player->mo->subsector->sector) - P_RunSpecialSectorCheck(player, sector); + originalsector = player->mo->subsector->sector; - // Iterate through touching_sectorlist + P_PlayerOnSpecial3DFloor(player, originalsector); // Handle FOFs first. + if TELEPORTED return; + + P_RunSpecialSectorCheck(player, originalsector); + if TELEPORTED return; + + // Iterate through touching_sectorlist for SF_TRIGGERSPECIAL_TOUCH for (node = player->mo->touching_sectorlist; node; node = node->m_sectorlist_next) { - sector = node->m_sector; + loopsector = node->m_sector; - if (sector == player->mo->subsector->sector) // Don't duplicate + if (loopsector == originalsector) // Don't duplicate continue; // Check 3D floors... - P_PlayerOnSpecial3DFloor(player, sector); + P_PlayerOnSpecial3DFloor(player, loopsector); + if TELEPORTED return; - if (!(sector->flags & SF_TRIGGERSPECIAL_TOUCH)) - return; - // After P_PlayerOnSpecial3DFloor, recheck if the player is in that sector, - // because the player can be teleported in between these times. - if (sector == player->mo->subsector->sector) - P_RunSpecialSectorCheck(player, sector); + if (!(loopsector->flags & SF_TRIGGERSPECIAL_TOUCH)) + continue; + + P_RunSpecialSectorCheck(player, loopsector); + if TELEPORTED return; } } +#undef TELEPORTED + /** Animate planes, scroll walls, etc. and keeps track of level timelimit and exits if time is up. * * \sa P_CheckTimeLimit, P_CheckPointLimit @@ -5748,6 +5802,8 @@ void P_SpawnSpecials(INT32 fromnetsave) EV_DoFloor(&lines[i], bounceFloor); if (lines[i].special == 54) break; + /* FALLTHRU */ + case 55: // New super cool and awesome moving ceiling type if (lines[i].backsector) EV_DoCeiling(&lines[i], bounceCeiling); @@ -5759,7 +5815,8 @@ void P_SpawnSpecials(INT32 fromnetsave) EV_DoFloor(&lines[i], bounceFloorCrush); if (lines[i].special == 57) - break; //only move the floor + break; //only move the floor + /* FALLTHRU */ case 58: // New super cool and awesome moving ceiling crush type if (lines[i].backsector) @@ -6865,6 +6922,7 @@ static void P_SpawnScrollers(void) Add_Scroller(sc_ceiling, -dx, dy, control, s, accel, l->flags & ML_NOCLIMB); if (special != 533) break; + /* FALLTHRU */ case 523: // carry objects on ceiling dx = FixedMul(dx, CARRYFACTOR); @@ -6879,6 +6937,7 @@ static void P_SpawnScrollers(void) Add_Scroller(sc_floor, -dx, dy, control, s, accel, l->flags & ML_NOCLIMB); if (special != 530) break; + /* FALLTHRU */ case 520: // carry objects on floor dx = FixedMul(dx, CARRYFACTOR); diff --git a/src/p_user.c b/src/p_user.c index d3be2990..007e3a55 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1255,11 +1255,12 @@ boolean P_IsObjectOnGroundIn(mobj_t *mo, sector_t *sec) if (!(rover->flags & FF_EXISTS)) continue; - // If the FOF is configured to let players through, continue. - if (!(rover->flags & FF_BLOCKPLAYER) && (rover->flags & FF_BLOCKOTHERS)) + // If the FOF is configured to let the object through, continue. + if (!((rover->flags & FF_BLOCKPLAYER && mo->player) + || (rover->flags & FF_BLOCKOTHERS && !mo->player))) continue; - // If the the platform is intangile from below, continue. + // If the the platform is intangible from below, continue. if (rover->flags & FF_PLATFORM) continue; @@ -1288,11 +1289,12 @@ boolean P_IsObjectOnGroundIn(mobj_t *mo, sector_t *sec) if (!(rover->flags & FF_EXISTS)) continue; - // If the FOF is configured to let players through, continue. - if (!(rover->flags & FF_BLOCKPLAYER) && (rover->flags & FF_BLOCKOTHERS)) + // If the FOF is configured to let the object through, continue. + if (!((rover->flags & FF_BLOCKPLAYER && mo->player) + || (rover->flags & FF_BLOCKOTHERS && !mo->player))) continue; - // If the the platform is intangile from above, continue. + // If the the platform is intangible from above, continue. if (rover->flags & FF_REVERSEPLATFORM) continue; @@ -1673,9 +1675,8 @@ void P_DoPlayerExit(player_t *player) #define SPACESPECIAL 12 boolean P_InSpaceSector(mobj_t *mo) // Returns true if you are in space { - sector_t *sector; - - sector = mo->subsector->sector; + sector_t *sector = mo->subsector->sector; + fixed_t topheight, bottomheight; if (GETSECSPECIAL(sector->special, 1) == SPACESPECIAL) return true; @@ -1688,11 +1689,18 @@ boolean P_InSpaceSector(mobj_t *mo) // Returns true if you are in space { if (GETSECSPECIAL(rover->master->frontsector->special, 1) != SPACESPECIAL) continue; +#ifdef ESLOPE + topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, mo->x, mo->y) : *rover->topheight; + bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, mo->x, mo->y) : *rover->bottomheight; +#else + topheight = *rover->topheight; + bottomheight = *rover->bottomheight; +#endif - if (mo->z > *rover->topheight) + if (mo->z + (mo->height/2) > topheight) continue; - if (mo->z + (mo->height/2) < *rover->bottomheight) + if (mo->z + (mo->height/2) < bottomheight) continue; return true; @@ -1704,9 +1712,10 @@ boolean P_InSpaceSector(mobj_t *mo) // Returns true if you are in space boolean P_InQuicksand(mobj_t *mo) // Returns true if you are in quicksand { - sector_t *sector; + sector_t *sector = mo->subsector->sector; + fixed_t topheight, bottomheight; - sector = mo->subsector->sector; + fixed_t flipoffset = ((mo->eflags & MFE_VERTICALFLIP) ? (mo->height/2) : 0); if (sector->ffloors) { @@ -1720,10 +1729,18 @@ boolean P_InQuicksand(mobj_t *mo) // Returns true if you are in quicksand if (!(rover->flags & FF_QUICKSAND)) continue; - if (mo->z > *rover->topheight) +#ifdef ESLOPE + topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, mo->x, mo->y) : *rover->topheight; + bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, mo->x, mo->y) : *rover->bottomheight; +#else + topheight = *rover->topheight; + bottomheight = *rover->bottomheight; +#endif + + if (mo->z + flipoffset > topheight) continue; - if (mo->z + (mo->height/2) < *rover->bottomheight) + if (mo->z + (mo->height/2) + flipoffset < bottomheight) continue; return true; @@ -2006,6 +2023,7 @@ static void P_CheckQuicksand(player_t *player) { ffloor_t *rover; fixed_t sinkspeed, friction; + fixed_t topheight, bottomheight; if (!(player->mo->subsector->sector->ffloors && player->mo->momz <= 0)) return; @@ -2017,16 +2035,38 @@ static void P_CheckQuicksand(player_t *player) if (!(rover->flags & FF_QUICKSAND)) continue; - if (*rover->topheight >= player->mo->z && *rover->bottomheight < player->mo->z + player->mo->height) +#ifdef ESLOPE + topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight; + bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight; +#else + topheight = *rover->topheight; + bottomheight = *rover->bottomheight; +#endif + + if (topheight >= player->mo->z && bottomheight < player->mo->z + player->mo->height) { sinkspeed = abs(rover->master->v1->x - rover->master->v2->x)>>1; sinkspeed = FixedDiv(sinkspeed,TICRATE*FRACUNIT); - player->mo->z -= sinkspeed; + if (player->mo->eflags & MFE_VERTICALFLIP) + { + fixed_t ceilingheight = P_GetCeilingZ(player->mo, player->mo->subsector->sector, player->mo->x, player->mo->y, NULL); - if (player->mo->z <= player->mo->subsector->sector->floorheight) - player->mo->z = player->mo->subsector->sector->floorheight; + player->mo->z += sinkspeed; + + if (player->mo->z + player->mo->height >= ceilingheight) + player->mo->z = ceilingheight - player->mo->height; + } + else + { + fixed_t floorheight = P_GetFloorZ(player->mo, player->mo->subsector->sector, player->mo->x, player->mo->y, NULL); + + player->mo->z -= sinkspeed; + + if (player->mo->z <= floorheight) + player->mo->z = floorheight; + } friction = abs(rover->master->v1->y - rover->master->v2->y)>>6; @@ -2389,11 +2429,11 @@ static void P_DoClimbing(player_t *player) // SRB2kart - unused floorclimb = true; #ifdef ESLOPE - bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight; topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight; + bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight; #else - bottomheight = *rover->bottomheight; topheight = *rover->topheight; + bottomheight = *rover->bottomheight; #endif // Only supports rovers that are moving like an 'elevator', not just the top or bottom. @@ -2582,13 +2622,20 @@ static void P_DoClimbing(player_t *player) // SRB2kart - unused // Is there a FOF directly below that we can move onto? if (glidesector->sector->ffloors) { + fixed_t topheight; ffloor_t *rover; for (rover = glidesector->sector->ffloors; rover; rover = rover->next) { if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || (rover->flags & FF_BUSTUP)) continue; - if (*rover->topheight > ceilingheight - FixedMul(16*FRACUNIT, player->mo->scale)) +#ifdef ESLOPE + topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight; +#else + topheight = *rover->topheight; +#endif + + if (topheight > ceilingheight - FixedMul(16*FRACUNIT, player->mo->scale)) { foundfof = true; break; @@ -2970,14 +3017,12 @@ static void P_DoTeeter(player_t *player) // SRB2kart - unused. { if (!(rover->flags & FF_EXISTS)) continue; +#ifdef ESLOPE + topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight; + bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight; +#else topheight = *rover->topheight; bottomheight = *rover->bottomheight; - -#ifdef ESLOPE - if (*rover->t_slope) - topheight = P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y); - if (*rover->b_slope) - bottomheight = P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y); #endif if (P_CheckSolidLava(player->mo, rover)) @@ -8893,13 +8938,23 @@ static void P_CalcPostImg(player_t *player) else if (sector->ffloors) { ffloor_t *rover; + fixed_t topheight; + fixed_t bottomheight; for (rover = sector->ffloors; rover; rover = rover->next) { if (!(rover->flags & FF_EXISTS)) continue; - if (pviewheight >= *rover->topheight || pviewheight <= *rover->bottomheight) +#ifdef ESLOPE + topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight; + bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight; +#else + topheight = *rover->topheight; + bottomheight = *rover->bottomheight; +#endif + + if (pviewheight >= topheight || pviewheight <= bottomheight) continue; if (P_FindSpecialLineFromTag(13, rover->master->frontsector->tag, -1) != -1) @@ -8911,13 +8966,23 @@ static void P_CalcPostImg(player_t *player) if (sector->ffloors) { ffloor_t *rover; + fixed_t topheight; + fixed_t bottomheight; for (rover = sector->ffloors; rover; rover = rover->next) { if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE) || rover->flags & FF_BLOCKPLAYER) continue; - if (pviewheight >= *rover->topheight || pviewheight <= *rover->bottomheight) +#ifdef ESLOPE + topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight; + bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight; +#else + topheight = *rover->topheight; + bottomheight = *rover->bottomheight; +#endif + + if (pviewheight >= topheight || pviewheight <= bottomheight) continue; *type = postimg_water; @@ -9145,6 +9210,7 @@ void P_PlayerThink(player_t *player) // check water content, set stuff in mobj P_MobjCheckWater(player->mo); +#ifndef SECTORSPECIALSAFTERTHINK #ifdef POLYOBJECTS if (player->onconveyor != 1 || !P_IsObjectOnGround(player->mo)) #endif @@ -9153,6 +9219,7 @@ void P_PlayerThink(player_t *player) if (!player->spectator) P_PlayerInSpecialSector(player); +#endif if (player->playerstate == PST_DEAD) { @@ -9529,6 +9596,17 @@ void P_PlayerAfterThink(player_t *player) cmd = &player->cmd; +#ifdef SECTORSPECIALSAFTERTHINK +#ifdef POLYOBJECTS + if (player->onconveyor != 1 || !P_IsObjectOnGround(player->mo)) +#endif + player->onconveyor = 0; + // check special sectors : damage & secrets + + if (!player->spectator) + P_PlayerInSpecialSector(player); +#endif + if (splitscreen && player == &players[secondarydisplayplayer]) thiscam = &camera2; else if (player == &players[displayplayer]) diff --git a/src/r_bsp.c b/src/r_bsp.c index 44cb991a..abb11204 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -1222,6 +1222,9 @@ static void R_Subsector(size_t num) while (count--) { // CONS_Debug(DBG_GAMELOGIC, "Adding normal line %d...(%d)\n", line->linedef-lines, leveltime); +#ifdef POLYOBJECTS + if (!line->polyseg) // ignore segs that belong to polyobjects +#endif R_AddLine(line); line++; curline = NULL; /* cph 2001/11/18 - must clear curline now we're done with it, so stuff doesn't try using it for other things */ diff --git a/src/r_data.c b/src/r_data.c index 7bad6bb8..d19882dd 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -944,23 +944,24 @@ static void R_InitExtraColormaps(void) for (cfile = clump = 0; cfile < numwadfiles; cfile++, clump = 0) { startnum = W_CheckNumForNamePwad("C_START", cfile, clump); - if (startnum == LUMPERROR) + if (startnum == INT16_MAX) continue; endnum = W_CheckNumForNamePwad("C_END", cfile, clump); - if (endnum == LUMPERROR) + if (endnum == INT16_MAX) I_Error("R_InitExtraColormaps: C_START without C_END\n"); - if (WADFILENUM(startnum) != WADFILENUM(endnum)) - I_Error("R_InitExtraColormaps: C_START and C_END in different wad files!\n"); + // This shouldn't be possible when you use the Pwad function, silly + //if (WADFILENUM(startnum) != WADFILENUM(endnum)) + //I_Error("R_InitExtraColormaps: C_START and C_END in different wad files!\n"); if (numcolormaplumps >= maxcolormaplumps) maxcolormaplumps *= 2; colormaplumps = Z_Realloc(colormaplumps, sizeof (*colormaplumps) * maxcolormaplumps, PU_STATIC, NULL); - colormaplumps[numcolormaplumps].wadfile = WADFILENUM(startnum); - colormaplumps[numcolormaplumps].firstlump = LUMPNUM(startnum+1); + colormaplumps[numcolormaplumps].wadfile = cfile; + colormaplumps[numcolormaplumps].firstlump = startnum+1; colormaplumps[numcolormaplumps].numlumps = endnum - (startnum + 1); numcolormaplumps++; } diff --git a/src/sdl/MakeNIX.cfg b/src/sdl/MakeNIX.cfg index e7ebb2ec..6998a03a 100644 --- a/src/sdl/MakeNIX.cfg +++ b/src/sdl/MakeNIX.cfg @@ -65,37 +65,6 @@ ifdef MACOSX LIBS+=-framework CoreFoundation endif -# -#here is GP2x (arm-gp2x-linux) -# -ifdef GP2X - PNG_CONFIG?=$(PREFIX)-libpng12-config -ifdef STATIC #need a better setting name - CFLAGS+=-I$(OPEN2X)/include -ifndef NOMIXER - LIBS+=-lvorbisidec -ifdef MIKMOD - LIBS+=-lmikmod -endif -ifdef SMPEGLIB - LIBS+=-lsmpeg - LD=$(CXX) -endif -endif - NONET=1 -endif -ifndef ARCHNAME -"error" -endif - NONX86=1 - NOHW=1 - NOHS=1 - NOMD5=1 - WFLAGS+=-O0 - OPTS+=-DGP2X -ffast-math -mcpu=arm920t - EXENAME?=SRB2GP2X.gpe -endif - ifndef NOHW OPTS+=-I/usr/X11R6/include LDFLAGS+=-L/usr/X11R6/lib diff --git a/src/sdl/Makefile.cfg b/src/sdl/Makefile.cfg index b54f7057..58c4d086 100644 --- a/src/sdl/Makefile.cfg +++ b/src/sdl/Makefile.cfg @@ -14,26 +14,6 @@ ifdef PANDORA include sdl/SRB2Pandora/Makefile.cfg endif #ifdef PANDORA -ifdef DC -include sdl/SRB2DC/Makefile.cfg -endif #ifdef DC - -ifdef PS3N -include sdl/SRB2PS3/Makefile.cfg -endif #ifdef PS3N - -ifdef PSP -include sdl/SRB2PSP/Makefile.cfg -endif #ifdef PSP - -ifdef XBOX -include sdl/SRB2XBOX/Makefile.cfg -endif #ifdef XBOX - -ifdef WINCE -include sdl/SRB2CE/Makefile.cfg -endif #ifef WINCE - ifdef CYGWIN32 include sdl/MakeCYG.cfg endif #ifdef CYGWIN32 @@ -150,15 +130,8 @@ endif endif endif -# FIXME: DevkitPPC and ready-compiled SDL Wii require these things to be in a silly order -ifdef WII -include sdl/SRB2WII/Makefile.cfg -endif #ifdef WII - CFLAGS+=$(SDL_CFLAGS) LIBS:=$(SDL_LDFLAGS) $(LIBS) -ifndef WII ifdef STATIC LIBS+=$(shell $(SDL_CONFIG) --static-libs) endif -endif diff --git a/src/sdl/endtxt.c b/src/sdl/endtxt.c index 1d7756b4..1e72ca9a 100644 --- a/src/sdl/endtxt.c +++ b/src/sdl/endtxt.c @@ -33,7 +33,6 @@ void ShowEndTxt(void) { -#if !(defined (_WIN32_WCE) || defined (_XBOX) || defined (_arch_dreamcast)) INT32 i; UINT16 j, att = 0; INT32 nlflag = 1; @@ -232,5 +231,4 @@ void ShowEndTxt(void) printf("\n"); Z_Free(data); -#endif } diff --git a/src/sdl/hwsym_sdl.c b/src/sdl/hwsym_sdl.c index 54f5da3a..f4686d2b 100644 --- a/src/sdl/hwsym_sdl.c +++ b/src/sdl/hwsym_sdl.c @@ -37,14 +37,8 @@ #pragma warning(default : 4214 4244) #endif -#if defined (_XBOX) || defined (_arch_dreamcast) || defined(GP2X) -#define NOLOADSO -#endif - -#if SDL_VERSION_ATLEAST(1,2,6) && !defined (NOLOADSO) -#include "SDL_loadso.h" // 1.2.6+ -#elif !defined (NOLOADSO) -#define NOLOADSO +#ifndef NOLOADSO +#include "SDL_loadso.h" #endif #define _CREATE_DLL_ // necessary for Unix AND Windows diff --git a/src/sdl/i_main.c b/src/sdl/i_main.c index d299a867..c4809587 100644 --- a/src/sdl/i_main.c +++ b/src/sdl/i_main.c @@ -26,28 +26,6 @@ #include #endif -#ifdef _WII -#include -#include -#include -#ifdef REMOTE_DEBUGGING -#include -#endif -static char wiicwd[PATH_MAX] = "sd:/"; -static char localip[16] = {0}; -static char gateway[16] = {0}; -static char netmask[16] = {0}; -#endif - -#ifdef _PSP -#include -#include -PSP_HEAP_SIZE_KB(24*1024); -PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER | PSP_THREAD_ATTR_VFPU); -PSP_MAIN_THREAD_NAME("SRB2Kart"); -PSP_MAIN_THREAD_STACK_SIZE_KB(256); -#endif - #ifdef HAVE_SDL #ifdef HAVE_TTF @@ -79,23 +57,12 @@ FILE *logstream = NULL; #endif #endif -#if defined (_WIN32) && !defined (_XBOX) +#if defined (_WIN32) #include "../win32/win_dbg.h" typedef BOOL (WINAPI *p_IsDebuggerPresent)(VOID); #endif -#ifdef _arch_dreamcast -#include -KOS_INIT_FLAGS(INIT_DEFAULT -//| INIT_NET -//| INIT_MALLOCSTATS -//| INIT_QUIET -//| INIT_OCRAM -//| INIT_NO_DCLOAD -); -#endif - -#if defined (_WIN32) && !defined (_XBOX) && !defined (_WIN32_WCE) +#if defined (_WIN32) static inline VOID MakeCodeWritable(VOID) { #ifdef USEASM // Disable write-protection of code segment @@ -136,13 +103,6 @@ static inline VOID MakeCodeWritable(VOID) \return int */ -#if defined (_XBOX) && defined (__GNUC__) -void XBoxStartup() -{ - const char *logdir = NULL; - myargc = -1; - myargv = NULL; -#else #ifdef FORCESDLMAIN int SDL_main(int argc, char **argv) #else @@ -152,56 +112,19 @@ int main(int argc, char **argv) const char *logdir = NULL; myargc = argc; myargv = argv; /// \todo pull out path to exe from this string -#endif #ifdef HAVE_TTF -#ifdef _PS3 - // apparently there is a bug in SDL_PSL1GHT which needs this to be set to work around - SDL_setenv("SDL_VIDEODRIVER", "psl1ght", 1); - I_StartupTTF(FONTPOINTSIZE, SDL_INIT_VIDEO, SDL_SWSURFACE|SDL_DOUBLEBUF); -#elif defined(_WIN32) +#ifdef _WIN32 I_StartupTTF(FONTPOINTSIZE, SDL_INIT_VIDEO|SDL_INIT_AUDIO, SDL_SWSURFACE); #else I_StartupTTF(FONTPOINTSIZE, SDL_INIT_VIDEO, SDL_SWSURFACE); #endif #endif -#ifdef _PS3 - // initialise controllers. - //ioPadInit(7); -#endif - -// init Wii-specific stuff -#ifdef _WII - // Start network - if_config(localip, netmask, gateway, TRUE); - -#ifdef REMOTE_DEBUGGING -#if REMOTE_DEBUGGING == 0 - DEBUG_Init(GDBSTUB_DEVICE_TCP, GDBSTUB_DEF_TCPPORT); // Port 2828 -#elif REMOTE_DEBUGGING > 2 - DEBUG_Init(GDBSTUB_DEVICE_TCP, REMOTE_DEBUGGING); // Custom Port -#elif REMOTE_DEBUGGING < 0 - DEBUG_Init(GDBSTUB_DEVICE_USB, GDBSTUB_DEF_CHANNEL); // Slot 1 -#else - DEBUG_Init(GDBSTUB_DEVICE_USB, REMOTE_DEBUGGING-1); // Custom Slot -#endif -#endif - // Start FAT filesystem - fatInitDefault(); - - if (getcwd(wiicwd, PATH_MAX)) - I_PutEnv(va("HOME=%ssrb2wii", wiicwd)); -#endif - logdir = D_Home(); #ifdef LOGMESSAGES -#if defined(_WIN32_WCE) || defined(GP2X) - logstream = fopen(va("%s.log",argv[0]), "wt"); -#elif defined (_WII) - logstream = fopen(va("%s/log.txt",logdir), "wt"); -#elif defined (DEFAULTDIR) +#ifdef DEFAULTDIR if (logdir) logstream = fopen(va("%s/"DEFAULTDIR"/log.txt",logdir), "wt"); else @@ -211,8 +134,7 @@ int main(int argc, char **argv) //I_OutputMsg("I_StartupSystem() ...\n"); I_StartupSystem(); -#if defined (_WIN32) && !defined (_XBOX) -#ifndef _WIN32_WCE +#if defined (_WIN32) { #if 0 // just load the DLL p_IsDebuggerPresent pfnIsDebuggerPresent = (p_IsDebuggerPresent)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsDebuggerPresent"); @@ -226,11 +148,8 @@ int main(int argc, char **argv) LoadLibraryA("exchndl.dll"); } } -#endif prevExceptionFilter = SetUnhandledExceptionFilter(RecordExceptionInfo); -#ifndef _WIN32_WCE MakeCodeWritable(); -#endif #endif // startup SRB2 CONS_Printf("Setting up SRB2Kart...\n"); diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index a8c00065..bd4c93a6 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -26,19 +26,12 @@ #include "../config.h.in" #endif -#ifndef _WIN32_WCE #include -#endif -#ifdef _XBOX -#include "SRB2XBOX/xboxhelp.h" -#endif - -#if defined (_WIN32) && !defined (_XBOX) +#ifdef _WIN32 #define RPC_NO_WINDOWS_H #include #include "../doomtype.h" -#ifndef _WIN32_WCE typedef BOOL (WINAPI *p_GetDiskFreeSpaceExA)(LPCSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER); typedef BOOL (WINAPI *p_IsProcessorFeaturePresent) (DWORD); typedef DWORD (WINAPI *p_timeGetTime) (void); @@ -46,7 +39,6 @@ typedef UINT (WINAPI *p_timeEndPeriod) (UINT); typedef HANDLE (WINAPI *p_OpenFileMappingA) (DWORD, BOOL, LPCSTR); typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); #endif -#endif #include #include #include @@ -59,18 +51,10 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); #include #endif -#ifdef _arch_dreamcast -#include -#include -#include -#include -void __set_fpscr(long); // in libgcc / kernel's startup.s? -#else #include -#if defined (_WIN32) && !defined (_WIN32_WCE) && !defined (_XBOX) +#ifdef _WIN32 #include #endif -#endif #ifdef _MSC_VER #pragma warning(disable : 4214 4244) @@ -88,15 +72,10 @@ void __set_fpscr(long); // in libgcc / kernel's startup.s? #pragma warning(default : 4214 4244) #endif -#if SDL_VERSION_ATLEAST(1,2,7) && !defined (DC) -#include "SDL_cpuinfo.h" // 1.2.7 or greater +#include "SDL_cpuinfo.h" #define HAVE_SDLCPUINFO -#endif -#ifdef _PSP -//#include -#elif !defined(_PS3) -#if defined (__unix__) || defined(__APPLE__) || (defined (UNIXCOMMON) && !defined (_arch_dreamcast) && !defined (__HAIKU__) && !defined (_WII)) +#if defined (__unix__) || defined(__APPLE__) || (defined (UNIXCOMMON) && !defined (__HAIKU__)) #if defined (__linux__) #include #else @@ -111,20 +90,17 @@ void __set_fpscr(long); // in libgcc / kernel's startup.s? #include #endif #endif -#endif -#ifndef _PS3 -#if defined (__linux__) || (defined (UNIXCOMMON) && !defined (_arch_dreamcast) && !defined (_PSP) && !defined (__HAIKU__) && !defined (_WII)) +#if defined (__linux__) || (defined (UNIXCOMMON) && !defined (__HAIKU__)) #ifndef NOTERMIOS #include #include // ioctl #define HAVE_TERMIOS #endif #endif -#endif #ifndef NOMUMBLE -#if defined (__linux__) && !defined(_PS3) // need -lrt +#ifdef __linux__ // need -lrt #include #ifdef MAP_FAILED #define HAVE_SHM @@ -132,7 +108,7 @@ void __set_fpscr(long); // in libgcc / kernel's startup.s? #include #endif -#if defined (_WIN32) && !defined (_WIN32_WCE) && !defined (_XBOX) +#ifdef _WIN32 #define HAVE_MUMBLE #define WINMUMBLE #elif defined (HAVE_SHM) @@ -140,10 +116,6 @@ void __set_fpscr(long); // in libgcc / kernel's startup.s? #endif #endif // NOMUMBLE -#ifdef _WIN32_WCE -#include "SRB2CE/cehelp.h" -#endif - #ifndef O_BINARY #define O_BINARY 0 #endif @@ -153,44 +125,7 @@ void __set_fpscr(long); // in libgcc / kernel's startup.s? #endif // Locations for searching the srb2.srb -#ifdef _arch_dreamcast -#define DEFAULTWADLOCATION1 "/cd" -#define DEFAULTWADLOCATION2 "/pc" -#define DEFAULTWADLOCATION3 "/pc/home/alam/srb2code/data" -#define DEFAULTSEARCHPATH1 "/cd" -#define DEFAULTSEARCHPATH2 "/pc" -//#define DEFAULTSEARCHPATH3 "/pc/home/alam/srb2code/data" -#elif defined (GP2X) -#define DEFAULTWADLOCATION1 "/mnt/sd" -#define DEFAULTWADLOCATION2 "/mnt/sd/SRB2" -#define DEFAULTWADLOCATION3 "/tmp/mnt/sd" -#define DEFAULTWADLOCATION4 "/tmp/mnt/sd/SRB2" -#define DEFAULTSEARCHPATH1 "/mnt/sd" -#define DEFAULTSEARCHPATH2 "/tmp/mnt/sd" -#elif defined (_WII) -#define NOCWD -#define NOHOME -#define NEED_SDL_GETENV -#define DEFAULTWADLOCATION1 "sd:/srb2wii" -#define DEFAULTWADLOCATION2 "usb:/srb2wii" -#define DEFAULTSEARCHPATH1 "sd:/srb2wii" -#define DEFAULTSEARCHPATH2 "usb:/srb2wii" -// PS3: TODO: this will need modification most likely -#elif defined (_PS3) -#define NOCWD -#define NOHOME -#define DEFAULTWADLOCATION1 "/dev_hdd0/game/SRB2-PS3_/USRDIR/etc" -#define DEFAULTWADLOCATION2 "/dev_usb/SRB2PS3" -#define DEFAULTSEARCHPATH1 "/dev_hdd0/game/SRB2-PS3_/USRDIR/etc" -#define DEFAULTSEARCHPATH2 "/dev_usb/SRB2PS3" -#elif defined (_PSP) -#define NOCWD -#define NOHOME -#define DEFAULTWADLOCATION1 "host0:/bin/Resources" -#define DEFAULTWADLOCATION2 "ms0:/PSP/GAME/SRB2PSP" -#define DEFAULTSEARCHPATH1 "host0:/" -#define DEFAULTSEARCHPATH2 "ms0:/PSP/GAME/SRB2PSP" -#elif defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) +#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) #define DEFAULTWADLOCATION1 "/usr/local/share/games/SRB2" #define DEFAULTWADLOCATION2 "/usr/local/games/SRB2" #define DEFAULTWADLOCATION3 "/usr/share/games/SRB2" @@ -198,23 +133,6 @@ void __set_fpscr(long); // in libgcc / kernel's startup.s? #define DEFAULTSEARCHPATH1 "/usr/local/games" #define DEFAULTSEARCHPATH2 "/usr/games" #define DEFAULTSEARCHPATH3 "/usr/local" -#elif defined (_XBOX) -#define NOCWD -#ifdef __GNUC__ -#include -#endif -#define DEFAULTWADLOCATION1 "c:\\srb2" -#define DEFAULTWADLOCATION2 "d:\\srb2" -#define DEFAULTWADLOCATION3 "e:\\srb2" -#define DEFAULTWADLOCATION4 "f:\\srb2" -#define DEFAULTWADLOCATION5 "g:\\srb2" -#define DEFAULTWADLOCATION6 "h:\\srb2" -#define DEFAULTWADLOCATION7 "i:\\srb2" -#elif defined (_WIN32_WCE) -#define NOCWD -#define NOHOME -#define DEFAULTWADLOCATION1 "\\Storage Card\\SRB2DEMO" -#define DEFAULTSEARCHPATH1 "\\Storage Card" #elif defined (_WIN32) #define DEFAULTWADLOCATION1 "c:\\games\\srb2" #define DEFAULTWADLOCATION2 "\\games\\srb2" @@ -270,9 +188,6 @@ static void JoyReset(SDLJoyInfo_t *JoySet) { if (JoySet->dev) { -#ifdef GP2X //GP2X's SDL does an illegal free on the 1st joystick... - if (SDL_JoystickIndex(JoySet->dev) != 0) -#endif SDL_JoystickClose(JoySet->dev); } JoySet->dev = NULL; @@ -308,7 +223,6 @@ SDL_bool framebuffer = SDL_FALSE; UINT8 keyboard_started = false; -#if !defined (DC) FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) { //static char msg[] = "oh no! back to reality!\r\n"; @@ -362,7 +276,6 @@ FUNCNORETURN static ATTRNORETURN void quit_handler(int num) raise(num); I_Quit(); } -#endif #ifdef HAVE_TERMIOS // TERMIOS console code from Quake3: thank you! @@ -487,9 +400,7 @@ static void I_StartupConsole(void) signal(SIGTTIN, SIG_IGN); signal(SIGTTOU, SIG_IGN); -#if !defined(GP2X) //read is bad on GP2X consolevent = !M_CheckParm("-noconsole"); -#endif framebuffer = M_CheckParm("-framebuffer"); if (framebuffer) @@ -577,7 +488,7 @@ void I_GetConsoleEvents(void) (void)d; } -#elif defined (_WIN32) && !(defined (_XBOX) || defined (_WIN32_WCE)) +#elif defined (_WIN32) static BOOL I_ReadyConsole(HANDLE ci) { DWORD gotinput; @@ -590,70 +501,78 @@ static BOOL I_ReadyConsole(HANDLE ci) static boolean entering_con_command = false; +static void Impl_HandleKeyboardConsoleEvent(KEY_EVENT_RECORD evt, HANDLE co) +{ + event_t event; + CONSOLE_SCREEN_BUFFER_INFO CSBI; + DWORD t; + + memset(&event,0x00,sizeof (event)); + + if (evt.bKeyDown) + { + event.type = ev_console; + entering_con_command = true; + switch (evt.wVirtualKeyCode) + { + case VK_ESCAPE: + case VK_TAB: + event.data1 = KEY_NULL; + break; + case VK_SHIFT: + event.data1 = KEY_LSHIFT; + break; + case VK_RETURN: + entering_con_command = false; + // Fall through. + default: + event.data1 = MapVirtualKey(evt.wVirtualKeyCode,2); // convert in to char + } + if (co != INVALID_HANDLE_VALUE && GetFileType(co) == FILE_TYPE_CHAR && GetConsoleMode(co, &t)) + { + if (event.data1 && event.data1 != KEY_LSHIFT && event.data1 != KEY_RSHIFT) + { +#ifdef _UNICODE + WriteConsole(co, &evt.uChar.UnicodeChar, 1, &t, NULL); +#else + WriteConsole(co, &evt.uChar.AsciiChar, 1 , &t, NULL); +#endif + } + if (evt.wVirtualKeyCode == VK_BACK + && GetConsoleScreenBufferInfo(co,&CSBI)) + { + WriteConsoleOutputCharacterA(co, " ",1, CSBI.dwCursorPosition, &t); + } + } + } + else + { + event.type = ev_keyup; + switch (evt.wVirtualKeyCode) + { + case VK_SHIFT: + event.data1 = KEY_LSHIFT; + break; + default: + break; + } + } + if (event.data1) D_PostEvent(&event); +} + void I_GetConsoleEvents(void) { - event_t ev = {0,0,0,0}; HANDLE ci = GetStdHandle(STD_INPUT_HANDLE); HANDLE co = GetStdHandle(STD_OUTPUT_HANDLE); - CONSOLE_SCREEN_BUFFER_INFO CSBI; INPUT_RECORD input; DWORD t; while (I_ReadyConsole(ci) && ReadConsoleInput(ci, &input, 1, &t) && t) { - memset(&ev,0x00,sizeof (ev)); switch (input.EventType) { case KEY_EVENT: - if (input.Event.KeyEvent.bKeyDown) - { - ev.type = ev_console; - entering_con_command = true; - switch (input.Event.KeyEvent.wVirtualKeyCode) - { - case VK_ESCAPE: - case VK_TAB: - ev.data1 = KEY_NULL; - break; - case VK_SHIFT: - ev.data1 = KEY_LSHIFT; - break; - case VK_RETURN: - entering_con_command = false; - // Fall through. - default: - ev.data1 = MapVirtualKey(input.Event.KeyEvent.wVirtualKeyCode,2); // convert in to char - } - if (co != INVALID_HANDLE_VALUE && GetFileType(co) == FILE_TYPE_CHAR && GetConsoleMode(co, &t)) - { - if (ev.data1 && ev.data1 != KEY_LSHIFT && ev.data1 != KEY_RSHIFT) - { -#ifdef _UNICODE - WriteConsole(co, &input.Event.KeyEvent.uChar.UnicodeChar, 1, &t, NULL); -#else - WriteConsole(co, &input.Event.KeyEvent.uChar.AsciiChar, 1 , &t, NULL); -#endif - } - if (input.Event.KeyEvent.wVirtualKeyCode == VK_BACK - && GetConsoleScreenBufferInfo(co,&CSBI)) - { - WriteConsoleOutputCharacterA(co, " ",1, CSBI.dwCursorPosition, &t); - } - } - } - else - { - ev.type = ev_keyup; - switch (input.Event.KeyEvent.wVirtualKeyCode) - { - case VK_SHIFT: - ev.data1 = KEY_LSHIFT; - break; - default: - break; - } - } - if (ev.data1) D_PostEvent(&ev); + Impl_HandleKeyboardConsoleEvent(input.Event.KeyEvent, co); break; case MOUSE_EVENT: case WINDOW_BUFFER_SIZE_EVENT: @@ -708,17 +627,6 @@ static inline void I_ShutdownConsole(void){} void I_GetConsoleEvents(void){} static inline void I_StartupConsole(void) { -#ifdef _arch_dreamcast - char title[] = "SRB2 for Dreamcast!\n"; - __set_fpscr(0x00040000); /* ignore FPU underflow */ - //printf("\nHello world!\n\n"); - pvr_init_defaults(); - conio_init(CONIO_TTY_PVR, CONIO_INPUT_LINE); - conio_set_theme(CONIO_THEME_MATRIX); - conio_clear(); - conio_putstr(title); - //printf("\nHello world!\n\n"); -#endif #ifdef _DEBUG consolevent = !M_CheckParm("-noconsole"); #else @@ -738,7 +646,6 @@ static inline void I_ShutdownConsole(void){} // void I_StartupKeyboard (void) { -#if !defined (DC) #ifdef SIGINT signal(SIGINT , quit_handler); #endif @@ -755,7 +662,6 @@ void I_StartupKeyboard (void) signal(SIGSEGV , signal_handler); signal(SIGABRT , signal_handler); signal(SIGFPE , signal_handler); -#endif } // @@ -767,10 +673,6 @@ void I_OutputMsg(const char *fmt, ...) XBOXSTATIC char txt[8192]; va_list argptr; -#ifdef _arch_dreamcast - if (!keyboard_started) conio_printf(fmt); -#endif - va_start(argptr,fmt); vsprintf(txt, fmt, argptr); va_end(argptr); @@ -780,7 +682,7 @@ void I_OutputMsg(const char *fmt, ...) DEFAULTFONTBGR, DEFAULTFONTBGG, DEFAULTFONTBGB, DEFAULTFONTBGA, txt); #endif -#if defined (_WIN32) && !defined (_XBOX) && defined (_MSC_VER) +#if defined (_WIN32) && defined (_MSC_VER) OutputDebugStringA(txt); #endif @@ -795,7 +697,7 @@ void I_OutputMsg(const char *fmt, ...) } #endif -#if defined (_WIN32) && !defined (_XBOX) && !defined(_WIN32_WCE) +#if defined (_WIN32) #ifdef DEBUGFILE if (debugfile != stderr) #endif @@ -909,22 +811,12 @@ INT32 I_GetKey (void) // void I_JoyScale(void) { -#ifdef GP2X - if (JoyInfo.dev && SDL_JoystickIndex(JoyInfo.dev) == 0) - Joystick.bGamepadStyle = true; - else -#endif Joystick.bGamepadStyle = cv_joyscale.value==0; JoyInfo.scale = Joystick.bGamepadStyle?1:cv_joyscale.value; } void I_JoyScale2(void) { -#ifdef GP2X - if (JoyInfo2.dev && SDL_JoystickIndex(JoyInfo2.dev) == 0) - Joystick.bGamepadStyle = true; - else -#endif Joystick2.bGamepadStyle = cv_joyscale2.value==0; JoyInfo2.scale = Joystick2.bGamepadStyle?1:cv_joyscale2.value; } @@ -1027,11 +919,6 @@ void I_GetJoystickEvents(void) event.type = ev_keydown; else event.type = ev_keyup; -#ifdef _PSP - if (i == 12) - event.data1 = KEY_ESCAPE; - else -#endif event.data1 = KEY_JOY1 + i; D_PostEvent(&event); } @@ -1082,13 +969,11 @@ void I_GetJoystickEvents(void) axisy = SDL_JoystickGetAxis(JoyInfo.dev, i*2 + 1); else axisy = 0; -#ifdef _arch_dreamcast // -128 to 127 - axisx = axisx*8; - axisy = axisy*8; -#else // -32768 to 32767 + + // -32768 to 32767 axisx = axisx/32; axisy = axisy/32; -#endif + if (Joystick.bGamepadStyle) { @@ -1206,15 +1091,11 @@ static int joy_open(const char *fname) if (JoyInfo.buttons > JOYBUTTONS) JoyInfo.buttons = JOYBUTTONS; -#ifdef DC - JoyInfo.hats = 0; -#else JoyInfo.hats = SDL_JoystickNumHats(JoyInfo.dev); if (JoyInfo.hats > JOYHATS) JoyInfo.hats = JOYHATS; JoyInfo.balls = SDL_JoystickNumBalls(JoyInfo.dev); -#endif //Joystick.bGamepadStyle = !stricmp(SDL_JoystickName(JoyInfo.dev), "pad"); @@ -1371,13 +1252,9 @@ void I_GetJoystick2Events(void) axisy = SDL_JoystickGetAxis(JoyInfo2.dev, i*2 + 1); else axisy = 0; -#ifdef _arch_dreamcast // -128 to 127 - axisx = axisx*8; - axisy = axisy*8; -#else // -32768 to 32767 + // -32768 to 32767 axisx = axisx/32; axisy = axisy/32; -#endif if (Joystick2.bGamepadStyle) { @@ -1496,15 +1373,11 @@ static int joy_open2(const char *fname) if (JoyInfo2.buttons > JOYBUTTONS) JoyInfo2.buttons = JOYBUTTONS; -#ifdef DC - JoyInfo2.hats = 0; -#else JoyInfo2.hats = SDL_JoystickNumHats(JoyInfo2.dev); if (JoyInfo2.hats > JOYHATS) JoyInfo2.hats = JOYHATS; JoyInfo2.balls = SDL_JoystickNumBalls(JoyInfo2.dev); -#endif //Joystick.bGamepadStyle = !stricmp(SDL_JoystickName(JoyInfo2.dev), "pad"); @@ -1788,7 +1661,7 @@ static void I_ShutdownMouse2(void) if (fdmouse2 != -1) close(fdmouse2); mouse2_started = 0; } -#elif defined (_WIN32) && !defined (_XBOX) +#elif defined (_WIN32) static HANDLE mouse2filehandle = INVALID_HANDLE_VALUE; @@ -1986,7 +1859,7 @@ void I_StartupMouse2(void) } mouse2_started = 1; I_AddExitFunc(I_ShutdownMouse2); -#elif defined (_WIN32) && !defined (_XBOX) +#elif defined (_WIN32) DCB dcb; if (mouse2filehandle != INVALID_HANDLE_VALUE) @@ -2081,7 +1954,7 @@ FUNCMATH ticcmd_t *I_BaseTiccmd2(void) return &emptycmd2; } -#if (defined (_WIN32) && !defined (_WIN32_WCE)) && !defined (_XBOX) +#if defined (_WIN32) static HMODULE winmm = NULL; static DWORD starttickcount = 0; // hack for win2k time bug static p_timeGetTime pfntimeGetTime = NULL; @@ -2151,13 +2024,8 @@ static void I_ShutdownTimer(void) // tic_t I_GetTime (void) { -#ifdef _arch_dreamcast - static Uint64 basetime = 0; - Uint64 ticks = timer_ms_gettime64(); //using timer_ms_gettime64 instand of SDL_GetTicks for the Dreamcast -#else static Uint32 basetime = 0; Uint32 ticks = SDL_GetTicks(); -#endif if (!basetime) basetime = ticks; @@ -2166,11 +2034,7 @@ tic_t I_GetTime (void) ticks = (ticks*TICRATE); -#if 0 //#ifdef _WIN32_WCE - ticks = (ticks/10); -#else ticks = (ticks/1000); -#endif return (tic_t)ticks; } @@ -2181,7 +2045,7 @@ tic_t I_GetTime (void) // FUNCMATH void I_StartupTimer(void) { -#if (defined (_WIN32) && !defined (_WIN32_WCE)) && !defined (_XBOX) +#ifdef _WIN32 // for win2k time bug if (M_CheckParm("-gettickcount")) { @@ -2197,9 +2061,6 @@ FUNCMATH void I_StartupTimer(void) pfntimeGetTime = (p_timeGetTime)GetProcAddress(winmm, "timeGetTime"); } I_AddExitFunc(I_ShutdownTimer); -#elif 0 //#elif !defined (_arch_dreamcast) && !defined(GP2X) // the DC have it own timer and GP2X have broken pthreads? - if (SDL_InitSubSystem(SDL_INIT_TIMER) < 0) - I_Error("SRB2: Needs SDL_Timer, Error: %s", SDL_GetError()); #endif } @@ -2207,35 +2068,14 @@ FUNCMATH void I_StartupTimer(void) void I_Sleep(void) { -#if !(defined (_arch_dreamcast) || defined (_XBOX)) if (cv_sleep.value != -1) SDL_Delay(cv_sleep.value); -#endif } INT32 I_StartupSystem(void) { SDL_version SDLcompiled; SDL_version SDLlinked; -#ifdef _XBOX -#ifdef __GNUC__ - char DP[] =" Sonic Robo Blast 2!\n"; - debugPrint(DP); -#endif - unlink("e:/Games/SRB2/stdout.txt"); - freopen("e:/Games/SRB2/stdout.txt", "w+", stdout); - unlink("e:/Games/SRB2/stderr.txt"); - freopen("e:/Games/SRB2/stderr.txt", "w+", stderr); -#endif -#ifdef _arch_dreamcast -#ifdef _DEBUG - //gdb_init(); -#endif - printf(__FILE__":%i\n",__LINE__); -#ifdef _DEBUG - //gdb_breakpoint(); -#endif -#endif SDL_VERSION(&SDLcompiled) SDL_GetVersion(&SDLlinked); I_StartupConsole(); @@ -2243,11 +2083,7 @@ INT32 I_StartupSystem(void) SDLcompiled.major, SDLcompiled.minor, SDLcompiled.patch); I_OutputMsg("Linked with SDL version: %d.%d.%d\n", SDLlinked.major, SDLlinked.minor, SDLlinked.patch); -#if 0 //#ifdef GP2X //start up everything - if (SDL_Init(SDL_INIT_NOPARACHUTE|SDL_INIT_EVERYTHING) < 0) -#else - if (SDL_Init(SDL_INIT_NOPARACHUTE) < 0) -#endif + if (SDL_Init(0) < 0) I_Error("SRB2: SDL System Error: %s", SDL_GetError()); //Alam: Oh no.... #ifndef NOMUMBLE I_SetupMumble(); @@ -2289,9 +2125,7 @@ void I_Quit(void) I_ShutdownGraphics(); I_ShutdownInput(); I_ShutdownSystem(); -#ifndef _arch_dreamcast SDL_Quit(); -#endif /* if option -noendtxt is set, don't print the text */ if (!M_CheckParm("-noendtxt") && W_CheckNumForName("ENDOOM") != LUMPERROR) { @@ -2300,10 +2134,6 @@ void I_Quit(void) } death: W_Shutdown(); -#ifdef GP2X - chdir("/usr/gp2x"); - execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL); -#endif exit(0); } @@ -2356,10 +2186,8 @@ void I_Error(const char *error, ...) I_ShutdownInput(); if (errorcount == 7) I_ShutdownSystem(); -#ifndef _arch_dreamcast if (errorcount == 8) SDL_Quit(); -#endif if (errorcount == 9) { M_SaveConfig(NULL); @@ -2378,12 +2206,6 @@ void I_Error(const char *error, ...) buffer, NULL); W_Shutdown(); - -#ifdef GP2X - chdir("/usr/gp2x"); - execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL); -#endif - exit(-1); // recursive errors detected } } @@ -2419,9 +2241,7 @@ void I_Error(const char *error, ...) I_ShutdownGraphics(); I_ShutdownInput(); I_ShutdownSystem(); -#ifndef _arch_dreamcast SDL_Quit(); -#endif // Implement message box with SDL_ShowSimpleMessageBox, // which should fail gracefully if it can't put a message box up @@ -2441,11 +2261,6 @@ void I_Error(const char *error, ...) *(INT32 *)2 = 4; //Alam: Debug! #endif -#ifdef GP2X - chdir("/usr/gp2x"); - execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL); -#endif - exit(-1); } @@ -2508,7 +2323,7 @@ void I_ShutdownSystem(void) for (c = MAX_QUIT_FUNCS-1; c >= 0; c--) if (quit_funcs[c]) (*quit_funcs[c])(); -#ifdef LOGMESSAGES +#ifdef LOGMESSAGES if (logstream) { I_OutputMsg("I_ShutdownSystem(): end of logstream.\n"); @@ -2521,10 +2336,8 @@ void I_ShutdownSystem(void) void I_GetDiskFreeSpace(INT64 *freespace) { -#if defined (_arch_dreamcast) || defined (_PSP) - *freespace = 0; -#elif defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) -#if defined (SOLARIS) || defined (__HAIKU__) || defined (_WII) || defined (_PS3) +#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) +#if defined (SOLARIS) || defined (__HAIKU__) *freespace = INT32_MAX; return; #else // Both Linux and BSD have this, apparently. @@ -2536,7 +2349,7 @@ void I_GetDiskFreeSpace(INT64 *freespace) } *freespace = stfs.f_bavail * stfs.f_bsize; #endif -#elif (defined (_WIN32) && !defined (_WIN32_WCE)) && !defined (_XBOX) +#elif defined (_WIN32) static p_GetDiskFreeSpaceExA pfnGetDiskFreeSpaceEx = NULL; static boolean testwin95 = false; ULARGE_INTEGER usedbytes, lfreespace; @@ -2567,13 +2380,6 @@ void I_GetDiskFreeSpace(INT64 *freespace) char *I_GetUserName(void) { -#ifdef GP2X - static char username[MAXPLAYERNAME] = "GP2XUSER"; - return username; -#elif defined (PSP) - static char username[MAXPLAYERNAME] = "PSPUSER"; - return username; -#elif !(defined (_WIN32_WCE) || defined (_XBOX)) static char username[MAXPLAYERNAME]; char *p; #ifdef _WIN32 @@ -2605,7 +2411,6 @@ char *I_GetUserName(void) if (strcmp(username, "") != 0) return username; -#endif return NULL; // dummy for platform independent version } @@ -2614,7 +2419,7 @@ INT32 I_mkdir(const char *dirname, INT32 unixright) //[segabor] #if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) || defined (__CYGWIN__) || defined (__OS2__) return mkdir(dirname, unixright); -#elif (defined (_WIN32) || (defined (_WIN32_WCE) && !defined (__GNUC__))) && !defined (_XBOX) +#elif defined (_WIN32) UNREFERENCED_PARAMETER(unixright); /// \todo should implement ntright under nt... return CreateDirectoryA(dirname, NULL); #else @@ -2628,9 +2433,6 @@ char *I_GetEnv(const char *name) { #ifdef NEED_SDL_GETENV return SDL_getenv(name); -#elif defined(_WIN32_WCE) - (void)name; - return NULL; #else return getenv(name); #endif @@ -2640,8 +2442,6 @@ INT32 I_PutEnv(char *variable) { #ifdef NEED_SDL_GETENV return SDL_putenv(variable); -#elif defined(_WIN32_WCE) - return ((variable)?-1:0); #else return putenv(variable); #endif @@ -2781,15 +2581,6 @@ static const char *locateWad(void) if (((envstr = I_GetEnv("SRB2WADDIR")) != NULL) && isWadPathOk(envstr)) return envstr; -#if defined(_WIN32_WCE) || defined(_PS3) || defined(_PSP) - // examine argv[0] - strcpy(returnWadPath, myargv[0]); - pathonly(returnWadPath); - I_PutEnv(va("HOME=%s",returnWadPath)); - if (isWadPathOk(returnWadPath)) - return returnWadPath; -#endif - #ifndef NOCWD I_OutputMsg(",."); // examine current dir @@ -2908,9 +2699,9 @@ const char *I_LocateWad(void) if (waddir) { // change to the directory where we found srb2.srb -#if (defined (_WIN32) && !defined (_WIN32_WCE)) && !defined (_XBOX) +#if defined (_WIN32) SetCurrentDirectoryA(waddir); -#elif !defined (_WIN32_WCE) && !defined (_PS3) +#else if (chdir(waddir) == -1) I_OutputMsg("Couldn't change working directory\n"); #endif @@ -2927,17 +2718,7 @@ const char *I_LocateWad(void) // quick fix for compil UINT32 I_GetFreeMem(UINT32 *total) { -#if defined (_arch_dreamcast) - //Dreamcast! - if (total) - *total = 16<<20; - return 8<<20; -#elif defined (_PSP) - // PSP - if (total) - *total = 32<<20; - return 16<<20; -#elif defined (FREEBSD) +#ifdef FREEBSD struct vmmeter sum; kvm_t *kd; struct nlist namelist[] = @@ -2974,7 +2755,7 @@ UINT32 I_GetFreeMem(UINT32 *total) if (total) *total = 32 << 20; return 32 << 20; -#elif (defined (_WIN32) || (defined (_WIN32_WCE) && !defined (__GNUC__))) && !defined (_XBOX) +#elif defined (_WIN32) MEMORYSTATUS info; info.dwLength = sizeof (MEMORYSTATUS); @@ -3046,7 +2827,7 @@ UINT32 I_GetFreeMem(UINT32 *total) const CPUInfoFlags *I_CPUInfo(void) { -#if (defined (_WIN32) && !defined (_WIN32_WCE)) && !defined (_XBOX) +#if defined (_WIN32) static CPUInfoFlags WIN_CPUInfo; SYSTEM_INFO SI; p_IsProcessorFeaturePresent pfnCPUID = (p_IsProcessorFeaturePresent)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsProcessorFeaturePresent"); diff --git a/src/sdl/i_ttf.c b/src/sdl/i_ttf.c index 4a41f120..f2cd497e 100644 --- a/src/sdl/i_ttf.c +++ b/src/sdl/i_ttf.c @@ -26,10 +26,7 @@ #include "i_ttf.h" // Search directories to find aforementioned TTF file. -#ifdef _PS3 -#include -#define FONTSEARCHPATH1 "/dev_hdd0/game/SRB2-PS3_/USRDIR/etc" -#elif defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) +#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) #define FONTSEARCHPATH1 "/usr/share/fonts" #define FONTSEARCHPATH2 "/usr/local/share/fonts" #define FONTSEARCHPATH3 "/usr/games/SRB2" @@ -233,16 +230,9 @@ void I_StartupTTF(UINT32 fontpointsize, Uint32 initflags, Uint32 vidmodeflags) { char *fontpath = NULL; INT32 fontstatus = -1; -#ifdef _PS3 - videoState state; - videoGetState(0, 0, &state); - videoGetResolution(state.displayMode.resolution, &res); - bitsperpixel = 24; -#else res.width = 320; res.height = 200; bitsperpixel = 8; -#endif // what's the point of trying to display an error? // SDL_ttf is not started, can't display anything to screen (presumably)... diff --git a/src/sdl/i_ttf.h b/src/sdl/i_ttf.h index 929c8021..5fae9ed1 100644 --- a/src/sdl/i_ttf.h +++ b/src/sdl/i_ttf.h @@ -57,13 +57,12 @@ int currentfonthinting; int currentfontoutline; #endif -#ifndef _PS3 typedef struct { UINT16 width; UINT16 height; } VideoResolution; -#endif + UINT8 bitsperpixel; typedef enum diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index f3691c90..f35fe9be 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -47,7 +47,7 @@ #include "../doomdef.h" -#if defined (_WIN32) +#ifdef _WIN32 #include "SDL_syswm.h" #endif @@ -107,6 +107,9 @@ static SDL_bool disable_mouse = SDL_FALSE; // first entry in the modelist which is not bigger than MAXVIDWIDTHxMAXVIDHEIGHT static INT32 firstEntry = 0; +// Total mouse motion X/Y offsets +static INT32 mousemovex = 0, mousemovey = 0; + // SDL vars static SDL_Surface *vidSurface = NULL; static SDL_Surface *bufSurface = NULL; @@ -119,7 +122,8 @@ static Uint8 BitsPerPixel = 16; Uint16 realwidth = BASEVIDWIDTH; Uint16 realheight = BASEVIDHEIGHT; static SDL_bool mousegrabok = SDL_TRUE; -#define HalfWarpMouse(x,y) SDL_WarpMouseInWindow(window, (Uint16)(x/2),(Uint16)(y/2)) +static SDL_bool wrapmouseok = SDL_FALSE; +#define HalfWarpMouse(x,y) if (wrapmouseok) SDL_WarpMouseInWindow(window, (Uint16)(x/2),(Uint16)(y/2)) static SDL_bool videoblitok = SDL_FALSE; static SDL_bool exposevideo = SDL_FALSE; static SDL_bool usesdl2soft = SDL_FALSE; @@ -158,7 +162,7 @@ static INT32 windowedModes[MAXWINMODES][2] = static void Impl_VideoSetupSDLBuffer(void); static void Impl_VideoSetupBuffer(void); static SDL_bool Impl_CreateWindow(SDL_bool fullscreen); -static void Impl_SetWindowName(const char *title); +//static void Impl_SetWindowName(const char *title); static void Impl_SetWindowIcon(void); static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) @@ -181,15 +185,13 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) wasfullscreen = SDL_TRUE; SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP); } - else if (wasfullscreen) - { - wasfullscreen = SDL_FALSE; - SDL_SetWindowFullscreen(window, 0); - SDL_SetWindowSize(window, width, height); - SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED_DISPLAY(1), SDL_WINDOWPOS_CENTERED_DISPLAY(1)); - } - else + else // windowed mode { + if (wasfullscreen) + { + wasfullscreen = SDL_FALSE; + SDL_SetWindowFullscreen(window, 0); + } // Reposition window only in windowed mode SDL_SetWindowSize(window, width, height); SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED_DISPLAY(1), SDL_WINDOWPOS_CENTERED_DISPLAY(1)); @@ -350,6 +352,8 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code) static void SDLdoUngrabMouse(void) { SDL_SetWindowGrab(window, SDL_FALSE); + wrapmouseok = SDL_FALSE; + SDL_SetRelativeMouseMode(SDL_FALSE); } void SDLforceUngrabMouse(void) @@ -357,6 +361,8 @@ void SDLforceUngrabMouse(void) if (SDL_WasInit(SDL_INIT_VIDEO)==SDL_INIT_VIDEO && window != NULL) { SDL_SetWindowGrab(window, SDL_FALSE); + wrapmouseok = SDL_FALSE; + SDL_SetRelativeMouseMode(SDL_FALSE); } } @@ -605,36 +611,43 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type) static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt) { - event_t event; - int wwidth, wheight; - if (USE_MOUSEINPUT) { - SDL_GetWindowSize(window, &wwidth, &wheight); - if ((SDL_GetMouseFocus() != window && SDL_GetKeyboardFocus() != window)) { SDLdoUngrabMouse(); return; } + // If using relative mouse mode, don't post an event_t just now, + // add on the offsets so we can make an overall event later. + if (SDL_GetRelativeMouseMode()) + { + if (SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window) + { + mousemovex += evt.xrel; + mousemovey += -evt.yrel; + SDL_SetWindowGrab(window, SDL_TRUE); + } + return; + } + + // If the event is from warping the pointer to middle + // of the screen then ignore it. if ((evt.x == realwidth/2) && (evt.y == realheight/2)) { return; } - else - { - event.data2 = (INT32)lround((evt.xrel) * ((float)wwidth / (float)realwidth)); - event.data3 = (INT32)lround(-evt.yrel * ((float)wheight / (float)realheight)); - } - - event.type = ev_mouse; + // Don't send an event_t if not in relative mouse mode anymore, + // just grab and set relative mode + // this fixes the stupid camera jerk on mouse entering bug + // -- Monster Iestyn if (SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window) { - D_PostEvent(&event); SDL_SetWindowGrab(window, SDL_TRUE); - HalfWarpMouse(wwidth, wheight); + if (SDL_SetRelativeMouseMode(SDL_TRUE) == 0) // already warps mouse if successful + wrapmouseok = SDL_TRUE; // TODO: is wrapmouseok or HalfWarpMouse needed anymore? } } } @@ -782,13 +795,15 @@ void I_GetEvent(void) SDL_Event evt; // We only want the first motion event, // otherwise we'll end up catching the warp back to center. - int mouseMotionOnce = 0; + //int mouseMotionOnce = 0; if (!graphics_started) { return; } + mousemovex = mousemovey = 0; + while (SDL_PollEvent(&evt)) { switch (evt.type) @@ -801,8 +816,9 @@ void I_GetEvent(void) Impl_HandleKeyboardEvent(evt.key, evt.type); break; case SDL_MOUSEMOTION: - if (!mouseMotionOnce) Impl_HandleMouseMotionEvent(evt.motion); - mouseMotionOnce = 1; + //if (!mouseMotionOnce) + Impl_HandleMouseMotionEvent(evt.motion); + //mouseMotionOnce = 1; break; case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONDOWN: @@ -825,6 +841,20 @@ void I_GetEvent(void) } } + // Send all relative mouse movement as one single mouse event. + if (mousemovex || mousemovey) + { + event_t event; + int wwidth, wheight; + SDL_GetWindowSize(window, &wwidth, &wheight); + //SDL_memset(&event, 0, sizeof(event_t)); + event.type = ev_mouse; + event.data1 = 0; + event.data2 = (INT32)lround(mousemovex * ((float)wwidth / (float)realwidth)); + event.data3 = (INT32)lround(mousemovey * ((float)wheight / (float)realheight)); + D_PostEvent(&event); + } + // In order to make wheels act like buttons, we have to set their state to Up. // This is because wheel messages don't have an up/down state. gamekeydown[KEY_MOUSEWHEELDOWN] = gamekeydown[KEY_MOUSEWHEELUP] = 0; @@ -838,7 +868,9 @@ void I_StartupMouse(void) return; if (!firsttimeonmouse) + { HalfWarpMouse(realwidth, realheight); // warp to center + } else firsttimeonmouse = SDL_FALSE; if (cv_usemouse.value) @@ -899,7 +931,7 @@ static inline boolean I_SkipFrame(void) { static boolean skip = false; - if (render_soft != rendermode) + if (rendermode != render_soft) return false; skip = !skip; @@ -909,6 +941,7 @@ static inline boolean I_SkipFrame(void) case GS_LEVEL: if (!paused) return false; + /* FALLTHRU */ case GS_TIMEATTACK: case GS_WAITINGPLAYERS: return skip; // Skip odd frames @@ -931,7 +964,7 @@ void I_FinishUpdate(void) if (cv_ticrate.value) SCR_DisplayTicRate(); - if (render_soft == rendermode && screens[0]) + if (rendermode == render_soft && screens[0]) { SDL_Rect rect; @@ -958,7 +991,7 @@ void I_FinishUpdate(void) } #ifdef HWRENDER - else + else if (rendermode == render_opengl) { OglSdlFinishUpdate(cv_vidwait.value); } @@ -1186,11 +1219,11 @@ INT32 VID_SetMode(INT32 modeNum) } vid.modenum = -1; } - Impl_SetWindowName("SRB2Kart "VERSIONSTRING); + //Impl_SetWindowName("SRB2Kart "VERSIONSTRING); - SDLSetMode(windowedModes[modeNum][0], windowedModes[modeNum][1], USE_FULLSCREEN); + SDLSetMode(vid.width, vid.height, USE_FULLSCREEN); - if (render_soft == rendermode) + if (rendermode == render_soft) { if (bufSurface) { @@ -1209,30 +1242,20 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen) int flags = 0; if (rendermode == render_none) // dedicated - { return SDL_TRUE; // Monster Iestyn -- not sure if it really matters what we return here tbh - } if (window != NULL) - { return SDL_FALSE; - } if (fullscreen) - { flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; - } if (borderlesswindow) - { flags |= SDL_WINDOW_BORDERLESS; - } #ifdef HWRENDER if (rendermode == render_opengl) - { flags |= SDL_WINDOW_OPENGL; - } #endif // Create a window @@ -1261,7 +1284,13 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen) #endif if (rendermode == render_soft) { - renderer = SDL_CreateRenderer(window, -1, (usesdl2soft ? SDL_RENDERER_SOFTWARE : 0) | (cv_vidwait.value && !usesdl2soft ? SDL_RENDERER_PRESENTVSYNC : 0)); + flags = 0; // Use this to set SDL_RENDERER_* flags now + if (usesdl2soft) + flags |= SDL_RENDERER_SOFTWARE; + else if (cv_vidwait.value) + flags |= SDL_RENDERER_PRESENTVSYNC; + + renderer = SDL_CreateRenderer(window, -1, flags); if (renderer == NULL) { CONS_Printf(M_GetText("Couldn't create rendering context: %s\n"), SDL_GetError()); @@ -1273,14 +1302,16 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen) return SDL_TRUE; } +/* static void Impl_SetWindowName(const char *title) { - if (window != NULL) + if (window == NULL) { return; } SDL_SetWindowTitle(window, title); } +*/ static void Impl_SetWindowIcon(void) { @@ -1483,7 +1514,7 @@ void I_ShutdownGraphics(void) rendermode = render_none; if (icoSurface) SDL_FreeSurface(icoSurface); icoSurface = NULL; - if (render_soft == oldrendermode) + if (oldrendermode == render_soft) { if (vidSurface) SDL_FreeSurface(vidSurface); vidSurface = NULL; diff --git a/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj b/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj index fbf9bacb..68391f99 100644 --- a/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj +++ b/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj @@ -1214,7 +1214,7 @@ C01FCF4B08A954540054247B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 2.1.18; + CURRENT_PROJECT_VERSION = 2.1.19; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", NORMALSRB2, @@ -1226,7 +1226,7 @@ C01FCF4C08A954540054247B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 2.1.18; + CURRENT_PROJECT_VERSION = 2.1.19; GCC_ENABLE_FIX_AND_CONTINUE = NO; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 88bbadd2..71832459 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -43,12 +43,10 @@ #define HAVE_ZLIB #ifndef _MSC_VER -#ifndef _WII #ifndef _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE #endif #endif -#endif #ifndef _LFS64_LARGEFILE #define _LFS64_LARGEFILE diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index 21afd831..cd7ced7c 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -71,7 +71,6 @@ INT32 oglflags = 0; void *GLUhandle = NULL; SDL_GLContext sdlglcontext = 0; -#ifndef STATIC_OPENGL void *GetGLFunc(const char *proc) { if (strncmp(proc, "glu", 3) == 0) @@ -83,7 +82,6 @@ void *GetGLFunc(const char *proc) } return SDL_GL_GetProcAddress(proc); } -#endif boolean LoadGL(void) { diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index 99d30b74..3e837267 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -49,7 +49,7 @@ #define MIX_CHANNELS 8 #endif -#if defined (_WIN32) && !defined (_WIN32_WCE) && !defined (_XBOX) +#ifdef _WIN32 #include #elif defined (__GNUC__) #include @@ -85,21 +85,11 @@ // mixing buffer, and the samplerate of the raw data. // Needed for calling the actual sound output. -#if defined (_WIN32_WCE) || defined (DC) || defined (PSP) || defined(GP2X) -#define NUM_CHANNELS MIX_CHANNELS -#else #define NUM_CHANNELS MIX_CHANNELS*4 -#endif #define INDEXOFSFX(x) ((sfxinfo_t *)x - S_sfx) -#if defined (_WIN32_WCE) || defined (DC) || defined (PSP) -static Uint16 samplecount = 512; //Alam: .5KB samplecount at 11025hz is 46.439909297052154195011337868481ms of buffer -#elif defined(GP2X) -static Uint16 samplecount = 128; -#else static Uint16 samplecount = 1024; //Alam: 1KB samplecount at 22050hz is 46.439909297052154195011337868481ms of buffer -#endif typedef struct chan_struct { @@ -151,17 +141,10 @@ static SDL_bool musicStarted = SDL_FALSE; #ifdef HAVE_MIXER static SDL_mutex *Msc_Mutex = NULL; /* FIXME: Make this file instance-specific */ -#ifdef _arch_dreamcast -#define MIDI_PATH "/ram" -#elif defined(GP2X) -#define MIDI_PATH "/mnt/sd/srb2" -#define MIDI_PATH2 "/tmp/mnt/sd/srb2" -#else #define MIDI_PATH srb2home #if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) #define MIDI_PATH2 "/tmp" #endif -#endif #define MIDI_TMPFILE "srb2music" #define MIDI_TMPFILE2 "srb2wav" static INT32 musicvol = 62; @@ -176,7 +159,7 @@ static SDL_bool canlooping = SDL_TRUE; #if SDL_MIXER_VERSION_ATLEAST(1,2,7) #define USE_RWOPS // ok, USE_RWOPS is in here -#if defined (DC) || defined (_WIN32_WCE) || defined (_XBOX) //|| defined(_WIN32) || defined(GP2X) +#if 0 // defined(_WIN32) #undef USE_RWOPS #endif #endif @@ -1188,13 +1171,6 @@ void I_StartupSound(void) #endif #ifndef HAVE_MIXER nomidimusic = nodigimusic = true; -#endif -#ifdef DC - //nosound = true; -#ifdef HAVE_MIXER - nomidimusic = true; - nodigimusic = true; -#endif #endif memset(channels, 0, sizeof (channels)); //Alam: Clean it @@ -1243,13 +1219,7 @@ void I_StartupSound(void) audio.samples /= 2; } -#if defined (_PSP) && defined (HAVE_MIXER) // Bug in PSP's SDL_OpenAudio, can not open twice - I_SetChannels(); - sound_started = true; - Snd_Mutex = SDL_CreateMutex(); -#else if (nosound) -#endif return; #ifdef HW3SOUND @@ -1302,7 +1272,7 @@ void I_StartupSound(void) snddev.bps = 16; snddev.sample_rate = audio.freq; snddev.numsfxs = NUMSFX; -#if defined (_WIN32) && !defined (_XBOX) +#if defined (_WIN32) snddev.cooplevel = 0x00000002; snddev.hWnd = vid.WndParent; #endif @@ -1520,9 +1490,7 @@ void I_InitMusic(void) I_OutputMsg("Compiled for SDL_mixer version: %d.%d.%d\n", MIXcompiled.major, MIXcompiled.minor, MIXcompiled.patch); #ifdef MIXER_POS -#ifndef _WII if (MIXlinked->major == 1 && MIXlinked->minor == 2 && MIXlinked->patch < 7) -#endif canlooping = SDL_FALSE; #endif #ifdef USE_RWOPS @@ -1531,13 +1499,11 @@ void I_InitMusic(void) #endif I_OutputMsg("Linked with SDL_mixer version: %d.%d.%d\n", MIXlinked->major, MIXlinked->minor, MIXlinked->patch); -#if !(defined (DC) || defined (PSP) || defined(GP2X) || defined (WII)) if (audio.freq < 44100 && !M_CheckParm ("-freq")) //I want atleast 44Khz { audio.samples = (Uint16)(audio.samples*(INT32)(44100/audio.freq)); audio.freq = 44100; //Alam: to keep it around the same XX ms } -#endif if (sound_started #ifdef HW3SOUND @@ -1929,7 +1895,7 @@ boolean I_StartDigSong(const char *musicname, boolean looping) if (loopstart > 0) { loopstartDig = (double)((44.1l+loopstart) / 44100.0l); //8 PCM chucks off and PCM to secs -//#ifdef GP2X//#ifdef PARANOIA +//#ifdef PARANOIA //I_OutputMsg("I_StartDigSong: setting looping point to %ul PCMs(%f seconds)\n", loopstart, loopstartDig); //#endif } diff --git a/src/sdl12/MakeCYG.cfg b/src/sdl12/MakeCYG.cfg index 5907579c..b55d9dc5 100644 --- a/src/sdl12/MakeCYG.cfg +++ b/src/sdl12/MakeCYG.cfg @@ -1,5 +1,5 @@ # -# sdl/makeCYG.cfg for SRB2/Cygwin +# sdl12/makeCYG.cfg for SRB2/Cygwin # # diff --git a/src/sdl12/MakeNIX.cfg b/src/sdl12/MakeNIX.cfg index 457f5230..1278aaf0 100644 --- a/src/sdl12/MakeNIX.cfg +++ b/src/sdl12/MakeNIX.cfg @@ -1,5 +1,5 @@ # -# sdl/makeNIX.cfg for SRB2/?nix +# sdl12/makeNIX.cfg for SRB2/?nix # #Valgrind support diff --git a/src/sdl12/Makefile.cfg b/src/sdl12/Makefile.cfg index 1d404c4c..8d9ebc35 100644 --- a/src/sdl12/Makefile.cfg +++ b/src/sdl12/Makefile.cfg @@ -1,5 +1,5 @@ # -# sdl/makefile.cfg for SRB2/SDL +# sdl12/makefile.cfg for SRB2/SDL # # @@ -7,35 +7,35 @@ # ifdef UNIXCOMMON -include sdl/MakeNIX.cfg +include sdl12/MakeNIX.cfg endif ifdef PANDORA -include sdl/SRB2Pandora/Makefile.cfg +include sdl12/SRB2Pandora/Makefile.cfg endif #ifdef PANDORA ifdef DC -include sdl/SRB2DC/Makefile.cfg +include sdl12/SRB2DC/Makefile.cfg endif #ifdef DC ifdef PS3N -include sdl/SRB2PS3/Makefile.cfg +include sdl12/SRB2PS3/Makefile.cfg endif #ifdef PS3N ifdef PSP -include sdl/SRB2PSP/Makefile.cfg +include sdl12/SRB2PSP/Makefile.cfg endif #ifdef PSP ifdef XBOX -include sdl/SRB2XBOX/Makefile.cfg +include sdl12/SRB2XBOX/Makefile.cfg endif #ifdef XBOX ifdef WINCE -include sdl/SRB2CE/Makefile.cfg +include sdl12/SRB2CE/Makefile.cfg endif #ifef WINCE ifdef CYGWIN32 -include sdl/MakeCYG.cfg +include sdl12/MakeCYG.cfg endif #ifdef CYGWIN32 ifdef SDL_PKGCONFIG @@ -151,7 +151,7 @@ endif # FIXME: DevkitPPC and ready-compiled SDL Wii require these things to be in a silly order ifdef WII -include sdl/SRB2WII/Makefile.cfg +include sdl12/SRB2WII/Makefile.cfg endif #ifdef WII CFLAGS+=$(SDL_CFLAGS) diff --git a/src/sdl12/SRB2PS3/Makefile.cfg b/src/sdl12/SRB2PS3/Makefile.cfg index a4a01714..80f8db7b 100644 --- a/src/sdl12/SRB2PS3/Makefile.cfg +++ b/src/sdl12/SRB2PS3/Makefile.cfg @@ -27,10 +27,10 @@ PKGNAME?=SRB2PS3.pkg endif DGBNAME?=$(EXENAME).debug -SRB2PS3DIR=sdl/SRB2PS3 +SRB2PS3DIR=sdl12/SRB2PS3 ICON0?=$(SRB2PS3DIR)/ICON0.png SFOXML?=sfo.xml -SRB2TTF?=sdl/srb2.ttf +SRB2TTF?=sdl12/srb2.ttf TITLE=Sonic Robo Blast 2 v2.0.6 APPID=SRB2-PS3 diff --git a/src/sdl12/SRB2PSP/Makefile.cfg b/src/sdl12/SRB2PSP/Makefile.cfg index f9ec6416..5e4c0ba2 100644 --- a/src/sdl12/SRB2PSP/Makefile.cfg +++ b/src/sdl12/SRB2PSP/Makefile.cfg @@ -36,14 +36,14 @@ endif PSP_EBOOT_TITLE=SRB2-PSP vME PSP_EBOOT_SFO=$(BIN)/PARAM.SFO - PSP_EBOOT_ICON=sdl/SRB2PSP/ICON0.png + PSP_EBOOT_ICON=sdl12/SRB2PSP/ICON0.png PSP_EBOOT_ICON1=NULL PSP_EBOOT_UNKPNG=NULL - PSP_EBOOT_PIC1=sdl/SRB2PSP/PIC1.png + PSP_EBOOT_PIC1=sdl12/SRB2PSP/PIC1.png PSP_EBOOT_SND0=NULL PSP_EBOOT_PSAR=NULL - SIGNER?=sdl/SRB2PSP/psp-prxsign/psp-prxsign + SIGNER?=sdl12/SRB2PSP/psp-prxsign/psp-prxsign SDL=1 PREFIX=psp @@ -100,8 +100,8 @@ kxploit: $(BIN)/$(EXENAME) $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1) \ $(PSP_EBOOT_SND0) NULL $(PSP_EBOOT_PSAR) -sdl/SRB2PSP/psp-prxsign/psp-prxsign: - -$(MAKE) -C sdl/SRB2PSP/psp-prxsign CFLAGS=-pipe CC="$(HOSTCC)" +sdl12/SRB2PSP/psp-prxsign/psp-prxsign: + -$(MAKE) -C sdl12/SRB2PSP/psp-prxsign CFLAGS=-pipe CC="$(HOSTCC)" fix-up: $(BIN)/$(EXENAME) @echo Running psp-fixup-imports on $(EXENAME) diff --git a/src/sdl12/SRB2Pandora/Makefile.cfg b/src/sdl12/SRB2Pandora/Makefile.cfg index c7f0f844..1f057a21 100644 --- a/src/sdl12/SRB2Pandora/Makefile.cfg +++ b/src/sdl12/SRB2Pandora/Makefile.cfg @@ -2,8 +2,8 @@ PNDNAME=SRB2.pnd PNDDIR=$(BIN)/pnd -ICON=sdl/SRB2Pandora/icon.png -PXML=sdl/SRB2Pandora/PXML.xml +ICON=sdl12/SRB2Pandora/icon.png +PXML=sdl12/SRB2Pandora/PXML.xml SED=sed CAT=cat diff --git a/src/sdl12/SRB2WII/Makefile.cfg b/src/sdl12/SRB2WII/Makefile.cfg index 1b186304..778d2c3d 100644 --- a/src/sdl12/SRB2WII/Makefile.cfg +++ b/src/sdl12/SRB2WII/Makefile.cfg @@ -16,8 +16,8 @@ EXENAME?=$(SRB2NAME).elf DBGNAME?=$(SRB2NAME).elf.debug DOLNAME?=$(SRB2NAME).dol -ICONPNG?=sdl/SRB2WII/icon.png -METAXML?=sdl/SRB2WII/meta.xml +ICONPNG?=sdl12/SRB2WII/icon.png +METAXML?=sdl12/SRB2WII/meta.xml APPDIR=apps/$(SRB2NAME) ZIPNAME=$(SRB2NAME).zip diff --git a/src/sdl12/macosx/Srb2mac.xcodeproj/project.pbxproj b/src/sdl12/macosx/Srb2mac.xcodeproj/project.pbxproj index 98a760c7..fada7849 100644 --- a/src/sdl12/macosx/Srb2mac.xcodeproj/project.pbxproj +++ b/src/sdl12/macosx/Srb2mac.xcodeproj/project.pbxproj @@ -1214,7 +1214,7 @@ C01FCF4B08A954540054247B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 2.1.18; + CURRENT_PROJECT_VERSION = 2.1.19; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", NORMALSRB2, @@ -1226,7 +1226,7 @@ C01FCF4C08A954540054247B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 2.1.18; + CURRENT_PROJECT_VERSION = 2.1.19; GCC_ENABLE_FIX_AND_CONTINUE = NO; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( diff --git a/src/sounds.c b/src/sounds.c index 3c077f55..1881385d 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -518,7 +518,7 @@ void S_InitRuntimeSounds (void) { sfxenum_t i; INT32 value; - char soundname[7]; + char soundname[10]; for (i = sfx_freeslot0; i <= sfx_lastskinsoundslot; i++) { diff --git a/src/v_video.c b/src/v_video.c index b3906997..bda2f5e8 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1083,6 +1083,7 @@ char *V_WordWrap(INT32 x, INT32 w, INT32 option, const char *string) { case V_MONOSPACE: spacewidth = 8; + /* FALLTHRU */ case V_OLDSPACING: charwidth = 8; break; @@ -1160,6 +1161,7 @@ void V_DrawString(INT32 x, INT32 y, INT32 option, const char *string) { case V_MONOSPACE: spacewidth = 8; + /* FALLTHRU */ case V_OLDSPACING: charwidth = 8; break; @@ -1364,6 +1366,7 @@ void V_DrawSmallString(INT32 x, INT32 y, INT32 option, const char *string) { case V_MONOSPACE: spacewidth = 4; + /* FALLTHRU */ case V_OLDSPACING: charwidth = 4; break; @@ -1465,6 +1468,7 @@ void V_DrawThinString(INT32 x, INT32 y, INT32 option, const char *string) { case V_MONOSPACE: spacewidth = 5; + /* FALLTHRU */ case V_OLDSPACING: charwidth = 5; break; @@ -1558,6 +1562,7 @@ void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) { case V_MONOSPACE: spacewidth = 8; + /* FALLTHRU */ case V_OLDSPACING: charwidth = 8; break; @@ -1842,6 +1847,7 @@ INT32 V_StringWidth(const char *string, INT32 option) { case V_MONOSPACE: spacewidth = 8; + /* FALLTHRU */ case V_OLDSPACING: charwidth = 8; break; @@ -1880,6 +1886,7 @@ INT32 V_SmallStringWidth(const char *string, INT32 option) { case V_MONOSPACE: spacewidth = 4; + /* FALLTHRU */ case V_OLDSPACING: charwidth = 4; break; @@ -1918,6 +1925,7 @@ INT32 V_ThinStringWidth(const char *string, INT32 option) { case V_MONOSPACE: spacewidth = 5; + /* FALLTHRU */ case V_OLDSPACING: charwidth = 5; break; diff --git a/src/win32/win_cd.c b/src/win32/win_cd.c index d73b9552..ae13d3e5 100644 --- a/src/win32/win_cd.c +++ b/src/win32/win_cd.c @@ -180,9 +180,9 @@ static LPSTR hms(UINT seconds) hours = minutes / 60; minutes %= 60; if (hours > 0) - sprintf (s, "%lu:%02lu:%02lu", hours, minutes, seconds); + sprintf (s, "%lu:%02lu:%02lu", (long unsigned int)hours, (long unsigned int)minutes, (long unsigned int)seconds); else - sprintf (s, "%2lu:%02lu", minutes, seconds); + sprintf (s, "%2lu:%02lu", (long unsigned int)minutes, (long unsigned int)seconds); return s; } diff --git a/src/win32/win_main.c b/src/win32/win_main.c index 8f2d70e1..943c5528 100644 --- a/src/win32/win_main.c +++ b/src/win32/win_main.c @@ -470,7 +470,7 @@ static inline BOOL tlErrorMessage(const TCHAR *err) // // warn user if there is one // - printf("Error %Ts..\n", err); + printf("Error %s..\n", err); fflush(stdout); MessageBox(hWndMain, err, TEXT("ERROR"), MB_OK); diff --git a/src/y_inter.c b/src/y_inter.c index c23cf735..c2b210d1 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -57,7 +57,7 @@ typedef union { struct { - char passed1[14]; // KNUCKLES GOT / CRAWLA HONCHO + char passed1[21]; // KNUCKLES GOT / CRAWLA HONCHO char passed2[16]; // THROUGH THE ACT / PASSED THE ACT INT32 passedx1; INT32 passedx2; @@ -77,7 +77,7 @@ typedef union struct { - char passed1[SKINNAMESIZE+1]; // KNUCKLES GOT / CRAWLA HONCHO + char passed1[29]; // KNUCKLES GOT / CRAWLA HONCHO char passed2[17]; // A CHAOS EMERALD / GOT THEM ALL! char passed3[15]; // CAN NOW BECOME char passed4[SKINNAMESIZE+7]; // SUPER CRAWLA HONCHO @@ -164,6 +164,20 @@ static void Y_CalculateMatchWinners(void); static void Y_FollowIntermission(void); static void Y_UnloadData(void); +// Stuff copy+pasted from st_stuff.c +static INT32 SCX(INT32 x) +{ + return FixedInt(FixedMul(x<