diff --git a/LUASTUFF.md b/LUASTUFF.md index 8960fad48..83ec76545 100644 --- a/LUASTUFF.md +++ b/LUASTUFF.md @@ -161,6 +161,37 @@ Duration is in milliseconds and is optional to set, default value is 84ms. Exactly same as P_CheckSight but uses cheaper algorithm, useful for things like nametags. Doesn't work exactly like P_CheckSight so don't use it for anything gameplay-related. +## musicdef_t + +Userdata structure representing a musicdef. Fields: + +`musicdef.name` - song identifier ("kmap01" for example). + +`musicdef.usage`, `musicdef.source` - fields from vanilla MUSICDEFS lump. + +`musicdef.filename` - unused for now. + +`musicdef.title`, `musicdef.alttitle`, `musicdef.authors` - fields from MUSCINFO lump. + +`#musicdef` - returns integer id for musicdef (which can be used as index in `musicdefs`). + +All fields are read-only. + +## S_FindMusicCredit(name) + +Returns musicdef corresponding to music with given identifier. For example, `S_FindMusicCredit("kmap01")` will return +musicdef for green hills music. + +## musicdefs + +Global table for all musicdefs, similar to mobjinfo, states, etc. Can take either integer indices, +from `0` to `#musicdefs-1`, or string indices (which is equal to calling `S_FindMusicCredit`). + +## addHook("MusicCredit", function(musicdef)) + +Hook is called whenever `S_ShowMusicCredit` (either from game or mod) is called. Takes musicdef as only argument, returning true +will overwrite vanilla behavior (not show music credit), can be used to implement custom music credit pop-ups. + # Other changes ## P_PlayRinglossSound(source, damager) diff --git a/libs/gettext/bin32/autopoint b/libs/gettext/bin32/autopoint deleted file mode 100755 index 0d3f47f84..000000000 --- a/libs/gettext/bin32/autopoint +++ /dev/null @@ -1,717 +0,0 @@ -#! /bin/sh -# -# Copyright (C) 2002-2010 Free Software Foundation, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# - -# This file is meant for authors, maintainers, co-maintainers or installers -# of packages which are internationalized with the help of GNU gettext. For -# further information how to use it consult the GNU gettext manual. - -progname=$0 -package=gettext-tools -version=0.18.1 - -# Set variables -# - gettext_dir directory where the sources are stored. -prefix="/usr/local/i686-w64-mingw32/stow/gettext-0.18.1.1" -datarootdir="${prefix}/share" -gettext_dir="${datarootdir}/gettext" - -# func_tmpdir -# creates a temporary directory. -# Sets variable -# - tmp pathname of freshly created temporary directory -func_tmpdir () -{ - # Use the environment variable TMPDIR, falling back to /tmp. This allows - # users to specify a different temporary directory, for example, if their - # /tmp is filled up or too small. - : ${TMPDIR=/tmp} - { - # Use the mktemp program if available. If not available, hide the error - # message. - tmp=`(umask 077 && mktemp -d "$TMPDIR/gtXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" - } || - { - # Use a simple mkdir command. It is guaranteed to fail if the directory - # already exists. $RANDOM is bash specific and expands to empty in shells - # other than bash, ksh and zsh. Its use does not increase security; - # rather, it minimizes the probability of failure in a very cluttered /tmp - # directory. - tmp=$TMPDIR/gt$$-$RANDOM - (umask 077 && mkdir "$tmp") - } || - { - echo "$0: cannot create a temporary directory in $TMPDIR" >&2 - { (exit 1); exit 1; } - } -} - -# Support for relocatability. -func_find_curr_installdir () -{ - # Determine curr_installdir, even taking into account symlinks. - curr_executable="$0" - case "$curr_executable" in - */* | *\\*) ;; - *) # Need to look in the PATH. - if test "${PATH_SEPARATOR+set}" != set; then - func_tmpdir - { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh - chmod +x "$tmp"/conf.sh - if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -rf "$tmp" - fi - save_IFS="$IFS"; IFS="$PATH_SEPARATOR" - for dir in $PATH; do - IFS="$save_IFS" - test -z "$dir" && dir=. - for exec_ext in ''; do - if test -f "$dir/$curr_executable$exec_ext"; then - curr_executable="$dir/$curr_executable$exec_ext" - break 2 - fi - done - done - IFS="$save_IFS" - ;; - esac - # Make absolute. - case "$curr_executable" in - /* | ?:/* | ?:\\*) ;; - *) curr_executable=`pwd`/"$curr_executable" ;; - esac - # Resolve symlinks. - sed_dirname='s,/[^/]*$,,' - sed_linkdest='s,^.* -> \(.*\),\1,p' - while : ; do - lsline=`LC_ALL=C ls -l "$curr_executable"` - case "$lsline" in - *" -> "*) - linkdest=`echo "$lsline" | sed -n -e "$sed_linkdest"` - case "$linkdest" in - /* | ?:/* | ?:\\*) curr_executable="$linkdest" ;; - *) curr_executable=`echo "$curr_executable" | sed -e "$sed_dirname"`/"$linkdest" ;; - esac ;; - *) break ;; - esac - done - curr_installdir=`echo "$curr_executable" | sed -e 's,/[^/]*$,,'` - # Canonicalize. - curr_installdir=`cd "$curr_installdir" && pwd` -} -func_find_prefixes () -{ - # Compute the original/current installation prefixes by stripping the - # trailing directories off the original/current installation directories. - orig_installprefix="$orig_installdir" - curr_installprefix="$curr_installdir" - while true; do - orig_last=`echo "$orig_installprefix" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'` - curr_last=`echo "$curr_installprefix" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'` - if test -z "$orig_last" || test -z "$curr_last"; then - break - fi - if test "$orig_last" != "$curr_last"; then - break - fi - orig_installprefix=`echo "$orig_installprefix" | sed -e 's,/[^/]*$,,'` - curr_installprefix=`echo "$curr_installprefix" | sed -e 's,/[^/]*$,,'` - done -} -if test "no" = yes; then - exec_prefix="${prefix}" - bindir="${exec_prefix}/bin" - orig_installdir="$bindir" # see Makefile.am's *_SCRIPTS variables - func_find_curr_installdir # determine curr_installdir - func_find_prefixes - # Relocate the directory variables that we use. - gettext_dir=`echo "$gettext_dir/" | sed -e "s%^${orig_installprefix}/%${curr_installprefix}/%" | sed -e 's,/$,,'` -fi - -# func_usage -# outputs to stdout the --help usage message. -func_usage () -{ - echo "\ -Usage: autopoint [OPTION]... - -Copies standard gettext infrastructure files into a source package. - -Options: - --help print this help and exit - --version print version information and exit - -f, --force force overwriting of files that already exist - -n, --dry-run print modifications but don't perform them" -# echo "\ -# -V version copy the infrastructure of the specified gettext version -# (dangerous)" - echo " -Report bugs to ." -} - -# func_version -# outputs to stdout the --version message. -func_version () -{ - echo "$progname (GNU $package) $version" - echo "Uses a versions archive in git format." - echo "Copyright (C) 2002-2010 Free Software Foundation, Inc. -License GPLv3+: GNU GPL version 3 or later -This is free software: you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law." - echo "Written by" "Bruno Haible" -} - -# func_fatal_error message -# outputs to stderr a fatal error message, and terminates the program. -func_fatal_error () -{ - echo "autopoint: *** $1" 1>&2 - echo "autopoint: *** Stop." 1>&2 - exit 1 -} - -# Command-line option processing. -# Removes the OPTIONS from the arguments. Sets the variables: -# - force yes if --force was given, empty otherwise -# - ver gettext version if -V was given, empty otherwise -# - doit false if --dry-run was given, : otherwise -{ - force= - ver= - doit=: - - while test $# -gt 0; do - case "$1" in - -n | --dry-run | --dry-ru | --dry-r | --dry- | --dry | --dr | --d ) - shift - doit=false ;; - -f | --force | --forc | --for | --fo | --f ) - shift - force=yes ;; - --help | --hel | --he | --h ) - func_usage; exit 0 ;; -# -V ) # Some people put a space between -V and the version number. -# shift -# if test $# = 0; then -# func_usage 1>&2 -# exit 1 -# fi -# ver=$1; -# shift ;; -# -V*) # Some people omit the space between -V and the version number. -# ver=`echo "X$1" | sed -e 's/^X-V//'` -# shift ;; - --version | --versio | --versi | --vers | --ver | --ve | --v ) - func_version - exit 0 ;; - -- ) # Stop option prcessing - shift; break ;; - -* ) - echo "autopoint: unknown option $1" 1>&2 - echo "Try 'autopoint --help' for more information." 1>&2 - exit 1 ;; - * ) - break ;; - esac - done -} - -# Command-line argument processing. -# Analyzes the remaining arguments. -{ - if test $# -gt 0; then - func_usage 1>&2 - exit 1 - fi -} - -srcdir=`pwd` -# The current directory is now $srcdir. - -# Check integrity of package: A configure.in/ac must be present. Sets variable -# - configure_in name of configure.in/ac file. -if test -f configure.in; then - configure_in=configure.in -else - if test -f configure.ac; then - configure_in=configure.ac - else - # KDE specific convention: configure.in.in - if test -f configure.in.in; then - configure_in=configure.in.in - else - func_fatal_error "Missing configure.in or configure.ac, please cd to your package first." - fi - fi -fi - -# Check whether the -V option and the version number in configure.in match. -# At least one of the two must be given. If both are given, they must agree. -sed_extract_AM_GNU_GETTEXT_VERSION_argument='s/^AM_GNU_GETTEXT_VERSION(\([^()]*\)).*$/\1/' -sed_remove_outer_brackets='s/^\[\(.*\)\]$/\1/' -xver=`cat "$configure_in" | grep '^AM_GNU_GETTEXT_VERSION(' | sed -n -e "$sed_extract_AM_GNU_GETTEXT_VERSION_argument"p | sed -e "$sed_remove_outer_brackets" | sed -e 1q` -if test -z "$xver" && test -f intl/VERSION; then - xver=`cat intl/VERSION | LC_ALL=C sed -n -e 's/^.*gettext-\([-+_.0-9A-Za-z]*\).*$/\1/p'` -fi -if test -n "$xver"; then - if test -n "$ver"; then - if test "X$ver" != "X$xver"; then - func_fatal_error "Version mismatch: specified -V $ver but the package uses gettext version $xver" - fi - else - ver="$xver" - fi -else - if test -z "$ver"; then - func_fatal_error "Missing version: please specify in $configure_in through a line 'AM_GNU_GETTEXT_VERSION(x.yy.zz)' the gettext version the package is using" - fi -fi - -# Check whether the version number is supported. -case "$ver" in - 0.10.35 | 0.10.36 | 0.10.37 | 0.10.38 | 0.10.39 | 0.10.40 | \ - 0.11 | 0.11.1 | 0.11.2 | 0.11.3 | 0.11.4 | 0.11.5 | \ - 0.12 | 0.12.1 | \ - 0.13 | 0.13.1 | \ - 0.14 | 0.14.1 | 0.14.2 | 0.14.3 | 0.14.4 | 0.14.5 | 0.14.6 | \ - 0.15 | \ - 0.16 | 0.16.1 | \ - 0.17 | \ - 0.18 | 0.18.1 ) - ;; - *) - func_fatal_error "The AM_GNU_GETTEXT_VERSION declaration in your $configure_in - file requires the infrastructure from gettext-$ver but this version - is older. Please upgrade to gettext-$ver or newer." - ;; -esac - -# Check in which directory config.rpath, mkinstalldirs etc. belong. -auxdir=`cat "$configure_in" | grep '^AC_CONFIG_AUX_DIR' | sed -n -e 's/AC_CONFIG_AUX_DIR(\([^()]*\))/\1/p' | sed -e 's/^\[\(.*\)\]$/\1/' | sed -e 1q` -if test -n "$auxdir"; then - auxdir="$auxdir/" -fi - -# Check in which directory the *.m4 macros belong. -m4dir=m4 -if test -f Makefile.am; then - # A package using automake. - # Extract the macro directory name from Makefile.am. - aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'` - m4dir_is_next= - for arg in $aclocal_amflags; do - if test -n "$m4dir_is_next"; then - m4dir="$arg" - break - else - if test "X$arg" = "X-I"; then - m4dir_is_next=yes - else - m4dir_is_next= - fi - fi - done -fi - -# Check whether to omit the intl/ directory. -omitintl=`cat "$configure_in" | grep '^AM_GNU_GETTEXT' | sed -n -e 's/^AM_GNU_GETTEXT(\([^(),]*\).*$/\1/p' | sed -e 's/^\[\(.*\)\]$/\1/' | sed -e 1q` -omitintl=`if test 'external' = "$omitintl"; then echo yes; fi` - -# Check in which directory or directories the po/* infrastructure belongs. -sed_extract_config_files='s,#.*$,, -s,^dnl .*$,, -s, dnl .*$,, -/AC_CONFIG_FILES(/ { - ta - :a - s/)/)/ - tb - s/\\$// - N - ba - :b - s,^.*AC_CONFIG_FILES([[ ]*\([^]"$`\\)]*\).*$,\1,p -}' -configfiles=`cat "$configure_in" | sed -n -e "$sed_extract_config_files"` -# PO directories have a Makefile.in generated from Makefile.in.in. -# Treat a directory as a PO directory if and only if it has a -# POTFILES.in file. This allows packages to have multiple PO -# directories under different names or in different locations. -sed_remove_Makefile_in='s,/Makefile\.in$,,' -podirs=`for f in $configfiles; do case "$f" in */Makefile.in) echo $f;; esac; done | sed -e "$sed_remove_Makefile_in"` -if test -z "$podirs"; then - # If we cannot get the list of PO directories from configure.ac, assume the - # common default. - podirs="po" -fi - -# Set up a temporary checkout directory. -# Set variables -# - work_dir directory containing the temporary checkout -work_dir=tmpwrk$$ -mkdir "$work_dir" || { - if test -d "$work_dir"; then - func_fatal_error "directory $work_dir already exists" - else - func_fatal_error "cannot create directory $work_dir" - fi -} - -# We support three archive formats. -# -# Format | Size (KiB) for gettext-0.17 | Extra tools needed | -# -------+-----------------------------+--------------------+ -# dir | 3000 | -- | -# cvs | 356 | cvs | -# git | 484 | git | -# -------+-----------------------------+--------------------+ - -case "git" in - dir) - # The archive of different versions is very large, but using it does not - # require special tools. - gzip -d -c < "$gettext_dir/archive.dir.tar.gz" | (cd "$work_dir" && tar xf - "gettext-$ver") - if test `find "$work_dir" -type f -print | wc -l` = 0; then - rm -rf "$work_dir" - func_fatal_error "infrastructure files for version $ver not found; this is autopoint from GNU $package $version" - fi - mv "$work_dir/gettext-$ver" "$work_dir/archive" - ;; - - cvs) - # We distributed the many different versions of the files in a CVS - # repository. This guaranteed a good compression rate: - # - # Including version size in KB of - # "du autopoint-files/archive" - # 0.10.35 240 - # 0.10.36 428 - # 0.10.37 436 - # 0.10.38 488 - # 0.10.39 500 - # 0.10.40 528 - # 0.11 720 - # 0.11.1 740 - # 0.11.2 748 - # 0.11.3 804 - # 0.11.4 864 - # 0.11.5 880 - # 0.12 1032 - # 0.12.1 1032 - # 0.13 1220 - # 0.13.1 1236 - # 0.14 1296 - # 0.14.1 1300 - # 0.14.2 1420 - # 0.14.3 1428 - # 0.14.4 1464 - # 0.14.5 1508 - # 0.14.6 1580 - # 0.15 1760 - # 0.16 1808 - # 0.16.1 1812 - # 0.17 2128 - # 0.18 2656 - # - # The requirement that the user must have the CVS program available is not - # a severe restrictions, because most of the people who use autopoint are - # users of CVS. - # - # But the CVS format is now deprecated, because "cvs init" does not work in - # all circumstances - # (see ) - # and we are not allowed to distribute the cvs infrastructure files - # ourselves - # (see ). - # - # Check availability of the CVS program. - (cvs -v) >/dev/null 2>/dev/null || func_fatal_error "cvs program not found" - - # Set up a temporary CVS repository. - # We need the temporary CVS repository because any checkout needs write - # access to the CVSROOT/history file, so it cannot be under $gettext_dir. - # We need the temporary checkout directory because when --force was not - # given, we need to compare the existing files with the checked out ones. - # Set variables - # - cvs_dir directory containing the temporary repository - cvs_dir=tmpcvs$$ - # Use an umask of 077, to avoid attacks that work by overwriting files in - # the "$CVSROOT"/CVSROOT directory. - (umask 077 && mkdir "$cvs_dir") || { - if test -d "$cvs_dir"; then - func_fatal_error "directory $cvs_dir already exists" - else - func_fatal_error "cannot create directory $cvs_dir" - fi - } - CVSROOT="$srcdir/$cvs_dir" - unset CVS_CLIENT_LOG - unset CVS_CLIENT_PORT - unset CVS_IGNORE_REMOTE_ROOT - unset CVS_LOCAL_BRANCH_NUM - unset CVS_NOBASES - unset CVS_PASSFILE - unset CVS_PASSWORD - unset CVS_PROXY_PORT - unset CVS_RCMD_PORT - unset CVS_RSH - unset CVS_SERVER - unset CVS_SERVER_SLEEP - CVS_SIGN_COMMITS= - export CVS_SIGN_COMMITS - unset CVS_SSH - unset CVS_VERIFY_CHECKOUTS - unset CVS_VERIFY_TEMPLATE - unset CVSIGNORE - unset CVSREAD - unset CVSREADONLYFS - unset CVSUMASK - unset CVSWRAPPERS - - # Need to pass -d "$CVSROOT", because there may be a CVS directory in the - # current directory. - cvs -d "$CVSROOT" init - gzip -d -c < "$gettext_dir/archive.cvs.tar.gz" | (cd "$cvs_dir" && tar xf -) - - cd "$work_dir" - cvsver=gettext-`echo "$ver" | sed -e 's/\./_/g'` - (cvs -d "$CVSROOT" checkout -r"$cvsver" archive > /dev/null) 2>&1 | grep -v '^cvs checkout: Updating' - find archive -name CVS -type d -print | xargs rm -rf - cd .. - rm -rf "$cvs_dir" - # Check that really all CVS directories are gone, otherwise we would overwrite - # the contents of the user's CVS directories. - if test `find $work_dir/archive -name CVS -type d -print | wc -l` != 0; then - rm -rf "$work_dir" - func_fatal_error "failed to remove all CVS subdirectories" - fi - if test `find $work_dir/archive -type f -print | wc -l` = 0; then - rm -rf "$work_dir" - func_fatal_error "infrastructure files for version $ver not found; this is autopoint from GNU $package $version" - fi - ;; - - git) - # Check availability of the git program. - (git --version) >/dev/null 2>/dev/null || func_fatal_error "git program not found" - mkdir "$work_dir/archive" - gzip -d -c < "$gettext_dir/archive.git.tar.gz" | (cd "$work_dir/archive" && tar xf -) - (cd "$work_dir/archive" && git checkout -q "gettext-$ver") || { - rm -rf "$work_dir" - func_fatal_error "infrastructure files for version $ver not found; this is autopoint from GNU $package $version" - } - (cd "$work_dir/archive" && rm -rf .git .gitignore) - ;; -esac - -# func_destfile file -# determines the destination file, relative to the package's top level -# directory, for a given file name, relative to archive. -# Sets variables -# - destfile relative destination file name, or -# empty if the file shall be omitted -# - sharedowner yes if the file is not only owned by GNU gettext but may -# be installed by automake or other tools, otherwise empty -# - allpodirs yes if the file is to be installed in every dir in $podirs -func_destfile () -{ - # There are five categories of files: - # ABOUT_NLS -> top level directory - # config.rpath mkinstalldirs -> $auxdir - # m4/* -> $m4dir/ - # intl/* -> intl/ - # po/* -> - sharedowner= - allpodirs= - case `echo "$1" | sed -e 's,[^/]*$,,'` in - "" ) - case "$1" in - config.rpath ) destfile="$auxdir$1" ;; - mkinstalldirs ) destfile="$auxdir$1" sharedowner=yes ;; - * ) destfile="$1" ;; - esac - ;; - m4/ ) destfile=`echo "$1" | sed -e "s,^m4/,$m4dir/,"` ;; - intl/ ) if test -n "$omitintl"; then destfile=""; else destfile="$1"; fi ;; - po/ ) destfile=`echo "$1" | sed -e "s,^po/,,"` allpodirs=yes ;; - * ) destfile="$1" ;; - esac -} - -# func_compare existingfile gettextfile -# compares the existing file and the file from gettext, and decides whether the -# existing file should be overwritten with the file from gettext. Returns 0 if -# it should be overwritten, or 1 if it should be skipped. -sed_extract_serial='s/^#.* serial \([^ ]*\).*/\1/p -1q' -func_compare () -{ - if cmp -s "$1" "$2"; then - false - else - case "$2" in - *.m4) - # For interoperability with gnulib. gnulib often has newer versions of - # the *.m4 files than the latest gettext release. Don't overwrite a - # newer version from gnulib with an older version from the gettext - # release. The version can be retrieved from the first line, which - # looks like this: # file.m4 serial NN ... - existing_serial=`sed -n -e "$sed_extract_serial" < "$1"` - gettext_serial=`sed -n -e "$sed_extract_serial" < "$2"` - if test -n "$existing_serial" && test -n "$gettext_serial" \ - && test "$existing_serial" -ge "$gettext_serial" 2> /dev/null; then - false - else - true - fi - ;; - *) - true - ;; - esac - fi -} - -# If some files have been locally modified and we have not been requested -# to overwrite them, then bail out. This is better than leaving a source -# package around where half of the files are locally modified and half are -# original - too great risk of version mismatch. -if test -z "$force"; then - mismatch= - func_tmpdir - mismatchfile="$tmp"/autopoint.diff - for file in `find "$work_dir/archive" -type f -print | sed -e "s,^$work_dir/archive/,," | LC_ALL=C sort`; do - func_destfile "$file" - if test -n "$destfile"; then - func_compare_to_destfile () - { - finaldestfile="$1" - if test -f "$finaldestfile"; then - if func_compare "$finaldestfile" "$work_dir/archive/$file"; then - if test -n "$sharedowner"; then - echo "autopoint: warning: File $finaldestfile has been locally modified." 1>&2 - else - echo "autopoint: File $finaldestfile has been locally modified." 1>&2 - mismatch=yes - diff -c "$work_dir/archive/$file" "$finaldestfile" | sed -e "1s,$work_dir/archive/,," >> "$mismatchfile" - fi - fi - fi - } - if test -n "$allpodirs"; then - for dir in $podirs; do - func_compare_to_destfile "$dir/$destfile" - done - else - func_compare_to_destfile "$destfile" - fi - fi - done - if test -n "$mismatch"; then - rm -rf "$work_dir" - func_fatal_error "Some files have been locally modified. Not overwriting them because --force has not been specified. For your convenience, you find the local modifications in the file '$mismatchfile'." - fi - rm -rf "$tmp" -fi - -# func_mkdir_for to -# ensures the directory that would the given file exists. -# 'to' is a relative pathname, relative to the current directory. -func_mkdir_for () -{ - base=`echo "$1" | sed -e 's,/[^/]*$,,'` - if test "X$base" != "X$1" && test -n "$base"; then - func_mkdir_for "$base" - # Recompute base. It was clobbered by the recursive call. - base=`echo "$1" | sed -e 's,/[^/]*$,,'` - test -d "$base" || { echo "Creating directory $base"; mkdir "$base"; } - fi -} - -# func_copy from to -# copies a file. -# 'from' is a relative pathname, relative to the current directory. -# 'to' is a relative pathname, relative to the current directory. -func_copy () -{ - if $doit; then - func_mkdir_for "$2" - rm -f "$2" - echo "Copying file $2" - cp "$1" "$2" - else - echo "Copy file $2" - fi -} - -# func_backup to -# makes a backup of a file that is about to be overwritten or replaced. -# 'to' is a relative pathname, relative to the current directory. -func_backup () -{ - if $doit; then - if test -f "$1"; then - rm -f "$1~" - cp -p "$1" "$1~" - fi - fi -} - -# Now copy the files. -for file in `find "$work_dir/archive" -type f -print | sed -e "s,^$work_dir/archive/,," | LC_ALL=C sort`; do - func_destfile "$file" - if test -n "$destfile"; then - func_copy_to_destfile () - { - finaldestfile="$1" - mustcopy= - if test -f "$finaldestfile"; then - if func_compare "$finaldestfile" "$work_dir/archive/$file"; then - if test -n "$force"; then - # Overwrite locally modified file. - mustcopy=yes - fi - # If --force is not specified, don't overwrite locally modified files - # for which GNU gettext is a shared owner. - fi - else - mustcopy=yes - fi - if test -n "$mustcopy"; then - func_backup "$finaldestfile" - func_copy "$work_dir/archive/$file" "$finaldestfile" - fi - } - if test -n "$allpodirs"; then - for dir in $podirs; do - func_copy_to_destfile "$dir/$destfile" - done - else - func_copy_to_destfile "$destfile" - fi - fi -done - -# That's it. -rm -rf "$work_dir" -exit 0 diff --git a/libs/gettext/bin32/envsubst.exe b/libs/gettext/bin32/envsubst.exe deleted file mode 100644 index 3c326aa0d..000000000 Binary files a/libs/gettext/bin32/envsubst.exe and /dev/null differ diff --git a/libs/gettext/bin32/gettext.exe b/libs/gettext/bin32/gettext.exe deleted file mode 100644 index eb1048ebc..000000000 Binary files a/libs/gettext/bin32/gettext.exe and /dev/null differ diff --git a/libs/gettext/bin32/gettext.sh b/libs/gettext/bin32/gettext.sh deleted file mode 100755 index 2369ab501..000000000 --- a/libs/gettext/bin32/gettext.sh +++ /dev/null @@ -1,123 +0,0 @@ -#! /bin/sh -# -# Copyright (C) 2003, 2005-2007 Free Software Foundation, Inc. -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU Library General Public -# License along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -# USA. -# - -# Find a way to echo strings without interpreting backslash. -if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then - echo='echo' -else - if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then - echo='printf %s\n' - else - echo_func () { - cat < -This is free software: you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law." - echo "Written by" "Bruno Haible" - } - if test $# = 1; then - case "$1" in - --help | --hel | --he | --h ) - func_usage; exit 0 ;; - --version | --versio | --versi | --vers | --ver | --ve | --v ) - func_version; exit 0 ;; - esac - fi - func_usage 1>&2 - exit 1 - ;; - esac -fi - -# eval_gettext MSGID -# looks up the translation of MSGID and substitutes shell variables in the -# result. -eval_gettext () { - gettext "$1" | (export PATH `envsubst --variables "$1"`; envsubst "$1") -} - -# eval_ngettext MSGID MSGID-PLURAL COUNT -# looks up the translation of MSGID / MSGID-PLURAL for COUNT and substitutes -# shell variables in the result. -eval_ngettext () { - ngettext "$1" "$2" "$3" | (export PATH `envsubst --variables "$1 $2"`; envsubst "$1 $2") -} - -# Note: This use of envsubst is much safer than using the shell built-in 'eval' -# would be. -# 1) The security problem with Chinese translations that happen to use a -# character such as \xe0\x60 is avoided. -# 2) The security problem with malevolent translators who put in command lists -# like "$(...)" or "`...`" is avoided. -# 3) The translations can only refer to shell variables that are already -# mentioned in MSGID or MSGID-PLURAL. -# -# Note: "export PATH" above is a dummy; this is for the case when -# `envsubst --variables ...` returns nothing. -# -# Note: In eval_ngettext above, "$1 $2" means a string whose variables set is -# the union of the variables set of "$1" and "$2". -# -# Note: The minimal use of backquote above ensures that trailing newlines are -# not dropped, not from the gettext invocation and not from the value of any -# shell variable. -# -# Note: Field splitting on the `envsubst --variables ...` result is desired, -# since envsubst outputs the variables, separated by newlines. Pathname -# wildcard expansion or tilde expansion has no effect here, since the words -# output by "envsubst --variables ..." consist solely of alphanumeric -# characters and underscore. diff --git a/libs/gettext/bin32/gettextize b/libs/gettext/bin32/gettextize deleted file mode 100755 index 27a23b732..000000000 --- a/libs/gettext/bin32/gettextize +++ /dev/null @@ -1,1281 +0,0 @@ -#! /bin/sh -# -# Copyright (C) 1995-1998, 2000-2010 Free Software Foundation, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# - -# This file is meant for authors or maintainers which want to -# internationalize their package with the help of GNU gettext. For -# further information how to use it consult the GNU gettext manual. - -progname=$0 -package=gettext-tools -version=0.18.1 - -# Set variables -# - gettext_dir directory where the sources are stored. -prefix="/usr/local/i686-w64-mingw32/stow/gettext-0.18.1.1" -datarootdir="${prefix}/share" -gettext_dir="${datarootdir}/gettext" - -# func_tmpdir -# creates a temporary directory. -# Sets variable -# - tmp pathname of freshly created temporary directory -func_tmpdir () -{ - # Use the environment variable TMPDIR, falling back to /tmp. This allows - # users to specify a different temporary directory, for example, if their - # /tmp is filled up or too small. - : ${TMPDIR=/tmp} - { - # Use the mktemp program if available. If not available, hide the error - # message. - tmp=`(umask 077 && mktemp -d "$TMPDIR/gtXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" - } || - { - # Use a simple mkdir command. It is guaranteed to fail if the directory - # already exists. $RANDOM is bash specific and expands to empty in shells - # other than bash, ksh and zsh. Its use does not increase security; - # rather, it minimizes the probability of failure in a very cluttered /tmp - # directory. - tmp=$TMPDIR/gt$$-$RANDOM - (umask 077 && mkdir "$tmp") - } || - { - echo "$0: cannot create a temporary directory in $TMPDIR" >&2 - { (exit 1); exit 1; } - } -} - -# Support for relocatability. -func_find_curr_installdir () -{ - # Determine curr_installdir, even taking into account symlinks. - curr_executable="$0" - case "$curr_executable" in - */* | *\\*) ;; - *) # Need to look in the PATH. - if test "${PATH_SEPARATOR+set}" != set; then - func_tmpdir - { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh - chmod +x "$tmp"/conf.sh - if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -rf "$tmp" - fi - save_IFS="$IFS"; IFS="$PATH_SEPARATOR" - for dir in $PATH; do - IFS="$save_IFS" - test -z "$dir" && dir=. - for exec_ext in ''; do - if test -f "$dir/$curr_executable$exec_ext"; then - curr_executable="$dir/$curr_executable$exec_ext" - break 2 - fi - done - done - IFS="$save_IFS" - ;; - esac - # Make absolute. - case "$curr_executable" in - /* | ?:/* | ?:\\*) ;; - *) curr_executable=`pwd`/"$curr_executable" ;; - esac - # Resolve symlinks. - sed_dirname='s,/[^/]*$,,' - sed_linkdest='s,^.* -> \(.*\),\1,p' - while : ; do - lsline=`LC_ALL=C ls -l "$curr_executable"` - case "$lsline" in - *" -> "*) - linkdest=`echo "$lsline" | sed -n -e "$sed_linkdest"` - case "$linkdest" in - /* | ?:/* | ?:\\*) curr_executable="$linkdest" ;; - *) curr_executable=`echo "$curr_executable" | sed -e "$sed_dirname"`/"$linkdest" ;; - esac ;; - *) break ;; - esac - done - curr_installdir=`echo "$curr_executable" | sed -e 's,/[^/]*$,,'` - # Canonicalize. - curr_installdir=`cd "$curr_installdir" && pwd` -} -func_find_prefixes () -{ - # Compute the original/current installation prefixes by stripping the - # trailing directories off the original/current installation directories. - orig_installprefix="$orig_installdir" - curr_installprefix="$curr_installdir" - while true; do - orig_last=`echo "$orig_installprefix" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'` - curr_last=`echo "$curr_installprefix" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'` - if test -z "$orig_last" || test -z "$curr_last"; then - break - fi - if test "$orig_last" != "$curr_last"; then - break - fi - orig_installprefix=`echo "$orig_installprefix" | sed -e 's,/[^/]*$,,'` - curr_installprefix=`echo "$curr_installprefix" | sed -e 's,/[^/]*$,,'` - done -} -if test "no" = yes; then - exec_prefix="${prefix}" - bindir="${exec_prefix}/bin" - orig_installdir="$bindir" # see Makefile.am's *_SCRIPTS variables - func_find_curr_installdir # determine curr_installdir - func_find_prefixes - # Relocate the directory variables that we use. - gettext_dir=`echo "$gettext_dir/" | sed -e "s%^${orig_installprefix}/%${curr_installprefix}/%" | sed -e 's,/$,,'` -fi - -# func_usage -# outputs to stdout the --help usage message. -func_usage () -{ - echo "\ -Usage: gettextize [OPTION]... [package-dir] - -Prepares a source package to use gettext. - -Options: - --help print this help and exit - --version print version information and exit - -f, --force force writing of new files even if old exist - --intl install libintl in a subdirectory (deprecated) - --po-dir=DIR specify directory with PO files - --no-changelog don't update or create ChangeLog files - --symlink make symbolic links instead of copying files - -n, --dry-run print modifications but don't perform them - -Report bugs to ." -} - -# func_version -# outputs to stdout the --version message. -func_version () -{ - echo "$progname (GNU $package) $version" - echo "Copyright (C) 1995-1998, 2000-2010 Free Software Foundation, Inc. -License GPLv3+: GNU GPL version 3 or later -This is free software: you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law." - echo "Written by" "Ulrich Drepper" -} - -# func_fatal_error message -# outputs to stderr a fatal error message, and terminates the program. -func_fatal_error () -{ - echo "gettextize: *** $1" 1>&2 - echo "gettextize: *** Stop." 1>&2 - exit 1 -} - -# Nuisances. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -# Command-line option processing. -# Removes the OPTIONS from the arguments. Sets the variables: -# - force 1 if --force was given, 0 otherwise -# - intldir yes if --intl was given, empty otherwise -# - podirs list of directories specified with --po-dir -# - try_ln_s : if --symlink was given, false otherwise -# - do_changelog false if --no-changelog was given, : otherwise -# - doit false if --dry-run was given, : otherwise -{ - force=0 - intldir= - podirs= - try_ln_s=false - do_changelog=: - doit=: - - while test $# -gt 0; do - case "$1" in - -c | --copy | --cop | --co | --c ) # accepted for backward compatibility - shift ;; - -n | --dry-run | --dry-ru | --dry-r | --dry- | --dry | --dr | --d ) - shift - doit=false ;; - -f | --force | --forc | --for | --fo | --f ) - shift - force=1 ;; - --help | --hel | --he | --h ) - func_usage; exit 0 ;; - --intl | --int | --in | --i ) - shift - intldir=yes ;; - --po-dir | --po-di | --po-d | --po- | --po | --p ) - shift - if test $# = 0; then - func_fatal_error "missing argument for --po-dir" - fi - case "$1" in - -*) func_fatal_error "missing argument for --po-dir" ;; - esac - podirs="$podirs $1" - shift ;; - --po-dir=* ) - arg=`echo "X$1" | sed -e 's/^X--po-dir=//'` - podirs="$podirs $arg" - shift ;; - --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c ) - shift - do_changelog=false ;; - --symlink | --symlin | --symli | --syml | --sym | --sy | --s ) - shift - try_ln_s=: ;; - --version | --versio | --versi | --vers | --ver | --ve | --v ) - func_version - exit 0 ;; - -- ) # Stop option prcessing - shift; break ;; - -* ) - echo "gettextize: unknown option $1" 1>&2 - echo "Try 'gettextize --help' for more information." 1>&2 - exit 1 ;; - * ) - break ;; - esac - done - # podirs defaults to "po". - test -n "$podirs" || podirs="po" -} - -# Warn about deprecated options. -if test -n "$intldir"; then - echo "gettextize: warning: the option '--intl' is deprecated and will be removed" 1>&2 -fi - -# Command-line argument processing. -# Analyzes the remaining arguments. -# Sets the variables -# - origdir to the original directory, -# - srcdir to the package directory, and cd-s into it. -{ - if test $# -gt 1; then - func_usage 1>&2 - exit 1 - fi - origdir=`pwd` - if test $# -eq 1; then - srcdir=$1 - if cd "$srcdir"; then - srcdir=`pwd` - else - func_fatal_error "Cannot change directory to '$srcdir'." - fi - else - srcdir=$origdir - fi -} - -# The current directory is now $srcdir. - -# Check integrity of package: A configure.in/ac must be present. Sets variable -# - configure_in name of configure.in/ac file. -test -f configure.in || test -f configure.ac || - func_fatal_error "Missing configure.in or configure.ac, please cd to your package first." -configure_in=NONE -if test -f configure.in; then - configure_in=configure.in -else - if test -f configure.ac; then - configure_in=configure.ac - fi -fi - -# Check whether the --force option is needed but has not been specified. -if test $force -eq 0; then - if test -d intl; then - func_fatal_error "intl/ subdirectory exists: use option -f if you really want to delete it." - fi - for podir in $podirs; do - if test -f "$podir/Makefile.in.in"; then - func_fatal_error "$podir/Makefile.in.in exists: use option -f if you really want to delete it." - fi - done - if test -f ABOUT-NLS; then - func_fatal_error "ABOUT-NLS exists: use option -f if you really want to delete it." - fi -fi - -# Check in which directory config.rpath etc. belong. -auxdir=`cat "$configure_in" | grep '^AC_CONFIG_AUX_DIR' | sed -n -e 's/AC_CONFIG_AUX_DIR(\([^()]*\))/\1/p' | sed -e 's/^\[\(.*\)\]$/\1/' | sed -e 1q` -if test -n "$auxdir"; then - auxdir="$auxdir/" -fi - -# For simplicity we change to the gettext source directory. -cd "$gettext_dir" || - func_fatal_error "gettext source directory '${gettext_dir}' doesn't exist" - -# Variables which keep track what has been modified. -added_directories= -removed_directory= -added_extradist= -added_acoutput= -removed_acoutput=" intl/intlh.inst" - -# Variable: -# - please accumulates instructions for the user. -please= - -# Variable: -# - date current date, for use in ChangeLog entries. -date=`date +%Y-%m-%d` - -# func_copy from to -# copies a file. -# 'from' is a relative pathname, relative to the current directory. -# 'to' is a relative pathname, relative to $srcdir. -func_copy () -{ - if $doit; then - rm -f "$srcdir/$2" - echo "Copying file $2" - cp "$1" "$srcdir/$2" - else - echo "Copy file $2" - fi -} - -# func_linkorcopy from absfrom to -# links or copies a file. -# 'from' is a relative pathname, relative to the current directory. -# 'absfrom' is the corresponding absolute pathname. -# 'to' is a relative pathname, relative to $srcdir. -func_linkorcopy () -{ - if $doit; then - rm -f "$srcdir/$3" - ($try_ln_s && ln -s "$2" "$srcdir/$3" && echo "Symlinking file $3") 2>/dev/null || - { echo "Copying file $3"; cp "$1" "$srcdir/$3"; } - else - if $try_ln_s; then - echo "Symlink file $3" - else - echo "Copy file $3" - fi - fi -} - -# func_backup to -# makes a backup of a file that is about to be overwritten or replaced. -# 'to' is a relative pathname, relative to $srcdir. -func_backup () -{ - if $doit; then - if test -f "$srcdir/$1"; then - rm -f "$srcdir/$1~" - cp -p "$srcdir/$1" "$srcdir/$1~" - fi - fi -} - -# func_remove to -# removes a file. -# 'to' is a relative pathname, relative to $srcdir. -func_remove () -{ - if $doit; then - echo "Removing $1" - rm -f "$srcdir/$1" - else - echo "Remove $1" - fi -} - -# func_ChangeLog_init -# func_ChangeLog_add_entry line -# func_ChangeLog_finish -# manage the ChangeLog file, relative to $srcdir. -func_ChangeLog_init () -{ - modified_ChangeLog= -} -func_ChangeLog_add_entry () -{ - if $doit; then - if test -z "$modified_ChangeLog"; then - echo "$date gettextize " > "$srcdir/ChangeLog.tmp" - echo >> "$srcdir/ChangeLog.tmp" - modified_ChangeLog=yes - fi - echo "$1" >> "$srcdir/ChangeLog.tmp" - else - modified_ChangeLog=yes - fi -} -func_ChangeLog_finish () -{ - if test -n "$modified_ChangeLog"; then - if $doit; then - echo >> "$srcdir/ChangeLog.tmp" - if test -f "$srcdir/ChangeLog"; then - echo "Adding an entry to ChangeLog (backup is in ChangeLog~)" - cat "$srcdir/ChangeLog" >> "$srcdir/ChangeLog.tmp" - rm -f "$srcdir/ChangeLog~" - cp -p "$srcdir/ChangeLog" "$srcdir/ChangeLog~" - else - echo "Creating ChangeLog" - fi - cp "$srcdir/ChangeLog.tmp" "$srcdir/ChangeLog" - rm -f "$srcdir/ChangeLog.tmp" - else - if test -f "$srcdir/ChangeLog"; then - echo "Add an entry to ChangeLog" - else - echo "Create ChangeLog" - fi - fi - fi -} - -# func_poChangeLog_init -# func_poChangeLog_add_entry line -# func_poChangeLog_finish -# manage the $podir/ChangeLog file, relative to $srcdir. -func_poChangeLog_init () -{ - modified_poChangeLog= -} -func_poChangeLog_add_entry () -{ - if $doit; then - if test -z "$modified_poChangeLog"; then - echo "$date gettextize " > "$srcdir/$podir/ChangeLog.tmp" - echo >> "$srcdir/$podir/ChangeLog.tmp" - modified_poChangeLog=yes - fi - echo "$1" >> "$srcdir/$podir/ChangeLog.tmp" - else - modified_poChangeLog=yes - fi -} -func_poChangeLog_finish () -{ - if test -n "$modified_poChangeLog"; then - if $doit; then - echo >> "$srcdir/$podir/ChangeLog.tmp" - if test -f "$srcdir/$podir/ChangeLog"; then - echo "Adding an entry to $podir/ChangeLog (backup is in $podir/ChangeLog~)" - cat "$srcdir/$podir/ChangeLog" >> "$srcdir/$podir/ChangeLog.tmp" - rm -f "$srcdir/$podir/ChangeLog~" - cp -p "$srcdir/$podir/ChangeLog" "$srcdir/$podir/ChangeLog~" - else - echo "Creating $podir/ChangeLog" - fi - cp "$srcdir/$podir/ChangeLog.tmp" "$srcdir/$podir/ChangeLog" - rm -f "$srcdir/$podir/ChangeLog.tmp" - else - if test -f "$srcdir/$podir/ChangeLog"; then - echo "Add an entry to $podir/ChangeLog" - else - echo "Create $podir/ChangeLog" - fi - fi - fi -} - -# func_m4ChangeLog_init -# func_m4ChangeLog_add_entry line -# func_m4ChangeLog_finish -# manage the $m4dir/ChangeLog file, relative to $srcdir. -func_m4ChangeLog_init () -{ - if test -n "$using_m4ChangeLog"; then - modified_m4ChangeLog= - created_m4ChangeLog= - fi -} -func_m4ChangeLog_add_entry () -{ - if test -n "$using_m4ChangeLog"; then - if $doit; then - if test -z "$modified_m4ChangeLog"; then - echo "$date gettextize " > "$srcdir/$m4dir/ChangeLog.tmp" - echo >> "$srcdir/$m4dir/ChangeLog.tmp" - modified_m4ChangeLog=yes - fi - echo "$1" >> "$srcdir/$m4dir/ChangeLog.tmp" - else - modified_m4ChangeLog=yes - fi - else - line="$1" - line=`echo "$line" | sed -e "s%^ \\* % * $m4dir/%"` - func_ChangeLog_add_entry "$line" - fi -} -func_m4ChangeLog_finish () -{ - if test -n "$using_m4ChangeLog"; then - if test -n "$modified_m4ChangeLog"; then - if $doit; then - echo >> "$srcdir/$m4dir/ChangeLog.tmp" - if test -f "$srcdir/$m4dir/ChangeLog"; then - echo "Adding an entry to $m4dir/ChangeLog (backup is in $m4dir/ChangeLog~)" - cat "$srcdir/$m4dir/ChangeLog" >> "$srcdir/$m4dir/ChangeLog.tmp" - rm -f "$srcdir/$m4dir/ChangeLog~" - cp -p "$srcdir/$m4dir/ChangeLog" "$srcdir/$m4dir/ChangeLog~" - else - echo "Creating $m4dir/ChangeLog" - created_m4ChangeLog=yes - fi - cp "$srcdir/$m4dir/ChangeLog.tmp" "$srcdir/$m4dir/ChangeLog" - rm -f "$srcdir/$m4dir/ChangeLog.tmp" - else - if test -f "$srcdir/$m4dir/ChangeLog"; then - echo "Add an entry to $m4dir/ChangeLog" - else - echo "Create $m4dir/ChangeLog" - created_m4ChangeLog=yes - fi - fi - fi - fi -} -using_m4ChangeLog=yes - -if test ! -f "$srcdir/intl/Makefile.in" && test -n "$intldir"; then - added_acoutput="$added_acoutput intl/Makefile" -fi -if test -f "$srcdir/intl/Makefile.in" && test -z "$intldir"; then - removed_acoutput="$removed_acoutput intl/Makefile" -fi -if test -d "$srcdir/intl"; then - # Remove everything inside intl except for RCS and CVS subdirs and invisible - # files. - if $doit; then - echo "Wiping out intl/ subdirectory" - (cd "$srcdir/intl" && - for f in *; do - if test CVS != "$f" && test RCS != "$f"; then - rm -rf "$f" - fi - done) - else - echo "Wipe out intl/ subdirectory" - fi - if test -z "$intldir"; then - removed_directory=intl - fi -else - if test -n "$intldir"; then - if $doit; then - echo "Creating intl/ subdirectory" - mkdir "$srcdir/intl" || func_fatal_error "failed to create intl/ subdirectory" - else - echo "Create intl/ subdirectory" - fi - added_directories="$added_directories intl" - fi -fi - -$do_changelog && func_ChangeLog_init - -for podir in $podirs; do - test -d "$srcdir/$podir" || { - if $doit; then - echo "Creating $podir/ subdirectory" - mkdir "$srcdir/$podir" || func_fatal_error "failed to create $podir/ subdirectory" - else - echo "Create $podir/ subdirectory" - fi - added_directories="$added_directories $podir" - } -done - -# Create the directory for config.rpath, if needed. -# This is for consistency with autoreconf and automake. -# Note that $auxdir is either empty or ends in a slash. -test -d "$srcdir/$auxdir" || { - if $doit; then - echo "Creating $auxdir subdirectory" - mkdir "$srcdir/$auxdir" || func_fatal_error "failed to create $auxdir subdirectory" - else - echo "Create $auxdir subdirectory" - fi -} - -# Now copy all files. Take care for the destination directories. -for file in *; do - case $file in - ABOUT-NLS) - func_linkorcopy $file "$gettext_dir/$file" $file - ;; - config.rpath) - if test -f "$srcdir/$auxdir$file"; then - : - else - added_extradist="$added_extradist $auxdir$file" - fi - func_linkorcopy $file "$gettext_dir/$file" "$auxdir$file" - ;; - esac -done - -# Copy files to intl/ subdirectory. -if test -n "$intldir"; then - cd intl - for file in *; do - if test $file != COPYING.LIB-2.0 && test $file != COPYING.LIB-2.1; then - if test $file != plural.c; then - func_linkorcopy $file "$gettext_dir/intl/$file" intl/$file - else - # plural.c is a generated file; it must be copied and touched. - func_copy $file intl/$file - if $doit; then - (sleep 2; touch "$srcdir/intl/$file") & - fi - fi - fi - done - cd .. -else - echo "Not copying intl/ directory." - # Tell the user what to put into configure.ac, if it is not already there. - if grep '^AM_GNU_GETTEXT([[]\?external[]]\?[ ]*[,)]' "$srcdir/$configure_in" > /dev/null; then - : - else - please="$please -Please use AM_GNU_GETTEXT([external]) in order to cause autoconfiguration -to look for an external libintl. -" - fi -fi - -# Copy files to po/ subdirectory. -cd po -for podir in $podirs; do - $do_changelog && func_poChangeLog_init - for file in Makefile.in.in; do - same=no - if test -f "$srcdir/$podir/$file"; then - if cmp -s $file "$srcdir/$podir/$file"; then - same=yes - fi - else - added_acoutput="$added_acoutput $podir/Makefile.in" - fi - if $do_changelog && test $same = no; then - if test -f "$srcdir/$podir/$file"; then - func_poChangeLog_add_entry " * $file: Upgrade to gettext-${version}." - else - func_poChangeLog_add_entry " * $file: New file, from gettext-${version}." - fi - fi - func_backup "$podir/$file" - func_linkorcopy $file "$gettext_dir/po/$file" "$podir/$file" - done - for file in *; do - case $file in - Makefile.in.in) - # Already handled above. - ;; - Makevars.template) - func_linkorcopy Makevars.template "$gettext_dir/po/Makevars.template" "$podir/Makevars.template" - if test -f "$srcdir/po/Makevars"; then - LC_ALL=C sed -n -e 's/[ ]*\([A-Za-z0-9_]*\)[ ]*=.*/\1/p' < "$srcdir/$podir/Makevars" | LC_ALL=C sort > "$srcdir/$podir/Makevars.tmp1" - LC_ALL=C sed -n -e 's/[ ]*\([A-Za-z0-9_]*\)[ ]*=.*/\1/p' < "$srcdir/$podir/Makevars.template" | LC_ALL=C sort > "$srcdir/$podir/Makevars.tmp2" - missingvars=`LC_ALL=C comm -13 "$srcdir/$podir/Makevars.tmp1" "$srcdir/$podir/Makevars.tmp2"` - rm -f "$srcdir/$podir/Makevars.tmp1" "$srcdir/$podir/Makevars.tmp2" - if test -n "$missingvars"; then - please="$please -Please update $podir/Makevars so that it defines all the variables mentioned -in $podir/Makevars.template. -You can then remove $podir/Makevars.template. -" - fi - else - please="$please -Please create $podir/Makevars from the template in $podir/Makevars.template. -You can then remove $podir/Makevars.template. -" - fi - ;; - *) - same=no - if test -f "$srcdir/$podir/$file"; then - if cmp -s $file "$srcdir/$podir/$file"; then - same=yes - fi - fi - if $do_changelog && test $same = no; then - if test -f "$srcdir/$podir/$file"; then - func_poChangeLog_add_entry " * $file: Upgrade to gettext-${version}." - else - func_poChangeLog_add_entry " * $file: New file, from gettext-${version}." - fi - fi - func_backup "$podir/$file" - func_linkorcopy $file "$gettext_dir/po/$file" "$podir/$file" - ;; - esac - done - if test -f "$srcdir/$podir/cat-id-tbl.c"; then - func_remove "$podir/cat-id-tbl.c" - $do_changelog && func_poChangeLog_add_entry " * cat-id-tbl.c: Remove file." - fi - if test -f "$srcdir/$podir/stamp-cat-id"; then - func_remove "$podir/stamp-cat-id" - $do_changelog && func_poChangeLog_add_entry " * stamp-cat-id: Remove file." - fi - if test ! -f "$srcdir/$podir/POTFILES.in"; then - if $doit; then - echo "Creating initial $podir/POTFILES.in" - echo '# List of source files which contain translatable strings.' > "$srcdir/$podir/POTFILES.in" - else - echo "Create initial $podir/POTFILES.in" - fi - $do_changelog && func_poChangeLog_add_entry " * POTFILES.in: New file." - please="$please -Please fill $podir/POTFILES.in as described in the documentation. -" - fi - $do_changelog && func_poChangeLog_finish -done - -# Determine whether we can assume automake 1.9 or newer. -have_automake19= -if (aclocal --version) >/dev/null 2>/dev/null; then - aclocal_version=`aclocal --version | sed -n -e 1p | sed -e 's/^[^0-9]*//'` - case $aclocal_version in - 1.9* | 1.[1-9][0-9]* | [2-9]*) have_automake19=yes ;; - esac -fi - -m4filelist='gettext.m4 iconv.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 nls.m4 - po.m4 progtest.m4' -# With aclocal versions < 1.9 we need all m4 files, otherwise "aclocal -I m4" -# might give an error. (aclocal < 1.9 didn't know which macros are really -# needed, it looked which macros are potentially needed.) -min_automake_version=1.9 -if test -n "$intldir" || test -z "$have_automake19"; then - # Add intldir.m4, intl.m4 and its dependencies. - m4filelist=$m4filelist' codeset.m4 fcntl-o.m4 glibc2.m4 glibc21.m4 intdiv0.m4 - intl.m4 intldir.m4 intlmacosx.m4 intmax.m4 inttypes_h.m4 inttypes-pri.m4 - lcmessage.m4 lock.m4 longlong.m4 printf-posix.m4 size_max.m4 stdint_h.m4 - threadlib.m4 uintmax_t.m4 visibility.m4 wchar_t.m4 wint_t.m4 xsize.m4' - min_automake_version=1.8 -fi - -# All sorts of bugs could occur if the configure file was remade with the wrong -# version of gettext.m4 et al. (because then the configure and the po/Makefile.in.in -# don't fit together). It is therefore important that the package carries the -# right versions of gettext.m4 et al. with it. -if test -f "$srcdir/Makefile.am"; then - # A package using automake. - - # Determine whether it's using automake 1.8 or newer. - have_automake18= - if (aclocal --version) >/dev/null 2>/dev/null; then - aclocal_version=`aclocal --version | sed -n -e 1p | sed -e 's/^[^0-9]*//'` - case $aclocal_version in - 1.[8-9]* | 1.[1-9][0-9]* | [2-9]*) have_automake18=yes ;; - esac - fi - - # Extract the macro directory name from Makefile.am. - aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$srcdir/Makefile.am" | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'` - m4dir=m4 - m4dir_defaulted=yes - m4dir_is_next= - for arg in $aclocal_amflags; do - if test -n "$m4dir_is_next"; then - # Ignore absolute directory pathnames, like /usr/local/share/aclocal. - case "$arg" in - /*) ;; - *) - m4dir="$arg" - m4dir_defaulted= - break - ;; - esac - m4dir_is_next= - else - if test "X$arg" = "X-I"; then - m4dir_is_next=yes - else - m4dir_is_next= - fi - fi - done - - # Decide whether to use $m4dir/ChangeLog, or to use ChangeLog instead. - if test -d "$srcdir/$m4dir" && test -f "$srcdir/ChangeLog" && test ! -f "$srcdir/$m4dir/ChangeLog"; then - # The programmer has no $m4dir/ChangeLog so far. Don't introduce one. - using_m4ChangeLog= - fi - - # Update the *.m4 files and the corresponding Makefile.am. - $do_changelog && func_m4ChangeLog_init - added_m4dir= - added_m4files= - if test -d "$srcdir/$m4dir"; then - : - else - if $doit; then - echo "Creating directory $m4dir" - mkdir "$srcdir/$m4dir" - else - echo "Create directory $m4dir" - fi - added_m4dir=yes - fi - for file in $m4filelist; do - same=no - if test -f "$srcdir/$m4dir/$file"; then - if cmp -s "${datarootdir}/aclocal/$file" "$srcdir/$m4dir/$file"; then - same=yes - fi - else - added_m4files="$added_m4files $file" - fi - if $do_changelog && test $same = no; then - if test -f "$srcdir/$m4dir/$file"; then - func_m4ChangeLog_add_entry " * $file: Upgrade to gettext-${version}." - else - func_m4ChangeLog_add_entry " * $file: New file, from gettext-${version}." - fi - fi - func_backup "$m4dir/$file" - func_linkorcopy "${datarootdir}/aclocal/$file" "${datarootdir}/aclocal/$file" "$m4dir/$file" - done - missing_m4Makefileam= - if test -n "$added_m4files"; then - if test -f "$srcdir/$m4dir/Makefile.am"; then - if $doit; then - echo "Updating EXTRA_DIST in $m4dir/Makefile.am (backup is in $m4dir/Makefile.am~)" - func_backup "$m4dir/Makefile.am" - rm -f "$srcdir/$m4dir/Makefile.am" - if grep '^EXTRA_DIST[ ]*=' "$srcdir/$m4dir/Makefile.am~" > /dev/null; then - sed -e "s%^\(EXTRA_DIST[ ]*=\) \\?%\\1$added_m4files %" < "$srcdir/$m4dir/Makefile.am~" > "$srcdir/$m4dir/Makefile.am" - $do_changelog && func_m4ChangeLog_add_entry " * Makefile.am (EXTRA_DIST): Add the new files." - else - (cat "$srcdir/$m4dir/Makefile.am~"; echo; echo "EXTRA_DIST =$added_m4files") > "$srcdir/$m4dir/Makefile.am" - $do_changelog && func_m4ChangeLog_add_entry " * Makefile.am (EXTRA_DIST): New variable." - fi - else - echo "Update EXTRA_DIST in $m4dir/Makefile.am" - $do_changelog && func_m4ChangeLog_add_entry " * Makefile.am (EXTRA_DIST)." - fi - else - # $m4dir/Makefile.am is not needed any more when aclocal 1.8 or newer - # is used. - if test -z "$have_automake18"; then - if $doit; then - echo "Creating $m4dir/Makefile.am" - echo "EXTRA_DIST =$added_m4files" > "$srcdir/$m4dir/Makefile.am" - else - echo "Create $m4dir/Makefile.am" - fi - $do_changelog && func_m4ChangeLog_add_entry " * Makefile.am: New file." - added_acoutput="$added_acoutput $m4dir/Makefile" - else - missing_m4Makefileam=yes - fi - fi - fi - if test -n "$added_m4dir" && test -z "$missing_m4Makefileam"; then - added_directories="$added_directories $m4dir" - fi - $do_changelog && func_m4ChangeLog_finish - # automake will arrange for $m4dir/ChangeLog to be distributed if a - # $m4dir/Makefile.am exists. If not, we need to add it to Makefile.am's - # EXTRA_DIST explicitly. - if test -n "$created_m4ChangeLog" && test -n "$missing_m4Makefileam"; then - added_extradist="$added_extradist $m4dir/ChangeLog" - fi - - # Update the top-level Makefile.am. - modified_Makefile_am= - # func_modify_Makefile_am changelog_comment - # assumes a modified copy of $srcdir/Makefile.am in $srcdir/Makefile.am.tmp - # and replaces the original Makefile.am file with the modified one if - # the two files differ. Then it removes the modified copy. - func_modify_Makefile_am () - { - if cmp -s "$srcdir/Makefile.am" "$srcdir/Makefile.am.tmp"; then - : - else - if test -z "$modified_Makefile_am"; then - if $doit; then - echo "Updating Makefile.am (backup is in Makefile.am~)" - func_backup Makefile.am - else - echo "Update Makefile.am" - fi - fi - if $doit; then - rm -f "$srcdir/Makefile.am" - cp "$srcdir/Makefile.am.tmp" "$srcdir/Makefile.am" - fi - if $do_changelog; then - if test -z "$modified_Makefile_am"; then - func_ChangeLog_add_entry " * Makefile.am $1" - else - func_ChangeLog_add_entry " $1" - fi - fi - modified_Makefile_am=yes - fi - rm -f "$srcdir/Makefile.am.tmp" - } - - if test -n "$added_directories"; then - if grep '^SUBDIRS[ ]*=' "$srcdir/Makefile.am" > /dev/null; then - sed -e "s%^\(SUBDIRS[ ]*=\) \\?%\\1$added_directories %" < "$srcdir/Makefile.am" > "$srcdir/Makefile.am.tmp" - added_directories_pretty=`echo $added_directories | sed -e 's/ /, /g'` - func_modify_Makefile_am "(SUBDIRS): Add $added_directories_pretty." - else - (cat "$srcdir/Makefile.am"; echo; echo "SUBDIRS =$added_directories") > "$srcdir/Makefile.am.tmp" - func_modify_Makefile_am "(SUBDIRS): New variable." - fi - fi - if test -n "$removed_directory"; then - sed -e '/^SUBDIRS[ ]*=/ { - :a - s%\([ ]\)'"$removed_directory"'[ ]%\1% - s%[ ]'"$removed_directory"'$%% - tb - :b - s%\\$%\\% - tc - bd - :c - n - ba - :d - }' < "$srcdir/Makefile.am" > "$srcdir/Makefile.am.tmp" - func_modify_Makefile_am "(SUBDIRS): Remove $removed_directory." - fi - if test -n "$added_directories"; then - if grep '^DIST_SUBDIRS[ ]*=' "$srcdir/Makefile.am" > /dev/null; then - sed -e "s%^\(DIST_SUBDIRS[ ]*=\) \\?%\\1$added_directories %" < "$srcdir/Makefile.am" > "$srcdir/Makefile.am.tmp" - added_directories_pretty=`echo $added_directories | sed -e 's/ /, /g'` - func_modify_Makefile_am "(DIST_SUBDIRS): Add $added_directories_pretty." - fi - fi - if test -n "$removed_directory"; then - sed -e '/^DIST_SUBDIRS[ ]*=/ { - :a - s%\([ ]\)'"$removed_directory"'[ ]%\1% - s%[ ]'"$removed_directory"'$%% - tb - :b - s%\\$%\\% - tc - bd - :c - n - ba - :d - }' < "$srcdir/Makefile.am" > "$srcdir/Makefile.am.tmp" - func_modify_Makefile_am "(DIST_SUBDIRS): Remove $removed_directory." - fi - if test -n "$m4dir_defaulted"; then - if grep '^ACLOCAL_AMFLAGS[ ]*=' "$srcdir/Makefile.am" > /dev/null; then - sed -e "s%^\(ACLOCAL_AMFLAGS[ ]*=\) \\?%\\1 -I $m4dir %" < "$srcdir/Makefile.am" > "$srcdir/Makefile.am.tmp" - func_modify_Makefile_am "(ACLOCAL_AMFLAGS): Add -I $m4dir." - else - (cat "$srcdir/Makefile.am"; echo; echo "ACLOCAL_AMFLAGS = -I $m4dir") > "$srcdir/Makefile.am.tmp" - func_modify_Makefile_am "(ACLOCAL_AMFLAGS): New variable." - fi - # Also update Makefile.in and, if existent, Makefile. Otherwise they - # would take into account the new flags only after a few rounds of - # "./configure", "make", "touch configure.in", "make distclean". - if $doit; then - for file in Makefile.in Makefile; do - if test -f "$srcdir/$file"; then - func_backup $file - rm -f "$srcdir/$file" - sed -e "s%(ACLOCAL)%(ACLOCAL) -I $m4dir%" < "$srcdir/$file~" > "$srcdir/$file" - fi - done - fi - fi - if test -n "$added_extradist"; then - if grep '^EXTRA_DIST[ ]*=' "$srcdir/Makefile.am" > /dev/null; then - sed -e "s%^\(EXTRA_DIST[ ]*=\)%\\1$added_extradist %" < "$srcdir/Makefile.am" > "$srcdir/Makefile.am.tmp" - added_extradist_pretty=`echo $added_extradist | sed -e 's/ /, /g'` - func_modify_Makefile_am "(EXTRA_DIST): Add $added_extradist_pretty." - else - (cat "$srcdir/Makefile.am"; echo; echo "EXTRA_DIST =$added_extradist") > "$srcdir/Makefile.am.tmp" - func_modify_Makefile_am "(EXTRA_DIST): New variable." - fi - fi - # Extract the aclocal options name from Makefile.am. - aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$srcdir/Makefile.am" | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'` - aclocal_options= - m4dir_is_next= - for arg in $aclocal_amflags; do - if test -n "$m4dir_is_next"; then - aclocal_options="$aclocal_options -I $arg" - m4dir_is_next= - else - if test "X$arg" = "X-I"; then - m4dir_is_next=yes - else - m4dir_is_next= - fi - fi - done - please="$please -Please run 'aclocal$aclocal_options' to regenerate the aclocal.m4 file. -You need aclocal from GNU automake $min_automake_version (or newer) to do this. -Then run 'autoconf' to regenerate the configure file. -" - - # Also create $m4dir/Makefile.in from $m4dir/Makefile.am, because automake - # doesn't do it by itself. - if $doit; then - case "$added_acoutput" in - *" $m4dir/Makefile") - (cd "$srcdir" && automake "$m4dir/Makefile") 2>/dev/null || - please="$please -Please run 'automake $m4dir/Makefile' to create $m4dir/Makefile.in -" - ;; - esac - fi -else - please="$please -Please add the files -$m4filelist -from the ${datarootdir}/aclocal directory to your aclocal.m4 file. -" -fi - -modified_configure_in= -# func_modify_configure_in changelog_comment -# assumes a modified copy of $srcdir/$configure_in in $srcdir/$configure_in.tmp -# and replaces the original configure.in/ac file with the modified one if -# the two files differ. Then it removes the modified copy. -func_modify_configure_in () -{ - if cmp -s "$srcdir/$configure_in" "$srcdir/$configure_in.tmp"; then - : - else - if test -z "$modified_configure_in"; then - if $doit; then - echo "Updating $configure_in (backup is in $configure_in~)" - func_backup $configure_in - else - echo "Update $configure_in" - fi - fi - if $doit; then - rm -f "$srcdir/$configure_in" - cp "$srcdir/$configure_in.tmp" "$srcdir/$configure_in" - fi - if $do_changelog; then - if test -z "$modified_configure_in"; then - func_ChangeLog_add_entry " * $configure_in $1" - else - func_ChangeLog_add_entry " $1" - fi - fi - modified_configure_in=yes - fi - rm -f "$srcdir/$configure_in.tmp" -} - -if test -n "$added_acoutput"; then - if grep '^AC_CONFIG_FILES(' "$srcdir/$configure_in" > /dev/null; then - sedprog=' -ta -b -:a -n -ba' - sed -e "s%^\\(AC_CONFIG_FILES([^])\\,]*\\)%\\1$added_acoutput%$sedprog" < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp" - added_acoutput_pretty=`echo $added_acoutput | sed -e 's/ /, /g'` - func_modify_configure_in "(AC_CONFIG_FILES): Add $added_acoutput_pretty." - else - if grep '^AC_OUTPUT(' "$srcdir/$configure_in" > /dev/null; then - sed -e "s%^\\(AC_OUTPUT([^])\\,]*\\)%\\1$added_acoutput%" < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp" - added_acoutput_pretty=`echo $added_acoutput | sed -e 's/ /, /g'` - func_modify_configure_in "(AC_OUTPUT): Add $added_acoutput_pretty." - else - please="$please -Please add$added_acoutput to the AC_OUTPUT or AC_CONFIG_FILES invocation in the $configure_in file. -" - fi - fi -fi -if test -n "$removed_acoutput"; then - for file in $removed_acoutput; do - tag= - sedprog='{ - s%\([[ ]\)'"$file"'[ ]%\1% - s%\([[ ]\)'"$file"'\([]),]\)%\1\2% - s%[[ ]'"$file"'$%% - :a - tb - :b - s%\\$%\\% - tc - bd - :c - n - s%\([ ]\)'"$file"'[ ]%\1% - s%\([ ]\)'"$file"'\([]),]\)%\1\2% - s%[ ]'"$file"'$%% - ba - :d - }' - sed -e '/^AC_CONFIG_FILES(/'"$sedprog" < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp" - if cmp -s "$srcdir/$configure_in" "$srcdir/$configure_in.tmp"; then - sed -e '/^AC_OUTPUT(/'"$sedprog" < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp" - if cmp -s "$srcdir/$configure_in" "$srcdir/$configure_in.tmp"; then - : - else - tag=AC_OUTPUT - fi - else - tag=AC_CONFIG_FILES - fi - if test -n "$tag"; then - func_modify_configure_in "($tag): Remove $file." - else - rm -f "$srcdir/$configure_in.tmp" - if test "$file" != intl/intlh.inst; then - please="$please -Please remove $file from the AC_OUTPUT or AC_CONFIG_FILES invocation -in the $configure_in file. -" - fi - fi - done -fi -sed -e 's%sed -e "/POTFILES =/r po/POTFILES" po/Makefile\.in > po/Makefile *;* *%%' < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp" -func_modify_configure_in "(AC_OUTPUT): Remove command that created po/Makefile." -sed -e '/^\(dnl \|\)AC_LINK_FILES(\$nls_cv_header_libgt, \$nls_cv_header_intl)$/d' < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp" -func_modify_configure_in "(AC_LINK_FILES): Remove invocation." -sed -e 's/^AM_GNU_GETTEXT_VERSION([^()]*)/AM_GNU_GETTEXT_VERSION(['"$version"'])/' < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp" -func_modify_configure_in "(AM_GNU_GETTEXT_VERSION): Bump to $version." -$do_changelog && func_ChangeLog_finish - -# Recommend replacement for deprecated Makefile variables. -use_libtool=`cat "$srcdir/$configure_in" | grep '^A[CM]_PROG_LIBTOOL'` -for file in `(cd "$srcdir"; find . -name Makefile.am -print; find . -name Makefile.in -print) | sed -e 's,^\./,,'`; do - if test -f "$srcdir/$file"; then - if test `echo "$file" | sed -e 's,^.*/,,'` = Makefile.in && grep automake "$srcdir/$file" >/dev/null 2>&1; then - continue; - fi - # INTLLIBS is deprecated because it doesn't distinguish the two - # cases: with libtool, without libtool. - if grep '@''INTLLIBS''@' "$srcdir/$file" >/dev/null 2>&1; then - if test -n "$use_libtool"; then - please="$please -Please change $file to use @""LTLIBINTL""@ or @""LIBINTL""@ instead of -@""INTLLIBS""@. Which one, depends whether it is used with libtool or not. -@""INTLLIBS""@ will go away. -" - else - please="$please -Please change $file to use @""LIBINTL""@ instead of @""INTLLIBS""@. -@""INTLLIBS""@ will go away. -" - fi - fi - # DATADIRNAME is deprecated because we install only .gmo files nowadays, - # which can be stored in the platform independent $prefix/share hierarchy. - if grep '@''DATADIRNAME''@' "$srcdir/$file" >/dev/null 2>&1; then - please="$please -Please change $file to use the constant string \"share\" instead of -@""DATADIRNAME""@. @""DATADIRNAME""@ will go away. -" - fi - # INSTOBJEXT is deprecated because we install only .gmo files nowadays, - # no catgets .cat catalogs. - if grep '@''INSTOBJEXT''@' "$srcdir/$file" >/dev/null 2>&1; then - please="$please -Please change $file to use the constant string \".mo\" instead of -@""INSTOBJEXT""@. @""INSTOBJEXT""@ will go away. -" - fi - # GENCAT is deprecated because we install no catgets catalogs anymore. - if grep '@''GENCAT''@' "$srcdir/$file" >/dev/null 2>&1; then - please="$please -Please change $file to use the constant string \"gencat\" instead of -@""GENCAT""@. @""GENCAT""@ will go away. Maybe you don't even need it any more? -" - fi - # POSUB is deprecated because it causes "./configure --disable-nls", "make", - # "make dist" to create a buggy tarfile. - if grep '@''POSUB''@' "$srcdir/$file" >/dev/null 2>&1; then - please="$please -Please change $file to use the constant string \"po\" instead of -@""POSUB""@. @""POSUB""@ will go away. -" - fi - fi -done - -# Recommend replacement for deprecated configure variables. -if grep '\$nls_cv_header_' "$srcdir/$configure_in" >/dev/null 2>&1; then - please="$please -Please stop using \$nls_cv_header_intl or \$nls_cv_header_libgt in the -$configure_in file. Both will go away. Use or \"gettext.h\" instead. -" -fi - -# Recommend fetching config.guess and config.sub. -if test -f "$srcdir/$auxdir"config.guess && test -f "$srcdir/$auxdir"config.sub; then - : -else - please="$please -You will also need config.guess and config.sub, which you can get from the CVS -of the 'config' project at http://savannah.gnu.org/. The commands to fetch them -are -\$ wget 'http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess' -\$ wget 'http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub' -" -fi - -if $doit; then - echo "$please" - echo "You might also want to copy the convenience header file gettext.h" - echo "from the $gettext_dir directory into your package." - echo "It is a wrapper around that implements the configure --disable-nls" - echo "option." - echo - count=`echo "$please" | grep '^$' | wc -l` - count=`echo "$count" | sed -e 's/[ ]//g'` - case "$count" in - 1) count="paragraph";; - 2) count="two paragraphs";; - 3) count="three paragraphs";; - 4) count="four paragraphs";; - 5) count="five paragraphs";; - *) count="$count paragraphs";; - esac - echo "Press Return to acknowledge the previous $count." - # Read from /dev/tty, not stdin, so that gettextize cannot be abused by - # non-interactive tools. - read dummy < /dev/tty -fi - -exit 0 diff --git a/libs/gettext/bin32/libasprintf-0.dll b/libs/gettext/bin32/libasprintf-0.dll deleted file mode 100644 index dcd8f8593..000000000 Binary files a/libs/gettext/bin32/libasprintf-0.dll and /dev/null differ diff --git a/libs/gettext/bin32/libgcc_s_sjlj-1.dll b/libs/gettext/bin32/libgcc_s_sjlj-1.dll deleted file mode 100644 index b7c5910fd..000000000 Binary files a/libs/gettext/bin32/libgcc_s_sjlj-1.dll and /dev/null differ diff --git a/libs/gettext/bin32/libgettextlib-0-18-1.dll b/libs/gettext/bin32/libgettextlib-0-18-1.dll deleted file mode 100644 index b1bfb9462..000000000 Binary files a/libs/gettext/bin32/libgettextlib-0-18-1.dll and /dev/null differ diff --git a/libs/gettext/bin32/libgettextpo-0.dll b/libs/gettext/bin32/libgettextpo-0.dll deleted file mode 100644 index cea1c97be..000000000 Binary files a/libs/gettext/bin32/libgettextpo-0.dll and /dev/null differ diff --git a/libs/gettext/bin32/libgettextsrc-0-18-1.dll b/libs/gettext/bin32/libgettextsrc-0-18-1.dll deleted file mode 100644 index 95f904658..000000000 Binary files a/libs/gettext/bin32/libgettextsrc-0-18-1.dll and /dev/null differ diff --git a/libs/gettext/bin32/libintl-8.dll b/libs/gettext/bin32/libintl-8.dll deleted file mode 100644 index 9f10b6c55..000000000 Binary files a/libs/gettext/bin32/libintl-8.dll and /dev/null differ diff --git a/libs/gettext/bin32/msgattrib.exe b/libs/gettext/bin32/msgattrib.exe deleted file mode 100644 index 4f64eda79..000000000 Binary files a/libs/gettext/bin32/msgattrib.exe and /dev/null differ diff --git a/libs/gettext/bin32/msgcat.exe b/libs/gettext/bin32/msgcat.exe deleted file mode 100644 index b41e9141f..000000000 Binary files a/libs/gettext/bin32/msgcat.exe and /dev/null differ diff --git a/libs/gettext/bin32/msgcmp.exe b/libs/gettext/bin32/msgcmp.exe deleted file mode 100644 index 7743c9ed6..000000000 Binary files a/libs/gettext/bin32/msgcmp.exe and /dev/null differ diff --git a/libs/gettext/bin32/msgcomm.exe b/libs/gettext/bin32/msgcomm.exe deleted file mode 100644 index de4c6699f..000000000 Binary files a/libs/gettext/bin32/msgcomm.exe and /dev/null differ diff --git a/libs/gettext/bin32/msgconv.exe b/libs/gettext/bin32/msgconv.exe deleted file mode 100644 index 7be1c362f..000000000 Binary files a/libs/gettext/bin32/msgconv.exe and /dev/null differ diff --git a/libs/gettext/bin32/msgen.exe b/libs/gettext/bin32/msgen.exe deleted file mode 100644 index ee42349bf..000000000 Binary files a/libs/gettext/bin32/msgen.exe and /dev/null differ diff --git a/libs/gettext/bin32/msgexec.exe b/libs/gettext/bin32/msgexec.exe deleted file mode 100644 index 99e56dc02..000000000 Binary files a/libs/gettext/bin32/msgexec.exe and /dev/null differ diff --git a/libs/gettext/bin32/msgfilter.exe b/libs/gettext/bin32/msgfilter.exe deleted file mode 100644 index b99f25d57..000000000 Binary files a/libs/gettext/bin32/msgfilter.exe and /dev/null differ diff --git a/libs/gettext/bin32/msgfmt.exe b/libs/gettext/bin32/msgfmt.exe deleted file mode 100644 index 1badcca98..000000000 Binary files a/libs/gettext/bin32/msgfmt.exe and /dev/null differ diff --git a/libs/gettext/bin32/msggrep.exe b/libs/gettext/bin32/msggrep.exe deleted file mode 100644 index 2f27989b4..000000000 Binary files a/libs/gettext/bin32/msggrep.exe and /dev/null differ diff --git a/libs/gettext/bin32/msginit.exe b/libs/gettext/bin32/msginit.exe deleted file mode 100644 index 2f8fbef5e..000000000 Binary files a/libs/gettext/bin32/msginit.exe and /dev/null differ diff --git a/libs/gettext/bin32/msgmerge.exe b/libs/gettext/bin32/msgmerge.exe deleted file mode 100644 index 09dcad0c5..000000000 Binary files a/libs/gettext/bin32/msgmerge.exe and /dev/null differ diff --git a/libs/gettext/bin32/msgunfmt.exe b/libs/gettext/bin32/msgunfmt.exe deleted file mode 100644 index eada3edfd..000000000 Binary files a/libs/gettext/bin32/msgunfmt.exe and /dev/null differ diff --git a/libs/gettext/bin32/msguniq.exe b/libs/gettext/bin32/msguniq.exe deleted file mode 100644 index 6cb12abfb..000000000 Binary files a/libs/gettext/bin32/msguniq.exe and /dev/null differ diff --git a/libs/gettext/bin32/ngettext.exe b/libs/gettext/bin32/ngettext.exe deleted file mode 100644 index c1faea08e..000000000 Binary files a/libs/gettext/bin32/ngettext.exe and /dev/null differ diff --git a/libs/gettext/bin32/recode-sr-latin.exe b/libs/gettext/bin32/recode-sr-latin.exe deleted file mode 100644 index 366202d0b..000000000 Binary files a/libs/gettext/bin32/recode-sr-latin.exe and /dev/null differ diff --git a/libs/gettext/bin32/xgettext.exe b/libs/gettext/bin32/xgettext.exe deleted file mode 100644 index 4c3e02b7d..000000000 Binary files a/libs/gettext/bin32/xgettext.exe and /dev/null differ diff --git a/libs/gettext/bin64/autopoint b/libs/gettext/bin64/autopoint deleted file mode 100755 index 73d909638..000000000 --- a/libs/gettext/bin64/autopoint +++ /dev/null @@ -1,717 +0,0 @@ -#! /bin/sh -# -# Copyright (C) 2002-2010 Free Software Foundation, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# - -# This file is meant for authors, maintainers, co-maintainers or installers -# of packages which are internationalized with the help of GNU gettext. For -# further information how to use it consult the GNU gettext manual. - -progname=$0 -package=gettext-tools -version=0.18.1 - -# Set variables -# - gettext_dir directory where the sources are stored. -prefix="/usr/local/x86_64-w64-mingw32/stow/gettext-0.18.1.1" -datarootdir="${prefix}/share" -gettext_dir="${datarootdir}/gettext" - -# func_tmpdir -# creates a temporary directory. -# Sets variable -# - tmp pathname of freshly created temporary directory -func_tmpdir () -{ - # Use the environment variable TMPDIR, falling back to /tmp. This allows - # users to specify a different temporary directory, for example, if their - # /tmp is filled up or too small. - : ${TMPDIR=/tmp} - { - # Use the mktemp program if available. If not available, hide the error - # message. - tmp=`(umask 077 && mktemp -d "$TMPDIR/gtXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" - } || - { - # Use a simple mkdir command. It is guaranteed to fail if the directory - # already exists. $RANDOM is bash specific and expands to empty in shells - # other than bash, ksh and zsh. Its use does not increase security; - # rather, it minimizes the probability of failure in a very cluttered /tmp - # directory. - tmp=$TMPDIR/gt$$-$RANDOM - (umask 077 && mkdir "$tmp") - } || - { - echo "$0: cannot create a temporary directory in $TMPDIR" >&2 - { (exit 1); exit 1; } - } -} - -# Support for relocatability. -func_find_curr_installdir () -{ - # Determine curr_installdir, even taking into account symlinks. - curr_executable="$0" - case "$curr_executable" in - */* | *\\*) ;; - *) # Need to look in the PATH. - if test "${PATH_SEPARATOR+set}" != set; then - func_tmpdir - { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh - chmod +x "$tmp"/conf.sh - if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -rf "$tmp" - fi - save_IFS="$IFS"; IFS="$PATH_SEPARATOR" - for dir in $PATH; do - IFS="$save_IFS" - test -z "$dir" && dir=. - for exec_ext in ''; do - if test -f "$dir/$curr_executable$exec_ext"; then - curr_executable="$dir/$curr_executable$exec_ext" - break 2 - fi - done - done - IFS="$save_IFS" - ;; - esac - # Make absolute. - case "$curr_executable" in - /* | ?:/* | ?:\\*) ;; - *) curr_executable=`pwd`/"$curr_executable" ;; - esac - # Resolve symlinks. - sed_dirname='s,/[^/]*$,,' - sed_linkdest='s,^.* -> \(.*\),\1,p' - while : ; do - lsline=`LC_ALL=C ls -l "$curr_executable"` - case "$lsline" in - *" -> "*) - linkdest=`echo "$lsline" | sed -n -e "$sed_linkdest"` - case "$linkdest" in - /* | ?:/* | ?:\\*) curr_executable="$linkdest" ;; - *) curr_executable=`echo "$curr_executable" | sed -e "$sed_dirname"`/"$linkdest" ;; - esac ;; - *) break ;; - esac - done - curr_installdir=`echo "$curr_executable" | sed -e 's,/[^/]*$,,'` - # Canonicalize. - curr_installdir=`cd "$curr_installdir" && pwd` -} -func_find_prefixes () -{ - # Compute the original/current installation prefixes by stripping the - # trailing directories off the original/current installation directories. - orig_installprefix="$orig_installdir" - curr_installprefix="$curr_installdir" - while true; do - orig_last=`echo "$orig_installprefix" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'` - curr_last=`echo "$curr_installprefix" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'` - if test -z "$orig_last" || test -z "$curr_last"; then - break - fi - if test "$orig_last" != "$curr_last"; then - break - fi - orig_installprefix=`echo "$orig_installprefix" | sed -e 's,/[^/]*$,,'` - curr_installprefix=`echo "$curr_installprefix" | sed -e 's,/[^/]*$,,'` - done -} -if test "no" = yes; then - exec_prefix="${prefix}" - bindir="${exec_prefix}/bin" - orig_installdir="$bindir" # see Makefile.am's *_SCRIPTS variables - func_find_curr_installdir # determine curr_installdir - func_find_prefixes - # Relocate the directory variables that we use. - gettext_dir=`echo "$gettext_dir/" | sed -e "s%^${orig_installprefix}/%${curr_installprefix}/%" | sed -e 's,/$,,'` -fi - -# func_usage -# outputs to stdout the --help usage message. -func_usage () -{ - echo "\ -Usage: autopoint [OPTION]... - -Copies standard gettext infrastructure files into a source package. - -Options: - --help print this help and exit - --version print version information and exit - -f, --force force overwriting of files that already exist - -n, --dry-run print modifications but don't perform them" -# echo "\ -# -V version copy the infrastructure of the specified gettext version -# (dangerous)" - echo " -Report bugs to ." -} - -# func_version -# outputs to stdout the --version message. -func_version () -{ - echo "$progname (GNU $package) $version" - echo "Uses a versions archive in git format." - echo "Copyright (C) 2002-2010 Free Software Foundation, Inc. -License GPLv3+: GNU GPL version 3 or later -This is free software: you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law." - echo "Written by" "Bruno Haible" -} - -# func_fatal_error message -# outputs to stderr a fatal error message, and terminates the program. -func_fatal_error () -{ - echo "autopoint: *** $1" 1>&2 - echo "autopoint: *** Stop." 1>&2 - exit 1 -} - -# Command-line option processing. -# Removes the OPTIONS from the arguments. Sets the variables: -# - force yes if --force was given, empty otherwise -# - ver gettext version if -V was given, empty otherwise -# - doit false if --dry-run was given, : otherwise -{ - force= - ver= - doit=: - - while test $# -gt 0; do - case "$1" in - -n | --dry-run | --dry-ru | --dry-r | --dry- | --dry | --dr | --d ) - shift - doit=false ;; - -f | --force | --forc | --for | --fo | --f ) - shift - force=yes ;; - --help | --hel | --he | --h ) - func_usage; exit 0 ;; -# -V ) # Some people put a space between -V and the version number. -# shift -# if test $# = 0; then -# func_usage 1>&2 -# exit 1 -# fi -# ver=$1; -# shift ;; -# -V*) # Some people omit the space between -V and the version number. -# ver=`echo "X$1" | sed -e 's/^X-V//'` -# shift ;; - --version | --versio | --versi | --vers | --ver | --ve | --v ) - func_version - exit 0 ;; - -- ) # Stop option prcessing - shift; break ;; - -* ) - echo "autopoint: unknown option $1" 1>&2 - echo "Try 'autopoint --help' for more information." 1>&2 - exit 1 ;; - * ) - break ;; - esac - done -} - -# Command-line argument processing. -# Analyzes the remaining arguments. -{ - if test $# -gt 0; then - func_usage 1>&2 - exit 1 - fi -} - -srcdir=`pwd` -# The current directory is now $srcdir. - -# Check integrity of package: A configure.in/ac must be present. Sets variable -# - configure_in name of configure.in/ac file. -if test -f configure.in; then - configure_in=configure.in -else - if test -f configure.ac; then - configure_in=configure.ac - else - # KDE specific convention: configure.in.in - if test -f configure.in.in; then - configure_in=configure.in.in - else - func_fatal_error "Missing configure.in or configure.ac, please cd to your package first." - fi - fi -fi - -# Check whether the -V option and the version number in configure.in match. -# At least one of the two must be given. If both are given, they must agree. -sed_extract_AM_GNU_GETTEXT_VERSION_argument='s/^AM_GNU_GETTEXT_VERSION(\([^()]*\)).*$/\1/' -sed_remove_outer_brackets='s/^\[\(.*\)\]$/\1/' -xver=`cat "$configure_in" | grep '^AM_GNU_GETTEXT_VERSION(' | sed -n -e "$sed_extract_AM_GNU_GETTEXT_VERSION_argument"p | sed -e "$sed_remove_outer_brackets" | sed -e 1q` -if test -z "$xver" && test -f intl/VERSION; then - xver=`cat intl/VERSION | LC_ALL=C sed -n -e 's/^.*gettext-\([-+_.0-9A-Za-z]*\).*$/\1/p'` -fi -if test -n "$xver"; then - if test -n "$ver"; then - if test "X$ver" != "X$xver"; then - func_fatal_error "Version mismatch: specified -V $ver but the package uses gettext version $xver" - fi - else - ver="$xver" - fi -else - if test -z "$ver"; then - func_fatal_error "Missing version: please specify in $configure_in through a line 'AM_GNU_GETTEXT_VERSION(x.yy.zz)' the gettext version the package is using" - fi -fi - -# Check whether the version number is supported. -case "$ver" in - 0.10.35 | 0.10.36 | 0.10.37 | 0.10.38 | 0.10.39 | 0.10.40 | \ - 0.11 | 0.11.1 | 0.11.2 | 0.11.3 | 0.11.4 | 0.11.5 | \ - 0.12 | 0.12.1 | \ - 0.13 | 0.13.1 | \ - 0.14 | 0.14.1 | 0.14.2 | 0.14.3 | 0.14.4 | 0.14.5 | 0.14.6 | \ - 0.15 | \ - 0.16 | 0.16.1 | \ - 0.17 | \ - 0.18 | 0.18.1 ) - ;; - *) - func_fatal_error "The AM_GNU_GETTEXT_VERSION declaration in your $configure_in - file requires the infrastructure from gettext-$ver but this version - is older. Please upgrade to gettext-$ver or newer." - ;; -esac - -# Check in which directory config.rpath, mkinstalldirs etc. belong. -auxdir=`cat "$configure_in" | grep '^AC_CONFIG_AUX_DIR' | sed -n -e 's/AC_CONFIG_AUX_DIR(\([^()]*\))/\1/p' | sed -e 's/^\[\(.*\)\]$/\1/' | sed -e 1q` -if test -n "$auxdir"; then - auxdir="$auxdir/" -fi - -# Check in which directory the *.m4 macros belong. -m4dir=m4 -if test -f Makefile.am; then - # A package using automake. - # Extract the macro directory name from Makefile.am. - aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'` - m4dir_is_next= - for arg in $aclocal_amflags; do - if test -n "$m4dir_is_next"; then - m4dir="$arg" - break - else - if test "X$arg" = "X-I"; then - m4dir_is_next=yes - else - m4dir_is_next= - fi - fi - done -fi - -# Check whether to omit the intl/ directory. -omitintl=`cat "$configure_in" | grep '^AM_GNU_GETTEXT' | sed -n -e 's/^AM_GNU_GETTEXT(\([^(),]*\).*$/\1/p' | sed -e 's/^\[\(.*\)\]$/\1/' | sed -e 1q` -omitintl=`if test 'external' = "$omitintl"; then echo yes; fi` - -# Check in which directory or directories the po/* infrastructure belongs. -sed_extract_config_files='s,#.*$,, -s,^dnl .*$,, -s, dnl .*$,, -/AC_CONFIG_FILES(/ { - ta - :a - s/)/)/ - tb - s/\\$// - N - ba - :b - s,^.*AC_CONFIG_FILES([[ ]*\([^]"$`\\)]*\).*$,\1,p -}' -configfiles=`cat "$configure_in" | sed -n -e "$sed_extract_config_files"` -# PO directories have a Makefile.in generated from Makefile.in.in. -# Treat a directory as a PO directory if and only if it has a -# POTFILES.in file. This allows packages to have multiple PO -# directories under different names or in different locations. -sed_remove_Makefile_in='s,/Makefile\.in$,,' -podirs=`for f in $configfiles; do case "$f" in */Makefile.in) echo $f;; esac; done | sed -e "$sed_remove_Makefile_in"` -if test -z "$podirs"; then - # If we cannot get the list of PO directories from configure.ac, assume the - # common default. - podirs="po" -fi - -# Set up a temporary checkout directory. -# Set variables -# - work_dir directory containing the temporary checkout -work_dir=tmpwrk$$ -mkdir "$work_dir" || { - if test -d "$work_dir"; then - func_fatal_error "directory $work_dir already exists" - else - func_fatal_error "cannot create directory $work_dir" - fi -} - -# We support three archive formats. -# -# Format | Size (KiB) for gettext-0.17 | Extra tools needed | -# -------+-----------------------------+--------------------+ -# dir | 3000 | -- | -# cvs | 356 | cvs | -# git | 484 | git | -# -------+-----------------------------+--------------------+ - -case "git" in - dir) - # The archive of different versions is very large, but using it does not - # require special tools. - gzip -d -c < "$gettext_dir/archive.dir.tar.gz" | (cd "$work_dir" && tar xf - "gettext-$ver") - if test `find "$work_dir" -type f -print | wc -l` = 0; then - rm -rf "$work_dir" - func_fatal_error "infrastructure files for version $ver not found; this is autopoint from GNU $package $version" - fi - mv "$work_dir/gettext-$ver" "$work_dir/archive" - ;; - - cvs) - # We distributed the many different versions of the files in a CVS - # repository. This guaranteed a good compression rate: - # - # Including version size in KB of - # "du autopoint-files/archive" - # 0.10.35 240 - # 0.10.36 428 - # 0.10.37 436 - # 0.10.38 488 - # 0.10.39 500 - # 0.10.40 528 - # 0.11 720 - # 0.11.1 740 - # 0.11.2 748 - # 0.11.3 804 - # 0.11.4 864 - # 0.11.5 880 - # 0.12 1032 - # 0.12.1 1032 - # 0.13 1220 - # 0.13.1 1236 - # 0.14 1296 - # 0.14.1 1300 - # 0.14.2 1420 - # 0.14.3 1428 - # 0.14.4 1464 - # 0.14.5 1508 - # 0.14.6 1580 - # 0.15 1760 - # 0.16 1808 - # 0.16.1 1812 - # 0.17 2128 - # 0.18 2656 - # - # The requirement that the user must have the CVS program available is not - # a severe restrictions, because most of the people who use autopoint are - # users of CVS. - # - # But the CVS format is now deprecated, because "cvs init" does not work in - # all circumstances - # (see ) - # and we are not allowed to distribute the cvs infrastructure files - # ourselves - # (see ). - # - # Check availability of the CVS program. - (cvs -v) >/dev/null 2>/dev/null || func_fatal_error "cvs program not found" - - # Set up a temporary CVS repository. - # We need the temporary CVS repository because any checkout needs write - # access to the CVSROOT/history file, so it cannot be under $gettext_dir. - # We need the temporary checkout directory because when --force was not - # given, we need to compare the existing files with the checked out ones. - # Set variables - # - cvs_dir directory containing the temporary repository - cvs_dir=tmpcvs$$ - # Use an umask of 077, to avoid attacks that work by overwriting files in - # the "$CVSROOT"/CVSROOT directory. - (umask 077 && mkdir "$cvs_dir") || { - if test -d "$cvs_dir"; then - func_fatal_error "directory $cvs_dir already exists" - else - func_fatal_error "cannot create directory $cvs_dir" - fi - } - CVSROOT="$srcdir/$cvs_dir" - unset CVS_CLIENT_LOG - unset CVS_CLIENT_PORT - unset CVS_IGNORE_REMOTE_ROOT - unset CVS_LOCAL_BRANCH_NUM - unset CVS_NOBASES - unset CVS_PASSFILE - unset CVS_PASSWORD - unset CVS_PROXY_PORT - unset CVS_RCMD_PORT - unset CVS_RSH - unset CVS_SERVER - unset CVS_SERVER_SLEEP - CVS_SIGN_COMMITS= - export CVS_SIGN_COMMITS - unset CVS_SSH - unset CVS_VERIFY_CHECKOUTS - unset CVS_VERIFY_TEMPLATE - unset CVSIGNORE - unset CVSREAD - unset CVSREADONLYFS - unset CVSUMASK - unset CVSWRAPPERS - - # Need to pass -d "$CVSROOT", because there may be a CVS directory in the - # current directory. - cvs -d "$CVSROOT" init - gzip -d -c < "$gettext_dir/archive.cvs.tar.gz" | (cd "$cvs_dir" && tar xf -) - - cd "$work_dir" - cvsver=gettext-`echo "$ver" | sed -e 's/\./_/g'` - (cvs -d "$CVSROOT" checkout -r"$cvsver" archive > /dev/null) 2>&1 | grep -v '^cvs checkout: Updating' - find archive -name CVS -type d -print | xargs rm -rf - cd .. - rm -rf "$cvs_dir" - # Check that really all CVS directories are gone, otherwise we would overwrite - # the contents of the user's CVS directories. - if test `find $work_dir/archive -name CVS -type d -print | wc -l` != 0; then - rm -rf "$work_dir" - func_fatal_error "failed to remove all CVS subdirectories" - fi - if test `find $work_dir/archive -type f -print | wc -l` = 0; then - rm -rf "$work_dir" - func_fatal_error "infrastructure files for version $ver not found; this is autopoint from GNU $package $version" - fi - ;; - - git) - # Check availability of the git program. - (git --version) >/dev/null 2>/dev/null || func_fatal_error "git program not found" - mkdir "$work_dir/archive" - gzip -d -c < "$gettext_dir/archive.git.tar.gz" | (cd "$work_dir/archive" && tar xf -) - (cd "$work_dir/archive" && git checkout -q "gettext-$ver") || { - rm -rf "$work_dir" - func_fatal_error "infrastructure files for version $ver not found; this is autopoint from GNU $package $version" - } - (cd "$work_dir/archive" && rm -rf .git .gitignore) - ;; -esac - -# func_destfile file -# determines the destination file, relative to the package's top level -# directory, for a given file name, relative to archive. -# Sets variables -# - destfile relative destination file name, or -# empty if the file shall be omitted -# - sharedowner yes if the file is not only owned by GNU gettext but may -# be installed by automake or other tools, otherwise empty -# - allpodirs yes if the file is to be installed in every dir in $podirs -func_destfile () -{ - # There are five categories of files: - # ABOUT_NLS -> top level directory - # config.rpath mkinstalldirs -> $auxdir - # m4/* -> $m4dir/ - # intl/* -> intl/ - # po/* -> - sharedowner= - allpodirs= - case `echo "$1" | sed -e 's,[^/]*$,,'` in - "" ) - case "$1" in - config.rpath ) destfile="$auxdir$1" ;; - mkinstalldirs ) destfile="$auxdir$1" sharedowner=yes ;; - * ) destfile="$1" ;; - esac - ;; - m4/ ) destfile=`echo "$1" | sed -e "s,^m4/,$m4dir/,"` ;; - intl/ ) if test -n "$omitintl"; then destfile=""; else destfile="$1"; fi ;; - po/ ) destfile=`echo "$1" | sed -e "s,^po/,,"` allpodirs=yes ;; - * ) destfile="$1" ;; - esac -} - -# func_compare existingfile gettextfile -# compares the existing file and the file from gettext, and decides whether the -# existing file should be overwritten with the file from gettext. Returns 0 if -# it should be overwritten, or 1 if it should be skipped. -sed_extract_serial='s/^#.* serial \([^ ]*\).*/\1/p -1q' -func_compare () -{ - if cmp -s "$1" "$2"; then - false - else - case "$2" in - *.m4) - # For interoperability with gnulib. gnulib often has newer versions of - # the *.m4 files than the latest gettext release. Don't overwrite a - # newer version from gnulib with an older version from the gettext - # release. The version can be retrieved from the first line, which - # looks like this: # file.m4 serial NN ... - existing_serial=`sed -n -e "$sed_extract_serial" < "$1"` - gettext_serial=`sed -n -e "$sed_extract_serial" < "$2"` - if test -n "$existing_serial" && test -n "$gettext_serial" \ - && test "$existing_serial" -ge "$gettext_serial" 2> /dev/null; then - false - else - true - fi - ;; - *) - true - ;; - esac - fi -} - -# If some files have been locally modified and we have not been requested -# to overwrite them, then bail out. This is better than leaving a source -# package around where half of the files are locally modified and half are -# original - too great risk of version mismatch. -if test -z "$force"; then - mismatch= - func_tmpdir - mismatchfile="$tmp"/autopoint.diff - for file in `find "$work_dir/archive" -type f -print | sed -e "s,^$work_dir/archive/,," | LC_ALL=C sort`; do - func_destfile "$file" - if test -n "$destfile"; then - func_compare_to_destfile () - { - finaldestfile="$1" - if test -f "$finaldestfile"; then - if func_compare "$finaldestfile" "$work_dir/archive/$file"; then - if test -n "$sharedowner"; then - echo "autopoint: warning: File $finaldestfile has been locally modified." 1>&2 - else - echo "autopoint: File $finaldestfile has been locally modified." 1>&2 - mismatch=yes - diff -c "$work_dir/archive/$file" "$finaldestfile" | sed -e "1s,$work_dir/archive/,," >> "$mismatchfile" - fi - fi - fi - } - if test -n "$allpodirs"; then - for dir in $podirs; do - func_compare_to_destfile "$dir/$destfile" - done - else - func_compare_to_destfile "$destfile" - fi - fi - done - if test -n "$mismatch"; then - rm -rf "$work_dir" - func_fatal_error "Some files have been locally modified. Not overwriting them because --force has not been specified. For your convenience, you find the local modifications in the file '$mismatchfile'." - fi - rm -rf "$tmp" -fi - -# func_mkdir_for to -# ensures the directory that would the given file exists. -# 'to' is a relative pathname, relative to the current directory. -func_mkdir_for () -{ - base=`echo "$1" | sed -e 's,/[^/]*$,,'` - if test "X$base" != "X$1" && test -n "$base"; then - func_mkdir_for "$base" - # Recompute base. It was clobbered by the recursive call. - base=`echo "$1" | sed -e 's,/[^/]*$,,'` - test -d "$base" || { echo "Creating directory $base"; mkdir "$base"; } - fi -} - -# func_copy from to -# copies a file. -# 'from' is a relative pathname, relative to the current directory. -# 'to' is a relative pathname, relative to the current directory. -func_copy () -{ - if $doit; then - func_mkdir_for "$2" - rm -f "$2" - echo "Copying file $2" - cp "$1" "$2" - else - echo "Copy file $2" - fi -} - -# func_backup to -# makes a backup of a file that is about to be overwritten or replaced. -# 'to' is a relative pathname, relative to the current directory. -func_backup () -{ - if $doit; then - if test -f "$1"; then - rm -f "$1~" - cp -p "$1" "$1~" - fi - fi -} - -# Now copy the files. -for file in `find "$work_dir/archive" -type f -print | sed -e "s,^$work_dir/archive/,," | LC_ALL=C sort`; do - func_destfile "$file" - if test -n "$destfile"; then - func_copy_to_destfile () - { - finaldestfile="$1" - mustcopy= - if test -f "$finaldestfile"; then - if func_compare "$finaldestfile" "$work_dir/archive/$file"; then - if test -n "$force"; then - # Overwrite locally modified file. - mustcopy=yes - fi - # If --force is not specified, don't overwrite locally modified files - # for which GNU gettext is a shared owner. - fi - else - mustcopy=yes - fi - if test -n "$mustcopy"; then - func_backup "$finaldestfile" - func_copy "$work_dir/archive/$file" "$finaldestfile" - fi - } - if test -n "$allpodirs"; then - for dir in $podirs; do - func_copy_to_destfile "$dir/$destfile" - done - else - func_copy_to_destfile "$destfile" - fi - fi -done - -# That's it. -rm -rf "$work_dir" -exit 0 diff --git a/libs/gettext/bin64/envsubst.exe b/libs/gettext/bin64/envsubst.exe deleted file mode 100644 index 8e09a3397..000000000 Binary files a/libs/gettext/bin64/envsubst.exe and /dev/null differ diff --git a/libs/gettext/bin64/gettext.exe b/libs/gettext/bin64/gettext.exe deleted file mode 100644 index c9f48a0eb..000000000 Binary files a/libs/gettext/bin64/gettext.exe and /dev/null differ diff --git a/libs/gettext/bin64/gettext.sh b/libs/gettext/bin64/gettext.sh deleted file mode 100755 index 2369ab501..000000000 --- a/libs/gettext/bin64/gettext.sh +++ /dev/null @@ -1,123 +0,0 @@ -#! /bin/sh -# -# Copyright (C) 2003, 2005-2007 Free Software Foundation, Inc. -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU Library General Public -# License along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -# USA. -# - -# Find a way to echo strings without interpreting backslash. -if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then - echo='echo' -else - if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then - echo='printf %s\n' - else - echo_func () { - cat < -This is free software: you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law." - echo "Written by" "Bruno Haible" - } - if test $# = 1; then - case "$1" in - --help | --hel | --he | --h ) - func_usage; exit 0 ;; - --version | --versio | --versi | --vers | --ver | --ve | --v ) - func_version; exit 0 ;; - esac - fi - func_usage 1>&2 - exit 1 - ;; - esac -fi - -# eval_gettext MSGID -# looks up the translation of MSGID and substitutes shell variables in the -# result. -eval_gettext () { - gettext "$1" | (export PATH `envsubst --variables "$1"`; envsubst "$1") -} - -# eval_ngettext MSGID MSGID-PLURAL COUNT -# looks up the translation of MSGID / MSGID-PLURAL for COUNT and substitutes -# shell variables in the result. -eval_ngettext () { - ngettext "$1" "$2" "$3" | (export PATH `envsubst --variables "$1 $2"`; envsubst "$1 $2") -} - -# Note: This use of envsubst is much safer than using the shell built-in 'eval' -# would be. -# 1) The security problem with Chinese translations that happen to use a -# character such as \xe0\x60 is avoided. -# 2) The security problem with malevolent translators who put in command lists -# like "$(...)" or "`...`" is avoided. -# 3) The translations can only refer to shell variables that are already -# mentioned in MSGID or MSGID-PLURAL. -# -# Note: "export PATH" above is a dummy; this is for the case when -# `envsubst --variables ...` returns nothing. -# -# Note: In eval_ngettext above, "$1 $2" means a string whose variables set is -# the union of the variables set of "$1" and "$2". -# -# Note: The minimal use of backquote above ensures that trailing newlines are -# not dropped, not from the gettext invocation and not from the value of any -# shell variable. -# -# Note: Field splitting on the `envsubst --variables ...` result is desired, -# since envsubst outputs the variables, separated by newlines. Pathname -# wildcard expansion or tilde expansion has no effect here, since the words -# output by "envsubst --variables ..." consist solely of alphanumeric -# characters and underscore. diff --git a/libs/gettext/bin64/gettextize b/libs/gettext/bin64/gettextize deleted file mode 100755 index 8261a1cb7..000000000 --- a/libs/gettext/bin64/gettextize +++ /dev/null @@ -1,1281 +0,0 @@ -#! /bin/sh -# -# Copyright (C) 1995-1998, 2000-2010 Free Software Foundation, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# - -# This file is meant for authors or maintainers which want to -# internationalize their package with the help of GNU gettext. For -# further information how to use it consult the GNU gettext manual. - -progname=$0 -package=gettext-tools -version=0.18.1 - -# Set variables -# - gettext_dir directory where the sources are stored. -prefix="/usr/local/x86_64-w64-mingw32/stow/gettext-0.18.1.1" -datarootdir="${prefix}/share" -gettext_dir="${datarootdir}/gettext" - -# func_tmpdir -# creates a temporary directory. -# Sets variable -# - tmp pathname of freshly created temporary directory -func_tmpdir () -{ - # Use the environment variable TMPDIR, falling back to /tmp. This allows - # users to specify a different temporary directory, for example, if their - # /tmp is filled up or too small. - : ${TMPDIR=/tmp} - { - # Use the mktemp program if available. If not available, hide the error - # message. - tmp=`(umask 077 && mktemp -d "$TMPDIR/gtXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" - } || - { - # Use a simple mkdir command. It is guaranteed to fail if the directory - # already exists. $RANDOM is bash specific and expands to empty in shells - # other than bash, ksh and zsh. Its use does not increase security; - # rather, it minimizes the probability of failure in a very cluttered /tmp - # directory. - tmp=$TMPDIR/gt$$-$RANDOM - (umask 077 && mkdir "$tmp") - } || - { - echo "$0: cannot create a temporary directory in $TMPDIR" >&2 - { (exit 1); exit 1; } - } -} - -# Support for relocatability. -func_find_curr_installdir () -{ - # Determine curr_installdir, even taking into account symlinks. - curr_executable="$0" - case "$curr_executable" in - */* | *\\*) ;; - *) # Need to look in the PATH. - if test "${PATH_SEPARATOR+set}" != set; then - func_tmpdir - { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh - chmod +x "$tmp"/conf.sh - if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -rf "$tmp" - fi - save_IFS="$IFS"; IFS="$PATH_SEPARATOR" - for dir in $PATH; do - IFS="$save_IFS" - test -z "$dir" && dir=. - for exec_ext in ''; do - if test -f "$dir/$curr_executable$exec_ext"; then - curr_executable="$dir/$curr_executable$exec_ext" - break 2 - fi - done - done - IFS="$save_IFS" - ;; - esac - # Make absolute. - case "$curr_executable" in - /* | ?:/* | ?:\\*) ;; - *) curr_executable=`pwd`/"$curr_executable" ;; - esac - # Resolve symlinks. - sed_dirname='s,/[^/]*$,,' - sed_linkdest='s,^.* -> \(.*\),\1,p' - while : ; do - lsline=`LC_ALL=C ls -l "$curr_executable"` - case "$lsline" in - *" -> "*) - linkdest=`echo "$lsline" | sed -n -e "$sed_linkdest"` - case "$linkdest" in - /* | ?:/* | ?:\\*) curr_executable="$linkdest" ;; - *) curr_executable=`echo "$curr_executable" | sed -e "$sed_dirname"`/"$linkdest" ;; - esac ;; - *) break ;; - esac - done - curr_installdir=`echo "$curr_executable" | sed -e 's,/[^/]*$,,'` - # Canonicalize. - curr_installdir=`cd "$curr_installdir" && pwd` -} -func_find_prefixes () -{ - # Compute the original/current installation prefixes by stripping the - # trailing directories off the original/current installation directories. - orig_installprefix="$orig_installdir" - curr_installprefix="$curr_installdir" - while true; do - orig_last=`echo "$orig_installprefix" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'` - curr_last=`echo "$curr_installprefix" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'` - if test -z "$orig_last" || test -z "$curr_last"; then - break - fi - if test "$orig_last" != "$curr_last"; then - break - fi - orig_installprefix=`echo "$orig_installprefix" | sed -e 's,/[^/]*$,,'` - curr_installprefix=`echo "$curr_installprefix" | sed -e 's,/[^/]*$,,'` - done -} -if test "no" = yes; then - exec_prefix="${prefix}" - bindir="${exec_prefix}/bin" - orig_installdir="$bindir" # see Makefile.am's *_SCRIPTS variables - func_find_curr_installdir # determine curr_installdir - func_find_prefixes - # Relocate the directory variables that we use. - gettext_dir=`echo "$gettext_dir/" | sed -e "s%^${orig_installprefix}/%${curr_installprefix}/%" | sed -e 's,/$,,'` -fi - -# func_usage -# outputs to stdout the --help usage message. -func_usage () -{ - echo "\ -Usage: gettextize [OPTION]... [package-dir] - -Prepares a source package to use gettext. - -Options: - --help print this help and exit - --version print version information and exit - -f, --force force writing of new files even if old exist - --intl install libintl in a subdirectory (deprecated) - --po-dir=DIR specify directory with PO files - --no-changelog don't update or create ChangeLog files - --symlink make symbolic links instead of copying files - -n, --dry-run print modifications but don't perform them - -Report bugs to ." -} - -# func_version -# outputs to stdout the --version message. -func_version () -{ - echo "$progname (GNU $package) $version" - echo "Copyright (C) 1995-1998, 2000-2010 Free Software Foundation, Inc. -License GPLv3+: GNU GPL version 3 or later -This is free software: you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law." - echo "Written by" "Ulrich Drepper" -} - -# func_fatal_error message -# outputs to stderr a fatal error message, and terminates the program. -func_fatal_error () -{ - echo "gettextize: *** $1" 1>&2 - echo "gettextize: *** Stop." 1>&2 - exit 1 -} - -# Nuisances. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -# Command-line option processing. -# Removes the OPTIONS from the arguments. Sets the variables: -# - force 1 if --force was given, 0 otherwise -# - intldir yes if --intl was given, empty otherwise -# - podirs list of directories specified with --po-dir -# - try_ln_s : if --symlink was given, false otherwise -# - do_changelog false if --no-changelog was given, : otherwise -# - doit false if --dry-run was given, : otherwise -{ - force=0 - intldir= - podirs= - try_ln_s=false - do_changelog=: - doit=: - - while test $# -gt 0; do - case "$1" in - -c | --copy | --cop | --co | --c ) # accepted for backward compatibility - shift ;; - -n | --dry-run | --dry-ru | --dry-r | --dry- | --dry | --dr | --d ) - shift - doit=false ;; - -f | --force | --forc | --for | --fo | --f ) - shift - force=1 ;; - --help | --hel | --he | --h ) - func_usage; exit 0 ;; - --intl | --int | --in | --i ) - shift - intldir=yes ;; - --po-dir | --po-di | --po-d | --po- | --po | --p ) - shift - if test $# = 0; then - func_fatal_error "missing argument for --po-dir" - fi - case "$1" in - -*) func_fatal_error "missing argument for --po-dir" ;; - esac - podirs="$podirs $1" - shift ;; - --po-dir=* ) - arg=`echo "X$1" | sed -e 's/^X--po-dir=//'` - podirs="$podirs $arg" - shift ;; - --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c ) - shift - do_changelog=false ;; - --symlink | --symlin | --symli | --syml | --sym | --sy | --s ) - shift - try_ln_s=: ;; - --version | --versio | --versi | --vers | --ver | --ve | --v ) - func_version - exit 0 ;; - -- ) # Stop option prcessing - shift; break ;; - -* ) - echo "gettextize: unknown option $1" 1>&2 - echo "Try 'gettextize --help' for more information." 1>&2 - exit 1 ;; - * ) - break ;; - esac - done - # podirs defaults to "po". - test -n "$podirs" || podirs="po" -} - -# Warn about deprecated options. -if test -n "$intldir"; then - echo "gettextize: warning: the option '--intl' is deprecated and will be removed" 1>&2 -fi - -# Command-line argument processing. -# Analyzes the remaining arguments. -# Sets the variables -# - origdir to the original directory, -# - srcdir to the package directory, and cd-s into it. -{ - if test $# -gt 1; then - func_usage 1>&2 - exit 1 - fi - origdir=`pwd` - if test $# -eq 1; then - srcdir=$1 - if cd "$srcdir"; then - srcdir=`pwd` - else - func_fatal_error "Cannot change directory to '$srcdir'." - fi - else - srcdir=$origdir - fi -} - -# The current directory is now $srcdir. - -# Check integrity of package: A configure.in/ac must be present. Sets variable -# - configure_in name of configure.in/ac file. -test -f configure.in || test -f configure.ac || - func_fatal_error "Missing configure.in or configure.ac, please cd to your package first." -configure_in=NONE -if test -f configure.in; then - configure_in=configure.in -else - if test -f configure.ac; then - configure_in=configure.ac - fi -fi - -# Check whether the --force option is needed but has not been specified. -if test $force -eq 0; then - if test -d intl; then - func_fatal_error "intl/ subdirectory exists: use option -f if you really want to delete it." - fi - for podir in $podirs; do - if test -f "$podir/Makefile.in.in"; then - func_fatal_error "$podir/Makefile.in.in exists: use option -f if you really want to delete it." - fi - done - if test -f ABOUT-NLS; then - func_fatal_error "ABOUT-NLS exists: use option -f if you really want to delete it." - fi -fi - -# Check in which directory config.rpath etc. belong. -auxdir=`cat "$configure_in" | grep '^AC_CONFIG_AUX_DIR' | sed -n -e 's/AC_CONFIG_AUX_DIR(\([^()]*\))/\1/p' | sed -e 's/^\[\(.*\)\]$/\1/' | sed -e 1q` -if test -n "$auxdir"; then - auxdir="$auxdir/" -fi - -# For simplicity we change to the gettext source directory. -cd "$gettext_dir" || - func_fatal_error "gettext source directory '${gettext_dir}' doesn't exist" - -# Variables which keep track what has been modified. -added_directories= -removed_directory= -added_extradist= -added_acoutput= -removed_acoutput=" intl/intlh.inst" - -# Variable: -# - please accumulates instructions for the user. -please= - -# Variable: -# - date current date, for use in ChangeLog entries. -date=`date +%Y-%m-%d` - -# func_copy from to -# copies a file. -# 'from' is a relative pathname, relative to the current directory. -# 'to' is a relative pathname, relative to $srcdir. -func_copy () -{ - if $doit; then - rm -f "$srcdir/$2" - echo "Copying file $2" - cp "$1" "$srcdir/$2" - else - echo "Copy file $2" - fi -} - -# func_linkorcopy from absfrom to -# links or copies a file. -# 'from' is a relative pathname, relative to the current directory. -# 'absfrom' is the corresponding absolute pathname. -# 'to' is a relative pathname, relative to $srcdir. -func_linkorcopy () -{ - if $doit; then - rm -f "$srcdir/$3" - ($try_ln_s && ln -s "$2" "$srcdir/$3" && echo "Symlinking file $3") 2>/dev/null || - { echo "Copying file $3"; cp "$1" "$srcdir/$3"; } - else - if $try_ln_s; then - echo "Symlink file $3" - else - echo "Copy file $3" - fi - fi -} - -# func_backup to -# makes a backup of a file that is about to be overwritten or replaced. -# 'to' is a relative pathname, relative to $srcdir. -func_backup () -{ - if $doit; then - if test -f "$srcdir/$1"; then - rm -f "$srcdir/$1~" - cp -p "$srcdir/$1" "$srcdir/$1~" - fi - fi -} - -# func_remove to -# removes a file. -# 'to' is a relative pathname, relative to $srcdir. -func_remove () -{ - if $doit; then - echo "Removing $1" - rm -f "$srcdir/$1" - else - echo "Remove $1" - fi -} - -# func_ChangeLog_init -# func_ChangeLog_add_entry line -# func_ChangeLog_finish -# manage the ChangeLog file, relative to $srcdir. -func_ChangeLog_init () -{ - modified_ChangeLog= -} -func_ChangeLog_add_entry () -{ - if $doit; then - if test -z "$modified_ChangeLog"; then - echo "$date gettextize " > "$srcdir/ChangeLog.tmp" - echo >> "$srcdir/ChangeLog.tmp" - modified_ChangeLog=yes - fi - echo "$1" >> "$srcdir/ChangeLog.tmp" - else - modified_ChangeLog=yes - fi -} -func_ChangeLog_finish () -{ - if test -n "$modified_ChangeLog"; then - if $doit; then - echo >> "$srcdir/ChangeLog.tmp" - if test -f "$srcdir/ChangeLog"; then - echo "Adding an entry to ChangeLog (backup is in ChangeLog~)" - cat "$srcdir/ChangeLog" >> "$srcdir/ChangeLog.tmp" - rm -f "$srcdir/ChangeLog~" - cp -p "$srcdir/ChangeLog" "$srcdir/ChangeLog~" - else - echo "Creating ChangeLog" - fi - cp "$srcdir/ChangeLog.tmp" "$srcdir/ChangeLog" - rm -f "$srcdir/ChangeLog.tmp" - else - if test -f "$srcdir/ChangeLog"; then - echo "Add an entry to ChangeLog" - else - echo "Create ChangeLog" - fi - fi - fi -} - -# func_poChangeLog_init -# func_poChangeLog_add_entry line -# func_poChangeLog_finish -# manage the $podir/ChangeLog file, relative to $srcdir. -func_poChangeLog_init () -{ - modified_poChangeLog= -} -func_poChangeLog_add_entry () -{ - if $doit; then - if test -z "$modified_poChangeLog"; then - echo "$date gettextize " > "$srcdir/$podir/ChangeLog.tmp" - echo >> "$srcdir/$podir/ChangeLog.tmp" - modified_poChangeLog=yes - fi - echo "$1" >> "$srcdir/$podir/ChangeLog.tmp" - else - modified_poChangeLog=yes - fi -} -func_poChangeLog_finish () -{ - if test -n "$modified_poChangeLog"; then - if $doit; then - echo >> "$srcdir/$podir/ChangeLog.tmp" - if test -f "$srcdir/$podir/ChangeLog"; then - echo "Adding an entry to $podir/ChangeLog (backup is in $podir/ChangeLog~)" - cat "$srcdir/$podir/ChangeLog" >> "$srcdir/$podir/ChangeLog.tmp" - rm -f "$srcdir/$podir/ChangeLog~" - cp -p "$srcdir/$podir/ChangeLog" "$srcdir/$podir/ChangeLog~" - else - echo "Creating $podir/ChangeLog" - fi - cp "$srcdir/$podir/ChangeLog.tmp" "$srcdir/$podir/ChangeLog" - rm -f "$srcdir/$podir/ChangeLog.tmp" - else - if test -f "$srcdir/$podir/ChangeLog"; then - echo "Add an entry to $podir/ChangeLog" - else - echo "Create $podir/ChangeLog" - fi - fi - fi -} - -# func_m4ChangeLog_init -# func_m4ChangeLog_add_entry line -# func_m4ChangeLog_finish -# manage the $m4dir/ChangeLog file, relative to $srcdir. -func_m4ChangeLog_init () -{ - if test -n "$using_m4ChangeLog"; then - modified_m4ChangeLog= - created_m4ChangeLog= - fi -} -func_m4ChangeLog_add_entry () -{ - if test -n "$using_m4ChangeLog"; then - if $doit; then - if test -z "$modified_m4ChangeLog"; then - echo "$date gettextize " > "$srcdir/$m4dir/ChangeLog.tmp" - echo >> "$srcdir/$m4dir/ChangeLog.tmp" - modified_m4ChangeLog=yes - fi - echo "$1" >> "$srcdir/$m4dir/ChangeLog.tmp" - else - modified_m4ChangeLog=yes - fi - else - line="$1" - line=`echo "$line" | sed -e "s%^ \\* % * $m4dir/%"` - func_ChangeLog_add_entry "$line" - fi -} -func_m4ChangeLog_finish () -{ - if test -n "$using_m4ChangeLog"; then - if test -n "$modified_m4ChangeLog"; then - if $doit; then - echo >> "$srcdir/$m4dir/ChangeLog.tmp" - if test -f "$srcdir/$m4dir/ChangeLog"; then - echo "Adding an entry to $m4dir/ChangeLog (backup is in $m4dir/ChangeLog~)" - cat "$srcdir/$m4dir/ChangeLog" >> "$srcdir/$m4dir/ChangeLog.tmp" - rm -f "$srcdir/$m4dir/ChangeLog~" - cp -p "$srcdir/$m4dir/ChangeLog" "$srcdir/$m4dir/ChangeLog~" - else - echo "Creating $m4dir/ChangeLog" - created_m4ChangeLog=yes - fi - cp "$srcdir/$m4dir/ChangeLog.tmp" "$srcdir/$m4dir/ChangeLog" - rm -f "$srcdir/$m4dir/ChangeLog.tmp" - else - if test -f "$srcdir/$m4dir/ChangeLog"; then - echo "Add an entry to $m4dir/ChangeLog" - else - echo "Create $m4dir/ChangeLog" - created_m4ChangeLog=yes - fi - fi - fi - fi -} -using_m4ChangeLog=yes - -if test ! -f "$srcdir/intl/Makefile.in" && test -n "$intldir"; then - added_acoutput="$added_acoutput intl/Makefile" -fi -if test -f "$srcdir/intl/Makefile.in" && test -z "$intldir"; then - removed_acoutput="$removed_acoutput intl/Makefile" -fi -if test -d "$srcdir/intl"; then - # Remove everything inside intl except for RCS and CVS subdirs and invisible - # files. - if $doit; then - echo "Wiping out intl/ subdirectory" - (cd "$srcdir/intl" && - for f in *; do - if test CVS != "$f" && test RCS != "$f"; then - rm -rf "$f" - fi - done) - else - echo "Wipe out intl/ subdirectory" - fi - if test -z "$intldir"; then - removed_directory=intl - fi -else - if test -n "$intldir"; then - if $doit; then - echo "Creating intl/ subdirectory" - mkdir "$srcdir/intl" || func_fatal_error "failed to create intl/ subdirectory" - else - echo "Create intl/ subdirectory" - fi - added_directories="$added_directories intl" - fi -fi - -$do_changelog && func_ChangeLog_init - -for podir in $podirs; do - test -d "$srcdir/$podir" || { - if $doit; then - echo "Creating $podir/ subdirectory" - mkdir "$srcdir/$podir" || func_fatal_error "failed to create $podir/ subdirectory" - else - echo "Create $podir/ subdirectory" - fi - added_directories="$added_directories $podir" - } -done - -# Create the directory for config.rpath, if needed. -# This is for consistency with autoreconf and automake. -# Note that $auxdir is either empty or ends in a slash. -test -d "$srcdir/$auxdir" || { - if $doit; then - echo "Creating $auxdir subdirectory" - mkdir "$srcdir/$auxdir" || func_fatal_error "failed to create $auxdir subdirectory" - else - echo "Create $auxdir subdirectory" - fi -} - -# Now copy all files. Take care for the destination directories. -for file in *; do - case $file in - ABOUT-NLS) - func_linkorcopy $file "$gettext_dir/$file" $file - ;; - config.rpath) - if test -f "$srcdir/$auxdir$file"; then - : - else - added_extradist="$added_extradist $auxdir$file" - fi - func_linkorcopy $file "$gettext_dir/$file" "$auxdir$file" - ;; - esac -done - -# Copy files to intl/ subdirectory. -if test -n "$intldir"; then - cd intl - for file in *; do - if test $file != COPYING.LIB-2.0 && test $file != COPYING.LIB-2.1; then - if test $file != plural.c; then - func_linkorcopy $file "$gettext_dir/intl/$file" intl/$file - else - # plural.c is a generated file; it must be copied and touched. - func_copy $file intl/$file - if $doit; then - (sleep 2; touch "$srcdir/intl/$file") & - fi - fi - fi - done - cd .. -else - echo "Not copying intl/ directory." - # Tell the user what to put into configure.ac, if it is not already there. - if grep '^AM_GNU_GETTEXT([[]\?external[]]\?[ ]*[,)]' "$srcdir/$configure_in" > /dev/null; then - : - else - please="$please -Please use AM_GNU_GETTEXT([external]) in order to cause autoconfiguration -to look for an external libintl. -" - fi -fi - -# Copy files to po/ subdirectory. -cd po -for podir in $podirs; do - $do_changelog && func_poChangeLog_init - for file in Makefile.in.in; do - same=no - if test -f "$srcdir/$podir/$file"; then - if cmp -s $file "$srcdir/$podir/$file"; then - same=yes - fi - else - added_acoutput="$added_acoutput $podir/Makefile.in" - fi - if $do_changelog && test $same = no; then - if test -f "$srcdir/$podir/$file"; then - func_poChangeLog_add_entry " * $file: Upgrade to gettext-${version}." - else - func_poChangeLog_add_entry " * $file: New file, from gettext-${version}." - fi - fi - func_backup "$podir/$file" - func_linkorcopy $file "$gettext_dir/po/$file" "$podir/$file" - done - for file in *; do - case $file in - Makefile.in.in) - # Already handled above. - ;; - Makevars.template) - func_linkorcopy Makevars.template "$gettext_dir/po/Makevars.template" "$podir/Makevars.template" - if test -f "$srcdir/po/Makevars"; then - LC_ALL=C sed -n -e 's/[ ]*\([A-Za-z0-9_]*\)[ ]*=.*/\1/p' < "$srcdir/$podir/Makevars" | LC_ALL=C sort > "$srcdir/$podir/Makevars.tmp1" - LC_ALL=C sed -n -e 's/[ ]*\([A-Za-z0-9_]*\)[ ]*=.*/\1/p' < "$srcdir/$podir/Makevars.template" | LC_ALL=C sort > "$srcdir/$podir/Makevars.tmp2" - missingvars=`LC_ALL=C comm -13 "$srcdir/$podir/Makevars.tmp1" "$srcdir/$podir/Makevars.tmp2"` - rm -f "$srcdir/$podir/Makevars.tmp1" "$srcdir/$podir/Makevars.tmp2" - if test -n "$missingvars"; then - please="$please -Please update $podir/Makevars so that it defines all the variables mentioned -in $podir/Makevars.template. -You can then remove $podir/Makevars.template. -" - fi - else - please="$please -Please create $podir/Makevars from the template in $podir/Makevars.template. -You can then remove $podir/Makevars.template. -" - fi - ;; - *) - same=no - if test -f "$srcdir/$podir/$file"; then - if cmp -s $file "$srcdir/$podir/$file"; then - same=yes - fi - fi - if $do_changelog && test $same = no; then - if test -f "$srcdir/$podir/$file"; then - func_poChangeLog_add_entry " * $file: Upgrade to gettext-${version}." - else - func_poChangeLog_add_entry " * $file: New file, from gettext-${version}." - fi - fi - func_backup "$podir/$file" - func_linkorcopy $file "$gettext_dir/po/$file" "$podir/$file" - ;; - esac - done - if test -f "$srcdir/$podir/cat-id-tbl.c"; then - func_remove "$podir/cat-id-tbl.c" - $do_changelog && func_poChangeLog_add_entry " * cat-id-tbl.c: Remove file." - fi - if test -f "$srcdir/$podir/stamp-cat-id"; then - func_remove "$podir/stamp-cat-id" - $do_changelog && func_poChangeLog_add_entry " * stamp-cat-id: Remove file." - fi - if test ! -f "$srcdir/$podir/POTFILES.in"; then - if $doit; then - echo "Creating initial $podir/POTFILES.in" - echo '# List of source files which contain translatable strings.' > "$srcdir/$podir/POTFILES.in" - else - echo "Create initial $podir/POTFILES.in" - fi - $do_changelog && func_poChangeLog_add_entry " * POTFILES.in: New file." - please="$please -Please fill $podir/POTFILES.in as described in the documentation. -" - fi - $do_changelog && func_poChangeLog_finish -done - -# Determine whether we can assume automake 1.9 or newer. -have_automake19= -if (aclocal --version) >/dev/null 2>/dev/null; then - aclocal_version=`aclocal --version | sed -n -e 1p | sed -e 's/^[^0-9]*//'` - case $aclocal_version in - 1.9* | 1.[1-9][0-9]* | [2-9]*) have_automake19=yes ;; - esac -fi - -m4filelist='gettext.m4 iconv.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 nls.m4 - po.m4 progtest.m4' -# With aclocal versions < 1.9 we need all m4 files, otherwise "aclocal -I m4" -# might give an error. (aclocal < 1.9 didn't know which macros are really -# needed, it looked which macros are potentially needed.) -min_automake_version=1.9 -if test -n "$intldir" || test -z "$have_automake19"; then - # Add intldir.m4, intl.m4 and its dependencies. - m4filelist=$m4filelist' codeset.m4 fcntl-o.m4 glibc2.m4 glibc21.m4 intdiv0.m4 - intl.m4 intldir.m4 intlmacosx.m4 intmax.m4 inttypes_h.m4 inttypes-pri.m4 - lcmessage.m4 lock.m4 longlong.m4 printf-posix.m4 size_max.m4 stdint_h.m4 - threadlib.m4 uintmax_t.m4 visibility.m4 wchar_t.m4 wint_t.m4 xsize.m4' - min_automake_version=1.8 -fi - -# All sorts of bugs could occur if the configure file was remade with the wrong -# version of gettext.m4 et al. (because then the configure and the po/Makefile.in.in -# don't fit together). It is therefore important that the package carries the -# right versions of gettext.m4 et al. with it. -if test -f "$srcdir/Makefile.am"; then - # A package using automake. - - # Determine whether it's using automake 1.8 or newer. - have_automake18= - if (aclocal --version) >/dev/null 2>/dev/null; then - aclocal_version=`aclocal --version | sed -n -e 1p | sed -e 's/^[^0-9]*//'` - case $aclocal_version in - 1.[8-9]* | 1.[1-9][0-9]* | [2-9]*) have_automake18=yes ;; - esac - fi - - # Extract the macro directory name from Makefile.am. - aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$srcdir/Makefile.am" | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'` - m4dir=m4 - m4dir_defaulted=yes - m4dir_is_next= - for arg in $aclocal_amflags; do - if test -n "$m4dir_is_next"; then - # Ignore absolute directory pathnames, like /usr/local/share/aclocal. - case "$arg" in - /*) ;; - *) - m4dir="$arg" - m4dir_defaulted= - break - ;; - esac - m4dir_is_next= - else - if test "X$arg" = "X-I"; then - m4dir_is_next=yes - else - m4dir_is_next= - fi - fi - done - - # Decide whether to use $m4dir/ChangeLog, or to use ChangeLog instead. - if test -d "$srcdir/$m4dir" && test -f "$srcdir/ChangeLog" && test ! -f "$srcdir/$m4dir/ChangeLog"; then - # The programmer has no $m4dir/ChangeLog so far. Don't introduce one. - using_m4ChangeLog= - fi - - # Update the *.m4 files and the corresponding Makefile.am. - $do_changelog && func_m4ChangeLog_init - added_m4dir= - added_m4files= - if test -d "$srcdir/$m4dir"; then - : - else - if $doit; then - echo "Creating directory $m4dir" - mkdir "$srcdir/$m4dir" - else - echo "Create directory $m4dir" - fi - added_m4dir=yes - fi - for file in $m4filelist; do - same=no - if test -f "$srcdir/$m4dir/$file"; then - if cmp -s "${datarootdir}/aclocal/$file" "$srcdir/$m4dir/$file"; then - same=yes - fi - else - added_m4files="$added_m4files $file" - fi - if $do_changelog && test $same = no; then - if test -f "$srcdir/$m4dir/$file"; then - func_m4ChangeLog_add_entry " * $file: Upgrade to gettext-${version}." - else - func_m4ChangeLog_add_entry " * $file: New file, from gettext-${version}." - fi - fi - func_backup "$m4dir/$file" - func_linkorcopy "${datarootdir}/aclocal/$file" "${datarootdir}/aclocal/$file" "$m4dir/$file" - done - missing_m4Makefileam= - if test -n "$added_m4files"; then - if test -f "$srcdir/$m4dir/Makefile.am"; then - if $doit; then - echo "Updating EXTRA_DIST in $m4dir/Makefile.am (backup is in $m4dir/Makefile.am~)" - func_backup "$m4dir/Makefile.am" - rm -f "$srcdir/$m4dir/Makefile.am" - if grep '^EXTRA_DIST[ ]*=' "$srcdir/$m4dir/Makefile.am~" > /dev/null; then - sed -e "s%^\(EXTRA_DIST[ ]*=\) \\?%\\1$added_m4files %" < "$srcdir/$m4dir/Makefile.am~" > "$srcdir/$m4dir/Makefile.am" - $do_changelog && func_m4ChangeLog_add_entry " * Makefile.am (EXTRA_DIST): Add the new files." - else - (cat "$srcdir/$m4dir/Makefile.am~"; echo; echo "EXTRA_DIST =$added_m4files") > "$srcdir/$m4dir/Makefile.am" - $do_changelog && func_m4ChangeLog_add_entry " * Makefile.am (EXTRA_DIST): New variable." - fi - else - echo "Update EXTRA_DIST in $m4dir/Makefile.am" - $do_changelog && func_m4ChangeLog_add_entry " * Makefile.am (EXTRA_DIST)." - fi - else - # $m4dir/Makefile.am is not needed any more when aclocal 1.8 or newer - # is used. - if test -z "$have_automake18"; then - if $doit; then - echo "Creating $m4dir/Makefile.am" - echo "EXTRA_DIST =$added_m4files" > "$srcdir/$m4dir/Makefile.am" - else - echo "Create $m4dir/Makefile.am" - fi - $do_changelog && func_m4ChangeLog_add_entry " * Makefile.am: New file." - added_acoutput="$added_acoutput $m4dir/Makefile" - else - missing_m4Makefileam=yes - fi - fi - fi - if test -n "$added_m4dir" && test -z "$missing_m4Makefileam"; then - added_directories="$added_directories $m4dir" - fi - $do_changelog && func_m4ChangeLog_finish - # automake will arrange for $m4dir/ChangeLog to be distributed if a - # $m4dir/Makefile.am exists. If not, we need to add it to Makefile.am's - # EXTRA_DIST explicitly. - if test -n "$created_m4ChangeLog" && test -n "$missing_m4Makefileam"; then - added_extradist="$added_extradist $m4dir/ChangeLog" - fi - - # Update the top-level Makefile.am. - modified_Makefile_am= - # func_modify_Makefile_am changelog_comment - # assumes a modified copy of $srcdir/Makefile.am in $srcdir/Makefile.am.tmp - # and replaces the original Makefile.am file with the modified one if - # the two files differ. Then it removes the modified copy. - func_modify_Makefile_am () - { - if cmp -s "$srcdir/Makefile.am" "$srcdir/Makefile.am.tmp"; then - : - else - if test -z "$modified_Makefile_am"; then - if $doit; then - echo "Updating Makefile.am (backup is in Makefile.am~)" - func_backup Makefile.am - else - echo "Update Makefile.am" - fi - fi - if $doit; then - rm -f "$srcdir/Makefile.am" - cp "$srcdir/Makefile.am.tmp" "$srcdir/Makefile.am" - fi - if $do_changelog; then - if test -z "$modified_Makefile_am"; then - func_ChangeLog_add_entry " * Makefile.am $1" - else - func_ChangeLog_add_entry " $1" - fi - fi - modified_Makefile_am=yes - fi - rm -f "$srcdir/Makefile.am.tmp" - } - - if test -n "$added_directories"; then - if grep '^SUBDIRS[ ]*=' "$srcdir/Makefile.am" > /dev/null; then - sed -e "s%^\(SUBDIRS[ ]*=\) \\?%\\1$added_directories %" < "$srcdir/Makefile.am" > "$srcdir/Makefile.am.tmp" - added_directories_pretty=`echo $added_directories | sed -e 's/ /, /g'` - func_modify_Makefile_am "(SUBDIRS): Add $added_directories_pretty." - else - (cat "$srcdir/Makefile.am"; echo; echo "SUBDIRS =$added_directories") > "$srcdir/Makefile.am.tmp" - func_modify_Makefile_am "(SUBDIRS): New variable." - fi - fi - if test -n "$removed_directory"; then - sed -e '/^SUBDIRS[ ]*=/ { - :a - s%\([ ]\)'"$removed_directory"'[ ]%\1% - s%[ ]'"$removed_directory"'$%% - tb - :b - s%\\$%\\% - tc - bd - :c - n - ba - :d - }' < "$srcdir/Makefile.am" > "$srcdir/Makefile.am.tmp" - func_modify_Makefile_am "(SUBDIRS): Remove $removed_directory." - fi - if test -n "$added_directories"; then - if grep '^DIST_SUBDIRS[ ]*=' "$srcdir/Makefile.am" > /dev/null; then - sed -e "s%^\(DIST_SUBDIRS[ ]*=\) \\?%\\1$added_directories %" < "$srcdir/Makefile.am" > "$srcdir/Makefile.am.tmp" - added_directories_pretty=`echo $added_directories | sed -e 's/ /, /g'` - func_modify_Makefile_am "(DIST_SUBDIRS): Add $added_directories_pretty." - fi - fi - if test -n "$removed_directory"; then - sed -e '/^DIST_SUBDIRS[ ]*=/ { - :a - s%\([ ]\)'"$removed_directory"'[ ]%\1% - s%[ ]'"$removed_directory"'$%% - tb - :b - s%\\$%\\% - tc - bd - :c - n - ba - :d - }' < "$srcdir/Makefile.am" > "$srcdir/Makefile.am.tmp" - func_modify_Makefile_am "(DIST_SUBDIRS): Remove $removed_directory." - fi - if test -n "$m4dir_defaulted"; then - if grep '^ACLOCAL_AMFLAGS[ ]*=' "$srcdir/Makefile.am" > /dev/null; then - sed -e "s%^\(ACLOCAL_AMFLAGS[ ]*=\) \\?%\\1 -I $m4dir %" < "$srcdir/Makefile.am" > "$srcdir/Makefile.am.tmp" - func_modify_Makefile_am "(ACLOCAL_AMFLAGS): Add -I $m4dir." - else - (cat "$srcdir/Makefile.am"; echo; echo "ACLOCAL_AMFLAGS = -I $m4dir") > "$srcdir/Makefile.am.tmp" - func_modify_Makefile_am "(ACLOCAL_AMFLAGS): New variable." - fi - # Also update Makefile.in and, if existent, Makefile. Otherwise they - # would take into account the new flags only after a few rounds of - # "./configure", "make", "touch configure.in", "make distclean". - if $doit; then - for file in Makefile.in Makefile; do - if test -f "$srcdir/$file"; then - func_backup $file - rm -f "$srcdir/$file" - sed -e "s%(ACLOCAL)%(ACLOCAL) -I $m4dir%" < "$srcdir/$file~" > "$srcdir/$file" - fi - done - fi - fi - if test -n "$added_extradist"; then - if grep '^EXTRA_DIST[ ]*=' "$srcdir/Makefile.am" > /dev/null; then - sed -e "s%^\(EXTRA_DIST[ ]*=\)%\\1$added_extradist %" < "$srcdir/Makefile.am" > "$srcdir/Makefile.am.tmp" - added_extradist_pretty=`echo $added_extradist | sed -e 's/ /, /g'` - func_modify_Makefile_am "(EXTRA_DIST): Add $added_extradist_pretty." - else - (cat "$srcdir/Makefile.am"; echo; echo "EXTRA_DIST =$added_extradist") > "$srcdir/Makefile.am.tmp" - func_modify_Makefile_am "(EXTRA_DIST): New variable." - fi - fi - # Extract the aclocal options name from Makefile.am. - aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$srcdir/Makefile.am" | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'` - aclocal_options= - m4dir_is_next= - for arg in $aclocal_amflags; do - if test -n "$m4dir_is_next"; then - aclocal_options="$aclocal_options -I $arg" - m4dir_is_next= - else - if test "X$arg" = "X-I"; then - m4dir_is_next=yes - else - m4dir_is_next= - fi - fi - done - please="$please -Please run 'aclocal$aclocal_options' to regenerate the aclocal.m4 file. -You need aclocal from GNU automake $min_automake_version (or newer) to do this. -Then run 'autoconf' to regenerate the configure file. -" - - # Also create $m4dir/Makefile.in from $m4dir/Makefile.am, because automake - # doesn't do it by itself. - if $doit; then - case "$added_acoutput" in - *" $m4dir/Makefile") - (cd "$srcdir" && automake "$m4dir/Makefile") 2>/dev/null || - please="$please -Please run 'automake $m4dir/Makefile' to create $m4dir/Makefile.in -" - ;; - esac - fi -else - please="$please -Please add the files -$m4filelist -from the ${datarootdir}/aclocal directory to your aclocal.m4 file. -" -fi - -modified_configure_in= -# func_modify_configure_in changelog_comment -# assumes a modified copy of $srcdir/$configure_in in $srcdir/$configure_in.tmp -# and replaces the original configure.in/ac file with the modified one if -# the two files differ. Then it removes the modified copy. -func_modify_configure_in () -{ - if cmp -s "$srcdir/$configure_in" "$srcdir/$configure_in.tmp"; then - : - else - if test -z "$modified_configure_in"; then - if $doit; then - echo "Updating $configure_in (backup is in $configure_in~)" - func_backup $configure_in - else - echo "Update $configure_in" - fi - fi - if $doit; then - rm -f "$srcdir/$configure_in" - cp "$srcdir/$configure_in.tmp" "$srcdir/$configure_in" - fi - if $do_changelog; then - if test -z "$modified_configure_in"; then - func_ChangeLog_add_entry " * $configure_in $1" - else - func_ChangeLog_add_entry " $1" - fi - fi - modified_configure_in=yes - fi - rm -f "$srcdir/$configure_in.tmp" -} - -if test -n "$added_acoutput"; then - if grep '^AC_CONFIG_FILES(' "$srcdir/$configure_in" > /dev/null; then - sedprog=' -ta -b -:a -n -ba' - sed -e "s%^\\(AC_CONFIG_FILES([^])\\,]*\\)%\\1$added_acoutput%$sedprog" < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp" - added_acoutput_pretty=`echo $added_acoutput | sed -e 's/ /, /g'` - func_modify_configure_in "(AC_CONFIG_FILES): Add $added_acoutput_pretty." - else - if grep '^AC_OUTPUT(' "$srcdir/$configure_in" > /dev/null; then - sed -e "s%^\\(AC_OUTPUT([^])\\,]*\\)%\\1$added_acoutput%" < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp" - added_acoutput_pretty=`echo $added_acoutput | sed -e 's/ /, /g'` - func_modify_configure_in "(AC_OUTPUT): Add $added_acoutput_pretty." - else - please="$please -Please add$added_acoutput to the AC_OUTPUT or AC_CONFIG_FILES invocation in the $configure_in file. -" - fi - fi -fi -if test -n "$removed_acoutput"; then - for file in $removed_acoutput; do - tag= - sedprog='{ - s%\([[ ]\)'"$file"'[ ]%\1% - s%\([[ ]\)'"$file"'\([]),]\)%\1\2% - s%[[ ]'"$file"'$%% - :a - tb - :b - s%\\$%\\% - tc - bd - :c - n - s%\([ ]\)'"$file"'[ ]%\1% - s%\([ ]\)'"$file"'\([]),]\)%\1\2% - s%[ ]'"$file"'$%% - ba - :d - }' - sed -e '/^AC_CONFIG_FILES(/'"$sedprog" < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp" - if cmp -s "$srcdir/$configure_in" "$srcdir/$configure_in.tmp"; then - sed -e '/^AC_OUTPUT(/'"$sedprog" < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp" - if cmp -s "$srcdir/$configure_in" "$srcdir/$configure_in.tmp"; then - : - else - tag=AC_OUTPUT - fi - else - tag=AC_CONFIG_FILES - fi - if test -n "$tag"; then - func_modify_configure_in "($tag): Remove $file." - else - rm -f "$srcdir/$configure_in.tmp" - if test "$file" != intl/intlh.inst; then - please="$please -Please remove $file from the AC_OUTPUT or AC_CONFIG_FILES invocation -in the $configure_in file. -" - fi - fi - done -fi -sed -e 's%sed -e "/POTFILES =/r po/POTFILES" po/Makefile\.in > po/Makefile *;* *%%' < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp" -func_modify_configure_in "(AC_OUTPUT): Remove command that created po/Makefile." -sed -e '/^\(dnl \|\)AC_LINK_FILES(\$nls_cv_header_libgt, \$nls_cv_header_intl)$/d' < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp" -func_modify_configure_in "(AC_LINK_FILES): Remove invocation." -sed -e 's/^AM_GNU_GETTEXT_VERSION([^()]*)/AM_GNU_GETTEXT_VERSION(['"$version"'])/' < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp" -func_modify_configure_in "(AM_GNU_GETTEXT_VERSION): Bump to $version." -$do_changelog && func_ChangeLog_finish - -# Recommend replacement for deprecated Makefile variables. -use_libtool=`cat "$srcdir/$configure_in" | grep '^A[CM]_PROG_LIBTOOL'` -for file in `(cd "$srcdir"; find . -name Makefile.am -print; find . -name Makefile.in -print) | sed -e 's,^\./,,'`; do - if test -f "$srcdir/$file"; then - if test `echo "$file" | sed -e 's,^.*/,,'` = Makefile.in && grep automake "$srcdir/$file" >/dev/null 2>&1; then - continue; - fi - # INTLLIBS is deprecated because it doesn't distinguish the two - # cases: with libtool, without libtool. - if grep '@''INTLLIBS''@' "$srcdir/$file" >/dev/null 2>&1; then - if test -n "$use_libtool"; then - please="$please -Please change $file to use @""LTLIBINTL""@ or @""LIBINTL""@ instead of -@""INTLLIBS""@. Which one, depends whether it is used with libtool or not. -@""INTLLIBS""@ will go away. -" - else - please="$please -Please change $file to use @""LIBINTL""@ instead of @""INTLLIBS""@. -@""INTLLIBS""@ will go away. -" - fi - fi - # DATADIRNAME is deprecated because we install only .gmo files nowadays, - # which can be stored in the platform independent $prefix/share hierarchy. - if grep '@''DATADIRNAME''@' "$srcdir/$file" >/dev/null 2>&1; then - please="$please -Please change $file to use the constant string \"share\" instead of -@""DATADIRNAME""@. @""DATADIRNAME""@ will go away. -" - fi - # INSTOBJEXT is deprecated because we install only .gmo files nowadays, - # no catgets .cat catalogs. - if grep '@''INSTOBJEXT''@' "$srcdir/$file" >/dev/null 2>&1; then - please="$please -Please change $file to use the constant string \".mo\" instead of -@""INSTOBJEXT""@. @""INSTOBJEXT""@ will go away. -" - fi - # GENCAT is deprecated because we install no catgets catalogs anymore. - if grep '@''GENCAT''@' "$srcdir/$file" >/dev/null 2>&1; then - please="$please -Please change $file to use the constant string \"gencat\" instead of -@""GENCAT""@. @""GENCAT""@ will go away. Maybe you don't even need it any more? -" - fi - # POSUB is deprecated because it causes "./configure --disable-nls", "make", - # "make dist" to create a buggy tarfile. - if grep '@''POSUB''@' "$srcdir/$file" >/dev/null 2>&1; then - please="$please -Please change $file to use the constant string \"po\" instead of -@""POSUB""@. @""POSUB""@ will go away. -" - fi - fi -done - -# Recommend replacement for deprecated configure variables. -if grep '\$nls_cv_header_' "$srcdir/$configure_in" >/dev/null 2>&1; then - please="$please -Please stop using \$nls_cv_header_intl or \$nls_cv_header_libgt in the -$configure_in file. Both will go away. Use or \"gettext.h\" instead. -" -fi - -# Recommend fetching config.guess and config.sub. -if test -f "$srcdir/$auxdir"config.guess && test -f "$srcdir/$auxdir"config.sub; then - : -else - please="$please -You will also need config.guess and config.sub, which you can get from the CVS -of the 'config' project at http://savannah.gnu.org/. The commands to fetch them -are -\$ wget 'http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess' -\$ wget 'http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub' -" -fi - -if $doit; then - echo "$please" - echo "You might also want to copy the convenience header file gettext.h" - echo "from the $gettext_dir directory into your package." - echo "It is a wrapper around that implements the configure --disable-nls" - echo "option." - echo - count=`echo "$please" | grep '^$' | wc -l` - count=`echo "$count" | sed -e 's/[ ]//g'` - case "$count" in - 1) count="paragraph";; - 2) count="two paragraphs";; - 3) count="three paragraphs";; - 4) count="four paragraphs";; - 5) count="five paragraphs";; - *) count="$count paragraphs";; - esac - echo "Press Return to acknowledge the previous $count." - # Read from /dev/tty, not stdin, so that gettextize cannot be abused by - # non-interactive tools. - read dummy < /dev/tty -fi - -exit 0 diff --git a/libs/gettext/bin64/msgattrib.exe b/libs/gettext/bin64/msgattrib.exe deleted file mode 100644 index cc904e272..000000000 Binary files a/libs/gettext/bin64/msgattrib.exe and /dev/null differ diff --git a/libs/gettext/bin64/msgcat.exe b/libs/gettext/bin64/msgcat.exe deleted file mode 100644 index 3af8a496d..000000000 Binary files a/libs/gettext/bin64/msgcat.exe and /dev/null differ diff --git a/libs/gettext/bin64/msgcmp.exe b/libs/gettext/bin64/msgcmp.exe deleted file mode 100644 index 27e6c6f62..000000000 Binary files a/libs/gettext/bin64/msgcmp.exe and /dev/null differ diff --git a/libs/gettext/bin64/msgcomm.exe b/libs/gettext/bin64/msgcomm.exe deleted file mode 100644 index 5d39de446..000000000 Binary files a/libs/gettext/bin64/msgcomm.exe and /dev/null differ diff --git a/libs/gettext/bin64/msgconv.exe b/libs/gettext/bin64/msgconv.exe deleted file mode 100644 index d454ac15f..000000000 Binary files a/libs/gettext/bin64/msgconv.exe and /dev/null differ diff --git a/libs/gettext/bin64/msgen.exe b/libs/gettext/bin64/msgen.exe deleted file mode 100644 index bd9438b36..000000000 Binary files a/libs/gettext/bin64/msgen.exe and /dev/null differ diff --git a/libs/gettext/bin64/msgexec.exe b/libs/gettext/bin64/msgexec.exe deleted file mode 100644 index dd988641e..000000000 Binary files a/libs/gettext/bin64/msgexec.exe and /dev/null differ diff --git a/libs/gettext/bin64/msgfilter.exe b/libs/gettext/bin64/msgfilter.exe deleted file mode 100644 index 1c07caf3c..000000000 Binary files a/libs/gettext/bin64/msgfilter.exe and /dev/null differ diff --git a/libs/gettext/bin64/msgfmt.exe b/libs/gettext/bin64/msgfmt.exe deleted file mode 100644 index 1907713a5..000000000 Binary files a/libs/gettext/bin64/msgfmt.exe and /dev/null differ diff --git a/libs/gettext/bin64/msggrep.exe b/libs/gettext/bin64/msggrep.exe deleted file mode 100644 index 4cc3cbf0f..000000000 Binary files a/libs/gettext/bin64/msggrep.exe and /dev/null differ diff --git a/libs/gettext/bin64/msginit.exe b/libs/gettext/bin64/msginit.exe deleted file mode 100644 index 67ac3e2d3..000000000 Binary files a/libs/gettext/bin64/msginit.exe and /dev/null differ diff --git a/libs/gettext/bin64/msgmerge.exe b/libs/gettext/bin64/msgmerge.exe deleted file mode 100644 index 1104a71f9..000000000 Binary files a/libs/gettext/bin64/msgmerge.exe and /dev/null differ diff --git a/libs/gettext/bin64/msgunfmt.exe b/libs/gettext/bin64/msgunfmt.exe deleted file mode 100644 index a0b6f5c3f..000000000 Binary files a/libs/gettext/bin64/msgunfmt.exe and /dev/null differ diff --git a/libs/gettext/bin64/msguniq.exe b/libs/gettext/bin64/msguniq.exe deleted file mode 100644 index 875d1362d..000000000 Binary files a/libs/gettext/bin64/msguniq.exe and /dev/null differ diff --git a/libs/gettext/bin64/ngettext.exe b/libs/gettext/bin64/ngettext.exe deleted file mode 100644 index 674204be3..000000000 Binary files a/libs/gettext/bin64/ngettext.exe and /dev/null differ diff --git a/libs/gettext/bin64/recode-sr-latin.exe b/libs/gettext/bin64/recode-sr-latin.exe deleted file mode 100644 index bdc3f8bbd..000000000 Binary files a/libs/gettext/bin64/recode-sr-latin.exe and /dev/null differ diff --git a/libs/gettext/bin64/xgettext.exe b/libs/gettext/bin64/xgettext.exe deleted file mode 100644 index f43f64239..000000000 Binary files a/libs/gettext/bin64/xgettext.exe and /dev/null differ diff --git a/libs/gettext/gettext-0.18.1.1-tml.patch b/libs/gettext/gettext-0.18.1.1-tml.patch deleted file mode 100644 index 55e295fe0..000000000 --- a/libs/gettext/gettext-0.18.1.1-tml.patch +++ /dev/null @@ -1,177 +0,0 @@ ---- gettext-runtime/intl/printf.c -+++ gettext-runtime/intl/printf.c -@@ -69,7 +69,7 @@ - #define STATIC static - - /* This needs to be consistent with libgnuintl.h.in. */ --#if defined __NetBSD__ || defined __BEOS__ || defined __CYGWIN__ || defined __MINGW32__ -+#if defined __NetBSD__ || defined __BEOS__ || defined __CYGWIN__ - /* Don't break __attribute__((format(printf,M,N))). - This redefinition is only possible because the libc in NetBSD, Cygwin, - mingw does not have a function __printf__. */ ---- gettext-runtime/intl/libgnuintl.h.in -+++ gettext-runtime/intl/libgnuintl.h.in -@@ -330,7 +330,7 @@ - - #if !(defined printf && defined _GL_STDIO_H) /* don't override gnulib */ - #undef printf --#if defined __NetBSD__ || defined __BEOS__ || defined __CYGWIN__ || defined __MINGW32__ -+#if defined __NetBSD__ || defined __BEOS__ || defined __CYGWIN__ - /* Don't break __attribute__((format(printf,M,N))). - This redefinition is only possible because the libc in NetBSD, Cygwin, - mingw does not have a function __printf__. ----- gettext-tools/gnulib-lib/clean-temp.c -+++ gettext-tools/gnulib-lib/clean-temp.c -@@ -66,9 +66,11 @@ - # endif - #endif - -+#ifndef _WIN64 - #ifndef uintptr_t - # define uintptr_t unsigned long - #endif -+#endif - - #if !GNULIB_FCNTL_SAFER - /* The results of open() in this file are not used with fchdir, ---- gettext-tools/gnulib-lib/fstrcmp.c -+++ gettext-tools/gnulib-lib/fstrcmp.c -@@ -55,9 +55,11 @@ - #include "minmax.h" - #include "xalloc.h" - -+#ifndef _WIN64 - #ifndef uintptr_t - # define uintptr_t unsigned long - #endif -+#endif - - - #define ELEMENT char ---- gettext-tools/gnulib-lib/gl_array_list.c -+++ gettext-tools/gnulib-lib/gl_array_list.c -@@ -55,9 +55,11 @@ - /* Checked size_t computations. */ - #include "xsize.h" - -+#ifndef _WIN64 - #ifndef uintptr_t - # define uintptr_t unsigned long - #endif -+#endif - - /* -------------------------- gl_list_t Data Type -------------------------- */ - ---- gettext-tools/gnulib-lib/gl_linkedhash_list.c -+++ gettext-tools/gnulib-lib/gl_linkedhash_list.c -@@ -55,9 +55,11 @@ - - #include "xsize.h" - -+#ifndef _WIN64 - #ifndef uintptr_t - # define uintptr_t unsigned long - #endif -+#endif - - #define WITH_HASHTABLE 1 - ---- gettext-tools/gnulib-lib/stdio.in.h -+++ gettext-tools/gnulib-lib/stdio.in.h -@@ -642,10 +642,6 @@ - # if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \ - || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) - # if defined __GNUC__ --# if !(defined __cplusplus && defined GNULIB_NAMESPACE) --/* Don't break __attribute__((format(printf,M,N))). */ --# define printf __printf__ --# endif - _GL_FUNCDECL_RPL_1 (__printf__, int, - (const char *format, ...) - __asm__ (@ASM_SYMBOL_PREFIX@ ---- gettext-tools/gnulib-lib/tempname.c -+++ gettext-tools/gnulib-lib/tempname.c -@@ -54,6 +54,10 @@ - #include - #include - -+#ifdef _WIN32 -+# include -+#endif -+ - #include - - #if _LIBC -@@ -73,6 +73,10 @@ - # define __xstat64(version, file, buf) stat (file, buf) - #endif - -+#ifdef _WIN32 -+# define mkdir(path,mode) _mkdir(path) -+#endif -+ - #if ! (HAVE___SECURE_GETENV || _LIBC) - # define __secure_getenv getenv - #endif ---- gettext-tools/src/write-java.c -+++ gettext-tools/src/write-java.c -@@ -30,6 +30,10 @@ - #include - #include - -+#ifdef _WIN32 -+# include -+#endif -+ - #include - #if !defined S_ISDIR && defined S_IFDIR - # define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) -@@ -53,6 +53,10 @@ - # define S_IXUSR 00100 - #endif - -+#ifdef _WIN32 -+# define mkdir(path,mode) _mkdir(path) -+#endif -+ - #include "c-ctype.h" - #include "error.h" - #include "xerror.h" ---- gettext-tools/src/write-csharp.c -+++ gettext-tools/src/write-csharp.c -@@ -29,6 +29,10 @@ - #include - #include - -+#ifdef _WIN32 -+# include -+#endif -+ - #include - #if !defined S_ISDIR && defined S_IFDIR - # define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) -@@ -70,6 +70,10 @@ - # define S_IXOTH (S_IXUSR >> 6) - #endif - -+#ifdef _WIN32 -+# define mkdir(path,mode) _mkdir(path) -+#endif -+ - #include "c-ctype.h" - #include "relocatable.h" - #include "error.h" ---- gettext-tools/woe32dll/export.h -+++ gettext-tools/woe32dll/export.h -@@ -90,7 +90,11 @@ - --export-all-symbols is used. */ - - /* IMP(x) is a symbol that contains the address of x. */ -+#ifdef _WIN64 -+#define IMP(x) __imp_##x -+#else - #define IMP(x) _imp__##x -+#endif - - /* Ensure that the variable x is exported from the library, and that a - pseudo-variable IMP(x) is available. */ diff --git a/libs/gettext/include32/autosprintf.h b/libs/gettext/include32/autosprintf.h deleted file mode 100644 index f447391b0..000000000 --- a/libs/gettext/include32/autosprintf.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Class autosprintf - formatted output to an ostream. - Copyright (C) 2002 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. */ - -#ifndef _AUTOSPRINTF_H -#define _AUTOSPRINTF_H - -#ifndef __attribute__ -/* This feature is available in gcc versions 2.5 and later. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ -# define __attribute__(Spec) /* empty */ -# endif -/* The __-protected variants of `format' and `printf' attributes - are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) -# define __format__ format -# define __printf__ printf -# endif -#endif - -#include -#include - -namespace gnu -{ - /* A temporary object, usually allocated on the stack, representing - the result of an asprintf() call. */ - class autosprintf - { - public: - /* Constructor: takes a format string and the printf arguments. */ - autosprintf (const char *format, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); - /* Copy constructor. */ - autosprintf (const autosprintf& src); - /* Destructor: frees the temporarily allocated string. */ - ~autosprintf (); - /* Conversion to string. */ - operator char * () const; - operator std::string () const; - /* Output to an ostream. */ - friend inline std::ostream& operator<< (std::ostream& stream, const autosprintf& tmp) - { - stream << (tmp.str ? tmp.str : "(error in autosprintf)"); - return stream; - } - private: - char *str; - }; -} - -#endif /* _AUTOSPRINTF_H */ diff --git a/libs/gettext/include32/gettext-po.h b/libs/gettext/include32/gettext-po.h deleted file mode 100644 index 091ad86fa..000000000 --- a/libs/gettext/include32/gettext-po.h +++ /dev/null @@ -1,357 +0,0 @@ -/* Public API for GNU gettext PO files - contained in libgettextpo. - Copyright (C) 2003-2008, 2010 Free Software Foundation, Inc. - Written by Bruno Haible , 2003. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifndef _GETTEXT_PO_H -#define _GETTEXT_PO_H 1 - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/* =========================== Meta Information ============================ */ - -/* Version number: (major<<16) + (minor<<8) + subminor */ -#define LIBGETTEXTPO_VERSION 0x001201 -extern __declspec (dllimport) int libgettextpo_version; - -/* ================================= Types ================================= */ - -/* A po_file_t represents the contents of a PO file. */ -typedef struct po_file *po_file_t; - -/* A po_message_iterator_t represents an iterator through a domain of a - PO file. */ -typedef struct po_message_iterator *po_message_iterator_t; - -/* A po_message_t represents a message in a PO file. */ -typedef struct po_message *po_message_t; - -/* A po_filepos_t represents a string's position within a source file. */ -typedef struct po_filepos *po_filepos_t; - -/* A po_error_handler handles error situations. */ -struct po_error_handler -{ - /* Signal an error. The error message is built from FORMAT and the following - arguments. ERRNUM, if nonzero, is an errno value. - Must increment the error_message_count variable declared in error.h. - Must not return if STATUS is nonzero. */ - void (*error) (int status, int errnum, - const char *format, ...) -#if ((__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || __GNUC__ > 3) && !__STRICT_ANSI__ - __attribute__ ((__format__ (__printf__, 3, 4))) -#endif - ; - - /* Signal an error. The error message is built from FORMAT and the following - arguments. The error location is at FILENAME line LINENO. ERRNUM, if - nonzero, is an errno value. - Must increment the error_message_count variable declared in error.h. - Must not return if STATUS is nonzero. */ - void (*error_at_line) (int status, int errnum, - const char *filename, unsigned int lineno, - const char *format, ...) -#if ((__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || __GNUC__ > 3) && !__STRICT_ANSI__ - __attribute__ ((__format__ (__printf__, 5, 6))) -#endif - ; - - /* Signal a multiline warning. The PREFIX applies to all lines of the - MESSAGE. Free the PREFIX and MESSAGE when done. */ - void (*multiline_warning) (char *prefix, char *message); - - /* Signal a multiline error. The PREFIX applies to all lines of the - MESSAGE. Free the PREFIX and MESSAGE when done. - Must increment the error_message_count variable declared in error.h if - PREFIX is non-NULL. */ - void (*multiline_error) (char *prefix, char *message); -}; -typedef const struct po_error_handler *po_error_handler_t; - -/* A po_xerror_handler handles warnings, error and fatal error situations. */ -#define PO_SEVERITY_WARNING 0 /* just a warning, tell the user */ -#define PO_SEVERITY_ERROR 1 /* an error, the operation cannot complete */ -#define PO_SEVERITY_FATAL_ERROR 2 /* an error, the operation must be aborted */ -struct po_xerror_handler -{ - /* Signal a problem of the given severity. - MESSAGE and/or FILENAME + LINENO indicate where the problem occurred. - If FILENAME is NULL, FILENAME and LINENO and COLUMN should be ignored. - If LINENO is (size_t)(-1), LINENO and COLUMN should be ignored. - If COLUMN is (size_t)(-1), it should be ignored. - MESSAGE_TEXT is the problem description (if MULTILINE_P is true, - multiple lines of text, each terminated with a newline, otherwise - usually a single line). - Must not return if SEVERITY is PO_SEVERITY_FATAL_ERROR. */ - void (*xerror) (int severity, - po_message_t message, - const char *filename, size_t lineno, size_t column, - int multiline_p, const char *message_text); - /* Signal a problem that refers to two messages. - Similar to two calls to xerror. - If possible, a "..." can be appended to MESSAGE_TEXT1 and prepended to - MESSAGE_TEXT2. */ - void (*xerror2) (int severity, - po_message_t message1, - const char *filename1, size_t lineno1, size_t column1, - int multiline_p1, const char *message_text1, - po_message_t message2, - const char *filename2, size_t lineno2, size_t column2, - int multiline_p2, const char *message_text2); -}; -typedef const struct po_xerror_handler *po_xerror_handler_t; - -/* Memory allocation: - The memory allocations performed by these functions use xmalloc(), - therefore will cause a program exit if memory is exhausted. - The memory allocated by po_file_read, and implicitly returned through - the po_message_* functions, lasts until freed with po_file_free. */ - - -/* ============================= po_file_t API ============================= */ - -/* Create an empty PO file representation in memory. */ -extern po_file_t po_file_create (void); - -/* Read a PO file into memory. - Return its contents. Upon failure, return NULL and set errno. */ -#define po_file_read po_file_read_v3 -extern po_file_t po_file_read (const char *filename, - po_xerror_handler_t handler); - -/* Write an in-memory PO file to a file. - Upon failure, return NULL and set errno. */ -#define po_file_write po_file_write_v2 -extern po_file_t po_file_write (po_file_t file, const char *filename, - po_xerror_handler_t handler); - -/* Free a PO file from memory. */ -extern void po_file_free (po_file_t file); - -/* Return the names of the domains covered by a PO file in memory. */ -extern const char * const * po_file_domains (po_file_t file); - - -/* =========================== Header entry API ============================ */ - -/* Return the header entry of a domain of a PO file in memory. - The domain NULL denotes the default domain. - Return NULL if there is no header entry. */ -extern const char * po_file_domain_header (po_file_t file, const char *domain); - -/* Return the value of a field in a header entry. - The return value is either a freshly allocated string, to be freed by the - caller, or NULL. */ -extern char * po_header_field (const char *header, const char *field); - -/* Return the header entry with a given field set to a given value. The field - is added if necessary. - The return value is a freshly allocated string. */ -extern char * po_header_set_field (const char *header, const char *field, const char *value); - - -/* ======================= po_message_iterator_t API ======================= */ - -/* Create an iterator for traversing a domain of a PO file in memory. - The domain NULL denotes the default domain. */ -extern po_message_iterator_t po_message_iterator (po_file_t file, const char *domain); - -/* Free an iterator. */ -extern void po_message_iterator_free (po_message_iterator_t iterator); - -/* Return the next message, and advance the iterator. - Return NULL at the end of the message list. */ -extern po_message_t po_next_message (po_message_iterator_t iterator); - -/* Insert a message in a PO file in memory, in the domain and at the position - indicated by the iterator. The iterator thereby advances past the freshly - inserted message. */ -extern void po_message_insert (po_message_iterator_t iterator, po_message_t message); - - -/* =========================== po_message_t API ============================ */ - -/* Return a freshly constructed message. - To finish initializing the message, you must set the msgid and msgstr. */ -extern po_message_t po_message_create (void); - -/* Return the context of a message, or NULL for a message not restricted to a - context. */ -extern const char * po_message_msgctxt (po_message_t message); - -/* Change the context of a message. NULL means a message not restricted to a - context. */ -extern void po_message_set_msgctxt (po_message_t message, const char *msgctxt); - -/* Return the msgid (untranslated English string) of a message. */ -extern const char * po_message_msgid (po_message_t message); - -/* Change the msgid (untranslated English string) of a message. */ -extern void po_message_set_msgid (po_message_t message, const char *msgid); - -/* Return the msgid_plural (untranslated English plural string) of a message, - or NULL for a message without plural. */ -extern const char * po_message_msgid_plural (po_message_t message); - -/* Change the msgid_plural (untranslated English plural string) of a message. - NULL means a message without plural. */ -extern void po_message_set_msgid_plural (po_message_t message, const char *msgid_plural); - -/* Return the msgstr (translation) of a message. - Return the empty string for an untranslated message. */ -extern const char * po_message_msgstr (po_message_t message); - -/* Change the msgstr (translation) of a message. - Use an empty string to denote an untranslated message. */ -extern void po_message_set_msgstr (po_message_t message, const char *msgstr); - -/* Return the msgstr[index] for a message with plural handling, or - NULL when the index is out of range or for a message without plural. */ -extern const char * po_message_msgstr_plural (po_message_t message, int index); - -/* Change the msgstr[index] for a message with plural handling. - Use a NULL value at the end to reduce the number of plural forms. */ -extern void po_message_set_msgstr_plural (po_message_t message, int index, const char *msgstr); - -/* Return the comments for a message. */ -extern const char * po_message_comments (po_message_t message); - -/* Change the comments for a message. - comments should be a multiline string, ending in a newline, or empty. */ -extern void po_message_set_comments (po_message_t message, const char *comments); - -/* Return the extracted comments for a message. */ -extern const char * po_message_extracted_comments (po_message_t message); - -/* Change the extracted comments for a message. - comments should be a multiline string, ending in a newline, or empty. */ -extern void po_message_set_extracted_comments (po_message_t message, const char *comments); - -/* Return the i-th file position for a message, or NULL if i is out of - range. */ -extern po_filepos_t po_message_filepos (po_message_t message, int i); - -/* Remove the i-th file position from a message. - The indices of all following file positions for the message are decremented - by one. */ -extern void po_message_remove_filepos (po_message_t message, int i); - -/* Add a file position to a message, if it is not already present for the - message. - file is the file name. - start_line is the line number where the string starts, or (size_t)(-1) if no - line number is available. */ -extern void po_message_add_filepos (po_message_t message, const char *file, size_t start_line); - -/* Return the previous context of a message, or NULL for none. */ -extern const char * po_message_prev_msgctxt (po_message_t message); - -/* Change the previous context of a message. NULL is allowed. */ -extern void po_message_set_prev_msgctxt (po_message_t message, const char *prev_msgctxt); - -/* Return the previous msgid (untranslated English string) of a message, or - NULL for none. */ -extern const char * po_message_prev_msgid (po_message_t message); - -/* Change the previous msgid (untranslated English string) of a message. - NULL is allowed. */ -extern void po_message_set_prev_msgid (po_message_t message, const char *prev_msgid); - -/* Return the previous msgid_plural (untranslated English plural string) of a - message, or NULL for none. */ -extern const char * po_message_prev_msgid_plural (po_message_t message); - -/* Change the previous msgid_plural (untranslated English plural string) of a - message. NULL is allowed. */ -extern void po_message_set_prev_msgid_plural (po_message_t message, const char *prev_msgid_plural); - -/* Return true if the message is marked obsolete. */ -extern int po_message_is_obsolete (po_message_t message); - -/* Change the obsolete mark of a message. */ -extern void po_message_set_obsolete (po_message_t message, int obsolete); - -/* Return true if the message is marked fuzzy. */ -extern int po_message_is_fuzzy (po_message_t message); - -/* Change the fuzzy mark of a message. */ -extern void po_message_set_fuzzy (po_message_t message, int fuzzy); - -/* Return true if the message is marked as being a format string of the given - type (e.g. "c-format"). */ -extern int po_message_is_format (po_message_t message, const char *format_type); - -/* Change the format string mark for a given type of a message. */ -extern void po_message_set_format (po_message_t message, const char *format_type, /*bool*/int value); - -/* If a numeric range of a message is set, return true and store the minimum - and maximum value in *MINP and *MAXP. */ -extern int po_message_is_range (po_message_t message, int *minp, int *maxp); - -/* Change the numeric range of a message. MIN and MAX must be non-negative, - with MIN < MAX. Use MIN = MAX = -1 to remove the numeric range of a - message. */ -extern void po_message_set_range (po_message_t message, int min, int max); - - -/* =========================== po_filepos_t API ============================ */ - -/* Return the file name. */ -extern const char * po_filepos_file (po_filepos_t filepos); - -/* Return the line number where the string starts, or (size_t)(-1) if no line - number is available. */ -extern size_t po_filepos_start_line (po_filepos_t filepos); - - -/* ============================ Format type API ============================= */ - -/* Return a NULL terminated array of the supported format types. */ -extern const char * const * po_format_list (void); - -/* Return the pretty name associated with a format type. - For example, for "csharp-format", return "C#". - Return NULL if the argument is not a supported format type. */ -extern const char * po_format_pretty_name (const char *format_type); - - -/* ============================= Checking API ============================== */ - -/* Test whether an entire file PO file is valid, like msgfmt does it. - If it is invalid, pass the reasons to the handler. */ -extern void po_file_check_all (po_file_t file, po_xerror_handler_t handler); - -/* Test a single message, to be inserted in a PO file in memory, like msgfmt - does it. If it is invalid, pass the reasons to the handler. The iterator - is not modified by this call; it only specifies the file and the domain. */ -extern void po_message_check_all (po_message_t message, po_message_iterator_t iterator, po_xerror_handler_t handler); - -/* Test whether the message translation is a valid format string if the message - is marked as being a format string. If it is invalid, pass the reasons to - the handler. */ -#define po_message_check_format po_message_check_format_v2 -extern void po_message_check_format (po_message_t message, po_xerror_handler_t handler); - - -#ifdef __cplusplus -} -#endif - -#endif /* _GETTEXT_PO_H */ diff --git a/libs/gettext/include32/libintl.h b/libs/gettext/include32/libintl.h deleted file mode 100644 index a8e2d414b..000000000 --- a/libs/gettext/include32/libintl.h +++ /dev/null @@ -1,464 +0,0 @@ -/* Message catalogs for internationalization. - Copyright (C) 1995-1997, 2000-2010 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. */ - -#ifndef _LIBINTL_H -#define _LIBINTL_H 1 - -#include -#if (defined __APPLE__ && defined __MACH__) && 0 -# include -#endif - -/* The LC_MESSAGES locale category is the category used by the functions - gettext() and dgettext(). It is specified in POSIX, but not in ANSI C. - On systems that don't define it, use an arbitrary value instead. - On Solaris, defines __LOCALE_H (or _LOCALE_H in Solaris 2.5) - then includes (i.e. this file!) and then only defines - LC_MESSAGES. To avoid a redefinition warning, don't define LC_MESSAGES - in this case. */ -#if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun)) -# define LC_MESSAGES 1729 -#endif - -/* We define an additional symbol to signal that we use the GNU - implementation of gettext. */ -#define __USE_GNU_GETTEXT 1 - -/* Provide information about the supported file formats. Returns the - maximum minor revision number supported for a given major revision. */ -#define __GNU_GETTEXT_SUPPORTED_REVISION(major) \ - ((major) == 0 || (major) == 1 ? 1 : -1) - -/* Resolve a platform specific conflict on DJGPP. GNU gettext takes - precedence over _conio_gettext. */ -#ifdef __DJGPP__ -# undef gettext -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/* Version number: (major<<16) + (minor<<8) + subminor */ -#define LIBINTL_VERSION 0x001201 -extern int libintl_version; - - -/* We redirect the functions to those prefixed with "libintl_". This is - necessary, because some systems define gettext/textdomain/... in the C - library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer). - If we used the unprefixed names, there would be cases where the - definition in the C library would override the one in the libintl.so - shared library. Recall that on ELF systems, the symbols are looked - up in the following order: - 1. in the executable, - 2. in the shared libraries specified on the link command line, in order, - 3. in the dependencies of the shared libraries specified on the link - command line, - 4. in the dlopen()ed shared libraries, in the order in which they were - dlopen()ed. - The definition in the C library would override the one in libintl.so if - either - * -lc is given on the link command line and -lintl isn't, or - * -lc is given on the link command line before -lintl, or - * libintl.so is a dependency of a dlopen()ed shared library but not - linked to the executable at link time. - Since Solaris gettext() behaves differently than GNU gettext(), this - would be unacceptable. - - The redirection happens by default through macros in C, so that &gettext - is independent of the compilation unit, but through inline functions in - C++, in order not to interfere with the name mangling of class fields or - class methods called 'gettext'. */ - -/* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS. - If he doesn't, we choose the method. A third possible method is - _INTL_REDIRECT_ASM, supported only by GCC. */ -#if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS) -# if defined __GNUC__ && __GNUC__ >= 2 && !(defined __APPLE_CC__ && __APPLE_CC__ > 1) && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus) -# define _INTL_REDIRECT_ASM -# else -# ifdef __cplusplus -# define _INTL_REDIRECT_INLINE -# else -# define _INTL_REDIRECT_MACROS -# endif -# endif -#endif -/* Auxiliary macros. */ -#ifdef _INTL_REDIRECT_ASM -# define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname)) -# define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring -# define _INTL_STRINGIFY(prefix) #prefix -#else -# define _INTL_ASM(cname) -#endif - -/* _INTL_MAY_RETURN_STRING_ARG(n) declares that the given function may return - its n-th argument literally. This enables GCC to warn for example about - printf (gettext ("foo %y")). */ -#if defined __GNUC__ && __GNUC__ >= 3 && !(defined __APPLE_CC__ && __APPLE_CC__ > 1 && defined __cplusplus) -# define _INTL_MAY_RETURN_STRING_ARG(n) __attribute__ ((__format_arg__ (n))) -#else -# define _INTL_MAY_RETURN_STRING_ARG(n) -#endif - -/* Look up MSGID in the current default message catalog for the current - LC_MESSAGES locale. If not found, returns MSGID itself (the default - text). */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_gettext (const char *__msgid) - _INTL_MAY_RETURN_STRING_ARG (1); -static inline char *gettext (const char *__msgid) -{ - return libintl_gettext (__msgid); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define gettext libintl_gettext -#endif -extern char *gettext (const char *__msgid) - _INTL_ASM (libintl_gettext) - _INTL_MAY_RETURN_STRING_ARG (1); -#endif - -/* Look up MSGID in the DOMAINNAME message catalog for the current - LC_MESSAGES locale. */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_dgettext (const char *__domainname, const char *__msgid) - _INTL_MAY_RETURN_STRING_ARG (2); -static inline char *dgettext (const char *__domainname, const char *__msgid) -{ - return libintl_dgettext (__domainname, __msgid); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define dgettext libintl_dgettext -#endif -extern char *dgettext (const char *__domainname, const char *__msgid) - _INTL_ASM (libintl_dgettext) - _INTL_MAY_RETURN_STRING_ARG (2); -#endif - -/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY - locale. */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_dcgettext (const char *__domainname, const char *__msgid, - int __category) - _INTL_MAY_RETURN_STRING_ARG (2); -static inline char *dcgettext (const char *__domainname, const char *__msgid, - int __category) -{ - return libintl_dcgettext (__domainname, __msgid, __category); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define dcgettext libintl_dcgettext -#endif -extern char *dcgettext (const char *__domainname, const char *__msgid, - int __category) - _INTL_ASM (libintl_dcgettext) - _INTL_MAY_RETURN_STRING_ARG (2); -#endif - - -/* Similar to `gettext' but select the plural form corresponding to the - number N. */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2, - unsigned long int __n) - _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2); -static inline char *ngettext (const char *__msgid1, const char *__msgid2, - unsigned long int __n) -{ - return libintl_ngettext (__msgid1, __msgid2, __n); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define ngettext libintl_ngettext -#endif -extern char *ngettext (const char *__msgid1, const char *__msgid2, - unsigned long int __n) - _INTL_ASM (libintl_ngettext) - _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2); -#endif - -/* Similar to `dgettext' but select the plural form corresponding to the - number N. */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_dngettext (const char *__domainname, const char *__msgid1, - const char *__msgid2, unsigned long int __n) - _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3); -static inline char *dngettext (const char *__domainname, const char *__msgid1, - const char *__msgid2, unsigned long int __n) -{ - return libintl_dngettext (__domainname, __msgid1, __msgid2, __n); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define dngettext libintl_dngettext -#endif -extern char *dngettext (const char *__domainname, - const char *__msgid1, const char *__msgid2, - unsigned long int __n) - _INTL_ASM (libintl_dngettext) - _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3); -#endif - -/* Similar to `dcgettext' but select the plural form corresponding to the - number N. */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_dcngettext (const char *__domainname, - const char *__msgid1, const char *__msgid2, - unsigned long int __n, int __category) - _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3); -static inline char *dcngettext (const char *__domainname, - const char *__msgid1, const char *__msgid2, - unsigned long int __n, int __category) -{ - return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define dcngettext libintl_dcngettext -#endif -extern char *dcngettext (const char *__domainname, - const char *__msgid1, const char *__msgid2, - unsigned long int __n, int __category) - _INTL_ASM (libintl_dcngettext) - _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3); -#endif - - - -/* Set the current default message catalog to DOMAINNAME. - If DOMAINNAME is null, return the current default. - If DOMAINNAME is "", reset to the default of "messages". */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_textdomain (const char *__domainname); -static inline char *textdomain (const char *__domainname) -{ - return libintl_textdomain (__domainname); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define textdomain libintl_textdomain -#endif -extern char *textdomain (const char *__domainname) - _INTL_ASM (libintl_textdomain); -#endif - -/* Specify that the DOMAINNAME message catalog will be found - in DIRNAME rather than in the system locale data base. */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_bindtextdomain (const char *__domainname, - const char *__dirname); -static inline char *bindtextdomain (const char *__domainname, - const char *__dirname) -{ - return libintl_bindtextdomain (__domainname, __dirname); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define bindtextdomain libintl_bindtextdomain -#endif -extern char *bindtextdomain (const char *__domainname, const char *__dirname) - _INTL_ASM (libintl_bindtextdomain); -#endif - -/* Specify the character encoding in which the messages from the - DOMAINNAME message catalog will be returned. */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_bind_textdomain_codeset (const char *__domainname, - const char *__codeset); -static inline char *bind_textdomain_codeset (const char *__domainname, - const char *__codeset) -{ - return libintl_bind_textdomain_codeset (__domainname, __codeset); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define bind_textdomain_codeset libintl_bind_textdomain_codeset -#endif -extern char *bind_textdomain_codeset (const char *__domainname, - const char *__codeset) - _INTL_ASM (libintl_bind_textdomain_codeset); -#endif - - - -/* Support for format strings with positions in *printf(), following the - POSIX/XSI specification. - Note: These replacements for the *printf() functions are visible only - in source files that #include or #include "gettext.h". - Packages that use *printf() in source files that don't refer to _() - or gettext() but for which the format string could be the return value - of _() or gettext() need to add this #include. Oh well. */ - -#if !0 - -#include -#include - -/* Get va_list. */ -#if (defined __STDC__ && __STDC__) || defined __cplusplus || defined _MSC_VER -# include -#else -# include -#endif - -#if !(defined fprintf && defined _GL_STDIO_H) /* don't override gnulib */ -#undef fprintf -#define fprintf libintl_fprintf -extern int fprintf (FILE *, const char *, ...); -#endif -#if !(defined vfprintf && defined _GL_STDIO_H) /* don't override gnulib */ -#undef vfprintf -#define vfprintf libintl_vfprintf -extern int vfprintf (FILE *, const char *, va_list); -#endif - -#if !(defined printf && defined _GL_STDIO_H) /* don't override gnulib */ -#undef printf -#if defined __NetBSD__ || defined __BEOS__ || defined __CYGWIN__ || defined __MINGW32__ -/* Don't break __attribute__((format(printf,M,N))). - This redefinition is only possible because the libc in NetBSD, Cygwin, - mingw does not have a function __printf__. - Alternatively, we could have done this redirection only when compiling with - __GNUC__, together with a symbol redirection: - extern int printf (const char *, ...) - __asm__ (#__USER_LABEL_PREFIX__ "libintl_printf"); - But doing it now would introduce a binary incompatibility with already - distributed versions of libintl on these systems. */ -# define libintl_printf __printf__ -#endif -#define printf libintl_printf -extern int printf (const char *, ...); -#endif -#if !(defined vprintf && defined _GL_STDIO_H) /* don't override gnulib */ -#undef vprintf -#define vprintf libintl_vprintf -extern int vprintf (const char *, va_list); -#endif - -#if !(defined sprintf && defined _GL_STDIO_H) /* don't override gnulib */ -#undef sprintf -#define sprintf libintl_sprintf -extern int sprintf (char *, const char *, ...); -#endif -#if !(defined vsprintf && defined _GL_STDIO_H) /* don't override gnulib */ -#undef vsprintf -#define vsprintf libintl_vsprintf -extern int vsprintf (char *, const char *, va_list); -#endif - -#if 1 - -#if !(defined snprintf && defined _GL_STDIO_H) /* don't override gnulib */ -#undef snprintf -#define snprintf libintl_snprintf -extern int snprintf (char *, size_t, const char *, ...); -#endif -#if !(defined vsnprintf && defined _GL_STDIO_H) /* don't override gnulib */ -#undef vsnprintf -#define vsnprintf libintl_vsnprintf -extern int vsnprintf (char *, size_t, const char *, va_list); -#endif - -#endif - -#if 0 - -#if !(defined asprintf && defined _GL_STDIO_H) /* don't override gnulib */ -#undef asprintf -#define asprintf libintl_asprintf -extern int asprintf (char **, const char *, ...); -#endif -#if !(defined vasprintf && defined _GL_STDIO_H) /* don't override gnulib */ -#undef vasprintf -#define vasprintf libintl_vasprintf -extern int vasprintf (char **, const char *, va_list); -#endif - -#endif - -#if 0 - -#undef fwprintf -#define fwprintf libintl_fwprintf -extern int fwprintf (FILE *, const wchar_t *, ...); -#undef vfwprintf -#define vfwprintf libintl_vfwprintf -extern int vfwprintf (FILE *, const wchar_t *, va_list); - -#undef wprintf -#define wprintf libintl_wprintf -extern int wprintf (const wchar_t *, ...); -#undef vwprintf -#define vwprintf libintl_vwprintf -extern int vwprintf (const wchar_t *, va_list); - -#undef swprintf -#define swprintf libintl_swprintf -extern int swprintf (wchar_t *, size_t, const wchar_t *, ...); -#undef vswprintf -#define vswprintf libintl_vswprintf -extern int vswprintf (wchar_t *, size_t, const wchar_t *, va_list); - -#endif - -#endif - - -/* Support for the locale chosen by the user. */ -#if (defined __APPLE__ && defined __MACH__) || defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ - -#undef setlocale -#define setlocale libintl_setlocale -extern char *setlocale (int, const char *); - -#if 0 - -#undef newlocale -#define newlocale libintl_newlocale -extern locale_t newlocale (int, const char *, locale_t); - -#endif - -#endif - - -/* Support for relocatable packages. */ - -/* Sets the original and the current installation prefix of the package. - Relocation simply replaces a pathname starting with the original prefix - by the corresponding pathname with the current prefix instead. Both - prefixes should be directory names without trailing slash (i.e. use "" - instead of "/"). */ -#define libintl_set_relocation_prefix libintl_set_relocation_prefix -extern void - libintl_set_relocation_prefix (const char *orig_prefix, - const char *curr_prefix); - - -#ifdef __cplusplus -} -#endif - -#endif /* libintl.h */ diff --git a/libs/gettext/include64/autosprintf.h b/libs/gettext/include64/autosprintf.h deleted file mode 100644 index f447391b0..000000000 --- a/libs/gettext/include64/autosprintf.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Class autosprintf - formatted output to an ostream. - Copyright (C) 2002 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. */ - -#ifndef _AUTOSPRINTF_H -#define _AUTOSPRINTF_H - -#ifndef __attribute__ -/* This feature is available in gcc versions 2.5 and later. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ -# define __attribute__(Spec) /* empty */ -# endif -/* The __-protected variants of `format' and `printf' attributes - are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) -# define __format__ format -# define __printf__ printf -# endif -#endif - -#include -#include - -namespace gnu -{ - /* A temporary object, usually allocated on the stack, representing - the result of an asprintf() call. */ - class autosprintf - { - public: - /* Constructor: takes a format string and the printf arguments. */ - autosprintf (const char *format, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); - /* Copy constructor. */ - autosprintf (const autosprintf& src); - /* Destructor: frees the temporarily allocated string. */ - ~autosprintf (); - /* Conversion to string. */ - operator char * () const; - operator std::string () const; - /* Output to an ostream. */ - friend inline std::ostream& operator<< (std::ostream& stream, const autosprintf& tmp) - { - stream << (tmp.str ? tmp.str : "(error in autosprintf)"); - return stream; - } - private: - char *str; - }; -} - -#endif /* _AUTOSPRINTF_H */ diff --git a/libs/gettext/include64/gettext-po.h b/libs/gettext/include64/gettext-po.h deleted file mode 100644 index 24fd8e90e..000000000 --- a/libs/gettext/include64/gettext-po.h +++ /dev/null @@ -1,357 +0,0 @@ -/* Public API for GNU gettext PO files - contained in libgettextpo. - Copyright (C) 2003-2008, 2010 Free Software Foundation, Inc. - Written by Bruno Haible , 2003. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifndef _GETTEXT_PO_H -#define _GETTEXT_PO_H 1 - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/* =========================== Meta Information ============================ */ - -/* Version number: (major<<16) + (minor<<8) + subminor */ -#define LIBGETTEXTPO_VERSION 0x001201 -extern int libgettextpo_version; - -/* ================================= Types ================================= */ - -/* A po_file_t represents the contents of a PO file. */ -typedef struct po_file *po_file_t; - -/* A po_message_iterator_t represents an iterator through a domain of a - PO file. */ -typedef struct po_message_iterator *po_message_iterator_t; - -/* A po_message_t represents a message in a PO file. */ -typedef struct po_message *po_message_t; - -/* A po_filepos_t represents a string's position within a source file. */ -typedef struct po_filepos *po_filepos_t; - -/* A po_error_handler handles error situations. */ -struct po_error_handler -{ - /* Signal an error. The error message is built from FORMAT and the following - arguments. ERRNUM, if nonzero, is an errno value. - Must increment the error_message_count variable declared in error.h. - Must not return if STATUS is nonzero. */ - void (*error) (int status, int errnum, - const char *format, ...) -#if ((__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || __GNUC__ > 3) && !__STRICT_ANSI__ - __attribute__ ((__format__ (__printf__, 3, 4))) -#endif - ; - - /* Signal an error. The error message is built from FORMAT and the following - arguments. The error location is at FILENAME line LINENO. ERRNUM, if - nonzero, is an errno value. - Must increment the error_message_count variable declared in error.h. - Must not return if STATUS is nonzero. */ - void (*error_at_line) (int status, int errnum, - const char *filename, unsigned int lineno, - const char *format, ...) -#if ((__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || __GNUC__ > 3) && !__STRICT_ANSI__ - __attribute__ ((__format__ (__printf__, 5, 6))) -#endif - ; - - /* Signal a multiline warning. The PREFIX applies to all lines of the - MESSAGE. Free the PREFIX and MESSAGE when done. */ - void (*multiline_warning) (char *prefix, char *message); - - /* Signal a multiline error. The PREFIX applies to all lines of the - MESSAGE. Free the PREFIX and MESSAGE when done. - Must increment the error_message_count variable declared in error.h if - PREFIX is non-NULL. */ - void (*multiline_error) (char *prefix, char *message); -}; -typedef const struct po_error_handler *po_error_handler_t; - -/* A po_xerror_handler handles warnings, error and fatal error situations. */ -#define PO_SEVERITY_WARNING 0 /* just a warning, tell the user */ -#define PO_SEVERITY_ERROR 1 /* an error, the operation cannot complete */ -#define PO_SEVERITY_FATAL_ERROR 2 /* an error, the operation must be aborted */ -struct po_xerror_handler -{ - /* Signal a problem of the given severity. - MESSAGE and/or FILENAME + LINENO indicate where the problem occurred. - If FILENAME is NULL, FILENAME and LINENO and COLUMN should be ignored. - If LINENO is (size_t)(-1), LINENO and COLUMN should be ignored. - If COLUMN is (size_t)(-1), it should be ignored. - MESSAGE_TEXT is the problem description (if MULTILINE_P is true, - multiple lines of text, each terminated with a newline, otherwise - usually a single line). - Must not return if SEVERITY is PO_SEVERITY_FATAL_ERROR. */ - void (*xerror) (int severity, - po_message_t message, - const char *filename, size_t lineno, size_t column, - int multiline_p, const char *message_text); - /* Signal a problem that refers to two messages. - Similar to two calls to xerror. - If possible, a "..." can be appended to MESSAGE_TEXT1 and prepended to - MESSAGE_TEXT2. */ - void (*xerror2) (int severity, - po_message_t message1, - const char *filename1, size_t lineno1, size_t column1, - int multiline_p1, const char *message_text1, - po_message_t message2, - const char *filename2, size_t lineno2, size_t column2, - int multiline_p2, const char *message_text2); -}; -typedef const struct po_xerror_handler *po_xerror_handler_t; - -/* Memory allocation: - The memory allocations performed by these functions use xmalloc(), - therefore will cause a program exit if memory is exhausted. - The memory allocated by po_file_read, and implicitly returned through - the po_message_* functions, lasts until freed with po_file_free. */ - - -/* ============================= po_file_t API ============================= */ - -/* Create an empty PO file representation in memory. */ -extern po_file_t po_file_create (void); - -/* Read a PO file into memory. - Return its contents. Upon failure, return NULL and set errno. */ -#define po_file_read po_file_read_v3 -extern po_file_t po_file_read (const char *filename, - po_xerror_handler_t handler); - -/* Write an in-memory PO file to a file. - Upon failure, return NULL and set errno. */ -#define po_file_write po_file_write_v2 -extern po_file_t po_file_write (po_file_t file, const char *filename, - po_xerror_handler_t handler); - -/* Free a PO file from memory. */ -extern void po_file_free (po_file_t file); - -/* Return the names of the domains covered by a PO file in memory. */ -extern const char * const * po_file_domains (po_file_t file); - - -/* =========================== Header entry API ============================ */ - -/* Return the header entry of a domain of a PO file in memory. - The domain NULL denotes the default domain. - Return NULL if there is no header entry. */ -extern const char * po_file_domain_header (po_file_t file, const char *domain); - -/* Return the value of a field in a header entry. - The return value is either a freshly allocated string, to be freed by the - caller, or NULL. */ -extern char * po_header_field (const char *header, const char *field); - -/* Return the header entry with a given field set to a given value. The field - is added if necessary. - The return value is a freshly allocated string. */ -extern char * po_header_set_field (const char *header, const char *field, const char *value); - - -/* ======================= po_message_iterator_t API ======================= */ - -/* Create an iterator for traversing a domain of a PO file in memory. - The domain NULL denotes the default domain. */ -extern po_message_iterator_t po_message_iterator (po_file_t file, const char *domain); - -/* Free an iterator. */ -extern void po_message_iterator_free (po_message_iterator_t iterator); - -/* Return the next message, and advance the iterator. - Return NULL at the end of the message list. */ -extern po_message_t po_next_message (po_message_iterator_t iterator); - -/* Insert a message in a PO file in memory, in the domain and at the position - indicated by the iterator. The iterator thereby advances past the freshly - inserted message. */ -extern void po_message_insert (po_message_iterator_t iterator, po_message_t message); - - -/* =========================== po_message_t API ============================ */ - -/* Return a freshly constructed message. - To finish initializing the message, you must set the msgid and msgstr. */ -extern po_message_t po_message_create (void); - -/* Return the context of a message, or NULL for a message not restricted to a - context. */ -extern const char * po_message_msgctxt (po_message_t message); - -/* Change the context of a message. NULL means a message not restricted to a - context. */ -extern void po_message_set_msgctxt (po_message_t message, const char *msgctxt); - -/* Return the msgid (untranslated English string) of a message. */ -extern const char * po_message_msgid (po_message_t message); - -/* Change the msgid (untranslated English string) of a message. */ -extern void po_message_set_msgid (po_message_t message, const char *msgid); - -/* Return the msgid_plural (untranslated English plural string) of a message, - or NULL for a message without plural. */ -extern const char * po_message_msgid_plural (po_message_t message); - -/* Change the msgid_plural (untranslated English plural string) of a message. - NULL means a message without plural. */ -extern void po_message_set_msgid_plural (po_message_t message, const char *msgid_plural); - -/* Return the msgstr (translation) of a message. - Return the empty string for an untranslated message. */ -extern const char * po_message_msgstr (po_message_t message); - -/* Change the msgstr (translation) of a message. - Use an empty string to denote an untranslated message. */ -extern void po_message_set_msgstr (po_message_t message, const char *msgstr); - -/* Return the msgstr[index] for a message with plural handling, or - NULL when the index is out of range or for a message without plural. */ -extern const char * po_message_msgstr_plural (po_message_t message, int index); - -/* Change the msgstr[index] for a message with plural handling. - Use a NULL value at the end to reduce the number of plural forms. */ -extern void po_message_set_msgstr_plural (po_message_t message, int index, const char *msgstr); - -/* Return the comments for a message. */ -extern const char * po_message_comments (po_message_t message); - -/* Change the comments for a message. - comments should be a multiline string, ending in a newline, or empty. */ -extern void po_message_set_comments (po_message_t message, const char *comments); - -/* Return the extracted comments for a message. */ -extern const char * po_message_extracted_comments (po_message_t message); - -/* Change the extracted comments for a message. - comments should be a multiline string, ending in a newline, or empty. */ -extern void po_message_set_extracted_comments (po_message_t message, const char *comments); - -/* Return the i-th file position for a message, or NULL if i is out of - range. */ -extern po_filepos_t po_message_filepos (po_message_t message, int i); - -/* Remove the i-th file position from a message. - The indices of all following file positions for the message are decremented - by one. */ -extern void po_message_remove_filepos (po_message_t message, int i); - -/* Add a file position to a message, if it is not already present for the - message. - file is the file name. - start_line is the line number where the string starts, or (size_t)(-1) if no - line number is available. */ -extern void po_message_add_filepos (po_message_t message, const char *file, size_t start_line); - -/* Return the previous context of a message, or NULL for none. */ -extern const char * po_message_prev_msgctxt (po_message_t message); - -/* Change the previous context of a message. NULL is allowed. */ -extern void po_message_set_prev_msgctxt (po_message_t message, const char *prev_msgctxt); - -/* Return the previous msgid (untranslated English string) of a message, or - NULL for none. */ -extern const char * po_message_prev_msgid (po_message_t message); - -/* Change the previous msgid (untranslated English string) of a message. - NULL is allowed. */ -extern void po_message_set_prev_msgid (po_message_t message, const char *prev_msgid); - -/* Return the previous msgid_plural (untranslated English plural string) of a - message, or NULL for none. */ -extern const char * po_message_prev_msgid_plural (po_message_t message); - -/* Change the previous msgid_plural (untranslated English plural string) of a - message. NULL is allowed. */ -extern void po_message_set_prev_msgid_plural (po_message_t message, const char *prev_msgid_plural); - -/* Return true if the message is marked obsolete. */ -extern int po_message_is_obsolete (po_message_t message); - -/* Change the obsolete mark of a message. */ -extern void po_message_set_obsolete (po_message_t message, int obsolete); - -/* Return true if the message is marked fuzzy. */ -extern int po_message_is_fuzzy (po_message_t message); - -/* Change the fuzzy mark of a message. */ -extern void po_message_set_fuzzy (po_message_t message, int fuzzy); - -/* Return true if the message is marked as being a format string of the given - type (e.g. "c-format"). */ -extern int po_message_is_format (po_message_t message, const char *format_type); - -/* Change the format string mark for a given type of a message. */ -extern void po_message_set_format (po_message_t message, const char *format_type, /*bool*/int value); - -/* If a numeric range of a message is set, return true and store the minimum - and maximum value in *MINP and *MAXP. */ -extern int po_message_is_range (po_message_t message, int *minp, int *maxp); - -/* Change the numeric range of a message. MIN and MAX must be non-negative, - with MIN < MAX. Use MIN = MAX = -1 to remove the numeric range of a - message. */ -extern void po_message_set_range (po_message_t message, int min, int max); - - -/* =========================== po_filepos_t API ============================ */ - -/* Return the file name. */ -extern const char * po_filepos_file (po_filepos_t filepos); - -/* Return the line number where the string starts, or (size_t)(-1) if no line - number is available. */ -extern size_t po_filepos_start_line (po_filepos_t filepos); - - -/* ============================ Format type API ============================= */ - -/* Return a NULL terminated array of the supported format types. */ -extern const char * const * po_format_list (void); - -/* Return the pretty name associated with a format type. - For example, for "csharp-format", return "C#". - Return NULL if the argument is not a supported format type. */ -extern const char * po_format_pretty_name (const char *format_type); - - -/* ============================= Checking API ============================== */ - -/* Test whether an entire file PO file is valid, like msgfmt does it. - If it is invalid, pass the reasons to the handler. */ -extern void po_file_check_all (po_file_t file, po_xerror_handler_t handler); - -/* Test a single message, to be inserted in a PO file in memory, like msgfmt - does it. If it is invalid, pass the reasons to the handler. The iterator - is not modified by this call; it only specifies the file and the domain. */ -extern void po_message_check_all (po_message_t message, po_message_iterator_t iterator, po_xerror_handler_t handler); - -/* Test whether the message translation is a valid format string if the message - is marked as being a format string. If it is invalid, pass the reasons to - the handler. */ -#define po_message_check_format po_message_check_format_v2 -extern void po_message_check_format (po_message_t message, po_xerror_handler_t handler); - - -#ifdef __cplusplus -} -#endif - -#endif /* _GETTEXT_PO_H */ diff --git a/libs/gettext/include64/libintl.h b/libs/gettext/include64/libintl.h deleted file mode 100644 index a8e2d414b..000000000 --- a/libs/gettext/include64/libintl.h +++ /dev/null @@ -1,464 +0,0 @@ -/* Message catalogs for internationalization. - Copyright (C) 1995-1997, 2000-2010 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. */ - -#ifndef _LIBINTL_H -#define _LIBINTL_H 1 - -#include -#if (defined __APPLE__ && defined __MACH__) && 0 -# include -#endif - -/* The LC_MESSAGES locale category is the category used by the functions - gettext() and dgettext(). It is specified in POSIX, but not in ANSI C. - On systems that don't define it, use an arbitrary value instead. - On Solaris, defines __LOCALE_H (or _LOCALE_H in Solaris 2.5) - then includes (i.e. this file!) and then only defines - LC_MESSAGES. To avoid a redefinition warning, don't define LC_MESSAGES - in this case. */ -#if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun)) -# define LC_MESSAGES 1729 -#endif - -/* We define an additional symbol to signal that we use the GNU - implementation of gettext. */ -#define __USE_GNU_GETTEXT 1 - -/* Provide information about the supported file formats. Returns the - maximum minor revision number supported for a given major revision. */ -#define __GNU_GETTEXT_SUPPORTED_REVISION(major) \ - ((major) == 0 || (major) == 1 ? 1 : -1) - -/* Resolve a platform specific conflict on DJGPP. GNU gettext takes - precedence over _conio_gettext. */ -#ifdef __DJGPP__ -# undef gettext -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/* Version number: (major<<16) + (minor<<8) + subminor */ -#define LIBINTL_VERSION 0x001201 -extern int libintl_version; - - -/* We redirect the functions to those prefixed with "libintl_". This is - necessary, because some systems define gettext/textdomain/... in the C - library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer). - If we used the unprefixed names, there would be cases where the - definition in the C library would override the one in the libintl.so - shared library. Recall that on ELF systems, the symbols are looked - up in the following order: - 1. in the executable, - 2. in the shared libraries specified on the link command line, in order, - 3. in the dependencies of the shared libraries specified on the link - command line, - 4. in the dlopen()ed shared libraries, in the order in which they were - dlopen()ed. - The definition in the C library would override the one in libintl.so if - either - * -lc is given on the link command line and -lintl isn't, or - * -lc is given on the link command line before -lintl, or - * libintl.so is a dependency of a dlopen()ed shared library but not - linked to the executable at link time. - Since Solaris gettext() behaves differently than GNU gettext(), this - would be unacceptable. - - The redirection happens by default through macros in C, so that &gettext - is independent of the compilation unit, but through inline functions in - C++, in order not to interfere with the name mangling of class fields or - class methods called 'gettext'. */ - -/* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS. - If he doesn't, we choose the method. A third possible method is - _INTL_REDIRECT_ASM, supported only by GCC. */ -#if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS) -# if defined __GNUC__ && __GNUC__ >= 2 && !(defined __APPLE_CC__ && __APPLE_CC__ > 1) && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus) -# define _INTL_REDIRECT_ASM -# else -# ifdef __cplusplus -# define _INTL_REDIRECT_INLINE -# else -# define _INTL_REDIRECT_MACROS -# endif -# endif -#endif -/* Auxiliary macros. */ -#ifdef _INTL_REDIRECT_ASM -# define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname)) -# define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring -# define _INTL_STRINGIFY(prefix) #prefix -#else -# define _INTL_ASM(cname) -#endif - -/* _INTL_MAY_RETURN_STRING_ARG(n) declares that the given function may return - its n-th argument literally. This enables GCC to warn for example about - printf (gettext ("foo %y")). */ -#if defined __GNUC__ && __GNUC__ >= 3 && !(defined __APPLE_CC__ && __APPLE_CC__ > 1 && defined __cplusplus) -# define _INTL_MAY_RETURN_STRING_ARG(n) __attribute__ ((__format_arg__ (n))) -#else -# define _INTL_MAY_RETURN_STRING_ARG(n) -#endif - -/* Look up MSGID in the current default message catalog for the current - LC_MESSAGES locale. If not found, returns MSGID itself (the default - text). */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_gettext (const char *__msgid) - _INTL_MAY_RETURN_STRING_ARG (1); -static inline char *gettext (const char *__msgid) -{ - return libintl_gettext (__msgid); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define gettext libintl_gettext -#endif -extern char *gettext (const char *__msgid) - _INTL_ASM (libintl_gettext) - _INTL_MAY_RETURN_STRING_ARG (1); -#endif - -/* Look up MSGID in the DOMAINNAME message catalog for the current - LC_MESSAGES locale. */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_dgettext (const char *__domainname, const char *__msgid) - _INTL_MAY_RETURN_STRING_ARG (2); -static inline char *dgettext (const char *__domainname, const char *__msgid) -{ - return libintl_dgettext (__domainname, __msgid); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define dgettext libintl_dgettext -#endif -extern char *dgettext (const char *__domainname, const char *__msgid) - _INTL_ASM (libintl_dgettext) - _INTL_MAY_RETURN_STRING_ARG (2); -#endif - -/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY - locale. */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_dcgettext (const char *__domainname, const char *__msgid, - int __category) - _INTL_MAY_RETURN_STRING_ARG (2); -static inline char *dcgettext (const char *__domainname, const char *__msgid, - int __category) -{ - return libintl_dcgettext (__domainname, __msgid, __category); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define dcgettext libintl_dcgettext -#endif -extern char *dcgettext (const char *__domainname, const char *__msgid, - int __category) - _INTL_ASM (libintl_dcgettext) - _INTL_MAY_RETURN_STRING_ARG (2); -#endif - - -/* Similar to `gettext' but select the plural form corresponding to the - number N. */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2, - unsigned long int __n) - _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2); -static inline char *ngettext (const char *__msgid1, const char *__msgid2, - unsigned long int __n) -{ - return libintl_ngettext (__msgid1, __msgid2, __n); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define ngettext libintl_ngettext -#endif -extern char *ngettext (const char *__msgid1, const char *__msgid2, - unsigned long int __n) - _INTL_ASM (libintl_ngettext) - _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2); -#endif - -/* Similar to `dgettext' but select the plural form corresponding to the - number N. */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_dngettext (const char *__domainname, const char *__msgid1, - const char *__msgid2, unsigned long int __n) - _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3); -static inline char *dngettext (const char *__domainname, const char *__msgid1, - const char *__msgid2, unsigned long int __n) -{ - return libintl_dngettext (__domainname, __msgid1, __msgid2, __n); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define dngettext libintl_dngettext -#endif -extern char *dngettext (const char *__domainname, - const char *__msgid1, const char *__msgid2, - unsigned long int __n) - _INTL_ASM (libintl_dngettext) - _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3); -#endif - -/* Similar to `dcgettext' but select the plural form corresponding to the - number N. */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_dcngettext (const char *__domainname, - const char *__msgid1, const char *__msgid2, - unsigned long int __n, int __category) - _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3); -static inline char *dcngettext (const char *__domainname, - const char *__msgid1, const char *__msgid2, - unsigned long int __n, int __category) -{ - return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define dcngettext libintl_dcngettext -#endif -extern char *dcngettext (const char *__domainname, - const char *__msgid1, const char *__msgid2, - unsigned long int __n, int __category) - _INTL_ASM (libintl_dcngettext) - _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3); -#endif - - - -/* Set the current default message catalog to DOMAINNAME. - If DOMAINNAME is null, return the current default. - If DOMAINNAME is "", reset to the default of "messages". */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_textdomain (const char *__domainname); -static inline char *textdomain (const char *__domainname) -{ - return libintl_textdomain (__domainname); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define textdomain libintl_textdomain -#endif -extern char *textdomain (const char *__domainname) - _INTL_ASM (libintl_textdomain); -#endif - -/* Specify that the DOMAINNAME message catalog will be found - in DIRNAME rather than in the system locale data base. */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_bindtextdomain (const char *__domainname, - const char *__dirname); -static inline char *bindtextdomain (const char *__domainname, - const char *__dirname) -{ - return libintl_bindtextdomain (__domainname, __dirname); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define bindtextdomain libintl_bindtextdomain -#endif -extern char *bindtextdomain (const char *__domainname, const char *__dirname) - _INTL_ASM (libintl_bindtextdomain); -#endif - -/* Specify the character encoding in which the messages from the - DOMAINNAME message catalog will be returned. */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_bind_textdomain_codeset (const char *__domainname, - const char *__codeset); -static inline char *bind_textdomain_codeset (const char *__domainname, - const char *__codeset) -{ - return libintl_bind_textdomain_codeset (__domainname, __codeset); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define bind_textdomain_codeset libintl_bind_textdomain_codeset -#endif -extern char *bind_textdomain_codeset (const char *__domainname, - const char *__codeset) - _INTL_ASM (libintl_bind_textdomain_codeset); -#endif - - - -/* Support for format strings with positions in *printf(), following the - POSIX/XSI specification. - Note: These replacements for the *printf() functions are visible only - in source files that #include or #include "gettext.h". - Packages that use *printf() in source files that don't refer to _() - or gettext() but for which the format string could be the return value - of _() or gettext() need to add this #include. Oh well. */ - -#if !0 - -#include -#include - -/* Get va_list. */ -#if (defined __STDC__ && __STDC__) || defined __cplusplus || defined _MSC_VER -# include -#else -# include -#endif - -#if !(defined fprintf && defined _GL_STDIO_H) /* don't override gnulib */ -#undef fprintf -#define fprintf libintl_fprintf -extern int fprintf (FILE *, const char *, ...); -#endif -#if !(defined vfprintf && defined _GL_STDIO_H) /* don't override gnulib */ -#undef vfprintf -#define vfprintf libintl_vfprintf -extern int vfprintf (FILE *, const char *, va_list); -#endif - -#if !(defined printf && defined _GL_STDIO_H) /* don't override gnulib */ -#undef printf -#if defined __NetBSD__ || defined __BEOS__ || defined __CYGWIN__ || defined __MINGW32__ -/* Don't break __attribute__((format(printf,M,N))). - This redefinition is only possible because the libc in NetBSD, Cygwin, - mingw does not have a function __printf__. - Alternatively, we could have done this redirection only when compiling with - __GNUC__, together with a symbol redirection: - extern int printf (const char *, ...) - __asm__ (#__USER_LABEL_PREFIX__ "libintl_printf"); - But doing it now would introduce a binary incompatibility with already - distributed versions of libintl on these systems. */ -# define libintl_printf __printf__ -#endif -#define printf libintl_printf -extern int printf (const char *, ...); -#endif -#if !(defined vprintf && defined _GL_STDIO_H) /* don't override gnulib */ -#undef vprintf -#define vprintf libintl_vprintf -extern int vprintf (const char *, va_list); -#endif - -#if !(defined sprintf && defined _GL_STDIO_H) /* don't override gnulib */ -#undef sprintf -#define sprintf libintl_sprintf -extern int sprintf (char *, const char *, ...); -#endif -#if !(defined vsprintf && defined _GL_STDIO_H) /* don't override gnulib */ -#undef vsprintf -#define vsprintf libintl_vsprintf -extern int vsprintf (char *, const char *, va_list); -#endif - -#if 1 - -#if !(defined snprintf && defined _GL_STDIO_H) /* don't override gnulib */ -#undef snprintf -#define snprintf libintl_snprintf -extern int snprintf (char *, size_t, const char *, ...); -#endif -#if !(defined vsnprintf && defined _GL_STDIO_H) /* don't override gnulib */ -#undef vsnprintf -#define vsnprintf libintl_vsnprintf -extern int vsnprintf (char *, size_t, const char *, va_list); -#endif - -#endif - -#if 0 - -#if !(defined asprintf && defined _GL_STDIO_H) /* don't override gnulib */ -#undef asprintf -#define asprintf libintl_asprintf -extern int asprintf (char **, const char *, ...); -#endif -#if !(defined vasprintf && defined _GL_STDIO_H) /* don't override gnulib */ -#undef vasprintf -#define vasprintf libintl_vasprintf -extern int vasprintf (char **, const char *, va_list); -#endif - -#endif - -#if 0 - -#undef fwprintf -#define fwprintf libintl_fwprintf -extern int fwprintf (FILE *, const wchar_t *, ...); -#undef vfwprintf -#define vfwprintf libintl_vfwprintf -extern int vfwprintf (FILE *, const wchar_t *, va_list); - -#undef wprintf -#define wprintf libintl_wprintf -extern int wprintf (const wchar_t *, ...); -#undef vwprintf -#define vwprintf libintl_vwprintf -extern int vwprintf (const wchar_t *, va_list); - -#undef swprintf -#define swprintf libintl_swprintf -extern int swprintf (wchar_t *, size_t, const wchar_t *, ...); -#undef vswprintf -#define vswprintf libintl_vswprintf -extern int vswprintf (wchar_t *, size_t, const wchar_t *, va_list); - -#endif - -#endif - - -/* Support for the locale chosen by the user. */ -#if (defined __APPLE__ && defined __MACH__) || defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ - -#undef setlocale -#define setlocale libintl_setlocale -extern char *setlocale (int, const char *); - -#if 0 - -#undef newlocale -#define newlocale libintl_newlocale -extern locale_t newlocale (int, const char *, locale_t); - -#endif - -#endif - - -/* Support for relocatable packages. */ - -/* Sets the original and the current installation prefix of the package. - Relocation simply replaces a pathname starting with the original prefix - by the corresponding pathname with the current prefix instead. Both - prefixes should be directory names without trailing slash (i.e. use "" - instead of "/"). */ -#define libintl_set_relocation_prefix libintl_set_relocation_prefix -extern void - libintl_set_relocation_prefix (const char *orig_prefix, - const char *curr_prefix); - - -#ifdef __cplusplus -} -#endif - -#endif /* libintl.h */ diff --git a/libs/gettext/lib32/gettext/hostname.exe b/libs/gettext/lib32/gettext/hostname.exe deleted file mode 100644 index ec691522b..000000000 Binary files a/libs/gettext/lib32/gettext/hostname.exe and /dev/null differ diff --git a/libs/gettext/lib32/gettext/project-id b/libs/gettext/lib32/gettext/project-id deleted file mode 100755 index 496f466c9..000000000 --- a/libs/gettext/lib32/gettext/project-id +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/sh -# Prints a package's identification PACKAGE VERSION or PACKAGE. -# -# Copyright (C) 2001-2003, 2005 Free Software Foundation, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -want_version="$1" - -# NLS nuisances: Letter ranges are different in the Estonian locale. -LC_ALL=C - -while true; do - if test -f configure; then - package=`(grep '^PACKAGE_NAME=' configure; grep '^ *PACKAGE=' configure) | grep -v '=[ ]*$' | sed -e '1q' | sed -e 's/^[^=]*=//' | sed -e "s/^'//" -e "s/'$//"` - case "$package" in - *[\"\$\`\{\}]*) - # Some packages (gcal) retrieve the package name dynamically. - package= - ;; - esac - if test -n "$package"; then - is_gnu=`LC_ALL=C grep "GNU $package" * 2>/dev/null | grep -v '^libtool:'` - if test -n "$is_gnu"; then - package="GNU $package" - fi - if test -n "$want_version"; then - version=`(grep '^PACKAGE_VERSION=' configure; grep '^ *VERSION=' configure) | grep -v '=[ ]*$' | sed -e '1q' | sed -e 's/^[^=]*=//' | sed -e "s/^'//" -e "s/'$//"` - case "$version" in - *[\"\$\`\{\}]*) - # Some packages (gcal, gcc, clisp) retrieve the version dynamically. - version= - ;; - esac - if test -n "$version"; then - echo "$package $version" - else - echo "$package" - fi - else - echo "$package" - fi - exit 0 - fi - fi - dir=`basename \`pwd\`` - case "$dir" in - i18n) - # This directory name, used in GNU make, is not the top level directory. - ;; - *[A-Za-z]*[0-9]*) - package=`echo "$dir" | sed -e 's/^\([^0-9]*\)[0-9].*$/\1/' -e 's/[-_]$//'` - if test -n "$want_version"; then - version=`echo "$dir" | sed -e 's/^[^0-9]*\([0-9].*\)$/\1/'` - echo "$package $version" - else - echo "$package" - fi - exit 0 - ;; - esac - # Go to parent directory - last=`/bin/pwd` - cd .. - curr=`/bin/pwd` - if test "$last" = "$curr"; then - # Oops, didn't find the package name. - if test -n "$want_version"; then - echo "PACKAGE VERSION" - else - echo "PACKAGE" - fi - exit 0 - fi -done diff --git a/libs/gettext/lib32/gettext/urlget.exe b/libs/gettext/lib32/gettext/urlget.exe deleted file mode 100644 index 8f4234b54..000000000 Binary files a/libs/gettext/lib32/gettext/urlget.exe and /dev/null differ diff --git a/libs/gettext/lib32/gettext/user-email b/libs/gettext/lib32/gettext/user-email deleted file mode 100755 index ebcee4d11..000000000 --- a/libs/gettext/lib32/gettext/user-email +++ /dev/null @@ -1,436 +0,0 @@ -#!/bin/sh -# Prints the user's email address, with confirmation from the user. -# -# Copyright (C) 2001-2003, 2005 Free Software Foundation, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# Prerequisites for using ${exec_prefix}/lib and ${datarootdir}/locale. -prefix="/usr/local/i686-w64-mingw32/stow/gettext-0.18.1.1" -exec_prefix="${prefix}" -datarootdir="${prefix}/share" -datadir="${datarootdir}" -# Set variables libdir, localedir. -libdir="${exec_prefix}/lib" -localedir="${datarootdir}/locale" - -# Support for relocatability. -if test "no" = yes; then - orig_installdir="$libdir"/gettext # see Makefile.am's install rule - # Determine curr_installdir without caring for symlinked callers. - curr_installdir=`echo "$0" | sed -e 's,/[^/]*$,,'` - curr_installdir=`cd "$curr_installdir" && pwd` - # Compute the original/current installation prefixes by stripping the - # trailing directories off the original/current installation directories. - while true; do - orig_last=`echo "$orig_installdir" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'` - curr_last=`echo "$curr_installdir" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'` - if test -z "$orig_last" || test -z "$curr_last"; then - break - fi - if test "$orig_last" != "$curr_last"; then - break - fi - orig_installdir=`echo "$orig_installdir" | sed -e 's,/[^/]*$,,'` - curr_installdir=`echo "$curr_installdir" | sed -e 's,/[^/]*$,,'` - done - # Now relocate the directory variables that we use. - libdir=`echo "$libdir/" | sed -e "s%^${orig_installdir}/%${curr_installdir}/%" | sed -e 's,/$,,'` - localedir=`echo "$localedir/" | sed -e "s%^${orig_installdir}/%${curr_installdir}/%" | sed -e 's,/$,,'` -fi - -# Internationalization. -. gettext.sh -TEXTDOMAIN=gettext-tools -export TEXTDOMAIN -TEXTDOMAINDIR="$localedir" -export TEXTDOMAINDIR - -# Redirect fileno 3 to interactive I/O. -exec 3>/dev/tty - -# Output a prompt. -if test $# != 0; then - echo "$1" 1>&3 -fi - -# Find the user name on the local machine. -user=`id -u -n 2>/dev/null` -if test -z "$user"; then - user="$USER" - if test -z "$user"; then - user="$LOGNAME" - if test -z "$user"; then - user=unknown - fi - fi -fi - -# Find the hostname. -# hostname on some systems (SVR3.2, old Linux) returns a bogus exit status, -# so uname gets run too, so we keep only the first line of output. -#host=`(hostname || uname -n) 2>/dev/null | sed 1q` -host=`"$libdir"/gettext/hostname --short 2>/dev/null | sed 1q` - -# Find the hostname. -hostfqdn=`"$libdir"/gettext/hostname --fqdn 2>/dev/null | sed 1q` - -# Find a list of email addresses from various mailer configuration files. -# All mailers use configuration files under $HOME. We handle them in a -# last-modified - first-priority order. -cd $HOME -files="" - -# ----------------------- BEGIN MAILER SPECIFIC CODE ----------------------- - -# Mozilla Thunderbird addresses -files="$files .thunderbird/*/prefs.js" - -# Mozilla addresses -files="$files .mozilla/*/prefs.js" - -# Netscape 4 addresses -files="$files .netscape/liprefs.js .netscape/preferences.js" - -# Netscape 3 addresses -files="$files .netscape/preferences" - -# Emacs/XEmacs rmail, Emacs/XEmacs gnus, XEmacs vm addresses -# XEmacs mew addresses -files="$files .emacs .emacs.el" - -# KDE2 addresses -files="$files .kde2/share/config/emaildefaults" - -# KDE kmail addresses -files="$files .kde2/share/config/kmailrc" - -# GNOME evolution 2 addresses -files="$files .gconf/apps/evolution/mail/%gconf.xml" - -# GNOME evolution 1 addresses -files="$files evolution/config.xmldb" - -# GNOME balsa addresses -files="$files .gnome/balsa" - -# StarOffice and OpenOffice addresses -sed_dos2unix='s/\r$//' -sed_soffice51='s,StarOffice 5\.1=\(.*\)$,\1/sofficerc,p' -sed_soffice52='s,StarOffice 5\.2=\(.*\)$,\1/user/sofficerc,p' -sed_ooffice='s,^OpenOffice[^=]*=\(.*\)$,\1/user/config/registry/instance/org/openoffice/UserProfile.xml,p' -files="$files Office51/sofficerc Office52/user/sofficerc "`sed -n -e "$sed_dos2unix" -e "$sed_soffice51" -e "$sed_soffice52" -e "$sed_ooffice" .sversionrc 2>/dev/null | sed -e 's,^file://*,/,'` - -# mutt addresses -files="$files .muttrc" - -# pine addresses -files="$files .pinerc" - -# xfmail addresses -files="$files .xfmail/.xfmailrc" - -# tkrat addresses -files="$files .ratatosk/ratatoskrc" - -# ----------------------- END MAILER SPECIFIC CODE ----------------------- - -# Expand wildcards and remove nonexistent files from the list. -nfiles="" -for file in $files; do - if test -r "$file" && test ! -d "$file"; then - nfiles="$nfiles $file" - fi -done -files="$nfiles" - -addresses="" - -if test -n "$files"; then - - for file in `ls -t $files`; do - - case "$file" in - -# ----------------------- BEGIN MAILER SPECIFIC CODE ----------------------- - - # Mozilla and Mozilla Thunderbird addresses - .mozilla/*/prefs.js | .thunderbird/*/prefs.js) - addresses="$addresses "`grep -h '^user_pref("mail\.identity\..*\.useremail", ".*");$' $file 2>/dev/null | sed -e 's/^user_pref("mail\.identity\..*\.useremail", "\(.*\)");$/\1/'` - ;; - - # Netscape 4 addresses - .netscape/liprefs.js | .netscape/preferences.js) - addresses="$addresses "`grep -h '^user_pref("mail\.identity\.useremail", ".*");$' $file 2>/dev/null | sed -e 's/^user_pref("mail\.identity\.useremail", "\(.*\)");$/\1/'` - ;; - - # Netscape 3 addresses - .netscape/preferences) - addresses="$addresses "`grep -h '^EMAIL_ADDRESS:' $file 2>/dev/null | sed -e 's/^EMAIL_ADDRESS:[ ]*//'` - ;; - - .emacs | .emacs.el) - # Emacs/XEmacs rmail, Emacs/XEmacs gnus, XEmacs vm addresses - addresses="$addresses "`grep -h '[ (]user-mail-address "[^"]*"' $file 2>/dev/null | sed -e 's/^.*[ (]user-mail-address "\([^"]*\)".*$/\1/'` - # XEmacs mew addresses - domains=`grep -h '[ (]mew-mail-domain "[^"]*"' $file 2>/dev/null | sed -e 's/^.*[ (]mew-mail-domain "\([^"]*\)".*$/\1/'` - if test -n "$domains"; then - for domain in $domains; do - addresses="$addresses ${user}@$domain" - done - fi - ;; - - # KDE2 addresses - .kde2/share/config/emaildefaults) - addresses="$addresses "`grep -h '^EmailAddress=' $file 2>/dev/null | sed -e 's/^EmailAddress=//'` - ;; - - # KDE kmail addresses - .kde2/share/config/kmailrc) - addresses="$addresses "`grep -h '^Email Address=' $file 2>/dev/null | sed -e 's/^Email Address=//'` - ;; - - # GNOME evolution 2 addresses - .gconf/apps/evolution/mail/%gconf.xml) - sedexpr0='s,^.*<addr-spec>\(.*\)</addr-spec>.*$,\1,p' - addresses="$addresses "`sed -n -e "$sedexpr0" < $file` - ;; - - # GNOME evolution 1 addresses - evolution/config.xmldb) - sedexpr0='s/^.*\(.*\).*$,\1,p' $file 2>/dev/null` - ;; - - # StarOffice addresses - # Not a typo. They really write "Adress" with a single d. - # German orthography... - */sofficerc) - addresses="$addresses "`grep -h '^User-Adress=' $file 2>/dev/null | sed -e 's/#[^#]*$//' -e 's/^.*#//'` - ;; - - # mutt addresses - .muttrc) - mutt_addresses=`grep -h '^set from="[^"]*"[ ]*$' $file 2>/dev/null | sed -e 's/^set from="\([^"]*\)"[ ]*$/\1/'` - if test -n "$mutt_addresses"; then - addresses="$addresses $mutt_addresses" - else - # mutt uses $EMAIL as fallback. - if test -n "$EMAIL"; then - addresses="$addresses $EMAIL" - fi - fi - ;; - - # pine addresses - .pinerc) - domains=`grep -h '^user-domain=' $file 2>/dev/null | sed -e 's/^user-domain=//'` - if test -n "$domains"; then - for domain in $domains; do - addresses="$addresses ${user}@$domain" - done - else - # The use-only-domain-name option is only used if the user-domain option is not present. - domains=`grep -h '^use-only-domain-name=' $file 2>/dev/null | sed -e 's/^use-only-domain-name=//'` - if test "Yes" = "$domains"; then - addresses="$addresses ${user}@"`echo "$hostfqdn" | sed -e 's/^[^.]*\.//'` - fi - fi - ;; - - # xfmail addresses - .xfmail/.xfmailrc) - addresses="$addresses "`grep -h '^from=.*<.*>' $file 2>/dev/null | sed -e 's/^.*<\([^<>]*\)>.*$/\1/'` - ;; - - # tkrat addresses - .ratatosk/ratatoskrc) - domains=`grep -h '^set option(masquerade_as) ' $file 2>/dev/null | sed -e 's/^set option(masquerade_as) //'` - if test -n "$domains"; then - for domain in $domains; do - addresses="$addresses ${user}@$domain" - done - else - # The domain option is used only if the masquerade_as option is not present. - domains=`grep -h '^set option(domain) ' $file 2>/dev/null | sed -e 's/^set option(domain) //'` - if test -n "$domains"; then - for domain in $domains; do - addresses="$addresses ${user}@${host}.$domain" - done - fi - fi - ;; - -# ----------------------- END MAILER SPECIFIC CODE ----------------------- - - esac - - done - -fi - -# Some Debian systems have a file /etc/mailname. -if test -r /etc/mailname; then - hostmailname=`cat /etc/mailname` - if test -n "$hostmailname"; then - addresses="$addresses ${user}@$hostmailname" - fi -fi - -# SuSE Linux >= 8.0 systems have a file /etc/sysconfig/mail. -if test -r /etc/sysconfig/mail; then - hostmailname=`. /etc/sysconfig/mail && echo "$FROM_HEADER"` - if test -n "$hostmailname"; then - addresses="$addresses ${user}@$hostmailname" - fi -fi - -# elm has no user-defined addresses. -# mailx has no user-defined addresses. -# mh has no user-defined addresses. -# They use the system default. -addresses="$addresses ${user}@$hostfqdn" - -# Normalize addresses: remove addresses without @, lowercase the part after @, -# and remove duplicates. -lowercase_sed='{ -h -s/^[^@]*@\(.*\)$/\1/ -y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ -x -s/^\([^@]*\)@.*/\1@/ -G -s/\ -// -p -}' -naddresses="" -for addr in $addresses; do - case "$addr" in - "<"*">") addr=`echo "$addr" | sed -e 's/^$//'` ;; - esac - case "$addr" in - *@*) - addr=`echo "$addr" | sed -n -e "$lowercase_sed"` - case " $naddresses " in - *" $addr "*) ;; - *) naddresses="$naddresses $addr" ;; - esac - ;; - esac -done -addresses="$naddresses" - -# Now it's time to ask the user. -case "$addresses" in - " "*" "*) - # At least two addresses. - lines="" - i=0 - for addr in $addresses; do - i=`expr $i + 1` - lines="${lines}${i} ${addr} -" - done - while true; do - { gettext "Which is your email address?"; echo; } 1>&3 - echo "$lines" 1>&3 - { gettext "Please choose the number, or enter your email address."; echo; } 1>&3 - read answer < /dev/tty - case "$answer" in - *@*) ;; - [0-9]*) - i=0 - for addr in $addresses; do - i=`expr $i + 1` - if test "$i" = "$answer"; then - break 2 - fi - done - ;; - esac - case "$answer" in - "<"*">") answer=`echo "$answer" | sed -e 's/^$//'` ;; - esac - case "$answer" in - *" "*) { gettext "Invalid email address: invalid character."; echo; echo; } 1>&3 ; continue ;; - *@*.*) ;; - *@*) { gettext "Invalid email address: need a fully qualified host name or domain name."; echo; echo; } 1>&3 ; continue ;; - *) { gettext "Invalid email address: missing @"; echo; echo; } 1>&3 ; continue ;; - esac - addr=`echo "$answer" | sed -n -e "$lowercase_sed"` - break - done - ;; - " "*) - # One address. - while true; do - { gettext "Is the following your email address?"; echo; } 1>&3 - echo " $addresses" 1>&3 - { gettext "Please confirm by pressing Return, or enter your email address."; echo; } 1>&3 - read answer < /dev/tty - if test -z "$answer"; then - addr=`echo "$addresses" | sed -e 's/^ //'` - break - fi - case "$answer" in - "<"*">") answer=`echo "$answer" | sed -e 's/^$//'` ;; - esac - case "$answer" in - *" "*) { gettext "Invalid email address: invalid character."; echo; echo; } 1>&3 ; continue ;; - *@*.*) ;; - *@*) { gettext "Invalid email address: need a fully qualified host name or domain name."; echo; echo; } 1>&3 ; continue ;; - *) { gettext "Invalid email address: missing @"; echo; echo; } 1>&3 ; continue ;; - esac - addr=`echo "$answer" | sed -n -e "$lowercase_sed"` - break - done - ;; - "") - # No address. - { gettext "Couldn't find out about your email address."; echo; } 1>&3 - while true; do - { gettext "Please enter your email address."; echo; } 1>&3 - read answer < /dev/tty - case "$answer" in - "<"*">") answer=`echo "$answer" | sed -e 's/^$//'` ;; - esac - case "$answer" in - *" "*) { gettext "Invalid email address: invalid character."; echo; echo; } 1>&3 ; continue ;; - *@*.*) ;; - *@*) { gettext "Invalid email address: need a fully qualified host name or domain name."; echo; echo; } 1>&3 ; continue ;; - *) { gettext "Invalid email address: missing @"; echo; echo; } 1>&3 ; continue ;; - esac - addr=`echo "$answer" | sed -n -e "$lowercase_sed"` - break - done - ;; - *) echo "internal error" 1>&3 ; exit 1 ;; -esac - -# Print to standard output. -echo "$addr" diff --git a/libs/gettext/lib32/libasprintf.dll.a b/libs/gettext/lib32/libasprintf.dll.a deleted file mode 100644 index d83727061..000000000 Binary files a/libs/gettext/lib32/libasprintf.dll.a and /dev/null differ diff --git a/libs/gettext/lib32/libgettextlib.dll.a b/libs/gettext/lib32/libgettextlib.dll.a deleted file mode 100644 index 5b1c93d8a..000000000 Binary files a/libs/gettext/lib32/libgettextlib.dll.a and /dev/null differ diff --git a/libs/gettext/lib32/libgettextpo.dll.a b/libs/gettext/lib32/libgettextpo.dll.a deleted file mode 100644 index b4e858aab..000000000 Binary files a/libs/gettext/lib32/libgettextpo.dll.a and /dev/null differ diff --git a/libs/gettext/lib32/libgettextsrc.dll.a b/libs/gettext/lib32/libgettextsrc.dll.a deleted file mode 100644 index 83425c51f..000000000 Binary files a/libs/gettext/lib32/libgettextsrc.dll.a and /dev/null differ diff --git a/libs/gettext/lib32/libintl.dll.a b/libs/gettext/lib32/libintl.dll.a deleted file mode 100644 index 9e595475f..000000000 Binary files a/libs/gettext/lib32/libintl.dll.a and /dev/null differ diff --git a/libs/gettext/lib64/gettext/hostname.exe b/libs/gettext/lib64/gettext/hostname.exe deleted file mode 100644 index afc31abd8..000000000 Binary files a/libs/gettext/lib64/gettext/hostname.exe and /dev/null differ diff --git a/libs/gettext/lib64/gettext/project-id b/libs/gettext/lib64/gettext/project-id deleted file mode 100755 index 496f466c9..000000000 --- a/libs/gettext/lib64/gettext/project-id +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/sh -# Prints a package's identification PACKAGE VERSION or PACKAGE. -# -# Copyright (C) 2001-2003, 2005 Free Software Foundation, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -want_version="$1" - -# NLS nuisances: Letter ranges are different in the Estonian locale. -LC_ALL=C - -while true; do - if test -f configure; then - package=`(grep '^PACKAGE_NAME=' configure; grep '^ *PACKAGE=' configure) | grep -v '=[ ]*$' | sed -e '1q' | sed -e 's/^[^=]*=//' | sed -e "s/^'//" -e "s/'$//"` - case "$package" in - *[\"\$\`\{\}]*) - # Some packages (gcal) retrieve the package name dynamically. - package= - ;; - esac - if test -n "$package"; then - is_gnu=`LC_ALL=C grep "GNU $package" * 2>/dev/null | grep -v '^libtool:'` - if test -n "$is_gnu"; then - package="GNU $package" - fi - if test -n "$want_version"; then - version=`(grep '^PACKAGE_VERSION=' configure; grep '^ *VERSION=' configure) | grep -v '=[ ]*$' | sed -e '1q' | sed -e 's/^[^=]*=//' | sed -e "s/^'//" -e "s/'$//"` - case "$version" in - *[\"\$\`\{\}]*) - # Some packages (gcal, gcc, clisp) retrieve the version dynamically. - version= - ;; - esac - if test -n "$version"; then - echo "$package $version" - else - echo "$package" - fi - else - echo "$package" - fi - exit 0 - fi - fi - dir=`basename \`pwd\`` - case "$dir" in - i18n) - # This directory name, used in GNU make, is not the top level directory. - ;; - *[A-Za-z]*[0-9]*) - package=`echo "$dir" | sed -e 's/^\([^0-9]*\)[0-9].*$/\1/' -e 's/[-_]$//'` - if test -n "$want_version"; then - version=`echo "$dir" | sed -e 's/^[^0-9]*\([0-9].*\)$/\1/'` - echo "$package $version" - else - echo "$package" - fi - exit 0 - ;; - esac - # Go to parent directory - last=`/bin/pwd` - cd .. - curr=`/bin/pwd` - if test "$last" = "$curr"; then - # Oops, didn't find the package name. - if test -n "$want_version"; then - echo "PACKAGE VERSION" - else - echo "PACKAGE" - fi - exit 0 - fi -done diff --git a/libs/gettext/lib64/gettext/urlget.exe b/libs/gettext/lib64/gettext/urlget.exe deleted file mode 100644 index 8f1d6b405..000000000 Binary files a/libs/gettext/lib64/gettext/urlget.exe and /dev/null differ diff --git a/libs/gettext/lib64/gettext/user-email b/libs/gettext/lib64/gettext/user-email deleted file mode 100755 index 7d2d679bc..000000000 --- a/libs/gettext/lib64/gettext/user-email +++ /dev/null @@ -1,436 +0,0 @@ -#!/bin/sh -# Prints the user's email address, with confirmation from the user. -# -# Copyright (C) 2001-2003, 2005 Free Software Foundation, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# Prerequisites for using ${exec_prefix}/lib and ${datarootdir}/locale. -prefix="/usr/local/x86_64-w64-mingw32/stow/gettext-0.18.1.1" -exec_prefix="${prefix}" -datarootdir="${prefix}/share" -datadir="${datarootdir}" -# Set variables libdir, localedir. -libdir="${exec_prefix}/lib" -localedir="${datarootdir}/locale" - -# Support for relocatability. -if test "no" = yes; then - orig_installdir="$libdir"/gettext # see Makefile.am's install rule - # Determine curr_installdir without caring for symlinked callers. - curr_installdir=`echo "$0" | sed -e 's,/[^/]*$,,'` - curr_installdir=`cd "$curr_installdir" && pwd` - # Compute the original/current installation prefixes by stripping the - # trailing directories off the original/current installation directories. - while true; do - orig_last=`echo "$orig_installdir" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'` - curr_last=`echo "$curr_installdir" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'` - if test -z "$orig_last" || test -z "$curr_last"; then - break - fi - if test "$orig_last" != "$curr_last"; then - break - fi - orig_installdir=`echo "$orig_installdir" | sed -e 's,/[^/]*$,,'` - curr_installdir=`echo "$curr_installdir" | sed -e 's,/[^/]*$,,'` - done - # Now relocate the directory variables that we use. - libdir=`echo "$libdir/" | sed -e "s%^${orig_installdir}/%${curr_installdir}/%" | sed -e 's,/$,,'` - localedir=`echo "$localedir/" | sed -e "s%^${orig_installdir}/%${curr_installdir}/%" | sed -e 's,/$,,'` -fi - -# Internationalization. -. gettext.sh -TEXTDOMAIN=gettext-tools -export TEXTDOMAIN -TEXTDOMAINDIR="$localedir" -export TEXTDOMAINDIR - -# Redirect fileno 3 to interactive I/O. -exec 3>/dev/tty - -# Output a prompt. -if test $# != 0; then - echo "$1" 1>&3 -fi - -# Find the user name on the local machine. -user=`id -u -n 2>/dev/null` -if test -z "$user"; then - user="$USER" - if test -z "$user"; then - user="$LOGNAME" - if test -z "$user"; then - user=unknown - fi - fi -fi - -# Find the hostname. -# hostname on some systems (SVR3.2, old Linux) returns a bogus exit status, -# so uname gets run too, so we keep only the first line of output. -#host=`(hostname || uname -n) 2>/dev/null | sed 1q` -host=`"$libdir"/gettext/hostname --short 2>/dev/null | sed 1q` - -# Find the hostname. -hostfqdn=`"$libdir"/gettext/hostname --fqdn 2>/dev/null | sed 1q` - -# Find a list of email addresses from various mailer configuration files. -# All mailers use configuration files under $HOME. We handle them in a -# last-modified - first-priority order. -cd $HOME -files="" - -# ----------------------- BEGIN MAILER SPECIFIC CODE ----------------------- - -# Mozilla Thunderbird addresses -files="$files .thunderbird/*/prefs.js" - -# Mozilla addresses -files="$files .mozilla/*/prefs.js" - -# Netscape 4 addresses -files="$files .netscape/liprefs.js .netscape/preferences.js" - -# Netscape 3 addresses -files="$files .netscape/preferences" - -# Emacs/XEmacs rmail, Emacs/XEmacs gnus, XEmacs vm addresses -# XEmacs mew addresses -files="$files .emacs .emacs.el" - -# KDE2 addresses -files="$files .kde2/share/config/emaildefaults" - -# KDE kmail addresses -files="$files .kde2/share/config/kmailrc" - -# GNOME evolution 2 addresses -files="$files .gconf/apps/evolution/mail/%gconf.xml" - -# GNOME evolution 1 addresses -files="$files evolution/config.xmldb" - -# GNOME balsa addresses -files="$files .gnome/balsa" - -# StarOffice and OpenOffice addresses -sed_dos2unix='s/\r$//' -sed_soffice51='s,StarOffice 5\.1=\(.*\)$,\1/sofficerc,p' -sed_soffice52='s,StarOffice 5\.2=\(.*\)$,\1/user/sofficerc,p' -sed_ooffice='s,^OpenOffice[^=]*=\(.*\)$,\1/user/config/registry/instance/org/openoffice/UserProfile.xml,p' -files="$files Office51/sofficerc Office52/user/sofficerc "`sed -n -e "$sed_dos2unix" -e "$sed_soffice51" -e "$sed_soffice52" -e "$sed_ooffice" .sversionrc 2>/dev/null | sed -e 's,^file://*,/,'` - -# mutt addresses -files="$files .muttrc" - -# pine addresses -files="$files .pinerc" - -# xfmail addresses -files="$files .xfmail/.xfmailrc" - -# tkrat addresses -files="$files .ratatosk/ratatoskrc" - -# ----------------------- END MAILER SPECIFIC CODE ----------------------- - -# Expand wildcards and remove nonexistent files from the list. -nfiles="" -for file in $files; do - if test -r "$file" && test ! -d "$file"; then - nfiles="$nfiles $file" - fi -done -files="$nfiles" - -addresses="" - -if test -n "$files"; then - - for file in `ls -t $files`; do - - case "$file" in - -# ----------------------- BEGIN MAILER SPECIFIC CODE ----------------------- - - # Mozilla and Mozilla Thunderbird addresses - .mozilla/*/prefs.js | .thunderbird/*/prefs.js) - addresses="$addresses "`grep -h '^user_pref("mail\.identity\..*\.useremail", ".*");$' $file 2>/dev/null | sed -e 's/^user_pref("mail\.identity\..*\.useremail", "\(.*\)");$/\1/'` - ;; - - # Netscape 4 addresses - .netscape/liprefs.js | .netscape/preferences.js) - addresses="$addresses "`grep -h '^user_pref("mail\.identity\.useremail", ".*");$' $file 2>/dev/null | sed -e 's/^user_pref("mail\.identity\.useremail", "\(.*\)");$/\1/'` - ;; - - # Netscape 3 addresses - .netscape/preferences) - addresses="$addresses "`grep -h '^EMAIL_ADDRESS:' $file 2>/dev/null | sed -e 's/^EMAIL_ADDRESS:[ ]*//'` - ;; - - .emacs | .emacs.el) - # Emacs/XEmacs rmail, Emacs/XEmacs gnus, XEmacs vm addresses - addresses="$addresses "`grep -h '[ (]user-mail-address "[^"]*"' $file 2>/dev/null | sed -e 's/^.*[ (]user-mail-address "\([^"]*\)".*$/\1/'` - # XEmacs mew addresses - domains=`grep -h '[ (]mew-mail-domain "[^"]*"' $file 2>/dev/null | sed -e 's/^.*[ (]mew-mail-domain "\([^"]*\)".*$/\1/'` - if test -n "$domains"; then - for domain in $domains; do - addresses="$addresses ${user}@$domain" - done - fi - ;; - - # KDE2 addresses - .kde2/share/config/emaildefaults) - addresses="$addresses "`grep -h '^EmailAddress=' $file 2>/dev/null | sed -e 's/^EmailAddress=//'` - ;; - - # KDE kmail addresses - .kde2/share/config/kmailrc) - addresses="$addresses "`grep -h '^Email Address=' $file 2>/dev/null | sed -e 's/^Email Address=//'` - ;; - - # GNOME evolution 2 addresses - .gconf/apps/evolution/mail/%gconf.xml) - sedexpr0='s,^.*<addr-spec>\(.*\)</addr-spec>.*$,\1,p' - addresses="$addresses "`sed -n -e "$sedexpr0" < $file` - ;; - - # GNOME evolution 1 addresses - evolution/config.xmldb) - sedexpr0='s/^.*\(.*\).*$,\1,p' $file 2>/dev/null` - ;; - - # StarOffice addresses - # Not a typo. They really write "Adress" with a single d. - # German orthography... - */sofficerc) - addresses="$addresses "`grep -h '^User-Adress=' $file 2>/dev/null | sed -e 's/#[^#]*$//' -e 's/^.*#//'` - ;; - - # mutt addresses - .muttrc) - mutt_addresses=`grep -h '^set from="[^"]*"[ ]*$' $file 2>/dev/null | sed -e 's/^set from="\([^"]*\)"[ ]*$/\1/'` - if test -n "$mutt_addresses"; then - addresses="$addresses $mutt_addresses" - else - # mutt uses $EMAIL as fallback. - if test -n "$EMAIL"; then - addresses="$addresses $EMAIL" - fi - fi - ;; - - # pine addresses - .pinerc) - domains=`grep -h '^user-domain=' $file 2>/dev/null | sed -e 's/^user-domain=//'` - if test -n "$domains"; then - for domain in $domains; do - addresses="$addresses ${user}@$domain" - done - else - # The use-only-domain-name option is only used if the user-domain option is not present. - domains=`grep -h '^use-only-domain-name=' $file 2>/dev/null | sed -e 's/^use-only-domain-name=//'` - if test "Yes" = "$domains"; then - addresses="$addresses ${user}@"`echo "$hostfqdn" | sed -e 's/^[^.]*\.//'` - fi - fi - ;; - - # xfmail addresses - .xfmail/.xfmailrc) - addresses="$addresses "`grep -h '^from=.*<.*>' $file 2>/dev/null | sed -e 's/^.*<\([^<>]*\)>.*$/\1/'` - ;; - - # tkrat addresses - .ratatosk/ratatoskrc) - domains=`grep -h '^set option(masquerade_as) ' $file 2>/dev/null | sed -e 's/^set option(masquerade_as) //'` - if test -n "$domains"; then - for domain in $domains; do - addresses="$addresses ${user}@$domain" - done - else - # The domain option is used only if the masquerade_as option is not present. - domains=`grep -h '^set option(domain) ' $file 2>/dev/null | sed -e 's/^set option(domain) //'` - if test -n "$domains"; then - for domain in $domains; do - addresses="$addresses ${user}@${host}.$domain" - done - fi - fi - ;; - -# ----------------------- END MAILER SPECIFIC CODE ----------------------- - - esac - - done - -fi - -# Some Debian systems have a file /etc/mailname. -if test -r /etc/mailname; then - hostmailname=`cat /etc/mailname` - if test -n "$hostmailname"; then - addresses="$addresses ${user}@$hostmailname" - fi -fi - -# SuSE Linux >= 8.0 systems have a file /etc/sysconfig/mail. -if test -r /etc/sysconfig/mail; then - hostmailname=`. /etc/sysconfig/mail && echo "$FROM_HEADER"` - if test -n "$hostmailname"; then - addresses="$addresses ${user}@$hostmailname" - fi -fi - -# elm has no user-defined addresses. -# mailx has no user-defined addresses. -# mh has no user-defined addresses. -# They use the system default. -addresses="$addresses ${user}@$hostfqdn" - -# Normalize addresses: remove addresses without @, lowercase the part after @, -# and remove duplicates. -lowercase_sed='{ -h -s/^[^@]*@\(.*\)$/\1/ -y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ -x -s/^\([^@]*\)@.*/\1@/ -G -s/\ -// -p -}' -naddresses="" -for addr in $addresses; do - case "$addr" in - "<"*">") addr=`echo "$addr" | sed -e 's/^$//'` ;; - esac - case "$addr" in - *@*) - addr=`echo "$addr" | sed -n -e "$lowercase_sed"` - case " $naddresses " in - *" $addr "*) ;; - *) naddresses="$naddresses $addr" ;; - esac - ;; - esac -done -addresses="$naddresses" - -# Now it's time to ask the user. -case "$addresses" in - " "*" "*) - # At least two addresses. - lines="" - i=0 - for addr in $addresses; do - i=`expr $i + 1` - lines="${lines}${i} ${addr} -" - done - while true; do - { gettext "Which is your email address?"; echo; } 1>&3 - echo "$lines" 1>&3 - { gettext "Please choose the number, or enter your email address."; echo; } 1>&3 - read answer < /dev/tty - case "$answer" in - *@*) ;; - [0-9]*) - i=0 - for addr in $addresses; do - i=`expr $i + 1` - if test "$i" = "$answer"; then - break 2 - fi - done - ;; - esac - case "$answer" in - "<"*">") answer=`echo "$answer" | sed -e 's/^$//'` ;; - esac - case "$answer" in - *" "*) { gettext "Invalid email address: invalid character."; echo; echo; } 1>&3 ; continue ;; - *@*.*) ;; - *@*) { gettext "Invalid email address: need a fully qualified host name or domain name."; echo; echo; } 1>&3 ; continue ;; - *) { gettext "Invalid email address: missing @"; echo; echo; } 1>&3 ; continue ;; - esac - addr=`echo "$answer" | sed -n -e "$lowercase_sed"` - break - done - ;; - " "*) - # One address. - while true; do - { gettext "Is the following your email address?"; echo; } 1>&3 - echo " $addresses" 1>&3 - { gettext "Please confirm by pressing Return, or enter your email address."; echo; } 1>&3 - read answer < /dev/tty - if test -z "$answer"; then - addr=`echo "$addresses" | sed -e 's/^ //'` - break - fi - case "$answer" in - "<"*">") answer=`echo "$answer" | sed -e 's/^$//'` ;; - esac - case "$answer" in - *" "*) { gettext "Invalid email address: invalid character."; echo; echo; } 1>&3 ; continue ;; - *@*.*) ;; - *@*) { gettext "Invalid email address: need a fully qualified host name or domain name."; echo; echo; } 1>&3 ; continue ;; - *) { gettext "Invalid email address: missing @"; echo; echo; } 1>&3 ; continue ;; - esac - addr=`echo "$answer" | sed -n -e "$lowercase_sed"` - break - done - ;; - "") - # No address. - { gettext "Couldn't find out about your email address."; echo; } 1>&3 - while true; do - { gettext "Please enter your email address."; echo; } 1>&3 - read answer < /dev/tty - case "$answer" in - "<"*">") answer=`echo "$answer" | sed -e 's/^$//'` ;; - esac - case "$answer" in - *" "*) { gettext "Invalid email address: invalid character."; echo; echo; } 1>&3 ; continue ;; - *@*.*) ;; - *@*) { gettext "Invalid email address: need a fully qualified host name or domain name."; echo; echo; } 1>&3 ; continue ;; - *) { gettext "Invalid email address: missing @"; echo; echo; } 1>&3 ; continue ;; - esac - addr=`echo "$answer" | sed -n -e "$lowercase_sed"` - break - done - ;; - *) echo "internal error" 1>&3 ; exit 1 ;; -esac - -# Print to standard output. -echo "$addr" diff --git a/libs/gettext/lib64/libasprintf.a b/libs/gettext/lib64/libasprintf.a deleted file mode 100644 index 7988c40bf..000000000 Binary files a/libs/gettext/lib64/libasprintf.a and /dev/null differ diff --git a/libs/gettext/lib64/libgettextpo.a b/libs/gettext/lib64/libgettextpo.a deleted file mode 100644 index bf824d464..000000000 Binary files a/libs/gettext/lib64/libgettextpo.a and /dev/null differ diff --git a/libs/gettext/lib64/libintl.a b/libs/gettext/lib64/libintl.a deleted file mode 100644 index 42794ae61..000000000 Binary files a/libs/gettext/lib64/libintl.a and /dev/null differ diff --git a/src/Makefile b/src/Makefile index 9acfd6d3c..f97fa7e62 100644 --- a/src/Makefile +++ b/src/Makefile @@ -181,7 +181,8 @@ objdir:=$(makedir)/objs # very sophisticated dependency sources+=\ - $(call List,Sourcefile) + $(call List,Sourcefile)\ + $(call List,core/Sourcefile) sources+=\ $(call List,blua/Sourcefile) @@ -262,12 +263,10 @@ opts+=$(debug_opts) opts+=$(foreach v,$(passthru_opts),$(if $($(v)),-D$(v))) opts+=$(WFLAGS) $(CPPFLAGS) $(CFLAGS) -libs+=$(LDFLAGS) -lstdc++ -asflags:=$(ASFLAGS) -x assembler-with-cpp +cxxopts:=$(opts) $(CXXFLAGS) -std=c++17 -cxxopts:=$(opts) -cxxopts+=-std=c++17 -cxxopts+=$(CXXFLAGS) +libs+=$(LDFLAGS) -lstdc++ -lpthread +asflags:=$(ASFLAGS) -x assembler-with-cpp cc=$(CC) cxx=$(CXX) @@ -288,6 +287,7 @@ ifndef SILENT ifndef MAKE_RESTARTS ifndef destructive $(shell $(CC) -v) +#$(shell $(CXX) -v) define flags = SHELL ..... $(SHELL) @@ -315,6 +315,7 @@ endif LD:=$(CC) cc:=$(cc) $(opts) +cxx:=$(cxx) $(cxxopts) ifdef UPX upx=$(UPX) $(UPX_OPTS) endif @@ -377,19 +378,6 @@ endif $(.)$(cc) -MM -MF $$@ -MT $(objdir)/$$*.o $(2) $$< endef -# dependency recipe template (C++) -# 1: source file suffix -# 2: extra flags to gcc -define _recipecxx = -$(depdir)/%.d : %.$(1) | $$$$(@D)/ -ifndef WINDOWSHELL -ifdef Echo_name - @printf '%-20.20s\r' $$< -endif -endif - $(.)$(cxx) -MM -MF $$@ -MT $(objdir)/$$*.o $(2) $$< -endef - $(eval $(call _recipe,c)) $(eval $(call _recipe,cpp)) $(eval $(call _recipe,s,$(asflags))) diff --git a/src/Makefile.cfg b/src/Makefile.cfg deleted file mode 100644 index 2e407ac3f..000000000 --- a/src/Makefile.cfg +++ /dev/null @@ -1,589 +0,0 @@ -# vim: ft=make -# -# Makefile.cfg for SRB2 -# - -# -# GNU compiler & tools' flags -# and other things -# - -# See the following variable don't start with 'GCC'. This is -# to avoid a false positive with the version detection... - -SUPPORTED_GCC_VERSIONS:=\ - 151 150 15\ - 142 141 140 14\ - 132 131 130 13\ - 123 122 121 120 12\ - 114 113 112 111 110 11\ - 105 104 103 102 101 100 10\ - 95 94 93 92 91 90\ - 85 84 83 82 81 80\ - 75 74 73 72 71 70\ - 64 63 62 61 60\ - 55 54 53 52 51 50\ - 49 48 47 46 45 44 43 42 41 40 - -LATEST_GCC_VERSION=14.2.1 - -# gcc or g++ -ifdef PREFIX - CC:=$(PREFIX)-gcc - CXX:=$(PREFIX)-g++ - OBJCOPY?=$(PREFIX)-objcopy - OBJDUMP?=$(PREFIX)-objdump - STRIP?=$(PREFIX)-strip - WINDRES?=$(PREFIX)-windres -else - OBJCOPY?=objcopy - OBJDUMP?=objdump - STRIP?=strip - WINDRES?=windres -endif - -# because Apple screws with us on this -# need to get bintools from homebrew -ifdef MACOSX - CC=clang - CXX=clang - OBJCOPY=gobjcopy - OBJDUMP=gobjdump -endif - -# Automatically set version flag, but not if one was manually set -ifeq (,$(filter GCC%,$(.VARIABLES))) - version:=$(shell $(CC) --version) - # check if this is in fact GCC - ifneq (,$(or $(findstring gcc,$(version)),$(findstring GCC,$(version)))) - shellversion:=$(shell $(CC) -dumpversion) - - # Try to remove "-win32" - version:=$(subst -win32,.0,$(shellversion)) - - # Turn version into words of major, minor - v:=$(subst ., ,$(version)) - # concat. major minor - v:=$(word 1,$(v))$(word 2,$(v)) - - # If this version is not in the list, default to the latest supported - ifeq (,$(filter $(v),$(SUPPORTED_GCC_VERSIONS))) - $(info\ - Your compiler version, GCC $(version), is not supported by the Makefile.\ - The Makefile will assume GCC $(LATEST_GCC_VERSION).) - GCC$(subst .,,$(LATEST_GCC_VERSION))=1 - else - $(info Detected GCC $(version) (GCC$(v))) - GCC$(v)=1 - endif - endif -endif - -ifdef GCC151 -GCC150=1 -endif - -ifdef GCC15 -GCC150=1 -endif - -ifdef GCC150 -GCC142=1 -endif - -ifdef GCC142 -GCC141=1 -endif - -ifdef GCC141 -GCC140=1 -endif - -ifdef GCC14 -GCC140=1 -endif - -ifdef GCC140 -GCC132=1 -endif - -ifdef GCC132 -GCC131=1 -endif - -ifdef GCC131 -GCC130=1 -endif - -ifdef GCC13 -GCC130=1 -endif - -ifdef GCC130 -GCC123=1 -endif - -ifdef GCC123 -GCC122=1 -endif - -ifdef GCC122 -GCC121=1 -endif - -ifdef GCC121 -GCC120=1 -endif - -ifdef GCC12 -GCC120=1 -endif - -ifdef GCC120 -GCC114=1 -endif - -ifdef GCC114 -GCC113=1 -endif - -ifdef GCC113 -GCC112=1 -endif - -ifdef GCC112 -GCC111=1 -endif - -ifdef GCC111 -GCC110=1 -endif - -ifdef GCC11 -GCC110=1 -endif - -ifdef GCC110 -GCC105=1 -endif - -ifdef GCC105 -GCC104=1 -endif - -ifdef GCC104 -GCC103=1 -endif - -ifdef GCC103 -GCC102=1 -endif - -ifdef GCC102 -GCC101=1 -endif - -ifdef GCC101 -GCC100=1 -endif - -ifdef GCC10 -GCC100=1 -endif - -ifdef GCC100 -GCC93=1 -endif - -ifdef GCC95 -GCC94=1 -endif - -ifdef GCC94 -GCC93=1 -endif - -ifdef GCC93 -GCC92=1 -endif - -ifdef GCC92 -GCC91=1 -endif - -ifdef GCC91 -GCC90=1 -endif - -ifdef GCC90 -GCC85=1 -endif - -ifdef GCC85 -GCC84=1 -endif - -ifdef GCC84 -GCC83=1 -endif - -ifdef GCC83 -GCC82=1 -endif - -ifdef GCC82 -GCC81=1 -endif - -ifdef GCC81 -GCC80=1 -endif - -ifdef GCC80 -GCC75=1 -endif - -ifdef GCC75 -GCC74=1 -endif - -ifdef GCC74 -GCC73=1 -endif - -ifdef GCC73 -GCC72=1 -endif - -ifdef GCC72 -GCC71=1 -endif - -ifdef GCC71 -GCC70=1 -endif - -ifdef GCC70 -GCC64=1 -endif - -ifdef GCC64 -GCC63=1 -endif - -ifdef GCC63 -GCC62=1 -endif - -ifdef GCC62 -GCC61=1 -endif - -ifdef GCC61 -GCC60=1 -endif - -ifdef GCC60 -GCC55=1 -endif - -ifdef GCC55 -GCC54=1 -endif - -ifdef GCC54 -GCC53=1 -endif - -ifdef GCC53 -GCC52=1 -endif - -ifdef GCC52 -GCC51=1 -endif - -ifdef GCC51 -GCC50=1 -endif - -ifdef GCC50 -GCC49=1 -endif - -ifdef GCC49 -GCC48=1 -endif - -ifdef GCC48 -GCC47=1 -endif - -ifdef GCC47 -GCC46=1 -endif - -ifdef GCC46 -GCC45=1 -endif - -ifdef GCC45 -GCC44=1 -endif - -ifdef GCC44 -GCC43=1 -endif - -ifdef GCC43 -GCC42=1 -endif - -ifdef GCC42 -GCC41=1 -endif - -ifdef GCC41 -GCC40=1 -VCHELP=1 -endif - -ifdef GCC295 -GCC29=1 -endif - -OLDWFLAGS:=$(WFLAGS) -# -W -Wno-unused -WFLAGS=-Wall -ifndef GCC295 -#WFLAGS+=-Wno-packed -endif -ifndef RELAXWARNINGS - WFLAGS+=-W -#WFLAGS+=-Wno-sign-compare -ifndef GCC295 - WFLAGS+=-Wno-div-by-zero -endif -#WFLAGS+=-Wsystem-headers -WFLAGS+=-Wfloat-equal -#WFLAGS+=-Wtraditional -ifdef VCHELP - #WFLAGS+=-Wdeclaration-after-statement - WFLAGS+=-Wno-error=declaration-after-statement -endif - WFLAGS+=-Wundef -ifndef GCC295 - WFLAGS+=-Wendif-labels -endif -ifdef GCC41 - WFLAGS+=-Wshadow -endif -#WFLAGS+=-Wlarger-than-%len% - WFLAGS+=-Wpointer-arith -Wbad-function-cast -ifdef GCC45 -#WFLAGS+=-Wc++-compat -endif - WFLAGS+=-Wcast-qual -ifndef NOCASTALIGNWARN - WFLAGS+=-Wcast-align -endif - WFLAGS+=-Wwrite-strings -ifndef ERRORMODE -#WFLAGS+=-Wconversion -ifdef GCC43 - #WFLAGS+=-Wno-sign-conversion -endif -endif - WFLAGS+=-Wsign-compare -ifdef GCC45 - WFLAGS+=-Wlogical-op -endif - WFLAGS+=-Waggregate-return -ifdef HAIKU -ifdef GCC41 - #WFLAGS+=-Wno-attributes -endif -endif -#WFLAGS+=-Wstrict-prototypes -ifdef GCC40 - WFLAGS+=-Wold-style-definition -endif - WFLAGS+=-Wmissing-prototypes -Wmissing-declarations -ifdef GCC40 - WFLAGS+=-Wmissing-field-initializers -endif - WFLAGS+=-Wmissing-noreturn -#WFLAGS+=-Wmissing-format-attribute -#WFLAGS+=-Wno-multichar -#WFLAGS+=-Wno-deprecated-declarations -#WFLAGS+=-Wpacked -#WFLAGS+=-Wpadded -#WFLAGS+=-Wredundant-decls - WFLAGS+=-Wnested-externs -#WFLAGS+=-Wunreachable-code - WFLAGS+=-Winline -ifdef GCC43 - WFLAGS+=-funit-at-a-time - WFLAGS+=-Wlogical-op -endif -ifndef GCC295 - WFLAGS+=-Wdisabled-optimization -endif -endif -WFLAGS+=-Wformat-y2k -ifdef GCC71 -WFLAGS+=-Wno-error=format-overflow=2 -endif -WFLAGS+=-Wformat-security -ifndef GCC29 -#WFLAGS+=-Winit-self -endif -ifdef GCC46 -WFLAGS+=-Wno-suggest-attribute=noreturn -endif - -ifdef NOLDWARNING -LDFLAGS+=-Wl,--as-needed -endif - -ifdef ERRORMODE -WFLAGS+=-Werror -endif - -WFLAGS+=$(OLDWFLAGS) - -ifdef GCC43 - #WFLAGS+=-Wno-error=clobbered -endif -ifdef GCC44 - WFLAGS+=-Wno-error=array-bounds -endif -ifdef GCC46 - WFLAGS+=-Wno-error=suggest-attribute=noreturn -endif -ifdef GCC54 - WFLAGS+=-Wno-logical-op -Wno-error=logical-op -endif -ifdef GCC61 - WFLAGS+=-Wno-tautological-compare -Wno-error=tautological-compare -endif -ifdef GCC71 - WFLAGS+=-Wno-error=implicit-fallthrough - WFLAGS+=-Wno-implicit-fallthrough - WFLAGS+=-Wno-format-truncation -endif -ifdef GCC81 - WFLAGS+=-Wno-error=format-overflow - WFLAGS+=-Wno-error=stringop-truncation - WFLAGS+=-Wno-error=stringop-overflow - WFLAGS+=-Wno-format-overflow - WFLAGS+=-Wno-stringop-truncation - WFLAGS+=-Wno-stringop-overflow - WFLAGS+=-Wno-error=multistatement-macros -endif - -#indicate platform and what interface use with -ifndef LINUX -ifndef FREEBSD -ifndef CYGWIN32 -ifndef MINGW -ifndef MINGW64 -ifndef SDL -$(error No interface or platform flag defined) -endif -endif -endif -endif -endif -endif - -#determine the interface directory (where you put all i_*.c) -i_net_o=$(OBJDIR)/i_net.o -i_system_o=$(OBJDIR)/i_system.o -i_sound_o=$(OBJDIR)/i_sound.o -i_main_o=$(OBJDIR)/i_main.o -#set OBJDIR and BIN's starting place -OBJDIR=../objs -BIN=../bin -REMOVE?=rm -f -CP?=cp -MKDIR?=mkdir -p -MKISOFS?=mkisofs -DD?=dd -GZIP?=gzip -GZIP_OPTS?=-9 -f -n -GZIP_OPT2=$(GZIP_OPTS) --rsyncable -UPX?=upx -UPX_OPTS?=--best --preserve-build-id -ifndef ECHO -UPX_OPTS+=-q -endif - -#Interface Setup -ifdef LINUX - SDL=1 -ifdef LINUX64 - OBJDIR:=$(OBJDIR)/Linux64 - BIN:=$(BIN)/Linux64 -else - OBJDIR:=$(OBJDIR)/Linux - BIN:=$(BIN)/Linux -endif -else -ifdef FREEBSD - INTERFACE=sdl - SDL=1 - - OBJDIR:=$(OBJDIR)/FreeBSD - BIN:=$(BIN)/FreeBSD -else -ifdef SOLARIS - INTERFACE=sdl - SDL=1 - - OBJDIR:=$(OBJDIR)/Solaris - BIN:=$(BIN)/Solaris -else -ifdef CYGWIN32 - INTERFACE=sdl - SDL=1 - - OBJDIR:=$(OBJDIR)/cygwin - BIN:=$(BIN)/Cygwin -else -ifdef MINGW64 - INTERFACE=win32 - OBJDIR:=$(OBJDIR)/Mingw64 - BIN:=$(BIN)/Mingw64 -else -ifdef MINGW - INTERFACE=win32 - OBJDIR:=$(OBJDIR)/Mingw - BIN:=$(BIN)/Mingw -endif -endif -endif -endif -endif -endif - -ifdef ARCHNAME - OBJDIR:=$(OBJDIR)/$(ARCHNAME) - BIN:=$(BIN)/$(ARCHNAME) -endif - -OBJDUMP_OPTS?=--wide --source --line-numbers -LD=$(CC) - -ifdef SDL - INTERFACE=sdl - OBJDIR:=$(OBJDIR)/SDL -endif - -ifdef DEBUGMODE - OBJDIR:=$(OBJDIR)/Debug - BIN:=$(BIN)/Debug -else - OBJDIR:=$(OBJDIR)/Release - BIN:=$(BIN)/Release -endif diff --git a/src/Makefile.d/dedicated.mk b/src/Makefile.d/dedicated.mk index fef452467..a421b465d 100644 --- a/src/Makefile.d/dedicated.mk +++ b/src/Makefile.d/dedicated.mk @@ -4,8 +4,6 @@ sources+=$(call List,dedicated/Sourcefile) opts+=-DDEDICATED -libs+=-lpthread - ifdef MINGW libs+=-mconsole endif diff --git a/src/Makefile.d/sdl.mk b/src/Makefile.d/sdl.mk index 9f2074d9d..c704a83eb 100644 --- a/src/Makefile.d/sdl.mk +++ b/src/Makefile.d/sdl.mk @@ -10,8 +10,8 @@ makedir:=$(makedir)/SDL -sources+=$(call List,sdl/Sourcefile) opts+=-DDIRECTFULLSCREEN -DHAVE_SDL +sources+=$(call List,sdl/Sourcefile) NOUPNP=1 diff --git a/src/Makefile.d/versions.mk b/src/Makefile.d/versions.mk index a3cdbbd4b..ce23c3e4e 100644 --- a/src/Makefile.d/versions.mk +++ b/src/Makefile.d/versions.mk @@ -16,6 +16,9 @@ $(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\ $(and $(findstring =,$(v)),\ $(eval $(call _predecessor,$(subst =, ,$(v)))))) +# aggregate returns seem to happen alot in c++ so just supress em lel +CXXFLAGS+= -Wno-aggregate-return + # -W -Wno-unused ifdef GCC150 diff --git a/src/Sourcefile b/src/Sourcefile index 227e6c95a..f3cc487c1 100644 --- a/src/Sourcefile +++ b/src/Sourcefile @@ -13,6 +13,7 @@ f_finale.c f_wipe.c filesrch.c g_game.c +g_demo.c g_input.c hu_stuff.c i_tcp.c @@ -49,14 +50,15 @@ r_bsp.c r_data.c r_draw.c r_fps.c -r_main.c +r_main.cpp r_patch.c r_patchrotation.c -r_plane.c -r_segs.c +r_plane.cpp +r_segs.cpp +r_skins.c r_sky.c r_splats.c -r_things.c +r_things.cpp r_portal.c p_ceilng.c p_enemy.c @@ -77,6 +79,7 @@ p_tick.c p_user.c k_director.c k_kart.c +k_hud.c k_stats.c lua_baselib.c lua_blockmaplib.c diff --git a/src/am_map.c b/src/am_map.c index 11b3796b0..fe0b5e9a5 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -341,7 +341,7 @@ static void AM_FrameBufferInit(void) f_x = f_y = 0; f_w = vid.width; f_h = vid.height; - am_buf = screens[0]; + am_buf = vid.screens[0]; } // diff --git a/src/android/i_video.c b/src/android/i_video.c index 8b4bee314..4db66afe0 100644 --- a/src/android/i_video.c +++ b/src/android/i_video.c @@ -46,7 +46,6 @@ INT32 VID_SetMode(INT32 modenum) vid.modenum = 0; vid.width = 320; vid.height = 240; - vid.bpp = 1; vid.buffer = android_surface; return 0; } diff --git a/src/blua/lauxlib.c b/src/blua/lauxlib.c index aad72ca41..e898e38d6 100644 --- a/src/blua/lauxlib.c +++ b/src/blua/lauxlib.c @@ -133,26 +133,26 @@ LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) { - if (!lua_checkstack(L, space)) + if (l_unlikely(!lua_checkstack(L, space))) luaL_error(L, "stack overflow (%s)", mes); } LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) { - if (lua_type(L, narg) != t) + if (l_unlikely(lua_type(L, narg) != t)) tag_error(L, narg, t); } LUALIB_API void luaL_checkany (lua_State *L, int narg) { - if (lua_type(L, narg) == LUA_TNONE) + if (l_unlikely(lua_type(L, narg) == LUA_TNONE)) luaL_argerror(L, narg, "value expected"); } LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) { const char *s = lua_tolstring(L, narg, len); - if (!s) tag_error(L, narg, LUA_TSTRING); + if (l_unlikely(!s)) tag_error(L, narg, LUA_TSTRING); return s; } @@ -170,7 +170,7 @@ LUALIB_API const char *luaL_optlstring (lua_State *L, int narg, LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) { lua_Number d = lua_tonumber(L, narg); - if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ + if (l_unlikely(d == 0 && !lua_isnumber(L, narg))) /* avoid extra test when d is not 0 */ tag_error(L, narg, LUA_TNUMBER); return d; } diff --git a/src/blua/lauxlib.h b/src/blua/lauxlib.h index 87c41ba61..c8555a557 100644 --- a/src/blua/lauxlib.h +++ b/src/blua/lauxlib.h @@ -102,7 +102,7 @@ LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx, */ #define luaL_argcheck(L, cond,numarg,extramsg) \ - ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) + ((void)(l_likely(cond) || luaL_argerror(L, (numarg), (extramsg)))) #define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) #define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) #define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) diff --git a/src/blua/lbaselib.c b/src/blua/lbaselib.c index 3c919cb64..8d2272d03 100644 --- a/src/blua/lbaselib.c +++ b/src/blua/lbaselib.c @@ -106,7 +106,7 @@ static int luaB_setmetatable (lua_State *L) { luaL_checktype(L, 1, LUA_TTABLE); luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, "nil or table expected"); - if (luaL_getmetafield(L, 1, "__metatable")) + if (l_unlikely(luaL_getmetafield(L, 1, "__metatable"))) luaL_error(L, "cannot change a protected metatable"); lua_settop(L, 2); lua_setmetatable(L, 1); @@ -120,10 +120,10 @@ static void getfunc (lua_State *L, int opt) { lua_Debug ar; int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1); luaL_argcheck(L, level >= 0, 1, "level must be non-negative"); - if (lua_getstack(L, level, &ar) == 0) + if (l_unlikely(lua_getstack(L, level, &ar) == 0)) luaL_argerror(L, 1, "invalid level"); lua_getinfo(L, "f", &ar); - if (lua_isnil(L, -1)) + if (l_unlikely(lua_isnil(L, -1))) luaL_error(L, "no function environment for tail call at level %d", level); } @@ -151,7 +151,7 @@ static int luaB_setfenv (lua_State *L) { lua_setfenv(L, -2); return 0; } - else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0) + else if (l_unlikely(lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0)) luaL_error(L, LUA_QL("setfenv") " cannot change environment of given object"); return 1; @@ -265,7 +265,7 @@ static int luaB_ipairs (lua_State *L) { static int luaB_assert (lua_State *L) { luaL_checkany(L, 1); - if (!lua_toboolean(L, 1)) + if (l_unlikely(!lua_toboolean(L, 1))) return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!")); return lua_gettop(L); } @@ -278,7 +278,7 @@ static int luaB_unpack (lua_State *L) { e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1)); if (i > e) return 0; /* empty range */ n = e - i + 1; /* number of elements */ - if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */ + if (l_unlikely(n <= 0 || !lua_checkstack(L, n))) /* n <= 0 means arith. overflow */ return luaL_error(L, "too many results to unpack"); lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */ while (i++ < e) /* push arg[i + 1...e] */ @@ -445,9 +445,9 @@ static int luaB_costatus (lua_State *L) { static int auxresume (lua_State *L, lua_State *co, int narg) { int status = costatus(L, co); - if (!lua_checkstack(co, narg)) + if (l_unlikely(!lua_checkstack(co, narg))) luaL_error(L, "too many arguments to resume"); - if (status != CO_SUS) { + if (l_unlikely(status != CO_SUS)) { lua_pushfstring(L, "cannot resume %s coroutine", statnames[status]); return -1; /* error flag */ } @@ -456,7 +456,7 @@ static int auxresume (lua_State *L, lua_State *co, int narg) { status = lua_resume(co, narg); if (status == 0 || status == LUA_YIELD) { int nres = lua_gettop(co); - if (!lua_checkstack(L, nres + 1)) + if (l_unlikely(!lua_checkstack(L, nres + 1))) luaL_error(L, "too many results to resume"); lua_xmove(co, L, nres); /* move yielded values */ return nres; diff --git a/src/blua/ldblib.c b/src/blua/ldblib.c index 2eacef929..28f7c42bf 100644 --- a/src/blua/ldblib.c +++ b/src/blua/ldblib.c @@ -73,7 +73,7 @@ static int db_getinfo (lua_State *L) { } else return luaL_argerror(L, arg+1, "function or level expected"); - if (!lua_getinfo(L1, options, &ar)) + if (l_unlikely(!lua_getinfo(L1, options, &ar))) return luaL_argerror(L, arg+2, "invalid option"); lua_createtable(L, 0, 2); if (strchr(options, 'S')) { @@ -104,7 +104,7 @@ static int db_getlocal (lua_State *L) { lua_State *L1 = getthread(L, &arg); lua_Debug ar; const char *name; - if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ + if (l_unlikely(!lua_getstack(L1, luaL_checkint(L, arg+1), &ar))) /* out of range? */ return luaL_argerror(L, arg+1, "level out of range"); name = lua_getlocal(L1, &ar, luaL_checkint(L, arg+2)); if (name) { diff --git a/src/blua/ldo.c b/src/blua/ldo.c index 7470a79b7..ad8a32694 100644 --- a/src/blua/ldo.c +++ b/src/blua/ldo.c @@ -172,7 +172,7 @@ void luaD_reallocCI (lua_State *L, int newsize) { void luaD_growstack (lua_State *L, int n) { - if (n <= L->stacksize) /* double size is enough? */ + if (l_likely(n <= L->stacksize)) /* double size is enough? */ luaD_reallocstack(L, 2*L->stacksize); else luaD_reallocstack(L, L->stacksize + n); @@ -180,11 +180,11 @@ void luaD_growstack (lua_State *L, int n) { static CallInfo *growCI (lua_State *L) { - if (L->size_ci > LUAI_MAXCALLS) /* overflow while handling overflow? */ + if (l_unlikely(L->size_ci > LUAI_MAXCALLS)) /* overflow while handling overflow? */ luaD_throw(L, LUA_ERRERR); else { luaD_reallocCI(L, 2*L->size_ci); - if (L->size_ci > LUAI_MAXCALLS) + if (l_unlikely(L->size_ci > LUAI_MAXCALLS)) luaG_runerror(L, "stack overflow"); } return ++L->ci; @@ -257,7 +257,7 @@ static StkId tryfuncTM (lua_State *L, StkId func) { const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL); StkId p; ptrdiff_t funcr = savestack(L, func); - if (!ttisfunction(tm)) + if (l_unlikely(!ttisfunction(tm))) luaG_typeerror(L, func, "call"); /* Open a hole inside the stack at `func' */ for (p = L->top; p > func; p--) setobjs2s(L, p, p-1); @@ -356,7 +356,7 @@ int luaD_poscall (lua_State *L, StkId firstResult) { StkId res; int wanted, i; CallInfo *ci; - if (L->hookmask & LUA_MASKRET) + if (l_unlikely(L->hookmask) & LUA_MASKRET) firstResult = callrethooks(L, firstResult); ci = L->ci--; res = ci->func; /* res == final position of 1st result */ @@ -380,7 +380,7 @@ int luaD_poscall (lua_State *L, StkId firstResult) { ** function position. */ void luaD_call (lua_State *L, StkId func, int nResults) { - if (++L->nCcalls >= LUAI_MAXCCALLS) { + if (l_unlikely(++L->nCcalls >= LUAI_MAXCCALLS)) { if (L->nCcalls == LUAI_MAXCCALLS) luaG_runerror(L, "C stack overflow"); else if (L->nCcalls >= (LUAI_MAXCCALLS + (LUAI_MAXCCALLS>>3))) @@ -430,15 +430,15 @@ static int resume_error (lua_State *L, const char *msg) { LUA_API int lua_resume (lua_State *L, int nargs) { int status; lua_lock(L); - if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci)) + if (l_unlikely(L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci))) return resume_error(L, "cannot resume non-suspended coroutine"); - if (L->nCcalls >= LUAI_MAXCCALLS) + if (l_unlikely(L->nCcalls >= LUAI_MAXCCALLS)) return resume_error(L, "C stack overflow"); luai_userstateresume(L, nargs); lua_assert(L->errfunc == 0); L->baseCcalls = ++L->nCcalls; status = luaD_rawrunprotected(L, resume, L->top - nargs); - if (status != 0) { /* error? */ + if (l_unlikely(status != 0)) { /* error? */ L->status = cast_byte(status); /* mark thread as `dead' */ luaD_seterrorobj(L, status, L->top); L->ci->top = L->top; @@ -456,7 +456,7 @@ LUA_API int lua_resume (lua_State *L, int nargs) { LUA_API int lua_yield (lua_State *L, int nresults) { luai_userstateyield(L, nresults); lua_lock(L); - if (L->nCcalls > L->baseCcalls) + if (l_unlikely(L->nCcalls > L->baseCcalls)) luaG_runerror(L, "attempt to yield across metamethod/C-call boundary"); L->base = L->top - nresults; /* protect stack slots below */ L->status = LUA_YIELD; @@ -474,7 +474,7 @@ int luaD_pcall (lua_State *L, Pfunc func, void *u, ptrdiff_t old_errfunc = L->errfunc; L->errfunc = ef; status = luaD_rawrunprotected(L, func, u); - if (status != 0) { /* an error occurred? */ + if (l_unlikely(status != 0)) { /* an error occurred? */ StkId oldtop = restorestack(L, old_top); luaF_close(L, oldtop); /* close eventual pending closures */ luaD_seterrorobj(L, status, oldtop); @@ -511,8 +511,8 @@ static void f_parser (lua_State *L, void *ud) { tf = ((c == LUA_SIGNATURE[0]) ? luaU_undump : luaY_parser)(L, p->z, &p->buff, p->name); #else - if (c == LUA_SIGNATURE[0]) - luaG_runerror(L, "invalid format, cannot load bytecode scripts"); + if (l_unlikely(c == LUA_SIGNATURE[0])) + luaG_runerror(L, "invalid format, cannot load bytecode scripts"); tf = luaY_parser(L, p->z, &p->buff, p->name); #endif cl = luaF_newLclosure(L, tf->nups, hvalue(gt(L))); diff --git a/src/blua/ldo.h b/src/blua/ldo.h index 29364965f..baaa1301c 100644 --- a/src/blua/ldo.h +++ b/src/blua/ldo.h @@ -14,7 +14,7 @@ #define luaD_checkstack(L,n) \ - if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \ + if (l_unlikely((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue))) \ luaD_growstack(L, n); \ else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); diff --git a/src/blua/liolib.c b/src/blua/liolib.c index 2d69f45cd..40e3e4582 100644 --- a/src/blua/liolib.c +++ b/src/blua/liolib.c @@ -84,7 +84,7 @@ static int io_type (lua_State *L) { static FILE *tofile (lua_State *L) { FILE **f = tofilep(L); - if (*f == NULL) + if (l_unlikely(*f == NULL)) luaL_error(L, "attempt to use a closed file"); return *f; } @@ -184,8 +184,8 @@ static int io_open (lua_State *L) { break; } } - if (strstr(filename, "..") || strchr(filename, ':') || StartsWith(filename, "\\") - || StartsWith(filename, "/") || !pass) + if (l_unlikely(strstr(filename, "..") || strchr(filename, ':') || StartsWith(filename, "\\") + || StartsWith(filename, "/") || !pass)) { luaL_error(L,"access denied to %s", filename); return pushresult(L,0,filename); @@ -202,7 +202,7 @@ static int io_open (lua_State *L) { { *splitter = 0; I_mkdir(destFilename, 0755); - *splitter = '/'; + *splitter = '/'; splitter++; forward = strchr(splitter, '/'); @@ -226,7 +226,7 @@ static FILE *getiofile (lua_State *L, int findex) { FILE *f; lua_rawgeti(L, LUA_ENVIRONINDEX, findex); f = *(FILE **)lua_touserdata(L, -1); - if (f == NULL) + if (l_unlikely(f == NULL)) luaL_error(L, "standard %s file is closed", fnames[findex - 1]); return f; } @@ -238,7 +238,7 @@ static int g_iofile (lua_State *L, int f, const char *mode) { if (filename) { FILE **pf = newfile(L); *pf = fopen(filename, mode); - if (*pf == NULL) + if (l_unlikely(*pf == NULL)) fileerror(L, 1, filename); } else { @@ -290,7 +290,7 @@ static int io_lines (lua_State *L) { const char *filename = luaL_checkstring(L, 1); FILE **pf = newfile(L); *pf = fopen(filename, "r"); - if (*pf == NULL) + if (l_unlikely(*pf == NULL)) fileerror(L, 1, filename); aux_lines(L, lua_gettop(L), 1); return 1; @@ -307,7 +307,7 @@ static int io_lines (lua_State *L) { static int read_number (lua_State *L, FILE *f) { lua_Number d; - if (fscanf(f, LUA_NUMBER_SCAN, &d) == 1) { + if (l_likely(fscanf(f, LUA_NUMBER_SCAN, &d) == 1)) { lua_pushnumber(L, d); return 1; } @@ -454,7 +454,7 @@ static int g_write (lua_State *L, FILE *f, int arg) { else { size_t l; const char *s = luaL_checklstring(L, arg, &l); - if (ftell(f) + l > FILELIMIT) + if (l_unlikely(ftell(f) + l > FILELIMIT)) { luaL_error(L,"write limit bypassed in file. Changes have been discarded."); break; @@ -483,7 +483,7 @@ static int f_seek (lua_State *L) { int op = luaL_checkoption(L, 2, "cur", modenames); long offset = luaL_optlong(L, 3, 0); op = fseek(f, offset, mode[op]); - if (op) + if (l_unlikely(op)) return pushresult(L, 0, NULL); /* error */ else { lua_pushinteger(L, ftell(f)); diff --git a/src/blua/lmem.c b/src/blua/lmem.c index 1b9bed658..a49d3dce1 100644 --- a/src/blua/lmem.c +++ b/src/blua/lmem.c @@ -48,7 +48,7 @@ void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, void *newblock; int newsize; if (*size >= limit/2) { /* cannot double it? */ - if (*size >= limit) /* cannot grow even a little? */ + if (l_unlikely(*size >= limit)) /* cannot grow even a little? */ luaG_runerror(L, errormsg); newsize = limit; /* still have at least one free place */ } @@ -77,7 +77,7 @@ void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { global_State *g = G(L); lua_assert((osize == 0) == (block == NULL)); block = (*g->frealloc)(g->ud, block, osize, nsize); - if (block == NULL && nsize > 0) + if (l_unlikely(block == NULL && nsize > 0)) luaD_throw(L, LUA_ERRMEM); lua_assert((nsize == 0) == (block == NULL)); g->totalbytes = (g->totalbytes - osize) + nsize; diff --git a/src/blua/lparser.c b/src/blua/lparser.c index 3f392ae7b..871c9730d 100644 --- a/src/blua/lparser.c +++ b/src/blua/lparser.c @@ -103,7 +103,7 @@ static void checknext (LexState *ls, int c) { static void check_match (LexState *ls, int what, int who, int where) { - if (!testnext(ls, what)) { + if (l_unlikely(!testnext(ls, what))) { if (where == ls->linenumber) error_expected(ls, what); else { @@ -275,7 +275,7 @@ static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) { static void enterlevel (LexState *ls) { - if (++ls->L->nCcalls > LUAI_MAXCCALLS) + if (l_unlikely(++ls->L->nCcalls > LUAI_MAXCCALLS)) luaX_lexerror(ls, "chunk has too many syntax levels", 0); } @@ -643,7 +643,7 @@ static void funcargs (LexState *ls, expdesc *f) { int line = ls->linenumber; switch (ls->t.token) { case '(': { /* funcargs -> `(' [ explist1 ] `)' */ - if (line != ls->lastline) + if (l_unlikely(line != ls->lastline)) luaX_syntaxerror(ls,"ambiguous syntax (function call x new statement)"); luaX_next(ls); if (ls->t.token == ')') /* arg list is empty? */ @@ -712,7 +712,7 @@ static void prefixexp (LexState *ls, expdesc *v) { case '$': { lua_Number i = ls->t.seminfo.r; if (i == 0) i = ls->fs->nrhs; - if (i <= 0 || i > ls->fs->nlhs) + if (l_unlikely(i <= 0 || i > ls->fs->nlhs)) luaX_syntaxerror(ls, "pseudo-variable out of range or not in assignment"); else { expdesc_list *lhs = ls->fs->lhs; @@ -1105,7 +1105,7 @@ static void breakstat (LexState *ls, lua_Number n) { upval |= bl->upval; bl = bl->previous; } - if (!bl) + if (l_unlikely(!bl)) luaX_syntaxerror(ls, "no loop to break"); if (upval) luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0); @@ -1124,7 +1124,7 @@ static void continuestat (LexState *ls) { //upval |= bl->upval; // AK: ADDITION (would this fix forbody probs?) bl = bl->previous; } - if (!bl) + if (l_unlikely(!bl)) luaX_syntaxerror(ls, "no loop to continue"); //if (upval) //AK: experimental diff --git a/src/blua/lstring.c b/src/blua/lstring.c index afc851d0c..0bcc30877 100644 --- a/src/blua/lstring.c +++ b/src/blua/lstring.c @@ -83,7 +83,7 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { o != NULL; o = o->gch.next) { TString *ts = rawgco2ts(o); - if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) { + if (l_unlikely(ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0))) { /* string may be dead */ if (isdead(G(L), o)) changewhite(o); return ts; @@ -95,7 +95,7 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { Udata *luaS_newudata (lua_State *L, size_t s, Table *e) { Udata *u; - if (s > MAX_SIZET - sizeof(Udata)) + if (l_unlikely(s > MAX_SIZET - sizeof(Udata))) luaM_toobig(L); u = cast(Udata *, luaM_malloc(L, s + sizeof(Udata))); u->uv.marked = luaC_white(G(L)); /* is not finalized */ diff --git a/src/blua/lstrlib.c b/src/blua/lstrlib.c index 297504e95..e2fd23604 100644 --- a/src/blua/lstrlib.c +++ b/src/blua/lstrlib.c @@ -113,7 +113,7 @@ static int str_byte (lua_State *L) { if ((size_t)pose > l) pose = l; if (posi > pose) return 0; /* empty interval; return no values */ n = (int)(pose - posi + 1); - if (posi + n <= pose) /* overflow? */ + if (l_unlikely(posi + n <= pose)) /* overflow? */ luaL_error(L, "string slice too long"); luaL_checkstack(L, n, "string slice too long"); for (i=0; i= ms->level || ms->capture[l].len == CAP_UNFINISHED) + if (l_unlikely(l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED)) return luaL_error(ms->L, "invalid capture index"); return l; } @@ -204,14 +204,14 @@ static int capture_to_close (MatchState *ms) { static const char *classend (MatchState *ms, const char *p) { switch (*p++) { case L_ESC: { - if (*p == '\0') + if (l_unlikely(*p == '\0')) luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")"); return p+1; } case '[': { if (*p == '^') p++; do { /* look for a `]' */ - if (*p == '\0') + if (l_unlikely(*p == '\0')) luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")"); if (*(p++) == L_ESC && *p != '\0') p++; /* skip escapes (e.g. `%]') */ @@ -282,7 +282,7 @@ static const char *match (MatchState *ms, const char *s, const char *p); static const char *matchbalance (MatchState *ms, const char *s, const char *p) { - if (*p == 0 || *(p+1) == 0) + if (l_unlikely(*p == 0 || *(p+1) == 0)) luaL_error(ms->L, "unbalanced pattern"); if (*s != *p) return NULL; else { @@ -332,7 +332,8 @@ static const char *start_capture (MatchState *ms, const char *s, const char *p, int what) { const char *res; int level = ms->level; - if (level >= LUA_MAXCAPTURES) luaL_error(ms->L, "too many captures"); + if (l_unlikely(level >= LUA_MAXCAPTURES)) + luaL_error(ms->L, "too many captures"); ms->capture[level].init = s; ms->capture[level].len = what; ms->level = level+1; @@ -386,7 +387,7 @@ static const char *match (MatchState *ms, const char *s, const char *p) { case 'f': { /* frontier? */ const char *ep; char previous; p += 2; - if (*p != '[') + if (l_unlikely(*p != '[')) luaL_error(ms->L, "missing " LUA_QL("[") " after " LUA_QL("%%f") " in pattern"); ep = classend(ms, p); /* points to what is next */ @@ -468,14 +469,15 @@ static const char *lmemfind (const char *s1, size_t l1, static void push_onecapture (MatchState *ms, int i, const char *s, const char *e) { if (i >= ms->level) { - if (i == 0) /* ms->level == 0, too */ + if (l_likely(i == 0)) /* ms->level == 0, too */ lua_pushlstring(ms->L, s, e - s); /* add whole match */ else luaL_error(ms->L, "invalid capture index"); } else { ptrdiff_t l = ms->capture[i].len; - if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture"); + if (l_unlikely(l == CAP_UNFINISHED)) + luaL_error(ms->L, "unfinished capture"); if (l == CAP_POSITION) lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1); else @@ -637,7 +639,7 @@ static void add_value (MatchState *ms, luaL_Buffer *b, const char *s, lua_pop(L, 1); lua_pushlstring(L, s, e - s); /* keep original text */ } - else if (!lua_isstring(L, -1)) + else if (l_unlikely(!lua_isstring(L, -1))) luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1)); luaL_addvalue(b); /* add result to accumulator */ } @@ -727,7 +729,7 @@ static void addquoted (lua_State *L, luaL_Buffer *b, int arg) { static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { const char *p = strfrmt; while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */ - if ((size_t)(p - strfrmt) >= sizeof(FLAGS)) + if (l_unlikely((size_t)(p - strfrmt) >= sizeof(FLAGS))) luaL_error(L, "invalid format (repeated flags)"); if (isdigit(uchar(*p))) p++; /* skip width */ if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ @@ -736,7 +738,7 @@ static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { if (isdigit(uchar(*p))) p++; /* skip precision */ if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ } - if (isdigit(uchar(*p))) + if (l_unlikely(isdigit(uchar(*p)))) luaL_error(L, "invalid format (width or precision too long)"); *(form++) = '%'; strncpy(form, strfrmt, p - strfrmt + 1); diff --git a/src/blua/ltable.c b/src/blua/ltable.c index 0ddd9ef4f..b21bc4bfa 100644 --- a/src/blua/ltable.c +++ b/src/blua/ltable.c @@ -278,7 +278,7 @@ static void setnodevector (lua_State *L, Table *t, int size) { else { int i; lsize = ceillog2(size); - if (lsize > MAXBITS) + if (l_unlikely(lsize > MAXBITS)) luaG_runerror(L, "table overflow"); size = twoto(lsize); t->node = luaM_newvector(L, size, Node); @@ -498,8 +498,9 @@ TValue *luaH_set (lua_State *L, Table *t, const TValue *key) { if (p != luaO_nilobject) return cast(TValue *, p); else { - if (ttisnil(key)) luaG_runerror(L, "table index is nil"); - else if (ttisnumber(key) && luai_numisnan(nvalue(key))) + if (l_unlikely(ttisnil(key))) + luaG_runerror(L, "table index is nil"); + else if (l_unlikely(ttisnumber(key) && luai_numisnan(nvalue(key)))) luaG_runerror(L, "table index is NaN"); return newkey(L, t, key); } diff --git a/src/blua/ltablib.c b/src/blua/ltablib.c index 2dd157155..5f4ead74a 100644 --- a/src/blua/ltablib.c +++ b/src/blua/ltablib.c @@ -134,7 +134,7 @@ static int tremove (lua_State *L) { static void addfield (lua_State *L, luaL_Buffer *b, int i) { lua_rawgeti(L, 1, i); - if (!lua_isstring(L, -1)) + if (l_unlikely(!lua_isstring(L, -1))) luaL_error(L, "invalid value (%s) at index %d in table for " LUA_QL("concat"), luaL_typename(L, -1), i); luaL_addvalue(b); @@ -224,12 +224,14 @@ static void auxsort (lua_State *L, int l, int u) { for (;;) { /* invariant: a[l..i] <= P <= a[j..u] */ /* repeat ++i until a[i] >= P */ while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) { - if (i>u) luaL_error(L, "invalid order function for sorting"); + if (l_unlikely(i>u)) + luaL_error(L, "invalid order function for sorting"); lua_pop(L, 1); /* remove a[i] */ } /* repeat --j until a[j] <= P */ while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) { - if (j +#if defined(__GNUC__) +#define l_likely(x) (__builtin_expect(((x) != 0), 1)) +#define l_unlikely(x) (__builtin_expect(((x) != 0), 0)) +#else +#define l_likely(x) (x) +#define l_unlikely(x) (x) +#endif + +#endif + /* ** Local configuration. You can use this space to add your redefinitions ** without modifying the main part of the file. diff --git a/src/blua/lvm.c b/src/blua/lvm.c index c6269966c..02d2265c1 100644 --- a/src/blua/lvm.c +++ b/src/blua/lvm.c @@ -119,7 +119,7 @@ void luaV_gettable (lua_State *L, TValue *t, TValue *key, StkId val) { } /* else will try the tag method */ } - else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX))) + else if (l_unlikely(ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))) luaG_typeerror(L, t, "index"); if (ttisfunction(tm)) { callTMres(L, val, tm, t, key); @@ -147,7 +147,7 @@ void luaV_settable (lua_State *L, TValue *t, TValue *key, StkId val) { } /* else will try the tag method */ } - else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX))) + else if (l_unlikely(ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))) luaG_typeerror(L, t, "index"); if (ttisfunction(tm)) { callTM(L, tm, t, key, val); @@ -293,7 +293,8 @@ void luaV_concat (lua_State *L, int total, int last) { /* collect total length */ for (n = 1; n < total && tostring(L, top-n-1); n++) { size_t l = tsvalue(top-n-1)->len; - if (l >= MAX_SIZET - tl) luaG_runerror(L, "string length overflow"); + if (l_unlikely(l >= MAX_SIZET - tl)) + luaG_runerror(L, "string length overflow"); tl += l; } buffer = luaZ_openspace(L, &G(L)->buff, tl); @@ -322,8 +323,8 @@ static void Arith (lua_State *L, StkId ra, TValue *rb, case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break; case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break; case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break; - case TM_DIV: if (nc == 0) { luaG_runerror(L, "divide by zero error"); } else setnvalue(ra, luai_numdiv(nb, nc)); break; - case TM_MOD: if (nc == 0) { luaG_runerror(L, "modulo by zero error"); } else setnvalue(ra, luai_nummod(nb, nc)); break; + case TM_DIV: if (l_unlikely(nc == 0)) { luaG_runerror(L, "divide by zero error"); } else setnvalue(ra, luai_numdiv(nb, nc)); break; + case TM_MOD: if (l_unlikely(nc == 0)) { luaG_runerror(L, "modulo by zero error"); } else setnvalue(ra, luai_nummod(nb, nc)); break; case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break; case TM_UNM: setnvalue(ra, luai_numunm(nb)); break; case TM_AND: setnvalue(ra, luai_numand(nb, nc)); break; @@ -491,7 +492,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { TValue *rc = RKC(i); if (ttisnumber(rb) && ttisnumber(rc)) { lua_Number nb = nvalue(rb), nc = nvalue(rc); - if (nc == 0) { + if (l_unlikely(nc == 0)) { luaG_runerror(L, "divide by zero error"); } else @@ -506,7 +507,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { TValue *rc = RKC(i); if (ttisnumber(rb) && ttisnumber(rc)) { lua_Number nb = nvalue(rb), nc = nvalue(rc); - if (nc == 0) { + if (l_unlikely(nc == 0)) { luaG_runerror(L, "modulo by zero error"); } else @@ -580,7 +581,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { } default: { /* try metamethod */ Protect( - if (!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN)) + if (l_unlikely(!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN))) luaG_typeerror(L, rb, "get length of"); ) } @@ -724,11 +725,11 @@ void luaV_execute (lua_State *L, int nexeccalls) { const TValue *plimit = ra+1; const TValue *pstep = ra+2; L->savedpc = pc; /* next steps may throw errors */ - if (!tonumber(init, ra)) + if (l_unlikely(!tonumber(init, ra))) luaG_runerror(L, LUA_QL("for") " initial value must be a number"); - else if (!tonumber(plimit, ra+1)) + else if (l_unlikely(!tonumber(plimit, ra+1))) luaG_runerror(L, LUA_QL("for") " limit must be a number"); - else if (!tonumber(pstep, ra+2)) + else if (l_unlikely(!tonumber(pstep, ra+2))) luaG_runerror(L, LUA_QL("for") " step must be a number"); if (ra && pstep) setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep))); diff --git a/src/byteptr.h b/src/byteptr.h index 0345038b8..205884acc 100644 --- a/src/byteptr.h +++ b/src/byteptr.h @@ -28,6 +28,7 @@ #define WRITEUINT8(p,b) do { UINT8 *p_tmp = (void *)p; const UINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITESINT8(p,b) do { SINT8 *p_tmp = (void *)p; const SINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITEINT16(p,b) do { INT16 *p_tmp = (void *)p; const INT16 tv = ( INT16)(b); memcpy(p, &tv, sizeof( INT16)); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEINT16_2(p,b) do { INT16 *p_tmp = ( INT16 *)p; const INT16 tv = ( INT16)(b); memcpy(p, &tv, sizeof( INT16)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0) // dumb hack for mumble #define WRITEUINT16(p,b) do { UINT16 *p_tmp = (void *)p; const UINT16 tv = ( UINT16)(b); memcpy(p, &tv, sizeof( UINT16)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITEINT32(p,b) do { INT32 *p_tmp = (void *)p; const INT32 tv = ( INT32)(b); memcpy(p, &tv, sizeof( INT32)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITEUINT32(p,b) do { UINT32 *p_tmp = (void *)p; const UINT32 tv = ( UINT32)(b); memcpy(p, &tv, sizeof( UINT32)); p_tmp++; p = (void *)p_tmp; } while (0) @@ -38,6 +39,7 @@ #define WRITEUINT8(p,b) do { UINT8 *p_tmp = ( UINT8 *)p; *p_tmp = ( UINT8)(b); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITESINT8(p,b) do { SINT8 *p_tmp = ( SINT8 *)p; *p_tmp = ( SINT8)(b); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITEINT16(p,b) do { INT16 *p_tmp = ( INT16 *)p; *p_tmp = ( INT16)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEINT16_2(p,b) do { INT16 *p_tmp = ( INT16 *)p; *p_tmp = ( INT16)(b); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0) // dumb hack for mumble #define WRITEUINT16(p,b) do { UINT16 *p_tmp = ( UINT16 *)p; *p_tmp = ( UINT16)(b); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITEINT32(p,b) do { INT32 *p_tmp = ( INT32 *)p; *p_tmp = ( INT32)(b); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITEUINT32(p,b) do { UINT32 *p_tmp = ( UINT32 *)p; *p_tmp = ( UINT32)(b); p_tmp++; p = (void *)p_tmp; } while (0) diff --git a/src/command.h b/src/command.h index 2276a0ae2..6d1944f9a 100644 --- a/src/command.h +++ b/src/command.h @@ -13,6 +13,10 @@ #ifndef __COMMAND_H__ #define __COMMAND_H__ +#ifdef __cplusplus +extern "C" { +#endif + #include #include "doomdef.h" @@ -189,4 +193,8 @@ UINT8 CV_CheatsEnabled(void); // Returns cvar by name. Exposed here for Lua. consvar_t *CV_FindVar(const char *name); +#ifdef __cplusplus +} // extern "C" +#endif + #endif // __COMMAND_H__ diff --git a/src/console.c b/src/console.c index 8c1824456..bb86d444b 100644 --- a/src/console.c +++ b/src/console.c @@ -1321,13 +1321,6 @@ void CONS_Debug(INT32 debugflags, const char *fmt, ...) // void CONS_Error(const char *msg) { -#ifdef RPC_NO_WINDOWS_H - if (!graphics_started) - { - MessageBoxA(vid.WndParent, msg, "SRB2Kart Warning", MB_OK); - return; - } -#endif CONS_Printf("\x82%s", msg); // write error msg in different colour CONS_Printf(M_GetText("Press ENTER to continue\n")); diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt new file mode 100644 index 000000000..db8bc5a15 --- /dev/null +++ b/src/core/CMakeLists.txt @@ -0,0 +1 @@ +target_sourcefile(cpp) diff --git a/src/core/Sourcefile b/src/core/Sourcefile new file mode 100644 index 000000000..e8701d507 --- /dev/null +++ b/src/core/Sourcefile @@ -0,0 +1,2 @@ +memory.cpp +thread_pool.cpp diff --git a/src/core/memory.cpp b/src/core/memory.cpp new file mode 100644 index 000000000..e75cf91f7 --- /dev/null +++ b/src/core/memory.cpp @@ -0,0 +1,71 @@ +// BLANKART +//----------------------------------------------------------------------------- +// Copyright (C) 2024 by Ronald "Eidolon" Kinard +// Copyright (C) 2024 by Kart Krew +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- + +#include "memory.h" + +#include +#include + +#include "../z_zone.h" + +namespace +{ + +class LinearMemory +{ + size_t size_; + size_t height_; + void* memory_; + +public: + constexpr explicit LinearMemory(size_t size) noexcept; + + void* allocate(size_t size); + void reset() noexcept; +}; + +constexpr LinearMemory::LinearMemory(size_t size) noexcept : size_(size), height_{0}, memory_{nullptr} {} + +void* LinearMemory::allocate(size_t size) +{ + size_t aligned_size = (size + 15) & ~15; + if (height_ + aligned_size > size_) + { + throw std::bad_alloc(); + } + + if (memory_ == nullptr) + { + memory_ = Z_Malloc(size_, PU_STATIC, nullptr); + } + + void* ptr = (void*)((uintptr_t)(memory_) + height_); + height_ += aligned_size; + return ptr; +} + +void LinearMemory::reset() noexcept +{ + height_ = 0; +} + +} // namespace + +static LinearMemory g_frame_memory {4 * 1024 * 1024}; + +void* Z_Frame_Alloc(size_t size) +{ + return g_frame_memory.allocate(size); +} + +void Z_Frame_Reset() +{ + g_frame_memory.reset(); +} diff --git a/src/core/memory.h b/src/core/memory.h new file mode 100644 index 000000000..ba49e3d51 --- /dev/null +++ b/src/core/memory.h @@ -0,0 +1,32 @@ +// BLANKART +//----------------------------------------------------------------------------- +// Copyright (C) 2024 by Ronald "Eidolon" Kinard +// Copyright (C) 2024 by Kart Krew +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- + +#ifndef __SRB2_CORE_MEMORY_H__ +#define __SRB2_CORE_MEMORY_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif // __cpluspplus + +/// @brief Allocate a block of memory with a lifespan of the current main-thread frame. +/// This function is NOT thread-safe, but the allocated memory may be used across threads. +/// @return a pointer to a block of memory aligned with libc malloc alignment, or null if allocation fails +void* Z_Frame_Alloc(size_t size); + +/// @brief Resets per-frame memory. Not thread safe. +void Z_Frame_Reset(void); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif // __SRB2_CORE_MEMORY_H__ diff --git a/src/core/spmc_queue.hpp b/src/core/spmc_queue.hpp new file mode 100644 index 000000000..d85e1300d --- /dev/null +++ b/src/core/spmc_queue.hpp @@ -0,0 +1,192 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +// This class is derived from Conor Williams' implementation of a concurrent deque +// https://github.com/ConorWilliams/ConcurrentDeque +// Copyright (C) 2021 Conor Williams + +// The original version was for C++23. This one has been shrunk slightly and adapted to our conventions. + +#ifndef __SRB2_CORE_SPMC_QUEUE_HPP__ +#define __SRB2_CORE_SPMC_QUEUE_HPP__ + +#include +#include +#include +#include +#include + +//#include + +#include "../cxxutil.hpp" + +namespace srb2 +{ + +template +class SpMcQueue +{ + struct RingBuff { + public: + explicit RingBuff(int64_t cap) : _cap{cap}, _mask{cap - 1} + { + SRB2_ASSERT(cap && (!(cap & (cap - 1))) && "Capacity must be buf power of 2!"); + _buff = std::unique_ptr(new T[_cap]); + } + + std::int64_t capacity() const noexcept { return _cap; } + + // Store (copy) at modulo index + void store(int64_t i, T&& x) noexcept + { + _buff[i & _mask] = std::move(x); + } + + // Load (copy) at modulo index + T load(int64_t i) const noexcept + { + return _buff[i & _mask]; + } + + // Allocates and returns a new ring buffer, copies elements in range [b, t) into the new buffer. + RingBuff* resize(std::int64_t b, std::int64_t t) const + { + //ZoneScoped; + RingBuff* ptr = new RingBuff{2 * _cap}; + for (std::int64_t i = t; i != b; ++i) { + ptr->store(i, load(i)); + } + return ptr; + } + + private: + int64_t _cap; // Capacity of the buffer + int64_t _mask; // Bit mask to perform modulo capacity operations + + std::unique_ptr _buff; + }; + + alignas(64) std::atomic bottom_; + alignas(64) std::atomic top_; + alignas(64) std::atomic buffer_; + + std::vector> garbage_; + +public: + SpMcQueue(size_t capacity) : bottom_(0), top_(0), buffer_(new RingBuff(capacity)) + { + garbage_.reserve(32); + } + ~SpMcQueue() noexcept + { + delete buffer_.load(std::memory_order_relaxed); + }; + + size_t size() const noexcept + { + int64_t bottom = bottom_.load(std::memory_order_relaxed); + int64_t top = top_.load(std::memory_order_relaxed); + return static_cast(bottom >= top ? bottom - top : 0); + } + + bool empty() const noexcept + { + return size() == 0; + } + + void push(T&& v) noexcept + { + int64_t bottom = bottom_.load(std::memory_order_relaxed); + int64_t top = top_.load(std::memory_order_acquire); + RingBuff* buf = buffer_.load(std::memory_order_relaxed); + + if (buf->capacity() < (bottom - top) + 1) + { + // Queue is full, build a new one + RingBuff* newbuf = buf->resize(bottom, top); + garbage_.emplace_back(buf); + buffer_.store(newbuf, std::memory_order_relaxed); + buf = newbuf; + } + + // Construct new object, this does not have to be atomic as no one can steal this item until after we + // store the new value of bottom, ordering is maintained by surrounding atomics. + buf->store(bottom, std::move(v)); + + std::atomic_thread_fence(std::memory_order_release); + bottom_.store(bottom + 1, std::memory_order_relaxed); + } + + std::optional pop() noexcept + { + int64_t bottom = bottom_.load(std::memory_order_relaxed) - 1; + RingBuff* buf = buffer_.load(std::memory_order_relaxed); + + bottom_.store(bottom, std::memory_order_relaxed); // Stealers can no longer steal + + std::atomic_thread_fence(std::memory_order_seq_cst); + int64_t top = top_.load(std::memory_order_relaxed); + + if (top <= bottom) + { + // Non-empty deque + if (top == bottom) + { + // The last item could get stolen, by a stealer that loaded bottom before our write above + if (!top_.compare_exchange_strong(top, top + 1, std::memory_order_seq_cst, std::memory_order_relaxed)) + { + // Failed race, thief got the last item. + bottom_.store(bottom + 1, std::memory_order_relaxed); + return std::nullopt; + } + bottom_.store(bottom + 1, std::memory_order_relaxed); + } + + // Can delay load until after acquiring slot as only this thread can push(), this load is not + // required to be atomic as we are the exclusive writer. + return buf->load(bottom); + + } + else + { + bottom_.store(bottom + 1, std::memory_order_relaxed); + return std::nullopt; + } + } + + std::optional steal() noexcept + { + int64_t top = top_.load(std::memory_order_acquire); + std::atomic_thread_fence(std::memory_order_seq_cst); + int64_t bottom = bottom_.load(std::memory_order_acquire); + + if (top < bottom) + { + // Must load *before* acquiring the slot as slot may be overwritten immediately after acquiring. + // This load is NOT required to be atomic even-though it may race with an overrite as we only + // return the value if we win the race below garanteeing we had no race during our read. If we + // loose the race then 'x' could be corrupt due to read-during-write race but as T is trivially + // destructible this does not matter. + T x = buffer_.load(std::memory_order_consume)->load(top); + + if (!top_.compare_exchange_strong(top, top + 1, std::memory_order_seq_cst, std::memory_order_relaxed)) + { + return std::nullopt; + } + + return x; + + } + else + { + return std::nullopt; + } + } +}; + +} // namespace srb2 + +#endif // __SRB2_CORE_SPMC_QUEUE_HPP__ diff --git a/src/core/static_vec.hpp b/src/core/static_vec.hpp new file mode 100644 index 000000000..a5a529564 --- /dev/null +++ b/src/core/static_vec.hpp @@ -0,0 +1,255 @@ +// BLANKART +//----------------------------------------------------------------------------- +// Copyright (C) 2024 by Ronald "Eidolon" Kinard +// Copyright (C) 2024 by Kart Krew +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- + +#ifndef __SRB2_CORE_STATIC_VEC_HPP__ +#define __SRB2_CORE_STATIC_VEC_HPP__ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../cxxutil.hpp" + +namespace srb2 +{ + +template +class StaticVec; + +template +class StaticVec +{ + std::array arr_ {{}}; + size_t size_ = 0; + +public: + using value_type = T; + + constexpr StaticVec() {} + + StaticVec(const StaticVec& rhs) + { + for (size_t i = size_; i > 0; i--) + { + arr_[i] = T(); + } + size_ = rhs.size(); + for (size_t i = 0; i < size_; i++) + { + arr_[i] = rhs.arr_[i]; + } + } + + StaticVec(StaticVec&& rhs) noexcept(std::is_nothrow_move_assignable_v) + { + for (size_t i = size_; i > 0; i--) + { + arr_[i] = T(); + } + size_ = rhs.size(); + for (size_t i = 0; i < size_; i++) + { + arr_[i] = std::move(rhs.arr_[i]); + } + while (rhs.size() > 0) + { + rhs.pop_back(); + } + } + + constexpr StaticVec(std::initializer_list list) noexcept(std::is_nothrow_move_assignable_v) + { + size_ = list.size(); + size_t i = 0; + for (auto itr = list.begin(); itr != list.end(); itr++) + { + arr_[i] = *itr; + i++; + } + } + + ~StaticVec() = default; + + StaticVec& operator=(const StaticVec& rhs) + { + for (size_t i = size_; i > 0; i--) + { + arr_[i] = T(); + } + size_ = rhs.size(); + for (size_t i = 0; i < size_; i++) + { + arr_[i] = rhs.arr_[i]; + } + return *this; + } + + StaticVec& operator=(StaticVec&& rhs) noexcept(std::is_nothrow_move_constructible_v) + { + for (size_t i = size_; i > 0; i--) + { + arr_[i] = T(); + } + size_ = rhs.size(); + for (size_t i = 0; i < size_; i++) + { + arr_[i] = std::move(rhs.arr_[i]); + } + while (rhs.size() > 0) + { + rhs.pop_back(); + } + return *this; + } + + void push_back(const T& value) { arr_[size_++] = value; } + + void pop_back() { arr_[--size_] = T(); } + + void resize(size_t size, T value = T()) + { + if (size >= Limit) + { + throw std::length_error("new size >= Capacity"); + } + + if (size == size_) + { + return; + } + else if (size < size_) + { + while (size_ > size) + { + pop_back(); + } + } + else + { + while (size_ < size) + { + push_back(value); + } + } + } + + void clear() + { + arr_ = {{}}; + size_ = 0; + } + + using iterator = typename std::array::iterator; + using const_iterator = typename std::array::const_iterator; + + constexpr iterator begin() noexcept { return arr_.begin(); } + + constexpr const_iterator begin() const noexcept { return arr_.cbegin(); } + + constexpr const_iterator cbegin() const noexcept { return arr_.cbegin(); } + + constexpr iterator end() noexcept { return std::next(arr_.begin(), size_); } + + constexpr const_iterator end() const noexcept { return cend(); } + + constexpr const_iterator cend() const noexcept { return std::next(arr_.cbegin(), size_); } + + constexpr std::reverse_iterator rbegin() noexcept { return std::reverse_iterator(this->end()); } + + constexpr std::reverse_iterator crbegin() const noexcept { return std::reverse_iterator(this->cend()); } + + constexpr std::reverse_iterator rend() noexcept { return std::reverse_iterator(this->begin()); } + + constexpr std::reverse_iterator crend() const noexcept { return std::reverse_iterator(this->cbegin()); } + + constexpr bool empty() const noexcept { return size_ == 0; } + + constexpr size_t size() const noexcept { return size_; } + + constexpr size_t capacity() const noexcept { return Limit; } + + constexpr size_t max_size() const noexcept { return Limit; } + + constexpr T& operator[](size_t index) noexcept { return arr_[index]; } + + T& at(size_t index) + { + if (index >= size_) + { + throw std::out_of_range("index >= size"); + } + return this[index]; + } + + constexpr const T& operator[](size_t index) const noexcept { return arr_[index]; } + + const T& at(size_t index) const + { + if (index >= size_) + { + throw std::out_of_range("index >= size"); + } + return this[index]; + } + + T& front() { return *arr_[0]; } + + T& back() { return *arr_[size_ - 1]; } +}; + +} // namespace srb2 + +template +bool operator==(const srb2::StaticVec& lhs, const srb2::StaticVec& rhs) +{ + const size_t size = lhs.size(); + if (size != rhs.size()) + { + return false; + } + for (size_t i = 0; i < lhs; i++) + { + if (rhs[i] != lhs[i]) + { + return false; + } + } + return true; +} + +template +bool operator!=(const srb2::StaticVec& lhs, const srb2::StaticVec& rhs) +{ + return !(lhs == rhs); +} + +template +struct std::hash> +{ + size_t operator()(const srb2::StaticVec& input) const + { + constexpr size_t prime = sizeof(size_t) == 8 ? 0x00000100000001B3 : 0x01000193; + constexpr size_t basis = sizeof(size_t) == 8 ? 0xcbf29ce484222325 : 0x811c9dc5; + + size_t ret = basis; + for (auto itr = input.begin(); itr != input.end(); itr++) + { + ret = (ret * prime) ^ std::hash(*itr); + } + return ret; + } +}; + +#endif // __SRB2_CORE_STATIC_VEC_HPP__ diff --git a/src/core/thread_pool.cpp b/src/core/thread_pool.cpp new file mode 100644 index 000000000..11aa6f1bb --- /dev/null +++ b/src/core/thread_pool.cpp @@ -0,0 +1,346 @@ +// BLANKART +//----------------------------------------------------------------------------- +// Copyright (C) 2024 by Ronald "Eidolon" Kinard +// Copyright (C) 2024 by Kart Krew +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- + +#include "thread_pool.h" + +#include +#include +#include +#include +#include +#include + +//#include +//#include + +#include "../cxxutil.hpp" +#include "../m_argv.h" + +using namespace srb2; + +static void do_work(ThreadPool::Task& work) +{ + try + { + //ZoneScoped; + (work.thunk)(work.raw.data()); + } + catch (...) + { + // can't do anything + } + + (work.deleter)(work.raw.data()); + if (work.pseudosema) + { + work.pseudosema->fetch_sub(1, std::memory_order_relaxed); + } +} + +static void pool_executor( + //int thread_index, + std::shared_ptr> pool_alive, + std::shared_ptr worker_ready_mutex, + std::shared_ptr worker_ready_condvar, + std::shared_ptr my_wq, + std::vector> other_wqs +) +{ + { + //std::string thread_name = fmt::format("Thread Pool Thread {}", thread_index); + //tracy::SetThreadName(thread_name.c_str()); + } + + int spins = 0; + while (true) + { + std::optional work = my_wq->steal(); + bool did_work = false; + if (work) + { + do_work(*work); + + did_work = true; + spins = 0; + } + else + { + for (auto& q : other_wqs) + { + work = q->steal(); + if (work) + { + do_work(*work); + + did_work = true; + spins = 0; + + // We only want to steal one work item at a time, to prioritize our own queue + break; + } + } + } + + if (!did_work) + { + // Spin a few loops to avoid yielding, then wait for the ready lock + spins += 1; + if (spins > 100) + { + std::unique_lock ready_lock {*worker_ready_mutex}; + while (my_wq->empty() && pool_alive->load()) + { + worker_ready_condvar->wait(ready_lock); + } + + if (!pool_alive->load()) + { + break; + } + } + } + } +} + +ThreadPool::ThreadPool() +{ + immediate_mode_ = true; +} + +ThreadPool::ThreadPool(size_t threads) +{ + next_queue_index_ = 0; + pool_alive_ = std::make_shared>(true); + + for (size_t i = 0; i < threads; i++) + { + std::shared_ptr wsq = std::make_shared(2048); + work_queues_.push_back(wsq); + + std::shared_ptr mutex = std::make_shared(); + worker_ready_mutexes_.push_back(std::move(mutex)); + std::shared_ptr condvar = std::make_shared(); + worker_ready_condvars_.push_back(std::move(condvar)); + } + + for (size_t i = 0; i < threads; i++) + { + std::shared_ptr my_queue = work_queues_[i]; + std::vector> other_queues; + for (size_t j = 0; j < threads; j++) + { + // Order the other queues starting from the next adjacent worker + // i.e. if this is worker 2 of 8, then other queues is 3, 4, 5, 6, 7, 0, 1 + // This tries to balance out work stealing behavior + + size_t other_index = j + i; + if (other_index >= threads) + { + other_index -= threads; + } + + if (other_index != i) + { + other_queues.push_back(work_queues_[other_index]); + } + } + + std::thread thread; + try + { + thread = std::thread + { + pool_executor, + //i, + pool_alive_, + worker_ready_mutexes_[i], + worker_ready_condvars_[i], + my_queue, + other_queues + }; + } + catch (const std::system_error& error) + { + // Safe shutdown and rethrow + pool_alive_->store(false); + for (auto& t : threads_) + { + t.join(); + } + throw error; + } + + threads_.push_back(std::move(thread)); + } +} + +ThreadPool::ThreadPool(ThreadPool&&) = default; +ThreadPool::~ThreadPool() = default; + +ThreadPool& ThreadPool::operator=(ThreadPool&&) = default; + +void ThreadPool::begin_sema() +{ + sema_begun_ = true; +} + +ThreadPool::Sema ThreadPool::end_sema() +{ + Sema ret = Sema(std::move(cur_sema_)); + cur_sema_ = nullptr; + sema_begun_ = false; + return ret; +} + +void ThreadPool::notify() +{ + for (size_t i = 0; i < work_queues_.size(); i++) + { + auto& q = work_queues_[i]; + size_t count = q->size(); + if (count > 0) + { + worker_ready_condvars_[i]->notify_one(); + } + } +} + +void ThreadPool::notify_sema(const ThreadPool::Sema& sema) +{ + if (!sema.pseudosema_) + { + return; + } + notify(); +} + +void ThreadPool::wait_idle() +{ + if (immediate_mode_) + { + return; + } + + //ZoneScoped; + + for (size_t i = 0; i < work_queues_.size(); i++) + { + auto& q = work_queues_[i]; + + std::optional work; + while ((work = q->pop()).has_value()) + { + do_work(*work); + } + } +} + +void ThreadPool::wait_sema(const Sema& sema) +{ + if (!sema.pseudosema_) + { + return; + } + + //ZoneScoped; + + while (sema.pseudosema_->load(std::memory_order_seq_cst) > 0) + { + // spin to win + for (size_t i = 0; i < work_queues_.size(); i++) + { + auto& q = work_queues_[i]; + + std::optional work; + if ((work = q->pop()).has_value()) + { + do_work(*work); + break; + } + } + } + + if (sema.pseudosema_->load(std::memory_order_seq_cst) != 0) + { + throw std::exception(); + } +} + +void ThreadPool::shutdown() +{ + if (immediate_mode_) + { + return; + } + + wait_idle(); + + pool_alive_->store(false); + + for (auto& condvar : worker_ready_condvars_) + { + condvar->notify_all(); + } + for (auto& t : threads_) + { + t.join(); + } +} + +std::unique_ptr srb2::g_main_threadpool; + +void I_ThreadPoolInit(void) +{ + SRB2_ASSERT(g_main_threadpool == nullptr); + size_t thread_count = std::min(static_cast(9), std::thread::hardware_concurrency()); + if (thread_count > 1) + { + // The main thread will act as a worker when waiting for pool idle + // Make one less worker thread to avoid unnecessary context switching + thread_count -= 1; + } + + if (M_CheckParm("-singlethreaded")) + { + g_main_threadpool = std::make_unique(); + } + else + { + g_main_threadpool = std::make_unique(thread_count); + } +} + +void I_ThreadPoolShutdown(void) +{ + if (!g_main_threadpool) + { + return; + } + + g_main_threadpool->shutdown(); + g_main_threadpool = nullptr; +} + +void I_ThreadPoolSubmit(srb2cthunk_t thunk, void* data) +{ + SRB2_ASSERT(g_main_threadpool != nullptr); + + g_main_threadpool->schedule([=]() { + (thunk)(data); + }); + g_main_threadpool->notify(); +} + +void I_ThreadPoolWaitIdle(void) +{ + SRB2_ASSERT(g_main_threadpool != nullptr); + + g_main_threadpool->wait_idle(); +} diff --git a/src/core/thread_pool.h b/src/core/thread_pool.h new file mode 100644 index 000000000..75961614e --- /dev/null +++ b/src/core/thread_pool.h @@ -0,0 +1,163 @@ +// BLANKART +//----------------------------------------------------------------------------- +// Copyright (C) 2024 by Ronald "Eidolon" Kinard +// Copyright (C) 2024 by Kart Krew +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- + +#ifndef __SRB2_CORE_THREAD_POOL_H__ +#define __SRB2_CORE_THREAD_POOL_H__ + +#include + +#ifdef __cplusplus + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "spmc_queue.hpp" + +namespace srb2 +{ + +class ThreadPool +{ +public: + struct Task + { + void (*thunk)(void*); + void (*deleter)(void*); + std::shared_ptr> pseudosema; + std::array>)> raw; + }; + + using Queue = SpMcQueue; + + class Sema + { + std::shared_ptr> pseudosema_; + + explicit Sema(std::shared_ptr> sema) : pseudosema_(sema) {} + + friend class ThreadPool; + public: + Sema() = default; + }; + +private: + std::shared_ptr> pool_alive_; + std::vector> worker_ready_mutexes_; + std::vector> worker_ready_condvars_; + std::vector> work_queues_; + std::vector threads_; + size_t next_queue_index_ = 0; + std::shared_ptr> cur_sema_; + + bool immediate_mode_ = false; + bool sema_begun_ = false; + +public: + ThreadPool(); + explicit ThreadPool(size_t threads); + ThreadPool(const ThreadPool&) = delete; + ThreadPool(ThreadPool&&); + ~ThreadPool(); + + ThreadPool& operator=(const ThreadPool&) = delete; + ThreadPool& operator=(ThreadPool&&); + + void begin_sema(); + ThreadPool::Sema end_sema(); + + /// Enqueue but don't notify + template void schedule(T&& thunk); + /// Notify threads after several schedules + void notify(); + void notify_sema(const Sema& sema); + void wait_idle(); + void wait_sema(const Sema& sema); + void shutdown(); +}; + +extern std::unique_ptr g_main_threadpool; + +template +void callable_caller(F* f) +{ + (*f)(); +} + +template +void callable_destroyer(F* f) +{ + f->~F(); +} + +template +void ThreadPool::schedule(T&& thunk) +{ + static_assert(sizeof(T) <= sizeof(std::declval().raw)); + + if (immediate_mode_) + { + (thunk)(); + return; + } + + if (sema_begun_) + { + if (cur_sema_ == nullptr) + { + cur_sema_ = std::make_shared>(0); + } + cur_sema_->fetch_add(1, std::memory_order_relaxed); + } + + size_t qi = next_queue_index_; + + { + std::shared_ptr q = work_queues_[qi]; + Task task; + task.thunk = reinterpret_cast(callable_caller); + task.deleter = reinterpret_cast(callable_destroyer); + task.pseudosema = cur_sema_; + new (reinterpret_cast(task.raw.data())) T(std::move(thunk)); + + q->push(std::move(task)); + } + // worker_ready_condvars_[qi]->notify_one(); + + next_queue_index_ += 1; + if (next_queue_index_ >= threads_.size()) + { + next_queue_index_ = 0; + } +} + +} // namespace srb2 + +extern "C" { + +#endif // __cplusplus + +typedef void (*srb2cthunk_t)(void*); + +void I_ThreadPoolInit(void); +void I_ThreadPoolShutdown(void); +void I_ThreadPoolSubmit(srb2cthunk_t thunk, void* data); +void I_ThreadPoolWaitIdle(void); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // __SRB2_CORE_THREAD_POOL_H__ diff --git a/src/cxxutil.hpp b/src/cxxutil.hpp new file mode 100644 index 000000000..545d38dfd --- /dev/null +++ b/src/cxxutil.hpp @@ -0,0 +1,152 @@ +#ifndef __SRB2_CXXUTIL_HPP__ +#define __SRB2_CXXUTIL_HPP__ + +#include +#include +#include + +#include "doomdef.h" + +namespace srb2 { + +template +class Finally { +public: + explicit Finally(const F& f) noexcept : f_(f) {} + explicit Finally(F&& f) noexcept : f_(f) {} + + Finally(Finally&& from) noexcept : f_(std::move(from.f_)), call_(std::exchange(from.call_, false)) {} + + Finally(const Finally& from) = delete; + void operator=(const Finally& from) = delete; + void operator=(Finally&& from) = delete; + + ~Finally() noexcept { + if (call_) + f_(); + } + +private: + F f_; + bool call_ = true; +}; + +template +Finally> finally(F&& f) noexcept { + return Finally {std::forward(f)}; +} + +struct SourceLocation { + const char* file_name; + unsigned int line_number; +}; + +#define SRB2_SOURCE_LOCATION \ + srb2::SourceLocation { __FILE__, __LINE__ } + +#ifndef SRB2_ASSERT_HANDLER +#define SRB2_ASSERT_HANDLER srb2::IErrorAssertHandler +#endif + +#if !defined(NDEBUG) || defined(PARANOIA) +// An assertion level of 2 will activate all invocations of the SRB2_ASSERT macro +#define SRB2_ASSERTION_LEVEL 2 +#else +// The minimum assertion level is 1 +#define SRB2_ASSERTION_LEVEL 1 +#endif + +/// Assert a precondition expression in debug builds. +#define SRB2_ASSERT(expr) srb2::do_assert<2, SRB2_ASSERT_HANDLER>([&] { return (expr); }, SRB2_SOURCE_LOCATION, #expr) + +class IErrorAssertHandler { +public: + static void handle(const SourceLocation& source_location, const char* expression) { + I_Error("Assertion failed at %s:%u: %s != true", + source_location.file_name, + source_location.line_number, + expression); + } +}; + +class NoOpAssertHandler { +public: + static void handle(const SourceLocation& source_location, const char* expression) {(void)source_location; (void)expression;} +}; + +/// @brief Assert a precondition expression, aborting the application if it fails. +/// @tparam Expr +/// @tparam Level the level of this assertion; if it is less than or equal to SRB2_ASSERTION_LEVEL, this overload will +/// activate. +/// @param expr a callable which returns a bool +/// @param source_location a struct containing the source location of the assertion, e.g. SRB2_SOURCE_LOCATION +/// @param expression the expression evaluated in the expression callable +/// @param message an optional message to display for the assertion +template +std::enable_if_t<(Level <= SRB2_ASSERTION_LEVEL), void> +do_assert(const Expr& expr, const SourceLocation& source_location, const char* expression = "") noexcept { + static_assert(Level > 0, "level of an assertion must not be 0"); + if (!expr()) { + Handler::handle(source_location, expression); + std::abort(); + } +} + +template +std::enable_if_t<(Level > SRB2_ASSERTION_LEVEL), void> +do_assert(const Expr&, const SourceLocation&, const char* = "") noexcept { +} + +template +class NotNull final { + T ptr_; + +public: + static_assert(std::is_convertible_v() != nullptr), bool>, + "T is not comparable with nullptr_t"); + + /// @brief Move-construct from the pointer value U, asserting that it is not null. Allows construction of a + /// NotNull from any compatible pointer U, for example with polymorphic classes. + template >> + constexpr NotNull(U&& rhs) : ptr_(std::forward(rhs)) { + SRB2_ASSERT(ptr_ != nullptr); + } + + /// @brief Wrap the pointer type T, asserting that the pointer is not null. + template >> + constexpr NotNull(T rhs) : ptr_(std::move(rhs)) { + SRB2_ASSERT(ptr_ != nullptr); + } + + /// @brief Copy construction from NotNull of convertible type U. Only if the incoming pointer is NotNull already. + template >> + constexpr NotNull(const NotNull& rhs) : NotNull(rhs.get()) { + // Value is guaranteed to be not null by construction; no assertion necessary + } + + NotNull(const NotNull& rhs) = default; + NotNull& operator=(const NotNull& rhs) = default; + + /// @brief Get the stored pointer. + constexpr T get() const { return ptr_; } + + /// @brief Convert to T (the pointer type). + constexpr operator T() const { return get(); } + + /// @brief Arrow-dereference to *T (the actual value pointed to). + constexpr decltype(auto) operator->() const { return get(); } + + /// @brief Dereference to *T (the actual value pointed to). + constexpr decltype(auto) operator*() const { return *get(); } + + // It is not allowed to construct NotNull with nullptr regardless of T. + NotNull(std::nullptr_t) = delete; + NotNull& operator=(std::nullptr_t) = delete; +}; + +template +NotNull(T) -> NotNull; + +} // namespace srb2 + +#endif // __SRB2_CXXUTIL_HPP__ diff --git a/src/d_clisrv.c b/src/d_clisrv.c index da864f151..892ac14a0 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -90,9 +90,12 @@ char motd[254], server_context[8]; // Message of the Day, Unique Context (even w plrinfo playerinfo[MAXPLAYERS]; SINT8 joinnode = 0; // used for CL_VIEWSERVER +boolean player_muted[MAXPLAYERS] = {0}; + // Server specific vars UINT8 playernode[MAXPLAYERS]; + // Minimum timeout for sending the savegame // The actual timeout will be longer depending on the savegame length tic_t jointimeout = (3*TICRATE); @@ -567,58 +570,7 @@ void SendKick(UINT8 playernum, UINT8 msg) // end of extra data function // ----------------------------------------------------------------- -// ----------------------------------------------------------------- -// extra data function for lmps -// ----------------------------------------------------------------- - -// if extradatabit is set, after the ziped tic you find this: -// -// type | description -// ---------+-------------- -// byte | size of the extradata -// byte | the extradata (xd) bits: see XD_... -// with this byte you know what parameter folow -// if (xd & XDNAMEANDCOLOR) -// byte | color -// char[MAXPLAYERNAME] | name of the player -// endif -// if (xd & XD_WEAPON_PREF) -// byte | original weapon switch: boolean, true if use the old -// | weapon switch methode -// char[NUMWEAPONS] | the weapon switch priority -// byte | autoaim: true if use the old autoaim system -// endif -/*boolean AddLmpExtradata(UINT8 **demo_point, INT32 playernum) -{ - UINT8 *textcmd = D_GetExistingTextcmd(gametic, playernum); - - if (!textcmd) - return false; - - M_Memcpy(*demo_point, textcmd, textcmd[0]+1); - *demo_point += textcmd[0]+1; - return true; -} - -void ReadLmpExtraData(UINT8 **demo_pointer, INT32 playernum) -{ - UINT8 nextra; - UINT8 *textcmd; - - if (!demo_pointer) - return; - - textcmd = D_GetTextcmd(gametic, playernum); - nextra = **demo_pointer; - M_Memcpy(textcmd, *demo_pointer, nextra + 1); - // increment demo pointer - *demo_pointer += nextra + 1; -}*/ - -// ----------------------------------------------------------------- -// end extra data function for lmps -// ----------------------------------------------------------------- - +// can we get rid of this finally lmao // ----------------------------------------------------------------- // resynch player data // ----------------------------------------------------------------- @@ -1580,70 +1532,6 @@ static boolean CL_SendJoin(void) return HSendPacket(servernode, false, 0, sizeof (clientconfig_pak)); } -static void -CopyCaretColors (char *p, const char *s, int n) -{ - char *t; - int m; - int c; - if (!n) - return; - while (( t = strchr(s, '^') )) - { - m = ( t - s ); - - if (m >= n) - { - memcpy(p, s, n); - return; - } - else - memcpy(p, s, m); - - p += m; - n -= m; - s += m; - - if (!n) - return; - - if (s[1]) - { - c = toupper(s[1]); - if (isdigit(c)) - c = 0x80 + ( c - '0' ); - else if (c >= 'A' && c <= 'F') - c = 0x80 + ( c - 'A' ); - else - c = 0; - - if (c) - { - *p++ = c; - n--; - - if (!n) - return; - } - else - { - if (n < 2) - break; - - memcpy(p, s, 2); - - p += 2; - n -= 2; - } - - s += 2; - } - else - break; - } - strncpy(p, s, n); -} - static void SV_SendServerInfo(INT32 node, tic_t servertime) { UINT8 *p; @@ -2126,7 +2014,7 @@ static void CL_ReloadReceivedSavegame(void) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { - camera[i].subsector = R_PointInSubsector(camera[i].x, camera[i].y); + camera[i].subsector = R_PointInSubsectorFast(camera[i].x, camera[i].y); } cl_redownloadinggamestate = false; @@ -3488,6 +3376,8 @@ void CL_Reset(void) #endif G_ResetAllDeviceRumbles(); + memset(player_muted, 0, sizeof(player_muted)); + // D_StartTitle should get done now, but the calling function will handle it } @@ -3508,31 +3398,12 @@ static void Command_GetPlayerNum(void) SINT8 nametonum(const char *name) { - INT32 playernum, i; + INT32 playernum = D_LookupPlayer(name); - if (!strcmp(name, "0")) - return 0; + if (playernum == -1) + CONS_Printf(M_GetText("There is no player named \"%s\"\n"), name); - playernum = (SINT8)atoi(name); - - if (playernum < 0 || playernum >= MAXPLAYERS) - return -1; - - if (playernum) - { - if (playeringame[playernum]) - return (SINT8)playernum; - else - return -1; - } - - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && !stricmp(player_names[i], name)) - return (SINT8)i; - - CONS_Printf(M_GetText("There is no player named \"%s\"\n"), name); - - return -1; + return playernum; } /** Lists all players and their player numbers. diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 35c77ce12..bf5005e64 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -13,6 +13,10 @@ #ifndef __D_CLISRV__ #define __D_CLISRV__ +#ifdef __cplusplus +extern "C" { +#endif + #include "d_ticcmd.h" #include "d_net.h" #include "d_netcmd.h" @@ -667,6 +671,8 @@ SINT8 nametonum(const char *name); extern char motd[254], server_context[8]; extern UINT8 playernode[MAXPLAYERS]; +extern boolean player_muted[MAXPLAYERS]; + INT32 D_NumPlayers(void); void D_ResetTiccmds(void); @@ -694,4 +700,9 @@ typedef struct rewind_s { void CL_ClearRewinds(void); rewind_t *CL_SaveRewindPoint(size_t demopos); rewind_t *CL_RewindToTime(tic_t time); + +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/d_main.c b/src/d_main.c index fd06f9605..3563f5949 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -72,6 +72,9 @@ #include "d_protocol.h" #include "m_perfstats.h" #include "k_kart.h" +#include "k_hud.h" + +#include "core/memory.h" #include "lua_script.h" @@ -325,6 +328,39 @@ static void D_Renderview(void) R_ApplyLevelInterpolators(rendertimefrac); + if (rendermode == render_soft) + { + // if this is display player 1 + if (cv_homremoval.value) + { + if (cv_homremoval.value == 1) + { + // Clear the software screen buffer to remove HOM + memset(vid.screens[0], 31, vid.width * vid.height); + } + else if (cv_homremoval.value == 2) + { + //'development' HOM removal -- makes it blindingly obvious if HOM is spotted. + memset(vid.screens[0], 32+(timeinmap&15), vid.width * vid.height); + } + } + } + + // Draw over the fourth screen so you don't have to stare at a HOM :V + if (splitscreen == 2) + { + // V_DrawPatchFill, but for the fourth screen only + patch_t *pat = W_CachePatchName("SRB2BACK", PU_CACHE); + INT32 dupz = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); + INT32 x, y, pw = SHORT(pat->width) * dupz, ph = SHORT(pat->height) * dupz; + + for (x = vid.width>>1; x < vid.width; x += pw) + { + for (y = vid.height>>1; y < vid.height; y += ph) + V_DrawScaledPatch(x, y, V_NOSCALESTART, pat); + } + } + for (i = 0; i <= splitscreen; i++) { const boolean issplitscreen = (i > 0); @@ -336,7 +372,6 @@ static void D_Renderview(void) if (!issplitscreen) // Initialize for P1 { viewwindowy = viewwindowx = 0; - topleft = screens[0]; objectsdrawn = 0; } @@ -350,8 +385,6 @@ static void D_Renderview(void) #endif if (issplitscreen) // Splitscreen-specific { - const INT32 len = viewheight*sizeof(ylookup[0]); - switch (i) { case 1: @@ -365,28 +398,20 @@ static void D_Renderview(void) viewwindowx = 0; viewwindowy = viewheight; } - M_Memcpy(ylookup, ylookup2, len); break; case 2: viewwindowx = 0; viewwindowy = viewheight; - M_Memcpy(ylookup, ylookup3, len); break; case 3: viewwindowx = viewwidth; viewwindowy = viewheight; - M_Memcpy(ylookup, ylookup4, len); default: break; } - - topleft = screens[0] + viewwindowy*vid.width + viewwindowx; } R_RenderPlayerView(&players[displayplayers[i]]); - - if (issplitscreen) - M_Memcpy(ylookup, ylookup1, viewheight*sizeof (ylookup[0])); } if (!issplitscreen) @@ -584,7 +609,7 @@ static boolean D_Display(void) { if (rendermode == render_soft) { - VID_BlitLinearScreen(screens[0], screens[1], vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.rowbytes); + VID_BlitLinearScreen(vid.screens[0], vid.screens[1], vid.width, vid.height, vid.width, vid.rowbytes); } lastdraw = false; @@ -618,7 +643,7 @@ static boolean D_Display(void) V_DrawFadeScreen(TC_RAINBOW, (leveltime & 0x20) ? SKINCOLOR_PASTEL : SKINCOLOR_MOONSLAM); // vid size change is now finished if it was on... - vid.recalc = 0; + vid.recalc = false; #ifdef HAVE_THREADS I_lock_mutex(&m_menu_mutex); @@ -750,6 +775,8 @@ void D_SRB2Loop(void) precise_t enterprecise = I_GetPreciseTime(); precise_t finishprecise = enterprecise; + Z_Frame_Reset(); + // Casting the return value of a function is bad practice (apparently) double budget = ((R_GetFramerateCap() == 0) ? 0.0 : round((1.0 / R_GetFramerateCap()) * I_GetPrecisePrecision())); capbudget = (precise_t)budget; @@ -926,7 +953,7 @@ void D_SRB2Loop(void) if ((elapsed > 0) && ((INT64)capbudget > elapsed) && !vsync_with_match_refresh) { - I_SleepDuration(capbudget - (finishprecise - enterprecise)); + I_SleepDuration(capbudget - elapsed); } } // Capture the time once more to get the real delta time. @@ -1216,32 +1243,32 @@ static boolean AddIWAD(void) } // extra graphic patches for saturn specific thingies -boolean found_extra_kart = false; +boolean found_extra_kart = false; boolean found_extra2_kart = false; boolean found_extra3_kart = false; -boolean xtra_speedo = false; // extra speedometer check -boolean xtra_speedo_clr = false; // extra speedometer colour check -boolean xtra_speedo3 = false; // 80x 11 extra speedometer check -boolean xtra_speedo_clr3 = false; // 80x 11 extra speedometer colour check -boolean achi_speedo = false; // achiiro speedometer check -boolean achi_speedo_clr = false; // extra speedometer colour check -boolean dial_speedo = false; // dial speedometer check -boolean dial_speedo_clr = false; // dial speedometer colour check -boolean kartz_speedo = false; // kartZ speedo +boolean xtra_speedo = false; // extra speedometer check +boolean xtra_speedo_clr = false; // extra speedometer colour check +boolean xtra_speedo3 = false; // 80x 11 extra speedometer check +boolean xtra_speedo_clr3 = false; // 80x 11 extra speedometer colour check +boolean achi_speedo = false; // achiiro speedometer check +boolean achi_speedo_clr = false; // extra speedometer colour check +boolean dial_speedo = false; // dial speedometer check +boolean dial_speedo_clr = false; // dial speedometer colour check +boolean kartz_speedo = false; // kartZ speedo boolean kartz_speedo_smol = false; // kartZ speedo but smol -boolean clr_hud = false; // colour hud check +boolean clr_hud = false; // colour hud check boolean driftgaugegfx_clr = false; // driftgauge colour check -boolean big_lap = false; // bigger lap counter -boolean big_lap_color = false; // bigger lap counter but colour -boolean statdp = false; // stat display for extended player setup -boolean nametaggfx = false; // Nametag stuffs -boolean driftgaugegfx = false; // Driftgauge stuffs -boolean multiitem_icon = false; // Extra icons for Sneakers, Banana and Jawz -boolean joystickicon = false; // Extra icons for the joystick input display -boolean minidoticon = false; // Dot graphic for minimap player angle display -boolean minilighticon = false; // mkwii-style minimap headlight +boolean big_lap = false; // bigger lap counter +boolean big_lap_color = false; // bigger lap counter but colour +boolean statdp = false; // stat display for extended player setup +boolean nametaggfx = false; // Nametag stuffs +boolean driftgaugegfx = false; // Driftgauge stuffs +boolean multiitem_icon = false; // Extra icons for Sneakers, Banana and Jawz +boolean joystickicon = false; // Extra icons for the joystick input display +boolean minidoticon = false; // Dot graphic for minimap player angle display +boolean minilighticon = false; // mkwii-style minimap headlight // static void IdentifyVersion(void) @@ -1451,7 +1478,7 @@ static void D_CheckSaturnExtraFiles(void) } // extra round joystick inputdisplay sprites - if (W_CheckMultipleLumps("JOYBCK","JOYKNB","JOYSHD", NULL)) + if (W_CheckMultipleLumps("JOYBCK", "JOYKNB", "JOYSHD", NULL)) { joystickicon = true; PUSHCONS(inputdisplay_cons_temp, last_inputdisplay_i, 3, "StickGFX"); @@ -1582,11 +1609,6 @@ void D_SRB2Main(void) I_OutputMsg("setvbuf didnt work\n"); #endif -#ifdef GETTEXT - // initialise locale code - M_StartupLocale(); -#endif - // get parameters from a response file (eg: srb2 @parms.txt) M_FindResponseFile(); @@ -1814,7 +1836,7 @@ void D_SRB2Main(void) { name = lumpinfo->name; - if (name[0] == 'M' && name[1] == 'A' && name[2] == 'P') // Ignore the headers + if (memcmp(name, "MAP", 3) == 0) // Ignore the headers { INT16 num; if (name[5] != '\0') @@ -1844,7 +1866,7 @@ void D_SRB2Main(void) { name = lumpinfo->name; - if (name[0] == 'M' && name[1] == 'A' && name[2] == 'P') // Ignore the headers + if (memcmp(name, "MAP", 3) == 0) // Ignore the headers { INT16 num; if (name[5] != '\0') diff --git a/src/d_main.h b/src/d_main.h index cb4049e54..1e2de572d 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -14,6 +14,10 @@ #ifndef __D_MAIN__ #define __D_MAIN__ +#ifdef __cplusplus +extern "C" { +#endif + #include "d_event.h" #include "w_wad.h" // for MAX_WADFILES @@ -90,4 +94,8 @@ const char *D_Home(void); // void D_StartTitle(void); +#ifdef __cplusplus +} // extern "C" +#endif + #endif //__D_MAIN__ diff --git a/src/d_net.h b/src/d_net.h index 1b6cd905c..caeb3c83f 100644 --- a/src/d_net.h +++ b/src/d_net.h @@ -18,6 +18,10 @@ #ifndef __D_NET__ #define __D_NET__ +#ifdef __cplusplus +extern "C" { +#endif + // Max computers in a game // 127 is probably as high as this can go, because // SINT8 is used for nodes sometimes >:( @@ -43,8 +47,6 @@ extern SINT8 nodetoplayer4[MAXNETNODES]; // Say the numplayer for this node if a extern UINT8 playerpernode[MAXNETNODES]; // Used specially for splitscreen extern boolean nodeingame[MAXNETNODES]; // Set false as nodes leave game -extern boolean serverrunning; - void Net_AckTicker(void); // If reliable return true if packet sent, 0 else @@ -65,4 +67,8 @@ void Net_SendAcks(INT32 node); void Net_WaitAllAckReceived(UINT32 timeout); const char *Net_GetPacketName(UINT8 packettype); +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 91ea8e945..0d14733da 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -204,11 +204,6 @@ static void Command_Archivetest_f(void); // CLIENT VARIABLES // ========================================================================= -void SendWeaponPref(void); -void SendWeaponPref2(void); -void SendWeaponPref3(void); -void SendWeaponPref4(void); - static CV_PossibleValue_t usemouse_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Force"}, {0, NULL}}; static CV_PossibleValue_t autobalance_cons_t[] = {{0, "MIN"}, {4, "MAX"}, {0, NULL}}; @@ -1030,6 +1025,9 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_scr_width); CV_RegisterVar(&cv_scr_height); + CV_RegisterVar(&cv_parallelsoftware); + CV_RegisterVar(&cv_paralleldrawmasked); + CV_RegisterVar(&cv_soundtest); CV_RegisterVar(&cv_perfstats); @@ -1051,7 +1049,9 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_verticallook[i]); } + CV_RegisterVar(&cv_resyncdemo); CV_RegisterVar(&cv_demodateformat); + CV_RegisterVar(&cv_showspecstuff); // ingame object placing @@ -2083,7 +2083,7 @@ static void Command_ResetCamera_f(void) } /* Consider replacing nametonum with this */ -static INT32 LookupPlayer(const char *s) +INT32 D_LookupPlayer(const char *s) { INT32 playernum; @@ -2099,8 +2099,7 @@ static INT32 LookupPlayer(const char *s) for (playernum = 0; playernum < MAXPLAYERS; ++playernum) { /* Match name case-insensitively: fully, or partially the start. */ - if (playeringame[playernum]) - if (strnicmp(player_names[playernum], s, strlen(s)) == 0) + if (playeringame[playernum] && (strnicmp(player_names[playernum], s, strlen(s)) == 0)) { return playernum; } @@ -2211,7 +2210,7 @@ static void Command_View_f(void) } else { - if (( playernum = LookupPlayer(COM_Argv(1)) ) == -1) + if (( playernum = D_LookupPlayer(COM_Argv(1)) ) == -1) { CONS_Alert(CONS_WARNING, "There is no player by that name!\n"); return; diff --git a/src/d_netcmd.h b/src/d_netcmd.h index b4ee22d93..1078de5d2 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -15,8 +15,17 @@ #ifndef __D_NETCMD__ #define __D_NETCMD__ +#ifdef __cplusplus +extern "C" { +#endif + #include "command.h" +void SendWeaponPref(void); +void SendWeaponPref2(void); +void SendWeaponPref3(void); +void SendWeaponPref4(void); + // console vars extern consvar_t cv_playername; extern consvar_t cv_playercolor; @@ -314,8 +323,13 @@ void ClearAdminPlayers(void); void RemoveAdminPlayer(INT32 playernum); void ItemFinder_OnChange(void); void D_SetPassword(const char *pw); +INT32 D_LookupPlayer(const char *s); // used for the player setup menu UINT8 CanChangeSkin(INT32 playernum); +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/d_netfil.c b/src/d_netfil.c index 0650f3c34..d45570a0e 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -111,7 +111,9 @@ static fileused_t transferFiles[UINT8_MAX + 1]; // Receiver structure INT32 fileneedednum; // Number of files needed to join the server fileneeded_t fileneeded[MAX_WADFILES]; // List of needed files +#ifdef HAVE_THREADS static I_mutex downloadmutex; +#endif char downloaddir[512] = "DOWNLOAD"; file_download_t filedownload; @@ -1351,14 +1353,18 @@ void CURLAbortFile(void) { filedownload.http_running = false; +#ifdef HAVE_THREADS // lock and unlock to wait for the download thread to exit I_lock_mutex(&downloadmutex); I_unlock_mutex(downloadmutex); +#endif } void CURLGetFile(void) { +#ifdef HAVE_THREADS I_lock_mutex(&downloadmutex); +#endif CURLMcode mc; /* return code used by curl_multi_wait() */ CURLcode easyres; /* Return from easy interface */ CURLMsg *m; /* for picking up messages with the transfer status */ @@ -1453,7 +1459,9 @@ void CURLGetFile(void) } filedownload.http_running = false; +#ifdef HAVE_THREADS I_unlock_mutex(downloadmutex); +#endif } HTTP_login * diff --git a/src/d_netfil.h b/src/d_netfil.h index 464d885b3..b84c83391 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -13,6 +13,10 @@ #ifndef __D_NETFIL__ #define __D_NETFIL__ +#ifdef __cplusplus +extern "C" { +#endif + #include "d_clisrv.h" #include "w_wad.h" @@ -125,4 +129,8 @@ HTTP_login * CURLGetLogin (const char *url, HTTP_login ***return_prev_next); size_t curlwrite_data(void *ptr, size_t size, size_t nmemb, FILE *stream); #endif +#ifdef __cplusplus +} // extern "C" +#endif + #endif // __D_NETFIL__ diff --git a/src/doomdef.h b/src/doomdef.h index f9467199b..e81f43429 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -58,6 +58,9 @@ // warning C4152: nonstandard extension, function/data pointer conversion in expression // warning C4213: nonstandard extension used : cast on l-value +#ifdef __cplusplus +extern "C" { +#endif #include "doomtype.h" @@ -69,11 +72,6 @@ #define _USE_MATH_DEFINES // fixes M_PI errors in r_plane.c for Visual Studio #include -#ifdef GETTEXT -#include -#include -#endif - #include #include #include @@ -447,14 +445,8 @@ void CONS_Debug(INT32 debugflags, const char *fmt, ...) FUNCDEBUG; extern char savegamename[256]; // m_misc.h -#ifdef GETTEXT -#define M_GetText(String) gettext(String) -void M_StartupLocale(void); -#else -// If no translations are to be used, make a stub -// M_GetText function that just returns the string. +//TODO: delet this #define M_GetText(x) (x) -#endif FUNCINLINE static ATTRINLINE void *M_Memcpy(void *dest, const void *src, size_t n) { @@ -524,12 +516,15 @@ UINT32 quickncasehash (const char *p, size_t n) return x; } +#ifndef __cplusplus #ifndef min // Double-Check with WATTCP-32's cdefs.h #define min(x, y) (((x) < (y)) ? (x) : (y)) #endif #ifndef max // Double-Check with WATTCP-32's cdefs.h #define max(x, y) (((x) > (y)) ? (x) : (y)) #endif +#endif + #ifndef CLAMP #define CLAMP(x, y, z) ((x) < (y) ? (y) : ((x) > (z) ? (z) : (x))) #endif @@ -560,6 +555,14 @@ UINT32 quickncasehash (const char *p, size_t n) #define UNLIKELY(x) (x) #endif +#ifdef __cplusplus +#if defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER) + #define restrict __restrict +#else + #define restrict +#endif +#endif + // An assert-type mechanism. #ifdef PARANOIA #define I_Assert(e) ((e) ? (void)0 : I_Error("assert failed: %s, file %s, line %d", #e, __FILE__, __LINE__)) @@ -657,4 +660,8 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; #undef UPDATE_ALERT #endif +#ifdef __cplusplus +} // extern "C" +#endif + #endif // __DOOMDEF__ diff --git a/src/doomstat.h b/src/doomstat.h index f8a3899ca..5a501f8c3 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -125,7 +125,7 @@ extern boolean lastdraw; extern INT32 postimgparam[MAXSPLITSCREENPLAYERS]; extern INT32 viewwindowx, viewwindowy; -extern INT32 viewwidth, scaledviewwidth; +extern INT32 viewwidth; extern boolean gamedataloaded; @@ -446,19 +446,19 @@ extern UINT16 spacetimetics; extern UINT16 extralifetics; // SRB2kart -extern tic_t introtime; -extern tic_t starttime; -extern tic_t raceexittime; -extern tic_t battleexittime; -extern INT32 hyudorotime; -extern INT32 stealtime; -extern INT32 sneakertime; -extern INT32 itemtime; -extern INT32 comebacktime; -extern INT32 bumptime; -extern INT32 wipeoutslowtime; -extern INT32 wantedreduce; -extern INT32 wantedfrequency; +extern const tic_t introtime; +extern const tic_t starttime; +extern const tic_t raceexittime; +extern const tic_t battleexittime; +extern const INT32 hyudorotime; +extern const INT32 stealtime; +extern const INT32 sneakertime; +extern const INT32 itemtime; +extern const INT32 comebacktime; +extern const INT32 bumptime; +extern const INT32 wipeoutslowtime; +extern const INT32 wantedreduce; +extern const INT32 wantedfrequency; extern UINT8 introtoplay; extern UINT8 creditscutscene; diff --git a/src/doomtype.h b/src/doomtype.h index 174bba5b1..ac41a4413 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -17,6 +17,10 @@ #ifndef __DOOMTYPE__ #define __DOOMTYPE__ +#ifdef __cplusplus +extern "C" { +#endif + #if defined (_WIN32) //#define WIN32_LEAN_AND_MEAN #define RPC_NO_WINDOWS_H @@ -100,8 +104,10 @@ typedef long ssize_t; #define strnicmp(x,y,n) strncasecmp(x,y,n) #endif +#ifndef __cplusplus char *strcasestr(const char *in, const char *what); #define stristr strcasestr +#endif #if defined (macintosh) //|| defined (__APPLE__) //skip all boolean/Boolean crap #define true 1 @@ -156,22 +162,19 @@ size_t strlcpy(char *dst, const char *src, size_t siz); /* Boolean type definition */ -// \note __BYTEBOOL__ used to be set above if "macintosh" was defined, -// if macintosh's version of boolean type isn't needed anymore, then isn't this macro pointless now? -#ifndef __BYTEBOOL__ - #define __BYTEBOOL__ - - //faB: clean that up !! - #if defined( _MSC_VER) && (_MSC_VER >= 1800) // MSVC 2013 and forward - #include "stdbool.h" - #elif defined (_WIN32) - #define false FALSE // use windows types - #define true TRUE - #define boolean BOOL - #else - typedef enum {false, true} boolean; - #endif -#endif // __BYTEBOOL__ +#ifndef _WIN32 +#include +// dont use stdbools _BOOL type +// its smaller (1 byte) than the old interger bool (4 bytes) +// which results in packed struct sizes being mismatched between vanilla and this +// however we gotta still include stdbool cause since c23 true and false are keywords +// which we cant use as enumeration constants +typedef int32_t boolean; +#else +#define false FALSE +#define true TRUE +#define boolean BOOL +#endif /* 7.18.2.1 Limits of exact-width integer types */ #ifndef INT8_MIN @@ -385,4 +388,8 @@ unset_bit_array (bitarray_t * const array, const int value) typedef UINT64 precise_t; +#ifdef __cplusplus +} // extern "C" +#endif + #endif //__DOOMTYPE__ diff --git a/src/f_finale.c b/src/f_finale.c index b98570b48..6d062af11 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -540,6 +540,8 @@ static const char *credits[] = { "\"Jin\"", "\"riomccloud\"", "\"chromaticpipe\"", + "\"PAS\"", + "\"$HOME\"", "\"Achii\"", "\"Anonimus\"", "\"scizor300\"", diff --git a/src/f_wipe.c b/src/f_wipe.c index 1523ca1d3..cbb411b8b 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -313,7 +313,7 @@ void F_WipeStartScreen(void) return; } #endif - wipe_scr_start = screens[3]; + wipe_scr_start = vid.screens[3]; I_ReadScreen(wipe_scr_start); #endif } @@ -330,7 +330,7 @@ void F_WipeEndScreen(void) return; } #endif - wipe_scr_end = screens[4]; + wipe_scr_end = vid.screens[4]; I_ReadScreen(wipe_scr_end); V_DrawBlock(0, 0, 0, vid.width, vid.height, wipe_scr_start); #endif @@ -353,7 +353,7 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu) // Init the wipe WipeInAction = true; - wipe_scr = screens[0]; + wipe_scr = vid.screens[0]; // lastwipetic should either be 0 or the tic we last wiped // on for fade-to-black diff --git a/src/filesrch.h b/src/filesrch.h index 76d5700c0..075895cb0 100644 --- a/src/filesrch.h +++ b/src/filesrch.h @@ -4,6 +4,10 @@ #ifndef __FILESRCH_H__ #define __FILESRCH_H__ +#ifdef __cplusplus +extern "C" { +#endif + #include "doomdef.h" #include "d_netfil.h" #include "m_menu.h" // MAXSTRINGLENGTH @@ -96,4 +100,8 @@ void closefilemenu(boolean validsize); void searchfilemenu(char *tempname); boolean preparefilemenu(boolean samedepth, boolean replayhut); +#ifdef __cplusplus +} // extern "C" +#endif + #endif // __FILESRCH_H__ diff --git a/src/g_demo.c b/src/g_demo.c new file mode 100644 index 000000000..820ef45fb --- /dev/null +++ b/src/g_demo.c @@ -0,0 +1,4070 @@ +// SONIC ROBO BLAST 2 KART +//----------------------------------------------------------------------------- +// Copyright (C) 1993-1996 by id Software, Inc. +// Copyright (C) 1998-2000 by DooM Legacy Team. +// Copyright (C) 1999-2020 by Sonic Team Junior. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file g_demo.c +/// \brief Demo recording and playback + +#include "doomdef.h" +#include "console.h" +#include "d_main.h" +#include "d_clisrv.h" +#include "d_player.h" +#include "f_finale.h" +#include "filesrch.h" // for refreshdirmenu +#include "p_setup.h" +#include "p_saveg.h" +#include "i_time.h" +#include "i_system.h" +#include "am_map.h" +#include "m_random.h" +#include "p_local.h" +#include "r_draw.h" +#include "r_main.h" +#include "s_sound.h" +#include "g_game.h" +#include "m_cheat.h" +#include "m_misc.h" +#include "m_menu.h" +#include "m_argv.h" +#include "hu_stuff.h" +#include "st_stuff.h" +#include "z_zone.h" +#include "i_video.h" +#include "byteptr.h" +#include "i_joy.h" +#include "r_local.h" +#include "r_things.h" +#include "y_inter.h" +#include "v_video.h" +#include "dehacked.h" // get_number (for ghost thok) +#include "lua_script.h" // LUA_ArchiveDemo and LUA_UnArchiveDemo +#include "lua_hook.h" +#include "lua_libs.h" // gL (Lua state) +#include "b_bot.h" +#include "m_cond.h" // condition sets +#include "md5.h" // demo checksums +#include "k_director.h" // SRB2kart +#include "k_kart.h" // SRB2kart +#include "k_stats.h" // SRB2kart +#include "r_fps.h" // frame interpolation/uncapped + +#ifdef HAVE_DISCORDRPC +#include "discord.h" +#endif + +// for replay dates +#include +#include + +// menu demo things +UINT8 numDemos = 0; //3; -- i'm FED UP of losing my skincolour to a broken demo. change this back when we make new ones +UINT32 demoDelayTime = 15*TICRATE; +UINT32 demoIdleTime = 3*TICRATE; + +boolean nodrawers; // for comparative timing purposes +boolean noblit; // for comparative timing purposes +static tic_t demostarttime; // for comparative timing purposes + +//@TODO put these all in a struct for namespacing purposes? +static char demoname[128]; +savebuffer_t demobuf; +static UINT8 *demotime_p, *demoinfo_p; +static UINT8 *demoend; +static UINT8 demoflags; +static boolean demosynced = true; // console warning message + +struct demovars_s demo; + +boolean metalrecording; // recording as metal sonic +mobj_t *metalplayback; +static UINT8 *metalbuffer = NULL; +static UINT8 *metal_p; +static UINT16 metalversion; + +consvar_t cv_resyncdemo = {"resyncdemo", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + +// extra data stuff (events registered this frame while recording) +static struct { + UINT8 flags; // EZT flags + + // EZT_COLOR + UINT8 color, lastcolor; + + // EZT_SCALE + fixed_t scale, lastscale; + + // EZT_KART + INT32 kartitem, kartamount, kartbumpers; + + UINT8 desyncframes; // Don't try to resync unless we've been off for two frames, to monkeypatch a few trouble spots + + // EZT_HIT + UINT16 hits; + mobj_t **hitlist; +} ghostext[MAXPLAYERS]; + +// Your naming conventions are stupid and useless. +// There is no conflict here. +demoghost *ghosts = NULL; + +static CV_PossibleValue_t recordmultiplayerdemos_cons_t[] = {{0, "Disabled"}, {1, "Manual Save"}, {2, "Auto Save"}, {0, NULL}}; +consvar_t cv_recordmultiplayerdemos = {"netdemo_record", "Manual Save", CV_SAVE, recordmultiplayerdemos_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + +static CV_PossibleValue_t netdemosyncquality_cons_t[] = {{1, "MIN"}, {35, "MAX"}, {0, NULL}}; +consvar_t cv_netdemosyncquality = {"netdemo_syncquality", "1", CV_SAVE, netdemosyncquality_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + +// Units are MiB. +static CV_PossibleValue_t maxdemosize_cons_t[] = {{10, "MIN"}, {100, "MAX"}, {0, NULL}}; +consvar_t cv_maxdemosize = {"maxdemosize", "10", CV_SAVE, maxdemosize_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + +static CV_PossibleValue_t demochangemap_cons_t[] = {{0, "Disabled"}, {1, "Diff Map"}, {2, "Always"}, {0, NULL}}; +consvar_t cv_demochangemap = {"netdemo_savemapchange", "Disabled", CV_SAVE, demochangemap_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + +static CV_PossibleValue_t demodateformat_cons_t[] = {{0, "Automatic"}, {1, "EU"}, {2, "US"}, {0, NULL}}; +consvar_t cv_demodateformat = {"netdemo_dateformat", "Automatic", CV_SAVE, demodateformat_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + +#define DEMOVERSION 0x0002 +#define DEMOHEADER "\xF0" "KartReplay" "\x0F" + +#define DF_GHOST 0x01 // This demo contains ghost data too! +#define DF_RECORDATTACK 0x02 // This demo is from record attack and contains its final completion time! +#define DF_NIGHTSATTACK 0x04 // This demo is from NiGHTS attack and contains its time left, score, and mares! +#define DF_ATTACKMASK 0x06 // This demo is from ??? attack and contains ??? + +#define DF_LUAVARS 0x20 // this demo contains extra lua vars; this is mostly used for backwards compability + +#define DF_ATTACKSHIFT 1 +#define DF_ENCORE 0x40 +#define DF_MULTIPLAYER 0x80 // This demo was recorded in multiplayer mode! + +#ifdef DEMO_COMPAT_100 +#define DF_FILELIST 0x08 // This demo contains an extra files list +#define DF_GAMETYPEMASK 0x30 +#define DF_GAMESHIFT 4 +#endif + +#define DEMO_SPECTATOR 0x40 + +// For demos +#define ZT_FWD 0x01 +#define ZT_SIDE 0x02 +#define ZT_ANGLE 0x04 +#define ZT_BUTTONS 0x08 +#define ZT_AIMING 0x10 +#define ZT_DRIFT 0x20 +#define ZT_LATENCY 0x40 +#define DEMOMARKER 0x80 // demoend + +UINT8 demo_extradata[MAXPLAYERS]; +UINT8 demo_writerng; // 0=no, 1=yes, 2=yes but on a timeout +static ticcmd_t oldcmd[MAXPLAYERS]; + +#define DW_END 0xFF // End of extradata block +#define DW_RNG 0xFE // Check RNG seed! + +#define DW_EXTRASTUFF 0xFE // Numbers below this are reserved for writing player slot data + +// Below consts are only used for demo extrainfo sections +#define DW_STANDING 0x00 + +// For Metal Sonic and time attack ghosts +#define GZT_XYZ 0x01 +#define GZT_MOMXY 0x02 +#define GZT_MOMZ 0x04 +#define GZT_ANGLE 0x08 +// Not used for Metal Sonic +#define GZT_SPRITE 0x10 // Animation frame +#define GZT_EXTRA 0x20 +#define GZT_NIGHTS 0x40 // NiGHTS Mode stuff! + +// GZT_EXTRA flags +#define EZT_THOK 0x01 // Spawned a thok object +#define EZT_SPIN 0x02 // Because one type of thok object apparently wasn't enough +#define EZT_REV 0x03 // And two types wasn't enough either yet +#define EZT_THOKMASK 0x03 +#define EZT_COLOR 0x04 // Changed color (Super transformation, Mario fireflowers/invulnerability, etc.) +#define EZT_FLIP 0x08 // Reversed gravity +#define EZT_SCALE 0x10 // Changed size +#define EZT_HIT 0x20 // Damaged a mobj +#define EZT_SPRITE 0x40 // Changed sprite set completely out of PLAY (NiGHTS, SOCs, whatever) +#define EZT_KART 0x80 // SRB2Kart: Changed current held item/quantity and bumpers for battle + +static mobj_t oldmetal, oldghost[MAXPLAYERS]; + +static void G_ResetDemoPlayback(char *pdemoname); + +void G_SaveMetal(UINT8 **buffer) +{ + I_Assert(buffer != NULL && *buffer != NULL); + + WRITEUINT32(*buffer, metal_p - metalbuffer); +} + +void G_LoadMetal(UINT8 **buffer) +{ + I_Assert(buffer != NULL && *buffer != NULL); + + G_DoPlayMetal(); + metal_p = metalbuffer + READUINT32(*buffer); +} + +ticcmd_t *G_CopyTiccmd(ticcmd_t* dest, const ticcmd_t* src, const size_t n) +{ + return M_Memcpy(dest, src, n*sizeof(*src)); +} + +ticcmd_t *G_MoveTiccmd(ticcmd_t* dest, const ticcmd_t* src, const size_t n) +{ + size_t i; + for (i = 0; i < n; i++) + { + dest[i].forwardmove = src[i].forwardmove; + dest[i].sidemove = src[i].sidemove; + dest[i].angleturn = SHORT(src[i].angleturn); + dest[i].aiming = (INT16)SHORT(src[i].aiming); + dest[i].buttons = (UINT16)SHORT(src[i].buttons); + dest[i].driftturn = (INT16)SHORT(src[i].driftturn); + dest[i].latency = (INT16)SHORT(src[i].latency); + } + return dest; +} + +// Finds a skin with the closest stats if the expected skin doesn't exist. +static INT32 GetSkinNumClosestToStats(UINT8 kartspeed, UINT8 kartweight) +{ + INT32 i, closest_skin = 0; + UINT8 closest_stats = UINT8_MAX, stat_diff; + + for (i = 0; i < numskins; i++) + { + stat_diff = abs(skins[i].kartspeed - kartspeed) + abs(skins[i].kartweight - kartweight); + if (stat_diff < closest_stats) + { + closest_stats = stat_diff; + closest_skin = i; + } + } + + return closest_skin; +} + +static void FindClosestSkinForStats(UINT32 p, UINT8 kartspeed, UINT8 kartweight) +{ + INT32 closest_skin = GetSkinNumClosestToStats(kartspeed, kartweight); + + //CONS_Printf("Using %s instead...\n", skins[closest_skin].name); + SetPlayerSkinByNum(p, closest_skin); +} + +void G_ReadDemoExtraData(void) +{ + INT32 p, extradata, i; + char name[17]; + + if (leveltime > starttime) + { + rewind_t *rewind = CL_SaveRewindPoint(demobuf.p - demobuf.buffer); + if (rewind) + { + memcpy(rewind->oldcmd, oldcmd, sizeof (oldcmd)); + memcpy(rewind->oldghost, oldghost, sizeof (oldghost)); + } + } + + memset(name, '\0', 17); + + p = READUINT8(demobuf.p); + + while (p < DW_EXTRASTUFF) + { + extradata = READUINT8(demobuf.p); + + if (extradata & DXD_RESPAWN) + { + if (players[p].mo) + P_DamageMobj(players[p].mo, NULL, NULL, DMG_INSTAKILL); // Is this how this should work..? + } + if (extradata & DXD_SKIN) + { + UINT8 kartspeed, kartweight; + + // Skin + M_Memcpy(name, demobuf.p, 16); + demobuf.p += 16; + SetPlayerSkin(p, name); + + kartspeed = READUINT8(demobuf.p); + kartweight = READUINT8(demobuf.p); + + if (stricmp(skins[players[p].skin].name, name) != 0) + FindClosestSkinForStats(p, kartspeed, kartweight); + + players[p].kartspeed = kartspeed; + players[p].kartweight = kartweight; + } + if (extradata & DXD_COLOR) + { + // Color + M_Memcpy(name, demobuf.p, 16); + demobuf.p += 16; + for (i = 0; i < MAXSKINCOLORS; i++) + if (!stricmp(KartColor_Names[i], name)) // SRB2kart + { + players[p].skincolor = i; + if (players[p].mo) + players[p].mo->color = i; + break; + } + } + if (extradata & DXD_NAME) + { + // Name + M_Memcpy(player_names[p],demobuf.p,16); + demobuf.p += 16; + } + if (extradata & DXD_PLAYSTATE) + { + extradata = READUINT8(demobuf.p); + + switch (extradata) { + case DXD_PST_PLAYING: + players[p].pflags |= PF_WANTSTOJOIN; // fuck you + break; + + case DXD_PST_SPECTATING: + players[p].pflags &= ~PF_WANTSTOJOIN; // double-fuck you + if (!playeringame[p]) + { + CL_ClearPlayer(p); + playeringame[p] = true; + G_AddPlayer(p); + players[p].spectator = true; + + // There's likely an off-by-one error in timing recording or playback of joins. This hacks around it so I don't have to find out where that is. \o/ + if (oldcmd[p].forwardmove) + P_RandomByte(); + } + else + { + players[p].spectator = true; + if (players[p].mo) + P_DamageMobj(players[p].mo, NULL, NULL, DMG_INSTAKILL); + else + players[p].playerstate = PST_REBORN; + } + break; + + case DXD_PST_LEFT: + CL_RemovePlayer(p, 0); + break; + } + + G_ResetViews(); + + // maybe these are necessary? + if (G_BattleGametype()) + K_CheckBumpers(); // SRB2Kart + else if (G_RaceGametype()) + P_CheckRacers(); // also SRB2Kart + } + + + p = READUINT8(demobuf.p); + } + + while (p != DW_END) + { + UINT32 rng; + UINT32 checkrng; + + switch (p) + { + case DW_RNG: + rng = READUINT32(demobuf.p); + checkrng = P_GetRandSeed(); + if (checkrng != rng) + { + if (demosynced) + { + CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced (RNG)!\n")); + CONS_Printf("expected rng %d got %d\n", rng, checkrng); + } + demosynced = false; + + P_SetRandSeed(rng); + } + } + + p = READUINT8(demobuf.p); + } + + if (!(demoflags & DF_GHOST) && *demobuf.p == DEMOMARKER) + { + // end of demo data stream + G_CheckDemoStatus(); + return; + } +} + +void G_WriteDemoExtraData(void) +{ + INT32 i; + char name[17]; + + for (i = 0; i < MAXPLAYERS; i++) + { + if (demo_extradata[i]) + { + WRITEUINT8(demobuf.p, i); + WRITEUINT8(demobuf.p, demo_extradata[i]); + + //if (demo_extradata[i] & DXD_RESPAWN) has no extra data + if (demo_extradata[i] & DXD_SKIN) + { + // Skin + memset(name, 0, 16); + strncpy(name, skins[players[i].skin].name, 16); + M_Memcpy(demobuf.p,name,16); + demobuf.p += 16; + + WRITEUINT8(demobuf.p, skins[players[i].skin].kartspeed); + WRITEUINT8(demobuf.p, skins[players[i].skin].kartweight); + } + if (demo_extradata[i] & DXD_COLOR) + { + // Color + memset(name, 0, 16); + strncpy(name, KartColor_Names[players[i].skincolor], 16); + M_Memcpy(demobuf.p,name,16); + demobuf.p += 16; + } + if (demo_extradata[i] & DXD_NAME) + { + // Name + memset(name, 0, 16); + memcpy(name, player_names[i], 15); // Keeping 1 null byte for safety, sorry players with name containing more than 15 characters + M_Memcpy(demobuf.p,name,16); + demobuf.p += 16; + } + if (demo_extradata[i] & DXD_PLAYSTATE) + { + demo_writerng = 1; + if (!playeringame[i]) + WRITEUINT8(demobuf.p, DXD_PST_LEFT); + else if ( + players[i].spectator && + !(players[i].pflags & PF_WANTSTOJOIN) // <= fuck you specifically + ) + WRITEUINT8(demobuf.p, DXD_PST_SPECTATING); + else + WRITEUINT8(demobuf.p, DXD_PST_PLAYING); + } + } + + demo_extradata[i] = 0; + } + + // May not be necessary, but might as well play it safe... + if ((leveltime & 255) == 128) + demo_writerng = 1; + + { + static UINT8 timeout = 0; + + if (timeout) timeout--; + + if (demo_writerng == 1 || (demo_writerng == 2 && timeout == 0)) + { + demo_writerng = 0; + timeout = 16; + WRITEUINT8(demobuf.p, DW_RNG); + WRITEUINT32(demobuf.p, P_GetRandSeed()); + } + } + + WRITEUINT8(demobuf.p, DW_END); +} + +void G_ReadDemoTiccmd(ticcmd_t *cmd, INT32 playernum) +{ + UINT8 ziptic; + + if (!demobuf.p || !demo.deferstart) + return; + ziptic = READUINT8(demobuf.p); + + if (ziptic & ZT_FWD) + oldcmd[playernum].forwardmove = READSINT8(demobuf.p); + if (ziptic & ZT_SIDE) + oldcmd[playernum].sidemove = READSINT8(demobuf.p); + if (ziptic & ZT_ANGLE) + oldcmd[playernum].angleturn = READINT16(demobuf.p); + if (ziptic & ZT_BUTTONS) + oldcmd[playernum].buttons = READUINT16(demobuf.p); + if (ziptic & ZT_AIMING) + oldcmd[playernum].aiming = READINT16(demobuf.p); + if (ziptic & ZT_DRIFT) + oldcmd[playernum].driftturn = READINT16(demobuf.p); + if (ziptic & ZT_LATENCY) + oldcmd[playernum].latency = READUINT8(demobuf.p); + + G_CopyTiccmd(cmd, &oldcmd[playernum], 1); + + // SRB2kart: Copy-pasted from ticcmd building, removes that crappy demo cam + if (((players[displayplayers[0]].mo && players[displayplayers[0]].speed > 0) // Moving + || (leveltime > starttime && (cmd->buttons & BT_ACCELERATE && cmd->buttons & BT_BRAKE)) // Rubber-burn turn + || (players[displayplayers[0]].kartstuff[k_respawn]) // Respawning + || (players[displayplayers[0]].spectator || objectplacing)) // Not a physical player + && !(players[displayplayers[0]].kartstuff[k_spinouttimer] && players[displayplayers[0]].kartstuff[k_sneakertimer])) // Spinning and boosting cancels out spinout + localangle[0] += (cmd->angleturn<<16); + + if (!(demoflags & DF_GHOST) && *demobuf.p == DEMOMARKER) + { + // end of demo data stream + G_CheckDemoStatus(); + return; + } +} + +void G_WriteDemoTiccmd(ticcmd_t *cmd, INT32 playernum) +{ + char ziptic = 0; + UINT8 *ziptic_p; + + if (!demobuf.p) + return; + + ziptic_p = demobuf.p++; // the ziptic, written at the end of this function + + if (cmd->forwardmove != oldcmd[playernum].forwardmove) + { + WRITEUINT8(demobuf.p,cmd->forwardmove); + oldcmd[playernum].forwardmove = cmd->forwardmove; + ziptic |= ZT_FWD; + } + + if (cmd->sidemove != oldcmd[playernum].sidemove) + { + WRITEUINT8(demobuf.p,cmd->sidemove); + oldcmd[playernum].sidemove = cmd->sidemove; + ziptic |= ZT_SIDE; + } + + if (cmd->angleturn != oldcmd[playernum].angleturn) + { + WRITEINT16(demobuf.p,cmd->angleturn); + oldcmd[playernum].angleturn = cmd->angleturn; + ziptic |= ZT_ANGLE; + } + + if (cmd->buttons != oldcmd[playernum].buttons) + { + WRITEUINT16(demobuf.p,cmd->buttons); + oldcmd[playernum].buttons = cmd->buttons; + ziptic |= ZT_BUTTONS; + } + + if (cmd->aiming != oldcmd[playernum].aiming) + { + WRITEINT16(demobuf.p,cmd->aiming); + oldcmd[playernum].aiming = cmd->aiming; + ziptic |= ZT_AIMING; + } + + if (cmd->driftturn != oldcmd[playernum].driftturn) + { + WRITEINT16(demobuf.p,cmd->driftturn); + oldcmd[playernum].driftturn = cmd->driftturn; + ziptic |= ZT_DRIFT; + } + + if (cmd->latency != oldcmd[playernum].latency) + { + WRITEUINT8(demobuf.p,cmd->latency); + oldcmd[playernum].latency = cmd->latency; + ziptic |= ZT_LATENCY; + } + + *ziptic_p = ziptic; + + // attention here for the ticcmd size! + // latest demos with mouse aiming byte in ticcmd + if (!(demoflags & DF_GHOST) && ziptic_p > demoend - 9) + { + G_CheckDemoStatus(); // no more space + return; + } +} + +void G_GhostAddThok(INT32 playernum) +{ + if (!demo.recording || !(demoflags & DF_GHOST)) + return; + + ghostext[playernum].flags = (ghostext[playernum].flags & ~EZT_THOKMASK) | EZT_THOK; +} + +void G_GhostAddSpin(INT32 playernum) +{ + if (!demo.recording || !(demoflags & DF_GHOST)) + return; + + ghostext[playernum].flags = (ghostext[playernum].flags & ~EZT_THOKMASK) | EZT_SPIN; +} + +void G_GhostAddRev(INT32 playernum) +{ + if (!demo.recording || !(demoflags & DF_GHOST)) + return; + + ghostext[playernum].flags = (ghostext[playernum].flags & ~EZT_THOKMASK) | EZT_REV; +} + +void G_GhostAddFlip(INT32 playernum) +{ + if (!demo.recording || !(demoflags & DF_GHOST)) + return; + + ghostext[playernum].flags |= EZT_FLIP; +} + +void G_GhostAddColor(INT32 playernum, ghostcolor_t color) +{ + if (!demo.recording || !(demoflags & DF_GHOST)) + return; + + if (ghostext[playernum].lastcolor == (UINT8)color) + { + ghostext[playernum].flags &= ~EZT_COLOR; + return; + } + + ghostext[playernum].flags |= EZT_COLOR; + ghostext[playernum].color = (UINT8)color; +} + +void G_GhostAddScale(INT32 playernum, fixed_t scale) +{ + if (!demo.recording || !(demoflags & DF_GHOST)) + return; + + if (ghostext[playernum].lastscale == scale) + { + ghostext[playernum].flags &= ~EZT_SCALE; + return; + } + + ghostext[playernum].flags |= EZT_SCALE; + ghostext[playernum].scale = scale; +} + +void G_GhostAddHit(INT32 playernum, mobj_t *victim) +{ + if (!demo.recording || !(demoflags & DF_GHOST)) + return; + + ghostext[playernum].flags |= EZT_HIT; + ghostext[playernum].hits++; + ghostext[playernum].hitlist = Z_Realloc(ghostext[playernum].hitlist, ghostext[playernum].hits * sizeof(mobj_t *), PU_LEVEL, &ghostext[playernum].hitlist); + P_SetTarget(ghostext[playernum].hitlist + (ghostext[playernum].hits-1), victim); +} + +void G_WriteAllGhostTics(void) +{ + if (!demobuf.p) + return; + + UINT8 *save_demo_p = demobuf.p; +#define CHECKSPACE(num) if (demobuf.p+(num) > demoend) { demobuf.p = save_demo_p; G_CheckDemoStatus(); return; } + + boolean toobig = false; + INT32 i, counter = leveltime; + + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i] || players[i].spectator) + continue; + + if (P_MobjWasRemoved(players[i].mo)) + continue; + + counter++; + + if (multiplayer && ((counter % cv_netdemosyncquality.value) != 0)) // Only write 1 in this many ghost datas per tic to cut down on multiplayer replay size. + continue; + + if (((ghostext[i].flags && (ghostext[i].flags & EZT_HIT)) || ghostext[i].hits) + && !ghostext[i].hitlist) // hitlist might be freed during resynch, beware PU_LEVEL! + { + ghostext[i].hits = 0; + continue; + } + + CHECKSPACE(1); + + WRITEUINT8(demobuf.p, i); + G_WriteGhostTic(players[i].mo, i); + + // attention here for the ticcmd size! + // latest demos with mouse aiming byte in ticcmd + if (demobuf.p >= demoend - (13 + 9 + 9)) + { + toobig = true; + break; + } + } + + CHECKSPACE(1); + WRITEUINT8(demobuf.p, 0xFF); + + if (toobig) + { + G_CheckDemoStatus(); // no more space + return; + } + +#undef CHECKSPACE +} + +void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) +{ + char ziptic = 0; + UINT8 *ziptic_p; + UINT32 i; + UINT8 sprite; + UINT8 frame; + + if (!demobuf.p) + return; + + UINT8 *save_demo_p = demobuf.p; +#define CHECKSPACE(num) if (demobuf.p+(num) > demoend) { demobuf.p = save_demo_p; G_CheckDemoStatus(); return; } + + if (!(demoflags & DF_GHOST)) + return; // No ghost data to write. + + if (ghost->player && ghost->player->pflags & PF_NIGHTSMODE && ghost->tracer) + { + // We're talking about the NiGHTS thing, not the normal platforming thing! + ziptic |= GZT_NIGHTS; + ghost = ghost->tracer; + } + + ziptic_p = demobuf.p++; // the ziptic, written at the end of this function + +#define MAXMOM (0x7FFF<<8) + + // GZT_XYZ is only useful if you've moved 256 FRACUNITS or more in a single tic. + if (abs(ghost->x-oldghost[playernum].x) > MAXMOM + || abs(ghost->y-oldghost[playernum].y) > MAXMOM + || abs(ghost->z-oldghost[playernum].z) > MAXMOM + || ((UINT8)(leveltime & 255) > 0 && (UINT8)(leveltime & 255) <= (UINT8)cv_netdemosyncquality.value)) // Hack to enable slightly nicer resyncing + { + oldghost[playernum].x = ghost->x; + oldghost[playernum].y = ghost->y; + oldghost[playernum].z = ghost->z; + ziptic |= GZT_XYZ; + + CHECKSPACE(sizeof(fixed_t)*3); + WRITEFIXED(demobuf.p, oldghost[playernum].x); + WRITEFIXED(demobuf.p, oldghost[playernum].y); + WRITEFIXED(demobuf.p, oldghost[playernum].z); + } + else + { + // For moving normally: + // Store one full byte of movement, plus one byte of fractional movement. + INT16 momx = (INT16)((ghost->x-oldghost[playernum].x + (1<<4))>>8); + INT16 momy = (INT16)((ghost->y-oldghost[playernum].y + (1<<4))>>8); + + if (momx != oldghost[playernum].momx + || momy != oldghost[playernum].momy) + { + oldghost[playernum].momx = momx; + oldghost[playernum].momy = momy; + ziptic |= GZT_MOMXY; + + CHECKSPACE(4); + + WRITEINT16(demobuf.p, momx); + WRITEINT16(demobuf.p, momy); + } + + momx = (INT16)((ghost->z-oldghost[playernum].z + (1<<4))>>8); + + if (momx != oldghost[playernum].momz) + { + oldghost[playernum].momz = momx; + ziptic |= GZT_MOMZ; + + CHECKSPACE(2); + + WRITEINT16(demobuf.p, momx); + } + + // This SHOULD set oldghost.x/y/z to match ghost->x/y/z + // but it keeps the fractional loss of one byte, + // so it will hopefully be made up for in future tics. + oldghost[playernum].x += oldghost[playernum].momx<<8; + oldghost[playernum].y += oldghost[playernum].momy<<8; + oldghost[playernum].z += oldghost[playernum].momz<<8; + } + +#undef MAXMOM + + // Only store the 8 most relevant bits of angle + // because exact values aren't too easy to discern to begin with when only 8 angles have different sprites + // and it does not affect this mode of movement at all anyway. + if (ghost->angle>>24 != oldghost[playernum].angle) + { + oldghost[playernum].angle = ghost->angle>>24; + ziptic |= GZT_ANGLE; + + CHECKSPACE(1); + + WRITEUINT8(demobuf.p, oldghost[playernum].angle); + } + + // Store the sprite frame. + frame = ghost->frame & 0xFF; + if (frame != oldghost[playernum].frame) + { + oldghost[playernum].frame = frame; + ziptic |= GZT_SPRITE; + + CHECKSPACE(1); + + WRITEUINT8(demobuf.p, oldghost[playernum].frame); + } + + // Check for sprite set changes + sprite = ghost->sprite; + if (sprite != oldghost[playernum].sprite) + { + oldghost[playernum].sprite = sprite; + ghostext[playernum].flags |= EZT_SPRITE; + } + + if (ghost->player) + { + if ( + ghostext[playernum].kartitem != ghost->player->kartstuff[k_itemtype] || + ghostext[playernum].kartamount != ghost->player->kartstuff[k_itemamount] || + ghostext[playernum].kartbumpers != ghost->player->kartstuff[k_bumper] + ) + { + ghostext[playernum].flags |= EZT_KART; + ghostext[playernum].kartitem = ghost->player->kartstuff[k_itemtype]; + ghostext[playernum].kartamount = ghost->player->kartstuff[k_itemamount]; + ghostext[playernum].kartbumpers = ghost->player->kartstuff[k_bumper]; + + } + } + + if (ghostext[playernum].color == ghostext[playernum].lastcolor) + ghostext[playernum].flags &= ~EZT_COLOR; + + if (ghostext[playernum].scale == ghostext[playernum].lastscale) + ghostext[playernum].flags &= ~EZT_SCALE; + + if (ghostext[playernum].flags) + { + ziptic |= GZT_EXTRA; + WRITEUINT8(demobuf.p, ghostext[playernum].flags); + + if (ghostext[playernum].flags & EZT_COLOR) + { + CHECKSPACE(1); + WRITEUINT8(demobuf.p, ghostext[playernum].color); + ghostext[playernum].lastcolor = ghostext[playernum].color; + } + + if (ghostext[playernum].flags & EZT_SCALE) + { + CHECKSPACE(sizeof(fixed_t)); + WRITEFIXED(demobuf.p, ghostext[playernum].scale); + ghostext[playernum].lastscale = ghostext[playernum].scale; + } + + if (ghostext[playernum].flags & EZT_HIT) + { + CHECKSPACE(2); + WRITEUINT16(demobuf.p, ghostext[playernum].hits); + + for (i = 0; i < ghostext[playernum].hits; i++) + { + mobj_t *mo = ghostext[playernum].hitlist[i]; + + CHECKSPACE(4+4+2+sizeof(fixed_t)*3+sizeof(angle_t)); + + WRITEUINT32(demobuf.p, UINT32_MAX); // reserved for some method of determining exactly which mobj this is. (mobjnum doesn't work here.) + WRITEUINT32(demobuf.p, mo->type); + WRITEUINT16(demobuf.p, (UINT16)mo->health); + WRITEFIXED(demobuf.p, mo->x); + WRITEFIXED(demobuf.p, mo->y); + WRITEFIXED(demobuf.p, mo->z); + WRITEANGLE(demobuf.p, mo->angle); + P_SetTarget(ghostext[playernum].hitlist+i, NULL); + } + + ghostext[playernum].hits = 0; + } + + if (ghostext[playernum].flags & EZT_SPRITE) + { + CHECKSPACE(1); + WRITEUINT8(demobuf.p, sprite); + } + + if (ghostext[playernum].flags & EZT_KART) + { + CHECKSPACE(12); + WRITEINT32(demobuf.p, ghostext[playernum].kartitem); + WRITEINT32(demobuf.p, ghostext[playernum].kartamount); + WRITEINT32(demobuf.p, ghostext[playernum].kartbumpers); + } + + ghostext[playernum].flags = 0; + } + + *ziptic_p = ziptic; +#undef CHECKSPACE +} + +void G_ConsAllGhostTics(void) +{ + UINT8 p; + + if (!demobuf.p || !demo.deferstart) + return; + + p = READUINT8(demobuf.p); + + while (p != 0xFF) + { + G_ConsGhostTic(p); + p = READUINT8(demobuf.p); + } + + if (*demobuf.p == DEMOMARKER) + { + // end of demo data stream + G_CheckDemoStatus(); + return; + } +} + +// Uses ghost data to do consistency checks on your position. +// This fixes desynchronising demos when fighting eggman. +void G_ConsGhostTic(INT32 playernum) +{ + UINT8 ziptic; + fixed_t px,py,pz,gx,gy,gz; + mobj_t *testmo; + fixed_t syncleeway; + boolean nightsfail = false; + + if (!(demoflags & DF_GHOST)) + return; // No ghost data to use. + + testmo = players[playernum].mo; + + // Grab ghost data. + ziptic = READUINT8(demobuf.p); + + if (ziptic & GZT_XYZ) + { + oldghost[playernum].x = READFIXED(demobuf.p); + oldghost[playernum].y = READFIXED(demobuf.p); + oldghost[playernum].z = READFIXED(demobuf.p); + syncleeway = 0; + } + else + { + if (ziptic & GZT_MOMXY) + { + oldghost[playernum].momx = READINT16(demobuf.p)<<8; + oldghost[playernum].momy = READINT16(demobuf.p)<<8; + } + + if (ziptic & GZT_MOMZ) + oldghost[playernum].momz = READINT16(demobuf.p)<<8; + + oldghost[playernum].x += oldghost[playernum].momx; + oldghost[playernum].y += oldghost[playernum].momy; + oldghost[playernum].z += oldghost[playernum].momz; + syncleeway = FRACUNIT; + } + + if (ziptic & GZT_ANGLE) + demobuf.p++; + + if (ziptic & GZT_SPRITE) + demobuf.p++; + + if (ziptic & GZT_NIGHTS) + { + if (!testmo || !testmo->player || !(testmo->player->pflags & PF_NIGHTSMODE) || !testmo->tracer) + nightsfail = true; + else + testmo = testmo->tracer; + } + + if (ziptic & GZT_EXTRA) + { // But wait, there's more! + ziptic = READUINT8(demobuf.p); + if (ziptic & EZT_COLOR) + demobuf.p++; + + if (ziptic & EZT_SCALE) + demobuf.p += sizeof(fixed_t); + + if (ziptic & EZT_HIT) + { // Resync mob damage. + UINT16 i, count = READUINT16(demobuf.p); + thinker_t *th; + mobj_t *mobj; + + UINT32 type; + UINT16 health; + fixed_t x; + fixed_t y; + fixed_t z; + + for (i = 0; i < count; i++) + { + demobuf.p += 4; // reserved. + type = READUINT32(demobuf.p); + health = READUINT16(demobuf.p); + x = READFIXED(demobuf.p); + y = READFIXED(demobuf.p); + z = READFIXED(demobuf.p); + demobuf.p += sizeof(angle_t); // angle, unnecessary for cons. + + mobj = NULL; + for (th = thinkercap.next; th != &thinkercap; th = th->next) + { + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + mobj = (mobj_t *)th; + if (mobj->type == (mobjtype_t)type && mobj->x == x && mobj->y == y && mobj->z == z) + break; + mobj = NULL; // wasn't this one, keep searching. + } + + if (mobj && mobj->health != health) // Wasn't damaged?! This is desync! Fix it! + { + if (demosynced) + { + CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced (health)!\n")); + CONS_Printf("expected health %d got %d\n", health, mobj->health); + } + + demosynced = false; + P_DamageMobj(mobj, players[0].mo, players[0].mo, 1); + } + } + } + + if (ziptic & EZT_SPRITE) + demobuf.p++; + + if (ziptic & EZT_KART) + { + ghostext[playernum].kartitem = READINT32(demobuf.p); + ghostext[playernum].kartamount = READINT32(demobuf.p); + ghostext[playernum].kartbumpers = READINT32(demobuf.p); + } + } + + if (testmo) + { + // Re-synchronise + px = testmo->x; + py = testmo->y; + pz = testmo->z; + gx = oldghost[playernum].x; + gy = oldghost[playernum].y; + gz = oldghost[playernum].z; + + if (nightsfail || abs(px-gx) > syncleeway || abs(py-gy) > syncleeway || abs(pz-gz) > syncleeway) + { + ghostext[playernum].desyncframes++; + + if (ghostext[playernum].desyncframes >= 2) + { + if (demosynced) + CONS_Alert(CONS_WARNING, "Demo playback has desynced (player %s)!\n", player_names[playernum]); + demosynced = false; + + if (cv_resyncdemo.value) + { + P_UnsetThingPosition(testmo); + testmo->x = oldghost[playernum].x; + testmo->y = oldghost[playernum].y; + P_SetThingPosition(testmo); + testmo->z = oldghost[playernum].z; + } + + if (abs(testmo->z - testmo->floorz) < 4*FRACUNIT) + testmo->z = testmo->floorz; // Sync players to the ground when they're likely supposed to be there... + + ghostext[playernum].desyncframes = 2; + } + } + else + ghostext[playernum].desyncframes = 0; + + if ( +#ifdef DEMO_COMPAT_100 + demo.version != 0x0001 && +#endif + ( + players[playernum].kartstuff[k_itemtype] != ghostext[playernum].kartitem || + players[playernum].kartstuff[k_itemamount] != ghostext[playernum].kartamount || + players[playernum].kartstuff[k_bumper] != ghostext[playernum].kartbumpers + ) + ) + { + if (demosynced) + { + CONS_Alert(CONS_WARNING, "Demo playback has desynced (item/bumpers)!(player %s)!\n", player_names[playernum]); + CONS_Printf("expected item type %d got %d\n", ghostext[playernum].kartitem, players[playernum].kartstuff[k_itemtype]); + CONS_Printf("expected item amount %d got %d\n", ghostext[playernum].kartamount, players[playernum].kartstuff[k_itemamount]); + } + demosynced = false; + + players[playernum].kartstuff[k_itemtype] = ghostext[playernum].kartitem; + players[playernum].kartstuff[k_itemamount] = ghostext[playernum].kartamount; + players[playernum].kartstuff[k_bumper] = ghostext[playernum].kartbumpers; + } + } + + if (*demobuf.p == DEMOMARKER) + { + // end of demo data stream + G_CheckDemoStatus(); + return; + } +} + +void G_GhostTicker(void) +{ + demoghost *g,*p; + + for (g = ghosts, p = NULL; g; g = g->next) + { + // Skip normal demo data. + UINT8 ziptic = READUINT8(g->p); + +#ifdef DEMO_COMPAT_100 + if (g->version != 0x0001) + { +#endif + while (ziptic != DW_END) // Get rid of extradata stuff + { + if (ziptic == 0) // Only support player 0 info for now + { + ziptic = READUINT8(g->p); + if (ziptic & DXD_SKIN) + g->p += 18; // We _could_ read this info, but it shouldn't change anything in record attack... + if (ziptic & DXD_COLOR) + g->p += 16; // Same tbh + if (ziptic & DXD_NAME) + g->p += 16; // yea + if (ziptic & DXD_PLAYSTATE && READUINT8(g->p) != DXD_PST_PLAYING) + I_Error("Ghost is not a record attack ghost"); //@TODO lmao don't blow up like this + } + else if (ziptic == DW_RNG) + g->p += 4; // RNG seed + else + I_Error("Ghost is not a record attack ghost"); //@TODO lmao don't blow up like this + + ziptic = READUINT8(g->p); + } + + ziptic = READUINT8(g->p); // Back to actual ziptic stuff +#ifdef DEMO_COMPAT_100 + } +#endif + + if (ziptic & ZT_FWD) + g->p++; + if (ziptic & ZT_SIDE) + g->p++; + if (ziptic & ZT_ANGLE) + g->p += 2; + if (ziptic & ZT_BUTTONS) + g->p += 2; + if (ziptic & ZT_AIMING) + g->p += 2; + if (ziptic & ZT_DRIFT) + g->p += 2; + if (ziptic & ZT_LATENCY) + g->p += 1; + + // Grab ghost data. + ziptic = READUINT8(g->p); + +#ifdef DEMO_COMPAT_100 + if (g->version != 0x0001) + { +#endif + if (ziptic == 0xFF) + goto skippedghosttic; // Didn't write ghost info this frame + else if (ziptic != 0) + I_Error("Ghost is not a record attack ghost"); //@TODO lmao don't blow up like this + ziptic = READUINT8(g->p); +#ifdef DEMO_COMPAT_100 + } +#endif + if (ziptic & GZT_XYZ) + { + g->oldmo.x = READFIXED(g->p); + g->oldmo.y = READFIXED(g->p); + g->oldmo.z = READFIXED(g->p); + } + else + { + if (ziptic & GZT_MOMXY) + { + g->oldmo.momx = READINT16(g->p)<<8; + g->oldmo.momy = READINT16(g->p)<<8; + } + if (ziptic & GZT_MOMZ) + g->oldmo.momz = READINT16(g->p)<<8; + g->oldmo.x += g->oldmo.momx; + g->oldmo.y += g->oldmo.momy; + g->oldmo.z += g->oldmo.momz; + } + if (ziptic & GZT_ANGLE) + g->oldmo.angle = READUINT8(g->p)<<24; + if (ziptic & GZT_SPRITE) + g->oldmo.frame = READUINT8(g->p); + + // Update ghost + P_UnsetThingPosition(g->mo); + g->mo->x = g->oldmo.x; + g->mo->y = g->oldmo.y; + g->mo->z = g->oldmo.z; + P_SetThingPosition(g->mo); + g->mo->angle = g->oldmo.angle; + g->mo->frame = g->oldmo.frame | tr_trans30<p); + if (ziptic & EZT_COLOR) + { + g->color = READUINT8(g->p); + switch(g->color) + { + default: + case GHC_NORMAL: // Go back to skin color + g->mo->color = g->oldmo.color; + break; + // Handled below + case GHC_SUPER: + case GHC_INVINCIBLE: + break; + case GHC_FIREFLOWER: // Fireflower + g->mo->color = SKINCOLOR_WHITE; + break; + } + } + if (ziptic & EZT_FLIP) + g->mo->eflags ^= MFE_VERTICALFLIP; + if (ziptic & EZT_SCALE) + { + g->mo->destscale = READFIXED(g->p); + if (g->mo->destscale != g->mo->scale) + P_SetScale(g->mo, g->mo->destscale); + } + if (ziptic & EZT_THOKMASK) + { // Let's only spawn ONE of these per frame, thanks. + mobj_t *mobj; + INT32 type = -1; + if (g->mo->skin) + { + switch (ziptic & EZT_THOKMASK) + { + case EZT_THOK: + type = (UINT32)mobjinfo[MT_PLAYER].painchance; + break; + case EZT_SPIN: + type = (UINT32)mobjinfo[MT_PLAYER].damage; + break; + case EZT_REV: + type = (UINT32)mobjinfo[MT_PLAYER].raisestate; + break; + } + } + if (type != -1) + { + if (type == MT_GHOST) + { + mobj = P_SpawnGhostMobj(g->mo); // does a large portion of the work for us + mobj->frame = (mobj->frame & ~FF_FRAMEMASK)|tr_trans60<mo->x, g->mo->y, g->mo->z - FixedDiv(FixedMul(g->mo->info->height, g->mo->scale) - g->mo->height,3*FRACUNIT), MT_THOK); + mobj->sprite = states[mobjinfo[type].spawnstate].sprite; + mobj->frame = (states[mobjinfo[type].spawnstate].frame & FF_FRAMEMASK) | tr_trans60<tics = -1; // nope. + mobj->color = g->mo->color; + if (g->mo->eflags & MFE_VERTICALFLIP) + { + mobj->flags2 |= MF2_OBJECTFLIP; + mobj->eflags |= MFE_VERTICALFLIP; + } + P_SetScale(mobj, g->mo->scale); + mobj->destscale = g->mo->scale; + } + mobj->floorz = mobj->z; + mobj->ceilingz = mobj->z+mobj->height; + P_UnsetThingPosition(mobj); + mobj->flags = MF_NOBLOCKMAP|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY; // make an ATTEMPT to curb crazy SOCs fucking stuff up... + P_SetThingPosition(mobj); + mobj->fuse = 8; + P_SetTarget(&mobj->target, g->mo); + } + } + if (ziptic & EZT_HIT) + { // Spawn hit poofs for killing things! + UINT16 i, count = READUINT16(g->p), health; + //UINT32 type; + fixed_t x,y,z; + angle_t angle; + mobj_t *poof; + for (i = 0; i < count; i++) + { + g->p += 4; // reserved + g->p += 4; // backwards compat., type used to be here + health = READUINT16(g->p); + x = READFIXED(g->p); + y = READFIXED(g->p); + z = READFIXED(g->p); + angle = READANGLE(g->p); + if (health != 0 || i >= 4) // only spawn for the first 4 hits per frame, to prevent ghosts from splode-spamming too bad. + continue; + poof = P_SpawnMobj(x, y, z, MT_GHOST); + poof->angle = angle; + poof->flags = MF_NOBLOCKMAP|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY; // make an ATTEMPT to curb crazy SOCs fucking stuff up... + poof->health = 0; + P_SetMobjStateNF(poof, S_XPLD1); + } + } + if (ziptic & EZT_SPRITE) + g->mo->sprite = READUINT8(g->p); + if (ziptic & EZT_KART) + g->p += 12; // kartitem, kartamount, kartbumpers + } + +#ifdef DEMO_COMPAT_100 + if (g->version != 0x0001) + { +#endif + if (READUINT8(g->p) != 0xFF) // Make sure there isn't other ghost data here. + I_Error("Ghost is not a record attack ghost"); //@TODO lmao don't blow up like this +#ifdef DEMO_COMPAT_100 + } +#endif + +skippedghosttic: + // Tick ghost colors (Super and Mario Invincibility flashing) + switch(g->color) + { + case GHC_SUPER: // Super Sonic (P_DoSuperStuff) + g->mo->color = SKINCOLOR_SUPER1; + g->mo->color += abs( ( (signed)( (unsigned)leveltime >> 1 ) % 9) - 4); + break; + case GHC_INVINCIBLE: // Mario invincibility (P_CheckInvincibilityTimer) + g->mo->color = (UINT8)(leveltime % MAXSKINCOLORS); + break; + default: + break; + } + + // Demo ends after ghost data. + if (*g->p == DEMOMARKER) + { + g->mo->momx = g->mo->momy = g->mo->momz = 0; + if (p) + p->next = g->next; + else + ghosts = g->next; + Z_Free(g); + continue; + } + p = g; + } +} + +// Demo rewinding functions +typedef struct rewindinfo_s { + tic_t leveltime; + + struct { + boolean ingame; + player_t player; + mobj_t mobj; + } playerinfo[MAXPLAYERS]; + + struct rewindinfo_s *prev; +} rewindinfo_t; + +static tic_t currentrewindnum; +static rewindinfo_t *rewindhead = NULL; // Reverse chronological order + +void G_InitDemoRewind(void) +{ + CL_ClearRewinds(); + + while (rewindhead) + { + rewindinfo_t *p = rewindhead->prev; + Z_Free(rewindhead); + rewindhead = p; + } + + currentrewindnum = 0; +} + +void G_StoreRewindInfo(void) +{ + static UINT8 timetolog = 8; + rewindinfo_t *info; + size_t i; + + if (timetolog-- > 0) + return; + timetolog = 8; + + info = Z_Calloc(sizeof(rewindinfo_t), PU_STATIC, NULL); + + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i] || players[i].spectator) + { + info->playerinfo[i].ingame = false; + continue; + } + + info->playerinfo[i].ingame = true; + memcpy(&info->playerinfo[i].player, &players[i], sizeof(player_t)); + if (players[i].mo) + memcpy(&info->playerinfo[i].mobj, players[i].mo, sizeof(mobj_t)); + } + + info->leveltime = leveltime; + info->prev = rewindhead; + rewindhead = info; +} + +void G_PreviewRewind(tic_t previewtime) +{ + SINT8 i; + size_t j; + fixed_t tweenvalue = 0; + rewindinfo_t *info = rewindhead, *next_info = rewindhead; + + if (!info) + return; + + while (info->leveltime > previewtime && info->prev) + { + next_info = info; + info = info->prev; + } + if (info != next_info) + tweenvalue = FixedDiv(previewtime - info->leveltime, next_info->leveltime - info->leveltime); + + + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i] || players[i].spectator) + { + if (info->playerinfo[i].player.mo) + { + //@TODO spawn temp object to act as a player display + } + + continue; + } + + if (!info->playerinfo[i].ingame || !info->playerinfo[i].player.mo) + { + if (players[i].mo) + players[i].mo->flags2 |= MF2_DONTDRAW; + + continue; + } + + if (!players[i].mo) + continue; //@TODO spawn temp object to act as a player display + + players[i].mo->flags2 &= ~MF2_DONTDRAW; + + P_UnsetThingPosition(players[i].mo); +#define TWEEN(pr) info->playerinfo[i].mobj.pr + FixedMul((INT32) (next_info->playerinfo[i].mobj.pr - info->playerinfo[i].mobj.pr), tweenvalue) + players[i].mo->x = TWEEN(x); + players[i].mo->y = TWEEN(y); + players[i].mo->z = TWEEN(z); + players[i].mo->angle = TWEEN(angle); +#undef TWEEN + P_SetThingPosition(players[i].mo); + + players[i].frameangle = info->playerinfo[i].player.frameangle + FixedMul((INT32) (next_info->playerinfo[i].player.frameangle - info->playerinfo[i].player.frameangle), tweenvalue); + + players[i].mo->sprite = info->playerinfo[i].mobj.sprite; + players[i].mo->frame = info->playerinfo[i].mobj.frame; + + players[i].realtime = info->playerinfo[i].player.realtime; + for (j = 0; j < NUMKARTSTUFF; j++) + players[i].kartstuff[j] = info->playerinfo[i].player.kartstuff[j]; + } + + for (i = splitscreen; i >= 0; i--) + P_ResetCamera(&players[displayplayers[i]], &camera[i]); +} + +void G_ConfirmRewind(tic_t rewindtime) +{ + SINT8 i; + tic_t j; + boolean oldmenuactive = menuactive, oldsounddisabled = sound_disabled; + + INT32 olddp1 = displayplayers[0], olddp2 = displayplayers[1], olddp3 = displayplayers[2], olddp4 = displayplayers[3]; + UINT8 oldss = splitscreen; + + menuactive = false; // Prevent loops + + CV_StealthSetValue(&cv_renderview, 0); + + if (rewindtime <= starttime) + { + demo.rewinding = false; + G_DoPlayDemo(NULL); // Restart the current demo + } + else + { + rewind_t *rewind; + sound_disabled = true; // Prevent sound spam + demo.rewinding = true; + + rewind = CL_RewindToTime(rewindtime); + + if (rewind) + { + demobuf.p = demobuf.buffer + rewind->demopos; + memcpy(oldcmd, rewind->oldcmd, sizeof (oldcmd)); + memcpy(oldghost, rewind->oldghost, sizeof (oldghost)); + paused = false; + } + else + { + demo.rewinding = true; + G_DoPlayDemo(NULL); // Restart the current demo + } + } + + for (j = 0; j < rewindtime && leveltime < rewindtime; j++) + { + G_Ticker((j % NEWTICRATERATIO) == 0); + } + + demo.rewinding = false; + menuactive = oldmenuactive; // Bring the menu back up + sound_disabled = oldsounddisabled; // Re-enable SFX + + wipegamestate = gamestate; // No fading back in! + + COM_BufInsertText("renderview on\n"); + + splitscreen = oldss; + displayplayers[0] = olddp1; + displayplayers[1] = olddp2; + displayplayers[2] = olddp3; + displayplayers[3] = olddp4; + R_ExecuteSetViewSize(); + G_ResetViews(); + + for (i = splitscreen; i >= 0; i--) + P_ResetCamera(&players[displayplayers[i]], &camera[i]); +} + +void G_ReadMetalTic(mobj_t *metal) +{ + UINT8 ziptic; + UINT16 speed; + UINT8 statetype; + + if (!metal_p) + return; + ziptic = READUINT8(metal_p); + + // Read changes from the tic + if (ziptic & GZT_XYZ) + { + oldmetal.x = READFIXED(metal_p); + oldmetal.y = READFIXED(metal_p); + oldmetal.z = READFIXED(metal_p); + P_MoveOrigin(metal, oldmetal.x, oldmetal.y, oldmetal.z); + oldmetal.x = metal->x; + oldmetal.y = metal->y; + oldmetal.z = metal->z; + } + else + { + if (ziptic & GZT_MOMXY) + { + oldmetal.momx = READINT16(metal_p)<<8; + oldmetal.momy = READINT16(metal_p)<<8; + } + if (ziptic & GZT_MOMZ) + oldmetal.momz = READINT16(metal_p)<<8; + oldmetal.x += oldmetal.momx; + oldmetal.y += oldmetal.momy; + oldmetal.z += oldmetal.momz; + } + if (ziptic & GZT_ANGLE) + oldmetal.angle = READUINT8(metal_p)<<24; + if (ziptic & GZT_SPRITE) + metal_p++; // Currently unused. (Metal Sonic figures out what he's doing his own damn self.) + + // Set movement, position, and angle + // oldmetal contains where you're supposed to be. + metal->momx = oldmetal.momx; + metal->momy = oldmetal.momy; + metal->momz = oldmetal.momz; + P_UnsetThingPosition(metal); + metal->x = oldmetal.x; + metal->y = oldmetal.y; + metal->z = oldmetal.z; + P_SetThingPosition(metal); + metal->angle = oldmetal.angle; + + if (ziptic & GZT_EXTRA) + { // But wait, there's more! + ziptic = READUINT8(metal_p); + if (ziptic & EZT_FLIP) + metal->eflags ^= MFE_VERTICALFLIP; + if (ziptic & EZT_SCALE) + { + metal->destscale = READFIXED(metal_p); + if (metal->destscale != metal->scale) + P_SetScale(metal, metal->destscale); + } + } + + // Calculates player's speed based on distance-of-a-line formula + speed = FixedDiv(P_AproxDistance(oldmetal.momx, oldmetal.momy), metal->scale)>>FRACBITS; + + // Use speed to decide an appropriate state + if (speed > 20) // default skin runspeed + statetype = 2; + else if (speed > 1) // stopspeed + statetype = 1; + else + statetype = 0; + + // Set state + if (statetype != metal->threshold) + { + switch (statetype) + { + case 2: // run + P_SetMobjState(metal,metal->info->meleestate); + break; + case 1: // walk + P_SetMobjState(metal,metal->info->seestate); + break; + default: // stand + P_SetMobjState(metal,metal->info->spawnstate); + break; + } + metal->threshold = statetype; + } + + // TODO: Modify state durations based on movement speed, similar to players? + + if (*metal_p == DEMOMARKER) + { + // end of demo data stream + G_StopMetalDemo(); + return; + } +} + +void G_WriteMetalTic(mobj_t *metal) +{ + UINT8 ziptic = 0; + UINT8 *ziptic_p; + + if (!demobuf.p) // demobuf.p will be NULL until the race start linedef executor is triggered! + return; + + ziptic_p = demobuf.p++; // the ziptic, written at the end of this function + + #define MAXMOM (0xFFFF<<8) + + // GZT_XYZ is only useful if you've moved 256 FRACUNITS or more in a single tic. + if (abs(metal->x-oldmetal.x) > MAXMOM + || abs(metal->y-oldmetal.y) > MAXMOM + || abs(metal->z-oldmetal.z) > MAXMOM) + { + oldmetal.x = metal->x; + oldmetal.y = metal->y; + oldmetal.z = metal->z; + WRITEFIXED(demobuf.p,oldmetal.x); + WRITEFIXED(demobuf.p,oldmetal.y); + WRITEFIXED(demobuf.p,oldmetal.z); + ziptic |= GZT_XYZ; + } + else + { + // For moving normally: + // Store one full byte of movement, plus one byte of fractional movement. + INT16 momx = (INT16)((metal->x-oldmetal.x)>>8); + INT16 momy = (INT16)((metal->y-oldmetal.y)>>8); + if (momx != oldmetal.momx + || momy != oldmetal.momy) + { + oldmetal.momx = momx; + oldmetal.momy = momy; + WRITEINT16(demobuf.p,momx); + WRITEINT16(demobuf.p,momy); + ziptic |= GZT_MOMXY; + } + momx = (INT16)((metal->z-oldmetal.z)>>8); + if (momx != oldmetal.momz) + { + oldmetal.momz = momx; + WRITEINT16(demobuf.p,momx); + ziptic |= GZT_MOMZ; + } + + // This SHOULD set oldmetal.x/y/z to match metal->x/y/z + // but it keeps the fractional loss of one byte, + // so it will hopefully be made up for in future tics. + oldmetal.x += oldmetal.momx<<8; + oldmetal.y += oldmetal.momy<<8; + oldmetal.z += oldmetal.momz<<8; + } + + #undef MAXMOM + + // Only store the 8 most relevant bits of angle + // because exact values aren't too easy to discern to begin with when only 8 angles have different sprites + // and it does not affect movement at all anyway. + if (metal->angle>>24 != oldmetal.angle) + { + oldmetal.angle = metal->angle>>24; + WRITEUINT8(demobuf.p,oldmetal.angle); + ziptic |= GZT_ANGLE; + } + + // Metal Sonic does not need our state changes. + // ... currently. + + { + UINT8 *exttic_p = NULL; + UINT8 exttic = 0; + if ((metal->eflags & MFE_VERTICALFLIP) != (oldmetal.eflags & MFE_VERTICALFLIP)) + { + if (!exttic_p) + exttic_p = demobuf.p++; + exttic |= EZT_FLIP; + oldmetal.eflags ^= MFE_VERTICALFLIP; + } + if (metal->scale != oldmetal.scale) + { + if (!exttic_p) + exttic_p = demobuf.p++; + exttic |= EZT_SCALE; + WRITEFIXED(demobuf.p,metal->scale); + oldmetal.scale = metal->scale; + } + if (exttic_p) + { + *exttic_p = exttic; + ziptic |= GZT_EXTRA; + } + } + + *ziptic_p = ziptic; + + // attention here for the ticcmd size! + // latest demos with mouse aiming byte in ticcmd + if (demobuf.p >= demoend - 32) + { + G_StopMetalRecording(); // no more space + return; + } +} + +// +// G_RecordDemo +// +void G_RecordDemo(const char *name) +{ + INT32 maxsize; + + demobuf.p = NULL; + G_ResetDemoRecording(); + demoend = NULL; + + if (cv_recordmultiplayerdemos.value) + { + CONS_Printf("Recording demo %s.lmp\n", name); + + strcpy(demoname, name); + strcat(demoname, ".lmp"); + + maxsize = cv_maxdemosize.value*1024*1024; + + demobuf.buffer = Z_Malloc(maxsize + 100*1024, PU_STATIC, NULL); + demoend = demobuf.buffer + maxsize; + + if (demobuf.buffer) + demo.recording = true; + else + CONS_Alert(CONS_ERROR, "Failed to allocate demo buffer\n"); + } +} + +void G_RecordMetal(void) +{ + INT32 maxsize; + maxsize = cv_maxdemosize.value*1024*1024; + if (demobuf.buffer) + Z_Free(demobuf.buffer); + demobuf.p = NULL; + metalrecording = false; + demobuf.buffer = Z_Malloc(maxsize + 100*1024, PU_STATIC, NULL); + demoend = demobuf.buffer + maxsize; + + if (demobuf.buffer) + metalrecording = true; + else + CONS_Alert(CONS_ERROR, "Failed to allocate demo buffer\n"); +} + +void G_BeginRecording(void) +{ + UINT8 i, p; + char name[17]; + player_t *player = &players[consoleplayer]; + + char *filename; + UINT8 totalfiles; + UINT8 *m; + + if (!cv_recordmultiplayerdemos.value) + { + G_ResetDemoRecording(); + return; + } + + if (demobuf.buffer == NULL) + { + CONS_Alert(CONS_ERROR, "No demo buffer allocated\n"); + G_ResetDemoRecording(); + return; + } + + if (demobuf.p) + { + G_ResetDemoRecording(); + return; + } + + memset(name,0,sizeof(name)); + + demobuf.p = demobuf.buffer; + demoflags = DF_GHOST|(multiplayer ? DF_MULTIPLAYER : (modeattacking<important) + { + nameonly(( filename = va("%s", wadfiles[i]->filename) )); + WRITESTRINGL(demobuf.p, filename, MAX_WADPATH); + WRITEMEM(demobuf.p, wadfiles[i]->md5sum, 16); + + totalfiles++; + } + + WRITEUINT8(m, totalfiles); + + switch ((demoflags & DF_ATTACKMASK)>>DF_ATTACKSHIFT) + { + case ATTACKING_NONE: // 0 + break; + case ATTACKING_RECORD: // 1 + demotime_p = demobuf.p; + WRITEUINT32(demobuf.p,UINT32_MAX); // time + WRITEUINT32(demobuf.p,UINT32_MAX); // lap + break; + default: // 3 + break; + } + + WRITEUINT32(demobuf.p, P_GetInitSeed()); + + // Reserved for extrainfo location from start of file + demoinfo_p = demobuf.p; + WRITEUINT32(demobuf.p, 0); + + // Save netvars + CV_SaveNetVars(&demobuf.p, true); + + // Now store some info for each in-game player + for (p = 0; p < MAXPLAYERS; p++) + { + if (!playeringame[p]) + continue; + + player = &players[p]; + + WRITEUINT8(demobuf.p, p | (player->spectator ? DEMO_SPECTATOR : 0)); + + // Name + memset(name, 0, 16); + memcpy(name, player_names[p], 15); + M_Memcpy(demobuf.p,name,16); + demobuf.p += 16; + + // Skin + memset(name, 0, 16); + strncpy(name, skins[player->skin].name, 16); + M_Memcpy(demobuf.p,name,16); + demobuf.p += 16; + + // Color + memset(name, 0, 16); + strncpy(name, KartColor_Names[player->skincolor], 16); + M_Memcpy(demobuf.p,name,16); + demobuf.p += 16; + + // Score, since Kart uses this to determine where you start on the map + WRITEUINT32(demobuf.p, player->score); + + // Kart speed and weight + WRITEUINT8(demobuf.p, skins[player->skin].kartspeed); + WRITEUINT8(demobuf.p, skins[player->skin].kartweight); + } + + WRITEUINT8(demobuf.p, 0xFF); // Denote the end of the player listing + + // player lua vars, always saved even if empty... Unless it's record attack. + if (demoflags & DF_LUAVARS) + LUA_Archive(&demobuf, false); + + memset(&oldcmd,0,sizeof(oldcmd)); + memset(&oldghost,0,sizeof(oldghost)); + memset(&ghostext,0,sizeof(ghostext)); + + for (i = 0; i < MAXPLAYERS; i++) + { + ghostext[i].lastcolor = ghostext[i].color = GHC_NORMAL; + ghostext[i].lastscale = ghostext[i].scale = FRACUNIT; + + if (players[i].mo) + { + oldghost[i].x = players[i].mo->x; + oldghost[i].y = players[i].mo->y; + oldghost[i].z = players[i].mo->z; + oldghost[i].angle = players[i].mo->angle; + + // preticker started us gravity flipped + if (players[i].mo->eflags & MFE_VERTICALFLIP) + ghostext[i].flags |= EZT_FLIP; + } + } +} + +void G_BeginMetal(void) +{ + mobj_t *mo = players[consoleplayer].mo; + + if (demobuf.buffer == NULL) + { + CONS_Alert(CONS_ERROR, "No metal demo buffer allocated\n"); + metalrecording = false; + return; + } + + if (demobuf.p) + { + Z_Free(demobuf.buffer); + demobuf.buffer = NULL; + metalrecording = false; + return; + } + + demobuf.p = demobuf.buffer; + + // Write header. + M_Memcpy(demobuf.p, DEMOHEADER, 12); demobuf.p += 12; + WRITEUINT8(demobuf.p,VERSION); + WRITEUINT8(demobuf.p,SUBVERSION); + WRITEUINT16(demobuf.p,DEMOVERSION); + + // demo checksum + demobuf.p += 16; + + M_Memcpy(demobuf.p, "METL", 4); demobuf.p += 4; + + // Set up our memory. + memset(&oldmetal,0,sizeof(oldmetal)); + oldmetal.x = mo->x; + oldmetal.y = mo->y; + oldmetal.z = mo->z; + oldmetal.angle = mo->angle; +} + +void G_WriteStanding(UINT8 ranking, char *name, INT32 skinnum, UINT8 color, UINT32 val) +{ + char temp[17]; + + if (!demobuf.p) + return; + + if (demoinfo_p && *(UINT32 *)demoinfo_p == 0 && demobuf.buffer != NULL) + { + WRITEUINT8(demobuf.p, DEMOMARKER); // add the demo end marker + *(UINT32 *)demoinfo_p = demobuf.p - demobuf.buffer; + } + + WRITEUINT8(demobuf.p, DW_STANDING); + WRITEUINT8(demobuf.p, ranking); + + // Name + memset(temp, 0, 16); + strncpy(temp, name, 16); + M_Memcpy(demobuf.p,temp,16); + demobuf.p += 16; + + // Skin + memset(temp, 0, 16); + strncpy(temp, skins[skinnum].name, 16); + M_Memcpy(demobuf.p,temp,16); + demobuf.p += 16; + + // Color + memset(temp, 0, 16); + strncpy(temp, KartColor_Names[color], 16); + M_Memcpy(demobuf.p,temp,16); + demobuf.p += 16; + + // Score/time/whatever + WRITEUINT32(demobuf.p, val); +} + +void G_SetDemoTime(UINT32 ptime, UINT32 plap) +{ + if (!demo.recording || !demotime_p) + return; + if (demoflags & DF_RECORDATTACK) + { + WRITEUINT32(demotime_p, ptime); + WRITEUINT32(demotime_p, plap); + demotime_p = NULL; + } +} + +static void G_LoadDemoExtraFiles(UINT8 **pp) +{ + UINT8 totalfiles; + char filename[MAX_WADPATH]; + UINT8 md5sum[16]; + filestatus_t ncs = FS_NOTFOUND; + boolean toomany = false; + boolean alreadyloaded; + UINT8 i, j; + + totalfiles = READUINT8((*pp)); + for (i = 0; i < totalfiles; ++i) + { + if (toomany) + SKIPSTRING((*pp)); + else + { + strlcpy(filename, (char *)(*pp), sizeof filename); + SKIPSTRING((*pp)); + } + READMEM((*pp), md5sum, 16); + + if (!toomany) + { + alreadyloaded = false; + + for (j = 0; j < numwadfiles; ++j) + { + if (memcmp(md5sum, wadfiles[j]->md5sum, 16) == 0) + { + alreadyloaded = true; + break; + } + } + + if (alreadyloaded) + continue; + + if (numwadfiles >= MAX_WADFILES) + toomany = true; + else + ncs = findfile(filename, md5sum, false); + + if (toomany) + { + CONS_Alert(CONS_WARNING, M_GetText("Too many files loaded to add anymore for demo playback\n")); + if (!CON_Ready()) + M_StartMessage(M_GetText("There are too many files loaded to add this demo's addons.\n\nDemo playback may desync.\n\nPress ESC\n"), NULL, MM_NOTHING); + } + else if (ncs != FS_FOUND) + { + if (ncs == FS_NOTFOUND) + CONS_Alert(CONS_NOTICE, M_GetText("You do not have a copy of %s\n"), filename); + else if (ncs == FS_MD5SUMBAD) + CONS_Alert(CONS_NOTICE, M_GetText("Checksum mismatch on %s\n"), filename); + else + CONS_Alert(CONS_NOTICE, M_GetText("Unknown error finding file %s\n"), filename); + + if (!CON_Ready()) + M_StartMessage(M_GetText("There were errors trying to add this demo's addons. Check the console for more information.\n\nDemo playback may desync.\n\nPress ESC\n"), NULL, MM_NOTHING); + } + else + { + P_PartialAddWadFile(filename, false); + } + } + } + + if (P_PartialAddGetStage() >= 0) + P_MultiSetupWadFiles(true); // in case any partial adds were done +} + +static void G_SkipDemoExtraFiles(UINT8 **pp) +{ + UINT8 totalfiles; + UINT8 i; + + totalfiles = READUINT8((*pp)); + for (i = 0; i < totalfiles; ++i) + { + SKIPSTRING((*pp));// file name + (*pp) += 16;// md5 + } +} + +// G_CheckDemoExtraFiles: checks if our loaded WAD list matches the demo's. +// Enabling quick prevents filesystem checks to see if needed files are available to load. +static UINT8 G_CheckDemoExtraFiles(UINT8 **pp, boolean quick) +{ + UINT8 totalfiles, filesloaded, nmusfilecount; + char filename[MAX_WADPATH]; + UINT8 md5sum[16]; + boolean toomany = false; + boolean alreadyloaded; + UINT8 i, j; + UINT8 error = 0; + + totalfiles = READUINT8((*pp)); + filesloaded = 0; + for (i = 0; i < totalfiles; ++i) + { + if (toomany) + SKIPSTRING((*pp)); + else + { + strlcpy(filename, (char *)(*pp), sizeof filename); + SKIPSTRING((*pp)); + } + READMEM((*pp), md5sum, 16); + + if (!toomany) + { + alreadyloaded = false; + nmusfilecount = 0; + + for (j = 0; j < numwadfiles; ++j) + { + if (wadfiles[j]->important && j > mainwads) + nmusfilecount++; + else + continue; + + if (memcmp(md5sum, wadfiles[j]->md5sum, 16) == 0) + { + alreadyloaded = true; + + if (i != nmusfilecount-1 && error < DFILE_ERROR_OUTOFORDER) + error |= DFILE_ERROR_OUTOFORDER; + + break; + } + } + + if (alreadyloaded) + { + filesloaded++; + continue; + } + + if (numwadfiles >= MAX_WADFILES) + error = DFILE_ERROR_CANNOTLOAD; + else if (!quick && findfile(filename, md5sum, false) != FS_FOUND) + error = DFILE_ERROR_CANNOTLOAD; + else if (error < DFILE_ERROR_INCOMPLETEOUTOFORDER) + error |= DFILE_ERROR_NOTLOADED; + } else + error = DFILE_ERROR_CANNOTLOAD; + } + + // Get final file count + nmusfilecount = 0; + + for (j = 0; j < numwadfiles; ++j) + if (wadfiles[j]->important && j > mainwads) + nmusfilecount++; + + if (!error && filesloaded < nmusfilecount) + error = DFILE_ERROR_EXTRAFILES; + + return error; +} + +// Returns bitfield: +// 1 == new demo has lower time +// 2 == new demo has higher score +// 4 == new demo has higher rings +UINT8 G_CmpDemoTime(char *oldname, char *newname) +{ + UINT8 *buffer,*p; + UINT8 flags; + UINT32 oldtime, newtime, oldlap, newlap; + UINT16 oldversion; + size_t bufsize ATTRUNUSED; + UINT8 c; + UINT16 s ATTRUNUSED; + UINT8 aflags = 0; + + // load the new file + FIL_DefaultExtension(newname, ".lmp"); + bufsize = FIL_ReadFile(newname, &buffer); + I_Assert(bufsize != 0); + p = buffer; + + // read demo header + I_Assert(!memcmp(p, DEMOHEADER, 12)); + p += 12; // DEMOHEADER + c = READUINT8(p); // VERSION + I_Assert(c == VERSION); + c = READUINT8(p); // SUBVERSION + I_Assert(c == SUBVERSION); + s = READUINT16(p); + I_Assert(s == DEMOVERSION); + p += 64; // full demo title + p += 16; // demo checksum + I_Assert(!memcmp(p, "PLAY", 4)); + p += 4; // PLAY + p += 2; // gamemap + p += 16; // map md5 + flags = READUINT8(p); // demoflags + p++; // gametype + G_SkipDemoExtraFiles(&p); + + aflags = flags & (DF_RECORDATTACK|DF_NIGHTSATTACK); + I_Assert(aflags); + if (flags & DF_RECORDATTACK) + { + newtime = READUINT32(p); + newlap = READUINT32(p); + } + else // appease compiler + return 0; + + Z_Free(buffer); + + // load old file + FIL_DefaultExtension(oldname, ".lmp"); + if (!FIL_ReadFile(oldname, &buffer)) + { + CONS_Alert(CONS_ERROR, M_GetText("Failed to read file '%s'.\n"), oldname); + return UINT8_MAX; + } + p = buffer; + + // read demo header + if (memcmp(p, DEMOHEADER, 12)) + { + CONS_Alert(CONS_NOTICE, M_GetText("File '%s' invalid format. It will be overwritten.\n"), oldname); + Z_Free(buffer); + return UINT8_MAX; + } p += 12; // DEMOHEADER + p++; // VERSION + p++; // SUBVERSION + oldversion = READUINT16(p); + switch(oldversion) // demoversion + { + case DEMOVERSION: // latest always supported + p += 64; // full demo title + break; +#ifdef DEMO_COMPAT_100 + case 0x0001: + // Old replays gotta go :] + CONS_Alert(CONS_NOTICE, M_GetText("File '%s' outdated version. It will be overwritten. Nyeheheh.\n"), oldname); + Z_Free(buffer); + return UINT8_MAX; +#endif + // too old, cannot support. + default: + CONS_Alert(CONS_NOTICE, M_GetText("File '%s' invalid format. It will be overwritten.\n"), oldname); + Z_Free(buffer); + return UINT8_MAX; + } + p += 16; // demo checksum + if (memcmp(p, "PLAY", 4)) + { + CONS_Alert(CONS_NOTICE, M_GetText("File '%s' invalid format. It will be overwritten.\n"), oldname); + Z_Free(buffer); + return UINT8_MAX; + } p += 4; // "PLAY" + p += 2; // gamemap + p += 16; // mapmd5 + flags = READUINT8(p); + p++; // gametype + G_SkipDemoExtraFiles(&p); + if (!(flags & aflags)) + { + CONS_Alert(CONS_NOTICE, M_GetText("File '%s' not from same game mode. It will be overwritten.\n"), oldname); + Z_Free(buffer); + return UINT8_MAX; + } + if (flags & DF_RECORDATTACK) + { + oldtime = READUINT32(p); + oldlap = READUINT32(p); + } + else // appease compiler + return UINT8_MAX; + + Z_Free(buffer); + + c = 0; + if (newtime < oldtime + || (newtime == oldtime && (newlap < oldlap))) + c |= 1; // Better time + if (newlap < oldlap + || (newlap == oldlap && newtime < oldtime)) + c |= 1<<1; // Better lap time + return c; +} + +void G_LoadDemoInfo(menudemo_t *pdemo) +{ + UINT8 *infobuffer, *info_p, *extrainfo_p; + UINT8 version, subversion, pdemoflags; + UINT16 pdemoversion, count; + + if (!FIL_ReadFile(pdemo->filepath, &infobuffer)) + { + CONS_Alert(CONS_ERROR, M_GetText("Failed to read file '%s'.\n"), pdemo->filepath); + pdemo->type = MD_INVALID; + sprintf(pdemo->title, "INVALID REPLAY"); + + return; + } + + info_p = infobuffer; + + if (memcmp(info_p, DEMOHEADER, 12)) + { + CONS_Alert(CONS_ERROR, M_GetText("%s is not a SRB2Kart replay file.\n"), pdemo->filepath); + pdemo->type = MD_INVALID; + sprintf(pdemo->title, "INVALID REPLAY"); + Z_Free(infobuffer); + return; + } + + pdemo->type = MD_LOADED; + + info_p += 12; // DEMOHEADER + + version = READUINT8(info_p); + subversion = READUINT8(info_p); + pdemoversion = READUINT16(info_p); + + memset(pdemo->version, 0, sizeof(pdemo->version)); + snprintf(pdemo->version, sizeof(pdemo->version), "v%d.%d", version, subversion); + + switch(pdemoversion) + { + case DEMOVERSION: // latest always supported + // demo title + M_Memcpy(pdemo->title, info_p, 64); + info_p += 64; + + break; +#ifdef DEMO_COMPAT_100 + case 0x0001: + pdemo->type = MD_OUTDATED; + sprintf(pdemo->title, "Legacy Replay"); + break; +#endif + // too old, cannot support. + default: + CONS_Alert(CONS_ERROR, M_GetText("%s is an incompatible replay format and cannot be played.\n"), pdemo->filepath); + pdemo->type = MD_INVALID; + sprintf(pdemo->title, "INVALID REPLAY"); + Z_Free(infobuffer); + return; + } + + if (version != VERSION || subversion != SUBVERSION) + pdemo->type = MD_OUTDATED; + + info_p += 16; // demo checksum + if (memcmp(info_p, "PLAY", 4)) + { + CONS_Alert(CONS_ERROR, M_GetText("%s is the wrong type of recording and cannot be played.\n"), pdemo->filepath); + pdemo->type = MD_INVALID; + sprintf(pdemo->title, "INVALID REPLAY"); + Z_Free(infobuffer); + return; + } + info_p += 4; // "PLAY" + pdemo->map = READINT16(info_p); + info_p += 16; // mapmd5 + + pdemoflags = READUINT8(info_p); + + // temp? + if (!(pdemoflags & DF_MULTIPLAYER)) + { + CONS_Alert(CONS_ERROR, M_GetText("%s is not a multiplayer replay and can't be listed on this menu fully yet.\n"), pdemo->filepath); + Z_Free(infobuffer); + return; + } +#ifdef DEMO_COMPAT_100 + else if (pdemoversion == 0x0001) + { + CONS_Alert(CONS_ERROR, M_GetText("%s is a legacy multiplayer replay and cannot be played.\n"), pdemo->filepath); + pdemo->type = MD_INVALID; + sprintf(pdemo->title, "INVALID REPLAY"); + Z_Free(infobuffer); + return; + } +#endif + + pdemo->gametype = READUINT8(info_p); + + pdemo->addonstatus = G_CheckDemoExtraFiles(&info_p, true); + info_p += 4; // RNG seed + + extrainfo_p = infobuffer + READUINT32(info_p); + + // Pared down version of CV_LoadNetVars to find the kart speed + pdemo->kartspeed = 1; // Default to normal speed + count = READUINT16(info_p); + while (count--) + { + UINT16 netid; + char *svalue; + + netid = READUINT16(info_p); + svalue = (char *)info_p; + SKIPSTRING(info_p); + info_p++; // stealth + + if (netid == cv_kartspeed.netid) + { + UINT8 j; + for (j = 0; kartspeed_cons_t[j].strvalue; j++) + if (!stricmp(kartspeed_cons_t[j].strvalue, svalue)) + pdemo->kartspeed = kartspeed_cons_t[j].value; + } + else if (netid == cv_basenumlaps.netid && pdemo->gametype == GT_RACE) + pdemo->numlaps = atoi(svalue); + } + + if (pdemoflags & DF_ENCORE) + pdemo->kartspeed |= DF_ENCORE; + + // Read standings! + count = 0; + + while (READUINT8(extrainfo_p) == DW_STANDING) // Assume standings are always first in the extrainfo + { + INT32 i; + char temp[16]; + + pdemo->standings[count].ranking = READUINT8(extrainfo_p); + + // Name + M_Memcpy(pdemo->standings[count].name, extrainfo_p, 16); + extrainfo_p += 16; + + // Skin + M_Memcpy(temp,extrainfo_p,16); + extrainfo_p += 16; + pdemo->standings[count].skin = UINT8_MAX; + for (i = 0; i < numskins; i++) + if (stricmp(skins[i].name, temp) == 0) + { + pdemo->standings[count].skin = i; + break; + } + + // Color + M_Memcpy(temp,extrainfo_p,16); + extrainfo_p += 16; + for (i = 0; i < MAXSKINCOLORS; i++) + if (!stricmp(KartColor_Names[i],temp)) // SRB2kart + { + pdemo->standings[count].color = i; + break; + } + + // Score/time/whatever + pdemo->standings[count].timeorscore = READUINT32(extrainfo_p); + + count++; + + if (count >= MAXPLAYERS) + break; //@TODO still cycle through the rest of these if extra demo data is ever used + } + + // I think that's everything we need? + Z_Free(infobuffer); +} + +#if defined (_WIN32) +// return the file creation time +// useful for demos that were renamed +static long G_GetCreationTime(char *filepath) +{ + struct stat fileinfo; + + if (stat(filepath, &fileinfo) == 0) + return fileinfo.st_ctime; + + return 0; +} +#endif + +static char *G_GetDemoDate(menudemo_t *pdemo) +{ + char *datetime; + datetime = malloc(sizeof(pdemo->date)); // mallocma balls + + // no mallocma balls... :c + if (!datetime) + { + return NULL; + } + + time_t file_time = 0; + + // get le filepath + char *filename; + filename = strdup(pdemo->filepath); + +#if defined (_WIN32) + if (!filename) + { + // if we cant get a filename try just getting the file create time + file_time = G_GetCreationTime(pdemo->filepath); + goto skipfilenametime; + } +#else + if (!filename) + { + free(datetime); + return NULL; + } +#endif + + // get the actual filename Zzz... + nameonly(filename); + + // convert it to long Zzz.... + file_time = strtol(filename, NULL, 10); + free(filename); // dont need this anymore a + +#if defined (_WIN32) +skipfilenametime: +#endif + + // then throw it into localtime to get an actual human readable format lmao + struct tm *tm_buf = NULL; + tm_buf = localtime(&file_time); + + // cant believe we ended up in 1970 + if (tm_buf == NULL || tm_buf->tm_year <= 110) + { +#if defined (_WIN32) + // uh ohh, we got an invalid time + // try one more time getting the creation time + file_time = G_GetCreationTime(pdemo->filepath); + tm_buf = localtime(&file_time); + + if (tm_buf == NULL || tm_buf->tm_year <= 110) + { + free(datetime); + return NULL; + } + + goto gotcreationtime; +#else + free(datetime); + return NULL; +#endif + } + +#if defined (_WIN32) +gotcreationtime: +#endif + + const char *format; + + // US ppl are special (: + if (cv_demodateformat.value == 2) + format = "%m.%d.%Y"; + else if (cv_demodateformat.value == 1) + format = "%d.%m.%Y"; + else + format = strstr(setlocale(LC_TIME, NULL), "en_US") ? "%m.%d.%Y" : "%d.%m.%Y"; + + strftime(datetime, sizeof(pdemo->date), format, tm_buf); + + return datetime; +} + +void G_LoadDemoTitle(menudemo_t *pdemo) +{ + UINT8 infobuffer[96], *info_p; + UINT16 pdemoversion; + size_t count; + + FILE *handle = fopen(pdemo->filepath, "rb"); + + if (!handle) + { + CONS_Alert(CONS_ERROR, M_GetText("Failed to read file '%s'.\n"), pdemo->filepath); + sprintf(pdemo->title, "INVALID REPLAY"); + return; + } + + count = fread(infobuffer, 1, 96, handle); + fclose(handle); + info_p = infobuffer; + + // First check isn't too accurate technically, but well, valid replays should be larger than that anyway + if (count < 96 || memcmp(info_p, DEMOHEADER, 12)) + { + CONS_Alert(CONS_ERROR, M_GetText("%s is not a SRB2Kart replay file.\n"), pdemo->filepath); + sprintf(pdemo->title, "INVALID REPLAY"); + return; + } + + info_p += 12; // DEMOHEADER + + READUINT8(info_p); + READUINT8(info_p); + pdemoversion = READUINT16(info_p); + + memset(pdemo->date, 0, sizeof(pdemo->date)); + + switch(pdemoversion) + { + case DEMOVERSION: // latest always supported + // demo title + M_Memcpy(pdemo->title, info_p, 64); + + // demo date + char *demodate; + demodate = G_GetDemoDate(pdemo); + if (demodate) + strncpy(pdemo->date, demodate, sizeof(pdemo->date)); + free(demodate); + break; +#ifdef DEMO_COMPAT_100 + case 0x0001: + sprintf(pdemo->title, "Legacy Replay"); + break; +#endif + // too old, cannot support. + default: + CONS_Alert(CONS_ERROR, M_GetText("%s is an incompatible replay format and cannot be played.\n"), pdemo->filepath); + sprintf(pdemo->title, "INVALID REPLAY"); + } +} + +// +// G_PlayDemo +// +void G_DeferedPlayDemo(const char *name) +{ + COM_BufAddText("playdemo \""); + COM_BufAddText(name); + COM_BufAddText("\" -addfiles\n"); +} + +// +// Start a demo from a .LMP file or from a wad resource +// +#define SKIPERRORS +void G_DoPlayDemo(char *defdemoname) +{ + UINT8 i, p; + lumpnum_t l; + char skin[17],color[17],*n,*pdemoname; + UINT8 version,subversion; + UINT32 randseed; + char msg[1024]; +#if defined(SKIPERRORS) && !defined(DEVELOP) + boolean skiperrors = false; +#endif + boolean spectator; + UINT8 slots[MAXPLAYERS], kartspeed[MAXPLAYERS], kartweight[MAXPLAYERS], numslots = 0; + + G_InitDemoRewind(); + + skin[16] = '\0'; + color[16] = '\0'; + + // No demo name means we're restarting the current demo + if (defdemoname == NULL) + { + demobuf.p = demobuf.buffer; + pdemoname = ZZ_Alloc(1); // Easier than adding checks for this everywhere it's freed + } + else + { + n = defdemoname+strlen(defdemoname); + while (*n != '/' && *n != '\\' && n != defdemoname) + n--; + if (n != defdemoname) + n++; + pdemoname = ZZ_Alloc(strlen(n)+1); + strcpy(pdemoname,n); + + M_SetPlaybackMenuPointer(); + + // Internal if no extension, external if one exists + if (FIL_CheckExtension(defdemoname)) + { + //FIL_DefaultExtension(defdemoname, ".lmp"); + if (!FIL_ReadFile(defdemoname, &demobuf.buffer)) + { + snprintf(msg, 1024, M_GetText("Failed to read file '%s'.\n"), defdemoname); + CONS_Alert(CONS_ERROR, "%s", msg); + gameaction = ga_nothing; + M_StartMessage(msg, NULL, MM_NOTHING); + return; + } + demobuf.p = demobuf.buffer; + } + // load demo resource from WAD + else if ((l = W_CheckNumForName(defdemoname)) == LUMPERROR) + { + snprintf(msg, 1024, M_GetText("Failed to read lump '%s'.\n"), defdemoname); + CONS_Alert(CONS_ERROR, "%s", msg); + gameaction = ga_nothing; + M_StartMessage(msg, NULL, MM_NOTHING); + return; + } + else // it's an internal demo + { + demobuf.buffer = demobuf.p = W_CacheLumpNum(l, PU_STATIC); +#if defined(SKIPERRORS) && !defined(DEVELOP) + skiperrors = true; // SRB2Kart: Don't print warnings for staff ghosts, since they'll inevitably happen when we make bugfixes/changes... +#endif + } + } + + // read demo header + gameaction = ga_nothing; + demo.playback = true; + if (memcmp(demobuf.p, DEMOHEADER, 12)) + { + snprintf(msg, 1024, M_GetText("%s is not a SRB2Kart replay file.\n"), pdemoname); + CONS_Alert(CONS_ERROR, "%s", msg); + M_StartMessage(msg, NULL, MM_NOTHING); + G_ResetDemoPlayback(pdemoname); + return; + } + demobuf.p += 12; // DEMOHEADER + + version = READUINT8(demobuf.p); + subversion = READUINT8(demobuf.p); + demo.version = READUINT16(demobuf.p); + switch(demo.version) + { + case DEMOVERSION: // latest always supported + // demo title + M_Memcpy(demo.titlename, demobuf.p, 64); + demobuf.p += 64; + + break; +#ifdef DEMO_COMPAT_100 + case 0x0001: + break; +#endif + // too old, cannot support. + default: + snprintf(msg, 1024, M_GetText("%s is an incompatible replay format and cannot be played.\n"), pdemoname); + CONS_Alert(CONS_ERROR, "%s", msg); + M_StartMessage(msg, NULL, MM_NOTHING); + G_ResetDemoPlayback(pdemoname); + return; + } + demobuf.p += 16; // demo checksum + if (memcmp(demobuf.p, "PLAY", 4)) + { + snprintf(msg, 1024, M_GetText("%s is the wrong type of recording and cannot be played.\n"), pdemoname); + CONS_Alert(CONS_ERROR, "%s", msg); + M_StartMessage(msg, NULL, MM_NOTHING); + G_ResetDemoPlayback(pdemoname); + return; + } + demobuf.p += 4; // "PLAY" + gamemap = READINT16(demobuf.p); + demobuf.p += 16; // mapmd5 + + demoflags = READUINT8(demobuf.p); +#ifdef DEMO_COMPAT_100 + if (demo.version == 0x0001) + { + if (demoflags & DF_MULTIPLAYER) + { + snprintf(msg, 1024, M_GetText("%s is an alpha multiplayer replay and cannot be played.\n"), pdemoname); + CONS_Alert(CONS_ERROR, "%s", msg); + M_StartMessage(msg, NULL, MM_NOTHING); + G_ResetDemoPlayback(pdemoname); + return; + } + } + else + { +#endif + gametype = READUINT8(demobuf.p); + + if (demo.title) // Titledemos should always play and ought to always be compatible with whatever wadlist is running. + G_SkipDemoExtraFiles(&demobuf.p); + else if (demo.loadfiles) + G_LoadDemoExtraFiles(&demobuf.p); + else if (demo.ignorefiles) + G_SkipDemoExtraFiles(&demobuf.p); + else + { + UINT8 error = G_CheckDemoExtraFiles(&demobuf.p, false); + + if (error) + { + switch (error) + { + case DFILE_ERROR_NOTLOADED: + snprintf(msg, 1024, + M_GetText("Required files for this demo are not loaded.\n\nUse\n\"playdemo %s -addfiles\"\nto load them and play the demo.\n"), + pdemoname); + break; + + case DFILE_ERROR_OUTOFORDER: + snprintf(msg, 1024, + M_GetText("Required files for this demo are loaded out of order.\n\nUse\n\"playdemo %s -force\"\nto play the demo anyway.\n"), + pdemoname); + break; + + case DFILE_ERROR_INCOMPLETEOUTOFORDER: + snprintf(msg, 1024, + M_GetText("Required files for this demo are not loaded, and some are out of order.\n\nUse\n\"playdemo %s -addfiles\"\nto load needed files and play the demo.\n"), + pdemoname); + break; + + case DFILE_ERROR_CANNOTLOAD: + snprintf(msg, 1024, + M_GetText("Required files for this demo cannot be loaded.\n\nUse\n\"playdemo %s -force\"\nto play the demo anyway.\n"), + pdemoname); + break; + + case DFILE_ERROR_EXTRAFILES: + snprintf(msg, 1024, + M_GetText("You have additional files loaded beyond the demo's file list.\n\nUse\n\"playdemo %s -force\"\nto play the demo anyway.\n"), + pdemoname); + break; + } + + CONS_Alert(CONS_ERROR, "%s", msg); + if (!CON_Ready()) // In the console they'll just see the notice there! No point pulling them out. + M_StartMessage(msg, NULL, MM_NOTHING); + G_ResetDemoPlayback(pdemoname); + return; + } + } +#ifdef DEMO_COMPAT_100 + } +#endif + + modeattacking = (demoflags & DF_ATTACKMASK)>>DF_ATTACKSHIFT; + multiplayer = !!(demoflags & DF_MULTIPLAYER); + CON_ToggleOff(); + + hu_demotime = UINT32_MAX; + hu_demolap = UINT32_MAX; + + switch (modeattacking) + { + case ATTACKING_NONE: // 0 + break; + case ATTACKING_RECORD: // 1 + hu_demotime = READUINT32(demobuf.p); + hu_demolap = READUINT32(demobuf.p); + break; + default: // 3 + modeattacking = ATTACKING_NONE; + break; + } + + // Random seed + randseed = READUINT32(demobuf.p); +#ifdef DEMO_COMPAT_100 + if (demo.version != 0x0001) +#endif + demobuf.p += 4; // Extrainfo location + +#ifdef DEMO_COMPAT_100 + if (demo.version == 0x0001) + { + // Player name + M_Memcpy(player_names[0],demobuf.p,16); + demobuf.p += 16; + + // Skin + M_Memcpy(skin,demobuf.p,16); + demobuf.p += 16; + + // Color + M_Memcpy(color,demobuf.p,16); + demobuf.p += 16; + + demobuf.p += 5; // Backwards compat - some stats + // SRB2kart + kartspeed[0] = READUINT8(demobuf.p); + kartweight[0] = READUINT8(demobuf.p); + // + demobuf.p += 9; // Backwards compat - more stats + + // Skin not loaded? + if (!SetPlayerSkin(0, skin)) + { + snprintf(msg, 1024, M_GetText("%s features a character that is not currently loaded.\n"), pdemoname); + CONS_Alert(CONS_ERROR, "%s", msg); + M_StartMessage(msg, NULL, MM_NOTHING); + G_ResetDemoPlayback(pdemoname); + return; + } + + // ...*map* not loaded? + if (!gamemap || (gamemap > NUMMAPS) || !mapheaderinfo[gamemap-1] || !(mapheaderinfo[gamemap-1]->menuflags & LF2_EXISTSHACK)) + { + snprintf(msg, 1024, M_GetText("%s features a course that is not currently loaded.\n"), pdemoname); + CONS_Alert(CONS_ERROR, "%s", msg); + M_StartMessage(msg, NULL, MM_NOTHING); + G_ResetDemoPlayback(pdemoname); + return; + } + + // Set color + for (i = 0; i < MAXSKINCOLORS; i++) + if (!stricmp(KartColor_Names[i],color)) // SRB2kart + { + players[0].skincolor = i; + break; + } + + // net var data + CV_LoadNetVars(&demobuf.p); + + // Sigh ... it's an empty demo. + if (*demobuf.p == DEMOMARKER) + { + snprintf(msg, 1024, M_GetText("%s contains no data to be played.\n"), pdemoname); + CONS_Alert(CONS_ERROR, "%s", msg); + M_StartMessage(msg, NULL, MM_NOTHING); + G_ResetDemoPlayback(pdemoname); + return; + } + + Z_Free(pdemoname); + + memset(&oldcmd,0,sizeof(oldcmd)); + memset(&oldghost,0,sizeof(oldghost)); + memset(&ghostext,0,sizeof(ghostext)); + + CONS_Alert(CONS_WARNING, M_GetText("Demo version does not match game version. Desyncs may occur.\n")); + + // console warning messages +#if defined(SKIPERRORS) && !defined(DEVELOP) + demosynced = (!skiperrors); +#else + demosynced = true; +#endif + + // didn't start recording right away. + demo.deferstart = false; + + consoleplayer = 0; + memset(displayplayers, 0, sizeof(displayplayers)); + memset(playeringame, 0, sizeof(playeringame)); + playeringame[0] = true; + + goto post_compat; + } +#endif + + // net var data + CV_LoadNetVars(&demobuf.p); + + // Sigh ... it's an empty demo. + if (*demobuf.p == DEMOMARKER) + { + snprintf(msg, 1024, M_GetText("%s contains no data to be played.\n"), pdemoname); + CONS_Alert(CONS_ERROR, "%s", msg); + M_StartMessage(msg, NULL, MM_NOTHING); + G_ResetDemoPlayback(pdemoname); + return; + } + + Z_Free(pdemoname); + + memset(&oldcmd,0,sizeof(oldcmd)); + memset(&oldghost,0,sizeof(oldghost)); + memset(&ghostext,0,sizeof(ghostext)); + +#if defined(SKIPERRORS) && !defined(DEVELOP) + if ((VERSION != version || SUBVERSION != subversion) && !skiperrors) +#else + if (VERSION != version || SUBVERSION != subversion) +#endif + CONS_Alert(CONS_WARNING, M_GetText("Demo version does not match game version. Desyncs may occur.\n")); + + // console warning messages +#if defined(SKIPERRORS) && !defined(DEVELOP) + demosynced = (!skiperrors); +#else + demosynced = true; +#endif + + // didn't start recording right away. + demo.deferstart = false; + + //LUA_HookInt(gamemap, HOOK(MapChange)); + + consoleplayer = 0; + memset(playeringame, 0, sizeof(playeringame)); + memset(displayplayers, 0, sizeof(displayplayers)); + memset(camera, 0, sizeof(camera)); // reset freecam + + // Load players that were in-game when the map started + p = READUINT8(demobuf.p); + + while (p != 0xFF) + { + spectator = false; + if (p & DEMO_SPECTATOR) + { + spectator = true; + p &= ~DEMO_SPECTATOR; + + if (modeattacking) + { + snprintf(msg, 1024, M_GetText("%s is a Record Attack replay with spectators, and is thus invalid.\n"), pdemoname); + CONS_Alert(CONS_ERROR, "%s", msg); + M_StartMessage(msg, NULL, MM_NOTHING); + G_ResetDemoPlayback(pdemoname); + return; + } + } + slots[numslots] = p; numslots++; + + if (modeattacking && numslots > 1) + { + snprintf(msg, 1024, M_GetText("%s is a Record Attack replay with multiple players, and is thus invalid.\n"), pdemoname); + CONS_Alert(CONS_ERROR, "%s", msg); + M_StartMessage(msg, NULL, MM_NOTHING); + G_ResetDemoPlayback(pdemoname); + return; + } + + if (!playeringame[displayplayers[0]] || players[displayplayers[0]].spectator) + displayplayers[0] = consoleplayer = serverplayer = p; + + playeringame[p] = true; + players[p].spectator = spectator; + + // Name + M_Memcpy(player_names[p],demobuf.p,16); + demobuf.p += 16; + + // Skin + M_Memcpy(skin,demobuf.p,16); + demobuf.p += 16; + SetPlayerSkin(p, skin); + + // Color + M_Memcpy(color,demobuf.p,16); + demobuf.p += 16; + for (i = 0; i < MAXSKINCOLORS; i++) + if (!stricmp(KartColor_Names[i],color)) // SRB2kart + { + players[p].skincolor = i; + break; + } + + // Score, since Kart uses this to determine where you start on the map + players[p].score = READUINT32(demobuf.p); + + // Kart stats, temporarily + kartspeed[p] = READUINT8(demobuf.p); + kartweight[p] = READUINT8(demobuf.p); + + if (stricmp(skins[players[p].skin].name, skin) != 0) + FindClosestSkinForStats(p, kartspeed[p], kartweight[p]); + + // Look for the next player + p = READUINT8(demobuf.p); + } + + // end of player read (the 0xFF marker) + // so this is where we are to read our lua variables (if possible!) + if (demoflags & DF_LUAVARS) // again, used for compability, lua shit will be saved to replays regardless of if it's even been loaded + { + if (!gL) // No Lua state! ...I guess we'll just start one... + LUA_ClearState(); + + // No modeattacking check, DF_LUAVARS won't be present here. + LUA_UnArchive(&demobuf, false); + } + + splitscreen = 0; + + if (demo.title) + { + splitscreen = M_RandomKey(6)-1; + splitscreen = min(min(3, numslots-1), splitscreen); // Bias toward 1p and 4p views + + for (p = 0; p <= splitscreen; p++) + G_ResetView(p+1, slots[M_RandomKey(numslots)], false); + } + + R_ExecuteSetViewSize(); + +#ifdef DEMO_COMPAT_100 +post_compat: +#endif + + P_SetRandSeed(randseed); + G_InitNew(demoflags & DF_ENCORE, G_BuildMapName(gamemap), true, true); // Doesn't matter whether you reset or not here, given changes to resetplayer. + + for (i = 0; i < MAXPLAYERS; i++) + { + if (players[i].mo) + { + players[i].mo->color = players[i].skincolor; + oldghost[i].x = players[i].mo->x; + oldghost[i].y = players[i].mo->y; + oldghost[i].z = players[i].mo->z; + } + + // Set saved attribute values + // No cheat checking here, because even if they ARE wrong... + // it would only break the replay if we clipped them. + players[i].kartspeed = kartspeed[i]; + players[i].kartweight = kartweight[i]; + } + + if (cv_director.value) + CV_SetValue(&cv_director, 0); + + demo.deferstart = true; +} +#undef SKIPERRORS + +void G_AddGhost(char *defdemoname) +{ + INT32 i; + lumpnum_t l; + char name[17],skin[17],color[17],*n,*pdemoname,md5[16]; + demoghost *gh; + UINT8 flags; + UINT8 *buffer,*p; + mapthing_t *mthing; + UINT16 count, ghostversion; + skin_t *ghskin = &skins[0]; + UINT8 kartspeed = UINT8_MAX, kartweight = UINT8_MAX; + + name[16] = '\0'; + skin[16] = '\0'; + color[16] = '\0'; + + n = defdemoname+strlen(defdemoname); + while (*n != '/' && *n != '\\' && n != defdemoname) + n--; + if (n != defdemoname) + n++; + pdemoname = ZZ_Alloc(strlen(n)+1); + strcpy(pdemoname,n); + + // Internal if no extension, external if one exists + if (FIL_CheckExtension(defdemoname)) + { + //FIL_DefaultExtension(defdemoname, ".lmp"); + if (!FIL_ReadFileTag(defdemoname, &buffer, PU_LEVEL)) + { + CONS_Alert(CONS_ERROR, M_GetText("Failed to read file '%s'.\n"), defdemoname); + Z_Free(pdemoname); + return; + } + p = buffer; + } + // load demo resource from WAD + else if ((l = W_CheckNumForName(defdemoname)) == LUMPERROR) + { + CONS_Alert(CONS_ERROR, M_GetText("Failed to read lump '%s'.\n"), defdemoname); + Z_Free(pdemoname); + return; + } + else // it's an internal demo + buffer = p = W_CacheLumpNum(l, PU_LEVEL); + + // read demo header + if (memcmp(p, DEMOHEADER, 12)) + { + CONS_Alert(CONS_NOTICE, M_GetText("Ghost %s: Not a SRB2Kart replay.\n"), pdemoname); + Z_Free(pdemoname); + Z_Free(buffer); + return; + } + + p += 12; // DEMOHEADER + p++; // VERSION + p++; // SUBVERSION + + ghostversion = READUINT16(p); + switch(ghostversion) + { + case DEMOVERSION: // latest always supported + p += 64; // title + break; +#ifdef DEMO_COMPAT_100 + case 0x0001: + break; +#endif + // too old, cannot support. + default: + CONS_Alert(CONS_NOTICE, M_GetText("Ghost %s: Demo version incompatible.\n"), pdemoname); + Z_Free(pdemoname); + Z_Free(buffer); + return; + } + + M_Memcpy(md5, p, 16); p += 16; // demo checksum + for (gh = ghosts; gh; gh = gh->next) + if (!memcmp(md5, gh->checksum, 16)) // another ghost in the game already has this checksum? + { // Don't add another one, then! + CONS_Debug(DBG_SETUP, "Rejecting duplicate ghost %s (MD5 was matched)\n", pdemoname); + Z_Free(pdemoname); + Z_Free(buffer); + return; + } + + if (memcmp(p, "PLAY", 4)) + { + CONS_Alert(CONS_NOTICE, M_GetText("Ghost %s: Demo format unacceptable.\n"), pdemoname); + Z_Free(pdemoname); + Z_Free(buffer); + return; + } + + p += 4; // "PLAY" + p += 2; // gamemap + p += 16; // mapmd5 (possibly check for consistency?) + + flags = READUINT8(p); + + if (!(flags & DF_GHOST)) + { + CONS_Alert(CONS_NOTICE, M_GetText("Ghost %s: No ghost data in this demo.\n"), pdemoname); + Z_Free(pdemoname); + Z_Free(buffer); + return; + } + +#ifdef DEMO_COMPAT_100 + if (ghostversion != 0x0001) +#endif + p++; // gametype + +#ifdef DEMO_COMPAT_100 + if (ghostversion != 0x0001) +#endif + G_SkipDemoExtraFiles(&p); // Don't wanna modify the file list for ghosts. + switch ((flags & DF_ATTACKMASK)>>DF_ATTACKSHIFT) + { + case ATTACKING_NONE: // 0 + break; + case ATTACKING_RECORD: // 1 + p += 8; // demo time, lap + break; + default: // 3 + break; + } + + p += 4; // random seed + +#ifdef DEMO_COMPAT_100 + if (ghostversion == 0x0001) + { + // Player name (TODO: Display this somehow if it doesn't match cv_playername!) + M_Memcpy(name, p,16); + p += 16; + + // Skin + M_Memcpy(skin, p,16); + p += 16; + + // Color + M_Memcpy(color, p,16); + p += 16; + + // Ghosts do not have a player structure to put this in. + p++; // charability + p++; // charability2 + p++; // actionspd + p++; // mindash + p++; // maxdash + // SRB2kart + p++; // kartspeed + p++; // kartweight + // + p++; // normalspeed + p++; // runspeed + p++; // thrustfactor + p++; // accelstart + p++; // acceleration + p += 4; // jumpfactor + } + else +#endif + p += 4; // Extra data location reference + + // net var data + count = READUINT16(p); + while (count--) + { + p += 2; + SKIPSTRING(p); + p++; + } + + if (*p == DEMOMARKER) + { + CONS_Alert(CONS_NOTICE, M_GetText("Failed to add ghost %s: Replay is empty.\n"), pdemoname); + Z_Free(pdemoname); + Z_Free(buffer); + return; + } + +#ifdef DEMO_COMPAT_100 + if (ghostversion != 0x0001) + { +#endif + if (READUINT8(p) != 0) + { + CONS_Alert(CONS_NOTICE, M_GetText("Failed to add ghost %s: Invalid player slot.\n"), pdemoname); + Z_Free(pdemoname); + Z_Free(buffer); + return; + } + + // Player name (TODO: Display this somehow if it doesn't match cv_playername!) + M_Memcpy(name, p, 16); + p += 16; + + // Skin + M_Memcpy(skin, p, 16); + p += 16; + + // Color + M_Memcpy(color, p, 16); + p += 16; + + p += 4; // score + + kartspeed = READUINT8(p); + kartweight = READUINT8(p); + + if (READUINT8(p) != 0xFF) + { + CONS_Alert(CONS_NOTICE, M_GetText("Failed to add ghost %s: Invalid player slot.\n"), pdemoname); + Z_Free(pdemoname); + Z_Free(buffer); + return; + } +#ifdef DEMO_COMPAT_100 + } +#endif + + for (i = 0; i < numskins; i++) + if (!stricmp(skins[i].name,skin)) + { + ghskin = &skins[i]; + break; + } + + if (i == numskins) + { + if (kartspeed != UINT8_MAX && kartweight != UINT8_MAX) + ghskin = &skins[GetSkinNumClosestToStats(kartspeed, kartweight)]; + + CONS_Alert(CONS_NOTICE, M_GetText("Ghost %s: Invalid character. Falling back to %s.\n"), pdemoname, ghskin->name); + } + + gh = Z_Calloc(sizeof(demoghost), PU_LEVEL, NULL); + gh->next = ghosts; + gh->buffer = buffer; + M_Memcpy(gh->checksum, md5, 16); + gh->p = p; + + ghosts = gh; + + gh->version = ghostversion; + mthing = playerstarts[0]; + I_Assert(mthing); + { // A bit more complex than P_SpawnPlayer because ghosts aren't solid and won't just push themselves out of the ceiling. + fixed_t z,f,c; + gh->mo = P_SpawnMobj(mthing->x << FRACBITS, mthing->y << FRACBITS, 0, MT_GHOST); + gh->mo->angle = FixedAngle(mthing->angle*FRACUNIT); + f = gh->mo->floorz; + c = gh->mo->ceilingz - mobjinfo[MT_PLAYER].height; + if (!!(mthing->options & MTF_AMBUSH) ^ !!(mthing->options & MTF_OBJECTFLIP)) + { + z = c; + if (mthing->options >> ZSHIFT) + z -= ((mthing->options >> ZSHIFT) << FRACBITS); + if (z < f) + z = f; + } + else + { + z = f; + if (mthing->options >> ZSHIFT) + z += ((mthing->options >> ZSHIFT) << FRACBITS); + if (z > c) + z = c; + } + gh->mo->z = z; + } + gh->mo->state = states+S_KART_STND1; // SRB2kart - was S_PLAY_STND + gh->mo->sprite = gh->mo->state->sprite; + gh->mo->frame = (gh->mo->state->frame & FF_FRAMEMASK) | tr_trans20<mo->tics = -1; + + gh->oldmo.x = gh->mo->x; + gh->oldmo.y = gh->mo->y; + gh->oldmo.z = gh->mo->z; + + // Set skin + gh->mo->skin = gh->oldmo.skin = ghskin; + + // Set color + gh->mo->color = ((skin_t*)gh->mo->skin)->prefcolor; + for (i = 0; i < MAXSKINCOLORS; i++) + if (!stricmp(KartColor_Names[i],color)) // SRB2kart + { + gh->mo->color = (UINT8)i; + break; + } + gh->oldmo.color = gh->mo->color; + + CONS_Printf(M_GetText("Added ghost %s from %s\n"), name, pdemoname); + Z_Free(pdemoname); +} + +// A simplified version of G_AddGhost... +void G_UpdateStaffGhostName(lumpnum_t l) +{ + UINT8 *buffer,*p; + UINT16 ghostversion; + UINT8 flags; + + buffer = p = W_CacheLumpNum(l, PU_CACHE); + + // read demo header + if (memcmp(p, DEMOHEADER, 12)) + { + goto fail; + } + + p += 12; // DEMOHEADER + p++; // VERSION + p++; // SUBVERSION + + ghostversion = READUINT16(p); + switch(ghostversion) + { + case DEMOVERSION: // latest always supported + p += 64; // full demo title + break; + +#ifdef DEMO_COMPAT_100 + case 0x0001: + break; +#endif + + // too old, cannot support. + default: + goto fail; + } + + p += 16; // demo checksum + + if (memcmp(p, "PLAY", 4)) + { + goto fail; + } + + p += 4; // "PLAY" + p += 2; // gamemap + p += 16; // mapmd5 (possibly check for consistency?) + + flags = READUINT8(p); + if (!(flags & DF_GHOST)) + { + goto fail; // we don't NEED to do it here, but whatever + } + +#ifdef DEMO_COMPAT_100 + if (ghostversion != 0x0001) +#endif + p++; // Gametype + +#ifdef DEMO_COMPAT_100 + if (ghostversion != 0x0001) +#endif + G_SkipDemoExtraFiles(&p); + + switch ((flags & DF_ATTACKMASK)>>DF_ATTACKSHIFT) + { + case ATTACKING_NONE: // 0 + break; + case ATTACKING_RECORD: // 1 + p += 8; // demo time, lap + break; + default: // 3 + break; + } + + p += 4; // random seed + + +#ifdef DEMO_COMPAT_100 + if (ghostversion == 0x0001) + { + // Player name + M_Memcpy(dummystaffname, p,16); + dummystaffname[16] = '\0'; + goto fail; // Not really a failure but whatever + } +#endif + + p += 4; // Extrainfo location marker + + // Ehhhh don't need ghostversion here (?) so I'll reuse the var here + ghostversion = READUINT16(p); + while (ghostversion--) + { + p += 2; + SKIPSTRING(p); + p++; // stealth + } + + // Assert first player is in and then read name + if (READUINT8(p) != 0) + goto fail; + M_Memcpy(dummystaffname, p,16); + dummystaffname[16] = '\0'; + + // Ok, no longer any reason to care, bye +fail: + Z_Free(buffer); + return; +} + +// +// G_TimeDemo +// NOTE: name is a full filename for external demos +// +static INT32 restorecv_vidwait; + +void G_TimeDemo(const char *name) +{ + nodrawers = M_CheckParm("-nodraw"); + noblit = M_CheckParm("-noblit"); + restorecv_vidwait = cv_vidwait.value; + if (cv_vidwait.value) + CV_Set(&cv_vidwait, "0"); + demo.timing = true; + singletics = true; + framecount = 0; + demostarttime = I_GetTime(); + G_DeferedPlayDemo(name); +} + +void G_DoPlayMetal(void) +{ + lumpnum_t l; + mobj_t *mo = NULL; + thinker_t *th; + + // it's an internal demo + if ((l = W_CheckNumForName(va("%sMS",G_BuildMapName(gamemap)))) == LUMPERROR) + { + CONS_Alert(CONS_WARNING, M_GetText("No bot recording for this map.\n")); + return; + } + else + metalbuffer = metal_p = W_CacheLumpNum(l, PU_STATIC); + + // find metal sonic + for (th = thinkercap.next; th != &thinkercap; th = th->next) + { + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + + mo = (mobj_t *)th; + if (mo->type == MT_METALSONIC_RACE) + break; + } + if (!mo) + { + CONS_Alert(CONS_ERROR, M_GetText("Failed to find bot entity.\n")); + Z_Free(metalbuffer); + return; + } + + // read demo header + metal_p += 12; // DEMOHEADER + metal_p++; // VERSION + metal_p++; // SUBVERSION + metalversion = READUINT16(metal_p); + switch(metalversion) + { + case DEMOVERSION: // latest always supported + break; +#ifdef DEMO_COMPAT_100 + case 0x0001: + I_Error("You need to implement demo compat here, doofus! %s:%d", __FILE__, __LINE__); +#endif + // too old, cannot support. + default: + CONS_Alert(CONS_WARNING, M_GetText("Failed to load bot recording for this map, format version incompatible.\n")); + Z_Free(metalbuffer); + return; + } + metal_p += 16; // demo checksum + if (memcmp(metal_p, "METL", 4)) + { + CONS_Alert(CONS_WARNING, M_GetText("Failed to load bot recording for this map, wasn't recorded in Metal format.\n")); + Z_Free(metalbuffer); + return; + } metal_p += 4; // "METL" + + // read initial tic + memset(&oldmetal,0,sizeof(oldmetal)); + oldmetal.x = mo->x; + oldmetal.y = mo->y; + oldmetal.z = mo->z; + oldmetal.angle = mo->angle; + metalplayback = mo; +} + +void G_DoneLevelLoad(void) +{ + CONS_Printf(M_GetText("Loaded level in %f sec\n"), (double)(I_GetTime() - demostarttime) / TICRATE); + framecount = 0; + demostarttime = I_GetTime(); +} + +/* +=================== += += G_CheckDemoStatus += += Called after a death or level completion to allow demos to be cleaned up += Returns true if a new demo loop action will take place +=================== +*/ + +// Stops metal sonic's demo. Separate from other functions because metal + replays can coexist +void G_StopMetalDemo(void) +{ + // Metal Sonic finishing doesn't end the game, dammit. + Z_Free(metalbuffer); + metalbuffer = NULL; + metalplayback = NULL; + metal_p = NULL; +} + +// Stops metal sonic recording. +ATTRNORETURN void FUNCNORETURN G_StopMetalRecording(void) +{ + boolean saved = false; + if (demobuf.p && demobuf.buffer != NULL) + { + UINT8 *p = demobuf.buffer+16; // checksum position +#ifdef NOMD5 + UINT8 i; + WRITEUINT8(demobuf.p, DEMOMARKER); // add the demo end marker + for (i = 0; i < 16; i++, p++) + *p = P_RandomByte(); // This MD5 was chosen by fair dice roll and most likely < 50% correct. +#else + WRITEUINT8(demobuf.p, DEMOMARKER); // add the demo end marker + md5_buffer((char *)p+16, demobuf.p - (p+16), (void *)p); // make a checksum of everything after the checksum in the file. +#endif + saved = FIL_WriteFile(va("%sMS.LMP", G_BuildMapName(gamemap)), demobuf.buffer, demobuf.p - demobuf.buffer); // finally output the file. + } + Z_Free(demobuf.buffer); + demobuf.buffer = NULL; + metalrecording = false; + if (saved) + I_Error("Saved to %sMS.LMP", G_BuildMapName(gamemap)); + I_Error("Failed to save demo!"); +} + +// reset engine variable set for the demos +// called from stopdemo command, map command, and g_checkdemoStatus. +void G_StopDemo(void) +{ + Z_Free(demobuf.buffer); + demobuf.buffer = NULL; + demo.playback = false; + if (demo.title) + modeattacking = ATTACKING_NONE; + demo.title = false; + demo.timing = false; + singletics = false; + + UINT8 i; + for (i = 0; i < MAXSPLITSCREENPLAYERS; ++i) + { + camera[i].freecam = false; + camera[i].localangle = 0; + camera[i].localaiming = 0; + } + + CV_SetValue(&cv_playbackspeed, 1); + demo.rewinding = false; + CL_ClearRewinds(); + + if (gamestate == GS_LEVEL && rendermode != render_none) + { + V_SetPaletteLump("PLAYPAL"); // Reset the palette + R_ReInitColormaps(0, LUMPERROR); + } + if (gamestate == GS_INTERMISSION) + Y_EndIntermission(); // cleanup + if (gamestate == GS_VOTING) + Y_EndVote(); + + M_ClearMenus(true); + + G_SetGamestate(GS_NULL); + wipegamestate = GS_NULL; + SV_StopServer(); + SV_ResetServer(); +} + +// Stops timing a demo. +static void G_StopTimingDemo(void) +{ + INT32 demotime; + double f1, f2; + demotime = I_GetTime() - demostarttime; + if (!demotime) + return; + G_StopDemo(); + demo.timing = false; + f1 = (double)demotime; + f2 = (double)framecount*TICRATE; + + CONS_Printf(M_GetText("timed %u gametics in %d realtics - %u frames\n%f seconds, %f avg fps\n"), + leveltime, demotime, (UINT32)framecount, f1/TICRATE, f2/f1); + + if (restorecv_vidwait != cv_vidwait.value) + CV_SetValue(&cv_vidwait, restorecv_vidwait); + + D_StartTitle(); +} + + +boolean G_CheckDemoStatus(void) +{ + while (ghosts) + { + demoghost *next = ghosts->next; + Z_Free(ghosts); + ghosts = next; + } + ghosts = NULL; + + // DO NOT end metal sonic demos here + + if (demo.timing) + { + G_StopTimingDemo(); + return true; + } + + if (demo.playback) + { + if (demo.quitafterplaying) + I_Quit(); + + if (multiplayer && !demo.title) + { + G_ExitLevel(); + } + else if (modeattacking && !demo.title) // nooo dont crash our titledemos + { + G_StopDemo(); + M_EndModeAttackRun(); + } + else + { + G_StopDemo(); + D_StartTitle(); + } + + return true; + } + + if (!demo.recording) + return false; + + if (modeattacking || demo.savemode != DSM_NOTSAVING) + { + G_SaveDemo(); + return true; + } + + G_ResetDemoRecording(); + + return false; +} + +void G_ResetDemoRecording(void) +{ + if (demobuf.buffer) + Z_Free(demobuf.buffer); + demobuf.buffer = NULL; + demo.recording = false; +} + +static void G_ResetDemoPlayback(char *pdemoname) +{ + if (pdemoname) + Z_Free(pdemoname); + if (demobuf.buffer) + Z_Free(demobuf.buffer); + demobuf.buffer = NULL; + demo.playback = false; + if (demo.title) + modeattacking = ATTACKING_NONE; + demo.title = false; +} + +void G_SaveDemo(void) +{ + if (!demobuf.p) + { + CONS_Alert(CONS_ERROR, "Failed to save Demo. No Demo pointer exists!\n"); + // reset the demo buffer + G_ResetDemoRecording(); + return; + } + + if (demobuf.buffer == NULL) + { + CONS_Alert(CONS_ERROR, "Failed to save Demo. No Demo buffer allocated!\n"); + // reset the demo buffer + G_ResetDemoRecording(); + return; + } + + UINT8 *p = demobuf.buffer+16; // after version + UINT32 length; + + // Ensure extrainfo pointer is always available, even if no info is present. + if (demoinfo_p && *(UINT32 *)demoinfo_p == 0) + { + WRITEUINT8(demobuf.p, DEMOMARKER); // add the demo end marker + *(UINT32 *)demoinfo_p = demobuf.p - demobuf.buffer; + } + WRITEUINT8(demobuf.p, DW_END); // Mark end of demo extra data. + + M_Memcpy(p, demo.titlename, 64); // Write demo title here + p += 64; + + if (multiplayer) + { + // Change the demo's name to be a slug of the title + char demo_slug[128]; + char *writepoint; + size_t i, strindex = 0; + boolean dash = true; + + for (i = 0; demo.titlename[i] && i < 127; i++) + { + if ((demo.titlename[i] >= 'a' && demo.titlename[i] <= 'z') || + (demo.titlename[i] >= '0' && demo.titlename[i] <= '9')) + { + demo_slug[strindex] = demo.titlename[i]; + strindex++; + dash = false; + } + else if (demo.titlename[i] >= 'A' && demo.titlename[i] <= 'Z') + { + demo_slug[strindex] = demo.titlename[i] + 'a' - 'A'; + strindex++; + dash = false; + } + else if (!dash) + { + demo_slug[strindex] = '-'; + strindex++; + dash = true; + } + } + + demo_slug[strindex] = 0; + if (dash) demo_slug[strindex-1] = 0; + + writepoint = strstr(demoname, "-") + 1; + demo_slug[128 - (writepoint - demoname) - 4] = 0; + sprintf(writepoint, "%s.lmp", demo_slug); + } + + length = *(UINT32 *)demoinfo_p; + WRITEUINT32(demoinfo_p, length); +#ifdef NOMD5 + for (UINT8 k = 0; k < 16; k++, p++) + *p = M_RandomByte(); // This MD5 was chosen by fair dice roll and most likely < 50% correct. +#else + // Make a checksum of everything after the checksum in the file up to the end of the standard data. Extrainfo is freely modifiable. + md5_buffer((char *)p+16, (demobuf.buffer + length) - (p+16), p); +#endif + + + if (FIL_WriteFile(va(pandf, srb2home, demoname), demobuf.buffer, demobuf.p - demobuf.buffer)) // finally output the file. + demo.savemode = DSM_SAVED; + + G_ResetDemoRecording(); + + if (modeattacking != ATTACKING_RECORD) + { + if (demo.savemode == DSM_SAVED) + CONS_Printf(M_GetText("Demo %s recorded\n"), demoname); + else + CONS_Alert(CONS_WARNING, M_GetText("Demo %s not saved\n"), demoname); + } +} + +boolean G_DemoTitleResponder(event_t *ev) +{ + INT32 ch; + + if (ev->type != ev_keydown) + return false; + + ch = (INT32)ev->data1; + + // Only ESC and non-keyboard keys abort connection + if (ch == KEY_ESCAPE) + { + demo.savemode = (cv_recordmultiplayerdemos.value == 2) ? DSM_WILLAUTOSAVE : DSM_NOTSAVING; + return true; + } + + if (ch == KEY_ENTER || ch >= KEY_MOUSE1) + { + demo.savemode = DSM_WILLSAVE; + return true; + } + + M_TextInputHandle(&demo.titlenameinput, ch); + + return true; +} diff --git a/src/g_demo.h b/src/g_demo.h new file mode 100644 index 000000000..de1495e91 --- /dev/null +++ b/src/g_demo.h @@ -0,0 +1,191 @@ +// SONIC ROBO BLAST 2 KART +//----------------------------------------------------------------------------- +// Copyright (C) 1993-1996 by id Software, Inc. +// Copyright (C) 1998-2000 by DooM Legacy Team. +// Copyright (C) 1999-2020 by Sonic Team Junior. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file g_demo.h +/// \brief Demo recording and playback + +#ifndef __G_DEMO__ +#define __G_DEMO__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "doomdef.h" +#include "doomstat.h" +#include "d_event.h" +#include "p_saveg.h" +#include "m_textinput.h" + +extern savebuffer_t demobuf; + +// demoplaying back and demo recording +extern consvar_t cv_recordmultiplayerdemos, cv_netdemosyncquality, cv_maxdemosize, cv_demochangemap; +extern consvar_t cv_demodateformat; +extern consvar_t cv_resyncdemo; + +// Publicly-accessible demo vars +struct demovars_s { + char titlename[65]; + textinput_t titlenameinput; + boolean recording, playback, timing; + UINT16 version; // Current file format of the demo being played + boolean title; // Title Screen demo can be cancelled by any key + boolean rewinding; // Rewind in progress + + boolean loadfiles, ignorefiles; // Demo file loading options + boolean fromtitle; // SRB2Kart: Don't stop the music + boolean inreplayhut; // Go back to replayhut after demos + boolean quitafterplaying; // quit after playing a demo from cmdline + boolean deferstart; // don't start playing demo right away + + tic_t savebutton; // Used to determine when the local player can choose to save the replay while the race is still going + enum { + DSM_NOTSAVING, + DSM_WILLAUTOSAVE, + DSM_TITLEENTRY, + DSM_WILLSAVE, + DSM_SAVED + } savemode; +}; + +extern struct demovars_s demo; + +typedef enum { + MD_NOTLOADED, + MD_LOADED, + MD_SUBDIR, + MD_OUTDATED, + MD_INVALID +} menudemotype_e; + +typedef struct menudemo_s { + char filepath[256]; + menudemotype_e type; + + char title[65]; // Null-terminated for string prints + char date[11]; // date when replay was recorded + char version[12]; // combined version and subversion + UINT16 map; + UINT8 addonstatus; // What do we need to do addon-wise to play this demo? + UINT8 gametype; + UINT8 kartspeed; // Add OR DF_ENCORE for encore mode, idk + UINT8 numlaps; + + struct { + UINT8 ranking; + char name[17]; + UINT8 skin, color; + UINT32 timeorscore; + } standings[MAXPLAYERS]; +} menudemo_t; + +extern mobj_t *metalplayback; + +// Only called by startup code. +void G_RecordDemo(const char *name); +void G_RecordMetal(void); +void G_BeginRecording(void); +void G_BeginMetal(void); + +// Only called by shutdown code. +void G_WriteStanding(UINT8 ranking, char *name, INT32 skinnum, UINT8 color, UINT32 val); +void G_SetDemoTime(UINT32 ptime, UINT32 plap); +UINT8 G_CmpDemoTime(char *oldname, char *newname); + +void G_LoadDemoInfo(menudemo_t *pdemo); +void G_LoadDemoTitle(menudemo_t *pdemo); // For use in replay search feature +void G_DeferedPlayDemo(const char *demo); + +typedef enum +{ + GHC_NORMAL = 0, + GHC_SUPER, + GHC_FIREFLOWER, + GHC_INVINCIBLE +} ghostcolor_t; + +extern UINT8 demo_extradata[MAXPLAYERS]; +extern UINT8 demo_writerng; +#define DXD_RESPAWN 0x01 // "respawn" command in console +#define DXD_SKIN 0x02 // skin changed +#define DXD_NAME 0x04 // name changed +#define DXD_COLOR 0x08 // color changed +#define DXD_PLAYSTATE 0x10 // state changed between playing, spectating, or not in-game + +#define DXD_PST_PLAYING 0x01 +#define DXD_PST_SPECTATING 0x02 +#define DXD_PST_LEFT 0x03 + +// Record/playback tics +void G_ReadDemoExtraData(void); +void G_WriteDemoExtraData(void); +void G_ReadDemoTiccmd(ticcmd_t *cmd, INT32 playernum); +void G_WriteDemoTiccmd(ticcmd_t *cmd, INT32 playernum); +void G_GhostAddThok(INT32 playernum); +void G_GhostAddSpin(INT32 playernum); +void G_GhostAddRev(INT32 playernum); +void G_GhostAddColor(INT32 playernum, ghostcolor_t color); +void G_GhostAddFlip(INT32 playernum); +void G_GhostAddScale(INT32 playernum, fixed_t scale); +void G_GhostAddHit(INT32 playernum, mobj_t *victim); +void G_WriteAllGhostTics(void); +void G_WriteGhostTic(mobj_t *ghost, INT32 playernum); +void G_ConsAllGhostTics(void); +void G_ConsGhostTic(INT32 playernum); +void G_GhostTicker(void); + +void G_InitDemoRewind(void); +void G_StoreRewindInfo(void); +void G_PreviewRewind(tic_t previewtime); +void G_ConfirmRewind(tic_t rewindtime); + +void G_ReadMetalTic(mobj_t *metal); +void G_WriteMetalTic(mobj_t *metal); +void G_SaveMetal(UINT8 **buffer); +void G_LoadMetal(UINT8 **buffer); + +// Your naming conventions are stupid and useless. +// There is no conflict here. +typedef struct demoghost { + UINT8 checksum[16]; + UINT8 *buffer, *p, color; + UINT16 version; + mobj_t oldmo, *mo; + struct demoghost *next; +} demoghost; +extern demoghost *ghosts; + +// G_CheckDemoExtraFiles: checks if our loaded WAD list matches the demo's. +#define DFILE_ERROR_NOTLOADED 0x01 // Files are not loaded, but can be without a restart. +#define DFILE_ERROR_OUTOFORDER 0x02 // Files are loaded, but out of order. +#define DFILE_ERROR_INCOMPLETEOUTOFORDER 0x03 // Some files are loaded out of order, but others are not. +#define DFILE_ERROR_CANNOTLOAD 0x04 // Files are missing and cannot be loaded. +#define DFILE_ERROR_EXTRAFILES 0x05 // Extra files outside of the replay's file list are loaded. + +void G_ResetDemoRecording(void); +void G_DoPlayDemo(char *defdemoname); +void G_TimeDemo(const char *name); +void G_AddGhost(char *defdemoname); +void G_UpdateStaffGhostName(lumpnum_t l); +void G_DoPlayMetal(void); +void G_DoneLevelLoad(void); +void G_StopMetalDemo(void); +ATTRNORETURN void FUNCNORETURN G_StopMetalRecording(void); +void G_StopDemo(void); +boolean G_CheckDemoStatus(void); +void G_SaveDemo(void); +boolean G_DemoTitleResponder(event_t *ev); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // __G_DEMO__ diff --git a/src/g_game.c b/src/g_game.c index b7b18fcb7..201d0e013 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -59,10 +59,6 @@ #include "discord.h" #endif -// for replay dates -#include -#include - gameaction_t gameaction; gamestate_t gamestate = GS_NULL; UINT8 ultimatemode = false; @@ -87,8 +83,6 @@ static void G_DoContinued(void); static void G_DoWorldDone(void); static void G_DoStartVote(void); -static void G_ResetDemoPlayback(char *pdemoname); - music_t mapmusic; INT16 gamemap = 1; @@ -108,15 +102,6 @@ UINT8 modeattacking = ATTACKING_NONE; boolean imcontinuing = false; boolean runemeraldmanager = false; -// menu demo things -UINT8 numDemos = 0; //3; -- i'm FED UP of losing my skincolour to a broken demo. change this back when we make new ones -UINT32 demoDelayTime = 15*TICRATE; -UINT32 demoIdleTime = 3*TICRATE; - -boolean nodrawers; // for comparative timing purposes -boolean noblit; // for comparative timing purposes -static tic_t demostarttime; // for comparative timing purposes - boolean netgame; // only true if packets are broadcast boolean multiplayer; boolean playeringame[MAXPLAYERS]; @@ -211,19 +196,19 @@ UINT16 spacetimetics = 11*TICRATE + (TICRATE/2); UINT16 extralifetics = 4*TICRATE; // SRB2kart -tic_t introtime = 108+5; // plus 5 for white fade -tic_t starttime = 6*TICRATE + (3*TICRATE/4); -tic_t raceexittime = 5*TICRATE + (2*TICRATE/3); -tic_t battleexittime = 8*TICRATE; -INT32 hyudorotime = 7*TICRATE; -INT32 stealtime = TICRATE/2; -INT32 sneakertime = TICRATE + (TICRATE/3); -INT32 itemtime = 8*TICRATE; -INT32 comebacktime = 10*TICRATE; -INT32 bumptime = 6; -INT32 wipeoutslowtime = 20; -INT32 wantedreduce = 5*TICRATE; -INT32 wantedfrequency = 10*TICRATE; +const tic_t introtime = 108+5; // plus 5 for white fade +const tic_t starttime = 6*TICRATE + (3*TICRATE/4); +const tic_t raceexittime = 5*TICRATE + (2*TICRATE/3); +const tic_t battleexittime = 8*TICRATE; +const INT32 hyudorotime = 7*TICRATE; +const INT32 stealtime = TICRATE/2; +const INT32 sneakertime = TICRATE + (TICRATE/3); +const INT32 itemtime = 8*TICRATE; +const INT32 comebacktime = 10*TICRATE; +const INT32 bumptime = 6; +const INT32 wipeoutslowtime = 20; +const INT32 wantedreduce = 5*TICRATE; +const INT32 wantedfrequency = 10*TICRATE; INT32 gameovertics = 15*TICRATE; @@ -290,64 +275,8 @@ UINT32 timesBeaten; UINT32 timesBeatenWithEmeralds; //UINT32 timesBeatenUltimate; -//@TODO put these all in a struct for namespacing purposes? -static char demoname[128]; -savebuffer_t demobuf; -static UINT8 *demotime_p, *demoinfo_p; -static UINT8 *demoend; -static UINT8 demoflags; -static boolean demosynced = true; // console warning message - -struct demovars_s demo; - -boolean metalrecording; // recording as metal sonic -mobj_t *metalplayback; -static UINT8 *metalbuffer = NULL; -static UINT8 *metal_p; -static UINT16 metalversion; - -// extra data stuff (events registered this frame while recording) -static struct { - UINT8 flags; // EZT flags - - // EZT_COLOR - UINT8 color, lastcolor; - - // EZT_SCALE - fixed_t scale, lastscale; - - // EZT_KART - INT32 kartitem, kartamount, kartbumpers; - - UINT8 desyncframes; // Don't try to resync unless we've been off for two frames, to monkeypatch a few trouble spots - - // EZT_HIT - UINT16 hits; - mobj_t **hitlist; -} ghostext[MAXPLAYERS]; - -// Your naming conventions are stupid and useless. -// There is no conflict here. -demoghost *ghosts = NULL; - INT16 prevmap, nextmap; -static CV_PossibleValue_t recordmultiplayerdemos_cons_t[] = {{0, "Disabled"}, {1, "Manual Save"}, {2, "Auto Save"}, {0, NULL}}; -consvar_t cv_recordmultiplayerdemos = {"netdemo_record", "Manual Save", CV_SAVE, recordmultiplayerdemos_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; - -static CV_PossibleValue_t netdemosyncquality_cons_t[] = {{1, "MIN"}, {35, "MAX"}, {0, NULL}}; -consvar_t cv_netdemosyncquality = {"netdemo_syncquality", "1", CV_SAVE, netdemosyncquality_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; - -// Units are MiB. -static CV_PossibleValue_t maxdemosize_cons_t[] = {{10, "MIN"}, {100, "MAX"}, {0, NULL}}; -consvar_t cv_maxdemosize = {"maxdemosize", "10", CV_SAVE, maxdemosize_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; - -static CV_PossibleValue_t demochangemap_cons_t[] = {{0, "Disabled"}, {1, "Diff Map"}, {2, "Always"}, {0, NULL}}; -consvar_t cv_demochangemap = {"netdemo_savemapchange", "Disabled", CV_SAVE, demochangemap_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; - -static CV_PossibleValue_t demodateformat_cons_t[] = {{0, "Automatic"}, {1, "EU"}, {2, "US"}, {0, NULL}}; -consvar_t cv_demodateformat = {"netdemo_dateformat", "Automatic", CV_SAVE, demodateformat_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; - // Analog Control void SendWeaponPref(void); void SendWeaponPref2(void); @@ -4290,3943 +4219,6 @@ INT32 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep) return newmapnum; } -// -// DEMO RECORDING -// - -#define DEMOVERSION 0x0002 -#define DEMOHEADER "\xF0" "KartReplay" "\x0F" - -#define DF_GHOST 0x01 // This demo contains ghost data too! -#define DF_RECORDATTACK 0x02 // This demo is from record attack and contains its final completion time! -#define DF_NIGHTSATTACK 0x04 // This demo is from NiGHTS attack and contains its time left, score, and mares! -#define DF_ATTACKMASK 0x06 // This demo is from ??? attack and contains ??? - -#define DF_LUAVARS 0x20 // this demo contains extra lua vars; this is mostly used for backwards compability - -#define DF_ATTACKSHIFT 1 -#define DF_ENCORE 0x40 -#define DF_MULTIPLAYER 0x80 // This demo was recorded in multiplayer mode! - -#ifdef DEMO_COMPAT_100 -#define DF_FILELIST 0x08 // This demo contains an extra files list -#define DF_GAMETYPEMASK 0x30 -#define DF_GAMESHIFT 4 -#endif - -#define DEMO_SPECTATOR 0x40 - -// For demos -#define ZT_FWD 0x01 -#define ZT_SIDE 0x02 -#define ZT_ANGLE 0x04 -#define ZT_BUTTONS 0x08 -#define ZT_AIMING 0x10 -#define ZT_DRIFT 0x20 -#define ZT_LATENCY 0x40 -#define DEMOMARKER 0x80 // demoend - -UINT8 demo_extradata[MAXPLAYERS]; -UINT8 demo_writerng; // 0=no, 1=yes, 2=yes but on a timeout -static ticcmd_t oldcmd[MAXPLAYERS]; - -#define DW_END 0xFF // End of extradata block -#define DW_RNG 0xFE // Check RNG seed! - -#define DW_EXTRASTUFF 0xFE // Numbers below this are reserved for writing player slot data - -// Below consts are only used for demo extrainfo sections -#define DW_STANDING 0x00 - -// For Metal Sonic and time attack ghosts -#define GZT_XYZ 0x01 -#define GZT_MOMXY 0x02 -#define GZT_MOMZ 0x04 -#define GZT_ANGLE 0x08 -// Not used for Metal Sonic -#define GZT_SPRITE 0x10 // Animation frame -#define GZT_EXTRA 0x20 -#define GZT_NIGHTS 0x40 // NiGHTS Mode stuff! - -// GZT_EXTRA flags -#define EZT_THOK 0x01 // Spawned a thok object -#define EZT_SPIN 0x02 // Because one type of thok object apparently wasn't enough -#define EZT_REV 0x03 // And two types wasn't enough either yet -#define EZT_THOKMASK 0x03 -#define EZT_COLOR 0x04 // Changed color (Super transformation, Mario fireflowers/invulnerability, etc.) -#define EZT_FLIP 0x08 // Reversed gravity -#define EZT_SCALE 0x10 // Changed size -#define EZT_HIT 0x20 // Damaged a mobj -#define EZT_SPRITE 0x40 // Changed sprite set completely out of PLAY (NiGHTS, SOCs, whatever) -#define EZT_KART 0x80 // SRB2Kart: Changed current held item/quantity and bumpers for battle - -static mobj_t oldmetal, oldghost[MAXPLAYERS]; - -void G_SaveMetal(UINT8 **buffer) -{ - I_Assert(buffer != NULL && *buffer != NULL); - - WRITEUINT32(*buffer, metal_p - metalbuffer); -} - -void G_LoadMetal(UINT8 **buffer) -{ - I_Assert(buffer != NULL && *buffer != NULL); - - G_DoPlayMetal(); - metal_p = metalbuffer + READUINT32(*buffer); -} - -ticcmd_t *G_CopyTiccmd(ticcmd_t* dest, const ticcmd_t* src, const size_t n) -{ - return M_Memcpy(dest, src, n*sizeof(*src)); -} - -ticcmd_t *G_MoveTiccmd(ticcmd_t* dest, const ticcmd_t* src, const size_t n) -{ - size_t i; - for (i = 0; i < n; i++) - { - dest[i].forwardmove = src[i].forwardmove; - dest[i].sidemove = src[i].sidemove; - dest[i].angleturn = SHORT(src[i].angleturn); - dest[i].aiming = (INT16)SHORT(src[i].aiming); - dest[i].buttons = (UINT16)SHORT(src[i].buttons); - dest[i].driftturn = (INT16)SHORT(src[i].driftturn); - dest[i].latency = (INT16)SHORT(src[i].latency); - } - return dest; -} - -// Finds a skin with the closest stats if the expected skin doesn't exist. -static INT32 GetSkinNumClosestToStats(UINT8 kartspeed, UINT8 kartweight) -{ - INT32 i, closest_skin = 0; - UINT8 closest_stats = UINT8_MAX, stat_diff; - - for (i = 0; i < numskins; i++) - { - stat_diff = abs(skins[i].kartspeed - kartspeed) + abs(skins[i].kartweight - kartweight); - if (stat_diff < closest_stats) - { - closest_stats = stat_diff; - closest_skin = i; - } - } - - return closest_skin; -} - -static void FindClosestSkinForStats(UINT32 p, UINT8 kartspeed, UINT8 kartweight) -{ - INT32 closest_skin = GetSkinNumClosestToStats(kartspeed, kartweight); - - //CONS_Printf("Using %s instead...\n", skins[closest_skin].name); - SetPlayerSkinByNum(p, closest_skin); -} - -void G_ReadDemoExtraData(void) -{ - INT32 p, extradata, i; - char name[17]; - - if (leveltime > starttime) - { - rewind_t *rewind = CL_SaveRewindPoint(demobuf.p - demobuf.buffer); - if (rewind) - { - memcpy(rewind->oldcmd, oldcmd, sizeof (oldcmd)); - memcpy(rewind->oldghost, oldghost, sizeof (oldghost)); - } - } - - memset(name, '\0', 17); - - p = READUINT8(demobuf.p); - - while (p < DW_EXTRASTUFF) - { - extradata = READUINT8(demobuf.p); - - if (extradata & DXD_RESPAWN) - { - if (players[p].mo) - P_DamageMobj(players[p].mo, NULL, NULL, DMG_INSTAKILL); // Is this how this should work..? - } - if (extradata & DXD_SKIN) - { - UINT8 kartspeed, kartweight; - - // Skin - M_Memcpy(name, demobuf.p, 16); - demobuf.p += 16; - SetPlayerSkin(p, name); - - kartspeed = READUINT8(demobuf.p); - kartweight = READUINT8(demobuf.p); - - if (stricmp(skins[players[p].skin].name, name) != 0) - FindClosestSkinForStats(p, kartspeed, kartweight); - - players[p].kartspeed = kartspeed; - players[p].kartweight = kartweight; - } - if (extradata & DXD_COLOR) - { - // Color - M_Memcpy(name, demobuf.p, 16); - demobuf.p += 16; - for (i = 0; i < MAXSKINCOLORS; i++) - if (!stricmp(KartColor_Names[i], name)) // SRB2kart - { - players[p].skincolor = i; - if (players[p].mo) - players[p].mo->color = i; - break; - } - } - if (extradata & DXD_NAME) - { - // Name - M_Memcpy(player_names[p],demobuf.p,16); - demobuf.p += 16; - } - if (extradata & DXD_PLAYSTATE) - { - extradata = READUINT8(demobuf.p); - - switch (extradata) { - case DXD_PST_PLAYING: - players[p].pflags |= PF_WANTSTOJOIN; // fuck you - break; - - case DXD_PST_SPECTATING: - players[p].pflags &= ~PF_WANTSTOJOIN; // double-fuck you - if (!playeringame[p]) - { - CL_ClearPlayer(p); - playeringame[p] = true; - G_AddPlayer(p); - players[p].spectator = true; - - // There's likely an off-by-one error in timing recording or playback of joins. This hacks around it so I don't have to find out where that is. \o/ - if (oldcmd[p].forwardmove) - P_RandomByte(); - } - else - { - players[p].spectator = true; - if (players[p].mo) - P_DamageMobj(players[p].mo, NULL, NULL, DMG_INSTAKILL); - else - players[p].playerstate = PST_REBORN; - } - break; - - case DXD_PST_LEFT: - CL_RemovePlayer(p, 0); - break; - } - - G_ResetViews(); - - // maybe these are necessary? - if (G_BattleGametype()) - K_CheckBumpers(); // SRB2Kart - else if (G_RaceGametype()) - P_CheckRacers(); // also SRB2Kart - } - - - p = READUINT8(demobuf.p); - } - - while (p != DW_END) - { - UINT32 rng; - UINT32 checkrng; - - switch (p) - { - case DW_RNG: - rng = READUINT32(demobuf.p); - checkrng = P_GetRandSeed(); - if (checkrng != rng) - { - if (demosynced) - { - CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced (RNG)!\n")); - CONS_Printf("expected rng %d got %d\n", rng, checkrng); - } - demosynced = false; - - P_SetRandSeed(rng); - } - } - - p = READUINT8(demobuf.p); - } - - if (!(demoflags & DF_GHOST) && *demobuf.p == DEMOMARKER) - { - // end of demo data stream - G_CheckDemoStatus(); - return; - } -} - -void G_WriteDemoExtraData(void) -{ - INT32 i; - char name[17]; - - for (i = 0; i < MAXPLAYERS; i++) - { - if (demo_extradata[i]) - { - WRITEUINT8(demobuf.p, i); - WRITEUINT8(demobuf.p, demo_extradata[i]); - - //if (demo_extradata[i] & DXD_RESPAWN) has no extra data - if (demo_extradata[i] & DXD_SKIN) - { - // Skin - memset(name, 0, 16); - strncpy(name, skins[players[i].skin].name, 16); - M_Memcpy(demobuf.p,name,16); - demobuf.p += 16; - - WRITEUINT8(demobuf.p, skins[players[i].skin].kartspeed); - WRITEUINT8(demobuf.p, skins[players[i].skin].kartweight); - } - if (demo_extradata[i] & DXD_COLOR) - { - // Color - memset(name, 0, 16); - strncpy(name, KartColor_Names[players[i].skincolor], 16); - M_Memcpy(demobuf.p,name,16); - demobuf.p += 16; - } - if (demo_extradata[i] & DXD_NAME) - { - // Name - memset(name, 0, 16); - memcpy(name, player_names[i], 15); // Keeping 1 null byte for safety, sorry players with name containing more than 15 characters - M_Memcpy(demobuf.p,name,16); - demobuf.p += 16; - } - if (demo_extradata[i] & DXD_PLAYSTATE) - { - demo_writerng = 1; - if (!playeringame[i]) - WRITEUINT8(demobuf.p, DXD_PST_LEFT); - else if ( - players[i].spectator && - !(players[i].pflags & PF_WANTSTOJOIN) // <= fuck you specifically - ) - WRITEUINT8(demobuf.p, DXD_PST_SPECTATING); - else - WRITEUINT8(demobuf.p, DXD_PST_PLAYING); - } - } - - demo_extradata[i] = 0; - } - - // May not be necessary, but might as well play it safe... - if ((leveltime & 255) == 128) - demo_writerng = 1; - - { - static UINT8 timeout = 0; - - if (timeout) timeout--; - - if (demo_writerng == 1 || (demo_writerng == 2 && timeout == 0)) - { - demo_writerng = 0; - timeout = 16; - WRITEUINT8(demobuf.p, DW_RNG); - WRITEUINT32(demobuf.p, P_GetRandSeed()); - } - } - - WRITEUINT8(demobuf.p, DW_END); -} - -void G_ReadDemoTiccmd(ticcmd_t *cmd, INT32 playernum) -{ - UINT8 ziptic; - - if (!demobuf.p || !demo.deferstart) - return; - ziptic = READUINT8(demobuf.p); - - if (ziptic & ZT_FWD) - oldcmd[playernum].forwardmove = READSINT8(demobuf.p); - if (ziptic & ZT_SIDE) - oldcmd[playernum].sidemove = READSINT8(demobuf.p); - if (ziptic & ZT_ANGLE) - oldcmd[playernum].angleturn = READINT16(demobuf.p); - if (ziptic & ZT_BUTTONS) - oldcmd[playernum].buttons = READUINT16(demobuf.p); - if (ziptic & ZT_AIMING) - oldcmd[playernum].aiming = READINT16(demobuf.p); - if (ziptic & ZT_DRIFT) - oldcmd[playernum].driftturn = READINT16(demobuf.p); - if (ziptic & ZT_LATENCY) - oldcmd[playernum].latency = READUINT8(demobuf.p); - - G_CopyTiccmd(cmd, &oldcmd[playernum], 1); - - // SRB2kart: Copy-pasted from ticcmd building, removes that crappy demo cam - if (((players[displayplayers[0]].mo && players[displayplayers[0]].speed > 0) // Moving - || (leveltime > starttime && (cmd->buttons & BT_ACCELERATE && cmd->buttons & BT_BRAKE)) // Rubber-burn turn - || (players[displayplayers[0]].kartstuff[k_respawn]) // Respawning - || (players[displayplayers[0]].spectator || objectplacing)) // Not a physical player - && !(players[displayplayers[0]].kartstuff[k_spinouttimer] && players[displayplayers[0]].kartstuff[k_sneakertimer])) // Spinning and boosting cancels out spinout - localangle[0] += (cmd->angleturn<<16); - - if (!(demoflags & DF_GHOST) && *demobuf.p == DEMOMARKER) - { - // end of demo data stream - G_CheckDemoStatus(); - return; - } -} - -void G_WriteDemoTiccmd(ticcmd_t *cmd, INT32 playernum) -{ - char ziptic = 0; - UINT8 *ziptic_p; - - if (!demobuf.p) - return; - - ziptic_p = demobuf.p++; // the ziptic, written at the end of this function - - if (cmd->forwardmove != oldcmd[playernum].forwardmove) - { - WRITEUINT8(demobuf.p,cmd->forwardmove); - oldcmd[playernum].forwardmove = cmd->forwardmove; - ziptic |= ZT_FWD; - } - - if (cmd->sidemove != oldcmd[playernum].sidemove) - { - WRITEUINT8(demobuf.p,cmd->sidemove); - oldcmd[playernum].sidemove = cmd->sidemove; - ziptic |= ZT_SIDE; - } - - if (cmd->angleturn != oldcmd[playernum].angleturn) - { - WRITEINT16(demobuf.p,cmd->angleturn); - oldcmd[playernum].angleturn = cmd->angleturn; - ziptic |= ZT_ANGLE; - } - - if (cmd->buttons != oldcmd[playernum].buttons) - { - WRITEUINT16(demobuf.p,cmd->buttons); - oldcmd[playernum].buttons = cmd->buttons; - ziptic |= ZT_BUTTONS; - } - - if (cmd->aiming != oldcmd[playernum].aiming) - { - WRITEINT16(demobuf.p,cmd->aiming); - oldcmd[playernum].aiming = cmd->aiming; - ziptic |= ZT_AIMING; - } - - if (cmd->driftturn != oldcmd[playernum].driftturn) - { - WRITEINT16(demobuf.p,cmd->driftturn); - oldcmd[playernum].driftturn = cmd->driftturn; - ziptic |= ZT_DRIFT; - } - - if (cmd->latency != oldcmd[playernum].latency) - { - WRITEUINT8(demobuf.p,cmd->latency); - oldcmd[playernum].latency = cmd->latency; - ziptic |= ZT_LATENCY; - } - - *ziptic_p = ziptic; - - // attention here for the ticcmd size! - // latest demos with mouse aiming byte in ticcmd - if (!(demoflags & DF_GHOST) && ziptic_p > demoend - 9) - { - G_CheckDemoStatus(); // no more space - return; - } -} - -void G_GhostAddThok(INT32 playernum) -{ - if (!demo.recording || !(demoflags & DF_GHOST)) - return; - - ghostext[playernum].flags = (ghostext[playernum].flags & ~EZT_THOKMASK) | EZT_THOK; -} - -void G_GhostAddSpin(INT32 playernum) -{ - if (!demo.recording || !(demoflags & DF_GHOST)) - return; - - ghostext[playernum].flags = (ghostext[playernum].flags & ~EZT_THOKMASK) | EZT_SPIN; -} - -void G_GhostAddRev(INT32 playernum) -{ - if (!demo.recording || !(demoflags & DF_GHOST)) - return; - - ghostext[playernum].flags = (ghostext[playernum].flags & ~EZT_THOKMASK) | EZT_REV; -} - -void G_GhostAddFlip(INT32 playernum) -{ - if (!demo.recording || !(demoflags & DF_GHOST)) - return; - - ghostext[playernum].flags |= EZT_FLIP; -} - -void G_GhostAddColor(INT32 playernum, ghostcolor_t color) -{ - if (!demo.recording || !(demoflags & DF_GHOST)) - return; - - if (ghostext[playernum].lastcolor == (UINT8)color) - { - ghostext[playernum].flags &= ~EZT_COLOR; - return; - } - - ghostext[playernum].flags |= EZT_COLOR; - ghostext[playernum].color = (UINT8)color; -} - -void G_GhostAddScale(INT32 playernum, fixed_t scale) -{ - if (!demo.recording || !(demoflags & DF_GHOST)) - return; - - if (ghostext[playernum].lastscale == scale) - { - ghostext[playernum].flags &= ~EZT_SCALE; - return; - } - - ghostext[playernum].flags |= EZT_SCALE; - ghostext[playernum].scale = scale; -} - -void G_GhostAddHit(INT32 playernum, mobj_t *victim) -{ - if (!demo.recording || !(demoflags & DF_GHOST)) - return; - - ghostext[playernum].flags |= EZT_HIT; - ghostext[playernum].hits++; - ghostext[playernum].hitlist = Z_Realloc(ghostext[playernum].hitlist, ghostext[playernum].hits * sizeof(mobj_t *), PU_LEVEL, &ghostext[playernum].hitlist); - P_SetTarget(ghostext[playernum].hitlist + (ghostext[playernum].hits-1), victim); -} - -void G_WriteAllGhostTics(void) -{ - if (!demobuf.p) - return; - - UINT8 *save_demo_p = demobuf.p; -#define CHECKSPACE(num) if (demobuf.p+(num) > demoend) { demobuf.p = save_demo_p; G_CheckDemoStatus(); return; } - - boolean toobig = false; - INT32 i, counter = leveltime; - - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator) - continue; - - if (P_MobjWasRemoved(players[i].mo)) - continue; - - counter++; - - if (multiplayer && ((counter % cv_netdemosyncquality.value) != 0)) // Only write 1 in this many ghost datas per tic to cut down on multiplayer replay size. - continue; - - if (((ghostext[i].flags && (ghostext[i].flags & EZT_HIT)) || ghostext[i].hits) - && !ghostext[i].hitlist) // hitlist might be freed during resynch, beware PU_LEVEL! - { - ghostext[i].hits = 0; - continue; - } - - CHECKSPACE(1); - - WRITEUINT8(demobuf.p, i); - G_WriteGhostTic(players[i].mo, i); - - // attention here for the ticcmd size! - // latest demos with mouse aiming byte in ticcmd - if (demobuf.p >= demoend - (13 + 9 + 9)) - { - toobig = true; - break; - } - } - - CHECKSPACE(1); - WRITEUINT8(demobuf.p, 0xFF); - - if (toobig) - { - G_CheckDemoStatus(); // no more space - return; - } - -#undef CHECKSPACE -} - -void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) -{ - char ziptic = 0; - UINT8 *ziptic_p; - UINT32 i; - UINT8 sprite; - UINT8 frame; - - if (!demobuf.p) - return; - - UINT8 *save_demo_p = demobuf.p; -#define CHECKSPACE(num) if (demobuf.p+(num) > demoend) { demobuf.p = save_demo_p; G_CheckDemoStatus(); return; } - - if (!(demoflags & DF_GHOST)) - return; // No ghost data to write. - - if (ghost->player && ghost->player->pflags & PF_NIGHTSMODE && ghost->tracer) - { - // We're talking about the NiGHTS thing, not the normal platforming thing! - ziptic |= GZT_NIGHTS; - ghost = ghost->tracer; - } - - ziptic_p = demobuf.p++; // the ziptic, written at the end of this function - -#define MAXMOM (0x7FFF<<8) - - // GZT_XYZ is only useful if you've moved 256 FRACUNITS or more in a single tic. - if (abs(ghost->x-oldghost[playernum].x) > MAXMOM - || abs(ghost->y-oldghost[playernum].y) > MAXMOM - || abs(ghost->z-oldghost[playernum].z) > MAXMOM - || ((UINT8)(leveltime & 255) > 0 && (UINT8)(leveltime & 255) <= (UINT8)cv_netdemosyncquality.value)) // Hack to enable slightly nicer resyncing - { - oldghost[playernum].x = ghost->x; - oldghost[playernum].y = ghost->y; - oldghost[playernum].z = ghost->z; - ziptic |= GZT_XYZ; - - CHECKSPACE(sizeof(fixed_t)*3); - WRITEFIXED(demobuf.p, oldghost[playernum].x); - WRITEFIXED(demobuf.p, oldghost[playernum].y); - WRITEFIXED(demobuf.p, oldghost[playernum].z); - } - else - { - // For moving normally: - // Store one full byte of movement, plus one byte of fractional movement. - INT16 momx = (INT16)((ghost->x-oldghost[playernum].x + (1<<4))>>8); - INT16 momy = (INT16)((ghost->y-oldghost[playernum].y + (1<<4))>>8); - - if (momx != oldghost[playernum].momx - || momy != oldghost[playernum].momy) - { - oldghost[playernum].momx = momx; - oldghost[playernum].momy = momy; - ziptic |= GZT_MOMXY; - - CHECKSPACE(4); - - WRITEINT16(demobuf.p, momx); - WRITEINT16(demobuf.p, momy); - } - - momx = (INT16)((ghost->z-oldghost[playernum].z + (1<<4))>>8); - - if (momx != oldghost[playernum].momz) - { - oldghost[playernum].momz = momx; - ziptic |= GZT_MOMZ; - - CHECKSPACE(2); - - WRITEINT16(demobuf.p, momx); - } - - // This SHOULD set oldghost.x/y/z to match ghost->x/y/z - // but it keeps the fractional loss of one byte, - // so it will hopefully be made up for in future tics. - oldghost[playernum].x += oldghost[playernum].momx<<8; - oldghost[playernum].y += oldghost[playernum].momy<<8; - oldghost[playernum].z += oldghost[playernum].momz<<8; - } - -#undef MAXMOM - - // Only store the 8 most relevant bits of angle - // because exact values aren't too easy to discern to begin with when only 8 angles have different sprites - // and it does not affect this mode of movement at all anyway. - if (ghost->angle>>24 != oldghost[playernum].angle) - { - oldghost[playernum].angle = ghost->angle>>24; - ziptic |= GZT_ANGLE; - - CHECKSPACE(1); - - WRITEUINT8(demobuf.p, oldghost[playernum].angle); - } - - // Store the sprite frame. - frame = ghost->frame & 0xFF; - if (frame != oldghost[playernum].frame) - { - oldghost[playernum].frame = frame; - ziptic |= GZT_SPRITE; - - CHECKSPACE(1); - - WRITEUINT8(demobuf.p, oldghost[playernum].frame); - } - - // Check for sprite set changes - sprite = ghost->sprite; - if (sprite != oldghost[playernum].sprite) - { - oldghost[playernum].sprite = sprite; - ghostext[playernum].flags |= EZT_SPRITE; - } - - if (ghost->player) - { - if ( - ghostext[playernum].kartitem != ghost->player->kartstuff[k_itemtype] || - ghostext[playernum].kartamount != ghost->player->kartstuff[k_itemamount] || - ghostext[playernum].kartbumpers != ghost->player->kartstuff[k_bumper] - ) - { - ghostext[playernum].flags |= EZT_KART; - ghostext[playernum].kartitem = ghost->player->kartstuff[k_itemtype]; - ghostext[playernum].kartamount = ghost->player->kartstuff[k_itemamount]; - ghostext[playernum].kartbumpers = ghost->player->kartstuff[k_bumper]; - - } - } - - if (ghostext[playernum].color == ghostext[playernum].lastcolor) - ghostext[playernum].flags &= ~EZT_COLOR; - - if (ghostext[playernum].scale == ghostext[playernum].lastscale) - ghostext[playernum].flags &= ~EZT_SCALE; - - if (ghostext[playernum].flags) - { - ziptic |= GZT_EXTRA; - WRITEUINT8(demobuf.p, ghostext[playernum].flags); - - if (ghostext[playernum].flags & EZT_COLOR) - { - CHECKSPACE(1); - WRITEUINT8(demobuf.p, ghostext[playernum].color); - ghostext[playernum].lastcolor = ghostext[playernum].color; - } - - if (ghostext[playernum].flags & EZT_SCALE) - { - CHECKSPACE(sizeof(fixed_t)); - WRITEFIXED(demobuf.p, ghostext[playernum].scale); - ghostext[playernum].lastscale = ghostext[playernum].scale; - } - - if (ghostext[playernum].flags & EZT_HIT) - { - CHECKSPACE(2); - WRITEUINT16(demobuf.p, ghostext[playernum].hits); - - for (i = 0; i < ghostext[playernum].hits; i++) - { - mobj_t *mo = ghostext[playernum].hitlist[i]; - - CHECKSPACE(4+4+2+sizeof(fixed_t)*3+sizeof(angle_t)); - - WRITEUINT32(demobuf.p, UINT32_MAX); // reserved for some method of determining exactly which mobj this is. (mobjnum doesn't work here.) - WRITEUINT32(demobuf.p, mo->type); - WRITEUINT16(demobuf.p, (UINT16)mo->health); - WRITEFIXED(demobuf.p, mo->x); - WRITEFIXED(demobuf.p, mo->y); - WRITEFIXED(demobuf.p, mo->z); - WRITEANGLE(demobuf.p, mo->angle); - P_SetTarget(ghostext[playernum].hitlist+i, NULL); - } - - ghostext[playernum].hits = 0; - } - - if (ghostext[playernum].flags & EZT_SPRITE) - { - CHECKSPACE(1); - WRITEUINT8(demobuf.p, sprite); - } - - if (ghostext[playernum].flags & EZT_KART) - { - CHECKSPACE(12); - WRITEINT32(demobuf.p, ghostext[playernum].kartitem); - WRITEINT32(demobuf.p, ghostext[playernum].kartamount); - WRITEINT32(demobuf.p, ghostext[playernum].kartbumpers); - } - - ghostext[playernum].flags = 0; - } - - *ziptic_p = ziptic; -#undef CHECKSPACE -} - -void G_ConsAllGhostTics(void) -{ - UINT8 p; - - if (!demobuf.p || !demo.deferstart) - return; - - p = READUINT8(demobuf.p); - - while (p != 0xFF) - { - G_ConsGhostTic(p); - p = READUINT8(demobuf.p); - } - - if (*demobuf.p == DEMOMARKER) - { - // end of demo data stream - G_CheckDemoStatus(); - return; - } -} - -// Uses ghost data to do consistency checks on your position. -// This fixes desynchronising demos when fighting eggman. -void G_ConsGhostTic(INT32 playernum) -{ - UINT8 ziptic; - fixed_t px,py,pz,gx,gy,gz; - mobj_t *testmo; - fixed_t syncleeway; - boolean nightsfail = false; - - if (!(demoflags & DF_GHOST)) - return; // No ghost data to use. - - testmo = players[playernum].mo; - - // Grab ghost data. - ziptic = READUINT8(demobuf.p); - - if (ziptic & GZT_XYZ) - { - oldghost[playernum].x = READFIXED(demobuf.p); - oldghost[playernum].y = READFIXED(demobuf.p); - oldghost[playernum].z = READFIXED(demobuf.p); - syncleeway = 0; - } - else - { - if (ziptic & GZT_MOMXY) - { - oldghost[playernum].momx = READINT16(demobuf.p)<<8; - oldghost[playernum].momy = READINT16(demobuf.p)<<8; - } - - if (ziptic & GZT_MOMZ) - oldghost[playernum].momz = READINT16(demobuf.p)<<8; - - oldghost[playernum].x += oldghost[playernum].momx; - oldghost[playernum].y += oldghost[playernum].momy; - oldghost[playernum].z += oldghost[playernum].momz; - syncleeway = FRACUNIT; - } - - if (ziptic & GZT_ANGLE) - demobuf.p++; - - if (ziptic & GZT_SPRITE) - demobuf.p++; - - if (ziptic & GZT_NIGHTS) - { - if (!testmo || !testmo->player || !(testmo->player->pflags & PF_NIGHTSMODE) || !testmo->tracer) - nightsfail = true; - else - testmo = testmo->tracer; - } - - if (ziptic & GZT_EXTRA) - { // But wait, there's more! - ziptic = READUINT8(demobuf.p); - if (ziptic & EZT_COLOR) - demobuf.p++; - - if (ziptic & EZT_SCALE) - demobuf.p += sizeof(fixed_t); - - if (ziptic & EZT_HIT) - { // Resync mob damage. - UINT16 i, count = READUINT16(demobuf.p); - thinker_t *th; - mobj_t *mobj; - - UINT32 type; - UINT16 health; - fixed_t x; - fixed_t y; - fixed_t z; - - for (i = 0; i < count; i++) - { - demobuf.p += 4; // reserved. - type = READUINT32(demobuf.p); - health = READUINT16(demobuf.p); - x = READFIXED(demobuf.p); - y = READFIXED(demobuf.p); - z = READFIXED(demobuf.p); - demobuf.p += sizeof(angle_t); // angle, unnecessary for cons. - - mobj = NULL; - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - mobj = (mobj_t *)th; - if (mobj->type == (mobjtype_t)type && mobj->x == x && mobj->y == y && mobj->z == z) - break; - mobj = NULL; // wasn't this one, keep searching. - } - - if (mobj && mobj->health != health) // Wasn't damaged?! This is desync! Fix it! - { - if (demosynced) - { - CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced (health)!\n")); - CONS_Printf("expected health %d got %d\n", health, mobj->health); - } - - demosynced = false; - P_DamageMobj(mobj, players[0].mo, players[0].mo, 1); - } - } - } - - if (ziptic & EZT_SPRITE) - demobuf.p++; - - if (ziptic & EZT_KART) - { - ghostext[playernum].kartitem = READINT32(demobuf.p); - ghostext[playernum].kartamount = READINT32(demobuf.p); - ghostext[playernum].kartbumpers = READINT32(demobuf.p); - } - } - - if (testmo) - { - // Re-synchronise - px = testmo->x; - py = testmo->y; - pz = testmo->z; - gx = oldghost[playernum].x; - gy = oldghost[playernum].y; - gz = oldghost[playernum].z; - - if (nightsfail || abs(px-gx) > syncleeway || abs(py-gy) > syncleeway || abs(pz-gz) > syncleeway) - { - ghostext[playernum].desyncframes++; - - if (ghostext[playernum].desyncframes >= 2) - { - if (demosynced) - CONS_Alert(CONS_WARNING, "Demo playback has desynced (player %s)!\n", player_names[playernum]); - demosynced = false; - - P_UnsetThingPosition(testmo); - testmo->x = oldghost[playernum].x; - testmo->y = oldghost[playernum].y; - P_SetThingPosition(testmo); - testmo->z = oldghost[playernum].z; - - if (abs(testmo->z - testmo->floorz) < 4*FRACUNIT) - testmo->z = testmo->floorz; // Sync players to the ground when they're likely supposed to be there... - - ghostext[playernum].desyncframes = 2; - } - } - else - ghostext[playernum].desyncframes = 0; - - if ( -#ifdef DEMO_COMPAT_100 - demo.version != 0x0001 && -#endif - ( - players[playernum].kartstuff[k_itemtype] != ghostext[playernum].kartitem || - players[playernum].kartstuff[k_itemamount] != ghostext[playernum].kartamount || - players[playernum].kartstuff[k_bumper] != ghostext[playernum].kartbumpers - ) - ) - { - if (demosynced) - { - CONS_Alert(CONS_WARNING, "Demo playback has desynced (item/bumpers)!(player %s)!\n", player_names[playernum]); - CONS_Printf("expected item type %d got %d\n", ghostext[playernum].kartitem, players[playernum].kartstuff[k_itemtype]); - CONS_Printf("expected item amount %d got %d\n", ghostext[playernum].kartamount, players[playernum].kartstuff[k_itemamount]); - } - demosynced = false; - - players[playernum].kartstuff[k_itemtype] = ghostext[playernum].kartitem; - players[playernum].kartstuff[k_itemamount] = ghostext[playernum].kartamount; - players[playernum].kartstuff[k_bumper] = ghostext[playernum].kartbumpers; - } - } - - if (*demobuf.p == DEMOMARKER) - { - // end of demo data stream - G_CheckDemoStatus(); - return; - } -} - -void G_GhostTicker(void) -{ - demoghost *g,*p; - - for (g = ghosts, p = NULL; g; g = g->next) - { - // Skip normal demo data. - UINT8 ziptic = READUINT8(g->p); - -#ifdef DEMO_COMPAT_100 - if (g->version != 0x0001) - { -#endif - while (ziptic != DW_END) // Get rid of extradata stuff - { - if (ziptic == 0) // Only support player 0 info for now - { - ziptic = READUINT8(g->p); - if (ziptic & DXD_SKIN) - g->p += 18; // We _could_ read this info, but it shouldn't change anything in record attack... - if (ziptic & DXD_COLOR) - g->p += 16; // Same tbh - if (ziptic & DXD_NAME) - g->p += 16; // yea - if (ziptic & DXD_PLAYSTATE && READUINT8(g->p) != DXD_PST_PLAYING) - I_Error("Ghost is not a record attack ghost"); //@TODO lmao don't blow up like this - } - else if (ziptic == DW_RNG) - g->p += 4; // RNG seed - else - I_Error("Ghost is not a record attack ghost"); //@TODO lmao don't blow up like this - - ziptic = READUINT8(g->p); - } - - ziptic = READUINT8(g->p); // Back to actual ziptic stuff -#ifdef DEMO_COMPAT_100 - } -#endif - - if (ziptic & ZT_FWD) - g->p++; - if (ziptic & ZT_SIDE) - g->p++; - if (ziptic & ZT_ANGLE) - g->p += 2; - if (ziptic & ZT_BUTTONS) - g->p += 2; - if (ziptic & ZT_AIMING) - g->p += 2; - if (ziptic & ZT_DRIFT) - g->p += 2; - if (ziptic & ZT_LATENCY) - g->p += 1; - - // Grab ghost data. - ziptic = READUINT8(g->p); - -#ifdef DEMO_COMPAT_100 - if (g->version != 0x0001) - { -#endif - if (ziptic == 0xFF) - goto skippedghosttic; // Didn't write ghost info this frame - else if (ziptic != 0) - I_Error("Ghost is not a record attack ghost"); //@TODO lmao don't blow up like this - ziptic = READUINT8(g->p); -#ifdef DEMO_COMPAT_100 - } -#endif - if (ziptic & GZT_XYZ) - { - g->oldmo.x = READFIXED(g->p); - g->oldmo.y = READFIXED(g->p); - g->oldmo.z = READFIXED(g->p); - } - else - { - if (ziptic & GZT_MOMXY) - { - g->oldmo.momx = READINT16(g->p)<<8; - g->oldmo.momy = READINT16(g->p)<<8; - } - if (ziptic & GZT_MOMZ) - g->oldmo.momz = READINT16(g->p)<<8; - g->oldmo.x += g->oldmo.momx; - g->oldmo.y += g->oldmo.momy; - g->oldmo.z += g->oldmo.momz; - } - if (ziptic & GZT_ANGLE) - g->oldmo.angle = READUINT8(g->p)<<24; - if (ziptic & GZT_SPRITE) - g->oldmo.frame = READUINT8(g->p); - - // Update ghost - P_UnsetThingPosition(g->mo); - g->mo->x = g->oldmo.x; - g->mo->y = g->oldmo.y; - g->mo->z = g->oldmo.z; - P_SetThingPosition(g->mo); - g->mo->angle = g->oldmo.angle; - g->mo->frame = g->oldmo.frame | tr_trans30<p); - if (ziptic & EZT_COLOR) - { - g->color = READUINT8(g->p); - switch(g->color) - { - default: - case GHC_NORMAL: // Go back to skin color - g->mo->color = g->oldmo.color; - break; - // Handled below - case GHC_SUPER: - case GHC_INVINCIBLE: - break; - case GHC_FIREFLOWER: // Fireflower - g->mo->color = SKINCOLOR_WHITE; - break; - } - } - if (ziptic & EZT_FLIP) - g->mo->eflags ^= MFE_VERTICALFLIP; - if (ziptic & EZT_SCALE) - { - g->mo->destscale = READFIXED(g->p); - if (g->mo->destscale != g->mo->scale) - P_SetScale(g->mo, g->mo->destscale); - } - if (ziptic & EZT_THOKMASK) - { // Let's only spawn ONE of these per frame, thanks. - mobj_t *mobj; - INT32 type = -1; - if (g->mo->skin) - { - switch (ziptic & EZT_THOKMASK) - { - case EZT_THOK: - type = (UINT32)mobjinfo[MT_PLAYER].painchance; - break; - case EZT_SPIN: - type = (UINT32)mobjinfo[MT_PLAYER].damage; - break; - case EZT_REV: - type = (UINT32)mobjinfo[MT_PLAYER].raisestate; - break; - } - } - if (type != -1) - { - if (type == MT_GHOST) - { - mobj = P_SpawnGhostMobj(g->mo); // does a large portion of the work for us - mobj->frame = (mobj->frame & ~FF_FRAMEMASK)|tr_trans60<mo->x, g->mo->y, g->mo->z - FixedDiv(FixedMul(g->mo->info->height, g->mo->scale) - g->mo->height,3*FRACUNIT), MT_THOK); - mobj->sprite = states[mobjinfo[type].spawnstate].sprite; - mobj->frame = (states[mobjinfo[type].spawnstate].frame & FF_FRAMEMASK) | tr_trans60<tics = -1; // nope. - mobj->color = g->mo->color; - if (g->mo->eflags & MFE_VERTICALFLIP) - { - mobj->flags2 |= MF2_OBJECTFLIP; - mobj->eflags |= MFE_VERTICALFLIP; - } - P_SetScale(mobj, g->mo->scale); - mobj->destscale = g->mo->scale; - } - mobj->floorz = mobj->z; - mobj->ceilingz = mobj->z+mobj->height; - P_UnsetThingPosition(mobj); - mobj->flags = MF_NOBLOCKMAP|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY; // make an ATTEMPT to curb crazy SOCs fucking stuff up... - P_SetThingPosition(mobj); - mobj->fuse = 8; - P_SetTarget(&mobj->target, g->mo); - } - } - if (ziptic & EZT_HIT) - { // Spawn hit poofs for killing things! - UINT16 i, count = READUINT16(g->p), health; - //UINT32 type; - fixed_t x,y,z; - angle_t angle; - mobj_t *poof; - for (i = 0; i < count; i++) - { - g->p += 4; // reserved - g->p += 4; // backwards compat., type used to be here - health = READUINT16(g->p); - x = READFIXED(g->p); - y = READFIXED(g->p); - z = READFIXED(g->p); - angle = READANGLE(g->p); - if (health != 0 || i >= 4) // only spawn for the first 4 hits per frame, to prevent ghosts from splode-spamming too bad. - continue; - poof = P_SpawnMobj(x, y, z, MT_GHOST); - poof->angle = angle; - poof->flags = MF_NOBLOCKMAP|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY; // make an ATTEMPT to curb crazy SOCs fucking stuff up... - poof->health = 0; - P_SetMobjStateNF(poof, S_XPLD1); - } - } - if (ziptic & EZT_SPRITE) - g->mo->sprite = READUINT8(g->p); - if (ziptic & EZT_KART) - g->p += 12; // kartitem, kartamount, kartbumpers - } - -#ifdef DEMO_COMPAT_100 - if (g->version != 0x0001) - { -#endif - if (READUINT8(g->p) != 0xFF) // Make sure there isn't other ghost data here. - I_Error("Ghost is not a record attack ghost"); //@TODO lmao don't blow up like this -#ifdef DEMO_COMPAT_100 - } -#endif - -skippedghosttic: - // Tick ghost colors (Super and Mario Invincibility flashing) - switch(g->color) - { - case GHC_SUPER: // Super Sonic (P_DoSuperStuff) - g->mo->color = SKINCOLOR_SUPER1; - g->mo->color += abs( ( (signed)( (unsigned)leveltime >> 1 ) % 9) - 4); - break; - case GHC_INVINCIBLE: // Mario invincibility (P_CheckInvincibilityTimer) - g->mo->color = (UINT8)(leveltime % MAXSKINCOLORS); - break; - default: - break; - } - - // Demo ends after ghost data. - if (*g->p == DEMOMARKER) - { - g->mo->momx = g->mo->momy = g->mo->momz = 0; - if (p) - p->next = g->next; - else - ghosts = g->next; - Z_Free(g); - continue; - } - p = g; - } -} - -// Demo rewinding functions -typedef struct rewindinfo_s { - tic_t leveltime; - - struct { - boolean ingame; - player_t player; - mobj_t mobj; - } playerinfo[MAXPLAYERS]; - - struct rewindinfo_s *prev; -} rewindinfo_t; - -static tic_t currentrewindnum; -static rewindinfo_t *rewindhead = NULL; // Reverse chronological order - -void G_InitDemoRewind(void) -{ - CL_ClearRewinds(); - - while (rewindhead) - { - rewindinfo_t *p = rewindhead->prev; - Z_Free(rewindhead); - rewindhead = p; - } - - currentrewindnum = 0; -} - -void G_StoreRewindInfo(void) -{ - static UINT8 timetolog = 8; - rewindinfo_t *info; - size_t i; - - if (timetolog-- > 0) - return; - timetolog = 8; - - info = Z_Calloc(sizeof(rewindinfo_t), PU_STATIC, NULL); - - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator) - { - info->playerinfo[i].ingame = false; - continue; - } - - info->playerinfo[i].ingame = true; - memcpy(&info->playerinfo[i].player, &players[i], sizeof(player_t)); - if (players[i].mo) - memcpy(&info->playerinfo[i].mobj, players[i].mo, sizeof(mobj_t)); - } - - info->leveltime = leveltime; - info->prev = rewindhead; - rewindhead = info; -} - -void G_PreviewRewind(tic_t previewtime) -{ - SINT8 i; - size_t j; - fixed_t tweenvalue = 0; - rewindinfo_t *info = rewindhead, *next_info = rewindhead; - - if (!info) - return; - - while (info->leveltime > previewtime && info->prev) - { - next_info = info; - info = info->prev; - } - if (info != next_info) - tweenvalue = FixedDiv(previewtime - info->leveltime, next_info->leveltime - info->leveltime); - - - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator) - { - if (info->playerinfo[i].player.mo) - { - //@TODO spawn temp object to act as a player display - } - - continue; - } - - if (!info->playerinfo[i].ingame || !info->playerinfo[i].player.mo) - { - if (players[i].mo) - players[i].mo->flags2 |= MF2_DONTDRAW; - - continue; - } - - if (!players[i].mo) - continue; //@TODO spawn temp object to act as a player display - - players[i].mo->flags2 &= ~MF2_DONTDRAW; - - P_UnsetThingPosition(players[i].mo); -#define TWEEN(pr) info->playerinfo[i].mobj.pr + FixedMul((INT32) (next_info->playerinfo[i].mobj.pr - info->playerinfo[i].mobj.pr), tweenvalue) - players[i].mo->x = TWEEN(x); - players[i].mo->y = TWEEN(y); - players[i].mo->z = TWEEN(z); - players[i].mo->angle = TWEEN(angle); -#undef TWEEN - P_SetThingPosition(players[i].mo); - - players[i].frameangle = info->playerinfo[i].player.frameangle + FixedMul((INT32) (next_info->playerinfo[i].player.frameangle - info->playerinfo[i].player.frameangle), tweenvalue); - - players[i].mo->sprite = info->playerinfo[i].mobj.sprite; - players[i].mo->frame = info->playerinfo[i].mobj.frame; - - players[i].realtime = info->playerinfo[i].player.realtime; - for (j = 0; j < NUMKARTSTUFF; j++) - players[i].kartstuff[j] = info->playerinfo[i].player.kartstuff[j]; - } - - for (i = splitscreen; i >= 0; i--) - P_ResetCamera(&players[displayplayers[i]], &camera[i]); -} - -void G_ConfirmRewind(tic_t rewindtime) -{ - SINT8 i; - tic_t j; - boolean oldmenuactive = menuactive, oldsounddisabled = sound_disabled; - - INT32 olddp1 = displayplayers[0], olddp2 = displayplayers[1], olddp3 = displayplayers[2], olddp4 = displayplayers[3]; - UINT8 oldss = splitscreen; - - menuactive = false; // Prevent loops - - CV_StealthSetValue(&cv_renderview, 0); - - if (rewindtime <= starttime) - { - demo.rewinding = false; - G_DoPlayDemo(NULL); // Restart the current demo - } - else - { - rewind_t *rewind; - sound_disabled = true; // Prevent sound spam - demo.rewinding = true; - - rewind = CL_RewindToTime(rewindtime); - - if (rewind) - { - demobuf.p = demobuf.buffer + rewind->demopos; - memcpy(oldcmd, rewind->oldcmd, sizeof (oldcmd)); - memcpy(oldghost, rewind->oldghost, sizeof (oldghost)); - paused = false; - } - else - { - demo.rewinding = true; - G_DoPlayDemo(NULL); // Restart the current demo - } - } - - for (j = 0; j < rewindtime && leveltime < rewindtime; j++) - { - G_Ticker((j % NEWTICRATERATIO) == 0); - } - - demo.rewinding = false; - menuactive = oldmenuactive; // Bring the menu back up - sound_disabled = oldsounddisabled; // Re-enable SFX - - wipegamestate = gamestate; // No fading back in! - - COM_BufInsertText("renderview on\n"); - - splitscreen = oldss; - displayplayers[0] = olddp1; - displayplayers[1] = olddp2; - displayplayers[2] = olddp3; - displayplayers[3] = olddp4; - R_ExecuteSetViewSize(); - G_ResetViews(); - - for (i = splitscreen; i >= 0; i--) - P_ResetCamera(&players[displayplayers[i]], &camera[i]); -} - -void G_ReadMetalTic(mobj_t *metal) -{ - UINT8 ziptic; - UINT16 speed; - UINT8 statetype; - - if (!metal_p) - return; - ziptic = READUINT8(metal_p); - - // Read changes from the tic - if (ziptic & GZT_XYZ) - { - oldmetal.x = READFIXED(metal_p); - oldmetal.y = READFIXED(metal_p); - oldmetal.z = READFIXED(metal_p); - P_MoveOrigin(metal, oldmetal.x, oldmetal.y, oldmetal.z); - oldmetal.x = metal->x; - oldmetal.y = metal->y; - oldmetal.z = metal->z; - } - else - { - if (ziptic & GZT_MOMXY) - { - oldmetal.momx = READINT16(metal_p)<<8; - oldmetal.momy = READINT16(metal_p)<<8; - } - if (ziptic & GZT_MOMZ) - oldmetal.momz = READINT16(metal_p)<<8; - oldmetal.x += oldmetal.momx; - oldmetal.y += oldmetal.momy; - oldmetal.z += oldmetal.momz; - } - if (ziptic & GZT_ANGLE) - oldmetal.angle = READUINT8(metal_p)<<24; - if (ziptic & GZT_SPRITE) - metal_p++; // Currently unused. (Metal Sonic figures out what he's doing his own damn self.) - - // Set movement, position, and angle - // oldmetal contains where you're supposed to be. - metal->momx = oldmetal.momx; - metal->momy = oldmetal.momy; - metal->momz = oldmetal.momz; - P_UnsetThingPosition(metal); - metal->x = oldmetal.x; - metal->y = oldmetal.y; - metal->z = oldmetal.z; - P_SetThingPosition(metal); - metal->angle = oldmetal.angle; - - if (ziptic & GZT_EXTRA) - { // But wait, there's more! - ziptic = READUINT8(metal_p); - if (ziptic & EZT_FLIP) - metal->eflags ^= MFE_VERTICALFLIP; - if (ziptic & EZT_SCALE) - { - metal->destscale = READFIXED(metal_p); - if (metal->destscale != metal->scale) - P_SetScale(metal, metal->destscale); - } - } - - // Calculates player's speed based on distance-of-a-line formula - speed = FixedDiv(P_AproxDistance(oldmetal.momx, oldmetal.momy), metal->scale)>>FRACBITS; - - // Use speed to decide an appropriate state - if (speed > 20) // default skin runspeed - statetype = 2; - else if (speed > 1) // stopspeed - statetype = 1; - else - statetype = 0; - - // Set state - if (statetype != metal->threshold) - { - switch (statetype) - { - case 2: // run - P_SetMobjState(metal,metal->info->meleestate); - break; - case 1: // walk - P_SetMobjState(metal,metal->info->seestate); - break; - default: // stand - P_SetMobjState(metal,metal->info->spawnstate); - break; - } - metal->threshold = statetype; - } - - // TODO: Modify state durations based on movement speed, similar to players? - - if (*metal_p == DEMOMARKER) - { - // end of demo data stream - G_StopMetalDemo(); - return; - } -} - -void G_WriteMetalTic(mobj_t *metal) -{ - UINT8 ziptic = 0; - UINT8 *ziptic_p; - - if (!demobuf.p) // demobuf.p will be NULL until the race start linedef executor is triggered! - return; - - ziptic_p = demobuf.p++; // the ziptic, written at the end of this function - - #define MAXMOM (0xFFFF<<8) - - // GZT_XYZ is only useful if you've moved 256 FRACUNITS or more in a single tic. - if (abs(metal->x-oldmetal.x) > MAXMOM - || abs(metal->y-oldmetal.y) > MAXMOM - || abs(metal->z-oldmetal.z) > MAXMOM) - { - oldmetal.x = metal->x; - oldmetal.y = metal->y; - oldmetal.z = metal->z; - WRITEFIXED(demobuf.p,oldmetal.x); - WRITEFIXED(demobuf.p,oldmetal.y); - WRITEFIXED(demobuf.p,oldmetal.z); - ziptic |= GZT_XYZ; - } - else - { - // For moving normally: - // Store one full byte of movement, plus one byte of fractional movement. - INT16 momx = (INT16)((metal->x-oldmetal.x)>>8); - INT16 momy = (INT16)((metal->y-oldmetal.y)>>8); - if (momx != oldmetal.momx - || momy != oldmetal.momy) - { - oldmetal.momx = momx; - oldmetal.momy = momy; - WRITEINT16(demobuf.p,momx); - WRITEINT16(demobuf.p,momy); - ziptic |= GZT_MOMXY; - } - momx = (INT16)((metal->z-oldmetal.z)>>8); - if (momx != oldmetal.momz) - { - oldmetal.momz = momx; - WRITEINT16(demobuf.p,momx); - ziptic |= GZT_MOMZ; - } - - // This SHOULD set oldmetal.x/y/z to match metal->x/y/z - // but it keeps the fractional loss of one byte, - // so it will hopefully be made up for in future tics. - oldmetal.x += oldmetal.momx<<8; - oldmetal.y += oldmetal.momy<<8; - oldmetal.z += oldmetal.momz<<8; - } - - #undef MAXMOM - - // Only store the 8 most relevant bits of angle - // because exact values aren't too easy to discern to begin with when only 8 angles have different sprites - // and it does not affect movement at all anyway. - if (metal->angle>>24 != oldmetal.angle) - { - oldmetal.angle = metal->angle>>24; - WRITEUINT8(demobuf.p,oldmetal.angle); - ziptic |= GZT_ANGLE; - } - - // Metal Sonic does not need our state changes. - // ... currently. - - { - UINT8 *exttic_p = NULL; - UINT8 exttic = 0; - if ((metal->eflags & MFE_VERTICALFLIP) != (oldmetal.eflags & MFE_VERTICALFLIP)) - { - if (!exttic_p) - exttic_p = demobuf.p++; - exttic |= EZT_FLIP; - oldmetal.eflags ^= MFE_VERTICALFLIP; - } - if (metal->scale != oldmetal.scale) - { - if (!exttic_p) - exttic_p = demobuf.p++; - exttic |= EZT_SCALE; - WRITEFIXED(demobuf.p,metal->scale); - oldmetal.scale = metal->scale; - } - if (exttic_p) - { - *exttic_p = exttic; - ziptic |= GZT_EXTRA; - } - } - - *ziptic_p = ziptic; - - // attention here for the ticcmd size! - // latest demos with mouse aiming byte in ticcmd - if (demobuf.p >= demoend - 32) - { - G_StopMetalRecording(); // no more space - return; - } -} - -// -// G_RecordDemo -// -void G_RecordDemo(const char *name) -{ - INT32 maxsize; - - demobuf.p = NULL; - G_ResetDemoRecording(); - demoend = NULL; - - if (cv_recordmultiplayerdemos.value) - { - CONS_Printf("Recording demo %s.lmp\n", name); - - strcpy(demoname, name); - strcat(demoname, ".lmp"); - - maxsize = cv_maxdemosize.value*1024*1024; - - demobuf.buffer = Z_Malloc(maxsize + 100*1024, PU_STATIC, NULL); - demoend = demobuf.buffer + maxsize; - - if (demobuf.buffer) - demo.recording = true; - else - CONS_Alert(CONS_ERROR, "Failed to allocate demo buffer\n"); - } -} - -void G_RecordMetal(void) -{ - INT32 maxsize; - maxsize = cv_maxdemosize.value*1024*1024; - if (demobuf.buffer) - Z_Free(demobuf.buffer); - demobuf.p = NULL; - metalrecording = false; - demobuf.buffer = Z_Malloc(maxsize + 100*1024, PU_STATIC, NULL); - demoend = demobuf.buffer + maxsize; - - if (demobuf.buffer) - metalrecording = true; - else - CONS_Alert(CONS_ERROR, "Failed to allocate demo buffer\n"); -} - -void G_BeginRecording(void) -{ - UINT8 i, p; - char name[17]; - player_t *player = &players[consoleplayer]; - - char *filename; - UINT8 totalfiles; - UINT8 *m; - - if (!cv_recordmultiplayerdemos.value) - { - G_ResetDemoRecording(); - return; - } - - if (demobuf.buffer == NULL) - { - CONS_Alert(CONS_ERROR, "No demo buffer allocated\n"); - G_ResetDemoRecording(); - return; - } - - if (demobuf.p) - { - G_ResetDemoRecording(); - return; - } - - memset(name,0,sizeof(name)); - - demobuf.p = demobuf.buffer; - demoflags = DF_GHOST|(multiplayer ? DF_MULTIPLAYER : (modeattacking<important) - { - nameonly(( filename = va("%s", wadfiles[i]->filename) )); - WRITESTRINGL(demobuf.p, filename, MAX_WADPATH); - WRITEMEM(demobuf.p, wadfiles[i]->md5sum, 16); - - totalfiles++; - } - - WRITEUINT8(m, totalfiles); - - switch ((demoflags & DF_ATTACKMASK)>>DF_ATTACKSHIFT) - { - case ATTACKING_NONE: // 0 - break; - case ATTACKING_RECORD: // 1 - demotime_p = demobuf.p; - WRITEUINT32(demobuf.p,UINT32_MAX); // time - WRITEUINT32(demobuf.p,UINT32_MAX); // lap - break; - default: // 3 - break; - } - - WRITEUINT32(demobuf.p, P_GetInitSeed()); - - // Reserved for extrainfo location from start of file - demoinfo_p = demobuf.p; - WRITEUINT32(demobuf.p, 0); - - // Save netvars - CV_SaveNetVars(&demobuf.p, true); - - // Now store some info for each in-game player - for (p = 0; p < MAXPLAYERS; p++) { - if (playeringame[p]) { - player = &players[p]; - - WRITEUINT8(demobuf.p, p | (player->spectator ? DEMO_SPECTATOR : 0)); - - // Name - memset(name, 0, 16); - memcpy(name, player_names[p], 15); - M_Memcpy(demobuf.p,name,16); - demobuf.p += 16; - - // Skin - memset(name, 0, 16); - strncpy(name, skins[player->skin].name, 16); - M_Memcpy(demobuf.p,name,16); - demobuf.p += 16; - - // Color - memset(name, 0, 16); - strncpy(name, KartColor_Names[player->skincolor], 16); - M_Memcpy(demobuf.p,name,16); - demobuf.p += 16; - - // Score, since Kart uses this to determine where you start on the map - WRITEUINT32(demobuf.p, player->score); - - // Kart speed and weight - WRITEUINT8(demobuf.p, skins[player->skin].kartspeed); - WRITEUINT8(demobuf.p, skins[player->skin].kartweight); - - } - } - - WRITEUINT8(demobuf.p, 0xFF); // Denote the end of the player listing - - // player lua vars, always saved even if empty... Unless it's record attack. - if (demoflags & DF_LUAVARS) - LUA_Archive(&demobuf, false); - - memset(&oldcmd,0,sizeof(oldcmd)); - memset(&oldghost,0,sizeof(oldghost)); - memset(&ghostext,0,sizeof(ghostext)); - - for (i = 0; i < MAXPLAYERS; i++) - { - ghostext[i].lastcolor = ghostext[i].color = GHC_NORMAL; - ghostext[i].lastscale = ghostext[i].scale = FRACUNIT; - - if (players[i].mo) - { - oldghost[i].x = players[i].mo->x; - oldghost[i].y = players[i].mo->y; - oldghost[i].z = players[i].mo->z; - oldghost[i].angle = players[i].mo->angle; - - // preticker started us gravity flipped - if (players[i].mo->eflags & MFE_VERTICALFLIP) - ghostext[i].flags |= EZT_FLIP; - } - } -} - -void G_BeginMetal(void) -{ - mobj_t *mo = players[consoleplayer].mo; - - if (demobuf.buffer == NULL) - { - CONS_Alert(CONS_ERROR, "No metal demo buffer allocated\n"); - metalrecording = false; - return; - } - - if (demobuf.p) - { - Z_Free(demobuf.buffer); - demobuf.buffer = NULL; - metalrecording = false; - return; - } - - demobuf.p = demobuf.buffer; - - // Write header. - M_Memcpy(demobuf.p, DEMOHEADER, 12); demobuf.p += 12; - WRITEUINT8(demobuf.p,VERSION); - WRITEUINT8(demobuf.p,SUBVERSION); - WRITEUINT16(demobuf.p,DEMOVERSION); - - // demo checksum - demobuf.p += 16; - - M_Memcpy(demobuf.p, "METL", 4); demobuf.p += 4; - - // Set up our memory. - memset(&oldmetal,0,sizeof(oldmetal)); - oldmetal.x = mo->x; - oldmetal.y = mo->y; - oldmetal.z = mo->z; - oldmetal.angle = mo->angle; -} - -void G_WriteStanding(UINT8 ranking, char *name, INT32 skinnum, UINT8 color, UINT32 val) -{ - char temp[17]; - - if (!demobuf.p) - return; - - if (demoinfo_p && *(UINT32 *)demoinfo_p == 0 && demobuf.buffer != NULL) - { - WRITEUINT8(demobuf.p, DEMOMARKER); // add the demo end marker - *(UINT32 *)demoinfo_p = demobuf.p - demobuf.buffer; - } - - WRITEUINT8(demobuf.p, DW_STANDING); - WRITEUINT8(demobuf.p, ranking); - - // Name - memset(temp, 0, 16); - strncpy(temp, name, 16); - M_Memcpy(demobuf.p,temp,16); - demobuf.p += 16; - - // Skin - memset(temp, 0, 16); - strncpy(temp, skins[skinnum].name, 16); - M_Memcpy(demobuf.p,temp,16); - demobuf.p += 16; - - // Color - memset(temp, 0, 16); - strncpy(temp, KartColor_Names[color], 16); - M_Memcpy(demobuf.p,temp,16); - demobuf.p += 16; - - // Score/time/whatever - WRITEUINT32(demobuf.p, val); -} - -void G_SetDemoTime(UINT32 ptime, UINT32 plap) -{ - if (!demo.recording || !demotime_p) - return; - if (demoflags & DF_RECORDATTACK) - { - WRITEUINT32(demotime_p, ptime); - WRITEUINT32(demotime_p, plap); - demotime_p = NULL; - } -} - -static void G_LoadDemoExtraFiles(UINT8 **pp) -{ - UINT8 totalfiles; - char filename[MAX_WADPATH]; - UINT8 md5sum[16]; - filestatus_t ncs = FS_NOTFOUND; - boolean toomany = false; - boolean alreadyloaded; - UINT8 i, j; - - totalfiles = READUINT8((*pp)); - for (i = 0; i < totalfiles; ++i) - { - if (toomany) - SKIPSTRING((*pp)); - else - { - strlcpy(filename, (char *)(*pp), sizeof filename); - SKIPSTRING((*pp)); - } - READMEM((*pp), md5sum, 16); - - if (!toomany) - { - alreadyloaded = false; - - for (j = 0; j < numwadfiles; ++j) - { - if (memcmp(md5sum, wadfiles[j]->md5sum, 16) == 0) - { - alreadyloaded = true; - break; - } - } - - if (alreadyloaded) - continue; - - if (numwadfiles >= MAX_WADFILES) - toomany = true; - else - ncs = findfile(filename, md5sum, false); - - if (toomany) - { - CONS_Alert(CONS_WARNING, M_GetText("Too many files loaded to add anymore for demo playback\n")); - if (!CON_Ready()) - M_StartMessage(M_GetText("There are too many files loaded to add this demo's addons.\n\nDemo playback may desync.\n\nPress ESC\n"), NULL, MM_NOTHING); - } - else if (ncs != FS_FOUND) - { - if (ncs == FS_NOTFOUND) - CONS_Alert(CONS_NOTICE, M_GetText("You do not have a copy of %s\n"), filename); - else if (ncs == FS_MD5SUMBAD) - CONS_Alert(CONS_NOTICE, M_GetText("Checksum mismatch on %s\n"), filename); - else - CONS_Alert(CONS_NOTICE, M_GetText("Unknown error finding file %s\n"), filename); - - if (!CON_Ready()) - M_StartMessage(M_GetText("There were errors trying to add this demo's addons. Check the console for more information.\n\nDemo playback may desync.\n\nPress ESC\n"), NULL, MM_NOTHING); - } - else - { - P_PartialAddWadFile(filename, false); - } - } - } - - if (P_PartialAddGetStage() >= 0) - P_MultiSetupWadFiles(true); // in case any partial adds were done -} - -static void G_SkipDemoExtraFiles(UINT8 **pp) -{ - UINT8 totalfiles; - UINT8 i; - - totalfiles = READUINT8((*pp)); - for (i = 0; i < totalfiles; ++i) - { - SKIPSTRING((*pp));// file name - (*pp) += 16;// md5 - } -} - -// G_CheckDemoExtraFiles: checks if our loaded WAD list matches the demo's. -// Enabling quick prevents filesystem checks to see if needed files are available to load. -static UINT8 G_CheckDemoExtraFiles(UINT8 **pp, boolean quick) -{ - UINT8 totalfiles, filesloaded, nmusfilecount; - char filename[MAX_WADPATH]; - UINT8 md5sum[16]; - boolean toomany = false; - boolean alreadyloaded; - UINT8 i, j; - UINT8 error = 0; - - totalfiles = READUINT8((*pp)); - filesloaded = 0; - for (i = 0; i < totalfiles; ++i) - { - if (toomany) - SKIPSTRING((*pp)); - else - { - strlcpy(filename, (char *)(*pp), sizeof filename); - SKIPSTRING((*pp)); - } - READMEM((*pp), md5sum, 16); - - if (!toomany) - { - alreadyloaded = false; - nmusfilecount = 0; - - for (j = 0; j < numwadfiles; ++j) - { - if (wadfiles[j]->important && j > mainwads) - nmusfilecount++; - else - continue; - - if (memcmp(md5sum, wadfiles[j]->md5sum, 16) == 0) - { - alreadyloaded = true; - - if (i != nmusfilecount-1 && error < DFILE_ERROR_OUTOFORDER) - error |= DFILE_ERROR_OUTOFORDER; - - break; - } - } - - if (alreadyloaded) - { - filesloaded++; - continue; - } - - if (numwadfiles >= MAX_WADFILES) - error = DFILE_ERROR_CANNOTLOAD; - else if (!quick && findfile(filename, md5sum, false) != FS_FOUND) - error = DFILE_ERROR_CANNOTLOAD; - else if (error < DFILE_ERROR_INCOMPLETEOUTOFORDER) - error |= DFILE_ERROR_NOTLOADED; - } else - error = DFILE_ERROR_CANNOTLOAD; - } - - // Get final file count - nmusfilecount = 0; - - for (j = 0; j < numwadfiles; ++j) - if (wadfiles[j]->important && j > mainwads) - nmusfilecount++; - - if (!error && filesloaded < nmusfilecount) - error = DFILE_ERROR_EXTRAFILES; - - return error; -} - -// Returns bitfield: -// 1 == new demo has lower time -// 2 == new demo has higher score -// 4 == new demo has higher rings -UINT8 G_CmpDemoTime(char *oldname, char *newname) -{ - UINT8 *buffer,*p; - UINT8 flags; - UINT32 oldtime, newtime, oldlap, newlap; - UINT16 oldversion; - size_t bufsize ATTRUNUSED; - UINT8 c; - UINT16 s ATTRUNUSED; - UINT8 aflags = 0; - - // load the new file - FIL_DefaultExtension(newname, ".lmp"); - bufsize = FIL_ReadFile(newname, &buffer); - I_Assert(bufsize != 0); - p = buffer; - - // read demo header - I_Assert(!memcmp(p, DEMOHEADER, 12)); - p += 12; // DEMOHEADER - c = READUINT8(p); // VERSION - I_Assert(c == VERSION); - c = READUINT8(p); // SUBVERSION - I_Assert(c == SUBVERSION); - s = READUINT16(p); - I_Assert(s == DEMOVERSION); - p += 64; // full demo title - p += 16; // demo checksum - I_Assert(!memcmp(p, "PLAY", 4)); - p += 4; // PLAY - p += 2; // gamemap - p += 16; // map md5 - flags = READUINT8(p); // demoflags - p++; // gametype - G_SkipDemoExtraFiles(&p); - - aflags = flags & (DF_RECORDATTACK|DF_NIGHTSATTACK); - I_Assert(aflags); - if (flags & DF_RECORDATTACK) - { - newtime = READUINT32(p); - newlap = READUINT32(p); - } - else // appease compiler - return 0; - - Z_Free(buffer); - - // load old file - FIL_DefaultExtension(oldname, ".lmp"); - if (!FIL_ReadFile(oldname, &buffer)) - { - CONS_Alert(CONS_ERROR, M_GetText("Failed to read file '%s'.\n"), oldname); - return UINT8_MAX; - } - p = buffer; - - // read demo header - if (memcmp(p, DEMOHEADER, 12)) - { - CONS_Alert(CONS_NOTICE, M_GetText("File '%s' invalid format. It will be overwritten.\n"), oldname); - Z_Free(buffer); - return UINT8_MAX; - } p += 12; // DEMOHEADER - p++; // VERSION - p++; // SUBVERSION - oldversion = READUINT16(p); - switch(oldversion) // demoversion - { - case DEMOVERSION: // latest always supported - p += 64; // full demo title - break; -#ifdef DEMO_COMPAT_100 - case 0x0001: - // Old replays gotta go :] - CONS_Alert(CONS_NOTICE, M_GetText("File '%s' outdated version. It will be overwritten. Nyeheheh.\n"), oldname); - Z_Free(buffer); - return UINT8_MAX; -#endif - // too old, cannot support. - default: - CONS_Alert(CONS_NOTICE, M_GetText("File '%s' invalid format. It will be overwritten.\n"), oldname); - Z_Free(buffer); - return UINT8_MAX; - } - p += 16; // demo checksum - if (memcmp(p, "PLAY", 4)) - { - CONS_Alert(CONS_NOTICE, M_GetText("File '%s' invalid format. It will be overwritten.\n"), oldname); - Z_Free(buffer); - return UINT8_MAX; - } p += 4; // "PLAY" - p += 2; // gamemap - p += 16; // mapmd5 - flags = READUINT8(p); - p++; // gametype - G_SkipDemoExtraFiles(&p); - if (!(flags & aflags)) - { - CONS_Alert(CONS_NOTICE, M_GetText("File '%s' not from same game mode. It will be overwritten.\n"), oldname); - Z_Free(buffer); - return UINT8_MAX; - } - if (flags & DF_RECORDATTACK) - { - oldtime = READUINT32(p); - oldlap = READUINT32(p); - } - else // appease compiler - return UINT8_MAX; - - Z_Free(buffer); - - c = 0; - if (newtime < oldtime - || (newtime == oldtime && (newlap < oldlap))) - c |= 1; // Better time - if (newlap < oldlap - || (newlap == oldlap && newtime < oldtime)) - c |= 1<<1; // Better lap time - return c; -} - -void G_LoadDemoInfo(menudemo_t *pdemo) -{ - UINT8 *infobuffer, *info_p, *extrainfo_p; - UINT8 version, subversion, pdemoflags; - UINT16 pdemoversion, count; - - if (!FIL_ReadFile(pdemo->filepath, &infobuffer)) - { - CONS_Alert(CONS_ERROR, M_GetText("Failed to read file '%s'.\n"), pdemo->filepath); - pdemo->type = MD_INVALID; - sprintf(pdemo->title, "INVALID REPLAY"); - - return; - } - - info_p = infobuffer; - - if (memcmp(info_p, DEMOHEADER, 12)) - { - CONS_Alert(CONS_ERROR, M_GetText("%s is not a SRB2Kart replay file.\n"), pdemo->filepath); - pdemo->type = MD_INVALID; - sprintf(pdemo->title, "INVALID REPLAY"); - Z_Free(infobuffer); - return; - } - - pdemo->type = MD_LOADED; - - info_p += 12; // DEMOHEADER - - version = READUINT8(info_p); - subversion = READUINT8(info_p); - pdemoversion = READUINT16(info_p); - - memset(pdemo->version, 0, sizeof(pdemo->version)); - snprintf(pdemo->version, sizeof(pdemo->version), "v%d.%d", version, subversion); - - switch(pdemoversion) - { - case DEMOVERSION: // latest always supported - // demo title - M_Memcpy(pdemo->title, info_p, 64); - info_p += 64; - - break; -#ifdef DEMO_COMPAT_100 - case 0x0001: - pdemo->type = MD_OUTDATED; - sprintf(pdemo->title, "Legacy Replay"); - break; -#endif - // too old, cannot support. - default: - CONS_Alert(CONS_ERROR, M_GetText("%s is an incompatible replay format and cannot be played.\n"), pdemo->filepath); - pdemo->type = MD_INVALID; - sprintf(pdemo->title, "INVALID REPLAY"); - Z_Free(infobuffer); - return; - } - - if (version != VERSION || subversion != SUBVERSION) - pdemo->type = MD_OUTDATED; - - info_p += 16; // demo checksum - if (memcmp(info_p, "PLAY", 4)) - { - CONS_Alert(CONS_ERROR, M_GetText("%s is the wrong type of recording and cannot be played.\n"), pdemo->filepath); - pdemo->type = MD_INVALID; - sprintf(pdemo->title, "INVALID REPLAY"); - Z_Free(infobuffer); - return; - } - info_p += 4; // "PLAY" - pdemo->map = READINT16(info_p); - info_p += 16; // mapmd5 - - pdemoflags = READUINT8(info_p); - - // temp? - if (!(pdemoflags & DF_MULTIPLAYER)) - { - CONS_Alert(CONS_ERROR, M_GetText("%s is not a multiplayer replay and can't be listed on this menu fully yet.\n"), pdemo->filepath); - Z_Free(infobuffer); - return; - } -#ifdef DEMO_COMPAT_100 - else if (pdemoversion == 0x0001) - { - CONS_Alert(CONS_ERROR, M_GetText("%s is a legacy multiplayer replay and cannot be played.\n"), pdemo->filepath); - pdemo->type = MD_INVALID; - sprintf(pdemo->title, "INVALID REPLAY"); - Z_Free(infobuffer); - return; - } -#endif - - pdemo->gametype = READUINT8(info_p); - - pdemo->addonstatus = G_CheckDemoExtraFiles(&info_p, true); - info_p += 4; // RNG seed - - extrainfo_p = infobuffer + READUINT32(info_p); - - // Pared down version of CV_LoadNetVars to find the kart speed - pdemo->kartspeed = 1; // Default to normal speed - count = READUINT16(info_p); - while (count--) - { - UINT16 netid; - char *svalue; - - netid = READUINT16(info_p); - svalue = (char *)info_p; - SKIPSTRING(info_p); - info_p++; // stealth - - if (netid == cv_kartspeed.netid) - { - UINT8 j; - for (j = 0; kartspeed_cons_t[j].strvalue; j++) - if (!stricmp(kartspeed_cons_t[j].strvalue, svalue)) - pdemo->kartspeed = kartspeed_cons_t[j].value; - } - else if (netid == cv_basenumlaps.netid && pdemo->gametype == GT_RACE) - pdemo->numlaps = atoi(svalue); - } - - if (pdemoflags & DF_ENCORE) - pdemo->kartspeed |= DF_ENCORE; - - // Read standings! - count = 0; - - while (READUINT8(extrainfo_p) == DW_STANDING) // Assume standings are always first in the extrainfo - { - INT32 i; - char temp[16]; - - pdemo->standings[count].ranking = READUINT8(extrainfo_p); - - // Name - M_Memcpy(pdemo->standings[count].name, extrainfo_p, 16); - extrainfo_p += 16; - - // Skin - M_Memcpy(temp,extrainfo_p,16); - extrainfo_p += 16; - pdemo->standings[count].skin = UINT8_MAX; - for (i = 0; i < numskins; i++) - if (stricmp(skins[i].name, temp) == 0) - { - pdemo->standings[count].skin = i; - break; - } - - // Color - M_Memcpy(temp,extrainfo_p,16); - extrainfo_p += 16; - for (i = 0; i < MAXSKINCOLORS; i++) - if (!stricmp(KartColor_Names[i],temp)) // SRB2kart - { - pdemo->standings[count].color = i; - break; - } - - // Score/time/whatever - pdemo->standings[count].timeorscore = READUINT32(extrainfo_p); - - count++; - - if (count >= MAXPLAYERS) - break; //@TODO still cycle through the rest of these if extra demo data is ever used - } - - // I think that's everything we need? - Z_Free(infobuffer); -} - -#if defined (_WIN32) -// return the file creation time -// useful for demos that were renamed -static long G_GetCreationTime(char *filepath) -{ - struct stat fileinfo; - - if (stat(filepath, &fileinfo) == 0) - return fileinfo.st_ctime; - - return 0; -} -#endif - -static char *G_GetDemoDate(menudemo_t *pdemo) -{ - char *datetime; - datetime = malloc(sizeof(pdemo->date)); // mallocma balls - - // no mallocma balls... :c - if (!datetime) - { - return NULL; - } - - time_t file_time = 0; - - // get le filepath - char *filename; - filename = strdup(pdemo->filepath); - -#if defined (_WIN32) - if (!filename) - { - // if we cant get a filename try just getting the file create time - file_time = G_GetCreationTime(pdemo->filepath); - goto skipfilenametime; - } -#else - if (!filename) - { - free(datetime); - return NULL; - } -#endif - - // get the actual filename Zzz... - nameonly(filename); - - // convert it to long Zzz.... - file_time = strtol(filename, NULL, 10); - free(filename); // dont need this anymore a - -#if defined (_WIN32) -skipfilenametime: -#endif - - // then throw it into localtime to get an actual human readable format lmao - struct tm *tm_buf = NULL; - tm_buf = localtime(&file_time); - - // cant believe we ended up in 1970 - if (tm_buf == NULL || tm_buf->tm_year <= 110) - { -#if defined (_WIN32) - // uh ohh, we got an invalid time - // try one more time getting the creation time - file_time = G_GetCreationTime(pdemo->filepath); - tm_buf = localtime(&file_time); - - if (tm_buf == NULL || tm_buf->tm_year <= 110) - { - free(datetime); - return NULL; - } - - goto gotcreationtime; -#else - free(datetime); - return NULL; -#endif - } - -#if defined (_WIN32) -gotcreationtime: -#endif - - const char *format; - - // US ppl are special (: - if (cv_demodateformat.value == 2) - format = "%m.%d.%Y"; - else if (cv_demodateformat.value == 1) - format = "%d.%m.%Y"; - else - format = strstr(setlocale(LC_TIME, NULL), "en_US") ? "%m.%d.%Y" : "%d.%m.%Y"; - - strftime(datetime, sizeof(pdemo->date), format, tm_buf); - - return datetime; -} - -void G_LoadDemoTitle(menudemo_t *pdemo) -{ - UINT8 infobuffer[96], *info_p; - UINT16 pdemoversion; - size_t count; - - FILE *handle = fopen(pdemo->filepath, "rb"); - - if (!handle) - { - CONS_Alert(CONS_ERROR, M_GetText("Failed to read file '%s'.\n"), pdemo->filepath); - sprintf(pdemo->title, "INVALID REPLAY"); - return; - } - - count = fread(infobuffer, 1, 96, handle); - fclose(handle); - info_p = infobuffer; - - // First check isn't too accurate technically, but well, valid replays should be larger than that anyway - if (count < 96 || memcmp(info_p, DEMOHEADER, 12)) - { - CONS_Alert(CONS_ERROR, M_GetText("%s is not a SRB2Kart replay file.\n"), pdemo->filepath); - sprintf(pdemo->title, "INVALID REPLAY"); - return; - } - - info_p += 12; // DEMOHEADER - - READUINT8(info_p); - READUINT8(info_p); - pdemoversion = READUINT16(info_p); - - memset(pdemo->date, 0, sizeof(pdemo->date)); - - switch(pdemoversion) - { - case DEMOVERSION: // latest always supported - // demo title - M_Memcpy(pdemo->title, info_p, 64); - - // demo date - char *demodate; - demodate = G_GetDemoDate(pdemo); - if (demodate) - strncpy(pdemo->date, demodate, sizeof(pdemo->date)); - free(demodate); - break; -#ifdef DEMO_COMPAT_100 - case 0x0001: - sprintf(pdemo->title, "Legacy Replay"); - break; -#endif - // too old, cannot support. - default: - CONS_Alert(CONS_ERROR, M_GetText("%s is an incompatible replay format and cannot be played.\n"), pdemo->filepath); - sprintf(pdemo->title, "INVALID REPLAY"); - } -} - -// -// G_PlayDemo -// -void G_DeferedPlayDemo(const char *name) -{ - COM_BufAddText("playdemo \""); - COM_BufAddText(name); - COM_BufAddText("\" -addfiles\n"); -} - -// -// Start a demo from a .LMP file or from a wad resource -// -#define SKIPERRORS -void G_DoPlayDemo(char *defdemoname) -{ - UINT8 i, p; - lumpnum_t l; - char skin[17],color[17],*n,*pdemoname; - UINT8 version,subversion; - UINT32 randseed; - char msg[1024]; -#if defined(SKIPERRORS) && !defined(DEVELOP) - boolean skiperrors = false; -#endif - boolean spectator; - UINT8 slots[MAXPLAYERS], kartspeed[MAXPLAYERS], kartweight[MAXPLAYERS], numslots = 0; - - G_InitDemoRewind(); - - skin[16] = '\0'; - color[16] = '\0'; - - // No demo name means we're restarting the current demo - if (defdemoname == NULL) - { - demobuf.p = demobuf.buffer; - pdemoname = ZZ_Alloc(1); // Easier than adding checks for this everywhere it's freed - } - else - { - n = defdemoname+strlen(defdemoname); - while (*n != '/' && *n != '\\' && n != defdemoname) - n--; - if (n != defdemoname) - n++; - pdemoname = ZZ_Alloc(strlen(n)+1); - strcpy(pdemoname,n); - - M_SetPlaybackMenuPointer(); - - // Internal if no extension, external if one exists - if (FIL_CheckExtension(defdemoname)) - { - //FIL_DefaultExtension(defdemoname, ".lmp"); - if (!FIL_ReadFile(defdemoname, &demobuf.buffer)) - { - snprintf(msg, 1024, M_GetText("Failed to read file '%s'.\n"), defdemoname); - CONS_Alert(CONS_ERROR, "%s", msg); - gameaction = ga_nothing; - M_StartMessage(msg, NULL, MM_NOTHING); - return; - } - demobuf.p = demobuf.buffer; - } - // load demo resource from WAD - else if ((l = W_CheckNumForName(defdemoname)) == LUMPERROR) - { - snprintf(msg, 1024, M_GetText("Failed to read lump '%s'.\n"), defdemoname); - CONS_Alert(CONS_ERROR, "%s", msg); - gameaction = ga_nothing; - M_StartMessage(msg, NULL, MM_NOTHING); - return; - } - else // it's an internal demo - { - demobuf.buffer = demobuf.p = W_CacheLumpNum(l, PU_STATIC); -#if defined(SKIPERRORS) && !defined(DEVELOP) - skiperrors = true; // SRB2Kart: Don't print warnings for staff ghosts, since they'll inevitably happen when we make bugfixes/changes... -#endif - } - } - - // read demo header - gameaction = ga_nothing; - demo.playback = true; - if (memcmp(demobuf.p, DEMOHEADER, 12)) - { - snprintf(msg, 1024, M_GetText("%s is not a SRB2Kart replay file.\n"), pdemoname); - CONS_Alert(CONS_ERROR, "%s", msg); - M_StartMessage(msg, NULL, MM_NOTHING); - G_ResetDemoPlayback(pdemoname); - return; - } - demobuf.p += 12; // DEMOHEADER - - version = READUINT8(demobuf.p); - subversion = READUINT8(demobuf.p); - demo.version = READUINT16(demobuf.p); - switch(demo.version) - { - case DEMOVERSION: // latest always supported - // demo title - M_Memcpy(demo.titlename, demobuf.p, 64); - demobuf.p += 64; - - break; -#ifdef DEMO_COMPAT_100 - case 0x0001: - break; -#endif - // too old, cannot support. - default: - snprintf(msg, 1024, M_GetText("%s is an incompatible replay format and cannot be played.\n"), pdemoname); - CONS_Alert(CONS_ERROR, "%s", msg); - M_StartMessage(msg, NULL, MM_NOTHING); - G_ResetDemoPlayback(pdemoname); - return; - } - demobuf.p += 16; // demo checksum - if (memcmp(demobuf.p, "PLAY", 4)) - { - snprintf(msg, 1024, M_GetText("%s is the wrong type of recording and cannot be played.\n"), pdemoname); - CONS_Alert(CONS_ERROR, "%s", msg); - M_StartMessage(msg, NULL, MM_NOTHING); - G_ResetDemoPlayback(pdemoname); - return; - } - demobuf.p += 4; // "PLAY" - gamemap = READINT16(demobuf.p); - demobuf.p += 16; // mapmd5 - - demoflags = READUINT8(demobuf.p); -#ifdef DEMO_COMPAT_100 - if (demo.version == 0x0001) - { - if (demoflags & DF_MULTIPLAYER) - { - snprintf(msg, 1024, M_GetText("%s is an alpha multiplayer replay and cannot be played.\n"), pdemoname); - CONS_Alert(CONS_ERROR, "%s", msg); - M_StartMessage(msg, NULL, MM_NOTHING); - G_ResetDemoPlayback(pdemoname); - return; - } - } - else - { -#endif - gametype = READUINT8(demobuf.p); - - if (demo.title) // Titledemos should always play and ought to always be compatible with whatever wadlist is running. - G_SkipDemoExtraFiles(&demobuf.p); - else if (demo.loadfiles) - G_LoadDemoExtraFiles(&demobuf.p); - else if (demo.ignorefiles) - G_SkipDemoExtraFiles(&demobuf.p); - else - { - UINT8 error = G_CheckDemoExtraFiles(&demobuf.p, false); - - if (error) - { - switch (error) - { - case DFILE_ERROR_NOTLOADED: - snprintf(msg, 1024, - M_GetText("Required files for this demo are not loaded.\n\nUse\n\"playdemo %s -addfiles\"\nto load them and play the demo.\n"), - pdemoname); - break; - - case DFILE_ERROR_OUTOFORDER: - snprintf(msg, 1024, - M_GetText("Required files for this demo are loaded out of order.\n\nUse\n\"playdemo %s -force\"\nto play the demo anyway.\n"), - pdemoname); - break; - - case DFILE_ERROR_INCOMPLETEOUTOFORDER: - snprintf(msg, 1024, - M_GetText("Required files for this demo are not loaded, and some are out of order.\n\nUse\n\"playdemo %s -addfiles\"\nto load needed files and play the demo.\n"), - pdemoname); - break; - - case DFILE_ERROR_CANNOTLOAD: - snprintf(msg, 1024, - M_GetText("Required files for this demo cannot be loaded.\n\nUse\n\"playdemo %s -force\"\nto play the demo anyway.\n"), - pdemoname); - break; - - case DFILE_ERROR_EXTRAFILES: - snprintf(msg, 1024, - M_GetText("You have additional files loaded beyond the demo's file list.\n\nUse\n\"playdemo %s -force\"\nto play the demo anyway.\n"), - pdemoname); - break; - } - - CONS_Alert(CONS_ERROR, "%s", msg); - if (!CON_Ready()) // In the console they'll just see the notice there! No point pulling them out. - M_StartMessage(msg, NULL, MM_NOTHING); - G_ResetDemoPlayback(pdemoname); - return; - } - } -#ifdef DEMO_COMPAT_100 - } -#endif - - modeattacking = (demoflags & DF_ATTACKMASK)>>DF_ATTACKSHIFT; - multiplayer = !!(demoflags & DF_MULTIPLAYER); - CON_ToggleOff(); - - hu_demotime = UINT32_MAX; - hu_demolap = UINT32_MAX; - - switch (modeattacking) - { - case ATTACKING_NONE: // 0 - break; - case ATTACKING_RECORD: // 1 - hu_demotime = READUINT32(demobuf.p); - hu_demolap = READUINT32(demobuf.p); - break; - default: // 3 - modeattacking = ATTACKING_NONE; - break; - } - - // Random seed - randseed = READUINT32(demobuf.p); -#ifdef DEMO_COMPAT_100 - if (demo.version != 0x0001) -#endif - demobuf.p += 4; // Extrainfo location - -#ifdef DEMO_COMPAT_100 - if (demo.version == 0x0001) - { - // Player name - M_Memcpy(player_names[0],demobuf.p,16); - demobuf.p += 16; - - // Skin - M_Memcpy(skin,demobuf.p,16); - demobuf.p += 16; - - // Color - M_Memcpy(color,demobuf.p,16); - demobuf.p += 16; - - demobuf.p += 5; // Backwards compat - some stats - // SRB2kart - kartspeed[0] = READUINT8(demobuf.p); - kartweight[0] = READUINT8(demobuf.p); - // - demobuf.p += 9; // Backwards compat - more stats - - // Skin not loaded? - if (!SetPlayerSkin(0, skin)) - { - snprintf(msg, 1024, M_GetText("%s features a character that is not currently loaded.\n"), pdemoname); - CONS_Alert(CONS_ERROR, "%s", msg); - M_StartMessage(msg, NULL, MM_NOTHING); - G_ResetDemoPlayback(pdemoname); - return; - } - - // ...*map* not loaded? - if (!gamemap || (gamemap > NUMMAPS) || !mapheaderinfo[gamemap-1] || !(mapheaderinfo[gamemap-1]->menuflags & LF2_EXISTSHACK)) - { - snprintf(msg, 1024, M_GetText("%s features a course that is not currently loaded.\n"), pdemoname); - CONS_Alert(CONS_ERROR, "%s", msg); - M_StartMessage(msg, NULL, MM_NOTHING); - G_ResetDemoPlayback(pdemoname); - return; - } - - // Set color - for (i = 0; i < MAXSKINCOLORS; i++) - if (!stricmp(KartColor_Names[i],color)) // SRB2kart - { - players[0].skincolor = i; - break; - } - - // net var data - CV_LoadNetVars(&demobuf.p); - - // Sigh ... it's an empty demo. - if (*demobuf.p == DEMOMARKER) - { - snprintf(msg, 1024, M_GetText("%s contains no data to be played.\n"), pdemoname); - CONS_Alert(CONS_ERROR, "%s", msg); - M_StartMessage(msg, NULL, MM_NOTHING); - G_ResetDemoPlayback(pdemoname); - return; - } - - Z_Free(pdemoname); - - memset(&oldcmd,0,sizeof(oldcmd)); - memset(&oldghost,0,sizeof(oldghost)); - memset(&ghostext,0,sizeof(ghostext)); - - CONS_Alert(CONS_WARNING, M_GetText("Demo version does not match game version. Desyncs may occur.\n")); - - // console warning messages -#if defined(SKIPERRORS) && !defined(DEVELOP) - demosynced = (!skiperrors); -#else - demosynced = true; -#endif - - // didn't start recording right away. - demo.deferstart = false; - - consoleplayer = 0; - memset(displayplayers, 0, sizeof(displayplayers)); - memset(playeringame, 0, sizeof(playeringame)); - playeringame[0] = true; - - goto post_compat; - } -#endif - - // net var data - CV_LoadNetVars(&demobuf.p); - - // Sigh ... it's an empty demo. - if (*demobuf.p == DEMOMARKER) - { - snprintf(msg, 1024, M_GetText("%s contains no data to be played.\n"), pdemoname); - CONS_Alert(CONS_ERROR, "%s", msg); - M_StartMessage(msg, NULL, MM_NOTHING); - G_ResetDemoPlayback(pdemoname); - return; - } - - Z_Free(pdemoname); - - memset(&oldcmd,0,sizeof(oldcmd)); - memset(&oldghost,0,sizeof(oldghost)); - memset(&ghostext,0,sizeof(ghostext)); - -#if defined(SKIPERRORS) && !defined(DEVELOP) - if ((VERSION != version || SUBVERSION != subversion) && !skiperrors) -#else - if (VERSION != version || SUBVERSION != subversion) -#endif - CONS_Alert(CONS_WARNING, M_GetText("Demo version does not match game version. Desyncs may occur.\n")); - - // console warning messages -#if defined(SKIPERRORS) && !defined(DEVELOP) - demosynced = (!skiperrors); -#else - demosynced = true; -#endif - - // didn't start recording right away. - demo.deferstart = false; - - //LUA_HookInt(gamemap, HOOK(MapChange)); - - consoleplayer = 0; - memset(playeringame,0,sizeof(playeringame)); - memset(displayplayers,0,sizeof(displayplayers)); - memset(camera,0,sizeof(camera)); // reset freecam - - // Load players that were in-game when the map started - p = READUINT8(demobuf.p); - - while (p != 0xFF) - { - spectator = false; - if (p & DEMO_SPECTATOR) - { - spectator = true; - p &= ~DEMO_SPECTATOR; - - if (modeattacking) - { - snprintf(msg, 1024, M_GetText("%s is a Record Attack replay with spectators, and is thus invalid.\n"), pdemoname); - CONS_Alert(CONS_ERROR, "%s", msg); - M_StartMessage(msg, NULL, MM_NOTHING); - G_ResetDemoPlayback(pdemoname); - return; - } - } - slots[numslots] = p; numslots++; - - if (modeattacking && numslots > 1) - { - snprintf(msg, 1024, M_GetText("%s is a Record Attack replay with multiple players, and is thus invalid.\n"), pdemoname); - CONS_Alert(CONS_ERROR, "%s", msg); - M_StartMessage(msg, NULL, MM_NOTHING); - G_ResetDemoPlayback(pdemoname); - return; - } - - if (!playeringame[displayplayers[0]] || players[displayplayers[0]].spectator) - displayplayers[0] = consoleplayer = serverplayer = p; - - playeringame[p] = true; - players[p].spectator = spectator; - - // Name - M_Memcpy(player_names[p],demobuf.p,16); - demobuf.p += 16; - - // Skin - M_Memcpy(skin,demobuf.p,16); - demobuf.p += 16; - SetPlayerSkin(p, skin); - - // Color - M_Memcpy(color,demobuf.p,16); - demobuf.p += 16; - for (i = 0; i < MAXSKINCOLORS; i++) - if (!stricmp(KartColor_Names[i],color)) // SRB2kart - { - players[p].skincolor = i; - break; - } - - // Score, since Kart uses this to determine where you start on the map - players[p].score = READUINT32(demobuf.p); - - // Kart stats, temporarily - kartspeed[p] = READUINT8(demobuf.p); - kartweight[p] = READUINT8(demobuf.p); - - if (stricmp(skins[players[p].skin].name, skin) != 0) - FindClosestSkinForStats(p, kartspeed[p], kartweight[p]); - - // Look for the next player - p = READUINT8(demobuf.p); - } - - // end of player read (the 0xFF marker) - // so this is where we are to read our lua variables (if possible!) - if (demoflags & DF_LUAVARS) // again, used for compability, lua shit will be saved to replays regardless of if it's even been loaded - { - if (!gL) // No Lua state! ...I guess we'll just start one... - LUA_ClearState(); - - // No modeattacking check, DF_LUAVARS won't be present here. - LUA_UnArchive(&demobuf, false); - } - - splitscreen = 0; - - if (demo.title) - { - splitscreen = M_RandomKey(6)-1; - splitscreen = min(min(3, numslots-1), splitscreen); // Bias toward 1p and 4p views - - for (p = 0; p <= splitscreen; p++) - G_ResetView(p+1, slots[M_RandomKey(numslots)], false); - } - - R_ExecuteSetViewSize(); - -#ifdef DEMO_COMPAT_100 -post_compat: -#endif - - P_SetRandSeed(randseed); - G_InitNew(demoflags & DF_ENCORE, G_BuildMapName(gamemap), true, true); // Doesn't matter whether you reset or not here, given changes to resetplayer. - - for (i = 0; i < MAXPLAYERS; i++) - { - if (players[i].mo) - { - players[i].mo->color = players[i].skincolor; - oldghost[i].x = players[i].mo->x; - oldghost[i].y = players[i].mo->y; - oldghost[i].z = players[i].mo->z; - } - - // Set saved attribute values - // No cheat checking here, because even if they ARE wrong... - // it would only break the replay if we clipped them. - players[i].kartspeed = kartspeed[i]; - players[i].kartweight = kartweight[i]; - } - - if (cv_director.value) - CV_SetValue(&cv_director, 0); - - demo.deferstart = true; -} -#undef SKIPERRORS - -void G_AddGhost(char *defdemoname) -{ - INT32 i; - lumpnum_t l; - char name[17],skin[17],color[17],*n,*pdemoname,md5[16]; - demoghost *gh; - UINT8 flags; - UINT8 *buffer,*p; - mapthing_t *mthing; - UINT16 count, ghostversion; - skin_t *ghskin = &skins[0]; - UINT8 kartspeed = UINT8_MAX, kartweight = UINT8_MAX; - - name[16] = '\0'; - skin[16] = '\0'; - color[16] = '\0'; - - n = defdemoname+strlen(defdemoname); - while (*n != '/' && *n != '\\' && n != defdemoname) - n--; - if (n != defdemoname) - n++; - pdemoname = ZZ_Alloc(strlen(n)+1); - strcpy(pdemoname,n); - - // Internal if no extension, external if one exists - if (FIL_CheckExtension(defdemoname)) - { - //FIL_DefaultExtension(defdemoname, ".lmp"); - if (!FIL_ReadFileTag(defdemoname, &buffer, PU_LEVEL)) - { - CONS_Alert(CONS_ERROR, M_GetText("Failed to read file '%s'.\n"), defdemoname); - Z_Free(pdemoname); - return; - } - p = buffer; - } - // load demo resource from WAD - else if ((l = W_CheckNumForName(defdemoname)) == LUMPERROR) - { - CONS_Alert(CONS_ERROR, M_GetText("Failed to read lump '%s'.\n"), defdemoname); - Z_Free(pdemoname); - return; - } - else // it's an internal demo - buffer = p = W_CacheLumpNum(l, PU_LEVEL); - - // read demo header - if (memcmp(p, DEMOHEADER, 12)) - { - CONS_Alert(CONS_NOTICE, M_GetText("Ghost %s: Not a SRB2Kart replay.\n"), pdemoname); - Z_Free(pdemoname); - Z_Free(buffer); - return; - } - - p += 12; // DEMOHEADER - p++; // VERSION - p++; // SUBVERSION - - ghostversion = READUINT16(p); - switch(ghostversion) - { - case DEMOVERSION: // latest always supported - p += 64; // title - break; -#ifdef DEMO_COMPAT_100 - case 0x0001: - break; -#endif - // too old, cannot support. - default: - CONS_Alert(CONS_NOTICE, M_GetText("Ghost %s: Demo version incompatible.\n"), pdemoname); - Z_Free(pdemoname); - Z_Free(buffer); - return; - } - - M_Memcpy(md5, p, 16); p += 16; // demo checksum - for (gh = ghosts; gh; gh = gh->next) - if (!memcmp(md5, gh->checksum, 16)) // another ghost in the game already has this checksum? - { // Don't add another one, then! - CONS_Debug(DBG_SETUP, "Rejecting duplicate ghost %s (MD5 was matched)\n", pdemoname); - Z_Free(pdemoname); - Z_Free(buffer); - return; - } - - if (memcmp(p, "PLAY", 4)) - { - CONS_Alert(CONS_NOTICE, M_GetText("Ghost %s: Demo format unacceptable.\n"), pdemoname); - Z_Free(pdemoname); - Z_Free(buffer); - return; - } - - p += 4; // "PLAY" - p += 2; // gamemap - p += 16; // mapmd5 (possibly check for consistency?) - - flags = READUINT8(p); - - if (!(flags & DF_GHOST)) - { - CONS_Alert(CONS_NOTICE, M_GetText("Ghost %s: No ghost data in this demo.\n"), pdemoname); - Z_Free(pdemoname); - Z_Free(buffer); - return; - } - -#ifdef DEMO_COMPAT_100 - if (ghostversion != 0x0001) -#endif - p++; // gametype - -#ifdef DEMO_COMPAT_100 - if (ghostversion != 0x0001) -#endif - G_SkipDemoExtraFiles(&p); // Don't wanna modify the file list for ghosts. - switch ((flags & DF_ATTACKMASK)>>DF_ATTACKSHIFT) - { - case ATTACKING_NONE: // 0 - break; - case ATTACKING_RECORD: // 1 - p += 8; // demo time, lap - break; - default: // 3 - break; - } - - p += 4; // random seed - -#ifdef DEMO_COMPAT_100 - if (ghostversion == 0x0001) - { - // Player name (TODO: Display this somehow if it doesn't match cv_playername!) - M_Memcpy(name, p,16); - p += 16; - - // Skin - M_Memcpy(skin, p,16); - p += 16; - - // Color - M_Memcpy(color, p,16); - p += 16; - - // Ghosts do not have a player structure to put this in. - p++; // charability - p++; // charability2 - p++; // actionspd - p++; // mindash - p++; // maxdash - // SRB2kart - p++; // kartspeed - p++; // kartweight - // - p++; // normalspeed - p++; // runspeed - p++; // thrustfactor - p++; // accelstart - p++; // acceleration - p += 4; // jumpfactor - } - else -#endif - p += 4; // Extra data location reference - - // net var data - count = READUINT16(p); - while (count--) - { - p += 2; - SKIPSTRING(p); - p++; - } - - if (*p == DEMOMARKER) - { - CONS_Alert(CONS_NOTICE, M_GetText("Failed to add ghost %s: Replay is empty.\n"), pdemoname); - Z_Free(pdemoname); - Z_Free(buffer); - return; - } - -#ifdef DEMO_COMPAT_100 - if (ghostversion != 0x0001) - { -#endif - if (READUINT8(p) != 0) - { - CONS_Alert(CONS_NOTICE, M_GetText("Failed to add ghost %s: Invalid player slot.\n"), pdemoname); - Z_Free(pdemoname); - Z_Free(buffer); - return; - } - - // Player name (TODO: Display this somehow if it doesn't match cv_playername!) - M_Memcpy(name, p, 16); - p += 16; - - // Skin - M_Memcpy(skin, p, 16); - p += 16; - - // Color - M_Memcpy(color, p, 16); - p += 16; - - p += 4; // score - - kartspeed = READUINT8(p); - kartweight = READUINT8(p); - - if (READUINT8(p) != 0xFF) - { - CONS_Alert(CONS_NOTICE, M_GetText("Failed to add ghost %s: Invalid player slot.\n"), pdemoname); - Z_Free(pdemoname); - Z_Free(buffer); - return; - } -#ifdef DEMO_COMPAT_100 - } -#endif - - for (i = 0; i < numskins; i++) - if (!stricmp(skins[i].name,skin)) - { - ghskin = &skins[i]; - break; - } - - if (i == numskins) - { - if (kartspeed != UINT8_MAX && kartweight != UINT8_MAX) - ghskin = &skins[GetSkinNumClosestToStats(kartspeed, kartweight)]; - - CONS_Alert(CONS_NOTICE, M_GetText("Ghost %s: Invalid character. Falling back to %s.\n"), pdemoname, ghskin->name); - } - - gh = Z_Calloc(sizeof(demoghost), PU_LEVEL, NULL); - gh->next = ghosts; - gh->buffer = buffer; - M_Memcpy(gh->checksum, md5, 16); - gh->p = p; - - ghosts = gh; - - gh->version = ghostversion; - mthing = playerstarts[0]; - I_Assert(mthing); - { // A bit more complex than P_SpawnPlayer because ghosts aren't solid and won't just push themselves out of the ceiling. - fixed_t z,f,c; - gh->mo = P_SpawnMobj(mthing->x << FRACBITS, mthing->y << FRACBITS, 0, MT_GHOST); - gh->mo->angle = FixedAngle(mthing->angle*FRACUNIT); - f = gh->mo->floorz; - c = gh->mo->ceilingz - mobjinfo[MT_PLAYER].height; - if (!!(mthing->options & MTF_AMBUSH) ^ !!(mthing->options & MTF_OBJECTFLIP)) - { - z = c; - if (mthing->options >> ZSHIFT) - z -= ((mthing->options >> ZSHIFT) << FRACBITS); - if (z < f) - z = f; - } - else - { - z = f; - if (mthing->options >> ZSHIFT) - z += ((mthing->options >> ZSHIFT) << FRACBITS); - if (z > c) - z = c; - } - gh->mo->z = z; - } - gh->mo->state = states+S_KART_STND1; // SRB2kart - was S_PLAY_STND - gh->mo->sprite = gh->mo->state->sprite; - gh->mo->frame = (gh->mo->state->frame & FF_FRAMEMASK) | tr_trans20<mo->tics = -1; - - gh->oldmo.x = gh->mo->x; - gh->oldmo.y = gh->mo->y; - gh->oldmo.z = gh->mo->z; - - // Set skin - gh->mo->skin = gh->oldmo.skin = ghskin; - - // Set color - gh->mo->color = ((skin_t*)gh->mo->skin)->prefcolor; - for (i = 0; i < MAXSKINCOLORS; i++) - if (!stricmp(KartColor_Names[i],color)) // SRB2kart - { - gh->mo->color = (UINT8)i; - break; - } - gh->oldmo.color = gh->mo->color; - - CONS_Printf(M_GetText("Added ghost %s from %s\n"), name, pdemoname); - Z_Free(pdemoname); -} - -// A simplified version of G_AddGhost... -void G_UpdateStaffGhostName(lumpnum_t l) -{ - UINT8 *buffer,*p; - UINT16 ghostversion; - UINT8 flags; - - buffer = p = W_CacheLumpNum(l, PU_CACHE); - - // read demo header - if (memcmp(p, DEMOHEADER, 12)) - { - goto fail; - } - - p += 12; // DEMOHEADER - p++; // VERSION - p++; // SUBVERSION - - ghostversion = READUINT16(p); - switch(ghostversion) - { - case DEMOVERSION: // latest always supported - p += 64; // full demo title - break; - -#ifdef DEMO_COMPAT_100 - case 0x0001: - break; -#endif - - // too old, cannot support. - default: - goto fail; - } - - p += 16; // demo checksum - - if (memcmp(p, "PLAY", 4)) - { - goto fail; - } - - p += 4; // "PLAY" - p += 2; // gamemap - p += 16; // mapmd5 (possibly check for consistency?) - - flags = READUINT8(p); - if (!(flags & DF_GHOST)) - { - goto fail; // we don't NEED to do it here, but whatever - } - -#ifdef DEMO_COMPAT_100 - if (ghostversion != 0x0001) -#endif - p++; // Gametype - -#ifdef DEMO_COMPAT_100 - if (ghostversion != 0x0001) -#endif - G_SkipDemoExtraFiles(&p); - - switch ((flags & DF_ATTACKMASK)>>DF_ATTACKSHIFT) - { - case ATTACKING_NONE: // 0 - break; - case ATTACKING_RECORD: // 1 - p += 8; // demo time, lap - break; - default: // 3 - break; - } - - p += 4; // random seed - - -#ifdef DEMO_COMPAT_100 - if (ghostversion == 0x0001) - { - // Player name - M_Memcpy(dummystaffname, p,16); - dummystaffname[16] = '\0'; - goto fail; // Not really a failure but whatever - } -#endif - - p += 4; // Extrainfo location marker - - // Ehhhh don't need ghostversion here (?) so I'll reuse the var here - ghostversion = READUINT16(p); - while (ghostversion--) - { - p += 2; - SKIPSTRING(p); - p++; // stealth - } - - // Assert first player is in and then read name - if (READUINT8(p) != 0) - goto fail; - M_Memcpy(dummystaffname, p,16); - dummystaffname[16] = '\0'; - - // Ok, no longer any reason to care, bye -fail: - Z_Free(buffer); - return; -} - -// -// G_TimeDemo -// NOTE: name is a full filename for external demos -// -static INT32 restorecv_vidwait; - -void G_TimeDemo(const char *name) -{ - nodrawers = M_CheckParm("-nodraw"); - noblit = M_CheckParm("-noblit"); - restorecv_vidwait = cv_vidwait.value; - if (cv_vidwait.value) - CV_Set(&cv_vidwait, "0"); - demo.timing = true; - singletics = true; - framecount = 0; - demostarttime = I_GetTime(); - G_DeferedPlayDemo(name); -} - -void G_DoPlayMetal(void) -{ - lumpnum_t l; - mobj_t *mo = NULL; - thinker_t *th; - - // it's an internal demo - if ((l = W_CheckNumForName(va("%sMS",G_BuildMapName(gamemap)))) == LUMPERROR) - { - CONS_Alert(CONS_WARNING, M_GetText("No bot recording for this map.\n")); - return; - } - else - metalbuffer = metal_p = W_CacheLumpNum(l, PU_STATIC); - - // find metal sonic - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo = (mobj_t *)th; - if (mo->type == MT_METALSONIC_RACE) - break; - } - if (!mo) - { - CONS_Alert(CONS_ERROR, M_GetText("Failed to find bot entity.\n")); - Z_Free(metalbuffer); - return; - } - - // read demo header - metal_p += 12; // DEMOHEADER - metal_p++; // VERSION - metal_p++; // SUBVERSION - metalversion = READUINT16(metal_p); - switch(metalversion) - { - case DEMOVERSION: // latest always supported - break; -#ifdef DEMO_COMPAT_100 - case 0x0001: - I_Error("You need to implement demo compat here, doofus! %s:%d", __FILE__, __LINE__); -#endif - // too old, cannot support. - default: - CONS_Alert(CONS_WARNING, M_GetText("Failed to load bot recording for this map, format version incompatible.\n")); - Z_Free(metalbuffer); - return; - } - metal_p += 16; // demo checksum - if (memcmp(metal_p, "METL", 4)) - { - CONS_Alert(CONS_WARNING, M_GetText("Failed to load bot recording for this map, wasn't recorded in Metal format.\n")); - Z_Free(metalbuffer); - return; - } metal_p += 4; // "METL" - - // read initial tic - memset(&oldmetal,0,sizeof(oldmetal)); - oldmetal.x = mo->x; - oldmetal.y = mo->y; - oldmetal.z = mo->z; - oldmetal.angle = mo->angle; - metalplayback = mo; -} - -void G_DoneLevelLoad(void) -{ - CONS_Printf(M_GetText("Loaded level in %f sec\n"), (double)(I_GetTime() - demostarttime) / TICRATE); - framecount = 0; - demostarttime = I_GetTime(); -} - -/* -=================== -= -= G_CheckDemoStatus -= -= Called after a death or level completion to allow demos to be cleaned up -= Returns true if a new demo loop action will take place -=================== -*/ - -// Stops metal sonic's demo. Separate from other functions because metal + replays can coexist -void G_StopMetalDemo(void) -{ - // Metal Sonic finishing doesn't end the game, dammit. - Z_Free(metalbuffer); - metalbuffer = NULL; - metalplayback = NULL; - metal_p = NULL; -} - -// Stops metal sonic recording. -ATTRNORETURN void FUNCNORETURN G_StopMetalRecording(void) -{ - boolean saved = false; - if (demobuf.p && demobuf.buffer != NULL) - { - UINT8 *p = demobuf.buffer+16; // checksum position -#ifdef NOMD5 - UINT8 i; - WRITEUINT8(demobuf.p, DEMOMARKER); // add the demo end marker - for (i = 0; i < 16; i++, p++) - *p = P_RandomByte(); // This MD5 was chosen by fair dice roll and most likely < 50% correct. -#else - WRITEUINT8(demobuf.p, DEMOMARKER); // add the demo end marker - md5_buffer((char *)p+16, demobuf.p - (p+16), (void *)p); // make a checksum of everything after the checksum in the file. -#endif - saved = FIL_WriteFile(va("%sMS.LMP", G_BuildMapName(gamemap)), demobuf.buffer, demobuf.p - demobuf.buffer); // finally output the file. - } - Z_Free(demobuf.buffer); - demobuf.buffer = NULL; - metalrecording = false; - if (saved) - I_Error("Saved to %sMS.LMP", G_BuildMapName(gamemap)); - I_Error("Failed to save demo!"); -} - -// reset engine variable set for the demos -// called from stopdemo command, map command, and g_checkdemoStatus. -void G_StopDemo(void) -{ - Z_Free(demobuf.buffer); - demobuf.buffer = NULL; - demo.playback = false; - if (demo.title) - modeattacking = ATTACKING_NONE; - demo.title = false; - demo.timing = false; - singletics = false; - - UINT8 i; - for (i = 0; i < MAXSPLITSCREENPLAYERS; ++i) - { - camera[i].freecam = false; - camera[i].localangle = 0; - camera[i].localaiming = 0; - } - - CV_SetValue(&cv_playbackspeed, 1); - demo.rewinding = false; - CL_ClearRewinds(); - - if (gamestate == GS_LEVEL && rendermode != render_none) - { - V_SetPaletteLump("PLAYPAL"); // Reset the palette - R_ReInitColormaps(0, LUMPERROR); - } - if (gamestate == GS_INTERMISSION) - Y_EndIntermission(); // cleanup - if (gamestate == GS_VOTING) - Y_EndVote(); - - M_ClearMenus(true); - - G_SetGamestate(GS_NULL); - wipegamestate = GS_NULL; - SV_StopServer(); - SV_ResetServer(); -} - -// Stops timing a demo. -static void G_StopTimingDemo(void) -{ - INT32 demotime; - double f1, f2; - demotime = I_GetTime() - demostarttime; - if (!demotime) - return; - G_StopDemo(); - demo.timing = false; - f1 = (double)demotime; - f2 = (double)framecount*TICRATE; - - CONS_Printf(M_GetText("timed %u gametics in %d realtics - %u frames\n%f seconds, %f avg fps\n"), - leveltime, demotime, (UINT32)framecount, f1/TICRATE, f2/f1); - - if (restorecv_vidwait != cv_vidwait.value) - CV_SetValue(&cv_vidwait, restorecv_vidwait); - - D_StartTitle(); -} - - -boolean G_CheckDemoStatus(void) -{ - while (ghosts) - { - demoghost *next = ghosts->next; - Z_Free(ghosts); - ghosts = next; - } - ghosts = NULL; - - // DO NOT end metal sonic demos here - - if (demo.timing) - { - G_StopTimingDemo(); - return true; - } - - if (demo.playback) - { - if (demo.quitafterplaying) - I_Quit(); - - if (multiplayer && !demo.title) - { - G_ExitLevel(); - } - else if (modeattacking && !demo.title) // nooo dont crash our titledemos - { - G_StopDemo(); - M_EndModeAttackRun(); - } - else - { - G_StopDemo(); - D_StartTitle(); - } - - return true; - } - - if (!demo.recording) - return false; - - if (modeattacking || demo.savemode != DSM_NOTSAVING) - { - G_SaveDemo(); - return true; - } - - G_ResetDemoRecording(); - - return false; -} - -void G_ResetDemoRecording(void) -{ - if (demobuf.buffer) - Z_Free(demobuf.buffer); - demobuf.buffer = NULL; - demo.recording = false; -} - -static void G_ResetDemoPlayback(char *pdemoname) -{ - if (pdemoname) - Z_Free(pdemoname); - if (demobuf.buffer) - Z_Free(demobuf.buffer); - demobuf.buffer = NULL; - demo.playback = false; - if (demo.title) - modeattacking = ATTACKING_NONE; - demo.title = false; -} - -void G_SaveDemo(void) -{ - if (!demobuf.p) - { - CONS_Alert(CONS_ERROR, "Failed to save Demo. No Demo pointer exists!\n"); - // reset the demo buffer - G_ResetDemoRecording(); - return; - } - - if (demobuf.buffer == NULL) - { - CONS_Alert(CONS_ERROR, "Failed to save Demo. No Demo buffer allocated!\n"); - // reset the demo buffer - G_ResetDemoRecording(); - return; - } - - UINT8 *p = demobuf.buffer+16; // after version - UINT32 length; - - // Ensure extrainfo pointer is always available, even if no info is present. - if (demoinfo_p && *(UINT32 *)demoinfo_p == 0) - { - WRITEUINT8(demobuf.p, DEMOMARKER); // add the demo end marker - *(UINT32 *)demoinfo_p = demobuf.p - demobuf.buffer; - } - WRITEUINT8(demobuf.p, DW_END); // Mark end of demo extra data. - - M_Memcpy(p, demo.titlename, 64); // Write demo title here - p += 64; - - if (multiplayer) - { - // Change the demo's name to be a slug of the title - char demo_slug[128]; - char *writepoint; - size_t i, strindex = 0; - boolean dash = true; - - for (i = 0; demo.titlename[i] && i < 127; i++) - { - if ((demo.titlename[i] >= 'a' && demo.titlename[i] <= 'z') || - (demo.titlename[i] >= '0' && demo.titlename[i] <= '9')) - { - demo_slug[strindex] = demo.titlename[i]; - strindex++; - dash = false; - } - else if (demo.titlename[i] >= 'A' && demo.titlename[i] <= 'Z') - { - demo_slug[strindex] = demo.titlename[i] + 'a' - 'A'; - strindex++; - dash = false; - } - else if (!dash) - { - demo_slug[strindex] = '-'; - strindex++; - dash = true; - } - } - - demo_slug[strindex] = 0; - if (dash) demo_slug[strindex-1] = 0; - - writepoint = strstr(demoname, "-") + 1; - demo_slug[128 - (writepoint - demoname) - 4] = 0; - sprintf(writepoint, "%s.lmp", demo_slug); - } - - length = *(UINT32 *)demoinfo_p; - WRITEUINT32(demoinfo_p, length); -#ifdef NOMD5 - for (UINT8 k = 0; k < 16; k++, p++) - *p = M_RandomByte(); // This MD5 was chosen by fair dice roll and most likely < 50% correct. -#else - // Make a checksum of everything after the checksum in the file up to the end of the standard data. Extrainfo is freely modifiable. - md5_buffer((char *)p+16, (demobuf.buffer + length) - (p+16), p); -#endif - - - if (FIL_WriteFile(va(pandf, srb2home, demoname), demobuf.buffer, demobuf.p - demobuf.buffer)) // finally output the file. - demo.savemode = DSM_SAVED; - - G_ResetDemoRecording(); - - if (modeattacking != ATTACKING_RECORD) - { - if (demo.savemode == DSM_SAVED) - CONS_Printf(M_GetText("Demo %s recorded\n"), demoname); - else - CONS_Alert(CONS_WARNING, M_GetText("Demo %s not saved\n"), demoname); - } -} - -boolean G_DemoTitleResponder(event_t *ev) -{ - INT32 ch; - - if (ev->type != ev_keydown) - return false; - - ch = (INT32)ev->data1; - - // Only ESC and non-keyboard keys abort connection - if (ch == KEY_ESCAPE) - { - demo.savemode = (cv_recordmultiplayerdemos.value == 2) ? DSM_WILLAUTOSAVE : DSM_NOTSAVING; - return true; - } - - if (ch == KEY_ENTER || ch >= KEY_MOUSE1) - { - demo.savemode = DSM_WILLSAVE; - return true; - } - - M_TextInputHandle(&demo.titlenameinput, ch); - - return true; -} - // // G_SetGamestate // diff --git a/src/g_game.h b/src/g_game.h index 5714097b2..9d8b74144 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -14,9 +14,14 @@ #ifndef __G_GAME__ #define __G_GAME__ +#ifdef __cplusplus +extern "C" { +#endif + #include "doomdef.h" #include "doomstat.h" #include "d_event.h" +#include "g_demo.h" #include "p_saveg.h" #include "m_textinput.h" @@ -34,75 +39,6 @@ extern INT32 player_name_changes[MAXPLAYERS]; extern player_t players[MAXPLAYERS]; extern boolean playeringame[MAXPLAYERS]; -extern savebuffer_t demobuf; - -// ====================================== -// DEMO playback/recording related stuff. -// ====================================== - -// demoplaying back and demo recording -extern consvar_t cv_recordmultiplayerdemos, cv_netdemosyncquality, cv_maxdemosize, cv_demochangemap; -extern consvar_t cv_demodateformat; - -// Publicly-accessible demo vars -struct demovars_s { - char titlename[65]; - textinput_t titlenameinput; - boolean recording, playback, timing; - UINT16 version; // Current file format of the demo being played - boolean title; // Title Screen demo can be cancelled by any key - boolean rewinding; // Rewind in progress - - boolean loadfiles, ignorefiles; // Demo file loading options - boolean fromtitle; // SRB2Kart: Don't stop the music - boolean inreplayhut; // Go back to replayhut after demos - boolean quitafterplaying; // quit after playing a demo from cmdline - boolean deferstart; // don't start playing demo right away - - tic_t savebutton; // Used to determine when the local player can choose to save the replay while the race is still going - enum { - DSM_NOTSAVING, - DSM_WILLAUTOSAVE, - DSM_TITLEENTRY, - DSM_WILLSAVE, - DSM_SAVED - } savemode; -}; - -extern struct demovars_s demo; - -typedef enum { - MD_NOTLOADED, - MD_LOADED, - MD_SUBDIR, - MD_OUTDATED, - MD_INVALID -} menudemotype_e; - -typedef struct menudemo_s { - char filepath[256]; - menudemotype_e type; - - char title[65]; // Null-terminated for string prints - char date[11]; // date when replay was recorded - char version[12]; // combined version and subversion - UINT16 map; - UINT8 addonstatus; // What do we need to do addon-wise to play this demo? - UINT8 gametype; - UINT8 kartspeed; // Add OR DF_ENCORE for encore mode, idk - UINT8 numlaps; - - struct { - UINT8 ranking; - char name[17]; - UINT8 skin, color; - UINT32 timeorscore; - } standings[MAXPLAYERS]; -} menudemo_t; - - -extern mobj_t *metalplayback; - // gametic at level start extern tic_t levelstarttic; @@ -286,10 +222,6 @@ void G_SpawnPlayer(INT32 playernum, boolean starpost); void G_DeferedInitNew(boolean pencoremode, const char *mapname, INT32 pickedchar, UINT8 ssplayers, boolean FLS); -void G_LoadDemoInfo(menudemo_t *pdemo); -void G_LoadDemoTitle(menudemo_t *pdemo); // For use in replay search feature -void G_DeferedPlayDemo(const char *demo); - // Can be called by the startup code or M_Responder, calls P_SetupLevel. void G_LoadGame(UINT32 slot, INT16 mapoverride); @@ -297,97 +229,6 @@ void G_SaveGameData(boolean force); void G_SaveGame(UINT32 slot); -// Only called by startup code. -void G_RecordDemo(const char *name); -void G_RecordMetal(void); -void G_BeginRecording(void); -void G_BeginMetal(void); - -// Only called by shutdown code. -void G_WriteStanding(UINT8 ranking, char *name, INT32 skinnum, UINT8 color, UINT32 val); -void G_SetDemoTime(UINT32 ptime, UINT32 plap); -UINT8 G_CmpDemoTime(char *oldname, char *newname); - -typedef enum -{ - GHC_NORMAL = 0, - GHC_SUPER, - GHC_FIREFLOWER, - GHC_INVINCIBLE -} ghostcolor_t; - -extern UINT8 demo_extradata[MAXPLAYERS]; -extern UINT8 demo_writerng; -#define DXD_RESPAWN 0x01 // "respawn" command in console -#define DXD_SKIN 0x02 // skin changed -#define DXD_NAME 0x04 // name changed -#define DXD_COLOR 0x08 // color changed -#define DXD_PLAYSTATE 0x10 // state changed between playing, spectating, or not in-game - -#define DXD_PST_PLAYING 0x01 -#define DXD_PST_SPECTATING 0x02 -#define DXD_PST_LEFT 0x03 - -// Record/playback tics -void G_ReadDemoExtraData(void); -void G_WriteDemoExtraData(void); -void G_ReadDemoTiccmd(ticcmd_t *cmd, INT32 playernum); -void G_WriteDemoTiccmd(ticcmd_t *cmd, INT32 playernum); -void G_GhostAddThok(INT32 playernum); -void G_GhostAddSpin(INT32 playernum); -void G_GhostAddRev(INT32 playernum); -void G_GhostAddColor(INT32 playernum, ghostcolor_t color); -void G_GhostAddFlip(INT32 playernum); -void G_GhostAddScale(INT32 playernum, fixed_t scale); -void G_GhostAddHit(INT32 playernum, mobj_t *victim); -void G_WriteAllGhostTics(void); -void G_WriteGhostTic(mobj_t *ghost, INT32 playernum); -void G_ConsAllGhostTics(void); -void G_ConsGhostTic(INT32 playernum); -void G_GhostTicker(void); - -void G_InitDemoRewind(void); -void G_StoreRewindInfo(void); -void G_PreviewRewind(tic_t previewtime); -void G_ConfirmRewind(tic_t rewindtime); - -void G_ReadMetalTic(mobj_t *metal); -void G_WriteMetalTic(mobj_t *metal); -void G_SaveMetal(UINT8 **buffer); -void G_LoadMetal(UINT8 **buffer); - -// Your naming conventions are stupid and useless. -// There is no conflict here. -typedef struct demoghost { - UINT8 checksum[16]; - UINT8 *buffer, *p, color; - UINT16 version; - mobj_t oldmo, *mo; - struct demoghost *next; -} demoghost; -extern demoghost *ghosts; - -// G_CheckDemoExtraFiles: checks if our loaded WAD list matches the demo's. -#define DFILE_ERROR_NOTLOADED 0x01 // Files are not loaded, but can be without a restart. -#define DFILE_ERROR_OUTOFORDER 0x02 // Files are loaded, but out of order. -#define DFILE_ERROR_INCOMPLETEOUTOFORDER 0x03 // Some files are loaded out of order, but others are not. -#define DFILE_ERROR_CANNOTLOAD 0x04 // Files are missing and cannot be loaded. -#define DFILE_ERROR_EXTRAFILES 0x05 // Extra files outside of the replay's file list are loaded. - -void G_ResetDemoRecording(void); -void G_DoPlayDemo(char *defdemoname); -void G_TimeDemo(const char *name); -void G_AddGhost(char *defdemoname); -void G_UpdateStaffGhostName(lumpnum_t l); -void G_DoPlayMetal(void); -void G_DoneLevelLoad(void); -void G_StopMetalDemo(void); -ATTRNORETURN void FUNCNORETURN G_StopMetalRecording(void); -void G_StopDemo(void); -boolean G_CheckDemoStatus(void); -void G_SaveDemo(void); -boolean G_DemoTitleResponder(event_t *ev); - #define G_GametypeHasTeams() (G_IsGameType(GT_TEAMMATCH) || G_IsGameType(GT_CTF)) #define G_BattleGametype() (G_IsGameType(GT_MATCH)) #define G_RaceGametype() (G_IsGameType(GT_RACE)) @@ -484,4 +325,8 @@ void G_AddMapToBuffer(INT16 map); void G_FixCamera(UINT8 view); +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/hardware/Sourcefile b/src/hardware/Sourcefile index 3114c975c..e66482c3d 100644 --- a/src/hardware/Sourcefile +++ b/src/hardware/Sourcefile @@ -1,6 +1,6 @@ hw_bsp.c hw_draw.c -hw_main.c +hw_main.cpp hw_clip.c hw_md2.c hw_cache.c diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 801442b6f..3b5c5426e 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -25,22 +25,23 @@ GLMipmap_t *current_texture = NULL; boolean currently_batching = false; -FOutVector* finalVertexArray = NULL;// contains subset of sorted vertices and texture coordinates to be sent to gpu +FOutVector* finalVertexArray = NULL;// contains subset of sorted vertices and texture coordinates to be sent to gpu UINT32* finalVertexIndexArray = NULL;// contains indexes for glDrawElements, taking into account fan->triangles conversion // NOTE have this alloced as 3x finalVertexArray size int finalVertexArrayAllocSize = 65536; + //GLubyte* colorArray = NULL;// contains color data to be sent to gpu, if needed //int colorArrayAllocSize = 65536; // not gonna use this for now, just sort by color and change state when it changes // later maybe when using vertex attributes if it's needed -PolygonArrayEntry* polygonArray = NULL;// contains the polygon data from DrawPolygon, waiting to be processed -int polygonArraySize = 0; -PolygonArrayEntry **polygonArraySorted = NULL;// contains sorted pointers to polygonArray +PolygonArrayEntry* polygonArray = NULL ;// contains the polygon data from DrawPolygon, waiting to be processed +PolygonArrayEntry **polygonArraySorted = NULL; // contains sorted pointers to polygonArray +int polygonArraySize = 0; int polygonArrayAllocSize = 65536; -FOutVector* unsortedVertexArray = NULL;// contains unsorted vertices and texture coordinates from DrawPolygon -int unsortedVertexArraySize = 0; +FOutVector* unsortedVertexArray = NULL; // contains unsorted vertices and texture coordinates from DrawPolygon +int unsortedVertexArraySize = 0; int unsortedVertexArrayAllocSize = 65536; // Enables batching mode. HWR_ProcessPolygon will collect polygons instead of passing them directly to the rendering backend. @@ -55,11 +56,11 @@ void HWR_StartBatching(void) // init arrays if that has not been done yet if (!finalVertexArray) { - finalVertexArray = malloc(finalVertexArrayAllocSize * sizeof(FOutVector)); + finalVertexArray = malloc(finalVertexArrayAllocSize * sizeof(FOutVector)); finalVertexIndexArray = malloc(finalVertexArrayAllocSize * 3 * sizeof(UINT32)); - polygonArray = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry)); - polygonArraySorted = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry *)); - unsortedVertexArray = malloc(unsortedVertexArrayAllocSize * sizeof(FOutVector)); + polygonArray = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry)); + polygonArraySorted = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry *)); + unsortedVertexArray = malloc(unsortedVertexArrayAllocSize * sizeof(FOutVector)); } currently_batching = true; @@ -129,16 +130,15 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt } } - static int comparePolygons(const void *p1, const void *p2) { - const PolygonArrayEntry *poly1 = *(PolygonArrayEntry *const *)p1; - const PolygonArrayEntry *poly2 = *(PolygonArrayEntry *const *)p2; int diff; INT64 diff64; + const PolygonArrayEntry *poly1 = *(PolygonArrayEntry *const *)p1; + const PolygonArrayEntry *poly2 = *(PolygonArrayEntry *const *)p2; - int shader1 = (poly1->polyFlags & PF_NoTexture || poly1->horizonSpecial) ? -1 : poly1->shader; - int shader2 = (poly2->polyFlags & PF_NoTexture || poly2->horizonSpecial) ? -1 : poly2->shader; + const int shader1 = (poly1->polyFlags & PF_NoTexture || poly1->horizonSpecial) ? -1 : poly1->shader; + const int shader2 = (poly2->polyFlags & PF_NoTexture || poly2->horizonSpecial) ? -1 : poly2->shader; // skywalls and horizon lines must retain their order for horizon lines to work if (shader1 == -1 && shader2 == -1) @@ -174,13 +174,13 @@ static int comparePolygons(const void *p1, const void *p2) static int comparePolygonsNoShaders(const void *p1, const void *p2) { - PolygonArrayEntry *poly1 = *(PolygonArrayEntry *const *)p1; - PolygonArrayEntry *poly2 = *(PolygonArrayEntry *const *)p2; int diff; INT64 diff64; + const PolygonArrayEntry *poly1 = *(PolygonArrayEntry *const *)p1; + const PolygonArrayEntry *poly2 = *(PolygonArrayEntry *const *)p2; - GLMipmap_t *texture1 = (poly1->polyFlags & PF_NoTexture || poly1->horizonSpecial) ? NULL : poly1->texture; - GLMipmap_t *texture2 = (poly2->polyFlags & PF_NoTexture || poly2->horizonSpecial) ? NULL : poly2->texture; + const GLMipmap_t *texture1 = (poly1->polyFlags & PF_NoTexture || poly1->horizonSpecial) ? NULL : poly1->texture; + const GLMipmap_t *texture2 = (poly2->polyFlags & PF_NoTexture || poly2->horizonSpecial) ? NULL : poly2->texture; // skywalls and horizon lines must retain their order for horizon lines to work if (!texture1 && !texture2) @@ -204,17 +204,16 @@ static int comparePolygonsNoShaders(const void *p1, const void *p2) // the rendering backend to draw them. void HWR_RenderBatches(void) { - int finalVertexWritePos = 0;// position in finalVertexArray - int finalIndexWritePos = 0;// position in finalVertexIndexArray - - int polygonReadPos = 0;// position in polygonArraySorted + int finalVertexWritePos = 0; // position in finalVertexArray + int finalIndexWritePos = 0; // position in finalVertexIndexArray + int polygonReadPos = 0; // position in polygonArraySorted int currentShader; int nextShader = 0; - GLMipmap_t *currentTexture = NULL; - GLMipmap_t *nextTexture = NULL; - FBITFIELD currentPolyFlags = 0; - FBITFIELD nextPolyFlags = 0; + GLMipmap_t *currentTexture = NULL; + GLMipmap_t *nextTexture = NULL; + FBITFIELD currentPolyFlags = 0; + FBITFIELD nextPolyFlags = 0; FSurfaceInfo currentSurfaceInfo; FSurfaceInfo nextSurfaceInfo; @@ -225,8 +224,8 @@ void HWR_RenderBatches(void) I_Error("HWR_RenderBatches called without starting batching"); } - nextSurfaceInfo.LightInfo.fade_end = 0; - nextSurfaceInfo.LightInfo.fade_start = 0; + nextSurfaceInfo.LightInfo.fade_end = 0; + nextSurfaceInfo.LightInfo.fade_start = 0; nextSurfaceInfo.LightInfo.light_level = 0; nextSurfaceInfo.LightInfo.directional = false; @@ -244,7 +243,7 @@ void HWR_RenderBatches(void) ps_hw_numpolys.value.i = polygonArraySize; ps_hw_numcalls.value.i = ps_hw_numverts.value.i = 0; ps_hw_numshaders.value.i = ps_hw_numtextures.value.i - = ps_hw_numpolyflags.value.i = ps_hw_numcolors.value.i = 1; + = ps_hw_numpolyflags.value.i = ps_hw_numcolors.value.i = 1; // init polygonArraySorted for (i = 0; i < polygonArraySize; i++) @@ -254,10 +253,7 @@ void HWR_RenderBatches(void) // sort polygons PS_START_TIMING(ps_hw_batchsorttime); - if (cv_glshaders.value && gl_shadersavailable) - qs22j(polygonArraySorted, polygonArraySize, sizeof(PolygonArrayEntry *), comparePolygons); - else - qs22j(polygonArraySorted, polygonArraySize, sizeof(PolygonArrayEntry *), comparePolygonsNoShaders); + qs22j(polygonArraySorted, polygonArraySize, sizeof(PolygonArrayEntry *), (HWR_UseShader() ? comparePolygons : comparePolygonsNoShaders)); PS_STOP_TIMING(ps_hw_batchsorttime); // sort order @@ -269,16 +265,16 @@ void HWR_RenderBatches(void) PS_START_TIMING(ps_hw_batchdrawtime); - currentShader = polygonArraySorted[0]->shader; - currentTexture = polygonArraySorted[0]->texture; - currentPolyFlags = polygonArraySorted[0]->polyFlags; + currentShader = polygonArraySorted[0]->shader; + currentTexture = polygonArraySorted[0]->texture; + currentPolyFlags = polygonArraySorted[0]->polyFlags; currentSurfaceInfo = polygonArraySorted[0]->surf; // For now, will sort and track the colors. Vertex attributes could be used instead of uniforms // and a color array could replace the color calls. // set state for first batch - if (cv_glshaders.value && gl_shadersavailable) + if (HWR_UseShader()) { GL_SetShader(currentShader); } @@ -303,16 +299,17 @@ void HWR_RenderBatches(void) // steps: // write vertices // check for changes or end, otherwise go back to writing - // changes will affect the next vars and the change bools - // end could set flag for stopping + // changes will affect the next vars and the change bools + // end could set flag for stopping // execute draw call // could check ending flag here // change states according to next vars and change bools, updating the current vars and reseting the bools // reset write pos // repeat loop - PolygonArrayEntry *entry = polygonArraySorted[polygonReadPos++]; - int numVerts = entry->numVerts; + const PolygonArrayEntry *entry = polygonArraySorted[polygonReadPos++]; + const int numVerts = entry->numVerts; + // before writing, check if there is enough room // using 'while' instead of 'if' here makes sure that there will *always* be enough room. // probably never will this loop run more than once though @@ -324,13 +321,15 @@ void HWR_RenderBatches(void) // going from fans to triangles increases vertex count to 3x finalVertexIndexArray = realloc(finalVertexIndexArray, finalVertexArrayAllocSize * 3 * sizeof(UINT32)); } + // write the vertices of the polygon - memcpy(&finalVertexArray[finalVertexWritePos], &unsortedVertexArray[entry->vertsIndex], - numVerts * sizeof(FOutVector)); + memcpy(&finalVertexArray[finalVertexWritePos], &unsortedVertexArray[entry->vertsIndex], numVerts * sizeof(FOutVector)); + // write the indexes, pointing to the fan vertexes but in triangles format firstIndex = finalVertexWritePos; lastIndex = finalVertexWritePos + numVerts; finalVertexWritePos += 2; + while (finalVertexWritePos < lastIndex) { finalVertexIndexArray[finalIndexWritePos++] = firstIndex; @@ -345,16 +344,16 @@ void HWR_RenderBatches(void) else { // check if a state change is required, set the change bools and next vars - PolygonArrayEntry *nextEntry = polygonArraySorted[polygonReadPos]; - nextShader = nextEntry->shader; - nextTexture = nextEntry->texture; - nextPolyFlags = nextEntry->polyFlags; + const PolygonArrayEntry *nextEntry = polygonArraySorted[polygonReadPos]; + nextShader = nextEntry->shader; + nextTexture = nextEntry->texture; + nextPolyFlags = nextEntry->polyFlags; nextSurfaceInfo = nextEntry->surf; if (nextPolyFlags & PF_NoTexture) nextTexture = 0; - if (currentShader != nextShader && cv_glshaders.value && gl_shadersavailable) + if (currentShader != nextShader && HWR_UseShader()) { changeState = true; changeShader = true; @@ -372,14 +371,14 @@ void HWR_RenderBatches(void) changePolyFlags = true; } - if (cv_glshaders.value && gl_shadersavailable) + if (HWR_UseShader()) { if (currentSurfaceInfo.PolyColor.rgba != nextSurfaceInfo.PolyColor.rgba || currentSurfaceInfo.TintColor.rgba != nextSurfaceInfo.TintColor.rgba || currentSurfaceInfo.FadeColor.rgba != nextSurfaceInfo.FadeColor.rgba || currentSurfaceInfo.LightInfo.light_level != nextSurfaceInfo.LightInfo.light_level || - currentSurfaceInfo.LightInfo.fade_start != nextSurfaceInfo.LightInfo.fade_start || - currentSurfaceInfo.LightInfo.fade_end != nextSurfaceInfo.LightInfo.fade_end || + currentSurfaceInfo.LightInfo.fade_start != nextSurfaceInfo.LightInfo.fade_start || + currentSurfaceInfo.LightInfo.fade_end != nextSurfaceInfo.LightInfo.fade_end || currentSurfaceInfo.LightInfo.directional != nextSurfaceInfo.LightInfo.directional) { changeState = true; @@ -405,7 +404,7 @@ void HWR_RenderBatches(void) ps_hw_numverts.value.i += finalIndexWritePos; // reset write positions finalVertexWritePos = 0; - finalIndexWritePos = 0; + finalIndexWritePos = 0; } else continue; @@ -451,9 +450,10 @@ void HWR_RenderBatches(void) ps_hw_numcolors.value.i++; } - // and that should be it? } + // and that should be it? } + // reset the arrays (set sizes to 0) polygonArraySize = 0; unsortedVertexArraySize = 0; diff --git a/src/hardware/hw_batching.h b/src/hardware/hw_batching.h index 7f418fc77..d1808ce43 100644 --- a/src/hardware/hw_batching.h +++ b/src/hardware/hw_batching.h @@ -13,6 +13,10 @@ #ifndef __HWR_BATCHING_H__ #define __HWR_BATCHING_H__ +#ifdef __cplusplus +extern "C" { +#endif + #include "hw_defs.h" #include "hw_data.h" #include "hw_gl.h" @@ -36,4 +40,8 @@ void HWR_SetCurrentTexture(GLMipmap_t *texture); void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, int shader, boolean horizonSpecial); void HWR_RenderBatches(void); +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 934f13a14..76231750c 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -371,12 +371,13 @@ static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 count, poly_t *poly) line_t *line = lseg->linedef; // portal check - if (!gl_maphasportals && line->special == 40 && lseg->side == 0) + if (!gl_maphasportals && line->special == PORTALSPECIAL && lseg->side == 0) { // Find the other side! - INT32 line2 = P_FindSpecialLineFromTag(40, line->tag, -1); + INT32 line2 = P_FindSpecialLineFromTag(PORTALSPECIAL, line->tag, -1); + if (line == &lines[line2]) - line2 = P_FindSpecialLineFromTag(40, line->tag, line2); + line2 = P_FindSpecialLineFromTag(PORTALSPECIAL, line->tag, line2); if (line2 >= 0) // found it! gl_maphasportals = 1; } diff --git a/src/hardware/hw_clip.h b/src/hardware/hw_clip.h index dfaa87f81..4299fbaea 100644 --- a/src/hardware/hw_clip.h +++ b/src/hardware/hw_clip.h @@ -7,6 +7,10 @@ * */ +#ifdef __cplusplus +extern "C" { +#endif + // OpenGL BSP clipping #include "../doomdef.h" #include "../tables.h" @@ -22,3 +26,7 @@ angle_t gld_FrustumAngle(angle_t tiltangle); void gld_FrustumSetup(void); boolean gld_SphereInFrustum(float x, float y, float z, float radius); #endif + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 7e996e083..5c13cf9ff 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -96,12 +96,12 @@ void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option) pdupx = pdupy = 2.0f; break; case V_SMALLSCALEPATCH: - pdupx = 2.0f * FIXED_TO_FLOAT(vid.fsmalldupx); - pdupy = 2.0f * FIXED_TO_FLOAT(vid.fsmalldupy); + pdupx = 2.0f * FIXED_TO_FLOAT(vid.smalldupx*FRACUNIT); + pdupy = 2.0f * FIXED_TO_FLOAT(vid.smalldupy*FRACUNIT); break; case V_MEDSCALEPATCH: - pdupx = 2.0f * FIXED_TO_FLOAT(vid.fmeddupx); - pdupy = 2.0f * FIXED_TO_FLOAT(vid.fmeddupy); + pdupx = 2.0f * FIXED_TO_FLOAT(vid.meddupx*FRACUNIT); + pdupy = 2.0f * FIXED_TO_FLOAT(vid.meddupx*FRACUNIT); break; } diff --git a/src/hardware/hw_gl.h b/src/hardware/hw_gl.h index a21fd0a3a..8780fc57b 100644 --- a/src/hardware/hw_gl.h +++ b/src/hardware/hw_gl.h @@ -13,6 +13,10 @@ #ifndef __HWR_GL_H__ #define __HWR_GL_H__ +#ifdef __cplusplus +extern "C" { +#endif + #include "../screen.h" #include "hw_data.h" @@ -76,4 +80,8 @@ UINT32 GL_CreateLightTable(RGBA_t *hw_lighttable); void GL_ClearLightTables(void); void GL_SetScreenPalette(RGBA_t *palette); +#ifdef __cplusplus +} // extern "C" +#endif + #endif // __HWR_GL_H__ diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index 0589ba1d2..09956b99d 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -14,6 +14,10 @@ #ifndef _HWR_GLOB_H_ #define _HWR_GLOB_H_ +#ifdef __cplusplus +extern "C" { +#endif + #include "hw_defs.h" #include "../m_misc.h" #include "../r_defs.h" @@ -109,4 +113,8 @@ const char *HWR_GetShaderName(INT32 shader); extern customshaderxlat_t shaderxlat[]; +#ifdef __cplusplus +} // extern "C" +#endif + #endif //_HW_GLOB_ diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.cpp similarity index 90% rename from src/hardware/hw_main.c rename to src/hardware/hw_main.cpp index 43cb25aed..0504c1597 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.cpp @@ -11,13 +11,15 @@ /// \file /// \brief hardware renderer, using the standard HardWareRender driver DLL for SRB2 -#include +#ifdef HWRENDER + +#include +#define _USE_MATH_DEFINES +#include #include "../doomstat.h" #include "../doomdef.h" -#ifdef HWRENDER - #include "hw_main.h" #include "hw_glob.h" #include "hw_gl.h" @@ -100,28 +102,28 @@ sector_t *gl_backsector; static boolean gl_maphashorizonlines = false; // values for the far clipping plane -static float clipping_distances[] = {1024.0f, 2048.0f, 4096.0f, 6144.0f, 8192.0f, 12288.0f, 16384.0f}; +static constexpr float clipping_distances[] = {1024.0f, 2048.0f, 4096.0f, 6144.0f, 8192.0f, 12288.0f, 16384.0f}; // values for bsp culling // slightly higher than the far clipping plane to compensate for impreciseness -static INT32 bsp_culling_distances[] = {(1024+512)*FRACUNIT, (2048+512)*FRACUNIT, (4096+512)*FRACUNIT, +static constexpr INT32 bsp_culling_distances[] = {(1024+512)*FRACUNIT, (2048+512)*FRACUNIT, (4096+512)*FRACUNIT, (6144+512)*FRACUNIT, (8192+512)*FRACUNIT, (12288+512)*FRACUNIT, (16384+512)*FRACUNIT}; // Performance stats -ps_metric_t ps_hw_nodesorttime = {0}; -ps_metric_t ps_hw_nodedrawtime = {0}; -ps_metric_t ps_hw_spritesorttime = {0}; -ps_metric_t ps_hw_spritedrawtime = {0}; +ps_metric_t ps_hw_nodesorttime = {}; +ps_metric_t ps_hw_nodedrawtime = {}; +ps_metric_t ps_hw_spritesorttime = {}; +ps_metric_t ps_hw_spritedrawtime = {}; // Performance stats for batching -ps_metric_t ps_hw_numpolys = {0}; -ps_metric_t ps_hw_numverts = {0}; -ps_metric_t ps_hw_numcalls = {0}; -ps_metric_t ps_hw_numshaders = {0}; -ps_metric_t ps_hw_numtextures = {0}; -ps_metric_t ps_hw_numpolyflags = {0}; -ps_metric_t ps_hw_numcolors = {0}; -ps_metric_t ps_hw_batchsorttime = {0}; -ps_metric_t ps_hw_batchdrawtime = {0}; +ps_metric_t ps_hw_numpolys = {}; +ps_metric_t ps_hw_numverts = {}; +ps_metric_t ps_hw_numcalls = {}; +ps_metric_t ps_hw_numshaders = {}; +ps_metric_t ps_hw_numtextures = {}; +ps_metric_t ps_hw_numpolyflags = {}; +ps_metric_t ps_hw_numcolors = {}; +ps_metric_t ps_hw_batchsorttime = {}; +ps_metric_t ps_hw_batchdrawtime = {}; static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, boolean noencore, FSurfaceInfo* Surf, INT32 cutflag, ffloor_t *pfloor, FBITFIELD polyflags); static void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap); @@ -372,15 +374,15 @@ void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 fixed_t extralight = R_GetSpriteDirectionalLighting(R_PointToAngle(spr->mobj->x, spr->mobj->y)); // Less change in contrast in dark sectors - extralight = FixedMul(extralight, min(max(0, *lightlevel), 255) * FRACUNIT / 255); + extralight = FixedMul(extralight, CLAMP(*lightlevel, 0, 255) * FRACUNIT / 255); // simple OGL approximation - fixed_t tr = R_PointToDist(spr->mobj->x, spr->mobj->y); + fixed_t tr = R_QuickCamDist(spr->mobj->x, spr->mobj->y) << FRACBITS; fixed_t xscale = FixedDiv((vid.width / 2) << FRACBITS, tr); // Less change in contrast at further distances, to counteract DOOM diminished light fixed_t n = FixedDiv(FixedMul(xscale, LIGHTRESOLUTIONFIX), ((MAXLIGHTSCALE-1) << LIGHTSCALESHIFT)); - extralight = FixedMul(extralight, min(n, FRACUNIT)); + extralight = FixedMul(extralight, std::min(n, FRACUNIT)); // Contrast is stronger for normal sprites, stronger than wall lighting is at the same distance *lightlevel += FixedFloor((extralight * 2) + (FRACUNIT / 2)) / FRACUNIT; @@ -414,9 +416,9 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col float tint_alpha, fade_alpha; float red, green, blue; - red = (float)poly_color.s.red; + red = (float)poly_color.s.red; green = (float)poly_color.s.green; - blue = (float)poly_color.s.blue; + blue = (float)poly_color.s.blue; // 48 is just an arbritrary value that looked relatively okay. tint_alpha = (float)(sqrt(tint_color.s.alpha) * 48) / 255.0f; @@ -428,20 +430,20 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col fade_alpha = (float)(sqrt(255-light_level) * 12) / 255.0f; // Clamp the alpha values - tint_alpha = min(max(tint_alpha, 0.0f), 1.0f); - fade_alpha = min(max(fade_alpha, 0.0f), 1.0f); + tint_alpha = CLAMP(tint_alpha, 0.0f, 1.0f); + fade_alpha = CLAMP(fade_alpha, 0.0f, 1.0f); - red = (tint_color.s.red * tint_alpha) + (red * (1.0f - tint_alpha)); + red = (tint_color.s.red * tint_alpha) + (red * (1.0f - tint_alpha)); green = (tint_color.s.green * tint_alpha) + (green * (1.0f - tint_alpha)); - blue = (tint_color.s.blue * tint_alpha) + (blue * (1.0f - tint_alpha)); + blue = (tint_color.s.blue * tint_alpha) + (blue * (1.0f - tint_alpha)); - red = (fade_color.s.red * fade_alpha) + (red * (1.0f - fade_alpha)); + red = (fade_color.s.red * fade_alpha) + (red * (1.0f - fade_alpha)); green = (fade_color.s.green * fade_alpha) + (green * (1.0f - fade_alpha)); - blue = (fade_color.s.blue * fade_alpha) + (blue * (1.0f - fade_alpha)); + blue = (fade_color.s.blue * fade_alpha) + (blue * (1.0f - fade_alpha)); - poly_color.s.red = (UINT8)red; + poly_color.s.red = (UINT8)red; poly_color.s.green = (UINT8)green; - poly_color.s.blue = (UINT8)blue; + poly_color.s.blue = (UINT8)blue; } // Clamp the light level, since it can sometimes go out of the 0-255 range from animations @@ -548,7 +550,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool size_t len; float tempxsow, tempytow; - float scrollx = 0.0f, scrolly = 0.0f; + float scrollx = 0.0f, scrolly = 0.0f, anglef = 0.0f; angle_t angle = 0; static FOutVector *planeVerts = NULL; @@ -668,14 +670,11 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool if (angle) // Only needs to be done if there's an altered angle { - angle = InvAngle(angle)>>ANGLETOFINESHIFT; - - // This needs to be done so everything aligns after rotation - // It would be done so that rotation is done, THEN the translation, but I couldn't get it to rotate AND scroll like software does - tempxsow = FloatToFixed(flatxref); - tempytow = FloatToFixed(flatyref); - flatxref = (FixedToFloat(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle)))); - flatyref = (FixedToFloat(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle)))); + tempxsow = flatxref; + tempytow = flatyref; + anglef = ANG2RAD(InvAngle(angle)); + flatxref = (tempxsow * cos(anglef)) - (tempytow * sin(anglef)); + flatyref = (tempxsow * sin(anglef)) + (tempytow * cos(anglef)); } #define SETUP3DVERT(vert, vx, vy) {\ @@ -686,10 +685,10 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool /* Need to rotate before translate */\ if (angle) /* Only needs to be done if there's an altered angle */\ {\ - tempxsow = FloatToFixed(vert->s);\ - tempytow = FloatToFixed(vert->t);\ - vert->s = (FixedToFloat(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle))));\ - vert->t = (FixedToFloat(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle))));\ + tempxsow = vert->s;\ + tempytow = vert->t;\ + vert->s = (tempxsow * cos(anglef)) - (tempytow * sin(anglef));\ + vert->t = (tempxsow * sin(anglef)) + (tempytow * cos(anglef));\ }\ \ vert->x = (vx);\ @@ -740,14 +739,15 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool UINT8 numplanes, j; vertex_t v; // For determining the closest distance from the line to the camera, to split render planes for minimum distortion; - const float renderdist = 27000.0f; // How far out to properly render the plane - const float farrenderdist = 32768.0f; // From here, raise plane to horizon level to fill in the line with some texture distortion + static constexpr float renderdist = 27000.0f; // How far out to properly render the plane + static constexpr float farrenderdist = 32768.0f; // From here, raise plane to horizon level to fill in the line with some texture distortion - seg_t *line = &segs[subsector->firstline]; + const seg_t *line = &segs[subsector->firstline]; for (i = 0; i < subsector->numlines; i++, line++) { - if (line->linedef->special != HORIZONSPECIAL) + // this check sucks and is a hotspot lel + if (LIKELY(line->linedef->special != HORIZONSPECIAL)) continue; if (R_PointOnSegSide(viewx, viewy, line) != 0) @@ -763,8 +763,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool } else { - x1 = FixedToFloat(line->v1->x); - y1 = FixedToFloat(line->v1->x); + x1 = y1 = FixedToFloat(line->v1->x); } if (line->pv2) @@ -780,6 +779,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool // Based on the seg length and the distance from the line, split horizon into multiple poly sets to reduce distortion dist = sqrtf((xd*xd) + (yd*yd)) / dist / 16.0f; + if (dist > 100.0f) numplanes = 100; else @@ -1027,7 +1027,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, // Lactozilla: If both heights of a side lay on the same position, then this wall is a triangle. // To avoid division by zero, which would result in a NaN, we check if the vertical difference // between the two vertices is not zero. - if (fpclassify(diff) == FP_ZERO) + if (std::fpclassify(diff) == FP_ZERO) pegmul = 0.0; else pegmul = (pegb - pegt) / diff; @@ -1039,7 +1039,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, endpegt = wallVerts[2].t; endpegb = wallVerts[1].t; - if (fpclassify(diff) == FP_ZERO) + if (std::fpclassify(diff) == FP_ZERO) endpegmul = 0.0; else endpegmul = (endpegb - endpegt) / diff; @@ -1084,12 +1084,12 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, else solid = false; - height = FixedToFloat(P_GetLightZAt(&list[i], v1x, v1y)); + height = FixedToFloat(P_GetLightZAt(&list[i], v1x, v1y)); endheight = FixedToFloat(P_GetLightZAt(&list[i], v2x, v2y)); if (solid) { - bheight = FixedToFloat(P_GetFFloorBottomZAt(list[i].caster, v1x, v1y)); + bheight = FixedToFloat(P_GetFFloorBottomZAt(list[i].caster, v1x, v1y)); endbheight = FixedToFloat(P_GetFFloorBottomZAt(list[i].caster, v2x, v2y)); } @@ -1097,6 +1097,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, { if (solid && top > bheight) top = bheight; + if (solid && endtop > endbheight) endtop = endbheight; } @@ -1112,15 +1113,12 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, endbheight = endrealbot; } - if (endbheight >= endtop) - continue; - - if (bheight >= top) + if ((endbheight >= endtop) || (bheight >= top)) continue; // Found a break // The heights are clamped to ensure the polygon doesn't cross itself. - bot = CLAMP(bheight, realbot, top); + bot = CLAMP(bheight, realbot, top); endbot = CLAMP(endbheight, endrealbot, endtop); Surf->PolyColor.s.alpha = alpha; @@ -1149,6 +1147,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, bot = realbot; endbot = endrealbot; + if ((endtop <= endrealbot) && (top <= realbot)) return; @@ -1195,14 +1194,14 @@ static void HWR_SkyWallList_Add(FOutVector *wallVerts) if (!skyWallVertexArray) { // array has not been allocated yet. allocate it now - skyWallVertexArray = Z_Malloc(sizeof(FOutVector) * 4 * skyWallVertexArrayAllocSize, PU_STATIC, NULL); + skyWallVertexArray = static_cast(Z_Malloc(sizeof(FOutVector) * 4 * skyWallVertexArrayAllocSize, PU_STATIC, NULL)); } if (skyWallVertexArraySize == skyWallVertexArrayAllocSize) { // allocated array got full, allocate more space skyWallVertexArrayAllocSize *= 2; - skyWallVertexArray = Z_Realloc(skyWallVertexArray, sizeof(FOutVector) * 4 * skyWallVertexArrayAllocSize, PU_STATIC, NULL); + skyWallVertexArray = static_cast(Z_Realloc(skyWallVertexArray, sizeof(FOutVector) * 4 * skyWallVertexArrayAllocSize, PU_STATIC, NULL)); } memcpy(skyWallVertexArray + skyWallVertexArraySize * 4, wallVerts, sizeof(FOutVector) * 4); @@ -1389,7 +1388,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // x offset the texture fixed_t texturehpeg = gl_sidedef->textureoffset + gl_curline->offset; - float cliplow = (float)texturehpeg; + float cliplow = (float)texturehpeg; float cliphigh = (float)(texturehpeg + (gl_curline->flength*FRACUNIT)); FUINT lightnum = gl_frontsector->lightlevel; @@ -1420,6 +1419,13 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // Sky Ceilings wallVerts[3].y = wallVerts[2].y = FixedToFloat(INT32_MAX); + auto draw_sky_walls = [&](int vert1, int vert2, fixed_t world, fixed_t worldslope) + { + wallVerts[vert1].y = FixedToFloat(world); + wallVerts[vert2].y = FixedToFloat(worldslope); + HWR_DrawSkyWall(wallVerts, &Surf); + }; + if (gl_frontsector->ceilingpic == skyflatnum) { if (gl_backsector->ceilingpic == skyflatnum) @@ -1430,25 +1436,19 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom && (worldhigh != worldtop || worldhighslope != worldtopslope)) // Removing the second line above will render more rarely visible skywalls. Example: Cave garden ceiling in Dark race { - wallVerts[0].y = FixedToFloat(worldhigh); - wallVerts[1].y = FixedToFloat(worldhighslope); - HWR_DrawSkyWall(wallVerts, &Surf); + draw_sky_walls(0, 1, worldhigh, worldhighslope); } } else { // Only the frontsector is sky, just draw a skywall from the front ceiling - wallVerts[0].y = FixedToFloat(worldtop); - wallVerts[1].y = FixedToFloat(worldtopslope); - HWR_DrawSkyWall(wallVerts, &Surf); + draw_sky_walls(0, 1, worldtop, worldtopslope); } } else if (gl_backsector->ceilingpic == skyflatnum) { // Only the backsector is sky, just draw a skywall from the front ceiling - wallVerts[0].y = FixedToFloat(worldtop); - wallVerts[1].y = FixedToFloat(worldtopslope); - HWR_DrawSkyWall(wallVerts, &Surf); + draw_sky_walls(0, 1, worldtop, worldtopslope); } // Sky Floors @@ -1466,25 +1466,19 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // Removing the second line above will render more rarely visible skywalls. Example: Cave garden ceiling in Dark race && !(gl_sidedef->bottomtexture)) { - wallVerts[3].y = FixedToFloat(worldlow); - wallVerts[2].y = FixedToFloat(worldlowslope); - HWR_DrawSkyWall(wallVerts, &Surf); + draw_sky_walls(3, 2, worldlow, worldlowslope); } } else { // Only the backsector has sky, just draw a skywall from the back floor - wallVerts[3].y = FixedToFloat(worldbottom); - wallVerts[2].y = FixedToFloat(worldbottomslope); - HWR_DrawSkyWall(wallVerts, &Surf); + draw_sky_walls(3, 2, worldbottom, worldbottomslope); } } else if ((gl_backsector->floorpic == skyflatnum) && !(gl_sidedef->bottomtexture)) { // Only the backsector has sky, just draw a skywall from the back floor if there's no bottomtexture - wallVerts[3].y = FixedToFloat(worldlow); - wallVerts[2].y = FixedToFloat(worldlowslope); - HWR_DrawSkyWall(wallVerts, &Surf); + draw_sky_walls(3, 2, worldlow, worldlowslope); } } @@ -1677,10 +1671,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } else { - popentop = min(worldtop, worldhigh); - popenbottom = max(worldbottom, worldlow); - popentopslope = min(worldtopslope, worldhighslope); - popenbottomslope = max(worldbottomslope, worldlowslope); + popentop = std::min(worldtop, worldhigh); + popenbottom = std::max(worldbottom, worldlow); + popentopslope = std::min(worldtopslope, worldhighslope); + popenbottomslope = std::max(worldbottomslope, worldlowslope); } // Find the wall's coordinates @@ -1690,12 +1684,12 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { if (!!(gl_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gl_linedef->flags & ML_EFFECT3)) // Peg it to the floor { - polybottom = max(front->floorheight, back->floorheight) + gl_sidedef->rowoffset; - polytop = polybottom + midtexheight; + polybottom = std::max(front->floorheight, back->floorheight) + gl_sidedef->rowoffset; + polytop = polybottom + midtexheight; } else // Peg it to the ceiling { - polytop = min(front->ceilingheight, back->ceilingheight) + gl_sidedef->rowoffset; + polytop = std::min(front->ceilingheight, back->ceilingheight) + gl_sidedef->rowoffset; polybottom = polytop - midtexheight; } @@ -1712,9 +1706,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } else // Skew it according to the ceiling's slope { - polytop = popentop + gl_sidedef->rowoffset; - polybottom = polytop - midtexheight; - polytopslope = popentopslope + gl_sidedef->rowoffset; + polytop = popentop + gl_sidedef->rowoffset; + polybottom = polytop - midtexheight; + polytopslope = popentopslope + gl_sidedef->rowoffset; polybottomslope = polytopslope - midtexheight; } @@ -1723,24 +1717,24 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // you must use the linedef's backsector to be correct if (gl_curline->polyseg) { - lowcut = polybottom; - highcut = polytop; - lowcutslope = polybottomslope; + lowcut = polybottom; + highcut = polytop; + lowcutslope = polybottomslope; highcutslope = polytopslope; } else { // The cut-off values of a linedef can always be constant, since every line has an absoulute front and or back sector - lowcut = popenbottom; - highcut = popentop; - lowcutslope = popenbottomslope; + lowcut = popenbottom; + highcut = popentop; + lowcutslope = popenbottomslope; highcutslope = popentopslope; } - h = min(highcut, polytop); - l = max(polybottom, lowcut); - hS = min(highcutslope, polytopslope); - lS = max(polybottomslope, lowcutslope); + h = std::min(highcut, polytop); + l = std::max(polybottom, lowcut); + hS = std::min(highcutslope, polytopslope); + lS = std::max(polybottomslope, lowcutslope); // PEGGING fixed_t texturevpegslope; @@ -1896,10 +1890,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom INT32 texnum; line_t * newline = NULL; // Multi-Property FOF - lowcut = max(worldbottom, worldlow); - highcut = min(worldtop, worldhigh); - lowcutslope = max(worldbottomslope, worldlowslope); - highcutslope = min(worldtopslope, worldhighslope); + lowcut = std::max(worldbottom, worldlow); + highcut = std::min(worldtop, worldhigh); + lowcutslope = std::max(worldbottomslope, worldlowslope); + highcutslope = std::min(worldtopslope, worldhighslope); if (gl_backsector->ffloors) { @@ -1920,7 +1914,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (rover->master->flags & ML_TFERLINE) { - size_t linenum = min((size_t)(gl_curline->linedef-gl_backsector->lines[0]), rover->master->frontsector->linecount); + size_t linenum = std::min((size_t)(gl_curline->linedef-gl_backsector->lines[0]), rover->master->frontsector->linecount); newline = rover->master->frontsector->lines[0] + linenum; texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); } @@ -2034,7 +2028,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if ((roverflags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) { - blendmode = rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent; + blendmode = rover->blend ? HWR_GetBlendModeFlag(rover->blend) : static_cast(PF_Translucent); Surf.PolyColor.s.alpha = CLAMP(rover->alpha, 0, 255); } @@ -2070,7 +2064,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (rover->master->flags & ML_TFERLINE) { - size_t linenum = min((size_t)(gl_curline->linedef-gl_backsector->lines[0]), rover->master->frontsector->linecount); + size_t linenum = std::min((size_t)(gl_curline->linedef-gl_backsector->lines[0]), rover->master->frontsector->linecount); newline = rover->master->frontsector->lines[0] + linenum; texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); } @@ -2151,7 +2145,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if ((roverflags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) { - blendmode = rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent; + blendmode = rover->blend ? HWR_GetBlendModeFlag(rover->blend) : static_cast(PF_Translucent); Surf.PolyColor.s.alpha = CLAMP(rover->alpha, 0, 255); } @@ -2185,6 +2179,7 @@ static inline boolean HWR_UsePortals(void) boolean checkforemptylines = true; // Don't modify anything here, just check // Kalaron: Modified for sloped linedefs + static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector) { fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends @@ -2318,17 +2313,107 @@ static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector) // HWR_AddLine // Clips the given segment and adds any visible pieces to the line list. +namespace +{ + enum class AddLineType + { + kPortal, + kNormal, + }; + +template +static inline void DoAddLine(seg_t* line, angle_t angle1, angle_t angle2) +{ + // SoM: Backsector needs to be run through R_FakeFlat + static sector_t tempsec; + + auto do_addline = [&](bool dontdraw) { + if (!line->backsector) + { + gld_clipper_SafeAddClipRange(angle2, angle1); + } + else + { + gl_backsector = R_FakeFlat(gl_backsector, &tempsec, NULL, NULL, true); + + if (CheckClip(gl_frontsector, gl_backsector)) + { + gld_clipper_SafeAddClipRange(angle2, angle1); + checkforemptylines = false; + } + + // Reject empty lines used for triggers and special events. + // Identical floor and ceiling on both sides, + // identical light levels on both sides, + // and no middle texture. + if (checkforemptylines && R_IsEmptyLine(line, gl_frontsector, gl_backsector)) + return; + } + + if constexpr (Type == AddLineType::kPortal) + { + if (gl_portal_state != GLPORTAL_SEARCH && !dontdraw)// no need to do this during the portal check + HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D + } + else if constexpr (Type == AddLineType::kNormal) + { + HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D + } + }; + + if constexpr (Type == AddLineType::kPortal) + { + boolean dont_draw = false; + + // do extra checks on the seg when rendering portals: + // don't render segs that are behind the portal destination line + if (portalclipline && + !HWR_PortalCheckPointSide(line->v1->x, line->v1->y) && + !HWR_PortalCheckPointSide(line->v2->x, line->v2->y)) + { + return; + } + + if (gl_portal_state == GLPORTAL_STENCIL || gl_portal_state == GLPORTAL_DEPTH) + goto doaddline; + + if (line->linedef->special == PORTALSPECIAL) + { + if (line->side == 0) + { + // Find the other side! + INT32 line2 = P_FindSpecialLineFromTag(PORTALSPECIAL, line->linedef->tag, -1); + + if (line->linedef == &lines[line2]) + line2 = P_FindSpecialLineFromTag(PORTALSPECIAL, line->linedef->tag, line2); + + if (line2 >= 0) // found it! + { + if (gl_portal_state == GLPORTAL_SEARCH) + HWR_Portal_Add2Lines(line->linedef-lines, line2, line); + else if (gl_portal_state == GLPORTAL_INSIDE) + dont_draw = true; + } + } + else + return;// dont do anything with the other side i guess? + } + + doaddline: + do_addline(dont_draw); // no need to do this during the portal check + } + else if constexpr (Type == AddLineType::kNormal) + { + do_addline(false); + } +} + static void HWR_AddLine(seg_t *line) { angle_t angle1, angle2; - // SoM: Backsector needs to be run through R_FakeFlat - static sector_t tempsec; - fixed_t v1x, v1y, v2x, v2y; // the seg's vertexes as fixed_t - boolean dont_draw = false; - if (line->polyseg && !(line->polyseg->flags & POF_RENDERSIDES)) return; @@ -2372,73 +2457,12 @@ static void HWR_AddLine(seg_t *line) gl_backsector = line->backsector; - if (LIKELY(!HWR_UsePortals())) - { -doaddline: - if (!line->backsector) - { - gld_clipper_SafeAddClipRange(angle2, angle1); - } - else - { - gl_backsector = R_FakeFlat(gl_backsector, &tempsec, NULL, NULL, true); - - if (CheckClip(gl_frontsector, gl_backsector)) - { - gld_clipper_SafeAddClipRange(angle2, angle1); - checkforemptylines = false; - } - - // Reject empty lines used for triggers and special events. - // Identical floor and ceiling on both sides, - // identical light levels on both sides, - // and no middle texture. - if (checkforemptylines && R_IsEmptyLine(line, gl_frontsector, gl_backsector)) - return; - } - - if (LIKELY(gl_portal_state != GLPORTAL_SEARCH && !dont_draw))// no need to do this during the portal check - HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D - - return; - } - - // do extra checks on the seg when rendering portals: - // don't render segs that are behind the portal destination line - if (portalclipline && - !HWR_PortalCheckPointSide(line->v1->x, line->v1->y) && - !HWR_PortalCheckPointSide(line->v2->x, line->v2->y)) - { - return; - } - - if (gl_portal_state == GLPORTAL_STENCIL || gl_portal_state == GLPORTAL_DEPTH) - goto doaddline; - - if (line->linedef->special == 40) - { - if (line->side == 0) - { - // Find the other side! - INT32 line2 = P_FindSpecialLineFromTag(40, line->linedef->tag, -1); - - if (line->linedef == &lines[line2]) - line2 = P_FindSpecialLineFromTag(40, line->linedef->tag, line2); - - if (line2 >= 0) // found it! - { - if (gl_portal_state == GLPORTAL_SEARCH) - HWR_Portal_Add2Lines(line->linedef-lines, line2, line); - else if (gl_portal_state == GLPORTAL_INSIDE) - dont_draw = true; - } - } - else - return;// dont do anything with the other side i guess? - } - - goto doaddline; + if (UNLIKELY(HWR_UsePortals())) + DoAddLine(line, angle1, angle2); + else + DoAddLine(line, angle1, angle2); } +}; // HWR_CheckBBox // Checks BSP node/subtree bounding box. @@ -2502,18 +2526,18 @@ static boolean HWR_CheckBBox(const fixed_t *bspcoord) if (viewx < bspcoord[BOXLEFT]) // 1,4,6 { if (viewy > bspcoord[BOXTOP]) // 1 - mindist = R_PointToDist(bspcoord[BOXLEFT], bspcoord[BOXTOP]); + mindist = R_QuickCamDist(bspcoord[BOXLEFT], bspcoord[BOXTOP]) << FRACBITS; else if (viewy < bspcoord[BOXBOTTOM]) // 6 - mindist = R_PointToDist(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM]); + mindist = R_QuickCamDist(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM]) << FRACBITS; else // 4 mindist = bspcoord[BOXLEFT] - viewx; } else if (viewx > bspcoord[BOXRIGHT]) // 3,5,8 { if (viewy > bspcoord[BOXTOP]) // 3 - mindist = R_PointToDist(bspcoord[BOXRIGHT], bspcoord[BOXTOP]); + mindist = R_QuickCamDist(bspcoord[BOXRIGHT], bspcoord[BOXTOP]) << FRACBITS; else if (viewy < bspcoord[BOXBOTTOM]) // 8 - mindist = R_PointToDist(bspcoord[BOXRIGHT], bspcoord[BOXBOTTOM]); + mindist = R_QuickCamDist(bspcoord[BOXRIGHT], bspcoord[BOXBOTTOM]) << FRACBITS; else // 5 mindist = viewx - bspcoord[BOXRIGHT]; } @@ -2920,7 +2944,7 @@ static void HWR_Subsector(size_t num) if (sub->validcount == validcount) continue; - sector_t *controlSec = §ors[rover->secnum]; + const sector_t *controlSec = §ors[rover->secnum]; if (!controlSec->moved) continue; @@ -3041,7 +3065,7 @@ static void HWR_Subsector(size_t num) false, *rover->bottomheight, *gl_frontsector->lightlist[light].lightlevel, - CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent), + CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : static_cast(PF_Translucent)), false, gl_frontsector->lightlist[light].extra_colormap); } else @@ -3087,7 +3111,7 @@ static void HWR_Subsector(size_t num) true, *rover->topheight, *gl_frontsector->lightlist[light].lightlevel, - CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent), + CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : static_cast(PF_Translucent)), false, gl_frontsector->lightlist[light].extra_colormap); } else @@ -3156,7 +3180,10 @@ doaddline: while (count--) { if (LIKELY(!line->polyseg)) // ignore segs that belong to polyobjects + { HWR_AddLine(line); + } + line++; } } @@ -3179,10 +3206,19 @@ doaddline: // Just call with BSP root. // +namespace +{ + enum class BspType + { + kPortal, + kNormal, + }; + +template static void HWR_RenderBSPNode(INT32 bspnum) { - register const node_t *bsp; - register INT32 side; + const node_t *bsp; + INT32 side; ps_numbspcalls.value.i++; while (!(bspnum & NF_SUBSECTOR)) // Keep going until found a subsector @@ -3192,61 +3228,47 @@ static void HWR_RenderBSPNode(INT32 bspnum) // Decide which side the view point is on. side = R_PointOnSideFast(viewx, viewy, bsp); - // Recursively divide front space (toward the viewer). - HWR_RenderBSPNode(bsp->children[side]); + if constexpr (Type == BspType::kPortal) + { + // Recursively divide front space (toward the viewer). + if (HWR_PortalCheckBBox(bsp->bbox[side])) + HWR_RenderBSPNode(bsp->children[side]); - // Possibly divide back space (away from the viewer). - if (!(HWR_CheckBBox(bsp->bbox[side^1]))) - return; + // Possibly divide back space (away from the viewer). + if (!(HWR_CheckBBox(bsp->bbox[side^1]) && HWR_PortalCheckBBox(bsp->bbox[side^1]))) + return; + } + else if constexpr (Type == BspType::kNormal) + { + // Recursively divide front space (toward the viewer). + HWR_RenderBSPNode(bsp->children[side]); + + // Possibly divide back space (away from the viewer). + if (!(HWR_CheckBBox(bsp->bbox[side^1]))) + return; + } bspnum = bsp->children[side^1]; } + if constexpr (Type == BspType::kPortal) + { + // PORTAL CULLING + if (portalcullsector) + { + // skip all subsectors encountered before the portal + // destination's front sector + if (portalcullsector != subsectors[bspnum & ~NF_SUBSECTOR].sector) + return; + else + portalcullsector = NULL; + } + } + // e6y: support for extended nodes HWR_Subsector(bspnum == -1 ? 0 : bspnum & ~NF_SUBSECTOR); } - -// -// Same thing but with extra portal checks -// -static void HWR_RenderPortalBSPNode(INT32 bspnum) -{ - register const node_t *bsp; - register INT32 side; - ps_numbspcalls.value.i++; - - while (!(bspnum & NF_SUBSECTOR)) // Keep going until found a subsector - { - bsp = &nodes[bspnum]; - - // Decide which side the view point is on. - side = R_PointOnSideFast(viewx, viewy, bsp); - - // Recursively divide front space (toward the viewer). - if (HWR_PortalCheckBBox(bsp->bbox[side])) - HWR_RenderPortalBSPNode(bsp->children[side]); - - // Possibly divide back space (away from the viewer). - if (!(HWR_CheckBBox(bsp->bbox[side^1]) && HWR_PortalCheckBBox(bsp->bbox[side^1]))) - return; - - bspnum = bsp->children[side^1]; - } - - // PORTAL CULLING - if (portalcullsector) - { - // skip all subsectors encountered before the portal - // destination's front sector - if (portalcullsector != subsectors[bspnum & ~NF_SUBSECTOR].sector) - return; - else - portalcullsector = NULL; - } - - // e6y: support for extended nodes - HWR_Subsector(bspnum == -1 ? 0 : bspnum & ~NF_SUBSECTOR); -} +}; // ========================================================================== // gl_things.c @@ -3294,7 +3316,7 @@ static gl_vissprite_t *HWR_NewVisSprite(void) // Finds a floor through which light does not pass. static fixed_t HWR_OpaqueFloorAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height) { - const sector_t *sec = R_PointInSubsector(x, y)->sector; + const sector_t *sec = R_PointInSubsectorFast(x, y)->sector; fixed_t floorz = sec->floorheight; if (sec->ffloors) @@ -3504,15 +3526,11 @@ static void HWR_RotateSpritePolyToAim(gl_vissprite_t *spr, FOutVector *wallVerts } // uncapped/interpolation - interpmobjstate_t interp = {0}; + interpmobjstate_t interp = {}; float basey, lowy; - INT32 dist = -1; - - if (cv_maxinterpdist.value) - dist = R_QuickCamDist(spr->mobj->x, spr->mobj->y); // do interpolation - if (R_UsingFrameInterpolation() && !paused && (!cv_maxinterpdist.value || dist < cv_maxinterpdist.value)) + if (R_UsingFrameInterpolation() && !paused && R_CheckInterpDist(spr->mobj)) { if (precip) { @@ -3571,8 +3589,8 @@ static inline void HWR_ApplyDispoffset(gl_vissprite_t *spr, FOutVector *wallVert { HWR_RotateSpritePolyToAim(spr, wallVerts, false, papersprite); - float sprdist = sqrtf((spr->x1 - gl_viewx)*(spr->x1 - gl_viewx) + (spr->z1 - gl_viewy)*(spr->z1 - gl_viewy) + (spr->gzt - gl_viewz)*(spr->gzt - gl_viewz)); - float distfact = ((2.0f*spr->dispoffset) + 20.0f) / sprdist; + const float sprdist = sqrtf((spr->x1 - gl_viewx)*(spr->x1 - gl_viewx) + (spr->z1 - gl_viewy)*(spr->z1 - gl_viewy) + (spr->gzt - gl_viewz)*(spr->gzt - gl_viewz)); + const float distfact = ((2.0f*spr->dispoffset) + 20.0f) / sprdist; for (size_t i = 0; i < 4; i++) { @@ -3619,10 +3637,10 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) hwrpatch = ((GLPatch_t *)gpatch->hardware); // Draw shadow BEFORE sprite - if (cv_shadow.value // Shadows enabled + if (UNLIKELY(cv_shadow.value // Shadows enabled && (spr->mobj->flags & (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY)) != (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY) // Ceiling scenery have no shadow. && !(spr->mobj->flags2 & MF2_DEBRIS) // Debris have no corona or shadow. - && (spr->mobj->z >= spr->mobj->floorz)) // Without this, your shadow shows on the floor, even after you die and fall through the ground. + && (spr->mobj->z >= spr->mobj->floorz))) // Without this, your shadow shows on the floor, even after you die and fall through the ground. { //////////////////// // SHADOW SPRITE! // @@ -3714,6 +3732,9 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude; } + if (cv_playerfade.value && spr->mobj->player) + Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(spr->mobj), Surf.PolyColor.s.alpha); + if (HWR_UseShader()) { shader = SHADER_SPRITE; @@ -3733,12 +3754,14 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) for (i = 1; i < sector->numlights; i++) { - fixed_t h = P_GetLightZAt(§or->lightlist[i], spr->mobj->x, spr->mobj->y); + const fixed_t h = P_GetLightZAt(§or->lightlist[i], spr->mobj->x, spr->mobj->y); + if (!(h <= temp)) continue; if (!lightset) - lightlevel = min(*list[i-1].lightlevel, 255); + lightlevel = static_cast(CLAMP(*list[i-1].lightlevel, 0, 255)); + colormap = list[i-1].extra_colormap; break; } @@ -3756,7 +3779,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) { if (!lightset) { - lightlevel = min(*list[i].lightlevel, 255); + lightlevel = static_cast(CLAMP(*list[i].lightlevel, 0, 255)); HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false); } @@ -3765,9 +3788,9 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) if (i + 1 < sector->numlights) { - temp = P_GetLightZAt(&list[i+1], v1x, v1y); - bheight = FixedToFloat(temp); - temp = P_GetLightZAt(&list[i+1], v2x, v2y); + temp = P_GetLightZAt(&list[i+1], v1x, v1y); + bheight = FixedToFloat(temp); + temp = P_GetLightZAt(&list[i+1], v2x, v2y); endbheight = FixedToFloat(temp); } else @@ -3776,15 +3799,12 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) endbheight = endrealbot; } - if (endbheight >= endtop) - continue; - - if (bheight >= top) + if ((endbheight >= endtop) || (bheight >= top)) continue; // Found a break // The heights are clamped to ensure the polygon doesn't cross itself. - bot = CLAMP(bheight, realbot, top); + bot = CLAMP(bheight, realbot, top); endbot = CLAMP(endbheight, endrealbot, endtop); wallVerts[3].t = towtop + ((realtop - top) * towmult); @@ -3869,11 +3889,13 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) INT32 shader = SHADER_NONE; - if (!spr->mobj || !spr->mobj->subsector) + const mobj_t *sprmo = spr->mobj; + + if (UNLIKELY(!sprmo || !sprmo->subsector)) return; - const boolean papersprite = (spr->mobj->frame & FF_PAPERSPRITE); - sector_t *sector = spr->mobj->subsector->sector; + const boolean papersprite = (sprmo->frame & FF_PAPERSPRITE); + const sector_t *sector = sprmo->subsector->sector; if (sector->numlights) { @@ -3938,10 +3960,10 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) } // Draw shadow BEFORE sprite - if (cv_shadow.value // Shadows enabled - && (spr->mobj->flags & (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY)) != (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY) // Ceiling scenery have no shadow. - && !(spr->mobj->flags2 & MF2_DEBRIS) // Debris have no corona or shadow. - && (spr->mobj->z >= spr->mobj->floorz)) // Without this, your shadow shows on the floor, even after you die and fall through the ground. + if (UNLIKELY(cv_shadow.value // Shadows enabled + && (sprmo->flags & (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY)) != (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY) // Ceiling scenery have no shadow. + && !(sprmo->flags2 & MF2_DEBRIS) // Debris have no corona or shadow. + && (sprmo->z >= sprmo->floorz))) // Without this, your shadow shows on the floor, even after you die and fall through the ground. { //////////////////// // SHADOW SPRITE! // @@ -3958,37 +3980,37 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) // colormap test INT32 lightlevel = 255; - boolean lightset = HWR_OverrideObjectLightLevel(spr->mobj, &lightlevel); + const boolean lightset = HWR_OverrideObjectLightLevel(spr->mobj, &lightlevel); extracolormap_t *colormap = sector->extra_colormap; const boolean fullbright = R_ThingIsFullBright(spr->mobj); if (!lightset) { - lightlevel = min(sector->lightlevel, 255); + lightlevel = static_cast(CLAMP(sector->lightlevel, 0, 255)); HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false); } HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector) && !fullbright); INT32 blendmode; - if (spr->mobj->frame & FF_BLENDMASK) - blendmode = ((spr->mobj->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1; + if (sprmo->frame & FF_BLENDMASK) + blendmode = ((sprmo->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1; else - blendmode = spr->mobj->blendmode; + blendmode = sprmo->blendmode; if (UNLIKELY(!cv_translucency.value)) // translucency disabled { Surf.PolyColor.s.alpha = 0xFF; blend = PF_Translucent|PF_Occlude; } - else if (spr->mobj->flags2 & MF2_SHADOW) + else if (sprmo->flags2 & MF2_SHADOW) { Surf.PolyColor.s.alpha = 0x40; blend = HWR_GetBlendModeFlag(blendmode); } - else if (spr->mobj->frame & FF_TRANSMASK) + else if (sprmo->frame & FF_TRANSMASK) { - INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT; + INT32 trans = (sprmo->frame & FF_TRANSMASK)>>FF_TRANSSHIFT; blend = HWR_SurfaceBlend(blendmode, trans, &Surf); } else @@ -4001,6 +4023,9 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude; } + if (cv_playerfade.value && sprmo->player) + Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(spr->mobj), Surf.PolyColor.s.alpha); + if (HWR_UseShader()) { shader = SHADER_SPRITE; @@ -4021,7 +4046,9 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) INT32 shader = SHADER_NONE; - if (!spr->mobj || !spr->mobj->subsector) + const mobj_t *sprmo = spr->mobj; + + if (UNLIKELY(!sprmo || !sprmo->subsector)) return; // cache sprite graphics @@ -4059,7 +4086,7 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) wallVerts[0].t = wallVerts[1].t = hwrpatch->max_t; // colormap test - sector_t *sector = spr->mobj->subsector->sector; + sector_t *sector = sprmo->subsector->sector; UINT8 lightlevel = 255; extracolormap_t *colormap = sector->extra_colormap; @@ -4067,18 +4094,18 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) { INT32 light; - light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false); // Always use the light at the top instead of whatever I was doing before + light = R_GetPlaneLight(sector, sprmo->z + sprmo->height, false); // Always use the light at the top instead of whatever I was doing before - if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = min(*sector->lightlist[light].lightlevel, 255); + if (!(sprmo->frame & FF_FULLBRIGHT)) + lightlevel = static_cast(CLAMP(*sector->lightlist[light].lightlevel, 0, 255)); if (sector->lightlist[light].extra_colormap) colormap = sector->lightlist[light].extra_colormap; } else { - if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = min(sector->lightlevel, 255); + if (!(sprmo->frame & FF_FULLBRIGHT)) + lightlevel = static_cast(CLAMP(sector->lightlevel, 0, 255)); if (sector->extra_colormap) colormap = sector->extra_colormap; @@ -4086,9 +4113,9 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector)); - if (spr->mobj->frame & FF_TRANSMASK) + if (sprmo->frame & FF_TRANSMASK) { - INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT; + INT32 trans = (sprmo->frame & FF_TRANSMASK)>>FF_TRANSSHIFT; blend = HWR_SurfaceBlend(AST_TRANSLUCENT, trans, &Surf); } else @@ -4129,8 +4156,8 @@ static int CompareVisSprites(const void *p1, const void *p2) // "boolean to int" // check for precip first, because then sprX->mobj is actually a precipmobj_t and does not have flags2 or tracer - int transparency1 = (!spr1->precip && (spr1->mobj->flags2 & MF2_SHADOW)) || (spr1->mobj->frame & FF_TRANSMASK); - int transparency2 = (!spr2->precip && (spr2->mobj->flags2 & MF2_SHADOW)) || (spr2->mobj->frame & FF_TRANSMASK); + const int transparency1 = (!spr1->precip && (spr1->mobj->flags2 & MF2_SHADOW)) || (spr1->mobj->frame & FF_TRANSMASK); + const int transparency2 = (!spr2->precip && (spr2->mobj->flags2 & MF2_SHADOW)) || (spr2->mobj->frame & FF_TRANSMASK); idiff = transparency1 - transparency2; if (idiff != 0) return idiff; @@ -4226,7 +4253,7 @@ static void *HWR_CreateDrawNode(gl_drawnode_type_t type) if (!drawnodes) { alloceddrawnodes = DRAWNODES_INIT_SIZE; - drawnodes = Z_Malloc(alloceddrawnodes * sizeof(gl_drawnode_t), PU_LEVEL, &drawnodes); + drawnodes = static_cast(Z_Malloc(alloceddrawnodes * sizeof(gl_drawnode_t), PU_LEVEL, &drawnodes)); } else if (numdrawnodes >= alloceddrawnodes) { @@ -4252,7 +4279,7 @@ static void *HWR_CreateDrawNode(gl_drawnode_type_t type) static void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 texnum, boolean noencore, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap) { - wallinfo_t *wallinfo = HWR_CreateDrawNode(DRAWNODE_WALL); + wallinfo_t *wallinfo = static_cast(HWR_CreateDrawNode(DRAWNODE_WALL)); M_Memcpy(wallinfo->wallVerts, wallVerts, sizeof (wallinfo->wallVerts)); M_Memcpy(&wallinfo->Surf, pSurf, sizeof (FSurfaceInfo)); @@ -4266,7 +4293,7 @@ static void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, I static void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap) { - planeinfo_t *planeinfo = HWR_CreateDrawNode(DRAWNODE_PLANE); + planeinfo_t *planeinfo = static_cast(HWR_CreateDrawNode(DRAWNODE_PLANE)); planeinfo->isceiling = isceiling; planeinfo->fixedheight = fixedheight; @@ -4284,7 +4311,7 @@ static void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, b // When that happens it'll just be done through HWR_AddTransparentFloor and HWR_RenderPlane static void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap) { - polyplaneinfo_t *polyplaneinfo = HWR_CreateDrawNode(DRAWNODE_POLYOBJECT_PLANE); + polyplaneinfo_t *polyplaneinfo = static_cast(HWR_CreateDrawNode(DRAWNODE_POLYOBJECT_PLANE)); polyplaneinfo->isceiling = isceiling; polyplaneinfo->fixedheight = fixedheight; @@ -4323,7 +4350,7 @@ static void HWR_RenderDrawNodes(void) PS_START_TIMING(ps_hw_nodesorttime); - sortindex = Z_Malloc(sizeof(INT32) * numdrawnodes, PU_STATIC, NULL); + sortindex = static_cast(Z_Malloc(sizeof(INT32) * numdrawnodes, PU_STATIC, NULL)); // Reversed order for (i = 0; i < numdrawnodes; i++) @@ -4343,7 +4370,8 @@ static void HWR_RenderDrawNodes(void) for (i = run_start+1; i < numdrawnodes; i++) { - if (drawnodes[sortindex[i]].type != DRAWNODE_PLANE) break; + if (drawnodes[sortindex[i]].type != DRAWNODE_PLANE) + break; } run_end = i-1; @@ -4432,6 +4460,15 @@ static void HWR_RenderDrawNodes(void) // -------------------------------------------------------------------------- // Draw all vissprites // -------------------------------------------------------------------------- +namespace +{ + enum class DrawSpritesType + { + kSprites, + kModels, + }; + +template static void HWR_DrawSprites(void) { UINT32 i; @@ -4446,56 +4483,44 @@ static void HWR_DrawSprites(void) continue; } - HWR_DrawSprite(spr); - } -} - -static void HWR_DrawModels(void) -{ - UINT32 i; - - for (i = 0; i < gl_visspritecount; i++) - { - gl_vissprite_t *spr = gl_vsprorder[i]; - - if (spr->precip) + if constexpr (Type == DrawSpritesType::kModels) { - HWR_DrawPrecipitationSprite(spr); - continue; - } - - if (!spr->mobj) - continue; - - if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) - { - md2_t *md2; - - if (spr->mobj->localskin) + if (spr->mobj && spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) { - if (spr->mobj->skinlocal) - md2 = &md2_localplayermodels[(skin_t *)spr->mobj->localskin - localskins]; + md2_t *md2; + + if (spr->mobj->localskin) + { + if (spr->mobj->skinlocal) + md2 = &md2_localplayermodels[(skin_t *)spr->mobj->localskin - localskins]; + else + md2 = &md2_playermodels [(skin_t *)spr->mobj->localskin - skins]; + } else - md2 = &md2_playermodels [(skin_t *)spr->mobj->localskin - skins]; + md2 = &md2_playermodels[(skin_t *)spr->mobj->skin - skins]; + + // 8/1/19: Only don't display player models if no default SPR_PLAY is found. + if (((md2->notfound || md2->scale < 0.0f) && ((!cv_glfallbackplayermodel.value) || md2_models[SPR_PLAY].notfound || md2_models[SPR_PLAY].scale < 0.0f)) || spr->mobj->state == &states[S_PLAY_SIGN]) + HWR_DrawSprite(spr); + else + HWR_DrawMD2(spr); } else - md2 = &md2_playermodels[(skin_t *)spr->mobj->skin - skins]; - - // 8/1/19: Only don't display player models if no default SPR_PLAY is found. - if (((md2->notfound || md2->scale < 0.0f) && ((!cv_glfallbackplayermodel.value) || md2_models[SPR_PLAY].notfound || md2_models[SPR_PLAY].scale < 0.0f)) || spr->mobj->state == &states[S_PLAY_SIGN]) - HWR_DrawSprite(spr); - else - HWR_DrawMD2(spr); + { + if (md2_models[spr->mobj->sprite].notfound || md2_models[spr->mobj->sprite].scale < 0.0f) + HWR_DrawSprite(spr); + else + HWR_DrawMD2(spr); + } } - else + + if constexpr (Type == DrawSpritesType::kSprites) { - if (md2_models[spr->mobj->sprite].notfound || md2_models[spr->mobj->sprite].scale < 0.0f) - HWR_DrawSprite(spr); - else - HWR_DrawMD2(spr); + HWR_DrawSprite(spr); } } } +} // -------------------------------------------------------------------------- // HWR_AddSprites @@ -4522,7 +4547,7 @@ static void HWR_AddSprites(sector_t *sec) { // Use the smaller setting if (limit_dist) - limit_dist = min(current_bsp_culling_distance/mapobjectscale, limit_dist); + limit_dist = std::min(current_bsp_culling_distance/mapobjectscale, limit_dist); else limit_dist = current_bsp_culling_distance/mapobjectscale; } @@ -4562,13 +4587,13 @@ static void HWR_AddPrecipitationSprites(void) drawdist = ((fixed_t)(cv_drawdist_precip.value) * (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT)); // No to infinite precipitation draw distance. - if (drawdist == 0) + if (cv_drawdist_precip.value == 0) { return; } if (current_bsp_culling_distance) - drawdist = min((fixed_t)current_bsp_culling_distance, drawdist); + drawdist = std::min((fixed_t)current_bsp_culling_distance, drawdist); R_GetRenderBlockMapDimensions(drawdist, &xl, &xh, &yl, &yh); @@ -4620,7 +4645,6 @@ static void HWR_ProjectSprite(mobj_t *thing) angle_t camang = 0; #endif INT32 heightsec, phs; - INT32 dist = -1; fixed_t spr_width, spr_height; fixed_t spr_offset, spr_topoffset; @@ -4635,12 +4659,9 @@ static void HWR_ProjectSprite(mobj_t *thing) return; // uncapped/interpolation - interpmobjstate_t interp = {0}; + interpmobjstate_t interp = {}; - if (cv_maxinterpdist.value) - dist = R_QuickCamDist(thing->x, thing->y); - - if (R_UsingFrameInterpolation() && !paused && (!cv_maxinterpdist.value || dist < cv_maxinterpdist.value)) + if (R_UsingFrameInterpolation() && !paused && R_CheckInterpDist(thing)) { R_InterpolateMobjState(thing, rendertimefrac, &interp); } @@ -4679,8 +4700,8 @@ static void HWR_ProjectSprite(mobj_t *thing) return; const boolean mirrored = thing->mirrored; - const boolean vflip = (thing->eflags & MFE_VERTICALFLIP); - const boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); + const boolean vflip = (thing->eflags & MFE_VERTICALFLIP); + const boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); this_scale = FixedToFloat(interp.scale); spritexscale = FixedToFloat(interp.spritexscale); @@ -4697,7 +4718,7 @@ static void HWR_ProjectSprite(mobj_t *thing) #ifdef ROTSPRITE // determine here if sprite should rotate for optimization const boolean sliprollrotate = (cv_sliptideroll.value && (thing->player && thing->player->sliproll)); - const boolean shouldrotate = (interp.sloperoll || interp.slopepitch || interp.roll || interp.pitch || thing->rollangle || sliprollrotate); + const boolean shouldrotate = (interp.sloperoll || interp.slopepitch || interp.roll || interp.pitch || thing->rollangle || sliprollrotate); #endif //Fab : 02-08-98: 'skin' override spritedef currently used for skin @@ -4929,21 +4950,21 @@ static void HWR_ProjectSprite(mobj_t *thing) if ((vis->mobj->flags & MF_BOSS) && (vis->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash" { if (vis->mobj->type == MT_CYBRAKDEMON) - vis->colormap = R_GetTranslationColormap(TC_ALLWHITE, 0, GTC_CACHE); + vis->colormap = static_cast(R_GetTranslationColormap(TC_ALLWHITE, SKINCOLOR_NONE, GTC_CACHE)); else if (vis->mobj->type == MT_METALSONIC_BATTLE) - vis->colormap = R_GetTranslationColormap(TC_METALSONIC, 0, GTC_CACHE); + vis->colormap = static_cast(R_GetTranslationColormap(TC_METALSONIC, SKINCOLOR_NONE, GTC_CACHE)); else - vis->colormap = R_GetTranslationColormap(TC_BOSS, 0, GTC_CACHE); + vis->colormap = static_cast(R_GetTranslationColormap(TC_BOSS, SKINCOLOR_NONE, GTC_CACHE)); } else if (thing->color) { // New colormap stuff for skins Tails 06-07-2002 if (thing->colorized) - vis->colormap = R_GetTranslationColormap(TC_RAINBOW, thing->color, GTC_CACHE); + vis->colormap = static_cast(R_GetTranslationColormap(TC_RAINBOW, static_cast(thing->color), GTC_CACHE)); else if (thing->skin && thing->sprite == SPR_PLAY) // This thing is a player! - vis->colormap = R_GetLocalTranslationColormap(thing->skin, thing->localskin, thing->color, GTC_CACHE, thing->skinlocal); + vis->colormap = static_cast(R_GetLocalTranslationColormap(static_cast(thing->skin), static_cast(thing->localskin), static_cast(thing->color), GTC_CACHE, thing->skinlocal)); else - vis->colormap = R_GetTranslationColormap(TC_DEFAULT, thing->color, GTC_CACHE); + vis->colormap = static_cast(R_GetTranslationColormap(TC_DEFAULT, static_cast(thing->color), GTC_CACHE)); } else { @@ -4981,7 +5002,6 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) size_t lumpoff; unsigned rot = 0; UINT8 flip; - INT32 dist = -1; if (!thing) return; @@ -4993,13 +5013,10 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) } // uncapped/interpolation - interpmobjstate_t interp = {0}; - - if (cv_maxinterpdist.value) - dist = R_QuickCamDist(thing->x, thing->y); + interpmobjstate_t interp = {}; // do interpolation - if (R_UsingFrameInterpolation() && !paused && (!cv_maxinterpdist.value || dist < cv_maxinterpdist.value)) + if (R_UsingFrameInterpolation() && !paused && R_CheckInterpDist((mobj_t*)thing)) { R_InterpolatePrecipMobjState(thing, rendertimefrac, &interp); } @@ -5118,8 +5135,8 @@ static gl_sky_t gl_sky; static void HWR_SkyDomeVertex(gl_sky_t *sky, gl_skyvertex_t *vbo, int r, int c, signed char yflip, float delta, boolean foglayer) { - static const float scale = 10000.0f; - static const float maxSideAngle = DEG2RADGL(60.0f); + static constexpr float scale = 10000.0f; + static constexpr float maxSideAngle = DEG2RADGL(60.0f); float topAngle = DEG2RADGL(c / (float)sky->columns * 360.0f); float sideAngle = (maxSideAngle * (float)(sky->rows - r) / (float)sky->rows); @@ -5130,7 +5147,7 @@ static void HWR_SkyDomeVertex(gl_sky_t *sky, gl_skyvertex_t *vbo, int r, int c, float z = (realRadius * (float)sin(topAngle)); float timesRepeat = (4 * (256.0f / sky->width)); - if (fpclassify(timesRepeat) == FP_ZERO) + if (std::fpclassify(timesRepeat) == FP_ZERO) timesRepeat = 1.0f; if (!foglayer) @@ -5204,11 +5221,11 @@ void HWR_BuildSkyDome(void) sky->vertex_count = 2 * sky->rows * (sky->columns * 2 + 2) + sky->columns * 2; if (!sky->loops) - sky->loops = malloc((sky->rows * 2 + 2) * sizeof(sky->loops[0])); + sky->loops = static_cast(malloc((sky->rows * 2 + 2) * sizeof(sky->loops[0]))); // create vertex array if (!sky->data) - sky->data = malloc(sky->vertex_count * sizeof(sky->data[0])); + sky->data = static_cast(malloc(sky->vertex_count * sizeof(sky->data[0]))); sky->texture = texturetranslation[skytexture]; sky->width = texture->width; @@ -5259,7 +5276,7 @@ void HWR_BuildSkyDome(void) static boolean drewsky = false; // precompute to save a bit of division -static const float FINEDEGREE = (360.0f/(float)FINEANGLES); +static constexpr float FINEDEGREE = (360.0f/(float)FINEANGLES); static void HWR_DrawSkyBackground(void) { @@ -5416,48 +5433,56 @@ void HWR_SetStencilState(int state, int level) GL_SetSpecialState(HWD_SET_PORTAL_MODE, state); } -typedef void (*bspfunc)(INT32 bspnum); - // Renders the current viewpoint, though takes portal arguments for recursive portals. -void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *player, int stencil_level, boolean allow_portals) +namespace +{ + enum class RenderViewpointType + { + kPortal, + kNormal, + }; + +template +void HWR_RenderViewpoint(gl_portal_t *rootportal, player_t *player, int stencil_level, boolean allow_portals) { gl_portallist_t portallist; + const float fpov = FixedToFloat(R_GetPlayerFov(player)); const boolean skybox = (skyboxmo[0] && cv_skybox.value); - const boolean useportals = HWR_UsePortals() && allow_portals; - bspfunc bspFunc = (useportals && portalclipline) ? HWR_RenderPortalBSPNode : HWR_RenderBSPNode; portallist.base = portallist.cap = NULL; + HWR_SetPortalState(GLPORTAL_OFF); // there may be portals and they need to be drawn as regural walls - if (useportals && stencil_level < cv_maxportals.value) // if recursion limit is not reached + if constexpr (Type == RenderViewpointType::kPortal) { - gl_portal_t *portal; - - // search for portals in current frame - currentportallist = &portallist; - HWR_SetPortalState(GLPORTAL_SEARCH); - - HWR_ClearClipper(); - - if (rootportal) - HWR_PortalClipping(rootportal); - - validcount++; - - // no actual rendering happens - bspFunc((INT32)numnodes-1); - - // for each found portal: - // note: if necessary, could sort the portals here? - for (portal = portallist.base; portal; portal = portal->next) + if (allow_portals && stencil_level < cv_maxportals.value) // if recursion limit is not reached { - HWR_RenderPortal(portal, rootportal, fpov, player, stencil_level); - } + gl_portal_t *portal; - HWR_SetPortalState(GLPORTAL_INSIDE); // when portal walls are encountered in following bsp traversal, nothing should be drawn + // search for portals in current frame + currentportallist = &portallist; + HWR_SetPortalState(GLPORTAL_SEARCH); + + HWR_ClearClipper(); + + if (rootportal) + HWR_PortalClipping(rootportal); + + validcount++; + + // no actual rendering happens + HWR_RenderBSPNode((INT32)numnodes-1); + + // for each found portal: + // note: if necessary, could sort the portals here? + for (portal = portallist.base; portal; portal = portal->next) + { + HWR_RenderPortal(portal, rootportal, fpov, player, stencil_level); + } + + HWR_SetPortalState(GLPORTAL_INSIDE); // when portal walls are encountered in following bsp traversal, nothing should be drawn + } } - else - HWR_SetPortalState(GLPORTAL_OFF); // there may be portals and they need to be drawn as regural walls // draw normal things in current frame in current incremented stencil buffer area HWR_SetStencilState(HWR_STENCIL_NORMAL, stencil_level); @@ -5467,16 +5492,19 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl HWR_ClearSprites(); HWR_ClearClipper(); - if (useportals && rootportal) + if constexpr (Type == RenderViewpointType::kPortal) { - HWR_PortalFrame(rootportal);// for portalclipsector, it could have gone null from search - HWR_PortalClipping(rootportal); + if (allow_portals && rootportal) + { + HWR_PortalFrame(rootportal);// for portalclipsector, it could have gone null from search + HWR_PortalClipping(rootportal); + } } if (HWR_IsWireframeMode()) GL_SetSpecialState(HWD_SET_WIREFRAME, 1); - ps_numbspcalls.value.i = 0; + ps_numbspcalls.value.i = 0; ps_numpolyobjects.value.i = 0; PS_START_TIMING(ps_bsptime); @@ -5485,21 +5513,32 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl if (LIKELY(cv_glbatching.value)) HWR_StartBatching(); - if (useportals && !rootportal && portallist.base && !skybox) // if portals have been drawn in the main view, then render skywalls differently - gl_collect_skywalls = true; + if constexpr (Type == RenderViewpointType::kPortal) + { + if (allow_portals && !rootportal && portallist.base && !skybox) // if portals have been drawn in the main view, then render skywalls differently + gl_collect_skywalls = true; - // HAYA: Save the old portal state, and turn portals off while normally rendering the BSP tree. - // This fixes specific effects not working, such as horizon lines. - SINT8 oldgl_portal_state = gl_portal_state; + // HAYA: Save the old portal state, and turn portals off while normally rendering the BSP tree. + // This fixes specific effects not working, such as horizon lines. + SINT8 oldgl_portal_state = gl_portal_state; - if (gl_portal_state != GLPORTAL_OFF) // if we already haven't hit the recursion limit or we already ended our portal shenanigans - HWR_SetPortalState(GLPORTAL_INSIDE); // TURN IT OFF + if (gl_portal_state != GLPORTAL_OFF) // if we already haven't hit the recursion limit or we already ended our portal shenanigans + HWR_SetPortalState(GLPORTAL_INSIDE); // TURN IT OFF - // Recursively "render" the BSP tree. - bspFunc((INT32)numnodes-1); + // Recursively "render" the BSP tree. + if (allow_portals && portalclipline) + HWR_RenderBSPNode((INT32)numnodes-1); + else + HWR_RenderBSPNode((INT32)numnodes-1); - // woo we back - HWR_SetPortalState(oldgl_portal_state); + // woo we back + HWR_SetPortalState(oldgl_portal_state); + } + else if constexpr (Type == RenderViewpointType::kNormal) + { + // Recursively "render" the BSP tree. + HWR_RenderBSPNode((INT32)numnodes-1); + } if (allow_portals) // looks weird, but this is only true when its not skybox rendering skipping precip in skyboxes like software does HWR_AddPrecipitationSprites(); @@ -5509,17 +5548,20 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl if (LIKELY(cv_glbatching.value)) HWR_RenderBatches(); - if (skyWallVertexArraySize) // if there are skywalls to draw using the alternate method + if constexpr (Type == RenderViewpointType::kPortal) { - HWR_SetStencilState(HWR_STENCIL_SKY, -1); - HWR_DrawSkyWallList(); - HWR_SkyWallList_Clear(); - HWR_SetStencilState(HWR_STENCIL_NORMAL, 1); - drewsky = false; - HWR_DrawSkyBackground(); - HWR_SetStencilState(HWR_STENCIL_NORMAL, 0); - GL_ClearBuffer(false, false, true, 0);// clear skywall markings from the stencil buffer - HWR_SetTransform(fpov);// restore transform + if (skyWallVertexArraySize) // if there are skywalls to draw using the alternate method + { + HWR_SetStencilState(HWR_STENCIL_SKY, -1); + HWR_DrawSkyWallList(); + HWR_SkyWallList_Clear(); + HWR_SetStencilState(HWR_STENCIL_NORMAL, 1); + drewsky = false; + HWR_DrawSkyBackground(); + HWR_SetStencilState(HWR_STENCIL_NORMAL, 0); + GL_ClearBuffer(false, false, true, 0);// clear skywall markings from the stencil buffer + HWR_SetTransform(fpov);// restore transform + } } gl_collect_skywalls = false; @@ -5528,13 +5570,13 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl HWR_SortVisSprites(); PS_STOP_TIMING(ps_hw_spritesorttime); PS_START_TIMING(ps_hw_spritedrawtime); - if (LIKELY(!cv_glmdls.value)) - HWR_DrawSprites(); + if (UNLIKELY(cv_glmdls.value)) + HWR_DrawSprites(); else - HWR_DrawModels(); + HWR_DrawSprites(); PS_STOP_TIMING(ps_hw_spritedrawtime); - ps_numdrawnodes.value.i = 0; + ps_numdrawnodes.value.i = 0; ps_hw_nodesorttime.value.p = 0; ps_hw_nodedrawtime.value.p = 0; HWR_RenderDrawNodes(); @@ -5542,17 +5584,21 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl if (HWR_IsWireframeMode()) GL_SetSpecialState(HWD_SET_WIREFRAME, 0); - HWR_FreePortalList(portallist); + HWR_FreePortalList(portallist); // always call this just in case } +}; +extern "C" { + void HWR_RenderPortalViewpoint(gl_portal_t *rootportal, player_t *player, int stencil_level, boolean allow_portals) { + HWR_RenderViewpoint(rootportal, player, stencil_level, allow_portals); + } +} // ========================================================================== // Render the current frame. // ========================================================================== static void HWR_RenderFrame(player_t *player, boolean skybox) { - const float fpov = FixedToFloat(R_GetPlayerFov(player)); - // set window position gl_viewwindowx = gl_baseviewwindowx; gl_viewwindowy = gl_baseviewwindowy; @@ -5567,28 +5613,12 @@ static void HWR_RenderFrame(player_t *player, boolean skybox) gl_viewwindowx += gl_viewwidth; } - if (splitscreen == 2 && player == &players[displayplayers[2]]) - { - // V_DrawPatchFill, but for the fourth screen only - patch_t *gpatch = W_CachePatchName("SRB2BACK", PU_PATCH); - INT32 dupz = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); - INT32 x, y, pw = (gpatch->width * dupz), ph = (gpatch->height * dupz); - - for (x = vid.width >> 1; x < vid.width; x += pw) - { - for (y = vid.height >> 1; y < vid.height; y += ph) - HWR_DrawStretchyFixedPatch(gpatch, (x)<(NULL, player, 0, !skybox); + else + HWR_RenderViewpoint(NULL, player, 0, !skybox); // Unset transform and shader GL_SetTransform(NULL); @@ -5642,10 +5675,6 @@ static void HWR_RollTransform(FTransform *tr, angle_t roll) void HWR_RenderPlayerView(void) { - player_t * player = &players[displayplayers[viewssnum]]; - - const boolean skybox = (skyboxmo[0] && cv_skybox.value); // True if there's a skybox object and skyboxes are on - // Clear the color buffer, stops HOMs. Also seems to fix the skybox issue on Intel GPUs. if (viewssnum == 0) // Only do it if it's the first screen being rendered { @@ -5676,6 +5705,9 @@ void HWR_RenderPlayerView(void) if (viewssnum > 3) return; + player_t * player = &players[displayplayers[viewssnum]]; + const boolean skybox = (skyboxmo[0] && cv_skybox.value); // True if there's a skybox object and skyboxes are on + // Render the skybox if there is one. PS_START_TIMING(ps_skyboxtime); drewsky = false; @@ -5745,6 +5777,7 @@ void HWR_LoadLevel(boolean reloadinggamestate) static void HWR_TogglePaletteRendering(void) { V_ResetPaletteCVars(); // dont carry over changed palettes + ST_ResetPaletteStuff(); // which state should we go to? if (HWR_ShouldUsePaletteRendering()) @@ -6011,7 +6044,7 @@ static void HWR_DoPostProcessor(player_t *player) //UINT8 viewnum = R_GetViewNumber(); // see below //camera_t *thiscam = &camera[viewnum]; - camera_t *thiscam = &camera[0]; + const camera_t *thiscam = &camera[0]; // Not supported in splitscreen - someone want to add support? const boolean screenwave = (!splitscreen && (thiscam->postimg & POSTIMG_WATER || thiscam->postimg & POSTIMG_HEAT)); diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 6dc0d23a6..2ffbfd506 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -20,6 +20,10 @@ #ifndef __HWR_MAIN_H__ #define __HWR_MAIN_H__ +#ifdef __cplusplus +extern "C" { +#endif + #include "hw_gl.h" #include "hw_glob.h" #include "hw_data.h" @@ -105,7 +109,8 @@ void HWR_SetViewSize(void); void HWR_AddCommands(void); void HWR_RenderPlayerView(void); -void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *player, int stencil_level, boolean allow_portals); +void HWR_RenderViewpoint(gl_portal_t *rootportal, player_t *player, int stencil_level, boolean allow_portals); +void HWR_RenderPortalViewpoint(gl_portal_t *rootportal, player_t *player, int stencil_level, boolean allow_portals); void HWR_ClearSkyDome(void); void HWR_BuildSkyDome(void); @@ -228,4 +233,8 @@ FUNCINLINE static ATTRINLINE boolean HWR_PalRenderFlashpal(void) return (cv_glflashpal.value && HWR_ShouldUsePaletteRendering()); } +#ifdef __cplusplus +}// extern "C" +#endif + #endif diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 2696cf89d..e39c0e6b8 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1187,7 +1187,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr) spriteinfo_t *sprinfo; interpmobjstate_t interp; - if (R_UsingFrameInterpolation() && !paused && (!cv_maxinterpdist.value || R_QuickCamDist(spr->mobj->x, spr->mobj->y) < cv_maxinterpdist.value)) + if (R_UsingFrameInterpolation() && !paused && R_CheckInterpDist(spr->mobj)) { R_InterpolateMobjState(spr->mobj, rendertimefrac, &interp); } @@ -1227,6 +1227,9 @@ void HWR_DrawMD2(gl_vissprite_t *spr) Surf.PolyFlags = HWR_GetBlendModeFlag(blendmode); } + if (cv_playerfade.value && spr->mobj->player) + Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(spr->mobj), Surf.PolyColor.s.alpha); + // dont forget to enabled the depth test because we can't do this like // before: polygons models are not sorted @@ -1241,7 +1244,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr) else { md2s = md2_playermodels; - skinnum = (skin_t *)spr->mobj->localskin - skins; + skinnum = (skin_t *)spr->mobj->localskin - skins; } } else @@ -1266,6 +1269,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr) if (md2->error) return; // we already failed loading this before :( + if (!md2->model) { CONS_Debug(DBG_RENDER, "Loading model... (%s, %s)", sprnames[spr->mobj->sprite], md2->filename); @@ -1284,6 +1288,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr) return; } } + //Hurdler: arf, I don't like that implementation at all... too much crappy gpatch = md2->glpatch; if (gpatch) diff --git a/src/hardware/hw_md2.h b/src/hardware/hw_md2.h index 2e3e005b7..014638f56 100644 --- a/src/hardware/hw_md2.h +++ b/src/hardware/hw_md2.h @@ -15,6 +15,10 @@ #ifndef _HW_MD2_H_ #define _HW_MD2_H_ +#ifdef __cplusplus +extern "C" { +#endif + #include "hw_glob.h" #include "hw_model.h" @@ -46,4 +50,8 @@ void HWR_DrawMD2(gl_vissprite_t *spr); void HWR_AddPlayerMD2(INT32 skin, boolean local); void HWR_AddSpriteMD2(size_t spritenum); +#ifdef __cplusplus +} // extern "C" +#endif + #endif // _HW_MD2_H_ diff --git a/src/hardware/hw_portal.c b/src/hardware/hw_portal.c index 9bb5af40f..db17d05bf 100644 --- a/src/hardware/hw_portal.c +++ b/src/hardware/hw_portal.c @@ -45,8 +45,8 @@ static gl_portal_t* HWR_Portal_Add (seg_t *seg) // Linked list. if (!currentportallist->base) { - currentportallist->base = portal; - currentportallist->cap = portal; + currentportallist->base = portal; + currentportallist->cap = portal; } else { @@ -66,6 +66,7 @@ void HWR_FreePortalList(gl_portallist_t freelist) // free memory from portal list allocated by calls to Add2Lines gl_portal_t *gl_portal_temp = freelist.base; + while (gl_portal_temp) { gl_portal_t *nextportal = gl_portal_temp->next; @@ -125,14 +126,13 @@ void HWR_PortalFrame(gl_portal_t* portal) if (portal->clipline != -1) { portalclipline = &lines[portal->clipline]; - portalcullsector = portalclipline->frontsector; - viewsector = portalclipline->frontsector; + portalcullsector = viewsector = portalclipline->frontsector; } else { portalclipline = NULL; portalcullsector = NULL; - viewsector = R_PointInSubsector(viewx, viewy)->sector; + viewsector = R_PointInSubsectorFast(viewx, viewy)->sector; } } @@ -146,7 +146,7 @@ static void HWR_RenderPortalSeg(gl_portal_t* portal, SINT8 state) gl_curline = portal->seg; gl_frontsector = portal->seg->frontsector; - gl_backsector = portal->seg->backsector; + gl_backsector = portal->seg->backsector; HWR_ProcessSeg(); gl_drawing_stencil = false; @@ -169,7 +169,7 @@ void HWR_RenderPortal(gl_portal_t* portal, gl_portal_t* rootportal, const float // go to portal frame lmao HWR_PortalFrame(portal); // call HWR_RenderViewpoint - HWR_RenderViewpoint(portal, fpov, player, stencil_level + 1, true); + HWR_RenderPortalViewpoint(portal, player, stencil_level + 1, true); // return to current frame if (rootportal) HWR_PortalFrame(rootportal); @@ -202,7 +202,9 @@ boolean HWR_PortalCheckPointSide(fixed_t x, fixed_t y) // so first check if the point is precisely on the line, and then if not, check the side. vertex_t closest_point; + P_ClosestPointOnLine(x, y, portalclipline, &closest_point); + if (closest_point.x != x || closest_point.y != y) { if (P_PointOnLineSide(x, y, portalclipline) != 1) diff --git a/src/hardware/hw_portal.h b/src/hardware/hw_portal.h index f42d2f61c..494110d79 100644 --- a/src/hardware/hw_portal.h +++ b/src/hardware/hw_portal.h @@ -14,6 +14,10 @@ #ifndef __HW_PORTAL__ #define __HW_PORTAL__ +#ifdef __cplusplus +extern "C" { +#endif + #ifdef HWRENDER #include "../doomstat.h" @@ -77,5 +81,9 @@ void HWR_FreePortalList(gl_portallist_t portallist); boolean HWR_PortalCheckPointSide(fixed_t x, fixed_t y); boolean HWR_PortalCheckBBox(const fixed_t *bspcoord); +#endif + +#ifdef __cplusplus +}// extern "C" #endif #endif diff --git a/src/hardware/r_opengl/ogl_win.c b/src/hardware/r_opengl/ogl_win.c index e819e0f68..31daa22fd 100644 --- a/src/hardware/r_opengl/ogl_win.c +++ b/src/hardware/r_opengl/ogl_win.c @@ -28,7 +28,6 @@ #define RPC_NO_WINDOWS_H #include #include -#undef GETTEXT #include "r_opengl.h" diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 3988f11b4..497b1b08a 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -16,7 +16,6 @@ #define RPC_NO_WINDOWS_H #include #endif -#undef GETTEXT #ifdef __GNUC__ #include #endif @@ -690,7 +689,7 @@ typedef enum gluniform_leveltime, gluniform_scr_resolution, - + gluniform_max, } gluniform_t; @@ -1730,6 +1729,114 @@ static void GL_AllocTextureBuffer(GLMipmap_t *pTexInfo) } } +#define PADDING_CHECK(offset, alphaCheck) { from = to + (offset); if ((alphaCheck)) from = NULL; else goto foundFrom; } + +static void PadRGBABitmap(RGBA_t *tex, UINT16 w, UINT16 h) +{ + INT32 i; + boolean notLeft, notRight, notTop, notBottom; + RGBA_t *to = tex - 1, *from; + + for (i = 0; i < w * h; i++) + { + to++; + if (to->rgba != 0) + continue; + from = NULL; + + notLeft = i % w != 0; + notRight = i % w != w - 1; + notTop = i / w != 0; + notBottom = i / w != h - 1; + + if (notRight) PADDING_CHECK(1, from->s.alpha == 0) // Check +X + if (notBottom) PADDING_CHECK(w, from->s.alpha == 0) // Check +Y + if (notLeft) PADDING_CHECK(-1, from->s.alpha == 0) // Check -X + if (notTop) PADDING_CHECK(-w, from->s.alpha == 0) // Check -Y + if (notRight && notBottom) PADDING_CHECK(1 + w, from->s.alpha == 0) // Check +X+Y + if (notLeft && notBottom) PADDING_CHECK(-1 + w, from->s.alpha == 0) // Check -X+Y + if (notLeft && notTop) PADDING_CHECK(-1 - w, from->s.alpha == 0) // Check -X-Y + if (notRight && notTop) PADDING_CHECK(1 - w, from->s.alpha == 0) // Check +X-Y + +foundFrom: + if (from != NULL) + { + *to = *from; + to->s.alpha = 0; + } + } +} + +#undef PADDING_CHECK + +static void GenerateMipmaps(INT32 w, INT32 h, RGBA_t *tex, INT32 maxLOD) +{ + if (tex == NULL) + { + GL_MSG_Warning("GenerateMipmaps: attempted to generate mipmaps without texture data"); + return; + } + + RGBA_t samplePoint[4]; + boolean padTexture; + INT32 pointsSampled = 0; + INT32 m, j, i, p; + UINT16 sumR, sumG, sumB, sumA; + + for (m = 0; m < maxLOD; m++) + { + if (w <= 1 || h <= 1) + return; + + padTexture = false; + + for (j = 0; j < h / 2; j++) + { + for (i = 0; i < w / 2; i++) + { + samplePoint[0] = tex[w*j*2 + i*2]; + samplePoint[1] = tex[w*j*2 + i*2+1]; + samplePoint[2] = tex[w*(j*2+1) + i*2]; + samplePoint[3] = tex[w*(j*2+1) + i*2+1]; + + pointsSampled = sumR = sumG = sumB = sumA = 0; + + for (p = 0; p < 4; p++) + { + if (samplePoint[p].s.alpha == 0) + continue; + sumR += samplePoint[p].s.red; + sumG += samplePoint[p].s.green; + sumB += samplePoint[p].s.blue; + sumA += samplePoint[p].s.alpha; + pointsSampled++; + } + + if (pointsSampled > 0) + { + tex[(w/2)*j+i].s.red = sumR / pointsSampled; + tex[(w/2)*j+i].s.green = sumG / pointsSampled; + tex[(w/2)*j+i].s.blue = sumB / pointsSampled; + tex[(w/2)*j+i].s.alpha = sumA / pointsSampled; + } + else + { + tex[(w/2)*j+i].rgba = 0; + padTexture = true; + } + } + } + + w /= 2; + h /= 2; + + if (padTexture) + PadRGBABitmap(tex, w, h); + + pglTexSubImage2D(GL_TEXTURE_2D, m + 1, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, tex); + } +} + // -----------------+ // UpdateTexture : Updates texture data. // -----------------+ @@ -1738,6 +1845,7 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) // Upload a texture GLuint num = pTexInfo->downloaded; boolean update = true; + const boolean applyPadding = mag_filter == GL_LINEAR || min_filter == GL_LINEAR; INT32 w = pTexInfo->width, h = pTexInfo->height; INT32 i, j; @@ -1796,15 +1904,32 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) pImgData++; } } + + if (applyPadding) + PadRGBABitmap(tex, w, h); + break; case GL_TEXFMT_RGBA: // Directly upload the texture data without any kind of conversion. ptex = pImgData; + + // However, it does need to be copied to a buffer for generating mipmaps and padding + if (MipMap || applyPadding) + { + GL_AllocTextureBuffer(pTexInfo); + tex = textureBuffer; + memcpy(tex, ptex, w * h * 4); + ptex = tex; + + if (applyPadding) + PadRGBABitmap(tex, w, h); + } + break; case GL_TEXFMT_ALPHA_INTENSITY_88: GL_AllocTextureBuffer(pTexInfo); ptex = tex = textureBuffer; - texformat = GL_LUMINANCE_ALPHA; + texformat = GL_RGBA; for (idx = 0, j = 0; j < h; j++) { @@ -1822,7 +1947,7 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) case GL_TEXFMT_ALPHA_8: // Used for fade masks GL_AllocTextureBuffer(pTexInfo); ptex = tex = textureBuffer; - texformat = GL_ALPHA; + texformat = GL_RGBA; memset(&tex->s, 255, sizeof(byteColor_t)*w*h); // 255 because the fade mask is modulated with the screen texture, so alpha affects it while the colours don't @@ -1858,8 +1983,6 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) if (MipMap && !transparent) // No mipmaps on transparent stuff { - int maxlod = (texformat == GL_LUMINANCE_ALPHA || texformat == GL_ALPHA) ? 4 : 5; - pglTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); if (update) @@ -1869,7 +1992,8 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) // Control the mipmap level of detail pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0); - pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, maxlod); + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 5); + GenerateMipmaps(w, h, tex, 5); } else { @@ -1893,7 +2017,6 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropic_filter); } - // -----------------+ // SetTexture : The mipmap becomes the current texture source // -----------------+ @@ -2736,7 +2859,7 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics poly.green = byte2float[Surface->PolyColor.s.green]; poly.blue = byte2float[Surface->PolyColor.s.blue]; poly.alpha = byte2float[Surface->PolyColor.s.alpha]; - + pglColor4ubv((GLubyte*)&Surface->PolyColor.s); GL_SetBlend(((poly.alpha < 1) ? Surface->PolyFlags : (PF_Masked|PF_Occlude))|PF_Modulated); @@ -2750,7 +2873,7 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics fade.green = byte2float[Surface->FadeColor.s.green]; fade.blue = byte2float[Surface->FadeColor.s.blue]; fade.alpha = byte2float[Surface->FadeColor.s.alpha]; - + if (Surface->LightTableId && Surface->LightTableId != lt_downloaded) { pglActiveTexture(GL_TEXTURE2); diff --git a/src/hardware/r_opengl/r_opengl.h b/src/hardware/r_opengl/r_opengl.h index b70febad4..e0d7e13ac 100644 --- a/src/hardware/r_opengl/r_opengl.h +++ b/src/hardware/r_opengl/r_opengl.h @@ -20,6 +20,10 @@ #ifndef _R_OPENGL_H_ #define _R_OPENGL_H_ +#ifdef __cplusplus +extern "C" { +#endif + #ifdef HAVE_SDL #define _MATH_DEFINES_DEFINED @@ -143,4 +147,8 @@ typedef enum GLF_NOTEXENV = 0x02, } oglflags_t; +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 0da2d9930..07ebdd26f 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -49,6 +49,7 @@ #include "s_sound.h" // song credits #include "k_kart.h" +#include "k_hud.h" #include "m_textinput.h" @@ -259,8 +260,6 @@ INT32 HU_FallBackFrSpecialLetter(INT32 key) } } - - static char cechotext[1024]; static tic_t cechotimer = 0; static tic_t cechoduration = 5*TICRATE; @@ -702,7 +701,7 @@ static void Command_Sayto_f(void) return; } - target = nametonum(COM_Argv(1)); + target = D_LookupPlayer(COM_Argv(1)); if (target == -1) { CONS_Alert(CONS_NOTICE, M_GetText("No player with that name!\n")); @@ -950,6 +949,9 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) else stop_spamming[playernum] = 4; // you can hold off for 4 tics, can you? + if (player_muted[playernum]) + spam_eatmsg = 1; // Let lua know we're skipping this message + // run the lua hook even if we were supposed to eat the msg, netgame consistency goes first. if (LUA_HookPlayerMsg(playernum, target, flags, msg, spam_eatmsg)) @@ -1180,6 +1182,23 @@ static boolean HU_clearChatSpaces(void) return nothingbutspaces; } +static void DoMute(const char *name) +{ + INT32 pnum = D_LookupPlayer(name); + + if (pnum < 0) + { + HU_AddChatText("\x85""ERROR: \x80Player not found.", false); + return; + } + + player_muted[pnum] = !player_muted[pnum]; + + HU_AddChatText(va("Player '%s' has been %smuted.", player_names[pnum], player_muted[pnum] ? "" : "un"), false); + if (player_muted[pnum]) + HU_AddChatText("Use same command to unmute them.", false); +} + static void HU_SendChatMessage(void) { char buf[2 + HU_MAXMSGLEN + 1]; @@ -1206,7 +1225,19 @@ static void HU_SendChatMessage(void) return; } - if (strlen(msg) > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm + size_t len = strlen(msg); + + if (len >= 5 && strnicmp(msg, "/mute", 5) == 0) // Used /mute + { + if (len > 6) + DoMute(msg+6); + else + HU_AddChatText("\x82NOTICE: \x80Usage: /mute ", false); + + return; + } + + if (len > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm { INT32 spc = 1; // used if nodenum[1] is a space. char *nodenum = (char*) malloc(3); diff --git a/src/i_joy.h b/src/i_joy.h index 01f29c2cd..20252b54d 100644 --- a/src/i_joy.h +++ b/src/i_joy.h @@ -13,6 +13,10 @@ #ifndef __I_JOY_H__ #define __I_JOY_H__ +#ifdef __cplusplus +extern "C" { +#endif + #include "g_input.h" /*! @@ -55,4 +59,8 @@ typedef struct JoyType_s JoyType_t; extern JoyType_t Joystick[MAXSPLITSCREENPLAYERS]; +#ifdef __cplusplus +} // extern "C" +#endif + #endif // __I_JOY_H__ diff --git a/src/i_net.h b/src/i_net.h index 098a6563d..70d8f0384 100644 --- a/src/i_net.h +++ b/src/i_net.h @@ -14,6 +14,10 @@ #ifndef __I_NET__ #define __I_NET__ +#ifdef __cplusplus +extern "C" { +#endif + #ifdef __GNUG__ #pragma interface #endif @@ -180,4 +184,8 @@ extern bannednode_t *bannednode; /// \brief Called by D_SRB2Main to be defined by extern network driver boolean I_InitNetwork(void); +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/i_sound.h b/src/i_sound.h index 925be7596..9c6cf20d7 100644 --- a/src/i_sound.h +++ b/src/i_sound.h @@ -13,6 +13,10 @@ #ifndef __I_SOUND__ #define __I_SOUND__ +#ifdef __cplusplus +extern "C" { +#endif + #include "doomdef.h" #include "sounds.h" #include "command.h" @@ -241,4 +245,8 @@ boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void)); boolean I_FadeOutStopSong(UINT32 ms); boolean I_FadeInPlaySong(UINT32 ms, boolean looping); +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/i_system.h b/src/i_system.h index e7fb26a41..b26db7a82 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -14,6 +14,10 @@ #ifndef __I_SYSTEM__ #define __I_SYSTEM__ +#ifdef __cplusplus +extern "C" { +#endif + #include "d_ticcmd.h" #include "d_event.h" @@ -256,4 +260,8 @@ const char *I_ClipboardPaste(void); void I_RegisterSysCommands(void); +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/i_threads.h b/src/i_threads.h index 45a3dcc3e..17500aeca 100644 --- a/src/i_threads.h +++ b/src/i_threads.h @@ -14,6 +14,10 @@ #ifndef I_THREADS_H #define I_THREADS_H +#ifdef __cplusplus +extern "C" { +#endif + typedef void (*I_thread_fn)(void *userdata); typedef void * I_mutex; @@ -35,5 +39,9 @@ void I_hold_cond (I_cond *, I_mutex); void I_wake_one_cond (I_cond *); void I_wake_all_cond (I_cond *); +#ifdef __cplusplus +} // extern "C" +#endif + #endif/*I_THREADS_H*/ #endif/*HAVE_THREADS*/ diff --git a/src/i_time.c b/src/i_time.c index 2d136f27e..da6bc3882 100644 --- a/src/i_time.c +++ b/src/i_time.c @@ -37,18 +37,20 @@ tic_t I_GetTime(void) void I_InitializeTime(void) { - g_time.time = 0; - g_time.timefrac = 0; - - enterprecise = 0; - oldenterprecise = 0; - tictimer = 0.0; - CV_RegisterVar(&cv_timescale); // I_StartupTimer is preserved for potential subsystems that need to setup // timing information for I_GetPreciseTime and sleeping I_StartupTimer(); + + g_time.time = 0; + g_time.timefrac = 0; + + enterprecise = I_GetPreciseTime(); + oldenterprecise = enterprecise; + entertic = 0; + oldentertics = 0; + tictimer = 0.0; } void I_UpdateTime(fixed_t timescale) @@ -61,7 +63,7 @@ void I_UpdateTime(fixed_t timescale) ticratescaled = (double)TICRATE * FixedToFloat(timescale); enterprecise = I_GetPreciseTime(); - elapsedseconds = (double)((INT64)enterprecise - oldenterprecise) / I_GetPrecisePrecision(); + elapsedseconds = (double)(enterprecise - oldenterprecise) / I_GetPrecisePrecision(); tictimer += elapsedseconds; while (tictimer > 1.0/ticratescaled) { diff --git a/src/i_video.h b/src/i_video.h index 70321d138..68042a654 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -14,6 +14,10 @@ #ifndef __I_VIDEO__ #define __I_VIDEO__ +#ifdef __cplusplus +extern "C" { +#endif + #include "doomtype.h" #ifdef __GNUG__ @@ -149,4 +153,8 @@ boolean UseScreenFBO(void); extern boolean downsample; #endif +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/k_hud.c b/src/k_hud.c new file mode 100644 index 000000000..c3b49bd3b --- /dev/null +++ b/src/k_hud.c @@ -0,0 +1,4808 @@ +// SONIC ROBO BLAST 2 KART +//----------------------------------------------------------------------------- +// Copyright (C) 2018-2020 by Kart Krew +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file k_hud.c +/// \brief HUD drawing functions exclusive to Kart + +#include "doomdef.h" +#include "doomstat.h" +#include "doomtype.h" +#include "command.h" +#include "d_netcmd.h" +#include "d_player.h" +#include "hu_stuff.h" +#include "g_game.h" +#include "i_joy.h" +#include "m_fixed.h" +#include "m_menu.h" // ffdhidshfuisduifigergho9igj89dgodhfih AAAAAAAAAA +#include "p_local.h" +#include "p_setup.h" +#include "r_defs.h" +#include "r_draw.h" +#include "r_state.h" +#include "r_fps.h" +#include "s_sound.h" +#include "screen.h" +#include "st_stuff.h" +#include "tables.h" +#include "v_video.h" +#include "z_zone.h" +#include "m_cond.h" +#include "k_director.h" +#include "k_kart.h" +#include "lua_hud.h" // For Lua hud checks +#include "d_main.h" // found_extra_kart +#include "i_video.h" + +#include "k_hud.h" + +#ifdef ROTSPRITE +#include "r_patchrotation.h" +#endif + +#ifdef HWRENDER +#include "hardware/hw_main.h" +#endif + +#define XTRA3PSCALE 50135 //0.765 +#define XTRA3VSCALE 35344 //0.55 + +// Hud offset cvars +#define IMPL_HUD_OFFSET_X(name)\ +consvar_t cv_##name##_xoffset = {"hud_" #name "_xoffset", "0", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; + +#define IMPL_HUD_OFFSET_Y(name)\ +consvar_t cv_##name##_yoffset = {"hud_" #name "_yoffset", "0", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; + +#define IMPL_HUD_OFFSET(name)\ +IMPL_HUD_OFFSET_X(name)\ +IMPL_HUD_OFFSET_Y(name) + +IMPL_HUD_OFFSET(item); // Item box +IMPL_HUD_OFFSET(time); // Time +IMPL_HUD_OFFSET(laps); // Number of laps +IMPL_HUD_OFFSET(dnft); // Countdown (did not finish timer) +IMPL_HUD_OFFSET(speed); // Speedometer +IMPL_HUD_OFFSET(posi); // Position in race +IMPL_HUD_OFFSET(wheel); // RA Wheel +IMPL_HUD_OFFSET(face); // Mini rankings +IMPL_HUD_OFFSET(stcd); // Starting countdown +IMPL_HUD_OFFSET_Y(chek); // Check gfx +IMPL_HUD_OFFSET(mini); // Minimap +IMPL_HUD_OFFSET(want); // Wanted +IMPL_HUD_OFFSET(stat); // Stats + +#undef IMPL_HUD_OFFSET +#undef IMPL_HUD_OFFSET_X +#undef IMPL_HUD_OFFSET_Y + +// extra hud things +consvar_t cv_showstats = {"showstats", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_highresportrait = {"highresportrait", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // make char potraits use their high-res version instead + +CV_PossibleValue_t inputdisplay_cons_t[NUMINPUTDISPLAYSTUFF]; +consvar_t cv_showinput = {"showinput", "Off", CV_SAVE, inputdisplay_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + +static CV_PossibleValue_t minihead_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Others"}, {0, NULL}}; +consvar_t cv_minihead = {"smallminimapplayers", "Off", CV_SAVE, minihead_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showminimapnames = {"showminimapnames", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + +CV_PossibleValue_t minimapdot_cons_t[NUMMINIMAPDOTSTUFF]; +consvar_t cv_showminimapangle = {"showminimapangle", "Off", CV_SAVE, minimapdot_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + +static CV_PossibleValue_t posanim_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Smooth"}, {0, NULL}}; +consvar_t cv_posanim = {"postitionanimation", "On", CV_SAVE, posanim_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_smallposnum = {"smallpositionnumber", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_showlapemblem = {"showlapemblem", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + +static CV_PossibleValue_t huditemamount_cons_t[] = {{0, "Vanilla"}, {1, "Multiple"}, {2, "Always"},{0, NULL}}; +consvar_t cv_huditemamount = {"showitemamountnumber", "Vanilla", CV_SAVE, huditemamount_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_fancyroulette = {"animatedroulette", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_darkitembox = {"darkitembox", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // itembox gets a dark border with specific items +consvar_t cv_multiitemicon = {"multiitemicon", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_showlaptimes = {"showlaptimes", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_biglaps = {"biglaphud", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // here for ppl who dont want to make 2 more patches for their custom hud + +// Speedometer +CV_PossibleValue_t speedo_cons_t[NUMSPEEDOSTUFF]; +consvar_t cv_newspeedometer = {"newspeedometer", "Default", CV_SAVE, speedo_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_battlespeedo = {"battlespeedo", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // toggle for showing the speedometer in battlemode + +// Colourized HUD +consvar_t cv_colorizedhud = {"colorizedhud", "Off", CV_SAVE|CV_CALL, CV_OnOff, SaturnHud_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_colorizeditembox = {"colorizeditembox", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + +static CV_PossibleValue_t HudColor_cons_t[MAXSKINCOLORS+1]; +consvar_t cv_colorizedhudcolor = {"colorizedhudcolor", "Skin Color", CV_SAVE, HudColor_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + +// Driftgauge +static CV_PossibleValue_t driftgaugeoffset_cons_t[] = { + {-FRACUNIT*128, "MIN"}, {FRACUNIT*128, "MAX"}, {0, NULL}}; +CV_PossibleValue_t driftgaugestyle_cons_t[NUMDGAUGESTUFF]; + +consvar_t cv_driftgauge = {"kartdriftgauge", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_driftgaugeofs = {"kartdriftgaugeoffset", "-20", CV_FLOAT|CV_SAVE, driftgaugeoffset_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_driftgaugetrans = {"kartdriftgaugetransparency", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_driftgaugestyle = {"kartdriftgaugestyle", "1", CV_SAVE, driftgaugestyle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + +// Nametags +static CV_PossibleValue_t nametagtrans_cons_t[] = { + {0, "Never"}, {1, "Far only"}, {2, "Dynamic"}, {3, "Always"}, {4, "HUD Trans."}, {0, NULL}}; +static CV_PossibleValue_t nametagdistance_cons_t[] = { + {0, "MIN"}, {640, "MAX"}, {0, NULL}}; +static CV_PossibleValue_t nametagmaxplayer_cons_t[] = { + {1, "MIN"}, {MAXPLAYERS, "MAX"}, {0, NULL}}; +static CV_PossibleValue_t nametagsize_cons_t[] = { + {0, "Off"}, {1, "Small"}, {2, "Minimal"}, {0, NULL}}; +static CV_PossibleValue_t nametagrestat_cons_t[] = { + {0, "Off"}, {1, "Restat"}, {2, "Always"}, {0, NULL}}; + +consvar_t cv_nametag = {"kartnametag", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagtrans = {"kartnametagtransparency", "Dynamic", CV_SAVE, nametagtrans_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagfacerank = {"kartnametagfacerank", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagrestat = {"kartnametagrestat", "Restat", CV_SAVE, nametagrestat_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagdist = {"kartnametagdist", "320", CV_SAVE, nametagdistance_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagmaxplayers = {"kartnametagmaxplayers", "3", CV_SAVE, nametagmaxplayer_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagmaxlenght = {"kartnametagmaxlenght", "12", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showownnametag = {"kartnametagshowown", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_smallnametags = {"kartnametagsmall", "Off", CV_SAVE, nametagsize_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagscore = {"kartnametagscore", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_shownametagspectator = {"kartshownametagspectator", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; + +// Registers kart client commands and variables. +// Nothing needed for a dedicated server should be registered here. +void K_RegisterKartHudStuff(void) +{ + HudColor_cons_t[0].value = 0; + HudColor_cons_t[0].strvalue = "Skin Color"; + + for (INT32 i = 1; i < MAXSKINCOLORS; i++) + { + HudColor_cons_t[i].value = i; + HudColor_cons_t[i].strvalue = KartColor_Names[i]; // SRB2kart + } + HudColor_cons_t[MAXSKINCOLORS].value = 0; + HudColor_cons_t[MAXSKINCOLORS].strvalue = NULL; + +#define REG_HUD_OFFSET_X(name)\ + CV_RegisterVar(&cv_##name##_xoffset); + +#define REG_HUD_OFFSET_Y(name)\ + CV_RegisterVar(&cv_##name##_yoffset); + +#define REG_HUD_OFFSET(name)\ + REG_HUD_OFFSET_X(name)\ + REG_HUD_OFFSET_Y(name) + + REG_HUD_OFFSET(item); // Item box + REG_HUD_OFFSET(time); // Time + REG_HUD_OFFSET(laps); // Number of laps + REG_HUD_OFFSET(dnft); // Countdown (did not finish timer) + REG_HUD_OFFSET(speed); // Speedometer + REG_HUD_OFFSET(posi); // Position in race + REG_HUD_OFFSET(wheel); // Position in race + REG_HUD_OFFSET(face); // Mini rankings + REG_HUD_OFFSET(stcd); // Starting countdown + REG_HUD_OFFSET_Y(chek); // Check gfx + REG_HUD_OFFSET(mini); // Minimap + REG_HUD_OFFSET(want); // Wanted + REG_HUD_OFFSET(stat); // Stats + +#undef REG_HUD_OFFSET +#undef REG_HUD_OFFSET_X +#undef REG_HUD_OFFSET_Y + + CV_RegisterVar(&cv_kartminimap); + CV_RegisterVar(&cv_kartcheck); + + CV_RegisterVar(&cv_kartspeedometer); + + CV_RegisterVar(&cv_showstats); + CV_RegisterVar(&cv_showinput); + + CV_RegisterVar(&cv_posanim); + CV_RegisterVar(&cv_smallposnum); + + CV_RegisterVar(&cv_fancyroulette); + + CV_RegisterVar(&cv_showlaptimes); + CV_RegisterVar(&cv_newspeedometer); + + CV_RegisterVar(&cv_battlespeedo); + + CV_RegisterVar(&cv_minihead); + CV_RegisterVar(&cv_showminimapnames); + CV_RegisterVar(&cv_showminimapangle); + + CV_RegisterVar(&cv_showlapemblem); + + CV_RegisterVar(&cv_stagetitle); + + // Colourized HUD + CV_RegisterVar(&cv_colorizedhud); + CV_RegisterVar(&cv_colorizedhudcolor); + CV_RegisterVar(&cv_colorizeditembox); + + CV_RegisterVar(&cv_biglaps); + + CV_RegisterVar(&cv_darkitembox); + + CV_RegisterVar(&cv_multiitemicon); + CV_RegisterVar(&cv_huditemamount); + + CV_RegisterVar(&cv_highresportrait); + + CV_RegisterVar(&cv_nametag); + CV_RegisterVar(&cv_nametagtrans); + CV_RegisterVar(&cv_nametagfacerank); + CV_RegisterVar(&cv_nametagmaxplayers); + CV_RegisterVar(&cv_nametagmaxlenght); + CV_RegisterVar(&cv_nametagdist); + CV_RegisterVar(&cv_showownnametag); + CV_RegisterVar(&cv_smallnametags); + CV_RegisterVar(&cv_nametagrestat); + CV_RegisterVar(&cv_nametagscore); + CV_RegisterVar(&cv_shownametagspectator); + + CV_RegisterVar(&cv_driftgauge); + CV_RegisterVar(&cv_driftgaugeofs); + CV_RegisterVar(&cv_driftgaugetrans); + CV_RegisterVar(&cv_driftgaugestyle); + + CV_RegisterVar(&cv_lessflicker); +} + +//{ Patch Definitions + +// --Saturn patches-- +// dont leave those unitialized incase we missed a check somewhere + +// -Speedometers- + +// Smol speedo +static patch_t *skp_smallsticker = NULL; +static patch_t *skp_smallsticker3 = NULL; + +static patch_t *skp_speedpatches[5] = {NULL}; + +// Achii speedo +static patch_t *skp_smallstickerachi = NULL; +static patch_t *skp_speedpatchesachi[5] = {NULL}; +static patch_t *skp_smallstickerachiclr = NULL; +static patch_t *skp_speedpatchesachiclr[5] = {NULL}; + +// Kartz speedo +static patch_t *kp_kartzspeedo[25] = {NULL}; +static patch_t *kp_kartzspeedo_smol[25] = {NULL}; + +// dial speedometer +static patch_t *skp_rankfinish = NULL; +static patch_t *skp_dialbase[2] = {NULL}; +static patch_t *skp_speedpatchesdial[5] = {NULL}; +static patch_t *skp_dialnum[10] = {NULL}; +//static patch_t *skp_dialclr = NULL; +static patch_t *skp_dialbaseclr[2] = {NULL}; +static patch_t *skp_speedpatchesdialclr[5] = {NULL}; +static patch_t *skp_dialnumclr[10] = {NULL}; + +// -Colourized hud- + +static patch_t *kp_timestickerclr = NULL; +static patch_t *kp_timestickerwideclr = NULL; +static patch_t *kp_lapstickerclr = NULL; +static patch_t *kp_lapstickerbigclr = NULL; +static patch_t *kp_lapstickerbig2clr = NULL; +static patch_t *kp_lapstickerwideclr = NULL; +//static patch_t *kp_lapstickernarrowclr = NULL; +static patch_t *kp_bumperstickerclr = NULL; +static patch_t *kp_bumperstickerwideclr = NULL; +static patch_t *kp_karmastickerclr = NULL; +static patch_t *kp_timeoutstickerclr = NULL; +static patch_t *skp_smallstickerclr = NULL; +static patch_t *skp_smallstickerclr3 = NULL; +static patch_t *kp_itemmulstickerclr[2] = {NULL}; +static patch_t *kp_itembgclr[4] = {NULL}; + +// -Misc.- + +static patch_t *kp_lapstickerbig = NULL; +static patch_t *kp_lapstickerbig2 = NULL; + +static patch_t *nametagpic = NULL; +static patch_t *nametagline = NULL; +static patch_t *nametagspeed = NULL; +static patch_t *nametagweight = NULL; + +static patch_t *driftgauge = NULL; +static patch_t *driftgaugecolor = NULL; +static patch_t *driftgaugesmall = NULL; +static patch_t *driftgaugesmallcolor = NULL; + +static patch_t *kp_minimapdot = NULL; + +static patch_t *joybacking = NULL; +static patch_t *joyknob = NULL; +static patch_t *joyshadow = NULL; + +static patch_t *kp_multjawz = NULL; +static patch_t *kp_multsneaker[2] = {NULL}; +static patch_t *kp_multbanana[3] = {NULL}; + +static void K_LoadSaturnHUDGraphics(void) +{ + INT32 i; + char buffer[9]; + + if (found_extra_kart) + { + if (xtra_speedo) // smol speedometer + { + skp_smallsticker = (patch_t *)W_CachePatchName("SP_SMSTC", PU_HUDGFX); + skp_speedpatches[0] = (patch_t *)W_CachePatchName("K_TRNULL", PU_HUDGFX); // lolxd + skp_speedpatches[1] = (patch_t *)W_CachePatchName("SP_MKMH", PU_HUDGFX); + skp_speedpatches[2] = (patch_t *)W_CachePatchName("SP_MMPH", PU_HUDGFX); + skp_speedpatches[3] = (patch_t *)W_CachePatchName("SP_MFRAC", PU_HUDGFX); + skp_speedpatches[4] = (patch_t *)W_CachePatchName("SP_MPERC", PU_HUDGFX); + } + + if (achi_speedo) + { + skp_smallstickerachi = (patch_t *)W_CachePatchName("SP_AMSTC", PU_HUDGFX); + skp_speedpatchesachi[0] = (patch_t *)W_CachePatchName("K_TRNULL", PU_HUDGFX); // lolxd + skp_speedpatchesachi[1] = (patch_t *)W_CachePatchName("SP_AKMH", PU_HUDGFX); + skp_speedpatchesachi[2] = (patch_t *)W_CachePatchName("SP_AMPH", PU_HUDGFX); + skp_speedpatchesachi[3] = (patch_t *)W_CachePatchName("SP_AFRAC", PU_HUDGFX); + skp_speedpatchesachi[4] = (patch_t *)W_CachePatchName("SP_APERC", PU_HUDGFX); + } + + if (dial_speedo) + { + skp_rankfinish = (patch_t *)W_CachePatchName("RANKFIN", PU_HUDGFX); + skp_dialbase[0] = (patch_t *)W_CachePatchName("K_DSPBS1", PU_HUDGFX); + skp_dialbase[1] = (patch_t *)W_CachePatchName("K_DSPBS2", PU_HUDGFX); + + skp_speedpatchesdial[0] = (patch_t *)W_CachePatchName("K_TRNULL", PU_HUDGFX); // lolxd + skp_speedpatchesdial[1] = (patch_t *)W_CachePatchName("SP_DKMH", PU_HUDGFX); + skp_speedpatchesdial[2] = (patch_t *)W_CachePatchName("SP_DMPH", PU_HUDGFX); + skp_speedpatchesdial[3] = (patch_t *)W_CachePatchName("SP_DFRAC", PU_HUDGFX); + skp_speedpatchesdial[4] = (patch_t *)W_CachePatchName("SP_DPERC", PU_HUDGFX); + + sprintf(buffer, "K_DSPNMx"); + for (i = 0; i < 10; i++) + { + buffer[7] = '0'+(i%10); + skp_dialnum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + } + } + + // KartZ speedo + if (kartz_speedo) + { + const char* patchNames[] = { + "K_KZSP1", "K_KZSP2", "K_KZSP3", "K_KZSP4", "K_KZSP5", + "K_KZSP6", "K_KZSP7", "K_KZSP8", "K_KZSP9", "K_KZSP10", + "K_KZSP11", "K_KZSP12", "K_KZSP13", "K_KZSP14", "K_KZSP15", + "K_KZSP16", "K_KZSP17", "K_KZSP18", "K_KZSP19", "K_KZSP20", + "K_KZSP21", "K_KZSP22", "K_KZSP23", "K_KZSP24", "K_KZSP25" + }; + + for (size_t m = 0; m < sizeof(patchNames) / sizeof(patchNames[0]); ++m) + { + kp_kartzspeedo[m] = (patch_t *)W_CachePatchName(patchNames[m], PU_HUDGFX); + } + } + + if (kartz_speedo_smol) + { + const char* patchNames[] = { + "K_KZSS1", "K_KZSS2", "K_KZSS3", "K_KZSS4", "K_KZSS5", + "K_KZSS6", "K_KZSS7", "K_KZSS8", "K_KZSS9", "K_KZSS10", + "K_KZSS11", "K_KZSS12", "K_KZSS13", "K_KZSS14", "K_KZSS15", + "K_KZSS16", "K_KZSS17", "K_KZSS18", "K_KZSS19", "K_KZSS20", + "K_KZSS21", "K_KZSS22", "K_KZSS23", "K_KZSS24", "K_KZSS25" + }; + + for (size_t m = 0; m < sizeof(patchNames) / sizeof(patchNames[0]); ++m) + { + kp_kartzspeedo_smol[m] = (patch_t *)W_CachePatchName(patchNames[m], PU_HUDGFX); + } + } + + if (big_lap) + { + kp_lapstickerbig = (patch_t *)W_CachePatchName("K_STLAPB", PU_HUDGFX); + kp_lapstickerbig2 = (patch_t *)W_CachePatchName("K_STLA2B", PU_HUDGFX); + } + + // Nametags + if (nametaggfx) + { + nametagpic = (patch_t *)W_CachePatchName("NTLINE", PU_HUDGFX); + nametagline = (patch_t *)W_CachePatchName("NTLINEV", PU_HUDGFX); + nametagspeed = (patch_t *)W_CachePatchName("NTSP", PU_HUDGFX); + nametagweight = (patch_t *)W_CachePatchName("NTWH", PU_HUDGFX); + } + + if (driftgaugegfx) + { + driftgauge = (patch_t *)W_CachePatchName("K_DGAU", PU_HUDGFX); + driftgaugesmall = (patch_t *)W_CachePatchName("K_DGSU", PU_HUDGFX); + + if (driftgaugegfx_clr) + { + driftgaugecolor = (patch_t *)W_CachePatchName("K_DCAU", PU_HUDGFX); + driftgaugesmallcolor = (patch_t *)W_CachePatchName("K_DCSU", PU_HUDGFX); + } + } + + if (joystickicon) + { + joybacking = (patch_t *)W_CachePatchName("JOYBCK", PU_HUDGFX); + joyknob = (patch_t *)W_CachePatchName("JOYKNB", PU_HUDGFX); + joyshadow = (patch_t *)W_CachePatchName("JOYSHD", PU_HUDGFX); + } + + if (minidoticon) + { + kp_minimapdot = (patch_t *)W_CachePatchName("MMAPDOT", PU_HUDGFX); + } + + if (multiitem_icon) + { + kp_multsneaker[0] = (patch_t *)W_CachePatchName("K_ITSHO2", PU_HUDGFX); + kp_multsneaker[1] = (patch_t *)W_CachePatchName("K_ITSHO3", PU_HUDGFX); + kp_multbanana[0] = (patch_t *)W_CachePatchName("K_ITBAN2", PU_HUDGFX); + kp_multbanana[1] = (patch_t *)W_CachePatchName("K_ITBAN3", PU_HUDGFX); + kp_multbanana[2] = (patch_t *)W_CachePatchName("K_ITBAN4", PU_HUDGFX); + kp_multjawz = (patch_t *)W_CachePatchName("K_ITJAW2", PU_HUDGFX); + } + } + + if (found_extra2_kart) + { + if (xtra_speedo_clr) + { + skp_smallstickerclr = (patch_t *)W_CachePatchName("SC_SMSTC", PU_HUDGFX); + } + + if (xtra_speedo_clr3) + { + skp_smallstickerclr3 = (patch_t *)W_CachePatchName("SC_SM3TC", PU_HUDGFX); + } + + if (achi_speedo_clr) + { + skp_smallstickerachiclr = (patch_t *)W_CachePatchName("SC_AMSTC", PU_HUDGFX); + skp_speedpatchesachiclr[0] = (patch_t *)W_CachePatchName("K_TRNULL", PU_HUDGFX); // lolxd + skp_speedpatchesachiclr[1] = (patch_t *)W_CachePatchName("SC_AKMH", PU_HUDGFX); + skp_speedpatchesachiclr[2] = (patch_t *)W_CachePatchName("SC_AMPH", PU_HUDGFX); + skp_speedpatchesachiclr[3] = (patch_t *)W_CachePatchName("SC_AFRAC", PU_HUDGFX); + skp_speedpatchesachiclr[4] = (patch_t *)W_CachePatchName("SC_APERC", PU_HUDGFX); + } + + if (dial_speedo_clr) + { + skp_dialbaseclr[0] = (patch_t *)W_CachePatchName("K_DSPBC1", PU_HUDGFX); + skp_dialbaseclr[1] = (patch_t *)W_CachePatchName("K_DSPBC2", PU_HUDGFX); + + skp_speedpatchesdialclr[0] = (patch_t *)W_CachePatchName("K_TRNULL", PU_HUDGFX); // lolxd + skp_speedpatchesdialclr[1] = (patch_t *)W_CachePatchName("SC_DKMH", PU_HUDGFX); + skp_speedpatchesdialclr[2] = (patch_t *)W_CachePatchName("SC_DMPH", PU_HUDGFX); + skp_speedpatchesdialclr[3] = (patch_t *)W_CachePatchName("SC_DFRAC", PU_HUDGFX); + skp_speedpatchesdialclr[4] = (patch_t *)W_CachePatchName("SC_DPERC", PU_HUDGFX); + + sprintf(buffer, "K_DSPNCx"); + for (i = 0; i < 10; i++) + { + buffer[7] = '0'+(i%10); + skp_dialnumclr[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + } + } + + if (big_lap_color) + { + kp_lapstickerbigclr = (patch_t *)W_CachePatchName("K_SCLAPB", PU_HUDGFX); + kp_lapstickerbig2clr = (patch_t *)W_CachePatchName("K_SCLA2B", PU_HUDGFX); + } + + // Colourized hud + if (clr_hud) + { + kp_timestickerclr = (patch_t *)W_CachePatchName("K_SCTIME", PU_HUDGFX); + kp_timestickerwideclr = (patch_t *)W_CachePatchName("K_SCTIMW", PU_HUDGFX); + kp_lapstickerclr = (patch_t *)W_CachePatchName("K_SCLAPS", PU_HUDGFX); + kp_lapstickerwideclr = (patch_t *)W_CachePatchName("K_SCLAPW", PU_HUDGFX); + kp_bumperstickerclr = (patch_t *)W_CachePatchName("K_SCBALN", PU_HUDGFX); + kp_bumperstickerwideclr = (patch_t *)W_CachePatchName("K_SCBALW", PU_HUDGFX); + kp_karmastickerclr = (patch_t *)W_CachePatchName("K_SCKARM", PU_HUDGFX); + kp_timeoutstickerclr = (patch_t *)W_CachePatchName("K_SCTOUT", PU_HUDGFX); + kp_itembgclr[0] = (patch_t *)W_CachePatchName("K_ITBC" , PU_HUDGFX); + kp_itembgclr[1] = (patch_t *)W_CachePatchName("K_ITBCD" , PU_HUDGFX); + kp_itembgclr[2] = (patch_t *)W_CachePatchName("K_ISBC" , PU_HUDGFX); + kp_itembgclr[3] = (patch_t *)W_CachePatchName("K_ISBCD" , PU_HUDGFX); + kp_itemmulstickerclr[1] = (patch_t *)W_CachePatchName("K_ISMULC", PU_HUDGFX); + kp_itemmulstickerclr[0] = (patch_t *)W_CachePatchName("K_ITMULC", PU_HUDGFX); + } + } + + if (found_extra3_kart) + { + if (xtra_speedo3) // 80x11 patch scaled to size + { + skp_smallsticker3 = (patch_t *)W_CachePatchName("SP_SM3TC", PU_HUDGFX); + } + } +} + +// -- Kart patches -- + +#define NUMPOSNUMS 10 +#define NUMPOSFRAMES 7 // White, three blues, three reds +#define NUMWINFRAMES 6 // Red, yellow, green, cyan, blue, purple + +static patch_t *kp_nodraw; +static patch_t *kp_timesticker; +static patch_t *kp_timestickerwide; +static patch_t *kp_lapsticker; +static patch_t *kp_lapstickerwide; +//static patch_t *kp_lapstickernarrow; +static patch_t *kp_splitlapflag; +static patch_t *kp_bumpersticker; +static patch_t *kp_bumperstickerwide; +static patch_t *kp_karmasticker; +static patch_t *kp_splitkarmabomb; +static patch_t *kp_timeoutsticker; + +static patch_t *kp_startcountdown[16]; +static patch_t *kp_racefinish[6]; + +static patch_t *kp_positionnum[NUMPOSNUMS][NUMPOSFRAMES]; +static patch_t *kp_winnernum[NUMPOSFRAMES]; + +static patch_t *kp_facenum[MAXPLAYERS+1]; +static patch_t *kp_facehighlight[8]; + +static patch_t *kp_rankbumper; +static patch_t *kp_tinybumper[2]; +static patch_t *kp_ranknobumpers; + +static patch_t *kp_battlewin; +static patch_t *kp_battlecool; +static patch_t *kp_battlelose; +static patch_t *kp_battlewait; +static patch_t *kp_battleinfo; +static patch_t *kp_wanted; +static patch_t *kp_wantedsplit; +static patch_t *kp_wantedreticle; + +static patch_t *kp_itembg[4]; +static patch_t *kp_itemtimer[2]; +static patch_t *kp_itemmulsticker[2]; +static patch_t *kp_itemx; + +static patch_t *kp_sneaker[2]; +static patch_t *kp_rocketsneaker[2]; +static patch_t *kp_invincibility[13]; +static patch_t *kp_banana[2]; +static patch_t *kp_eggman[2]; +static patch_t *kp_orbinaut[5]; +static patch_t *kp_jawz[2]; +static patch_t *kp_mine[2]; +static patch_t *kp_ballhog[2]; +static patch_t *kp_selfpropelledbomb[2]; +static patch_t *kp_grow[2]; +static patch_t *kp_shrink[2]; +static patch_t *kp_thundershield[2]; +static patch_t *kp_hyudoro[2]; +static patch_t *kp_pogospring[2]; +static patch_t *kp_kitchensink[2]; +static patch_t *kp_sadface[2]; + +static patch_t *kp_check[6]; + +static patch_t *kp_eggnum[4]; + +static patch_t *kp_fpview[3]; +static patch_t *kp_inputwheel[5]; + +static patch_t *kp_challenger[25]; + +static patch_t *kp_lapanim_lap[7]; +static patch_t *kp_lapanim_final[11]; +static patch_t *kp_lapanim_number[10][3]; +static patch_t *kp_lapanim_emblem[2]; +static patch_t *kp_lapanim_hand[3]; + +static patch_t *kp_yougotem; + +void K_LoadKartHUDGraphics(void) +{ + INT32 i, j; + char buffer[9]; + + // Null Stuff + kp_nodraw = (patch_t *)W_CachePatchName("K_TRNULL", PU_HUDGFX); + + // Stickers + kp_timesticker = (patch_t *)W_CachePatchName("K_STTIME", PU_HUDGFX); + kp_timestickerwide = (patch_t *)W_CachePatchName("K_STTIMW", PU_HUDGFX); + kp_lapsticker = (patch_t *)W_CachePatchName("K_STLAPS", PU_HUDGFX); + kp_lapstickerwide = (patch_t *)W_CachePatchName("K_STLAPW", PU_HUDGFX); + //kp_lapstickernarrow = (patch_t *)W_CachePatchName("K_STLAPN", PU_HUDGFX); + kp_splitlapflag = (patch_t *)W_CachePatchName("K_SPTLAP", PU_HUDGFX); + kp_bumpersticker = (patch_t *)W_CachePatchName("K_STBALN", PU_HUDGFX); + kp_bumperstickerwide = (patch_t *)W_CachePatchName("K_STBALW", PU_HUDGFX); + kp_karmasticker = (patch_t *)W_CachePatchName("K_STKARM", PU_HUDGFX); + kp_splitkarmabomb = (patch_t *)W_CachePatchName("K_SPTKRM", PU_HUDGFX); + kp_timeoutsticker = (patch_t *)W_CachePatchName("K_STTOUT", PU_HUDGFX); + + // Starting countdown + kp_startcountdown[0] = (patch_t *)W_CachePatchName("K_CNT3A", PU_HUDGFX); + kp_startcountdown[1] = (patch_t *)W_CachePatchName("K_CNT2A", PU_HUDGFX); + kp_startcountdown[2] = (patch_t *)W_CachePatchName("K_CNT1A", PU_HUDGFX); + kp_startcountdown[3] = (patch_t *)W_CachePatchName("K_CNTGOA", PU_HUDGFX); + kp_startcountdown[4] = (patch_t *)W_CachePatchName("K_CNT3B", PU_HUDGFX); + kp_startcountdown[5] = (patch_t *)W_CachePatchName("K_CNT2B", PU_HUDGFX); + kp_startcountdown[6] = (patch_t *)W_CachePatchName("K_CNT1B", PU_HUDGFX); + kp_startcountdown[7] = (patch_t *)W_CachePatchName("K_CNTGOB", PU_HUDGFX); + + // Splitscreen + kp_startcountdown[8] = (patch_t *)W_CachePatchName("K_SMC3A", PU_HUDGFX); + kp_startcountdown[9] = (patch_t *)W_CachePatchName("K_SMC2A", PU_HUDGFX); + kp_startcountdown[10] = (patch_t *)W_CachePatchName("K_SMC1A", PU_HUDGFX); + kp_startcountdown[11] = (patch_t *)W_CachePatchName("K_SMCGOA", PU_HUDGFX); + kp_startcountdown[12] = (patch_t *)W_CachePatchName("K_SMC3B", PU_HUDGFX); + kp_startcountdown[13] = (patch_t *)W_CachePatchName("K_SMC2B", PU_HUDGFX); + kp_startcountdown[14] = (patch_t *)W_CachePatchName("K_SMC1B", PU_HUDGFX); + kp_startcountdown[15] = (patch_t *)W_CachePatchName("K_SMCGOB", PU_HUDGFX); + + // Finish + kp_racefinish[0] = (patch_t *)W_CachePatchName("K_FINA", PU_HUDGFX); + kp_racefinish[1] = (patch_t *)W_CachePatchName("K_FINB", PU_HUDGFX); + + // Splitscreen + kp_racefinish[2] = (patch_t *)W_CachePatchName("K_SMFINA", PU_HUDGFX); + kp_racefinish[3] = (patch_t *)W_CachePatchName("K_SMFINB", PU_HUDGFX); + + // 2P splitscreen + kp_racefinish[4] = (patch_t *)W_CachePatchName("K_2PFINA", PU_HUDGFX); + kp_racefinish[5] = (patch_t *)W_CachePatchName("K_2PFINB", PU_HUDGFX); + + // Position numbers + sprintf(buffer, "K_POSNxx"); + for (i = 0; i < NUMPOSNUMS; i++) + { + buffer[6] = '0'+i; + for (j = 0; j < NUMPOSFRAMES; j++) + { + buffer[7] = '0'+j; + kp_positionnum[i][j] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + } + } + + sprintf(buffer, "K_POSNWx"); + for (i = 0; i < NUMWINFRAMES; i++) + { + buffer[7] = '0'+i; + kp_winnernum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + } + + sprintf(buffer, "OPPRNKxx"); + for (i = 0; i <= MAXPLAYERS; i++) + { + buffer[6] = '0'+(i/10); + buffer[7] = '0'+(i%10); + kp_facenum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + } + + sprintf(buffer, "K_CHILIx"); + for (i = 0; i < 8; i++) + { + buffer[7] = '0'+(i+1); + kp_facehighlight[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + } + + // Extra ranking icons + kp_rankbumper = (patch_t *)W_CachePatchName("K_BLNICO", PU_HUDGFX); + kp_tinybumper[0] = (patch_t *)W_CachePatchName("K_BLNA", PU_HUDGFX); + kp_tinybumper[1] = (patch_t *)W_CachePatchName("K_BLNB", PU_HUDGFX); + kp_ranknobumpers = (patch_t *)W_CachePatchName("K_NOBLNS", PU_HUDGFX); + + // Battle graphics + kp_battlewin = (patch_t *)W_CachePatchName("K_BWIN", PU_HUDGFX); + kp_battlecool = (patch_t *)W_CachePatchName("K_BCOOL", PU_HUDGFX); + kp_battlelose = (patch_t *)W_CachePatchName("K_BLOSE", PU_HUDGFX); + kp_battlewait = (patch_t *)W_CachePatchName("K_BWAIT", PU_HUDGFX); + kp_battleinfo = (patch_t *)W_CachePatchName("K_BINFO", PU_HUDGFX); + kp_wanted = (patch_t *)W_CachePatchName("K_WANTED", PU_HUDGFX); + kp_wantedsplit = (patch_t *)W_CachePatchName("4PWANTED", PU_HUDGFX); + kp_wantedreticle = (patch_t *)W_CachePatchName("MMAPWANT", PU_HUDGFX); + + // Kart Item Windows + kp_itembg[0] = (patch_t *)W_CachePatchName("K_ITBG", PU_HUDGFX); + kp_itembg[1] = (patch_t *)W_CachePatchName("K_ITBGD", PU_HUDGFX); + kp_itemtimer[0] = (patch_t *)W_CachePatchName("K_ITIMER", PU_HUDGFX); + kp_itemmulsticker[0] = (patch_t *)W_CachePatchName("K_ITMUL", PU_HUDGFX); + kp_itemx = (patch_t *)W_CachePatchName("K_ITX", PU_HUDGFX); + // Splitscreen + kp_itembg[2] = (patch_t *)W_CachePatchName("K_ISBG", PU_HUDGFX); + kp_itembg[3] = (patch_t *)W_CachePatchName("K_ISBGD", PU_HUDGFX); + kp_itemtimer[1] = (patch_t *)W_CachePatchName("K_ISIMER", PU_HUDGFX); + kp_itemmulsticker[1] = (patch_t *)W_CachePatchName("K_ISMUL", PU_HUDGFX); + + // Kart Items + kp_sneaker[0] = (patch_t *)W_CachePatchName("K_ITSHOE", PU_HUDGFX); + kp_rocketsneaker[0] = (patch_t *)W_CachePatchName("K_ITRSHE", PU_HUDGFX); + kp_banana[0] = (patch_t *)W_CachePatchName("K_ITBANA", PU_HUDGFX); + kp_eggman[0] = (patch_t *)W_CachePatchName("K_ITEGGM", PU_HUDGFX); + kp_jawz[0] = (patch_t *)W_CachePatchName("K_ITJAWZ", PU_HUDGFX); + kp_mine[0] = (patch_t *)W_CachePatchName("K_ITMINE", PU_HUDGFX); + kp_ballhog[0] = (patch_t *)W_CachePatchName("K_ITBHOG", PU_HUDGFX); + kp_selfpropelledbomb[0] = (patch_t *)W_CachePatchName("K_ITSPB", PU_HUDGFX); + kp_grow[0] = (patch_t *)W_CachePatchName("K_ITGROW", PU_HUDGFX); + kp_shrink[0] = (patch_t *)W_CachePatchName("K_ITSHRK", PU_HUDGFX); + kp_thundershield[0] = (patch_t *)W_CachePatchName("K_ITTHNS", PU_HUDGFX); + kp_hyudoro[0] = (patch_t *)W_CachePatchName("K_ITHYUD", PU_HUDGFX); + kp_pogospring[0] = (patch_t *)W_CachePatchName("K_ITPOGO", PU_HUDGFX); + kp_kitchensink[0] = (patch_t *)W_CachePatchName("K_ITSINK", PU_HUDGFX); + kp_sadface[0] = (patch_t *)W_CachePatchName("K_ITSAD", PU_HUDGFX); + // Splitscreen + kp_sneaker[1] = (patch_t *)W_CachePatchName("K_ISSHOE", PU_HUDGFX); + kp_rocketsneaker[1] = (patch_t *)W_CachePatchName("K_ISRSHE", PU_HUDGFX); + kp_banana[1] = (patch_t *)W_CachePatchName("K_ISBANA", PU_HUDGFX); + kp_eggman[1] = (patch_t *)W_CachePatchName("K_ISEGGM", PU_HUDGFX); + kp_orbinaut[4] = (patch_t *)W_CachePatchName("K_ISORBN", PU_HUDGFX); + kp_jawz[1] = (patch_t *)W_CachePatchName("K_ISJAWZ", PU_HUDGFX); + kp_mine[1] = (patch_t *)W_CachePatchName("K_ISMINE", PU_HUDGFX); + kp_ballhog[1] = (patch_t *)W_CachePatchName("K_ISBHOG", PU_HUDGFX); + kp_selfpropelledbomb[1] = (patch_t *)W_CachePatchName("K_ISSPB", PU_HUDGFX); + kp_grow[1] = (patch_t *)W_CachePatchName("K_ISGROW", PU_HUDGFX); + kp_shrink[1] = (patch_t *)W_CachePatchName("K_ISSHRK", PU_HUDGFX); + kp_thundershield[1] = (patch_t *)W_CachePatchName("K_ISTHNS", PU_HUDGFX); + kp_hyudoro[1] = (patch_t *)W_CachePatchName("K_ISHYUD", PU_HUDGFX); + kp_pogospring[1] = (patch_t *)W_CachePatchName("K_ISPOGO", PU_HUDGFX); + kp_kitchensink[1] = (patch_t *)W_CachePatchName("K_ISSINK", PU_HUDGFX); + kp_sadface[1] = (patch_t *)W_CachePatchName("K_ISSAD", PU_HUDGFX); + + sprintf(buffer, "K_ITINVx"); + for (i = 0; i < 7; i++) + { + buffer[7] = '1'+i; + kp_invincibility[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + } + + sprintf(buffer, "K_ITORBx"); + for (i = 0; i < 4; i++) + { + buffer[7] = '1'+i; + kp_orbinaut[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + } + + sprintf(buffer, "K_ISINVx"); + for (i = 0; i < 6; i++) + { + buffer[7] = '1'+i; + kp_invincibility[i+7] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + } + + // CHECK indicators + sprintf(buffer, "K_CHECKx"); + for (i = 0; i < 6; i++) + { + buffer[7] = '1'+i; + kp_check[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + } + + // Eggman warning numbers + sprintf(buffer, "K_EGGNx"); + for (i = 0; i < 4; i++) + { + buffer[6] = '0'+i; + kp_eggnum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + } + + // First person mode + kp_fpview[0] = (patch_t *)W_CachePatchName("VIEWA0", PU_HUDGFX); + kp_fpview[1] = (patch_t *)W_CachePatchName("VIEWB0D0", PU_HUDGFX); + kp_fpview[2] = (patch_t *)W_CachePatchName("VIEWC0E0", PU_HUDGFX); + + // Input UI Wheel + sprintf(buffer, "K_WHEELx"); + for (i = 0; i < 5; i++) + { + buffer[7] = '0'+i; + kp_inputwheel[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + } + + // HERE COMES A NEW CHALLENGER + sprintf(buffer, "K_CHALxx"); + for (i = 0; i < 25; i++) + { + buffer[6] = '0'+((i+1)/10); + buffer[7] = '0'+((i+1)%10); + kp_challenger[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + } + + // Lap start animation + sprintf(buffer, "K_LAP0x"); + for (i = 0; i < 7; i++) + { + buffer[6] = '0'+(i+1); + kp_lapanim_lap[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + } + + sprintf(buffer, "K_LAPFxx"); + for (i = 0; i < 11; i++) + { + buffer[6] = '0'+((i+1)/10); + buffer[7] = '0'+((i+1)%10); + kp_lapanim_final[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + } + + sprintf(buffer, "K_LAPNxx"); + for (i = 0; i < 10; i++) + { + buffer[6] = '0'+i; + for (j = 0; j < 3; j++) + { + buffer[7] = '0'+(j+1); + kp_lapanim_number[i][j] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + } + } + + sprintf(buffer, "K_LAPE0x"); + for (i = 0; i < 2; i++) + { + buffer[7] = '0'+(i+1); + kp_lapanim_emblem[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + } + + sprintf(buffer, "K_LAPH0x"); + for (i = 0; i < 3; i++) + { + buffer[7] = '0'+(i+1); + kp_lapanim_hand[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + } + + kp_yougotem = (patch_t *)W_CachePatchName("YOUGOTEM", PU_HUDGFX); + + if (found_extra_kart || found_extra2_kart || found_extra3_kart) + K_LoadSaturnHUDGraphics(); +} + +// For the item toggle menu +const char *K_GetItemPatch(UINT8 item, boolean tiny) +{ + switch (item) + { + case KITEM_SNEAKER: + case KRITEM_TRIPLESNEAKER: + return (tiny ? "K_ISSHOE" : "K_ITSHOE"); + case KITEM_ROCKETSNEAKER: + return (tiny ? "K_ISRSHE" : "K_ITRSHE"); + case KITEM_INVINCIBILITY: + return (tiny ? "K_ISINV1" : "K_ITINV1"); + case KITEM_BANANA: + case KRITEM_TRIPLEBANANA: + case KRITEM_TENFOLDBANANA: + return (tiny ? "K_ISBANA" : "K_ITBANA"); + case KITEM_EGGMAN: + return (tiny ? "K_ISEGGM" : "K_ITEGGM"); + case KITEM_ORBINAUT: + return (tiny ? "K_ISORBN" : "K_ITORB1"); + case KITEM_JAWZ: + case KRITEM_DUALJAWZ: + return (tiny ? "K_ISJAWZ" : "K_ITJAWZ"); + case KITEM_MINE: + return (tiny ? "K_ISMINE" : "K_ITMINE"); + case KITEM_BALLHOG: + return (tiny ? "K_ISBHOG" : "K_ITBHOG"); + case KITEM_SPB: + return (tiny ? "K_ISSPB" : "K_ITSPB"); + case KITEM_GROW: + return (tiny ? "K_ISGROW" : "K_ITGROW"); + case KITEM_SHRINK: + return (tiny ? "K_ISSHRK" : "K_ITSHRK"); + case KITEM_THUNDERSHIELD: + return (tiny ? "K_ISTHNS" : "K_ITTHNS"); + case KITEM_HYUDORO: + return (tiny ? "K_ISHYUD" : "K_ITHYUD"); + case KITEM_POGOSPRING: + return (tiny ? "K_ISPOGO" : "K_ITPOGO"); + case KITEM_KITCHENSINK: + return (tiny ? "K_ISSINK" : "K_ITSINK"); + case KRITEM_TRIPLEORBINAUT: + return (tiny ? "K_ISORBN" : "K_ITORB3"); + case KRITEM_QUADORBINAUT: + return (tiny ? "K_ISORBN" : "K_ITORB4"); + default: + return (tiny ? "K_ISSAD" : "K_ITSAD"); + } +} + +//} + +INT32 ITEM_X, ITEM_Y; // Item Window +INT32 TIME_X, TIME_Y; // Time Sticker +INT32 LAPS_X, LAPS_Y; // Lap Sticker +INT32 SPDM_X, SPDM_Y; // Speedometer +INT32 POSI_X, POSI_Y; // Position Number +INT32 FACE_X, FACE_Y; // Top-four Faces +INT32 STCD_X, STCD_Y; // Starting countdown +INT32 CHEK_Y; // CHECK graphic +INT32 MINI_X, MINI_Y; // Minimap +INT32 WANT_X, WANT_Y; // Battle WANTED poster + +// This is for the P2 and P4 side of splitscreen. Then we'll flip P1's and P2's to the bottom with V_SPLITSCREEN. +INT32 ITEM2_X, ITEM2_Y; +INT32 LAPS2_X, LAPS2_Y; +INT32 POSI2_X, POSI2_Y; + +static void K_initKartHUD(void) +{ + /* + BASEVIDWIDTH = 320 + BASEVIDHEIGHT = 200 + + Item window graphic is 41 x 33 + + Time Sticker graphic is 116 x 11 + Time Font is a solid block of (8 x [12) x 14], equal to 96 x 14 + Therefore, timestamp is 116 x 14 altogether + + Lap Sticker is 80 x 11 + Lap flag is 22 x 20 + Lap Font is a solid block of (3 x [12) x 14], equal to 36 x 14 + Therefore, lapstamp is 80 x 20 altogether + + Position numbers are 43 x 53 + + Faces are 32 x 32 + Faces draw downscaled at 16 x 16 + Therefore, the allocated space for them is 16 x 67 altogether + + ---- + + ORIGINAL CZ64 SPLITSCREEN: + + Item window: + if (!splitscreen) { ICONX = 139; ICONY = 20; } + else { ICONX = BASEVIDWIDTH-315; ICONY = 60; } + + Time: 236, STRINGY( 12) + Lap: BASEVIDWIDTH-304, STRINGY(BASEVIDHEIGHT-189) + + */ + + // Single Screen (defaults) + // Item Window + ITEM_X = 5 + cv_item_xoffset.value; // 5 + ITEM_Y = 5 + cv_item_yoffset.value; // 5 + // Level Timer + TIME_X = BASEVIDWIDTH - 148 + cv_time_xoffset.value; // 172 + TIME_Y = 9 + cv_time_yoffset.value; // 9 + // Level Laps + LAPS_X = 9 + cv_laps_xoffset.value; // 9 + LAPS_Y = BASEVIDHEIGHT - 29 + cv_laps_yoffset.value; // 171 + // Speedometer + SPDM_X = 9 + cv_speed_xoffset.value; // 9 + SPDM_Y = BASEVIDHEIGHT - 45 + cv_speed_yoffset.value; // 155 + // Position Number + POSI_X = BASEVIDWIDTH - 9 + cv_posi_xoffset.value; // 268 + POSI_Y = BASEVIDHEIGHT - 9 + cv_posi_yoffset.value; // 138 + // Top-Four Faces + FACE_X = 9 + cv_face_xoffset.value; // 9 + FACE_Y = 92 + cv_face_yoffset.value; // 92 + // Starting countdown + STCD_X = BASEVIDWIDTH/2 + cv_stcd_xoffset.value; // 9 + STCD_Y = BASEVIDHEIGHT/2 + cv_stcd_yoffset.value; // 92 + // CHECK graphic + CHEK_Y = BASEVIDHEIGHT + cv_chek_yoffset.value; // 200 + // Minimap + MINI_X = BASEVIDWIDTH - 50 + cv_mini_xoffset.value; // 270 + MINI_Y = (BASEVIDHEIGHT/2)-16 + cv_mini_yoffset.value; // 84 + // Battle WANTED poster + WANT_X = BASEVIDWIDTH - 55 + cv_want_xoffset.value; // 270 + WANT_Y = BASEVIDHEIGHT- 71 + cv_want_yoffset.value; // 176 + + if (splitscreen) // Splitscreen + { + ITEM_X = 5; + ITEM_Y = 3; + + LAPS_Y = (BASEVIDHEIGHT/2)-24; + + POSI_Y = (BASEVIDHEIGHT/2)- 2; + + STCD_Y = BASEVIDHEIGHT/4; + + MINI_Y = (BASEVIDHEIGHT/2); + + if (splitscreen > 1) // 3P/4P Small Splitscreen + { + // 1P (top left) + ITEM_X = -9; + ITEM_Y = -8; + + LAPS_X = 3; + LAPS_Y = (BASEVIDHEIGHT/2)-13; + + POSI_X = 24; + POSI_Y = (BASEVIDHEIGHT/2)- 16; + + // 2P (top right) + ITEM2_X = BASEVIDWIDTH-39; + ITEM2_Y = -8; + + LAPS2_X = BASEVIDWIDTH-3; + LAPS2_Y = (BASEVIDHEIGHT/2)-13; + + POSI2_X = BASEVIDWIDTH -4; + POSI2_Y = (BASEVIDHEIGHT/2)- 16; + + // Reminder that 3P and 4P are just 1P and 2P splitscreen'd to the bottom. + + STCD_X = BASEVIDWIDTH/4; + + MINI_X = (3*BASEVIDWIDTH/4); + MINI_Y = (3*BASEVIDHEIGHT/4); + + if (splitscreen > 2) // 4P-only + { + MINI_X = (BASEVIDWIDTH/2); + MINI_Y = (BASEVIDHEIGHT/2); + } + } + } + + if (timeinmap > 113 || forceshowhud) + hudtrans = cv_translucenthud.value; + else if (timeinmap > 105) + hudtrans = ((((INT32)timeinmap) - 105)*cv_translucenthud.value)/(113-105); + else + hudtrans = 0; + + // K_GetScreenCoords needs the right view* variables + R_SetViewContext(stplyrnum); + R_InterpolateView(rendertimefrac_unpaused, !cv_uncappedhud.value); +} + +UINT8 K_GetHudColor(void) +{ + if (cv_colorizedhud.value && cv_colorizedhudcolor.value) + return cv_colorizedhudcolor.value; + + return ((stplyr && gamestate == GS_LEVEL) ? stplyr->skincolor : cv_playercolor.value); +} + +boolean K_UseColorHud(void) +{ + return (cv_colorizedhud.value && clr_hud); +} + +enum +{ + SPEEDO_VANILLA, + SPEEDO_EXTRA, + SPEEDO_ACHII, + SPEEDO_DIAL, + SPEEDO_PMETER, + SPEEDO_PMETERSMOL, + SPEEDO_EXTRA3, +}; + +static SINT8 K_GetSpeedometerStyle(void) +{ + if (cv_newspeedometer.value == 2 && xtra_speedo) + return SPEEDO_EXTRA; + else if (cv_newspeedometer.value == 3 && achi_speedo) + return SPEEDO_ACHII; + else if (cv_newspeedometer.value == 4 && dial_speedo) + return SPEEDO_DIAL; + else if (cv_newspeedometer.value == 5 && kartz_speedo) + return SPEEDO_PMETER; + else if (cv_newspeedometer.value == 6 && kartz_speedo_smol) + return SPEEDO_PMETERSMOL; + else if (cv_newspeedometer.value == 7 && xtra_speedo3) + return SPEEDO_EXTRA3; + else + return SPEEDO_VANILLA; +} + +static boolean K_UseColorSpeedo(int speedostyle) +{ + if (!K_UseColorHud()) + return false; + + switch (speedostyle) + { + case SPEEDO_EXTRA: + return xtra_speedo_clr; + case SPEEDO_ACHII: + return achi_speedo_clr; + case SPEEDO_DIAL: + return dial_speedo_clr; + case SPEEDO_EXTRA3: + return xtra_speedo_clr3; + default: + return false; + } +} + +static boolean K_IsHighResolution(void) +{ + return (vid.width >= 640 && vid.height >= 400); +} + +boolean K_UseHighResPortraits(void) +{ + return (cv_highresportrait.value && K_IsHighResolution()); +} + +// returns the players faceprefix +// accounts for localskins +patch_t *K_GetFacePrefix(player_t *player, INT32 skinnum) +{ + if (!player->skinlocal) + return (K_UseHighResPortraits() ? facewantprefix[skinnum] : facerankprefix[skinnum]); + else + return (K_UseHighResPortraits() ? localfacewantprefix[skinnum] : localfacerankprefix[skinnum]); +} + +INT32 K_calcSplitFlags(INT32 snapflags) +{ + INT32 splitflags = 0; + + if (splitscreen == 0) + return snapflags; + + if (stplyrnum != 0) + { + if (splitscreen == 1 && stplyrnum == 1) + { + splitflags |= V_SPLITSCREEN; + } + else if (splitscreen > 1) + { + if (stplyrnum == 2 || (splitscreen == 3 && stplyrnum == 3)) + splitflags |= V_SPLITSCREEN; + if (stplyrnum == 1 || (splitscreen == 3 && stplyrnum == 3)) + splitflags |= V_HORZSCREEN; + } + } + + if (splitflags & V_SPLITSCREEN) + snapflags &= ~V_SNAPTOTOP; + else + snapflags &= ~V_SNAPTOBOTTOM; + + if (splitscreen > 1) + { + if (splitflags & V_HORZSCREEN) + snapflags &= ~V_SNAPTOLEFT; + else + snapflags &= ~V_SNAPTORIGHT; + } + + return (splitflags|snapflags); +} + +void K_getItemBoxDrawinfo(drawinfo_t *out) +{ + INT32 fx, fy, fflags; + + // pain and suffering defined below + if (splitscreen < 2) // don't change shit for THIS splitscreen. + { + fx = ITEM_X; + fy = ITEM_Y; + fflags = K_calcSplitFlags(V_SNAPTOTOP|V_SNAPTOLEFT); + } + else // now we're having a fun game. + { + if (!(stplyrnum & 1)) // If we are P1 or P3... + { + fx = ITEM_X; + fy = ITEM_Y; + fflags = V_SNAPTOLEFT|(stplyrnum & 2 ? V_SPLITSCREEN : V_SNAPTOTOP); // flip P3 to the bottom. + } + else // else, that means we're P2 or P4. + { + fx = ITEM2_X; + fy = ITEM2_Y; + fflags = V_SNAPTORIGHT|(stplyrnum & 2 ? V_SPLITSCREEN : V_SNAPTOTOP); // flip P4 to the bottom + } + } + + out->x = fx; + out->y = fy; + out->flags = fflags; +} + +void K_getLapsDrawinfo(drawinfo_t *out) +{ + INT32 fx, fy, fflags; + + // pain and suffering defined below + if (splitscreen < 2) // don't change shit for THIS splitscreen. + { + fx = LAPS_X; + fy = LAPS_Y; + fflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTOLEFT); + } + else + { + if (!(stplyrnum & 1)) // If we are P1 or P3... + { + fx = LAPS_X; + fy = LAPS_Y; + fflags = V_SNAPTOLEFT|(stplyrnum & 2 ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. + } + else // else, that means we're P2 or P4. + { + fx = LAPS2_X; + fy = LAPS2_Y; + fflags = V_SNAPTORIGHT|(stplyrnum & 2 ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom + } + } + + out->x = fx; + out->y = fy; + out->flags = fflags; +} + +void K_getMinimapDrawinfo(drawinfo_t *out) +{ + INT32 fx = MINI_X, fy = MINI_Y, fflags = (splitscreen == 3 ? 0 : V_SNAPTORIGHT); // flags should only be 0 when it's centered (4p split) + + out->x = fx; + out->y = fy; + out->flags = fflags; +} + +INT32 K_getMinimapTrans(void) +{ + INT32 minimaptrans = cv_kartminimap.value; + + if (!minimaptrans) + return -1; + + if (forceshowhud) + return (10-minimaptrans)<kartstuff[k_bumper] ? -5 : -8) : 0); + + // Customizations c: + if (!splitscreen) + { + x += 18 + cv_stat_xoffset.value + spdxoffset; + y += cv_stat_yoffset.value + spdoffset; + } + else if (splitscreen == 1) // I tried my best, but this is still mess :/ < :Blobcatpats: c: + { + x -= 10; + y -= 40; + y += spdoffset; + + // If we are in 2-player splitscreen, for player 1 we move hud to up and remove snapping + // to bottom + if (splitnum == 0) + { + y /= 2; + flags = V_SNAPTOLEFT; + } + else + { + // Can move it down a bit + y += 45; + } + } + else + { + if (splitnum == 0 || splitnum == 2) // If we are P1 or P3... + { + // ye i just align it to position number lol + x = POSI_X + 19; + y = POSI_Y - 6; + flags = V_SNAPTOLEFT|((splitnum == 2) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. + } + else // else, that means we're P2 or P4. + { + x = POSI2_X - 75; + y = POSI2_Y - 6; + flags = V_SNAPTORIGHT|((splitnum == 3) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom + } + } + + flags |= V_HUDTRANS; + + skin_t *fakeskin; + fakeskin = K_GetPlayerSkin(stplyr); + + if (!splitscreen) + { + // Skin name + if (K_IsHighResolution()) // V_DrawSmallString becomes a mess at low resolutions lel + { + V_DrawSmallString(x+20, y+12, flags|V_ALLOWLOWERCASE|V_SkinColorToHighlightcolor(stplyr->skincolor), fakeskin->realname); + } + else + { + V_DrawThinString(x+20, y+7, flags|V_ALLOWLOWERCASE|V_SkinColorToHighlightcolor(stplyr->skincolor), fakeskin->realname); + } + + // Icon and stats + if (K_UseHighResPortraits()) + V_DrawSmallMappedPatch(x, y, flags, R_GetSkinFaceWant(stplyr), R_GetLocalTranslationColormap(fakeskin, fakeskin, stplyr->skincolor, GTC_CACHE, stplyr->skinlocal)); + else + V_DrawMappedPatch(x, y, flags, R_GetSkinFaceRank(stplyr), R_GetLocalTranslationColormap(fakeskin, fakeskin, stplyr->skincolor, GTC_CACHE, stplyr->skinlocal)); + + V_DrawMappedPatch(x-3, y-2, flags, kp_facenum[min(9, max(1, stplyr->kartspeed))], R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_BLUEBERRY, GTC_CACHE)); + V_DrawMappedPatch(x+10, y+10, flags, kp_facenum[min(9, max(1, stplyr->kartweight))], R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_BURGUNDY, GTC_CACHE)); + } + else + { + // In splitscreen, just draw a string with stats + V_DrawString(x, y+10, flags, va("\x84%dS \x87%dW", stplyr->kartspeed, stplyr->kartweight)); + } +} + +static void K_drawKartItem(void) +{ + // ITEM_X = BASEVIDWIDTH-50; // 270 + // ITEM_Y = 24; // 24 + + // Why write V_DrawScaledPatch calls over and over when they're all the same? + // Set to 'no item' just in case. + const UINT8 offset = ((splitscreen > 1) ? 1 : 0); + patch_t *localpatch = kp_nodraw; + patch_t *localbg; + boolean dark = false; + + patch_t *localinv = ((offset) ? kp_invincibility[((leveltime % (6*3)) / 3) + 7] : kp_invincibility[(leveltime % (7*3)) / 3]); + INT32 fx = 0, fy = 0, fflags = 0; // final coords for hud and flags... + INT32 numberdisplaymin = cv_huditemamount.value == 2 ? 1 : 2; // No longer a constant so other things can modify this value + INT32 itembar = 0; + INT32 maxl = 0; // itembar's normal highest value + const INT32 barlength = (splitscreen > 1 ? 12 : 26); + UINT8 localcolor = SKINCOLOR_NONE; + SINT8 colormode = TC_RAINBOW; + UINT8 *colmap = NULL; + UINT8 *colormap = NULL; + + if (stplyr->kartstuff[k_itemroulette]) + { + localcolor = K_GetHudColor(); + + switch((stplyr->kartstuff[k_itemroulette] % (14*3)) / 3) + { + // Each case is handled in threes, to give three frames of in-game time to see the item on the roulette + case 0: // Sneaker + localpatch = kp_sneaker[offset]; + //localcolor = SKINCOLOR_RASPBERRY; + break; + case 1: // Banana + localpatch = kp_banana[offset]; + //localcolor = SKINCOLOR_YELLOW; + break; + case 2: // Orbinaut + localpatch = kp_orbinaut[3+offset]; + //localcolor = SKINCOLOR_STEEL; + break; + case 3: // Mine + localpatch = kp_mine[offset]; + //localcolor = SKINCOLOR_JET; + break; + case 4: // Grow + localpatch = kp_grow[offset]; + //localcolor = SKINCOLOR_TEAL; + break; + case 5: // Hyudoro + localpatch = kp_hyudoro[offset]; + //localcolor = SKINCOLOR_STEEL; + break; + case 6: // Rocket Sneaker + localpatch = kp_rocketsneaker[offset]; + //localcolor = SKINCOLOR_TANGERINE; + break; + case 7: // Jawz + localpatch = kp_jawz[offset]; + //localcolor = SKINCOLOR_JAWZ; + break; + case 8: // Self-Propelled Bomb + localpatch = kp_selfpropelledbomb[offset]; + //localcolor = SKINCOLOR_JET; + break; + case 9: // Shrink + localpatch = kp_shrink[offset]; + //localcolor = SKINCOLOR_ORANGE; + break; + case 10: // Invincibility + localpatch = localinv; + //localcolor = SKINCOLOR_GREY; + break; + case 11: // Eggman Monitor + localpatch = kp_eggman[offset]; + //localcolor = SKINCOLOR_ROSE; + break; + case 12: // Ballhog + localpatch = kp_ballhog[offset]; + //localcolor = SKINCOLOR_LILAC; + break; + case 13: // Thunder Shield + localpatch = kp_thundershield[offset]; + //localcolor = SKINCOLOR_CYAN; + break; + /*case 14: // Pogo Spring + localpatch = kp_pogospring[offset]; + localcolor = SKINCOLOR_TANGERINE; + break; + case 15: // Kitchen Sink + localpatch = kp_kitchensink[offset]; + localcolor = SKINCOLOR_STEEL; + break;*/ + default: + break; + } + } + else + { + // I'm doing this a little weird and drawing mostly in reverse order + // The only actual reason is to make sneakers line up this way in the code below + // This shouldn't have any actual baring over how it functions + // Hyudoro is first, because we're drawing it on top of the player's current item + if (stplyr->kartstuff[k_stolentimer] > 0) + { + if (leveltime & 2) + localpatch = kp_hyudoro[offset]; + else + localpatch = kp_nodraw; + } + else if ((stplyr->kartstuff[k_stealingtimer] > 0) && (leveltime & 2)) + { + localpatch = kp_hyudoro[offset]; + } + else if (stplyr->kartstuff[k_eggmanexplode] > 1) + { + if (leveltime & 1) + localpatch = kp_eggman[offset]; + else + localpatch = kp_nodraw; + } + else if (stplyr->kartstuff[k_rocketsneakertimer] > 1) + { + itembar = stplyr->kartstuff[k_rocketsneakertimer]; + maxl = (itemtime*3) - barlength; + + if (leveltime & 1) + localpatch = kp_rocketsneaker[offset]; + else + localpatch = kp_nodraw; + } + else if (stplyr->kartstuff[k_growshrinktimer] > 0) + { + if (stplyr->kartstuff[k_growcancel] > 0) + { + itembar = stplyr->kartstuff[k_growcancel]; + maxl = 26; + } + + if (leveltime & 1) + localpatch = kp_grow[offset]; + else + localpatch = kp_nodraw; + } + else if (stplyr->kartstuff[k_sadtimer] > 0) + { + if (leveltime & 2) + localpatch = kp_sadface[offset]; + else + localpatch = kp_nodraw; + } + else + { + if (stplyr->kartstuff[k_itemamount] <= 0) + return; + + const boolean usemultiicon = (multiitem_icon && cv_multiitemicon.value && !offset); + + switch (stplyr->kartstuff[k_itemtype]) + { + case KITEM_SNEAKER: + if (usemultiicon) + { + if (!cv_huditemamount.value) + numberdisplaymin = 4; + switch(stplyr->kartstuff[k_itemamount]) + { + case 1: + localpatch = kp_sneaker[offset]; + break; + case 2: + localpatch = kp_multsneaker[0]; + break; + default: + localpatch = kp_multsneaker[1]; + break; + } + } + else + { + localpatch = kp_sneaker[offset]; + } + break; + case KITEM_ROCKETSNEAKER: + localpatch = kp_rocketsneaker[offset]; + break; + case KITEM_INVINCIBILITY: + localpatch = localinv; + dark = true; + break; + case KITEM_BANANA: + if (usemultiicon) + { + if (!cv_huditemamount.value) + numberdisplaymin = 4; + switch(stplyr->kartstuff[k_itemamount]) + { + case 1: + localpatch = kp_banana[offset]; + break; + case 2: + localpatch = kp_multbanana[0]; + break; + case 3: + localpatch = kp_multbanana[1]; + break; + default: + localpatch = kp_multbanana[2]; + break; + } + } + else + { + localpatch = kp_banana[offset]; + } + break; + case KITEM_EGGMAN: + localpatch = kp_eggman[offset]; + break; + case KITEM_ORBINAUT: + if (!cv_huditemamount.value) + numberdisplaymin = offset ? 2 : 5; + localpatch = kp_orbinaut[(offset ? 4 : min(stplyr->kartstuff[k_itemamount]-1, 3))]; + break; + case KITEM_JAWZ: + if (usemultiicon) + { + if (!cv_huditemamount.value) + numberdisplaymin = 3; + localpatch = ((stplyr->kartstuff[k_itemamount] == 1) ? kp_jawz[offset] : kp_multjawz); + } + else + { + localpatch = kp_jawz[offset]; + } + break; + case KITEM_MINE: + localpatch = kp_mine[offset]; + break; + case KITEM_BALLHOG: + localpatch = kp_ballhog[offset]; + break; + case KITEM_SPB: + localpatch = kp_selfpropelledbomb[offset]; + dark = true; + break; + case KITEM_GROW: + localpatch = kp_grow[offset]; + break; + case KITEM_SHRINK: + localpatch = kp_shrink[offset]; + break; + case KITEM_THUNDERSHIELD: + localpatch = kp_thundershield[offset]; + dark = true; + break; + case KITEM_HYUDORO: + localpatch = kp_hyudoro[offset]; + break; + case KITEM_POGOSPRING: + localpatch = kp_pogospring[offset]; + break; + case KITEM_KITCHENSINK: + localpatch = kp_kitchensink[offset]; + break; + case KITEM_SAD: + localpatch = kp_sadface[offset]; + break; + default: + return; + } + + if (stplyr->kartstuff[k_itemheld] && !(leveltime & 1)) + localpatch = kp_nodraw; + } + + if (stplyr->kartstuff[k_itemblink] && (leveltime & 1)) + { + colormode = TC_BLINK; + + switch (stplyr->kartstuff[k_itemblinkmode]) + { + case 2: + localcolor = (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))); + break; + case 1: + localcolor = SKINCOLOR_RED; + break; + default: + localcolor = SKINCOLOR_WHITE; + break; + } + } + } + + localbg = K_getItemBoxPatch((boolean)offset, dark); + drawinfo_t info; + K_getItemBoxDrawinfo(&info); + fx = info.x; + fy = info.y; + fflags = info.flags; + + boolean flipamount = splitscreen > 1 && stplyrnum & 1; // Used for 3P/4P splitscreen to flip item amount stuff + + if (K_UseColorHud()) + colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); + + V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, localbg, cv_colorizeditembox.value ? colormap : NULL); + + fixed_t rfy = fy<kartstuff[k_itemroulette] && !stplyr->deadtimer) + { + fixed_t frac = R_GetHudUncap(); + UINT8 fancystep = (offset ? 6 : 10); + fixed_t fancyoffset = (stplyr->kartstuff[k_itemroulette] % 3)-1; + + if (fancyoffset != 0) + { + fancyflags &= ~V_HUDTRANS; + fancyflags |=V_HUDTRANSHALF; + } + + rfy += (fancystep * fancyoffset * FRACUNIT) + FixedMul(fancystep*FRACUNIT, frac) - fancystep/2*FRACUNIT; + } + + if (localcolor != SKINCOLOR_NONE) + colmap = R_GetTranslationColormap(colormode, localcolor, GTC_CACHE); + + // Then, the numbers: + if (stplyr->kartstuff[k_itemamount] >= numberdisplaymin && !stplyr->kartstuff[k_itemroulette]) + { + localbg = K_getItemMulPatch((boolean)offset); + + V_DrawMappedPatch(fx + (flipamount ? 48 : 0), fy, V_HUDTRANS|fflags|(flipamount ? V_FLIP : 0), localbg, colormap); // flip this graphic for p2 and p4 in split and shift it. + V_DrawFixedPatch(fx<kartstuff[k_itemamount])); + } + else + { + V_DrawScaledPatch(fx+28, fy+41, V_HUDTRANS|fflags, kp_itemx); + V_DrawKartString(fx+38, fy+36, V_HUDTRANS|fflags, va("%d", stplyr->kartstuff[k_itemamount])); + } + } + else + V_DrawFixedPatch(fx< 2) + { + V_DrawFill(fx+x+length, fy+y+1, 1, height, 12|fflags); // the right one + if (height == 2) + V_DrawFill(fx+x+2, fy+y+2, length-2, 1, 8|fflags); // the dulled underside + V_DrawFill(fx+x+2, fy+y+1, length-2, 1, 120|fflags); // the shine + } + } + + // Quick Eggman numbers + if (stplyr->kartstuff[k_eggmanexplode] > 1 /*&& stplyr->kartstuff[k_eggmanexplode] <= 3*TICRATE*/) + V_DrawScaledPatch(fx+17, fy+13-offset, V_HUDTRANS|fflags, kp_eggnum[min(3, G_TicsToSeconds(stplyr->kartstuff[k_eggmanexplode]))]); +} + +void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UINT8 mode) +{ + // TIME_X = BASEVIDWIDTH-124; // 196 + // TIME_Y = 6; // 6 + + INT32 splitflags = 0; + + if (!mode) + { + splitflags = V_HUDTRANS|K_calcSplitFlags(V_SNAPTOTOP|V_SNAPTORIGHT); + if (cv_timelimit.value && timelimitintics > 0) + { + if (drawtime >= timelimitintics) + drawtime = 0; + else + drawtime = timelimitintics - drawtime; + } + } + + if (K_UseColorHud()) // Colourized hud + { + UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); + V_DrawMappedPatch(TX, TY, splitflags, ((mode == 2) ? kp_lapstickerwideclr : kp_timestickerwideclr), colormap); + } + else + V_DrawScaledPatch(TX, TY, splitflags, ((mode == 2) ? kp_lapstickerwide : kp_timestickerwide)); + + TX += 33; + + if (drawtime == UINT32_MAX) + ; + else if (mode && !drawtime) + { + V_DrawKartString(TX, TY+3, splitflags, va("--'--\"--")); + } + else + { + tic_t worktime = drawtime/(60*TICRATE); + + if (cv_timelimit.value && cv_overtime.value && G_BattleGametype() && !players[consoleplayer].exiting && (leveltime > (timelimitintics + starttime + TICRATE/2))) // i hate this so much + { + V_DrawKartString(TX, TY+3, splitflags, va("OVERTIME")); + } + else if (worktime < 100) + { + // minutes time 00 __ __ + V_DrawKartString(TX, TY+3, splitflags, va("%d", worktime/10)); + V_DrawKartString(TX+12, TY+3, splitflags, va("%d", worktime%10)); + + // apostrophe location _'__ __ + V_DrawKartString(TX+24, TY+3, splitflags, va("'")); + + worktime = (drawtime/TICRATE % 60); + + // seconds time _ 00 __ + V_DrawKartString(TX+36, TY+3, splitflags, va("%d", worktime/10)); + V_DrawKartString(TX+48, TY+3, splitflags, va("%d", worktime%10)); + + // quotation mark location _ __"__ + V_DrawKartString(TX+60, TY+3, splitflags, va("\"")); + + worktime = G_TicsToCentiseconds(drawtime); + + // tics _ __ 00 + V_DrawKartString(TX+72, TY+3, splitflags, va("%d", worktime/10)); + V_DrawKartString(TX+84, TY+3, splitflags, va("%d", worktime%10)); + } + else if ((drawtime/TICRATE) & 1) + V_DrawKartString(TX, TY+3, splitflags, va("99'59\"99")); + } + + if (emblemmap && (modeattacking || (mode == 1)) && !demo.playback) // emblem time! + { + INT32 workx = TX + 96, worky = TY+18; + SINT8 curemb = 0; + patch_t *emblempic[3] = {NULL, NULL, NULL}; + UINT8 *emblemcol[3] = {NULL, NULL, NULL}; + + emblem_t *emblem = M_GetLevelEmblems(emblemmap); + while (emblem) + { + char targettext[9]; + + switch (emblem->type) + { + case ET_TIME: + { + static boolean canplaysound = true; + tic_t timetoreach = emblem->var; + + if (emblem->collected) + { + emblempic[curemb] = W_CachePatchName(M_GetEmblemPatch(emblem), PU_PATCH); + emblemcol[curemb] = R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_CACHE); + if (++curemb == 3) + break; + goto bademblem; + } + + snprintf(targettext, 9, "%i'%02i\"%02i", + G_TicsToMinutes(timetoreach, false), + G_TicsToSeconds(timetoreach), + G_TicsToCentiseconds(timetoreach)); + + if (!mode) + { + if (stplyr->realtime > timetoreach) + { + splitflags = (splitflags &~ V_HUDTRANS)|V_HUDTRANSHALF; + if (canplaysound) + { + S_StartSound(NULL, sfx_s3k72); //sfx_s26d); -- you STOLE fizzy lifting drinks + canplaysound = false; + } + } + else if (!canplaysound) + canplaysound = true; + } + + targettext[8] = 0; + } + break; + default: + goto bademblem; + } + + V_DrawRightAlignedString(workx, worky, splitflags, targettext); + workx -= 67; + V_DrawSmallScaledPatch(workx + 4, worky, splitflags, W_CachePatchName("NEEDIT", PU_PATCH)); + + break; + + bademblem: + emblem = M_GetLevelEmblems(-1); + } + + if (!mode) + splitflags = (splitflags &~ V_HUDTRANSHALF)|V_HUDTRANS; + + while (curemb--) + { + workx -= 12; + V_DrawSmallMappedPatch(workx + 4, worky, splitflags, emblempic[curemb], emblemcol[curemb]); + } + } +} + +#define POS_DELAY_TIME 10 + +static void K_DrawKartPositionNum(INT32 num) +{ + // POSI_X = BASEVIDWIDTH - 51; // 269 + // POSI_Y = BASEVIDHEIGHT- 64; // 136 + + const boolean wheeloffs = (cv_showinput.value && cv_posi_xoffset.value == 0 && cv_posi_yoffset.value == 0 && cv_wheel_xoffset.value == 0 && cv_wheel_yoffset.value == 0); + const boolean win = (stplyr->exiting && num == 1); + INT32 W = kp_positionnum[0][0]->width; + fixed_t scale = FRACUNIT; + patch_t *localpatch = kp_positionnum[0][0]; + INT32 fx = 0, fy = 0, fflags = 0; + const INT32 xoffs = wheeloffs ? -48 : 0; + boolean flipdraw = false; // flip the order we draw it in for MORE splitscreen bs. fun. + boolean flipvdraw = false; // used only for 2p splitscreen so overtaking doesn't make 1P's position fly off the screen. + boolean overtake = false; + + if ((cv_posanim.value && stplyr->kartstuff[k_positiondelay]) || stplyr->exiting) + { + if (cv_posanim.value == 2) + { + const UINT8 delay = (stplyr->exiting) ? POS_DELAY_TIME : stplyr->kartstuff[k_positiondelay]; + const fixed_t add = (scale * 3) >> ((splitscreen == 1) ? 1 : 2); + scale = (scale + min((add * (delay * delay)) / (POS_DELAY_TIME * POS_DELAY_TIME), add)); + } + else + scale *= 2; + + overtake = true; // this is used for splitscreen stuff in conjunction with flipdraw. + } + + if (splitscreen || cv_smallposnum.value || wheeloffs) + { + scale /= 2; + } + + W = FixedMul(W<>FRACBITS; + + // pain and suffering defined below + if (!splitscreen) + { + fx = POSI_X + xoffs; + fy = BASEVIDHEIGHT - 8 + cv_posi_yoffset.value; + fflags = V_SNAPTOBOTTOM|V_SNAPTORIGHT; + } + else if (splitscreen == 1) // for this splitscreen, we'll use case by case because it's a bit different. + { + fx = POSI_X; + if (stplyrnum == 0) // for player 1: display this at the top right, above the minimap. + { + fy = 30 + cv_posi_yoffset.value; + fflags = V_SNAPTOTOP|V_SNAPTORIGHT; + if (overtake) + flipvdraw = true; // make sure overtaking doesn't explode us + } + else // if we're not p1, that means we're p2. display this at the bottom right, below the minimap. + { + fy = BASEVIDHEIGHT - 8 + cv_posi_yoffset.value; + fflags = V_SNAPTOBOTTOM|V_SNAPTORIGHT; + } + } + else + { + if (!(stplyrnum & 1)) // If we are P1 or P3... + { + fx = POSI_X; + fy = POSI_Y; + fflags = V_SNAPTOLEFT|((stplyrnum == 2) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. + flipdraw = true; + if (num && num >= 10) + fx += W; // this seems dumb, but we need to do this in order for positions above 10 going off screen. + } + else // else, that means we're P2 or P4. + { + fx = POSI2_X; + fy = POSI2_Y; + fflags = V_SNAPTORIGHT|((stplyrnum == 3) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom + } + } + + // Special case for 0 + if (!num) + { + V_DrawFixedPatch(fx<= 0); // This function does not draw negative numbers + + // Draw the number + while (num) + { + if (win) // 1st place winner? You get rainbows!! + { + localpatch = kp_winnernum[(leveltime % (NUMWINFRAMES*3)) / 3]; + } + else if (stplyr->laps+1 >= cv_numlaps.value || stplyr->exiting) // Check for the final lap, or won + { + // Alternate frame every three frames + switch (leveltime % 9) + { + case 1: case 2: case 3: + if (K_IsPlayerLosing(stplyr)) + localpatch = kp_positionnum[num % 10][4]; + else + localpatch = kp_positionnum[num % 10][1]; + break; + case 4: case 5: case 6: + if (K_IsPlayerLosing(stplyr)) + localpatch = kp_positionnum[num % 10][5]; + else + localpatch = kp_positionnum[num % 10][2]; + break; + case 7: case 8: case 9: + if (K_IsPlayerLosing(stplyr)) + localpatch = kp_positionnum[num % 10][6]; + else + localpatch = kp_positionnum[num % 10][3]; + break; + default: + localpatch = kp_positionnum[num % 10][0]; + break; + } + } + else + { + localpatch = kp_positionnum[num % 10][0]; + } + + V_DrawFixedPatch((fx<width*scale/2) : 0), (fy<height*scale/2) : 0), scale, V_HUDTRANSHALF|fflags, localpatch, NULL); + // ^ if we overtake as p1 or p3 in splitscren, we shift it so that it doesn't go off screen. + // ^ if we overtake as p1 in 2p splits, shift vertically so that this doesn't happen either. + + fx -= W; + num /= 10; + } +} + +static boolean K_drawKartPositionFaces(void) +{ + // FACE_X = 15; // 15 + // FACE_Y = 72; // 72 + + INT32 Y = FACE_Y+9; // +9 to offset where it's being drawn if there are more than one + INT32 i, j, ranklines, strank = -1; + boolean completed[MAXPLAYERS]; + INT32 rankplayer[MAXPLAYERS]; + INT32 bumperx, numplayersingame = 0; + UINT8 *colormap; + + ranklines = 0; + memset(completed, 0, sizeof (completed)); + memset(rankplayer, 0, sizeof (rankplayer)); + + for (i = 0; i < MAXPLAYERS; i++) + { + rankplayer[i] = -1; + + if (!playeringame[i] || players[i].spectator || !players[i].mo) + continue; + + numplayersingame++; + } + + if (numplayersingame <= 1) + return true; + + if (!LUA_HudEnabled(hud_minirankings)) + return false; // Don't proceed but still return true for free play above if HUD is disabled. + + for (j = 0; j < numplayersingame; j++) + { + UINT8 lowestposition = MAXPLAYERS+1; + for (i = 0; i < MAXPLAYERS; i++) + { + if (completed[i] || !playeringame[i] || players[i].spectator || !players[i].mo) + continue; + + if (players[i].kartstuff[k_position] >= lowestposition) + continue; + + rankplayer[ranklines] = i; + lowestposition = players[i].kartstuff[k_position]; + } + + i = rankplayer[ranklines]; + + completed[i] = true; + + if (players+i == stplyr) + strank = ranklines; + + ranklines++; + } + + if (ranklines < 5) + Y -= (9*ranklines); + else + Y -= (9*5); + + if (G_BattleGametype() || strank <= 2) // too close to the top, or playing battle, or a spectator? would have had (strank == -1) called out, but already caught by (strank <= 2) + { + i = 0; + if (ranklines > 5) // could be both... + ranklines = 5; + } + else if (strank+3 > ranklines) // too close to the bottom? + { + i = ranklines - 5; + if (i < 0) + i = 0; + } + else + { + i = strank-2; + ranklines = strank+3; + } + + for (; i < ranklines; i++) + { + player_t *player; + player = &players[rankplayer[i]]; + + if (!playeringame[rankplayer[i]]) + continue; + if (player->spectator) + continue; + if (!player->mo) + continue; + + const UINT8 mocolor = player->mo->color; + + bumperx = FACE_X+19; + + if (mocolor) + { + colormap = R_GetTranslationColormap(player->skin, mocolor, GTC_CACHE); + if (player->mo->colorized) + colormap = R_GetTranslationColormap(TC_RAINBOW, mocolor, GTC_CACHE); + + if (K_UseHighResPortraits()) + V_DrawSmallMappedPatch(FACE_X, Y, V_HUDTRANS|V_SNAPTOLEFT, R_GetSkinFaceWant(player), colormap); + else + V_DrawMappedPatch(FACE_X, Y, V_HUDTRANS|V_SNAPTOLEFT, R_GetSkinFaceRank(player), colormap); + + if (LUA_HudEnabled(hud_battlebumpers)) + { + if (G_BattleGametype() && player->kartstuff[k_bumper] > 0) + { + V_DrawMappedPatch(bumperx-2, Y, V_HUDTRANS|V_SNAPTOLEFT, kp_tinybumper[0], colormap); + for (j = 1; j < player->kartstuff[k_bumper]; j++) + { + bumperx += 5; + V_DrawMappedPatch(bumperx, Y, V_HUDTRANS|V_SNAPTOLEFT, kp_tinybumper[1], colormap); + } + } + } // A new level of stupidity: checking if lua is enabled to close a bracket. :Fascinating: + } + + if (i == strank) + V_DrawScaledPatch(FACE_X, Y, V_HUDTRANS|V_SNAPTOLEFT, kp_facehighlight[(leveltime / 4) % 8]); + + if (G_BattleGametype() && player->kartstuff[k_bumper] <= 0) + V_DrawScaledPatch(FACE_X-4, Y-3, V_HUDTRANS|V_SNAPTOLEFT, kp_ranknobumpers); + else + { + INT32 pos = player->kartstuff[k_position]; + if (pos < 0 || pos > MAXPLAYERS) + pos = 0; + // Draws the little number over the face + V_DrawScaledPatch(FACE_X-5, Y+10, V_HUDTRANS|V_SNAPTOLEFT, kp_facenum[pos]); + } + + Y += 18; + } + + return false; +} + +// +// HU_DrawTabRankings -- moved here to take advantage of kart stuff! +// +void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 hilicol) +{ + INT32 i, rightoffset = 240; + const UINT8 *colormap; + const INT32 dupadjust = cv_betainterscreen.value ? 314 : (vid.width/vid.dupx), duptweak = cv_betainterscreen.value ? -3 : (dupadjust - BASEVIDWIDTH)/2; + + boolean (*_isHighlightedPlayer)(const player_t *) = (demo.playback ? P_IsDisplayPlayer : P_IsLocalPlayer); + + //this function is designed for 9 or less score lines only + //I_Assert(scorelines <= 9); -- not today bitch, kart fixed it up + + V_DrawFill(1-duptweak, 26, dupadjust-2, 1, 0); // Draw a horizontal line because it looks nice! + if (scorelines > 8) + { + V_DrawFill(160, 26, 1, 147, 0); // Draw a vertical line to separate the two sides. + V_DrawFill(1-duptweak, 173, dupadjust-2, 1, 0); // And a horizontal line near the bottom. + rightoffset = (BASEVIDWIDTH/2) - 4 - x; + } + + for (i = 0; i < scorelines; i++) + { + char strtime[MAXPLAYERNAME+1]; + const UINT8 pnum = tab[i].num; + player_t *player = &players[pnum]; + + if (player->spectator || !player->mo) + continue; //ignore them. + + const boolean whiteplayer = _isHighlightedPlayer(player); + const INT32 philicol = (whiteplayer ? V_SkinColorToHighlightcolor(player->skincolor) : 0); + + if ((netgame && pnum != serverplayer) || (cv_mindelay.value && P_IsLocalPlayer(player))) + { + HU_drawPlayerPing(x + ((i < 8) ? -17 : rightoffset + 11), y-4, pnum, 0); + } + + STRBUFCPY(strtime, tab[i].name); + + if (scorelines > 8) + V_DrawThinString(x + 20, y, philicol|V_ALLOWLOWERCASE|V_6WIDTHSPACE, strtime); + else + V_DrawString(x + 20, y, philicol|V_ALLOWLOWERCASE, strtime); + + if (player->mo->color) + { + if (player->mo->colorized) + colormap = R_GetTranslationColormap(TC_RAINBOW, player->mo->color, GTC_CACHE); + else + colormap = R_GetTranslationColormap(player->skin, player->mo->color, GTC_CACHE); + + if (K_UseHighResPortraits()) + V_DrawSmallMappedPatch(x, y-4, 0, R_GetSkinFaceWant(player), colormap); + else + V_DrawMappedPatch(x, y-4, 0, R_GetSkinFaceRank(player), colormap); + + /*if (G_BattleGametype() && player->kartstuff[k_bumper] > 0) -- not enough space for this + { + INT32 bumperx = x+19; + V_DrawMappedPatch(bumperx-2, y-4, 0, kp_tinybumper[0], colormap); + for (j = 1; j < player->kartstuff[k_bumper]; j++) + { + bumperx += 5; + V_DrawMappedPatch(bumperx, y-4, 0, kp_tinybumper[1], colormap); + } + }*/ + } + + if (whiteplayer) + V_DrawScaledPatch(x, y-4, 0, kp_facehighlight[(leveltime / 4) % 8]); + + if (G_BattleGametype() && player->kartstuff[k_bumper] <= 0) + V_DrawScaledPatch(x-4, y-7, 0, kp_ranknobumpers); + else + { + INT32 pos = player->kartstuff[k_position]; + if (pos < 0 || pos > MAXPLAYERS) + pos = 0; + // Draws the little number over the face + V_DrawScaledPatch(x-5, y+6, 0, kp_facenum[pos]); + } + + if (G_RaceGametype()) + { +#define timestring(time) va("%i'%02i\"%02i", G_TicsToMinutes(time, true), G_TicsToSeconds(time), G_TicsToCentiseconds(time)) + if (scorelines > 8) + { + if (player->exiting) + V_DrawRightAlignedThinString(x+rightoffset, y-1, hilicol|V_6WIDTHSPACE, timestring(player->realtime)); + else if (player->pflags & PF_TIMEOVER) + V_DrawRightAlignedThinString(x+rightoffset, y-1, V_6WIDTHSPACE, "NO CONTEST."); + else if (circuitmap) + V_DrawRightAlignedThinString(x+rightoffset, y-1, V_6WIDTHSPACE, va("Lap %d", tab[i].count)); + } + else + { + if (player->exiting) + V_DrawRightAlignedString(x+rightoffset, y, hilicol, timestring(player->realtime)); + else if (player->pflags & PF_TIMEOVER) + V_DrawRightAlignedThinString(x+rightoffset, y-1, 0, "NO CONTEST."); + else if (circuitmap) + V_DrawRightAlignedString(x+rightoffset, y, 0, va("Lap %d", tab[i].count)); + } +#undef timestring + } + else + V_DrawRightAlignedString(x+rightoffset, y, 0, va("%u", tab[i].count)); + + y += 18; + if (i == 7) + { + y = 33; + x = (BASEVIDWIDTH/2) + 4; + } + } +} + +static boolean K_BigLap(void) +{ + return (cv_biglaps.value && (cv_numlaps.value > 9) && (K_UseColorHud() ? big_lap_color : big_lap) && (!stplyr->exiting)); +} + +static void K_drawKartLaps(void) +{ + const INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTOLEFT); + INT32 fx = 0, fy = 0, fflags = 0; // stuff for 3p / 4p splitscreen. + const boolean flipstring = splitscreen > 1 && stplyrnum & 1; // used for 3p or 4p + INT32 stringw = 0; // used with the above + const char *laps; + + drawinfo_t info; + K_getLapsDrawinfo(&info); + fx = info.x; + fy = info.y; + fflags = info.flags; + + laps = (stplyr->exiting ? "FIN" : va("%d/%d", stplyr->laps+1, cv_numlaps.value)); + + // draw stuff as god intended. + if (splitscreen > 1) + { + if (flipstring) + { + stringw = V_StringWidth(laps, 0); + + V_DrawScaledPatch(fx-stringw-13, fy, V_HUDTRANS|fflags, kp_splitlapflag); + V_DrawRightAlignedString(fx, fy+1, V_HUDTRANS|fflags, laps); + } + else // draw stuff NORMALLY. + { + V_DrawScaledPatch(fx, fy, V_HUDTRANS|fflags, kp_splitlapflag); + V_DrawString(fx+13, fy+1, V_HUDTRANS|fflags, laps); + } + } + else + { + if (K_UseColorHud()) // Colourized hud + { + UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); + patch_t *biglapclr = (K_BigLap() ? ((stplyr->laps + 1 > 9) ? kp_lapstickerbig2clr : kp_lapstickerbigclr) : kp_lapstickerclr); + V_DrawMappedPatch(fx, fy, V_HUDTRANS|splitflags, biglapclr, colormap); + } + else + { + patch_t *biglap = (K_BigLap() ? ((stplyr->laps + 1 > 9) ? kp_lapstickerbig2 : kp_lapstickerbig) : kp_lapsticker); + V_DrawScaledPatch(fx, fy, V_HUDTRANS|splitflags, biglap); + } + + V_DrawKartString(fx+33, fy+3, V_HUDTRANS|splitflags, laps); + } +} + +#ifdef ROTSPRITE + +#define DIALSPDDIV 97090 // 1.48148; converts 200 to 135 +#define MPHDIV 68283 // 1.04192; converts 141 to 135 + +static void K_DrawDialNum(INT32 x, INT32 y, boolean colorized, INT32 flags, INT32 num, INT32 digits, const UINT8 *colormap) +{ + INT32 w; + + if (colorized) + w = skp_dialnumclr[0]->width; + else + w = skp_dialnum[0]->width; + + if (flags & V_NOSCALESTART) + w *= vid.dupx; + + if (num < 0) + num = -num; + + // draw the number + do + { + x -= (w); + + if (colorized) + V_DrawFixedPatch(x << FRACBITS, y << FRACBITS, FRACUNIT, flags, skp_dialnumclr[num % 10], colormap); + else + V_DrawFixedPatch(x << FRACBITS, y << FRACBITS, FRACUNIT, flags, skp_dialnum[num % 10], colormap); + + num /= 10; + } while (--digits); +} + +static void K_DrawDialLaps(INT32 x, INT32 y, INT32 num, INT32 total, INT32 flags) +{ + INT32 fx; + fx = x + ((num < 10) ? 0 : 6); + V_DrawRankNum(fx, y, flags, num, (num < 10) ? 1 : 2, NULL); + V_DrawScaledPatch(fx + 2, y, flags, frameslash); + V_DrawRankNum(fx + 13 + ((total < 10) ? 0 : 6), y, flags, total, (total < 10) ? 1 : 2, NULL); +} + +static void K_DrawDialSpeedometer(fixed_t speed, + fixed_t divisor, + INT32 splitflags, + boolean battlemode, + boolean infoactive, + boolean colorized) +{ + const UINT8* colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); + + INT32 rot = 0; + const UINT8 infoidx = (infoactive) ? 1 : 0; + patch_t* dialpatch; + + const angle_t speedangle = + FixedAngle(((min(135 * FRACUNIT, FixedDiv(speed, divisor)) - (45 * FRACUNIT)))); + + rot = R_GetRollAngle(speedangle); + + if (rot) + { + dialpatch = W_CachePatchNameRotated("K_DSDIAL", rot, PU_PATCH); + } + else + { + dialpatch = W_CachePatchName("K_DSDIAL", PU_PATCH); + } + + if (colorized) // Colourized hud + { + V_DrawMappedPatch( + SPDM_X, SPDM_Y - 9, (V_HUDTRANS | splitflags), skp_dialbaseclr[infoidx], colormap); + V_DrawMappedPatch(SPDM_X, + SPDM_Y + 30, + V_HUDTRANS | splitflags, + skp_speedpatchesdialclr[cv_kartspeedometer.value], + colormap); + } + else + { + V_DrawScaledPatch(SPDM_X, SPDM_Y - 9, (V_HUDTRANS | splitflags), skp_dialbase[infoidx]); + V_DrawScaledPatch(SPDM_X, + SPDM_Y + 30, + V_HUDTRANS | splitflags, + skp_speedpatchesdial[cv_kartspeedometer.value]); + } + + K_DrawDialNum(SPDM_X + 10, + SPDM_Y + 25, + colorized, + V_HUDTRANS | splitflags, + speed / FRACUNIT, + 3, + colormap); + + // gotta center the dial manually + V_DrawMappedPatch(SPDM_X - 19, SPDM_Y + 15, (V_HUDTRANS | splitflags), (dialpatch), colormap); + + if (!infoactive) + { + // no need to draw info if we're not supposed to + return; + } + + // draw the info + if (battlemode) + { + if (stplyr->kartstuff[k_bumper] <= 0) + { + V_DrawMappedPatch( + SPDM_X + 28, SPDM_Y + 27, V_HUDTRANS | splitflags, kp_splitkarmabomb, colormap); + K_DrawDialLaps(SPDM_X + 46, + SPDM_Y + 29, + stplyr->kartstuff[k_comebackpoints], + 2, + V_HUDTRANS | splitflags); + } + else // the above doesn't need to account for weird stuff since the max amount of karma + // necessary is always 2 ^^^^ + { + V_DrawMappedPatch( + SPDM_X + 28, SPDM_Y + 27, V_HUDTRANS | splitflags, kp_rankbumper, colormap); + K_DrawDialLaps(SPDM_X + 46, + SPDM_Y + 29, + stplyr->kartstuff[k_bumper], + cv_kartbumpers.value, + V_HUDTRANS | splitflags); + } + } + else + { + V_DrawScaledPatch(SPDM_X + 28, SPDM_Y + 27, V_HUDTRANS | splitflags, kp_splitlapflag); + + if (stplyr->exiting) + V_DrawScaledPatch(SPDM_X + 39, SPDM_Y + 29, V_HUDTRANS | splitflags, skp_rankfinish); + else + K_DrawDialLaps(SPDM_X + 46, + SPDM_Y + 29, + stplyr->laps + 1, + cv_numlaps.value, + V_HUDTRANS | splitflags); + } +} + +#endif + +static void K_drawKartSpeedometer(void) +{ + // why? + if (cv_kartspeedometer.value == 0) + return; + + // index 0 is the raw value, index 1 is the converted value + fixed_t convSpeed[2] = {0,0}; +#ifdef ROTSPRITE + fixed_t dial_divisor = DIALSPDDIV; +#endif + + INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTOLEFT); + + // man. + const UINT8 speedostyle = K_GetSpeedometerStyle(); + + switch (cv_kartspeedometer.value) + { + case 1: + convSpeed[0] = FixedDiv(FixedMul(stplyr->speed, 142371), mapobjectscale); // 2.172409058 + convSpeed[1] = convSpeed[0] / FRACUNIT; + break; + case 2: + convSpeed[0] = FixedDiv(FixedMul(stplyr->speed, 88465), mapobjectscale); // 1.349868774 + convSpeed[1] = convSpeed[0] / FRACUNIT; +#ifdef ROTSPRITE + dial_divisor = MPHDIV; +#endif + break; + case 3: + convSpeed[0] = FixedDiv(stplyr->speed, mapobjectscale); + convSpeed[1] = convSpeed[0] / FRACUNIT; +#ifdef ROTSPRITE + dial_divisor = MPHDIV; +#endif + break; + case 4: + if (stplyr->mo) + { + convSpeed[0] = (FixedDiv(stplyr->speed, FixedMul(K_GetKartSpeed(stplyr, false), ORIG_FRICTION))*100); + convSpeed[1] = convSpeed[0] >> FRACBITS; + } + break; + default: + break; + } + + if (speedostyle == SPEEDO_VANILLA) + { + const char *metric = ""; + + switch (cv_kartspeedometer.value) + { + case 1: + metric = va("%3d km/h", convSpeed[1]); + break; + case 2: + metric = va("%3d mph", convSpeed[1]); + break; + case 3: + metric = va("%3d fu/t", convSpeed[1]); + break; + case 4: + // if extra.kart is found, use its included % symbol + if (!xtra_speedo) + metric = va("%4d P", convSpeed[1]); + else + metric = va("%4d %%", convSpeed[1]); + break; + default: + break; + } + + V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, metric); + } + else if (speedostyle == SPEEDO_EXTRA) // why bother if we dont? + { + if (K_UseColorSpeedo(SPEEDO_EXTRA)) //Colourized hud + { + UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); + V_DrawMappedPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_smallstickerclr, colormap); + } + else + V_DrawScaledPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_smallsticker); + + V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed[1], 3, NULL); + V_DrawScaledPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_speedpatches[cv_kartspeedometer.value]); + } + else if (speedostyle == SPEEDO_ACHII) // why bother if we dont? + { + if (K_UseColorSpeedo(SPEEDO_ACHII)) //Colourized hud + { + UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); + V_DrawMappedPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_smallstickerachiclr, colormap); + V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed[1], 3, NULL); + V_DrawMappedPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_speedpatchesachiclr[cv_kartspeedometer.value], colormap); + } + else + { + V_DrawScaledPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_smallstickerachi); + V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed[1], 3, NULL); + V_DrawScaledPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_speedpatchesachi[cv_kartspeedometer.value]); + } + } +#ifdef ROTSPRITE + else if (speedostyle == SPEEDO_DIAL) // why bother if we dont? + { + K_DrawDialSpeedometer(convSpeed[0], + dial_divisor, + splitflags, + (boolean)(G_BattleGametype()), + (LUA_HudEnabled(hud_gametypeinfo)), + (K_UseColorSpeedo(SPEEDO_DIAL))); + } +#endif + else if (speedostyle == SPEEDO_EXTRA3) // why bother if we dont? + { + if (K_UseColorSpeedo(SPEEDO_EXTRA3)) //Colourized hud + { + UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); + V_DrawStretchyFixedPatch((SPDM_X-1)<speed, mapobjectscale)/FRACUNIT; + + for (INT32 i = 0; i < 22; ++i) + { + if (fuspeed < speedIntervals[i]) + { + spdpatch = i; + break; + } + } + + if (((fuspeed < 57 && fuspeed > 54) || (fuspeed < 60 && fuspeed > 56) || (fuspeed > 59)) && (leveltime & 4)) + spdpatch = 24; + else if (((fuspeed < 57 && fuspeed > 54) || (fuspeed < 60 && fuspeed > 56) || (fuspeed > 59)) && !(leveltime & 4)) + spdpatch = 23; + + V_DrawScaledPatch(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, (speedostyle == SPEEDO_PMETER) ? kp_kartzspeedo[spdpatch] : kp_kartzspeedo_smol[spdpatch]); + } +} + +#ifdef ROTSPRITE +#undef DIALSPDDIV +#undef MPHDIV +#endif + +static void K_drawKartBumpersOrKarma(void) +{ + const UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); + INT32 fx, fy, fflags; + const boolean flipstring = splitscreen > 1 && stplyrnum & 1; // same as laps, used for splitscreen + INT32 stringw = 0; // used with the above + const char *bumpval = ""; + + drawinfo_t info; + K_getLapsDrawinfo(&info); + fx = info.x; + fy = info.y; + fflags = info.flags; + + if (cv_battlespeedo.value && !splitscreen) + { + const UINT8 speedostyle = K_GetSpeedometerStyle(); + + if ((speedostyle == SPEEDO_EXTRA) || (speedostyle == SPEEDO_ACHII) || (speedostyle == SPEEDO_EXTRA3)) + fy += 5; + else + fy += 7; + } + + if (splitscreen > 1) + { + if (stplyr->kartstuff[k_bumper] <= 0) + { + bumpval = va("%d/2", stplyr->kartstuff[k_comebackpoints]); + + if (flipstring) + fx -= 37; + V_DrawMappedPatch(fx, fy-1, V_HUDTRANS|fflags, kp_splitkarmabomb, colormap); + V_DrawString(fx+13, fy+1, V_HUDTRANS|fflags, bumpval); + } + else // the above doesn't need to account for weird stuff since the max amount of karma necessary is always 2 ^^^^ + { + bumpval = va("%d/%d", stplyr->kartstuff[k_bumper], cv_kartbumpers.value); + + if (flipstring) // for p2 and p4, assume we can have more than 10 bumpers. It's retarded but who knows. + { + stringw = V_StringWidth(bumpval, 0); + + V_DrawMappedPatch(fx-stringw-13, fy-1, V_HUDTRANS|fflags, kp_rankbumper, colormap); + V_DrawRightAlignedString(fx, fy+1, V_HUDTRANS|fflags, bumpval); + } + else // draw bumpers normally. + { + V_DrawMappedPatch(fx, fy-1, V_HUDTRANS|fflags, kp_rankbumper, colormap); + V_DrawString(fx+13, fy+1, V_HUDTRANS|fflags, bumpval); + } + } + } + else + { + patch_t *patch; + + if (stplyr->kartstuff[k_bumper] <= 0) + { + patch = (K_UseColorHud() ? kp_karmastickerclr : kp_karmasticker); + bumpval = va("%d/2", stplyr->kartstuff[k_comebackpoints]); + } + else + { + if (stplyr->kartstuff[k_bumper] > 9 && cv_kartbumpers.value > 9) + patch = (K_UseColorHud() ? kp_bumperstickerwideclr : kp_bumperstickerwide); + else + patch = (K_UseColorHud() ? kp_bumperstickerclr : kp_bumpersticker); + + bumpval = va("%d/%d", stplyr->kartstuff[k_bumper], cv_kartbumpers.value); + } + + V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, patch, colormap); + V_DrawKartString(fx+47, fy+3, V_HUDTRANS|fflags, bumpval); + } +} + +#define lerp(from, to) cv_uncappedhud.value ? from + FixedMul(rendertimefrac, to - from) : to + +// converts mobj coordinates into screen coordinates +// NOTE: use with V_NOSCALESTART! +// Code updated in Lua by GenericHeroGuy for libSG +// Badly ported to C by NepDisk and acutally made to work and fixed by Indev!(Thanks so much!) +// Badly uncapped in C by GenericHeroGuy +// original code by Lat' +static boolean K_GetScreenCoords(vector2_t *vec, player_t *player, mobj_t *target, fixed_t hofs, boolean dontclip) +{ + fixed_t y, x; + fixed_t targx, targy, targz; + + fixed_t dist; + fixed_t distfact; + fixed_t offset; + + fixed_t yres, xres; + fixed_t fov; + + // this should never happen but its also kart so ¯\_(ツ)_/¯ + if (!player || P_MobjWasRemoved(target)) + return false; + + targx = lerp(target->old_x, target->x); + targy = lerp(target->old_y, target->y); + targz = lerp(target->old_z, target->z); + + // X coordinate + // get difference between camangle and angle towards target + x = (INT32)viewangle - (INT32)R_PointToAngle(targx, targy); + + distfact = FINECOSINE((x>>ANGLETOFINESHIFT) & FINEMASK); + if (!distfact) distfact = 1; + + if (encoremode) + x = -x; + if (x < (fixed_t)ANGLE_270 || x > (fixed_t)ANGLE_90) + return false; + + xres = vid.width<<(FRACBITS-1); + yres = vid.height<<(FRACBITS-1); + fov = FixedDiv(xres, FINETANGENT(((FixedAngle(cv_fov.value/2)+ANGLE_90)>>ANGLETOFINESHIFT) & 4095)); + + // flipping + const boolean targflip = target->eflags & MFE_VERTICALFLIP; + const boolean srcflip = player->pflags & PF_FLIPCAM && player->mo->eflags & MFE_VERTICALFLIP; + + // Y coordinate + // getting the angle difference here is a bit more involved... + // start by getting the height difference between the camera and target + y = viewz - targz - (targflip ? ((target->height * 2) / 3) : 0); // for some reason needs to be divided by "1.5" idk + + if (hofs) + y = y - (targflip ? -hofs : hofs); + + // then get the distance between camera and target + dist = R_PointToDist(targx, targy); + +#ifdef HWRENDER + // NOW we can get the angle differnce + if (rendermode == render_opengl && !cv_glshearing.value) + { + angle_t yang = R_PointToAngle2(0, 0, dist, y); // not perspective + x = FixedMul(x, FINECOSINE((yang>>ANGLETOFINESHIFT) & FINEMASK)); // perspective + y = -aimingangle - FixedDiv(yang, distfact); + + if (y < (fixed_t)ANGLE_270 || y > (fixed_t)ANGLE_90) // clip points behind the camera + return false; + if (splitscreen == 1) // multiply by 1.25 for 2P splitscreen + y = y + (y/4) ; + if (srcflip) // flipcam + y = -y; + + y = FixedMul(FINETANGENT((((angle_t)(-y)+ANGLE_90)>>ANGLETOFINESHIFT) & 4095), fov) + yres; // project the angle to get our final Y coordinate + } + else +#endif + { + const fixed_t fovratio = FixedDiv(90*FRACUNIT, 180*FRACUNIT - FixedMul(cv_fov.value, 4*FRACUNIT/3)-FRACUNIT*-30); + + y = FixedDiv(y, FixedMul(dist, distfact)); + if (srcflip) + y = -y; // flipcam + if (y != INT32_MIN) // I_Error(): FixedDiv: divide by zero + y = FixedMul(FixedDiv(y, fovratio), xres) + yres; + //else print("NOPE!") + + offset = FixedMul(FINETANGENT(((aimingangle+ANGLE_90)>>ANGLETOFINESHIFT) & 4095), xres); + + // this isn't fovtan... what am i even doing anymore + if (splitscreen == 1) + offset = 17*offset/120; + + // thanks fickle + offset = FixedDiv(offset, fovratio); + if (srcflip) + offset = -offset; // flipcam + y = y + offset; + } + + // project the angle to get our final X coordinate + x = FixedMul(FINETANGENT(((x+ANGLE_90)>>ANGLETOFINESHIFT) & 4095), fov); + if (splitscreen == 1) // divide by 320/200 (1.6) on 2P splitscreen + x = (x/2) + (x/8); + x = x + xres; + + // now clip in screen-space + if (!dontclip && (x < 0 || x > xres*2 || y < 0 || y > yres*2)) + return false; + + // adjust coords for splitscreen + if (splitscreen == 1) // 2P + { + y = y>>1; + if (stplyrnum > 0) + y = y + yres; + } + if (splitscreen >= 2) // 3P or 4P + { + x = x>>1; + y = y>>1; + if (stplyrnum & 1) + x = x + xres; + if (stplyrnum >= 2) + y = y + yres; + } + + vec->y = y; + vec->x = x; + return true; +} + +//Slighty fixed by Alug and further rewritten by NepDisk +//Decided to port and highly modify sunflower version for the main nametag drawing with additions by NepDisk. My previous one was broken anyway due to the changed screencoords and noscalestart +static void K_drawNameTags(void) +{ + UINT8 i, j; + INT32 trans; + vector2_t pos = {0}; + fixed_t namex, namey; + int tagsdisplayed = 0; + fixed_t distance = 0; + fixed_t maxdistance = 0; + boolean flipped = false; + fixed_t z; + + char *tag; + patch_t *icon = NULL; + + INT32 dup; + UINT8 *cm = NULL; + UINT8 tagcolor = 0; + INT32 vflags = 0; + boolean usenametagrestat = false; + fixed_t tagwidthsmall; + fixed_t tagwidth; + + if (P_MobjWasRemoved(stplyr->mo) || (stplyr->spectator && !cv_shownametagspectator.value) || stplyr->exiting) + return; + + maxdistance = ((10*cv_nametagdist.value) * mapobjectscale); + + for (i = 0; i < MAXPLAYERS; i++) + { + distance = 0; + flipped = false; + + if (i > PLAYERSMASK) + continue; + if (players[i].spectator || !playeringame[i] || P_MobjWasRemoved(players[i].mo)) + continue; + if (i == displayplayers[stplyrnum] && !cv_showownnametag.value && !(leveltime < 130)) + continue; + if (i != displayplayers[stplyrnum] && leveltime < starttime) + continue; + if (players[i].kartstuff[k_hyudorotimer]) // player is invisible + continue; + if (maxdistance) + distance = R_PointToDist(players[i].mo->x, players[i].mo->y); + if (distance > maxdistance) + continue; + if (!P_CheckSightFast(stplyr->mo, players[i].mo)) + continue; + + z = players[i].mo->height; + + //Saltyhop hehe + z += lerp(players[i].mo->old_spriteyoffset, players[i].mo->spriteyoffset); + + if (!K_GetScreenCoords(&pos, stplyr, players[i].mo, z, false)) + continue; + + tagsdisplayed++; + + if (tagsdisplayed > cv_nametagmaxplayers.value) + break; + + trans = 0; + + switch (cv_nametagtrans.value) + { + case 1: + if (distance > (maxdistance*3/4)) + trans = V_60TRANS; + break; + case 2: + if (distance > (maxdistance*3/1)) + trans = V_90TRANS; + else if (distance > (maxdistance*3/2)) + trans = V_80TRANS; + else if (distance > (maxdistance*3/3)) + trans = V_60TRANS; + else if (distance > (maxdistance*3/4)) + trans = V_40TRANS; + else if (distance > (maxdistance*3/5)) + trans = V_20TRANS; + break; + case 3: + trans = V_40TRANS; + break; + case 4: + trans = V_LocalTransFlag(); + break; + case 0: + default: + break; + } + + namex = pos.x>>FRACBITS; + namey = pos.y>>FRACBITS; + + tag = va("%s%s ", HU_SkinColorToConsoleColor(players[i].mo->color), player_names[i]); + icon = R_GetSkinFaceMini(players[i].mo->player); + + dup = vid.dupx; + cm = R_GetTranslationColormap(players[i].skin, players[i].mo->color, GTC_CACHE); + tagcolor = colortranslations[players[i].mo->color][7]; + vflags = trans | V_NOSCALESTART; + usenametagrestat = ((cv_nametagrestat.value == 1 && (players[i].kartspeed != skins[players[i].skin].kartspeed || players[i].kartweight != skins[players[i].skin].kartweight)) || cv_nametagrestat.value == 2); + tagwidthsmall = cv_smallnametags.value ? V_SmallStringWidth(player_names[i], V_ALLOWLOWERCASE) : V_ThinStringWidth(player_names[i], V_ALLOWLOWERCASE); + tagwidth = dup*tagwidthsmall; + + // If flipcam is on, other player is flipped relative to us when we have different + // verticalflip flag value. Otherwise, they are simply flipped when verticalflip flag says so + if ((stplyr->pflags & PF_FLIPCAM) && (stplyr->mo->eflags & MFE_VERTICALFLIP)) + flipped = (players[i].mo->eflags & MFE_VERTICALFLIP) != (stplyr->mo->eflags & MFE_VERTICALFLIP); + else + flipped = players[i].mo->eflags & MFE_VERTICALFLIP; + + if (cv_smallnametags.value || !nametaggfx) + { + if (flipped) + namey += dup*5; + else // small offset + namey -= dup*3; + + if (nametaggfx && cv_smallnametags.value == 1) + { + if (cv_nametagfacerank.value) + tagwidthsmall += icon->width - dup; + + // Have to draw the nametag using patches here since drawfill can't draw at this scale... + if (!flipped) + V_DrawFixedPatch(namex<height/2)<width/2); // add offset to other stuff + } + + //Name + V_DrawSmallString(namex, namey, V_ALLOWLOWERCASE | vflags, tag); + + if (usenametagrestat) + { + V_DrawSmallString(namex, namey - dup*5, vflags, va("\x84S%d ", players[i].kartspeed)); + V_DrawSmallString(namex + dup*10, namey - dup*5, vflags, va("\x87W%d ", players[i].kartweight)); + } + + if (cv_nametagscore.value) + { + INT32 yofs = usenametagrestat ? 10 : 5; + V_DrawSmallString(namex, namey - dup*yofs, V_ALLOWLOWERCASE | vflags, va("\x8A%d ", players[i].score)); + } + } + else + { + if (cv_nametagfacerank.value) + tagwidth += dup*(icon->width+1); + + if (flipped) + { + for (j = 0; j < 4; j++) + { + V_DrawFill(namex, namey, dup*3, dup*4, 31 | vflags); + V_DrawFill(namex+dup, namey, dup, dup*4, tagcolor | vflags); + namey += dup*4; + namex += dup; + } + namey -= dup*3; + V_DrawFill(namex, namey+dup*2, dup, dup, 31 | vflags); // a single black pixel + V_DrawFill(namex+dup, namey, tagwidth, dup*3, 31 | vflags); + V_DrawFill(namex+dup, namey+dup, tagwidth - dup, dup, tagcolor | vflags); + namex += dup*2; + } + else + { + for (j = 0; j < 4; j++) + { + namey -= dup*4; + V_DrawFill(namex, namey, dup*3, dup*4, 31 | vflags); + V_DrawFill(namex+dup, namey, dup, dup*4, tagcolor | vflags); + namex += dup; + } + + V_DrawFill(namex, namey, dup, dup, 31 | vflags); + V_DrawFill(namex+dup, namey, tagwidth - dup*2, dup*3, 31 | vflags); + V_DrawFill(namex+dup, namey+dup, tagwidth - dup*3, dup, tagcolor | vflags); + } + + if (cv_nametagfacerank.value) + { + V_DrawMappedPatch(namex, namey - dup*(icon->height+1), vflags, icon, cm); + namex += dup*(icon->height+1); // add offset to other stuff + } + + V_DrawThinString(namex, namey - dup*10, V_ALLOWLOWERCASE | vflags, tag); + + if (usenametagrestat) + { + V_DrawScaledPatch(namex, namey - dup*20, vflags, nametagspeed); + V_DrawScaledPatch(namex + dup*18, namey - dup*20, vflags, nametagweight); + V_DrawString(namex + dup*9, namey - dup*19, V_ALLOWLOWERCASE | vflags, va("\x84%d ", players[i].kartspeed)); + V_DrawString(namex + dup*27, namey - dup*19, V_ALLOWLOWERCASE | vflags, va("\x87%d ", players[i].kartweight)); + } + + if (cv_nametagscore.value) + { + INT32 yofs = usenametagrestat ? 25 : 15; + V_DrawSmallString(namex, namey - dup*yofs, V_ALLOWLOWERCASE | vflags, va("\x8A%d ", players[i].score)); + } + } + } +} + +// Based on Driftgauge refactor by GenericHeroGuy ported from lua and expanded by NepDisk +static void K_drawDriftGauge(void) +{ + vector2_t pos = {0}; + fixed_t basex, basey; + const int dup = vid.dupx; + int i; + UINT8 *cmap; + + static const UINT8 driftcolors[3][4] = { + {0, 0, 10, 16}, // no drift + {215, 215, 204, 253}, // blue + {125, 125, 151, 159} // red + }; + + static const UINT8 driftskins[3] = { + SKINCOLOR_NONE, + SKINCOLOR_TEAL, + SKINCOLOR_SALMON, + }; + + static UINT8 driftrainbow[18] = { + 0, 31, 47, 63, 79, 95, 111, 119, 127, 143, 159, 175, 183, 191, 199, 207, 223, 247 + }; + + if (camera[stplyrnum].freecam) + return; + + if (!splitscreen && !camera->chase) + return; + + if (forceshowhud) + goto skipcrap; // i will skip the drift early return and you cant stop me! + + if (!stplyr->kartstuff[k_drift]) + return; + +skipcrap: + + if (P_MobjWasRemoved(stplyr->mo)) + return; + + if (!K_GetScreenCoords(&pos, stplyr, stplyr->mo, FixedMul(cv_driftgaugeofs.value, cv_driftgaugeofs.value > 0 ? stplyr->mo->scale : mapobjectscale), false)) + return; + + fixed_t barx; + fixed_t bary; + INT32 BAR_WIDTH; + + const INT32 driftval = K_GetKartDriftSparkValue(stplyr); + const INT32 driftcharge = min(driftval*4, stplyr->kartstuff[k_driftcharge]); + const INT32 driftlevel = min(driftcharge / driftval, 2); + const INT32 drifttrans = ((cv_driftgaugetrans.value) ? V_LocalTransFlag() : 0); + + basex = pos.x>>FRACBITS; + basey = pos.y>>FRACBITS; + + switch (cv_driftgaugestyle.value) + { + case 1: + case 2: + case 3: + case 5: + { + if (!driftgaugegfx) + break; + + const boolean usescaledpatch = (cv_driftgaugestyle.value == 5 && xtra_speedo3); + + if (cv_driftgaugestyle.value == 1 || cv_driftgaugestyle.value == 3 || usescaledpatch) + { + barx = basex - dup*23; + BAR_WIDTH = dup*47; + } + else + { + barx = basex - dup*12; + BAR_WIDTH = dup*23; + } + + bary = basey - dup*2; + + if (usescaledpatch) // i hate hud code i hate hud code i hate hud code i hate hud code i hate hud code..... + { + if (K_UseColorSpeedo(SPEEDO_EXTRA3)) // Colourized hud + { + UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); + V_DrawStretchyFixedPatch((basex - dup*30)<= driftval*4) // rainbow sparks + { + cmap = R_GetTranslationColormap(TC_RAINBOW, 1 + leveltime % (MAXSKINCOLORS-1),GTC_CACHE); + + for (i = 0; i < 4; i++) + V_DrawFill(barx, bary+dup*1+dup*i, BAR_WIDTH, dup, (driftrainbow[min((leveltime % 18) + 1, 18 - 1)] + i*2) | V_NOSCALESTART|drifttrans); + } + else // none/blue/red + { + const INT32 limit = (driftval * (driftcharge >= driftval*2 ? 2 : 1)); + const INT32 width = ((driftcharge - (driftcharge >= driftval ? limit : 0)) * BAR_WIDTH) / limit; + + cmap = R_GetTranslationColormap(TC_RAINBOW, driftskins[driftlevel],GTC_CACHE); + + for (i = 0; i < 4; i++) + { + if (driftcharge >= driftval) + V_DrawFill(barx, bary+dup*1+dup*i, BAR_WIDTH, dup, driftcolors[driftlevel-1][i] | V_NOSCALESTART|drifttrans); + + V_DrawFill(barx, bary+dup*1+dup*i, width, dup, driftcolors[driftlevel][i] | V_NOSCALESTART|drifttrans); + } + } + + // right, also draw a cool number + //SG_DrawPaddedNum(v, basex + (dup*32), basey, driftcharge*100 / driftval, 3, "PINGN", V_NOSCALESTART|V_OFFSET|drifttrans, cmap) + if (cv_driftgaugestyle.value == 3) + V_DrawPaddedTallColorNum(basex + (dup*32), basey, V_NOSCALESTART|V_OFFSET|drifttrans, driftcharge*100 / driftval, 3, cmap); + else + V_DrawPingNum(cv_driftgaugestyle.value == 2 ? basex + (dup*22) : basex + (dup*32), basey, V_NOSCALESTART|V_OFFSET|drifttrans, driftcharge*100 / driftval, cmap); + } + break; + case 4: + { + cmap = R_GetTranslationColormap(TC_RAINBOW, driftskins[driftlevel],GTC_CACHE); + + if (driftcharge >= driftval*4) + cmap = R_GetTranslationColormap(TC_RAINBOW, 1 + leveltime % (MAXSKINCOLORS-1),GTC_CACHE); + + V_DrawPaddedTallColorNum(basex + (dup*16), basey, V_NOSCALESTART|V_OFFSET|drifttrans, driftcharge*100 / driftval, 3, cmap); + } + break; + default: + break; + } +} + +static fixed_t K_FindCheckX(fixed_t px, fixed_t py, angle_t ang, fixed_t mx, fixed_t my) +{ + fixed_t dist, x; + fixed_t range = RING_DIST/3; + angle_t diff; + + range *= gamespeed+1; + + dist = abs(R_PointToDist2(px, py, mx, my)); + if (dist > range) + return -BASEVIDWIDTH; + + diff = R_PointToAngle2(px, py, mx, my) - ang; + + if (diff < ANGLE_90 || diff > ANGLE_270) + return -BASEVIDWIDTH; + else + x = (FixedMul(FINETANGENT(((diff+ANGLE_90)>>ANGLETOFINESHIFT) & 4095), 160<>FRACBITS; + + if (encoremode) + x = BASEVIDWIDTH-x; + + if (splitscreen > 1) + x /= 2; + + return x; +} + +static void K_drawKartWanted(void) +{ + UINT8 i, numwanted = 0; + UINT8 *colormap = NULL; + INT32 basex = 0, basey = 0; + + if (stplyrnum != 0) + return; + + for (i = 0; i < 4; i++) + { + if (battlewanted[i] == -1) + break; + numwanted++; + } + + if (numwanted <= 0) + return; + + // set X/Y coords depending on splitscreen. + if (splitscreen < 3) // 1P and 2P use the same code. + { + basex = WANT_X; + basey = WANT_Y; + if (splitscreen == 2) + { + basey += 16; // slight adjust for 3P + basex -= 6; + } + } + else if (splitscreen == 3) // 4P splitscreen... + { + basex = BASEVIDWIDTH/2 - (kp_wantedsplit->width/2); // center on screen + basey = BASEVIDHEIGHT - 55; + //basey2 = 4; + } + + if (battlewanted[0] != -1) + colormap = R_GetTranslationColormap(0, players[battlewanted[0]].skincolor, GTC_CACHE); + + V_DrawFixedPatch(basex< 1 ? kp_wantedsplit : kp_wanted), colormap); + /*if (basey2) + V_DrawFixedPatch(basex< 1 ? 13 : 8), y = basey+(splitscreen > 1 ? 16 : 21); + fixed_t scale = FRACUNIT/2; + + if (battlewanted[i] == -1) + break; + + player_t *p = &players[battlewanted[i]]; + + if (numwanted == 1) + scale = FRACUNIT; + else + { + if (i & 1) + x += 16; + if (i > 1) + y += 16; + } + + if (p->skincolor) + { + colormap = R_GetTranslationColormap(TC_RAINBOW, p->skincolor, GTC_CACHE); + V_DrawFixedPatch(x<skin] : facerankprefix[p->skin]), colormap);*/ + } + } +} + +static void K_drawKartPlayerCheck(void) +{ + INT32 i; + UINT8 *colormap; + INT32 x; + + const INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM); + + if (!stplyr->mo || stplyr->spectator) + return; + + if (stplyr->awayviewtics) + return; + + if (camspin[0]) + return; + + for (i = 0; i < MAXPLAYERS; i++) + { + UINT8 pnum = 0; + + if (&players[i] == stplyr) + continue; + if (!playeringame[i] || players[i].spectator) + continue; + if (!players[i].mo) + continue; + + if ((players[i].kartstuff[k_invincibilitytimer] <= 0) && (leveltime & 2)) + pnum++; // white frames + + if (players[i].kartstuff[k_itemtype] == KITEM_GROW || players[i].kartstuff[k_growshrinktimer] > 0) + pnum += 4; + else if (players[i].kartstuff[k_itemtype] == KITEM_INVINCIBILITY || players[i].kartstuff[k_invincibilitytimer]) + pnum += 2; + + x = K_FindCheckX(stplyr->mo->x, stplyr->mo->y, stplyr->mo->angle, players[i].mo->x, players[i].mo->y); + if (x <= 320 && x >= 0) + { + if (x < 14) + x = 14; + else if (x > 306) + x = 306; + + colormap = R_GetTranslationColormap(TC_DEFAULT, players[i].mo->color, GTC_CACHE); + V_DrawMappedPatch(x, CHEK_Y, V_HUDTRANS|splitflags, kp_check[pnum], colormap); + } + } +} + +static boolean K_useSmallMinimapHead(player_t *player) +{ + return cv_minihead.value == 1 || (cv_minihead.value == 2 && !(player && P_IsDisplayPlayer(player))); +} + +static void K_drawKartMinimapIcon(fixed_t objx, fixed_t objy, INT32 hudx, INT32 hudy, INT32 flags, INT32 blend, patch_t *icon, UINT8 *colormap, drawinfo_t *dims, boolean scaleme) +{ + // amnum xpos & ypos are the icon's speed around the HUD. + // The number being divided by is for how fast it moves. + // The higher the number, the slower it moves. + + // am xpos & ypos are the icon's starting position. Withouht + // it, they wouldn't 'spawn' on the top-right side of the HUD. + + fixed_t amnumxpos, amnumypos; + INT32 amxpos, amypos; + fixed_t scale = FRACUNIT; + patch_t *AutomapPic; + INT16 w, h; + + AutomapPic = minimapinfo.minimap_pic; + + if (AutomapPic == NULL) + { + return; // no pic, just get outta here + } + + amnumxpos = (FixedMul(objx, minimapinfo.zoom) - minimapinfo.offs_x); + amnumypos = -(FixedMul(objy, minimapinfo.zoom) - minimapinfo.offs_y); + + if (encoremode) + amnumxpos = -amnumxpos; + + if (dims && (dims->x != 0) && (dims->y != 0)) + { + w = dims->x; + h = dims->y; + } + else + { + w = icon->width; + h = icon->height; + } + + amxpos = amnumxpos + ((hudx + (AutomapPic->width-w)/2)<height-h)/2)<player; + const boolean skinlocal = mo->skinlocal; + + fixed_t amnumxpos, amnumypos; + INT32 amxpos, amypos, wntdamxpos, wntdamypos; + fixed_t scale = FRACUNIT; + patch_t *minimaphead = NULL; + boolean minihead = K_useSmallMinimapHead(mo->player); + +#ifdef ROTSPRITE + angle_t rollangle = 0; + INT32 rot = 0; +#endif + + skin = K_GetMobjSkin(mo); + minimaphead = (skinlocal ? localfacemmapprefix : facemmapprefix)[K_GetMobjSkinNum(skin, skinlocal)]; + + amnumxpos = (FixedMul(lerp(mo->old_x, mo->x), minimapinfo.zoom) - minimapinfo.offs_x); + amnumypos = -(FixedMul(lerp(mo->old_y, mo->y), minimapinfo.zoom) - minimapinfo.offs_y); + + if (encoremode) + amnumxpos = -amnumxpos; + + amxpos = amnumxpos + ((x + (minimapinfo.minimap_pic->width-minimaphead->width) / 2)<height-minimaphead->height) / 2)<color), player_names[player - players]); + } + + + // thx wanted reticle for having weird offsets very cool + wntdamxpos = minihead ? amxpos + (1<width / 4)<height / 4)<spinoutrot) + { + // Rotate counterclockwise. + rollangle = FixedAngle(player->spinoutrot * -1); + rot = R_GetRollAngle(rollangle); + + if (rot) + { + minimaphead = W_CachePatchNameRotated(skin->facemmap, rot, PU_PATCH); + } + } +#endif + + if (!mo->color) // 'default' color + V_DrawSciencePatch(amxpos, amypos, flags, minimaphead, scale); + else + { + UINT8 *colormap; + + if (mo->colorized) + colormap = R_GetTranslationColormap(TC_RAINBOW, mo->color, GTC_CACHE); + else + colormap = R_GetLocalTranslationColormap(mo->skin, mo->localskin, mo->color, GTC_CACHE, skinlocal); + + V_DrawFixedPatch(amxpos, amypos, scale, flags, minimaphead, colormap); + + if (player + && ((G_RaceGametype() && player->kartstuff[k_position] == spbplace) + || (G_BattleGametype() && K_IsPlayerWanted(player)))) + { + V_DrawFixedPatch(wntdamxpos, wntdamypos, scale, flags, kp_wantedreticle, NULL); + } + } +} + +enum +{ + MINIANGLE_NONE = 0, + MINIANGLE_DOT, + MINIANGLE_LIGHT +}; + +static void K_drawKartMinimap(void) +{ + INT32 i = 0; + INT32 x, y; + INT32 minimaptrans, splitflags; + SINT8 localplayers[MAXSPLITSCREENPLAYERS]; + SINT8 numlocalplayers = 0; + patch_t *AutomapPic; + + // Draw the HUD only when playing in a level. + // hu_stuff needs this, unlike st_stuff. + if (gamestate != GS_LEVEL) + return; + + // Only draw for the first player + if (stplyrnum != 0) + return; + + AutomapPic = minimapinfo.minimap_pic; + + if (AutomapPic == NULL) + { + return; // no pic, just get outta here + } + + minimaptrans = K_getMinimapTrans(); + + // Exit early if it wouldn't draw anyway. + if (minimaptrans == -1) + return; + + drawinfo_t info; + K_getMinimapDrawinfo(&info); + x = info.x - (AutomapPic->width/2); + y = info.y - (AutomapPic->height/2); + splitflags = info.flags; + + splitflags |= minimaptrans; + + if (encoremode) + V_DrawScaledPatch(x+AutomapPic->width, y, splitflags|V_FLIP, AutomapPic); + else + V_DrawScaledPatch(x, y, splitflags, AutomapPic); + + if (!(splitscreen == 2)) + { + splitflags &= ~minimaptrans; + splitflags |= V_HUDTRANSHALF; + } + + // let offsets transfer to the heads, too! + if (encoremode) + x += AutomapPic->leftoffset; + else + x -= AutomapPic->leftoffset; + y -= AutomapPic->topoffset; + + // initialize + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + localplayers[i] = -1; + + // Player's tiny icons on the Automap. (drawn opposite direction so player 1 is drawn last in splitscreen) + if (ghosts) + { + demoghost *g = ghosts; + while (g) + { + K_drawKartMinimapHead(g->mo, x, y, splitflags); + g = g->next; + } + + if (!stplyr->mo || stplyr->spectator) // do we need the latter..? + return; + + localplayers[numlocalplayers++] = stplyr-players; + } + else + { + for (i = MAXPLAYERS-1; i >= 0; i--) + { + if (!playeringame[i]) + continue; + + if (!players[i].mo || players[i].spectator) + continue; + + if (P_IsDisplayPlayer(&players[i])) + { + // Draw display players on top of everything else + localplayers[numlocalplayers++] = i; + continue; + } + + // Now we know it's not a display player, handle non-local player exceptions. + if (G_BattleGametype() && players[i].kartstuff[k_bumper] <= 0) + continue; + + if (players[i].kartstuff[k_hyudorotimer] > 0) + { + if (!((players[i].kartstuff[k_hyudorotimer] < 1*TICRATE/2 + || players[i].kartstuff[k_hyudorotimer] > hyudorotime-(1*TICRATE/2)) + && !(leveltime & 1))) + continue; + } + + K_drawKartMinimapHead(players[i].mo, x, y, splitflags); + } + } + + // draw our local players here, opaque. + splitflags &= ~V_HUDTRANSHALF; + splitflags |= V_HUDTRANS; + + const SINT8 icondotradius = ((cv_minihead.value == 1) && !cv_showminimapnames.value) ? 8 : 10; + patch_t* minipatch; + INT32 rot; + INT32 blending; + + for (i = 0; i < numlocalplayers; i++) + { + if (localplayers[i] == -1) + continue; // this doesn't interest us + + mobj_t *mobj = players[localplayers[i]].mo; + + // dont draw for no contestants + boolean playertimedout = (mobj->health <= 0 && players[localplayers[i]].pflags & PF_TIMEOVER); + + if (cv_showminimapangle.value && (minidoticon || minilighticon) && !playertimedout) + { + UINT8 *colormap; + drawinfo_t dims; + fixed_t interpx, interpy; + fixed_t xoff = 0, yoff = 0; + blending = 0; + + angle_t ang = R_InterpolateAngle(mobj->old_angle, mobj->angle); + + if (encoremode) + ang = ANGLE_180 - ang; + + if (mobj->colorized) + colormap = R_GetTranslationColormap(TC_RAINBOW, mobj->color, GTC_CACHE); + else + colormap = R_GetLocalTranslationColormap(mobj->skin, mobj->localskin, mobj->color, GTC_CACHE, mobj->skinlocal); + + interpx = lerp(mobj->old_x, mobj->x); + interpy = lerp(mobj->old_y, mobj->y); + + minipatch = kp_minimapdot; + + dims.x = 0; + dims.y = 0; + + if (cv_showminimapangle.value == MINIANGLE_DOT) + { + xoff = FixedMul(FCOS(ang), icondotradius); + yoff = -FixedMul(FSIN(ang), icondotradius); + } + else if (cv_showminimapangle.value == MINIANGLE_LIGHT) + { + rot = R_GetRollAngle(ang); + minipatch = W_CachePatchNameRotated("MMAPHDLT", rot, PU_PATCH); + + blending = B_ADD; + xoff = yoff = 0; + + dims.x = 48; + dims.y = 24; + } + + K_drawKartMinimapIcon( + interpx, + interpy, + x + xoff, + y + yoff, + splitflags, + blending, + minipatch, + colormap, + &dims, + false + ); + } + + // draw the minimap head after the nonsense above + K_drawKartMinimapHead(mobj, x, y, splitflags); + } +} + +#undef lerp + +static void K_drawKartStartCountdown(void) +{ + INT32 pnum = 0, splitflags = K_calcSplitFlags(0); // 3 + + if (leveltime >= starttime-(2*TICRATE)) // 2 + pnum++; + if (leveltime >= starttime-TICRATE) // 1 + pnum++; + if (leveltime >= starttime) // GO! + pnum++; + if ((leveltime % (2*5)) / 5) // blink + pnum += 4; + if (splitscreen) // splitscreen + pnum += 8; + + V_DrawScaledPatch(STCD_X - (kp_startcountdown[pnum]->width/2), STCD_Y - (kp_startcountdown[pnum]->height/2), splitflags, kp_startcountdown[pnum]); +} + +static void K_drawKartFinish(void) +{ + INT32 pnum = 0, splitflags = K_calcSplitFlags(0); + + if (!stplyr->kartstuff[k_cardanimation] || stplyr->kartstuff[k_cardanimation] >= 2*TICRATE) + return; + + if ((stplyr->kartstuff[k_cardanimation] % (2*5)) / 5) // blink + pnum = 1; + + if (splitscreen > 1) // 3/4p, stationary FIN + { + pnum += 2; + V_DrawScaledPatch(STCD_X - (kp_racefinish[pnum]->width/2), STCD_Y - (kp_racefinish[pnum]->height/2), splitflags, kp_racefinish[pnum]); + return; + } + + //else -- 1/2p, scrolling FINISH + { + INT32 x, xval; + + if (splitscreen) // wide splitscreen + pnum += 4; + + x = ((vid.width<width<kartstuff[k_cardanimation])< x ? xval : x))/TICRATE; + + if (splitscreen && stplyrnum == 1) + x = -x; + + V_DrawFixedPatch(x + (STCD_X<>1), + (STCD_Y<height<<(FRACBITS-1)), + FRACUNIT, + splitflags, kp_racefinish[pnum], NULL); + } +} + +static void K_drawBattleFullscreen(void) +{ + INT32 cardanim = stplyr->kartstuff[k_cardanimation] << FRACBITS; + + // fill in the fractional bits + if (cardanim && cardanim != 164*FRACUNIT) + { + INT32 frac = R_GetHudUncap() * ((164 - stplyr->kartstuff[k_cardanimation])/8 + 1); + if (stplyr->exiting) + cardanim += frac; + else + cardanim += stplyr->kartstuff[k_comebacktimer] < 6*TICRATE ? -frac : frac; + } + + INT32 x = BASEVIDWIDTH/2; + INT32 y = (-64*FRACUNIT) + cardanim; // card animation goes from 0 to 164, 164 is the middle of the screen + INT32 splitflags = V_SNAPTOTOP; // I don't feel like properly supporting non-green resolutions, so you can have a misuse of SNAPTO instead + fixed_t scale = FRACUNIT; + boolean drawcomebacktimer = true; // lazy hack because it's cleaner in the long run. + + if (!LUA_HudEnabled(hud_battlecomebacktimer)) + drawcomebacktimer = false; + + if (splitscreen) + { + if ((splitscreen == 1 && stplyrnum == 1) || (splitscreen > 1 && stplyrnum & 2)) + { + y = (232*FRACUNIT) - (cardanim/2); + splitflags = V_SNAPTOBOTTOM; + } + else + y = (-32*FRACUNIT) + (cardanim/2); + + if (splitscreen > 1) + { + scale /= 2; + + if (stplyrnum & 1) + x = 3*BASEVIDWIDTH/4; + else + x = BASEVIDWIDTH/4; + } + else + { + if (stplyr->exiting) + { + if (stplyrnum == 1) + x = BASEVIDWIDTH-96; + else + x = 96; + } + else + scale /= 2; + } + } + + if (stplyr->exiting) + { + if (stplyrnum == 0) + V_DrawFadeScreen(0xFF00, 16); + if (stplyr->exiting < 6*TICRATE && !stplyr->spectator) + { + if (stplyr->kartstuff[k_position] == 1) + V_DrawFixedPatch(x<kartstuff[k_bumper] <= 0 && stplyr->kartstuff[k_comebacktimer] && comeback && !stplyr->spectator && drawcomebacktimer) + { + UINT16 t = stplyr->kartstuff[k_comebacktimer]/(10*TICRATE); + INT32 txoff, adjust = (splitscreen > 1) ? 4 : 6; // normal string is 8, kart string is 12, half of that for ease + INT32 ty = (BASEVIDHEIGHT/2)+66; + + txoff = adjust; + + while (t) + { + txoff += adjust; + t /= 10; + } + + if (splitscreen) + { + if (splitscreen > 1) + ty = (BASEVIDHEIGHT/4)+33; + if ((splitscreen == 1 && stplyrnum == 1) || (splitscreen > 1 && stplyrnum & 2)) + ty += (BASEVIDHEIGHT/2); + } + else + V_DrawFadeScreen(0xFF00, 16); + + if (!comebackshowninfo) + V_DrawFixedPatch(x< 1) + V_DrawString(x-txoff, ty, 0, va("%d", stplyr->kartstuff[k_comebacktimer]/TICRATE)); + else + { + if (K_UseColorHud()) // Colourized hud + { + UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); + V_DrawFixedPatch(x<kartstuff[k_comebacktimer]/TICRATE)); + } + } + + if (netgame && !stplyr->spectator && timeinmap > 113) // FREE PLAY? + { + UINT8 i; + + // check to see if there's anyone else at all + for (i = 0; i < MAXPLAYERS; i++) + { + if (i == displayplayers[0]) + continue; + if (playeringame[i] && !stplyr->spectator) + return; + } + + if (LUA_HudEnabled(hud_freeplay)) + K_drawKartFreePlay(leveltime); + } +} + +static void K_drawKartFirstPerson(void) +{ + static INT32 pnum[4], turn[4], drift[4]; + INT32 pn = 0, tn = 0, dr = 0; + INT32 target = 0, splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM); + INT32 x = BASEVIDWIDTH/2, y = BASEVIDHEIGHT; + fixed_t scale; + UINT8 *colmap = NULL; + ticcmd_t *cmd = &stplyr->cmd; + + if (stplyr->spectator || !stplyr->mo || (stplyr->mo->flags2 & MF2_DONTDRAW)) + return; + + pn = pnum[stplyrnum]; + tn = turn[stplyrnum]; + dr = drift[stplyrnum]; + + if (splitscreen) + { + y >>= 1; + if (splitscreen > 1) + x >>= 1; + } + + { + if (stplyr->speed < (20*stplyr->mo->scale) && (leveltime & 1) && !splitscreen) + y++; + // the following isn't EXPLICITLY right, it just gets the result we want, but i'm too lazy to look up the right way to do it + if (stplyr->mo->flags2 & MF2_SHADOW) + splitflags |= FF_TRANS80; + else if (stplyr->mo->frame & FF_TRANSMASK) + splitflags |= (stplyr->mo->frame & FF_TRANSMASK); + } + + if (cmd->driftturn > 400) // strong left turn + target = 2; + else if (cmd->driftturn < -400) // strong right turn + target = -2; + else if (cmd->driftturn > 0) // weak left turn + target = 1; + else if (cmd->driftturn < 0) // weak right turn + target = -1; + else // forward + target = 0; + + if (encoremode) + target = -target; + + if (pn < target) + pn++; + else if (pn > target) + pn--; + + if (pn < 0) + splitflags |= V_FLIP; // right turn + + target = abs(pn); + if (target > 2) + target = 2; + + x <<= FRACBITS; + y <<= FRACBITS; + + if (tn != cmd->driftturn/50) + tn -= (tn - (cmd->driftturn/50))/8; + + if (dr != stplyr->kartstuff[k_drift]*16) + dr -= (dr - (stplyr->kartstuff[k_drift]*16))/8; + + if (splitscreen == 1) + { + scale = (2*FRACUNIT)/3; + y += FRACUNIT/(vid.dupx < vid.dupy ? vid.dupx : vid.dupy); // correct a one-pixel gap on the screen view (not the basevid view) + } + else if (splitscreen) + scale = FRACUNIT/2; + else + scale = FRACUNIT; + + if (stplyr->mo) + { + INT32 dsone = K_GetKartDriftSparkValue(stplyr); + INT32 dstwo = dsone*2; + INT32 dsthree = dstwo*2; + +#ifndef DONTLIKETOASTERSFPTWEAKS + { + const angle_t ang = R_PointToAngle2(0, 0, stplyr->rmomx, stplyr->rmomy) - stplyr->frameangle; + // yes, the following is correct. no, you do not need to swap the x and y. + fixed_t xoffs = -P_ReturnThrustY(stplyr->mo, ang, (BASEVIDWIDTH<<(FRACBITS-2))/2); + fixed_t yoffs = -(P_ReturnThrustX(stplyr->mo, ang, 4*FRACUNIT) - 4*FRACUNIT); + + if (splitscreen) + xoffs = FixedMul(xoffs, scale); + + xoffs -= (tn)*scale; + xoffs -= (dr)*scale; + + if (stplyr->frameangle == stplyr->mo->angle) + { + const fixed_t mag = FixedDiv(stplyr->speed, 10*stplyr->mo->scale); + + if (mag < FRACUNIT) + { + xoffs = FixedMul(xoffs, mag); + if (!splitscreen) + yoffs = FixedMul(yoffs, mag); + } + } + + if (stplyr->mo->momz > 0) // TO-DO: Draw more of the kart so we can remove this if! + yoffs += stplyr->mo->momz/3; + + if (encoremode) + x -= xoffs; + else + x += xoffs; + if (!splitscreen) + y += yoffs; + } + + // drift sparks! + if ((leveltime & 1) && (stplyr->kartstuff[k_driftcharge] >= dsthree)) + colmap = R_GetTranslationColormap(TC_RAINBOW, (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))), GTC_CACHE); + else if ((leveltime & 1) && (stplyr->kartstuff[k_driftcharge] >= dstwo)) + colmap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_KETCHUP, GTC_CACHE); + else if ((leveltime & 1) && (stplyr->kartstuff[k_driftcharge] >= dsone)) + colmap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_SAPPHIRE, GTC_CACHE); + else +#endif + // invincibility/grow/shrink! + if (stplyr->mo->colorized && stplyr->mo->color) + colmap = R_GetTranslationColormap(TC_RAINBOW, stplyr->mo->color, GTC_CACHE); + } + + V_DrawFixedPatch(x, y, scale, splitflags, kp_fpview[target], colmap); + + pnum[stplyrnum] = pn; + turn[stplyrnum] = tn; + drift[stplyrnum] = dr; +} + +// doesn't need to ever support 4p +static void K_drawInput(void) +{ + INT32 offs, col; + static INT32 pn = 0; + + if (!cv_showinput.value || (timeinmap <= 105)) // dont bother + return; + + INT32 target = 0, splitflags = (V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_HUDTRANS); + INT32 x = (BASEVIDWIDTH - 32 + cv_wheel_xoffset.value)*FRACUNIT, y = (BASEVIDHEIGHT - 24 + cv_wheel_yoffset.value)*FRACUNIT; + + const UINT8 hudcolor = K_GetHudColor(); + const INT32 accent1 = splitflags|colortranslations[hudcolor][5]; + const INT32 accent2 = splitflags|colortranslations[hudcolor][9]; + const UINT8 *hudcolormap = R_GetTranslationColormap(0, hudcolor, GTC_CACHE); + + const ticcmd_t *cmd = &stplyr->cmd; + + if (timeinmap < 113) + { + INT32 count = ((INT32)(timeinmap) - 105); + INT32 frac = count > 0 && count < 6 ? R_GetHudUncap() << (FRACBITS - count - 11) : 0; + + offs = 64*FRACUNIT; + while (count-- > 0) + offs >>= 1; + x += (offs < FRACUNIT ? 0 : offs) - frac; + } + +#define BUTTW 8 +#define BUTTH 11 + +#define drawbutt(xoffs, butt, symb)\ + if (cmd->buttons & butt)\ + {\ + offs = 2*FRACUNIT;\ + col = accent1;\ + }\ + else\ + {\ + offs = 0;\ + col = accent2;\ + V_DrawFill((x + xoffs*FRACUNIT)>>FRACBITS, (y + BUTTH*FRACUNIT)>>FRACBITS, BUTTW-1, 2, splitflags|31);\ + }\ + V_DrawFill((x + xoffs*FRACUNIT)>>FRACBITS, (y+offs)>>FRACBITS, BUTTW-1, BUTTH, col);\ + V_DrawFixedPatch(x + FRACUNIT + xoffs*FRACUNIT, y + offs + FRACUNIT, FRACUNIT, splitflags, tny_font[symb-HU_FONTSTART], NULL) + + drawbutt(-2*BUTTW, BT_ACCELERATE, 'A'); + drawbutt( -BUTTW, BT_BRAKE, 'B'); + drawbutt( 0, BT_DRIFT, 'D'); + drawbutt( BUTTW, BT_ATTACK, 'I'); + +#undef drawbutt + +#undef BUTTW +#undef BUTTH + + y -= FRACUNIT; + + if (cv_showinput.value == 2 || cv_showinput.value == 3) + { + INT32 axis; + INT32 hudforward = 0; // for the stick input display :chaosleep: + UINT8 *shadowcolormap = NULL; + const INT32 joyx = x>>FRACBITS; + const INT32 joyy = y>>FRACBITS; + static const INT32 joyxoffs = -8; + static const INT32 joyyoffs = -24; + const boolean usejoysprite = (cv_showinput.value == 3 && joystickicon); + + // O backing + if (usejoysprite) + { + shadowcolormap = R_GetTranslationColormap(0, SKINCOLOR_BLACK, GTC_CACHE); + V_DrawMappedPatch(joyx+joyxoffs, joyy+joyyoffs-1, splitflags, joybacking, hudcolormap); + } + else + { + V_DrawFill(joyx+joyxoffs, joyy+joyyoffs-1, 16, 16, splitflags|accent2); + V_DrawFill(joyx+joyxoffs, joyy+joyyoffs+15, 16, 1, splitflags|31); + } + + // time for pain and suffering + // kart does not have anything we can get analogue joystick y axis values from + // during normal gameplay, so replicate shit here + + // this is horrid but we cant get actual input in replays so uhh + if (demo.playback || !P_IsLocalPlayer(stplyr)) // yeah........... + { + hudforward = stplyr->kartstuff[k_throwdir] * KART_FULLTURN; + } + else + { + const boolean analogjoystickmove = cv_usejoystick[stplyrnum].value && !Joystick[stplyrnum].bGamepadStyle; + const boolean gamepadjoystickmove = cv_usejoystick[stplyrnum].value && Joystick[stplyrnum].bGamepadStyle; + const UINT8 ssplayer = stplyrnum+1; + + axis = JoyAxis(AXISAIM, ssplayer); + + if (analogjoystickmove && axis != 0) + { + // JOYAXISRANGE is supposed to be 1023 (divide by 1024) + hudforward -= ((axis * KART_FULLTURN) / (JOYAXISRANGE-1)); + } + else + { + if (InputDown(gc_aimforward, ssplayer) || (gamepadjoystickmove && axis < 0)) + { + hudforward += KART_FULLTURN; + } + if (InputDown(gc_aimbackward, ssplayer) || (gamepadjoystickmove && axis > 0)) + { + hudforward-= KART_FULLTURN; + } + } + + hudforward = CLAMP(hudforward, -KART_FULLTURN, KART_FULLTURN); + } + + if (cmd->driftturn || hudforward) + { + INT16 turning = encoremode ? -cmd->driftturn : cmd->driftturn; + + if (usejoysprite) + { + V_DrawMappedPatch(joyx+joyxoffs+3-turning/80, joyy+joyyoffs+2-hudforward/80, splitflags, joyknob, shadowcolormap); + V_DrawMappedPatch(joyx+joyxoffs+3-turning/64, joyy+joyyoffs+1-hudforward/64, splitflags, joyknob, hudcolormap); + } + else + { + // joystick hole + V_DrawFill(joyx+joyxoffs+5, joyy+joyyoffs+4, 6, 6, splitflags|accent1); + // joystick top and back + V_DrawFill(joyx+joyxoffs+3-turning/80, joyy+joyyoffs+2-hudforward/80, 10, 10, splitflags|31); + V_DrawFill(joyx+joyxoffs+3-turning/64, joyy+joyyoffs+1-hudforward/64, 10, 10, splitflags|accent1); + } + } + else + { + if (usejoysprite) + { + V_DrawMappedPatch(joyx+joyxoffs+3, joyy+joyyoffs+8, splitflags, joyshadow, shadowcolormap); + V_DrawMappedPatch(joyx+joyxoffs+3, joyy+joyyoffs+1, splitflags, joyknob, hudcolormap); + } + else + { + V_DrawFill(joyx+joyxoffs+3, joyy+joyyoffs+11, 10, 1, splitflags|accent2); + V_DrawFill(joyx+joyxoffs+3, joyy+joyyoffs+1, 10, 10,splitflags|accent1); + } + } + } + else + { + if (!cmd->driftturn) // no turn + target = 0; + else // turning of multiple strengths! + { + target = ((abs(cmd->driftturn) - 1)/125)+1; + if (target > 4) + target = 4; + if (cmd->driftturn < 0) + target = -target; + } + + if (pn != target) + { + if (abs(pn - target) == 1) + pn = target; + else if (pn < target) + pn += 2; + else //if (pn > target) + pn -= 2; + } + + if (pn < 0) + { + splitflags |= V_FLIP; // right turn + x -= FRACUNIT; + } + + target = abs(pn); + if (target > 4) + target = 4; + + V_DrawFixedPatch(x, y, FRACUNIT, splitflags, kp_inputwheel[target], hudcolormap); + } +} + +static void K_drawChallengerScreen(void) +{ + // This is an insanely complicated animation. + static const UINT8 anim[52] = { + 0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13, // frame 1-14, 2 tics: HERE COMES A NEW slides in + 14,14,14,14,14,14, // frame 15, 6 tics: pause on the W + 15,16,17,18, // frame 16-19, 1 tic: CHALLENGER approaches screen + 19,20,19,20,19,20,19,20,19,20, // frame 20-21, 1 tic, 5 alternating: all text vibrates from impact + 21,22,23,24 // frame 22-25, 1 tic: CHALLENGER turns gold + }; + const UINT8 offset = min(52-1, (3*TICRATE)-mapreset); + + V_DrawFadeScreen(0xFF00, 16); // Fade out + V_DrawScaledPatch(0, 0, 0, kp_challenger[anim[offset]]); +} + +static void K_drawLapStartAnim(void) +{ + // This is an EVEN MORE insanely complicated animation. + const UINT8 progress = 80-stplyr->kartstuff[k_lapanimation]; + UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); + INT32 vflags = V_SNAPTOTOP|V_HUDTRANS; + + fixed_t slideout = max(0, 32*(((progress - 76)*FRACUNIT) + R_GetHudUncap())); + fixed_t slidein = max(0, 32*(((stplyr->kartstuff[k_lapanimation] - 76)*FRACUNIT) - R_GetHudUncap())); + + // First, draw the emblem and hand + INT32 emblemx = (BASEVIDWIDTH << (FRACBITS - 1)) + slidein; + INT32 y = 48*FRACUNIT - slideout; + + V_DrawFixedPatch(emblemx, y, FRACUNIT, vflags, kp_lapanim_emblem[modeattacking ? 1 : 0], colormap); + + INT32 hand = stplyr->kartstuff[k_laphand]; + if (hand >= 1 && hand <= 3) + { + y += 4*FRACUNIT - abs((int)(leveltime % 8)*FRACUNIT + R_GetHudUncap() - 4*FRACUNIT); + V_DrawFixedPatch(emblemx, y, FRACUNIT, vflags, kp_lapanim_hand[hand - 1], NULL); + } + + // Then the text + INT32 leftx = 82*FRACUNIT - slideout; + INT32 rightx = 188*FRACUNIT + slideout; + y = 30*FRACUNIT; + + if (stplyr->laps == (UINT8)(cv_numlaps.value - 1)) + { + // FINAL + V_DrawFixedPatch(leftx - 20*FRACUNIT, y, FRACUNIT, vflags, kp_lapanim_final[min(progress/2, 10)], NULL); + + // LAP + if (progress/2 - 12 >= 0) + V_DrawFixedPatch(rightx, y, FRACUNIT, vflags, kp_lapanim_lap[min(progress/2 - 12, 6)], NULL); + } + else + { + // LAP + V_DrawFixedPatch(leftx, y, FRACUNIT, vflags, kp_lapanim_lap[min(progress/2, 6)], NULL); + + char *lapnum = va("%02d", stplyr->laps + 1); + for (int i = 0; i < (int)strlen(lapnum); i++) + { + int digit = lapnum[i] - '0'; + int frame = min(2, progress/2 - 8 - (i*2)); + if (frame >= 0) + V_DrawFixedPatch(rightx + (i*20*FRACUNIT), y, FRACUNIT, vflags, kp_lapanim_number[digit][frame], NULL); + } + } +} + +void K_drawKartFreePlay(UINT32 flashtime) +{ + // no splitscreen support because it's not FREE PLAY if you have more than one player in-game + + if (!cv_showfreeplay.value) + return; + + if ((flashtime % TICRATE) < TICRATE/2) + return; + + V_DrawKartString((BASEVIDWIDTH - (LAPS_X+1)) - (12*9), // mirror the laps thingy + LAPS_Y+3, V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_HUDTRANS, "FREE PLAY"); +} + +static void K_drawDistributionDebugger(void) +{ + patch_t *items[NUMKARTRESULTS] = { + kp_sadface[1], + kp_sneaker[1], + kp_rocketsneaker[1], + kp_invincibility[7], + kp_banana[1], + kp_eggman[1], + kp_orbinaut[4], + kp_jawz[1], + kp_mine[1], + kp_ballhog[1], + kp_selfpropelledbomb[1], + kp_grow[1], + kp_shrink[1], + kp_thundershield[1], + kp_hyudoro[1], + kp_pogospring[1], + kp_kitchensink[1], + + kp_sneaker[1], + kp_banana[1], + kp_banana[1], + kp_orbinaut[4], + kp_orbinaut[4], + kp_jawz[1] + }; + INT32 useodds = 0; + INT32 pingame = 0, bestbumper = 0; + INT32 i; + INT32 x = -9, y = -9; + boolean dontforcespb = false; + boolean spbrush = false; + + if (stplyrnum != 0) // only for p1 + return; + + // The only code duplication from the Kart, just to avoid the actual item function from calculating pingame twice + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i] || players[i].spectator) + continue; + pingame++; + if (players[i].exiting) + dontforcespb = true; + if (players[i].kartstuff[k_bumper] > bestbumper) + bestbumper = players[i].kartstuff[k_bumper]; + } + + if (G_RaceGametype()) + spbrush = (spbplace != -1 && stplyr->kartstuff[k_position] == spbplace+1); + + useodds = K_FindUseodds(stplyr, 0, pingame, bestbumper, spbrush, dontforcespb); + + for (i = 1; i < NUMKARTRESULTS; i++) + { + const INT32 itemodds = K_KartGetItemOdds(useodds, i, 0, spbrush); + if (itemodds <= 0) + continue; + + V_DrawScaledPatch(x, y, V_HUDTRANS|V_SNAPTOTOP, items[i]); + V_DrawThinString(x+11, y+31, V_HUDTRANS|V_SNAPTOTOP, va("%d", itemodds)); + + // Display amount for multi-items + if (i >= NUMKARTITEMS) + { + INT32 amount; + switch (i) + { + case KRITEM_TENFOLDBANANA: + amount = 10; + break; + case KRITEM_QUADORBINAUT: + amount = 4; + break; + case KRITEM_DUALJAWZ: + amount = 2; + break; + default: + amount = 3; + break; + } + V_DrawString(x+24, y+31, V_ALLOWLOWERCASE|V_HUDTRANS|V_SNAPTOTOP, va("x%d", amount)); + } + + x += 32; + if (x >= 297) + { + x = -9; + y += 32; + } + } + + V_DrawString(0, 0, V_HUDTRANS|V_SNAPTOTOP, va("USEODDS %d", useodds)); +} + +static void K_drawCheckpointDebugger(void) +{ + if (stplyrnum != 0) // only for p1 + return; + + if (stplyr->starpostnum >= (numstarposts - (numstarposts/2))) + V_DrawString(8, 184, 0, va("Checkpoint: %d / %d (Can finish)", stplyr->starpostnum, numstarposts)); + else + V_DrawString(8, 184, 0, va("Checkpoint: %d / %d (Skip: %d)", stplyr->starpostnum, numstarposts, ((numstarposts/2) + stplyr->starpostnum))); + V_DrawString(8, 192, 0, va("Waypoint dist: Prev %d, Next %d", stplyr->kartstuff[k_prevcheck], stplyr->kartstuff[k_nextcheck])); +} + +// determines if gametype info (laps/bumpers) should be hidden +static boolean K_DisableGametypeInfo(void) +{ + if (!LUA_HudEnabled(hud_gametypeinfo)) + { + return true; + } + +#ifdef ROTSPRITE + if (splitscreen || (!cv_kartspeedometer.value)) + { + // don't need to run checks if we're in splitscreen, or not using the speedometer + return false; + } + + const UINT8 speedostyle = K_GetSpeedometerStyle(); + + if (G_RaceGametype()) + { + if (speedostyle == SPEEDO_DIAL) + return true; + } + else if (G_BattleGametype()) + { + if ((cv_battlespeedo.value) && (speedostyle == SPEEDO_DIAL)) + return true; + } +#endif + + return false; +} + +void K_drawKartHUD(void) +{ + boolean isfreeplay = false; + boolean battlefullscreen = false; + boolean freecam = camera[stplyrnum].freecam; //disable some hud elements w/ freecam + boolean gameinfovisible = false; + + // Define the X and Y for each drawn object + // This is handled by console/menu values + K_initKartHUD(); + + // Draw that fun first person HUD! Drawn ASAP so it looks more "real". + if (!camera[stplyrnum].chase && !freecam) + K_drawKartFirstPerson(); + + // Draw full screen stuff that turns off the rest of the HUD + if (mapreset && stplyrnum == 0) + { + K_drawChallengerScreen(); + return; + } + + battlefullscreen = ((G_BattleGametype()) + && (stplyr->exiting + || (stplyr->kartstuff[k_bumper] <= 0 + && stplyr->kartstuff[k_comebacktimer] + && comeback + && stplyr->playerstate == PST_LIVE))); + + if (!demo.title && (!battlefullscreen || splitscreen)) + { + // Draw the CHECK indicator before the other items, so it's overlapped by everything else + + if (LUA_HudEnabled(hud_check)) // delete lua when? + { + if (cv_kartcheck.value && !splitscreen && !players[displayplayers[0]].exiting && !freecam) + K_drawKartPlayerCheck(); + } + + // Draw WANTED status + if (G_BattleGametype()) + { + if (LUA_HudEnabled(hud_wanted)) + K_drawKartWanted(); + } + + if (cv_kartminimap.value) + { + if (LUA_HudEnabled(hud_minimap)) + K_drawKartMinimap(); + } + } + + if (battlefullscreen && !freecam) + { + if (LUA_HudEnabled(hud_battlefullscreen)) + K_drawBattleFullscreen(); + return; + } + + // Draw the item window + if (LUA_HudEnabled(hud_item) && !freecam) + K_drawKartItem(); + + if (cv_driftgauge.value && !modeattacking) + { + if (LUA_HudEnabled(hud_driftgauge)) + K_drawDriftGauge(); + } + + if (cv_nametag.value) + { + if (LUA_HudEnabled(hud_nametags)) + K_drawNameTags(); + } + + // If not splitscreen, draw... + if (!splitscreen && !demo.title) + { + tic_t realtime = stplyr->realtime; + + if (cv_showlaptimes.value + && stplyr->kartstuff[k_lapanimation] + && !stplyr->exiting + && stplyr->laptime[LAP_LAST] != 0 + && !midgamejoin) // due to vanilla compat, we cannot synch this oh well + { + if ((stplyr->kartstuff[k_lapanimation] / 5) & 1) + { + realtime = stplyr->laptime[LAP_LAST]; + } + else + { + realtime = UINT32_MAX; + } + } + + // Draw the timestamp + if (LUA_HudEnabled(hud_time)) + K_drawKartTimestamp(realtime, TIME_X, TIME_Y, gamemap, 0); + + if (!modeattacking) + { + // The top-four faces on the left + //if (LUA_HudEnabled(hud_minirankings)) + isfreeplay = K_drawKartPositionFaces(); + } + } + + if (!stplyr->spectator && !freecam) // Bottom of the screen elements, don't need in spectate mode + { + // get gametype info visibility ahead of time + gameinfovisible = (!K_DisableGametypeInfo()); + + if (!(splitscreen || demo.title)) + { + if (LUA_HudEnabled(hud_inputdisplay)) + K_drawInput(); + } + + if (!demo.title && cv_showstats.value) + { + if (LUA_HudEnabled(hud_statdisplay)) + K_drawKartStats(); + } + + if (demo.title) // Draw title logo instead in demo.titles + { + INT32 x = (BASEVIDWIDTH - 32)*FRACUNIT, y = 128*FRACUNIT, offs; + INT32 logoflags = V_SNAPTORIGHT|V_SNAPTOBOTTOM; + + if (splitscreen == 3) + { + x = BASEVIDWIDTH/2 + 10; + y = BASEVIDHEIGHT/2 - 30; + } + + if (timeinmap < 113) + { + INT32 count = ((INT32)(timeinmap) - 104); + INT32 frac = count > 0 ? R_GetHudUncap() << max(0, FRACBITS - count - 9) : 0; + + offs = 256*FRACUNIT; + while (count-- > 0) + offs >>= 1; + x += offs - frac; + } + + V_DrawSciencePatch(x - (54*FRACUNIT), y, logoflags, W_CachePatchName("TTKBANNR", PU_PATCH), FRACUNIT/4); + V_DrawSciencePatch(x - (54*FRACUNIT), y + (25*FRACUNIT), logoflags, W_CachePatchName("TTKART", PU_PATCH), FRACUNIT/4); + } + else if (G_RaceGametype()) // Race-only elements + { + // Draw the lap counter + if (gameinfovisible) + K_drawKartLaps(); + + if (!splitscreen) + { + // Draw the speedometer + // TODO: Make a better speedometer. << done :p + if (LUA_HudEnabled(hud_speedometer)) + K_drawKartSpeedometer(); + } + + if (isfreeplay) + ; + else if (!modeattacking) + { + // Draw the numerical position + if (LUA_HudEnabled(hud_position)) + K_DrawKartPositionNum(stplyr->kartstuff[k_position]); + } + } + else if (G_BattleGametype()) // Battle-only + { + // Draw the hits left! + if (gameinfovisible) + K_drawKartBumpersOrKarma(); + + if ((!splitscreen) && cv_battlespeedo.value) + { + // Draw the speedometer but in battle + // TODO: Make a better speedometer. << done :p + if (LUA_HudEnabled(hud_speedometer)) + K_drawKartSpeedometer(); + } + } + } + + // Draw the countdowns after everything else. + if (leveltime >= starttime-(3*TICRATE) + && leveltime < starttime+TICRATE) + K_drawKartStartCountdown(); + else if (racecountdown && (!splitscreen || !stplyr->exiting)) + { + char *countstr = va("%d", racecountdown/TICRATE); + + // Eeeh dunno if would be better to add another variable instead of LAPS_Y but this works too + int yoff = cv_dnft_yoffset.value - cv_laps_yoffset.value; + int xoff = cv_dnft_xoffset.value; + + if (splitscreen > 1) + V_DrawCenteredString(BASEVIDWIDTH/4+xoff, LAPS_Y+1+yoff, K_calcSplitFlags(V_SNAPTOBOTTOM), countstr); + else + { + INT32 karlen = strlen(countstr)*6; // half of 12 + V_DrawKartString((BASEVIDWIDTH/2)-karlen+xoff, LAPS_Y+3+yoff, K_calcSplitFlags(V_SNAPTOBOTTOM), countstr); + } + } + + // Race overlays + if (G_RaceGametype() && !freecam) + { + if (stplyr->exiting) + K_drawKartFinish(); + else if (stplyr->kartstuff[k_lapanimation] && !splitscreen && cv_showlapemblem.value) + K_drawLapStartAnim(); + } + + if (modeattacking || freecam) // everything after here is MP and debug only + return; + + if (G_BattleGametype() && !splitscreen && (stplyr->kartstuff[k_yougotem] % 2)) // * YOU GOT EM * + V_DrawScaledPatch(BASEVIDWIDTH/2 - (kp_yougotem->width/2), 32, V_HUDTRANS, kp_yougotem); + + // Draw FREE PLAY. + if (isfreeplay && !stplyr->spectator && timeinmap > 113) + { + if (LUA_HudEnabled(hud_freeplay)) + K_drawKartFreePlay(leveltime); + } + + if (cv_kartdebugdistribution.value) + K_drawDistributionDebugger(); + + if (cv_kartdebugcheckpoint.value) + K_drawCheckpointDebugger(); + + if (cv_kartdebugdirector.value) + K_DrawDirectorDebugger(); + + if (cv_kartdebugnodes.value) + { + UINT8 p; + for (p = 0; p < MAXPLAYERS; p++) + V_DrawString(8, 64+(8*p), V_YELLOWMAP, va("%d - %d (%dl)", p, playernode[p], players[p].cmd.latency)); + } + + if (cv_kartdebugcolorize.value && stplyr->mo && stplyr->mo->skin) + { + INT32 x = 0, y = 0; + UINT8 c; + + for (c = 1; c < MAXSKINCOLORS; c++) + { + UINT8 *cm = R_GetTranslationColormap(TC_RAINBOW, c, GTC_CACHE); + V_DrawFixedPatch(x<>1, 0, facewantprefix[stplyr->skin], cm); + + x += 16; + if (x > BASEVIDWIDTH-16) + { + x = 0; + y += 16; + } + } + } +} diff --git a/src/k_hud.h b/src/k_hud.h new file mode 100644 index 000000000..3d2e478a7 --- /dev/null +++ b/src/k_hud.h @@ -0,0 +1,81 @@ +// SONIC ROBO BLAST 2 KART +//----------------------------------------------------------------------------- +// Copyright (C) 2018-2020 by Kart Krew +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file k_hud.h +/// \brief HUD drawing functions exclusive to Kart + +#ifndef __K_HUD__ +#define __K_HUD__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "doomdef.h" +#include "d_player.h" // Need for player_t +#include "command.h" +#include "r_defs.h" + +UINT8 K_GetHudColor(void); +boolean K_UseColorHud(void); +boolean K_UseHighResPortraits(void); +patch_t *K_GetFacePrefix(player_t *player, INT32 skinnum); + +void K_RegisterKartHudStuff(void); + +extern consvar_t cv_colorizedhud, + cv_colorizeditembox, + cv_colorizedhudcolor; + +extern consvar_t cv_darkitembox; +extern consvar_t cv_biglaps; +extern consvar_t cv_highresportrait; +extern consvar_t cv_stat_xoffset, cv_stat_yoffset; +extern consvar_t cv_showstats; +extern consvar_t cv_fancyroulette; +extern consvar_t cv_showlaptimes; +extern consvar_t cv_battlespeedo; +extern consvar_t cv_multiitemicon; +extern consvar_t cv_huditemamount; + +#define NUMSPEEDOSTUFF 8 +extern CV_PossibleValue_t speedo_cons_t[NUMSPEEDOSTUFF]; +#define NUMDGAUGESTUFF 6 +extern CV_PossibleValue_t driftgaugestyle_cons_t[NUMDGAUGESTUFF]; +#define NUMINPUTDISPLAYSTUFF 5 +extern CV_PossibleValue_t inputdisplay_cons_t[NUMINPUTDISPLAYSTUFF]; +#define NUMMINIMAPDOTSTUFF 5 +extern CV_PossibleValue_t minimapdot_cons_t[NUMMINIMAPDOTSTUFF]; + +const char *K_GetItemPatch(UINT8 item, boolean tiny); +INT32 K_calcSplitFlags(INT32 snapflags); +void K_LoadKartHUDGraphics(void); +void K_drawKartHUD(void); +void K_drawKartFreePlay(UINT32 flashtime); +void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UINT8 mode); + +typedef struct +{ + INT32 x; + INT32 y; + INT32 flags; +} drawinfo_t; + +patch_t *K_getItemBoxPatch(boolean small, boolean dark); +patch_t *K_getItemMulPatch(boolean small); +void K_getItemBoxDrawinfo(drawinfo_t *out); +INT32 K_getMinimapTrans(void); +void K_getLapsDrawinfo(drawinfo_t *out); +void K_getMinimapDrawinfo(drawinfo_t *out); + +#ifdef __cplusplus +} // extern "C" +#endif + +// ========================================================================= +#endif // __K_HUD__ diff --git a/src/k_kart.c b/src/k_kart.c index 5589bdb6e..5d152ca17 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -10,76 +10,28 @@ #include "command.h" #include "d_netcmd.h" #include "d_player.h" -#include "hu_stuff.h" +#include "k_hud.h" #include "g_game.h" -#include "i_joy.h" #include "m_fixed.h" #include "m_random.h" #include "m_menu.h" // ffdhidshfuisduifigergho9igj89dgodhfih AAAAAAAAAA #include "p_local.h" -#include "p_setup.h" #include "p_slopes.h" #include "r_defs.h" #include "r_draw.h" -#include "r_local.h" #include "r_state.h" #include "r_things.h" -#include "r_fps.h" #include "s_sound.h" -#include "screen.h" -#include "st_stuff.h" #include "tables.h" #include "v_video.h" -#include "z_zone.h" #include "m_misc.h" #include "m_cond.h" #include "k_director.h" #include "k_kart.h" #include "k_stats.h" -#include "f_finale.h" -#include "lua_hud.h" // For Lua hud checks #include "lua_hook.h" // For MobjDamage and ShouldDamage -#include "d_main.h" // found_extra_kart - - #include "i_video.h" -#ifdef HWRENDER -#include "hardware/hw_main.h" -#endif - -#ifdef ROTSPRITE -#include "r_patchrotation.h" -#endif - -// Hud offset cvars -#define IMPL_HUD_OFFSET_X(name)\ -consvar_t cv_##name##_xoffset = {"hud_" #name "_xoffset", "0", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; - -#define IMPL_HUD_OFFSET_Y(name)\ -consvar_t cv_##name##_yoffset = {"hud_" #name "_yoffset", "0", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; - -#define IMPL_HUD_OFFSET(name)\ -IMPL_HUD_OFFSET_X(name)\ -IMPL_HUD_OFFSET_Y(name) - -IMPL_HUD_OFFSET(item); // Item box -IMPL_HUD_OFFSET(time); // Time -IMPL_HUD_OFFSET(laps); // Number of laps -IMPL_HUD_OFFSET(dnft); // Countdown (did not finish timer) -IMPL_HUD_OFFSET(speed); // Speedometer -IMPL_HUD_OFFSET(posi); // Position in race -IMPL_HUD_OFFSET(wheel); // RA Wheel -IMPL_HUD_OFFSET(face); // Mini rankings -IMPL_HUD_OFFSET(stcd); // Starting countdown -IMPL_HUD_OFFSET_Y(chek); // Check gfx -IMPL_HUD_OFFSET(mini); // Minimap -IMPL_HUD_OFFSET(want); // Wanted -IMPL_HUD_OFFSET(stat); // Stats - -#undef IMPL_HUD_OFFSET -#undef IMPL_HUD_OFFSET_X -#undef IMPL_HUD_OFFSET_Y // extra colourisation stuff static CV_PossibleValue_t colorspeedlines_cons_t[] = {{0, "Off"}, {1, "Normal"}, {2, "+Driftcharge"}, {3, "Drift only"}, {0, NULL}}; @@ -93,36 +45,6 @@ consvar_t cv_bananthrowroll = {"bananthrowroll", "0", CV_SAVE, bananthrowroll_co consvar_t cv_airsparks = {"airdriftsparks", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -//extra hud things -consvar_t cv_showstats = {"showstats", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -CV_PossibleValue_t inputdisplay_cons_t[NUMINPUTDISPLAYSTUFF]; -consvar_t cv_showinput = {"showinput", "Off", CV_SAVE, inputdisplay_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_showlaptimes = {"showlaptimes", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - -consvar_t cv_posanim = {"postitionanimation", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_smallposnum = {"smallpositionnumber", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - -consvar_t cv_fancyroulette = {"animatedroulette", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - -consvar_t cv_minihead = {"smallminimapplayers", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_showminimapnames = {"showminimapnames", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -CV_PossibleValue_t minimapdot_cons_t[NUMMINIMAPDOTSTUFF]; -consvar_t cv_showminimapangle = {"showminimapangle", "Off", CV_SAVE, minimapdot_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; - -consvar_t cv_highresportrait = {"highresportrait", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // make char potraits use their high-res version instead - -consvar_t cv_showlapemblem = {"showlapemblem", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_biglaps = {"biglaphud", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // here for ppl who dont want to make 2 more patches for their custom hud - -consvar_t cv_darkitembox = {"darkitembox", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // itembox gets a dark border with specific items -consvar_t cv_multiitemicon = {"multiitemicon", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -static CV_PossibleValue_t huditemamount_cons_t[] = {{0, "Vanilla"}, {1, "Multiple"}, {2, "Always"},{0, NULL}}; -consvar_t cv_huditemamount = {"showitemamountnumber", "Vanilla", CV_SAVE, huditemamount_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; - -CV_PossibleValue_t speedo_cons_t[NUMSPEEDOSTUFF]; -consvar_t cv_newspeedometer = {"newspeedometer", "Default", CV_SAVE, speedo_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_battlespeedo = {"battlespeedo", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // toggle for showing the speedometer in battlemode - consvar_t cv_playerblendeffects = {"playerblendeffects", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // funn-E streeetch @@ -182,50 +104,6 @@ static void saltyhop_onchange(void) } } -// Colourized HUD -consvar_t cv_colorizedhud = {"colorizedhud", "Off", CV_SAVE|CV_CALL, CV_OnOff, SaturnHud_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_colorizeditembox = {"colorizeditembox", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - -static CV_PossibleValue_t HudColor_cons_t[MAXSKINCOLORS+1]; -consvar_t cv_colorizedhudcolor = {"colorizedhudcolor", "Skin Color", CV_SAVE, HudColor_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; - -// driftgauge stuffs -static CV_PossibleValue_t driftgaugeoffset_cons_t[] = { - {-FRACUNIT*128, "MIN"}, {FRACUNIT*128, "MAX"}, {0, NULL}}; -CV_PossibleValue_t driftgaugestyle_cons_t[NUMDGAUGESTUFF]; - -consvar_t cv_driftgauge = {"kartdriftgauge", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_driftgaugeofs = {"kartdriftgaugeoffset", "-20", CV_FLOAT|CV_SAVE, driftgaugeoffset_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_driftgaugetrans = {"kartdriftgaugetransparency", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_driftgaugestyle = {"kartdriftgaugestyle", "1", CV_SAVE, driftgaugestyle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; - -// nametags -static CV_PossibleValue_t nametagtrans_cons_t[] = { - {0, "Never"}, {1, "Far only"}, {2, "Dynamic"}, {3, "Always"}, {4, "HUD Trans."}, {0, NULL}}; -/*static CV_PossibleValue_t nametagscaling_cons_t[] = { - {0, "MIN"}, {320, "MAX"}, {0, NULL}};*/ -static CV_PossibleValue_t nametagdistance_cons_t[] = { - {0, "MIN"}, {640, "MAX"}, {0, NULL}}; -static CV_PossibleValue_t nametagmaxplayer_cons_t[] = { - {1, "MIN"}, {MAXPLAYERS, "MAX"}, {0, NULL}}; -static CV_PossibleValue_t nametagsize_cons_t[] = { - {0, "Off"}, {1, "Small"}, {2, "Minimal"}, {0, NULL}}; -static CV_PossibleValue_t nametagrestat_cons_t[] = { - {0, "Off"}, {1, "Restat"}, {2, "Always"}, {0, NULL}}; - -consvar_t cv_nametag = {"kartnametag", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_nametagtrans = {"kartnametagtransparency", "Dynamic", CV_SAVE, nametagtrans_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_nametagfacerank = {"kartnametagfacerank", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_nametagrestat = {"kartnametagrestat", "Restat", CV_SAVE, nametagrestat_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_nametagdist = {"kartnametagdist", "320", CV_SAVE, nametagdistance_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_nametagmaxplayers = {"kartnametagmaxplayers", "3", CV_SAVE, nametagmaxplayer_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_nametagmaxlenght = {"kartnametagmaxlenght", "12", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; -//consvar_t cv_nametagscaling = {"nametagscaling", "160", CV_SAVE, nametagscaling_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_showownnametag = {"kartnametagshowown", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_smallnametags = {"kartnametagsmall", "Off", CV_SAVE, nametagsize_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_nametagscore = {"kartnametagscore", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_shownametagspectator = {"kartshownametagspectator", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; - static boolean K_SpeedLinesShouldBlend(player_t *player); // SOME IMPORTANT VARIABLES DEFINED IN DOOMDEF.H: @@ -238,9 +116,6 @@ static boolean K_SpeedLinesShouldBlend(player_t *player); // mapreset is set when enough players fill an empty server // nospectategrief is the players in-game needed to eliminate the person in last -#define XTRA3PSCALE 50135 //0.765 -#define XTRA3VSCALE 35344 //0.55 - //{ SRB2kart Color Code #define SKIN_RAMP_LENGTH 16 @@ -743,77 +618,6 @@ UINT8 K_GetKartColorByName(const char *name) return 0; } -UINT8 K_GetHudColor(void) -{ - if (cv_colorizedhud.value && cv_colorizedhudcolor.value) return cv_colorizedhudcolor.value; - - return ((stplyr && gamestate == GS_LEVEL) ? stplyr->skincolor : cv_playercolor.value); -} - -boolean K_UseColorHud(void) -{ - return (cv_colorizedhud.value && clr_hud); -} - -enum -{ - SPEEDO_VANILLA, - SPEEDO_EXTRA, - SPEEDO_ACHII, - SPEEDO_DIAL, - SPEEDO_PMETER, - SPEEDO_PMETERSMOL, - SPEEDO_EXTRA3, -}; - -static UINT8 K_GetSpeedometerStyle(void) -{ - if (cv_newspeedometer.value == 2 && xtra_speedo) - return SPEEDO_EXTRA; - else if (cv_newspeedometer.value == 3 && achi_speedo) - return SPEEDO_ACHII; - else if (cv_newspeedometer.value == 4 && dial_speedo) - return SPEEDO_DIAL; - else if (cv_newspeedometer.value == 5 && kartz_speedo) - return SPEEDO_PMETER; - else if (cv_newspeedometer.value == 6 && kartz_speedo_smol) - return SPEEDO_PMETERSMOL; - else if (cv_newspeedometer.value == 7 && xtra_speedo3) - return SPEEDO_EXTRA3; - else - return SPEEDO_VANILLA; -} - -static boolean K_UseColorSpeedo(int speedostyle) -{ - if (!K_UseColorHud()) - return false; - - switch (speedostyle) - { - case SPEEDO_EXTRA: - return xtra_speedo_clr; - case SPEEDO_ACHII: - return achi_speedo_clr; - case SPEEDO_DIAL: - return dial_speedo_clr; - case SPEEDO_EXTRA3: - return xtra_speedo_clr3; - default: - return false; - } -} - -static boolean K_IsHighResolution(void) -{ - return (vid.width >= 640 && vid.height >= 400); -} - -boolean K_UseHighResPortraits(void) -{ - return (cv_highresportrait.value && K_IsHighResolution()); -} - // returns the players skinnumber // accounts for localskins INT32 K_GetSkinNum(player_t *player) @@ -849,16 +653,6 @@ skin_t *K_GetPlayerSkin(player_t *player) return &K_GetSkinArray(player->skinlocal)[K_GetSkinNum(player)]; } -// returns the players faceprefix -// accounts for localskins -patch_t *K_GetFacePrefix(player_t *player, INT32 skinnum) -{ - if (!player->skinlocal) - return (K_UseHighResPortraits() ? facewantprefix[skinnum] : facerankprefix[skinnum]); - else - return (K_UseHighResPortraits() ? localfacewantprefix[skinnum] : localfacerankprefix[skinnum]); -} - //} //{ SRB2kart Net Variables @@ -889,8 +683,6 @@ void K_RegisterServerKartStuff(void) CV_RegisterVar(&cv_quadorbinaut); CV_RegisterVar(&cv_dualjawz); - CV_RegisterVar(&cv_kartminimap); - CV_RegisterVar(&cv_kartcheck); CV_RegisterVar(&cv_kartinvinsfx); CV_RegisterVar(&cv_kartspeed); CV_RegisterVar(&cv_kartbumpers); @@ -899,7 +691,6 @@ void K_RegisterServerKartStuff(void) CV_RegisterVar(&cv_kartencore); CV_RegisterVar(&cv_kartvoterulechanges); CV_RegisterVar(&cv_kartgametypepreference); - CV_RegisterVar(&cv_kartspeedometer); CV_RegisterVar(&cv_kartvoices); CV_RegisterVar(&cv_karthitemdialog); CV_RegisterVar(&cv_karteliminatelast); @@ -920,44 +711,7 @@ void K_RegisterServerKartStuff(void) // Nothing needed for a dedicated server should be registered here. void K_RegisterClientKartStuff(void) { - HudColor_cons_t[0].value = 0; - HudColor_cons_t[0].strvalue = "Skin Color"; - - for (INT32 i = 1; i < MAXSKINCOLORS; i++) - { - HudColor_cons_t[i].value = i; - HudColor_cons_t[i].strvalue = KartColor_Names[i]; // SRB2kart - } - HudColor_cons_t[MAXSKINCOLORS].value = 0; - HudColor_cons_t[MAXSKINCOLORS].strvalue = NULL; - -#define REG_HUD_OFFSET_X(name)\ - CV_RegisterVar(&cv_##name##_xoffset); - -#define REG_HUD_OFFSET_Y(name)\ - CV_RegisterVar(&cv_##name##_yoffset); - -#define REG_HUD_OFFSET(name)\ - REG_HUD_OFFSET_X(name)\ - REG_HUD_OFFSET_Y(name) - - REG_HUD_OFFSET(item); // Item box - REG_HUD_OFFSET(time); // Time - REG_HUD_OFFSET(laps); // Number of laps - REG_HUD_OFFSET(dnft); // Countdown (did not finish timer) - REG_HUD_OFFSET(speed); // Speedometer - REG_HUD_OFFSET(posi); // Position in race - REG_HUD_OFFSET(wheel); // Position in race - REG_HUD_OFFSET(face); // Mini rankings - REG_HUD_OFFSET(stcd); // Starting countdown - REG_HUD_OFFSET_Y(chek); // Check gfx - REG_HUD_OFFSET(mini); // Minimap - REG_HUD_OFFSET(want); // Wanted - REG_HUD_OFFSET(stat); // Stats - -#undef REG_HUD_OFFSET -#undef REG_HUD_OFFSET_X -#undef REG_HUD_OFFSET_Y + K_RegisterKartHudStuff(); // Colored speedlines CV_RegisterVar(&cv_coloredspeedlines); @@ -970,61 +724,8 @@ void K_RegisterClientKartStuff(void) CV_RegisterVar(&cv_airsparks); - CV_RegisterVar(&cv_showstats); - CV_RegisterVar(&cv_showinput); - - CV_RegisterVar(&cv_posanim); - CV_RegisterVar(&cv_smallposnum); - - CV_RegisterVar(&cv_fancyroulette); - - CV_RegisterVar(&cv_showlaptimes); - CV_RegisterVar(&cv_newspeedometer); - - CV_RegisterVar(&cv_battlespeedo); - - CV_RegisterVar(&cv_minihead); - CV_RegisterVar(&cv_showminimapnames); - CV_RegisterVar(&cv_showminimapangle); - - CV_RegisterVar(&cv_showlapemblem); - - CV_RegisterVar(&cv_stagetitle); - CV_RegisterVar(&cv_playerblendeffects); - // Colourized HUD - CV_RegisterVar(&cv_colorizedhud); - CV_RegisterVar(&cv_colorizedhudcolor); - CV_RegisterVar(&cv_colorizeditembox); - - CV_RegisterVar(&cv_biglaps); - - CV_RegisterVar(&cv_darkitembox); - - CV_RegisterVar(&cv_multiitemicon); - CV_RegisterVar(&cv_huditemamount); - - CV_RegisterVar(&cv_highresportrait); - - CV_RegisterVar(&cv_nametag); - CV_RegisterVar(&cv_nametagtrans); - CV_RegisterVar(&cv_nametagfacerank); - CV_RegisterVar(&cv_nametagmaxplayers); - CV_RegisterVar(&cv_nametagmaxlenght); - //CV_RegisterVar(&cv_nametagscaling); - CV_RegisterVar(&cv_nametagdist); - CV_RegisterVar(&cv_showownnametag); - CV_RegisterVar(&cv_smallnametags); - CV_RegisterVar(&cv_nametagrestat); - CV_RegisterVar(&cv_nametagscore); - CV_RegisterVar(&cv_shownametagspectator); - - CV_RegisterVar(&cv_driftgauge); - CV_RegisterVar(&cv_driftgaugeofs); - CV_RegisterVar(&cv_driftgaugetrans); - CV_RegisterVar(&cv_driftgaugestyle); - CV_RegisterVar(&cv_saltyhop); CV_RegisterVar(&cv_saltyhopsfx); CV_RegisterVar(&cv_saltysquish); @@ -1036,8 +737,6 @@ void K_RegisterClientKartStuff(void) CV_RegisterVar(&cv_squishdance); CV_RegisterVar(&cv_squishdancespeed); - CV_RegisterVar(&cv_lessflicker); - CV_RegisterVar(&cv_mouseturn); } @@ -1205,7 +904,7 @@ static void K_KartGetItemResult(player_t *player, SINT8 getitem) \return void */ -static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed, boolean spbrush) +INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed, boolean spbrush) { const INT32 distvar = (64*14); INT32 newodds; @@ -1364,7 +1063,7 @@ static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed, boolean sp //{ SRB2kart Roulette Code - Distance Based, no waypoints -static INT32 K_FindUseodds(player_t *player, fixed_t mashed, INT32 pingame, INT32 bestbumper, boolean spbrush, boolean dontforcespb) +INT32 K_FindUseodds(player_t *player, fixed_t mashed, INT32 pingame, INT32 bestbumper, boolean spbrush, boolean dontforcespb) { const INT32 distvar = (64*14); INT32 i; @@ -3668,8 +3367,8 @@ boolean K_CheckSlopeRollDist(mobj_t *mobj) if (!usedistance) return true; - const fixed_t rolldist = cv_sloperolldist.value * mapobjectscale; - const fixed_t m_dist = (R_QuickCamDist(mobj->x, mobj->y)*FRACUNIT); + const fixed_t rolldist = (cv_sloperolldist.value * mapobjectscale); + const fixed_t m_dist = (R_QuickCamDist(mobj->x, mobj->y) << FRACBITS); return (m_dist <= rolldist); } @@ -4480,14 +4179,14 @@ static void K_DoShrink(player_t *user) void K_DoPogoSpring(mobj_t *mo, fixed_t vertispeed, UINT8 sound) { - const fixed_t vscale = mapobjectscale + (mo->scale - mapobjectscale); - if (mo->player && mo->player->spectator) return; if (mo->eflags & MFE_SPRUNG) return; + const fixed_t vscale = mapobjectscale + (mo->scale - mapobjectscale); + mo->standingslope = NULL; mo->eflags |= MFE_SPRUNG; @@ -4901,7 +4600,7 @@ static void K_CalculateBananaSlope(mobj_t *mobj, fixed_t x, fixed_t y, fixed_t z //sec = R_PointInSubsector(x, y)->sector; if (mobj->x != x || mobj->y != y || mobj->subsector == NULL) - sec = R_PointInSubsector(x, y)->sector; + sec = R_PointInSubsectorFast(x, y)->sector; else sec = mobj->subsector->sector; @@ -5390,12 +5089,12 @@ player_t *K_FindJawzTarget(mobj_t *actor, player_t *source) // Engine Sounds. static void K_UpdateEngineSounds(player_t *player, ticcmd_t *cmd) { - const INT32 numsnds = 13; + static const INT32 numsnds = 13; - const fixed_t closedist = 160*FRACUNIT; - const fixed_t fardist = 1536*FRACUNIT; + static const fixed_t closedist = 160*FRACUNIT; + static const fixed_t fardist = 1536*FRACUNIT; - const UINT8 dampenval = 48; // 255 * 48 = close enough to FRACUNIT/6 + static const UINT8 dampenval = 48; // 255 * 48 = close enough to FRACUNIT/6 INT32 class, s, w; // engine class number @@ -5405,18 +5104,6 @@ static void K_UpdateEngineSounds(player_t *player, ticcmd_t *cmd) INT32 targetsnd = 0; INT32 i; - s = (player->kartspeed - 1) / 3; - w = (player->kartweight - 1) / 3; - -#define LOCKSTAT(stat) \ - if (stat < 0) { stat = 0; } \ - if (stat > 2) { stat = 2; } - LOCKSTAT(s); - LOCKSTAT(w); -#undef LOCKSTAT - - class = s + (3*w); - if (leveltime < 8 || player->spectator || player->exiting) { // Silence the engines, and reset sound number while we're at it. @@ -5522,13 +5209,25 @@ static void K_UpdateEngineSounds(player_t *player, ticcmd_t *cmd) return; } + s = (player->kartspeed - 1) / 3; + w = (player->kartweight - 1) / 3; + +#define LOCKSTAT(stat) \ + if (stat < 0) { stat = 0; } \ + if (stat > 2) { stat = 2; } + LOCKSTAT(s); + LOCKSTAT(w); +#undef LOCKSTAT + + class = s + (3*w); + S_StartSoundAtVolume(player->mo, (sfx_krta00 + player->kartstuff[k_enginesnd]) + (class * numsnds), volume); } static void K_UpdateInvincibilitySounds(player_t *player) { INT32 sfxnum = sfx_None; - boolean localplayer = P_IsLocalPlayer(player); + const boolean localplayer = P_IsLocalPlayer(player); if (player->mo->health > 0) { @@ -5594,21 +5293,14 @@ void K_KartPlayerHUDUpdate(player_t *player) static boolean K_SpeedLinesShouldBlend(player_t *player) { - fixed_t percentspeed = 0; - - if (!cv_playerblendeffects.value) - return false; - - if (!player->mo) + if (!cv_playerblendeffects.value || !player->mo) return false; if (player->kartstuff[k_sneakertimer]) return true; // this is how the percentage speedometer calcs, i suck at maths so this was the easiest thing to do lmao - percentspeed = (FixedDiv(player->speed, FixedMul(K_GetKartSpeed(player, false), ORIG_FRICTION))*100)>>FRACBITS; - - if (percentspeed > 127) // sneaker boost is around 25% + if ((FixedDiv(player->speed, FixedMul(K_GetKartSpeed(player, false), ORIG_FRICTION))*100)>>FRACBITS > 127) // sneaker boost is around 25% return true; return false; @@ -5724,6 +5416,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) else if (player->kartstuff[k_eggmanexplode]) // You're gonna diiiiie { const INT32 flashtime = 4<<(player->kartstuff[k_eggmanexplode]/TICRATE); + if (player->kartstuff[k_eggmanexplode] == 1 || (player->kartstuff[k_eggmanexplode] % (flashtime/2) != 0)) { player->mo->colorized = false; @@ -6055,6 +5748,7 @@ boolean K_CheckPlayersRespawnColliding(INT32 playernum, fixed_t x, fixed_t y) { INT32 i; fixed_t p1radius = players[playernum].mo->radius; + for (i = 0; i < MAXPLAYERS; i++) { if (playernum == i || !playeringame[i] || players[i].spectator || !players[i].mo || players[i].mo->health <= 0 @@ -6114,9 +5808,9 @@ INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue) return turnvalue; } - fixed_t p_topspeed = K_GetKartSpeed(player, false); - fixed_t p_curspeed = min(player->speed, p_topspeed * 2); - fixed_t p_maxspeed = p_topspeed * 3; + fixed_t p_topspeed = K_GetKartSpeed(player, false); + fixed_t p_curspeed = min(player->speed, p_topspeed * 2); + fixed_t p_maxspeed = p_topspeed * 3; fixed_t adjustangle = FixedDiv((p_maxspeed>>16) - (p_curspeed>>16), (p_maxspeed>>16) + player->kartweight); turnvalue = FixedMul(turnvalue, adjustangle); // Weight has a small effect on turning @@ -6337,7 +6031,7 @@ static void K_KartDrift(player_t *player, boolean onground) void K_KartUpdatePosition(player_t *player) { fixed_t position = 1; - fixed_t oldposition = player->kartstuff[k_position]; + fixed_t oldposition; fixed_t i, ppcd, pncd, ipcd, incd; fixed_t pmo, imo; mobj_t *mo; @@ -6345,6 +6039,8 @@ void K_KartUpdatePosition(player_t *player) if (player->spectator || !player->mo) return; + oldposition = player->kartstuff[k_position]; + for (i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i] || players[i].spectator || !players[i].mo) @@ -6366,32 +6062,47 @@ void K_KartUpdatePosition(player_t *player) // This checks every thing on the map, and looks for MT_BOSS3WAYPOINT (the thing we're using for checkpoint wp's, for now) for (mo = waypointcap; mo != NULL; mo = mo->tracer) { - pmo = P_AproxDistance(P_AproxDistance( mo->x - player->mo->x, - mo->y - player->mo->y), - mo->z - player->mo->z) / FRACUNIT; - imo = P_AproxDistance(P_AproxDistance( mo->x - players[i].mo->x, - mo->y - players[i].mo->y), - mo->z - players[i].mo->z) / FRACUNIT; + const boolean isprevcheckpointp = mo->health == player->starpostnum; + const boolean isnextcheckpointp = mo->health == (player->starpostnum + 1); - if (mo->health == player->starpostnum && (!mo->movecount || mo->movecount == player->laps+1)) + if ((isprevcheckpointp || isnextcheckpointp) && (!mo->movecount || mo->movecount == player->laps+1)) { - player->kartstuff[k_prevcheck] += pmo; - ppcd++; + pmo = P_AproxDistance(P_AproxDistance( mo->x - player->mo->x, + mo->y - player->mo->y), + mo->z - player->mo->z) / FRACUNIT; + + if (isprevcheckpointp) + { + player->kartstuff[k_prevcheck] += pmo; + ppcd++; + } + + if (isnextcheckpointp) + { + player->kartstuff[k_nextcheck] += pmo; + pncd++; + } } - if (mo->health == (player->starpostnum + 1) && (!mo->movecount || mo->movecount == player->laps+1)) + + const boolean isprevcheckpointi = mo->health == players[i].starpostnum; + const boolean isnextcheckpointi = mo->health == (players[i].starpostnum + 1); + + if ((isprevcheckpointi || isnextcheckpointi) && (!mo->movecount || mo->movecount == players[i].laps+1)) { - player->kartstuff[k_nextcheck] += pmo; - pncd++; - } - if (mo->health == players[i].starpostnum && (!mo->movecount || mo->movecount == players[i].laps+1)) - { - players[i].kartstuff[k_prevcheck] += imo; - ipcd++; - } - if (mo->health == (players[i].starpostnum + 1) && (!mo->movecount || mo->movecount == players[i].laps+1)) - { - players[i].kartstuff[k_nextcheck] += imo; - incd++; + imo = P_AproxDistance(P_AproxDistance( mo->x - players[i].mo->x, + mo->y - players[i].mo->y), + mo->z - players[i].mo->z) / FRACUNIT; + + if (isprevcheckpointi) + { + players[i].kartstuff[k_prevcheck] += imo; + ipcd++; + } + if (isnextcheckpointi ) + { + players[i].kartstuff[k_nextcheck] += imo; + incd++; + } } } @@ -7535,4424 +7246,3 @@ void K_UpdateSpectateGrief(void) } //} - -//{ SRB2kart HUD Code - -#define NUMPOSNUMS 10 -#define NUMPOSFRAMES 7 // White, three blues, three reds -#define NUMWINFRAMES 6 // Red, yellow, green, cyan, blue, purple - -//{ Patch Definitions -static patch_t *kp_nodraw; - -static patch_t *kp_timesticker; -static patch_t *kp_timestickerwide; -static patch_t *kp_lapsticker; -static patch_t *kp_lapstickerbig; -static patch_t *kp_lapstickerbig2; -static patch_t *kp_lapstickerwide; -//static patch_t *kp_lapstickernarrow; -static patch_t *kp_splitlapflag; -static patch_t *kp_bumpersticker; -static patch_t *kp_bumperstickerwide; -static patch_t *kp_karmasticker; -static patch_t *kp_splitkarmabomb; -static patch_t *kp_timeoutsticker; - -//Colourized hud -static patch_t *kp_timestickerclr; -static patch_t *kp_timestickerwideclr; -static patch_t *kp_lapstickerclr; -static patch_t *kp_lapstickerbigclr; -static patch_t *kp_lapstickerbig2clr; -static patch_t *kp_lapstickerwideclr; -//static patch_t *kp_lapstickernarrowclr; -static patch_t *kp_bumperstickerclr; -static patch_t *kp_bumperstickerwideclr; -static patch_t *kp_karmastickerclr; -static patch_t *kp_timeoutstickerclr; -static patch_t *skp_smallstickerclr; -static patch_t *skp_smallstickerclr3; -static patch_t *kp_itemmulstickerclr[2]; -static patch_t *kp_itembgclr[4]; - -//Kartz speedo -static patch_t *kp_kartzspeedo[25]; -static patch_t *kp_kartzspeedo_smol[25]; - -static patch_t *kp_startcountdown[16]; -static patch_t *kp_racefinish[6]; - -static patch_t *kp_positionnum[NUMPOSNUMS][NUMPOSFRAMES]; -static patch_t *kp_winnernum[NUMPOSFRAMES]; - -static patch_t *kp_facenum[MAXPLAYERS+1]; -static patch_t *kp_facehighlight[8]; - -static patch_t *kp_rankbumper; -static patch_t *kp_tinybumper[2]; -static patch_t *kp_ranknobumpers; - -static patch_t *kp_battlewin; -static patch_t *kp_battlecool; -static patch_t *kp_battlelose; -static patch_t *kp_battlewait; -static patch_t *kp_battleinfo; -static patch_t *kp_wanted; -static patch_t *kp_wantedsplit; -static patch_t *kp_wantedreticle; - -static patch_t *kp_itembg[4]; -static patch_t *kp_itemtimer[2]; -static patch_t *kp_itemmulsticker[2]; -static patch_t *kp_itemx; - -static patch_t *kp_sneaker[2]; -static patch_t *kp_multsneaker[2]; -static patch_t *kp_rocketsneaker[2]; -static patch_t *kp_invincibility[13]; -static patch_t *kp_banana[2]; -static patch_t *kp_multbanana[3]; -static patch_t *kp_eggman[2]; -static patch_t *kp_orbinaut[5]; -static patch_t *kp_jawz[2]; -static patch_t *kp_multjawz[1]; -static patch_t *kp_mine[2]; -static patch_t *kp_ballhog[2]; -static patch_t *kp_selfpropelledbomb[2]; -static patch_t *kp_grow[2]; -static patch_t *kp_shrink[2]; -static patch_t *kp_thundershield[2]; -static patch_t *kp_hyudoro[2]; -static patch_t *kp_pogospring[2]; -static patch_t *kp_kitchensink[2]; -static patch_t *kp_sadface[2]; - -static patch_t *kp_check[6]; - -static patch_t *kp_eggnum[4]; - -static patch_t *kp_fpview[3]; -static patch_t *kp_inputwheel[5]; - -static patch_t *kp_challenger[25]; - -static patch_t *kp_lapanim_lap[7]; -static patch_t *kp_lapanim_final[11]; -static patch_t *kp_lapanim_number[10][3]; -static patch_t *kp_lapanim_emblem[2]; -static patch_t *kp_lapanim_hand[3]; - -static patch_t *nametagpic; -static patch_t *nametagline; -static patch_t *nametagspeed; -static patch_t *nametagweight; - -static patch_t *driftgauge; -static patch_t *driftgaugecolor; -static patch_t *driftgaugesmall; -static patch_t *driftgaugesmallcolor; - -static patch_t *kp_yougotem; - -static patch_t *skp_smallsticker; -static patch_t *skp_smallsticker3; -static patch_t *skp_speedpatches[5]; - -static patch_t *skp_smallstickerachi; -static patch_t *skp_speedpatchesachi[5]; -static patch_t *skp_smallstickerachiclr; -static patch_t *skp_speedpatchesachiclr[5]; - -// dial speedometer -static patch_t *skp_rankfinish; -static patch_t *skp_dialbase[2]; -static patch_t *skp_speedpatchesdial[5]; -static patch_t *skp_dialnum[10]; -//static patch_t *skp_dialclr; -static patch_t *skp_dialbaseclr[2]; -static patch_t *skp_speedpatchesdialclr[5]; -static patch_t *skp_dialnumclr[10]; - -static patch_t *joybacking; -static patch_t *joyknob; -static patch_t *joyshadow; - -static patch_t *kp_minimapdot; - -void K_LoadKartHUDGraphics(void) -{ - INT32 i, j; - char buffer[9]; - - // Null Stuff - kp_nodraw = W_CachePatchName("K_TRNULL", PU_HUDGFX); - - // Stickers - kp_timesticker = W_CachePatchName("K_STTIME", PU_HUDGFX); - kp_timestickerwide = W_CachePatchName("K_STTIMW", PU_HUDGFX); - kp_lapsticker = W_CachePatchName("K_STLAPS", PU_HUDGFX); - kp_lapstickerwide = W_CachePatchName("K_STLAPW", PU_HUDGFX); - //kp_lapstickernarrow = W_CachePatchName("K_STLAPN", PU_HUDGFX); - kp_splitlapflag = W_CachePatchName("K_SPTLAP", PU_HUDGFX); - kp_bumpersticker = W_CachePatchName("K_STBALN", PU_HUDGFX); - kp_bumperstickerwide = W_CachePatchName("K_STBALW", PU_HUDGFX); - kp_karmasticker = W_CachePatchName("K_STKARM", PU_HUDGFX); - kp_splitkarmabomb = W_CachePatchName("K_SPTKRM", PU_HUDGFX); - kp_timeoutsticker = W_CachePatchName("K_STTOUT", PU_HUDGFX); - - if (xtra_speedo) // snowy speedometer - { - skp_smallsticker = W_CachePatchName("SP_SMSTC", PU_HUDGFX); - skp_speedpatches[0] = W_CachePatchName("K_TRNULL", PU_HUDGFX); // lolxd - skp_speedpatches[1] = W_CachePatchName("SP_MKMH", PU_HUDGFX); - skp_speedpatches[2] = W_CachePatchName("SP_MMPH", PU_HUDGFX); - skp_speedpatches[3] = W_CachePatchName("SP_MFRAC", PU_HUDGFX); - skp_speedpatches[4] = W_CachePatchName("SP_MPERC", PU_HUDGFX); - } - - if (xtra_speedo3) // 80x11 patch scaled to size - { - skp_smallsticker3 = W_CachePatchName("SP_SM3TC", PU_HUDGFX); - } - - if (achi_speedo) - { - skp_smallstickerachi = W_CachePatchName("SP_AMSTC", PU_HUDGFX); - skp_speedpatchesachi[0] = W_CachePatchName("K_TRNULL", PU_HUDGFX); // lolxd - skp_speedpatchesachi[1] = W_CachePatchName("SP_AKMH", PU_HUDGFX); - skp_speedpatchesachi[2] = W_CachePatchName("SP_AMPH", PU_HUDGFX); - skp_speedpatchesachi[3] = W_CachePatchName("SP_AFRAC", PU_HUDGFX); - skp_speedpatchesachi[4] = W_CachePatchName("SP_APERC", PU_HUDGFX); - } - - if (dial_speedo) - { - skp_rankfinish = W_CachePatchName("RANKFIN", PU_HUDGFX); - skp_dialbase[0] = W_CachePatchName("K_DSPBS1", PU_HUDGFX); - skp_dialbase[1] = W_CachePatchName("K_DSPBS2", PU_HUDGFX); - - skp_speedpatchesdial[0] = W_CachePatchName("K_TRNULL", PU_HUDGFX); // lolxd - skp_speedpatchesdial[1] = W_CachePatchName("SP_DKMH", PU_HUDGFX); - skp_speedpatchesdial[2] = W_CachePatchName("SP_DMPH", PU_HUDGFX); - skp_speedpatchesdial[3] = W_CachePatchName("SP_DFRAC", PU_HUDGFX); - skp_speedpatchesdial[4] = W_CachePatchName("SP_DPERC", PU_HUDGFX); - - sprintf(buffer, "K_DSPNMx"); - for (i = 0; i < 10; i++) - { - buffer[7] = '0'+(i%10); - skp_dialnum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); - } - } - - if (big_lap) - { - kp_lapstickerbig = W_CachePatchName("K_STLAPB", PU_HUDGFX); - kp_lapstickerbig2 = W_CachePatchName("K_STLA2B", PU_HUDGFX); - } - - // Colourized hud - if (clr_hud) - { - kp_timestickerclr = W_CachePatchName("K_SCTIME", PU_HUDGFX); - kp_timestickerwideclr = W_CachePatchName("K_SCTIMW", PU_HUDGFX); - kp_lapstickerclr = W_CachePatchName("K_SCLAPS", PU_HUDGFX); - kp_lapstickerwideclr = W_CachePatchName("K_SCLAPW", PU_HUDGFX); - kp_bumperstickerclr = W_CachePatchName("K_SCBALN", PU_HUDGFX); - kp_bumperstickerwideclr = W_CachePatchName("K_SCBALW", PU_HUDGFX); - kp_karmastickerclr = W_CachePatchName("K_SCKARM", PU_HUDGFX); - kp_timeoutstickerclr = W_CachePatchName("K_SCTOUT", PU_HUDGFX); - kp_itembgclr[0] = W_CachePatchName("K_ITBC" , PU_HUDGFX); - kp_itembgclr[1] = W_CachePatchName("K_ITBCD" , PU_HUDGFX); - kp_itembgclr[2] = W_CachePatchName("K_ISBC" , PU_HUDGFX); - kp_itembgclr[3] = W_CachePatchName("K_ISBCD" , PU_HUDGFX); - kp_itemmulstickerclr[1] = W_CachePatchName("K_ISMULC", PU_HUDGFX); - kp_itemmulstickerclr[0] = W_CachePatchName("K_ITMULC", PU_HUDGFX); - } - - if (big_lap_color) - { - kp_lapstickerbigclr = W_CachePatchName("K_SCLAPB", PU_HUDGFX); - kp_lapstickerbig2clr = W_CachePatchName("K_SCLA2B", PU_HUDGFX); - } - - if (xtra_speedo && xtra_speedo_clr) - skp_smallstickerclr = W_CachePatchName("SC_SMSTC", PU_HUDGFX); - - if (xtra_speedo3 && xtra_speedo_clr3) // 80x11 patch scaled to size - skp_smallstickerclr3 = W_CachePatchName("SC_SM3TC", PU_HUDGFX); - - if (achi_speedo && achi_speedo_clr) - { - skp_smallstickerachiclr = W_CachePatchName("SC_AMSTC", PU_HUDGFX); - skp_speedpatchesachiclr[0] = W_CachePatchName("K_TRNULL", PU_HUDGFX); // lolxd - skp_speedpatchesachiclr[1] = W_CachePatchName("SC_AKMH", PU_HUDGFX); - skp_speedpatchesachiclr[2] = W_CachePatchName("SC_AMPH", PU_HUDGFX); - skp_speedpatchesachiclr[3] = W_CachePatchName("SC_AFRAC", PU_HUDGFX); - skp_speedpatchesachiclr[4] = W_CachePatchName("SC_APERC", PU_HUDGFX); - } - - if (dial_speedo && dial_speedo_clr) - { - skp_dialbaseclr[0] = W_CachePatchName("K_DSPBC1", PU_HUDGFX); - skp_dialbaseclr[1] = W_CachePatchName("K_DSPBC2", PU_HUDGFX); - - skp_speedpatchesdialclr[0] = W_CachePatchName("K_TRNULL", PU_HUDGFX); // lolxd - skp_speedpatchesdialclr[1] = W_CachePatchName("SC_DKMH", PU_HUDGFX); - skp_speedpatchesdialclr[2] = W_CachePatchName("SC_DMPH", PU_HUDGFX); - skp_speedpatchesdialclr[3] = W_CachePatchName("SC_DFRAC", PU_HUDGFX); - skp_speedpatchesdialclr[4] = W_CachePatchName("SC_DPERC", PU_HUDGFX); - - sprintf(buffer, "K_DSPNCx"); - for (i = 0; i < 10; i++) - { - buffer[7] = '0'+(i%10); - skp_dialnumclr[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); - } - } - - // KartZ speedo - if (kartz_speedo) - { - const char* patchNames[] = { - "K_KZSP1", "K_KZSP2", "K_KZSP3", "K_KZSP4", "K_KZSP5", - "K_KZSP6", "K_KZSP7", "K_KZSP8", "K_KZSP9", "K_KZSP10", - "K_KZSP11", "K_KZSP12", "K_KZSP13", "K_KZSP14", "K_KZSP15", - "K_KZSP16", "K_KZSP17", "K_KZSP18", "K_KZSP19", "K_KZSP20", - "K_KZSP21", "K_KZSP22", "K_KZSP23", "K_KZSP24", "K_KZSP25" - }; - - for (size_t m = 0; m < sizeof(patchNames) / sizeof(patchNames[0]); ++m) - { - kp_kartzspeedo[m] = W_CachePatchName(patchNames[m], PU_HUDGFX); - } - } - - if (kartz_speedo_smol) - { - const char* patchNames[] = { - "K_KZSS1", "K_KZSS2", "K_KZSS3", "K_KZSS4", "K_KZSS5", - "K_KZSS6", "K_KZSS7", "K_KZSS8", "K_KZSS9", "K_KZSS10", - "K_KZSS11", "K_KZSS12", "K_KZSS13", "K_KZSS14", "K_KZSS15", - "K_KZSS16", "K_KZSS17", "K_KZSS18", "K_KZSS19", "K_KZSS20", - "K_KZSS21", "K_KZSS22", "K_KZSS23", "K_KZSS24", "K_KZSS25" - }; - - for (size_t m = 0; m < sizeof(patchNames) / sizeof(patchNames[0]); ++m) - { - kp_kartzspeedo_smol[m] = W_CachePatchName(patchNames[m], PU_HUDGFX); - } - } - - // Nametags - if (nametaggfx) - { - nametagpic = W_CachePatchName("NTLINE", PU_HUDGFX); - nametagline = W_CachePatchName("NTLINEV", PU_HUDGFX); - nametagspeed = W_CachePatchName("NTSP", PU_HUDGFX); - nametagweight = W_CachePatchName("NTWH", PU_HUDGFX); - } - - if (driftgaugegfx) - { - driftgauge = W_CachePatchName("K_DGAU", PU_HUDGFX); - driftgaugecolor = W_CachePatchName("K_DCAU", PU_HUDGFX); - } - - if (driftgaugegfx_clr) - { - driftgaugesmall = W_CachePatchName("K_DGSU", PU_HUDGFX); - driftgaugesmallcolor = W_CachePatchName("K_DCSU", PU_HUDGFX); - } - - if (joystickicon) - { - joybacking = W_CachePatchName("JOYBCK", PU_HUDGFX); - joyknob = W_CachePatchName("JOYKNB", PU_HUDGFX); - joyshadow = W_CachePatchName("JOYSHD", PU_HUDGFX); - } - - // Starting countdown - kp_startcountdown[0] = W_CachePatchName("K_CNT3A", PU_HUDGFX); - kp_startcountdown[1] = W_CachePatchName("K_CNT2A", PU_HUDGFX); - kp_startcountdown[2] = W_CachePatchName("K_CNT1A", PU_HUDGFX); - kp_startcountdown[3] = W_CachePatchName("K_CNTGOA", PU_HUDGFX); - kp_startcountdown[4] = W_CachePatchName("K_CNT3B", PU_HUDGFX); - kp_startcountdown[5] = W_CachePatchName("K_CNT2B", PU_HUDGFX); - kp_startcountdown[6] = W_CachePatchName("K_CNT1B", PU_HUDGFX); - kp_startcountdown[7] = W_CachePatchName("K_CNTGOB", PU_HUDGFX); - // Splitscreen - kp_startcountdown[8] = W_CachePatchName("K_SMC3A", PU_HUDGFX); - kp_startcountdown[9] = W_CachePatchName("K_SMC2A", PU_HUDGFX); - kp_startcountdown[10] = W_CachePatchName("K_SMC1A", PU_HUDGFX); - kp_startcountdown[11] = W_CachePatchName("K_SMCGOA", PU_HUDGFX); - kp_startcountdown[12] = W_CachePatchName("K_SMC3B", PU_HUDGFX); - kp_startcountdown[13] = W_CachePatchName("K_SMC2B", PU_HUDGFX); - kp_startcountdown[14] = W_CachePatchName("K_SMC1B", PU_HUDGFX); - kp_startcountdown[15] = W_CachePatchName("K_SMCGOB", PU_HUDGFX); - - // Finish - kp_racefinish[0] = W_CachePatchName("K_FINA", PU_HUDGFX); - kp_racefinish[1] = W_CachePatchName("K_FINB", PU_HUDGFX); - // Splitscreen - kp_racefinish[2] = W_CachePatchName("K_SMFINA", PU_HUDGFX); - kp_racefinish[3] = W_CachePatchName("K_SMFINB", PU_HUDGFX); - // 2P splitscreen - kp_racefinish[4] = W_CachePatchName("K_2PFINA", PU_HUDGFX); - kp_racefinish[5] = W_CachePatchName("K_2PFINB", PU_HUDGFX); - - // Position numbers - sprintf(buffer, "K_POSNxx"); - for (i = 0; i < NUMPOSNUMS; i++) - { - buffer[6] = '0'+i; - for (j = 0; j < NUMPOSFRAMES; j++) - { - //sprintf(buffer, "K_POSN%d%d", i, j); - buffer[7] = '0'+j; - kp_positionnum[i][j] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); - } - } - - sprintf(buffer, "K_POSNWx"); - for (i = 0; i < NUMWINFRAMES; i++) - { - buffer[7] = '0'+i; - kp_winnernum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); - } - - sprintf(buffer, "OPPRNKxx"); - for (i = 0; i <= MAXPLAYERS; i++) - { - buffer[6] = '0'+(i/10); - buffer[7] = '0'+(i%10); - kp_facenum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); - } - - sprintf(buffer, "K_CHILIx"); - for (i = 0; i < 8; i++) - { - buffer[7] = '0'+(i+1); - kp_facehighlight[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); - } - - // Extra ranking icons - kp_rankbumper = W_CachePatchName("K_BLNICO", PU_HUDGFX); - kp_tinybumper[0] = W_CachePatchName("K_BLNA", PU_HUDGFX); - kp_tinybumper[1] = W_CachePatchName("K_BLNB", PU_HUDGFX); - kp_ranknobumpers = W_CachePatchName("K_NOBLNS", PU_HUDGFX); - - // Battle graphics - kp_battlewin = W_CachePatchName("K_BWIN", PU_HUDGFX); - kp_battlecool = W_CachePatchName("K_BCOOL", PU_HUDGFX); - kp_battlelose = W_CachePatchName("K_BLOSE", PU_HUDGFX); - kp_battlewait = W_CachePatchName("K_BWAIT", PU_HUDGFX); - kp_battleinfo = W_CachePatchName("K_BINFO", PU_HUDGFX); - kp_wanted = W_CachePatchName("K_WANTED", PU_HUDGFX); - kp_wantedsplit = W_CachePatchName("4PWANTED", PU_HUDGFX); - kp_wantedreticle = W_CachePatchName("MMAPWANT", PU_HUDGFX); - - if (minidoticon) - kp_minimapdot = W_CachePatchName("MMAPDOT", PU_HUDGFX); - - // Kart Item Windows - kp_itembg[0] = W_CachePatchName("K_ITBG", PU_HUDGFX); - kp_itembg[1] = W_CachePatchName("K_ITBGD", PU_HUDGFX); - kp_itemtimer[0] = W_CachePatchName("K_ITIMER", PU_HUDGFX); - kp_itemmulsticker[0] = W_CachePatchName("K_ITMUL", PU_HUDGFX); - kp_itemx = W_CachePatchName("K_ITX", PU_HUDGFX); - - kp_sneaker[0] = W_CachePatchName("K_ITSHOE", PU_HUDGFX); - if (multiitem_icon) - { - kp_multsneaker[0] = W_CachePatchName("K_ITSHO2", PU_HUDGFX); - kp_multsneaker[1] = W_CachePatchName("K_ITSHO3", PU_HUDGFX); - } - kp_rocketsneaker[0] = W_CachePatchName("K_ITRSHE", PU_HUDGFX); - - sprintf(buffer, "K_ITINVx"); - for (i = 0; i < 7; i++) - { - buffer[7] = '1'+i; - kp_invincibility[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); - } - - kp_banana[0] = W_CachePatchName("K_ITBANA", PU_HUDGFX); - if (multiitem_icon) - { - kp_multbanana[0] = W_CachePatchName("K_ITBAN2", PU_HUDGFX); - kp_multbanana[1] = W_CachePatchName("K_ITBAN3", PU_HUDGFX); - kp_multbanana[2] = W_CachePatchName("K_ITBAN4", PU_HUDGFX); - } - kp_eggman[0] = W_CachePatchName("K_ITEGGM", PU_HUDGFX); - sprintf(buffer, "K_ITORBx"); - for (i = 0; i < 4; i++) - { - buffer[7] = '1'+i; - kp_orbinaut[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); - } - kp_jawz[0] = W_CachePatchName("K_ITJAWZ", PU_HUDGFX); - if (multiitem_icon) - { - kp_multjawz[0] = W_CachePatchName("K_ITJAW2", PU_HUDGFX); - } - kp_mine[0] = W_CachePatchName("K_ITMINE", PU_HUDGFX); - kp_ballhog[0] = W_CachePatchName("K_ITBHOG", PU_HUDGFX); - kp_selfpropelledbomb[0] = W_CachePatchName("K_ITSPB", PU_HUDGFX); - kp_grow[0] = W_CachePatchName("K_ITGROW", PU_HUDGFX); - kp_shrink[0] = W_CachePatchName("K_ITSHRK", PU_HUDGFX); - kp_thundershield[0] = W_CachePatchName("K_ITTHNS", PU_HUDGFX); - kp_hyudoro[0] = W_CachePatchName("K_ITHYUD", PU_HUDGFX); - kp_pogospring[0] = W_CachePatchName("K_ITPOGO", PU_HUDGFX); - kp_kitchensink[0] = W_CachePatchName("K_ITSINK", PU_HUDGFX); - kp_sadface[0] = W_CachePatchName("K_ITSAD", PU_HUDGFX); - - // Splitscreen - kp_itembg[2] = W_CachePatchName("K_ISBG", PU_HUDGFX); - kp_itembg[3] = W_CachePatchName("K_ISBGD", PU_HUDGFX); - kp_itemtimer[1] = W_CachePatchName("K_ISIMER", PU_HUDGFX); - kp_itemmulsticker[1] = W_CachePatchName("K_ISMUL", PU_HUDGFX); - - kp_sneaker[1] = W_CachePatchName("K_ISSHOE", PU_HUDGFX); - kp_rocketsneaker[1] = W_CachePatchName("K_ISRSHE", PU_HUDGFX); - sprintf(buffer, "K_ISINVx"); - for (i = 0; i < 6; i++) - { - buffer[7] = '1'+i; - kp_invincibility[i+7] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); - } - kp_banana[1] = W_CachePatchName("K_ISBANA", PU_HUDGFX); - kp_eggman[1] = W_CachePatchName("K_ISEGGM", PU_HUDGFX); - kp_orbinaut[4] = W_CachePatchName("K_ISORBN", PU_HUDGFX); - kp_jawz[1] = W_CachePatchName("K_ISJAWZ", PU_HUDGFX); - kp_mine[1] = W_CachePatchName("K_ISMINE", PU_HUDGFX); - kp_ballhog[1] = W_CachePatchName("K_ISBHOG", PU_HUDGFX); - kp_selfpropelledbomb[1] = W_CachePatchName("K_ISSPB", PU_HUDGFX); - kp_grow[1] = W_CachePatchName("K_ISGROW", PU_HUDGFX); - kp_shrink[1] = W_CachePatchName("K_ISSHRK", PU_HUDGFX); - kp_thundershield[1] = W_CachePatchName("K_ISTHNS", PU_HUDGFX); - kp_hyudoro[1] = W_CachePatchName("K_ISHYUD", PU_HUDGFX); - kp_pogospring[1] = W_CachePatchName("K_ISPOGO", PU_HUDGFX); - kp_kitchensink[1] = W_CachePatchName("K_ISSINK", PU_HUDGFX); - kp_sadface[1] = W_CachePatchName("K_ISSAD", PU_HUDGFX); - - // CHECK indicators - sprintf(buffer, "K_CHECKx"); - for (i = 0; i < 6; i++) - { - buffer[7] = '1'+i; - kp_check[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); - } - - // Eggman warning numbers - sprintf(buffer, "K_EGGNx"); - for (i = 0; i < 4; i++) - { - buffer[6] = '0'+i; - kp_eggnum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); - } - - // First person mode - kp_fpview[0] = W_CachePatchName("VIEWA0", PU_HUDGFX); - kp_fpview[1] = W_CachePatchName("VIEWB0D0", PU_HUDGFX); - kp_fpview[2] = W_CachePatchName("VIEWC0E0", PU_HUDGFX); - - // Input UI Wheel - sprintf(buffer, "K_WHEELx"); - for (i = 0; i < 5; i++) - { - buffer[7] = '0'+i; - kp_inputwheel[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); - } - - // HERE COMES A NEW CHALLENGER - sprintf(buffer, "K_CHALxx"); - for (i = 0; i < 25; i++) - { - buffer[6] = '0'+((i+1)/10); - buffer[7] = '0'+((i+1)%10); - kp_challenger[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); - } - - // Lap start animation - sprintf(buffer, "K_LAP0x"); - for (i = 0; i < 7; i++) - { - buffer[6] = '0'+(i+1); - kp_lapanim_lap[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); - } - - sprintf(buffer, "K_LAPFxx"); - for (i = 0; i < 11; i++) - { - buffer[6] = '0'+((i+1)/10); - buffer[7] = '0'+((i+1)%10); - kp_lapanim_final[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); - } - - sprintf(buffer, "K_LAPNxx"); - for (i = 0; i < 10; i++) - { - buffer[6] = '0'+i; - for (j = 0; j < 3; j++) - { - buffer[7] = '0'+(j+1); - kp_lapanim_number[i][j] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); - } - } - - sprintf(buffer, "K_LAPE0x"); - for (i = 0; i < 2; i++) - { - buffer[7] = '0'+(i+1); - kp_lapanim_emblem[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); - } - - sprintf(buffer, "K_LAPH0x"); - for (i = 0; i < 3; i++) - { - buffer[7] = '0'+(i+1); - kp_lapanim_hand[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); - } - - kp_yougotem = (patch_t *) W_CachePatchName("YOUGOTEM", PU_HUDGFX); -} - -// For the item toggle menu -const char *K_GetItemPatch(UINT8 item, boolean tiny) -{ - switch (item) - { - case KITEM_SNEAKER: - case KRITEM_TRIPLESNEAKER: - return (tiny ? "K_ISSHOE" : "K_ITSHOE"); - case KITEM_ROCKETSNEAKER: - return (tiny ? "K_ISRSHE" : "K_ITRSHE"); - case KITEM_INVINCIBILITY: - return (tiny ? "K_ISINV1" : "K_ITINV1"); - case KITEM_BANANA: - case KRITEM_TRIPLEBANANA: - case KRITEM_TENFOLDBANANA: - return (tiny ? "K_ISBANA" : "K_ITBANA"); - case KITEM_EGGMAN: - return (tiny ? "K_ISEGGM" : "K_ITEGGM"); - case KITEM_ORBINAUT: - return (tiny ? "K_ISORBN" : "K_ITORB1"); - case KITEM_JAWZ: - case KRITEM_DUALJAWZ: - return (tiny ? "K_ISJAWZ" : "K_ITJAWZ"); - case KITEM_MINE: - return (tiny ? "K_ISMINE" : "K_ITMINE"); - case KITEM_BALLHOG: - return (tiny ? "K_ISBHOG" : "K_ITBHOG"); - case KITEM_SPB: - return (tiny ? "K_ISSPB" : "K_ITSPB"); - case KITEM_GROW: - return (tiny ? "K_ISGROW" : "K_ITGROW"); - case KITEM_SHRINK: - return (tiny ? "K_ISSHRK" : "K_ITSHRK"); - case KITEM_THUNDERSHIELD: - return (tiny ? "K_ISTHNS" : "K_ITTHNS"); - case KITEM_HYUDORO: - return (tiny ? "K_ISHYUD" : "K_ITHYUD"); - case KITEM_POGOSPRING: - return (tiny ? "K_ISPOGO" : "K_ITPOGO"); - case KITEM_KITCHENSINK: - return (tiny ? "K_ISSINK" : "K_ITSINK"); - case KRITEM_TRIPLEORBINAUT: - return (tiny ? "K_ISORBN" : "K_ITORB3"); - case KRITEM_QUADORBINAUT: - return (tiny ? "K_ISORBN" : "K_ITORB4"); - default: - return (tiny ? "K_ISSAD" : "K_ITSAD"); - } -} - -//} - -INT32 ITEM_X, ITEM_Y; // Item Window -INT32 TIME_X, TIME_Y; // Time Sticker -INT32 LAPS_X, LAPS_Y; // Lap Sticker -INT32 SPDM_X, SPDM_Y; // Speedometer -INT32 POSI_X, POSI_Y; // Position Number -INT32 FACE_X, FACE_Y; // Top-four Faces -INT32 STCD_X, STCD_Y; // Starting countdown -INT32 CHEK_Y; // CHECK graphic -INT32 MINI_X, MINI_Y; // Minimap -INT32 WANT_X, WANT_Y; // Battle WANTED poster - -// This is for the P2 and P4 side of splitscreen. Then we'll flip P1's and P2's to the bottom with V_SPLITSCREEN. -INT32 ITEM2_X, ITEM2_Y; -INT32 LAPS2_X, LAPS2_Y; -INT32 POSI2_X, POSI2_Y; - - -static void K_initKartHUD(void) -{ - /* - BASEVIDWIDTH = 320 - BASEVIDHEIGHT = 200 - - Item window graphic is 41 x 33 - - Time Sticker graphic is 116 x 11 - Time Font is a solid block of (8 x [12) x 14], equal to 96 x 14 - Therefore, timestamp is 116 x 14 altogether - - Lap Sticker is 80 x 11 - Lap flag is 22 x 20 - Lap Font is a solid block of (3 x [12) x 14], equal to 36 x 14 - Therefore, lapstamp is 80 x 20 altogether - - Position numbers are 43 x 53 - - Faces are 32 x 32 - Faces draw downscaled at 16 x 16 - Therefore, the allocated space for them is 16 x 67 altogether - - ---- - - ORIGINAL CZ64 SPLITSCREEN: - - Item window: - if (!splitscreen) { ICONX = 139; ICONY = 20; } - else { ICONX = BASEVIDWIDTH-315; ICONY = 60; } - - Time: 236, STRINGY( 12) - Lap: BASEVIDWIDTH-304, STRINGY(BASEVIDHEIGHT-189) - - */ - - // Single Screen (defaults) - // Item Window - ITEM_X = 5 + cv_item_xoffset.value; // 5 - ITEM_Y = 5 + cv_item_yoffset.value; // 5 - // Level Timer - TIME_X = BASEVIDWIDTH - 148 + cv_time_xoffset.value; // 172 - TIME_Y = 9 + cv_time_yoffset.value; // 9 - // Level Laps - LAPS_X = 9 + cv_laps_xoffset.value; // 9 - LAPS_Y = BASEVIDHEIGHT - 29 + cv_laps_yoffset.value; // 171 - // Speedometer - SPDM_X = 9 + cv_speed_xoffset.value; // 9 - SPDM_Y = BASEVIDHEIGHT - 45 + cv_speed_yoffset.value; // 155 - // Position Number - POSI_X = BASEVIDWIDTH - 9 + cv_posi_xoffset.value; // 268 - POSI_Y = BASEVIDHEIGHT - 9 + cv_posi_yoffset.value; // 138 - // Top-Four Faces - FACE_X = 9 + cv_face_xoffset.value; // 9 - FACE_Y = 92 + cv_face_yoffset.value; // 92 - // Starting countdown - STCD_X = BASEVIDWIDTH/2 + cv_stcd_xoffset.value; // 9 - STCD_Y = BASEVIDHEIGHT/2 + cv_stcd_yoffset.value; // 92 - // CHECK graphic - CHEK_Y = BASEVIDHEIGHT + cv_chek_yoffset.value; // 200 - // Minimap - MINI_X = BASEVIDWIDTH - 50 + cv_mini_xoffset.value; // 270 - MINI_Y = (BASEVIDHEIGHT/2)-16 + cv_mini_yoffset.value; // 84 - // Battle WANTED poster - WANT_X = BASEVIDWIDTH - 55 + cv_want_xoffset.value; // 270 - WANT_Y = BASEVIDHEIGHT- 71 + cv_want_yoffset.value; // 176 - - if (splitscreen) // Splitscreen - { - ITEM_X = 5; - ITEM_Y = 3; - - LAPS_Y = (BASEVIDHEIGHT/2)-24; - - POSI_Y = (BASEVIDHEIGHT/2)- 2; - - STCD_Y = BASEVIDHEIGHT/4; - - MINI_Y = (BASEVIDHEIGHT/2); - - if (splitscreen > 1) // 3P/4P Small Splitscreen - { - // 1P (top left) - ITEM_X = -9; - ITEM_Y = -8; - - LAPS_X = 3; - LAPS_Y = (BASEVIDHEIGHT/2)-13; - - POSI_X = 24; - POSI_Y = (BASEVIDHEIGHT/2)- 16; - - // 2P (top right) - ITEM2_X = BASEVIDWIDTH-39; - ITEM2_Y = -8; - - LAPS2_X = BASEVIDWIDTH-3; - LAPS2_Y = (BASEVIDHEIGHT/2)-13; - - POSI2_X = BASEVIDWIDTH -4; - POSI2_Y = (BASEVIDHEIGHT/2)- 16; - - // Reminder that 3P and 4P are just 1P and 2P splitscreen'd to the bottom. - - STCD_X = BASEVIDWIDTH/4; - - MINI_X = (3*BASEVIDWIDTH/4); - MINI_Y = (3*BASEVIDHEIGHT/4); - - if (splitscreen > 2) // 4P-only - { - MINI_X = (BASEVIDWIDTH/2); - MINI_Y = (BASEVIDHEIGHT/2); - } - } - } - - if (timeinmap > 113 || forceshowhud) - hudtrans = cv_translucenthud.value; - else if (timeinmap > 105) - hudtrans = ((((INT32)timeinmap) - 105)*cv_translucenthud.value)/(113-105); - else - hudtrans = 0; - - // K_GetScreenCoords needs the right view* variables - R_SetViewContext(stplyrnum); - R_InterpolateView(rendertimefrac_unpaused, !cv_uncappedhud.value); -} - -INT32 K_calcSplitFlags(INT32 snapflags) -{ - INT32 splitflags = 0; - - if (splitscreen == 0) - return snapflags; - - if (stplyrnum != 0) - { - if (splitscreen == 1 && stplyrnum == 1) - { - splitflags |= V_SPLITSCREEN; - } - else if (splitscreen > 1) - { - if (stplyrnum == 2 || (splitscreen == 3 && stplyrnum == 3)) - splitflags |= V_SPLITSCREEN; - if (stplyrnum == 1 || (splitscreen == 3 && stplyrnum == 3)) - splitflags |= V_HORZSCREEN; - } - } - - if (splitflags & V_SPLITSCREEN) - snapflags &= ~V_SNAPTOTOP; - else - snapflags &= ~V_SNAPTOBOTTOM; - - if (splitscreen > 1) - { - if (splitflags & V_HORZSCREEN) - snapflags &= ~V_SNAPTOLEFT; - else - snapflags &= ~V_SNAPTORIGHT; - } - - return (splitflags|snapflags); -} - -void K_getItemBoxDrawinfo(drawinfo_t *out) -{ - INT32 fx, fy, fflags; - - // pain and suffering defined below - if (splitscreen < 2) // don't change shit for THIS splitscreen. - { - fx = ITEM_X; - fy = ITEM_Y; - fflags = K_calcSplitFlags(V_SNAPTOTOP|V_SNAPTOLEFT); - } - else // now we're having a fun game. - { - if (!(stplyrnum & 1)) // If we are P1 or P3... - { - fx = ITEM_X; - fy = ITEM_Y; - fflags = V_SNAPTOLEFT|(stplyrnum & 2 ? V_SPLITSCREEN : V_SNAPTOTOP); // flip P3 to the bottom. - } - else // else, that means we're P2 or P4. - { - fx = ITEM2_X; - fy = ITEM2_Y; - fflags = V_SNAPTORIGHT|(stplyrnum & 2 ? V_SPLITSCREEN : V_SNAPTOTOP); // flip P4 to the bottom - } - } - - out->x = fx; - out->y = fy; - out->flags = fflags; -} - -void K_getLapsDrawinfo(drawinfo_t *out) -{ - INT32 fx, fy, fflags; - - // pain and suffering defined below - if (splitscreen < 2) // don't change shit for THIS splitscreen. - { - fx = LAPS_X; - fy = LAPS_Y; - fflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTOLEFT); - } - else - { - if (!(stplyrnum & 1)) // If we are P1 or P3... - { - fx = LAPS_X; - fy = LAPS_Y; - fflags = V_SNAPTOLEFT|(stplyrnum & 2 ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. - } - else // else, that means we're P2 or P4. - { - fx = LAPS2_X; - fy = LAPS2_Y; - fflags = V_SNAPTORIGHT|(stplyrnum & 2 ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom - } - } - - out->x = fx; - out->y = fy; - out->flags = fflags; -} - -void K_getMinimapDrawinfo(drawinfo_t *out) -{ - INT32 fx = MINI_X, fy = MINI_Y, fflags = (splitscreen == 3 ? 0 : V_SNAPTORIGHT); // flags should only be 0 when it's centered (4p split) - - out->x = fx; - out->y = fy; - out->flags = fflags; -} - -INT32 K_getMinimapTrans(void) -{ - INT32 minimaptrans = cv_kartminimap.value; - - if (!minimaptrans) - return -1; - - if (forceshowhud) - return (10-minimaptrans)<kartstuff[k_bumper] ? -5 : -8) : 0); - - // Customizations c: - if (!splitscreen) - { - x += 18 + cv_stat_xoffset.value + spdxoffset; - y += cv_stat_yoffset.value + spdoffset; - } - else if (splitscreen == 1) // I tried my best, but this is still mess :/ < :Blobcatpats: c: - { - x -= 10; - y -= 40; - y += spdoffset; - - // If we are in 2-player splitscreen, for player 1 we move hud to up and remove snapping - // to bottom - if (splitnum == 0) - { - y /= 2; - flags = V_SNAPTOLEFT; - } - else - { - // Can move it down a bit - y += 45; - } - } - else - { - if (splitnum == 0 || splitnum == 2) // If we are P1 or P3... - { - // ye i just align it to position number lol - x = POSI_X + 19; - y = POSI_Y - 6; - flags = V_SNAPTOLEFT|((splitnum == 2) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. - } - else // else, that means we're P2 or P4. - { - x = POSI2_X - 75; - y = POSI2_Y - 6; - flags = V_SNAPTORIGHT|((splitnum == 3) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom - } - } - - flags |= V_HUDTRANS; - - skin_t *fakeskin; - fakeskin = K_GetPlayerSkin(stplyr); - - if (!splitscreen) - { - // Skin name - if (K_IsHighResolution()) // V_DrawSmallString becomes a mess at low resolutions lel - { - V_DrawSmallString(x+20, y+12, flags|V_ALLOWLOWERCASE|V_SkinColorToHighlightcolor(stplyr->skincolor), fakeskin->realname); - } - else - { - V_DrawThinString(x+20, y+7, flags|V_ALLOWLOWERCASE|V_SkinColorToHighlightcolor(stplyr->skincolor), fakeskin->realname); - } - - // Icon and stats - if (K_UseHighResPortraits()) - V_DrawSmallMappedPatch(x, y, flags, R_GetSkinFaceWant(stplyr), R_GetLocalTranslationColormap(fakeskin, fakeskin, stplyr->skincolor, GTC_CACHE, stplyr->skinlocal)); - else - V_DrawMappedPatch(x, y, flags, R_GetSkinFaceRank(stplyr), R_GetLocalTranslationColormap(fakeskin, fakeskin, stplyr->skincolor, GTC_CACHE, stplyr->skinlocal)); - - V_DrawMappedPatch(x-3, y-2, flags, kp_facenum[min(9, max(1, stplyr->kartspeed))], R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_BLUEBERRY, GTC_CACHE)); - V_DrawMappedPatch(x+10, y+10, flags, kp_facenum[min(9, max(1, stplyr->kartweight))], R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_BURGUNDY, GTC_CACHE)); - } - else - { - // In splitscreen, just draw a string with stats - V_DrawString(x, y+10, flags, va("\x84%dS \x87%dW", stplyr->kartspeed, stplyr->kartweight)); - } -} - -static void K_drawKartItem(void) -{ - // ITEM_X = BASEVIDWIDTH-50; // 270 - // ITEM_Y = 24; // 24 - - // Why write V_DrawScaledPatch calls over and over when they're all the same? - // Set to 'no item' just in case. - const UINT8 offset = ((splitscreen > 1) ? 1 : 0); - patch_t *localpatch = kp_nodraw; - patch_t *localbg; - boolean dark = false; - - patch_t *localinv = ((offset) ? kp_invincibility[((leveltime % (6*3)) / 3) + 7] : kp_invincibility[(leveltime % (7*3)) / 3]); - INT32 fx = 0, fy = 0, fflags = 0; // final coords for hud and flags... - //INT32 splitflags = K_calcSplitFlags(V_SNAPTOTOP|V_SNAPTOLEFT); - INT32 numberdisplaymin = cv_huditemamount.value == 2 ? 1 : 2; // No longer a constant so other things can modify this value - INT32 itembar = 0; - INT32 maxl = 0; // itembar's normal highest value - const INT32 barlength = (splitscreen > 1 ? 12 : 26); - UINT8 localcolor = SKINCOLOR_NONE; - SINT8 colormode = TC_RAINBOW; - UINT8 *colmap = NULL; - UINT8 *colormap = NULL; - - boolean flipamount = splitscreen > 1 && stplyrnum & 1; // Used for 3P/4P splitscreen to flip item amount stuff - - const boolean usemultiicon = (multiitem_icon && cv_multiitemicon.value && !offset); - - if (stplyr->kartstuff[k_itemroulette]) - { - localcolor = K_GetHudColor(); - - switch((stplyr->kartstuff[k_itemroulette] % (14*3)) / 3) - { - // Each case is handled in threes, to give three frames of in-game time to see the item on the roulette - case 0: // Sneaker - localpatch = kp_sneaker[offset]; - //localcolor = SKINCOLOR_RASPBERRY; - break; - case 1: // Banana - localpatch = kp_banana[offset]; - //localcolor = SKINCOLOR_YELLOW; - break; - case 2: // Orbinaut - localpatch = kp_orbinaut[3+offset]; - //localcolor = SKINCOLOR_STEEL; - break; - case 3: // Mine - localpatch = kp_mine[offset]; - //localcolor = SKINCOLOR_JET; - break; - case 4: // Grow - localpatch = kp_grow[offset]; - //localcolor = SKINCOLOR_TEAL; - break; - case 5: // Hyudoro - localpatch = kp_hyudoro[offset]; - //localcolor = SKINCOLOR_STEEL; - break; - case 6: // Rocket Sneaker - localpatch = kp_rocketsneaker[offset]; - //localcolor = SKINCOLOR_TANGERINE; - break; - case 7: // Jawz - localpatch = kp_jawz[offset]; - //localcolor = SKINCOLOR_JAWZ; - break; - case 8: // Self-Propelled Bomb - localpatch = kp_selfpropelledbomb[offset]; - //localcolor = SKINCOLOR_JET; - break; - case 9: // Shrink - localpatch = kp_shrink[offset]; - //localcolor = SKINCOLOR_ORANGE; - break; - case 10: // Invincibility - localpatch = localinv; - //localcolor = SKINCOLOR_GREY; - break; - case 11: // Eggman Monitor - localpatch = kp_eggman[offset]; - //localcolor = SKINCOLOR_ROSE; - break; - case 12: // Ballhog - localpatch = kp_ballhog[offset]; - //localcolor = SKINCOLOR_LILAC; - break; - case 13: // Thunder Shield - localpatch = kp_thundershield[offset]; - //localcolor = SKINCOLOR_CYAN; - break; - /*case 14: // Pogo Spring - localpatch = kp_pogospring[offset]; - localcolor = SKINCOLOR_TANGERINE; - break; - case 15: // Kitchen Sink - localpatch = kp_kitchensink[offset]; - localcolor = SKINCOLOR_STEEL; - break;*/ - default: - break; - } - } - else - { - // I'm doing this a little weird and drawing mostly in reverse order - // The only actual reason is to make sneakers line up this way in the code below - // This shouldn't have any actual baring over how it functions - // Hyudoro is first, because we're drawing it on top of the player's current item - if (stplyr->kartstuff[k_stolentimer] > 0) - { - if (leveltime & 2) - localpatch = kp_hyudoro[offset]; - else - localpatch = kp_nodraw; - } - else if ((stplyr->kartstuff[k_stealingtimer] > 0) && (leveltime & 2)) - { - localpatch = kp_hyudoro[offset]; - } - else if (stplyr->kartstuff[k_eggmanexplode] > 1) - { - if (leveltime & 1) - localpatch = kp_eggman[offset]; - else - localpatch = kp_nodraw; - } - else if (stplyr->kartstuff[k_rocketsneakertimer] > 1) - { - itembar = stplyr->kartstuff[k_rocketsneakertimer]; - maxl = (itemtime*3) - barlength; - - if (leveltime & 1) - localpatch = kp_rocketsneaker[offset]; - else - localpatch = kp_nodraw; - } - else if (stplyr->kartstuff[k_growshrinktimer] > 0) - { - if (stplyr->kartstuff[k_growcancel] > 0) - { - itembar = stplyr->kartstuff[k_growcancel]; - maxl = 26; - } - - if (leveltime & 1) - localpatch = kp_grow[offset]; - else - localpatch = kp_nodraw; - } - else if (stplyr->kartstuff[k_sadtimer] > 0) - { - if (leveltime & 2) - localpatch = kp_sadface[offset]; - else - localpatch = kp_nodraw; - } - else - { - if (stplyr->kartstuff[k_itemamount] <= 0) - return; - - switch(stplyr->kartstuff[k_itemtype]) - { - case KITEM_SNEAKER: - if (usemultiicon) - { - if (!cv_huditemamount.value) - numberdisplaymin = 4; - switch(stplyr->kartstuff[k_itemamount]) - { - case 1: - localpatch = kp_sneaker[offset]; - break; - case 2: - localpatch = kp_multsneaker[0]; - break; - default: - localpatch = kp_multsneaker[1]; - break; - } - } - else - { - localpatch = kp_sneaker[offset]; - } - break; - case KITEM_ROCKETSNEAKER: - localpatch = kp_rocketsneaker[offset]; - break; - case KITEM_INVINCIBILITY: - localpatch = localinv; - dark = true; - break; - case KITEM_BANANA: - if (usemultiicon) - { - if (!cv_huditemamount.value) - numberdisplaymin = 4; - switch(stplyr->kartstuff[k_itemamount]) - { - case 1: - localpatch = kp_banana[offset]; - break; - case 2: - localpatch = kp_multbanana[0]; - break; - case 3: - localpatch = kp_multbanana[1]; - break; - default: - localpatch = kp_multbanana[2]; - break; - } - } - else - { - localpatch = kp_banana[offset]; - } - break; - case KITEM_EGGMAN: - localpatch = kp_eggman[offset]; - break; - case KITEM_ORBINAUT: - if (!cv_huditemamount.value) - numberdisplaymin = offset ? 2 : 5; - localpatch = kp_orbinaut[(offset ? 4 : min(stplyr->kartstuff[k_itemamount]-1, 3))]; - break; - case KITEM_JAWZ: - if (usemultiicon) - { - if (!cv_huditemamount.value) - numberdisplaymin = 3; - localpatch = ((stplyr->kartstuff[k_itemamount] == 1) ? kp_jawz[offset] : kp_multjawz[0]); - } - else - { - localpatch = kp_jawz[offset]; - } - break; - case KITEM_MINE: - localpatch = kp_mine[offset]; - break; - case KITEM_BALLHOG: - localpatch = kp_ballhog[offset]; - break; - case KITEM_SPB: - localpatch = kp_selfpropelledbomb[offset]; - dark = true; - break; - case KITEM_GROW: - localpatch = kp_grow[offset]; - break; - case KITEM_SHRINK: - localpatch = kp_shrink[offset]; - break; - case KITEM_THUNDERSHIELD: - localpatch = kp_thundershield[offset]; - dark = true; - break; - case KITEM_HYUDORO: - localpatch = kp_hyudoro[offset]; - break; - case KITEM_POGOSPRING: - localpatch = kp_pogospring[offset]; - break; - case KITEM_KITCHENSINK: - localpatch = kp_kitchensink[offset]; - break; - case KITEM_SAD: - localpatch = kp_sadface[offset]; - break; - default: - return; - } - - if (stplyr->kartstuff[k_itemheld] && !(leveltime & 1)) - localpatch = kp_nodraw; - } - - if (stplyr->kartstuff[k_itemblink] && (leveltime & 1)) - { - colormode = TC_BLINK; - - switch (stplyr->kartstuff[k_itemblinkmode]) - { - case 2: - localcolor = (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))); - break; - case 1: - localcolor = SKINCOLOR_RED; - break; - default: - localcolor = SKINCOLOR_WHITE; - break; - } - } - } - - localbg = K_getItemBoxPatch((boolean)offset, dark); - drawinfo_t info; - K_getItemBoxDrawinfo(&info); - fx = info.x; - fy = info.y; - fflags = info.flags; - - if (K_UseColorHud()) - colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - - V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, localbg, cv_colorizeditembox.value ? colormap : NULL); - - fixed_t rfy = fy<kartstuff[k_itemroulette] && !stplyr->deadtimer) - { - fixed_t frac = R_GetHudUncap(); - UINT8 fancystep = (offset ? 6 : 10); - fixed_t fancyoffset = (stplyr->kartstuff[k_itemroulette] % 3)-1; - - if (fancyoffset != 0) - { - fancyflags &= ~V_HUDTRANS; - fancyflags |=V_HUDTRANSHALF; - } - - rfy += (fancystep * fancyoffset * FRACUNIT) + FixedMul(fancystep*FRACUNIT, frac) - fancystep/2*FRACUNIT; - } - - if (localcolor != SKINCOLOR_NONE) - colmap = R_GetTranslationColormap(colormode, localcolor, GTC_CACHE); - - // Then, the numbers: - if (stplyr->kartstuff[k_itemamount] >= numberdisplaymin && !stplyr->kartstuff[k_itemroulette]) - { - localbg = K_getItemMulPatch((boolean)offset); - - V_DrawMappedPatch(fx + (flipamount ? 48 : 0), fy, V_HUDTRANS|fflags|(flipamount ? V_FLIP : 0), localbg, colormap); // flip this graphic for p2 and p4 in split and shift it. - V_DrawFixedPatch(fx<kartstuff[k_itemamount])); - } - else - { - V_DrawScaledPatch(fx+28, fy+41, V_HUDTRANS|fflags, kp_itemx); - V_DrawKartString(fx+38, fy+36, V_HUDTRANS|fflags, va("%d", stplyr->kartstuff[k_itemamount])); - } - } - else - V_DrawFixedPatch(fx< 2) - { - V_DrawFill(fx+x+length, fy+y+1, 1, height, 12|fflags); // the right one - if (height == 2) - V_DrawFill(fx+x+2, fy+y+2, length-2, 1, 8|fflags); // the dulled underside - V_DrawFill(fx+x+2, fy+y+1, length-2, 1, 120|fflags); // the shine - } - } - - // Quick Eggman numbers - if (stplyr->kartstuff[k_eggmanexplode] > 1 /*&& stplyr->kartstuff[k_eggmanexplode] <= 3*TICRATE*/) - V_DrawScaledPatch(fx+17, fy+13-offset, V_HUDTRANS|fflags, kp_eggnum[min(3, G_TicsToSeconds(stplyr->kartstuff[k_eggmanexplode]))]); - -} - -void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UINT8 mode) -{ - // TIME_X = BASEVIDWIDTH-124; // 196 - // TIME_Y = 6; // 6 - - INT32 splitflags = 0; - if (!mode) - { - splitflags = V_HUDTRANS|K_calcSplitFlags(V_SNAPTOTOP|V_SNAPTORIGHT); - if (cv_timelimit.value && timelimitintics > 0) - { - if (drawtime >= timelimitintics) - drawtime = 0; - else - drawtime = timelimitintics - drawtime; - } - } - - if (K_UseColorHud()) // Colourized hud - { - UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - V_DrawMappedPatch(TX, TY, splitflags, ((mode == 2) ? kp_lapstickerwideclr : kp_timestickerwideclr), colormap); - } - else - V_DrawScaledPatch(TX, TY, splitflags, ((mode == 2) ? kp_lapstickerwide : kp_timestickerwide)); - - TX += 33; - - if (drawtime == UINT32_MAX) - ; - else if (mode && !drawtime) - { - V_DrawKartString(TX, TY+3, splitflags, va("--'--\"--")); - } - else - { - tic_t worktime = drawtime/(60*TICRATE); - - if (cv_timelimit.value && cv_overtime.value && G_BattleGametype() && !players[consoleplayer].exiting && (leveltime > (timelimitintics + starttime + TICRATE/2))) // i hate this so much - { - V_DrawKartString(TX, TY+3, splitflags, va("OVERTIME")); - } - else if (worktime < 100) - { - // minutes time 00 __ __ - V_DrawKartString(TX, TY+3, splitflags, va("%d", worktime/10)); - V_DrawKartString(TX+12, TY+3, splitflags, va("%d", worktime%10)); - - // apostrophe location _'__ __ - V_DrawKartString(TX+24, TY+3, splitflags, va("'")); - - worktime = (drawtime/TICRATE % 60); - - // seconds time _ 00 __ - V_DrawKartString(TX+36, TY+3, splitflags, va("%d", worktime/10)); - V_DrawKartString(TX+48, TY+3, splitflags, va("%d", worktime%10)); - - // quotation mark location _ __"__ - V_DrawKartString(TX+60, TY+3, splitflags, va("\"")); - - worktime = G_TicsToCentiseconds(drawtime); - - // tics _ __ 00 - V_DrawKartString(TX+72, TY+3, splitflags, va("%d", worktime/10)); - V_DrawKartString(TX+84, TY+3, splitflags, va("%d", worktime%10)); - } - else if ((drawtime/TICRATE) & 1) - V_DrawKartString(TX, TY+3, splitflags, va("99'59\"99")); - } - - if (emblemmap && (modeattacking || (mode == 1)) && !demo.playback) // emblem time! - { - INT32 workx = TX + 96, worky = TY+18; - SINT8 curemb = 0; - patch_t *emblempic[3] = {NULL, NULL, NULL}; - UINT8 *emblemcol[3] = {NULL, NULL, NULL}; - - emblem_t *emblem = M_GetLevelEmblems(emblemmap); - while (emblem) - { - char targettext[9]; - - switch (emblem->type) - { - case ET_TIME: - { - static boolean canplaysound = true; - tic_t timetoreach = emblem->var; - - if (emblem->collected) - { - emblempic[curemb] = W_CachePatchName(M_GetEmblemPatch(emblem), PU_PATCH); - emblemcol[curemb] = R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_CACHE); - if (++curemb == 3) - break; - goto bademblem; - } - - snprintf(targettext, 9, "%i'%02i\"%02i", - G_TicsToMinutes(timetoreach, false), - G_TicsToSeconds(timetoreach), - G_TicsToCentiseconds(timetoreach)); - - if (!mode) - { - if (stplyr->realtime > timetoreach) - { - splitflags = (splitflags &~ V_HUDTRANS)|V_HUDTRANSHALF; - if (canplaysound) - { - S_StartSound(NULL, sfx_s3k72); //sfx_s26d); -- you STOLE fizzy lifting drinks - canplaysound = false; - } - } - else if (!canplaysound) - canplaysound = true; - } - - targettext[8] = 0; - } - break; - default: - goto bademblem; - } - - V_DrawRightAlignedString(workx, worky, splitflags, targettext); - workx -= 67; - V_DrawSmallScaledPatch(workx + 4, worky, splitflags, W_CachePatchName("NEEDIT", PU_PATCH)); - - break; - - bademblem: - emblem = M_GetLevelEmblems(-1); - } - - if (!mode) - splitflags = (splitflags &~ V_HUDTRANSHALF)|V_HUDTRANS; - - while (curemb--) - { - workx -= 12; - V_DrawSmallMappedPatch(workx + 4, worky, splitflags, emblempic[curemb], emblemcol[curemb]); - } - } -} - -static void K_DrawKartPositionNum(INT32 num) -{ - // POSI_X = BASEVIDWIDTH - 51; // 269 - // POSI_Y = BASEVIDHEIGHT- 64; // 136 - - const boolean wheeloffs = (cv_showinput.value && cv_posi_xoffset.value == 0 && cv_posi_yoffset.value == 0 && cv_wheel_xoffset.value == 0 && cv_wheel_yoffset.value == 0); - boolean win = (stplyr->exiting && num == 1); - //INT32 X = POSI_X; - INT32 W = kp_positionnum[0][0]->width; - fixed_t scale = FRACUNIT; - patch_t *localpatch = kp_positionnum[0][0]; - //INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTORIGHT); - INT32 fx = 0, fy = 0, fflags = 0; - INT32 xoffs = wheeloffs ? -48 : 0; - boolean flipdraw = false; // flip the order we draw it in for MORE splitscreen bs. fun. - boolean flipvdraw = false; // used only for 2p splitscreen so overtaking doesn't make 1P's position fly off the screen. - boolean overtake = false; - - if ((cv_posanim.value && stplyr->kartstuff[k_positiondelay]) || stplyr->exiting) - { - scale *= 2; - overtake = true; // this is used for splitscreen stuff in conjunction with flipdraw. - } - - if (splitscreen || cv_smallposnum.value || wheeloffs) - { - scale /= 2; - } - - W = FixedMul(W<>FRACBITS; - - // pain and suffering defined below - if (!splitscreen) - { - fx = POSI_X + xoffs; - fy = BASEVIDHEIGHT - 8 + cv_posi_yoffset.value; - fflags = V_SNAPTOBOTTOM|V_SNAPTORIGHT; - } - else if (splitscreen == 1) // for this splitscreen, we'll use case by case because it's a bit different. - { - fx = POSI_X; - if (stplyrnum == 0) // for player 1: display this at the top right, above the minimap. - { - fy = 30 + cv_posi_yoffset.value; - fflags = V_SNAPTOTOP|V_SNAPTORIGHT; - if (overtake) - flipvdraw = true; // make sure overtaking doesn't explode us - } - else // if we're not p1, that means we're p2. display this at the bottom right, below the minimap. - { - fy = BASEVIDHEIGHT - 8 + cv_posi_yoffset.value; - fflags = V_SNAPTOBOTTOM|V_SNAPTORIGHT; - } - } - else - { - if (!(stplyrnum & 1)) // If we are P1 or P3... - { - fx = POSI_X; - fy = POSI_Y; - fflags = V_SNAPTOLEFT|((stplyrnum == 2) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. - flipdraw = true; - if (num && num >= 10) - fx += W; // this seems dumb, but we need to do this in order for positions above 10 going off screen. - } - else // else, that means we're P2 or P4. - { - fx = POSI2_X; - fy = POSI2_Y; - fflags = V_SNAPTORIGHT|((stplyrnum == 3) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom - } - } - - // Special case for 0 - if (!num) - { - V_DrawFixedPatch(fx<= 0); // This function does not draw negative numbers - - // Draw the number - while (num) - { - if (win) // 1st place winner? You get rainbows!! - { - localpatch = kp_winnernum[(leveltime % (NUMWINFRAMES*3)) / 3]; - } - else if (stplyr->laps+1 >= cv_numlaps.value || stplyr->exiting) // Check for the final lap, or won - { - // Alternate frame every three frames - switch (leveltime % 9) - { - case 1: case 2: case 3: - if (K_IsPlayerLosing(stplyr)) - localpatch = kp_positionnum[num % 10][4]; - else - localpatch = kp_positionnum[num % 10][1]; - break; - case 4: case 5: case 6: - if (K_IsPlayerLosing(stplyr)) - localpatch = kp_positionnum[num % 10][5]; - else - localpatch = kp_positionnum[num % 10][2]; - break; - case 7: case 8: case 9: - if (K_IsPlayerLosing(stplyr)) - localpatch = kp_positionnum[num % 10][6]; - else - localpatch = kp_positionnum[num % 10][3]; - break; - default: - localpatch = kp_positionnum[num % 10][0]; - break; - } - } - else - { - localpatch = kp_positionnum[num % 10][0]; - } - - V_DrawFixedPatch((fx<width*scale/2) : 0), (fy<height*scale/2) : 0), scale, V_HUDTRANSHALF|fflags, localpatch, NULL); - // ^ if we overtake as p1 or p3 in splitscren, we shift it so that it doesn't go off screen. - // ^ if we overtake as p1 in 2p splits, shift vertically so that this doesn't happen either. - - fx -= W; - num /= 10; - } -} - -static boolean K_drawKartPositionFaces(void) -{ - // FACE_X = 15; // 15 - // FACE_Y = 72; // 72 - - INT32 Y = FACE_Y+9; // +9 to offset where it's being drawn if there are more than one - INT32 i, j, ranklines, strank = -1; - boolean completed[MAXPLAYERS]; - INT32 rankplayer[MAXPLAYERS]; - INT32 bumperx, numplayersingame = 0; - UINT8 *colormap; - - ranklines = 0; - memset(completed, 0, sizeof (completed)); - memset(rankplayer, 0, sizeof (rankplayer)); - - for (i = 0; i < MAXPLAYERS; i++) - { - rankplayer[i] = -1; - - if (!playeringame[i] || players[i].spectator || !players[i].mo) - continue; - - numplayersingame++; - } - - if (numplayersingame <= 1) - return true; - - if (!LUA_HudEnabled(hud_minirankings)) - return false; // Don't proceed but still return true for free play above if HUD is disabled. - - for (j = 0; j < numplayersingame; j++) - { - UINT8 lowestposition = MAXPLAYERS+1; - for (i = 0; i < MAXPLAYERS; i++) - { - if (completed[i] || !playeringame[i] || players[i].spectator || !players[i].mo) - continue; - - if (players[i].kartstuff[k_position] >= lowestposition) - continue; - - rankplayer[ranklines] = i; - lowestposition = players[i].kartstuff[k_position]; - } - - i = rankplayer[ranklines]; - - completed[i] = true; - - if (players+i == stplyr) - strank = ranklines; - - ranklines++; - } - - if (ranklines < 5) - Y -= (9*ranklines); - else - Y -= (9*5); - - if (G_BattleGametype() || strank <= 2) // too close to the top, or playing battle, or a spectator? would have had (strank == -1) called out, but already caught by (strank <= 2) - { - i = 0; - if (ranklines > 5) // could be both... - ranklines = 5; - } - else if (strank+3 > ranklines) // too close to the bottom? - { - i = ranklines - 5; - if (i < 0) - i = 0; - } - else - { - i = strank-2; - ranklines = strank+3; - } - - for (; i < ranklines; i++) - { - player_t *player; - player = &players[rankplayer[i]]; - - if (!playeringame[rankplayer[i]]) - continue; - if (player->spectator) - continue; - if (!player->mo) - continue; - - const UINT8 mocolor = player->mo->color; - - bumperx = FACE_X+19; - - if (mocolor) - { - colormap = R_GetTranslationColormap(player->skin, mocolor, GTC_CACHE); - if (player->mo->colorized) - colormap = R_GetTranslationColormap(TC_RAINBOW, mocolor, GTC_CACHE); - - if (K_UseHighResPortraits()) - V_DrawSmallMappedPatch(FACE_X, Y, V_HUDTRANS|V_SNAPTOLEFT, R_GetSkinFaceWant(player), colormap); - else - V_DrawMappedPatch(FACE_X, Y, V_HUDTRANS|V_SNAPTOLEFT, R_GetSkinFaceRank(player), colormap); - - if (LUA_HudEnabled(hud_battlebumpers)) - { - if (G_BattleGametype() && player->kartstuff[k_bumper] > 0) - { - V_DrawMappedPatch(bumperx-2, Y, V_HUDTRANS|V_SNAPTOLEFT, kp_tinybumper[0], colormap); - for (j = 1; j < player->kartstuff[k_bumper]; j++) - { - bumperx += 5; - V_DrawMappedPatch(bumperx, Y, V_HUDTRANS|V_SNAPTOLEFT, kp_tinybumper[1], colormap); - } - } - } // A new level of stupidity: checking if lua is enabled to close a bracket. :Fascinating: - } - - if (i == strank) - V_DrawScaledPatch(FACE_X, Y, V_HUDTRANS|V_SNAPTOLEFT, kp_facehighlight[(leveltime / 4) % 8]); - - if (G_BattleGametype() && player->kartstuff[k_bumper] <= 0) - V_DrawScaledPatch(FACE_X-4, Y-3, V_HUDTRANS|V_SNAPTOLEFT, kp_ranknobumpers); - else - { - INT32 pos = player->kartstuff[k_position]; - if (pos < 0 || pos > MAXPLAYERS) - pos = 0; - // Draws the little number over the face - V_DrawScaledPatch(FACE_X-5, Y+10, V_HUDTRANS|V_SNAPTOLEFT, kp_facenum[pos]); - } - - Y += 18; - } - - return false; -} - -// -// HU_DrawTabRankings -- moved here to take advantage of kart stuff! -// -void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 hilicol) -{ - INT32 i, rightoffset = 240; - const UINT8 *colormap; - INT32 dupadjust = cv_betainterscreen.value ? 314 : (vid.width/vid.dupx), duptweak = cv_betainterscreen.value ? -3 : (dupadjust - BASEVIDWIDTH)/2; - - boolean (*_isHighlightedPlayer)(const player_t *) = (demo.playback ? P_IsDisplayPlayer : P_IsLocalPlayer); - - //this function is designed for 9 or less score lines only - //I_Assert(scorelines <= 9); -- not today bitch, kart fixed it up - - V_DrawFill(1-duptweak, 26, dupadjust-2, 1, 0); // Draw a horizontal line because it looks nice! - if (scorelines > 8) - { - V_DrawFill(160, 26, 1, 147, 0); // Draw a vertical line to separate the two sides. - V_DrawFill(1-duptweak, 173, dupadjust-2, 1, 0); // And a horizontal line near the bottom. - rightoffset = (BASEVIDWIDTH/2) - 4 - x; - } - - for (i = 0; i < scorelines; i++) - { - char strtime[MAXPLAYERNAME+1]; - const UINT8 pnum = tab[i].num; - player_t *player = &players[pnum]; - - if (player->spectator || !player->mo) - continue; //ignore them. - - const boolean whiteplayer = _isHighlightedPlayer(player); - const INT32 philicol = (whiteplayer ? V_SkinColorToHighlightcolor(player->skincolor) : 0); - - if ((netgame && pnum != serverplayer) || (cv_mindelay.value && P_IsLocalPlayer(player))) - { - HU_drawPlayerPing(x + ((i < 8) ? -17 : rightoffset + 11), y-4, pnum, 0); - } - - STRBUFCPY(strtime, tab[i].name); - - if (scorelines > 8) - V_DrawThinString(x + 20, y, philicol|V_ALLOWLOWERCASE|V_6WIDTHSPACE, strtime); - else - V_DrawString(x + 20, y, philicol|V_ALLOWLOWERCASE, strtime); - - if (player->mo->color) - { - if (player->mo->colorized) - colormap = R_GetTranslationColormap(TC_RAINBOW, player->mo->color, GTC_CACHE); - else - colormap = R_GetTranslationColormap(player->skin, player->mo->color, GTC_CACHE); - - if (K_UseHighResPortraits()) - V_DrawSmallMappedPatch(x, y-4, 0, R_GetSkinFaceWant(player), colormap); - else - V_DrawMappedPatch(x, y-4, 0, R_GetSkinFaceRank(player), colormap); - - /*if (G_BattleGametype() && player->kartstuff[k_bumper] > 0) -- not enough space for this - { - INT32 bumperx = x+19; - V_DrawMappedPatch(bumperx-2, y-4, 0, kp_tinybumper[0], colormap); - for (j = 1; j < player->kartstuff[k_bumper]; j++) - { - bumperx += 5; - V_DrawMappedPatch(bumperx, y-4, 0, kp_tinybumper[1], colormap); - } - }*/ - } - - if (whiteplayer) - V_DrawScaledPatch(x, y-4, 0, kp_facehighlight[(leveltime / 4) % 8]); - - if (G_BattleGametype() && player->kartstuff[k_bumper] <= 0) - V_DrawScaledPatch(x-4, y-7, 0, kp_ranknobumpers); - else - { - INT32 pos = player->kartstuff[k_position]; - if (pos < 0 || pos > MAXPLAYERS) - pos = 0; - // Draws the little number over the face - V_DrawScaledPatch(x-5, y+6, 0, kp_facenum[pos]); - } - - if (G_RaceGametype()) - { -#define timestring(time) va("%i'%02i\"%02i", G_TicsToMinutes(time, true), G_TicsToSeconds(time), G_TicsToCentiseconds(time)) - if (scorelines > 8) - { - if (player->exiting) - V_DrawRightAlignedThinString(x+rightoffset, y-1, hilicol|V_6WIDTHSPACE, timestring(player->realtime)); - else if (player->pflags & PF_TIMEOVER) - V_DrawRightAlignedThinString(x+rightoffset, y-1, V_6WIDTHSPACE, "NO CONTEST."); - else if (circuitmap) - V_DrawRightAlignedThinString(x+rightoffset, y-1, V_6WIDTHSPACE, va("Lap %d", tab[i].count)); - } - else - { - if (player->exiting) - V_DrawRightAlignedString(x+rightoffset, y, hilicol, timestring(player->realtime)); - else if (player->pflags & PF_TIMEOVER) - V_DrawRightAlignedThinString(x+rightoffset, y-1, 0, "NO CONTEST."); - else if (circuitmap) - V_DrawRightAlignedString(x+rightoffset, y, 0, va("Lap %d", tab[i].count)); - } -#undef timestring - } - else - V_DrawRightAlignedString(x+rightoffset, y, 0, va("%u", tab[i].count)); - - y += 18; - if (i == 7) - { - y = 33; - x = (BASEVIDWIDTH/2) + 4; - } - } -} - -static boolean K_BigLap(void) -{ - return (cv_biglaps.value && (cv_numlaps.value > 9) && (K_UseColorHud() ? big_lap_color : big_lap) && (!stplyr->exiting)); -} - -static void K_drawKartLaps(void) -{ - INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTOLEFT); - INT32 fx = 0, fy = 0, fflags = 0; // stuff for 3p / 4p splitscreen. - boolean flipstring = splitscreen > 1 && stplyrnum & 1; // used for 3p or 4p - INT32 stringw = 0; // used with the above - const char *laps; - - drawinfo_t info; - K_getLapsDrawinfo(&info); - fx = info.x; - fy = info.y; - fflags = info.flags; - - laps = (stplyr->exiting ? "FIN" : va("%d/%d", stplyr->laps+1, cv_numlaps.value)); - - // draw stuff as god intended. - if (splitscreen > 1) - { - if (flipstring) - { - stringw = V_StringWidth(laps, 0); - - V_DrawScaledPatch(fx-stringw-13, fy, V_HUDTRANS|fflags, kp_splitlapflag); - V_DrawRightAlignedString(fx, fy+1, V_HUDTRANS|fflags, laps); - } - else // draw stuff NORMALLY. - { - V_DrawScaledPatch(fx, fy, V_HUDTRANS|fflags, kp_splitlapflag); - V_DrawString(fx+13, fy+1, V_HUDTRANS|fflags, laps); - } - } - else - { - if (K_UseColorHud()) // Colourized hud - { - UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - patch_t *biglapclr = (K_BigLap() ? ((stplyr->laps + 1 > 9) ? kp_lapstickerbig2clr : kp_lapstickerbigclr) : kp_lapstickerclr); - V_DrawMappedPatch(fx, fy, V_HUDTRANS|splitflags, biglapclr, colormap); - } - else - { - patch_t *biglap = (K_BigLap() ? ((stplyr->laps + 1 > 9) ? kp_lapstickerbig2 : kp_lapstickerbig) : kp_lapsticker); - V_DrawScaledPatch(fx, fy, V_HUDTRANS|splitflags, biglap); - } - - V_DrawKartString(fx+33, fy+3, V_HUDTRANS|splitflags, laps); - } -} - -#ifdef ROTSPRITE - -#define DIALSPDDIV 97090 // 1.48148; converts 200 to 135 -#define MPHDIV 68283 // 1.04192; converts 141 to 135 - -static void K_DrawDialNum(INT32 x, INT32 y, boolean colorized, INT32 flags, INT32 num, INT32 digits, const UINT8 *colormap) -{ - INT32 w; - - if (colorized) - w = skp_dialnumclr[0]->width; - else - w = skp_dialnum[0]->width; - - if (flags & V_NOSCALESTART) - w *= vid.dupx; - - if (num < 0) - num = -num; - - // draw the number - do - { - x -= (w); - - if (colorized) - V_DrawFixedPatch(x << FRACBITS, y << FRACBITS, FRACUNIT, flags, skp_dialnumclr[num % 10], colormap); - else - V_DrawFixedPatch(x << FRACBITS, y << FRACBITS, FRACUNIT, flags, skp_dialnum[num % 10], colormap); - - num /= 10; - } while (--digits); -} - -static void K_DrawDialLaps(INT32 x, INT32 y, INT32 num, INT32 total, INT32 flags) -{ - INT32 fx; - fx = x + ((num < 10) ? 0 : 6); - V_DrawRankNum(fx, y, flags, num, (num < 10) ? 1 : 2, NULL); - V_DrawScaledPatch(fx + 2, y, flags, frameslash); - V_DrawRankNum(fx + 13 + ((total < 10) ? 0 : 6), y, flags, total, (total < 10) ? 1 : 2, NULL); -} - -static void K_DrawDialSpeedometer(fixed_t speed, - fixed_t divisor, - INT32 splitflags, - boolean battlemode, - boolean infoactive, - boolean colorized) -{ - UINT8* colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - - INT32 rot = 0; - UINT8 infoidx = (infoactive) ? 1 : 0; - patch_t* dialpatch; - - angle_t speedangle = - FixedAngle(((min(135 * FRACUNIT, FixedDiv(speed, divisor)) - (45 * FRACUNIT)))); - - rot = R_GetRollAngle(speedangle); - - if (rot) - { - dialpatch = W_CachePatchNameRotated("K_DSDIAL", rot, PU_PATCH); - } - else - { - dialpatch = W_CachePatchName("K_DSDIAL", PU_PATCH); - } - - if (colorized) // Colourized hud - { - V_DrawMappedPatch( - SPDM_X, SPDM_Y - 9, (V_HUDTRANS | splitflags), skp_dialbaseclr[infoidx], colormap); - V_DrawMappedPatch(SPDM_X, - SPDM_Y + 30, - V_HUDTRANS | splitflags, - skp_speedpatchesdialclr[cv_kartspeedometer.value], - colormap); - } - else - { - V_DrawScaledPatch(SPDM_X, SPDM_Y - 9, (V_HUDTRANS | splitflags), skp_dialbase[infoidx]); - V_DrawScaledPatch(SPDM_X, - SPDM_Y + 30, - V_HUDTRANS | splitflags, - skp_speedpatchesdial[cv_kartspeedometer.value]); - } - - K_DrawDialNum(SPDM_X + 10, - SPDM_Y + 25, - colorized, - V_HUDTRANS | splitflags, - speed / FRACUNIT, - 3, - colormap); - - // gotta center the dial manually - V_DrawMappedPatch(SPDM_X - 19, SPDM_Y + 15, (V_HUDTRANS | splitflags), (dialpatch), colormap); - - if (!infoactive) - { - // no need to draw info if we're not supposed to - return; - } - - // draw the info - if (battlemode) - { - if (stplyr->kartstuff[k_bumper] <= 0) - { - V_DrawMappedPatch( - SPDM_X + 28, SPDM_Y + 27, V_HUDTRANS | splitflags, kp_splitkarmabomb, colormap); - K_DrawDialLaps(SPDM_X + 46, - SPDM_Y + 29, - stplyr->kartstuff[k_comebackpoints], - 2, - V_HUDTRANS | splitflags); - } - else // the above doesn't need to account for weird stuff since the max amount of karma - // necessary is always 2 ^^^^ - { - V_DrawMappedPatch( - SPDM_X + 28, SPDM_Y + 27, V_HUDTRANS | splitflags, kp_rankbumper, colormap); - K_DrawDialLaps(SPDM_X + 46, - SPDM_Y + 29, - stplyr->kartstuff[k_bumper], - cv_kartbumpers.value, - V_HUDTRANS | splitflags); - } - } - else - { - V_DrawScaledPatch(SPDM_X + 28, SPDM_Y + 27, V_HUDTRANS | splitflags, kp_splitlapflag); - - if (stplyr->exiting) - V_DrawScaledPatch(SPDM_X + 39, SPDM_Y + 29, V_HUDTRANS | splitflags, skp_rankfinish); - else - K_DrawDialLaps(SPDM_X + 46, - SPDM_Y + 29, - stplyr->laps + 1, - cv_numlaps.value, - V_HUDTRANS | splitflags); - } -} - -#endif - -static void K_drawKartSpeedometer(void) -{ - // why? - if (cv_kartspeedometer.value == 0) - return; - - // index 0 is the raw value, index 1 is the converted value - fixed_t convSpeed[2] = {0,0}; -#ifdef ROTSPRITE - fixed_t dial_divisor = DIALSPDDIV; -#endif - - INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTOLEFT); - - // man. - const UINT8 speedostyle = K_GetSpeedometerStyle(); - - switch (cv_kartspeedometer.value) - { - case 1: - convSpeed[0] = FixedDiv(FixedMul(stplyr->speed, 142371), mapobjectscale); // 2.172409058 - convSpeed[1] = convSpeed[0] / FRACUNIT; - break; - case 2: - convSpeed[0] = FixedDiv(FixedMul(stplyr->speed, 88465), mapobjectscale); // 1.349868774 - convSpeed[1] = convSpeed[0] / FRACUNIT; -#ifdef ROTSPRITE - dial_divisor = MPHDIV; -#endif - break; - case 3: - convSpeed[0] = FixedDiv(stplyr->speed, mapobjectscale); - convSpeed[1] = convSpeed[0] / FRACUNIT; -#ifdef ROTSPRITE - dial_divisor = MPHDIV; -#endif - break; - case 4: - if (stplyr->mo) - { - convSpeed[0] = (FixedDiv(stplyr->speed, FixedMul(K_GetKartSpeed(stplyr, false), ORIG_FRICTION))*100); - convSpeed[1] = convSpeed[0] >> FRACBITS; - } - break; - default: - break; - } - - if (speedostyle == SPEEDO_VANILLA) - { - const char *metric = ""; - - switch (cv_kartspeedometer.value) - { - case 1: - metric = va("%3d km/h", convSpeed[1]); - break; - case 2: - metric = va("%3d mph", convSpeed[1]); - break; - case 3: - metric = va("%3d fu/t", convSpeed[1]); - break; - case 4: - // if extra.kart is found, use its included % symbol - if (!xtra_speedo) - metric = va("%4d P", convSpeed[1]); - else - metric = va("%4d %%", convSpeed[1]); - break; - default: - break; - } - - V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, metric); - } - else if (speedostyle == SPEEDO_EXTRA) // why bother if we dont? - { - if (K_UseColorSpeedo(SPEEDO_EXTRA)) //Colourized hud - { - UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - V_DrawMappedPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_smallstickerclr, colormap); - } - else - V_DrawScaledPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_smallsticker); - - V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed[1], 3, NULL); - V_DrawScaledPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_speedpatches[cv_kartspeedometer.value]); - } - else if (speedostyle == SPEEDO_ACHII) // why bother if we dont? - { - if (K_UseColorSpeedo(SPEEDO_ACHII)) //Colourized hud - { - UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - V_DrawMappedPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_smallstickerachiclr, colormap); - V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed[1], 3, NULL); - V_DrawMappedPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_speedpatchesachiclr[cv_kartspeedometer.value], colormap); - } - else - { - V_DrawScaledPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_smallstickerachi); - V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed[1], 3, NULL); - V_DrawScaledPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_speedpatchesachi[cv_kartspeedometer.value]); - } - } -#ifdef ROTSPRITE - else if (speedostyle == SPEEDO_DIAL) // why bother if we dont? - { - K_DrawDialSpeedometer(convSpeed[0], - dial_divisor, - splitflags, - (boolean)(G_BattleGametype()), - (LUA_HudEnabled(hud_gametypeinfo)), - (K_UseColorSpeedo(SPEEDO_DIAL))); - } -#endif - else if (speedostyle == SPEEDO_EXTRA3) // why bother if we dont? - { - if (K_UseColorSpeedo(SPEEDO_EXTRA3)) //Colourized hud - { - UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - V_DrawStretchyFixedPatch((SPDM_X-1)<speed, mapobjectscale)/FRACUNIT; - - for (INT32 i = 0; i < 22; ++i) - { - if (fuspeed < speedIntervals[i]) - { - spdpatch = i; - break; - } - } - - if (((fuspeed < 57 && fuspeed > 54) || (fuspeed < 60 && fuspeed > 56) || (fuspeed > 59)) && (leveltime & 4)) - spdpatch = 24; - else if (((fuspeed < 57 && fuspeed > 54) || (fuspeed < 60 && fuspeed > 56) || (fuspeed > 59)) && !(leveltime & 4)) - spdpatch = 23; - - V_DrawScaledPatch(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, (speedostyle == SPEEDO_PMETER) ? kp_kartzspeedo[spdpatch] : kp_kartzspeedo_smol[spdpatch]); - } -} - -#ifdef ROTSPRITE -#undef DIALSPDDIV -#undef MPHDIV -#endif - -static void K_drawKartBumpersOrKarma(void) -{ - UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - INT32 fx, fy, fflags; - boolean flipstring = splitscreen > 1 && stplyrnum & 1; // same as laps, used for splitscreen - INT32 stringw = 0; // used with the above - const char *bumpval = ""; - - drawinfo_t info; - K_getLapsDrawinfo(&info); - fx = info.x; - fy = info.y; - fflags = info.flags; - - if (cv_battlespeedo.value && !splitscreen) - { - const UINT8 speedostyle = K_GetSpeedometerStyle(); - - if ((speedostyle == SPEEDO_EXTRA) || (speedostyle == SPEEDO_ACHII) || (speedostyle == SPEEDO_EXTRA3)) - fy += 5; - else - fy += 7; - } - - if (splitscreen > 1) - { - if (stplyr->kartstuff[k_bumper] <= 0) - { - bumpval = va("%d/2", stplyr->kartstuff[k_comebackpoints]); - - if (flipstring) - fx -= 37; - V_DrawMappedPatch(fx, fy-1, V_HUDTRANS|fflags, kp_splitkarmabomb, colormap); - V_DrawString(fx+13, fy+1, V_HUDTRANS|fflags, bumpval); - } - else // the above doesn't need to account for weird stuff since the max amount of karma necessary is always 2 ^^^^ - { - bumpval = va("%d/%d", stplyr->kartstuff[k_bumper], cv_kartbumpers.value); - - if (flipstring) // for p2 and p4, assume we can have more than 10 bumpers. It's retarded but who knows. - { - stringw = V_StringWidth(bumpval, 0); - - V_DrawMappedPatch(fx-stringw-13, fy-1, V_HUDTRANS|fflags, kp_rankbumper, colormap); - V_DrawRightAlignedString(fx, fy+1, V_HUDTRANS|fflags, bumpval); - } - else // draw bumpers normally. - { - V_DrawMappedPatch(fx, fy-1, V_HUDTRANS|fflags, kp_rankbumper, colormap); - V_DrawString(fx+13, fy+1, V_HUDTRANS|fflags, bumpval); - } - } - } - else - { - patch_t *patch; - - if (stplyr->kartstuff[k_bumper] <= 0) - { - patch = (K_UseColorHud() ? kp_karmastickerclr : kp_karmasticker); - bumpval = va("%d/2", stplyr->kartstuff[k_comebackpoints]); - } - else - { - if (stplyr->kartstuff[k_bumper] > 9 && cv_kartbumpers.value > 9) - patch = (K_UseColorHud() ? kp_bumperstickerwideclr : kp_bumperstickerwide); - else - patch = (K_UseColorHud() ? kp_bumperstickerclr : kp_bumpersticker); - - bumpval = va("%d/%d", stplyr->kartstuff[k_bumper], cv_kartbumpers.value); - } - - V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, patch, colormap); - V_DrawKartString(fx+47, fy+3, V_HUDTRANS|fflags, bumpval); - } -} - -#define lerp(from, to) cv_uncappedhud.value ? from + FixedMul(rendertimefrac, to - from) : to - -// converts mobj coordinates into screen coordinates -// NOTE: use with V_NOSCALESTART! -// Code updated in Lua by GenericHeroGuy for libSG -// Badly ported to C by NepDisk and acutally made to work and fixed by Indev!(Thanks so much!) -// Badly uncapped in C by GenericHeroGuy -// original code by Lat' -static boolean K_GetScreenCoords(vector2_t *vec, player_t *player, mobj_t *target, fixed_t hofs, boolean dontclip) -{ - fixed_t y, x; - fixed_t targx, targy, targz; - - fixed_t dist; - fixed_t distfact; - fixed_t offset; - - fixed_t yres, xres; - fixed_t fov; - - // this should never happen but its also kart so ¯\_(ツ)_/¯ - if (!player || P_MobjWasRemoved(target)) - return false; - - targx = lerp(target->old_x, target->x); - targy = lerp(target->old_y, target->y); - targz = lerp(target->old_z, target->z); - - // X coordinate - // get difference between camangle and angle towards target - x = (INT32)viewangle - (INT32)R_PointToAngle(targx, targy); - - distfact = FINECOSINE((x>>ANGLETOFINESHIFT) & FINEMASK); - if (!distfact) distfact = 1; - - if (encoremode) - x = -x; - if (x < (fixed_t)ANGLE_270 || x > (fixed_t)ANGLE_90) - return false; - - xres = vid.width<<(FRACBITS-1); - yres = vid.height<<(FRACBITS-1); - fov = FixedDiv(xres, FINETANGENT(((FixedAngle(cv_fov.value/2)+ANGLE_90)>>ANGLETOFINESHIFT) & 4095)); - - // flipping - const boolean targflip = target->eflags & MFE_VERTICALFLIP; - const boolean srcflip = player->pflags & PF_FLIPCAM && player->mo->eflags & MFE_VERTICALFLIP; - - // Y coordinate - // getting the angle difference here is a bit more involved... - // start by getting the height difference between the camera and target - y = viewz - targz - (targflip ? ((target->height * 2) / 3) : 0); // for some reason needs to be divided by "1.5" idk - - if (hofs) - y = y - (targflip ? -hofs : hofs); - - // then get the distance between camera and target - dist = R_PointToDist(targx, targy); - -#ifdef HWRENDER - // NOW we can get the angle differnce - if (rendermode == render_opengl && !cv_glshearing.value) - { - angle_t yang = R_PointToAngle2(0, 0, dist, y); // not perspective - x = FixedMul(x, FINECOSINE((yang>>ANGLETOFINESHIFT) & FINEMASK)); // perspective - y = -aimingangle - FixedDiv(yang, distfact); - - if (y < (fixed_t)ANGLE_270 || y > (fixed_t)ANGLE_90) // clip points behind the camera - return false; - if (splitscreen == 1) // multiply by 1.25 for 2P splitscreen - y = y + (y/4) ; - if (srcflip) // flipcam - y = -y; - - y = FixedMul(FINETANGENT((((angle_t)(-y)+ANGLE_90)>>ANGLETOFINESHIFT) & 4095), fov) + yres; // project the angle to get our final Y coordinate - } - else -#endif - { - const fixed_t fovratio = FixedDiv(90*FRACUNIT, 180*FRACUNIT - FixedMul(cv_fov.value, 4*FRACUNIT/3)-FRACUNIT*-30); - - y = FixedDiv(y, FixedMul(dist, distfact)); - if (srcflip) - y = -y; // flipcam - if (y != INT32_MIN) // I_Error(): FixedDiv: divide by zero - y = FixedMul(FixedDiv(y, fovratio), xres) + yres; - //else print("NOPE!") - - offset = FixedMul(FINETANGENT(((aimingangle+ANGLE_90)>>ANGLETOFINESHIFT) & 4095), xres); - - // this isn't fovtan... what am i even doing anymore - if (splitscreen == 1) - offset = 17*offset/120; - - // thanks fickle - offset = FixedDiv(offset, fovratio); - if (srcflip) - offset = -offset; // flipcam - y = y + offset; - } - - // project the angle to get our final X coordinate - x = FixedMul(FINETANGENT(((x+ANGLE_90)>>ANGLETOFINESHIFT) & 4095), fov); - if (splitscreen == 1) // divide by 320/200 (1.6) on 2P splitscreen - x = (x/2) + (x/8); - x = x + xres; - - // now clip in screen-space - if (!dontclip && (x < 0 || x > xres*2 || y < 0 || y > yres*2)) - return false; - - // adjust coords for splitscreen - if (splitscreen == 1) // 2P - { - y = y>>1; - if (stplyrnum > 0) - y = y + yres; - } - if (splitscreen >= 2) // 3P or 4P - { - x = x>>1; - y = y>>1; - if (stplyrnum & 1) - x = x + xres; - if (stplyrnum >= 2) - y = y + yres; - } - - vec->y = y; - vec->x = x; - return true; -} - -//Slighty fixed by Alug and further rewritten by NepDisk -//Decided to port and highly modify sunflower version for the main nametag drawing with additions by NepDisk. My previous one was broken anyway due to the changed screencoords and noscalestart -static void K_drawNameTags(void) -{ - UINT8 i, j; - INT32 trans; - vector2_t pos = {0}; - fixed_t namex, namey; - int tagsdisplayed = 0; - fixed_t distance = 0; - fixed_t maxdistance = 0; - boolean flipped = false; - fixed_t z; - - char *tag; - patch_t *icon = NULL; - - INT32 dup; - UINT8 *cm = NULL; - UINT8 tagcolor = 0; - INT32 vflags = 0; - boolean usenametagrestat = false; - fixed_t tagwidthsmall; - fixed_t tagwidth; - - if (P_MobjWasRemoved(stplyr->mo) || (stplyr->spectator && !cv_shownametagspectator.value) || stplyr->exiting) - return; - - maxdistance = ((10*cv_nametagdist.value) * mapobjectscale); - - for (i = 0; i < MAXPLAYERS; i++) - { - distance = 0; - flipped = false; - - if (i > PLAYERSMASK) - continue; - if (players[i].spectator || !playeringame[i] || P_MobjWasRemoved(players[i].mo)) - continue; - if (i == displayplayers[stplyrnum] && !cv_showownnametag.value && !(leveltime < 130)) - continue; - if (i != displayplayers[stplyrnum] && leveltime < starttime) - continue; - if (players[i].kartstuff[k_hyudorotimer]) // player is invisible - continue; - if (maxdistance) - distance = R_PointToDist(players[i].mo->x, players[i].mo->y); - if (distance > maxdistance) - continue; - if (!P_CheckSightFast(stplyr->mo, players[i].mo)) - continue; - - z = players[i].mo->height; - - //Saltyhop hehe - z += lerp(players[i].mo->old_spriteyoffset, players[i].mo->spriteyoffset); - - if (!K_GetScreenCoords(&pos, stplyr, players[i].mo, z, false)) - continue; - - tagsdisplayed++; - - if (tagsdisplayed > cv_nametagmaxplayers.value) - break; - - trans = 0; - - switch (cv_nametagtrans.value) - { - case 1: - if (distance > (maxdistance*3/4)) - trans = V_60TRANS; - break; - case 2: - if (distance > (maxdistance*3/1)) - trans = V_90TRANS; - else if (distance > (maxdistance*3/2)) - trans = V_80TRANS; - else if (distance > (maxdistance*3/3)) - trans = V_60TRANS; - else if (distance > (maxdistance*3/4)) - trans = V_40TRANS; - else if (distance > (maxdistance*3/5)) - trans = V_20TRANS; - break; - case 3: - trans = V_40TRANS; - break; - case 4: - trans = V_LocalTransFlag(); - break; - case 0: - default: - break; - } - - namex = pos.x>>FRACBITS; - namey = pos.y>>FRACBITS; - - tag = va("%s%s ", HU_SkinColorToConsoleColor(players[i].mo->color), player_names[i]); - icon = R_GetSkinFaceMini(players[i].mo->player); - - dup = vid.dupx; - cm = R_GetTranslationColormap(players[i].skin, players[i].mo->color, GTC_CACHE); - tagcolor = colortranslations[players[i].mo->color][7]; - vflags = trans | V_NOSCALESTART; - usenametagrestat = ((cv_nametagrestat.value == 1 && (players[i].kartspeed != skins[players[i].skin].kartspeed || players[i].kartweight != skins[players[i].skin].kartweight)) || cv_nametagrestat.value == 2); - tagwidthsmall = cv_smallnametags.value ? V_SmallStringWidth(player_names[i], V_ALLOWLOWERCASE) : V_ThinStringWidth(player_names[i], V_ALLOWLOWERCASE); - tagwidth = dup*tagwidthsmall; - - // If flipcam is on, other player is flipped relative to us when we have different - // verticalflip flag value. Otherwise, they are simply flipped when verticalflip flag says so - if ((stplyr->pflags & PF_FLIPCAM) && (stplyr->mo->eflags & MFE_VERTICALFLIP)) - flipped = (players[i].mo->eflags & MFE_VERTICALFLIP) != (stplyr->mo->eflags & MFE_VERTICALFLIP); - else - flipped = players[i].mo->eflags & MFE_VERTICALFLIP; - - if (cv_smallnametags.value || !nametaggfx) - { - if (flipped) - namey += dup*5; - else // small offset - namey -= dup*3; - - if (nametaggfx && cv_smallnametags.value == 1) - { - if (cv_nametagfacerank.value) - tagwidthsmall += icon->width - dup; - - // Have to draw the nametag using patches here since drawfill can't draw at this scale... - if (!flipped) - V_DrawFixedPatch(namex<height/2)<width/2); // add offset to other stuff - } - - //Name - V_DrawSmallString(namex, namey, V_ALLOWLOWERCASE | vflags, tag); - - if (usenametagrestat) - { - V_DrawSmallString(namex, namey - dup*5, vflags, va("\x84S%d ", players[i].kartspeed)); - V_DrawSmallString(namex + dup*10, namey - dup*5, vflags, va("\x87W%d ", players[i].kartweight)); - } - - if (cv_nametagscore.value) - { - INT32 yofs = usenametagrestat ? 10 : 5; - V_DrawSmallString(namex, namey - dup*yofs, V_ALLOWLOWERCASE | vflags, va("\x8A%d ", players[i].score)); - } - } - else - { - if (cv_nametagfacerank.value) - tagwidth += dup*(icon->width+1); - - if (flipped) - { - for (j = 0; j < 4; j++) - { - V_DrawFill(namex, namey, dup*3, dup*4, 31 | vflags); - V_DrawFill(namex+dup, namey, dup, dup*4, tagcolor | vflags); - namey += dup*4; - namex += dup; - } - namey -= dup*3; - V_DrawFill(namex, namey+dup*2, dup, dup, 31 | vflags); // a single black pixel - V_DrawFill(namex+dup, namey, tagwidth, dup*3, 31 | vflags); - V_DrawFill(namex+dup, namey+dup, tagwidth - dup, dup, tagcolor | vflags); - namex += dup*2; - } - else - { - for (j = 0; j < 4; j++) - { - namey -= dup*4; - V_DrawFill(namex, namey, dup*3, dup*4, 31 | vflags); - V_DrawFill(namex+dup, namey, dup, dup*4, tagcolor | vflags); - namex += dup; - } - - V_DrawFill(namex, namey, dup, dup, 31 | vflags); - V_DrawFill(namex+dup, namey, tagwidth - dup*2, dup*3, 31 | vflags); - V_DrawFill(namex+dup, namey+dup, tagwidth - dup*3, dup, tagcolor | vflags); - } - - if (cv_nametagfacerank.value) - { - V_DrawMappedPatch(namex, namey - dup*(icon->height+1), vflags, icon, cm); - namex += dup*(icon->height+1); // add offset to other stuff - } - - V_DrawThinString(namex, namey - dup*10, V_ALLOWLOWERCASE | vflags, tag); - - if (usenametagrestat) - { - V_DrawScaledPatch(namex, namey - dup*20, vflags, nametagspeed); - V_DrawScaledPatch(namex + dup*18, namey - dup*20, vflags, nametagweight); - V_DrawString(namex + dup*9, namey - dup*19, V_ALLOWLOWERCASE | vflags, va("\x84%d ", players[i].kartspeed)); - V_DrawString(namex + dup*27, namey - dup*19, V_ALLOWLOWERCASE | vflags, va("\x87%d ", players[i].kartweight)); - } - - if (cv_nametagscore.value) - { - INT32 yofs = usenametagrestat ? 25 : 15; - V_DrawSmallString(namex, namey - dup*yofs, V_ALLOWLOWERCASE | vflags, va("\x8A%d ", players[i].score)); - } - } - } -} - -// Based on Driftgauge refactor by GenericHeroGuy ported from lua and expanded by NepDisk -static void K_drawDriftGauge(void) -{ - vector2_t pos = {0}; - fixed_t basex, basey; - const int dup = vid.dupx; - int i; - UINT8 *cmap; - - static UINT8 driftcolors[3][4] = { - {0, 0, 10, 16}, // no drift - {215, 215, 204, 253}, // blue - {125, 125, 151, 159} // red - }; - - static UINT8 driftskins[3] = { - SKINCOLOR_NONE, - SKINCOLOR_TEAL, - SKINCOLOR_SALMON, - }; - - static UINT8 driftrainbow[18] = { - 0, 31, 47, 63, 79, 95, 111, 119, 127, 143, 159, 175, 183, 191, 199, 207, 223, 247 - }; - - if (camera[stplyrnum].freecam) - return; - - if (!splitscreen && !camera->chase) - return; - - if (forceshowhud) - goto skipcrap; // i will skip the drift early return and you cant stop me! - - if (!stplyr->kartstuff[k_drift]) - return; - -skipcrap: - - if (P_MobjWasRemoved(stplyr->mo)) - return; - - if (!K_GetScreenCoords(&pos, stplyr, stplyr->mo, FixedMul(cv_driftgaugeofs.value, cv_driftgaugeofs.value > 0 ? stplyr->mo->scale : mapobjectscale), false)) - return; - - fixed_t barx; - fixed_t bary; - INT32 BAR_WIDTH; - - const INT32 driftval = K_GetKartDriftSparkValue(stplyr); - const INT32 driftcharge = min(driftval*4, stplyr->kartstuff[k_driftcharge]); - const INT32 driftlevel = min(driftcharge / driftval, 2); - const INT32 drifttrans = ((cv_driftgaugetrans.value) ? V_LocalTransFlag() : 0); - - basex = pos.x>>FRACBITS; - basey = pos.y>>FRACBITS; - - switch (cv_driftgaugestyle.value) - { - case 1: - case 2: - case 3: - case 5: - { - if (!driftgaugegfx) - break; - - const boolean usescaledpatch = (cv_driftgaugestyle.value == 5 && xtra_speedo3); - - if (cv_driftgaugestyle.value == 1 || cv_driftgaugestyle.value == 3 || usescaledpatch) - { - barx = basex - dup*23; - BAR_WIDTH = dup*47; - } - else - { - barx = basex - dup*12; - BAR_WIDTH = dup*23; - } - - bary = basey - dup*2; - - if (usescaledpatch) // i hate hud code i hate hud code i hate hud code i hate hud code i hate hud code..... - { - if (K_UseColorSpeedo(SPEEDO_EXTRA3)) // Colourized hud - { - UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - V_DrawStretchyFixedPatch((basex - dup*30)<= driftval*4) // rainbow sparks - { - cmap = R_GetTranslationColormap(TC_RAINBOW, 1 + leveltime % (MAXSKINCOLORS-1),GTC_CACHE); - - for (i = 0; i < 4; i++) - V_DrawFill(barx, bary+dup*1+dup*i, BAR_WIDTH, dup, (driftrainbow[min((leveltime % 18) + 1, 18 - 1)] + i*2) | V_NOSCALESTART|drifttrans); - } - else // none/blue/red - { - const INT32 limit = (driftval * (driftcharge >= driftval*2 ? 2 : 1)); - const INT32 width = ((driftcharge - (driftcharge >= driftval ? limit : 0)) * BAR_WIDTH) / limit; - - cmap = R_GetTranslationColormap(TC_RAINBOW, driftskins[driftlevel],GTC_CACHE); - - for (i = 0; i < 4; i++) - { - if (driftcharge >= driftval) - V_DrawFill(barx, bary+dup*1+dup*i, BAR_WIDTH, dup, driftcolors[driftlevel-1][i] | V_NOSCALESTART|drifttrans); - - V_DrawFill(barx, bary+dup*1+dup*i, width, dup, driftcolors[driftlevel][i] | V_NOSCALESTART|drifttrans); - } - } - - // right, also draw a cool number - //SG_DrawPaddedNum(v, basex + (dup*32), basey, driftcharge*100 / driftval, 3, "PINGN", V_NOSCALESTART|V_OFFSET|drifttrans, cmap) - if (cv_driftgaugestyle.value == 3) - V_DrawPaddedTallColorNum(basex + (dup*32), basey, V_NOSCALESTART|V_OFFSET|drifttrans, driftcharge*100 / driftval, 3, cmap); - else - V_DrawPingNum(cv_driftgaugestyle.value == 2 ? basex + (dup*22) : basex + (dup*32), basey, V_NOSCALESTART|V_OFFSET|drifttrans, driftcharge*100 / driftval, cmap); - } - break; - case 4: - { - cmap = R_GetTranslationColormap(TC_RAINBOW, driftskins[driftlevel],GTC_CACHE); - - if (driftcharge >= driftval*4) - cmap = R_GetTranslationColormap(TC_RAINBOW, 1 + leveltime % (MAXSKINCOLORS-1),GTC_CACHE); - - V_DrawPaddedTallColorNum(basex + (dup*16), basey, V_NOSCALESTART|V_OFFSET|drifttrans, driftcharge*100 / driftval, 3, cmap); - } - break; - default: - break; - } -} - -static fixed_t K_FindCheckX(fixed_t px, fixed_t py, angle_t ang, fixed_t mx, fixed_t my) -{ - fixed_t dist, x; - fixed_t range = RING_DIST/3; - angle_t diff; - - range *= gamespeed+1; - - dist = abs(R_PointToDist2(px, py, mx, my)); - if (dist > range) - return -BASEVIDWIDTH; - - diff = R_PointToAngle2(px, py, mx, my) - ang; - - if (diff < ANGLE_90 || diff > ANGLE_270) - return -BASEVIDWIDTH; - else - x = (FixedMul(FINETANGENT(((diff+ANGLE_90)>>ANGLETOFINESHIFT) & 4095), 160<>FRACBITS; - - if (encoremode) - x = BASEVIDWIDTH-x; - - if (splitscreen > 1) - x /= 2; - - return x; -} - -static void K_drawKartWanted(void) -{ - UINT8 i, numwanted = 0; - UINT8 *colormap = NULL; - INT32 basex = 0, basey = 0; - - if (stplyrnum != 0) - return; - - for (i = 0; i < 4; i++) - { - if (battlewanted[i] == -1) - break; - numwanted++; - } - - if (numwanted <= 0) - return; - - // set X/Y coords depending on splitscreen. - if (splitscreen < 3) // 1P and 2P use the same code. - { - basex = WANT_X; - basey = WANT_Y; - if (splitscreen == 2) - { - basey += 16; // slight adjust for 3P - basex -= 6; - } - } - else if (splitscreen == 3) // 4P splitscreen... - { - basex = BASEVIDWIDTH/2 - (kp_wantedsplit->width/2); // center on screen - basey = BASEVIDHEIGHT - 55; - //basey2 = 4; - } - - if (battlewanted[0] != -1) - colormap = R_GetTranslationColormap(0, players[battlewanted[0]].skincolor, GTC_CACHE); - - V_DrawFixedPatch(basex< 1 ? kp_wantedsplit : kp_wanted), colormap); - /*if (basey2) - V_DrawFixedPatch(basex< 1 ? 13 : 8), y = basey+(splitscreen > 1 ? 16 : 21); - fixed_t scale = FRACUNIT/2; - - if (battlewanted[i] == -1) - break; - - player_t *p = &players[battlewanted[i]]; - - if (numwanted == 1) - scale = FRACUNIT; - else - { - if (i & 1) - x += 16; - if (i > 1) - y += 16; - } - - if (p->skincolor) - { - colormap = R_GetTranslationColormap(TC_RAINBOW, p->skincolor, GTC_CACHE); - V_DrawFixedPatch(x<skin] : facerankprefix[p->skin]), colormap);*/ - } - } -} - -static void K_drawKartPlayerCheck(void) -{ - INT32 i; - UINT8 *colormap; - INT32 x; - - INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM); - - if (!stplyr->mo || stplyr->spectator) - return; - - if (stplyr->awayviewtics) - return; - - if (camspin[0]) - return; - - for (i = 0; i < MAXPLAYERS; i++) - { - UINT8 pnum = 0; - - if (&players[i] == stplyr) - continue; - if (!playeringame[i] || players[i].spectator) - continue; - if (!players[i].mo) - continue; - - if ((players[i].kartstuff[k_invincibilitytimer] <= 0) && (leveltime & 2)) - pnum++; // white frames - - if (players[i].kartstuff[k_itemtype] == KITEM_GROW || players[i].kartstuff[k_growshrinktimer] > 0) - pnum += 4; - else if (players[i].kartstuff[k_itemtype] == KITEM_INVINCIBILITY || players[i].kartstuff[k_invincibilitytimer]) - pnum += 2; - - x = K_FindCheckX(stplyr->mo->x, stplyr->mo->y, stplyr->mo->angle, players[i].mo->x, players[i].mo->y); - if (x <= 320 && x >= 0) - { - if (x < 14) - x = 14; - else if (x > 306) - x = 306; - - colormap = R_GetTranslationColormap(TC_DEFAULT, players[i].mo->color, GTC_CACHE); - V_DrawMappedPatch(x, CHEK_Y, V_HUDTRANS|splitflags, kp_check[pnum], colormap); - } - } -} - -static void K_drawKartMinimapIcon(fixed_t objx, fixed_t objy, INT32 hudx, INT32 hudy, INT32 flags, INT32 blend, patch_t *icon, UINT8 *colormap, drawinfo_t *dims, boolean scaleme) -{ - // amnum xpos & ypos are the icon's speed around the HUD. - // The number being divided by is for how fast it moves. - // The higher the number, the slower it moves. - - // am xpos & ypos are the icon's starting position. Withouht - // it, they wouldn't 'spawn' on the top-right side of the HUD. - - fixed_t amnumxpos, amnumypos; - INT32 amxpos, amypos; - fixed_t scale = FRACUNIT; - patch_t *AutomapPic; - INT16 w, h; - - AutomapPic = minimapinfo.minimap_pic; - - if (AutomapPic == NULL) - { - return; // no pic, just get outta here - } - - amnumxpos = (FixedMul(objx, minimapinfo.zoom) - minimapinfo.offs_x); - amnumypos = -(FixedMul(objy, minimapinfo.zoom) - minimapinfo.offs_y); - - if (encoremode) - amnumxpos = -amnumxpos; - - if (dims && (dims->x != 0) && (dims->y != 0)) - { - w = dims->x; - h = dims->y; - } - else - { - w = icon->width; - h = icon->height; - } - - amxpos = amnumxpos + ((hudx + (AutomapPic->width-w)/2)<height-h)/2)<player; - const boolean skinlocal = mo->skinlocal; - - fixed_t amnumxpos, amnumypos; - INT32 amxpos, amypos, wntdamxpos, wntdamypos; - fixed_t scale = FRACUNIT; - patch_t *minimaphead = NULL; - -#ifdef ROTSPRITE - angle_t rollangle = 0; - INT32 rot = 0; -#endif - - skin = K_GetMobjSkin(mo); - minimaphead = (skinlocal ? localfacemmapprefix : facemmapprefix)[K_GetMobjSkinNum(skin, skinlocal)]; - - amnumxpos = (FixedMul(lerp(mo->old_x, mo->x), minimapinfo.zoom) - minimapinfo.offs_x); - amnumypos = -(FixedMul(lerp(mo->old_y, mo->y), minimapinfo.zoom) - minimapinfo.offs_y); - - if (encoremode) - amnumxpos = -amnumxpos; - - amxpos = amnumxpos + ((x + (minimapinfo.minimap_pic->width-minimaphead->width) / 2)<height-minimaphead->height) / 2)<color), player_names[player - players]); - } - - // thx wanted reticle for having weird offsets very cool - wntdamxpos = cv_minihead.value ? amxpos + (1<width / 4)<height / 4)<spinoutrot) - { - // Rotate counterclockwise. - rollangle = FixedAngle(player->spinoutrot * -1); - rot = R_GetRollAngle(rollangle); - - if (rot) - { - minimaphead = W_CachePatchNameRotated(skin->facemmap, rot, PU_PATCH); - } - } -#endif - - if (!mo->color) // 'default' color - V_DrawSciencePatch(amxpos, amypos, flags, minimaphead, scale); - else - { - UINT8 *colormap; - - if (mo->colorized) - colormap = R_GetTranslationColormap(TC_RAINBOW, mo->color, GTC_CACHE); - else - colormap = R_GetLocalTranslationColormap(mo->skin, mo->localskin, mo->color, GTC_CACHE, skinlocal); - - V_DrawFixedPatch(amxpos, amypos, scale, flags, minimaphead, colormap); - - if (player - && ((G_RaceGametype() && player->kartstuff[k_position] == spbplace) - || (G_BattleGametype() && K_IsPlayerWanted(player)))) - { - V_DrawFixedPatch(wntdamxpos, wntdamypos, scale, flags, kp_wantedreticle, NULL); - } - } -} - -enum -{ - MINIANGLE_NONE = 0, - MINIANGLE_DOT, - MINIANGLE_LIGHT -}; - -static void K_drawKartMinimap(void) -{ - INT32 i = 0; - INT32 x, y; - INT32 minimaptrans, splitflags; - SINT8 localplayers[MAXSPLITSCREENPLAYERS]; - SINT8 numlocalplayers = 0; - patch_t *AutomapPic = NULL; - - // Draw the HUD only when playing in a level. - // hu_stuff needs this, unlike st_stuff. - if (gamestate != GS_LEVEL) - return; - - // Only draw for the first player - if (stplyrnum != 0) - return; - - AutomapPic = minimapinfo.minimap_pic; - - if (AutomapPic == NULL) - { - return; // no pic, just get outta here - } - - minimaptrans = K_getMinimapTrans(); - - // Exit early if it wouldn't draw anyway. - if (minimaptrans == -1) - return; - - drawinfo_t info; - K_getMinimapDrawinfo(&info); - x = info.x - (AutomapPic->width/2); - y = info.y - (AutomapPic->height/2); - splitflags = info.flags; - - splitflags |= minimaptrans; - - if (encoremode) - V_DrawScaledPatch(x+AutomapPic->width, y, splitflags|V_FLIP, AutomapPic); - else - V_DrawScaledPatch(x, y, splitflags, AutomapPic); - - if (!(splitscreen == 2)) - { - splitflags &= ~minimaptrans; - splitflags |= V_HUDTRANSHALF; - } - - // let offsets transfer to the heads, too! - if (encoremode) - x += AutomapPic->leftoffset; - else - x -= AutomapPic->leftoffset; - y -= AutomapPic->topoffset; - - // initialize - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - localplayers[i] = -1; - - // Player's tiny icons on the Automap. (drawn opposite direction so player 1 is drawn last in splitscreen) - if (ghosts) - { - demoghost *g = ghosts; - while (g) - { - K_drawKartMinimapHead(g->mo, x, y, splitflags); - g = g->next; - } - - if (!stplyr->mo || stplyr->spectator) // do we need the latter..? - return; - - localplayers[numlocalplayers++] = stplyr-players; - } - else - { - for (i = MAXPLAYERS-1; i >= 0; i--) - { - if (!playeringame[i]) - continue; - - if (!players[i].mo || players[i].spectator) - continue; - - if (P_IsDisplayPlayer(&players[i])) - { - // Draw display players on top of everything else - localplayers[numlocalplayers++] = i; - continue; - } - - // Now we know it's not a display player, handle non-local player exceptions. - if (G_BattleGametype() && players[i].kartstuff[k_bumper] <= 0) - continue; - - if (players[i].kartstuff[k_hyudorotimer] > 0) - { - if (!((players[i].kartstuff[k_hyudorotimer] < 1*TICRATE/2 - || players[i].kartstuff[k_hyudorotimer] > hyudorotime-(1*TICRATE/2)) - && !(leveltime & 1))) - continue; - } - - K_drawKartMinimapHead(players[i].mo, x, y, splitflags); - } - } - - // draw our local players here, opaque. - splitflags &= ~V_HUDTRANSHALF; - splitflags |= V_HUDTRANS; - - const SINT8 icondotradius = (cv_minihead.value && !cv_showminimapnames.value) ? 8 : 10; - patch_t* minipatch; - INT32 rot; - INT32 blending; - - for (i = 0; i < numlocalplayers; i++) - { - if (localplayers[i] == -1) - continue; // this doesn't interest us - - mobj_t *mobj = players[localplayers[i]].mo; - - // dont draw for no contestants - boolean playertimedout = (mobj->health <= 0 && players[localplayers[i]].pflags & PF_TIMEOVER); - - if (cv_showminimapangle.value && (minidoticon || minilighticon) && !playertimedout) - { - UINT8 *colormap; - drawinfo_t dims; - fixed_t interpx, interpy; - fixed_t xoff = 0, yoff = 0; - blending = 0; - - angle_t ang = R_InterpolateAngle(mobj->old_angle, mobj->angle); - - if (encoremode) - ang = ANGLE_180 - ang; - - if (mobj->colorized) - colormap = R_GetTranslationColormap(TC_RAINBOW, mobj->color, GTC_CACHE); - else - colormap = R_GetLocalTranslationColormap(mobj->skin, mobj->localskin, mobj->color, GTC_CACHE, mobj->skinlocal); - - interpx = lerp(mobj->old_x, mobj->x); - interpy = lerp(mobj->old_y, mobj->y); - - minipatch = kp_minimapdot; - - dims.x = 0; - dims.y = 0; - - if (cv_showminimapangle.value == MINIANGLE_DOT) - { - xoff = FixedMul(FCOS(ang), icondotradius); - yoff = -FixedMul(FSIN(ang), icondotradius); - } - else if (cv_showminimapangle.value == MINIANGLE_LIGHT) - { - rot = R_GetRollAngle(ang); - minipatch = W_CachePatchNameRotated("MMAPHDLT", rot, PU_PATCH); - - blending = B_ADD; - xoff = yoff = 0; - - dims.x = 48; - dims.y = 24; - } - - K_drawKartMinimapIcon( - interpx, - interpy, - x + xoff, - y + yoff, - splitflags, - blending, - minipatch, - colormap, - &dims, - false - ); - } - - // draw the minimap head after the nonsense above - K_drawKartMinimapHead(mobj, x, y, splitflags); - } -} - -#undef lerp - -static void K_drawKartStartCountdown(void) -{ - INT32 pnum = 0, splitflags = K_calcSplitFlags(0); // 3 - - if (leveltime >= starttime-(2*TICRATE)) // 2 - pnum++; - if (leveltime >= starttime-TICRATE) // 1 - pnum++; - if (leveltime >= starttime) // GO! - pnum++; - if ((leveltime % (2*5)) / 5) // blink - pnum += 4; - if (splitscreen) // splitscreen - pnum += 8; - - V_DrawScaledPatch(STCD_X - (kp_startcountdown[pnum]->width/2), STCD_Y - (kp_startcountdown[pnum]->height/2), splitflags, kp_startcountdown[pnum]); -} - -static void K_drawKartFinish(void) -{ - INT32 pnum = 0, splitflags = K_calcSplitFlags(0); - - if (!stplyr->kartstuff[k_cardanimation] || stplyr->kartstuff[k_cardanimation] >= 2*TICRATE) - return; - - if ((stplyr->kartstuff[k_cardanimation] % (2*5)) / 5) // blink - pnum = 1; - - if (splitscreen > 1) // 3/4p, stationary FIN - { - pnum += 2; - V_DrawScaledPatch(STCD_X - (kp_racefinish[pnum]->width/2), STCD_Y - (kp_racefinish[pnum]->height/2), splitflags, kp_racefinish[pnum]); - return; - } - - //else -- 1/2p, scrolling FINISH - { - INT32 x, xval; - - if (splitscreen) // wide splitscreen - pnum += 4; - - x = ((vid.width<width<kartstuff[k_cardanimation])< x ? xval : x))/TICRATE; - - if (splitscreen && stplyrnum == 1) - x = -x; - - V_DrawFixedPatch(x + (STCD_X<>1), - (STCD_Y<height<<(FRACBITS-1)), - FRACUNIT, - splitflags, kp_racefinish[pnum], NULL); - } -} - -static void K_drawBattleFullscreen(void) -{ - INT32 cardanim = stplyr->kartstuff[k_cardanimation] << FRACBITS; - - // fill in the fractional bits - if (cardanim && cardanim != 164*FRACUNIT) - { - INT32 frac = R_GetHudUncap() * ((164 - stplyr->kartstuff[k_cardanimation])/8 + 1); - if (stplyr->exiting) - cardanim += frac; - else - cardanim += stplyr->kartstuff[k_comebacktimer] < 6*TICRATE ? -frac : frac; - } - - INT32 x = BASEVIDWIDTH/2; - INT32 y = (-64*FRACUNIT) + cardanim; // card animation goes from 0 to 164, 164 is the middle of the screen - INT32 splitflags = V_SNAPTOTOP; // I don't feel like properly supporting non-green resolutions, so you can have a misuse of SNAPTO instead - fixed_t scale = FRACUNIT; - boolean drawcomebacktimer = true; // lazy hack because it's cleaner in the long run. - - if (!LUA_HudEnabled(hud_battlecomebacktimer)) - drawcomebacktimer = false; - - if (splitscreen) - { - if ((splitscreen == 1 && stplyrnum == 1) || (splitscreen > 1 && stplyrnum & 2)) - { - y = (232*FRACUNIT) - (cardanim/2); - splitflags = V_SNAPTOBOTTOM; - } - else - y = (-32*FRACUNIT) + (cardanim/2); - - if (splitscreen > 1) - { - scale /= 2; - - if (stplyrnum & 1) - x = 3*BASEVIDWIDTH/4; - else - x = BASEVIDWIDTH/4; - } - else - { - if (stplyr->exiting) - { - if (stplyrnum == 1) - x = BASEVIDWIDTH-96; - else - x = 96; - } - else - scale /= 2; - } - } - - if (stplyr->exiting) - { - if (stplyrnum == 0) - V_DrawFadeScreen(0xFF00, 16); - if (stplyr->exiting < 6*TICRATE && !stplyr->spectator) - { - if (stplyr->kartstuff[k_position] == 1) - V_DrawFixedPatch(x<kartstuff[k_bumper] <= 0 && stplyr->kartstuff[k_comebacktimer] && comeback && !stplyr->spectator && drawcomebacktimer) - { - UINT16 t = stplyr->kartstuff[k_comebacktimer]/(10*TICRATE); - INT32 txoff, adjust = (splitscreen > 1) ? 4 : 6; // normal string is 8, kart string is 12, half of that for ease - INT32 ty = (BASEVIDHEIGHT/2)+66; - - txoff = adjust; - - while (t) - { - txoff += adjust; - t /= 10; - } - - if (splitscreen) - { - if (splitscreen > 1) - ty = (BASEVIDHEIGHT/4)+33; - if ((splitscreen == 1 && stplyrnum == 1) || (splitscreen > 1 && stplyrnum & 2)) - ty += (BASEVIDHEIGHT/2); - } - else - V_DrawFadeScreen(0xFF00, 16); - - if (!comebackshowninfo) - V_DrawFixedPatch(x< 1) - V_DrawString(x-txoff, ty, 0, va("%d", stplyr->kartstuff[k_comebacktimer]/TICRATE)); - else - { - if (K_UseColorHud()) // Colourized hud - { - UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - V_DrawFixedPatch(x<kartstuff[k_comebacktimer]/TICRATE)); - } - } - - if (netgame && !stplyr->spectator && timeinmap > 113) // FREE PLAY? - { - UINT8 i; - - // check to see if there's anyone else at all - for (i = 0; i < MAXPLAYERS; i++) - { - if (i == displayplayers[0]) - continue; - if (playeringame[i] && !stplyr->spectator) - return; - } - - if (LUA_HudEnabled(hud_freeplay)) - K_drawKartFreePlay(leveltime); - } -} - -static void K_drawKartFirstPerson(void) -{ - static INT32 pnum[4], turn[4], drift[4]; - INT32 pn = 0, tn = 0, dr = 0; - INT32 target = 0, splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM); - INT32 x = BASEVIDWIDTH/2, y = BASEVIDHEIGHT; - fixed_t scale; - UINT8 *colmap = NULL; - ticcmd_t *cmd = &stplyr->cmd; - - if (stplyr->spectator || !stplyr->mo || (stplyr->mo->flags2 & MF2_DONTDRAW)) - return; - - pn = pnum[stplyrnum]; - tn = turn[stplyrnum]; - dr = drift[stplyrnum]; - - if (splitscreen) - { - y >>= 1; - if (splitscreen > 1) - x >>= 1; - } - - { - if (stplyr->speed < (20*stplyr->mo->scale) && (leveltime & 1) && !splitscreen) - y++; - // the following isn't EXPLICITLY right, it just gets the result we want, but i'm too lazy to look up the right way to do it - if (stplyr->mo->flags2 & MF2_SHADOW) - splitflags |= FF_TRANS80; - else if (stplyr->mo->frame & FF_TRANSMASK) - splitflags |= (stplyr->mo->frame & FF_TRANSMASK); - } - - if (cmd->driftturn > 400) // strong left turn - target = 2; - else if (cmd->driftturn < -400) // strong right turn - target = -2; - else if (cmd->driftturn > 0) // weak left turn - target = 1; - else if (cmd->driftturn < 0) // weak right turn - target = -1; - else // forward - target = 0; - - if (encoremode) - target = -target; - - if (pn < target) - pn++; - else if (pn > target) - pn--; - - if (pn < 0) - splitflags |= V_FLIP; // right turn - - target = abs(pn); - if (target > 2) - target = 2; - - x <<= FRACBITS; - y <<= FRACBITS; - - if (tn != cmd->driftturn/50) - tn -= (tn - (cmd->driftturn/50))/8; - - if (dr != stplyr->kartstuff[k_drift]*16) - dr -= (dr - (stplyr->kartstuff[k_drift]*16))/8; - - if (splitscreen == 1) - { - scale = (2*FRACUNIT)/3; - y += FRACUNIT/(vid.dupx < vid.dupy ? vid.dupx : vid.dupy); // correct a one-pixel gap on the screen view (not the basevid view) - } - else if (splitscreen) - scale = FRACUNIT/2; - else - scale = FRACUNIT; - - if (stplyr->mo) - { - INT32 dsone = K_GetKartDriftSparkValue(stplyr); - INT32 dstwo = dsone*2; - INT32 dsthree = dstwo*2; - -#ifndef DONTLIKETOASTERSFPTWEAKS - { - const angle_t ang = R_PointToAngle2(0, 0, stplyr->rmomx, stplyr->rmomy) - stplyr->frameangle; - // yes, the following is correct. no, you do not need to swap the x and y. - fixed_t xoffs = -P_ReturnThrustY(stplyr->mo, ang, (BASEVIDWIDTH<<(FRACBITS-2))/2); - fixed_t yoffs = -(P_ReturnThrustX(stplyr->mo, ang, 4*FRACUNIT) - 4*FRACUNIT); - - if (splitscreen) - xoffs = FixedMul(xoffs, scale); - - xoffs -= (tn)*scale; - xoffs -= (dr)*scale; - - if (stplyr->frameangle == stplyr->mo->angle) - { - const fixed_t mag = FixedDiv(stplyr->speed, 10*stplyr->mo->scale); - - if (mag < FRACUNIT) - { - xoffs = FixedMul(xoffs, mag); - if (!splitscreen) - yoffs = FixedMul(yoffs, mag); - } - } - - if (stplyr->mo->momz > 0) // TO-DO: Draw more of the kart so we can remove this if! - yoffs += stplyr->mo->momz/3; - - if (encoremode) - x -= xoffs; - else - x += xoffs; - if (!splitscreen) - y += yoffs; - } - - // drift sparks! - if ((leveltime & 1) && (stplyr->kartstuff[k_driftcharge] >= dsthree)) - colmap = R_GetTranslationColormap(TC_RAINBOW, (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))), GTC_CACHE); - else if ((leveltime & 1) && (stplyr->kartstuff[k_driftcharge] >= dstwo)) - colmap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_KETCHUP, GTC_CACHE); - else if ((leveltime & 1) && (stplyr->kartstuff[k_driftcharge] >= dsone)) - colmap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_SAPPHIRE, GTC_CACHE); - else -#endif - // invincibility/grow/shrink! - if (stplyr->mo->colorized && stplyr->mo->color) - colmap = R_GetTranslationColormap(TC_RAINBOW, stplyr->mo->color, GTC_CACHE); - } - - V_DrawFixedPatch(x, y, scale, splitflags, kp_fpview[target], colmap); - - pnum[stplyrnum] = pn; - turn[stplyrnum] = tn; - drift[stplyrnum] = dr; -} - -// doesn't need to ever support 4p -static void K_drawInput(void) -{ - static INT32 pn = 0; - INT32 offs, col; - - if (!cv_showinput.value) // dont bother - return; - - if (timeinmap <= 105) - return; - - INT32 target = 0, splitflags = (V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_HUDTRANS); - INT32 x = (BASEVIDWIDTH - 32 + cv_wheel_xoffset.value)*FRACUNIT, y = (BASEVIDHEIGHT - 24 + cv_wheel_yoffset.value)*FRACUNIT; - - const UINT8 hudcolor = K_GetHudColor(); - const INT32 accent1 = splitflags|colortranslations[hudcolor][5]; - const INT32 accent2 = splitflags|colortranslations[hudcolor][9]; - const UINT8 *hudcolormap = R_GetTranslationColormap(0, hudcolor, GTC_CACHE); - - ticcmd_t *cmd = &stplyr->cmd; - - if (timeinmap < 113) - { - INT32 count = ((INT32)(timeinmap) - 105); - INT32 frac = count > 0 && count < 6 ? R_GetHudUncap() << (FRACBITS - count - 11) : 0; - - offs = 64*FRACUNIT; - while (count-- > 0) - offs >>= 1; - x += (offs < FRACUNIT ? 0 : offs) - frac; - } - -#define BUTTW 8 -#define BUTTH 11 - -#define drawbutt(xoffs, butt, symb)\ - if (cmd->buttons & butt)\ - {\ - offs = 2*FRACUNIT;\ - col = accent1;\ - }\ - else\ - {\ - offs = 0;\ - col = accent2;\ - V_DrawFill((x + xoffs*FRACUNIT)>>FRACBITS, (y + BUTTH*FRACUNIT)>>FRACBITS, BUTTW-1, 2, splitflags|31);\ - }\ - V_DrawFill((x + xoffs*FRACUNIT)>>FRACBITS, (y+offs)>>FRACBITS, BUTTW-1, BUTTH, col);\ - V_DrawFixedPatch(x + FRACUNIT + xoffs*FRACUNIT, y + offs + FRACUNIT, FRACUNIT, splitflags, tny_font[symb-HU_FONTSTART], NULL) - - drawbutt(-2*BUTTW, BT_ACCELERATE, 'A'); - drawbutt( -BUTTW, BT_BRAKE, 'B'); - drawbutt( 0, BT_DRIFT, 'D'); - drawbutt( BUTTW, BT_ATTACK, 'I'); - -#undef drawbutt - -#undef BUTTW -#undef BUTTH - - y -= FRACUNIT; - - if (cv_showinput.value == 2 || cv_showinput.value == 3) - { - INT32 joyx, joyxoffs, joyy, joyyoffs, axis; - joyxoffs = -8, joyyoffs = -24; - joyx = x>>FRACBITS, joyy = y>>FRACBITS; - UINT8 *shadowcolormap = NULL; - const boolean usejoysprite = (cv_showinput.value == 3 && joystickicon); - - // O backing - if (usejoysprite) - { - shadowcolormap = R_GetTranslationColormap(0, SKINCOLOR_BLACK, GTC_CACHE); - V_DrawMappedPatch(joyx+joyxoffs, joyy+joyyoffs-1, splitflags, joybacking, hudcolormap); - } - else - { - V_DrawFill(joyx+joyxoffs, joyy+joyyoffs-1, 16, 16, splitflags|accent2); - V_DrawFill(joyx+joyxoffs, joyy+joyyoffs+15, 16, 1, splitflags|31); - } - - // time for pain and suffering - // kart does not have anything we can get analogue joystick y axis values from - // during normal gameplay, so replicate shit here - INT32 hudforward = 0; // for the stick input display :chaosleep: - - // this is horrid but we cant get actual input in replays so uhh - if (demo.playback || !P_IsLocalPlayer(stplyr)) // yeah........... - { - hudforward = stplyr->kartstuff[k_throwdir] * KART_FULLTURN; - } - else - { - const boolean analogjoystickmove = cv_usejoystick[stplyrnum].value && !Joystick[stplyrnum].bGamepadStyle; - const boolean gamepadjoystickmove = cv_usejoystick[stplyrnum].value && Joystick[stplyrnum].bGamepadStyle; - const UINT8 ssplayer = stplyrnum+1; - - axis = JoyAxis(AXISAIM, ssplayer); - - if (analogjoystickmove && axis != 0) - { - // JOYAXISRANGE is supposed to be 1023 (divide by 1024) - hudforward -= ((axis * KART_FULLTURN) / (JOYAXISRANGE-1)); - } - else - { - if (InputDown(gc_aimforward, ssplayer) || (gamepadjoystickmove && axis < 0)) - { - hudforward += KART_FULLTURN; - } - if (InputDown(gc_aimbackward, ssplayer) || (gamepadjoystickmove && axis > 0)) - { - hudforward-= KART_FULLTURN; - } - } - } - - hudforward = CLAMP(hudforward, -KART_FULLTURN, KART_FULLTURN); - - if (cmd->driftturn || hudforward) - { - INT16 turning = encoremode ? -cmd->driftturn : cmd->driftturn; - - if (usejoysprite) - { - V_DrawMappedPatch(joyx+joyxoffs+3-turning/80, joyy+joyyoffs+2-hudforward/80, splitflags, joyknob, shadowcolormap); - V_DrawMappedPatch(joyx+joyxoffs+3-turning/64, joyy+joyyoffs+1-hudforward/64, splitflags, joyknob, hudcolormap); - } - else - { - // joystick hole - V_DrawFill(joyx+joyxoffs+5, joyy+joyyoffs+4, 6, 6, splitflags|accent1); - // joystick top and back - V_DrawFill(joyx+joyxoffs+3-turning/80, joyy+joyyoffs+2-hudforward/80, 10, 10, splitflags|31); - V_DrawFill(joyx+joyxoffs+3-turning/64, joyy+joyyoffs+1-hudforward/64, 10, 10, splitflags|accent1); - } - } - else - { - if (usejoysprite) - { - V_DrawMappedPatch(joyx+joyxoffs+3, joyy+joyyoffs+8, splitflags, joyshadow, shadowcolormap); - V_DrawMappedPatch(joyx+joyxoffs+3, joyy+joyyoffs+1, splitflags, joyknob, hudcolormap); - } - else - { - V_DrawFill(joyx+joyxoffs+3, joyy+joyyoffs+11, 10, 1, splitflags|accent2); - V_DrawFill(joyx+joyxoffs+3, joyy+joyyoffs+1, 10, 10,splitflags|accent1); - } - } - } - else - { - if (!cmd->driftturn) // no turn - target = 0; - else // turning of multiple strengths! - { - target = ((abs(cmd->driftturn) - 1)/125)+1; - if (target > 4) - target = 4; - if (cmd->driftturn < 0) - target = -target; - } - - if (pn != target) - { - if (abs(pn - target) == 1) - pn = target; - else if (pn < target) - pn += 2; - else //if (pn > target) - pn -= 2; - } - - if (pn < 0) - { - splitflags |= V_FLIP; // right turn - x -= FRACUNIT; - } - - target = abs(pn); - if (target > 4) - target = 4; - - V_DrawFixedPatch(x, y, FRACUNIT, splitflags, kp_inputwheel[target], hudcolormap); - } -} - -static void K_drawChallengerScreen(void) -{ - // This is an insanely complicated animation. - static UINT8 anim[52] = { - 0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13, // frame 1-14, 2 tics: HERE COMES A NEW slides in - 14,14,14,14,14,14, // frame 15, 6 tics: pause on the W - 15,16,17,18, // frame 16-19, 1 tic: CHALLENGER approaches screen - 19,20,19,20,19,20,19,20,19,20, // frame 20-21, 1 tic, 5 alternating: all text vibrates from impact - 21,22,23,24 // frame 22-25, 1 tic: CHALLENGER turns gold - }; - const UINT8 offset = min(52-1, (3*TICRATE)-mapreset); - - V_DrawFadeScreen(0xFF00, 16); // Fade out - V_DrawScaledPatch(0, 0, 0, kp_challenger[anim[offset]]); -} - -static void K_drawLapStartAnim(void) -{ - // This is an EVEN MORE insanely complicated animation. - const UINT8 progress = 80-stplyr->kartstuff[k_lapanimation]; - UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - INT32 vflags = V_SNAPTOTOP|V_HUDTRANS; - - fixed_t slideout = max(0, 32*(((progress - 76)*FRACUNIT) + R_GetHudUncap())); - fixed_t slidein = max(0, 32*(((stplyr->kartstuff[k_lapanimation] - 76)*FRACUNIT) - R_GetHudUncap())); - - // First, draw the emblem and hand - INT32 emblemx = (BASEVIDWIDTH << (FRACBITS - 1)) + slidein; - INT32 y = 48*FRACUNIT - slideout; - - V_DrawFixedPatch(emblemx, y, FRACUNIT, vflags, kp_lapanim_emblem[modeattacking ? 1 : 0], colormap); - - INT32 hand = stplyr->kartstuff[k_laphand]; - if (hand >= 1 && hand <= 3) - { - y += 4*FRACUNIT - abs((int)(leveltime % 8)*FRACUNIT + R_GetHudUncap() - 4*FRACUNIT); - V_DrawFixedPatch(emblemx, y, FRACUNIT, vflags, kp_lapanim_hand[hand - 1], NULL); - } - - // Then the text - INT32 leftx = 82*FRACUNIT - slideout; - INT32 rightx = 188*FRACUNIT + slideout; - y = 30*FRACUNIT; - - if (stplyr->laps == (UINT8)(cv_numlaps.value - 1)) - { - // FINAL - V_DrawFixedPatch(leftx - 20*FRACUNIT, y, FRACUNIT, vflags, kp_lapanim_final[min(progress/2, 10)], NULL); - - // LAP - if (progress/2 - 12 >= 0) - V_DrawFixedPatch(rightx, y, FRACUNIT, vflags, kp_lapanim_lap[min(progress/2 - 12, 6)], NULL); - } - else - { - // LAP - V_DrawFixedPatch(leftx, y, FRACUNIT, vflags, kp_lapanim_lap[min(progress/2, 6)], NULL); - - char *lapnum = va("%02d", stplyr->laps + 1); - for (int i = 0; i < (int)strlen(lapnum); i++) - { - int digit = lapnum[i] - '0'; - int frame = min(2, progress/2 - 8 - (i*2)); - if (frame >= 0) - V_DrawFixedPatch(rightx + (i*20*FRACUNIT), y, FRACUNIT, vflags, kp_lapanim_number[digit][frame], NULL); - } - } -} - -void K_drawKartFreePlay(UINT32 flashtime) -{ - // no splitscreen support because it's not FREE PLAY if you have more than one player in-game - - if (! cv_showfreeplay.value) - return; - - if ((flashtime % TICRATE) < TICRATE/2) - return; - - V_DrawKartString((BASEVIDWIDTH - (LAPS_X+1)) - (12*9), // mirror the laps thingy - LAPS_Y+3, V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_HUDTRANS, "FREE PLAY"); -} - -static void K_drawDistributionDebugger(void) -{ - patch_t *items[NUMKARTRESULTS] = { - kp_sadface[1], - kp_sneaker[1], - kp_rocketsneaker[1], - kp_invincibility[7], - kp_banana[1], - kp_eggman[1], - kp_orbinaut[4], - kp_jawz[1], - kp_mine[1], - kp_ballhog[1], - kp_selfpropelledbomb[1], - kp_grow[1], - kp_shrink[1], - kp_thundershield[1], - kp_hyudoro[1], - kp_pogospring[1], - kp_kitchensink[1], - - kp_sneaker[1], - kp_banana[1], - kp_banana[1], - kp_orbinaut[4], - kp_orbinaut[4], - kp_jawz[1] - }; - INT32 useodds = 0; - INT32 pingame = 0, bestbumper = 0; - INT32 i; - INT32 x = -9, y = -9; - boolean dontforcespb = false; - boolean spbrush = false; - - if (stplyrnum != 0) // only for p1 - return; - - // The only code duplication from the Kart, just to avoid the actual item function from calculating pingame twice - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator) - continue; - pingame++; - if (players[i].exiting) - dontforcespb = true; - if (players[i].kartstuff[k_bumper] > bestbumper) - bestbumper = players[i].kartstuff[k_bumper]; - } - - if (G_RaceGametype()) - spbrush = (spbplace != -1 && stplyr->kartstuff[k_position] == spbplace+1); - - useodds = K_FindUseodds(stplyr, 0, pingame, bestbumper, spbrush, dontforcespb); - - for (i = 1; i < NUMKARTRESULTS; i++) - { - const INT32 itemodds = K_KartGetItemOdds(useodds, i, 0, spbrush); - if (itemodds <= 0) - continue; - - V_DrawScaledPatch(x, y, V_HUDTRANS|V_SNAPTOTOP, items[i]); - V_DrawThinString(x+11, y+31, V_HUDTRANS|V_SNAPTOTOP, va("%d", itemodds)); - - // Display amount for multi-items - if (i >= NUMKARTITEMS) - { - INT32 amount; - switch (i) - { - case KRITEM_TENFOLDBANANA: - amount = 10; - break; - case KRITEM_QUADORBINAUT: - amount = 4; - break; - case KRITEM_DUALJAWZ: - amount = 2; - break; - default: - amount = 3; - break; - } - V_DrawString(x+24, y+31, V_ALLOWLOWERCASE|V_HUDTRANS|V_SNAPTOTOP, va("x%d", amount)); - } - - x += 32; - if (x >= 297) - { - x = -9; - y += 32; - } - } - - V_DrawString(0, 0, V_HUDTRANS|V_SNAPTOTOP, va("USEODDS %d", useodds)); -} - -static void K_drawCheckpointDebugger(void) -{ - if (stplyrnum != 0) // only for p1 - return; - - if (stplyr->starpostnum >= (numstarposts - (numstarposts/2))) - V_DrawString(8, 184, 0, va("Checkpoint: %d / %d (Can finish)", stplyr->starpostnum, numstarposts)); - else - V_DrawString(8, 184, 0, va("Checkpoint: %d / %d (Skip: %d)", stplyr->starpostnum, numstarposts, ((numstarposts/2) + stplyr->starpostnum))); - V_DrawString(8, 192, 0, va("Waypoint dist: Prev %d, Next %d", stplyr->kartstuff[k_prevcheck], stplyr->kartstuff[k_nextcheck])); -} - -// determines if gametype info (laps/bumpers) should be hidden -static boolean K_DisableGametypeInfo(void) -{ - if (!LUA_HudEnabled(hud_gametypeinfo)) - { - return true; - } - -#ifdef ROTSPRITE - if (splitscreen || (!cv_kartspeedometer.value)) - { - // don't need to run checks if we're in splitscreen, or not using the speedometer - return false; - } - - const UINT8 speedostyle = K_GetSpeedometerStyle(); - - if (G_RaceGametype()) - { - if (speedostyle == SPEEDO_DIAL) - return true; - } - else if (G_BattleGametype()) - { - if ((cv_battlespeedo.value) && (speedostyle == SPEEDO_DIAL)) - return true; - } -#endif - - return false; -} - - -void K_drawKartHUD(void) -{ - boolean isfreeplay = false; - boolean battlefullscreen = false; - boolean freecam = camera[stplyrnum].freecam; //disable some hud elements w/ freecam - boolean gameinfovisible = false; - - // Define the X and Y for each drawn object - // This is handled by console/menu values - K_initKartHUD(); - - // Draw that fun first person HUD! Drawn ASAP so it looks more "real". - if (!camera[stplyrnum].chase && !freecam) - K_drawKartFirstPerson(); - - // Draw full screen stuff that turns off the rest of the HUD - if (mapreset && stplyrnum == 0) - { - K_drawChallengerScreen(); - return; - } - - battlefullscreen = ((G_BattleGametype()) - && (stplyr->exiting - || (stplyr->kartstuff[k_bumper] <= 0 - && stplyr->kartstuff[k_comebacktimer] - && comeback - && stplyr->playerstate == PST_LIVE))); - - if (!demo.title && (!battlefullscreen || splitscreen)) - { - // Draw the CHECK indicator before the other items, so it's overlapped by everything else - - if (LUA_HudEnabled(hud_check)) // delete lua when? - { - if (cv_kartcheck.value && !splitscreen && !players[displayplayers[0]].exiting && !freecam) - K_drawKartPlayerCheck(); - } - - // Draw WANTED status - if (G_BattleGametype()) - { - if (LUA_HudEnabled(hud_wanted)) - K_drawKartWanted(); - } - - if (cv_kartminimap.value) - { - if (LUA_HudEnabled(hud_minimap)) - K_drawKartMinimap(); - } - } - - if (battlefullscreen && !freecam) - { - if (LUA_HudEnabled(hud_battlefullscreen)) - K_drawBattleFullscreen(); - return; - } - - // Draw the item window - if (LUA_HudEnabled(hud_item) && !freecam) - K_drawKartItem(); - - if (cv_driftgauge.value && !modeattacking) - { - if (LUA_HudEnabled(hud_driftgauge)) - K_drawDriftGauge(); - } - - if (cv_nametag.value) - { - if (LUA_HudEnabled(hud_nametags)) - K_drawNameTags(); - } - - // If not splitscreen, draw... - if (!splitscreen && !demo.title) - { - tic_t realtime = stplyr->realtime; - - if (cv_showlaptimes.value - && stplyr->kartstuff[k_lapanimation] - && !stplyr->exiting - && stplyr->laptime[LAP_LAST] != 0 - && !midgamejoin) // due to vanilla compat, we cannot synch this oh well - { - if ((stplyr->kartstuff[k_lapanimation] / 5) & 1) - { - realtime = stplyr->laptime[LAP_LAST]; - } - else - { - realtime = UINT32_MAX; - } - } - - // Draw the timestamp - if (LUA_HudEnabled(hud_time)) - K_drawKartTimestamp(realtime, TIME_X, TIME_Y, gamemap, 0); - - if (!modeattacking) - { - // The top-four faces on the left - //if (LUA_HudEnabled(hud_minirankings)) - isfreeplay = K_drawKartPositionFaces(); - } - } - - if (!stplyr->spectator && !freecam) // Bottom of the screen elements, don't need in spectate mode - { - // get gametype info visibility ahead of time - gameinfovisible = (!K_DisableGametypeInfo()); - - if (!(splitscreen || demo.title)) - { - if (LUA_HudEnabled(hud_inputdisplay)) - K_drawInput(); - } - - if (!demo.title && cv_showstats.value) - { - if (LUA_HudEnabled(hud_statdisplay)) - K_drawKartStats(); - } - - if (demo.title) // Draw title logo instead in demo.titles - { - INT32 x = (BASEVIDWIDTH - 32)*FRACUNIT, y = 128*FRACUNIT, offs; - INT32 logoflags = V_SNAPTORIGHT|V_SNAPTOBOTTOM; - - if (splitscreen == 3) - { - x = BASEVIDWIDTH/2 + 10; - y = BASEVIDHEIGHT/2 - 30; - } - - if (timeinmap < 113) - { - INT32 count = ((INT32)(timeinmap) - 104); - INT32 frac = count > 0 ? R_GetHudUncap() << max(0, FRACBITS - count - 9) : 0; - - offs = 256*FRACUNIT; - while (count-- > 0) - offs >>= 1; - x += offs - frac; - } - - V_DrawSciencePatch(x - (54*FRACUNIT), y, logoflags, W_CachePatchName("TTKBANNR", PU_PATCH), FRACUNIT/4); - V_DrawSciencePatch(x - (54*FRACUNIT), y + (25*FRACUNIT), logoflags, W_CachePatchName("TTKART", PU_PATCH), FRACUNIT/4); - } - else if (G_RaceGametype()) // Race-only elements - { - // Draw the lap counter - if (gameinfovisible) - K_drawKartLaps(); - - if (!splitscreen) - { - // Draw the speedometer - // TODO: Make a better speedometer. << done :p - if (LUA_HudEnabled(hud_speedometer)) - K_drawKartSpeedometer(); - } - - if (isfreeplay) - ; - else if (!modeattacking) - { - // Draw the numerical position - if (LUA_HudEnabled(hud_position)) - K_DrawKartPositionNum(stplyr->kartstuff[k_position]); - } - } - else if (G_BattleGametype()) // Battle-only - { - // Draw the hits left! - if (gameinfovisible) - K_drawKartBumpersOrKarma(); - - if ((!splitscreen) && cv_battlespeedo.value) - { - // Draw the speedometer but in battle - // TODO: Make a better speedometer. << done :p - if (LUA_HudEnabled(hud_speedometer)) - K_drawKartSpeedometer(); - } - } - } - - // Draw the countdowns after everything else. - if (leveltime >= starttime-(3*TICRATE) - && leveltime < starttime+TICRATE) - K_drawKartStartCountdown(); - else if (racecountdown && (!splitscreen || !stplyr->exiting)) - { - char *countstr = va("%d", racecountdown/TICRATE); - - // Eeeh dunno if would be better to add another variable instead of LAPS_Y but this works too - int yoff = cv_dnft_yoffset.value - cv_laps_yoffset.value; - int xoff = cv_dnft_xoffset.value; - - if (splitscreen > 1) - V_DrawCenteredString(BASEVIDWIDTH/4+xoff, LAPS_Y+1+yoff, K_calcSplitFlags(V_SNAPTOBOTTOM), countstr); - else - { - INT32 karlen = strlen(countstr)*6; // half of 12 - V_DrawKartString((BASEVIDWIDTH/2)-karlen+xoff, LAPS_Y+3+yoff, K_calcSplitFlags(V_SNAPTOBOTTOM), countstr); - } - } - - // Race overlays - if (G_RaceGametype() && !freecam) - { - if (stplyr->exiting) - K_drawKartFinish(); - else if (stplyr->kartstuff[k_lapanimation] && !splitscreen && cv_showlapemblem.value) - K_drawLapStartAnim(); - } - - if (modeattacking || freecam) // everything after here is MP and debug only - return; - - if (G_BattleGametype() && !splitscreen && (stplyr->kartstuff[k_yougotem] % 2)) // * YOU GOT EM * - V_DrawScaledPatch(BASEVIDWIDTH/2 - (kp_yougotem->width/2), 32, V_HUDTRANS, kp_yougotem); - - // Draw FREE PLAY. - if (isfreeplay && !stplyr->spectator && timeinmap > 113) - { - if (LUA_HudEnabled(hud_freeplay)) - K_drawKartFreePlay(leveltime); - } - - if (cv_kartdebugdistribution.value) - K_drawDistributionDebugger(); - - if (cv_kartdebugcheckpoint.value) - K_drawCheckpointDebugger(); - - if (cv_kartdebugdirector.value) - K_DrawDirectorDebugger(); - - if (cv_kartdebugnodes.value) - { - UINT8 p; - for (p = 0; p < MAXPLAYERS; p++) - V_DrawString(8, 64+(8*p), V_YELLOWMAP, va("%d - %d (%dl)", p, playernode[p], players[p].cmd.latency)); - } - - if (cv_kartdebugcolorize.value && stplyr->mo && stplyr->mo->skin) - { - INT32 x = 0, y = 0; - UINT8 c; - - for (c = 1; c < MAXSKINCOLORS; c++) - { - UINT8 *cm = R_GetTranslationColormap(TC_RAINBOW, c, GTC_CACHE); - V_DrawFixedPatch(x<>1, 0, facewantprefix[stplyr->skin], cm); - - x += 16; - if (x > BASEVIDWIDTH-16) - { - x = 0; - y += 16; - } - } - } -} - -//} diff --git a/src/k_kart.h b/src/k_kart.h index 411bb0512..012cd48ac 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -6,6 +6,10 @@ #ifndef __K_KART__ #define __K_KART__ +#ifdef __cplusplus +extern "C" { +#endif + #include "doomdef.h" #include "d_player.h" // Need for player_t @@ -18,9 +22,6 @@ extern const UINT8 KartColor_Opposite[MAXSKINCOLORS*2]; void K_RainbowColormap(UINT8 *dest_colormap, UINT8 skincolor); void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color, boolean local); UINT8 K_GetKartColorByName(const char *name); -UINT8 K_GetHudColor(void); -boolean K_UseColorHud(void); -boolean K_UseHighResPortraits(void); void K_RegisterServerKartStuff(void); void K_RegisterClientKartStuff(void); @@ -29,30 +30,11 @@ extern consvar_t cv_coloredspeedlines, cv_coloredsneakertrail; extern consvar_t cv_bananajitter; extern consvar_t cv_bananthrowroll; extern consvar_t cv_airsparks; -extern consvar_t cv_colorizedhud, cv_colorizeditembox, cv_colorizedhudcolor; -extern consvar_t cv_darkitembox; -extern consvar_t cv_biglaps; -extern consvar_t cv_highresportrait; -extern consvar_t cv_stat_xoffset, cv_stat_yoffset; -extern consvar_t cv_showstats; -extern consvar_t cv_fancyroulette; -extern consvar_t cv_showlaptimes; -extern consvar_t cv_battlespeedo; -extern consvar_t cv_multiitemicon; -extern consvar_t cv_huditemamount; - -#define NUMSPEEDOSTUFF 8 -extern CV_PossibleValue_t speedo_cons_t[NUMSPEEDOSTUFF]; -#define NUMDGAUGESTUFF 6 -extern CV_PossibleValue_t driftgaugestyle_cons_t[NUMDGAUGESTUFF]; -#define NUMINPUTDISPLAYSTUFF 5 -extern CV_PossibleValue_t inputdisplay_cons_t[NUMINPUTDISPLAYSTUFF]; -#define NUMMINIMAPDOTSTUFF 5 -extern CV_PossibleValue_t minimapdot_cons_t[NUMMINIMAPDOTSTUFF]; - boolean K_IsPlayerLosing(player_t *player); boolean K_IsPlayerWanted(player_t *player); +INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed, boolean spbrush); +INT32 K_FindUseodds(player_t *player, fixed_t mashed, INT32 pingame, INT32 bestbumper, boolean spbrush, boolean dontforcespb); void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid); void K_FlipFromObject(mobj_t *mo, mobj_t *master); void K_MatchGenericExtraFlags(mobj_t *mo, mobj_t *master); @@ -111,26 +93,9 @@ void K_PlayOvertakeSound(mobj_t *source); void K_PlayHitEmSound(mobj_t *source, mobj_t *victim); void K_PlayPowerGloatSound(mobj_t *source); -const char *K_GetItemPatch(UINT8 item, boolean tiny); -INT32 K_calcSplitFlags(INT32 snapflags); -void K_LoadKartHUDGraphics(void); -void K_drawKartHUD(void); -void K_drawKartFreePlay(UINT32 flashtime); -void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UINT8 mode); - -typedef struct -{ - INT32 x; - INT32 y; - INT32 flags; -} drawinfo_t; - -patch_t *K_getItemBoxPatch(boolean small, boolean dark); -patch_t *K_getItemMulPatch(boolean small); -void K_getItemBoxDrawinfo(drawinfo_t *out); -INT32 K_getMinimapTrans(void); -void K_getLapsDrawinfo(drawinfo_t *out); -void K_getMinimapDrawinfo(drawinfo_t *out); +#ifdef __cplusplus +} // extern "C" +#endif // ========================================================================= #endif // __K_KART__ diff --git a/src/locale/en.po b/src/locale/en.po deleted file mode 100644 index b20dd837f..000000000 --- a/src/locale/en.po +++ /dev/null @@ -1,3993 +0,0 @@ -# Sonic Robo Blast 2 translation PO file. - -# Copyright (C) Sonic Team Junior - -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: 2.1\n" -"Report-Msgid-Bugs-To: Callum Dickinson \n" -"POT-Creation-Date: 2011-02-04 23:01+1300\n" -"PO-Revision-Date: 2011-02-04 23:01+1300\n" -"Last-Translator: Callum Dickinson \n" -"Language-Team: Sonic Team Junior \n" -"Language: English\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" - -#: command.c:103 -msgid "Command buffer full!\n" -msgstr "" - -#: command.c:480 -#, c-format -msgid "Unknown command '%s'\n" -msgstr "" - -#: command.c:497 -msgid "alias \n" -msgstr "" - -#: command.c:574 -msgid "exec : run a script file\n" -msgstr "" - -#: command.c:584 -#, c-format -msgid "couldn't execute file %s\n" -msgstr "" - -#: command.c:589 -#, c-format -msgid "executing %s\n" -msgstr "" - -#: command.c:623 -#, c-format -msgid "Variable %s:\n" -msgstr "" - -#: command.c:624 -msgid " flags :" -msgstr "" - -#: command.c:643 -#, c-format -msgid " range from %d to %d\n" -msgstr "" - -#: command.c:645 command.c:662 command.c:666 -#, c-format -msgid " Current value: %d\n" -msgstr "" - -#: command.c:650 -#, c-format -msgid " possible value : %s\n" -msgstr "" - -#: command.c:660 -#, c-format -msgid " Current value: %s\n" -msgstr "" - -#: command.c:669 -msgid "No Help for this command/variable\n" -msgstr "" - -#: command.c:674 -msgid "Commands\n" -msgstr "" - -#: command.c:688 -msgid "" -"\n" -"Variables\n" -msgstr "" - -#: command.c:696 -msgid "" -"\n" -"read help file for more or type help \n" -msgstr "" - -#: command.c:698 -#, c-format -msgid "Total : %d\n" -msgstr "" - -#: command.c:712 -msgid "Toggle : Toggle the value of a cvar\n" -msgstr "" - -#: command.c:718 -#, c-format -msgid "%s is not a cvar\n" -msgstr "" - -#: command.c:724 -#, c-format -msgid "%s is not a boolean value\n" -msgstr "" - -#: command.c:912 -#, c-format -msgid "Variable %s is already defined\n" -msgstr "" - -#: command.c:919 -#, c-format -msgid "%s is a command name\n" -msgstr "" - -#: command.c:942 -#, c-format -msgid "variable %s has CV_NOINIT without CV_CALL" -msgstr "" - -#: command.c:945 -#, c-format -msgid "variable %s has CV_CALL without a function" -msgstr "" - -#: command.c:1025 -#, c-format -msgid "Bounded cvar \"%s\" without maximum!" -msgstr "" - -#: command.c:1086 r_things.c:2527 -#, c-format -msgid "\"%s\" is not a possible value for \"%s\"\n" -msgstr "" - -#: command.c:1089 -#, c-format -msgid "Variable %s default value \"%s\" is not a possible value\n" -msgstr "" - -#: command.c:1117 command.c:1120 -#, c-format -msgid "%s set to %s\n" -msgstr "" - -#: command.c:1145 -#, c-format -msgid "Illegal netvar command received from %s\n" -msgstr "" - -#: command.c:1165 -#, c-format -msgid "Netvar not found with netid %hu\n" -msgstr "" - -#: command.c:1169 command.c:1171 -#, c-format -msgid "Netvar received: %s [netid=%d] value %s\n" -msgstr "" - -#: command.c:1227 -msgid "CV_Set: no variable\n" -msgstr "" - -#: command.c:1249 -#, c-format -msgid "Only the server can change this variable: %s %s\n" -msgstr "" - -#: command.c:1258 d_netcmd.c:4290 -msgid "" -"Changing this variable\n" -"requires cheats to be enabled.\n" -"Do you wish to enable cheats? (Y/N)\n" -msgstr "" - -#: command.c:1260 -msgid "Cheats must be enabled to use this.\n" -msgstr "" - -#: command.c:1282 -#, c-format -msgid "This variable can't be changed while in netgame: %s %s\n" -msgstr "" - -#: command.c:1516 -#, c-format -msgid "\"%s\" is \"%s\" default is \"%s\"\n" -msgstr "" - -#: console.c:165 -#, c-format -msgid "Number of console HUD lines is now %d\n" -msgstr "" - -#: console.c:193 -msgid "English keymap.\n" -msgstr "" - -#: console.c:207 -msgid "bind []\n" -msgstr "" - -#: console.c:208 -msgid "bind table :\n" -msgstr "" - -#: console.c:217 -msgid "Empty\n" -msgstr "" - -#: console.c:224 -msgid "Invalid key name\n" -msgstr "" - -#: console.c:1072 -msgid "Press ENTER to continue\n" -msgstr "" - -#: d_clisrv.c:201 d_clisrv.c:203 -#, c-format -msgid "" -"No more place in the buffer for netcmd %d\n" -"localtextcmd is %d\n" -"nparam is %s\n" -msgstr "" - -#: d_clisrv.c:275 -#, c-format -msgid "Got unknown net command [%s]=%d (max %d)\n" -msgstr "" - -#: d_clisrv.c:381 -msgid "Sending join request...\n" -msgstr "" - -#: d_clisrv.c:577 d_clisrv.c:599 d_clisrv.c:649 -msgid "No more free memory for savegame\n" -msgstr "" - -#: d_clisrv.c:665 -#, c-format -msgid "Didn't save %s for netgame" -msgstr "" - -#: d_clisrv.c:686 -#, c-format -msgid "Loading savegame length %s\n" -msgstr "" - -#: d_clisrv.c:689 -msgid "Can't read savegame sent" -msgstr "" - -#: d_clisrv.c:715 g_game.c:2976 -#, c-format -msgid "Map is now \"%s" -msgstr "" - -#: d_clisrv.c:720 g_game.c:2981 st_stuff.c:776 st_stuff.c:788 st_stuff.c:799 -#: st_stuff.c:810 st_stuff.c:821 st_stuff.c:832 st_stuff.c:843 st_stuff.c:854 -#: st_stuff.c:865 st_stuff.c:876 st_stuff.c:887 st_stuff.c:898 st_stuff.c:909 -#: st_stuff.c:920 -msgid "ZONE" -msgstr "" - -#: d_clisrv.c:728 -msgid "Can't load the level!\n" -msgstr "" - -#: d_clisrv.c:732 d_clisrv.c:740 -#, c-format -msgid "WARNING: Can't delete %s" -msgstr "" - -#: d_clisrv.c:933 -#, c-format -msgid "Can't delete %s" -msgstr "" - -#: d_clisrv.c:936 -msgid "Press ESC to abort\n" -msgstr "" - -#: d_clisrv.c:938 -msgid "Searching the server...\n" -msgstr "" - -#: d_clisrv.c:940 -msgid "Contacting the server...\n" -msgstr "" - -#: d_clisrv.c:958 -#, c-format -msgid "Connecting to: %s\n" -msgstr "" - -#: d_clisrv.c:968 -#, c-format -msgid "Gametype: %s\n" -msgstr "" - -#: d_clisrv.c:969 -#, c-format -msgid "Version: %d.%.2d.%u\n" -msgstr "" - -#: d_clisrv.c:986 -msgid "Found, " -msgstr "" - -#: d_clisrv.c:998 -#, c-format -msgid "" -"Maximum players reached: %d\n" -"Press ESC" -msgstr "" - -#: d_clisrv.c:1009 -msgid "Checking files...\n" -msgstr "" - -#: d_clisrv.c:1096 -msgid "Network game synchronization aborted.\n" -msgstr "" - -#: d_clisrv.c:1126 -msgid "Cheats have been activated.\n" -msgstr "" - -#: d_clisrv.c:1149 -msgid "Ban List:\n" -msgstr "" - -#: d_clisrv.c:1161 -#, c-format -msgid "Why: %s\n" -msgstr "" - -#: d_clisrv.c:1167 -msgid " None\n" -msgstr "" - -#: d_clisrv.c:1184 -msgid "Could not save ban list into ban.txt\n" -msgstr "" - -#: d_clisrv.c:1254 -msgid "Could not open ban.txt for ban list\n" -msgstr "" - -#: d_clisrv.c:1288 -msgid "" -"Connect : connect to a server\n" -"Connect ANY: connect to the first lan server found\n" -"Connect SELF: connect to your own server.\n" -msgstr "" - -#: d_clisrv.c:1296 d_clisrv.c:1327 -msgid "" -"You cannot connect while in a game\n" -"End this game first\n" -msgstr "" - -#: d_clisrv.c:1302 -msgid "" -"You have wad files loaded and/or\n" -"modified the game in some way.\n" -"Please restart SRB2 before\n" -"connecting." -msgstr "" - -#: d_clisrv.c:1343 -msgid "There is no server identification with this network driver\n" -msgstr "" - -#: d_clisrv.c:1349 -msgid "There is no network driver\n" -msgstr "" - -#: d_clisrv.c:1509 -#, c-format -msgid "num:%2d node:%2d %s\n" -msgstr "" - -#: d_clisrv.c:1511 -#, c-format -msgid "num:%2d node:%2d %s\n" -msgstr "" - -#: d_clisrv.c:1539 -#, c-format -msgid "There is no player named \"%s\"\n" -msgstr "" - -#: d_clisrv.c:1571 -msgid " (verified admin)" -msgstr "" - -#: d_clisrv.c:1574 -msgid " (spectator)" -msgstr "" - -#: d_clisrv.c:1585 -msgid "Ban or : ban and kick a player\n" -msgstr "" - -#: d_clisrv.c:1602 d_clisrv.c:1757 -msgid "Too many bans! Geez, that's a lot of people you're excluding...\n" -msgstr "" - -#: d_clisrv.c:1635 d_clisrv.c:1680 d_net.c:1142 d_netcmd.c:1911 -#: d_netcmd.c:2207 d_netcmd.c:2577 d_netcmd.c:2928 d_netcmd.c:3007 -#: d_netcmd.c:3068 d_netcmd.c:3141 d_netcmd.c:3238 d_netcmd.c:3301 -#: d_netcmd.c:4406 g_game.c:1611 -msgid "You are not the server. You cannot do this.\n" -msgstr "" - -#: d_clisrv.c:1646 -msgid "Kick or : kick a player\n" -msgstr "" - -#: d_clisrv.c:1695 -msgid "Server is being shut down remotely. Goodbye!\n" -msgstr "" - -#: d_clisrv.c:1724 -#, c-format -msgid "Illegal kick command received from %s for player %d\n" -msgstr "" - -#: d_clisrv.c:1727 -#, c-format -msgid "" -"So, you must be asking, why is this an illegal kick?\n" -"Well, let's take a look at the facts, shall we?\n" -"\n" -"playernum (this is the guy who did it), he's %d.\n" -"pnum (the guy he's trying to kick) is %d.\n" -"playernum's node is %d.\n" -"That node has %d players.\n" -"Player 2 on that node is %d.\n" -"pnum's node is %d.\n" -"That node has %d players.\n" -"Player 2 on that node is %d.\n" -"\n" -"If you think this is a bug, please report it, including all of the details above.\n" -msgstr "" - -#: d_clisrv.c:1764 -msgid "has been kicked (Go away)\n" -msgstr "" - -#: d_clisrv.c:1768 -msgid "left the game (Broke ping limit)\n" -msgstr "" - -#: d_clisrv.c:1772 -msgid "left the game (Consistency failure)\n" -msgstr "" - -#: d_clisrv.c:1778 -#, c-format -msgid "Player kicked is #%d\n" -msgstr "" - -#: d_clisrv.c:1784 -#, c-format -msgid "Player %d is at %d, %d, %d\n" -msgstr "" - -#: d_clisrv.c:1786 -#, c-format -msgid "Player %d has a null mo\n" -msgstr "" - -#: d_clisrv.c:1792 -msgid "left the game (Connection timeout)\n" -msgstr "" - -#: d_clisrv.c:1795 -msgid "left the game\n" -msgstr "" - -#: d_clisrv.c:1798 -msgid "has been banned (Don't come back)\n" -msgstr "" - -#: d_clisrv.c:1802 -#, c-format -msgid "has been kicked (%s)\n" -msgstr "" - -#: d_clisrv.c:1806 -#, c-format -msgid "has been banned (%s)\n" -msgstr "" - -#: d_clisrv.c:1820 -msgid "" -"Server closed connection\n" -"(consistency failure)\n" -"Press ESC\n" -msgstr "" - -#: d_clisrv.c:1825 -msgid "" -"Server closed connection\n" -"(Broke ping limit)\n" -"Press ESC\n" -msgstr "" - -#: d_clisrv.c:1828 -msgid "" -"You have been banned by the server\n" -"\n" -"Press ESC\n" -msgstr "" - -#: d_clisrv.c:1830 -#, c-format -msgid "" -"You have been kicked\n" -"(%s)\n" -"Press ESC\n" -msgstr "" - -#: d_clisrv.c:1832 -#, c-format -msgid "" -"You have been banned\n" -"(%s)\n" -"Press ESC\n" -msgstr "" - -#: d_clisrv.c:1834 -msgid "" -"You have been kicked by the server\n" -"\n" -"Press ESC\n" -msgstr "" - -#: d_clisrv.c:2017 -#, c-format -msgid "Illegal add player command received from %s\n" -msgstr "" - -#: d_clisrv.c:2039 -#, c-format -msgid "Player %d has joined the game (node %d)\n" -msgstr "" - -#: d_clisrv.c:2063 -#, c-format -msgid "Player Address is %s\n" -msgstr "" - -#: d_clisrv.c:2135 -#, c-format -msgid "Server added player %d node %d\n" -msgstr "" - -#: d_clisrv.c:2175 -msgid "Starting Server....\n" -msgstr "" - -#: d_clisrv.c:2666 -msgid "" -"You have been banned\n" -"from the server" -msgstr "" - -#: d_clisrv.c:2669 -#, c-format -msgid "" -"Different SRB2 versions cannot\n" -"play a netgame!\n" -"(server version %d.%d.%d)" -msgstr "" - -#: d_clisrv.c:2671 -msgid "" -"The server is not accepting\n" -"joins for the moment" -msgstr "" - -#: d_clisrv.c:2673 -#, c-format -msgid "Maximum players reached: %d" -msgstr "" - -#: d_clisrv.c:2675 -msgid "" -"Too many players from\n" -"this node." -msgstr "" - -#: d_clisrv.c:2677 -msgid "" -"No players from\n" -"this node." -msgstr "" - -#: d_clisrv.c:2695 -msgid "Server couldn't send info, please try again" -msgstr "" - -#: d_clisrv.c:2719 -msgid "" -"Server has shutdown\n" -"\n" -"Press Esc" -msgstr "" - -#: d_clisrv.c:2728 -msgid "" -"Server Timeout\n" -"\n" -"Press Esc" -msgstr "" - -#: d_clisrv.c:2754 -#, c-format -msgid "Received packet from unknown host %d\n" -msgstr "" - -#: d_clisrv.c:2781 -#, c-format -msgid "" -"Server refuses connection\n" -"\n" -"Reason:\n" -"%s" -msgstr "" - -#: d_clisrv.c:2816 -msgid "Join accepted, waiting for next level change...\n" -msgstr "" - -#: d_clisrv.c:2817 -#, c-format -msgid "Server accept join gametic=%u mynode=%d\n" -msgstr "" - -#: d_clisrv.c:2855 -#, c-format -msgid "unknown packet received (%d) from unknown host\n" -msgstr "" - -#: d_clisrv.c:2915 -#, c-format -msgid "Illegal movement value recieved from node %d\n" -msgstr "" - -#: d_clisrv.c:2940 -#, c-format -msgid "Consistency failure for player %d, restoring...\n" -msgstr "" - -#: d_clisrv.c:3052 d_clisrv.c:3057 -#, c-format -msgid "PT_SERVERTICS recieved from non-host %d\n" -msgstr "" - -#: d_clisrv.c:3112 d_clisrv.c:3117 -#, c-format -msgid "PT_CONSISTENCY recieved from non-host %d\n" -msgstr "" - -#: d_clisrv.c:3135 d_clisrv.c:3140 -#, c-format -msgid "PT_PING recieved from non-host %d\n" -msgstr "" - -#: d_main.c:822 -#, c-format -msgid "SRB2.SRB/SRB2.WAD not found! Expected in %s, ss files: %s and %s\n" -msgstr "" - -#: d_main.c:982 -msgid "Development mode ON.\n" -msgstr "" - -#: d_main.c:995 -msgid "Please set $HOME to your home directory\n" -msgstr "" - -#: d_main.c:1098 -msgid "Z_Init: Init zone memory allocation daemon. \n" -msgstr "" - -#: d_main.c:1104 -msgid "W_Init: Init WADfiles.\n" -msgstr "" - -#: d_main.c:1118 d_main.c:1120 -msgid "A WAD file was not found or not valid\n" -msgstr "" - -#: d_main.c:1169 -msgid "HU_Init: Setting up heads up display.\n" -msgstr "" - -#: d_main.c:1214 -msgid "M_Init: Init miscellaneous info.\n" -msgstr "" - -#: d_main.c:1217 -msgid "R_Init: Init SRB2 refresh daemon - " -msgstr "" - -#: d_main.c:1221 -msgid "S_Init: Setting up sound.\n" -msgstr "" - -#: d_main.c:1237 -msgid "ST_Init: Init status bar.\n" -msgstr "" - -#: d_main.c:1244 -msgid "D_CheckNetGame: Checking network game status.\n" -msgstr "" - -#: d_main.c:1284 -#, c-format -msgid "Playing demo %s.\n" -msgstr "" - -#: d_net.c:1046 -#, c-format -msgid "Set extratics to %d\n" -msgstr "" - -#: d_net.c:1058 -#, c-format -msgid "Network bandwidth set to %d\n" -msgstr "" - -#: d_net.c:1061 -msgid "usage: -bandwidth " -msgstr "" - -#: d_net.c:1077 -msgid "usage: -packetsize " -msgstr "" - -#: d_net.c:1084 -msgid "Doomcom buffer invalid!" -msgstr "" - -#: d_net.c:1086 -#, c-format -msgid "Too many nodes (%d), max:%d" -msgstr "" - -#: d_net.c:1094 d_net.c:1109 -#, c-format -msgid "debug output to: %s\n" -msgstr "" - -#: d_net.c:1111 -#, c-format -msgid "cannot debug output to file %s!\n" -msgstr "" - -#: d_net.c:1133 -#, c-format -msgid "" -"%.2d : %s\n" -" %d tics, %d ms.\n" -msgstr "" - -#: d_net.c:1137 -#, c-format -msgid "" -"%.2d : %s\n" -" %d ms\n" -msgstr "" - -#: d_netcmd.c:1000 -#, c-format -msgid "%s renamed to %s\n" -msgstr "" - -#: d_netcmd.c:1007 -#, c-format -msgid "Player %d sent a bad name change\n" -msgstr "" - -#: d_netcmd.c:1381 -#, c-format -msgid "There is no player %d!" -msgstr "" - -#: d_netcmd.c:1486 -#, c-format -msgid "Illegal color change received from %s (team: %d), color: %d)\n" -msgstr "" - -#: d_netcmd.c:1590 d_netcmd.c:1932 d_netcmd.c:3500 d_netcmd.c:4453 -#: m_cheat.c:309 m_cheat.c:343 m_cheat.c:369 m_cheat.c:398 m_cheat.c:432 -#: m_cheat.c:508 m_cheat.c:532 m_cheat.c:551 m_cheat.c:570 -msgid "DEVMODE must be enabled.\n" -msgstr "" - -#: d_netcmd.c:1596 -msgid "rteleport -x -y -z : relative teleport to a location\n" -msgstr "" - -#: d_netcmd.c:1602 d_netcmd.c:1672 -msgid "You can't teleport while in a netgame!\n" -msgstr "" - -#: d_netcmd.c:1608 d_netcmd.c:1678 -msgid "Player is dead, etc.\n" -msgstr "" - -#: d_netcmd.c:1627 d_netcmd.c:1703 -msgid "Not a valid location\n" -msgstr "" - -#: d_netcmd.c:1644 -#, c-format -msgid "Teleporting by %d, %d, %d...\n" -msgstr "" - -#: d_netcmd.c:1648 d_netcmd.c:1723 -msgid "Unable to teleport to that spot!\n" -msgstr "" - -#: d_netcmd.c:1666 -msgid "teleport -x -y -z : teleport to a location\n" -msgstr "" - -#: d_netcmd.c:1687 -msgid "X value not specified\n" -msgstr "" - -#: d_netcmd.c:1696 -msgid "Y value not specified\n" -msgstr "" - -#: d_netcmd.c:1719 -#, c-format -msgid "Teleporting to %d, %d, %d...\n" -msgstr "" - -#: d_netcmd.c:1741 -msgid "playdemo : playback a demo\n" -msgstr "" - -#: d_netcmd.c:1750 d_netcmd.c:1778 -msgid "" -"\n" -"You can't play a demo while in a netgame.\n" -msgstr "" - -#: d_netcmd.c:1758 -#, c-format -msgid "Playing back demo '%s'.\n" -msgstr "" - -#: d_netcmd.c:1769 -msgid "timedemo : time a demo\n" -msgstr "" - -#: d_netcmd.c:1786 -#, c-format -msgid "Timing demo '%s'.\n" -msgstr "" - -#: d_netcmd.c:1795 -msgid "Stopped demo.\n" -msgstr "" - -#: d_netcmd.c:1840 -#, c-format -msgid "Map change: mapnum=%d gametype=%d ultmode=%d resetplayers=%d delay=%d skipprecutscene=%d\n" -msgstr "" - -#: d_netcmd.c:1905 -msgid "map [-gametype [-force]: warp to map\n" -msgstr "" - -#: d_netcmd.c:1918 -#, c-format -msgid "Internal game level '%s' not found\n" -msgstr "" - -#: d_netcmd.c:1924 -msgid "Sorry, level change disabled in single player.\n" -msgstr "" - -#: d_netcmd.c:1940 -#, c-format -msgid "Invalid level name %s\n" -msgstr "" - -#: d_netcmd.c:1965 -msgid "You can't switch gametypes in single player!\n" -msgstr "" - -#: d_netcmd.c:2039 -#, c-format -msgid "" -"That level doesn't support %s mode!\n" -"(Use -force to override)\n" -msgstr "" - -#: d_netcmd.c:2045 -msgid "That level doesn't support Single Player mode!\n" -msgstr "" - -#: d_netcmd.c:2068 -#, c-format -msgid "Illegal map change received from %s\n" -msgstr "" - -#: d_netcmd.c:2145 -#, c-format -msgid "Speeding off to %s...\n" -msgstr "" - -#: d_netcmd.c:2201 g_game.c:1604 -msgid "You can't pause here.\n" -msgstr "" - -#: d_netcmd.c:2217 -#, c-format -msgid "Illegal pause command received from %s\n" -msgstr "" - -#: d_netcmd.c:2242 -#, c-format -msgid "Game paused by %s\n" -msgstr "" - -#: d_netcmd.c:2244 -#, c-format -msgid "Game unpaused by %s\n" -msgstr "" - -#: d_netcmd.c:2267 d_netcmd.c:3541 d_netcmd.c:4394 d_netcmd.c:4410 -#: m_cheat.c:337 m_cheat.c:363 m_cheat.c:392 m_cheat.c:426 p_tick.c:51 -#: p_tick.c:119 -msgid "You must be in a level to use this.\n" -msgstr "" - -#: d_netcmd.c:2273 -msgid "You may only use this in co-op and single player!" -msgstr "" - -#: d_netcmd.c:2286 -#, c-format -msgid "Illegal suicide command recieved from %s\n" -msgstr "" - -#: d_netcmd.c:2355 -#, c-format -msgid "Illegal clear scores command received from %s\n" -msgstr "" - -#: d_netcmd.c:2370 -msgid "Scores have been reset by the server.\n" -msgstr "" - -#: d_netcmd.c:2387 d_netcmd.c:2424 -msgid "changeteam : switch to a new team (spectator or playing)\n" -msgstr "" - -#: d_netcmd.c:2389 d_netcmd.c:2426 -msgid "changeteam : switch to a new team (red, blue or spectator)\n" -msgstr "" - -#: d_netcmd.c:2391 d_netcmd.c:2417 d_netcmd.c:2488 d_netcmd.c:2514 -#: d_netcmd.c:2593 d_netcmd.c:2632 -msgid "This command cannot be used outside of Match, Tag or CTF.\n" -msgstr "" - -#: d_netcmd.c:2443 d_netcmd.c:2540 d_netcmd.c:2670 -msgid "Invalid gametype after initial checks!" -msgstr "" - -#: d_netcmd.c:2447 d_netcmd.c:2544 -msgid "You're already on that team!\n" -msgstr "" - -#: d_netcmd.c:2453 d_netcmd.c:2550 -msgid "The server does not allow team change.\n" -msgstr "" - -#: d_netcmd.c:2462 d_netcmd.c:2559 d_netcmd.c:2683 -msgid "No tag status changes after hidetime!\n" -msgstr "" - -#: d_netcmd.c:2484 d_netcmd.c:2521 -msgid "changeteam2 : switch to a new team (spectator or playing)\n" -msgstr "" - -#: d_netcmd.c:2486 d_netcmd.c:2523 -msgid "changeteam2 : switch to a new team (red, blue or spectator)\n" -msgstr "" - -#: d_netcmd.c:2587 d_netcmd.c:2639 -msgid "serverchangeteam : switch player to a new team (spectator or playing)\n" -msgstr "" - -#: d_netcmd.c:2589 d_netcmd.c:2641 -msgid "serverchangeteam : switch player to a new team (it, notit, playing, or spectator)\n" -msgstr "" - -#: d_netcmd.c:2591 d_netcmd.c:2643 -msgid "serverchangeteam : switch player to a new team (red, blue or spectator)\n" -msgstr "" - -#: d_netcmd.c:2674 -msgid "That player is already on that team!\n" -msgstr "" - -#: d_netcmd.c:2704 d_netcmd.c:2719 d_netcmd.c:2758 -#, c-format -msgid "Illegal team change received from player %s\n" -msgstr "" - -#: d_netcmd.c:2808 -#, c-format -msgid "Player %s sent illegal team change to team %d\n" -msgstr "" - -#: d_netcmd.c:2872 -#, c-format -msgid "%s was autobalanced to even the teams.\n" -msgstr "" - -#: d_netcmd.c:2874 -#, c-format -msgid "%s was scrambled to a different team.\n" -msgstr "" - -#: d_netcmd.c:2878 p_inter.c:2042 p_inter.c:2297 p_inter.c:2569 p_tick.c:507 -#: p_user.c:5529 -#, c-format -msgid "%s is now IT!\n" -msgstr "" - -#: d_netcmd.c:2880 -#, c-format -msgid "%s switched to the red team\n" -msgstr "" - -#: d_netcmd.c:2885 -#, c-format -msgid "%s is no longer IT!\n" -msgstr "" - -#: d_netcmd.c:2887 -#, c-format -msgid "%s switched to the blue team\n" -msgstr "" - -#: d_netcmd.c:2890 p_user.c:5540 -#, c-format -msgid "%s entered the game.\n" -msgstr "" - -#: d_netcmd.c:2892 -#, c-format -msgid "%s became a spectator.\n" -msgstr "" - -#: d_netcmd.c:2934 -msgid "password : change password\n" -msgstr "" - -#: d_netcmd.c:2958 -msgid "login : Administrator login\n" -msgstr "" - -#: d_netcmd.c:2974 -#, c-format -msgid "" -"Sending Login...%s\n" -"(Notice only given if password is correct.)\n" -msgstr "" - -#: d_netcmd.c:2992 -#, c-format -msgid "%s passed authentication. (%s)\n" -msgstr "" - -#: d_netcmd.c:2996 -#, c-format -msgid "Password from %d failed (%s)\n" -msgstr "" - -#: d_netcmd.c:3013 -msgid "verify : give admin privileges to a node\n" -msgstr "" - -#: d_netcmd.c:3035 -#, c-format -msgid "Illegal verification received from %s (serverplayer is %s)\n" -msgstr "" - -#: d_netcmd.c:3052 -msgid "Password correct. You are now a server administrator.\n" -msgstr "" - -#: d_netcmd.c:3062 -msgid "motd : Set a message that clients see upon join.\n" -msgstr "" - -#: d_netcmd.c:3089 d_netcmd.c:3122 -msgid "Message of the day set.\n" -msgstr "" - -#: d_netcmd.c:3108 -#, c-format -msgid "Illegal motd change received from %s\n" -msgstr "" - -#: d_netcmd.c:3133 -msgid "runsoc or : run a soc\n" -msgstr "" - -#: d_netcmd.c:3148 -msgid "Could not find SOC.\n" -msgstr "" - -#: d_netcmd.c:3152 d_netcmd.c:3242 d_netcmd.c:3585 d_netcmd.c:3632 -#: d_netcmd.c:3976 d_netcmd.c:4006 d_netcmd.c:4038 d_netcmd.c:4067 -#: d_netcmd.c:4550 m_cheat.c:279 m_cheat.c:299 m_cheat.c:602 p_mobj.c:2682 -msgid "WARNING: Game must be restarted to record statistics.\n" -msgstr "" - -#: d_netcmd.c:3170 -#, c-format -msgid "Illegal runsoc command received from %s\n" -msgstr "" - -#: d_netcmd.c:3194 d_netcmd.c:3433 -#, c-format -msgid "" -"The server tried to add %s,\n" -"but you don't have this file.\n" -"You need to find it in order\n" -"to play on this server." -msgstr "" - -#: d_netcmd.c:3199 -#, c-format -msgid "Unknown error finding soc file (%s) the server added.\n" -msgstr "" - -#: d_netcmd.c:3222 -msgid "addfile : load wad file\n" -msgstr "" - -#: d_netcmd.c:3268 -#, c-format -msgid "MD5 calc for %s took %f second\n" -msgstr "" - -#: d_netcmd.c:3273 w_wad.c:246 -#, c-format -msgid "File %s not found.\n" -msgstr "" - -#: d_netcmd.c:3295 -msgid "You must NOT be in a level to use this.\n" -msgstr "" - -#: d_netcmd.c:3344 d_netcmd.c:3414 -#, c-format -msgid "Illegal addfile command received from %s\n" -msgstr "" - -#: d_netcmd.c:3359 -#, c-format -msgid "The server doesn't have %s\n" -msgstr "" - -#: d_netcmd.c:3361 -#, c-format -msgid "Checksum mismatch on %s\n" -msgstr "" - -#: d_netcmd.c:3363 -#, c-format -msgid "Unknown error finding wad file (%s)\n" -msgstr "" - -#: d_netcmd.c:3381 -#, c-format -msgid "Illegal delfile command received from %s\n" -msgstr "" - -#: d_netcmd.c:3438 -#, c-format -msgid "" -"Checksum mismatch while loading %s.\n" -"Make sure you have the copy of\n" -"this file that the server has.\n" -msgstr "" - -#: d_netcmd.c:3443 -#, c-format -msgid "Unknown error finding wad file (%s) the server added.\n" -msgstr "" - -#: d_netcmd.c:3457 -#, c-format -msgid "There are %d wads loaded:\n" -msgstr "" - -#: d_netcmd.c:3477 -#, c-format -msgid "SRB2%s (%s %s %s)\n" -msgstr "" - -#: d_netcmd.c:3483 -#, c-format -msgid "" -"Mod ID: %d\n" -"Mod Version: %d\n" -"Code Base:%d\n" -msgstr "" - -#: d_netcmd.c:3491 -#, c-format -msgid "Current gametype is %d\n" -msgstr "" - -#: d_netcmd.c:3504 -msgid "jumptoaxis : Jump to axis within current mare.\n" -msgstr "" - -#: d_netcmd.c:3549 d_netcmd.c:4466 m_cheat.c:375 m_cheat.c:410 m_cheat.c:444 -msgid "You can't use this in a netgame.\n" -msgstr "" - -#: d_netcmd.c:3637 -msgid "Objectplace Controls:\\\\Camera L: Cycle backwards \\Camera R: Cycle forwards \\ Jump: Float up \\ Spin: Float down \\ Throw: Place object \\Toss Flag: Remove object (buggy)\\" -msgstr "" - -#: d_netcmd.c:3702 -#, c-format -msgid "Levels will end after %s scores %d point%s.\n" -msgstr "" - -#: d_netcmd.c:3704 -msgid "a team" -msgstr "" - -#: d_netcmd.c:3704 -msgid "someone" -msgstr "" - -#: d_netcmd.c:3709 -msgid "Point limit disabled\n" -msgstr "" - -#: d_netcmd.c:3717 -#, c-format -msgid "Number of laps set to %d\n" -msgstr "" - -#: d_netcmd.c:3747 -#, c-format -msgid "Levels will end after %d minute%s.\n" -msgstr "" - -#: d_netcmd.c:3759 -msgid "Time limit disabled\n" -msgstr "" - -#: d_netcmd.c:3783 -#, c-format -msgid "Gametype was changed from %s to %s\n" -msgstr "" - -#: d_netcmd.c:3948 -#, c-format -msgid "Illegal color change received from %s (team: %d, color: %d)\n" -msgstr "" - -#: d_netcmd.c:3964 d_netcmd.c:3985 d_netcmd.c:4018 d_netcmd.c:4050 -#: d_netcmd.c:4080 -msgid "You haven't earned this yet.\n" -msgstr "" - -#: d_netcmd.c:4137 -msgid "This command cannot be used outside of Team Match or CTF.\n" -msgstr "" - -#: d_netcmd.c:4264 -msgid "Teams will be scrambled next round.\n" -msgstr "" - -#: d_netcmd.c:4272 -msgid "Cheats cannot be disabled after they are activated. You must restart the server to disable cheats.\n" -msgstr "" - -#: d_netcmd.c:4279 d_netcmd.c:4401 -msgid "You can't use this in single player.\n" -msgstr "" - -#: d_netcmd.c:4373 -msgid "HIDETIME cannot be greater or equal to the time limit!\n" -msgstr "" - -#: d_netcmd.c:4425 -#, c-format -msgid "Illegal exitlevel command received from %s\n" -msgstr "" - -#: d_netcmd.c:4446 -#, c-format -msgid "Displayplayer is %d\n" -msgstr "" - -#: d_netcmd.c:4454 -msgid "If you want to change the sky interactively on a map, use the linedef executor feature instead.\n" -msgstr "" - -#: d_netcmd.c:4460 -msgid "skynum : change the sky\n" -msgstr "" - -#: d_netcmd.c:4470 -#, c-format -msgid "Previewing sky %s...\n" -msgstr "" - -#: d_netcmd.c:4482 -#, c-format -msgid "tunes : play a slot or the default stage tune at the specified speed(100%%)\n" -msgstr "" - -#: d_netcmd.c:4483 -#, c-format -msgid "The current tune is: %d\n" -msgstr "" - -#: d_netcmd.c:4491 -#, c-format -msgid "Valid slots are 1 to %d, or 0 to stop music\n" -msgstr "" - -#: d_netcmd.c:4568 -msgid "modifiedgame is true, but you can save emblem and time data in this mod.\n" -msgstr "" - -#: d_netcmd.c:4570 -msgid "modifiedgame is true, secrets will not be unlocked\n" -msgstr "" - -#: d_netcmd.c:4572 -msgid "modifiedgame is false, you can unlock secrets\n" -msgstr "" - -#: d_netcmd.c:4599 -#, c-format -msgid "Valid skin numbers are 0 to %d (-1 disables)\n" -msgstr "" - -#: d_netcmd.c:4617 d_netcmd.c:4629 -msgid "You may not change your name when chat is muted.\n" -msgstr "" - -#: d_netcmd.c:4755 -msgid "Chat has been muted.\n" -msgstr "" - -#: d_netcmd.c:4757 -msgid "Chat is no longer muted.\n" -msgstr "" - -#: d_netcmd.c:4789 d_netcmd.c:4807 -msgid "This only works in a netgame.\n" -msgstr "" - -#: d_netcmd.c:4797 -#, c-format -msgid "%s's score is %u\n" -msgstr "" - -#: d_netcmd.c:4799 -#, c-format -msgid "The pointlimit is %d\n" -msgstr "" - -#: d_netcmd.c:4811 -#, c-format -msgid "" -"The current time is %f.\n" -"The timelimit is %f\n" -msgstr "" - -#: d_netfil.c:308 -#, c-format -msgid "searching for '%s' " -msgstr "" - -#: d_netfil.c:317 -msgid "already loaded\n" -msgstr "" - -#: d_netfil.c:326 -#, c-format -msgid "found %d\n" -msgstr "" - -#: d_netfil.c:654 -#, c-format -msgid "Downloading %s...(done)\n" -msgstr "" - -#: dehacked.c:2148 -#, c-format -msgid "Thing %d doesn't exist" -msgstr "" - -#: dehacked.c:2166 -#, c-format -msgid "Character %d out of range" -msgstr "" - -#: dehacked.c:2201 -#, c-format -msgid "Level number %d out of range" -msgstr "" - -#: dehacked.c:2209 -#, c-format -msgid "Cutscene number %d out of range" -msgstr "" - -#: dehacked.c:2217 -#, c-format -msgid "Unlockable number %d out of range" -msgstr "" - -#: dehacked.c:2225 -#, c-format -msgid "Frame %d doesn't exist" -msgstr "" - -#: dehacked.c:2252 -#, c-format -msgid "Sound %d doesn't exist" -msgstr "" - -#: dehacked.c:2277 -#, c-format -msgid "HUD item number %d out of range" -msgstr "" - -#: dehacked.c:2285 -#, c-format -msgid "Emblem number %d out of range" -msgstr "" - -#: dehacked.c:2298 -#, c-format -msgid "Warning: patch from a different SRB2 version (%d), " -msgstr "" - -#: dehacked.c:2300 -msgid "only version 2.0 is supported\n" -msgstr "" - -#: dehacked.c:2305 -#, c-format -msgid "Unknown word: %s" -msgstr "" - -#: dehacked.c:2308 -#, c-format -msgid "missing argument for '%s'" -msgstr "" - -#: dehacked.c:2311 -#, c-format -msgid "No word in this line: %s" -msgstr "" - -#: dehacked.c:2315 -#, c-format -msgid "%d warning%s in the SOC lump\n" -msgstr "" - -#: dehacked.c:2361 -msgid "Unloading WAD SOC edits\n" -msgstr "" - -#: f_finale.c:227 -msgid "Sonic Team Junior\n" -msgstr "" - -#: f_finale.c:228 f_finale.c:230 -msgid "Staff\n" -msgstr "" - -#: f_finale.c:233 -msgid "Producer\n" -msgstr "" - -#: f_finale.c:237 f_finale.c:242 -msgid "Director\n" -msgstr "" - -#: f_finale.c:246 -msgid "Game Designers\n" -msgstr "" - -#: f_finale.c:257 -msgid "Character Designers\n" -msgstr "" - -#: f_finale.c:266 -msgid "Visual Design\n" -msgstr "" - -#: f_finale.c:273 -msgid "Landscape Design\n" -msgstr "" - -#: f_finale.c:282 -msgid "Chief Programmer\n" -msgstr "" - -#: f_finale.c:289 -msgid "Programmers\n" -msgstr "" - -#: f_finale.c:304 -msgid "Coding Assistants\n" -msgstr "" - -#: f_finale.c:321 -msgid "Level Designers\n" -msgstr "" - -#: f_finale.c:349 -msgid "Texture Artists\n" -msgstr "" - -#: f_finale.c:364 -msgid "Music Production\n" -msgstr "" - -#: f_finale.c:386 -msgid "Lead Guitar\n" -msgstr "" - -#: f_finale.c:395 -msgid "Sound Effects\n" -msgstr "" - -#: f_finale.c:406 -msgid "Official Mascot\n" -msgstr "" - -#: f_finale.c:413 -msgid "Sky Sanctuary Team\n" -msgstr "" - -#: f_finale.c:457 -msgid "Special Thanks\n" -msgstr "" - -#: f_finale.c:472 -msgid "In Fond Memory Of\n" -msgstr "" - -#: f_finale.c:487 -msgid "Modification By\n" -msgstr "" - -#: f_finale.c:557 -msgid "" -"Two months had passed since Dr. Eggman\n" -"tried to take over the world using his\n" -"Ring Satellite.\n" -"#" -msgstr "" - -#: f_finale.c:561 -msgid "" -"As it was about to drain the rings\n" -"away from the planet, Sonic burst into\n" -"the Satellite and for what he thought\n" -"would be the last time, defeated\n" -"Dr. Eggman.\n" -"#" -msgstr "" - -#: f_finale.c:567 -msgid "" -"\n" -"What Sonic, Tails, and Knuckles had\n" -"not anticipated was that Eggman would\n" -"return, bringing an all new threat.\n" -"#" -msgstr "" - -#: f_finale.c:571 -msgid "" -"About once every year, a strange asteroid\n" -"hovers around the planet. it suddenly\n" -"appears from nowhere, circles around, and\n" -"- just as mysteriously as it arrives, it\n" -"vanishes after about two months.\n" -"No one knows why it appears, or how.\n" -"#" -msgstr "" - -#: f_finale.c:578 -msgid "" -"\"Curses!\" Eggman yelled. \"That hedgehog\n" -"and his ridiculous friends will pay\n" -"dearly for this!\" Just then his scanner\n" -"blipped as the Black Rock made its\n" -"appearance from nowhere. Eggman looked at\n" -"the screen, and just shrugged it off.\n" -"#" -msgstr "" - -#: f_finale.c:585 -msgid "" -"It was only later\n" -"that he had an\n" -"idea. \"The Black\n" -"Rock usually has a\n" -"lot of energy\n" -"within it... if I\n" -"can somehow\n" -"harness this, I\n" -"can turn it into\n" -"the ultimate\n" -"battle station,\n" -"and every last\n" -"person will be\n" -"begging for mercy,\n" -"including Sonic!\"\n" -"#" -msgstr "" - -#: f_finale.c:601 -msgid "" -"\n" -"\n" -"Before beginning his scheme,\n" -"Eggman decided to give Sonic\n" -"a reunion party...\n" -"#" -msgstr "" - -#: f_finale.c:605 -msgid "" -"\"We're ready to fire in 15 seconds!\"\n" -"The robot said, his voice crackling a\n" -"little down the com-link. \"Good!\"\n" -"Eggman sat back in his Egg-Mobile and\n" -"began to count down as he saw the\n" -"GreenFlower city on the main monitor.\n" -"#" -msgstr "" - -#: f_finale.c:612 -msgid "" -"\"10...9...8...\"\n" -"Meanwhile, Sonic was tearing across the\n" -"zones, and everything became nothing but\n" -"a blur as he ran around loops, skimmed\n" -"over water, and catapulted himself off\n" -"rocks with his phenomenal speed.\n" -"#" -msgstr "" - -#: f_finale.c:619 -msgid "" -"\"5...4...3...\"\n" -"Sonic knew he was getting closer to the\n" -"City, and pushed himself harder. Finally,\n" -"the city appeared in the horizon.\n" -"\"2...1...Zero.\"\n" -"#" -msgstr "" - -#: f_finale.c:625 -msgid "" -"GreenFlower City was gone.\n" -"Sonic arrived just in time to see what\n" -"little of the 'ruins' were left. Everyone\n" -"and everything in the city had been\n" -"obliterated.\n" -"#" -msgstr "" - -#: f_finale.c:631 -msgid "" -"\"You're not quite as dead as we thought,\n" -"huh? Are you going to tell us your plan as\n" -"usual or will I 'have to work it out' or\n" -"something?\" \n" -"\"We'll see... let's give you a quick warm\n" -"up, Sonic! JETTYSYNS! Open fire!\"\n" -"#" -msgstr "" - -#: f_finale.c:638 -msgid "" -"Eggman took this\n" -"as his cue and\n" -"blasted off,\n" -"leaving Sonic\n" -"and Tails behind.\n" -"Tails looked at\n" -"the ruins of the\n" -"Greenflower City\n" -"with a grim face\n" -"and sighed. \n" -"\"Now what do we\n" -"do?\", he asked.\n" -"#" -msgstr "" - -#: f_finale.c:651 -msgid "" -"\"Easy! We go\n" -"find Eggman\n" -"and stop his\n" -"latest\n" -"insane plan.\n" -"Just like\n" -"we've always\n" -"done, right? \n" -"\n" -"... \n" -"\n" -"\"Tails,what\n" -"*ARE* you\n" -"doing?\"\n" -"#" -msgstr "" - -#: f_finale.c:664 -msgid "" -"\"I'm just finding what mission obje...\n" -"a-ha! Here it is! This will only give\n" -"the robot's primary objective. It says,\n" -"* LOCATE AND RETRIEVE CHAOS EMERALD.\n" -"ESTIMATED LOCATION: GREENFLOWER ZONE *\"\n" -"\"All right, then let's go!\"\n" -"#" -msgstr "" - -#: g_game.c:1514 -#, c-format -msgid "Viewpoint: %s\n" -msgstr "" - -#: g_game.c:2007 -#, c-format -msgid "Current mare is %d\n" -msgstr "" - -#: g_game.c:2094 -msgid "No deathmatch start in this map - shifting to player starts to avoid crash...\n" -msgstr "" - -#: g_game.c:2098 -msgid "There aren't enough starts in this map!\n" -msgstr "" - -#: g_game.c:2118 -msgid "No Red Team start in this map, resorting to Deathmatch starts!\n" -msgstr "" - -#: g_game.c:2135 -msgid "No Blue Team start in this map, resorting to Deathmatch starts!\n" -msgstr "" - -#: g_game.c:2300 -msgid "The round has ended.\n" -msgstr "" - -#: g_game.c:2337 -#, c-format -msgid "Unknown gametype! %d\n" -msgstr "" - -#: g_game.c:2432 -#, c-format -msgid "Next map given (MAP %d) doesn't exist! Reverting to MAP01.\n" -msgstr "" - -#: g_game.c:2445 -#, c-format -msgid "Warning: Can't find a compatible map after map %d; using map %d even though it is not compatible with the current gametype\n" -msgstr "" - -#: g_game.c:2708 g_game.c:2837 -msgid "No more free memory for saving game data\n" -msgstr "" - -#: g_game.c:2767 -#, c-format -msgid "Couldn't read file %s\n" -msgstr "" - -#: g_game.c:2859 -msgid "Game saved.\n" -msgstr "" - -#: g_game.c:2861 -#, c-format -msgid "Error while writing to %s for save slot %u, base: %s\n" -msgstr "" - -#: g_game.c:3187 -#, c-format -msgid "ERROR: cannot open file '%s'.\n" -msgstr "" - -#: g_game.c:3257 -msgid "Movie mode enabled.\n" -msgstr "" - -#: g_game.c:3266 -msgid "Movie mode disabled.\n" -msgstr "" - -#: g_game.c:3277 -#, c-format -msgid "Loaded level in %f sec\n" -msgstr "" - -#: g_game.c:3325 -#, c-format -msgid "" -"timed %u gametics in %d realtics\n" -"%f seconds, %f avg fps\n" -msgstr "" - -#: g_game.c:3354 -#, c-format -msgid "Demo %s recorded\n" -msgstr "" - -#: g_game.c:3356 -#, c-format -msgid "Demo %s not saved\n" -msgstr "" - -#: g_input.c:1299 -#, c-format -msgid "Control '%s' unknown\n" -msgstr "" - -#: g_input.c:1320 -msgid "setcontrol [<2nd keyname>]\n" -msgstr "" - -#: g_input.c:1335 -msgid "setcontrol2 [<2nd keyname>]\n" -msgstr "" - -#: hardware/hw_main.c:4346 -#, c-format -msgid "Patch info headers: %7s kb\n" -msgstr "" - -#: hardware/hw_main.c:4347 -#, c-format -msgid "3D Texture cache : %7s kb\n" -msgstr "" - -#: hardware/hw_main.c:4348 -#, c-format -msgid "Plane polygon : %7s kb\n" -msgstr "" - -#: hardware/hw_md2.c:898 -msgid "Error while loading md2.dat\n" -msgstr "" - -#: hardware/hw_md2.c:915 -#, c-format -msgid " Not found: %s\n" -msgstr "" - -#: hu_stuff.c:375 -msgid "The chat is muted. You can't say anything at the moment.\n" -msgstr "" - -#: hu_stuff.c:410 -msgid "say : send a message\n" -msgstr "" - -#: hu_stuff.c:427 -msgid "sayto : send a message to a player\n" -msgstr "" - -#: hu_stuff.c:434 -msgid "sayto: No player with that name!\n" -msgstr "" - -#: hu_stuff.c:450 -msgid "sayteam : send a message to your team\n" -msgstr "" - -#: hu_stuff.c:456 -msgid "Dedicated servers can't send team messages. Use \"say\".\n" -msgstr "" - -#: hu_stuff.c:470 -msgid "csay : send a message to be shown in the middle of the screen\n" -msgstr "" - -#: hu_stuff.c:476 -msgid "Only servers and admins can use csay.\n" -msgstr "" - -#: hu_stuff.c:502 -#, c-format -msgid "Illegal csay command received from non-admin %s\n" -msgstr "" - -#: hu_stuff.c:502 -#, c-format -msgid "Illegal say command received from %s while muted\n" -msgstr "" - -#: hu_stuff.c:526 -#, c-format -msgid "Illegal say command received from %s containing invalid characters\n" -msgstr "" - -#: hu_stuff.c:723 m_menu.c:6989 -msgid "[Message unsent]\n" -msgstr "" - -#: i_tcp.c:710 -msgid "failed to bind with IPv6 stack" -msgstr "" - -#: i_tcp.c:717 -msgid "UDP_Socket error. Could not set socket to non blocking mode" -msgstr "" - -#: i_tcp.c:724 -msgid "UDP_Socket error. Could not set socket to allow broadcast" -msgstr "" - -#: i_tcp.c:729 -#, c-format -msgid "Network system buffer: %dKb\n" -msgstr "" - -#: i_tcp.c:738 -msgid "Can't set buffer length to 64k, file transfer will be bad\n" -msgstr "" - -#: i_tcp.c:740 -#, c-format -msgid "Network system buffer set to: %dKb\n" -msgstr "" - -#: i_tcp.c:799 -#, c-format -msgid "Network system receive buffer: %dKb\n" -msgstr "" - -#: i_tcp.c:805 i_tcp.c:810 -#, c-format -msgid "Network system receive buffer set to: %dKb\n" -msgstr "" - -#: i_tcp.c:806 -msgid "Can't set receive buffer length to 64k, file transfer will be bad\n" -msgstr "" - -#: i_tcp.c:991 sdl/i_cdmus.c:383 sdl/i_sound.c:1138 sdl/i_sound.c:1463 -#: sdl/i_video.c:2162 -msgid "shut down\n" -msgstr "" - -#: i_tcp.c:1043 -#, c-format -msgid "Resolving %s\n" -msgstr "" - -#: i_tcp.c:1047 -#, c-format -msgid "%s unknown\n" -msgstr "" - -#: i_tcp.c:1054 -#, c-format -msgid "Resolved %s\n" -msgstr "" - -#: m_argv.c:161 -#, c-format -msgid "Response file %s not found" -msgstr "" - -#: m_argv.c:163 -#, c-format -msgid "Found response file %s\n" -msgstr "" - -#: m_argv.c:169 -msgid "No more free memory for the respone file" -msgstr "" - -#: m_argv.c:171 -#, c-format -msgid "Couldn't read response file because %s" -msgstr "" - -#: m_argv.c:183 -msgid "Not enough memory to read response file" -msgstr "" - -#: m_argv.c:214 -#, c-format -msgid "%d command-line args:\n" -msgstr "" - -#: m_cheat.c:272 -#, c-format -msgid "No Clipping %s\n" -msgstr "" - -#: m_cheat.c:272 m_cheat.c:292 -msgid "Off" -msgstr "" - -#: m_cheat.c:272 m_cheat.c:292 -msgid "On" -msgstr "" - -#: m_cheat.c:292 -#, c-format -msgid "Sissy Mode %s\n" -msgstr "" - -#: m_cheat.c:315 m_cheat.c:349 m_cheat.c:514 m_cheat.c:538 m_cheat.c:557 -#: m_cheat.c:576 -msgid "This only works in single player.\n" -msgstr "" - -#: m_cheat.c:321 -msgid "scale (5-400): set player scale size\n" -msgstr "" - -#: m_cheat.c:330 -#, c-format -msgid "Scale set to %d\n" -msgstr "" - -#: m_cheat.c:381 -msgid "hurtme \n" -msgstr "" - -#: m_cheat.c:404 m_cheat.c:419 -msgid "charability <1/2> \n" -msgstr "" - -#: m_cheat.c:438 m_cheat.c:461 -msgid "charspeed \n" -msgstr "" - -#: m_cheat.c:473 -msgid "Your reality is everyone's reality. Therefore, you should not use this command.\n" -msgstr "" - -#: m_cheat.c:524 -#, c-format -msgid "Temporary checkpoint created at %d, %d, %d\n" -msgstr "" - -#: m_cheat.c:544 -msgid "You now have all 7 emeralds.\n" -msgstr "" - -#: m_cheat.c:563 -msgid "Emeralds reset to zero.\n" -msgstr "" - -#: m_cheat.c:582 -msgid "All secrets unlocked.\n" -msgstr "" - -#: m_menu.c:4123 m_menu.c:4140 m_menu.c:4157 m_menu.c:4174 m_menu.c:4190 -#: m_menu.c:4669 -msgid "" -"You are in a network game.\n" -"End it?\n" -"(Y/N).\n" -msgstr "" - -#: m_menu.c:7116 -msgid "" -"Only the server can do a load net game!\n" -"\n" -"press a key." -msgstr "" - -#: m_menu.c:7169 -msgid "" -"Are you sure you want to end the game?\n" -"\n" -"press Y or N." -msgstr "" - -#: m_menu.c:7227 -#, c-format -msgid "" -"%s\n" -"\n" -"(Press 'Y' to quit)" -msgstr "" - -#: m_menu.c:8195 -msgid "" -"Eggman's tied explosives\n" -"to your girlfriend, and\n" -"will activate them if\n" -"you press the 'Y' key!\n" -"Press 'N' to save her!" -msgstr "" - -#: m_menu.c:8196 -msgid "" -"What would Tails say if\n" -"he saw you quitting the game?" -msgstr "" - -#: m_menu.c:8197 -msgid "" -"Hey!\n" -"Where do ya think you're goin'?" -msgstr "" - -#: m_menu.c:8198 -msgid "" -"Forget your studies!\n" -"Play some more!" -msgstr "" - -#: m_menu.c:8199 -msgid "" -"You're trying to say you\n" -"like Sonic 2K6 better than\n" -"this, right?" -msgstr "" - -#: m_menu.c:8200 -msgid "" -"Don't leave yet -- there's a\n" -"super emerald around that corner!" -msgstr "" - -#: m_menu.c:8201 -msgid "You'd rather work than play?" -msgstr "" - -#: m_menu.c:8202 -msgid "" -"Go ahead and leave. See if I care...\n" -"*sniffle*" -msgstr "" - -#: m_menu.c:8204 -msgid "" -"If you leave now,\n" -"Eggman will take over the world!" -msgstr "" - -#: m_menu.c:8205 -msgid "" -"Don't quit!\n" -"There are animals\n" -"to save!" -msgstr "" - -#: m_menu.c:8206 -msgid "" -"Aw c'mon, just bop\n" -"a few more robots!" -msgstr "" - -#: m_menu.c:8207 -msgid "Did you get all those Chaos Emeralds?" -msgstr "" - -#: m_menu.c:8208 -msgid "" -"If you leave, I'll use\n" -"my spin attack on you!" -msgstr "" - -#: m_menu.c:8209 -msgid "" -"Don't go!\n" -"You might find the hidden\n" -"levels!" -msgstr "" - -#: m_menu.c:8210 -msgid "" -"Hit the 'N' key, Sonic!\n" -"The 'N' key!" -msgstr "" - -#: m_menu.c:8212 -msgid "" -"Are you really going to\n" -"give up?\n" -"We certainly would never give you up." -msgstr "" - -#: m_menu.c:8213 -msgid "Come on, just ONE more netgame!" -msgstr "" - -#: m_menu.c:8214 -msgid "" -"Press 'N' to unlock\n" -"the Ultimate Cheat!" -msgstr "" - -#: m_menu.c:8215 -msgid "" -"Why don't you go back and try\n" -"jumping on that house to\n" -"see what happens?" -msgstr "" - -#: m_menu.c:8216 -msgid "" -"Every time you press 'Y', an\n" -"SRB2 Developer cries..." -msgstr "" - -#: m_menu.c:8217 -msgid "" -"You'll be back to play soon, though...\n" -"......right?" -msgstr "" - -#: m_menu.c:8218 -msgid "" -"Aww, is Egg Rock Zone too\n" -"difficult for you?" -msgstr "" - -#: m_misc.c:398 -msgid "saveconfig [-silent] : save config to a file\n" -msgstr "" - -#: m_misc.c:406 -#, c-format -msgid "config saved as %s\n" -msgstr "" - -#: m_misc.c:417 -msgid "loadconfig : load config from a file\n" -msgstr "" - -#: m_misc.c:434 -msgid "changeconfig : save current config and load another\n" -msgstr "" - -#: m_misc.c:454 -#, c-format -msgid "config file: %s\n" -msgstr "" - -#: m_misc.c:487 m_misc.c:505 -msgid "Config filename must be .cfg\n" -msgstr "" - -#: m_misc.c:497 m_misc.c:512 -#, c-format -msgid "Couldn't save game config file %s\n" -msgstr "" - -#: m_misc.c:1048 -msgid "Recording into next new file\n" -msgstr "" - -#: m_misc.c:1340 -#, c-format -msgid "screen shot %s saved in %s\n" -msgstr "" - -#: m_misc.c:1345 -#, c-format -msgid "Couldn't create screen shot %s in %s\n" -msgstr "" - -#: m_misc.c:1347 -#, c-format -msgid "Couldn't create screen shot (all 10000 slots used!) in %s\n" -msgstr "" - -#: mserv.c:337 mserv.c:364 -msgid "No servers currently running.\n" -msgstr "" - -#: mserv.c:465 mserv.c:506 mserv.c:572 mserv.c:610 mserv.c:850 mserv.c:947 -msgid "cannot connect to the master server\n" -msgstr "" - -#: mserv.c:466 mserv.c:507 mserv.c:573 -msgid "" -"There was a problem connecting to\n" -"the Master Server" -msgstr "" - -#: mserv.c:532 -#, c-format -msgid "" -"You have been banned from\n" -"hosting netgames.\n" -"\n" -"Under the following IP Range:\n" -"%s - %s\n" -"\n" -"For the following reason:\n" -"%s\n" -"\n" -"Your ban will expire on:\n" -"%s" -msgstr "" - -#: mserv.c:534 -#, c-format -msgid "" -"You have been banned from\n" -"joining netgames.\n" -"\n" -"Under the following IP Range:\n" -"%s - %s\n" -"\n" -"For the following reason:\n" -"%s\n" -"\n" -"Your ban will expire on:\n" -"%s" -msgstr "" - -#: mserv.c:557 -msgid "Master Server Offline." -msgstr "" - -#: mserv.c:558 -msgid "Offline" -msgstr "" - -#: mserv.c:602 -msgid "Not yet registered to the master server.\n" -msgstr "" - -#: mserv.c:606 -msgid "Retrieving server list...\n" -msgstr "" - -#: mserv.c:615 -msgid "cannot get server list\n" -msgstr "" - -#: mserv.c:637 -msgid "Connection to master server failed\n" -msgstr "" - -#: mserv.c:668 -msgid "Timeout on masterserver\n" -msgstr "" - -#: mserv.c:679 -#, c-format -msgid "Masterserver error on select #%u: %s\n" -msgstr "" - -#: mserv.c:691 -#, c-format -msgid "Masterserver getsockopt error #%u: %s\n" -msgstr "" - -#: mserv.c:703 -msgid "Dedicated internet servers must use the -room parameter!" -msgstr "" - -#: mserv.c:734 -msgid "Master Server Updated Successfully!\n" -msgstr "" - -#: mserv.c:843 -msgid "Registering this server to the master server...\n" -msgstr "" - -#: mserv.c:943 -msgid "Unregistering this server to the master server...\n" -msgstr "" - -#: mserv.c:952 -msgid "cannot remove this server from the master server\n" -msgstr "" - -#: mserv.c:980 -msgid "You cannot register on the Master Server mid-game, please end your current session and re-host ifyou wish to advertise your server on the Master Server.\n" -msgstr "" - -#: p_enemy.c:2057 -msgid "Note: All monitors turned off.\n" -msgstr "" - -#: p_enemy.c:2252 p_enemy.c:2291 p_enemy.c:2321 p_enemy.c:2352 p_enemy.c:2383 -#: p_enemy.c:2407 p_enemy.c:2437 p_enemy.c:2470 p_enemy.c:2509 p_enemy.c:2540 -#: p_enemy.c:2581 p_enemy.c:2614 p_enemy.c:4957 -msgid "ERROR: Powerup has no target!\n" -msgstr "" - -#: p_enemy.c:2258 -#, c-format -msgid "Power #%d out of range!\n" -msgstr "" - -#: p_enemy.c:2297 -#, c-format -msgid "Weapon #%d out of range!\n" -msgstr "" - -#: p_inter.c:1540 -#, c-format -msgid "%s returned the red flag to base.\n" -msgstr "" - -#: p_inter.c:1555 -#, c-format -msgid "%s picked up the red flag!\n" -msgstr "" - -#: p_inter.c:1591 -#, c-format -msgid "%s returned the blue flag to base.\n" -msgstr "" - -#: p_inter.c:1606 -#, c-format -msgid "%s picked up the blue flag!\n" -msgstr "" - -#: p_inter.c:1665 p_inter.c:1826 -#, c-format -msgid "%s%s%s died.\n" -msgstr "" - -#: p_inter.c:1679 -#, c-format -msgid "%s%s%s crushed %s%s%s with a heavy object!\n" -msgstr "" - -#: p_inter.c:1692 -#, c-format -msgid "%s%s%s suicided.\n" -msgstr "" - -#: p_inter.c:1703 -#, c-format -msgid "%s%s%s was fried by %s%s%s's fire trail.\n" -msgstr "" - -#: p_inter.c:1707 p_inter.c:1903 -#, c-format -msgid "%s%s%s was %s by %s%s%s's %sbounce ring.\n" -msgstr "" - -#: p_inter.c:1710 p_inter.c:1906 -#, c-format -msgid "%s%s%s was %s by %s%s%s's %sautomatic ring.\n" -msgstr "" - -#: p_inter.c:1713 p_inter.c:1909 -#, c-format -msgid "%s%s%s was %s by %s%s%s's %sscatter ring.\n" -msgstr "" - -#: p_inter.c:1716 p_inter.c:1912 -#, c-format -msgid "%s%s%s was %s by %s%s%s's %sexplosion ring.\n" -msgstr "" - -#: p_inter.c:1719 p_inter.c:1915 -#, c-format -msgid "%s%s%s was %s by %s%s%s's %sgrenade ring.\n" -msgstr "" - -#: p_inter.c:1722 p_inter.c:1918 -#, c-format -msgid "%s%s%s was %s by %s%s%s's %sturbo ring.\n" -msgstr "" - -#: p_inter.c:1725 p_inter.c:1921 -#, c-format -msgid "%s%s%s was %s by %s%s%s's %smine ring.\n" -msgstr "" - -#: p_inter.c:1728 p_inter.c:1924 -#, c-format -msgid "%s%s%s was %s by %s%s%s's %sBFR blast.\n" -msgstr "" - -#: p_inter.c:1732 p_inter.c:1928 -#, c-format -msgid "%s%s%s was %s by %s%s%s's %sBFR laser.\n" -msgstr "" - -#: p_inter.c:1734 p_inter.c:1930 -#, c-format -msgid "%s%s%s was %s by %s%s%s's %srail ring.\n" -msgstr "" - -#: p_inter.c:1738 p_inter.c:1934 -#, c-format -msgid "%s%s%s was %s by %s%s%s's %sring.\n" -msgstr "" - -#: p_inter.c:1742 p_inter.c:1884 -#, c-format -msgid "%s%s%s was %s by %s%s%s.\n" -msgstr "" - -#: p_inter.c:1751 p_inter.c:1844 -msgid "killed" -msgstr "" - -#: p_inter.c:1755 p_inter.c:1944 -msgid "reflected " -msgstr "" - -#: p_inter.c:1774 -#, c-format -msgid "%s%s%s drowned.\n" -msgstr "" - -#: p_inter.c:1779 -#, c-format -msgid "%s%s%s was impaled by spikes!\n" -msgstr "" - -#: p_inter.c:1784 -#, c-format -msgid "%s%s%s was crushed.\n" -msgstr "" - -#: p_inter.c:1790 -#, c-format -msgid "%s%s%s was %s by a blue crawla!\n" -msgstr "" - -#: p_inter.c:1794 -#, c-format -msgid "%s%s%s was %s by a red crawla!\n" -msgstr "" - -#: p_inter.c:1798 -#, c-format -msgid "%s%s%s was %s by a jetty-syn gunner!\n" -msgstr "" - -#: p_inter.c:1802 -#, c-format -msgid "%s%s%s was %s by a jetty-syn bomber!\n" -msgstr "" - -#: p_inter.c:1806 -#, c-format -msgid "%s%s%s was %s by a crawla commander!\n" -msgstr "" - -#: p_inter.c:1810 -#, c-format -msgid "%s%s%s was %s by the Egg Mobile!\n" -msgstr "" - -#: p_inter.c:1814 -#, c-format -msgid "%s%s%s was %s by the Egg Slimer!\n" -msgstr "" - -#: p_inter.c:1828 -#, c-format -msgid "%s%s%s fell in some nasty goop!\n" -msgstr "" - -#: p_inter.c:1830 -#, c-format -msgid "%s%s%s burned to death!\n" -msgstr "" - -#: p_inter.c:1832 -#, c-format -msgid "%s%s%s was electrocuted!\n" -msgstr "" - -#: p_inter.c:1835 -#, c-format -msgid "%s%s%s fell into a bottomless pit.\n" -msgstr "" - -#: p_inter.c:1837 -#, c-format -msgid "%s%s%s asphyxiated in space!\n" -msgstr "" - -#: p_inter.c:1854 -#, c-format -msgid "%s got a game over.\n" -msgstr "" - -#: p_inter.c:1856 -#, c-format -msgid "%s has %d lives remaining.\n" -msgstr "" - -#: p_inter.c:1891 -#, c-format -msgid "%s%s%s got nuked by %s%s%s!\n" -msgstr "" - -#: p_inter.c:1899 -#, c-format -msgid "%s%s%s was burnt by %s%s%s's fire trail.\n" -msgstr "" - -#: p_inter.c:1943 -msgid "hit" -msgstr "" - -#: p_inter.c:2031 -msgid "The IT player has left the game.\n" -msgstr "" - -#: p_inter.c:2051 p_inter.c:2075 -msgid "All players have been tagged!\n" -msgstr "" - -#: p_inter.c:2063 -msgid "There are no players able to become IT.\n" -msgstr "" - -#: p_inter.c:2315 p_inter.c:2574 -#, c-format -msgid "%s was found!\n" -msgstr "" - -#: p_inter.c:3981 -#, c-format -msgid "%s tossed the %s flag.\n" -msgstr "" - -#: p_inter.c:3983 -#, c-format -msgid "%s dropped the %s flag.\n" -msgstr "" - -#: p_mobj.c:202 p_mobj.c:264 -msgid "Warning: State Cycle Detected\n" -msgstr "" - -#: p_mobj.c:5757 -msgid "The red flag has returned to base.\n" -msgstr "" - -#: p_mobj.c:5767 -msgid "The blue flag has returned to base.\n" -msgstr "" - -#: p_setup.c:603 p_setup.c:605 p_setup.c:611 -msgid "You need to unlock this level first!\n" -msgstr "" - -#: p_setup.c:609 -msgid "You need to unlock this level in single player first!\n" -msgstr "" - -#: p_setup.c:876 -msgid "No more free memory for thing writing!\n" -msgstr "" - -#: p_setup.c:901 -#, c-format -msgid "newthings%d.lmp saved.\n" -msgstr "" - -#: p_setup.c:2228 -msgid "No player currently available to become IT. Awaiting available players.\n" -msgstr "" - -#: p_setup.c:2355 -#, c-format -msgid "Loading SOC lump: %s\n" -msgstr "" - -#: p_setup.c:2377 -#, c-format -msgid "Couldn't load wad file %s\n" -msgstr "" - -#: p_setup.c:2420 -#, c-format -msgid "%s sounds replaced\n" -msgstr "" - -#: p_setup.c:2422 -#, c-format -msgid "%s musics replaced\n" -msgstr "" - -#: p_setup.c:2481 -msgid "No maps added\n" -msgstr "" - -#: p_setup.c:2489 -#, c-format -msgid "Current map %d replaced by added file, ending the level to ensure consistiency.\n" -msgstr "" - -#: p_spec.c:3162 -#, c-format -msgid "%s\\captured the blue flag.\\\\\\\\" -msgstr "" - -#: p_spec.c:3197 p_spec.c:3276 -msgid "the enemy has returned\\their flag.\\\\\\\\" -msgstr "" - -#: p_spec.c:3200 p_spec.c:3279 -msgid "your flag was returned\\to base.\\\\\\\\" -msgstr "" - -#: p_spec.c:3244 -#, c-format -msgid "%s\\captured the red flag.\\\\\\\\" -msgstr "" - -#: p_spec.c:3482 -#, c-format -msgid "%s has finished the race.\n" -msgstr "" - -#: p_spec.c:3484 -#, c-format -msgid "%s started lap %d\n" -msgstr "" - -#: p_spec.c:4166 -#, c-format -msgid "%s recieved double points for surviving the round.\n" -msgstr "" - -#: p_tick.c:57 -msgid "" -"numthinkers <#>: Count number of thinkers\n" -"\t1: P_MobjThinker\n" -"\t2: P_RainThinker\n" -"\t3: P_SnowThinker\n" -"\t4: P_NullPrecipThinker\n" -"\t5: T_Friction\n" -"\t6: T_Pusher\n" -"\t7: P_RemoveThinkerDelayed\n" -msgstr "" - -#: p_tick.c:69 -msgid "Number of P_MobjThinker: " -msgstr "" - -#: p_tick.c:73 -msgid "Number of P_RainThinker: " -msgstr "" - -#: p_tick.c:77 -msgid "Number of P_SnowThinker: " -msgstr "" - -#: p_tick.c:81 -msgid "Number of P_NullPrecipThinker: " -msgstr "" - -#: p_tick.c:85 -msgid "Number of T_Friction: " -msgstr "" - -#: p_tick.c:89 -msgid "Number of T_Pusher: " -msgstr "" - -#: p_tick.c:93 -msgid "Number of P_RemoveThinkerDelayed: " -msgstr "" - -#: p_tick.c:96 -msgid "That is not a valid number.\n" -msgstr "" - -#: p_tick.c:131 -#, c-format -msgid "Object number %d out of range (max %d).\n" -msgstr "" - -#: p_tick.c:146 -#, c-format -msgid "There are %d objects of type %d currently in the level.\n" -msgstr "" - -#: p_tick.c:151 -msgid "Count of active objects in level:\n" -msgstr "" - -#: p_user.c:358 -#, c-format -msgid "%s got a chain of %u!\n" -msgstr "" - -#: p_user.c:1345 -#, c-format -msgid "%s has completed the level.\n" -msgstr "" - -#: p_user.c:4865 p_user.c:5004 -msgid "Sorry, you're too high to place this object (max: 4095 above bottom floor).\n" -msgstr "" - -#: p_user.c:4999 -msgid "Sorry, you're too high to place this object (max: 2047 above bottom floor).\n" -msgstr "" - -#: p_user.c:5051 -#, c-format -msgid "Spawned at %d\n" -msgstr "" - -#: p_user.c:5121 p_user.c:5138 -#, c-format -msgid "Current mapthing is %d\n" -msgstr "" - -#: p_user.c:5215 p_user.c:5225 -#, c-format -msgid "Sorry, you're too %s to place this object (max: %d %s).\n" -msgstr "" - -#: p_user.c:5215 p_user.c:5225 -msgid "high" -msgstr "" - -#: p_user.c:5215 p_user.c:5225 -msgid "low" -msgstr "" - -#: p_user.c:5216 p_user.c:5226 -msgid "above bottom floor" -msgstr "" - -#: p_user.c:5216 p_user.c:5226 -msgid "below top ceiling" -msgstr "" - -#: p_user.c:5273 -#, c-format -msgid "Placed object mapthingum %d, not the one below.\n" -msgstr "" - -#: p_user.c:5283 -#, c-format -msgid "Placed object type %d at %d, %d, %d, %d\n" -msgstr "" - -#: p_user.c:5329 -msgid "Deleting...\n" -msgstr "" - -#: p_user.c:5343 -msgid "Deleted.\n" -msgstr "" - -#: p_user.c:5364 -msgid "You cannot delete this item because it doesn't have a mapthing!\n" -msgstr "" - -#: p_user.c:5545 -msgid "You must wait until next round to enter the game.\n" -msgstr "" - -#: p_user.c:5551 p_user.c:5611 -msgid "Server does not allow team change.\n" -msgstr "" - -#: p_user.c:8721 -#, c-format -msgid "%s caused a world of pain.\n" -msgstr "" - -#: p_user.c:9737 -#, c-format -msgid "%s ran out of time.\n" -msgstr "" - -#: r_data.c:481 -#, c-format -msgid "Number of Extra Colormaps: %s\n" -msgstr "" - -#: r_main.c:136 -msgid "Splitscreen not supported in netplay, sorry!\n" -msgstr "" - -#: r_things.c:410 -#, c-format -msgid "sprite %s set in pwad %d\n" -msgstr "" - -#: r_things.c:414 -#, c-format -msgid "%s sprites added from file %s\n" -msgstr "" - -#: r_things.c:460 -#, c-format -msgid "%s sprites removed from file %s\n" -msgstr "" - -#: r_things.c:2377 -#, c-format -msgid "Skin %s not found\n" -msgstr "" - -#: r_things.c:2471 -#, c-format -msgid "Skin %d not found\n" -msgstr "" - -#: r_things.c:2788 -#, c-format -msgid "Added skin '%s'\n" -msgstr "" - -#: r_things.c:2850 -#, c-format -msgid "Removed skin '%s'\n" -msgstr "" - -#: s_sound.c:349 -msgid "Loading sounds... " -msgstr "" - -#: s_sound.c:355 -msgid " pre-cached all sound data\n" -msgstr "" - -#: s_sound.c:1081 -#, c-format -msgid "ERROR: Music lump %.6s not found!\n" -msgstr "" - -#: screen.c:169 -#, c-format -msgid "" -"WARNING: Resolution is not aspect-correct!\n" -"Use a multiple of %dx%d\n" -msgstr "" - -#: screen.c:311 -#, c-format -msgid "Using resolution: %d x %d\n" -msgstr "" - -#: screen.c:317 -#, c-format -msgid "Default resolution: %d x %d (%d bits)\n" -msgstr "" - -#: sdl/i_cdmus.c:99 sdl/i_cdmus.c:224 sdl/i_cdmus.c:436 win32/win_cd.c:401 -msgid "No CD in drive\n" -msgstr "" - -#: sdl/i_cdmus.c:105 -#, c-format -msgid "CD Error: %s\n" -msgstr "" - -#: sdl/i_cdmus.c:132 -msgid "CD eject failed\n" -msgstr "" - -#: sdl/i_cdmus.c:153 win32/win_cd.c:199 -msgid "" -"cd [on] [off] [remap] [reset] [select]\n" -" [open] [info] [play ] [resume]\n" -" [stop] [pause] [loop ]\n" -msgstr "" - -#: sdl/i_cdmus.c:186 -#, c-format -msgid "Opened CD-ROM drive %s\n" -msgstr "" - -#: sdl/i_cdmus.c:188 sdl/i_cdmus.c:422 sdl/i_cdmus.c:424 -#, c-format -msgid "Couldn't open CD-ROM drive %s: %s\n" -msgstr "" - -#: sdl/i_cdmus.c:238 -#, c-format -msgid "%u tracks\n" -msgstr "" - -#: sdl/i_cdmus.c:240 win32/win_cd.c:297 -#, c-format -msgid "Currently %s track %u\n" -msgstr "" - -#: sdl/i_cdmus.c:240 sdl/i_cdmus.c:242 win32/win_cd.c:297 -msgid "looping" -msgstr "" - -#: sdl/i_cdmus.c:240 sdl/i_cdmus.c:242 win32/win_cd.c:297 -msgid "playing" -msgstr "" - -#: sdl/i_cdmus.c:242 -#, c-format -msgid "Paused %s track %u\n" -msgstr "" - -#: sdl/i_cdmus.c:243 -#, c-format -msgid "Volume is %d\n" -msgstr "" - -#: sdl/i_cdmus.c:276 win32/win_cd.c:326 -#, c-format -msgid "Invalid CD command \"CD %s\"\n" -msgstr "" - -#: sdl/i_cdmus.c:406 -msgid "I_InitCD: Init CD audio\n" -msgstr "" - -#: sdl/i_cdmus.c:411 -#, c-format -msgid "Couldn't initialize SDL CDROM: %s\n" -msgstr "" - -#: sdl/i_cdmus.c:442 win32/win_cd.c:389 -msgid "CD audio Initialized\n" -msgstr "" - -#: sdl/i_cdmus.c:520 -#, c-format -msgid "Bad track number %u.\n" -msgstr "" - -#: sdl/i_cdmus.c:527 -#, c-format -msgid "Track %u is not audio\n" -msgstr "" - -#: sdl/i_cdmus.c:540 -#, c-format -msgid "Error playing track %d: %s\n" -msgstr "" - -#: sdl/i_main.c:183 win32/win_main.c:598 -msgid "Setting up SRB2...\n" -msgstr "" - -#: sdl/i_main.c:185 win32/win_main.c:600 -msgid "Entering main game loop...\n" -msgstr "" - -#: sdl/i_sound.c:1184 win32/win_snd.c:925 -#, c-format -msgid " requested frequency of %d hz\n" -msgstr "" - -#: sdl/i_sound.c:1264 -msgid " Using 3D sound driver\n" -msgstr "" - -#: sdl/i_sound.c:1267 sdl/i_sound.c:1272 -msgid " Failed loading 3D sound driver\n" -msgstr "" - -#: sdl/i_sound.c:1278 sdl/i_sound.c:1645 -msgid " couldn't open audio with desired format\n" -msgstr "" - -#: sdl/i_sound.c:1285 -#, c-format -msgid " Starting up with audio driver : %s\n" -msgstr "" - -#: sdl/i_sound.c:1289 -#, c-format -msgid " configured audio device with %d samples/slice at %ikhz(%dms buffer)\n" -msgstr "" - -#: sdl/i_sound.c:1291 -msgid " Sound module ready\n" -msgstr "" - -#: sdl/i_sound.c:1377 -#, c-format -msgid "Couldn't load music lump: %s\n" -msgstr "" - -#: sdl/i_sound.c:1387 -#, c-format -msgid "Couldn't load music data: %s\n" -msgstr "" - -#: sdl/i_sound.c:1421 -#, c-format -msgid "Couldn't open file %s to write music in\n" -msgstr "" - -#: sdl/i_sound.c:1428 -#, c-format -msgid "Couldn't write music into file %s because %s\n" -msgstr "" - -#: sdl/i_sound.c:1441 -#, c-format -msgid "Couldn't load music file %s: %s\n" -msgstr "" - -#: sdl/i_sound.c:1455 -msgid "I_ShutdownMusic: " -msgstr "" - -#: sdl/i_sound.c:1611 -msgid "I_InitMusic:" -msgstr "" - -#: sdl/i_sound.c:1617 -msgid " Unable to load FLAC support\n" -msgstr "" - -#: sdl/i_sound.c:1621 -msgid " Unable to load MOD support\n" -msgstr "" - -#: sdl/i_sound.c:1625 -msgid " Unable to load MP3 support\n" -msgstr "" - -#: sdl/i_sound.c:1629 -msgid " Unable to load OGG support\n" -msgstr "" - -#: sdl/i_sound.c:1635 -#, c-format -msgid " Unable to open music: %s\n" -msgstr "" - -#: sdl/i_sound.c:1651 -#, c-format -msgid " Starting with audio driver : %s\n" -msgstr "" - -#: sdl/i_sound.c:1657 -#, c-format -msgid " Starting up with audio driver : %s with SDL_Mixer\n" -msgstr "" - -#: sdl/i_sound.c:1671 -msgid "Music initialized\n" -msgstr "" - -#: sdl/i_sound.c:1690 -#, c-format -msgid "Couldn't play song because %s\n" -msgstr "" - -#: sdl/i_sound.c:1816 -#, c-format -msgid "Couldn't load MIDI: %s\n" -msgstr "" - -#: sdl/i_system.c:1120 sdl/i_system.c:1414 -#, c-format -msgid "Couldn't initialize joystick: %s\n" -msgstr "" - -#: sdl/i_system.c:1130 sdl/i_system.c:1422 -#, c-format -msgid "Cannot use joystick #%d/(%s), it doesn't exist\n" -msgstr "" - -#: sdl/i_system.c:1151 sdl/i_system.c:1443 -#, c-format -msgid "Found %d joysticks on this system\n" -msgstr "" - -#: sdl/i_system.c:1156 sdl/i_system.c:1448 -msgid "Found no joysticks on this system\n" -msgstr "" - -#: sdl/i_system.c:1161 -#, c-format -msgid "Joystick: %s\n" -msgstr "" - -#: sdl/i_system.c:1165 -#, c-format -msgid "Couldn't open joystick: %s\n" -msgstr "" - -#: sdl/i_system.c:1453 -#, c-format -msgid "Joystick2: %s\n" -msgstr "" - -#: sdl/i_system.c:1457 -#, c-format -msgid "Couldn't open joystick2: %s\n" -msgstr "" - -#: sdl/i_system.c:1782 win32/win_sys.c:977 -msgid "Read Error on secondary mouse port\n" -msgstr "" - -#: sdl/i_system.c:1878 win32/win_sys.c:1038 -#, c-format -msgid "Error opening %s!\n" -msgstr "" - -#: sdl/i_system.c:1946 -#, c-format -msgid "Can't open %s: Access denied\n" -msgstr "" - -#: sdl/i_system.c:1948 win32/win_sys.c:1040 -#, c-format -msgid "Can't open %s: error %d\n" -msgstr "" - -#: sdl/i_system.c:2124 win32/win_sys.c:460 -msgid "Using GetTickCount()\n" -msgstr "" - -#: sdl/i_video.c:553 win32/win_vid.c:1084 -#, c-format -msgid "%d video mode(s) available(s)\n" -msgstr "" - -#: sdl/i_video.c:565 -msgid "Unknown Surface" -msgstr "" - -#: sdl/i_video.c:570 -#, c-format -msgid " %ix%i at %i bit color\n" -msgstr "" - -#: sdl/i_video.c:573 -msgid " Stored in video memory\n" -msgstr "" - -#: sdl/i_video.c:575 -msgid " Stored in an OpenGL context\n" -msgstr "" - -#: sdl/i_video.c:577 -msgid " Uses preallocated memory\n" -msgstr "" - -#: sdl/i_video.c:579 -msgid " Stored in system memory\n" -msgstr "" - -#: sdl/i_video.c:582 -msgid " Uses asynchronous blits if possible\n" -msgstr "" - -#: sdl/i_video.c:584 -msgid " Uses synchronous blits if possible\n" -msgstr "" - -#: sdl/i_video.c:587 -msgid " Allows any pixel-format\n" -msgstr "" - -#: sdl/i_video.c:590 -msgid " Has exclusive palette access\n" -msgstr "" - -#: sdl/i_video.c:592 -msgid " Has nonexclusive palette access\n" -msgstr "" - -#: sdl/i_video.c:595 -msgid " Double buffered\n" -msgstr "" - -#: sdl/i_video.c:597 -msgid " No hardware flipping\n" -msgstr "" - -#: sdl/i_video.c:600 -msgid " Full screen\n" -msgstr "" - -#: sdl/i_video.c:602 -msgid " Resizable window\n" -msgstr "" - -#: sdl/i_video.c:604 -msgid " Nonresizable window\n" -msgstr "" - -#: sdl/i_video.c:607 -msgid " Uses hardware acceleration blit\n" -msgstr "" - -#: sdl/i_video.c:609 -msgid " Use colorkey blitting\n" -msgstr "" - -#: sdl/i_video.c:611 -msgid " Colorkey RLE acceleration blit\n" -msgstr "" - -#: sdl/i_video.c:613 -msgid " Use alpha blending acceleration blit\n" -msgstr "" - -#: sdl/i_video.c:623 -msgid "Video Interface Capabilities:\n" -msgstr "" - -#: sdl/i_video.c:625 -msgid " Hardware surfaces\n" -msgstr "" - -#: sdl/i_video.c:627 -msgid " Window manager\n" -msgstr "" - -#: sdl/i_video.c:631 -msgid " Accelerated blits HW-2-HW\n" -msgstr "" - -#: sdl/i_video.c:633 -msgid " Accelerated blits HW-2-HW with Colorkey\n" -msgstr "" - -#: sdl/i_video.c:635 -msgid " Accelerated blits HW-2-HW with Alpha\n" -msgstr "" - -#: sdl/i_video.c:638 -msgid " Accelerated blits SW-2-HW\n" -msgstr "" - -#: sdl/i_video.c:642 -msgid " Accelerated blits SW-2-HW with Colorkey\n" -msgstr "" - -#: sdl/i_video.c:644 -msgid " Accelerated blits SW-2-HW with Alpha\n" -msgstr "" - -#: sdl/i_video.c:646 -msgid " Accelerated Color filling\n" -msgstr "" - -#: sdl/i_video.c:649 -#, c-format -msgid " There is %i KB of video memory\n" -msgstr "" - -#: sdl/i_video.c:651 -msgid " There no video memory for SDL\n" -msgstr "" - -#: sdl/i_video.c:654 -msgid "Current Engine Mode" -msgstr "" - -#: sdl/i_video.c:656 -msgid "Prebuffer Mode" -msgstr "" - -#: sdl/i_video.c:657 -msgid "Postbuffer Mode" -msgstr "" - -#: sdl/i_video.c:659 -msgid "Current Video Mode" -msgstr "" - -#: sdl/i_video.c:675 win32/win_vid.c:1149 -msgid "No video modes present\n" -msgstr "" - -#: sdl/i_video.c:686 -#, c-format -msgid "Found %d FullScreen Video Modes:\n" -msgstr "" - -#: sdl/i_video.c:693 -#, c-format -msgid "%dx%d and " -msgstr "" - -#: sdl/i_video.c:697 -msgid "None\n" -msgstr "" - -#: sdl/i_video.c:707 win32/win_vid.c:1142 -#, c-format -msgid "vid_mode : set video mode, current video mode %i\n" -msgstr "" - -#: sdl/i_video.c:714 win32/win_vid.c:1101 -msgid "No such video mode\n" -msgstr "" - -#: sdl/i_video.c:1969 -#, c-format -msgid "Couldn't initialize SDL's Audio System with Video System: %s\n" -msgstr "" - -#: sdl/i_video.c:1973 -#, c-format -msgid "Couldn't initialize SDL's Video System: %s\n" -msgstr "" - -#: sdl/i_video.c:1985 -#, c-format -msgid "Starting up with video driver : %s\n" -msgstr "" - -#: sdl/i_video.c:2054 -msgid "" -"The version of the renderer doesn't match the version of the executable\n" -"Be sure you have installed SRB2 properly.\n" -msgstr "" - -#: sdl/i_video.c:2097 -#, c-format -msgid "Could not set vidmode: %s\n" -msgstr "" - -#: sdl/i_video.c:2106 -msgid "Not enough memory for video buffer\n" -msgstr "" - -#: sounds.c:1473 -msgid "No more free sound slots\n" -msgstr "" - -#: st_stuff.c:1558 -msgid "WAITING FOR PLAYERS TO HIDE..." -msgstr "" - -#: st_stuff.c:1564 -msgid "HIDE BEFORE TIME RUNS OUT!" -msgstr "" - -#: st_stuff.c:1566 -msgid "FLEE BEFORE YOU ARE HUNTED!" -msgstr "" - -#: st_stuff.c:1569 -msgid "HIDE TIME REMAINING:" -msgstr "" - -#: st_stuff.c:1578 -msgid "YOU'RE IT!" -msgstr "" - -#: st_stuff.c:1582 -msgid "TIME REMAINING:" -msgstr "" - -#: st_stuff.c:1584 -msgid "NO TIME LIMIT" -msgstr "" - -#: st_stuff.c:1727 st_stuff.c:1729 st_stuff.c:1773 st_stuff.c:1775 -msgid "RED TEAM" -msgstr "" - -#: st_stuff.c:1734 st_stuff.c:1736 st_stuff.c:1779 st_stuff.c:1781 -msgid "BLUE TEAM" -msgstr "" - -#: st_stuff.c:1741 st_stuff.c:1743 st_stuff.c:1785 st_stuff.c:1787 -msgid "SPECTATOR" -msgstr "" - -#: st_stuff.c:1821 -msgid "TIME LEFT" -msgstr "" - -#: st_stuff.c:1855 -msgid "CONTINUE?" -msgstr "" - -#: st_stuff.c:2196 st_stuff.c:2198 -msgid "OVERTIME!" -msgstr "" - -#: st_stuff.c:2251 -msgid "Viewpoint:" -msgstr "" - -#: st_stuff.c:2269 -msgid "I, Pope Rededict XVI proclaim" -msgstr "" - -#: st_stuff.c:2270 -msgid "AJ & Amy" -msgstr "" - -#: st_stuff.c:2271 -msgid "Husband & Wife" -msgstr "" - -#: st_stuff.c:2272 -msgid "on this day" -msgstr "" - -#: st_stuff.c:2273 -msgid "May 16, 2009" -msgstr "" - -#: st_stuff.c:2279 -msgid "Oh... it's you again..." -msgstr "" - -#: st_stuff.c:2280 -msgid "Look, I wanted to apologize for the way" -msgstr "" - -#: st_stuff.c:2281 -msgid "I've acted in the past." -msgstr "" - -#: st_stuff.c:2282 -msgid "I've seen the error of my ways" -msgstr "" - -#: st_stuff.c:2283 -msgid "and turned over a new leaf." -msgstr "" - -#: st_stuff.c:2284 -msgid "Instead of sending people to hell," -msgstr "" - -#: st_stuff.c:2285 -msgid "I now send them to heaven!" -msgstr "" - -#: st_stuff.c:2317 -msgid "Thank you!" -msgstr "" - -#: st_stuff.c:2318 -msgid "But our earless leader is in" -msgstr "" - -#: st_stuff.c:2319 -msgid "another castle!" -msgstr "" - -#: st_stuff.c:2328 st_stuff.c:2334 st_stuff.c:2356 -msgid "Press Viewpoint Key to watch a player." -msgstr "" - -#: st_stuff.c:2333 -msgid "You cannot move while hiding." -msgstr "" - -#: st_stuff.c:2344 -#, c-format -msgid "Respawn in: %d seconds." -msgstr "" - -#: st_stuff.c:2346 -msgid "Press Jump to respawn." -msgstr "" - -#: st_stuff.c:2351 -msgid "You are a spectator." -msgstr "" - -#: st_stuff.c:2353 -msgid "Press Fire to be assigned to a team." -msgstr "" - -#: st_stuff.c:2355 -msgid "Press Fire to enter the game." -msgstr "" - -#: st_stuff.c:2357 -msgid "Press Jump to float and Spin to sink." -msgstr "" - -#: w_wad.c:138 -#, c-format -msgid "Loading main config from %s\n" -msgstr "" - -#: w_wad.c:148 -#, c-format -msgid "Loading object config from %s\n" -msgstr "" - -#: w_wad.c:219 w_wad.c:264 -msgid "Maximum wad files reached\n" -msgstr "" - -#: w_wad.c:240 -#, c-format -msgid "Can't open %s\n" -msgstr "" - -#: w_wad.c:295 -#, c-format -msgid "Can't read wad header from %s because %s\n" -msgstr "" - -#: w_wad.c:305 -#, c-format -msgid "%s doesn't have IWAD or PWAD id\n" -msgstr "" - -#: w_wad.c:318 -#, c-format -msgid "%s wadfile directory is corrupt; maybe %s\n" -msgstr "" - -#: w_wad.c:398 -#, c-format -msgid "Added file %s (%u lumps)\n" -msgstr "" - -#: w_wad.c:414 -#, c-format -msgid "You can't remove the IWAD %s!\n" -msgstr "" - -#: w_wad.c:418 -#, c-format -msgid "Removing WAD %s...\n" -msgstr "" - -#: w_wad.c:438 -msgid " done unloading WAD\n" -msgstr "" - -#: w_wad.c:953 -#, c-format -msgid "File is corrupt or has been modified: %s (found md5: %s, wanted: %s)\n" -msgstr "" - -#: win32/win_cd.c:229 -msgid "CD tracks remapped in that order :\n" -msgstr "" - -#: win32/win_cd.c:256 -msgid "CD is not ready.\n" -msgstr "" - -#: win32/win_cd.c:281 -msgid "No audio tracks\n" -msgstr "" - -#: win32/win_cd.c:290 -msgid "audio" -msgstr "" - -#: win32/win_cd.c:290 -msgid "data " -msgstr "" - -#: win32/win_cd.c:293 -#, c-format -msgid "Total time : %s\n" -msgstr "" - -#: win32/win_main.c:335 -msgid "Hello, it's me, SRB2's Console Window\n" -msgstr "" - -#: win32/win_main.c:339 -msgid "We have a console already.\n" -msgstr "" - -#: win32/win_snd.c:987 -#, c-format -msgid "Using external sound driver %s\n" -msgstr "" - -#: win32/win_snd.c:992 -#, c-format -msgid "Not using external sound driver %s\n" -msgstr "" - -#: win32/win_snd.c:1003 -msgid " DirectSound DLL not loaded\n" -msgstr "" - -#: win32/win_snd.c:1011 -msgid "" -" DirectSoundCreate FAILED\n" -" there is no sound device or the sound device is under\n" -" the control of another application\n" -msgstr "" - -#: win32/win_snd.c:1023 -msgid " SetCooperativeLevel FAILED\n" -msgstr "" - -#: win32/win_snd.c:1049 -#, c-format -msgid "CreateSoundBuffer FAILED: %s (ErrNo %ld)\n" -msgstr "" - -#: win32/win_snd.c:1064 -msgid "Couldn't set primary buffer format.\n" -msgstr "" - -#: win32/win_snd.c:1071 -msgid " Compacting onboard sound-memory..." -msgstr "" - -#: win32/win_snd.c:1083 -msgid " Primary buffer continuous play FAILED\n" -msgstr "" - -#: win32/win_snd.c:1120 -msgid "sound initialized.\n" -msgstr "" - -#: win32/win_snd.c:1193 -#, c-format -msgid "%d mixer devices available\n" -msgstr "" - -#: win32/win_snd.c:1289 -msgid "No MIDI devices available, music is disabled\n" -msgstr "" - -#: win32/win_snd.c:1353 -msgid "No MIDI music\n" -msgstr "" - -#: win32/win_snd.c:1365 -msgid "midiStreamOpen FAILED\n" -msgstr "" - -#: win32/win_snd.c:1544 -msgid "Couldn't set volume\n" -msgstr "" - -#: win32/win_snd.c:2116 -msgid "Music lump is not MID music format\n" -msgstr "" - -#: win32/win_snd.c:2128 -msgid "I_RegisterSong: StreamBufferSetup FAILED" -msgstr "" - -#: win32/win_sys.c:892 -msgid "Could not create IDirectInput device 2" -msgstr "" - -#: win32/win_sys.c:1185 -msgid "\tMouse will not use DirectInput.\n" -msgstr "" - -#: win32/win_sys.c:1722 win32/win_sys.c:2081 -#, c-format -msgid "Capabilities: %lu axes, %lu buttons, %lu POVs, poll %u, Gamepad %d\n" -msgstr "" - -#: win32/win_sys.c:1954 -msgid "Joystick disabled\n" -msgstr "" - -#: win32/win_sys.c:1968 win32/win_sys.c:2330 -msgid "Looking for joystick devices:\n" -msgstr "" - -#: win32/win_sys.c:1975 win32/win_sys.c:2338 -msgid "Joystick initialize failed.\n" -msgstr "" - -#: win32/win_sys.c:1983 win32/win_sys.c:2346 -msgid "none found\n" -msgstr "" - -#: win32/win_sys.c:1986 win32/win_sys.c:2349 -msgid "none used\n" -msgstr "" - -#: win32/win_sys.c:1989 -msgid "Set the use_joystick variable to one of the enumerated joystick numbers\n" -msgstr "" - -#: win32/win_sys.c:2002 -msgid "I_InitJoystick: SetCooperativeLevel FAILED" -msgstr "" - -#: win32/win_sys.c:2006 win32/win_sys.c:2373 -msgid "Joystick already initialized\n" -msgstr "" - -#: win32/win_sys.c:2316 -msgid "Joystick2 disabled\n" -msgstr "" - -#: win32/win_sys.c:2353 -msgid "Set the use_joystick2 variable to one of the enumerated joysticks number\n" -msgstr "" - -#: win32/win_sys.c:2364 -msgid "I_InitJoystick2: SetCooperativeLevel FAILED" -msgstr "" - -#: win32/win_sys.c:3466 -#, c-format -msgid "Couldn't create DirectInput (reason: %s)" -msgstr "" - -#: win32/win_sys.c:3469 -msgid "Using DirectX3 interface\n" -msgstr "" - -#: win32/win_vid.c:621 -msgid "mode skipped (too many)\n" -msgstr "" - -#: win32/win_vid.c:769 -msgid "WARNING: This r_opengl version is not supported, use it at your own risk.\n" -msgstr "" - -#: win32/win_vid.c:981 -#, c-format -msgid "Mode changed to %d (%s)\n" -msgstr "" - -#: win32/win_vid.c:1108 -#, c-format -msgid "" -"width: %d\n" -"height: %d\n" -msgstr "" - -#: win32/win_vid.c:1110 -#, c-format -msgid "" -"bytes per scanline: %d\n" -"bytes per pixel: %d\n" -"numpages: %d\n" -msgstr "" - -#: y_inter.c:254 -msgid "GOT TIME BONUS EMBLEM!" -msgstr "" - -#: y_inter.c:256 -msgid "GOT PERFECT BONUS EMBLEM!" -msgstr "" - -#: y_inter.c:567 -msgid "Teams will be scrambled next round!" -msgstr "" - -#: z_zone.c:113 -#, c-format -msgid "system memory %uMB free %uMB\n" -msgstr "" - -#: z_zone.c:446 -msgid "Memory Info\n" -msgstr "" - -#: z_zone.c:447 -#, c-format -msgid "Total heap used : %7s KB\n" -msgstr "" - -#: z_zone.c:448 -#, c-format -msgid "Static : %7s KB\n" -msgstr "" - -#: z_zone.c:449 -#, c-format -msgid "Static (sound) : %7s KB\n" -msgstr "" - -#: z_zone.c:450 -#, c-format -msgid "Static (music) : %7s KB\n" -msgstr "" - -#: z_zone.c:451 -#, c-format -msgid "Level : %7s KB\n" -msgstr "" - -#: z_zone.c:452 -#, c-format -msgid "Special thinker : %7s KB\n" -msgstr "" - -#: z_zone.c:453 -#, c-format -msgid "All purgable : %7s KB\n" -msgstr "" - -#: z_zone.c:458 -#, c-format -msgid "Patch info headers: %7s KB\n" -msgstr "" - -#: z_zone.c:459 -#, c-format -msgid "Mipmap patches : %7s KB\n" -msgstr "" - -#: z_zone.c:460 -#, c-format -msgid "HW Texture cache : %7s KB\n" -msgstr "" - -#: z_zone.c:461 -#, c-format -msgid "Plane polygons : %7s KB\n" -msgstr "" - -#: z_zone.c:462 -#, c-format -msgid "HW Texture used : %7d KB\n" -msgstr "" - -#: z_zone.c:466 -msgid "System Memory Info\n" -msgstr "" - -#: z_zone.c:468 -#, c-format -msgid " Total physical memory: %7u KB\n" -msgstr "" - -#: z_zone.c:469 -#, c-format -msgid "Available physical memory: %7u KB\n" -msgstr "" diff --git a/src/locale/srb2.pot b/src/locale/srb2.pot deleted file mode 100644 index a25ea69ae..000000000 --- a/src/locale/srb2.pot +++ /dev/null @@ -1,4210 +0,0 @@ -# Sonic Robo Blast 2 translation base POT file. - -# Copyright (C) Sonic Team Junior - -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-09-02 06:13-0400\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" -"Content-Transfer-Encoding: 8bit\n" - -#: command.c:104 -msgid "Command buffer full!\n" -msgstr "" - -#: command.c:481 -#, c-format -msgid "Unknown command '%s'\n" -msgstr "" - -#: command.c:498 -msgid "alias \n" -msgstr "" - -#: command.c:566 -msgid "cechoflags : set CEcho flags, prepend with 0x to use hexadecimal" -msgstr "" - -#: command.c:585 -msgid "exec : run a script file\n" -msgstr "" - -#: command.c:595 -#, c-format -msgid "couldn't execute file %s\n" -msgstr "" - -#: command.c:600 -#, c-format -msgid "executing %s\n" -msgstr "" - -#: command.c:634 -#, c-format -msgid "Variable %s:\n" -msgstr "" - -#: command.c:635 -msgid " flags :" -msgstr "" - -#: command.c:654 -#, c-format -msgid " range from %d to %d\n" -msgstr "" - -#: command.c:656 command.c:673 command.c:677 -#, c-format -msgid " Current value: %d\n" -msgstr "" - -#: command.c:661 -#, c-format -msgid " possible value : %s\n" -msgstr "" - -#: command.c:671 -#, c-format -msgid " Current value: %s\n" -msgstr "" - -#: command.c:680 -msgid "No Help for this command/variable\n" -msgstr "" - -#: command.c:685 -msgid "Commands\n" -msgstr "" - -#: command.c:699 -msgid "" -"\n" -"Variables\n" -msgstr "" - -#: command.c:707 -msgid "" -"\n" -"read help file for more or type help \n" -msgstr "" - -#: command.c:709 -#, c-format -msgid "Total : %d\n" -msgstr "" - -#: command.c:723 -msgid "Toggle : Toggle the value of a cvar\n" -msgstr "" - -#: command.c:729 -#, c-format -msgid "%s is not a cvar\n" -msgstr "" - -#: command.c:735 -#, c-format -msgid "%s is not a boolean value\n" -msgstr "" - -#: command.c:923 -#, c-format -msgid "Variable %s is already defined\n" -msgstr "" - -#: command.c:930 -#, c-format -msgid "%s is a command name\n" -msgstr "" - -#: command.c:953 -#, c-format -msgid "variable %s has CV_NOINIT without CV_CALL" -msgstr "" - -#: command.c:956 -#, c-format -msgid "variable %s has CV_CALL without a function" -msgstr "" - -#: command.c:1043 -#, c-format -msgid "Bounded cvar \"%s\" without maximum!" -msgstr "" - -#: command.c:1104 r_things.c:2551 -#, c-format -msgid "\"%s\" is not a possible value for \"%s\"\n" -msgstr "" - -#: command.c:1107 -#, c-format -msgid "Variable %s default value \"%s\" is not a possible value\n" -msgstr "" - -#: command.c:1146 command.c:1149 -#, c-format -msgid "%s set to %s\n" -msgstr "" - -#: command.c:1174 -#, c-format -msgid "Illegal netvar command received from %s\n" -msgstr "" - -#: command.c:1194 -#, c-format -msgid "Netvar not found with netid %hu\n" -msgstr "" - -#: command.c:1198 command.c:1200 -#, c-format -msgid "Netvar received: %s [netid=%d] value %s\n" -msgstr "" - -#: command.c:1276 -msgid "CV_Set: no variable\n" -msgstr "" - -#: command.c:1298 -#, c-format -msgid "Only the server can change this variable: %s %s\n" -msgstr "" - -#: command.c:1317 -#, c-format -msgid "This variable can't be changed while in netgame: %s %s\n" -msgstr "" - -#: command.c:1527 -#, c-format -msgid "\"%s\" is \"%s\" default is \"%s\"\n" -msgstr "" - -#: console.c:164 -#, c-format -msgid "Number of console HUD lines is now %d\n" -msgstr "" - -#: console.c:192 -msgid "English keymap.\n" -msgstr "" - -#: console.c:206 -msgid "bind []\n" -msgstr "" - -#: console.c:207 -msgid "bind table :\n" -msgstr "" - -#: console.c:216 -msgid "Empty\n" -msgstr "" - -#: console.c:223 -msgid "Invalid key name\n" -msgstr "" - -#: console.c:1170 -msgid "NOTICE:" -msgstr "" - -#: console.c:1173 -msgid "WARNING:" -msgstr "" - -#: console.c:1176 -msgid "ERROR:" -msgstr "" - -#: console.c:1199 -msgid "Press ENTER to continue\n" -msgstr "" - -#: d_clisrv.c:216 -#, c-format -msgid "NetXCmd buffer full, cannot add netcmd %d! (size: %d, needed: %s)\n" -msgstr "" - -#: d_clisrv.c:383 -#, c-format -msgid "Got unknown net command [%s]=%d (max %d)\n" -msgstr "" - -#: d_clisrv.c:492 -msgid "Sending join request...\n" -msgstr "" - -#: d_clisrv.c:688 d_clisrv.c:710 d_clisrv.c:760 -msgid "No more free memory for savegame\n" -msgstr "" - -#: d_clisrv.c:776 -#, c-format -msgid "Didn't save %s for netgame" -msgstr "" - -#: d_clisrv.c:797 -#, c-format -msgid "Loading savegame length %s\n" -msgstr "" - -#: d_clisrv.c:800 -msgid "Can't read savegame sent" -msgstr "" - -#: d_clisrv.c:826 g_game.c:3198 -#, c-format -msgid "Map is now \"%s" -msgstr "" - -#: d_clisrv.c:831 g_game.c:3222 st_stuff.c:823 st_stuff.c:835 st_stuff.c:846 -#: st_stuff.c:857 st_stuff.c:868 st_stuff.c:879 st_stuff.c:890 st_stuff.c:901 -#: st_stuff.c:912 st_stuff.c:923 st_stuff.c:934 st_stuff.c:945 st_stuff.c:956 -#: st_stuff.c:967 -msgid "ZONE" -msgstr "" - -#: d_clisrv.c:839 -msgid "Can't load the level!\n" -msgstr "" - -#: d_clisrv.c:843 d_clisrv.c:851 d_clisrv.c:1047 -#, c-format -msgid "Can't delete %s" -msgstr "" - -#: d_clisrv.c:1051 -msgid "Searching for a server...\n" -msgstr "" - -#: d_clisrv.c:1053 -msgid "Contacting the server...\n" -msgstr "" - -#: d_clisrv.c:1054 -msgid "Press ESC to abort\n" -msgstr "" - -#: d_clisrv.c:1075 -#, c-format -msgid "Connecting to: %s\n" -msgstr "" - -#: d_clisrv.c:1085 -#, c-format -msgid "Gametype: %s\n" -msgstr "" - -#: d_clisrv.c:1086 -#, c-format -msgid "Version: %d.%.2d.%u\n" -msgstr "" - -#: d_clisrv.c:1106 -msgid "Found, " -msgstr "" - -#: d_clisrv.c:1118 -#, c-format -msgid "" -"Maximum players reached: %d\n" -"Press ESC" -msgstr "" - -#: d_clisrv.c:1129 -msgid "Checking files...\n" -msgstr "" - -#: d_clisrv.c:1221 -msgid "Network game synchronization aborted.\n" -msgstr "" - -#: d_clisrv.c:1271 -msgid "Ban List:\n" -msgstr "" - -#: d_clisrv.c:1283 -#, c-format -msgid "Why: %s\n" -msgstr "" - -#: d_clisrv.c:1289 -msgid " None\n" -msgstr "" - -#: d_clisrv.c:1306 -msgid "Could not save ban list into ban.txt\n" -msgstr "" - -#: d_clisrv.c:1376 -msgid "Could not open ban.txt for ban list\n" -msgstr "" - -#: d_clisrv.c:1413 -msgid "" -"Connect : connect to a server\n" -"Connect ANY: connect to the first lan server found\n" -"Connect SELF: connect to your own server.\n" -msgstr "" - -#: d_clisrv.c:1421 d_clisrv.c:1452 -msgid "" -"You cannot connect while in a game\n" -"End this game first\n" -msgstr "" - -#: d_clisrv.c:1427 m_menu.c:4822 m_menu.c:4856 m_menu.c:5074 -msgid "" -"You have wad files loaded and/or\n" -"modified the game in some way.\n" -"Please restart SRB2 before\n" -"connecting." -msgstr "" - -#: d_clisrv.c:1468 -msgid "There is no server identification with this network driver\n" -msgstr "" - -#: d_clisrv.c:1474 -msgid "There is no network driver\n" -msgstr "" - -#: d_clisrv.c:1634 -#, c-format -msgid "num:%2d node:%2d %s\n" -msgstr "" - -#: d_clisrv.c:1636 -#, c-format -msgid "num:%2d node:%2d %s\n" -msgstr "" - -#: d_clisrv.c:1664 -#, c-format -msgid "There is no player named \"%s\"\n" -msgstr "" - -#: d_clisrv.c:1696 -msgid " (verified admin)" -msgstr "" - -#: d_clisrv.c:1699 -msgid " (spectator)" -msgstr "" - -#: d_clisrv.c:1710 -msgid "Ban or : ban and kick a player\n" -msgstr "" - -#: d_clisrv.c:1727 d_clisrv.c:1882 -msgid "Too many bans! Geez, that's a lot of people you're excluding...\n" -msgstr "" - -#: d_clisrv.c:1760 d_clisrv.c:1805 d_net.c:1189 d_netcmd.c:1902 -#: d_netcmd.c:2179 d_netcmd.c:2550 d_netcmd.c:2901 d_netcmd.c:2980 -#: d_netcmd.c:3041 d_netcmd.c:3125 d_netcmd.c:3219 d_netcmd.c:3280 -#: d_netcmd.c:4244 g_game.c:1656 -msgid "You are not the server. You cannot do this.\n" -msgstr "" - -#: d_clisrv.c:1771 -msgid "Kick or : kick a player\n" -msgstr "" - -#: d_clisrv.c:1820 -msgid "Server is being shut down remotely. Goodbye!\n" -msgstr "" - -#: d_clisrv.c:1849 -#, c-format -msgid "Illegal kick command received from %s for player %d\n" -msgstr "" - -#: d_clisrv.c:1852 -#, c-format -msgid "" -"So, you must be asking, why is this an illegal kick?\n" -"Well, let's take a look at the facts, shall we?\n" -"\n" -"playernum (this is the guy who did it), he's %d.\n" -"pnum (the guy he's trying to kick) is %d.\n" -"playernum's node is %d.\n" -"That node has %d players.\n" -"Player 2 on that node is %d.\n" -"pnum's node is %d.\n" -"That node has %d players.\n" -"Player 2 on that node is %d.\n" -"\n" -"If you think this is a bug, please report it, including all of the details above.\n" -msgstr "" - -#: d_clisrv.c:1889 -msgid "has been kicked (Go away)\n" -msgstr "" - -#: d_clisrv.c:1893 -msgid "left the game (Broke ping limit)\n" -msgstr "" - -#: d_clisrv.c:1897 -msgid "left the game (Consistency failure)\n" -msgstr "" - -#: d_clisrv.c:1903 -#, c-format -msgid "Player kicked is #%d\n" -msgstr "" - -#: d_clisrv.c:1909 -#, c-format -msgid "Player %d is at %d, %d, %d\n" -msgstr "" - -#: d_clisrv.c:1911 -#, c-format -msgid "Player %d has a null mo\n" -msgstr "" - -#: d_clisrv.c:1917 -msgid "left the game (Connection timeout)\n" -msgstr "" - -#: d_clisrv.c:1920 -msgid "left the game\n" -msgstr "" - -#: d_clisrv.c:1923 -msgid "has been banned (Don't come back)\n" -msgstr "" - -#: d_clisrv.c:1927 -#, c-format -msgid "has been kicked (%s)\n" -msgstr "" - -#: d_clisrv.c:1931 -#, c-format -msgid "has been banned (%s)\n" -msgstr "" - -#: d_clisrv.c:1945 -msgid "" -"Server closed connection\n" -"(consistency failure)\n" -"Press ESC\n" -msgstr "" - -#: d_clisrv.c:1950 -msgid "" -"Server closed connection\n" -"(Broke ping limit)\n" -"Press ESC\n" -msgstr "" - -#: d_clisrv.c:1953 -msgid "" -"You have been banned by the server\n" -"\n" -"Press ESC\n" -msgstr "" - -#: d_clisrv.c:1955 -#, c-format -msgid "" -"You have been kicked\n" -"(%s)\n" -"Press ESC\n" -msgstr "" - -#: d_clisrv.c:1957 -#, c-format -msgid "" -"You have been banned\n" -"(%s)\n" -"Press ESC\n" -msgstr "" - -#: d_clisrv.c:1959 -msgid "" -"You have been kicked by the server\n" -"\n" -"Press ESC\n" -msgstr "" - -#: d_clisrv.c:2142 -#, c-format -msgid "Illegal add player command received from %s\n" -msgstr "" - -#: d_clisrv.c:2168 -#, c-format -msgid "Player %d has joined the game (node %d)\n" -msgstr "" - -#: d_clisrv.c:2192 -#, c-format -msgid "Player Address is %s\n" -msgstr "" - -#: d_clisrv.c:2264 -#, c-format -msgid "Server added player %d node %d\n" -msgstr "" - -#: d_clisrv.c:2304 -msgid "Starting Server....\n" -msgstr "" - -#: d_clisrv.c:2790 -msgid "" -"You have been banned\n" -"from the server" -msgstr "" - -#: d_clisrv.c:2793 -#, c-format -msgid "" -"Different SRB2 versions cannot\n" -"play a netgame!\n" -"(server version %d.%d.%d)" -msgstr "" - -#: d_clisrv.c:2795 -msgid "" -"The server is not accepting\n" -"joins for the moment" -msgstr "" - -#: d_clisrv.c:2797 -#, c-format -msgid "Maximum players reached: %d" -msgstr "" - -#: d_clisrv.c:2799 -msgid "" -"Too many players from\n" -"this node." -msgstr "" - -#: d_clisrv.c:2801 -msgid "" -"No players from\n" -"this node." -msgstr "" - -#: d_clisrv.c:2819 -msgid "Server couldn't send info, please try again" -msgstr "" - -#: d_clisrv.c:2843 -msgid "" -"Server has shutdown\n" -"\n" -"Press Esc" -msgstr "" - -#: d_clisrv.c:2852 -msgid "" -"Server Timeout\n" -"\n" -"Press Esc" -msgstr "" - -#: d_clisrv.c:2880 -#, c-format -msgid "Received packet from unknown host %d\n" -msgstr "" - -#: d_clisrv.c:2907 -#, c-format -msgid "" -"Server refuses connection\n" -"\n" -"Reason:\n" -"%s" -msgstr "" - -#: d_clisrv.c:2942 -msgid "Join accepted, waiting for next level change...\n" -msgstr "" - -#: d_clisrv.c:2943 -#, c-format -msgid "Server accept join gametic=%u mynode=%d\n" -msgstr "" - -#: d_clisrv.c:2981 -#, c-format -msgid "unknown packet received (%d) from unknown host\n" -msgstr "" - -#: d_clisrv.c:3041 -#, c-format -msgid "Illegal movement value recieved from node %d\n" -msgstr "" - -#: d_clisrv.c:3066 -#, c-format -msgid "Consistency failure for player %d, restoring...\n" -msgstr "" - -#: d_clisrv.c:3182 d_clisrv.c:3187 -#, c-format -msgid "PT_SERVERTICS recieved from non-host %d\n" -msgstr "" - -#: d_clisrv.c:3242 d_clisrv.c:3247 -#, c-format -msgid "PT_CONSISTENCY recieved from non-host %d\n" -msgstr "" - -#: d_clisrv.c:3265 d_clisrv.c:3270 -#, c-format -msgid "PT_PING recieved from non-host %d\n" -msgstr "" - -#: d_main.c:821 -#, c-format -msgid "SRB2.SRB/SRB2.WAD not found! Expected in %s, ss files: %s and %s\n" -msgstr "" - -#: d_main.c:977 -msgid "Development mode ON.\n" -msgstr "" - -#: d_main.c:988 -msgid "Please set $HOME to your home directory\n" -msgstr "" - -#: d_main.c:1092 -msgid "Z_Init: Init zone memory allocation daemon. \n" -msgstr "" - -#: d_main.c:1098 -msgid "W_Init: Init WADfiles.\n" -msgstr "" - -#: d_main.c:1112 d_main.c:1114 -msgid "A WAD file was not found or not valid\n" -msgstr "" - -#: d_main.c:1162 -msgid "HU_Init: Setting up heads up display.\n" -msgstr "" - -#: d_main.c:1207 -msgid "M_Init: Init miscellaneous info.\n" -msgstr "" - -#: d_main.c:1210 -msgid "R_Init: Init SRB2 refresh daemon - " -msgstr "" - -#: d_main.c:1214 -msgid "S_Init: Setting up sound.\n" -msgstr "" - -#: d_main.c:1230 -msgid "ST_Init: Init status bar.\n" -msgstr "" - -#: d_main.c:1237 -msgid "D_CheckNetGame: Checking network game status.\n" -msgstr "" - -#: d_main.c:1288 -#, c-format -msgid "Playing demo %s.\n" -msgstr "" - -#: d_net.c:1093 -#, c-format -msgid "Set extratics to %d\n" -msgstr "" - -#: d_net.c:1105 -#, c-format -msgid "Network bandwidth set to %d\n" -msgstr "" - -#: d_net.c:1108 -msgid "usage: -bandwidth " -msgstr "" - -#: d_net.c:1124 -msgid "usage: -packetsize " -msgstr "" - -#: d_net.c:1131 -msgid "Doomcom buffer invalid!" -msgstr "" - -#: d_net.c:1133 -#, c-format -msgid "Too many nodes (%d), max:%d" -msgstr "" - -#: d_net.c:1141 d_net.c:1156 -#, c-format -msgid "debug output to: %s\n" -msgstr "" - -#: d_net.c:1158 -#, c-format -msgid "cannot debug output to file %s!\n" -msgstr "" - -#: d_net.c:1180 -#, c-format -msgid "" -"%.2d : %s\n" -" %d tics, %d ms.\n" -msgstr "" - -#: d_net.c:1184 -#, c-format -msgid "" -"%.2d : %s\n" -" %d ms\n" -msgstr "" - -#: d_netcmd.c:997 -#, c-format -msgid "%s renamed to %s\n" -msgstr "" - -#: d_netcmd.c:1004 -#, c-format -msgid "Player %d sent a bad name change\n" -msgstr "" - -#: d_netcmd.c:1375 -#, c-format -msgid "There is no player %d!" -msgstr "" - -#: d_netcmd.c:1477 -#, c-format -msgid "Illegal color change received from %s (team: %d), color: %d)\n" -msgstr "" - -#: d_netcmd.c:1581 d_netcmd.c:1923 d_netcmd.c:3479 d_netcmd.c:4291 -#: m_cheat.c:325 m_cheat.c:359 m_cheat.c:383 m_cheat.c:412 m_cheat.c:446 -#: m_cheat.c:525 m_cheat.c:549 m_cheat.c:568 m_cheat.c:588 -msgid "DEVMODE must be enabled.\n" -msgstr "" - -#: d_netcmd.c:1587 -msgid "rteleport -x -y -z : relative teleport to a location\n" -msgstr "" - -#: d_netcmd.c:1593 d_netcmd.c:1663 -msgid "You can't teleport while in a netgame!\n" -msgstr "" - -#: d_netcmd.c:1599 d_netcmd.c:1669 -msgid "Player is dead, etc.\n" -msgstr "" - -#: d_netcmd.c:1618 d_netcmd.c:1694 -msgid "Not a valid location\n" -msgstr "" - -#: d_netcmd.c:1635 -#, c-format -msgid "Teleporting by %d, %d, %d...\n" -msgstr "" - -#: d_netcmd.c:1639 d_netcmd.c:1714 -msgid "Unable to teleport to that spot!\n" -msgstr "" - -#: d_netcmd.c:1657 -msgid "teleport -x -y -z : teleport to a location\n" -msgstr "" - -#: d_netcmd.c:1678 -msgid "X value not specified\n" -msgstr "" - -#: d_netcmd.c:1687 -msgid "Y value not specified\n" -msgstr "" - -#: d_netcmd.c:1710 -#, c-format -msgid "Teleporting to %d, %d, %d...\n" -msgstr "" - -#: d_netcmd.c:1732 -msgid "playdemo : playback a demo\n" -msgstr "" - -#: d_netcmd.c:1741 d_netcmd.c:1769 -msgid "" -"\n" -"You can't play a demo while in a netgame.\n" -msgstr "" - -#: d_netcmd.c:1749 -#, c-format -msgid "Playing back demo '%s'.\n" -msgstr "" - -#: d_netcmd.c:1760 -msgid "timedemo : time a demo\n" -msgstr "" - -#: d_netcmd.c:1777 -#, c-format -msgid "Timing demo '%s'.\n" -msgstr "" - -#: d_netcmd.c:1786 -msgid "Stopped demo.\n" -msgstr "" - -#: d_netcmd.c:1831 -#, c-format -msgid "Map change: mapnum=%d gametype=%d ultmode=%d resetplayers=%d delay=%d skipprecutscene=%d\n" -msgstr "" - -#: d_netcmd.c:1896 -msgid "map [-gametype [-force]: warp to map\n" -msgstr "" - -#: d_netcmd.c:1909 -#, c-format -msgid "Internal game level '%s' not found\n" -msgstr "" - -#: d_netcmd.c:1915 -msgid "Sorry, level change disabled in single player.\n" -msgstr "" - -#: d_netcmd.c:1931 -#, c-format -msgid "Invalid level name %s\n" -msgstr "" - -#: d_netcmd.c:1951 -msgid "You can't switch gametypes in single player!\n" -msgstr "" - -#: d_netcmd.c:2022 -#, c-format -msgid "" -"That level doesn't support %s mode!\n" -"(Use -force to override)\n" -msgstr "" - -#: d_netcmd.c:2028 -msgid "That level doesn't support Single Player mode!\n" -msgstr "" - -#: d_netcmd.c:2051 -#, c-format -msgid "Illegal map change received from %s\n" -msgstr "" - -#: d_netcmd.c:2116 -#, c-format -msgid "Speeding off to %s...\n" -msgstr "" - -#: d_netcmd.c:2173 g_game.c:1649 -msgid "You can't pause here.\n" -msgstr "" - -#: d_netcmd.c:2189 -#, c-format -msgid "Illegal pause command received from %s\n" -msgstr "" - -#: d_netcmd.c:2214 -#, c-format -msgid "Game paused by %s\n" -msgstr "" - -#: d_netcmd.c:2216 -#, c-format -msgid "Game unpaused by %s\n" -msgstr "" - -#: d_netcmd.c:2239 d_netcmd.c:3520 d_netcmd.c:4232 d_netcmd.c:4248 -#: m_cheat.c:353 m_cheat.c:377 m_cheat.c:406 m_cheat.c:440 m_cheat.c:635 -#: m_cheat.c:676 m_cheat.c:712 p_tick.c:51 p_tick.c:119 -msgid "You must be in a level to use this.\n" -msgstr "" - -#: d_netcmd.c:2245 -msgid "You may only use this in co-op, race, and single player!" -msgstr "" - -#: d_netcmd.c:2259 -#, c-format -msgid "Illegal suicide command recieved from %s\n" -msgstr "" - -#: d_netcmd.c:2328 -#, c-format -msgid "Illegal clear scores command received from %s\n" -msgstr "" - -#: d_netcmd.c:2343 -msgid "Scores have been reset by the server.\n" -msgstr "" - -#: d_netcmd.c:2360 d_netcmd.c:2397 -msgid "changeteam : switch to a new team (spectator or playing)\n" -msgstr "" - -#: d_netcmd.c:2362 d_netcmd.c:2399 -msgid "changeteam : switch to a new team (red, blue or spectator)\n" -msgstr "" - -#: d_netcmd.c:2364 d_netcmd.c:2390 d_netcmd.c:2461 d_netcmd.c:2487 -#: d_netcmd.c:2566 d_netcmd.c:2605 -msgid "This command cannot be used outside of Match, Tag or CTF.\n" -msgstr "" - -#: d_netcmd.c:2416 d_netcmd.c:2513 d_netcmd.c:2643 -msgid "Invalid gametype after initial checks!" -msgstr "" - -#: d_netcmd.c:2420 d_netcmd.c:2517 -msgid "You're already on that team!\n" -msgstr "" - -#: d_netcmd.c:2426 d_netcmd.c:2523 -msgid "The server does not allow team change.\n" -msgstr "" - -#: d_netcmd.c:2435 d_netcmd.c:2532 d_netcmd.c:2656 -msgid "No tag status changes after hidetime!\n" -msgstr "" - -#: d_netcmd.c:2457 d_netcmd.c:2494 -msgid "changeteam2 : switch to a new team (spectator or playing)\n" -msgstr "" - -#: d_netcmd.c:2459 d_netcmd.c:2496 -msgid "changeteam2 : switch to a new team (red, blue or spectator)\n" -msgstr "" - -#: d_netcmd.c:2560 d_netcmd.c:2612 -msgid "serverchangeteam : switch player to a new team (spectator or playing)\n" -msgstr "" - -#: d_netcmd.c:2562 d_netcmd.c:2614 -msgid "serverchangeteam : switch player to a new team (it, notit, playing, or spectator)\n" -msgstr "" - -#: d_netcmd.c:2564 d_netcmd.c:2616 -msgid "serverchangeteam : switch player to a new team (red, blue or spectator)\n" -msgstr "" - -#: d_netcmd.c:2647 -msgid "That player is already on that team!\n" -msgstr "" - -#: d_netcmd.c:2677 d_netcmd.c:2692 d_netcmd.c:2731 d_netcmd.c:2781 -#, c-format -msgid "Illegal team change received from player %s\n" -msgstr "" - -#: d_netcmd.c:2845 -#, c-format -msgid "%s was autobalanced to even the teams.\n" -msgstr "" - -#: d_netcmd.c:2847 -#, c-format -msgid "%s was scrambled to a different team.\n" -msgstr "" - -#: d_netcmd.c:2851 p_inter.c:2061 p_inter.c:2317 p_inter.c:2589 p_tick.c:507 -#: p_user.c:5622 -#, c-format -msgid "%s is now IT!\n" -msgstr "" - -#: d_netcmd.c:2853 -#, c-format -msgid "%s switched to the red team\n" -msgstr "" - -#: d_netcmd.c:2858 -#, c-format -msgid "%s is no longer IT!\n" -msgstr "" - -#: d_netcmd.c:2860 -#, c-format -msgid "%s switched to the blue team\n" -msgstr "" - -#: d_netcmd.c:2863 p_user.c:5633 -#, c-format -msgid "%s entered the game.\n" -msgstr "" - -#: d_netcmd.c:2865 -#, c-format -msgid "%s became a spectator.\n" -msgstr "" - -#: d_netcmd.c:2907 -msgid "password : change password\n" -msgstr "" - -#: d_netcmd.c:2931 -msgid "login : Administrator login\n" -msgstr "" - -#: d_netcmd.c:2947 -#, c-format -msgid "" -"Sending Login...%s\n" -"(Notice only given if password is correct.)\n" -msgstr "" - -#: d_netcmd.c:2965 -#, c-format -msgid "%s passed authentication. (%s)\n" -msgstr "" - -#: d_netcmd.c:2969 -#, c-format -msgid "Password from %d failed (%s)\n" -msgstr "" - -#: d_netcmd.c:2986 -msgid "verify : give admin privileges to a node\n" -msgstr "" - -#: d_netcmd.c:3008 -#, c-format -msgid "Illegal verification received from %s (serverplayer is %s)\n" -msgstr "" - -#: d_netcmd.c:3025 -msgid "Password correct. You are now a server administrator.\n" -msgstr "" - -#: d_netcmd.c:3035 -msgid "motd : Set a message that clients see upon join.\n" -msgstr "" - -#: d_netcmd.c:3067 d_netcmd.c:3104 -msgid "Message of the day set.\n" -msgstr "" - -#: d_netcmd.c:3088 -#, c-format -msgid "Illegal motd change received from %s\n" -msgstr "" - -#: d_netcmd.c:3117 -msgid "runsoc or : run a soc\n" -msgstr "" - -#: d_netcmd.c:3132 -msgid "Could not find SOC.\n" -msgstr "" - -#: d_netcmd.c:3151 -#, c-format -msgid "Illegal runsoc command received from %s\n" -msgstr "" - -#: d_netcmd.c:3175 d_netcmd.c:3412 -#, c-format -msgid "" -"The server tried to add %s,\n" -"but you don't have this file.\n" -"You need to find it in order\n" -"to play on this server." -msgstr "" - -#: d_netcmd.c:3180 -#, c-format -msgid "Unknown error finding soc file (%s) the server added.\n" -msgstr "" - -#: d_netcmd.c:3203 -msgid "addfile : load wad file\n" -msgstr "" - -#: d_netcmd.c:3247 -#, c-format -msgid "MD5 calc for %s took %f second\n" -msgstr "" - -#: d_netcmd.c:3252 w_wad.c:263 -#, c-format -msgid "File %s not found.\n" -msgstr "" - -#: d_netcmd.c:3274 -msgid "You must NOT be in a level to use this.\n" -msgstr "" - -#: d_netcmd.c:3323 d_netcmd.c:3393 -#, c-format -msgid "Illegal addfile command received from %s\n" -msgstr "" - -#: d_netcmd.c:3338 -#, c-format -msgid "The server doesn't have %s\n" -msgstr "" - -#: d_netcmd.c:3340 -#, c-format -msgid "Checksum mismatch on %s\n" -msgstr "" - -#: d_netcmd.c:3342 -#, c-format -msgid "Unknown error finding wad file (%s)\n" -msgstr "" - -#: d_netcmd.c:3360 -#, c-format -msgid "Illegal delfile command received from %s\n" -msgstr "" - -#: d_netcmd.c:3417 -#, c-format -msgid "" -"Checksum mismatch while loading %s.\n" -"Make sure you have the copy of\n" -"this file that the server has.\n" -msgstr "" - -#: d_netcmd.c:3422 -#, c-format -msgid "Unknown error finding wad file (%s) the server added.\n" -msgstr "" - -#: d_netcmd.c:3436 -#, c-format -msgid "There are %d wads loaded:\n" -msgstr "" - -#: d_netcmd.c:3456 -#, c-format -msgid "SRB2%s (%s %s %s)\n" -msgstr "" - -#: d_netcmd.c:3462 -#, c-format -msgid "" -"Mod ID: %d\n" -"Mod Version: %d\n" -"Code Base:%d\n" -msgstr "" - -#: d_netcmd.c:3470 -#, c-format -msgid "Current gametype is %d\n" -msgstr "" - -#: d_netcmd.c:3483 -msgid "jumptoaxis : Jump to axis within current mare.\n" -msgstr "" - -#: d_netcmd.c:3528 d_netcmd.c:4304 m_cheat.c:389 m_cheat.c:424 m_cheat.c:458 -msgid "You can't use this in a netgame.\n" -msgstr "" - -#: d_netcmd.c:3605 -msgid "Objectplace Controls:\\\\Camera L: Cycle backwards \\Camera R: Cycle forwards \\ Jump: Float up \\ Spin: Float down \\ Throw: Place object \\Toss Flag: Remove object (buggy)\\" -msgstr "" - -#: d_netcmd.c:3670 -#, c-format -msgid "Levels will end after %s scores %d point%s.\n" -msgstr "" - -#: d_netcmd.c:3672 -msgid "a team" -msgstr "" - -#: d_netcmd.c:3672 -msgid "someone" -msgstr "" - -#: d_netcmd.c:3677 -msgid "Point limit disabled\n" -msgstr "" - -#: d_netcmd.c:3684 -#, c-format -msgid "Number of laps set to %d\n" -msgstr "" - -#: d_netcmd.c:3714 -#, c-format -msgid "Levels will end after %d minute%s.\n" -msgstr "" - -#: d_netcmd.c:3726 -msgid "Time limit disabled\n" -msgstr "" - -#: d_netcmd.c:3750 -#, c-format -msgid "Gametype was changed from %s to %s\n" -msgstr "" - -#: d_netcmd.c:3916 -#, c-format -msgid "Illegal color change received from %s (team: %d, color: %d)\n" -msgstr "" - -#: d_netcmd.c:3932 d_netcmd.c:3946 -msgid "You haven't earned this yet.\n" -msgstr "" - -#: d_netcmd.c:4006 -msgid "This command cannot be used outside of Team Match or CTF.\n" -msgstr "" - -#: d_netcmd.c:4133 -msgid "Teams will be scrambled next round.\n" -msgstr "" - -#: d_netcmd.c:4211 -msgid "HIDETIME cannot be greater or equal to the time limit!\n" -msgstr "" - -#: d_netcmd.c:4239 -msgid "You can't use this in single player.\n" -msgstr "" - -#: d_netcmd.c:4263 -#, c-format -msgid "Illegal exitlevel command received from %s\n" -msgstr "" - -#: d_netcmd.c:4284 -#, c-format -msgid "Displayplayer is %d\n" -msgstr "" - -#: d_netcmd.c:4292 -msgid "If you want to change the sky interactively on a map, use the linedef executor feature instead.\n" -msgstr "" - -#: d_netcmd.c:4298 -msgid "skynum : change the sky\n" -msgstr "" - -#: d_netcmd.c:4308 -#, c-format -msgid "Previewing sky %s...\n" -msgstr "" - -#: d_netcmd.c:4320 -#, c-format -msgid "tunes : play a slot or the default stage tune at the specified speed(100%%)\n" -msgstr "" - -#: d_netcmd.c:4321 -#, c-format -msgid "The current tune is: %d\n" -msgstr "" - -#: d_netcmd.c:4329 -#, c-format -msgid "Valid slots are 1 to %d, or 0 to stop music\n" -msgstr "" - -#: d_netcmd.c:4400 -msgid "modifiedgame is true, but you can save emblem and time data in this mod.\n" -msgstr "" - -#: d_netcmd.c:4402 -msgid "modifiedgame is true, secrets will not be unlocked\n" -msgstr "" - -#: d_netcmd.c:4404 -msgid "modifiedgame is false, you can unlock secrets\n" -msgstr "" - -#: d_netcmd.c:4410 -msgid "At least one CHEAT-marked variable has been changed -- Cheats are enabled.\n" -msgstr "" - -#: d_netcmd.c:4412 -msgid "No CHEAT-marked variables are changed -- Cheats are disabled.\n" -msgstr "" - -#: d_netcmd.c:4439 -#, c-format -msgid "Valid skin numbers are 0 to %d (-1 disables)\n" -msgstr "" - -#: d_netcmd.c:4457 d_netcmd.c:4469 -msgid "You may not change your name when chat is muted.\n" -msgstr "" - -#: d_netcmd.c:4486 d_netcmd.c:4502 -msgid "You can't change your skin at the moment.\n" -msgstr "" - -#: d_netcmd.c:4603 -msgid "Chat has been muted.\n" -msgstr "" - -#: d_netcmd.c:4605 -msgid "Chat is no longer muted.\n" -msgstr "" - -#: d_netcmd.c:4637 d_netcmd.c:4655 -msgid "This only works in a netgame.\n" -msgstr "" - -#: d_netcmd.c:4645 -#, c-format -msgid "%s's score is %u\n" -msgstr "" - -#: d_netcmd.c:4647 -#, c-format -msgid "The pointlimit is %d\n" -msgstr "" - -#: d_netcmd.c:4659 -#, c-format -msgid "" -"The current time is %f.\n" -"The timelimit is %f\n" -msgstr "" - -#: d_netfil.c:308 -#, c-format -msgid "searching for '%s' " -msgstr "" - -#: d_netfil.c:317 -msgid "already loaded\n" -msgstr "" - -#: d_netfil.c:326 -#, c-format -msgid "found %d\n" -msgstr "" - -#: d_netfil.c:655 -#, c-format -msgid "Downloading %s...(done)\n" -msgstr "" - -#: dehacked.c:2505 -#, c-format -msgid "Thing %d doesn't exist" -msgstr "" - -#: dehacked.c:2523 -#, c-format -msgid "Character %d out of range" -msgstr "" - -#: dehacked.c:2561 -#, c-format -msgid "Level number %d out of range" -msgstr "" - -#: dehacked.c:2569 -#, c-format -msgid "Cutscene number %d out of range" -msgstr "" - -#: dehacked.c:2577 -#, c-format -msgid "Unlockable number %d out of range" -msgstr "" - -#: dehacked.c:2587 -#, c-format -msgid "Frame %d doesn't exist" -msgstr "" - -#: dehacked.c:2616 -#, c-format -msgid "Sound %d doesn't exist" -msgstr "" - -#: dehacked.c:2641 -#, c-format -msgid "HUD item number %d out of range" -msgstr "" - -#: dehacked.c:2649 -#, c-format -msgid "Emblem number %d out of range" -msgstr "" - -#: dehacked.c:2661 -#, c-format -msgid "" -"Patch is for SRB2 version %d,\n" -"only version %d is supported" -msgstr "" - -#: dehacked.c:2665 -#, c-format -msgid "Unknown word: %s" -msgstr "" - -#: dehacked.c:2668 -#, c-format -msgid "missing argument for '%s'" -msgstr "" - -#: dehacked.c:2671 -#, c-format -msgid "No word in this line: %s" -msgstr "" - -#: dehacked.c:2675 -#, c-format -msgid "%d warning%s in the SOC lump\n" -msgstr "" - -#: dehacked.c:2723 -msgid "Unloading WAD SOC edits\n" -msgstr "" - -#: f_finale.c:248 -msgid "Sonic Team Junior\n" -msgstr "" - -#: f_finale.c:249 f_finale.c:251 -msgid "Staff\n" -msgstr "" - -#: f_finale.c:254 -msgid "Producer\n" -msgstr "" - -#: f_finale.c:258 f_finale.c:263 -msgid "Director\n" -msgstr "" - -#: f_finale.c:267 -msgid "Game Designers\n" -msgstr "" - -#: f_finale.c:278 -msgid "Character Designers\n" -msgstr "" - -#: f_finale.c:287 -msgid "Visual Design\n" -msgstr "" - -#: f_finale.c:294 -msgid "Landscape Design\n" -msgstr "" - -#: f_finale.c:303 -msgid "Chief Programmer\n" -msgstr "" - -#: f_finale.c:310 -msgid "Programmers\n" -msgstr "" - -#: f_finale.c:327 -msgid "Coding Assistants\n" -msgstr "" - -#: f_finale.c:344 -msgid "Level Designers\n" -msgstr "" - -#: f_finale.c:372 -msgid "Texture Artists\n" -msgstr "" - -#: f_finale.c:387 -msgid "Music Production\n" -msgstr "" - -#: f_finale.c:409 -msgid "Lead Guitar\n" -msgstr "" - -#: f_finale.c:418 -msgid "Sound Effects\n" -msgstr "" - -#: f_finale.c:429 -msgid "Official Mascot\n" -msgstr "" - -#: f_finale.c:436 -msgid "Sky Sanctuary Team\n" -msgstr "" - -#: f_finale.c:480 -msgid "Special Thanks\n" -msgstr "" - -#: f_finale.c:495 -msgid "In Fond Memory Of\n" -msgstr "" - -#: f_finale.c:510 -msgid "Modification By\n" -msgstr "" - -#: f_finale.c:580 -msgid "" -"Two months had passed since Dr. Eggman\n" -"tried to take over the world using his\n" -"Ring Satellite.\n" -"#" -msgstr "" - -#: f_finale.c:584 -msgid "" -"As it was about to drain the rings\n" -"away from the planet, Sonic burst into\n" -"the Satellite and for what he thought\n" -"would be the last time, defeated\n" -"Dr. Eggman.\n" -"#" -msgstr "" - -#: f_finale.c:590 -msgid "" -"\n" -"What Sonic, Tails, and Knuckles had\n" -"not anticipated was that Eggman would\n" -"return, bringing an all new threat.\n" -"#" -msgstr "" - -#: f_finale.c:594 -msgid "" -"About once every year, a strange asteroid\n" -"hovers around the planet. it suddenly\n" -"appears from nowhere, circles around, and\n" -"- just as mysteriously as it arrives, it\n" -"vanishes after about two months.\n" -"No one knows why it appears, or how.\n" -"#" -msgstr "" - -#: f_finale.c:601 -msgid "" -"\"Curses!\" Eggman yelled. \"That hedgehog\n" -"and his ridiculous friends will pay\n" -"dearly for this!\" Just then his scanner\n" -"blipped as the Black Rock made its\n" -"appearance from nowhere. Eggman looked at\n" -"the screen, and just shrugged it off.\n" -"#" -msgstr "" - -#: f_finale.c:608 -msgid "" -"It was only later\n" -"that he had an\n" -"idea. \"The Black\n" -"Rock usually has a\n" -"lot of energy\n" -"within it... if I\n" -"can somehow\n" -"harness this, I\n" -"can turn it into\n" -"the ultimate\n" -"battle station,\n" -"and every last\n" -"person will be\n" -"begging for mercy,\n" -"including Sonic!\"\n" -"#" -msgstr "" - -#: f_finale.c:624 -msgid "" -"\n" -"\n" -"Before beginning his scheme,\n" -"Eggman decided to give Sonic\n" -"a reunion party...\n" -"#" -msgstr "" - -#: f_finale.c:628 -msgid "" -"\"We're ready to fire in 15 seconds!\"\n" -"The robot said, his voice crackling a\n" -"little down the com-link. \"Good!\"\n" -"Eggman sat back in his Egg-Mobile and\n" -"began to count down as he saw the\n" -"GreenFlower city on the main monitor.\n" -"#" -msgstr "" - -#: f_finale.c:635 -msgid "" -"\"10...9...8...\"\n" -"Meanwhile, Sonic was tearing across the\n" -"zones, and everything became nothing but\n" -"a blur as he ran around loops, skimmed\n" -"over water, and catapulted himself off\n" -"rocks with his phenomenal speed.\n" -"#" -msgstr "" - -#: f_finale.c:642 -msgid "" -"\"5...4...3...\"\n" -"Sonic knew he was getting closer to the\n" -"City, and pushed himself harder. Finally,\n" -"the city appeared in the horizon.\n" -"\"2...1...Zero.\"\n" -"#" -msgstr "" - -#: f_finale.c:648 -msgid "" -"GreenFlower City was gone.\n" -"Sonic arrived just in time to see what\n" -"little of the 'ruins' were left. Everyone\n" -"and everything in the city had been\n" -"obliterated.\n" -"#" -msgstr "" - -#: f_finale.c:654 -msgid "" -"\"You're not quite as dead as we thought,\n" -"huh? Are you going to tell us your plan as\n" -"usual or will I 'have to work it out' or\n" -"something?\" \n" -"\"We'll see... let's give you a quick warm\n" -"up, Sonic! JETTYSYNS! Open fire!\"\n" -"#" -msgstr "" - -#: f_finale.c:661 -msgid "" -"Eggman took this\n" -"as his cue and\n" -"blasted off,\n" -"leaving Sonic\n" -"and Tails behind.\n" -"Tails looked at\n" -"the ruins of the\n" -"Greenflower City\n" -"with a grim face\n" -"and sighed. \n" -"\"Now what do we\n" -"do?\", he asked.\n" -"#" -msgstr "" - -#: f_finale.c:674 -msgid "" -"\"Easy! We go\n" -"find Eggman\n" -"and stop his\n" -"latest\n" -"insane plan.\n" -"Just like\n" -"we've always\n" -"done, right? \n" -"\n" -"... \n" -"\n" -"\"Tails,what\n" -"*ARE* you\n" -"doing?\"\n" -"#" -msgstr "" - -#: f_finale.c:687 -msgid "" -"\"I'm just finding what mission obje...\n" -"a-ha! Here it is! This will only give\n" -"the robot's primary objective. It says,\n" -"* LOCATE AND RETRIEVE CHAOS EMERALD.\n" -"ESTIMATED LOCATION: GREENFLOWER ZONE *\"\n" -"\"All right, then let's go!\"\n" -"#" -msgstr "" - -#: g_game.c:506 -msgid "Game must be restarted to record statistics.\n" -msgstr "" - -#: g_game.c:1564 -#, c-format -msgid "Viewpoint: %s\n" -msgstr "" - -#: g_game.c:2042 -#, c-format -msgid "Current mare is %d\n" -msgstr "" - -#: g_game.c:2159 -msgid "No player spawns found, spawning at the first mapthing!\n" -msgstr "" - -#: g_game.c:2165 -msgid "No player spawns found, spawning at the origin!\n" -msgstr "" - -#: g_game.c:2179 -msgid "No CTF starts in this map!\n" -msgstr "" - -#: g_game.c:2188 -msgid "No Red Team starts in this map!\n" -msgstr "" - -#: g_game.c:2200 -msgid "Could not spawn at any Red Team starts!\n" -msgstr "" - -#: g_game.c:2208 -msgid "No Blue Team starts in this map!\n" -msgstr "" - -#: g_game.c:2219 -msgid "Could not spawn at any Blue Team starts!\n" -msgstr "" - -#: g_game.c:2239 -msgid "Could not spawn at any Deathmatch starts!\n" -msgstr "" - -#: g_game.c:2244 -msgid "No Deathmatch starts in this map!\n" -msgstr "" - -#: g_game.c:2262 -msgid "No Co-op starts in this map!\n" -msgstr "" - -#: g_game.c:2410 -msgid "The round has ended.\n" -msgstr "" - -#: g_game.c:2465 -#, c-format -msgid "Unknown gametype! %d\n" -msgstr "" - -#: g_game.c:2568 g_game.c:2582 -#, c-format -msgid "Next map given (MAP %d) doesn't exist! Reverting to MAP01.\n" -msgstr "" - -#: g_game.c:2595 -#, c-format -msgid "Can't find a compatible map after map %d; using map %d anyway\n" -msgstr "" - -#: g_game.c:2858 g_game.c:3041 -msgid "No more free memory for saving game data\n" -msgstr "" - -#: g_game.c:2922 g_game.c:2992 -msgid "" -"Savegame file corrupted\n" -"\n" -"Press ESC\n" -msgstr "" - -#: g_game.c:2966 -#, c-format -msgid "Couldn't read file %s\n" -msgstr "" - -#: g_game.c:2976 -msgid "" -"Save game from different version.\n" -"You can load this savegame, but\n" -"saving afterwards will be disabled.\n" -"\n" -"Do you want to continue anyway?\n" -"\n" -"(Press 'Y' to confirm)\n" -msgstr "" - -#: g_game.c:3060 -msgid "Game saved.\n" -msgstr "" - -#: g_game.c:3062 -#, c-format -msgid "Error while writing to %s for save slot %u, base: %s\n" -msgstr "" - -#: g_game.c:3662 -msgid "Demo is desynced!\n" -msgstr "" - -#: g_game.c:4172 g_game.c:4245 g_game.c:4392 -#, c-format -msgid "Failed to read file '%s'.\n" -msgstr "" - -#: g_game.c:4182 g_game.c:4188 -#, c-format -msgid "File '%s' invalid format. It will be overwritten.\n" -msgstr "" - -#: g_game.c:4196 -#, c-format -msgid "File '%s' not from timeattack. It will be overwritten.\n" -msgstr "" - -#: g_game.c:4264 -#, c-format -msgid "%s is a different replay format and cannot be played.\n" -msgstr "" - -#: g_game.c:4274 -#, c-format -msgid "%s is the wrong type of recording and cannot be played.\n" -msgstr "" - -#: g_game.c:4319 -msgid "Demo version does not match game version. Desyncs may occur.\n" -msgstr "" - -#: g_game.c:4406 g_game.c:4413 -#, c-format -msgid "Failed to add ghost %s: Demo format unacceptable.\n" -msgstr "" - -#: g_game.c:4422 -#, c-format -msgid "Failed to add ghost %s: No ghost data in this demo.\n" -msgstr "" - -#: g_game.c:4468 -#, c-format -msgid "Added ghost %s from %s\n" -msgstr "" - -#: g_game.c:4537 -msgid "Movie mode enabled.\n" -msgstr "" - -#: g_game.c:4546 -msgid "Movie mode disabled.\n" -msgstr "" - -#: g_game.c:4564 -msgid "No bot recording for this map.\n" -msgstr "" - -#: g_game.c:4582 -msgid "Could not find Metal Sonic.\n" -msgstr "" - -#: g_game.c:4600 -#, c-format -msgid "Loaded level in %f sec\n" -msgstr "" - -#: g_game.c:4660 -#, c-format -msgid "" -"timed %u gametics in %d realtics\n" -"%f seconds, %f avg fps\n" -msgstr "" - -#: g_game.c:4691 -#, c-format -msgid "Demo %s recorded\n" -msgstr "" - -#: g_game.c:4693 -#, c-format -msgid "Demo %s not saved\n" -msgstr "" - -#: g_input.c:1338 -#, c-format -msgid "Control '%s' unknown\n" -msgstr "" - -#: g_input.c:1359 -msgid "setcontrol [<2nd keyname>]\n" -msgstr "" - -#: g_input.c:1374 -msgid "setcontrol2 [<2nd keyname>]\n" -msgstr "" - -#: hardware/hw_main.c:4386 -#, c-format -msgid "Patch info headers: %7s kb\n" -msgstr "" - -#: hardware/hw_main.c:4387 -#, c-format -msgid "3D Texture cache : %7s kb\n" -msgstr "" - -#: hardware/hw_main.c:4388 -#, c-format -msgid "Plane polygon : %7s kb\n" -msgstr "" - -#: hardware/hw_md2.c:899 -msgid "Error while loading md2.dat\n" -msgstr "" - -#: hardware/hw_md2.c:916 -#, c-format -msgid " Not found: %s\n" -msgstr "" - -#: hu_stuff.c:405 -msgid "The chat is muted. You can't say anything at the moment.\n" -msgstr "" - -#: hu_stuff.c:440 -msgid "say : send a message\n" -msgstr "" - -#: hu_stuff.c:457 -msgid "sayto : send a message to a player\n" -msgstr "" - -#: hu_stuff.c:464 -msgid "sayto: No player with that name!\n" -msgstr "" - -#: hu_stuff.c:480 -msgid "sayteam : send a message to your team\n" -msgstr "" - -#: hu_stuff.c:486 -msgid "Dedicated servers can't send team messages. Use \"say\".\n" -msgstr "" - -#: hu_stuff.c:500 -msgid "csay : send a message to be shown in the middle of the screen\n" -msgstr "" - -#: hu_stuff.c:506 -msgid "Only servers and admins can use csay.\n" -msgstr "" - -#: hu_stuff.c:532 -#, c-format -msgid "Illegal csay command received from non-admin %s\n" -msgstr "" - -#: hu_stuff.c:532 -#, c-format -msgid "Illegal say command received from %s while muted\n" -msgstr "" - -#: hu_stuff.c:556 -#, c-format -msgid "Illegal say command received from %s containing invalid characters\n" -msgstr "" - -#: hu_stuff.c:753 -msgid "[Message unsent]\n" -msgstr "" - -#: i_tcp.c:310 -msgid "Looking for UPnP Internet Gatewaty Device\n" -msgstr "" - -#: i_tcp.c:326 -#, c-format -msgid "" -"Found UPnP device :\n" -" desc: %s\n" -" st: %s\n" -msgstr "" - -#: i_tcp.c:330 -#, c-format -msgid "Local LAN ip address : %s\n" -msgstr "" - -#: i_tcp.c:346 -msgid "Failed to talk to any UPnP device\n" -msgstr "" - -#: i_tcp.c:754 -msgid "Could not get broadcast rights\n" -msgstr "" - -#: i_tcp.c:772 -msgid "Could not limit IPv6 bind\n" -msgstr "" - -#: i_tcp.c:796 -#, c-format -msgid "Network system buffer: %dKb\n" -msgstr "" - -#: i_tcp.c:805 -msgid "Can't set buffer length to 64k, file transfer will be bad\n" -msgstr "" - -#: i_tcp.c:807 -#, c-format -msgid "Network system buffer set to: %dKb\n" -msgstr "" - -#: i_tcp.c:1195 sdl/i_cdmus.c:383 sdl/i_sound.c:1138 sdl/i_sound.c:1463 -#: sdl/i_video.c:2154 -msgid "shut down\n" -msgstr "" - -#: m_argv.c:161 -#, c-format -msgid "Response file %s not found" -msgstr "" - -#: m_argv.c:163 -#, c-format -msgid "Found response file %s\n" -msgstr "" - -#: m_argv.c:169 -msgid "No more free memory for the respone file" -msgstr "" - -#: m_argv.c:171 -#, c-format -msgid "Couldn't read response file because %s" -msgstr "" - -#: m_argv.c:183 -msgid "Not enough memory to read response file" -msgstr "" - -#: m_argv.c:214 -#, c-format -msgid "%d command-line args:\n" -msgstr "" - -#: m_cheat.c:268 m_cheat.c:288 m_cheat.c:308 m_cheat.c:611 m_cheat.c:647 -#: m_cheat.c:688 m_cheat.c:724 -msgid "You're too good to be cheating!\n" -msgstr "" - -#: m_cheat.c:274 -#, c-format -msgid "No Clipping %s\n" -msgstr "" - -#: m_cheat.c:274 m_cheat.c:294 -msgid "Off" -msgstr "" - -#: m_cheat.c:274 m_cheat.c:294 -msgid "On" -msgstr "" - -#: m_cheat.c:294 -#, c-format -msgid "Sissy Mode %s\n" -msgstr "" - -#: m_cheat.c:314 -msgid "Disabled" -msgstr "" - -#: m_cheat.c:314 -msgid "Enabled" -msgstr "" - -#: m_cheat.c:314 -#, c-format -msgid "SEP Field %s\n" -msgstr "" - -#: m_cheat.c:331 m_cheat.c:365 m_cheat.c:531 m_cheat.c:555 m_cheat.c:574 -#: m_cheat.c:594 m_cheat.c:641 m_cheat.c:682 m_cheat.c:718 -msgid "This only works in single player.\n" -msgstr "" - -#: m_cheat.c:337 -msgid "scale (5-400): set player scale size\n" -msgstr "" - -#: m_cheat.c:346 -#, c-format -msgid "Scale set to %d\n" -msgstr "" - -#: m_cheat.c:395 -msgid "hurtme \n" -msgstr "" - -#: m_cheat.c:418 m_cheat.c:433 -msgid "charability <1/2> \n" -msgstr "" - -#: m_cheat.c:452 m_cheat.c:478 -msgid "charspeed \n" -msgstr "" - -#: m_cheat.c:490 -msgid "Your reality is everyone's reality. Therefore, you should not use this command.\n" -msgstr "" - -#: m_cheat.c:541 -#, c-format -msgid "Temporary checkpoint created at %d, %d, %d\n" -msgstr "" - -#: m_cheat.c:561 m_menu.c:3295 -msgid "You now have all 7 emeralds.\n" -msgstr "" - -#: m_cheat.c:580 -msgid "Emeralds reset to zero.\n" -msgstr "" - -#: m_cheat.c:600 -msgid "All secrets unlocked.\n" -msgstr "" - -#: m_cheat.c:629 m_cheat.c:670 m_cheat.c:706 -msgid "You haven't earned this yet." -msgstr "" - -#: m_menu.c:1848 -msgid "" -"You can't use this while in a game!\n" -"\n" -"(Press a key)" -msgstr "" - -#: m_menu.c:1855 -msgid "" -"This cannot be done in a modified game.\n" -"\n" -"(Press a key)" -msgstr "" - -#: m_menu.c:2173 -msgid "" -"Eggman's tied explosives\n" -"to your girlfriend, and\n" -"will activate them if\n" -"you press the 'Y' key!\n" -"Press 'N' to save her!\n" -"\n" -"(Press 'Y' to quit)" -msgstr "" - -#: m_menu.c:2174 -msgid "" -"What would Tails say if\n" -"he saw you quitting the game?\n" -"\n" -"(Press 'Y' to quit)" -msgstr "" - -#: m_menu.c:2175 -msgid "" -"Hey!\n" -"Where do ya think you're goin'?\n" -"\n" -"(Press 'Y' to quit)" -msgstr "" - -#: m_menu.c:2176 -msgid "" -"Forget your studies!\n" -"Play some more!\n" -"\n" -"(Press 'Y' to quit)" -msgstr "" - -#: m_menu.c:2177 -msgid "" -"You're trying to say you\n" -"like Sonic 2K6 better than\n" -"this, right?\n" -"\n" -"(Press 'Y' to quit)" -msgstr "" - -#: m_menu.c:2178 -msgid "" -"Don't leave yet -- there's a\n" -"super emerald around that corner!\n" -"\n" -"(Press 'Y' to quit)" -msgstr "" - -#: m_menu.c:2179 -msgid "" -"You'd rather work than play?\n" -"\n" -"(Press 'Y' to quit)" -msgstr "" - -#: m_menu.c:2180 -msgid "" -"Go ahead and leave. See if I care...\n" -"*sniffle*\n" -"\n" -"(Press 'Y' to quit)" -msgstr "" - -#: m_menu.c:2182 -msgid "" -"If you leave now,\n" -"Eggman will take over the world!\n" -"\n" -"(Press 'Y' to quit)" -msgstr "" - -#: m_menu.c:2183 -msgid "" -"Don't quit!\n" -"There are animals\n" -"to save!\n" -"\n" -"(Press 'Y' to quit)" -msgstr "" - -#: m_menu.c:2184 -msgid "" -"Aw c'mon, just bop\n" -"a few more robots!\n" -"\n" -"(Press 'Y' to quit)" -msgstr "" - -#: m_menu.c:2185 -msgid "" -"Did you get all those Chaos Emeralds?\n" -"\n" -"(Press 'Y' to quit)" -msgstr "" - -#: m_menu.c:2186 -msgid "" -"If you leave, I'll use\n" -"my spin attack on you!\n" -"\n" -"(Press 'Y' to quit)" -msgstr "" - -#: m_menu.c:2187 -msgid "" -"Don't go!\n" -"You might find the hidden\n" -"levels!\n" -"\n" -"(Press 'Y' to quit)" -msgstr "" - -#: m_menu.c:2188 -msgid "" -"Hit the 'N' key, Sonic!\n" -"The 'N' key!\n" -"\n" -"(Press 'Y' to quit)" -msgstr "" - -#: m_menu.c:2190 -msgid "" -"Are you really going to give up?\n" -"We certainly would never give you up.\n" -"\n" -"(Press 'Y' to quit)" -msgstr "" - -#: m_menu.c:2191 -msgid "" -"Come on, just ONE more netgame!\n" -"\n" -"(Press 'Y' to quit)" -msgstr "" - -#: m_menu.c:2192 -msgid "" -"Press 'N' to unlock\n" -"the Ultimate Cheat!\n" -"\n" -"(Press 'Y' to quit)" -msgstr "" - -#: m_menu.c:2193 -msgid "" -"Why don't you go back and try\n" -"jumping on that house to\n" -"see what happens?\n" -"\n" -"(Press 'Y' to quit)" -msgstr "" - -#: m_menu.c:2194 -msgid "" -"Every time you press 'Y', an\n" -"SRB2 Developer cries...\n" -"\n" -"(Press 'Y' to quit)" -msgstr "" - -#: m_menu.c:2195 -msgid "" -"You'll be back to play soon, though...\n" -"......right?\n" -"\n" -"(Press 'Y' to quit)" -msgstr "" - -#: m_menu.c:2196 -msgid "" -"Aww, is Egg Rock Zone too\n" -"difficult for you?\n" -"\n" -"(Press 'Y' to quit)" -msgstr "" - -#: m_menu.c:3218 -msgid "" -"The server is not allowing\n" -" team changes at this time.\n" -"Press a key." -msgstr "" - -#: m_menu.c:3271 -msgid "" -"Retry this act from the last starpost?\n" -"\n" -"(Press 'Y' to confirm)\n" -msgstr "" - -#: m_menu.c:3315 -msgid "" -"Do you want to destroy all\n" -"robots in the current level?\n" -"\n" -"(Press 'Y' to confirm)\n" -msgstr "" - -#: m_menu.c:3591 m_menu.c:3763 -msgid "No selectable levels found.\n" -msgstr "" - -#: m_menu.c:4141 -msgid "" -"Are you sure you want to delete\n" -"this save game?\n" -"\n" -"(Press 'Y' to confirm)\n" -msgstr "" - -#: m_menu.c:4531 -msgid "No time-attackable levels found.\n" -msgstr "" - -#: m_menu.c:4562 y_inter.c:909 -msgid "Out of memory for replay filepath\n" -msgstr "" - -#: m_menu.c:4609 -msgid "" -"Are you sure you want to end the game?\n" -"\n" -"(Press 'Y' to confirm)" -msgstr "" - -#: m_menu.c:5467 -msgid "" -"Are you sure you want to delete\n" -"the time attack data?\n" -"\n" -"(Press 'Y' to confirm)\n" -msgstr "" - -#: m_menu.c:5469 -msgid "" -"Are you sure you want to delete\n" -"the secrets data?\n" -"\n" -"(Press 'Y' to confirm)\n" -msgstr "" - -#: m_menu.c:5706 -#, c-format -msgid "" -"Hit the new key for\n" -"%s\n" -"ESC for Cancel" -msgstr "" - -#: m_menu.c:5725 m_menu.c:5732 -msgid "SFX Enabled" -msgstr "" - -#: m_menu.c:5738 -msgid "SFX Disabled" -msgstr "" - -#: m_menu.c:5753 m_menu.c:5760 -msgid "Digital Music Enabled" -msgstr "" - -#: m_menu.c:5766 -msgid "Digital Music Disabled" -msgstr "" - -#: m_menu.c:5780 m_menu.c:5787 -msgid "MIDI Music Enabled" -msgstr "" - -#: m_menu.c:5793 -msgid "MIDI Music Disabled" -msgstr "" - -#: m_misc.c:398 -msgid "saveconfig [-silent] : save config to a file\n" -msgstr "" - -#: m_misc.c:406 -#, c-format -msgid "config saved as %s\n" -msgstr "" - -#: m_misc.c:417 -msgid "loadconfig : load config from a file\n" -msgstr "" - -#: m_misc.c:434 -msgid "changeconfig : save current config and load another\n" -msgstr "" - -#: m_misc.c:454 -#, c-format -msgid "config file: %s\n" -msgstr "" - -#: m_misc.c:487 m_misc.c:505 -msgid "Config filename must be .cfg\n" -msgstr "" - -#: m_misc.c:497 m_misc.c:512 -#, c-format -msgid "Couldn't save game config file %s\n" -msgstr "" - -#: m_misc.c:1054 -msgid "Recording into next new file\n" -msgstr "" - -#: m_misc.c:1346 -#, c-format -msgid "screen shot %s saved in %s\n" -msgstr "" - -#: m_misc.c:1351 -#, c-format -msgid "Couldn't create screen shot %s in %s\n" -msgstr "" - -#: m_misc.c:1353 -#, c-format -msgid "Couldn't create screen shot (all 10000 slots used!) in %s\n" -msgstr "" - -#: mserv.c:346 mserv.c:373 -msgid "No servers currently running.\n" -msgstr "" - -#: mserv.c:478 mserv.c:519 mserv.c:585 mserv.c:623 mserv.c:858 mserv.c:955 -msgid "cannot connect to the master server\n" -msgstr "" - -#: mserv.c:479 mserv.c:520 mserv.c:586 -msgid "" -"There was a problem connecting to\n" -"the Master Server" -msgstr "" - -#: mserv.c:545 -#, c-format -msgid "" -"You have been banned from\n" -"hosting netgames.\n" -"\n" -"Under the following IP Range:\n" -"%s - %s\n" -"\n" -"For the following reason:\n" -"%s\n" -"\n" -"Your ban will expire on:\n" -"%s" -msgstr "" - -#: mserv.c:547 -#, c-format -msgid "" -"You have been banned from\n" -"joining netgames.\n" -"\n" -"Under the following IP Range:\n" -"%s - %s\n" -"\n" -"For the following reason:\n" -"%s\n" -"\n" -"Your ban will expire on:\n" -"%s" -msgstr "" - -#: mserv.c:570 -msgid "Master Server Offline." -msgstr "" - -#: mserv.c:571 -msgid "Offline" -msgstr "" - -#: mserv.c:615 -msgid "Not yet registered to the master server.\n" -msgstr "" - -#: mserv.c:619 -msgid "Retrieving server list...\n" -msgstr "" - -#: mserv.c:628 -msgid "cannot get server list\n" -msgstr "" - -#: mserv.c:650 -msgid "Connection to master server failed\n" -msgstr "" - -#: mserv.c:681 -msgid "Timeout on masterserver\n" -msgstr "" - -#: mserv.c:692 -#, c-format -msgid "Masterserver error on select #%u: %s\n" -msgstr "" - -#: mserv.c:704 -#, c-format -msgid "Masterserver getsockopt error #%u: %s\n" -msgstr "" - -#: mserv.c:716 -msgid "Dedicated internet servers must use the -room parameter!" -msgstr "" - -#: mserv.c:747 -msgid "Master Server Updated Successfully!\n" -msgstr "" - -#: mserv.c:851 -msgid "Registering this server to the master server...\n" -msgstr "" - -#: mserv.c:951 -msgid "Unregistering this server to the master server...\n" -msgstr "" - -#: mserv.c:960 -msgid "cannot remove this server from the master server\n" -msgstr "" - -#: mserv.c:988 -msgid "You cannot register on the Master Server mid-game, please end your current session and re-host ifyou wish to advertise your server on the Master Server.\n" -msgstr "" - -#: p_enemy.c:2224 -msgid "All monitors turned off.\n" -msgstr "" - -#: p_enemy.c:2431 p_enemy.c:2468 p_enemy.c:2498 p_enemy.c:2526 p_enemy.c:2554 -#: p_enemy.c:2578 p_enemy.c:2611 p_enemy.c:2644 p_enemy.c:2692 p_enemy.c:2720 -#: p_enemy.c:2758 p_enemy.c:2788 p_enemy.c:5381 -msgid "ERROR: Powerup has no target!\n" -msgstr "" - -#: p_enemy.c:2437 -#, c-format -msgid "Power #%d out of range!\n" -msgstr "" - -#: p_enemy.c:2474 -#, c-format -msgid "Weapon #%d out of range!\n" -msgstr "" - -#: p_inter.c:1535 -#, c-format -msgid "%s returned the red flag to base.\n" -msgstr "" - -#: p_inter.c:1550 -#, c-format -msgid "%s picked up the red flag!\n" -msgstr "" - -#: p_inter.c:1586 -#, c-format -msgid "%s returned the blue flag to base.\n" -msgstr "" - -#: p_inter.c:1601 -#, c-format -msgid "%s picked up the blue flag!\n" -msgstr "" - -#: p_inter.c:1669 p_inter.c:1825 -#, c-format -msgid "%s died.\n" -msgstr "" - -#: p_inter.c:1699 -#, c-format -msgid "%s suicided.\n" -msgstr "" - -#: p_inter.c:1704 -#, c-format -msgid "%s crushed %s with a heavy object!\n" -msgstr "" - -#: p_inter.c:1713 -#, c-format -msgid "%s was fried by %s%s's fire trail.\n" -msgstr "" - -#: p_inter.c:1717 p_inter.c:1918 -#, c-format -msgid "%s was %s by %s%s's %sbounce ring.\n" -msgstr "" - -#: p_inter.c:1720 p_inter.c:1921 -#, c-format -msgid "%s was %s by %s%s's %sautomatic ring.\n" -msgstr "" - -#: p_inter.c:1723 p_inter.c:1924 -#, c-format -msgid "%s was %s by %s%s's %sscatter ring.\n" -msgstr "" - -#: p_inter.c:1726 p_inter.c:1927 -#, c-format -msgid "%s was %s by %s%s's %sexplosion ring.\n" -msgstr "" - -#: p_inter.c:1729 p_inter.c:1930 -#, c-format -msgid "%s was %s by %s%s's %sgrenade ring.\n" -msgstr "" - -#: p_inter.c:1732 p_inter.c:1933 -#, c-format -msgid "%s was %s by %s%s's %sturbo ring.\n" -msgstr "" - -#: p_inter.c:1735 p_inter.c:1936 -#, c-format -msgid "%s was %s by %s%s's %smine ring.\n" -msgstr "" - -#: p_inter.c:1738 p_inter.c:1939 -#, c-format -msgid "%s was %s by %s%s's %sBFR blast.\n" -msgstr "" - -#: p_inter.c:1742 p_inter.c:1943 -#, c-format -msgid "%s was %s by %s%s's %sBFR laser.\n" -msgstr "" - -#: p_inter.c:1744 p_inter.c:1945 -#, c-format -msgid "%s was %s by %s%s's %srail ring.\n" -msgstr "" - -#: p_inter.c:1748 p_inter.c:1949 -#, c-format -msgid "%s was %s by %s%s's %sring.\n" -msgstr "" - -#: p_inter.c:1752 p_inter.c:1894 -#, c-format -msgid "%s was %s by %s%s.\n" -msgstr "" - -#: p_inter.c:1759 p_inter.c:1840 -msgid "killed" -msgstr "" - -#: p_inter.c:1760 p_inter.c:1766 p_inter.c:1960 p_inter.c:1966 -msgid "the late " -msgstr "" - -#: p_inter.c:1762 p_inter.c:1962 -msgid "reflected " -msgstr "" - -#: p_inter.c:1778 -#, c-format -msgid "%s drowned.\n" -msgstr "" - -#: p_inter.c:1780 -#, c-format -msgid "%s was impaled by spikes!\n" -msgstr "" - -#: p_inter.c:1782 -#, c-format -msgid "%s was crushed.\n" -msgstr "" - -#: p_inter.c:1827 -#, c-format -msgid "%s fell in some nasty goop!\n" -msgstr "" - -#: p_inter.c:1829 -#, c-format -msgid "%s burned to death!\n" -msgstr "" - -#: p_inter.c:1831 -#, c-format -msgid "%s was electrocuted!\n" -msgstr "" - -#: p_inter.c:1834 -#, c-format -msgid "%s fell into a bottomless pit.\n" -msgstr "" - -#: p_inter.c:1836 -#, c-format -msgid "%s asphyxiated in space!\n" -msgstr "" - -#: p_inter.c:1906 -#, c-format -msgid "%s got nuked by %s%s!\n" -msgstr "" - -#: p_inter.c:1914 -#, c-format -msgid "%s was burnt by %s%s's fire trail.\n" -msgstr "" - -#: p_inter.c:1959 -msgid "hit" -msgstr "" - -#: p_inter.c:2050 -msgid "The IT player has left the game.\n" -msgstr "" - -#: p_inter.c:2070 p_inter.c:2094 -msgid "All players have been tagged!\n" -msgstr "" - -#: p_inter.c:2082 -msgid "There are no players able to become IT.\n" -msgstr "" - -#: p_inter.c:2335 p_inter.c:2594 -#, c-format -msgid "%s was found!\n" -msgstr "" - -#: p_inter.c:4006 -#, c-format -msgid "%s tossed the %s flag.\n" -msgstr "" - -#: p_inter.c:4008 -#, c-format -msgid "%s dropped the %s flag.\n" -msgstr "" - -#: p_mobj.c:202 p_mobj.c:264 -msgid "Warning: State Cycle Detected\n" -msgstr "" - -#: p_mobj.c:6044 -msgid "The red flag has returned to base.\n" -msgstr "" - -#: p_mobj.c:6054 -msgid "The blue flag has returned to base.\n" -msgstr "" - -#: p_setup.c:618 p_setup.c:620 p_setup.c:626 -msgid "You need to unlock this level first!\n" -msgstr "" - -#: p_setup.c:624 -msgid "You need to unlock this level in single player first!\n" -msgstr "" - -#: p_setup.c:897 -msgid "No more free memory for thing writing!\n" -msgstr "" - -#: p_setup.c:922 -#, c-format -msgid "newthings%d.lmp saved.\n" -msgstr "" - -#: p_setup.c:2287 -msgid "No player currently available to become IT. Awaiting available players.\n" -msgstr "" - -#: p_setup.c:2440 -#, c-format -msgid "Loading SOC lump: %s\n" -msgstr "" - -#: p_setup.c:2462 -#, c-format -msgid "Errors occured while loading %s; not added.\n" -msgstr "" - -#: p_setup.c:2510 -#, c-format -msgid "%s sounds replaced\n" -msgstr "" - -#: p_setup.c:2512 -#, c-format -msgid "%s midi musics replaced\n" -msgstr "" - -#: p_setup.c:2514 -#, c-format -msgid "%s digital musics replaced\n" -msgstr "" - -#: p_setup.c:2573 -msgid "No maps added\n" -msgstr "" - -#: p_setup.c:2581 -#, c-format -msgid "Current map %d replaced by added file, ending the level to ensure consistiency.\n" -msgstr "" - -#: p_spec.c:1445 -#, c-format -msgid "" -"WARNING: Linedef executor trigger isn't handling sector triggers properly!\n" -"specialtype = %d, if you are not a dev, report this warning instance\n" -"along with the wad that caused it!\n" -msgstr "" - -#: p_spec.c:3228 -#, c-format -msgid "%s\\captured the blue flag.\\\\\\\\" -msgstr "" - -#: p_spec.c:3263 p_spec.c:3342 -msgid "the enemy has returned\\their flag.\\\\\\\\" -msgstr "" - -#: p_spec.c:3266 p_spec.c:3345 -msgid "your flag was returned\\to base.\\\\\\\\" -msgstr "" - -#: p_spec.c:3310 -#, c-format -msgid "%s\\captured the red flag.\\\\\\\\" -msgstr "" - -#: p_spec.c:3548 -#, c-format -msgid "%s has finished the race.\n" -msgstr "" - -#: p_spec.c:3550 -#, c-format -msgid "%s started lap %d\n" -msgstr "" - -#: p_spec.c:4249 -#, c-format -msgid "%s recieved double points for surviving the round.\n" -msgstr "" - -#: p_spec.c:4408 -#, c-format -msgid "A FOF tagged %d has a top height below its bottom.\n" -msgstr "" - -#: p_tick.c:57 -msgid "" -"numthinkers <#>: Count number of thinkers\n" -"\t1: P_MobjThinker\n" -"\t2: P_RainThinker\n" -"\t3: P_SnowThinker\n" -"\t4: P_NullPrecipThinker\n" -"\t5: T_Friction\n" -"\t6: T_Pusher\n" -"\t7: P_RemoveThinkerDelayed\n" -msgstr "" - -#: p_tick.c:69 -msgid "Number of P_MobjThinker: " -msgstr "" - -#: p_tick.c:73 -msgid "Number of P_RainThinker: " -msgstr "" - -#: p_tick.c:77 -msgid "Number of P_SnowThinker: " -msgstr "" - -#: p_tick.c:81 -msgid "Number of P_NullPrecipThinker: " -msgstr "" - -#: p_tick.c:85 -msgid "Number of T_Friction: " -msgstr "" - -#: p_tick.c:89 -msgid "Number of T_Pusher: " -msgstr "" - -#: p_tick.c:93 -msgid "Number of P_RemoveThinkerDelayed: " -msgstr "" - -#: p_tick.c:96 -msgid "That is not a valid number.\n" -msgstr "" - -#: p_tick.c:131 -#, c-format -msgid "Object number %d out of range (max %d).\n" -msgstr "" - -#: p_tick.c:146 -#, c-format -msgid "There are %d objects of type %d currently in the level.\n" -msgstr "" - -#: p_tick.c:151 -msgid "Count of active objects in level:\n" -msgstr "" - -#: p_user.c:360 -#, c-format -msgid "%s got a chain of %u!\n" -msgstr "" - -#: p_user.c:1425 -#, c-format -msgid "%s has completed the level.\n" -msgstr "" - -#: p_user.c:4942 p_user.c:5081 -msgid "Sorry, you're too high to place this object (max: 4095 above bottom floor).\n" -msgstr "" - -#: p_user.c:5076 -msgid "Sorry, you're too high to place this object (max: 2047 above bottom floor).\n" -msgstr "" - -#: p_user.c:5128 -#, c-format -msgid "Spawned at %d\n" -msgstr "" - -#: p_user.c:5198 p_user.c:5215 -#, c-format -msgid "Current mapthing is %d\n" -msgstr "" - -#: p_user.c:5292 p_user.c:5302 -#, c-format -msgid "Sorry, you're too %s to place this object (max: %d %s).\n" -msgstr "" - -#: p_user.c:5292 p_user.c:5302 -msgid "high" -msgstr "" - -#: p_user.c:5292 p_user.c:5302 -msgid "low" -msgstr "" - -#: p_user.c:5293 p_user.c:5303 -msgid "above bottom floor" -msgstr "" - -#: p_user.c:5293 p_user.c:5303 -msgid "below top ceiling" -msgstr "" - -#: p_user.c:5350 -#, c-format -msgid "Placed object mapthingum %d, not the one below.\n" -msgstr "" - -#: p_user.c:5360 -#, c-format -msgid "Placed object type %d at %d, %d, %d, %d\n" -msgstr "" - -#: p_user.c:5406 -msgid "Deleting...\n" -msgstr "" - -#: p_user.c:5420 -msgid "Deleted.\n" -msgstr "" - -#: p_user.c:5441 -msgid "You cannot delete this item because it doesn't have a mapthing!\n" -msgstr "" - -#: p_user.c:5638 -msgid "You must wait until next round to enter the game.\n" -msgstr "" - -#: p_user.c:5644 p_user.c:5704 -msgid "Server does not allow team change.\n" -msgstr "" - -#: p_user.c:8806 -#, c-format -msgid "%s caused a world of pain.\n" -msgstr "" - -#: p_user.c:9855 -#, c-format -msgid "%s ran out of time.\n" -msgstr "" - -#: r_data.c:491 -#, c-format -msgid "Number of Extra Colormaps: %s\n" -msgstr "" - -#: r_main.c:139 -msgid "Splitscreen not supported in netplay, sorry!\n" -msgstr "" - -#: r_things.c:211 -#, c-format -msgid "Bad sprite name: %s" -msgstr "" - -#: r_things.c:428 -#, c-format -msgid "sprite %s set in pwad %d\n" -msgstr "" - -#: r_things.c:434 -#, c-format -msgid "%s added %hd frames in %s sprites\n" -msgstr "" - -#: r_things.c:480 -#, c-format -msgid "%s sprites removed from file %s\n" -msgstr "" - -#: r_things.c:2403 -#, c-format -msgid "Skin %s not found\n" -msgstr "" - -#: r_things.c:2501 -#, c-format -msgid "Skin %d not found\n" -msgstr "" - -#: r_things.c:2809 -#, c-format -msgid "Added skin '%s'\n" -msgstr "" - -#: r_things.c:2871 -#, c-format -msgid "Removed skin '%s'\n" -msgstr "" - -#: s_sound.c:349 -msgid "Loading sounds... " -msgstr "" - -#: s_sound.c:355 -msgid " pre-cached all sound data\n" -msgstr "" - -#: s_sound.c:1107 -#, c-format -msgid "Music lump %.6s not found!\n" -msgstr "" - -#: screen.c:169 -#, c-format -msgid "" -"Resolution is not aspect-correct!\n" -"Use a multiple of %dx%d\n" -msgstr "" - -#: screen.c:345 -#, c-format -msgid "Using resolution: %d x %d\n" -msgstr "" - -#: screen.c:351 -#, c-format -msgid "Default resolution: %d x %d (%d bits)\n" -msgstr "" - -#: sdl/i_cdmus.c:99 sdl/i_cdmus.c:224 sdl/i_cdmus.c:436 win32/win_cd.c:401 -msgid "No CD in drive\n" -msgstr "" - -#: sdl/i_cdmus.c:105 -#, c-format -msgid "CD Error: %s\n" -msgstr "" - -#: sdl/i_cdmus.c:132 -msgid "CD eject failed\n" -msgstr "" - -#: sdl/i_cdmus.c:153 win32/win_cd.c:199 -msgid "" -"cd [on] [off] [remap] [reset] [select]\n" -" [open] [info] [play ] [resume]\n" -" [stop] [pause] [loop ]\n" -msgstr "" - -#: sdl/i_cdmus.c:186 -#, c-format -msgid "Opened CD-ROM drive %s\n" -msgstr "" - -#: sdl/i_cdmus.c:188 sdl/i_cdmus.c:422 sdl/i_cdmus.c:424 -#, c-format -msgid "Couldn't open CD-ROM drive %s: %s\n" -msgstr "" - -#: sdl/i_cdmus.c:238 -#, c-format -msgid "%u tracks\n" -msgstr "" - -#: sdl/i_cdmus.c:240 win32/win_cd.c:297 -#, c-format -msgid "Currently %s track %u\n" -msgstr "" - -#: sdl/i_cdmus.c:240 sdl/i_cdmus.c:242 win32/win_cd.c:297 -msgid "looping" -msgstr "" - -#: sdl/i_cdmus.c:240 sdl/i_cdmus.c:242 win32/win_cd.c:297 -msgid "playing" -msgstr "" - -#: sdl/i_cdmus.c:242 -#, c-format -msgid "Paused %s track %u\n" -msgstr "" - -#: sdl/i_cdmus.c:243 -#, c-format -msgid "Volume is %d\n" -msgstr "" - -#: sdl/i_cdmus.c:276 win32/win_cd.c:326 -#, c-format -msgid "Invalid CD command \"CD %s\"\n" -msgstr "" - -#: sdl/i_cdmus.c:406 -msgid "I_InitCD: Init CD audio\n" -msgstr "" - -#: sdl/i_cdmus.c:411 -#, c-format -msgid "Couldn't initialize SDL CDROM: %s\n" -msgstr "" - -#: sdl/i_cdmus.c:442 win32/win_cd.c:389 -msgid "CD audio Initialized\n" -msgstr "" - -#: sdl/i_cdmus.c:520 -#, c-format -msgid "Bad track number %u.\n" -msgstr "" - -#: sdl/i_cdmus.c:527 -#, c-format -msgid "Track %u is not audio\n" -msgstr "" - -#: sdl/i_cdmus.c:540 -#, c-format -msgid "Error playing track %d: %s\n" -msgstr "" - -#: sdl/i_main.c:194 win32/win_main.c:598 -msgid "Setting up SRB2...\n" -msgstr "" - -#: sdl/i_main.c:196 win32/win_main.c:600 -msgid "Entering main game loop...\n" -msgstr "" - -#: sdl/i_sound.c:1184 win32/win_snd.c:923 -#, c-format -msgid " requested frequency of %d hz\n" -msgstr "" - -#: sdl/i_sound.c:1264 -msgid " Using 3D sound driver\n" -msgstr "" - -#: sdl/i_sound.c:1267 sdl/i_sound.c:1272 -msgid " Failed loading 3D sound driver\n" -msgstr "" - -#: sdl/i_sound.c:1278 sdl/i_sound.c:1645 -msgid " couldn't open audio with desired format\n" -msgstr "" - -#: sdl/i_sound.c:1285 -#, c-format -msgid " Starting up with audio driver : %s\n" -msgstr "" - -#: sdl/i_sound.c:1289 -#, c-format -msgid " configured audio device with %d samples/slice at %ikhz(%dms buffer)\n" -msgstr "" - -#: sdl/i_sound.c:1291 -msgid " Sound module ready\n" -msgstr "" - -#: sdl/i_sound.c:1377 -#, c-format -msgid "Couldn't load music lump: %s\n" -msgstr "" - -#: sdl/i_sound.c:1387 -#, c-format -msgid "Couldn't load music data: %s\n" -msgstr "" - -#: sdl/i_sound.c:1421 -#, c-format -msgid "Couldn't open file %s to write music in\n" -msgstr "" - -#: sdl/i_sound.c:1428 -#, c-format -msgid "Couldn't write music into file %s because %s\n" -msgstr "" - -#: sdl/i_sound.c:1441 -#, c-format -msgid "Couldn't load music file %s: %s\n" -msgstr "" - -#: sdl/i_sound.c:1455 -msgid "I_ShutdownMusic: " -msgstr "" - -#: sdl/i_sound.c:1611 -msgid "I_InitMusic:" -msgstr "" - -#: sdl/i_sound.c:1617 -msgid " Unable to load FLAC support\n" -msgstr "" - -#: sdl/i_sound.c:1621 -msgid " Unable to load MOD support\n" -msgstr "" - -#: sdl/i_sound.c:1625 -msgid " Unable to load MP3 support\n" -msgstr "" - -#: sdl/i_sound.c:1629 -msgid " Unable to load OGG support\n" -msgstr "" - -#: sdl/i_sound.c:1635 -#, c-format -msgid " Unable to open music: %s\n" -msgstr "" - -#: sdl/i_sound.c:1651 -#, c-format -msgid " Starting with audio driver : %s\n" -msgstr "" - -#: sdl/i_sound.c:1657 -#, c-format -msgid " Starting up with audio driver : %s with SDL_Mixer\n" -msgstr "" - -#: sdl/i_sound.c:1671 -msgid "Music initialized\n" -msgstr "" - -#: sdl/i_sound.c:1690 -#, c-format -msgid "Couldn't play song because %s\n" -msgstr "" - -#: sdl/i_sound.c:1816 -#, c-format -msgid "Couldn't load MIDI: %s\n" -msgstr "" - -#: sdl/i_system.c:1127 sdl/i_system.c:1421 -#, c-format -msgid "Couldn't initialize joystick: %s\n" -msgstr "" - -#: sdl/i_system.c:1137 sdl/i_system.c:1429 -#, c-format -msgid "Cannot use joystick #%d/(%s), it doesn't exist\n" -msgstr "" - -#: sdl/i_system.c:1158 sdl/i_system.c:1450 -#, c-format -msgid "Found %d joysticks on this system\n" -msgstr "" - -#: sdl/i_system.c:1163 sdl/i_system.c:1455 -msgid "Found no joysticks on this system\n" -msgstr "" - -#: sdl/i_system.c:1168 -#, c-format -msgid "Joystick: %s\n" -msgstr "" - -#: sdl/i_system.c:1172 -#, c-format -msgid "Couldn't open joystick: %s\n" -msgstr "" - -#: sdl/i_system.c:1460 -#, c-format -msgid "Joystick2: %s\n" -msgstr "" - -#: sdl/i_system.c:1464 -#, c-format -msgid "Couldn't open joystick2: %s\n" -msgstr "" - -#: sdl/i_system.c:1789 win32/win_sys.c:979 -msgid "Read Error on secondary mouse port\n" -msgstr "" - -#: sdl/i_system.c:1885 win32/win_sys.c:1040 -#, c-format -msgid "Error opening %s!\n" -msgstr "" - -#: sdl/i_system.c:1953 -#, c-format -msgid "Can't open %s: Access denied\n" -msgstr "" - -#: sdl/i_system.c:1955 win32/win_sys.c:1042 -#, c-format -msgid "Can't open %s: error %d\n" -msgstr "" - -#: sdl/i_system.c:2131 win32/win_sys.c:460 -msgid "Using GetTickCount()\n" -msgstr "" - -#: sdl/i_video.c:556 win32/win_vid.c:1082 -#, c-format -msgid "%d video mode(s) available(s)\n" -msgstr "" - -#: sdl/i_video.c:568 -msgid "Unknown Surface" -msgstr "" - -#: sdl/i_video.c:573 -#, c-format -msgid " %ix%i at %i bit color\n" -msgstr "" - -#: sdl/i_video.c:576 -msgid " Stored in video memory\n" -msgstr "" - -#: sdl/i_video.c:578 -msgid " Stored in an OpenGL context\n" -msgstr "" - -#: sdl/i_video.c:580 -msgid " Uses preallocated memory\n" -msgstr "" - -#: sdl/i_video.c:582 -msgid " Stored in system memory\n" -msgstr "" - -#: sdl/i_video.c:585 -msgid " Uses asynchronous blits if possible\n" -msgstr "" - -#: sdl/i_video.c:587 -msgid " Uses synchronous blits if possible\n" -msgstr "" - -#: sdl/i_video.c:590 -msgid " Allows any pixel-format\n" -msgstr "" - -#: sdl/i_video.c:593 -msgid " Has exclusive palette access\n" -msgstr "" - -#: sdl/i_video.c:595 -msgid " Has nonexclusive palette access\n" -msgstr "" - -#: sdl/i_video.c:598 -msgid " Double buffered\n" -msgstr "" - -#: sdl/i_video.c:600 -msgid " No hardware flipping\n" -msgstr "" - -#: sdl/i_video.c:603 -msgid " Full screen\n" -msgstr "" - -#: sdl/i_video.c:605 -msgid " Resizable window\n" -msgstr "" - -#: sdl/i_video.c:607 -msgid " Nonresizable window\n" -msgstr "" - -#: sdl/i_video.c:610 -msgid " Uses hardware acceleration blit\n" -msgstr "" - -#: sdl/i_video.c:612 -msgid " Use colorkey blitting\n" -msgstr "" - -#: sdl/i_video.c:614 -msgid " Colorkey RLE acceleration blit\n" -msgstr "" - -#: sdl/i_video.c:616 -msgid " Use alpha blending acceleration blit\n" -msgstr "" - -#: sdl/i_video.c:626 -msgid "Video Interface Capabilities:\n" -msgstr "" - -#: sdl/i_video.c:628 -msgid " Hardware surfaces\n" -msgstr "" - -#: sdl/i_video.c:630 -msgid " Window manager\n" -msgstr "" - -#: sdl/i_video.c:634 -msgid " Accelerated blits HW-2-HW\n" -msgstr "" - -#: sdl/i_video.c:636 -msgid " Accelerated blits HW-2-HW with Colorkey\n" -msgstr "" - -#: sdl/i_video.c:638 -msgid " Accelerated blits HW-2-HW with Alpha\n" -msgstr "" - -#: sdl/i_video.c:641 -msgid " Accelerated blits SW-2-HW\n" -msgstr "" - -#: sdl/i_video.c:645 -msgid " Accelerated blits SW-2-HW with Colorkey\n" -msgstr "" - -#: sdl/i_video.c:647 -msgid " Accelerated blits SW-2-HW with Alpha\n" -msgstr "" - -#: sdl/i_video.c:649 -msgid " Accelerated Color filling\n" -msgstr "" - -#: sdl/i_video.c:652 -#, c-format -msgid " There is %i KB of video memory\n" -msgstr "" - -#: sdl/i_video.c:654 -msgid " There no video memory for SDL\n" -msgstr "" - -#: sdl/i_video.c:657 -msgid "Current Engine Mode" -msgstr "" - -#: sdl/i_video.c:659 -msgid "Prebuffer Mode" -msgstr "" - -#: sdl/i_video.c:660 -msgid "Postbuffer Mode" -msgstr "" - -#: sdl/i_video.c:662 -msgid "Current Video Mode" -msgstr "" - -#: sdl/i_video.c:678 win32/win_vid.c:1147 -msgid "No video modes present\n" -msgstr "" - -#: sdl/i_video.c:689 -#, c-format -msgid "Found %d FullScreen Video Modes:\n" -msgstr "" - -#: sdl/i_video.c:696 -#, c-format -msgid "%dx%d and " -msgstr "" - -#: sdl/i_video.c:700 -msgid "None\n" -msgstr "" - -#: sdl/i_video.c:710 win32/win_vid.c:1140 -#, c-format -msgid "vid_mode : set video mode, current video mode %i\n" -msgstr "" - -#: sdl/i_video.c:717 win32/win_vid.c:1099 -msgid "No such video mode\n" -msgstr "" - -#: sdl/i_video.c:1961 -#, c-format -msgid "Couldn't initialize SDL's Audio System with Video System: %s\n" -msgstr "" - -#: sdl/i_video.c:1965 -#, c-format -msgid "Couldn't initialize SDL's Video System: %s\n" -msgstr "" - -#: sdl/i_video.c:1977 -#, c-format -msgid "Starting up with video driver : %s\n" -msgstr "" - -#: sdl/i_video.c:2046 -msgid "" -"The version of the renderer doesn't match the version of the executable\n" -"Be sure you have installed SRB2 properly.\n" -msgstr "" - -#: sdl/i_video.c:2089 -#, c-format -msgid "Could not set vidmode: %s\n" -msgstr "" - -#: sdl/i_video.c:2098 -msgid "Not enough memory for video buffer\n" -msgstr "" - -#: sounds.c:1470 -msgid "No more free sound slots\n" -msgstr "" - -#: st_stuff.c:1604 -msgid "WAITING FOR PLAYERS TO HIDE..." -msgstr "" - -#: st_stuff.c:1610 -msgid "HIDE BEFORE TIME RUNS OUT!" -msgstr "" - -#: st_stuff.c:1612 -msgid "FLEE BEFORE YOU ARE HUNTED!" -msgstr "" - -#: st_stuff.c:1615 -msgid "HIDE TIME REMAINING:" -msgstr "" - -#: st_stuff.c:1624 -msgid "YOU'RE IT!" -msgstr "" - -#: st_stuff.c:1628 -msgid "TIME REMAINING:" -msgstr "" - -#: st_stuff.c:1630 -msgid "NO TIME LIMIT" -msgstr "" - -#: st_stuff.c:1738 -msgid "TIME LEFT" -msgstr "" - -#: st_stuff.c:1772 -msgid "CONTINUE?" -msgstr "" - -#: st_stuff.c:1966 st_stuff.c:1968 -msgid "OVERTIME!" -msgstr "" - -#: st_stuff.c:2015 -msgid "Viewpoint:" -msgstr "" - -#: st_stuff.c:2033 -msgid "I, Pope Rededict XVI proclaim" -msgstr "" - -#: st_stuff.c:2034 -msgid "AJ & Amy" -msgstr "" - -#: st_stuff.c:2035 -msgid "Husband & Wife" -msgstr "" - -#: st_stuff.c:2036 -msgid "on this day" -msgstr "" - -#: st_stuff.c:2037 -msgid "May 16, 2009" -msgstr "" - -#: st_stuff.c:2043 -msgid "Oh... it's you again..." -msgstr "" - -#: st_stuff.c:2044 -msgid "Look, I wanted to apologize for the way" -msgstr "" - -#: st_stuff.c:2045 -msgid "I've acted in the past." -msgstr "" - -#: st_stuff.c:2046 -msgid "I've seen the error of my ways" -msgstr "" - -#: st_stuff.c:2047 -msgid "and turned over a new leaf." -msgstr "" - -#: st_stuff.c:2048 -msgid "Instead of sending people to hell," -msgstr "" - -#: st_stuff.c:2049 -msgid "I now send them to heaven!" -msgstr "" - -#: st_stuff.c:2081 -msgid "Thank you!" -msgstr "" - -#: st_stuff.c:2082 -msgid "But our earless leader is in" -msgstr "" - -#: st_stuff.c:2083 -msgid "another castle!" -msgstr "" - -#: st_stuff.c:2092 st_stuff.c:2098 st_stuff.c:2120 -msgid "Press Viewpoint Key to watch a player." -msgstr "" - -#: st_stuff.c:2097 -msgid "You cannot move while hiding." -msgstr "" - -#: st_stuff.c:2108 -#, c-format -msgid "Respawn in: %d seconds." -msgstr "" - -#: st_stuff.c:2110 -msgid "Press Jump to respawn." -msgstr "" - -#: st_stuff.c:2115 -msgid "You are a spectator." -msgstr "" - -#: st_stuff.c:2117 -msgid "Press Fire to be assigned to a team." -msgstr "" - -#: st_stuff.c:2119 -msgid "Press Fire to enter the game." -msgstr "" - -#: st_stuff.c:2121 -msgid "Press Jump to float and Spin to sink." -msgstr "" - -#: w_wad.c:147 -#, c-format -msgid "Loading main config from %s\n" -msgstr "" - -#: w_wad.c:157 -#, c-format -msgid "Loading object config from %s\n" -msgstr "" - -#: w_wad.c:236 w_wad.c:281 -msgid "Maximum wad files reached\n" -msgstr "" - -#: w_wad.c:257 -#, c-format -msgid "Can't open %s\n" -msgstr "" - -#: w_wad.c:312 -#, c-format -msgid "Can't read wad header from %s because %s\n" -msgstr "" - -#: w_wad.c:322 -#, c-format -msgid "%s does not have a valid WAD header\n" -msgstr "" - -#: w_wad.c:335 -#, c-format -msgid "Wadfile directory in %s is corrupted (%s)\n" -msgstr "" - -#: w_wad.c:391 -#, c-format -msgid "%s is already loaded\n" -msgstr "" - -#: w_wad.c:423 -#, c-format -msgid "Added file %s (%u lumps)\n" -msgstr "" - -#: w_wad.c:441 -#, c-format -msgid "You can't remove the IWAD %s!\n" -msgstr "" - -#: w_wad.c:445 -#, c-format -msgid "Removing WAD %s...\n" -msgstr "" - -#: w_wad.c:465 -msgid " done unloading WAD\n" -msgstr "" - -#: w_wad.c:1014 -#, c-format -msgid "File is corrupt or has been modified: %s (found md5: %s, wanted: %s)\n" -msgstr "" - -#: win32/win_cd.c:229 -msgid "CD tracks remapped in that order :\n" -msgstr "" - -#: win32/win_cd.c:256 -msgid "CD is not ready.\n" -msgstr "" - -#: win32/win_cd.c:281 -msgid "No audio tracks\n" -msgstr "" - -#: win32/win_cd.c:290 -msgid "audio" -msgstr "" - -#: win32/win_cd.c:290 -msgid "data " -msgstr "" - -#: win32/win_cd.c:293 -#, c-format -msgid "Total time : %s\n" -msgstr "" - -#: win32/win_main.c:335 -msgid "Hello, it's me, SRB2's Console Window\n" -msgstr "" - -#: win32/win_main.c:339 -msgid "We have a console already.\n" -msgstr "" - -#: win32/win_snd.c:985 -#, c-format -msgid "Using external sound driver %s\n" -msgstr "" - -#: win32/win_snd.c:990 -#, c-format -msgid "Not using external sound driver %s\n" -msgstr "" - -#: win32/win_snd.c:1001 -msgid " DirectSound DLL not loaded\n" -msgstr "" - -#: win32/win_snd.c:1009 -msgid "" -" DirectSoundCreate FAILED\n" -" there is no sound device or the sound device is under\n" -" the control of another application\n" -msgstr "" - -#: win32/win_snd.c:1021 -msgid " SetCooperativeLevel FAILED\n" -msgstr "" - -#: win32/win_snd.c:1047 -#, c-format -msgid "CreateSoundBuffer FAILED: %s (ErrNo %ld)\n" -msgstr "" - -#: win32/win_snd.c:1062 -msgid "Couldn't set primary buffer format.\n" -msgstr "" - -#: win32/win_snd.c:1069 -msgid " Compacting onboard sound-memory..." -msgstr "" - -#: win32/win_snd.c:1081 -msgid " Primary buffer continuous play FAILED\n" -msgstr "" - -#: win32/win_snd.c:1118 -msgid "sound initialized.\n" -msgstr "" - -#: win32/win_snd.c:1191 -#, c-format -msgid "%d mixer devices available\n" -msgstr "" - -#: win32/win_snd.c:1287 -msgid "No MIDI devices available, music is disabled\n" -msgstr "" - -#: win32/win_snd.c:1351 -msgid "No MIDI music\n" -msgstr "" - -#: win32/win_snd.c:1363 -msgid "midiStreamOpen FAILED\n" -msgstr "" - -#: win32/win_snd.c:1542 -msgid "Couldn't set volume\n" -msgstr "" - -#: win32/win_snd.c:2114 -msgid "Music lump is not MID music format\n" -msgstr "" - -#: win32/win_snd.c:2126 -msgid "I_RegisterSong: StreamBufferSetup FAILED" -msgstr "" - -#: win32/win_sys.c:894 -msgid "Could not create IDirectInput device 2" -msgstr "" - -#: win32/win_sys.c:1187 -msgid "\tMouse will not use DirectInput.\n" -msgstr "" - -#: win32/win_sys.c:1724 win32/win_sys.c:2083 -#, c-format -msgid "Capabilities: %lu axes, %lu buttons, %lu POVs, poll %u, Gamepad %d\n" -msgstr "" - -#: win32/win_sys.c:1956 -msgid "Joystick disabled\n" -msgstr "" - -#: win32/win_sys.c:1970 win32/win_sys.c:2332 -msgid "Looking for joystick devices:\n" -msgstr "" - -#: win32/win_sys.c:1977 win32/win_sys.c:2340 -msgid "Joystick initialize failed.\n" -msgstr "" - -#: win32/win_sys.c:1985 win32/win_sys.c:2348 -msgid "none found\n" -msgstr "" - -#: win32/win_sys.c:1988 win32/win_sys.c:2351 -msgid "none used\n" -msgstr "" - -#: win32/win_sys.c:1991 -msgid "Set the use_joystick variable to one of the enumerated joystick numbers\n" -msgstr "" - -#: win32/win_sys.c:2004 -msgid "I_InitJoystick: SetCooperativeLevel FAILED" -msgstr "" - -#: win32/win_sys.c:2008 win32/win_sys.c:2375 -msgid "Joystick already initialized\n" -msgstr "" - -#: win32/win_sys.c:2318 -msgid "Joystick2 disabled\n" -msgstr "" - -#: win32/win_sys.c:2355 -msgid "Set the use_joystick2 variable to one of the enumerated joysticks number\n" -msgstr "" - -#: win32/win_sys.c:2366 -msgid "I_InitJoystick2: SetCooperativeLevel FAILED" -msgstr "" - -#: win32/win_sys.c:3468 -#, c-format -msgid "Couldn't create DirectInput (reason: %s)" -msgstr "" - -#: win32/win_sys.c:3471 -msgid "Using DirectX3 interface\n" -msgstr "" - -#: win32/win_vid.c:621 -msgid "mode skipped (too many)\n" -msgstr "" - -#: win32/win_vid.c:769 -msgid "This r_opengl version is not supported, use it at your own risk!\n" -msgstr "" - -#: win32/win_vid.c:979 -#, c-format -msgid "Mode changed to %d (%s)\n" -msgstr "" - -#: win32/win_vid.c:1106 -#, c-format -msgid "" -"width: %d\n" -"height: %d\n" -msgstr "" - -#: win32/win_vid.c:1108 -#, c-format -msgid "" -"bytes per scanline: %d\n" -"bytes per pixel: %d\n" -"numpages: %d\n" -msgstr "" - -#: y_inter.c:249 -msgid "GOT TIME BONUS EMBLEM!" -msgstr "" - -#: y_inter.c:251 -msgid "GOT PERFECT BONUS EMBLEM!" -msgstr "" - -#: y_inter.c:579 -msgid "Teams will be scrambled next round!" -msgstr "" - -#: y_inter.c:925 -msgid "NEW MAP BEST!" -msgstr "" - -#: y_inter.c:925 -msgid "Saved" -msgstr "" - -#: y_inter.c:936 -msgid "NEW RECORD!" -msgstr "" - -#: y_inter.c:936 y_inter.c:941 -msgid "Saved replay as" -msgstr "" - -#: z_zone.c:148 -#, c-format -msgid "system memory %uMB free %uMB\n" -msgstr "" - -#: z_zone.c:614 -msgid "Memory Info\n" -msgstr "" - -#: z_zone.c:615 -#, c-format -msgid "Total heap used : %7s KB\n" -msgstr "" - -#: z_zone.c:616 -#, c-format -msgid "Static : %7s KB\n" -msgstr "" - -#: z_zone.c:617 -#, c-format -msgid "Static (sound) : %7s KB\n" -msgstr "" - -#: z_zone.c:618 -#, c-format -msgid "Static (music) : %7s KB\n" -msgstr "" - -#: z_zone.c:619 -#, c-format -msgid "Locked cache : %7s KB\n" -msgstr "" - -#: z_zone.c:620 -#, c-format -msgid "Level : %7s KB\n" -msgstr "" - -#: z_zone.c:621 -#, c-format -msgid "Special thinker : %7s KB\n" -msgstr "" - -#: z_zone.c:622 -#, c-format -msgid "All purgable : %7s KB\n" -msgstr "" - -#: z_zone.c:628 -#, c-format -msgid "Patch info headers: %7s KB\n" -msgstr "" - -#: z_zone.c:629 -#, c-format -msgid "Mipmap patches : %7s KB\n" -msgstr "" - -#: z_zone.c:630 -#, c-format -msgid "HW Texture cache : %7s KB\n" -msgstr "" - -#: z_zone.c:631 -#, c-format -msgid "Plane polygons : %7s KB\n" -msgstr "" - -#: z_zone.c:632 -#, c-format -msgid "HW Texture used : %7d KB\n" -msgstr "" - -#: z_zone.c:636 -msgid "System Memory Info\n" -msgstr "" - -#: z_zone.c:638 -#, c-format -msgid " Total physical memory: %7u KB\n" -msgstr "" - -#: z_zone.c:639 -#, c-format -msgid "Available physical memory: %7u KB\n" -msgstr "" diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 0ccc7d8ed..059df924c 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -16,6 +16,7 @@ #include "p_slopes.h" // P_GetZAt #include "z_zone.h" #include "r_main.h" +#include "r_skins.h" #include "r_things.h" #include "m_random.h" #include "s_sound.h" @@ -24,6 +25,7 @@ #include "hu_stuff.h" // HU_AddChatText #include "console.h" #include "k_kart.h" // SRB2Kart +#include "k_hud.h" // SRB2Kart #include "d_netcmd.h" // IsPlayerAdmin #include "d_main.h" diff --git a/src/lua_hook.h b/src/lua_hook.h index 45237aa80..c31a58a67 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -55,6 +55,7 @@ X (PlayerQuit),\ X (PlayerThink),/* P_PlayerThink */\ X (MusicChange),\ + X (MusicCredit),\ X (ShouldSpin),/*SRB2KART*/\ X (ShouldExplode),/*SRB2KART*/\ X (ShouldSquish),/*SRB2KART*/\ @@ -130,6 +131,7 @@ int LUA_HookPlayerCanDamage(player_t *, mobj_t *); void LUA_HookPlayerQuit(player_t *, int); int LUA_HookPlayerCmd(player_t *, ticcmd_t *); int LUA_HookMusicChange(const char *oldname, struct MusicChange *); +int LUA_HookMusicCredit(musicdef_t *musicdef); int LUA_HookShouldSpin(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Should player be spun out? int LUA_HookShouldExplode(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Should player be exploded? diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index a0f795985..54c39d560 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -14,6 +14,7 @@ #include "doomstat.h" #include "p_mobj.h" #include "g_game.h" +#include "r_skins.h" #include "r_things.h" #include "b_bot.h" #include "z_zone.h" @@ -1065,6 +1066,18 @@ int LUA_HookMusicChange(const char *oldname, struct MusicChange *param) return hook.status; } +int LUA_HookMusicCredit(musicdef_t *musicdef) +{ + Hook_State hook; + if (prepare_hook(&hook, 0, HOOK(MusicCredit))) + { + LUA_PushUserdata(gL, musicdef, META_MUSICDEF); + call_hooks(&hook, 1, res_true); + } + + return hook.status; +} + static int kartdamage_hook ( player_t *player, diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index d1dce0ae0..98120cebf 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -24,6 +24,7 @@ #include "w_wad.h" #include "z_zone.h" #include "k_kart.h" +#include "k_hud.h" // SRB2kart #include "lua_script.h" #include "lua_libs.h" @@ -1260,15 +1261,10 @@ extern int lib_hudadd(lua_State *L); static int lib_hudsetvotebackground(lua_State *L) { + memset(VoteScreen.luaPrefix, 0, sizeof(VoteScreen.luaPrefix)); + if (lua_isnoneornil(L, 1)) { - if (luaVoteScreen) - { - free(luaVoteScreen); - } - - luaVoteScreen = NULL; - return 0; } @@ -1279,15 +1275,8 @@ static int lib_hudsetvotebackground(lua_State *L) return luaL_argerror(L, 1, "prefix should 4 characters wide"); } - if (!luaVoteScreen) - { - luaVoteScreen = (char*)malloc(5); - luaVoteScreen[4] = 0; - } - - strncpy(luaVoteScreen, prefix, 4); - - strupr(luaVoteScreen); + strncpy(VoteScreen.luaPrefix, prefix, 4); + strupr(VoteScreen.luaPrefix); return 0; } diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 3ff2d97ae..0ac308bcb 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -16,6 +16,7 @@ #include "dehacked.h" #include "p_mobj.h" #include "p_local.h" +#include "s_sound.h" #include "z_zone.h" #include "lua_script.h" @@ -1072,6 +1073,109 @@ static int sfxinfo_num(lua_State *L) return 1; } +enum musicdef_e { + musicdef_name = 0, + musicdef_usage, + musicdef_source, + musicdef_filename, + musicdef_title, + musicdef_alttitle, + musicdef_authors, +}; + +const char *const musicdef_opt[] = { + "name", + "usage", + "source", + "filename", + "title", + "alttitle", + "authors", + NULL +}; + +static int musicdef_fields_ref = LUA_NOREF; + +static int lib_sFindMusicCredit(lua_State *L) +{ + const char *name = luaL_checkstring(L, 1); + LUA_PushUserdata(L, S_FindMusicCredit(name), META_MUSICDEF); + return 1; +} + +static int lib_getMusicDef(lua_State *L) +{ + musicdef_t *def = NULL; + + if (lua_isnumber(L, 2)) + def = S_GetMusicCredit(lua_tonumber(L, 2)); + else if (lua_isstring(L, 2)) + def = S_FindMusicCredit(lua_tostring(L, 2)); + else + return luaL_error(L, "musicdefs index must be number or string (got %s)", luaL_typename(L, 2)); + + LUA_PushUserdata(L, def, META_MUSICDEF); + + return 1; +} + +static int lib_setMusicDef(lua_State *L) +{ + return luaL_error(L, "musicdefs is read only"); +} + +static int lib_musicdefslen(lua_State *L) +{ + lua_pushinteger(L, nummusicdefs); + return 1; +} + +static int musicdef_get(lua_State *L) +{ + musicdef_t *musicdef = *((musicdef_t **)luaL_checkudata(L, 1, META_MUSICDEF)); + enum musicdef_e field = Lua_optoption(L, 2, -1, musicdef_fields_ref); + + I_Assert(musicdef != NULL); + + switch (field) + { + case musicdef_name: + lua_pushstring(L, musicdef->name); + return 1; + case musicdef_usage: + lua_pushstring(L, musicdef->usage); + return 1; + case musicdef_source: + lua_pushstring(L, musicdef->source); + return 1; + case musicdef_filename: + lua_pushstring(L, musicdef->filename); + return 1; + case musicdef_title: + lua_pushstring(L, musicdef->title); + return 1; + case musicdef_alttitle: + lua_pushstring(L, musicdef->alttitle); + return 1; + case musicdef_authors: + lua_pushstring(L, musicdef->authors); + return 1; + default: + return luaL_error(L, LUA_QL("musicdef_t") " has no field named " LUA_QS, lua_tostring(L, 2)); + } + return 0; +} + +static int musicdef_num(lua_State *L) +{ + musicdef_t *musicdef = *((musicdef_t **)luaL_checkudata(L, 1, META_MUSICDEF)); + + I_Assert(musicdef != NULL); + + lua_pushinteger(L, musicdef->num); + return 1; +} + ////////////////////////////// // // Now push all these functions into the Lua state! @@ -1126,6 +1230,18 @@ int LUA_InfoLib(lua_State *L) sfxinfo_fields_ref = Lua_CreateFieldTable(L, sfxinfo_opt); + luaL_newmetatable(L, META_MUSICDEF); + lua_pushcfunction(L, musicdef_get); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, musicdef_num); + lua_setfield(L, -2, "__len"); + lua_pop(L, 1); + + musicdef_fields_ref = Lua_CreateFieldTable(L, musicdef_opt); + + lua_register(L, "S_FindMusicCredit", lib_sFindMusicCredit); + lua_newuserdata(L, 0); lua_createtable(L, 0, 2); lua_pushcfunction(L, lib_getSprname); @@ -1176,5 +1292,19 @@ int LUA_InfoLib(lua_State *L) lua_pushvalue(L, -1); lua_setglobal(L, "S_sfx"); lua_setglobal(L, "sfxinfo"); + + lua_newuserdata(L, 0); + lua_createtable(L, 0, 2); + lua_pushcfunction(L, lib_getMusicDef); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, lib_setMusicDef); + lua_setfield(L, -2, "__newindex"); + + lua_pushcfunction(L, lib_musicdefslen); + lua_setfield(L, -2, "__len"); + lua_setmetatable(L, -2); + lua_setglobal(L, "musicdefs"); + return 0; } diff --git a/src/lua_libs.h b/src/lua_libs.h index c226c4714..729cea68d 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -10,6 +10,9 @@ /// \file lua_libs.h /// \brief libraries for Lua scripting +#include "doomtype.h" +#include "blua/lua.h" + extern lua_State *gL; #define LREG_VALID "VALID_USERDATA" @@ -20,6 +23,7 @@ extern lua_State *gL; #define META_STATE "STATE_T*" #define META_MOBJINFO "MOBJINFO_T*" #define META_SFXINFO "SFXINFO_T*" +#define META_MUSICDEF "MUSICDEF_T*" #define META_MOBJ "MOBJ_T*" #define META_MAPTHING "MAPTHING_T*" @@ -68,4 +72,4 @@ int LUA_SkinLib(lua_State *L); int LUA_ThinkerLib(lua_State *L); int LUA_MapLib(lua_State *L); int LUA_BlockmapLib(lua_State *L); -int LUA_HudLib(lua_State *L); \ No newline at end of file +int LUA_HudLib(lua_State *L); diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 504a1e130..4103bce99 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -15,6 +15,7 @@ #include "doomdef.h" #include "fastcmp.h" #include "r_things.h" +#include "r_skins.h" #include "r_main.h" #include "p_local.h" #include "g_game.h" diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 9562c5679..665512aef 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -13,6 +13,7 @@ #include "doomdef.h" #include "fastcmp.h" #include "r_main.h" +#include "r_skins.h" #include "r_things.h" #include "p_mobj.h" #include "d_player.h" diff --git a/src/lua_skinlib.c b/src/lua_skinlib.c index 403ac834e..4425f125c 100644 --- a/src/lua_skinlib.c +++ b/src/lua_skinlib.c @@ -12,6 +12,7 @@ #include "doomdef.h" #include "fastcmp.h" +#include "r_skins.h" #include "r_things.h" #include "sounds.h" @@ -277,4 +278,4 @@ int LUA_SkinLib(lua_State *L) lua_setglobal(L, "skins"); return 0; -} \ No newline at end of file +} diff --git a/src/m_anigif.c b/src/m_anigif.c index 05b1f8287..2d3f9c4e6 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -495,7 +495,7 @@ static void GIF_rgbconvert(UINT8 *linear, UINT8 *scr) static void GIF_framewrite(void) { UINT8 *p; - UINT8 *movie_screen = screens[2]; + UINT8 *movie_screen = vid.screens[2]; INT32 blitx, blity, blitw, blith; if (!gifframe_data) @@ -509,7 +509,7 @@ static void GIF_framewrite(void) if (gif_optimize && gif_frames > 0) { // before blit movie_screen points to last frame, cur_screen points to this frame - UINT8 *cur_screen = screens[0]; + UINT8 *cur_screen = vid.screens[0]; GIF_optimizeregion(cur_screen, movie_screen, &blitx, &blity, &blitw, &blith); // blit to temp screen @@ -535,7 +535,7 @@ static void GIF_framewrite(void) if (rendermode == render_opengl) { UINT8 *linear = HWR_GetScreenshot(); - GIF_rgbconvert(linear, screens[0]); + GIF_rgbconvert(linear, vid.screens[0]); //free(linear); // Allocated 'statically', no need to free now } #endif @@ -545,7 +545,7 @@ static void GIF_framewrite(void) if (gif_frames == 0 && rendermode == render_soft) I_ReadScreen(movie_screen); - movie_screen = screens[0]; + movie_screen = vid.screens[0]; } // screen regions are handled in GIF_lzw diff --git a/src/m_argv.h b/src/m_argv.h index f31a531d0..8f1a08ec4 100644 --- a/src/m_argv.h +++ b/src/m_argv.h @@ -14,6 +14,10 @@ #ifndef __M_ARGV__ #define __M_ARGV__ +#ifdef __cplusplus +extern "C" { +#endif + // // MISC // @@ -42,4 +46,8 @@ const char *M_GetNextParm(void); // Finds and loads a response file (@moreargs.txt) void M_FindResponseFile(void); +#ifdef __cplusplus +} // extern "C" +#endif + #endif //__M_ARGV__ diff --git a/src/m_fixed.h b/src/m_fixed.h index 3f1acd7ae..c0afae941 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -15,6 +15,10 @@ #ifndef __M_FIXED__ #define __M_FIXED__ +#ifdef __cplusplus +extern "C" { +#endif + #include "doomtype.h" #ifdef __GNUC__ #include @@ -49,6 +53,20 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FloatToFixed(float f) return (fixed_t)(f * FRACUNIT); } +/*! + \brief convert fixed_t into double-precision floating number +*/ + +FUNCMATH FUNCINLINE static ATTRINLINE double FixedToDouble(fixed_t x) +{ + return x / (double)FRACUNIT; +} + +FUNCMATH FUNCINLINE static ATTRINLINE fixed_t DoubleToFixed(double f) +{ + return (fixed_t)(f * FRACUNIT); +} + // for backwards compat #define FIXED_TO_FLOAT(x) FixedToFloat(x) // (((float)(x)) / ((float)FRACUNIT)) #define FLOAT_TO_FIXED(f) FloatToFixed(f) // (fixed_t)((f) * ((float)FRACUNIT)) @@ -356,4 +374,8 @@ void FM_MultMatrix(matrix_t *dest, const matrix_t *multme); void FM_Translate(matrix_t *dest, fixed_t x, fixed_t y, fixed_t z); void FM_Scale(matrix_t *dest, fixed_t x, fixed_t y, fixed_t z); +#ifdef __cplusplus +} // extern "C" +#endif + #endif //m_fixed.h diff --git a/src/m_menu.c b/src/m_menu.c index e5a20a7fa..0000fae90 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -70,6 +70,7 @@ #include "st_stuff.h" #include "i_sound.h" #include "k_kart.h" // SRB2kart +#include "k_hud.h" // SRB2kart #include "k_stats.h" // SRB2kart #include "d_player.h" // KITEM_ constants @@ -106,7 +107,7 @@ #define SMALLLINEHEIGHT 8 #define SLIDER_RANGE 10 #define SLIDER_WIDTH (8*SLIDER_RANGE+6) -#define SERVERS_PER_PAGE 11 +#define SERVERS_PER_PAGE 10 #define MAXSTAT 9 //Max number a stat can have typedef enum @@ -182,6 +183,8 @@ static char joystickInfo[8][29]; static UINT32 serverlistpage; static UINT32 oldserverlistpage; static float serverlistslidex; +static INT32 serverlistsearched[MAXSERVERLIST] = {0}; +static UINT32 serverlistsearchedcount = 0; #endif //static saveinfo_t savegameinfo[MAXSAVEGAMES]; // Extra info about the save games. @@ -210,6 +213,8 @@ static void M_StopMessage(INT32 choice); #ifndef NONET static void M_HandleServerPage(INT32 choice); +static void M_HandleServerSearch(INT32 choice); +static void M_SearchServerList(void); #endif // Prototyping is fun, innit? @@ -1109,11 +1114,11 @@ static menuitem_t MP_PlayerSetupMenu[] = #ifndef NONET static menuitem_t MP_ConnectMenu[] = { - {IT_STRING | IT_CVAR, NULL, "Sort By", &cv_serversort, 4}, - {IT_STRING | IT_KEYHANDLER, NULL, "Page", M_HandleServerPage, 12}, - {IT_STRING | IT_CALL, NULL, "Refresh", M_Refresh, 20}, + {IT_STRING | IT_KEYHANDLER, NULL, "", M_HandleServerSearch,0}, + {IT_STRING | IT_CVAR, NULL, "Sort By", &cv_serversort, 16}, + {IT_STRING | IT_KEYHANDLER, NULL, "Page", M_HandleServerPage, 24}, + {IT_STRING | IT_CALL, NULL, "Refresh", M_Refresh, 32}, - {IT_STRING | IT_SPACE, NULL, "", M_Connect, 36}, {IT_STRING | IT_SPACE, NULL, "", M_Connect, 48}, {IT_STRING | IT_SPACE, NULL, "", M_Connect, 60}, {IT_STRING | IT_SPACE, NULL, "", M_Connect, 72}, @@ -1128,6 +1133,7 @@ static menuitem_t MP_ConnectMenu[] = enum { + mp_connect_search, mp_connect_sort, mp_connect_page, mp_connect_refresh, @@ -1521,6 +1527,7 @@ enum //op_exp_dirlight, op_exp_skybox, op_exp_accuratefps, + op_exp_votescrn, #ifdef HWRENDER op_exp_glscrtx, #ifdef USE_FBO_OGL @@ -2323,44 +2330,46 @@ static menuitem_t OP_SaturnHudMenu[] = { {IT_HEADER, NULL, "Saturn Hud Options", NULL, 0}, - {IT_STRING | IT_CVAR, NULL, "Speedometer Style", &cv_newspeedometer, 10}, - {IT_STRING | IT_CVAR, NULL, "Battle Speedometer", &cv_battlespeedo, 15}, + {IT_STRING|IT_CVAR, NULL, "Speedometer Style", &cv_newspeedometer, 10}, + {IT_STRING|IT_CVAR, NULL, "Battle Speedometer", &cv_battlespeedo, 15}, - {IT_STRING | IT_CVAR, NULL, "Colourized HUD", &cv_colorizedhud, 25}, - {IT_STRING | IT_CVAR, NULL, "Colourized Itembox", &cv_colorizeditembox, 30}, - {IT_STRING | IT_CVAR, NULL, "Colourized HUD Color", &cv_colorizedhudcolor, 35}, + {IT_STRING|IT_CVAR, NULL, "Colourized HUD", &cv_colorizedhud, 25}, + {IT_STRING|IT_CVAR, NULL, "Colourized Itembox", &cv_colorizeditembox, 30}, + {IT_STRING|IT_CVAR, NULL, "Colourized HUD Color", &cv_colorizedhudcolor, 35}, - {IT_STRING | IT_CVAR, NULL, "Input Display", &cv_showinput, 45}, + {IT_STRING|IT_CVAR, NULL, "Input Display", &cv_showinput, 45}, - {IT_STRING | IT_CVAR, NULL, "Stat Display", &cv_showstats, 55}, + {IT_STRING|IT_CVAR, NULL, "Stat Display", &cv_showstats, 55}, - {IT_STRING | IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 65}, + {IT_STRING|IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 65}, - {IT_STRING | IT_CVAR, NULL, "Small Positionnumber", &cv_smallposnum, 75}, - {IT_STRING | IT_CVAR, NULL, "Positionnumber Animation", &cv_posanim, 80}, + {IT_STRING|IT_CVAR, NULL, "Small Positionnumber", &cv_smallposnum, 75}, + {IT_STRING|IT_CVAR, NULL, "Positionnumber Animation", &cv_posanim, 80}, - {IT_STRING | IT_CVAR, NULL, "Flash Lap Times", &cv_showlaptimes, 90}, + {IT_STRING|IT_CVAR, NULL, "Flash Lap Times", &cv_showlaptimes, 90}, - {IT_STRING | IT_CVAR, NULL, "Multi-Item icons", &cv_multiitemicon, 100}, - {IT_STRING | IT_CVAR, NULL, "Item Amount Number", &cv_huditemamount, 105}, - {IT_STRING | IT_CVAR, NULL, "Animated Roulette", &cv_fancyroulette, 110}, + {IT_STRING|IT_CVAR, NULL, "Multi-Item icons", &cv_multiitemicon, 100}, + {IT_STRING|IT_CVAR, NULL, "Item Amount Number", &cv_huditemamount, 105}, + {IT_STRING|IT_CVAR, NULL, "Animated Roulette", &cv_fancyroulette, 110}, - {IT_STRING | IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 120}, - {IT_STRING | IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 125}, + {IT_STRING|IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 120}, + {IT_STRING|IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 125}, - {IT_STRING | IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 135}, - {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 140}, - {IT_STRING | IT_CVAR, NULL, "Spin Minimap Icons", &cv_spinoutroll, 145}, - {IT_STRING | IT_CVAR, NULL, "Player Angle Visual", &cv_showminimapangle, 150}, + {IT_STRING|IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 135}, + {IT_STRING|IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 140}, + {IT_STRING|IT_CVAR, NULL, "Spin Minimap Icons", &cv_spinoutroll, 145}, + {IT_STRING|IT_CVAR, NULL, "Player Angle Visual", &cv_showminimapangle, 150}, - {IT_STRING | IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 160}, + {IT_STRING|IT_CVAR, NULL, "Music Credits", &cv_songcredits, 160}, - {IT_STRING | IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 170}, + {IT_STRING|IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 170}, - {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 180}, - {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 185}, + {IT_STRING|IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 180}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 195}, + {IT_STRING|IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 190}, + {IT_STRING|IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 195}, + + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 205}, }; static const char* OP_SaturnHudTooltips[] = @@ -2386,6 +2395,7 @@ static const char* OP_SaturnHudTooltips[] = "Minimize the player icons on the minimap.", "Erratically rotate player icons during spinouts.", "Visualize the player facing angle.", + "Show the Music Credits and which style.", "Make the Intermission screen look like in beta versions of Kart!\nEither with background or just the rest.", "Show the Director Toggle prompt when spectating.", "Nametag Options.", @@ -2416,6 +2426,7 @@ enum sh_smallmap, sh_iconspinout, sh_minidot, + sh_songcred, sh_betainter, sh_directorhud, sh_nametagmen, @@ -2466,9 +2477,13 @@ static menuitem_t OP_HudOffsetMenu[] = {IT_STRING | IT_CVAR, NULL, "Vertical Offset", &cv_stat_yoffset, 185}, }; +// FIXME: WE EFFECTIVELY HAVE NO MORE SPACE FOR GREEN RES +// i had to put multiple names into single lines at this point +// we ought to really do something better for this at this point +// absolutely crazy how many people put work into this at this point <3 static menuitem_t OP_SaturnCreditsMenu[] = { - {IT_HEADER, NULL, "Thanks to all contributers <3", NULL, 0}, + {IT_HEADER, NULL, "Thanks to all contributers <3", NULL, 0}, {IT_STRING2+IT_SPACE, NULL, "Alug", NULL, 10}, {IT_STRING2+IT_SPACE, NULL, "Indev", NULL, 20}, @@ -2477,20 +2492,21 @@ static menuitem_t OP_SaturnCreditsMenu[] = {IT_STRING2+IT_SPACE, NULL, "GenericHeroGuy", NULL, 50}, {IT_STRING2+IT_SPACE, NULL, "xyzzy", NULL, 60}, {IT_STRING2+IT_SPACE, NULL, "Chearii", NULL, 70}, + {IT_STRING2+IT_SPACE, NULL, "riomccloud", NULL, 80}, + {IT_STRING2+IT_SPACE, NULL, "chromaticpipe", NULL, 90}, + {IT_STRING2+IT_SPACE, NULL, "PAS", NULL, 100}, + {IT_STRING2+IT_SPACE, NULL, "$HOME", NULL, 110}, + {IT_STRING2+IT_SPACE, NULL, "Achii", NULL, 120}, + {IT_STRING2+IT_SPACE, NULL, "Anonimus", NULL, 130}, + {IT_STRING2+IT_SPACE, NULL, "scizor300", NULL, 140}, + {IT_STRING2+IT_SPACE, NULL, "Lugent", NULL, 150}, - {IT_STRING2+IT_SPACE, NULL, "Sunflower", NULL, 80}, - {IT_STRING2+IT_SPACE, NULL, "Yuz", NULL, 90}, - {IT_STRING2+IT_SPACE, NULL, "Democrab", NULL, 100}, - {IT_STRING2+IT_SPACE, NULL, "EXpand", NULL, 110}, - {IT_STRING2+IT_SPACE, NULL, "Nexit", NULL, 120}, - {IT_STRING2+IT_SPACE, NULL, "Spee", NULL, 130}, - {IT_STRING2+IT_SPACE, NULL, "jin", NULL, 140}, - {IT_STRING2+IT_SPACE, NULL, "riomccloud", NULL, 150}, - {IT_STRING2+IT_SPACE, NULL, "chromaticpipe", NULL, 160}, - {IT_STRING2+IT_SPACE, NULL, "Achii", NULL, 170}, - {IT_STRING2+IT_SPACE, NULL, "Anonimus", NULL, 180}, - {IT_STRING2+IT_SPACE, NULL, "scizor300", NULL, 190}, - {IT_STRING2+IT_SPACE, NULL, "Lugent", NULL, 200}, + {IT_HEADER, NULL, "", NULL, 124}, + + {IT_STRING2+IT_SPACE, NULL, "Sunflower Yuz", NULL, 180}, + {IT_STRING2+IT_SPACE, NULL, "Democrab EXpand", NULL, 190}, + {IT_STRING2+IT_SPACE, NULL, "Nexit Spee", NULL, 200}, + {IT_STRING2+IT_SPACE, NULL, "jin", NULL, 210}, {IT_HEADER, NULL, "Special Thanks <3", NULL, 168}, @@ -2502,7 +2518,7 @@ static menuitem_t OP_SaturnCreditsMenu[] = {IT_STRING, NULL, "", NULL, 258}, // dummy text II }; -// sry we dont have space for this anymore :/ +// sry we dont have space for this anymore :c /*static const char* OP_CreditTooltips[] = { NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, @@ -2726,7 +2742,7 @@ menu_t MISC_AddonsDef = 50, 28, 0, NULL, - {NULL} + NULL }; menu_t MISC_ReplayHutDef = @@ -2739,7 +2755,7 @@ menu_t MISC_ReplayHutDef = 30, 80, 0, M_QuitReplayHut, - {NULL} + NULL }; menu_t MISC_ReplayOptionsDef = @@ -2752,7 +2768,7 @@ menu_t MISC_ReplayOptionsDef = 27, 40, 0, NULL, - {NULL} + NULL }; menu_t MISC_ReplayStartDef = @@ -2765,7 +2781,7 @@ menu_t MISC_ReplayStartDef = 30, 90, 0, NULL, - {NULL} + NULL }; menu_t PlaybackMenuDef = { @@ -2778,12 +2794,12 @@ menu_t PlaybackMenuDef = { BASEVIDWIDTH/2 - 88, 2, 0, NULL, - {NULL} + NULL }; menu_t MAPauseDef = PAUSEMENUSTYLE(MAPauseMenu, 40, 72); -menu_t SPauseDef = PAUSEMENUSTYLE(SPauseMenu, 40, 72); -menu_t MPauseDef = PAUSEMENUSTYLE(MPauseMenu, 40, 72); +menu_t SPauseDef = PAUSEMENUSTYLE(SPauseMenu, 40, 72); +menu_t MPauseDef = PAUSEMENUSTYLE(MPauseMenu, 40, 72); #ifdef HAVE_DISCORDRPC menu_t MISC_DiscordRequestsDef = { @@ -2795,16 +2811,16 @@ menu_t MISC_DiscordRequestsDef = { 0, 0, 0, NULL, - {NULL} + NULL }; #endif // Misc Main Menu -menu_t MISC_ScrambleTeamDef = DEFAULTMENUSTYLE(NULL, MISC_ScrambleTeamMenu, &MPauseDef, 27, 40); -menu_t MISC_ChangeTeamDef = DEFAULTMENUSTYLE(NULL, MISC_ChangeTeamMenu, &MPauseDef, 27, 40); -menu_t MISC_ChangeSpectateDef = DEFAULTMENUSTYLE(NULL, MISC_ChangeSpectateMenu, &MPauseDef, 27, 40); -menu_t MISC_ChangeLevelDef = MAPICONMENUSTYLE(NULL, MISC_ChangeLevelMenu, &MPauseDef); -menu_t MISC_HelpDef = IMAGEDEF(MISC_HelpMenu); +menu_t MISC_ScrambleTeamDef = DEFAULTMENUSTYLE(NULL, MISC_ScrambleTeamMenu, &MPauseDef, 27, 40, NULL); +menu_t MISC_ChangeTeamDef = DEFAULTMENUSTYLE(NULL, MISC_ChangeTeamMenu, &MPauseDef, 27, 40, NULL); +menu_t MISC_ChangeSpectateDef = DEFAULTMENUSTYLE(NULL, MISC_ChangeSpectateMenu, &MPauseDef, 27, 40, NULL); +menu_t MISC_ChangeLevelDef = MAPICONMENUSTYLE(NULL, MISC_ChangeLevelMenu, &MPauseDef); +menu_t MISC_HelpDef = IMAGEDEF(MISC_HelpMenu); // // M_GetGametypeColor @@ -2891,7 +2907,7 @@ menu_t SR_PandoraDef = 60, 40, 0, M_ExitPandorasBox, - {NULL} + NULL }; menu_t SR_MainDef = CENTERMENUSTYLE(NULL, SR_MainMenu, &MainDef, 72); @@ -2907,7 +2923,7 @@ menu_t SR_UnlockChecklistDef = 280, 185, 0, NULL, - {NULL} + NULL }; menu_t SR_MusicTestDef = @@ -2920,7 +2936,7 @@ menu_t SR_MusicTestDef = 60, 150, 0, NULL, - {NULL} + NULL }; menu_t SR_EmblemHintDef = @@ -2933,7 +2949,7 @@ menu_t SR_EmblemHintDef = 60, 150, 0, NULL, - {NULL} + NULL }; // Single Player @@ -2949,7 +2965,7 @@ menu_t SP_LevelStatsDef = 280, 185, 0, NULL, - {NULL} + NULL }; static menu_t SP_TimeAttackDef = @@ -2962,7 +2978,7 @@ static menu_t SP_TimeAttackDef = 34, 40, 0, M_QuitTimeAttackMenu, - {NULL} + NULL }; static menu_t SP_ReplayDef = { @@ -2974,7 +2990,7 @@ static menu_t SP_ReplayDef = 34, 40, 0, NULL, - {NULL} + NULL }; static menu_t SP_GuestReplayDef = { @@ -2986,7 +3002,7 @@ static menu_t SP_GuestReplayDef = 34, 40, 0, NULL, - {NULL} + NULL }; static menu_t SP_GhostDef = { @@ -2998,7 +3014,7 @@ static menu_t SP_GhostDef = 34, 40, 0, NULL, - {NULL} + NULL }; // Multiplayer @@ -3016,7 +3032,7 @@ menu_t MP_MainDef = #else NULL, #endif - {NULL} + NULL }; menu_t MP_OfflineServerDef = MAPICONMENUSTYLE("M_MULTI", MP_OfflineServerMenu, &MP_MainDef); @@ -3034,7 +3050,7 @@ menu_t MP_ConnectDef = 27,24, 0, M_CancelConnect, - {NULL} + NULL }; #endif menu_t MP_PlayerSetupDef = @@ -3047,7 +3063,7 @@ menu_t MP_PlayerSetupDef = 36, 14, 0, M_QuitMultiPlayerMenu, - {NULL} + NULL }; // Options @@ -3061,18 +3077,18 @@ menu_t OP_MainDef = 60, 25, 0, NULL, - {NULL} + NULL }; -menu_t OP_ControlsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_ControlsMenu, &OP_MainDef, 60, 30); +menu_t OP_ControlsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_ControlsMenu, &OP_MainDef, 60, 30, OP_ControlsTooltips); //WTF -menu_t OP_MouseOptionsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_MouseOptionsMenu, &OP_ControlsDef, 60, 30); -menu_t OP_AllControlsDef = CONTROLMENUSTYLE(OP_AllControlsMenu, &OP_ControlsDef); -menu_t OP_Joystick1Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick1Menu, &OP_AllControlsDef, 30, 36); -menu_t OP_Joystick2Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick2Menu, &OP_AllControlsDef, 30, 36); -menu_t OP_Joystick3Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick3Menu, &OP_AllControlsDef, 30, 36); -menu_t OP_Joystick4Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick4Menu, &OP_AllControlsDef, 30, 36); -menu_t OP_JoystickSetDef = +menu_t OP_MouseOptionsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_MouseOptionsMenu, &OP_ControlsDef, 60, 30, OP_MouseTooltips); +menu_t OP_AllControlsDef = CONTROLMENUSTYLE(OP_AllControlsMenu, &OP_ControlsDef); +menu_t OP_Joystick1Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick1Menu, &OP_AllControlsDef, 30, 36, NULL); +menu_t OP_Joystick2Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick2Menu, &OP_AllControlsDef, 30, 36, NULL); +menu_t OP_Joystick3Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick3Menu, &OP_AllControlsDef, 30, 36, NULL); +menu_t OP_Joystick4Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick4Menu, &OP_AllControlsDef, 30, 36, NULL); +menu_t OP_JoystickSetDef = { "M_CONTRO", sizeof (OP_JoystickSetMenu)/sizeof (menuitem_t), @@ -3082,7 +3098,7 @@ menu_t OP_JoystickSetDef = 50, 40, 0, NULL, - {NULL} + NULL }; menu_t OP_VideoOptionsDef = @@ -3095,7 +3111,7 @@ menu_t OP_VideoOptionsDef = 30, 15, 0, NULL, - {NULL} + OP_VideoTooltips }; menu_t OP_VideoModeDef = @@ -3108,7 +3124,7 @@ menu_t OP_VideoModeDef = 48, 26, 0, NULL, - {NULL} + NULL }; menu_t OP_ColorOptionsDef = @@ -3121,7 +3137,7 @@ menu_t OP_ColorOptionsDef = 30, 30, 0, NULL, - {NULL} + NULL }; menu_t OP_SoundOptionsDef = @@ -3134,7 +3150,7 @@ menu_t OP_SoundOptionsDef = 30, 20, 0, NULL, - {NULL} + OP_SoundTooltips }; @@ -3148,25 +3164,25 @@ menu_t OP_HUDOptionsDef = 30, 20, 0, NULL, - {NULL} + NULL }; -menu_t OP_CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_CamOptionsMenu, &OP_MainDef, 30, 30); -menu_t OP_Player1CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player1CamOptionsMenu, &OP_CamOptionsDef, 30, 30); -menu_t OP_Player2CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player2CamOptionsMenu, &OP_CamOptionsDef, 30, 30); -menu_t OP_Player3CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player3CamOptionsMenu, &OP_CamOptionsDef, 30, 30); -menu_t OP_Player4CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player4CamOptionsMenu, &OP_CamOptionsDef, 30, 30); +menu_t OP_CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_CamOptionsMenu, &OP_MainDef, 30, 30, OP_CamOptionsTooltips); +menu_t OP_Player1CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player1CamOptionsMenu, &OP_CamOptionsDef, 30, 30, OP_PlayerCamOptionsTooltips); +menu_t OP_Player2CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player2CamOptionsMenu, &OP_CamOptionsDef, 30, 30, OP_PlayerCamOptionsTooltips); +menu_t OP_Player3CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player3CamOptionsMenu, &OP_CamOptionsDef, 30, 30, OP_PlayerCamOptionsTooltips); +menu_t OP_Player4CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player4CamOptionsMenu, &OP_CamOptionsDef, 30, 30, OP_PlayerCamOptionsTooltips); -menu_t OP_ChatOptionsDef = DEFAULTMENUSTYLE("M_HUD", OP_ChatOptionsMenu, &OP_HUDOptionsDef, 30, 30); +menu_t OP_ChatOptionsDef = DEFAULTMENUSTYLE("M_HUD", OP_ChatOptionsMenu, &OP_HUDOptionsDef, 30, 30, OP_ChatOptionsTooltips); -menu_t OP_SoundAdvancedDef = DEFAULTSCROLLSTYLE("M_SOUND", OP_SoundAdvancedMenu, &OP_SoundOptionsDef, 30, 30); +menu_t OP_SoundAdvancedDef = DEFAULTSCROLLSTYLE("M_SOUND", OP_SoundAdvancedMenu, &OP_SoundOptionsDef, 30, 30, OP_SoundAdvancedTooltips); -menu_t OP_FocusOptionsDef = DEFAULTMENUSTYLE(NULL, OP_FocusOptionsMenu, &OP_MainDef, 17, 30); +menu_t OP_FocusOptionsDef = DEFAULTMENUSTYLE(NULL, OP_FocusOptionsMenu, &OP_MainDef, 17, 30, OP_FocusOptionsTooltips); -menu_t OP_GameOptionsDef = DEFAULTMENUSTYLE("M_GAME", OP_GameOptionsMenu, &OP_MainDef, 30, 20); -menu_t OP_ServerOptionsDef = DEFAULTMENUSTYLE("M_SERVER", OP_ServerOptionsMenu, &OP_MainDef, 24, 20); +menu_t OP_GameOptionsDef = DEFAULTMENUSTYLE("M_GAME", OP_GameOptionsMenu, &OP_MainDef, 30, 20, OP_GameTooltips); +menu_t OP_ServerOptionsDef = DEFAULTMENUSTYLE("M_SERVER", OP_ServerOptionsMenu, &OP_MainDef, 24, 20, OP_ServerOptionsTooltips); #ifndef NONET -menu_t OP_AdvServerOptionsDef = DEFAULTSCROLLSTYLE("M_SERVER", OP_AdvServerOptionsMenu, &OP_ServerOptionsDef, 24, 30); +menu_t OP_AdvServerOptionsDef = DEFAULTSCROLLSTYLE("M_SERVER", OP_AdvServerOptionsMenu, &OP_ServerOptionsDef, 24, 30, OP_AdvServerOptionsTooltips); #endif //menu_t OP_NetgameOptionsDef = DEFAULTMENUSTYLE("M_SERVER", OP_NetgameOptionsMenu, &OP_ServerOptionsDef, 30, 30); @@ -3182,38 +3198,38 @@ menu_t OP_MonitorToggleDef = 47, 30, 0, NULL, - {NULL} + NULL }; #ifdef HWRENDER -menu_t OP_OpenGLOptionsDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_OpenGLOptionsMenu, &OP_VideoOptionsDef, 30, 30); +menu_t OP_OpenGLOptionsDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_OpenGLOptionsMenu, &OP_VideoOptionsDef, 30, 30, OP_OpenGLTooltips); #endif -menu_t OP_ExpOptionsDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_ExpOptionsMenu, &OP_VideoOptionsDef, 30, 25); +menu_t OP_ExpOptionsDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_ExpOptionsMenu, &OP_VideoOptionsDef, 30, 25, OP_ExpTooltips); -menu_t OP_DataOptionsDef = DEFAULTMENUSTYLE("M_DATA", OP_DataOptionsMenu, &OP_MainDef, 60, 30); -menu_t OP_ScreenshotOptionsDef = DEFAULTSCROLLSTYLE("M_SCSHOT", OP_ScreenshotOptionsMenu, &OP_DataOptionsDef, 30, 30); -menu_t OP_AddonsOptionsDef = DEFAULTMENUSTYLE("M_ADDONS", OP_AddonsOptionsMenu, &OP_DataOptionsDef, 30, 30); -menu_t OP_ProtocolDef = DEFAULTMENUSTYLE(NULL, OP_ProtocolMenu, &OP_DataOptionsDef, 30, 30); +menu_t OP_DataOptionsDef = DEFAULTMENUSTYLE("M_DATA", OP_DataOptionsMenu, &OP_MainDef, 60, 30, NULL); +menu_t OP_ScreenshotOptionsDef = DEFAULTSCROLLSTYLE("M_SCSHOT", OP_ScreenshotOptionsMenu, &OP_DataOptionsDef, 30, 30, NULL); +menu_t OP_AddonsOptionsDef = DEFAULTMENUSTYLE("M_ADDONS", OP_AddonsOptionsMenu, &OP_DataOptionsDef, 30, 30, NULL); +menu_t OP_ProtocolDef = DEFAULTMENUSTYLE(NULL, OP_ProtocolMenu, &OP_DataOptionsDef, 30, 30, NULL); #ifdef HAVE_DISCORDRPC -menu_t OP_DiscordOptionsDef = DEFAULTMENUSTYLE(NULL, OP_DiscordOptionsMenu, &OP_DataOptionsDef, 30, 30); +menu_t OP_DiscordOptionsDef = DEFAULTMENUSTYLE(NULL, OP_DiscordOptionsMenu, &OP_DataOptionsDef, 30, 30, NULL); #endif -menu_t OP_EraseDataDef = DEFAULTMENUSTYLE("M_DATA", OP_EraseDataMenu, &OP_DataOptionsDef, 30, 30); +menu_t OP_EraseDataDef = DEFAULTMENUSTYLE("M_DATA", OP_EraseDataMenu, &OP_DataOptionsDef, 30, 30, NULL); -menu_t OP_SaturnDef = DEFAULTSCROLLSTYLE(NULL, OP_SaturnMenu, &OP_MainDef, 30, 30); -menu_t OP_PlayerDistortDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_PlayerDistortMenu, &OP_SaturnDef, 30, 30); -menu_t OP_HudOffsetDef = DEFAULTSCROLLSTYLE(NULL, OP_HudOffsetMenu, &OP_SaturnHudDef, 30, 30); -menu_t OP_SaturnHudDef = DEFAULTSCROLLSTYLE(NULL, OP_SaturnHudMenu, &OP_SaturnDef, 30, 30); +menu_t OP_SaturnDef = DEFAULTSCROLLSTYLE(NULL, OP_SaturnMenu, &OP_MainDef, 30, 30, OP_SaturnTooltips); +menu_t OP_SaturnCreditsDef = DEFAULTMENUSTYLE(NULL, OP_SaturnCreditsMenu, &OP_SaturnDef, 30, 0, NULL); // OP_CreditTooltips no space :c -menu_t OP_SaturnCreditsDef = DEFAULTMENUSTYLE(NULL, OP_SaturnCreditsMenu, &OP_SaturnDef, 30, 0); +menu_t OP_SaturnHudDef = DEFAULTSCROLLSTYLE(NULL, OP_SaturnHudMenu, &OP_SaturnDef, 30, 30, OP_SaturnHudTooltips); +menu_t OP_PlayerDistortDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_PlayerDistortMenu, &OP_SaturnDef, 30, 30, OP_PlayerDistortTooltips); +menu_t OP_HudOffsetDef = DEFAULTSCROLLSTYLE(NULL, OP_HudOffsetMenu, &OP_SaturnHudDef, 30, 30, NULL); -menu_t OP_BirdDef = DEFAULTMENUSTYLE(NULL, OP_BirdMenu, &OP_MainDef, 30, 30); +menu_t OP_BirdDef = DEFAULTMENUSTYLE(NULL, OP_BirdMenu, &OP_MainDef, 30, 30, OP_BirdTooltips); -menu_t OP_NametagDef = DEFAULTMENUSTYLE(NULL, OP_NametagMenu, &OP_SaturnHudDef, 30, 40); -menu_t OP_DriftGaugeDef = DEFAULTMENUSTYLE(NULL, OP_DriftGaugeMenu, &OP_SaturnHudDef, 30, 40); +menu_t OP_NametagDef = DEFAULTMENUSTYLE(NULL, OP_NametagMenu, &OP_SaturnHudDef, 30, 40, OP_NametagTooltips); +menu_t OP_DriftGaugeDef = DEFAULTMENUSTYLE(NULL, OP_DriftGaugeMenu, &OP_SaturnHudDef, 30, 40, OP_DriftGaugeTooltips); -menu_t OP_TiltDef = DEFAULTMENUSTYLE(NULL, OP_TiltMenu, &OP_BirdDef, 30, 60); -menu_t OP_AdvancedBirdDef = DEFAULTMENUSTYLE(NULL, OP_AdvancedBirdMenu, &OP_BirdDef, 30, 60); +menu_t OP_TiltDef = DEFAULTMENUSTYLE(NULL, OP_TiltMenu, &OP_BirdDef, 30, 60, OP_TiltTooltips); +menu_t OP_AdvancedBirdDef = DEFAULTMENUSTYLE(NULL, OP_AdvancedBirdMenu, &OP_BirdDef, 30, 60, OP_AdvancedBirdTooltips); INT16 ccvarposition = 0; @@ -3230,7 +3246,7 @@ static void M_CustomCvarMenu(INT32 choice) /*menu_t OP_CustomCvarMenuDef = DEFAULTSCROLLMENUSTYLE( MTREE3(MN_OP_MAIN, MN_OP_DATA, MN_OP_ADDONS), "M_ADDONS", OP_CustomCvarMenu, &OP_MainDef, 30, 30);*/ -menu_t OP_CustomCvarMenuDef = DEFAULTSCROLLSTYLE("M_ADDONS", OP_CustomCvarMenu, &OP_MainDef, 10, 30); +menu_t OP_CustomCvarMenuDef = DEFAULTSCROLLSTYLE("M_ADDONS", OP_CustomCvarMenu, &OP_MainDef, 10, 30, NULL); menu_t OP_ForkedBirdDef = { NULL, @@ -3241,10 +3257,10 @@ menu_t OP_ForkedBirdDef = { 30, 6, 0, NULL, - {NULL} + NULL }; -menu_t OP_LocalSkinDef = DEFAULTMENUSTYLE(NULL, OP_TiltMenu, &OP_ForkedBirdDef, 30, 60); +menu_t OP_LocalSkinDef = DEFAULTMENUSTYLE(NULL, OP_TiltMenu, &OP_ForkedBirdDef, 30, 60, NULL); // ========================================================================== @@ -4865,6 +4881,9 @@ void M_Init(void) //todo put this somewhere better... CV_RegisterVar(&cv_allcaps); + + memset(menu_text_input_buf, 0, sizeof menu_text_input_buf); + M_TextInputInit(&menuinput, menu_text_input_buf, sizeof menu_text_input_buf); } void M_InitCharacterTables(void) @@ -5181,6 +5200,16 @@ static void M_DrawSplitText(INT32 x, INT32 y, INT32 option, const char* str, INT free(clines); } +static void M_DoToolTips(menu_t* menu) +{ + if (!menu->tooltips || itemOn == -1 || !menu->tooltips[itemOn]) + return; + + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, menu->tooltips[itemOn], coolalphatimer); + + if ((coolalphatimer > 0) && interpTimerHackAllow) + coolalphatimer--; +} static void M_DrawGenericMenu(void) { @@ -5327,23 +5356,7 @@ static void M_DrawGenericMenu(void) // dumb hack // tooltips - // replaced with macro so it doesent look as terrible anymore lol - DoToolTips(OP_ControlsDef, OP_ControlsTooltips); - DoToolTips(OP_MouseOptionsDef, OP_MouseTooltips); - DoToolTips(OP_VideoOptionsDef, OP_VideoTooltips); - DoToolTips(OP_SoundOptionsDef, OP_SoundTooltips); - DoToolTips(OP_FocusOptionsDef, OP_FocusOptionsTooltips); - DoToolTips(OP_ChatOptionsDef, OP_ChatOptionsTooltips); - DoToolTips(OP_GameOptionsDef, OP_GameTooltips); - DoToolTips(OP_ServerOptionsDef, OP_ServerOptionsTooltips); - //DoToolTips(OP_SaturnCreditsDef, OP_CreditTooltips); // C: - DoToolTips(OP_BirdDef, OP_BirdTooltips); - DoToolTips(OP_TiltDef, OP_TiltTooltips); - DoToolTips(OP_AdvancedBirdDef, OP_AdvancedBirdTooltips); - DoToolTips(OP_NametagDef, OP_NametagTooltips); - DoToolTips(OP_DriftGaugeDef, OP_DriftGaugeTooltips); - DoToolTips(OP_CamOptionsDef, OP_CamOptionsTooltips); - DoToolTips(OP_Player1CamOptionsDef || currentMenu == &OP_Player2CamOptionsDef || currentMenu == &OP_Player3CamOptionsDef || currentMenu == &OP_Player4CamOptionsDef, OP_PlayerCamOptionsTooltips); // god this one is still terrible lmao + M_DoToolTips(currentMenu); } static void M_DrawGenericBackgroundMenu(void) @@ -5474,16 +5487,7 @@ static void M_DrawGenericScrollMenu(void) // dumb hack // tooltips - // same macro here - DoToolTips(OP_ExpOptionsDef, OP_ExpTooltips); -#ifdef HWRENDER - DoToolTips(OP_OpenGLOptionsDef, OP_OpenGLTooltips); -#endif - DoToolTips(OP_SaturnDef, OP_SaturnTooltips); - DoToolTips(OP_SaturnHudDef, OP_SaturnHudTooltips); - DoToolTips(OP_AdvServerOptionsDef, OP_AdvServerOptionsTooltips); - DoToolTips(OP_SoundAdvancedDef, OP_SoundAdvancedTooltips); - DoToolTips(OP_PlayerDistortDef, OP_PlayerDistortTooltips); + M_DoToolTips(currentMenu); } static void M_DrawPauseMenu(void) @@ -5717,8 +5721,16 @@ boolean M_CanShowLevelInList(INT32 mapnum, INT32 gt) { case LLM_CREATESERVER: // Should the map be hidden? <-- well imma wanna toggle it, its just annoying being unable to select hell maps in mapselect - if ((mapheaderinfo[mapnum]->menuflags & LF2_HIDEINMENU && mapnum+1 != gamemap) && (gt == GT_RACE && (mapheaderinfo[mapnum]->typeoflevel & TOL_RACE))) // map hell - return cv_showallmaps.value; + + if (mapheaderinfo[mapnum]->menuflags & LF2_HIDEINMENU && mapnum+1 != gamemap) + { + if (cv_showallmaps.value && + ((gt == GT_RACE && (mapheaderinfo[mapnum]->typeoflevel & TOL_RACE)) || // race map hell + ((gt == GT_MATCH || gt == GT_TEAMMATCH) && (mapheaderinfo[mapnum]->typeoflevel & TOL_MATCH)))) // battle map hell + return true; + else + return false; + } // same goes here, just show every map if i want to if (M_MapLocked(mapnum+1)) // not unlocked @@ -5798,7 +5810,7 @@ menu_t MessageDef = 0, 0, // x, y (TO HACK) 0, // lastOn, flags (TO HACK) NULL, - {0}, + NULL, }; @@ -6291,6 +6303,8 @@ static boolean M_AddonsRefresh(void) return false; } +static tic_t addons_scrolltic = 0; // maybe not the best place but e + static void M_DrawAddons(void) { INT32 x, y; @@ -6298,6 +6312,8 @@ static void M_DrawAddons(void) const UINT8 *flashcol = NULL; UINT8 hilicol; + if (renderisnewtic) addons_scrolltic++; + // hack - need to refresh at end of frame to handle addfile... if (refreshdirmenu & M_AddonsRefresh()) { @@ -6381,6 +6397,9 @@ static void M_DrawAddons(void) for (; i < m; i++) { UINT32 flags = V_ALLOWLOWERCASE; +#define MAXADDONNAME 31 + char scrollbuf[MAXADDONNAME+1] = {0}; + if (y > BASEVIDHEIGHT) break; if (dirmenu[i]) #define type (UINT8)(dirmenu[i][DIR_TYPE]) @@ -6401,11 +6420,22 @@ static void M_DrawAddons(void) } #define charsonside 14 - if (dirmenu[i][DIR_LEN] > (charsonside*2 + 3)) - V_DrawString(x, y+4, flags, va("%.*s...%s", charsonside, dirmenu[i]+DIR_STRING, dirmenu[i]+DIR_STRING+dirmenu[i][DIR_LEN]-(charsonside+1))); + if (dirmenu[i][DIR_LEN] > MAXADDONNAME) + { + if ((size_t)i == dir_on[menudepthleft]) + { + M_ScrollString(dirmenu[i]+DIR_STRING, dirmenu[i][DIR_LEN]-1, scrollbuf, MAXADDONNAME, addons_scrolltic); + } + else + strncpy(scrollbuf, va("%.*s...%s", charsonside, dirmenu[i]+DIR_STRING, dirmenu[i]+DIR_STRING+dirmenu[i][DIR_LEN]-(charsonside+1)), MAXADDONNAME); + + V_DrawString(x, y+4, flags, scrollbuf); + } #undef charsonside else V_DrawString(x, y+4, flags, dirmenu[i]+DIR_STRING); + +#undef MAXADDONNAME } #undef type y += 16; @@ -6530,11 +6560,13 @@ static void M_HandleAddons(INT32 choice) case KEY_DOWNARROW: if (dir_on[menudepthleft] < sizedirmenu-1) dir_on[menudepthleft]++; + addons_scrolltic = 0; S_StartSound(NULL, sfx_menu1); break; case KEY_UPARROW: if (dir_on[menudepthleft]) dir_on[menudepthleft]--; + addons_scrolltic = 0; S_StartSound(NULL, sfx_menu1); break; case KEY_PGDN: @@ -6543,6 +6575,7 @@ static void M_HandleAddons(INT32 choice) for (i = numaddonsshown; i && (dir_on[menudepthleft] < sizedirmenu-1); i--) dir_on[menudepthleft]++; } + addons_scrolltic = 0; S_StartSound(NULL, sfx_menu1); break; case KEY_PGUP: @@ -6551,6 +6584,7 @@ static void M_HandleAddons(INT32 choice) for (i = numaddonsshown; i && (dir_on[menudepthleft]); i--) dir_on[menudepthleft]--; } + addons_scrolltic = 0; S_StartSound(NULL, sfx_menu1); break; case KEY_ENTER: @@ -6690,6 +6724,7 @@ static void M_HandleAddons(INT32 choice) case KEY_ESCAPE: exitmenu = true; + addons_scrolltic = 0; break; default: @@ -6862,6 +6897,32 @@ static void M_HutCheckReplays(size_t maxnum) } } +static int ReplayListSortComparator(const void *entry1, const void *entry2) +{ + const menudemo_t *demo1 = (const menudemo_t*)entry1; + const menudemo_t *demo2 = (const menudemo_t*)entry2; + + char filepath1[sizeof(demo1->filepath)]; + char filepath2[sizeof(demo2->filepath)]; + + // First check for directories, they always should be at the top + if (demo1->type == MD_SUBDIR && demo2->type != MD_SUBDIR) + return -1; + else if (demo2->type == MD_SUBDIR && demo1->type != MD_SUBDIR) + return 1; + else if (demo1->type == MD_SUBDIR && demo2->type == MD_SUBDIR) + return 0; + + memcpy(filepath1, demo1->filepath, sizeof(filepath1)); + memcpy(filepath2, demo2->filepath, sizeof(filepath2)); + + nameonly(filepath1); + nameonly(filepath2); + + // Comparing in opposite order to move new replays to the top + return strncmp(filepath2, filepath1, sizeof(filepath1)); +} + static void PrepReplayList(boolean reset) { size_t i; @@ -6905,6 +6966,8 @@ static void PrepReplayList(boolean reset) } } + qs22j(demolist_all, sizedirmenu, sizeof(menudemo_t), ReplayListSortComparator); + Unlock_search_state(); LoadReplayNames(); @@ -8428,56 +8491,11 @@ static musicdef_t *curplaying = NULL; static INT32 st_sel = 0; static tic_t st_musictime = 0; -static void scrollMusicName(const char name[], size_t len, size_t maxlen, char result[]) -{ - // How much should we scroll. Not sure why +1 is needed, but without it this function skips 2 - // characters at once sometimes - const size_t amount = len - maxlen + 1; - - // Note: anything above 17 will cause zero division - const size_t MAXSPEED = 6; - const size_t t = st_musictime / (35/min(amount, MAXSPEED)); - - const size_t state = (t / amount) % 4; - - switch (state) - { - // Show beginning of the name - case 0: - memcpy(result, name, maxlen-1); - break; - - // Scroll towards end of the name - case 1: - { - const size_t advance = t % amount; - memcpy(result, name+advance, maxlen-1); - } - break; - - // Show end of the name - case 2: - memcpy(result, name+len+1-maxlen, maxlen-1); - break; - - // Scroll towards start of the name - case 3: - { - const size_t advance = t % amount; - memcpy(result, name+len+1-maxlen-advance, maxlen-1); - } - break; - } - - // Technically not necessary, since it gets set again after function call, but just in case - result[maxlen] = 0; -} - static void M_MusicTest(INT32 choice) { (void)choice; - if (!S_PrepareSoundTest()) + if (!nummusicdefs) { M_StartMessage(M_GetText("No selectable tracks found.\n"),NULL,MM_NOTHING); return; @@ -8556,33 +8574,33 @@ static void M_DrawMusicTest(void) { INT32 t, b, q, m = 128; - if (numsoundtestdefs <= 8) + if (nummusicdefs <= 8) { t = 0; - b = numsoundtestdefs - 1; + b = nummusicdefs - 1; i = 0; } else { q = m; - m = (5*m)/numsoundtestdefs; + m = (5*m)/nummusicdefs; if (st_sel < 3) { t = 0; b = 7; i = 0; } - else if (st_sel >= numsoundtestdefs-4) + else if (st_sel >= nummusicdefs-4) { - t = numsoundtestdefs - 8; - b = numsoundtestdefs - 1; + t = nummusicdefs - 8; + b = nummusicdefs - 1; i = q-m; } else { t = st_sel - 3; b = st_sel + 4; - i = (t * (q-m))/(numsoundtestdefs - 8); + i = (t * (q-m))/(nummusicdefs - 8); } } @@ -8591,7 +8609,7 @@ static void M_DrawMusicTest(void) if (t != 0) V_DrawString(20+280+4, 60+4 - (skullAnimCounter/5), V_YELLOWMAP, "\x1A"); - if (b != numsoundtestdefs - 1) + if (b != nummusicdefs - 1) V_DrawString(20+280+4, 60+128-12 + (skullAnimCounter/5), V_YELLOWMAP, "\x1B"); x = 24; @@ -8605,21 +8623,22 @@ static void M_DrawMusicTest(void) V_DrawFill(20, y-4, 280-1, 16, 237); { + const musicdef_t *def = S_GetMusicCredit(t); const size_t MAXLENGTH = 34; - const char *songname = soundtestdefs[t]->title[0] ? soundtestdefs[t]->title : soundtestdefs[t]->source; + const char *songname = def->title[0] ? def->title : def->source; size_t namelength = strlen(songname); char buf[MAXLENGTH+1]; if (t == st_sel && namelength > MAXLENGTH) - scrollMusicName(songname, namelength, MAXLENGTH, buf); + M_ScrollString(songname, namelength, buf, MAXLENGTH, st_musictime); else strncpy(buf, songname, MAXLENGTH); buf[MAXLENGTH] = 0; V_DrawString(x, y, (t == st_sel ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE|V_MONOSPACE, buf); - if (curplaying == soundtestdefs[t]) + if (curplaying == def) { V_DrawFill(20+280-9, y-4, 8, 16, 230); } @@ -8637,7 +8656,7 @@ static void M_HandleMusicTest(INT32 choice) switch (choice) { case KEY_DOWNARROW: - if (st_sel++ >= numsoundtestdefs-1) + if (st_sel++ >= nummusicdefs-1) st_sel = 0; { S_StartSound(NULL, sfx_menu1); @@ -8646,18 +8665,18 @@ static void M_HandleMusicTest(INT32 choice) break; case KEY_UPARROW: if (!st_sel--) - st_sel = numsoundtestdefs-1; + st_sel = nummusicdefs-1; { S_StartSound(NULL, sfx_menu1); } st_musictime = 0; break; case KEY_PGDN: - if (st_sel < numsoundtestdefs-1) + if (st_sel < nummusicdefs-1) { st_sel += 3; - if (st_sel >= numsoundtestdefs-1) - st_sel = numsoundtestdefs-1; + if (st_sel >= nummusicdefs-1) + st_sel = nummusicdefs-1; S_StartSound(NULL, sfx_menu1); } st_musictime = 0; @@ -8691,7 +8710,7 @@ static void M_HandleMusicTest(INT32 choice) case KEY_ENTER: S_StopSounds(); S_StopMusic(); - curplaying = soundtestdefs[st_sel]; + curplaying = S_GetMusicCredit(st_sel); S_ChangeMusicInternal(curplaying->name, true); break; @@ -8700,9 +8719,6 @@ static void M_HandleMusicTest(INT32 choice) } if (exitmenu) { - Z_Free(soundtestdefs); - soundtestdefs = NULL; - if (currentMenu->prevMenu) M_SetupNextMenu(currentMenu->prevMenu); else @@ -9593,7 +9609,7 @@ Fetch_servers_thread (int *id) } #endif/*MASTERSERVER*/ -#define SERVERHEADERHEIGHT 36 +#define SERVERHEADERHEIGHT 48 #define SERVERLINEHEIGHT 12 #define S_LINEY(n) currentMenu->y + SERVERHEADERHEIGHT + (n * SERVERLINEHEIGHT) @@ -9601,6 +9617,57 @@ Fetch_servers_thread (int *id) #ifndef NONET static UINT32 localservercount; +static void M_SearchServerList(void) +{ + char servername[MAXSERVERNAME+1] = {0}; + serverlistsearchedcount = 0; + + for (UINT32 i = 0; i < serverlistcount; ++i) + { + StripColors(servername, serverlist[i].info.servername, MAXSERVERNAME); + if (menuinput.length == 0 || strcasestr(servername, menuinput.buffer) != NULL) + serverlistsearched[serverlistsearchedcount++] = i; + } + + if (menuinput.length > 0) + serverlistpage = 0; +} + +static void M_HandleServerSearch(INT32 choice) +{ + boolean exitmenu = false; // exit to previous menu + + switch (choice) + { + case KEY_DOWNARROW: + M_NextOpt(); + S_StartSound(NULL, sfx_menu1); + break; + case KEY_UPARROW: + M_PrevOpt(); + S_StartSound(NULL, sfx_menu1); + break; + case KEY_ESCAPE: + exitmenu = true; + break; + + default: + if (M_TextInputHandle(&menuinput, choice)) + { + S_StartSound(NULL, sfx_menu1); + M_SearchServerList(); + } + break; + } + if (exitmenu) + { + if (currentMenu->prevMenu) + M_SetupNextMenu(currentMenu->prevMenu); + else + M_ClearMenus(true); + } +} + static void M_HandleServerPage(INT32 choice) { boolean exitmenu = false; // exit to previous menu @@ -9623,7 +9690,7 @@ static void M_HandleServerPage(INT32 choice) case KEY_ENTER: case KEY_RIGHTARROW: S_StartSound(NULL, sfx_menu1); - if ((serverlistpage + 1) * SERVERS_PER_PAGE < serverlistcount) + if ((serverlistpage + 1) * SERVERS_PER_PAGE < serverlistsearchedcount) { oldserverlistpage = serverlistpage++; serverlistslidex = BASEVIDWIDTH; @@ -9654,7 +9721,7 @@ static void M_Connect(INT32 choice) { // do not call menuexitfunc M_ClearMenus(false); - COM_BufAddText(va("connect node %d\n", serverlist[choice-FIRSTSERVERLINE + serverlistpage * SERVERS_PER_PAGE].node)); + COM_BufAddText(va("connect node %d\n", serverlist[serverlistsearched[choice-FIRSTSERVERLINE + serverlistpage * SERVERS_PER_PAGE]].node)); } static void M_Refresh(INT32 choice) @@ -9712,11 +9779,11 @@ static void M_DrawServerCountAndHorizontalBar(void) radius = V_StringWidth(text, 0) / 2; - V_DrawCenteredString(center, currentMenu->y+28, 0, text); + V_DrawCenteredString(center, currentMenu->y+40, 0, text); // Horizontal line! - V_DrawFill(1, currentMenu->y+32, center - radius - 2, 1, 0); - V_DrawFill(center + radius + 2, currentMenu->y+32, BASEVIDWIDTH - 1, 1, 0); + V_DrawFill(1, currentMenu->y+44, center - radius - 2, 1, 0); + V_DrawFill(center + radius + 2, currentMenu->y+44, BASEVIDWIDTH - 1, 1, 0); } #endif @@ -9726,9 +9793,9 @@ static void M_DrawServerLines(INT32 x, INT32 page) const char *gt = "Unknown"; const char *spd = ""; - for (i = 0; i < min(serverlistcount - page * SERVERS_PER_PAGE, SERVERS_PER_PAGE); i++) + for (i = 0; i < min(serverlistsearchedcount - page * SERVERS_PER_PAGE, SERVERS_PER_PAGE); i++) { - INT32 slindex = i + page * SERVERS_PER_PAGE; + INT32 slindex = serverlistsearched[i + page * SERVERS_PER_PAGE]; UINT32 globalflags = ((serverlist[slindex].info.numberofplayer >= serverlist[slindex].info.maxplayer) ? V_TRANSLUCENT : 0) |((itemOn == FIRSTSERVERLINE+i) ? highlightflags : 0)|V_ALLOWLOWERCASE; @@ -9767,7 +9834,7 @@ static void M_DrawServerLines(INT32 x, INT32 page) static void M_DrawConnectMenu(void) { UINT16 i; - INT32 numPages = (serverlistcount+(SERVERS_PER_PAGE-1))/SERVERS_PER_PAGE; + INT32 numPages = (serverlistsearchedcount+(SERVERS_PER_PAGE-1))/SERVERS_PER_PAGE; INT32 mservflags = V_ALLOWLOWERCASE; for (i = FIRSTSERVERLINE; i < min(localservercount, SERVERS_PER_PAGE)+FIRSTSERVERLINE; i++) @@ -9817,6 +9884,16 @@ static void M_DrawConnectMenu(void) M_DrawServerLines(currentMenu->x, serverlistpage); } + V_DrawFill(currentMenu->x, currentMenu->y, MAXSTRINGLENGTH*8+6, 8+6, 239); + + const INT32 xoff = 3, yoff = 3; + + + if (itemOn != 0) + V_DrawString(currentMenu->x+xoff, currentMenu->y+yoff, V_ALLOWLOWERCASE, menuinput.buffer); + else + M_DrawTextInput(currentMenu->x+xoff, currentMenu->y+yoff, &menuinput, 0); + localservercount = serverlistcount; M_DrawGenericMenu(); @@ -9896,6 +9973,7 @@ void M_SortServerList(void) qs22j(serverlist, serverlistcount, sizeof(serverelem_t), ServerListEntryComparator_gametype); break; } + M_SearchServerList(); #endif } @@ -9954,6 +10032,9 @@ static void M_ConnectMenu(INT32 choice) CL_UpdateServerList(); + // Reset + M_TextInputSetString(&menuinput, ""); + M_SetupNextMenu(&MP_ConnectDef); itemOn = 0; @@ -10209,17 +10290,28 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) if (cv_nextmap.value && cv_showtrackaddon.value) { + static tic_t namescroll = 0; + static INT32 namescrollmap = 0; + char namescrollbuf[64]= {0}; + + if (cv_nextmap.value != namescrollmap) + { + namescrollmap = cv_nextmap.value; + namescroll = 0; + } + + if (renderisnewtic) namescroll++; + char *addonname = wadfiles[mapwads[cv_nextmap.value-1]]->filename; INT32 len; - INT32 charlimit = 21 + (dupadjust/5); + INT32 charlimit = min((size_t)(21 + (dupadjust/5)), sizeof(namescrollbuf)-1); nameonly(addonname); len = strlen(addonname); -#define charsonside 14 if (len > charlimit) - V_DrawThinString(x+w+5, y+i-8, V_TRANSLUCENT|MENUCAPS, va("%.*s...%s", charsonside, addonname, addonname+((len-charlimit) + charsonside))); // variable reuse... -#undef charsonside + M_ScrollString(addonname, len, namescrollbuf, charlimit, namescroll); else - V_DrawThinString(x+w+5, y+i-8, V_TRANSLUCENT|MENUCAPS, addonname); // variable reuse... + strncpy(namescrollbuf, addonname, sizeof(namescrollbuf)); + V_DrawThinString(x+w+5, y+i-8, V_TRANSLUCENT|MENUCAPS, namescrollbuf); // variable reuse... } if (!cv_kartencore.value || gamestate == GS_TIMEATTACK || cv_newgametype.value != GT_RACE) diff --git a/src/m_menu.h b/src/m_menu.h index 126d59e1b..06e0273fe 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -15,6 +15,11 @@ #ifndef __X_MENU__ #define __X_MENU__ +#ifdef __cplusplus +extern "C" { +#endif + +#include "r_skins.h" #include "d_event.h" #include "command.h" #include "i_threads.h" @@ -207,14 +212,14 @@ extern menuitem_t PlayerMenu[MAXSKINS]; typedef struct menu_s { const char *menutitlepic; - INT16 numitems; // # of menu items - struct menu_s *prevMenu; // previous menu - menuitem_t *menuitems; // menu items - void (*drawroutine)(void); // draw routine - INT16 x, y; // x, y of menu - INT16 lastOn; // last item user was on in menu - boolean (*quitroutine)(void); // called before quit a menu return true if we can - const char* tooltips[MAXTOOLTIPS]; // tooltips! give me that info bitch + INT16 numitems; // # of menu items + struct menu_s *prevMenu; // previous menu + menuitem_t *menuitems; // menu items + void (*drawroutine)(void); // draw routine + INT16 x, y; // x, y of menu + INT16 lastOn; // last item user was on in menu + boolean (*quitroutine)(void); // called before quit a menu return true if we can + const char* *tooltips; // tooltips! give me that info bitch } menu_t; void M_SetupNextMenu(menu_t *menudef); @@ -330,7 +335,7 @@ void M_PopupMasterServerConnectError(void); void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* name); // These defines make it a little easier to make menus -#define DEFAULTMENUSTYLE(header, source, prev, x, y)\ +#define DEFAULTMENUSTYLE(header, source, prev, x, y, tooltip)\ {\ header,\ sizeof(source)/sizeof(menuitem_t),\ @@ -340,10 +345,10 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na x, y,\ 0,\ NULL,\ - {NULL}\ + tooltip\ } -#define DEFAULTSCROLLSTYLE(header, source, prev, x, y)\ +#define DEFAULTSCROLLSTYLE(header, source, prev, x, y, tooltip)\ {\ header,\ sizeof(source)/sizeof(menuitem_t),\ @@ -353,7 +358,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na x, y,\ 0,\ NULL,\ - {NULL}\ + tooltip\ } @@ -367,7 +372,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na x, y,\ 0,\ NULL,\ - {NULL}\ + NULL\ } #define CENTERMENUSTYLE(header, source, prev, y)\ @@ -380,7 +385,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na BASEVIDWIDTH/2, y,\ 0,\ NULL,\ - {NULL}\ + NULL\ } #define MAPICONMENUSTYLE(header, source, prev)\ @@ -393,7 +398,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na 24,40,\ 0,\ NULL,\ - {NULL}\ + NULL\ } #define CONTROLMENUSTYLE(source, prev)\ @@ -406,7 +411,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na 26, 40,\ 0,\ NULL,\ - {NULL}\ + NULL\ } #define IMAGEDEF(source)\ @@ -419,18 +424,11 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na 0, 0,\ 0,\ NULL,\ - {NULL}\ + NULL\ } -#define DoToolTips(menu, tooltip)\ -if (currentMenu == &menu)\ -{\ - if (!(tooltip[itemOn] == NULL))\ - {\ - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, tooltip[itemOn], coolalphatimer);\ - if (coolalphatimer > 0 && interpTimerHackAllow)\ - coolalphatimer--;\ - }\ -} +#ifdef __cplusplus +} // extern "C" +#endif #endif //__X_MENU__ diff --git a/src/m_misc.c b/src/m_misc.c index 8a68e25cb..df860c92e 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -14,6 +14,10 @@ #ifdef __GNUC__ +#ifdef __cplusplus +extern "C" { +#endif + #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) // Ignore "argument might be clobbered by longjmp" warning in GCC // (if libpng is compiled with setjmp error handling) @@ -1060,7 +1064,7 @@ static boolean M_SetupaPNG(png_const_charp filename, png_bytep pal) png_init_io(apng_ptr, apng_FILE); #ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_set_user_limits(apng_ptr, MAXPNGWIDTH, MAXPNGHEIGHT); + png_set_user_limits(apng_ptr, MAXVIDWIDTH, MAXVIDHEIGHT); #endif //png_set_filter(apng_ptr, 0, PNG_ALL_FILTERS); @@ -1237,7 +1241,7 @@ void M_SaveFrame(void) if (rendermode == render_soft) { // munge planar buffer to linear - linear = screens[2]; + linear = vid.screens[2]; I_ReadScreen(linear); } #ifdef HWRENDER @@ -1375,7 +1379,7 @@ boolean M_SavePNG(const char *filename, void *data, int width, int height, const png_init_io(png_ptr, png_FILE); #ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_set_user_limits(png_ptr, MAXPNGWIDTH, MAXPNGHEIGHT); + png_set_user_limits(png_ptr, MAXVIDWIDTH, MAXVIDHEIGHT); #endif //png_set_filter(png_ptr, 0, PNG_ALL_FILTERS); @@ -1539,7 +1543,7 @@ void M_DoScreenShot(void) if (rendermode == render_soft) { // munge planar buffer to linear - linear = screens[2]; + linear = vid.screens[2]; I_ReadScreen(linear); } @@ -1600,6 +1604,52 @@ boolean M_ScreenshotResponder(event_t *ev) return true; } + +void M_ScrollString(const char name[], size_t len, char result[], size_t maxlen, tic_t timer) +{ + // How much should we scroll. Not sure why +1 is needed, but without it this function skips 2 + // characters at once sometimes + const size_t amount = len - maxlen + 1; + + // Note: anything above 17 will cause zero division + const size_t MAXSPEED = 6; + const tic_t t = timer / (35/min(amount, MAXSPEED)); + + const size_t state = (t / amount) % 4; + + switch (state) + { + // Show beginning of the name + case 0: + memcpy(result, name, maxlen-1); + break; + + // Scroll towards end of the name + case 1: + { + const size_t advance = t % amount; + memcpy(result, name+advance, maxlen-1); + } + break; + + // Show end of the name + case 2: + memcpy(result, name+len+1-maxlen, maxlen-1); + break; + + // Scroll towards start of the name + case 3: + { + const size_t advance = t % amount; + memcpy(result, name+len+1-maxlen-advance, maxlen-1); + } + break; + } + + // Technically not necessary, since it gets set again after function call, but just in case + result[maxlen] = 0; +} + void M_MinimapGenerate(void) { #ifdef USE_PNG @@ -1677,54 +1727,6 @@ failure: #endif //#ifdef USE_PNG } -// ========================================================================== -// TRANSLATION FUNCTIONS -// ========================================================================== - -// M_StartupLocale. -// Sets up gettext to translate SRB2's strings. -#ifdef GETTEXT -#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) -#define GETTEXTDOMAIN1 "/usr/share/locale" -#define GETTEXTDOMAIN2 "/usr/local/share/locale" -#elif defined (_WIN32) -#define GETTEXTDOMAIN1 "." -#endif - -void M_StartupLocale(void) -{ - char *textdomhandle = NULL; - - CONS_Printf("M_StartupLocale...\n"); - - setlocale(LC_ALL, ""); - - // Do not set numeric locale as that affects atof - setlocale(LC_NUMERIC, "C"); - - // FIXME: global name define anywhere? -#ifdef GETTEXTDOMAIN1 - textdomhandle = bindtextdomain("srb2", GETTEXTDOMAIN1); -#endif -#ifdef GETTEXTDOMAIN2 - if (!textdomhandle) - textdomhandle = bindtextdomain("srb2", GETTEXTDOMAIN2); -#endif -#ifdef GETTEXTDOMAIN3 - if (!textdomhandle) - textdomhandle = bindtextdomain("srb2", GETTEXTDOMAIN3); -#endif -#ifdef GETTEXTDOMAIN4 - if (!textdomhandle) - textdomhandle = bindtextdomain("srb2", GETTEXTDOMAIN4); -#endif - if (textdomhandle) - textdomain("srb2"); - else - CONS_Printf("Could not find locale text domain!\n"); -} -#endif - // ========================================================================== // MISC STRING FUNCTIONS // ========================================================================== @@ -1806,6 +1808,87 @@ INT32 axtoi(const char *hexStg) return intValue; } +void CopyCaretColors(char *p, const char *s, int n) +{ + char *t; + int m; + int c; + + if (!n) + return; + + while (( t = strchr(s, '^') )) + { + m = ( t - s ); + + if (m >= n) + { + memcpy(p, s, n); + return; + } + else + memcpy(p, s, m); + + p += m; + n -= m; + s += m; + + if (!n) + return; + + if (s[1]) + { + c = toupper(s[1]); + if (isdigit(c)) + c = 0x80 + ( c - '0' ); + else if (c >= 'A' && c <= 'F') + c = 0x80 + ( c - 'A' ); + else + c = 0; + + if (c) + { + *p++ = c; + n--; + + if (!n) + return; + } + else + { + if (n < 2) + break; + + memcpy(p, s, 2); + + p += 2; + n -= 2; + } + + s += 2; + } + else + break; + } + + strncpy(p, s, n); +} + +void StripColors(char *dst, char *src, size_t n) +{ + size_t j = 0; + + for (size_t i = 0; j < n && src[i] != 0; ++i) + { + char c = src[i]; + + if ((c & 0x80) == 0) + dst[j++] = c; + } + + dst[j] = 0; +} + /** Token parser for TEXTURES, ANIMDEFS, and potentially other lumps later down the line. * Was originally R_GetTexturesToken when I was coding up the TEXTURES parser, until I realized I needed it for ANIMDEFS too. * Parses up to the next whitespace character or comma. When finding the start of the next token, whitespace is skipped. @@ -2210,3 +2293,8 @@ void M_MkdirEach(const char *path, int start, int mode) { M_MkdirEachUntil(path, start, -1, mode); } + + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/src/m_misc.h b/src/m_misc.h index 98fbdaee7..0939a2747 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -15,6 +15,10 @@ #ifndef __M_MISC__ #define __M_MISC__ +#ifdef __cplusplus +extern "C" { +#endif + #include "doomtype.h" #include "tables.h" @@ -69,6 +73,8 @@ void M_ScreenShot(void); void M_DoScreenShot(void); boolean M_ScreenshotResponder(event_t *ev); +void M_ScrollString(const char name[], size_t len, char result[], size_t maxlen, tic_t timer); + void M_MinimapGenerate(void); void Command_SaveConfig_f(void); @@ -81,6 +87,11 @@ void M_SaveConfig(const char *filename); INT32 axtoi(const char *hexStg); +void CopyCaretColors(char *p, const char *s, int n); + +// Remove color codes from string +void StripColors(char *dst, char *src, size_t n); + const char *GetRevisionString(void); // Vector/matrix math @@ -116,4 +127,8 @@ FUNCMATH UINT8 M_CountBits(UINT32 num, UINT8 size); #include "w_wad.h" extern char configfile[MAX_WADPATH]; +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/p_enemy.c b/src/p_enemy.c index d500a0cb2..8cf62935a 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -16,6 +16,7 @@ #include "g_game.h" #include "p_local.h" #include "r_main.h" +#include "r_skins.h" #include "r_state.h" #include "s_sound.h" #include "m_random.h" diff --git a/src/p_inter.c b/src/p_inter.c index 059bbe15c..ea1aec415 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1542,15 +1542,17 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) { if (target->target->hnext) K_KillBananaChain(target->target->hnext, inflictor, source); + target->target->player->kartstuff[k_itemamount] = 0; } - else if (target->target->player->kartstuff[k_itemamount]) + else target->target->player->kartstuff[k_itemamount]--; } else if ((target->type == MT_ORBINAUT_SHIELD && target->target->player->kartstuff[k_itemtype] == KITEM_ORBINAUT) // orbit items || (target->type == MT_JAWZ_SHIELD && target->target->player->kartstuff[k_itemtype] == KITEM_JAWZ)) { target->target->player->kartstuff[k_itemamount]--; + if (target->lastlook != 0) { K_RepairOrbitChain(target); diff --git a/src/p_local.h b/src/p_local.h index 38dcc006b..944879fa8 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -158,6 +158,8 @@ extern consvar_t cv_tiltsmoothing; extern consvar_t cv_actionmovie; +extern consvar_t cv_screenquake; + extern consvar_t cv_lookbackmom[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_verticallook[MAXSPLITSCREENPLAYERS]; diff --git a/src/p_map.c b/src/p_map.c index 17263bfe9..acb70d0b7 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1691,7 +1691,7 @@ static boolean PIT_CheckLine(line_t *ld) boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { INT32 xl, xh, yl, yh, bx, by; - subsector_t *newsubsec; + sector_t *newsec; boolean blockval = true; ps_checkposition_calls.value.i++; @@ -1714,9 +1714,9 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) tmbbox[BOXLEFT] = x - tmthing->radius; if (thing->x != x || thing->y != y || thing->subsector == NULL) - newsubsec = R_PointInSubsector(x, y); + newsec = R_PointInSubsector(x, y)->sector; else - newsubsec = thing->subsector; + newsec = thing->subsector->sector; ceilingline = blockingline = NULL; @@ -1724,33 +1724,34 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) // that contains the point. // Any contacted lines the step closer together // will adjust them. - tmfloorz = tmdropoffz = P_GetFloorZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->floorheight; - tmceilingz = P_GetCeilingZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->ceilingheight; - tmfloorslope = newsubsec->sector->f_slope; - tmceilingslope = newsubsec->sector->c_slope; + tmfloorz = tmdropoffz = P_GetFloorZ(thing, newsec, x, y, NULL); //newsec->floorheight; + tmceilingz = P_GetCeilingZ(thing, newsec, x, y, NULL); //newsec->ceilingheight; + tmfloorslope = newsec->f_slope; + tmceilingslope = newsec->c_slope; // Check list of fake floors and see if tmfloorz/tmceilingz need to be altered. - if (newsubsec->sector->ffloors) + if (newsec->ffloors) { ffloor_t *rover; fixed_t delta1, delta2; INT32 thingtop = thing->z + thing->height; - for (rover = newsubsec->sector->ffloors; rover; rover = rover->next) + for (rover = newsec->ffloors; rover; rover = rover->next) { fixed_t topheight, bottomheight, midheight; if (!(rover->flags & FF_EXISTS)) continue; - topheight = P_GetFOFTopZ(thing, newsubsec->sector, rover, x, y, NULL); - bottomheight = P_GetFOFBottomZ(thing, newsubsec->sector, rover, x, y, NULL); + topheight = P_GetFOFTopZ(thing, newsec, rover, x, y, NULL); + bottomheight = P_GetFOFBottomZ(thing, newsec, rover, x, y, NULL); if ((rover->flags & (FF_SWIMMABLE|FF_GOOWATER)) == (FF_SWIMMABLE|FF_GOOWATER) && !(thing->flags & MF_NOGRAVITY)) { // If you're inside goowater and slowing down fixed_t sinklevel = FixedMul(thing->info->height/6, thing->scale); fixed_t minspeed = FixedMul(thing->info->height/9, thing->scale); + if (thing->z < topheight && bottomheight < thingtop && abs(thing->momz) < minspeed) { @@ -1984,7 +1985,7 @@ void P_CheckHoopPosition(mobj_t *hoopthing, fixed_t x, fixed_t y, fixed_t z, fix boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam) { INT32 xl, xh, yl, yh, bx, by; - subsector_t *newsubsec; + sector_t *newsec; tmx = x; tmy = y; @@ -1995,15 +1996,15 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam) tmbbox[BOXLEFT] = x - thiscam->radius; if (thiscam->x != x || thiscam->y != y || thiscam->subsector == NULL) - newsubsec = R_PointInSubsector(x, y); + newsec = R_PointInSubsectorFast(x, y)->sector; else - newsubsec = thiscam->subsector; + newsec = thiscam->subsector->sector; ceilingline = blockingline = NULL; mapcampointer = thiscam; - if (GETSECSPECIAL(newsubsec->sector->special, 4) == 12) + if (GETSECSPECIAL(newsec->special, 4) == 12) { // Camera noclip on entire sector. tmfloorz = tmdropoffz = thiscam->z; tmceilingz = tmdrpoffceilz = thiscam->z + thiscam->height; @@ -2014,45 +2015,47 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam) // that contains the point. // Any contacted lines the step closer together // will adjust them. - tmfloorz = tmdropoffz = P_CameraGetFloorZ(thiscam, newsubsec->sector, x, y, NULL); + tmfloorz = tmdropoffz = P_CameraGetFloorZ(thiscam, newsec, x, y, NULL); - tmceilingz = P_CameraGetCeilingZ(thiscam, newsubsec->sector, x, y, NULL); + tmceilingz = P_CameraGetCeilingZ(thiscam, newsec, x, y, NULL); // Cameras use the heightsec's heights rather then the actual sector heights. // If you can see through it, why not move the camera through it too? - if (newsubsec->sector->heightsec >= 0) + if (newsec->heightsec >= 0) { - tmfloorz = tmdropoffz = sectors[newsubsec->sector->heightsec].floorheight; - tmceilingz = tmdrpoffceilz = sectors[newsubsec->sector->heightsec].ceilingheight; + tmfloorz = tmdropoffz = sectors[newsec->heightsec].floorheight; + tmceilingz = tmdrpoffceilz = sectors[newsec->heightsec].ceilingheight; } // Use preset camera clipping heights if set with Sector Special Parameters whose control sector has Camera Intangible special -Red - if (newsubsec->sector->camsec >= 0) + if (newsec->camsec >= 0) { - tmfloorz = tmdropoffz = sectors[newsubsec->sector->camsec].floorheight; - tmceilingz = tmdrpoffceilz = sectors[newsubsec->sector->camsec].ceilingheight; + tmfloorz = tmdropoffz = sectors[newsec->camsec].floorheight; + tmceilingz = tmdrpoffceilz = sectors[newsec->camsec].ceilingheight; } // Check list of fake floors and see if tmfloorz/tmceilingz need to be altered. - if (newsubsec->sector->ffloors) + if (newsec->ffloors) { ffloor_t *rover; fixed_t delta1, delta2; INT32 thingtop = thiscam->z + thiscam->height; - for (rover = newsubsec->sector->ffloors; rover; rover = rover->next) + for (rover = newsec->ffloors; rover; rover = rover->next) { fixed_t topheight, bottomheight; + if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERALL) || GETSECSPECIAL(rover->master->frontsector->special, 4) == 12) continue; - topheight = P_CameraGetFOFTopZ(thiscam, newsubsec->sector, rover, x, y, NULL); - bottomheight = P_CameraGetFOFBottomZ(thiscam, newsubsec->sector, rover, x, y, NULL); + topheight = P_CameraGetFOFTopZ(thiscam, newsec, rover, x, y, NULL); + bottomheight = P_CameraGetFOFBottomZ(thiscam, newsec, rover, x, y, NULL); delta1 = thiscam->z - (bottomheight + ((topheight - bottomheight)/2)); delta2 = thingtop - (bottomheight + ((topheight - bottomheight)/2)); + if (topheight > tmfloorz && abs(delta1) < abs(delta2)) { tmfloorz = tmdropoffz = topheight; @@ -2171,8 +2174,6 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam) boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam) { subsector_t *s; - - boolean retval = true; UINT8 i; floatok = false; @@ -2181,7 +2182,7 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam) return false; if (thiscam->x != x || thiscam->y != y || thiscam->subsector == NULL) - s = R_PointInSubsector(x, y); + s = R_PointInSubsectorFast(x, y); else s = thiscam->subsector; @@ -2222,12 +2223,12 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam) else tryy = y; - if (!P_CheckCameraPosition(tryx, tryy, thiscam)) - return false; // solid wall or thing - if (tmceilingz - tmfloorz < thiscam->height) return false; // doesn't fit + if (!P_CheckCameraPosition(tryx, tryy, thiscam)) + return false; // solid wall or thing + floatok = true; if (tmceilingz - thiscam->z < thiscam->height) @@ -2248,7 +2249,8 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam) if ((tmfloorz - thiscam->z > MAXCAMERASTEPMOVE)) return false; // too big a step up - } while(tryx != x || tryy != y); + + } while (tryx != x || tryy != y); } else { @@ -2265,7 +2267,7 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam) thiscam->y = y; thiscam->subsector = s; - return retval; + return true; } // diff --git a/src/p_maputl.c b/src/p_maputl.c index 7b748c22e..11e7a1050 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -908,7 +908,7 @@ void P_SetUnderlayPosition(mobj_t *thing) void P_SetPrecipitationThingPosition(precipmobj_t *thing) { - thing->subsector = R_PointInSubsector(thing->x, thing->y); + thing->subsector = R_PointInSubsectorFast(thing->x, thing->y); // NOTE: this works because bnext/bprev are at the same // offsets in precipmobj_t and mobj_t diff --git a/src/p_mobj.c b/src/p_mobj.c index 444186579..2c8c17339 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -20,6 +20,7 @@ #include "p_setup.h" #include "r_fps.h" #include "r_main.h" +#include "r_skins.h" #include "r_things.h" #include "r_sky.h" #include "r_splats.h" @@ -177,7 +178,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) // Set animation state // The pflags version of this was just as convoluted. // Rewriten for SRB2kart ... though I don't know what this is. - switch(state) + switch (state) { case S_KART_STND1...S_KART_STND2_R: case S_KART_SQUISH: @@ -202,7 +203,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) do { - if (state == S_NULL) + if (UNLIKELY(state == S_NULL)) { // Bad SOC! CONS_Alert(CONS_ERROR, "Cannot remove player mobj by setting its state to S_NULL.\n"); //P_RemoveMobj(mobj); @@ -238,7 +239,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) state = st->nextstate; } while (!mobj->tics && !seenstate[state]); - if (!mobj->tics) + if (UNLIKELY(!mobj->tics)) CONS_Alert(CONS_WARNING, M_GetText("State cycle detected, exiting.\n")); if (!--recursion) @@ -305,7 +306,7 @@ boolean P_SetMobjState(mobj_t *mobj, statenum_t state) state = st->nextstate; } while (!mobj->tics && !seenstate[state]); - if (!mobj->tics) + if (UNLIKELY(!mobj->tics)) CONS_Alert(CONS_WARNING, M_GetText("State cycle detected, exiting.\n")); if (!--recursion) @@ -754,7 +755,7 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix testy += y; // If the highest point is in the sector, then we have it easy! Just get the Z at that point - if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) + if (R_PointInSubsectorFast(testx, testy)->sector == (boundsec ? boundsec : sector)) return P_GetSlopeZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point @@ -834,7 +835,7 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f testy += y; // If the highest point is in the sector, then we have it easy! Just get the Z at that point - if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) + if (R_PointInSubsectorFast(testx, testy)->sector == (boundsec ? boundsec : sector)) return P_GetSlopeZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point @@ -1893,11 +1894,9 @@ boolean P_CheckSolidLava(mobj_t *mo, ffloor_t *rover) I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); - fixed_t topheight = P_GetFFloorTopZAt(rover, mo->x, mo->y); - 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))) + && ((rover->master->flags & ML_EFFECT3) || mo->z-mo->momz > P_GetFFloorTopZAt(rover, mo->x, mo->y) - FixedMul(16*FRACUNIT, mo->scale))) return true; return false; @@ -3288,7 +3287,7 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled } } - thiscam->subsector = R_PointInSubsector(thiscam->x, thiscam->y); + thiscam->subsector = R_PointInSubsectorFast(thiscam->x, thiscam->y); thiscam->floorz = tmfloorz; thiscam->ceilingz = tmceilingz; @@ -3347,6 +3346,7 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled thiscam->ceilingz = thiscam->z + thiscam->height; thiscam->floorz = thiscam->z; } + return false; } @@ -3372,7 +3372,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) mobj->eflags &= ~MFE_JUSTSTEPPEDDOWN; // Zoom tube - if (mobj->tracer && mobj->tracer->type == MT_TUBEWAYPOINT) + if (UNLIKELY(mobj->tracer && mobj->tracer->type == MT_TUBEWAYPOINT)) { P_UnsetThingPosition(mobj); mobj->x += mobj->momx; @@ -3382,7 +3382,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) P_CheckPosition(mobj, mobj->x, mobj->y); goto animonly; } - else if (mobj->player->pflags & PF_MACESPIN && mobj->tracer) + else if (UNLIKELY(mobj->player->pflags & PF_MACESPIN && mobj->tracer)) { P_CheckPosition(mobj, mobj->x, mobj->y); goto animonly; @@ -3401,7 +3401,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) else P_TryMove(mobj, mobj->x, mobj->y, true); - if (!(netgame && mobj->player->spectator)) + if (LIKELY(!(netgame && mobj->player->spectator))) { // Crumbling platforms for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) @@ -3448,6 +3448,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) } } } + if (thereiswater) { for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) @@ -5980,7 +5981,8 @@ angle_t P_MobjPitchAndRoll(mobj_t *mobj) return 0; // if mobj doesent have any of those, no need to do the rest - if (mobj->roll == 0 && mobj->pitch == 0 && mobj->sloperoll == 0 && mobj->slopepitch == 0) + if (mobj->roll == 0 && mobj->pitch == 0 + && mobj->sloperoll == 0 && mobj->slopepitch == 0) return 0; size_t rot = (mobj->frame & FF_FRAMEMASK); @@ -6006,7 +6008,8 @@ angle_t P_MobjPitchAndRoll(mobj_t *mobj) sprframe = &sprdef->spriteframes[rot]; // No sprite frame? I guess it is possible - if (!sprframe) return 0; + if (!sprframe) + return 0; if (sprframe->rotate != SRF_SINGLE || (mobj->frame & FF_PAPERSPRITE)) { @@ -6015,9 +6018,9 @@ angle_t P_MobjPitchAndRoll(mobj_t *mobj) } return_angle = FixedMul(FINECOSINE((ang) >> ANGLETOFINESHIFT), mobj->roll) - + FixedMul(FINESINE((ang) >> ANGLETOFINESHIFT), mobj->pitch) - + FixedMul(FINECOSINE((camang) >> ANGLETOFINESHIFT), mobj->sloperoll) - + FixedMul(FINESINE((camang) >> ANGLETOFINESHIFT), mobj->slopepitch); + + FixedMul(FINESINE((ang) >> ANGLETOFINESHIFT), mobj->pitch) + + FixedMul(FINECOSINE((camang) >> ANGLETOFINESHIFT), mobj->sloperoll) + + FixedMul(FINESINE((camang) >> ANGLETOFINESHIFT), mobj->slopepitch); return return_angle; } @@ -9093,21 +9096,21 @@ void P_MobjThinker(mobj_t *mobj) mobj->eflags &= ~MFE_JUSTHITFLOOR; } - if (mobj->type == MT_FLINGRING + if (UNLIKELY(mobj->type == MT_FLINGRING || mobj->type == MT_FLINGCOIN || P_WeaponOrPanel(mobj->type) || mobj->type == MT_FLINGEMERALD || mobj->type == MT_BIGTUMBLEWEED || mobj->type == MT_LITTLETUMBLEWEED - || mobj->type == MT_CANNONBALLDECOR + || mobj->type == MT_CANNONBALLDECOR) || mobj->type == MT_FALLINGROCK) { P_TryMove(mobj, mobj->x, mobj->y, true); // Sets mo->standingslope correctly P_ButteredSlope(mobj); } - if (mobj->flags & (MF_ENEMY|MF_BOSS) && mobj->health - && P_CheckDeathPitCollide(mobj)) // extra pit check in case these didn't have momz + if (UNLIKELY(mobj->flags & (MF_ENEMY|MF_BOSS) && mobj->health + && P_CheckDeathPitCollide(mobj))) // extra pit check in case these didn't have momz { P_KillMobj(mobj, NULL, NULL); return; @@ -9116,10 +9119,10 @@ void P_MobjThinker(mobj_t *mobj) // Crush enemies! if (mobj->ceilingz - mobj->floorz < mobj->height) { - if (( + if (UNLIKELY(( (mobj->flags & (MF_ENEMY|MF_BOSS) && mobj->flags & MF_SHOOTABLE) - || mobj->type == MT_EGGSHIELD) + || mobj->type == MT_EGGSHIELD)) && !(mobj->flags & MF_NOCLIPHEIGHT) && mobj->health > 0) { @@ -9137,25 +9140,21 @@ void P_MobjThinker(mobj_t *mobj) if (P_MobjWasRemoved(mobj)) return; - switch (mobj->type) + if (UNLIKELY(P_WeaponOrPanel(mobj->type))) { - case MT_BOUNCEPICKUP ... MT_GRENADEPICKUP: - if (mobj->health == 0) // Fading tile - { - INT32 value = mobj->info->damage/10; - value = mobj->fuse/value; - value = 10-value; - value--; + if (mobj->health == 0) // Fading tile + { + INT32 value = mobj->info->damage/10; + value = mobj->fuse/value; + value = 10-value; + value--; - if (value <= 0) - value = 1; + if (value <= 0) + value = 1; - mobj->frame &= ~FF_TRANSMASK; - mobj->frame |= value << FF_TRANSSHIFT; - } - break; - default: - break; + mobj->frame &= ~FF_TRANSMASK; + mobj->frame |= value << FF_TRANSSHIFT; + } } } @@ -9980,8 +9979,7 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype mobj->precipflags |= PCF_FOF; else { - INT32 special = GETSECSPECIAL(mobj->subsector->sector->special, 1); - + const INT32 special = GETSECSPECIAL(mobj->subsector->sector->special, 1); if (special == 7 || special == 6 || mobj->subsector->sector->floorpic == skyflatnum) mobj->precipflags |= PCF_PIT; } @@ -10013,14 +10011,14 @@ void P_RemoveMobj(mobj_t *mobj) mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker; // needed for P_UnsetThingPosition, etc. to work. // Rings only, please! - if (mobj->spawnpoint && + if (UNLIKELY(mobj->spawnpoint && (mobj->type == MT_RING || mobj->type == MT_COIN || mobj->type == MT_BLUEBALL || mobj->type == MT_REDTEAMRING || mobj->type == MT_BLUETEAMRING || P_WeaponOrPanel(mobj->type)) - && !(mobj->flags2 & MF2_DONTRESPAWN)) + && !(mobj->flags2 & MF2_DONTRESPAWN))) { itemrespawnque[iquehead] = mobj->spawnpoint; itemrespawntime[iquehead] = leveltime; @@ -10042,13 +10040,13 @@ void P_RemoveMobj(mobj_t *mobj) } } - if (mobj->type == MT_OVERLAY) + if (UNLIKELY(mobj->type == MT_OVERLAY)) P_RemoveOverlay(mobj); - if (mobj->type == MT_SHADOW) + if (UNLIKELY(mobj->type == MT_SHADOW)) P_RemoveShadow(mobj); - if (mobj->type == MT_SPB) + if (UNLIKELY(mobj->type == MT_SPB)) spbplace = -1; mobj->health = 0; // Just because @@ -10060,6 +10058,7 @@ void P_RemoveMobj(mobj_t *mobj) P_DelSeclist(sector_list); sector_list = NULL; } + mobj->flags |= MF_NOSECTOR|MF_NOBLOCKMAP; mobj->subsector = NULL; mobj->state = NULL; @@ -10095,46 +10094,33 @@ void P_RemoveMobj(mobj_t *mobj) R_RemoveMobjInterpolator(mobj); // free block - // DBG: set everything in mobj_t to 0xFF instead of leaving it. debug memory error. if (mobj->flags & MF_NOTHINK && !mobj->thinker.next) { // Uh-oh, the mobj doesn't think, P_RemoveThinker would never go through! if (!mobj->thinker.references) { -#ifdef SCRAMBLE_REMOVED - // Invalidate mobj_t data to cause crashes if accessed! - memset(mobj, 0xff, sizeof(mobj_t)); -#endif // no references, dump it directly in the mobj cache mobj->hnext = mobjcache; mobjcache = mobj; + return; } - else - { // Add thinker just to delay removing it until refrences are gone. - mobj->flags &= ~MF_NOTHINK; - P_AddThinker((thinker_t *)mobj); -#ifdef PARANOIA - // Saved to avoid being scrambled like below... - mobj->thinker.debug_mobjtype = mobj->type; -#endif -#ifdef SCRAMBLE_REMOVED - // Invalidate mobj_t data to cause crashes if accessed! - memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); -#endif - P_RemoveThinker((thinker_t *)mobj); - } + + // Add thinker just to delay removing it until refrences are gone. + mobj->flags &= ~MF_NOTHINK; + P_AddThinker((thinker_t *)mobj); } - else - { + + P_RemoveThinker((thinker_t *)mobj); + #ifdef PARANOIA - // Saved to avoid being scrambled like below... - mobj->thinker.debug_mobjtype = mobj->type; + // Saved to avoid being scrambled like below... + mobj->thinker.debug_mobjtype = mobj->type; #endif + + // DBG: set everything in mobj_t to 0xFF instead of leaving it. debug memory error. #ifdef SCRAMBLE_REMOVED - // Invalidate mobj_t data to cause crashes if accessed! - memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); + // Invalidate mobj_t data to cause crashes if accessed! + memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); #endif - P_RemoveThinker((thinker_t *)mobj); - } } void P_FreePrecipMobj(precipmobj_t *mobj) @@ -10368,7 +10354,7 @@ void P_PrecipitationEffects(void) for (y = yl; y <= yh; y += RADIUSSTEP) for (x = xl; x <= xh; x += RADIUSSTEP) { - if (R_PointInSubsector((fixed_t)x, (fixed_t)y)->sector->ceilingpic != skyflatnum) // Found the outdoors! + if (R_PointInSubsectorFast((fixed_t)x, (fixed_t)y)->sector->ceilingpic != skyflatnum) // Found the outdoors! continue; newdist = S_CalculateSoundDistance(players[displayplayers[0]].mo->x, players[displayplayers[0]].mo->y, 0, (fixed_t)x, (fixed_t)y, 0); diff --git a/src/p_mobj.h b/src/p_mobj.h index 733153017..cd4033157 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -14,6 +14,10 @@ #ifndef __P_MOBJ__ #define __P_MOBJ__ +#ifdef __cplusplus +extern "C" { +#endif + // Basics. #include "tables.h" #include "m_fixed.h" @@ -536,4 +540,9 @@ extern mapthing_t *huntemeralds[MAXHUNTEMERALDS]; extern INT32 numhuntemeralds; extern boolean runemeraldmanager; extern INT32 numstarposts; + +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/p_saveg.c b/src/p_saveg.c index 3d17a14de..e8a5971ca 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -24,6 +24,7 @@ #include "r_fps.h" #include "r_things.h" #include "r_state.h" +#include "r_skins.h" #include "w_wad.h" #include "y_inter.h" #include "z_zone.h" diff --git a/src/p_setup.c b/src/p_setup.c index a69390961..4c76478dc 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -67,6 +67,8 @@ #include "lua_script.h" #include "lua_hook.h" +#include "y_inter.h" + #if !defined (UNDER_CE) #include #endif @@ -580,9 +582,6 @@ static void P_LoadRawSegs(UINT8 *data) else li->backsector = 0; - li->numlights = 0; - li->rlights = NULL; - P_UpdateSegLightOffset(li); } } @@ -675,6 +674,21 @@ INT32 P_AddLevelFlat(const char *flatname, levelflat_t *levelflat) levelflat->lumpnum = R_GetFlatNumForName(flatname); levelflat->baselumpnum = LUMPERROR; + // check if our flat contains cyan pixels + // not sure if this is the best way to do it but it works + { + const UINT8 *flat = (UINT8 *)W_CacheLumpNum(levelflat->lumpnum, PU_LEVEL); + size_t size = W_LumpLength(levelflat->lumpnum); + for (size_t steppy = 0; steppy < size; steppy++) + { + if (flat[steppy] == TRANSPARENTPIXEL) + { + levelflat->cyan = true; + break; + } + } + } + #ifndef ZDEBUG CONS_Debug(DBG_SETUP, "flat #%03d: %s\n", atoi(sizeu1(numlevelflats)), levelflat->name); #endif @@ -720,6 +734,21 @@ INT32 P_AddLevelFlatRuntime(const char *flatname) levelflat->lumpnum = R_GetFlatNumForName(flatname); levelflat->baselumpnum = LUMPERROR; + // check if our flat contains cyan pixels + // not sure if this is the best way to do it but it works + { + const UINT8 *flat = (UINT8 *)W_CacheLumpNum(levelflat->lumpnum, PU_LEVEL); + size_t size = W_LumpLength(levelflat->lumpnum); + for (size_t steppy = 0; steppy < size; steppy++) + { + if (flat[steppy] == TRANSPARENTPIXEL) + { + levelflat->cyan = true; + break; + } + } + } + #ifndef ZDEBUG CONS_Debug(DBG_SETUP, "flat #%03d: %s\n", atoi(sizeu1(numlevelflats)), levelflat->name); #endif @@ -2481,7 +2510,6 @@ static void P_SetupCamera(UINT8 pnum, camera_t *cam) cam->y = players[pnum].mo->y; cam->z = players[pnum].mo->z; cam->angle = players[pnum].mo->angle; - cam->subsector = R_PointInSubsector(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18) } else { @@ -2506,9 +2534,10 @@ static void P_SetupCamera(UINT8 pnum, camera_t *cam) cam->y = thing->y; cam->z = thing->z; cam->angle = FixedAngle((fixed_t)thing->angle << FRACBITS); - cam->subsector = R_PointInSubsector(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18) } + cam->subsector = R_PointInSubsectorFast(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18) + cam->chase = false; // tell camera to reset its position next tic } @@ -3104,11 +3133,128 @@ boolean P_AddWadFile(const char *wadfilename, boolean local) return true; } -// check for replacement votescreen backgrounds -boolean wideracereplaced = false; -boolean racereplaced = false; -boolean widebattlereplaced = false; -boolean battlereplaced = false; +static size_t sreplaces = 0, mreplaces = 0, digmreplaces = 0; + +// +// search for sound replacements +// +static boolean P_CheckSoundReplacements(UINT16 wadnum, char *name, size_t i) +{ + size_t j; + lumpnum_t lumpnum = (i|(wadnum<<16)); + + if (name[0] == 'D') + { + if (name[1] == 'S') + { + for (j = 1; j < NUMSFX; j++) + { + if (S_sfx[j].name && !strnicmp(S_sfx[j].name, name + 2, 6) + && (S_sfx[j].lumpnum != lumpnum) && (S_sfx[j].lumpnum != LUMPERROR)) + { + // the sound will be reloaded when needed, + // since sfx->data will be NULL + CONS_Debug(DBG_SETUP, "Sound %.8s replaced\n", name); + + I_FreeSfx(&S_sfx[j]); + + // Re-cache it + if (S_PrecacheSound()) + S_sfx[j].data = I_GetSfx(&S_sfx[j]); + + sreplaces++; + return true; + } + } + } + else if (name[1] == '_') + { + CONS_Debug(DBG_SETUP, "Music %.8s ignored\n", name); + mreplaces++; + return true; + } + } + else if (name[0] == 'O' && name[1] == '_') + { + CONS_Debug(DBG_SETUP, "Music %.8s replaced\n", name); + digmreplaces++; + return true; + } + + return false; +} + +// +// search for maps +// +static boolean P_CheckMapReplacements(char *name) +{ + if (memcmp(name, "MAP", 3) == 0) // Ignore the headers + { + INT16 num; + + if (name[5] != '\0') + return false; + + num = (INT16)M_MapNumber(name[3], name[4]); + + // we want to record whether this map exists. if it doesn't have a header, we can assume it's not relephant + if (num <= NUMMAPS && mapheaderinfo[num-1]) + { + if (mapheaderinfo[num-1]->menuflags & LF2_EXISTSHACK) + G_SetGameModified(multiplayer, true); // oops, double-defined - no record attack privileges for you + mapheaderinfo[num-1]->menuflags |= LF2_EXISTSHACK; + } + + if (num == gamemap) + partadd_replacescurrentmap = true; + + CONS_Printf("%s\n", name); + return true; + } + + return false; +} + +// +// check for non Lua votescreen replacements +// +static boolean P_CheckVoteReplacements(char *name) +{ + // widescreen patch Race + if (!VoteScreen.replaced.widerace && !memcmp(name, "INTERSCW", 8)) + { + VoteScreen.replaced.widerace = true; + return false; + } + + if (!VoteScreen.replaced.race && !memcmp(name, "INTERSCR", 8)) + { + VoteScreen.replaced.race = true; + return false; + } + + // widescreen patch Battle + if (!VoteScreen.replaced.widebattle && !memcmp(name, "BATTLSCW", 8)) + { + VoteScreen.replaced.widebattle = true; + return false; + } + + if (!VoteScreen.replaced.battle && !memcmp(name, "BATTLSCR", 8)) + { + VoteScreen.replaced.battle = true; + return false; + } + + if (VoteScreen.replaced.widerace && VoteScreen.replaced.race + && VoteScreen.replaced.widebattle && VoteScreen.replaced.battle) + { + return true; + } + + return false; +} // // Add a WAD file and do the per-WAD setup stages. @@ -3116,12 +3262,15 @@ boolean battlereplaced = false; // UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local) { - size_t i, j, sreplaces = 0, mreplaces = 0, digmreplaces = 0; + size_t i; UINT16 numlumps, wadnum; char *name; boolean mapsadded = false; + static boolean allvotereplaced = false; lumpinfo_t *lumpinfo; + sreplaces = mreplaces = digmreplaces = 0; + if ((numlumps = W_InitFile(wadfilename, local)) == INT16_MAX) { refreshdirmenu |= REFRESHDIR_NOTLOADED; @@ -3136,46 +3285,24 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local) wadfiles[wadnum]->localfile = local; - // - // search for sound replacements - // lumpinfo = wadfiles[wadnum]->lumpinfo; for (i = 0; i < numlumps; i++, lumpinfo++) { name = lumpinfo->name; - lumpnum_t lumpnum = i|(wadnum<<16); - if (name[0] == 'D') + if (P_CheckSoundReplacements(wadnum, name, i)) + continue; + + if (P_CheckMapReplacements(name)) { - if (name[1] == 'S') for (j = 1; j < NUMSFX; j++) - { - if (S_sfx[j].name && !strnicmp(S_sfx[j].name, name + 2, 6) && S_sfx[j].lumpnum != lumpnum && S_sfx[j].lumpnum != LUMPERROR) - { - // the sound will be reloaded when needed, - // since sfx->data will be NULL - CONS_Debug(DBG_SETUP, "Sound %.8s replaced\n", name); - - I_FreeSfx(&S_sfx[j]); - - // Re-cache it - if (S_PrecacheSound()) - S_sfx[j].data = I_GetSfx(&S_sfx[j]); - - sreplaces++; - } - } - else if (name[1] == '_') - { - CONS_Debug(DBG_SETUP, "Music %.8s ignored\n", name); - mreplaces++; - } - } - else if (name[0] == 'O' && name[1] == '_') - { - CONS_Debug(DBG_SETUP, "Music %.8s replaced\n", name); - digmreplaces++; + mapsadded = true; + continue; } + + if (!allvotereplaced && P_CheckVoteReplacements(name)) + allvotereplaced = true; } + if (!devparm && sreplaces) CONS_Printf(M_GetText("%s sounds replaced\n"), sizeu1(sreplaces)); if (!devparm && mreplaces) @@ -3183,6 +3310,9 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local) if (!devparm && digmreplaces) CONS_Printf(M_GetText("%s digital musics replaced\n"), sizeu1(digmreplaces)); + if (!mapsadded) + CONS_Printf(M_GetText("No maps added\n")); + // // search for sprite replacements // @@ -3207,80 +3337,9 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local) // S_LoadMusicDefs(wadnum); - // - // search for maps - // - lumpinfo = wadfiles[wadnum]->lumpinfo; - for (i = 0; i < numlumps; i++, lumpinfo++) - { - name = lumpinfo->name; - - if (name[0] == 'M' && name[1] == 'A' && name[2] == 'P') // Ignore the headers - { - INT16 num; - if (name[5]!='\0') - continue; - num = (INT16)M_MapNumber(name[3], name[4]); - - // we want to record whether this map exists. if it doesn't have a header, we can assume it's not relephant - if (num <= NUMMAPS && mapheaderinfo[num-1]) - { - if (mapheaderinfo[num-1]->menuflags & LF2_EXISTSHACK) - G_SetGameModified(multiplayer, true); // oops, double-defined - no record attack privileges for you - mapheaderinfo[num-1]->menuflags |= LF2_EXISTSHACK; - } - - if (num == gamemap) - partadd_replacescurrentmap = true; - - CONS_Printf("%s\n", name); - mapsadded = true; - } - } - if (!mapsadded) - CONS_Printf(M_GetText("No maps added\n")); - // TODO: Experimental SPRTINFO support, test first R_LoadSpriteInfoLumps(wadnum, wadfiles[wadnum]->numlumps); - // - // check for votescreen replacements - // - if (!wideracereplaced && !racereplaced && !widebattlereplaced && !battlereplaced) - { - lumpinfo = wadfiles[wadnum]->lumpinfo; - for (i = 0; i < numlumps; i++, lumpinfo++) - { - name = lumpinfo->name; - - // widescreen patch Race - if (!wideracereplaced && !strncmp(name, "INTERSCW", 8)) - { - wideracereplaced = true; - continue; - } - - if (!racereplaced && !strncmp(name, "INTERSCR", 8)) - { - racereplaced = true; - continue; - } - - // widescreen patch Battle - if (!widebattlereplaced && !strncmp(name, "BATTLSCW", 8)) - { - widebattlereplaced = true; - continue; - } - - if (!battlereplaced && !strncmp(name, "BATTLSCR", 8)) - { - battlereplaced = true; - continue; - } - } - } - refreshdirmenu &= ~REFRESHDIR_GAMEDATA; // Under usual circumstances we'd wait for REFRESHDIR_GAMEDATA to disappear the next frame, but it's a bit too dangerous for that... partadd_stage = 0; return wadnum; diff --git a/src/p_setup.h b/src/p_setup.h index 97209e154..8542aa8dc 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -14,6 +14,10 @@ #ifndef __P_SETUP__ #define __P_SETUP__ +#ifdef __cplusplus +extern "C" { +#endif + #include "doomdata.h" #include "doomstat.h" #include "r_defs.h" @@ -48,6 +52,7 @@ typedef struct INT32 animseq; // start pos. in the anim sequence INT32 numpics; INT32 speed; + boolean cyan; } levelflat_t; extern size_t numlevelflats; @@ -68,11 +73,6 @@ void HWR_LoadLevel(boolean reloadinggamestate); boolean P_AddWadFile(const char *wadfilename, boolean local); -extern boolean wideracereplaced; -extern boolean racereplaced; -extern boolean widebattlereplaced; -extern boolean battlereplaced; - // WARNING: The following functions should be grouped as follows: // any amount of PartialAdds followed by MultiSetups until returned true, // as soon as possible. @@ -116,4 +116,8 @@ UINT8 P_GetGrade(UINT32 pscore, INT16 map, UINT8 mare); UINT8 P_HasGrades(INT16 map, UINT8 mare); UINT32 P_GetScoreForGrade(INT16 map, UINT8 mare, UINT8 grade); +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/p_spec.c b/src/p_spec.c index 70fb19c20..224a55171 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2022,7 +2022,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) camera[i].y += y; camera[i].z += z; camera[i].reset = true; - camera[i].subsector = R_PointInSubsector(camera[i].x, camera[i].y); + camera[i].subsector = R_PointInSubsectorFast(camera[i].x, camera[i].y); R_RelativeTeleportViewInterpolation(i, x, y, z, 0); break; } diff --git a/src/p_tick.c b/src/p_tick.c index 5e1af1b68..9664d50be 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -573,7 +573,7 @@ static void P_RunQuakes(void) { fixed_t ir; - if (quake.time <= 0) + if (!cv_screenquake.value || quake.time <= 0) { quake.x = quake.y = quake.z = quake.roll = 0; return; @@ -618,8 +618,8 @@ static inline void P_ResetSpriteStuff(void) if (!mo || (mo->sprite == SPR_NULL) || (mo->flags2 & MF2_DONTDRAW) || (mo->type == MT_SHADOW)) continue; - mo->spritexscale = mo->realxscale; - mo->spriteyscale = mo->realyscale; + mo->spritexscale = mo->realxscale; + mo->spriteyscale = mo->realyscale; mo->spritexoffset = mo->realxoffset; mo->spriteyoffset = mo->realyoffset; } diff --git a/src/p_user.c b/src/p_user.c index bbf3d2478..7f643a9ef 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3044,6 +3044,8 @@ consvar_t cv_tiltsmoothing = {"tiltsmoothing", "32", CV_SAVE, CV_Natural, NULL, consvar_t cv_actionmovie = {"actionmovie", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_screenquake = {"quakescreenshake", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + static CV_PossibleValue_t lookbackmom_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Double"}, {0, NULL}}; consvar_t cv_lookbackmom[MAXSPLITSCREENPLAYERS] = { @@ -3402,7 +3404,7 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) } // update subsector to avoid crashes; - cam->subsector = R_PointInSubsector(cam->x, cam->y); + cam->subsector = R_PointInSubsectorFast(cam->x, cam->y); } void P_ResetCamera(player_t *player, camera_t *thiscam) @@ -3446,7 +3448,7 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) thiscam->relativex = 0; - thiscam->subsector = R_PointInSubsector(thiscam->x,thiscam->y); + thiscam->subsector = R_PointInSubsectorFast(thiscam->x,thiscam->y); thiscam->radius = 20*FRACUNIT; thiscam->height = 16*FRACUNIT; @@ -3682,7 +3684,7 @@ static void P_MoveCameraToSpawn(UINT8 playernum) thiscam->angle = player->mo->angle; thiscam->aiming = 0; - thiscam->subsector = R_PointInSubsector(thiscam->x,thiscam->y); + thiscam->subsector = R_PointInSubsectorFast(thiscam->x,thiscam->y); thiscam->reset_aiming = true; diff --git a/src/qs22j.h b/src/qs22j.h index c388b9c46..cf522b73d 100644 --- a/src/qs22j.h +++ b/src/qs22j.h @@ -16,6 +16,15 @@ #ifndef __QS22J__ #define __QS22J__ + +#ifdef __cplusplus +extern "C" { +#endif + void qs22j(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)); + +#ifdef __cplusplus +} // extern "C" +#endif #endif diff --git a/src/r_bsp.c b/src/r_bsp.cpp similarity index 84% rename from src/r_bsp.c rename to src/r_bsp.cpp index 427a6367c..a05bf70c4 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.cpp @@ -35,6 +35,7 @@ sector_t *backsector; // very ugly realloc() of drawsegs at run-time, I upped it to 512 // instead of 256.. and someone managed to send me a level with // 896 drawsegs! So too bad here's a limit removal a-la-Boom +drawseg_t *curdrawsegs = NULL; /**< This is used to handle multiple lists for masked drawsegs. */ drawseg_t *drawsegs = NULL; drawseg_t *ds_p = NULL; @@ -73,165 +74,96 @@ void R_ClearDrawSegs(void) ds_p = drawsegs; } -// Fix from boom. -#define MAXSEGS (MAXVIDWIDTH/2+1) +// CPhipps - +// Instead of clipsegs, let's try using an array with one entry for each column, +// indicating whether it's blocked by a solid wall yet or not. +UINT8 *solidcol; -// newend is one past the last valid seg -static cliprange_t *newend; -static cliprange_t solidsegs[MAXSEGS]; - -// -// R_ClipSolidWallSegment -// Does handle solid walls, -// e.g. single sided LineDefs (middle texture) -// that entirely block the view. -// -static void R_ClipSolidWallSegment(INT32 first, INT32 last) +void R_AllocClipSegMemory(void) { - cliprange_t *next; - cliprange_t *start; + solidcol = static_cast(Z_Realloc(solidcol, sizeof(*solidcol) * viewwidth, PU_STATIC, NULL)); +} - // Find the first range that touches the range (adjacent pixels are touching). - start = solidsegs; - while (start->last < first - 1) - start++; +namespace +{ - if (first < start->first) +enum class ClipType +{ + // Does handle solid walls, + // e.g. single sided LineDefs (middle texture) + // that entirely block the view. + kSolid, + kSolidDontRender, + + // Clips the given range of columns, but does not include it in the clip list. + // Does handle windows, e.g. LineDefs with upper and lower texture. + kPass, +}; + +// CPhipps - +// R_ClipWallSegment +// +// Replaces the old R_Clip*WallSegment functions. It draws bits of walls in those +// columns which aren't solid, and updates the solidcol[] array appropriately +template +static void R_ClipWallSegment(int first, int last) +{ + while (first < last) { - if (last < start->first - 1) - { - // Post is entirely visible (above start), so insert a new clippost. - R_StoreWallRange(first, last); - next = newend; - newend++; - // NO MORE CRASHING! - if (newend - solidsegs > MAXSEGS) - I_Error("R_ClipSolidWallSegment: Solid Segs overflow!\n"); + UINT8 *p; - while (next != start) + if (solidcol[first]) + { + p = static_cast(memchr(solidcol+first, 0, last-first)); + if (!p) + return; // All solid + + first = p - solidcol; + } + else + { + p = static_cast(memchr(solidcol+first, 1, last-first)); + + int to; + if (!p) + to = last; + else + to = p - solidcol; + + if constexpr (Type != ClipType::kSolidDontRender) { - *next = *(next-1); - next--; + R_StoreWallRange(first, to-1); } - next->first = first; - next->last = last; - return; - } - // There is a fragment above *start. - R_StoreWallRange(first, start->first - 1); - // Now adjust the clip size. - start->first = first; - } + if constexpr (Type != ClipType::kPass) + { + memset(solidcol+first, 1, to-first); + } - // Bottom contained in start? - if (last <= start->last) - return; - - next = start; - while (last >= (next+1)->first - 1) - { - // There is a fragment between two posts. - R_StoreWallRange(next->last + 1, (next+1)->first - 1); - next++; - - if (last <= next->last) - { - // Bottom is contained in next. - // Adjust the clip size. - start->last = next->last; - goto crunch; + first = to; } } - - // There is a fragment after *next. - R_StoreWallRange(next->last + 1, last); - // Adjust the clip size. - start->last = last; - - // Remove start+1 to next from the clip list, because start now covers their area. -crunch: - if (next == start) - return; // Post just extended past the bottom of one post. - - while (next++ != newend) - *++start = *next; // Remove a post. - - newend = start + 1; - - // NO MORE CRASHING! - if (newend - solidsegs > MAXSEGS) - I_Error("R_ClipSolidWallSegment: Solid Segs overflow!\n"); } -// -// R_ClipPassWallSegment -// Clips the given range of columns, but does not include it in the clip list. -// Does handle windows, e.g. LineDefs with upper and lower texture. -// -static inline void R_ClipPassWallSegment(INT32 first, INT32 last, boolean soliddontrender) -{ - cliprange_t *start; - - // Find the first range that touches the range - // (adjacent pixels are touching). - start = solidsegs; - while (start->last < first - 1) - start++; - - if (first < start->first) - { - if (last < start->first - 1) - { - // Post is entirely visible (above start). - if (!soliddontrender) - R_StoreWallRange(first, last); - return; - } - - // There is a fragment above *start. - if (!soliddontrender) - R_StoreWallRange(first, start->first - 1); - } - - // Bottom contained in start? - if (last <= start->last) - return; - - while (last >= (start+1)->first - 1) - { - // There is a fragment between two posts. - if (!soliddontrender) - R_StoreWallRange(start->last + 1, (start+1)->first - 1); - start++; - - if (last <= start->last) - return; - } - - // There is a fragment after *next. - if (!soliddontrender) - R_StoreWallRange(start->last + 1, last); -} +}; // namespace // // R_ClearClipSegs // void R_ClearClipSegs(void) { - solidsegs[0].first = -0x7fffffff; - solidsegs[0].last = -1; - solidsegs[1].first = viewwidth; - solidsegs[1].last = 0x7fffffff; - newend = solidsegs + 2; + memset(solidcol, 0, viewwidth); } + void R_PortalClearClipSegs(INT32 start, INT32 end) { - solidsegs[0].first = -0x7fffffff; - solidsegs[0].last = start-1; - solidsegs[1].first = end; - solidsegs[1].last = 0x7fffffff; - newend = solidsegs + 2; + R_ClearClipSegs(); + + if (start > 0) + memset(solidcol, 1, start); + + if (end < viewwidth) + memset(solidcol + end, 1, viewwidth - end); } // @@ -264,12 +196,12 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, mobj_t *pviewmobj = viewplayer->mo; INT32 heightsec; boolean underwater; - UINT8 i = R_GetViewNumber(); + camera_t *thiscam = &camera[R_GetViewNumber()]; - if (viewplayer == &players[displayplayers[i]] && camera[i].chase) - heightsec = R_PointInSubsector(camera[i].x, camera[i].y)->sector->heightsec; - else if (i > splitscreen && viewmobj) - heightsec = R_PointInSubsector(pviewmobj->x, pviewmobj->y)->sector->heightsec; + if (thiscam->chase) + heightsec = thiscam->subsector->sector->heightsec; + else if (viewmobj) + heightsec = pviewmobj->subsector->sector->heightsec; else return sec; @@ -389,6 +321,7 @@ static void R_AddLine(seg_t *line) INT32 x1, x2; angle_t angle1, angle2, span, tspan; static sector_t tempsec; + boolean bothfloorssky = false; g_portal = NULL; @@ -405,7 +338,7 @@ static void R_AddLine(seg_t *line) span = angle1 - angle2; // Back side? i.e. backface culling? - if (span >= ANGLE_180 || !line->linedef) + if (span >= ANGLE_180) return; // Global angle needed by segcalc. @@ -424,6 +357,7 @@ static void R_AddLine(seg_t *line) angle1 = clipangle; } + tspan = clipangle - angle2; if (tspan > doubleclipangle) { @@ -439,6 +373,8 @@ static void R_AddLine(seg_t *line) // The seg is in the view range, but not necessarily visible. angle1 = (angle1+ANGLE_90)>>ANGLETOFINESHIFT; angle2 = (angle2+ANGLE_90)>>ANGLETOFINESHIFT; + + // killough 1/31/98: Here is where "slime trails" can SOMETIMES occur: x1 = viewangletox[angle1]; x2 = viewangletox[angle2]; @@ -449,14 +385,16 @@ static void R_AddLine(seg_t *line) backsector = line->backsector; // Portal line - if (line->linedef->special == 40 && line->side == 0) + if (line->linedef->special == PORTALSPECIAL && line->side == 0) { if (portalrender < cv_maxportals.value) { // Find the other side! - INT32 line2 = P_FindSpecialLineFromTag(40, line->linedef->tag, -1); + INT32 line2 = P_FindSpecialLineFromTag(PORTALSPECIAL, line->linedef->tag, -1); + if (line->linedef == &lines[line2]) - line2 = P_FindSpecialLineFromTag(40, line->linedef->tag, line2); + line2 = P_FindSpecialLineFromTag(PORTALSPECIAL, line->linedef->tag, line2); + if (line2 >= 0) // found it! { Portal_Add2Lines(line->linedef-lines, line2, x1, x2); // Remember the lines for later rendering @@ -476,6 +414,10 @@ static void R_AddLine(seg_t *line) doorclosed = 0; + // likewise, but for floors and upper textures + if (backsector->floorpic == skyflatnum && frontsector->floorpic == skyflatnum) + bothfloorssky = true; + fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends fixed_t backf1, backf2, backc1, backc2; // back floor ceiling ends @@ -503,19 +445,19 @@ static void R_AddLine(seg_t *line) if (viewsector != backsector && viewsector != frontsector) { // here we're talking about a CEILING lower than a floor. ...yeah we don't even need to bother. - if (backc1 <= frontf1 && backc2 <= frontf2) + const boolean ceillow = (backc1 <= frontf1 && backc2 <= frontf2); + + // this tries to fix some skyboxes drawing a black void as a midtexture lel + if (ceillow && (!bothfloorssky && backsector->ceilingpic == skyflatnum && frontsector->ceilingpic != skyflatnum) // double sided with back ceiling sky but not front ceiling sky + && !line->sidedef->midtexture && !line->sidedef->bottomtexture && !line->sidedef->toptexture && !line->polyseg) // effectively empty { - goto clipsolid; - } - - // here we're talking about floors higher than ceilings, don't even bother either. - if (backf1 >= frontc1 && backf2 >= frontc2) - { - goto clipsolid; + goto clippass; } + doorclosed = ceillow + || (backf1 >= frontc1 && backf2 >= frontc2) // Check for automap fix. Store in doorclosed for r_segs.c - doorclosed = (backc1 <= backf1 && backc2 <= backf2 + || (backc1 <= backf1 && backc2 <= backf2 && ((backc1 >= frontc1 && backc2 >= frontc2) || curline->sidedef->toptexture) && ((backf1 <= frontf1 && backf2 >= frontf2) || curline->sidedef->bottomtexture) && (backsector->ceilingpic != skyflatnum || frontsector->ceilingpic != skyflatnum)); @@ -540,15 +482,15 @@ static void R_AddLine(seg_t *line) clippass: g_walloffscreen = false; - R_ClipPassWallSegment(x1, x2 - 1, false); + R_ClipWallSegment(x1, x2); if (g_walloffscreen) - R_ClipPassWallSegment(x1, x2 - 1, true); + R_ClipWallSegment(x1, x2); return; clipsolid: g_walloffscreen = false; - R_ClipSolidWallSegment(x1, x2 - 1); + R_ClipWallSegment(x1, x2); } // @@ -581,22 +523,11 @@ static boolean R_CheckBBox(const fixed_t *bspcoord) angle_t angle1, angle2; INT32 sx1, sx2, boxpos; const INT32* check; - cliprange_t *start; - // Find the corners of the box that define the edges from current viewpoint. - if (viewx <= bspcoord[BOXLEFT]) - boxpos = 0; - else if (viewx < bspcoord[BOXRIGHT]) - boxpos = 1; - else - boxpos = 2; - - if (viewy >= bspcoord[BOXTOP]) - boxpos |= 0; - else if (viewy > bspcoord[BOXBOTTOM]) - boxpos |= 1<<2; - else - boxpos |= 2<<2; + // Find the corners of the box + // that define the edges from current viewpoint. + boxpos = (viewx <= bspcoord[BOXLEFT] ? 0 : viewx < bspcoord[BOXRIGHT ] ? 1 : 2) + + (viewy >= bspcoord[BOXTOP ] ? 0 : viewy > bspcoord[BOXBOTTOM] ? 4 : 8); if (boxpos == 5) return true; @@ -607,18 +538,23 @@ static boolean R_CheckBBox(const fixed_t *bspcoord) angle1 = R_PointToAngle64(bspcoord[check[0]], bspcoord[check[1]]) - viewangle; angle2 = R_PointToAngle64(bspcoord[check[2]], bspcoord[check[3]]) - viewangle; - if ((signed)angle1 < (signed)angle2) + // cph - replaced old code, which was unclear and badly commented + // Much more efficient code now + if ((signed)angle1 < (signed)angle2) /* it's "behind" us */ { + /* Either angle1 or angle2 is behind us, so it doesn't matter if we + * change it to the corect sign + */ if ((angle1 >= ANGLE_180) && (angle1 < ANGLE_270)) angle1 = ANGLE_180-1; else angle2 = ANGLE_180; } - if ((signed)angle2 >= (signed)clipangle) return false; - if ((signed)angle1 <= -(signed)clipangle) return false; - if ((signed)angle1 >= (signed)clipangle) angle1 = clipangle; - if ((signed)angle2 <= -(signed)clipangle) angle2 = 0-clipangle; + if ((signed)angle2 >= (signed)clipangle) return false; // Both off left edge + if ((signed)angle1 <= -(signed)clipangle) return false; // Both off right edge + if ((signed)angle1 >= (signed)clipangle) angle1 = clipangle; // Clip at left edge + if ((signed)angle2 <= -(signed)clipangle) angle2 = -(signed)clipangle; // Clip at right edge // Find the first clippost that touches the source post (adjacent pixels are touching). angle1 = (angle1+ANGLE_90)>>ANGLETOFINESHIFT; @@ -630,20 +566,18 @@ static boolean R_CheckBBox(const fixed_t *bspcoord) if (sx1 >= sx2) return false; - start = solidsegs; - while (start->last < sx2) - start++; - - if (sx1 >= start->first && sx2 <= start->last) - return false; // The clippost contains the new span. + if (!memchr(solidcol+sx1, 0, sx2-sx1)) + { + // All columns it covers are already solidly covered + return false; + } return true; } - size_t numpolys; // number of polyobjects in current subsector size_t num_po_ptrs; // number of polyobject pointers allocated -polyobj_t **po_ptrs; // temp ptr array to sort polyobject pointers +polyobj_t **po_ptrs; // temp ptr array to sort polyobject pointers // // R_PolyobjCompare @@ -681,8 +615,7 @@ void R_SortPolyObjects(subsector_t *sub) { // use free instead realloc since faster (thanks Lee ^_^) free(po_ptrs); - po_ptrs = malloc((num_po_ptrs = numpolys*2) - * sizeof(*po_ptrs)); + po_ptrs = static_cast(malloc((num_po_ptrs = numpolys*2)* sizeof(*po_ptrs))); } po = sub->polyList; @@ -699,8 +632,7 @@ void R_SortPolyObjects(subsector_t *sub) // 03/10/06: only bother if there are actually polys to sort if (numpolys >= 2) { - qs22j(po_ptrs, numpolys, sizeof(polyobj_t *), - R_PolyobjCompare); + qs22j(po_ptrs, numpolys, sizeof(polyobj_t *), R_PolyobjCompare); } } } @@ -726,8 +658,8 @@ static int R_PolysegCompare(const void *p1, const void *p2) dist2v1 = vxdist(seg2->v1); dist2v2 = vxdist(seg2->v2); - if (min(dist1v1, dist1v2) != min(dist2v1, dist2v2)) - return min(dist1v1, dist1v2) - min(dist2v1, dist2v2); + if (std::min(dist1v1, dist1v2) != std::min(dist2v1, dist2v2)) + return std::min(dist1v1, dist1v2) - std::min(dist2v1, dist2v2); { // That didn't work, so now let's try this....... fixed_t delta1, delta2, x1, y1, x2, y2; @@ -828,14 +760,15 @@ static void R_Subsector(size_t num) fixed_t floorcenterz, ceilingcenterz; ffloor_t *rover; -#ifdef RANGECHECK - if (num >= numsubsectors) - I_Error("R_Subsector: ss %s with numss = %s\n", sizeu1(num), sizeu2(numsubsectors)); -#endif - // subsectors added at run-time if (num >= numsubsectors) + { +#ifdef RANGECHECK + I_Error("R_Subsector: ss %s with numss = %s\n", sizeu1(num), sizeu2(numsubsectors)); +#else return; +#endif + } sub = &subsectors[num]; frontsector = sub->sector; @@ -1144,7 +1077,7 @@ void R_Prep3DFloors(sector_t *sector) if (count != sector->numlights) { Z_Free(sector->lightlist); - sector->lightlist = Z_Calloc(sizeof (*sector->lightlist) * count, PU_LEVEL, NULL); + sector->lightlist = static_cast(Z_Calloc(sizeof (*sector->lightlist) * count, PU_LEVEL, NULL)); sector->numlights = count; } else @@ -1194,6 +1127,7 @@ void R_Prep3DFloors(sector_t *sector) } } } + if (!best) { sector->numlights = i; diff --git a/src/r_bsp.h b/src/r_bsp.h index 7ba6c330c..b9e4e291d 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -14,6 +14,10 @@ #ifndef __R_BSP__ #define __R_BSP__ +#ifdef __cplusplus +extern "C" { +#endif + #ifdef __GNUG__ #pragma interface #endif @@ -32,14 +36,17 @@ extern portal_t *g_portal; // is curline a portal seg? extern INT32 checkcoord[12][4]; +extern drawseg_t *curdrawsegs; extern drawseg_t *drawsegs; extern drawseg_t *ds_p; extern INT32 doorclosed; +extern UINT8 *solidcol; extern boolean g_walloffscreen; // BSP? void R_ClearClipSegs(void); void R_PortalClearClipSegs(INT32 start, INT32 end); +void R_AllocClipSegMemory(void); void R_ClearDrawSegs(void); void R_RenderBSPNode(INT32 bspnum); @@ -59,4 +66,9 @@ boolean R_IsEmptyLine(seg_t *line, const sector_t *front, const sector_t *back); INT32 R_GetPlaneLight(sector_t *sector, fixed_t planeheight, boolean underside); void R_Prep3DFloors(sector_t *sector); + +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/r_data.c b/src/r_data.c index 0b5b7badf..f3731c3fc 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -100,10 +100,10 @@ INT32 numtextures = 0; // total number of textures found, texture_t **textures = NULL; static UINT32 **texturecolumnofs; // column offset lookup table for each texture -static UINT8 **texturecache; // graphics data for each generated full-size texture +UINT8 **texturecache; // graphics data for each generated full-size texture // texture width is a power of 2, so it can easily repeat along sidedefs using a simple mask -INT32 *texturewidthmask; +static INT32 *texturewidthmask; fixed_t *textureheight; // needed for texture pegging @@ -296,7 +296,7 @@ static inline void R_DrawColumnInCache(column_t *patch, UINT8 *cache, INT32 orig // This is not optimised, but it's supposed to be executed only once // per level, when enough memory is available. // -static UINT8 *R_GenerateTexture(size_t texnum) +UINT8 *R_GenerateTexture(size_t texnum) { UINT8 *block; UINT8 *blocktex; @@ -473,11 +473,28 @@ UINT8 *R_GetColumn(fixed_t tex, INT32 col) { UINT8 *data; - col &= texturewidthmask[tex]; data = texturecache[tex]; + if (texturewidthmask[tex]) + col &= texturewidthmask[tex]; // set by load textures + else + { + const INT16 texwidth = textures[tex]->width; + + // Odd width texture, cannot just mask. + // Sometime gets colnum = -1 or = width, even without tiling. + // Test LostCiv, Map 20, crates. + col = ( col < 0 ) ? + texwidth - (((-col - 1) % texwidth) + 1) + : col % texwidth; + } + if (!data) + { + // This must be here because cache can be freed by other operations. + // To prevent must lock individual texture cache on every draw. data = R_GenerateTexture(tex); + } return data + LONG(texturecolumnofs[tex][col]); } @@ -649,6 +666,7 @@ void R_LoadTextures(void) M_Memcpy(texture->name, W_CheckNameForNumPwad(wadnum, lumpnum), sizeof(texture->name)); texture->width = SHORT(patchlump->width); texture->height = SHORT(patchlump->height); + texture->type = TEXTURETYPE_SINGLEPATCH; texture->patchcount = 1; texture->holes = false; @@ -661,9 +679,23 @@ void R_LoadTextures(void) Z_Free(patchlump); + // determine width power of 2 +#if 1 + // [WDJ] only need to determine if exact power of 2. + k = 1; + while (k < texture->width) + k<<=1; +#else + // Largest power of 2 that fits within width. k = 1; while (k << 1 <= texture->width) k <<= 1; +#endif + if (k != texture->width) + { + // Odd width + k = 1; // make texturewidthmask = 0 + } texturewidthmask[i] = k - 1; textureheight[i] = texture->height << FRACBITS; @@ -915,19 +947,22 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture) // Left Curly Brace texturesToken = M_GetToken(NULL); + if (texturesToken == NULL) { I_Error("Error parsing TEXTURES lump: Unexpected end of file where open curly brace for texture \"%s\" should be",newTextureName); } + if (strcmp(texturesToken,"{")==0) { if (actuallyLoadTexture) { // Allocate memory for a zero-patch texture. Obviously, we'll be adding patches momentarily. - resultTexture = (texture_t *)Z_Calloc(sizeof(texture_t),PU_STATIC,NULL); + resultTexture = (texture_t *)Z_Calloc(sizeof(texture_t), PU_STATIC, NULL); M_Memcpy(resultTexture->name, newTextureName, 8); resultTexture->width = newTextureWidth; resultTexture->height = newTextureHeight; + resultTexture->type = TEXTURETYPE_COMPOSITE; } Z_Free(texturesToken); texturesToken = M_GetToken(NULL); diff --git a/src/r_data.h b/src/r_data.h index f27dd0822..58afc34d0 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -14,6 +14,10 @@ #ifndef __R_DATA__ #define __R_DATA__ +#ifdef __cplusplus +extern "C" { +#endif + #include "r_defs.h" #include "r_state.h" @@ -33,6 +37,14 @@ typedef struct UINT16 wad, lump; } texpatch_t; +// texture type +enum +{ + TEXTURETYPE_UNKNOWN, + TEXTURETYPE_SINGLEPATCH, + TEXTURETYPE_COMPOSITE, +}; + // A maptexturedef_t describes a rectangular texture, // which is composed of one or more mappatch_t structures // that arrange graphic patches. @@ -40,9 +52,9 @@ typedef struct { // Keep name for switch changing, etc. char name[8]; + UINT8 type; // TEXTURETYPE_ INT16 width, height; boolean holes; - // All the patches[patchcount] are drawn back to front into the cached texture. INT16 patchcount; texpatch_t patches[0]; @@ -50,9 +62,7 @@ typedef struct // all loaded and prepared textures from the start of the game extern texture_t **textures; - -// texture width is a power of 2, so it can easily repeat along sidedefs using a simple mask -extern INT32 *texturewidthmask; +extern UINT8 **texturecache; // graphics data for each generated full-size texture extern fixed_t *textureheight; // needed for texture pegging @@ -68,6 +78,8 @@ extern CV_PossibleValue_t Color_cons_t[]; void R_LoadTextures(void); void R_FlushTextureCache(void); +UINT8 *R_GenerateTexture(size_t texnum); + INT32 R_GetTextureNum(INT32 texnum); void R_CheckTextureCache(INT32 tex); @@ -108,4 +120,8 @@ UINT8 NearestPaletteColor(UINT8 r, UINT8 g, UINT8 b, RGBA_t *palette); extern INT32 numtextures; +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/r_defs.h b/src/r_defs.h index a202b49ef..e1fc574bc 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -68,6 +68,37 @@ typedef struct #endif } extracolormap_t; +typedef struct +{ + lighttable_t* colormap; + + INT32 x; + INT32 yl; + INT32 yh; + fixed_t iscale; + fixed_t texturemid; + + UINT8* source; // first pixel in a column + UINT8* lightmap; // lighting only + + // translucency stuff here + UINT8* transmap; + + // translation stuff here + UINT8* translation; + + struct r_lightlist_s* lightlist; + + INT32 numlights; + INT32 maxlights; + + //Fix TUTIFRUTI + INT32 texheight; + INT32 sourcelength; +} drawcolumndata_t; + +extern drawcolumndata_t g_dc; + // // INTERNAL MAP TYPES used by play and refresh // @@ -389,6 +420,7 @@ typedef enum } slopetype_t; #define HORIZONSPECIAL 41 +#define PORTALSPECIAL 40 typedef struct line_s { @@ -527,9 +559,6 @@ typedef struct seg_s float flength; // length of the seg, used by hardware renderer #endif - // Why slow things down by calculating lightlists for every thick side? - size_t numlights; - r_lightlist_t *rlights; polyobj_t *polyseg; boolean dontrenderme; @@ -610,11 +639,11 @@ typedef struct drawseg_s struct ffloor_s *thicksides[MAXFFLOORS]; INT16 *thicksidecol; INT32 numthicksides; - fixed_t frontscale[MAXVIDWIDTH]; + fixed_t *frontscale; UINT8 portalpass; // if > 0 and <= portalrender, do not affect sprite clipping - fixed_t maskedtextureheight[MAXVIDWIDTH]; // For handling sloped midtextures + fixed_t *maskedtextureheight; // For handling sloped midtextures vertex_t leftpos, rightpos; // Used for rendering FOF walls with slopes } drawseg_t; diff --git a/src/r_draw.c b/src/r_draw.cpp similarity index 73% rename from src/r_draw.c rename to src/r_draw.cpp index d54fe90ce..23d512a19 100644 --- a/src/r_draw.c +++ b/src/r_draw.cpp @@ -15,6 +15,8 @@ /// not the architecture of the frame buffer. /// The frame buffer is a linear one, and we need only the base address. +#include + #include "doomdef.h" #include "doomstat.h" #include "r_local.h" @@ -38,47 +40,14 @@ /** \brief view info */ -INT32 viewwidth, scaledviewwidth, viewheight, viewwindowx, viewwindowy; - -/** \brief pointer to the start of each line of the screen, -*/ -UINT8 *ylookup[MAXVIDHEIGHT*4]; - -/** \brief pointer to the start of each line of the screen, for view1 (splitscreen) -*/ -UINT8 *ylookup1[MAXVIDHEIGHT*4]; - -/** \brief pointer to the start of each line of the screen, for view2 (splitscreen) -*/ -UINT8 *ylookup2[MAXVIDHEIGHT*4]; - -/** \brief pointer to the start of each line of the screen, for view3 (splitscreen) -*/ -UINT8 *ylookup3[MAXVIDHEIGHT*4]; - -/** \brief pointer to the start of each line of the screen, for view4 (splitscreen) -*/ -UINT8 *ylookup4[MAXVIDHEIGHT*4]; - -/** \brief x byte offset for columns inside the viewwindow, - so the first column starts at (SCRWIDTH - VIEWWIDTH)/2 -*/ -INT32 columnofs[MAXVIDWIDTH*4]; - -UINT8 *topleft; +INT32 linesize, viewwidth, viewheight, viewwindowx, viewwindowy; +UINT8 *renderscreen; // haleyjd // ========================================================================= // COLUMN DRAWING CODE STUFF // ========================================================================= -lighttable_t *dc_colormap; -INT32 dc_x = 0, dc_yl = 0, dc_yh = 0; - -fixed_t dc_iscale, dc_texturemid; -UINT8 dc_hires; // under MSVC boolean is a byte, while on other systems, it a bit, - // soo lets make it a byte on all system for the ASM code -UINT8 *dc_source; -INT32 dc_sourcelength; +drawcolumndata_t g_dc; // ----------------------- // translucency stuff here @@ -88,42 +57,34 @@ INT32 dc_sourcelength; UINT8 *transtables; // translucency tables UINT8 *blendtables[NUMBLENDMAPS]; -/** \brief R_DrawTransColumn uses this -*/ -UINT8 *dc_transmap; // one of the translucency tables +// -------------------------------------------- +// c drawer routines +// -------------------------------------------- -// ---------------------- -// translation stuff here -// ---------------------- - - -/** \brief R_DrawTranslatedColumn uses this -*/ -UINT8 *dc_translation; - -struct r_lightlist_s *dc_lightlist = NULL; -INT32 dc_numlights = 0, dc_maxlights, dc_texheight; +coldrawfunc_t *colfunc; +coldrawfunc_t *colfuncs[COLDRAWFUNC_MAX]; +int colfunctype; // ========================================================================= // SPAN DRAWING CODE STUFF // ========================================================================= -INT32 ds_y, ds_x1, ds_x2; -lighttable_t *ds_colormap; -fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep; - -UINT8 *ds_source; // points to the start of a flat -UINT8 *ds_transmap; // one of the translucency tables +drawspandata_t g_ds; // Vectors for Software's tilted slope drawers floatv3_t *ds_su, *ds_sv, *ds_sz; -floatv3_t *ds_sup, *ds_svp, *ds_szp; -float focallengthf, zeroheight; -/** \brief Variable flat sizes -*/ +float focallengthf; -UINT32 nflatxshift, nflatyshift, nflatshiftup, nflatmask; +// For, uh, tilted lighting, duh. +//static INT32 *tiltlighting; + +// -------------------------------------------- +// c drawer routines +// -------------------------------------------- + +spandrawfunc_t *spanfunc; +spandrawfunc_t *spanfuncs[SPANDRAWFUNC_MAX]; // ========================================================================== // OLD DOOM FUZZY EFFECT @@ -147,73 +108,10 @@ UINT32 nflatxshift, nflatyshift, nflatshiftup, nflatmask; static UINT8 **translationtablecache[TT_CACHE_SIZE] = {NULL}; static UINT8 **localtranslationtablecache[MAXLOCALSKINS] = {NULL}; - -// See also the enum skincolors_t -// TODO Callum: Can this be translated? -/* -const char *Color_Names[MAXSKINCOLORS] = -{ - "None", // SKINCOLOR_NONE - "White", // SKINCOLOR_WHITE - "Silver", // SKINCOLOR_SILVER - "Grey", // SKINCOLOR_GREY - "Black", // SKINCOLOR_BLACK - "Cyan", // SKINCOLOR_CYAN - "Teal", // SKINCOLOR_TEAL - "Steel_Blue",// SKINCOLOR_STEEL - "Blue", // SKINCOLOR_BLUE - "Peach", // SKINCOLOR_PEACH - "Tan", // SKINCOLOR_TAN - "Pink", // SKINCOLOR_PINK - "Lavender", // SKINCOLOR_LAVENDER - "Purple", // SKINCOLOR_PURPLE - "Orange", // SKINCOLOR_ORANGE - "Rosewood", // SKINCOLOR_ROSEWOOD - "Beige", // SKINCOLOR_BEIGE - "Brown", // SKINCOLOR_BROWN - "Red", // SKINCOLOR_RED - "Dark_Red", // SKINCOLOR_DARKRED - "Neon_Green",// SKINCOLOR_NEONGREEN - "Green", // SKINCOLOR_GREEN - "Zim", // SKINCOLOR_ZIM - "Olive", // SKINCOLOR_OLIVE - "Yellow", // SKINCOLOR_YELLOW - "Gold" // SKINCOLOR_GOLD -}; - -const UINT8 Color_Opposite[MAXSKINCOLORS*2] = -{ - SKINCOLOR_NONE,8, // SKINCOLOR_NONE - SKINCOLOR_BLACK,10, // SKINCOLOR_WHITE - SKINCOLOR_GREY,4, // SKINCOLOR_SILVER - SKINCOLOR_SILVER,12,// SKINCOLOR_GREY - SKINCOLOR_WHITE,8, // SKINCOLOR_BLACK - SKINCOLOR_NONE,8, // SKINCOLOR_CYAN - SKINCOLOR_NONE,8, // SKINCOLOR_TEAL - SKINCOLOR_NONE,8, // SKINCOLOR_STEEL - SKINCOLOR_ORANGE,9, // SKINCOLOR_BLUE - SKINCOLOR_NONE,8, // SKINCOLOR_PEACH - SKINCOLOR_NONE,8, // SKINCOLOR_TAN - SKINCOLOR_NONE,8, // SKINCOLOR_PINK - SKINCOLOR_NONE,8, // SKINCOLOR_LAVENDER - SKINCOLOR_NONE,8, // SKINCOLOR_PURPLE - SKINCOLOR_BLUE,12, // SKINCOLOR_ORANGE - SKINCOLOR_NONE,8, // SKINCOLOR_ROSEWOOD - SKINCOLOR_NONE,8, // SKINCOLOR_BEIGE - SKINCOLOR_NONE,8, // SKINCOLOR_BROWN - SKINCOLOR_GREEN,5, // SKINCOLOR_RED - SKINCOLOR_NONE,8, // SKINCOLOR_DARKRED - SKINCOLOR_NONE,8, // SKINCOLOR_NEONGREEN - SKINCOLOR_RED,11, // SKINCOLOR_GREEN - SKINCOLOR_PURPLE,3, // SKINCOLOR_ZIM - SKINCOLOR_NONE,8, // SKINCOLOR_OLIVE - SKINCOLOR_NONE,8, // SKINCOLOR_YELLOW - SKINCOLOR_NONE,8 // SKINCOLOR_GOLD -}; -*/ - CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1]; +static void R_GenerateBlendTables(void); + /** \brief Initializes the translucency tables used by the Software renderer. */ void R_InitTranslucencyTables(void) @@ -221,8 +119,7 @@ void R_InitTranslucencyTables(void) // Load here the transparency lookup tables 'TRANSx0' // NOTE: the TRANSx0 resources MUST BE aligned on 64k for the asm // optimised code (in other words, transtables pointer low word is 0) - transtables = Z_MallocAlign(NUMTRANSTABLES*0x10000, PU_STATIC, - NULL, 16); + transtables = static_cast(Z_MallocAlign(NUMTRANSTABLES*0x10000, PU_STATIC, NULL, 16)); W_ReadLump(W_GetNumForName("TRANS10"), transtables); W_ReadLump(W_GetNumForName("TRANS20"), transtables+0x10000); @@ -283,10 +180,10 @@ static void BlendTab_Subtractive(UINT8 *table, int style, UINT8 blendamt) RGBA_t frontrgba = V_GetColor(fg); RGBA_t result; - result.rgba = ASTBlendPixel(backrgba, frontrgba, style, 0xFF); - result.s.red = max(0, result.s.red - blendamt); - result.s.green = max(0, result.s.green - blendamt); - result.s.blue = max(0, result.s.blue - blendamt); + result.rgba = ASTBlendPixel(backrgba, frontrgba, style, 0xFF); + result.s.red = std::max(0, result.s.red - blendamt); + result.s.green = std::max(0, result.s.green - blendamt); + result.s.blue = std::max(0, result.s.blue - blendamt); table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut, result.s.red, result.s.green, result.s.blue); } @@ -339,17 +236,17 @@ static void BlendTab_GenerateMaps(INT32 tab, INT32 style, void (*genfunc)(UINT8 for (; i < num; i++) { const size_t offs = (0x10000 * i); - const UINT16 alpha = min(amtmul * i, 0xFF); + const UINT16 alpha = std::fmin(amtmul * i, 0xFF); genfunc(blendtables[tab] + offs, style, alpha); } } -void R_GenerateBlendTables(void) +static void R_GenerateBlendTables(void) { INT32 i; for (i = 0; i < NUMBLENDMAPS; i++) - blendtables[i] = Z_MallocAlign(BlendTab_Count[i] * 0x10000, PU_STATIC, NULL, 16); + blendtables[i] = static_cast(Z_MallocAlign(BlendTab_Count[i] * 0x10000, PU_STATIC, NULL, 16)); InitColorLUT(&transtab_lut, pLocalPalette, false); @@ -370,8 +267,8 @@ void R_GenerateBlendTables(void) BlendTab_Modulative(blendtables[blendtab_modulate]); } -#define ClipBlendLevel(style, trans) max(min((trans), BlendTab_Count[BlendTab_FromStyle[style]]-1), 0) -#define ClipTransLevel(trans) max(min((trans), NUMTRANSMAPS-2), 0) +#define ClipBlendLevel(style, trans) std::max(std::min((trans), BlendTab_Count[BlendTab_FromStyle[style]]-1), 0) +#define ClipTransLevel(trans) std::max(std::min((trans), NUMTRANSMAPS-2), 0) UINT8 *R_GetTranslucencyTable(INT32 alphalevel) { @@ -458,7 +355,7 @@ static UINT8* RGetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 f { // Allocate table for skin if necessary if (!tt[skintableindex]) - tt[skintableindex] = Z_Calloc(MAXTRANSLATIONS * sizeof(UINT8**), PU_STATIC, NULL); + tt[skintableindex] = static_cast(Z_Calloc(MAXTRANSLATIONS * sizeof(UINT8**), PU_STATIC, NULL)); // Get colormap ret = tt[skintableindex][color]; @@ -468,7 +365,7 @@ static UINT8* RGetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 f // Generate the colormap if necessary if (!ret) { - ret = Z_MallocAlign(NUM_PALETTE_ENTRIES, (flags & GTC_CACHE) ? PU_LEVEL : PU_STATIC, NULL, 8); + ret = static_cast(Z_MallocAlign(NUM_PALETTE_ENTRIES, (flags & GTC_CACHE) ? PU_LEVEL : PU_STATIC, NULL, 8)); K_GenerateKartColormap(ret, skinnum, color, local); //R_GenerateTranslationColormap(ret, skinnum, color); // SRB2kart // Cache the colormap if desired @@ -540,19 +437,6 @@ void R_FlushTranslationColormapCache(void) memset(localtranslationtablecache[i], 0, MAXTRANSLATIONS * sizeof(UINT8**)); } -/* -UINT8 R_GetColorByName(const char *name) -{ - UINT8 color = (UINT8)atoi(name); - if (color > 0 && color < MAXSKINCOLORS) - return color; - for (color = 1; color < MAXSKINCOLORS; color++) - if (!stricmp(Color_Names[color], name)) - return color; - return 0; -} -*/ - // ========================================================================== // COMMON DRAWER FOR 8 AND 16 BIT COLOR MODES // ========================================================================== @@ -572,39 +456,44 @@ UINT8 R_GetColorByName(const char *name) \param height hieght of buffer \return void - - */ +static void R_AllocViewMemory(void) +{ + negonearray = static_cast(Z_Realloc(negonearray, sizeof(*negonearray) * viewwidth, PU_STATIC, NULL)); + screenheightarray = static_cast(Z_Realloc(screenheightarray, sizeof(*screenheightarray) * viewwidth, PU_STATIC, NULL)); + + floorclip = static_cast(Z_Realloc(floorclip, sizeof(*floorclip) * viewwidth, PU_STATIC, NULL)); + ceilingclip = static_cast(Z_Realloc(ceilingclip, sizeof(*ceilingclip) * viewwidth, PU_STATIC, NULL)); + + frontscale = static_cast(Z_Realloc(frontscale, sizeof(*frontscale) * viewwidth, PU_STATIC, NULL)); + + xtoviewangle = static_cast(Z_Realloc(xtoviewangle, sizeof(*xtoviewangle) * (viewwidth + 1), PU_STATIC, NULL)); + + R_AllocSegMemory(); + R_AllocClipSegMemory(); + R_AllocPlaneMemory(); +#ifdef FLOORSPLATS + R_AllocFloorSpriteTables(); +#endif + R_AllocVisSpriteMemory(); +} + + void R_InitViewBuffer(INT32 width, INT32 height) { - INT32 i, bytesperpixel = vid.bpp; - if (width > MAXVIDWIDTH) width = MAXVIDWIDTH; if (height > MAXVIDHEIGHT) height = MAXVIDHEIGHT; - if (bytesperpixel < 1 || bytesperpixel > 4) - I_Error("R_InitViewBuffer: wrong bytesperpixel value %d\n", bytesperpixel); + + R_AllocViewMemory(); viewwindowx = 0; viewwindowy = 0; - // Column offset for those columns of the view window, but relative to the entire screen - for (i = 0; i < width; i++) - columnofs[i] = (viewwindowx + i) * bytesperpixel; - - // Precalculate all row offsets. - for (i = 0; i < height; i++) - { - ylookup[i] = ylookup1[i] = screens[0] + i*vid.width*bytesperpixel; - if (splitscreen == 1) - ylookup2[i] = screens[0] + (i+viewheight)*vid.width*bytesperpixel; - else - ylookup2[i] = screens[0] + i*vid.width*bytesperpixel + (viewwidth*bytesperpixel); - ylookup3[i] = screens[0] + (i+viewheight)*vid.width*bytesperpixel; - ylookup4[i] = screens[0] + (i+viewheight)*vid.width*bytesperpixel + (viewwidth*bytesperpixel); - } + linesize = vid.width; // killough 11/98 + renderscreen = vid.screens[0]; // haleyjd 07/02/14 } /** \brief viewborder patches lump numbers @@ -626,6 +515,28 @@ void R_InitViewBorder(void) viewborderlump[BRDR_BR] = W_GetNumForName("brdr_br"); } +/** \brief The R_VideoErase function + + Copy a screen buffer. + + \param ofs offest from buffer + \param count bytes to erase + + \return void + + +*/ +void R_VideoErase(size_t ofs, INT32 count) +{ + // LFB copy. + // This might not be a good idea if memcpy + // is not optimal, e.g. byte by byte on + // a 32bit CPU, as GNU GCC/Linux libc did + // at one point. + M_Memcpy(vid.screens[0] + ofs, vid.screens[1] + ofs, count); +} + + #if 0 /** \brief R_FillBackScreen @@ -648,7 +559,7 @@ void R_FillBackScreen(void) return; src = scr_borderpatch; - dest = screens[1]; + dest = vid.screens[1]; for (y = 0; y < vid.height; y++) { @@ -699,30 +610,7 @@ void R_FillBackScreen(void) V_DrawPatch(viewwindowx + scaledviewwidth, viewwindowy + viewheight, 1, W_CacheLumpNum(viewborderlump[BRDR_BR], PU_CACHE)); } -#endif -/** \brief The R_VideoErase function - - Copy a screen buffer. - - \param ofs offest from buffer - \param count bytes to erase - - \return void - - -*/ -void R_VideoErase(size_t ofs, INT32 count) -{ - // LFB copy. - // This might not be a good idea if memcpy - // is not optimal, e.g. byte by byte on - // a 32bit CPU, as GNU GCC/Linux libc did - // at one point. - M_Memcpy(screens[0] + ofs, screens[1] + ofs, count); -} - -#if 0 /** \brief The R_DrawViewBorder Draws the border around the view @@ -766,13 +654,14 @@ void R_DrawViewBorder(void) side <<= 1; // simpler using our VID_Blit routine - VID_BlitLinearScreen(screens[1] + ofs, screens[0] + ofs, side, viewheight - 1, + VID_BlitLinearScreen(vid.screens[1] + ofs, vid.screens[0] + ofs, side, viewheight - 1, vid.width, vid.width); } #endif // ========================================================================== -// INCLUDE 8bpp DRAWING CODE HERE +// INCLUDE DRAWING CODE HERE // ========================================================================== -#include "r_draw8.c" +#include "r_draw_column.cpp" +#include "r_draw_span.cpp" diff --git a/src/r_draw.h b/src/r_draw.h index 6e5758dd5..763375709 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -14,72 +14,143 @@ #ifndef __R_DRAW__ #define __R_DRAW__ +#ifdef __cplusplus +extern "C" { +#endif + #include "r_defs.h" #include "r_things.h" +#include "r_skins.h" // ------------------------------- // COMMON STUFF FOR 8bpp AND 16bpp // ------------------------------- -extern UINT8 *ylookup[MAXVIDHEIGHT*4]; -extern UINT8 *ylookup1[MAXVIDHEIGHT*4]; -extern UINT8 *ylookup2[MAXVIDHEIGHT*4]; -extern UINT8 *ylookup3[MAXVIDHEIGHT*4]; -extern UINT8 *ylookup4[MAXVIDHEIGHT*4]; -extern INT32 columnofs[MAXVIDWIDTH*4]; -extern UINT8 *topleft; +extern UINT8 *renderscreen; +extern INT32 linesize; -// ------------------------- -// COLUMN DRAWING CODE STUFF -// ------------------------- +FUNCINLINE static ATTRINLINE UINT8 *R_Address(INT32 px, INT32 py) +{ + return renderscreen + (py + viewwindowy) * linesize + (viewwindowx + px); +} -extern lighttable_t *dc_colormap; -extern INT32 dc_x, dc_yl, dc_yh; -extern fixed_t dc_iscale, dc_texturemid; -extern UINT8 dc_hires; - -extern UINT8 *dc_source; // first pixel in a column - -// translucency stuff here -extern UINT8 *dc_transmap; - -// translation stuff here - -extern UINT8 *dc_translation; - -extern struct r_lightlist_s *dc_lightlist; -extern INT32 dc_numlights, dc_maxlights; - -//Fix TUTIFRUTI -extern INT32 dc_texheight; - -// ----------------------- -// SPAN DRAWING CODE STUFF -// ----------------------- - -extern INT32 ds_y, ds_x1, ds_x2; -extern lighttable_t *ds_colormap; -extern fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep; -extern INT32 ds_waterofs, ds_bgofs; -extern UINT8 *ds_source; // start of a 64*64 tile image -extern INT32 dc_sourcelength; -extern UINT8 *ds_transmap; - -extern INT32 ds_bgofs; typedef struct { float x, y, z; } floatv3_t; +typedef struct +{ + INT32 y; + INT32 x1; + INT32 x2; + lighttable_t* colormap; + lighttable_t* translation; + + fixed_t xfrac; + fixed_t yfrac; + fixed_t xstep; + fixed_t ystep; + INT32 waterofs; + INT32 bgofs; + + fixed_t xoffs; + fixed_t yoffs; + + visplane_t *currentplane; + UINT8 *source; + UINT8 *transmap; + + float zeroheight; + + // Vectors for Software's tilted slope drawers + floatv3_t sup; + floatv3_t svp; + floatv3_t szp; + floatv3_t slope_origin; + floatv3_t slope_u; + floatv3_t slope_v; + + // Variable flat sizes + UINT32 nflatxshift; + UINT32 nflatyshift; + UINT32 nflatshiftup; + UINT32 nflatmask; + + fixed_t planeheight; + lighttable_t **planezlight; + + // + // Water ripple effect + // Needs the height of the plane, and the vertical position of the span. + // Sets planeripple.xfrac and planeripple.yfrac, added to ds_xfrac and ds_yfrac, if the span is not tilted. + // + struct + { + INT32 offset; + fixed_t xfrac, yfrac; + boolean active; + } planeripple; +} drawspandata_t; + +extern drawspandata_t g_ds; + +// Draws a single visplane. +void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_parallel); + // Vectors for Software's tilted slope drawers extern floatv3_t *ds_su, *ds_sv, *ds_sz; -extern floatv3_t *ds_sup, *ds_svp, *ds_szp; -extern float focallengthf, zeroheight; -// Variable flat sizes -extern UINT32 nflatxshift; -extern UINT32 nflatyshift; -extern UINT32 nflatshiftup; -extern UINT32 nflatmask; +extern float focallengthf; + + +typedef void (coldrawfunc_t)(drawcolumndata_t*); +typedef void (spandrawfunc_t)(drawspandata_t*); + +#define BASEDRAWFUNC 0 + +enum +{ + COLDRAWFUNC_BASE = BASEDRAWFUNC, + COLDRAWFUNC_FUZZY, + COLDRAWFUNC_TRANS, + COLDRAWFUNC_SHADOWED, + COLDRAWFUNC_TRANSTRANS, + COLDRAWFUNC_TWOSMULTIPATCH, + COLDRAWFUNC_TWOSMULTIPATCHTRANS, + COLDRAWFUNC_FOG, + + COLDRAWFUNC_MAX +}; + +extern int colfunctype; +extern coldrawfunc_t *colfunc; +extern coldrawfunc_t *colfuncs[COLDRAWFUNC_MAX]; + +enum +{ + SPANDRAWFUNC_BASE = BASEDRAWFUNC, + SPANDRAWFUNC_TRANS, + SPANDRAWFUNC_TILTED, + SPANDRAWFUNC_TILTEDTRANS, + + SPANDRAWFUNC_SPLAT, + SPANDRAWFUNC_TRANSSPLAT, + SPANDRAWFUNC_TILTEDSPLAT, + SPANDRAWFUNC_TILTEDTRANSSPLAT, + + SPANDRAWFUNC_WATER, + SPANDRAWFUNC_TILTEDWATER, + + SPANDRAWFUNC_FOG, + SPANDRAWFUNC_TILTEDFOG, + + SPANDRAWFUNC_MAX +}; + +extern spandrawfunc_t *spanfunc; +extern spandrawfunc_t *spanfuncs[SPANDRAWFUNC_MAX]; + +void R_DrawMaskedColumn(drawcolumndata_t* dc, column_t *column); /// \brief Top border #define BRDR_T 0 @@ -108,12 +179,15 @@ extern lumpnum_t viewborderlump[8]; #define GTC_MENUCACHE GTC_CACHE //@TODO Add a separate caching mechanism for menu colormaps distinct from in-level GTC_CACHE. For now this is still preferable to memory leaks... -#define TC_DEFAULT -1 -#define TC_BOSS -2 -#define TC_METALSONIC -3 // For Metal Sonic battle -#define TC_ALLWHITE -4 // For Cy-Brak-demon -#define TC_RAINBOW -5 // For invincibility power -#define TC_BLINK -6 // For item blinking +enum +{ + TC_BLINK = -6, // For item blinking, according to kart + TC_RAINBOW, // For single colour + TC_ALLWHITE, // For Cy-Brak-demon + TC_METALSONIC, // For Metal Sonic battle + TC_BOSS, + TC_DEFAULT +}; // Initialize color translation tables, for player rendering etc. UINT8* R_GetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 flags); @@ -138,7 +212,6 @@ enum extern UINT8 *blendtables[NUMBLENDMAPS]; void R_InitTranslucencyTables(void); -void R_GenerateBlendTables(void); UINT8 *R_GetTranslucencyTable(INT32 alphalevel); UINT8 *R_GetBlendTable(int style, INT32 alphalevel); @@ -161,33 +234,44 @@ void R_DrawViewBorder(void); #define TRANSPARENTPIXEL 247 // ----------------- -// 8bpp DRAWING CODE +// DRAWING CODE // ----------------- -void R_DrawColumn_8(void); -#define R_DrawWallColumn_8 R_DrawColumn_8 -void R_DrawShadeColumn_8(void); -void R_DrawTranslucentColumn_8(void); +// column drawers +void R_DrawColumn(drawcolumndata_t* dc); +void R_DrawColumnShadowed(drawcolumndata_t* dc); -void R_DrawTranslatedColumn_8(void); -void R_DrawTranslatedTranslucentColumn_8(void); -void R_DrawSpan_8(void); -void R_CalcTiltedLighting(fixed_t start, fixed_t end); -void R_DrawTiltedSpan_8(void); -void R_DrawTiltedTranslucentSpan_8(void); -#ifndef NOWATER -void R_DrawTiltedTranslucentWaterSpan_8(void); +void R_DrawTranslucentColumn(drawcolumndata_t* dc); + +void R_DrawTranslatedColumn(drawcolumndata_t* dc); +void R_DrawTranslatedTranslucentColumn(drawcolumndata_t* dc); + +void R_Draw2sMultiPatchColumn(drawcolumndata_t* dc); +void R_Draw2sMultiPatchTranslucentColumn(drawcolumndata_t* dc); + +void R_DrawFogColumn(drawcolumndata_t* dc); + +// span drawers +void R_DrawSpan(drawspandata_t* ds); + +void R_DrawSpan_Tilted(drawspandata_t* ds); +void R_DrawTranslucentSpan_Tilted(drawspandata_t* ds); +void R_DrawTranslucentWaterSpan_Tilted(drawspandata_t* ds); + +void R_DrawTranslucentSpan(drawspandata_t* ds); +void R_DrawTranslucentWaterSpan(drawspandata_t* ds); + +void R_DrawFogSpan(drawspandata_t* ds); +void R_DrawFogSpan_Tilted(drawspandata_t* ds); + +void R_DrawSplat_Tilted(drawspandata_t* ds); +void R_DrawSplat(drawspandata_t* ds); +void R_DrawTranslucentSplat(drawspandata_t* ds); +void R_DrawTranslucentSplat_Tilted(drawspandata_t* ds); + +#ifdef __cplusplus +} // extern "C" #endif -void R_DrawTiltedSplat_8(void); -void R_DrawSplat_8(void); -void R_DrawTranslucentSplat_8(void); -void R_DrawTranslucentSpan_8(void); -void R_DrawTranslucentWaterSpan_8(void); -void R_Draw2sMultiPatchColumn_8(void); -void R_Draw2sMultiPatchTranslucentColumn_8(void); -void R_DrawFogSpan_8(void); -void R_DrawFogColumn_8(void); -void R_DrawColumnShadowed_8(void); // ========================================================================= #endif // __R_DRAW__ diff --git a/src/r_draw8.c b/src/r_draw8.c deleted file mode 100644 index 6edc9d6a6..000000000 --- a/src/r_draw8.c +++ /dev/null @@ -1,1814 +0,0 @@ -// SONIC ROBO BLAST 2 -//----------------------------------------------------------------------------- -// Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. -// -// This program is free software distributed under the -// terms of the GNU General Public License, version 2. -// See the 'LICENSE' file for more details. -//----------------------------------------------------------------------------- -/// \file r_draw8.c -/// \brief 8bpp span/column drawer functions -/// \note no includes because this is included as part of r_draw.c - -// ========================================================================== -// COLUMNS -// ========================================================================== - -// A column is a vertical slice/span of a wall texture that uses -// a has a constant z depth from top to bottom. -// - -/** \brief The R_DrawColumn_8 function - Experiment to make software go faster. Taken from the Boom source -*/ -void R_DrawColumn_8(void) -{ - INT32 count; - UINT8 *restrict dest; - intptr_t frac; - intptr_t fracstep; - INT32 npow2min; - INT32 npow2max; - - count = dc_yh - dc_yl; - - if (count < 0) // Zero length, column does not exceed a pixel. - { - return; - } - - - if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) - { - return; - } - - // Framebuffer destination address. - // Use ylookup LUT to avoid multiply with ScreenWidth. - // Use columnofs LUT for subwindows? - dest = &topleft[dc_yl*vid.width + dc_x]; - - count++; - - // Determine scaling, which is the only mapping to be done. - fracstep = dc_iscale; - frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); - - // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. - // This is as fast as it gets. - const UINT8 *restrict source = dc_source; - const lighttable_t *restrict colormap = dc_colormap; - - intptr_t heightmask = dc_sourcelength-1; - npow2min = -1; - npow2max = dc_sourcelength; - - if (dc_sourcelength & heightmask) // not a power of 2 -- killough - { - heightmask = dc_texheight << FRACBITS; - - if (frac < 0) - { - while ((frac += heightmask) < 0) - { - ; - } - } - else - { - while (frac >= heightmask) - { - frac -= heightmask; - } - } - - do - { - // Re-map color indices from wall texture column - // using a lighting/special effects LUT. - // heightmask is the Tutti-Frutti fix - - // -1 is the lower clamp bound because column posts have a "safe" byte before the real data - // and a few bytes after as well - - // jartha: faster on my AMD FX-6300 CPU. - // Faster than ternaries, faster than std::min/std::max. Don't ask me why. - // I tested by viewing a non-PO2 texture from a consistent distance so it covered the entire screen. - // The framerate difference was about 50 frames at 640x400. - INT32 n = frac >> FRACBITS; - if (n < npow2min) - n = npow2min; - if (n > npow2max) - n = npow2max; - *dest = colormap[source[n]]; - - dest += vid.width; - - -#if __SIZEOF_POINTER__ < 8 // 64-bit systems have large enough numbers for this to be a non-issue - // Avoid overflow. - if (fracstep > 0x7FFFFFFF - frac) - { - frac += fracstep - heightmask; - } - else -#endif - { - frac += fracstep; - } - - while (frac >= heightmask) - { - frac -= heightmask; - } - } while (--count); - } - else - { - while ((count -= 2) >= 0) // texture height is a power of 2 - { - *dest = colormap[source[(frac>>FRACBITS) & heightmask]]; - - dest += vid.width; - frac += fracstep; - - *dest = colormap[source[(frac>>FRACBITS) & heightmask]]; - - dest += vid.width; - frac += fracstep; - } - - if (count & 1) - { - *dest = colormap[source[(frac>>FRACBITS) & heightmask]]; - } - } -} - - -void R_Draw2sMultiPatchColumn_8(void) -{ - INT32 count; - UINT8 *restrict dest; - intptr_t frac; - intptr_t fracstep; - - INT32 npow2min; - INT32 npow2max; - - count = dc_yh - dc_yl; - - if (count < 0) // Zero length, column does not exceed a pixel. - { - return; - } - - if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) - { - return; - } - - // Framebuffer destination address. - // Use ylookup LUT to avoid multiply with ScreenWidth. - // Use columnofs LUT for subwindows? - dest = &topleft[dc_yl*vid.width + dc_x]; - - count++; - - // Determine scaling, which is the only mapping to be done. - fracstep = dc_iscale; - frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); - - // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. - // This is as fast as it gets. - const UINT8 *restrict source = dc_source; - const lighttable_t *restrict colormap = dc_colormap; - intptr_t heightmask = dc_sourcelength-1; - UINT8 val; - - npow2min = -1; - npow2max = dc_sourcelength; - - if (dc_sourcelength & heightmask) // not a power of 2 -- killough - { - heightmask = dc_texheight << FRACBITS; - - if (frac < 0) - { - while ((frac += heightmask) < 0) - { - ; - } - } - else - { - while (frac >= heightmask) - { - frac -= heightmask; - } - } - - do - { - // Re-map color indices from wall texture column - // using a lighting/special effects LUT. - // heightmask is the Tutti-Frutti fix - - // -1 is the lower clamp bound because column posts have a "safe" byte before the real data - // and a few bytes after as well - - // jartha: faster on my AMD FX-6300 CPU. - // Faster than ternaries, faster than std::min/std::max. Don't ask me why. - // I tested by viewing a non-PO2 texture from a consistent distance so it covered the entire screen. - // The framerate difference was about 50 frames at 640x400. - INT32 n = frac >> FRACBITS; - if (n < npow2min) - n = npow2min; - if (n > npow2max) - n = npow2max; - - val = source[n]; - - if (val != TRANSPARENTPIXEL) - { - *dest = colormap[val]; - } - - dest += vid.width; - - // Avoid overflow. -#if __SIZEOF_POINTER__ < 8 - if (fracstep > 0x7FFFFFFF - frac) - { - frac += fracstep - heightmask; - } - else -#endif - { - frac += fracstep; - } - - while (frac >= heightmask) - { - frac -= heightmask; - } - } while (--count); - } - else - { - while ((count -= 2) >= 0) // texture height is a power of 2 - { - val = source[(frac>>FRACBITS) & heightmask]; - if (val != TRANSPARENTPIXEL) - { - *dest = colormap[val]; - } - - dest += vid.width; - frac += fracstep; - - val = source[(frac>>FRACBITS) & heightmask]; - if (val != TRANSPARENTPIXEL) - { - *dest = colormap[val]; - } - - dest += vid.width; - frac += fracstep; - } - - if (count & 1) - { - val = source[(frac>>FRACBITS) & heightmask]; - if (val != TRANSPARENTPIXEL) - { - *dest = colormap[val]; - } - } - } -} - -void R_Draw2sMultiPatchTranslucentColumn_8(void) -{ - INT32 count; - UINT8 *restrict dest; - intptr_t frac; - intptr_t fracstep; - - INT32 npow2min; - INT32 npow2max; - - count = dc_yh - dc_yl; - - if (count < 0) // Zero length, column does not exceed a pixel. - { - return; - } - - if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) - { - return; - } - - // Framebuffer destination address. - // Use ylookup LUT to avoid multiply with ScreenWidth. - // Use columnofs LUT for subwindows? - dest = &topleft[dc_yl*vid.width + dc_x]; - - count++; - - // Determine scaling, which is the only mapping to be done. - fracstep = dc_iscale; - frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); - - // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. - // This is as fast as it gets. - const UINT8 *restrict source = dc_source; - const UINT8 *transmap = dc_transmap; - const lighttable_t *restrict colormap = dc_colormap; - intptr_t heightmask = dc_sourcelength-1; - register UINT8 val; - - npow2min = -1; - npow2max = dc_sourcelength; - - if (dc_sourcelength & heightmask) // not a power of 2 -- killough - { - heightmask = dc_texheight << FRACBITS; - - if (frac < 0) - { - while ((frac += heightmask) < 0) - { - ; - } - } - else - { - while (frac >= heightmask) - { - frac -= heightmask; - } - } - - do - { - // Re-map color indices from wall texture column - // using a lighting/special effects LUT. - // heightmask is the Tutti-Frutti fix - - // -1 is the lower clamp bound because column posts have a "safe" byte before the real data - // and a few bytes after as well - - // jartha: faster on my AMD FX-6300 CPU. - // Faster than ternaries, faster than std::min/std::max. Don't ask me why. - // I tested by viewing a non-PO2 texture from a consistent distance so it covered the entire screen. - // The framerate difference was about 50 frames at 640x400. - INT32 n = frac >> FRACBITS; - if (n < npow2min) - n = npow2min; - if (n > npow2max) - n = npow2max; - - val = source[n]; - - if (val != TRANSPARENTPIXEL) - { - *dest = *(transmap + (colormap[val]<<8) + (*dest)); - } - - dest += vid.width; - - // Avoid overflow. -#if __SIZEOF_POINTER__ < 8 - if (fracstep > 0x7FFFFFFF - frac) - { - frac += fracstep - heightmask; - } - else -#endif - { - frac += fracstep; - } - - while (frac >= heightmask) - { - frac -= heightmask; - } - } while (--count); - } - else - { - while ((count -= 2) >= 0) // texture height is a power of 2 - { - val = source[(frac>>FRACBITS) & heightmask]; - if (val != TRANSPARENTPIXEL) - { - *dest = *(transmap + (colormap[val]<<8) + (*dest)); - } - - dest += vid.width; - frac += fracstep; - - val = source[(frac>>FRACBITS) & heightmask]; - if (val != TRANSPARENTPIXEL) - { - *dest = *(transmap + (colormap[val]<<8) + (*dest)); - } - - dest += vid.width; - frac += fracstep; - } - - if (count & 1) - { - val = source[(frac>>FRACBITS) & heightmask]; - if (val != TRANSPARENTPIXEL) - { - *dest = *(transmap + (colormap[val]<<8) + (*dest)); - } - } - } -} - -/** \brief The R_DrawShadeColumn_8 function - Experiment to make software go faster. Taken from the Boom source -*/ -void R_DrawShadeColumn_8(void) -{ - register INT32 count; - register UINT8 *dest; - register fixed_t frac, fracstep; - - // check out coords for src* - if ((dc_yl < 0) || (dc_x >= vid.width)) - return; - - count = dc_yh - dc_yl; - - if (count < 0) // Zero length, column does not exceed a pixel. - { - return; - } - - if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) - { - return; - } - - // FIXME. As above. - dest = &topleft[dc_yl*vid.width + dc_x]; - - // Looks familiar. - fracstep = dc_iscale; - frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); - - // Here we do an additional index re-mapping. - do - { - *dest = colormaps[(dc_source[frac>>FRACBITS] <<8) + (*dest)]; - dest += vid.width; - frac += fracstep; - } while (count--); -} - -/** \brief The R_DrawTranslucentColumn_8 function - I've made an asm routine for the transparency, because it slows down - a lot in 640x480 with big sprites (bfg on all screen, or transparent - walls on fullscreen) -*/ -void R_DrawTranslucentColumn_8(void) -{ - register INT32 count; - UINT8 *restrict dest; - intptr_t frac; - intptr_t fracstep; - - INT32 npow2min; - INT32 npow2max; - - count = dc_yh - dc_yl + 1; - - if (count <= 0) // Zero length, column does not exceed a pixel. - { - return; - } - - if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) - { - return; - } - - // FIXME. As above. - dest = &topleft[dc_yl*vid.width + dc_x]; - - // Looks familiar. - fracstep = dc_iscale; - frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); - - // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. - // This is as fast as it gets. - const UINT8 *restrict source = dc_source; - const UINT8 *transmap = dc_transmap; - const lighttable_t *restrict colormap = dc_colormap; - intptr_t heightmask = dc_sourcelength-1; - - npow2min = -1; - npow2max = dc_sourcelength; - - if (dc_sourcelength & heightmask) - { - heightmask = dc_texheight << FRACBITS; - - if (frac < 0) - { - while ((frac += heightmask) < 0) - { - ; - } - } - else - { - while (frac >= heightmask) - { - frac -= heightmask; - } - } - - do - { - // Re-map color indices from wall texture column - // using a lighting/special effects LUT. - // heightmask is the Tutti-Frutti fix - - // -1 is the lower clamp bound because column posts have a "safe" byte before the real data - // and a few bytes after as well - - // jartha: faster on my AMD FX-6300 CPU. - // Faster than ternaries, faster than std::min/std::max. Don't ask me why. - // I tested by viewing a non-PO2 texture from a consistent distance so it covered the entire screen. - // The framerate difference was about 50 frames at 640x400. - INT32 n = frac >> FRACBITS; - if (n < npow2min) - n = npow2min; - if (n > npow2max) - n = npow2max; - - *dest = *(transmap + (colormap[source[n]]<<8) + (*dest)); - - dest += vid.width; - - if ((frac += fracstep) >= heightmask) - { - frac -= heightmask; - } - } - while (--count); - } - else - { - while ((count -= 2) >= 0) // texture height is a power of 2 - { - *dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); - dest += vid.width; - frac += fracstep; - - *dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); - dest += vid.width; - frac += fracstep; - } - - if (count & 1) - { - *dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); - } - } -} - -/** \brief The R_DrawTranslatedTranslucentColumn_8 function - Spiffy function. Not only does it colormap a sprite, but does translucency as well. - Uber-kudos to Cyan Helkaraxe -*/ -void R_DrawTranslatedTranslucentColumn_8(void) -{ - register INT32 count; - UINT8 *restrict dest; - intptr_t frac; - intptr_t fracstep; - - INT32 npow2min; - INT32 npow2max; - - count = dc_yh - dc_yl + 1; - - if (count <= 0) // Zero length, column does not exceed a pixel. - { - return; - } - - if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) - { - return; - } - - // FIXME. As above. - dest = &topleft[dc_yl*vid.width + dc_x]; - - // Looks familiar. - fracstep = dc_iscale; - frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); - - // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. - // This is as fast as it gets. - intptr_t heightmask = dc_sourcelength-1; - - npow2min = -1; - npow2max = dc_sourcelength; - - if (dc_sourcelength & heightmask) - { - heightmask = dc_texheight << FRACBITS; - - if (frac < 0) - { - while ((frac += heightmask) < 0) - { - ; - } - } - else - { - while (frac >= heightmask) - { - frac -= heightmask; - } - } - - do - { - // Re-map color indices from wall texture column - // using a lighting/special effects LUT. - // heightmask is the Tutti-Frutti fix - - // -1 is the lower clamp bound because column posts have a "safe" byte before the real data - // and a few bytes after as well - - // jartha: faster on my AMD FX-6300 CPU. - // Faster than ternaries, faster than std::min/std::max. Don't ask me why. - // I tested by viewing a non-PO2 texture from a consistent distance so it covered the entire screen. - // The framerate difference was about 50 frames at 640x400. - INT32 n = frac >> FRACBITS; - if (n < npow2min) - n = npow2min; - if (n > npow2max) - n = npow2max; - - *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[n]]]<<8) + (*dest)); - - dest += vid.width; - - if ((frac += fracstep) >= heightmask) - { - frac -= heightmask; - } - } - while (--count); - } - else - { - while ((count -= 2) >= 0) // texture height is a power of 2 - { - *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); - dest += vid.width; - frac += fracstep; - - *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); - dest += vid.width; - frac += fracstep; - } - - if (count & 1) - { - *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); - } - } -} - -/** \brief The R_DrawTranslatedColumn_8 function - Draw columns up to 128 high but remap the green ramp to other colors - - \warning STILL NOT IN ASM, TO DO.. -*/ -void R_DrawTranslatedColumn_8(void) -{ - register INT32 count; - register UINT8 *dest; - register fixed_t frac, fracstep; - - count = dc_yh - dc_yl; - - if (count < 0) - { - return; - } - - if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) - { - return; - } - - // FIXME. As above. - dest = &topleft[dc_yl*vid.width + dc_x]; - - // Looks familiar. - fracstep = dc_iscale; - frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); - - // Here we do an additional index re-mapping. - do - { - // Translation tables are used - // to map certain colorramps to other ones, - // used with PLAY sprites. - // Thus the "green" ramp of the player 0 sprite - // is mapped to gray, red, black/indigo. - *dest = dc_colormap[dc_translation[dc_source[frac>>FRACBITS]]]; - - dest += vid.width; - - frac += fracstep; - } while (count--); -} - -// ========================================================================== -// SPANS -// ========================================================================== - -#define SPANSIZE 16 -#define INVSPAN 0.0625f - -// 4194303 = (2048x2048)-1 (2048x2048 is maximum flat size) -#define MAXFLATBYTES 4194303 - -/** \brief The R_DrawSpan_8 function - Draws the actual span. -*/ -void R_DrawSpan_8 (void) -{ - uintptr_t xposition; - uintptr_t yposition; - uintptr_t xstep, ystep; - register UINT32 bit; - - UINT8 *restrict source = ds_source; - UINT8 *restrict colormap = ds_colormap; - UINT8 *restrict dest = ylookup[ds_y] + columnofs[ds_x1]; - const UINT8 *restrict deststop = screens[0] + vid.rowbytes * vid.height; - - register size_t count = (ds_x2 - ds_x1 + 1); - size_t i; - - xposition = ds_xfrac; yposition = ds_yfrac; - xstep = ds_xstep; ystep = ds_ystep; - - // SoM: we only need 6 bits for the integer part (0 thru 63) so the rest - // can be used for the fraction part. This allows calculation of the memory address in the - // texture with two shifts, an OR and one AND. (see below) - // for texture sizes > 64 the amount of precision we can allow will decrease, but only by one - // bit per power of two (obviously) - // Ok, because I was able to eliminate the variable spot below, this function is now FASTER - // than the original span renderer. Whodathunkit? - xposition <<= nflatshiftup; yposition <<= nflatshiftup; - xstep <<= nflatshiftup; ystep <<= nflatshiftup; - - if (dest+8 > deststop) - { - return; - } - - while (count >= 8) - { - // SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't - // have the uber complicated math to calculate it now, so that was a memory write we didn't - // need! - for (i = 0; i < 8; i++) - { - bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - dest[i] = colormap[source[bit]]; - - xposition += xstep; - yposition += ystep; - } - - dest += 8; - count -= 8; - } - while (count-- && dest <= deststop) - { - bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - *dest++ = colormap[source[bit]]; - - xposition += xstep; - yposition += ystep; - } -} - -// R_CalcTiltedLighting -// Exactly what it says on the tin. I wish I wasn't too lazy to explain things properly. -static INT32 tiltlighting[MAXVIDWIDTH]; -void R_CalcTiltedLighting(fixed_t start, fixed_t end) -{ - // ZDoom uses a different lighting setup to us, and I couldn't figure out how to adapt their version - // of this function. Here's my own. - INT32 left = ds_x1, right = ds_x2; - fixed_t step = (end-start)/(ds_x2-ds_x1+1); - INT32 i; - - // I wanna do some optimizing by checking for out-of-range segments on either side to fill in all at once, - // but I'm too bad at coding to not crash the game trying to do that. I guess this is fast enough for now... - - for (i = left; i <= right; i++) - { - tiltlighting[i] = (start += step) >> FRACBITS; - - if (tiltlighting[i] < 0) - { - tiltlighting[i] = 0; - } - else if (tiltlighting[i] >= MAXLIGHTSCALE) - { - tiltlighting[i] = MAXLIGHTSCALE-1; - } - } -} - -#define PLANELIGHTFLOAT ((float)BASEVIDWIDTH * BASEVIDWIDTH / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan)) - -/** \brief The R_DrawTiltedSpan_8 function - Draw slopes! Holy sheit! -*/ -void R_DrawTiltedSpan_8(void) -{ - int width = ds_x2 - ds_x1; - double iz, uz, vz; - UINT32 u, v; - int i; - - UINT8 *source; - UINT8 *colormap; - register UINT8 *dest; - - double startz, startu, startv; - double izstep, uzstep, vzstep; - double endz, endu, endv; - UINT32 stepu, stepv; - register UINT32 bit; - - iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); - - // Lighting is simple. It's just linear interpolation from start to end - { - float planelightfloat = PLANELIGHTFLOAT; - float lightstart, lightend; - - lightend = (iz + ds_szp->x*width) * planelightfloat; - lightstart = iz * planelightfloat; - - R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend)); - //CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf); - } - - uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); - vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); - - dest = ylookup[ds_y] + columnofs[ds_x1]; - - source = ds_source; - -#if 0 // The "perfect" reference version of this routine. Pretty slow. - // Use it only to see how things are supposed to look. - i = 0; - do - { - double z = 1.f/iz; - u = (INT64)(uz*z) + viewx; - v = (INT64)(vz*z) + viewy; - - bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = colormap[source[bit]]; - - dest++; - iz += ds_szp->x; - uz += ds_sup->x; - vz += ds_svp->x; - } while (--width >= 0); -#else - startz = 1.f/iz; - startu = uz*startz; - startv = vz*startz; - - izstep = ds_szp->x * SPANSIZE; - uzstep = ds_sup->x * SPANSIZE; - vzstep = ds_svp->x * SPANSIZE; - width++; - - while (width >= SPANSIZE) - { - iz += izstep; - uz += uzstep; - vz += vzstep; - - endz = 1.f/iz; - endu = uz*endz; - endv = vz*endz; - stepu = (INT64)((endu - startu) * INVSPAN); - stepv = (INT64)((endv - startv) * INVSPAN); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; - - for (i = SPANSIZE-1; i >= 0; i--) - { - bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = colormap[source[bit]]; - - dest++; - u += stepu; - v += stepv; - } - startu = endu; - startv = endv; - width -= SPANSIZE; - } - if (width > 0) - { - if (width == 1) - { - u = (INT64)(startu); - v = (INT64)(startv); - bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = colormap[source[bit]]; - } - else - { - double left = width; - iz += ds_szp->x * left; - uz += ds_sup->x * left; - vz += ds_svp->x * left; - - endz = 1.f/iz; - endu = uz*endz; - endv = vz*endz; - left = 1.f/left; - stepu = (INT64)((endu - startu) * left); - stepv = (INT64)((endv - startv) * left); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; - - for (; width != 0; width--) - { - bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = colormap[source[bit]]; - - dest++; - u += stepu; - v += stepv; - } - } - } -#endif -} - -/** \brief The R_DrawTiltedTranslucentSpan_8 function - Like DrawTiltedSpan, but translucent -*/ -void R_DrawTiltedTranslucentSpan_8(void) -{ - int width = ds_x2 - ds_x1; - double iz, uz, vz; - UINT32 u, v; - int i; - - UINT8 *source; - UINT8 *colormap; - register UINT8 *dest; - - double startz, startu, startv; - double izstep, uzstep, vzstep; - double endz, endu, endv; - UINT32 stepu, stepv; - register UINT32 bit; - - iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); - - // Lighting is simple. It's just linear interpolation from start to end - { - float planelightfloat = PLANELIGHTFLOAT; - float lightstart, lightend; - - lightend = (iz + ds_szp->x*width) * planelightfloat; - lightstart = iz * planelightfloat; - - R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend)); - //CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf); - } - - uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); - vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); - - dest = ylookup[ds_y] + columnofs[ds_x1]; - - source = ds_source; - -#if 0 // The "perfect" reference version of this routine. Pretty slow. - // Use it only to see how things are supposed to look. - i = 0; - do - { - double z = 1.f/iz; - u = (INT64)(uz*z) + viewx; - v = (INT64)(vz*z) + viewy; - - bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dest); - - dest++; - iz += ds_szp->x; - uz += ds_sup->x; - vz += ds_svp->x; - } while (--width >= 0); -#else - startz = 1.f/iz; - startu = uz*startz; - startv = vz*startz; - - izstep = ds_szp->x * SPANSIZE; - uzstep = ds_sup->x * SPANSIZE; - vzstep = ds_svp->x * SPANSIZE; - width++; - - while (width >= SPANSIZE) - { - iz += izstep; - uz += uzstep; - vz += vzstep; - - endz = 1.f/iz; - endu = uz*endz; - endv = vz*endz; - stepu = (INT64)((endu - startu) * INVSPAN); - stepv = (INT64)((endv - startv) * INVSPAN); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; - - for (i = SPANSIZE-1; i >= 0; i--) - { - bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dest); - - dest++; - u += stepu; - v += stepv; - } - startu = endu; - startv = endv; - width -= SPANSIZE; - } - if (width > 0) - { - if (width == 1) - { - u = (INT64)(startu); - v = (INT64)(startv); - bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dest); - } - else - { - double left = width; - iz += ds_szp->x * left; - uz += ds_sup->x * left; - vz += ds_svp->x * left; - - endz = 1.f/iz; - endu = uz*endz; - endv = vz*endz; - left = 1.f/left; - stepu = (INT64)((endu - startu) * left); - stepv = (INT64)((endv - startv) * left); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; - - for (; width != 0; width--) - { - bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dest); - - dest++; - u += stepu; - v += stepv; - } - } - } -#endif -} - -#ifndef NOWATER -/** \brief The R_DrawTiltedTranslucentWaterSpan_8 function - Like DrawTiltedTranslucentSpan, but for water -*/ -void R_DrawTiltedTranslucentWaterSpan_8(void) -{ - int width = ds_x2 - ds_x1; - double iz, uz, vz; - UINT32 u, v; - int i; - - UINT8 *source; - UINT8 *colormap; - register UINT8 *dest; - UINT8 *dsrc; - - double startz, startu, startv; - double izstep, uzstep, vzstep; - double endz, endu, endv; - UINT32 stepu, stepv; - register UINT32 bit; - - iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); - - // Lighting is simple. It's just linear interpolation from start to end - { - float planelightfloat = PLANELIGHTFLOAT; - float lightstart, lightend; - - lightend = (iz + ds_szp->x*width) * planelightfloat; - lightstart = iz * planelightfloat; - - R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend)); - //CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf); - } - - uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); - vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); - - dest = ylookup[ds_y] + columnofs[ds_x1]; - dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1; - - source = ds_source; - -#if 0 // The "perfect" reference version of this routine. Pretty slow. - // Use it only to see how things are supposed to look. - i = 0; - do - { - double z = 1.f/iz; - u = (INT64)(uz*z) + viewx; - v = (INT64)(vz*z) + viewy; - - bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dsrc++); - - dest++; - iz += ds_szp->x; - uz += ds_sup->x; - vz += ds_svp->x; - } while (--width >= 0); -#else - startz = 1.f/iz; - startu = uz*startz; - startv = vz*startz; - - izstep = ds_szp->x * SPANSIZE; - uzstep = ds_sup->x * SPANSIZE; - vzstep = ds_svp->x * SPANSIZE; - width++; - - while (width >= SPANSIZE) - { - iz += izstep; - uz += uzstep; - vz += vzstep; - - endz = 1.f/iz; - endu = uz*endz; - endv = vz*endz; - stepu = (INT64)((endu - startu) * INVSPAN); - stepv = (INT64)((endv - startv) * INVSPAN); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; - - for (i = SPANSIZE-1; i >= 0; i--) - { - bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dsrc++); - - dest++; - u += stepu; - v += stepv; - } - startu = endu; - startv = endv; - width -= SPANSIZE; - } - if (width > 0) - { - if (width == 1) - { - u = (INT64)(startu); - v = (INT64)(startv); - bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dsrc++); - } - else - { - double left = width; - iz += ds_szp->x * left; - uz += ds_sup->x * left; - vz += ds_svp->x * left; - - endz = 1.f/iz; - endu = uz*endz; - endv = vz*endz; - left = 1.f/left; - stepu = (INT64)((endu - startu) * left); - stepv = (INT64)((endv - startv) * left); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; - - for (; width != 0; width--) - { - bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dsrc++); - - dest++; - u += stepu; - v += stepv; - } - } - } -#endif -} -#endif // NOWATER - -void R_DrawTiltedSplat_8(void) -{ - // x1, x2 = ds_x1, ds_x2 - int width = ds_x2 - ds_x1; - double iz, uz, vz; - UINT32 u, v; - int i; - - UINT8 *source; - UINT8 *colormap; - register UINT8 *dest; - - UINT8 val; - - double startz, startu, startv; - double izstep, uzstep, vzstep; - double endz, endu, endv; - UINT32 stepu, stepv; - register UINT32 bit; - - iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); - - // Lighting is simple. It's just linear interpolation from start to end - { - float planelightfloat = PLANELIGHTFLOAT; - float lightstart, lightend; - - lightend = (iz + ds_szp->x*width) * planelightfloat; - lightstart = iz * planelightfloat; - - R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend)); - //CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf); - } - - uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); - vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); - - dest = ylookup[ds_y] + columnofs[ds_x1]; - - source = ds_source; - //colormap = ds_colormap; - -#if 0 // The "perfect" reference version of this routine. Pretty slow. - // Use it only to see how things are supposed to look. - i = 0; - do - { - double z = 1.f/iz; - u = (INT64)(uz*z) + viewx; - v = (INT64)(vz*z) + viewy; - - bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); - val = source[bit]; - - if (val != TRANSPARENTPIXEL) - { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = colormap[val]; - } - dest++; - iz += ds_szp->x; - uz += ds_sup->x; - vz += ds_svp->x; - } while (--width >= 0); -#else - startz = 1.f/iz; - startu = uz*startz; - startv = vz*startz; - - izstep = ds_szp->x * SPANSIZE; - uzstep = ds_sup->x * SPANSIZE; - vzstep = ds_svp->x * SPANSIZE; - //x1 = 0; - width++; - - while (width >= SPANSIZE) - { - iz += izstep; - uz += uzstep; - vz += vzstep; - - endz = 1.f/iz; - endu = uz*endz; - endv = vz*endz; - stepu = (INT64)((endu - startu) * INVSPAN); - stepv = (INT64)((endv - startv) * INVSPAN); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; - - for (i = SPANSIZE-1; i >= 0; i--) - { - bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); - val = source[bit]; - if (val != TRANSPARENTPIXEL) - { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = colormap[val]; - } - dest++; - u += stepu; - v += stepv; - } - startu = endu; - startv = endv; - width -= SPANSIZE; - } - if (width > 0) - { - if (width == 1) - { - u = (INT64)(startu); - v = (INT64)(startv); - bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); - val = source[bit]; - if (val != TRANSPARENTPIXEL) - { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = colormap[val]; - } - } - else - { - double left = width; - iz += ds_szp->x * left; - uz += ds_sup->x * left; - vz += ds_svp->x * left; - - endz = 1.f/iz; - endu = uz*endz; - endv = vz*endz; - left = 1.f/left; - stepu = (INT64)((endu - startu) * left); - stepv = (INT64)((endv - startv) * left); - u = (INT64)(startu) + viewx; - v = (INT64)(startv) + viewy; - - for (; width != 0; width--) - { - bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); - val = source[bit]; - if (val != TRANSPARENTPIXEL) - { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = colormap[val]; - } - dest++; - u += stepu; - v += stepv; - } - } - } -#endif -} - -/** \brief The R_DrawSplat_8 function - Just like R_DrawSpan_8, but skips transparent pixels. -*/ -void R_DrawSplat_8 (void) -{ - UINT32 xposition; - UINT32 yposition; - UINT32 xstep, ystep; - register UINT32 bit; - - UINT8 *source; - UINT8 *colormap; - register UINT8 *dest; - - register size_t count; - size_t i; - UINT32 val; - - // SoM: we only need 6 bits for the integer part (0 thru 63) so the rest - // can be used for the fraction part. This allows calculation of the memory address in the - // texture with two shifts, an OR and one AND. (see below) - // for texture sizes > 64 the amount of precision we can allow will decrease, but only by one - // bit per power of two (obviously) - // Ok, because I was able to eliminate the variable spot below, this function is now FASTER - // than the original span renderer. Whodathunkit? - xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup; - xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup; - - source = ds_source; - colormap = ds_colormap; - dest = ylookup[ds_y] + columnofs[ds_x1]; - count = ds_x2 - ds_x1 + 1; - - while (count >= 8) - { - // SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't - // have the uber complicated math to calculate it now, so that was a memory write we didn't - // need! - // - // 4194303 = (2048x2048)-1 (2048x2048 is maximum flat size) - for (i = 0; i < 8; i++) - { - bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - bit &= MAXFLATBYTES; - val = source[bit]; - if (val != TRANSPARENTPIXEL) - dest[i] = colormap[val]; - - xposition += xstep; - yposition += ystep; - } - - dest += 8; - count -= 8; - } - while (count--) - { - bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val = source[bit]; - if (val != TRANSPARENTPIXEL) - { - *dest = colormap[val]; - } - - dest++; - xposition += xstep; - yposition += ystep; - } -} - -/** \brief The R_DrawTranslucentSplat_8 function - Just like R_DrawSplat_8, but is translucent! -*/ -void R_DrawTranslucentSplat_8 (void) -{ - UINT32 xposition; - UINT32 yposition; - UINT32 xstep, ystep; - register UINT32 bit; - - UINT8 *source; - UINT8 *colormap; - register UINT8 *dest; - - register size_t count; - size_t i; - UINT8 val; - - // SoM: we only need 6 bits for the integer part (0 thru 63) so the rest - // can be used for the fraction part. This allows calculation of the memory address in the - // texture with two shifts, an OR and one AND. (see below) - // for texture sizes > 64 the amount of precision we can allow will decrease, but only by one - // bit per power of two (obviously) - // Ok, because I was able to eliminate the variable spot below, this function is now FASTER - // than the original span renderer. Whodathunkit? - xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup; - xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup; - - source = ds_source; - colormap = ds_colormap; - dest = ylookup[ds_y] + columnofs[ds_x1]; - count = ds_x2 - ds_x1 + 1; - - while (count >= 8) - { - // SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't - // have the uber complicated math to calculate it now, so that was a memory write we didn't - // need! - for (i = 0; i < 8; i++) - { - bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val = source[bit]; - if (val != TRANSPARENTPIXEL) - dest[i] = *(ds_transmap + (colormap[val] << 8) + dest[i]); - - xposition += xstep; - yposition += ystep; - } - - dest += 8; - count -= 8; - } - while (count--) - { - bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val = source[bit]; - if (val != TRANSPARENTPIXEL) - *dest = *(ds_transmap + (colormap[val] << 8) + *dest); - - dest++; - xposition += xstep; - yposition += ystep; - } -} - -/** \brief The R_DrawTranslucentSpan_8 function - Draws the actual span with translucent. -*/ -void R_DrawTranslucentSpan_8 (void) -{ - fixed_t xposition; - fixed_t yposition; - fixed_t xstep, ystep; - register UINT32 bit; - - UINT8 *source; - UINT8 *colormap; - register UINT8 *dest; - const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; - - register size_t count = (ds_x2 - ds_x1 + 1); - size_t i; - - xposition = ds_xfrac; yposition = ds_yfrac; - xstep = ds_xstep; ystep = ds_ystep; - - // SoM: we only need 6 bits for the integer part (0 thru 63) so the rest - // can be used for the fraction part. This allows calculation of the memory address in the - // texture with two shifts, an OR and one AND. (see below) - // for texture sizes > 64 the amount of precision we can allow will decrease, but only by one - // bit per power of two (obviously) - // Ok, because I was able to eliminate the variable spot below, this function is now FASTER - // than the original span renderer. Whodathunkit? - xposition <<= nflatshiftup; yposition <<= nflatshiftup; - xstep <<= nflatshiftup; ystep <<= nflatshiftup; - - source = ds_source; - colormap = ds_colormap; - dest = ylookup[ds_y] + columnofs[ds_x1]; - - while (count >= 8) - { - // SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't - // have the uber complicated math to calculate it now, so that was a memory write we didn't - // need! - for (i = 0; i < 8; i++) - { - bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - dest[i] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[i]); - xposition += xstep; - yposition += ystep; - } - - dest += 8; - count -= 8; - } - while (count-- && dest <= deststop) - { - bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dest); - dest++; - xposition += xstep; - yposition += ystep; - } -} - -#ifndef NOWATER -void R_DrawTranslucentWaterSpan_8(void) -{ - UINT32 xposition; - UINT32 yposition; - UINT32 xstep, ystep; - register UINT32 bit; - - UINT8 *source; - UINT8 *colormap; - register UINT8 *dest; - UINT8 *dsrc; - - register size_t count; - size_t i; - - // SoM: we only need 6 bits for the integer part (0 thru 63) so the rest - // can be used for the fraction part. This allows calculation of the memory address in the - // texture with two shifts, an OR and one AND. (see below) - // for texture sizes > 64 the amount of precision we can allow will decrease, but only by one - // bit per power of two (obviously) - // Ok, because I was able to eliminate the variable spot below, this function is now FASTER - // than the original span renderer. Whodathunkit? - xposition = ds_xfrac << nflatshiftup; yposition = (ds_yfrac + ds_waterofs) << nflatshiftup; - xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup; - - source = ds_source; - colormap = ds_colormap; - dest = ylookup[ds_y] + columnofs[ds_x1]; - dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1; - count = ds_x2 - ds_x1 + 1; - - while (count >= 8) - { - // SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't - // have the uber complicated math to calculate it now, so that was a memory write we didn't - // need! - for (i = 0; i < 8; i++) - { - bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift); - dest[i] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; - } - - dest += 8; - count -= 8; - } - while (count--) - { - bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift); - *dest++ = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)]; - - xposition += xstep; - yposition += ystep; - } -} -#endif - -/** \brief The R_DrawFogSpan_8 function - Draws the actual span with fogging. -*/ -void R_DrawFogSpan_8(void) -{ - UINT8 *colormap; - register UINT8 *dest; - - register size_t count; - - colormap = ds_colormap; - dest = &topleft[ds_y *vid.width + ds_x1]; - - count = ds_x2 - ds_x1 + 1; - - while (count >= 4) - { - dest[0] = colormap[dest[0]]; - dest[1] = colormap[dest[1]]; - dest[2] = colormap[dest[2]]; - dest[3] = colormap[dest[3]]; - - dest += 4; - count -= 4; - } - - while (count--) - { - *dest = colormap[*dest]; - dest++; - } -} - -/** \brief The R_DrawFogColumn_8 function - Fog wall. -*/ -void R_DrawFogColumn_8(void) -{ - register INT32 count; - register UINT8 *dest; - - count = dc_yh - dc_yl; - - // Zero length, column does not exceed a pixel. - if (count < 0) - return; - -#ifdef RANGECHECK - if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) - I_Error("R_DrawFogColumn_8: %d to %d at %d", dc_yl, dc_yh, dc_x); -#endif - - // Framebuffer destination address. - // Use ylookup LUT to avoid multiply with ScreenWidth. - // Use columnofs LUT for subwindows? - //dest = ylookup[dc_yl] + columnofs[dc_x]; - dest = &topleft[dc_yl*vid.width + dc_x]; - - // Determine scaling, which is the only mapping to be done. - do - { - // Simple. Apply the colormap to what's already on the screen. - *dest = dc_colormap[*dest]; - dest += vid.width; - } while (count--); -} - -/** \brief The R_DrawShadeColumn_8 function - This is for 3D floors that cast shadows on walls. - - This function just cuts the column up into sections and calls R_DrawColumn_8 -*/ -void R_DrawColumnShadowed_8(void) -{ - register INT32 count; - INT32 realyh, i, height, bheight = 0, solid = 0; - - realyh = dc_yh; - - count = dc_yh - dc_yl; - - // Zero length, column does not exceed a pixel. - if (count < 0) - return; - -#ifdef RANGECHECK - if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) - I_Error("R_DrawColumnShadowed_8: %d to %d at %d", dc_yl, dc_yh, dc_x); -#endif - - // This runs through the lightlist from top to bottom and cuts up the column accordingly. - for (i = 0; i < dc_numlights; i++) - { - // If the height of the light is above the column, get the colormap - // anyway because the lighting of the top should be affected. - solid = dc_lightlist[i].flags & FF_CUTSOLIDS; - - height = dc_lightlist[i].height >> LIGHTSCALESHIFT; - if (solid) - { - bheight = dc_lightlist[i].botheight >> LIGHTSCALESHIFT; - if (bheight < height) - { - // confounded slopes sometimes allow partial invertedness, - // even including cases where the top and bottom heights - // should actually be the same! - // swap the height values as a workaround for this quirk - INT32 temp = height; - height = bheight; - bheight = temp; - } - } - if (height <= dc_yl) - { - dc_colormap = dc_lightlist[i].rcolormap; - if (encoremap) - dc_colormap += COLORMAP_REMAPOFFSET; - if (solid && dc_yl < bheight) - dc_yl = bheight; - continue; - } - // Found a break in the column! - dc_yh = height; - - if (dc_yh > realyh) - dc_yh = realyh; - basecolfunc(); // R_DrawColumn_8 for the appropriate architecture - if (solid) - dc_yl = bheight; - else - dc_yl = dc_yh + 1; - - dc_colormap = dc_lightlist[i].rcolormap; - if (encoremap) - dc_colormap += COLORMAP_REMAPOFFSET; - } - dc_yh = realyh; - if (dc_yl <= realyh) - walldrawerfunc(); // R_DrawWallColumn_8 for the appropriate architecture -} diff --git a/src/r_draw_column.cpp b/src/r_draw_column.cpp new file mode 100644 index 000000000..dcc1a5b90 --- /dev/null +++ b/src/r_draw_column.cpp @@ -0,0 +1,356 @@ +// SONIC ROBO BLAST 2 KART +//----------------------------------------------------------------------------- +// Copyright (C) 2025 by Kart Krew. +// Copyright (C) 2020 by Sonic Team Junior. +// Copyright (C) 2000 by DooM Legacy Team. +// Copyright (C) 1996 by id Software, Inc. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file r_draw_column.cpp +/// \brief column drawer functions +/// \note no includes because this is included as part of r_draw.cpp + +// ========================================================================== +// COLUMNS +// ========================================================================== + +// A column is a vertical slice/span of a wall texture that uses +// a has a constant z depth from top to bottom. +// + +enum DrawColumnType +{ + DC_BASIC = 0x0000, + DC_COLORMAP = 0x0001, + DC_TRANSMAP = 0x0002, + DC_HOLES = 0x0004, + DC_LIGHTLIST = 0x0008, +}; + +template +static constexpr UINT8 R_GetColumnTranslated(drawcolumndata_t* dc, UINT8 col, const UINT8 * restrict colormap) +{ + if constexpr (Type & DrawColumnType::DC_COLORMAP) + { + col = dc->translation[col]; + } + + return colormap[col]; +} + +template +static constexpr UINT8 R_GetColumnTranslucent(drawcolumndata_t* dc, UINT8 * restrict dest, UINT8 col, const UINT8 * restrict colormap) +{ + col = R_GetColumnTranslated(dc, col, colormap); + + if constexpr (Type & DrawColumnType::DC_TRANSMAP) + { + return *(dc->transmap + (col << 8) + (*dest)); + } + else + { + return col; + } +} + +template +static constexpr UINT8 R_DrawColumnPixel(drawcolumndata_t* dc, UINT8 * restrict dest, UINT32 bit, const restrict UINT8 *source, const restrict UINT8 *colormap) +{ + UINT8 col = source[bit]; + + if constexpr (Type & DrawColumnType::DC_HOLES) + { + if (col == TRANSPARENTPIXEL) + { + return *dest; + } + } + + return R_GetColumnTranslucent(dc, dest, col, colormap); +} + +/** \brief The R_DrawColumn function + Experiment to make software go faster. Taken from the Boom source +*/ +template +static void R_DrawColumnTemplate(drawcolumndata_t *dc) +{ + INT32 count; + + count = dc->yh - dc->yl; + + if (count < 0) // Zero length, column does not exceed a pixel. + { + return; + } + + if ((unsigned)dc->x >= (unsigned)vid.width || dc->yl < 0 || dc->yh >= vid.height) + { + return; + } + + if constexpr (Type & DrawColumnType::DC_LIGHTLIST) + { + constexpr DrawColumnType NewType = static_cast(Type & ~DC_LIGHTLIST); + INT32 i, height, bheight = 0, solid = 0; + drawcolumndata_t dc_copy = *dc; + + const INT32 realyh = dc_copy.yh; + + // This runs through the lightlist from top to bottom and cuts up the column accordingly. + for (i = 0; i < dc_copy.numlights; i++) + { + // If the height of the light is above the column, get the colormap + // anyway because the lighting of the top should be affected. + solid = dc_copy.lightlist[i].flags & FF_CUTSOLIDS; + height = dc_copy.lightlist[i].height >> LIGHTSCALESHIFT; + + if (solid) + { + bheight = dc_copy.lightlist[i].botheight >> LIGHTSCALESHIFT; + + if (bheight < height) + { + // confounded slopes sometimes allow partial invertedness, + // even including cases where the top and bottom heights + // should actually be the same! + // swap the height values as a workaround for this quirk + INT32 temp = height; + height = bheight; + bheight = temp; + } + } + + if (height <= dc_copy.yl) + { + dc_copy.colormap = dc_copy.lightlist[i].rcolormap; + + if (encoremap) + { + dc_copy.colormap += COLORMAP_REMAPOFFSET; + } + + if (solid && dc_copy.yl < bheight) + { + dc_copy.yl = bheight; + } + + continue; + } + + // Found a break in the column! + dc_copy.yh = height; + + if (dc_copy.yh > realyh) + { + dc_copy.yh = realyh; + } + + R_DrawColumnTemplate(&dc_copy); + if (solid) + { + dc_copy.yl = bheight; + } + else + { + dc_copy.yl = dc_copy.yh + 1; + } + + dc_copy.colormap = dc_copy.lightlist[i].rcolormap; + + if (encoremap) + { + dc_copy.colormap += COLORMAP_REMAPOFFSET; + } + } + + dc_copy.yh = realyh; + + if (dc_copy.yl <= realyh) + { + R_DrawColumnTemplate(&dc_copy); + } + } + else + { + // Inner loop that does the actual texture mapping, + // e.g. a DDA-lile scaling. + // This is as fast as it gets. (Yeah, right!!! -- killough) + // + // killough 2/1/98: more performance tuning + + intptr_t frac; + const intptr_t fracstep = dc->iscale; + const intptr_t heightmask = dc->sourcelength-1; + constexpr INT32 npow2min = -1; + const INT32 npow2max = dc->sourcelength; + const INT32 stride = vid.width; + + const UINT8 * restrict source = dc->source; + const lighttable_t * restrict colormap = dc->colormap; + + // Framebuffer destination address. + UINT8 * restrict dest = R_Address(dc->x, dc->yl); + + count++; + + // Determine scaling, which is the only mapping to be done. + frac = (dc->texturemid + FixedMul((dc->yl << FRACBITS) - centeryfrac, fracstep)); + + switch (heightmask) + { + case 255: + case 127: + { + while(count--) + { + *dest = R_DrawColumnPixel(dc, dest, (frac>>FRACBITS) & heightmask, source, colormap); + dest += stride; + frac += fracstep; + } + } + break; + case -1: + { + if (frac < 0) + // adjust in case we underread + frac += FRACUNIT; + + // texture has no height, so just go + while (--count >= 0) + { + *dest = R_DrawColumnPixel(dc, dest, frac>>FRACBITS, source, colormap); + dest += stride; + frac += fracstep; + } + } + break; + default: + { + if (!(dc->sourcelength & heightmask)) // power of 2 -- killough + { + while ((count -= 2) >= 0) // texture height is a power of 2 -- killough + { + *dest = R_DrawColumnPixel(dc, dest, (frac>>FRACBITS) & heightmask, source, colormap); + dest += stride; + frac += fracstep; + + *dest = R_DrawColumnPixel(dc, dest, (frac>>FRACBITS) & heightmask, source, colormap); + dest += stride; + frac += fracstep; + } + + if (count & 1) + { + *dest = R_DrawColumnPixel(dc, dest, (frac>>FRACBITS) & heightmask, source, colormap); + } + } + else + { + const intptr_t fixed_heightmask = dc->texheight << FRACBITS; + + if (frac < 0) + { + while ((frac += fixed_heightmask) < 0) + { + ; + } + } + else + { + while (frac >= fixed_heightmask) + { + frac -= fixed_heightmask; + } + } + + do + { + // Re-map color indices from wall texture column + // using a lighting/special effects LUT. + // heightmask is the Tutti-Frutti fix + + // -1 is the lower clamp bound because column posts have a "safe" byte before the real data + // and a few bytes after as well + *dest = R_DrawColumnPixel(dc, dest, CLAMP((frac >> FRACBITS), npow2min, npow2max), source, colormap); + + dest += stride; + +#if __SIZEOF_POINTER__ < 8 // 64-bit systems have large enough numbers for this to be a non-issue + // Avoid overflow. + if (fracstep > 0x7FFFFFFF - frac) + { + frac += fracstep - fixed_heightmask; + } + else +#endif + { + frac += fracstep; + } + + while (frac >= fixed_heightmask) + { + frac -= fixed_heightmask; + } + } + while (--count); + } + } + break; + } + } +} + +#define DEFINE_COLUMN_FUNC(name, flags) \ + void name(drawcolumndata_t *dc) \ + { \ + constexpr DrawColumnType opt = static_cast(flags); \ + R_DrawColumnTemplate(dc); \ + } + +DEFINE_COLUMN_FUNC(R_DrawColumn, DC_BASIC) +DEFINE_COLUMN_FUNC(R_DrawTranslucentColumn, DC_TRANSMAP) +DEFINE_COLUMN_FUNC(R_DrawTranslatedColumn, DC_COLORMAP) +DEFINE_COLUMN_FUNC(R_DrawColumnShadowed, DC_LIGHTLIST) +DEFINE_COLUMN_FUNC(R_DrawTranslatedTranslucentColumn, DC_COLORMAP|DC_TRANSMAP) +DEFINE_COLUMN_FUNC(R_Draw2sMultiPatchColumn, DC_HOLES) +DEFINE_COLUMN_FUNC(R_Draw2sMultiPatchTranslucentColumn, DC_HOLES|DC_TRANSMAP) + +/** \brief The R_DrawFogColumn function + Fog wall. +*/ +void R_DrawFogColumn(drawcolumndata_t* dc) +{ + INT32 count; + UINT8 * restrict dest; + + count = dc->yh - dc->yl; + + // Zero length, column does not exceed a pixel. + if (count < 0) + { + return; + } + + if ((unsigned)dc->x >= (unsigned)vid.width || dc->yl < 0 || dc->yh >= vid.height) + { + return; + } + + // Framebuffer destination address. + dest = R_Address(dc->x, dc->yl); + + const INT32 stride = vid.width; + const lighttable_t * restrict colormap = dc->colormap; + + // Determine scaling, which is the only mapping to be done. + do + { + // Simple. Apply the colormap to what's already on the screen. + *dest = colormap[*dest]; + dest += stride; + } while (count--); +} diff --git a/src/r_draw_span.cpp b/src/r_draw_span.cpp new file mode 100644 index 000000000..a8ed71008 --- /dev/null +++ b/src/r_draw_span.cpp @@ -0,0 +1,459 @@ +// SONIC ROBO BLAST 2 KART +//----------------------------------------------------------------------------- +// Copyright (C) 2025 by Kart Krew. +// Copyright (C) 2020 by Sonic Team Junior. +// Copyright (C) 2000 by DooM Legacy Team. +// Copyright (C) 1996 by id Software, Inc. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file r_draw_span.cpp +/// \brief span drawer functions +/// \note no includes because this is included as part of r_draw.cpp + +#ifdef HAVE_THREADS +#ifdef _WIN32 +#include +#define local_for_thread static __thread +#else +#include +#define local_for_thread thread_local static +#endif +#else +#define local_for_thread static +#endif + +// ========================================================================== +// SPANS +// ========================================================================== + +#define SPANSIZE 16 +#define INVSPAN 0.0625f + +// 4194303 = (2048x2048)-1 (2048x2048 is maximum flat size) +#define MAXFLATBYTES 4194303 + +#define PLANELIGHTFLOAT ((float)BASEVIDWIDTH * BASEVIDWIDTH / stride / ds->zeroheight / 21.0f * FIXED_TO_FLOAT(fovtan)) + +enum DrawSpanType +{ + DS_BASIC = 0x0000, + DS_COLORMAP = 0x0001, + DS_TRANSMAP = 0x0002, + DS_HOLES = 0x0004, + DS_RIPPLE = 0x0008, +}; + +template +static constexpr UINT8 R_GetSpanTranslated(drawspandata_t* ds, UINT8 col) +{ + if constexpr (Type & DrawSpanType::DS_COLORMAP) + { + return ds->translation[col]; + } + else + { + return col; + } +} + +template +static constexpr UINT8 R_GetSpanTranslucent(drawspandata_t* ds, UINT8 *dsrc, const UINT8 *colormap, UINT8 col) +{ + col = colormap[R_GetSpanTranslated(ds, col)]; + + if constexpr (Type & DrawSpanType::DS_TRANSMAP) + { + return *(ds->transmap + (col << 8) + (*dsrc)); + } + else + { + return col; + } +} + +template +static constexpr UINT8 R_DrawSpanPixel(drawspandata_t* ds, UINT8 *dsrc, const UINT8 *colormap, UINT32 bit, const UINT8 *source) +{ + UINT8 col = source[bit]; + + if constexpr (Type & DrawSpanType::DS_HOLES) + { + if (col == TRANSPARENTPIXEL) + { + return *dsrc; + } + } + + return R_GetSpanTranslucent(ds, dsrc, colormap, col); +} + +/** \brief The R_DrawSpan_8 function + Draws the actual span. +*/ +template +static void R_DrawSpanTemplate(drawspandata_t* ds) +{ + UINT32 xposition; + UINT32 yposition; + UINT32 xstep, ystep; + UINT32 bit; + + UINT8 * restrict dest = R_Address(ds->x1, ds->y); + UINT8 * restrict dsrc; + + const UINT8 * restrict deststop = vid.screens[0] + vid.rowbytes * vid.height; + + if (dest+8 > deststop) + { + return; + } + + intptr_t count = (ds->x2 - ds->x1 + 1); + size_t i; + + xposition = ds->xfrac; yposition = ds->yfrac; + xstep = ds->xstep; ystep = ds->ystep; + + const UINT8 * restrict source = ds->source; + const UINT8 * restrict colormap = ds->colormap; + + if constexpr (Type & DS_RIPPLE) + { + yposition += ds->waterofs; + } + + // SoM: we only need 6 bits for the integer part (0 thru 63) so the rest + // can be used for the fraction part. This allows calculation of the memory address in the + // texture with two shifts, an OR and one AND. (see below) + // for texture sizes > 64 the amount of precision we can allow will decrease, but only by one + // bit per power of two (obviously) + // Ok, because I was able to eliminate the variable spot below, this function is now FASTER + // than the original span renderer. Whodathunkit? + xposition <<= ds->nflatshiftup; yposition <<= ds->nflatshiftup; + xstep <<= ds->nflatshiftup; ystep <<= ds->nflatshiftup; + + if constexpr (Type & DS_RIPPLE) + { + dsrc = vid.screens[1] + (ds->y + ds->bgofs) * vid.width + ds->x1; + } + else + { + dsrc = dest; + } + + while (count >= 8) + { + // SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't + // have the uber complicated math to calculate it now, so that was a memory write we didn't + // need! + + for (i = 0; i < 8; i++) + { + bit = ((yposition >> ds->nflatyshift) & ds->nflatmask) | (xposition >> ds->nflatxshift); + + dest[i] = R_DrawSpanPixel(ds, &dsrc[i], colormap, bit, source); + + xposition += xstep; + yposition += ystep; + } + + dest += 8; + dsrc += 8; + + count -= 8; + } + + while (count-- && dest <= deststop) + { + bit = ((yposition >> ds->nflatyshift) & ds->nflatmask) | (xposition >> ds->nflatxshift); + + *dest = R_DrawSpanPixel(ds, dsrc, colormap, bit, source); + + dest++; + dsrc++; + + xposition += xstep; + yposition += ystep; + } +} + +// R_CalcTiltedLighting +// Exactly what it says on the tin. I wish I wasn't too lazy to explain things properly. +static void R_CalcTiltedLighting(INT32 *lightbuffer, INT32 x1, INT32 x2, fixed_t start, fixed_t end) +{ + // ZDoom uses a different lighting setup to us, and I couldn't figure out how to adapt their version + // of this function. Here's my own. + INT32 i, left = x1, right = x2; + const fixed_t step = (end-start)/(x2 - x1 + 1); + + // I wanna do some optimizing by checking for out-of-range segments on either side to fill in all at once, + // but I'm too bad at coding to not crash the game trying to do that. I guess this is fast enough for now... + + for (i = left; i <= right; i++) + { + lightbuffer[i] = (start += step) >> FRACBITS; + + if (lightbuffer[i] < 0) + { + lightbuffer[i] = 0; + } + else if (lightbuffer[i] >= MAXLIGHTSCALE) + { + lightbuffer[i] = MAXLIGHTSCALE-1; + } + } +} + +template +static void R_DrawTiltedSpanTemplate(drawspandata_t* ds) +{ + int width = ds->x2 - ds->x1; + float iz, uz, vz; + UINT32 u, v; + int i; + + UINT8 * restrict dest = R_Address(ds->x1, ds->y); + UINT8 * restrict dsrc; + + float startz, startu, startv; + float izstep, uzstep, vzstep; + float endz, endu, endv; + UINT32 stepu, stepv; + UINT32 bit; + local_for_thread INT32 *tiltlighting = NULL; + local_for_thread INT32 oldviewwidth = 0; + + // dont realloc every frame pls thx + if (tiltlighting == NULL || oldviewwidth != viewwidth) + { + tiltlighting = static_cast(realloc(tiltlighting, sizeof(*tiltlighting) * viewwidth)); + oldviewwidth = viewwidth; + } + + INT32 x1 = ds->x1; + const INT32 nflatxshift = ds->nflatxshift; + const INT32 nflatyshift = ds->nflatyshift; + const INT32 nflatmask = ds->nflatmask; + const INT32 stride = vid.width; + + iz = ds->szp.z + ds->szp.y*(centery-ds->y) + ds->szp.x*(ds->x1-centerx); + + // Lighting is simple. It's just linear interpolation from start to end + { + float planelightfloat = PLANELIGHTFLOAT; + float lightstart, lightend; + + lightend = (iz + ds->szp.x*width) * planelightfloat; + lightstart = iz * planelightfloat; + + R_CalcTiltedLighting(tiltlighting, ds->x1, ds->x2, FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend)); + //CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf); + } + + uz = ds->sup.z + ds->sup.y*(centery-ds->y) + ds->sup.x*(ds->x1-centerx); + vz = ds->svp.z + ds->svp.y*(centery-ds->y) + ds->svp.x*(ds->x1-centerx); + + const UINT8 *source = ds->source; + const UINT8 *colormap = ds->colormap; + + if constexpr (Type & DS_RIPPLE) + { + dsrc = vid.screens[1] + (ds->y + ds->bgofs) * stride + ds->x1; + } + else + { + dsrc = dest; + } + +#if 0 // The "perfect" reference version of this routine. Pretty slow. + // Use it only to see how things are supposed to look. + i = 0; + do + { + double z = 1.f/iz; + u = (INT64)(uz*z); + v = (INT64)(vz*z); + + bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); + colormap = planezlight[tiltlighting[ds->x1]] + (ds->colormap - colormaps); + + *dest = R_DrawSpanPixel(ds, dsrc, colormap, bit); + dest++; + ds->x1++; + dsrc++; + iz += ds_szp->x; + uz += ds_sup->x; + vz += ds_svp->x; + } while (--width >= 0); +#else + startz = 1.f/iz; + startu = uz*startz; + startv = vz*startz; + + izstep = ds->szp.x * SPANSIZE; + uzstep = ds->sup.x * SPANSIZE; + vzstep = ds->svp.x * SPANSIZE; + //x1 = 0; + width++; + + while (width >= SPANSIZE) + { + iz += izstep; + uz += uzstep; + vz += vzstep; + + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; + stepu = (INT64)((endu - startu) * INVSPAN); + stepv = (INT64)((endv - startv) * INVSPAN); + u = (INT64)(startu); + v = (INT64)(startv); + + x1 = ds->x1; + + for (i = 0; i < SPANSIZE; i++) + { + bit = (((v + stepv * i) >> nflatyshift) & nflatmask) | ((u + stepu * i) >> nflatxshift); + colormap = ds->planezlight[tiltlighting[x1 + i]] + (ds->colormap - colormaps); + dest[i] = R_DrawSpanPixel(ds, &dsrc[i], colormap, bit, source); + } + + ds->x1 += SPANSIZE; + dest += SPANSIZE; + dsrc += SPANSIZE; + startu = endu; + startv = endv; + width -= SPANSIZE; + } + + if (width > 0) + { + if (width == 1) + { + u = (INT64)(startu); + v = (INT64)(startv); + bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); + colormap = ds->planezlight[tiltlighting[ds->x1]] + (ds->colormap - colormaps); + *dest = R_DrawSpanPixel(ds, dsrc, colormap, bit, source); + ds->x1++; + } + else + { + double left = width; + iz += ds->szp.x * left; + uz += ds->sup.x * left; + vz += ds->svp.x * left; + + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; + left = 1.f/left; + stepu = (INT64)((endu - startu) * left); + stepv = (INT64)((endv - startv) * left); + u = (INT64)(startu); + v = (INT64)(startv); + + for (; width != 0; width--) + { + bit = ((v >> ds->nflatyshift) & ds->nflatmask) | (u >> ds->nflatxshift); + colormap = ds->planezlight[tiltlighting[ds->x1]] + (ds->colormap - colormaps); + *dest = R_DrawSpanPixel(ds, dsrc, colormap, bit, source); + dest++; + ds->x1++; + dsrc++; + u += stepu; + v += stepv; + } + } + } +#endif +} + +#define DEFINE_SPAN_FUNC(name, flags, template) \ +void name(drawspandata_t* ds) \ +{ \ + constexpr DrawSpanType opt = static_cast(flags); \ + template(ds); \ +} + +#define DEFINE_SPAN_COMBO(name, flags) \ +DEFINE_SPAN_FUNC(name, flags, R_DrawSpanTemplate) \ +DEFINE_SPAN_FUNC(name ## _Tilted, flags, R_DrawTiltedSpanTemplate) \ + +DEFINE_SPAN_COMBO(R_DrawSpan, DS_BASIC) +DEFINE_SPAN_COMBO(R_DrawTranslucentSpan, DS_TRANSMAP) +DEFINE_SPAN_COMBO(R_DrawSplat, DS_HOLES) +DEFINE_SPAN_COMBO(R_DrawTranslucentSplat, DS_TRANSMAP|DS_HOLES) +DEFINE_SPAN_COMBO(R_DrawTranslucentWaterSpan, DS_TRANSMAP|DS_RIPPLE) + +/** \brief The R_DrawFogSpan function + Draws the actual span with fogging. +*/ +void R_DrawFogSpan(drawspandata_t* ds) +{ + const UINT8 * restrict colormap = ds->colormap; + UINT8 * restrict dest = R_Address(ds->x1, ds->y); + + intptr_t count = ds->x2 - ds->x1 + 1; + + while (count >= 4) + { + dest[0] = colormap[dest[0]]; + dest[1] = colormap[dest[1]]; + dest[2] = colormap[dest[2]]; + dest[3] = colormap[dest[3]]; + + dest += 4; + count -= 4; + } + + while (count--) + { + *dest = colormap[*dest]; + dest++; + } +} + +void R_DrawFogSpan_Tilted(drawspandata_t* ds) +{ + int width = ds->x2 - ds->x1; + float iz = ds->szp.z + ds->szp.y*(centery-ds->y) + ds->szp.x*(ds->x1-centerx); + UINT8 * restrict dest; + + local_for_thread INT32 *tiltlighting = NULL; + local_for_thread INT32 oldviewwidth = 0; + + // dont realloc every frame pls thx + if (tiltlighting == NULL || oldviewwidth != viewwidth) + { + tiltlighting = static_cast(realloc(tiltlighting, sizeof(*tiltlighting) * viewwidth)); + oldviewwidth = viewwidth; + } + + dest = R_Address(ds->x1, ds->y); + const INT32 stride = vid.width; + + // Lighting is simple. It's just linear interpolation from start to end + { + float planelightfloat = PLANELIGHTFLOAT; + float lightstart, lightend; + + lightend = (iz + ds->szp.x*width) * planelightfloat; + lightstart = iz * planelightfloat; + + R_CalcTiltedLighting(tiltlighting, ds->x1, ds->x2, FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend)); + //CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf); + } + + do + { + UINT8 *colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps); + *dest = colormap[*dest]; + dest++; + } + while (--width >= 0); +} diff --git a/src/r_fps.c b/src/r_fps.c index 4938988dc..0c3a58737 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -173,7 +173,7 @@ static vector3_t *R_LerpVector3(const vector3_t *from, const vector3_t *to, fixe // recalc necessary stuff for mouseaiming // slopes are already calculated for the full possible view (which is 4*viewheight). -// 18/08/18: (No it's actually 16*viewheight, thanks Jimita for finding this out) +// 18/08/18: (No it's actually 16*viewheight, thanks Lactozilla for finding this out) static void R_SetupFreelook(void) { // clip it in the case we are looking a hardware 90 degrees full aiming @@ -232,7 +232,7 @@ void R_InterpolateView(fixed_t frac, boolean forceinvalid) viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); viewplayer = newview->player; - viewsector = R_PointInSubsector(viewx, viewy)->sector; + viewsector = R_PointInSubsectorFast(viewx, viewy)->sector; R_SetupFreelook(); } @@ -494,8 +494,8 @@ void R_CreateInterpolator_Polyobj(thinker_t *thinker, polyobj_t *polyobj) interp->polyobj.polyobj = polyobj; interp->polyobj.vertices_size = polyobj->numVertices; - interp->polyobj.oldvertices = Z_CallocAlign(sizeof(fixed_t) * 2 * polyobj->numVertices, PU_LEVEL, NULL, 32); - interp->polyobj.bakvertices = Z_CallocAlign(sizeof(fixed_t) * 2 * polyobj->numVertices, PU_LEVEL, NULL, 32); + interp->polyobj.oldvertices = Z_Calloc(sizeof(fixed_t) * 2 * polyobj->numVertices, PU_LEVEL, NULL); + interp->polyobj.bakvertices = Z_Calloc(sizeof(fixed_t) * 2 * polyobj->numVertices, PU_LEVEL, NULL); for (size_t i = 0; i < polyobj->numVertices; i++) { interp->polyobj.oldvertices[i * 2 ] = interp->polyobj.bakvertices[i * 2 ] = polyobj->vertices[i]->x; diff --git a/src/r_fps.h b/src/r_fps.h index 7ed55c848..870fa70f1 100644 --- a/src/r_fps.h +++ b/src/r_fps.h @@ -15,6 +15,10 @@ #ifndef __R_FPS_H__ #define __R_FPS_H__ +#ifdef __cplusplus +extern "C" { +#endif + #include "m_fixed.h" #include "p_local.h" #include "r_state.h" @@ -175,4 +179,8 @@ void R_UpdateMobjInterpolators(void); void R_ResetMobjInterpolationState(mobj_t *mobj); void R_ResetPrecipitationMobjInterpolationState(precipmobj_t *mobj); +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/r_local.h b/src/r_local.h index 1d3187750..4701cb400 100644 --- a/src/r_local.h +++ b/src/r_local.h @@ -14,6 +14,10 @@ #ifndef __R_LOCAL__ #define __R_LOCAL__ +#ifdef __cplusplus +extern "C" { +#endif + // Screen size related parameters. #include "doomdef.h" @@ -38,4 +42,8 @@ extern drawseg_t *firstseg; void SplitScreen_OnChange(void); +#ifdef __cplusplus +} // extern "C" +#endif + #endif // __R_LOCAL__ diff --git a/src/r_main.c b/src/r_main.cpp similarity index 75% rename from src/r_main.c rename to src/r_main.cpp index 490d6eda4..cef57ad2e 100644 --- a/src/r_main.c +++ b/src/r_main.cpp @@ -13,6 +13,8 @@ /// utility functions (BSP, geometry, trigonometry). /// See tables.c, too. +#include + #include "doomdef.h" #include "g_game.h" #include "g_input.h" @@ -88,7 +90,7 @@ INT32 viewangletox[FINEANGLES/2]; // The xtoviewangleangle[] table maps a screen pixel // to the lowest viewangle that maps back to x ranges // from clipangle to -clipangle. -angle_t xtoviewangle[MAXVIDWIDTH+1]; +angle_t *xtoviewangle; lighttable_t *scalelight[LIGHTLEVELS][MAXLIGHTSCALE]; lighttable_t *scalelightfixed[MAXLIGHTSCALE]; @@ -100,23 +102,23 @@ extracolormap_t extra_colormaps[MAXCOLORMAPS]; // Performance stats precise_t ps_prevframetime = 0; -ps_metric_t ps_rendercalltime = {0}; -ps_metric_t ps_otherrendertime = {0}; -ps_metric_t ps_uitime = {0}; -ps_metric_t ps_swaptime = {0}; +ps_metric_t ps_rendercalltime = {}; +ps_metric_t ps_otherrendertime = {}; +ps_metric_t ps_uitime = {}; +ps_metric_t ps_swaptime = {}; -ps_metric_t ps_skyboxtime = {0}; -ps_metric_t ps_bsptime = {0}; +ps_metric_t ps_skyboxtime = {}; +ps_metric_t ps_bsptime = {}; -ps_metric_t ps_sw_spritecliptime = {0}; -ps_metric_t ps_sw_portaltime = {0}; -ps_metric_t ps_sw_planetime = {0}; -ps_metric_t ps_sw_maskedtime = {0}; +ps_metric_t ps_sw_spritecliptime = {}; +ps_metric_t ps_sw_portaltime = {}; +ps_metric_t ps_sw_planetime = {}; +ps_metric_t ps_sw_maskedtime = {}; -ps_metric_t ps_numbspcalls = {0}; -ps_metric_t ps_numsprites = {0}; -ps_metric_t ps_numdrawnodes = {0}; -ps_metric_t ps_numpolyobjects = {0}; +ps_metric_t ps_numbspcalls = {}; +ps_metric_t ps_numsprites = {}; +ps_metric_t ps_numdrawnodes = {}; +ps_metric_t ps_numpolyobjects = {}; static CV_PossibleValue_t drawdist_cons_t[] = { /*{256, "256"},*/ {512, "512"}, {768, "768"}, @@ -139,10 +141,10 @@ static CV_PossibleValue_t drawdist_precip_cons_t[] = { #endif static CV_PossibleValue_t maxinterpdist_cons_t[] = { - /*{256, "256"},*/ {512, "512"}, {768, "768"}, - {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, - {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, - {8192, "8192"}, {0, "Infinite"}, {0, NULL}}; + /*{256, "256"},*/ {512, "512"}, {768, "768"}, + {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, + {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, + {8192, "8192"}, {0, "Infinite"}, {0, NULL}}; static CV_PossibleValue_t fov_cons_t[] = {{MINFOV*FRACUNIT, "MIN"}, {MAXFOV*FRACUNIT, "MAX"}, {0, NULL}}; @@ -157,10 +159,6 @@ static void FlipCam_OnChange(void); static void FlipCam2_OnChange(void); static void FlipCam3_OnChange(void); static void FlipCam4_OnChange(void); -void SendWeaponPref(void); -void SendWeaponPref2(void); -void SendWeaponPref3(void); -void SendWeaponPref4(void); static void DirLight_OnChange(void); @@ -172,51 +170,52 @@ consvar_t cv_tailspickup = {"tailspickup", "On", CV_NETVAR|CV_NOSHOWHELP, CV_OnO consvar_t cv_precachetextures = {"precachetextures", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_chasecam[MAXSPLITSCREENPLAYERS] = { - {"chasecam", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"chasecam", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, {"chasecam2", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, {"chasecam3", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, {"chasecam4", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL} }; consvar_t cv_flipcam[MAXSPLITSCREENPLAYERS] = { - {"flipcam", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"flipcam", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam_OnChange, 0, NULL, NULL, 0, 0, NULL}, {"flipcam2", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam2_OnChange, 0, NULL, NULL, 0, 0, NULL}, {"flipcam3", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam3_OnChange, 0, NULL, NULL, 0, 0, NULL}, {"flipcam4", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam4_OnChange, 0, NULL, NULL, 0, 0, NULL} }; -consvar_t cv_shadow = {"shadow", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_shadowoffs = {"offsetshadows", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_skybox = {"skybox", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_ffloorclip = {"r_ffloorclip", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_spriteclip = {"r_spriteclip", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_soniccd = {"soniccd", "Off", CV_NETVAR|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_allowmlook = {"allowmlook", "Yes", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_showhud = {"showhud", "Yes", CV_CALL, CV_YesNo, R_SetViewSize, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_translucenthud = {"translucenthud", "10", CV_SAVE, translucenthud_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_uncappedhud = {"uncappedhud", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; - -consvar_t cv_translucency = {"translucency", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_drawdist = {"drawdist", "Infinite", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_shadow = {"shadow", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_shadowoffs = {"offsetshadows", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_skybox = {"skybox", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_ffloorclip = {"r_ffloorclip", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_spriteclip = {"r_spriteclip", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_softcyancut = {"softwarecyancut", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_translucency = {"translucency", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_drawdist = {"drawdist", "Infinite", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_drawdist_precip = {"drawdist_precip", "1024", CV_SAVE|CV_CALL|CV_NOINIT, drawdist_precip_cons_t, Precipstuff_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_lessprecip = {"lessweathereffects", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Precipstuff_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_lessprecip = {"lessweathereffects", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Precipstuff_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_mobjscaleprecip = {"scaleprecipmobjscale", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Precipstuff_OnChange, 0, NULL, NULL, 0, 0, NULL}; - -consvar_t cv_maxinterpdist = {"maxinterpdist", "Infinite", CV_SAVE, maxinterpdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; - -consvar_t cv_ripplewater = {"waterripples", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - -// cap fov, fov too high tears software apart. -consvar_t cv_fov = {"fov", "90", CV_FLOAT|CV_CALL|CV_SAVE, fov_cons_t, Fov_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_fovchange = {"fovchange", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_maxinterpdist = {"maxinterpdist", "Infinite", CV_SAVE, maxinterpdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_playerfade = {"playerfade", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_ripplewater = {"waterripples", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // Okay, whoever said homremoval causes a performance hit should be shot. -consvar_t cv_homremoval = {"homremoval", "Yes", CV_SAVE, homremoval_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_homremoval = {"homremoval", "Yes", CV_SAVE, homremoval_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_maxportals = {"maxportals", "2", CV_SAVE, maxportals_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_maxportals = {"maxportals", "2", CV_SAVE, maxportals_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + +// cap fov, fov too high tears software apart. +consvar_t cv_fov = {"fov", "90", CV_FLOAT|CV_CALL|CV_SAVE, fov_cons_t, Fov_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_fovchange = {"fovchange", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // randomized directional lightning -consvar_t cv_randomdirlight = {"randomdirectionallight", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, DirLight_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_randomdirlight = {"randomdirectionallight", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, DirLight_OnChange, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_showhud = {"showhud", "Yes", CV_CALL, CV_YesNo, R_SetViewSize, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_translucenthud = {"translucenthud", "10", CV_SAVE, translucenthud_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_uncappedhud = {"uncappedhud", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_soniccd = {"soniccd", "Off", CV_NETVAR|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_allowmlook = {"allowmlook", "Yes", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; // tells to reset the maplight at next map change static void DirLight_OnChange(void) @@ -403,7 +402,8 @@ angle_t R_PlayerSliptideAngle(player_t *player) sprframe = &sprdef->spriteframes[rot]; // No sprite frame? I guess it is possible - if (!sprframe) return 0; + if (!sprframe) + return 0; if (sprframe->rotate != SRF_SINGLE || (mo->frame & FF_PAPERSPRITE)) ang = R_PointToAngle(mo->x, mo->y) - mo->angle; @@ -463,6 +463,7 @@ boolean R_DoCulling(line_t *cullheight, line_t *viewcullheight, fixed_t vz, fixe return false; cullplane = cullheight->frontsector->floorheight; + if (cullheight->flags & ML_NOCLIMB) // Group culling { if (!viewcullheight) @@ -494,7 +495,7 @@ boolean R_DoCulling(line_t *cullheight, line_t *viewcullheight, fixed_t vz, fixe // Returns search dimensions within a blockmap, in the direction of viewangle and out to a certain distance. void R_GetRenderBlockMapDimensions(fixed_t drawdist, INT32 *xl, INT32 *xh, INT32 *yl, INT32 *yh) { - const angle_t left = viewangle - clipangle; + const angle_t left = viewangle - clipangle; const angle_t right = viewangle + clipangle; const fixed_t vxleft = viewx + FixedMul(drawdist, FCOS(left)); @@ -504,10 +505,10 @@ void R_GetRenderBlockMapDimensions(fixed_t drawdist, INT32 *xl, INT32 *xh, INT32 const fixed_t vyright = viewy + FixedMul(drawdist, FSIN(right)); // Try to narrow the search to within only the field of view - *xl = (unsigned)(min(viewx, min(vxleft, vxright)) - bmaporgx)>>MAPBLOCKSHIFT; - *xh = (unsigned)(max(viewx, max(vxleft, vxright)) - bmaporgx)>>MAPBLOCKSHIFT; - *yl = (unsigned)(min(viewy, min(vyleft, vyright)) - bmaporgy)>>MAPBLOCKSHIFT; - *yh = (unsigned)(max(viewy, max(vyleft, vyright)) - bmaporgy)>>MAPBLOCKSHIFT; + *xl = (unsigned)(std::min(viewx, std::min(vxleft, vxright)) - bmaporgx)>>MAPBLOCKSHIFT; + *xh = (unsigned)(std::max(viewx, std::max(vxleft, vxright)) - bmaporgx)>>MAPBLOCKSHIFT; + *yl = (unsigned)(std::min(viewy, std::min(vyleft, vyright)) - bmaporgy)>>MAPBLOCKSHIFT; + *yh = (unsigned)(std::max(viewy, std::max(vyleft, vyright)) - bmaporgy)>>MAPBLOCKSHIFT; if (*xh >= bmapwidth) *xh = bmapwidth - 1; @@ -582,8 +583,6 @@ static void R_InitTextureMapping(void) doubleclipangle = clipangle*2; } - - // // R_InitLightTables // Only inits the zlight table, @@ -631,7 +630,7 @@ static struct { INT32 scrmapsize; INT32 x1; // clip rendering horizontally for efficiency - INT16 ceilingclip[MAXVIDWIDTH], floorclip[MAXVIDWIDTH]; + INT16 *ceilingclip, *floorclip; boolean use; } viewmorph = { @@ -642,7 +641,7 @@ static struct { 0, 0, - {}, {}, + NULL, NULL, false }; @@ -660,7 +659,6 @@ void R_CheckViewMorph(void) rollangle >>= ANGLETOFINESHIFT; rollangle = ((rollangle+2) & ~3) & FINEMASK; // Limit the distinct number of angles to reduce recalcs from angles changing a lot. - if (rollangle == viewmorph.rollangle && viewmorph.scrmapsize == vid.width*vid.height) return; // No change @@ -680,10 +678,10 @@ void R_CheckViewMorph(void) if (viewmorph.scrmapsize != vid.width*vid.height) { - if (viewmorph.scrmap) - free(viewmorph.scrmap); - viewmorph.scrmap = malloc(vid.width*vid.height * sizeof(INT32)); viewmorph.scrmapsize = vid.width*vid.height; + viewmorph.scrmap = static_cast(realloc(viewmorph.scrmap, vid.width*vid.height * sizeof(INT32))); + viewmorph.ceilingclip = static_cast(realloc(viewmorph.ceilingclip, vid.width * sizeof(INT16))); + viewmorph.floorclip = static_cast(realloc(viewmorph.floorclip, vid.width * sizeof(INT16))); } temp = FINECOSINE(rollangle); @@ -695,7 +693,7 @@ void R_CheckViewMorph(void) x1 = (vid.width*fabsf(rollcos) + vid.height*fabsf(rollsin)) / vid.width; y1 = (vid.height*fabsf(rollcos) + vid.width*fabsf(rollsin)) / vid.height; - temp = max(x1, y1)*FRACUNIT; + temp = std::max(x1, y1)*FRACUNIT; if (temp < FRACUNIT) temp = FRACUNIT; else @@ -741,10 +739,10 @@ void R_CheckViewMorph(void) xb = vid.width-1-xa; yb = vid.height-1-ya; - viewmorph.ceilingclip[xa] = min(viewmorph.ceilingclip[xa], ya); - viewmorph.floorclip[xa] = max(viewmorph.floorclip[xa], ya); - viewmorph.ceilingclip[xb] = min(viewmorph.ceilingclip[xb], yb); - viewmorph.floorclip[xb] = max(viewmorph.floorclip[xb], yb); + viewmorph.ceilingclip[xa] = std::min(viewmorph.ceilingclip[xa], ya); + viewmorph.floorclip[xa] = std::max(viewmorph.floorclip[xa], ya); + viewmorph.ceilingclip[xb] = std::min(viewmorph.ceilingclip[xb], yb); + viewmorph.floorclip[xb] = std::max(viewmorph.floorclip[xb], yb); x2 += rollcos; y2 += rollsin; } @@ -758,10 +756,10 @@ void R_CheckViewMorph(void) xb = vid.width-1-xa; yb = vid.height-1-ya; - viewmorph.ceilingclip[xa] = min(viewmorph.ceilingclip[xa], ya); - viewmorph.floorclip[xa] = max(viewmorph.floorclip[xa], ya); - viewmorph.ceilingclip[xb] = min(viewmorph.ceilingclip[xb], yb); - viewmorph.floorclip[xb] = max(viewmorph.floorclip[xb], yb); + viewmorph.ceilingclip[xa] = std::min(viewmorph.ceilingclip[xa], ya); + viewmorph.floorclip[xa] = std::max(viewmorph.floorclip[xa], ya); + viewmorph.ceilingclip[xb] = std::min(viewmorph.ceilingclip[xb], yb); + viewmorph.floorclip[xb] = std::max(viewmorph.floorclip[xb], yb); x2 -= rollsin; y2 += rollcos; } @@ -799,8 +797,8 @@ void R_CheckViewMorph(void) void R_ApplyViewMorph(void) { - UINT8 *tmpscr = screens[4]; - UINT8 *srcscr = screens[0]; + UINT8 *tmpscr = vid.screens[4]; + UINT8 *srcscr = vid.screens[0]; INT32 p, end = vid.width * vid.height; if (!viewmorph.use) @@ -835,8 +833,7 @@ void R_ApplyViewMorph(void) for (p = 0; p < end; p++) tmpscr[p] = srcscr[viewmorph.scrmap[p]]; - VID_BlitLinearScreen(tmpscr, screens[0], - vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.width); + VID_BlitLinearScreen(tmpscr, vid.screens[0], vid.width, vid.height, vid.width, vid.width); } angle_t R_ViewRollAngle(const player_t *player) @@ -889,6 +886,8 @@ void R_SetViewSize(void) setsizeneeded = true; } +static void R_SetupViewBuffers(void); + // // R_ExecuteSetViewSize // @@ -907,18 +906,15 @@ void R_ExecuteSetViewSize(void) // status bar overlay st_overlay = cv_showhud.value; - scaledviewwidth = vid.width; + viewwidth = vid.width; viewheight = vid.height; if (splitscreen) viewheight >>= 1; - viewwidth = scaledviewwidth; - if (splitscreen > 1) { viewwidth >>= 1; - scaledviewwidth >>= 1; } centerx = viewwidth/2; @@ -926,9 +922,7 @@ void R_ExecuteSetViewSize(void) centerxfrac = centerx<fovadd; - return max(MINFOV*FRACUNIT, min(fov, MAXFOV*FRACUNIT)); + return std::max(MINFOV*FRACUNIT, std::min(fov, MAXFOV*FRACUNIT)); } -static void R_SetFov(fixed_t playerfov) +static void R_CalcFov(fixed_t playerfov) { angle_t fov = FixedAngle(playerfov/2) + ANGLE_90; fovtan = FixedMul(FINETANGENT(fov >> ANGLETOFINESHIFT), viewmorph.zoomneeded); if (splitscreen == 1) // Splitscreen FOV should be adjusted to maintain expected vertical view fovtan = 17*fovtan/10; - // this is only used for planes rendering in software mode - INT32 j = viewheight*16; - for (INT32 i = 0; i < j; i++) - { - fixed_t dy = (i - viewheight*8)<children[side]; + } + + ret = &subsectors[nodenum & ~NF_SUBSECTOR]; + for (i = 0; i < ret->numlines; i++) + if (P_PointOnLineSide(x, y, segs[ret->firstline + i].linedef) != segs[ret->firstline + i].side) + return 0; + + return ret; +} + // // R_SetupFrame // @@ -1056,7 +1095,7 @@ static void R_SetupCommonFrame(player_t * player, sector_t * sector) if (sector != NULL) newview->sector = sector; else - newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; + newview->sector = R_PointInSubsectorFast(newview->x, newview->y)->sector; R_InterpolateView(rendertimefrac_unpaused, false); } @@ -1068,28 +1107,88 @@ static void R_SetupAimingFrame(player_t *player, camera_t *thiscam) newview->aim = player->awayviewaiming; newview->angle = player->awayviewmobj->angle; } - else if (thiscam->chase) + else if (thiscam && thiscam->chase) { newview->aim = thiscam->aiming; newview->angle = thiscam->angle; } + else if (P_IsLocalPlayer(player) && !demo.playback && player->playerstate != PST_DEAD) + { + newview->aim = localaiming[viewssnum]; + newview->angle = localangle[viewssnum]; + } else { newview->aim = player->aiming; newview->angle = player->mo->angle; + } +} - if (!demo.playback && player->playerstate != PST_DEAD) +static void R_SetupSkyScale(player_t *player, camera_t *thiscam, mapheader_t *mh) +{ + if (!mh->skybox_scalex && !mh->skybox_scaley && !mh->skybox_scalez) + return; + + auto setup_skyscale = [&](fixed_t mox, fixed_t moy, fixed_t zscale) + { + if (skyboxmo[1]) { - for (UINT8 i = 0; i <= splitscreen; i++) + angle_t ang; + fixed_t x = 0, y = 0; + + if (mh->skybox_scalex > 0) + x = (mox - skyboxmo[1]->x) / mh->skybox_scalex; + else if (mh->skybox_scalex < 0) + x = (mox - skyboxmo[1]->x) * -mh->skybox_scalex; + + if (mh->skybox_scaley > 0) + y = (moy - skyboxmo[1]->y) / mh->skybox_scaley; + else if (mh->skybox_scaley < 0) + y = (moy - skyboxmo[1]->y) * -mh->skybox_scaley; + + switch (viewmobj->angle) { - if (player == (i == 0 ? &players[consoleplayer] : &players[displayplayers[i]])) - { - newview->angle = localangle[i]; - newview->aim = localaiming[i]; + case 0: + newview->x += x; + newview->y += y; + break; + case ANGLE_90: + newview->x -= y; + newview->y += x; + break; + case ANGLE_180: + newview->x -= x; + newview->y -= y; + break; + case ANGLE_270: + newview->x += y; + newview->y -= x; + break; + default: + ang = viewmobj->angle>>ANGLETOFINESHIFT; + newview->x += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang)); + newview->y += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang)); break; - } } } + + if (mh->skybox_scalez > 0) + newview->z += zscale / mh->skybox_scalez; + else if (mh->skybox_scalez < 0) + newview->z += zscale * -mh->skybox_scalez; + }; + + if (player->awayviewtics && player->awayviewmobj) + { + setup_skyscale(player->awayviewmobj->x, player->awayviewmobj->y, (player->awayviewmobj->z + 20*FRACUNIT)); + } + else if (thiscam && thiscam->chase) + { + setup_skyscale(thiscam->x, thiscam->y, (thiscam->z + (thiscam->height>>1))); + } + else + { + setup_skyscale(player->mo->x, player->mo->y, player->viewz); } } @@ -1097,13 +1196,15 @@ void R_SkyboxFrame(int s) { player_t *player = &players[displayplayers[s]]; camera_t *thiscam = &camera[s]; - subsector_t * subsector = NULL; + subsector_t *subsector = NULL; + mapheader_t *mh = mapheaderinfo[gamemap-1]; - R_SetViewContext(VIEWCONTEXT_SKY1 + s); + R_SetViewContext(static_cast(VIEWCONTEXT_SKY1 + s)); // cut-away view stuff newview->sky = true; viewmobj = skyboxmo[0]; + #ifdef PARANOIA if (P_MobjWasRemoved(viewmobj)) { @@ -1111,78 +1212,19 @@ void R_SkyboxFrame(int s) I_Error("R_SkyboxFrame: viewmobj null (player %s)", sizeu1(playeri)); } #endif + R_SetupAimingFrame(player, thiscam); newview->angle += viewmobj->angle; newview->x = viewmobj->x; newview->y = viewmobj->y; - newview->z = 0; - if (viewmobj->spawnpoint) - newview->z = ((fixed_t)viewmobj->spawnpoint->angle)<z = (viewmobj->spawnpoint) ? (((fixed_t)viewmobj->spawnpoint->angle)<skybox_scalex > 0)\ - x = (viewmo->x - skyboxmo[1]->x) / mh->skybox_scalex;\ - else if (mh->skybox_scalex < 0)\ - x = (viewmo->x - skyboxmo[1]->x) * -mh->skybox_scalex;\ - if (mh->skybox_scaley > 0)\ - y = (viewmo->y - skyboxmo[1]->y) / mh->skybox_scaley;\ - else if (mh->skybox_scaley < 0)\ - y = (viewmo->y - skyboxmo[1]->y) * -mh->skybox_scaley;\ - if (viewmobj->angle == 0)\ - {\ - newview->x += x;\ - newview->y += y;\ - }\ - else if (viewmobj->angle == ANGLE_90)\ - {\ - newview->x -= y;\ - newview->y += x;\ - }\ - else if (viewmobj->angle == ANGLE_180)\ - {\ - newview->x -= x;\ - newview->y -= y;\ - }\ - else if (viewmobj->angle == ANGLE_270)\ - {\ - newview->x += y;\ - newview->y -= x;\ - }\ - else\ - {\ - angle_t ang = viewmobj->angle>>ANGLETOFINESHIFT;\ - newview->x += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang));\ - newview->y += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang));\ - }\ - }\ - if (mh->skybox_scalez > 0)\ - newview->z += zscale / mh->skybox_scalez;\ - else if (mh->skybox_scalez < 0)\ - newview->z += zscale * -mh->skybox_scalez; - - if (mapheaderinfo[gamemap-1]) + if (mh) { - mapheader_t *mh = mapheaderinfo[gamemap-1]; - - if (player->awayviewtics && player->awayviewmobj) - { - SETUPSKYVIEW(player->awayviewmobj, (player->awayviewmobj->z + 20*FRACUNIT)); - } - else if (thiscam->chase) - { - SETUPSKYVIEW(thiscam, (thiscam->z + (thiscam->height>>1))); - } - else - { - SETUPSKYVIEW(player->mo, player->viewz); - } + R_SetupSkyScale(player, thiscam, mh); } -#undef SETUPSKYVIEW if (!P_MobjWasRemoved(viewmobj) && viewmobj->subsector && viewmobj->subsector->sector) subsector = viewmobj->subsector; @@ -1197,7 +1239,8 @@ void R_SetupFrame(int s, boolean skybox) boolean chasecam = (cv_chasecam[s].value); sector_t * sector = NULL; - R_SetViewContext(VIEWCONTEXT_PLAYER1 + s); + R_SetViewContext(static_cast(VIEWCONTEXT_PLAYER1 + s)); + if (thiscam->reset) { R_ResetViewInterpolation(s); @@ -1243,12 +1286,13 @@ void R_SetupFrame(int s, boolean skybox) else if (thiscam && chasecam) // use outside cam view { viewmobj = NULL; + I_Assert(thiscam != NULL); newview->x = thiscam->x; newview->y = thiscam->y; newview->z = thiscam->z + (thiscam->height>>1); - if (thiscam != NULL && thiscam->subsector && thiscam->subsector->sector) + if (thiscam->subsector && thiscam->subsector->sector) sector = thiscam->subsector->sector; R_SetupCommonFrame(player, sector); @@ -1276,8 +1320,8 @@ static void R_PortalFrame(portal_t *portal) viewz = portal->viewz; viewangle = portal->viewangle; - // viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT); - // viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); + //viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT); + //viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); portalclipstart = portal->start; portalclipend = portal->end; @@ -1285,21 +1329,51 @@ static void R_PortalFrame(portal_t *portal) if (portal->clipline != -1) { portalclipline = &lines[portal->clipline]; - portalcullsector = portalclipline->frontsector; - viewsector = portalclipline->frontsector; + viewsector = portalcullsector = portalclipline->frontsector; } else { portalclipline = NULL; portalcullsector = NULL; - viewsector = R_PointInSubsector(viewx, viewy)->sector; + viewsector = R_PointInSubsectorFast(viewx, viewy)->sector; } } +static void Mask_Pre (maskcount_t* m) +{ + m->drawsegs[0] = ds_p - drawsegs; + m->vissprites[0] = visspritecount; + m->viewx = viewx; + m->viewy = viewy; + m->viewz = viewz; + m->viewsector = viewsector; +} + +static void Mask_Post (maskcount_t* m) +{ + m->drawsegs[1] = ds_p - drawsegs; + m->vissprites[1] = visspritecount; +} + // ================ // R_RenderView // ================ +// viewx, viewy, viewangle, all that good stuff must be set +static void R_RenderViewpoint(maskcount_t* mask, boolean drawprecip) +{ + Mask_Pre(mask); + + curdrawsegs = ds_p; + + R_RenderBSPNode((INT32)numnodes - 1); + + if (drawprecip) + R_AddPrecipitationSprites(); + + Mask_Post(mask); +} + // FAB NOTE FOR WIN32 PORT !! I'm not finished already, // but I suspect network may have problems with the video buffer being locked // for all duration of rendering, and being released only once at the end.. @@ -1310,52 +1384,19 @@ static fixed_t viewfov[MAXSPLITSCREENPLAYERS]; void R_RenderPlayerView(player_t *player) { - const boolean skybox = (skyboxmo[0] && cv_skybox.value); - UINT8 i; - - // if this is display player 1 - if (cv_homremoval.value && player == &players[displayplayers[0]]) - { - if (cv_homremoval.value == 1) - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); // No HOM effect! - else //'development' HOM removal -- makes it blindingly obvious if HOM is spotted. - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 128+(timeinmap&15)); - } - // Draw over the fourth screen so you don't have to stare at a HOM :V - else if (splitscreen == 2 && player == &players[displayplayers[2]]) - { - // V_DrawPatchFill, but for the fourth screen only - patch_t *pat = W_CachePatchName("SRB2BACK", PU_CACHE); - INT32 dupz = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); - INT32 x, y, pw = SHORT(pat->width) * dupz, ph = SHORT(pat->height) * dupz; - - for (x = vid.width>>1; x < vid.width; x += pw) - { - for (y = vid.height>>1; y < vid.height; y += ph) - V_DrawScaledPatch(x, y, V_NOSCALESTART, pat); - } - } + INT32 nummasks = 1; + maskcount_t* masks = static_cast(malloc(sizeof(maskcount_t))); + const boolean skybox = (skyboxmo[0] && cv_skybox.value); // load previous saved value of skyVisible for the player - for (i = 0; i <= splitscreen; i++) + skyVisible = skyVisiblePerPlayer[viewssnum]; + + const fixed_t fov = R_GetPlayerFov(player); + + if (viewfov[viewssnum] != fov) { - if (player != &players[displayplayers[i]]) - continue; - - skyVisible = skyVisiblePerPlayer[i]; - break; - } - - fixed_t fov = R_GetPlayerFov(player); - - for (UINT8 j = 0; j <= splitscreen; j++) - { - if (player == &players[displayplayers[j]] - && viewfov[j] != fov) - { - viewfov[j] = fov; - R_SetFov(fov); - } + viewfov[viewssnum] = fov; + R_SetFov(fov); } Portal_InitList(); @@ -1369,17 +1410,13 @@ void R_RenderPlayerView(player_t *player) R_ClearDrawSegs(); R_ClearPlanes(); R_ClearSprites(); -#ifdef FLOORSPLATS - R_ClearVisibleFloorSplats(); -#endif - R_RenderBSPNode((INT32)numnodes - 1); - R_ClipSprites(); + R_RenderViewpoint(&masks[nummasks - 1], false); + + R_ClipSprites(drawsegs, NULL); + R_DrawSkyPlanes(); // draw the fucker again to prevent some artifacts R_DrawPlanes(); -#ifdef FLOORSPLATS - R_DrawVisibleFloorSplats(); -#endif - R_DrawMasked(); + R_DrawMasked(masks, nummasks); } PS_STOP_TIMING(ps_skyboxtime); @@ -1406,22 +1443,16 @@ void R_RenderPlayerView(player_t *player) } R_ClearDrawSegs(); R_ClearSprites(); -#ifdef FLOORSPLATS - R_ClearVisibleFloorSplats(); -#endif // check for new console commands. NetUpdate(); - // The head node is the last node output. - ps_numbspcalls.value.i = ps_numpolyobjects.value.i = ps_numdrawnodes.value.i = 0; PS_START_TIMING(ps_bsptime); - R_RenderBSPNode((INT32)numnodes - 1); + R_RenderViewpoint(&masks[nummasks - 1], true); PS_STOP_TIMING(ps_bsptime); - R_AddPrecipitationSprites(); PS_START_TIMING(ps_sw_spritecliptime); - R_ClipSprites(); + R_ClipSprites(drawsegs, NULL); PS_STOP_TIMING(ps_sw_spritecliptime); ps_numsprites.value.i = numvisiblesprites; @@ -1450,43 +1481,40 @@ void R_RenderPlayerView(player_t *player) // that were previously stored. Portal_ClipApply(portal); + validcount++; + + masks = static_cast(realloc(masks, (++nummasks)*sizeof(maskcount_t))); + // Render the BSP from the new viewpoint, and clip // any sprites with the new clipsegs and window. - R_RenderBSPNode((INT32)numnodes - 1); - R_ClipSprites(); + R_RenderViewpoint(&masks[nummasks - 1], true); + + R_ClipSprites(ds_p - (masks[nummasks - 1].drawsegs[1] - masks[nummasks - 1].drawsegs[0]), portal); Portal_Remove(portal); - - validcount++; } } PS_STOP_TIMING(ps_sw_portaltime); PS_START_TIMING(ps_sw_planetime); + if (!skybox) + R_DrawSkyPlanes(); R_DrawPlanes(); PS_STOP_TIMING(ps_sw_planetime); -#ifdef FLOORSPLATS - R_DrawVisibleFloorSplats(); -#endif // draw mid texture and sprite // And now 3D floors/sides! PS_START_TIMING(ps_sw_maskedtime); - R_DrawMasked(); + R_DrawMasked(masks, nummasks); PS_STOP_TIMING(ps_sw_maskedtime); + free(masks); + // Check for new console commands. NetUpdate(); // save value to skyVisiblePerPlayer // this is so that P1 can't affect whether P2 can see a skybox or not, or vice versa - for (i = 0; i <= splitscreen; i++) - { - if (player != &players[displayplayers[i]]) - continue; - - skyVisiblePerPlayer[i] = skyVisible; - break; - } + skyVisiblePerPlayer[viewssnum] = skyVisible; } // ========================================================================= @@ -1523,18 +1551,17 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_fovchange); CV_RegisterVar(&cv_fov); - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - CV_RegisterVar(&cv_chasecam[i]); - } CV_RegisterVar(&cv_shadow); CV_RegisterVar(&cv_shadowoffs); CV_RegisterVar(&cv_skybox); CV_RegisterVar(&cv_ffloorclip); CV_RegisterVar(&cv_spriteclip); + CV_RegisterVar(&cv_softcyancut); for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { + CV_RegisterVar(&cv_chasecam[i]); + CV_RegisterVar(&cv_cam_dist[i]); CV_RegisterVar(&cv_cam_still[i]); CV_RegisterVar(&cv_cam_height[i]); @@ -1551,6 +1578,8 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_tiltsmoothing); CV_RegisterVar(&cv_actionmovie); + CV_RegisterVar(&cv_screenquake); + CV_RegisterVar(&cv_driftsparkpulse); CV_RegisterVar(&cv_gravstretch); CV_RegisterVar(&cv_sloperoll); @@ -1568,6 +1597,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_randomdirlight); CV_RegisterVar(&cv_maxinterpdist); + CV_RegisterVar(&cv_playerfade); CV_RegisterVar(&cv_ripplewater); diff --git a/src/r_main.h b/src/r_main.h index d3284764d..295e6e34d 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -14,6 +14,10 @@ #ifndef __R_MAIN__ #define __R_MAIN__ +#ifdef __cplusplus +extern "C" { +#endif + #include "d_player.h" #include "r_data.h" #include "m_perfstats.h" @@ -84,7 +88,7 @@ extern lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ]; // // killough 5/2/98: reformatted // -FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSide(fixed_t x, fixed_t y, const node_t *restrict node) +FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSide(fixed_t x, fixed_t y, const node_t* restrict node) { if (!node->dx) return x <= node->x ? node->dy > 0 : node->dy < 0; @@ -113,10 +117,10 @@ FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSideFast(fixed_t x, fixed_t FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSegSide(fixed_t x, fixed_t y, const seg_t *line) { - fixed_t lx = line->v1->x; - fixed_t ly = line->v1->y; - fixed_t ldx = line->v2->x - lx; - fixed_t ldy = line->v2->y - ly; + fixed_t lx = line->v1->x; + fixed_t ly = line->v1->y; + fixed_t ldx = line->v2->x - lx; + fixed_t ldy = line->v2->y - ly; // use cross product to determine side quickly INT64 v = ((INT64)y - ly) * ldx - ((INT64)x - lx) * ldy; @@ -133,42 +137,19 @@ fixed_t R_ScaleFromGlobalAngle(angle_t visangle); // // R_PointInSubsector // -FUNCINLINE static ATTRINLINE subsector_t *R_PointInSubsector(fixed_t x, fixed_t y) -{ - size_t nodenum = numnodes-1; - - while (!(nodenum & NF_SUBSECTOR)) - nodenum = nodes[nodenum].children[R_PointOnSide(x, y, nodes+nodenum)]; - - return &subsectors[nodenum & ~NF_SUBSECTOR]; +#define R_POINTINSUBSECTOR(FUNCNAME, SIDEFUNC)\ +FUNCINLINE static ATTRINLINE subsector_t *FUNCNAME(fixed_t x, fixed_t y)\ +{\ + size_t nodenum = numnodes-1;\ + while (!(nodenum & NF_SUBSECTOR))\ + nodenum = nodes[nodenum].children[SIDEFUNC(x, y, nodes+nodenum)];\ + return &subsectors[nodenum & ~NF_SUBSECTOR];\ } -// -// R_IsPointInSubsector, same as above but returns 0 if not in subsector -// -FUNCINLINE static ATTRINLINE subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) -{ - node_t *node; - INT32 side, i; - size_t nodenum; - subsector_t *ret; +R_POINTINSUBSECTOR(R_PointInSubsector, R_PointOnSide) +R_POINTINSUBSECTOR(R_PointInSubsectorFast, R_PointOnSideFast) - nodenum = numnodes - 1; - - while (!(nodenum & NF_SUBSECTOR)) - { - node = &nodes[nodenum]; - side = R_PointOnSide(x, y, node); - nodenum = node->children[side]; - } - - ret = &subsectors[nodenum & ~NF_SUBSECTOR]; - for (i = 0; i < ret->numlines; i++) - if (P_PointOnLineSide(x, y, segs[ret->firstline + i].linedef) != segs[ret->firstline + i].side) - return 0; - - return ret; -} +subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y); #define R_PointToDist(x, y) R_PointToDist2(viewx, viewy, x, y) #define R_PointToDist2(px2, py2, px1, py1) FixedHypot((px1) - (px2), (py1) - (py2)) @@ -207,12 +188,14 @@ extern consvar_t cv_chasecam[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_flipcam[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_shadow, cv_shadowoffs; extern consvar_t cv_ffloorclip, cv_spriteclip; +extern consvar_t cv_softcyancut; extern consvar_t cv_translucency; extern consvar_t cv_drawdist, cv_drawdist_precip, cv_lessprecip, cv_mobjscaleprecip; extern consvar_t cv_fov, cv_fovchange; extern consvar_t cv_skybox; extern consvar_t cv_tailspickup; extern consvar_t cv_maxinterpdist; +extern consvar_t cv_playerfade; extern consvar_t cv_ripplewater; extern consvar_t cv_randomdirlight; @@ -245,4 +228,9 @@ void R_RegisterEngineStuff(void); INT32 R_GetHudUncap(void); // same as above but keeps interpolation during pause INT32 R_GetMenuUncap(void); + +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/r_patch.c b/src/r_patch.c index 21f59401c..f48996ea4 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -16,6 +16,7 @@ #include "doomdef.h" #include "r_patch.h" #include "r_things.h" +#include "r_skins.h" #include "z_zone.h" #include "w_wad.h" diff --git a/src/r_patchrotation.h b/src/r_patchrotation.h index d387ae20f..b3bcd7a97 100644 --- a/src/r_patchrotation.h +++ b/src/r_patchrotation.h @@ -12,6 +12,10 @@ #ifndef __R_PATCHROTATION__ #define __R_PATCHROTATION__ +#ifdef __cplusplus +extern "C" { +#endif + #include "r_fps.h" // Sprite rotation @@ -27,4 +31,8 @@ extern fixed_t rollcosang[ROTANGLES]; extern fixed_t rollsinang[ROTANGLES]; #endif +#ifdef __cplusplus +} // extern "C" +#endif + #endif // __R_PATCHROTATION__ diff --git a/src/r_plane.c b/src/r_plane.c deleted file mode 100644 index 37930e89e..000000000 --- a/src/r_plane.c +++ /dev/null @@ -1,1204 +0,0 @@ -// SONIC ROBO BLAST 2 -//----------------------------------------------------------------------------- -// Copyright (C) 1993-1996 by id Software, Inc. -// Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. -// -// This program is free software distributed under the -// terms of the GNU General Public License, version 2. -// See the 'LICENSE' file for more details. -//----------------------------------------------------------------------------- -/// \file r_plane.c -/// \brief Here is a core component: drawing the floors and ceilings, -/// while maintaining a per column clipping list only. -/// Moreover, the sky areas have to be determined. - -#include "doomdef.h" -#include "console.h" -#include "g_game.h" -#include "p_setup.h" // levelflats -#include "p_slopes.h" -#include "r_data.h" -#include "r_local.h" -#include "r_state.h" -#include "r_splats.h" // faB(21jan):testing -#include "r_sky.h" -#include "v_video.h" -#include "w_wad.h" -#include "z_zone.h" -#include "p_tick.h" -#include "r_fps.h" -#include "r_portal.h" - -// -// opening -// - -// Quincunx antialiasing of flats! -//#define QUINCUNX - -// good night sweet prince -//#define SHITPLANESPARENCY - -static visplane_t *visplanes[MAXVISPLANES]; -static visplane_t *freetail; -static visplane_t **freehead = &freetail; - -visplane_t *floorplane; -visplane_t *ceilingplane; -static visplane_t *currentplane; - -visffloor_t ffloor[MAXFFLOORS]; -INT32 numffloors; - -//SoM: 3/23/2000: Boom visplane hashing routine. -#define visplane_hash(picnum,lightlevel,height) \ - ((unsigned)((picnum)*3+(lightlevel)+(height)*7) & VISPLANEHASHMASK) - -//SoM: 3/23/2000: Use boom opening limit removal -size_t maxopenings; -INT16 *openings, *lastopening; /// \todo free leak - -// -// Clip values are the solid pixel bounding the range. -// floorclip starts out SCREENHEIGHT -// ceilingclip starts out -1 -// -INT16 floorclip[MAXVIDWIDTH], ceilingclip[MAXVIDWIDTH]; -fixed_t frontscale[MAXVIDWIDTH]; - -// -// spanstart holds the start of a plane span -// initialized to 0 at start -// -static INT32 spanstart[MAXVIDHEIGHT]; - -// -// texture mapping -// -lighttable_t **planezlight; -static fixed_t planeheight; - -//added : 10-02-98: yslopetab is what yslope used to be, -// yslope points somewhere into yslopetab, -// now (viewheight/2) slopes are calculated above and -// below the original viewheight for mouselook -// (this is to calculate yslopes only when really needed) -// (when mouselookin', yslope is moving into yslopetab) -// Check R_SetupFrame, R_SetViewSize for more... -fixed_t yslopetab[MAXVIDHEIGHT*16]; -fixed_t *yslope; - -fixed_t basexscale, baseyscale; - -fixed_t cachedheight[MAXVIDHEIGHT]; -fixed_t cacheddistance[MAXVIDHEIGHT]; -fixed_t cachedxstep[MAXVIDHEIGHT]; -fixed_t cachedystep[MAXVIDHEIGHT]; - -static fixed_t xoffs, yoffs; - -// -// R_InitPlanes -// Only at game startup. -// -void R_InitPlanes(void) -{ - // FIXME: unused -} - -// -// Water ripple effect!! -// Needs the height of the plane, and the vertical position of the span. -// Sets planeripple.xfrac and planeripple.yfrac, added to ds_xfrac and ds_yfrac, if the span is not tilted. -// - -#ifndef NOWATER -INT32 ds_bgofs; -INT32 ds_waterofs; - -struct -{ - INT32 offset; - fixed_t xfrac, yfrac; - boolean active; -} planeripple; - -static void R_CalculatePlaneRipple(visplane_t *plane, INT32 y, fixed_t plheight, boolean calcfrac) -{ - fixed_t distance = FixedMul(plheight, yslope[y]); - const INT32 yay = (planeripple.offset + (distance>>9)) & 8191; - - // ripples da water texture - ds_bgofs = FixedDiv(FINESINE(yay), (1<<12) + (distance>>11))>>FRACBITS; - - if (calcfrac) - { - angle_t angle = (plane->viewangle + plane->plangle)>>ANGLETOFINESHIFT; - angle = (angle + 2048) & 8191; // 90 degrees - planeripple.xfrac = FixedMul(FINECOSINE(angle), (ds_bgofs<= viewwidth || y > viewheight) - I_Error("R_MapPlane: %d, %d at %d", x1, x2, y); -#endif - - if (x1 >= vid.width) - x1 = vid.width - 1; - - if (!currentplane->slope) - { - angle = (currentplane->viewangle + currentplane->plangle)>>ANGLETOFINESHIFT; - planecos = FINECOSINE(angle); - planesin = FINESINE(angle); - - if (planeheight != cachedheight[y]) - { - cachedheight[y] = planeheight; - cacheddistance[y] = distance = FixedMul(planeheight, yslope[y]); - span = abs(centery - y); - - if (span) // don't divide by zero - { - ds_xstep = FixedMul(planesin, planeheight) / span; - ds_ystep = FixedMul(planecos, planeheight) / span; - } - else - { - ds_xstep = FixedMul(distance, basexscale); - ds_ystep = FixedMul(distance, baseyscale); - } - - cachedxstep[y] = ds_xstep; - cachedystep[y] = ds_ystep; - } - else - { - distance = cacheddistance[y]; - ds_xstep = cachedxstep[y]; - ds_ystep = cachedystep[y]; - } - - ds_xfrac = xoffs + FixedMul(planecos, distance) + (x1 - centerx) * ds_xstep; - ds_yfrac = yoffs - FixedMul(planesin, distance) + (x1 - centerx) * ds_ystep; - } - -#ifndef NOWATER - if (planeripple.active) - { - // Needed for ds_bgofs - R_CalculatePlaneRipple(currentplane, y, planeheight, (!currentplane->slope)); - - if (currentplane->slope) - { - ds_sup = &ds_su[y]; - ds_svp = &ds_sv[y]; - ds_szp = &ds_sz[y]; - } - else - { - ds_xfrac += planeripple.xfrac; - ds_yfrac += planeripple.yfrac; - } - - if ((y + ds_bgofs) >= viewheight) - ds_bgofs = viewheight-y-1; - if ((y + ds_bgofs) < 0) - ds_bgofs = -y; - } -#endif - - if (currentplane->slope) - ds_colormap = colormaps; - else - { - pindex = distance >> LIGHTZSHIFT; - if (pindex >= MAXLIGHTZ) - pindex = MAXLIGHTZ - 1; - ds_colormap = planezlight[pindex]; - } - if (encoremap && !currentplane->noencore) - ds_colormap += COLORMAP_REMAPOFFSET; - - if (currentplane->extra_colormap) - ds_colormap = currentplane->extra_colormap->colormap + (ds_colormap - colormaps); - - ds_y = y; - ds_x1 = x1; - ds_x2 = x2; - - spanfunc(); -} - -void R_ClearFFloorClips (void) -{ - INT32 i, p; - - // opening / clipping determination - for (i = 0; i < viewwidth; i++) - { - for (p = 0; p < MAXFFLOORS; p++) - { - ffloor[p].f_clip[i] = (INT16)viewheight; - ffloor[p].c_clip[i] = -1; - } - } - - numffloors = 0; -} - -// -// R_ClearPlanes -// At begining of frame. -// -void R_ClearPlanes(void) -{ - INT32 i, p; - angle_t angle; - - // opening / clipping determination - for (i = 0; i < viewwidth; i++) - { - floorclip[i] = (INT16)viewheight; - ceilingclip[i] = -1; - frontscale[i] = INT32_MAX; - for (p = 0; p < MAXFFLOORS; p++) - { - ffloor[p].f_clip[i] = (INT16)viewheight; - ffloor[p].c_clip[i] = -1; - } - } - - numffloors = 0; - - for (i = 0; i < MAXVISPLANES; i++) - { - for (*freehead = visplanes[i], visplanes[i] = NULL; - freehead && *freehead ;) - { - freehead = &(*freehead)->next; - } - } - - lastopening = openings; - - // texture calculation - memset(cachedheight, 0, sizeof (cachedheight)); - - // left to right mapping - angle = (viewangle-ANGLE_90)>>ANGLETOFINESHIFT; - - // scale will be unit scale at SCREENWIDTH/2 distance - basexscale = FixedDiv (FINECOSINE(angle),centerxfrac); - baseyscale = -FixedDiv (FINESINE(angle),centerxfrac); -} - -static visplane_t *new_visplane(unsigned hash) -{ - visplane_t *check = freetail; - if (!check) - { - check = malloc(sizeof (*check)); - if (check == NULL) I_Error("%s: Out of memory", "new_visplane"); // FIXME: ugly - } - else - { - freetail = freetail->next; - if (!freetail) - freehead = &freetail; - } - check->next = visplanes[hash]; - visplanes[hash] = check; - return check; -} - -// -// R_FindPlane: Seek a visplane having the identical values: -// Same height, same flattexture, same lightlevel. -// If not, allocates another of them. -// -visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, - fixed_t xoff, fixed_t yoff, angle_t plangle, extracolormap_t *planecolormap, - ffloor_t *pfloor - , polyobj_t *polyobj - , pslope_t *slope - , boolean noencore - , boolean reverseLight, const sector_t *lighting_sector) -{ - visplane_t *check; - unsigned hash; - - if (slope); else // Don't mess with this right now if a slope is involved - { - xoff += viewx; - yoff -= viewy; - if (plangle != 0) - { - // Add the view offset, rotated by the plane angle. - fixed_t cosinecomponent = FINECOSINE(plangle>>ANGLETOFINESHIFT); - fixed_t sinecomponent = FINESINE(plangle>>ANGLETOFINESHIFT); - fixed_t oldxoff = xoff; - xoff = FixedMul(xoff,cosinecomponent)+FixedMul(yoff,sinecomponent); - yoff = -FixedMul(oldxoff,sinecomponent)+FixedMul(yoff,cosinecomponent); - } - } - - if (polyobj) - { - if (polyobj->angle != 0) - { - float ang = ANG2RAD(polyobj->angle); - float x = FixedToFloat(polyobj->centerPt.x); - float y = FixedToFloat(polyobj->centerPt.y); - xoff -= FloatToFixed(x * cos(ang) + y * sin(ang)); - yoff -= FloatToFixed(x * sin(ang) - y * cos(ang)); - } - else - { - xoff -= polyobj->centerPt.x; - yoff += polyobj->centerPt.y; - } - } - - if (slope != NULL && P_ApplyLightOffset(lightlevel >> LIGHTSEGSHIFT, lighting_sector)) - { - if (reverseLight) - { - lightlevel -= slope->lightOffset * 8; - } - else - { - lightlevel += slope->lightOffset * 8; - } - } - - // This appears to fix the Nimbus Ruins sky bug. - if (picnum == skyflatnum && pfloor) - { - height = 0; // all skies map together - lightlevel = 0; - } - - if (!pfloor) - { - hash = visplane_hash(picnum, lightlevel, height); - for (check = visplanes[hash]; check; check = check->next) - { - if (polyobj != check->polyobj) - continue; - if (height == check->height && picnum == check->picnum - && lightlevel == check->lightlevel - && xoff == check->xoffs && yoff == check->yoffs - && planecolormap == check->extra_colormap - && check->viewx == viewx && check->viewy == viewy && check->viewz == viewz - && check->viewangle == viewangle - && check->plangle == plangle - && check->slope == slope - && check->noencore == noencore) - { - return check; - } - } - } - else - { - hash = MAXVISPLANES - 1; - } - - check = new_visplane(hash); - - check->height = height; - check->picnum = picnum; - check->lightlevel = lightlevel; - check->minx = vid.width; - check->maxx = -1; - check->xoffs = xoff; - check->yoffs = yoff; - check->extra_colormap = planecolormap; - check->ffloor = pfloor; - check->viewx = viewx; - check->viewy = viewy; - check->viewz = viewz; - check->viewangle = viewangle; - check->plangle = plangle; - check->polyobj = polyobj; - check->slope = slope; - check->noencore = noencore; - - memset(check->top, 0xff, sizeof (check->top)); - memset(check->bottom, 0x00, sizeof (check->bottom)); - - return check; -} - -// -// R_CheckPlane: return same visplane or alloc a new one if needed -// -visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop) -{ - INT32 intrl, intrh; - INT32 unionl, unionh; - INT32 x; - - if (start < pl->minx) - { - intrl = pl->minx; - unionl = start; - } - else - { - unionl = pl->minx; - intrl = start; - } - - if (stop > pl->maxx) - { - intrh = pl->maxx; - unionh = stop; - } - else - { - unionh = pl->maxx; - intrh = stop; - } - - // 0xff is not equal to -1 with shorts... - for (x = intrl; x <= intrh; x++) - if (pl->top[x] != 0xffff || pl->bottom[x] != 0x0000) - break; - - if (x > intrh) /* Can use existing plane; extend range */ - { - pl->minx = unionl; - pl->maxx = unionh; - } - else /* Cannot use existing plane; create a new one */ - { - visplane_t *new_pl; - if (pl->ffloor) - { - new_pl = new_visplane(MAXVISPLANES - 1); - } - else - { - unsigned hash = visplane_hash(pl->picnum, pl->lightlevel, pl->height); - new_pl = new_visplane(hash); - } - - new_pl->height = pl->height; - new_pl->picnum = pl->picnum; - new_pl->lightlevel = pl->lightlevel; - new_pl->xoffs = pl->xoffs; - new_pl->yoffs = pl->yoffs; - new_pl->extra_colormap = pl->extra_colormap; - new_pl->ffloor = pl->ffloor; - new_pl->viewx = pl->viewx; - new_pl->viewy = pl->viewy; - new_pl->viewz = pl->viewz; - new_pl->viewangle = pl->viewangle; - new_pl->plangle = pl->plangle; - new_pl->polyobj = pl->polyobj; - new_pl->slope = pl->slope; - new_pl->noencore = pl->noencore; - pl = new_pl; - pl->minx = start; - pl->maxx = stop; - memset(pl->top, 0xff, sizeof pl->top); - memset(pl->bottom, 0x00, sizeof pl->bottom); - } - return pl; -} - - -// -// R_ExpandPlane -// -// This function basically expands the visplane or I_Errors. -// The reason for this is that when creating 3D floor planes, there is no -// need to create new ones with R_CheckPlane, because 3D floor planes -// are created by subsector and there is no way a subsector can graphically -// overlap. -void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop) -{ - INT32 unionl, unionh; -// INT32 x; - - // Don't expand polyobject planes here - we do that on our own. - if (pl->polyobj) - return; - - if (start < pl->minx) - { - unionl = start; - } - else - { - unionl = pl->minx; - } - - if (stop > pl->maxx) - { - unionh = stop; - } - else - { - unionh = pl->maxx; - } -/* - for (x = start; x <= stop; x++) - if (pl->top[x] != 0xffff || pl->bottom[x] != 0x0000) - break; - - if (x <= stop) - I_Error("R_ExpandPlane: planes in same subsector overlap?!\nminx: %d, maxx: %d, start: %d, stop: %d\n", pl->minx, pl->maxx, start, stop); -*/ - pl->minx = unionl, pl->maxx = unionh; -} - -// -// R_MakeSpans -// -void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2) -{ - // Alam: from r_splats's R_RenderFloorSplat - if (t1 >= vid.height) t1 = vid.height-1; - if (b1 >= vid.height) b1 = vid.height-1; - if (t2 >= vid.height) t2 = vid.height-1; - if (b2 >= vid.height) b2 = vid.height-1; - if (x-1 >= vid.width) x = vid.width; - - while (t1 < t2 && t1 <= b1) - { - R_MapPlane(t1, spanstart[t1], x - 1); - t1++; - } - while (b1 > b2 && b1 >= t1) - { - R_MapPlane(b1, spanstart[b1], x - 1); - b1--; - } - - while (t2 < t1 && t2 <= b2) - spanstart[t2++] = x; - while (b2 > b1 && b2 >= t2) - spanstart[b2--] = x; -} - -void R_DrawPlanes(void) -{ - visplane_t *pl; - INT32 i; - - spanfunc = basespanfunc; - wallcolfunc = walldrawerfunc; - - for (i = 0; i < MAXVISPLANES; i++, pl++) - { - for (pl = visplanes[i]; pl; pl = pl->next) - { - if (pl->ffloor != NULL || pl->polyobj != NULL) - continue; - - R_DrawSinglePlane(pl); - } - } - -#ifndef NOWATER - R_UpdatePlaneRipple(); -#endif -} - -static void R_DrawSkyPlane(visplane_t *pl) -{ - INT32 x; - INT32 angle; - - if (!newview->sky) - { - skyVisible = true; - return; - } - - wallcolfunc = walldrawerfunc; - - // use correct aspect ratio scale - dc_iscale = skyscale; - // Sky is always drawn full bright, - // i.e. colormaps[0] is used. - // Because of this hack, sky is not affected - // by INVUL inverse mapping. - dc_colormap = colormaps; - - if (encoremap) - dc_colormap += COLORMAP_REMAPOFFSET; - - dc_texturemid = skytexturemid; - dc_texheight = textureheight[skytexture] >>FRACBITS; - dc_sourcelength = dc_texheight; - - for (x = pl->minx; x <= pl->maxx; x++) - { - dc_yl = pl->top[x]; - dc_yh = pl->bottom[x]; - - if (!(dc_yl <= dc_yh)) - continue; - - angle = (pl->viewangle + xtoviewangle[x])>>ANGLETOSKYSHIFT; - dc_iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x]>>ANGLETOFINESHIFT)); - dc_x = x; - dc_source = R_GetColumn(texturetranslation[skytexture], angle); - wallcolfunc(); - } -} - -// Potentially override other stuff for now cus we're mean. :< But draw a slope plane! -// I copied ZDoom's code and adapted it to SRB2... -Red -void R_CalculateSlopeVectors(pslope_t *slope, fixed_t planeviewx, fixed_t planeviewy, fixed_t planeviewz, fixed_t planexscale, fixed_t planeyscale, fixed_t planexoffset, fixed_t planeyoffset, angle_t planeviewangle, angle_t planeangle, float fudge) -{ - floatv3_t p, m, n; - float ang; - float vx, vy, vz; - float xscale = FIXED_TO_FLOAT(planexscale); - float yscale = FIXED_TO_FLOAT(planeyscale); - // compiler complains when P_GetSlopeZAt is used in FLOAT_TO_FIXED directly - // use this as a temp var to store P_GetSlopeZAt's return value each time - fixed_t temp; - - vx = FIXED_TO_FLOAT(planeviewx+planexoffset); - vy = FIXED_TO_FLOAT(planeviewy-planeyoffset); - vz = FIXED_TO_FLOAT(planeviewz); - - temp = P_GetSlopeZAt(slope, planeviewx, planeviewy); - zeroheight = FIXED_TO_FLOAT(temp); - - // p is the texture origin in view space - // Don't add in the offsets at this stage, because doing so can result in - // errors if the flat is rotated. - ang = ANG2RAD(ANGLE_270 - planeviewangle); - p.x = vx * cos(ang) - vy * sin(ang); - p.z = vx * sin(ang) + vy * cos(ang); - temp = P_GetSlopeZAt(slope, -planexoffset, planeyoffset); - p.y = FIXED_TO_FLOAT(temp) - vz; - - // m is the v direction vector in view space - ang = ANG2RAD(ANGLE_180 - (planeviewangle + planeangle)); - m.x = yscale * cos(ang); - m.z = yscale * sin(ang); - - // n is the u direction vector in view space - n.x = xscale * sin(ang); - n.z = -xscale * cos(ang); - - ang = ANG2RAD(planeangle); - temp = P_GetSlopeZAt(slope, planeviewx + FLOAT_TO_FIXED(yscale * sin(ang)), planeviewy + FLOAT_TO_FIXED(yscale * cos(ang))); - m.y = FIXED_TO_FLOAT(temp) - zeroheight; - temp = P_GetSlopeZAt(slope, planeviewx + FLOAT_TO_FIXED(xscale * cos(ang)), planeviewy - FLOAT_TO_FIXED(xscale * sin(ang))); - n.y = FIXED_TO_FLOAT(temp) - zeroheight; - - m.x /= fudge; - m.y /= fudge; - m.z /= fudge; - - n.x *= fudge; - n.y *= fudge; - n.z *= fudge; - - // Eh. I tried making this stuff fixed-point and it exploded on me. Here's a macro for the only floating-point vector function I recall using. -#define CROSS(d, v1, v2) \ -d->x = (v1.y * v2.z) - (v1.z * v2.y);\ -d->y = (v1.z * v2.x) - (v1.x * v2.z);\ -d->z = (v1.x * v2.y) - (v1.y * v2.x) - CROSS(ds_sup, p, m); - CROSS(ds_svp, p, n); - CROSS(ds_szp, m, n); -#undef CROSS - - ds_sup->z *= focallengthf; - ds_svp->z *= focallengthf; - ds_szp->z *= focallengthf; - - // Premultiply the texture vectors with the scale factors -#define SFMULT 65536.f - ds_sup->x *= (SFMULT * (1<y *= (SFMULT * (1<z *= (SFMULT * (1<x *= (SFMULT * (1<y *= (SFMULT * (1<z *= (SFMULT * (1<slope, pl->viewx, pl->viewy, pl->viewz, FRACUNIT, FRACUNIT, xoff, yoff, pl->viewangle, pl->plangle, fudge); -} - - -void R_DrawSinglePlane(visplane_t *pl) -{ - INT32 light = 0; - INT32 x; - INT32 stop, angle; - size_t size; - ffloor_t *rover; - - if (!(pl->minx <= pl->maxx)) - return; - - // sky flat - if (pl->picnum == skyflatnum) - { - R_DrawSkyPlane(pl); - return; - } - -#ifndef NOWATER - planeripple.active = false; -#endif - spanfunc = basespanfunc; - - if (pl->polyobj && pl->polyobj->translucency != 0) - { - spanfunc = R_DrawTranslucentSpan_8; - - // Hacked up support for alpha value in software mode Tails 09-24-2002 (sidenote: ported to polys 10-15-2014, there was no time travel involved -Red) - if (pl->polyobj->translucency >= 10) - return; // Don't even draw it - else if (pl->polyobj->translucency > 0) - ds_transmap = R_GetTranslucencyTable(pl->polyobj->translucency); - else // Opaque, but allow transparent flat pixels - spanfunc = splatfunc; - -#ifdef SHITPLANESPARENCY - if (spanfunc == splatfunc || (pl->extra_colormap && pl->extra_colormap->fog)) -#else - if (!pl->extra_colormap || !(pl->extra_colormap->fog & 2)) -#endif - light = (pl->lightlevel >> LIGHTSEGSHIFT); - else - light = LIGHTLEVELS-1; - - } - else - { - if (pl->ffloor) - { - // Don't draw planes that shouldn't be drawn. - for (rover = pl->ffloor->target->ffloors; rover; rover = rover->next) - { - if ((pl->ffloor->flags & FF_CUTEXTRA) && (rover->flags & FF_EXTRA)) - { - if (!(rover->flags & FF_EXTRA)) - continue; - - // The plane is from an extra 3D floor... Check the flags so - // there are no undesired cuts. - if (((pl->ffloor->flags & (FF_FOG|FF_SWIMMABLE)) == (rover->flags & (FF_FOG|FF_SWIMMABLE))) - && pl->height < *rover->topheight - && pl->height > *rover->bottomheight) - return; - } - } - - if (pl->ffloor->flags & FF_TRANSLUCENT) - { - spanfunc = R_DrawTranslucentSpan_8; - - // Hacked up support for alpha value in software mode Tails 09-24-2002 - // ...unhacked by toaster 04-01-2021, re-hacked a little by sphere 19-11-2021 - // and mercilessly shoved into saturn by chearii 02-02-2025 - { - INT32 trans = (10*((256+12) - pl->ffloor->alpha))/255; - if (trans >= 10) - return; // Don't even draw it - if (pl->ffloor->blend) // additive, (reverse) subtractive, modulative - ds_transmap = R_GetBlendTable(pl->ffloor->blend, trans); - else if (!(ds_transmap = R_GetTranslucencyTable(trans)) || trans == 0) - spanfunc = splatfunc; // Opaque, but allow transparent flat pixels - } - -#ifdef SHITPLANESPARENCY - if (spanfunc == splatfunc || (pl->extra_colormap && pl->extra_colormap->fog)) -#else - if (!pl->extra_colormap || !(pl->extra_colormap->fog & 2)) -#endif - light = (pl->lightlevel >> LIGHTSEGSHIFT); - else - light = LIGHTLEVELS-1; - } - else if (pl->ffloor->flags & FF_FOG) - { - spanfunc = R_DrawFogSpan_8; - light = (pl->lightlevel >> LIGHTSEGSHIFT); - } - else light = (pl->lightlevel >> LIGHTSEGSHIFT); - -#ifndef NOWATER - if (pl->ffloor->flags & FF_RIPPLE) - { - INT32 top, bottom; - UINT8 *scr; - - if (cv_ripplewater.value) - { - planeripple.active = true; - - if (spanfunc == R_DrawTranslucentSpan_8) - { - spanfunc = R_DrawTranslucentWaterSpan_8; - - // Copy the current scene, ugh - top = pl->high-8; - bottom = pl->low+8; - - if (top < 0) - top = 0; - if (bottom > vid.height) - bottom = vid.height; - - if (splitscreen > 2 && viewplayer == &players[displayplayers[3]]) // Only copy the part of the screen we need - scr = (screens[0] + (top+(viewheight))*vid.width + viewwidth); - else if ((splitscreen == 1 && viewplayer == &players[displayplayers[1]]) - || (splitscreen > 1 && viewplayer == &players[displayplayers[2]])) - scr = (screens[0] + (top+(viewheight))*vid.width); - else if (splitscreen > 1 && viewplayer == &players[displayplayers[1]]) - scr = (screens[0] + ((top)*vid.width) + viewwidth); - else - scr = (screens[0] + ((top)*vid.width)); - - VID_BlitLinearScreen(scr, screens[1]+((top)*vid.width), - vid.width, bottom-top, - vid.width, vid.width); - } - } - else - { - planeripple.active = false; - } - } -#endif - } - else light = (pl->lightlevel >> LIGHTSEGSHIFT); - } - - if (!pl->slope && viewangle != pl->viewangle+pl->plangle) // Don't mess with angle on slopes! We'll handle this ourselves later - { - memset(cachedheight, 0, sizeof (cachedheight)); - angle = (pl->viewangle+pl->plangle-ANGLE_90)>>ANGLETOFINESHIFT; - basexscale = FixedDiv(FINECOSINE(angle),centerxfrac); - baseyscale = -FixedDiv(FINESINE(angle),centerxfrac); - viewangle = pl->viewangle+pl->plangle; - } - - currentplane = pl; - - ds_source = (UINT8 *) - W_CacheLumpNum(levelflats[pl->picnum].lumpnum, - PU_STATIC); // Stay here until Z_ChangeTag - - size = W_LumpLength(levelflats[pl->picnum].lumpnum); - - switch (size) - { - case 4194304: // 2048x2048 lump - nflatmask = 0x3FF800; - nflatxshift = 21; - nflatyshift = 10; - nflatshiftup = 5; - break; - case 1048576: // 1024x1024 lump - nflatmask = 0xFFC00; - nflatxshift = 22; - nflatyshift = 12; - nflatshiftup = 6; - break; - case 262144:// 512x512 lump' - nflatmask = 0x3FE00; - nflatxshift = 23; - nflatyshift = 14; - nflatshiftup = 7; - break; - case 65536: // 256x256 lump - nflatmask = 0xFF00; - nflatxshift = 24; - nflatyshift = 16; - nflatshiftup = 8; - break; - case 16384: // 128x128 lump - nflatmask = 0x3F80; - nflatxshift = 25; - nflatyshift = 18; - nflatshiftup = 9; - break; - case 1024: // 32x32 lump - nflatmask = 0x3E0; - nflatxshift = 27; - nflatyshift = 22; - nflatshiftup = 11; - break; - default: // 64x64 lump - nflatmask = 0xFC0; - nflatxshift = 26; - nflatyshift = 20; - nflatshiftup = 10; - break; - } - - xoffs = pl->xoffs; - yoffs = pl->yoffs; - planeheight = abs(pl->height - pl->viewz); - - if (light >= LIGHTLEVELS) - light = LIGHTLEVELS-1; - - if (light < 0) - light = 0; - - if (pl->slope) - { - float fudgecanyon = 0; - fixed_t temp; - // Okay, look, don't ask me why this works, but without this setup there's a disgusting-looking misalignment with the textures. -fickle - fudgecanyon = ((1<plangle & (ANGLE_90-1)); - - if (hack) - { - /* - Essentially: We can't & the components along the regular axes when the plane is rotated. - This is because the distance on each regular axis in order to loop is different. - We rotate them, & the components, add them together, & them again, and then rotate them back. - These three seperate & operations are done per axis in order to prevent overflows. - toast 10/04/17 - --- - ...of coooourse, this still isn't perfect. but it looks... merely kind of grody, rather than - completely wrong? idk. i'm just backporting this to kart right now. if anyone else wants to - ever try dig around: it's drifting towards 0,0, and no, multiplying by fudge doesn't fix it. - toast 27/09/18 - */ - - const fixed_t cosinecomponent = FINECOSINE(hack>>ANGLETOFINESHIFT); - const fixed_t sinecomponent = FINESINE(hack>>ANGLETOFINESHIFT); - - const fixed_t modmask = ((1 << (32-nflatshiftup)) - 1); - - fixed_t ox = (FixedMul(pl->slope->o.x,cosinecomponent) & modmask) - (FixedMul(pl->slope->o.y,sinecomponent) & modmask); - fixed_t oy = (-FixedMul(pl->slope->o.x,sinecomponent) & modmask) - (FixedMul(pl->slope->o.y,cosinecomponent) & modmask); - - temp = ox & modmask; - oy &= modmask; - ox = FixedMul(temp,cosinecomponent)+FixedMul(oy,-sinecomponent); // negative sine for opposite direction - oy = -FixedMul(temp,-sinecomponent)+FixedMul(oy,cosinecomponent); - - temp = xoffs; - xoffs = (FixedMul(temp,cosinecomponent) & modmask) + (FixedMul(yoffs,sinecomponent) & modmask); - yoffs = (-FixedMul(temp,sinecomponent) & modmask) + (FixedMul(yoffs,cosinecomponent) & modmask); - - temp = xoffs & modmask; - yoffs &= modmask; - xoffs = FixedMul(temp,cosinecomponent)+FixedMul(yoffs,-sinecomponent); // ditto - yoffs = -FixedMul(temp,-sinecomponent)+FixedMul(yoffs,cosinecomponent); - - xoffs -= (pl->slope->o.x - ox); - yoffs += (pl->slope->o.y + oy); - } - else - { - xoffs &= ((1 << (32-nflatshiftup))-1); - yoffs &= ((1 << (32-nflatshiftup))-1); - xoffs -= (pl->slope->o.x + (1 << (31-nflatshiftup))) & ~((1 << (32-nflatshiftup))-1); - yoffs += (pl->slope->o.y + (1 << (31-nflatshiftup))) & ~((1 << (32-nflatshiftup))-1); - } - - xoffs = (fixed_t)(xoffs*fudgecanyon); - yoffs = (fixed_t)(yoffs/fudgecanyon); - -#ifndef NOWATER - if (planeripple.active) - { - fixed_t plheight = abs(P_GetSlopeZAt(pl->slope, pl->viewx, pl->viewy) - pl->viewz); - - R_PlaneBounds(pl); - - for (x = pl->high; x < pl->low; x++) - { - R_CalculatePlaneRipple(pl, x, plheight, true); - R_SetSlopePlaneVectors(pl, x, (xoffs + planeripple.xfrac), (yoffs + planeripple.yfrac), fudgecanyon); - } - } - else -#endif - R_SetSlopePlaneVectors(pl, 0, xoffs, yoffs, fudgecanyon); - -#ifndef NOWATER - if (spanfunc == R_DrawTranslucentWaterSpan_8) - spanfunc = R_DrawTiltedTranslucentWaterSpan_8; - else -#endif - if (spanfunc == R_DrawTranslucentSpan_8) - spanfunc = R_DrawTiltedTranslucentSpan_8; - else if (spanfunc == splatfunc) - spanfunc = R_DrawTiltedSplat_8; - else - spanfunc = R_DrawTiltedSpan_8; - - planezlight = scalelight[light]; - } - else - planezlight = zlight[light]; - - // set the maximum value for unsigned - pl->top[pl->maxx+1] = 0xffff; - pl->top[pl->minx-1] = 0xffff; - pl->bottom[pl->maxx+1] = 0x0000; - pl->bottom[pl->minx-1] = 0x0000; - - stop = pl->maxx + 1; - - if (viewx != pl->viewx || viewy != pl->viewy) - { - viewx = pl->viewx; - viewy = pl->viewy; - } - if (viewz != pl->viewz) - viewz = pl->viewz; - - for (x = pl->minx; x <= stop; x++) - { - R_MakeSpans(x, pl->top[x-1], pl->bottom[x-1], - pl->top[x], pl->bottom[x]); - } - -/* -QUINCUNX anti-aliasing technique (sort of) - -Normally, Quincunx antialiasing staggers pixels -in a 5-die pattern like so: - -o o - o -o o - -To simulate this, we offset the plane by -FRACUNIT/4 in each direction, and draw -at 50% translucency. The result is -a 'smoothing' of the texture while -using the palette colors. -*/ -#ifdef QUINCUNX - if (spanfunc == R_DrawSpan_8) - { - INT32 i; - ds_transmap = R_GetTranslucencyTable(tr_trans50); - spanfunc = R_DrawTranslucentSpan_8; - for (i=0; i<4; i++) - { - xoffs = pl->xoffs; - yoffs = pl->yoffs; - - switch(i) - { - case 0: - xoffs -= FRACUNIT/4; - yoffs -= FRACUNIT/4; - break; - case 1: - xoffs -= FRACUNIT/4; - yoffs += FRACUNIT/4; - break; - case 2: - xoffs += FRACUNIT/4; - yoffs -= FRACUNIT/4; - break; - case 3: - xoffs += FRACUNIT/4; - yoffs += FRACUNIT/4; - break; - } - planeheight = abs(pl->height - pl->viewz); - - if (light >= LIGHTLEVELS) - light = LIGHTLEVELS-1; - - if (light < 0) - light = 0; - - planezlight = zlight[light]; - - // set the maximum value for unsigned - pl->top[pl->maxx+1] = 0xffff; - pl->top[pl->minx-1] = 0xffff; - pl->bottom[pl->maxx+1] = 0x0000; - pl->bottom[pl->minx-1] = 0x0000; - - stop = pl->maxx + 1; - - for (x = pl->minx; x <= stop; x++) - R_MakeSpans(x, pl->top[x-1], pl->bottom[x-1], - pl->top[x], pl->bottom[x]); - } - } -#endif - - Z_ChangeTag(ds_source, PU_CACHE); -} - -void R_PlaneBounds(visplane_t *plane) -{ - INT32 i; - INT32 hi, low; - - hi = plane->top[plane->minx]; - low = plane->bottom[plane->minx]; - - for (i = plane->minx + 1; i <= plane->maxx; i++) - { - if (plane->top[i] < hi) - hi = plane->top[i]; - if (plane->bottom[i] > low) - low = plane->bottom[i]; - } - plane->high = hi; - plane->low = low; -} diff --git a/src/r_plane.cpp b/src/r_plane.cpp new file mode 100644 index 000000000..499e302ac --- /dev/null +++ b/src/r_plane.cpp @@ -0,0 +1,1410 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 1993-1996 by id Software, Inc. +// Copyright (C) 1998-2000 by DooM Legacy Team. +// Copyright (C) 1999-2018 by Sonic Team Junior. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file r_plane.c +/// \brief Here is a core component: drawing the floors and ceilings, +/// while maintaining a per column clipping list only. +/// Moreover, the sky areas have to be determined. + +#include + +#include "doomdef.h" +#include "console.h" +#include "g_game.h" +#include "p_setup.h" // levelflats +#include "p_slopes.h" +#include "r_data.h" +#include "r_local.h" +#include "r_state.h" +#include "r_splats.h" // faB(21jan):testing +#include "r_sky.h" +#include "v_video.h" +#include "w_wad.h" +#include "z_zone.h" +#include "p_tick.h" +#include "r_fps.h" +#include "r_portal.h" + +#ifdef HAVE_THREADS +#include "core/thread_pool.h" +#endif + +// +// opening +// + +// Quincunx antialiasing of flats! +//#define QUINCUNX + +// good night sweet prince +//#define SHITPLANESPARENCY + +visplane_t *visplanes[MAXVISPLANES]; +static visplane_t *freetail; +static visplane_t **freehead = &freetail; + +visplane_t *floorplane; +visplane_t *ceilingplane; + +visffloor_t ffloor[MAXFFLOORS]; +INT32 numffloors; + +//SoM: 3/23/2000: Boom visplane hashing routine. +#define visplane_hash(picnum,lightlevel,height) \ + ((unsigned)((picnum)*3+(lightlevel)+(height)*7) & VISPLANEHASHMASK) + +//SoM: 3/23/2000: Use boom opening limit removal +size_t maxopenings; +INT16 *openings, *lastopening; /// \todo free leak + +// +// Clip values are the solid pixel bounding the range. +// floorclip starts out SCREENHEIGHT +// ceilingclip starts out -1 +// +INT16 *floorclip, *ceilingclip; +fixed_t *frontscale; + +// +// spanstart holds the start of a plane span +// initialized to 0 at start +// +static INT32 *spanstart; + +//added : 10-02-98: yslopetab is what yslope used to be, +// yslope points somewhere into yslopetab, +// now (viewheight/2) slopes are calculated above and +// below the original viewheight for mouselook +// (this is to calculate yslopes only when really needed) +// (when mouselookin', yslope is moving into yslopetab) +// Check R_SetupFrame, R_SetViewSize for more... +fixed_t *yslopetab; +fixed_t *yslope; + +fixed_t basexscale, baseyscale; + +static INT16 *ffloor_f_clip; +static INT16 *ffloor_c_clip; + +static void R_SetTiltedSpan(drawspandata_t* ds, INT32 span); +static void R_SetSlopePlaneVectors(drawspandata_t* ds, visplane_t *pl, INT32 y, fixed_t xoff, fixed_t yoff); + +static void R_ReallocPlaneBounds(visplane_t *pl) +{ + pl->top_memory = static_cast(Z_Realloc(pl->top_memory, sizeof(UINT16) * (viewwidth + 2), PU_STATIC, NULL)); + pl->bottom_memory = static_cast(Z_Realloc(pl->bottom_memory, sizeof(UINT16) * (viewwidth + 2), PU_STATIC, NULL)); + pl->top = pl->top_memory + 1; + pl->bottom = pl->bottom_memory + 1; +} + +void R_AllocPlaneMemory(void) +{ + visplane_t *check; + + // Alloc visplane top/bottom bounds + for (unsigned i = 0; i < MAXVISPLANES; i++) + { + check = visplanes[i]; + + while (check) + { + R_ReallocPlaneBounds(check); + check = check->next; + } + } + + // Need to do it for "freed" visplanes too + check = freetail; + while (check) + { + R_ReallocPlaneBounds(check); + check = check->next; + } + + // Alloc ffloor clip tables + ffloor_f_clip = static_cast(Z_Realloc(ffloor_f_clip, sizeof(*ffloor_f_clip) * (viewwidth * MAXFFLOORS), PU_STATIC, NULL)); + ffloor_c_clip = static_cast(Z_Realloc(ffloor_c_clip, sizeof(*ffloor_c_clip) * (viewwidth * MAXFFLOORS), PU_STATIC, NULL)); + + for (unsigned i = 0; i < MAXFFLOORS; i++) + { + ffloor[i].f_clip = ffloor_f_clip + (i * viewwidth); + ffloor[i].c_clip = ffloor_c_clip + (i * viewwidth); + } + + yslopetab = static_cast(Z_Realloc(yslopetab, sizeof(*yslopetab) * (viewheight * 16), PU_STATIC, NULL)); + spanstart = static_cast(Z_Realloc(spanstart, sizeof(*spanstart) * viewheight, PU_STATIC, NULL)); +} + +// +// Water ripple effect!! +// Needs the height of the plane, and the vertical position of the span. +// Sets planeripple.xfrac and planeripple.yfrac, added to ds_xfrac and ds_yfrac, if the span is not tilted. +// +static fixed_t R_CalculateRippleOffset(drawspandata_t* ds, INT32 y) +{ + const fixed_t distance = FixedMul(ds->planeheight, yslope[y]); + const INT32 yay = (ds->planeripple.offset + (distance>>9)) & 8191; + return FixedDiv(FINESINE(yay), (1<<12) + (distance>>11)); +} + +static void R_CalculatePlaneRipple(drawspandata_t* ds, angle_t angle) +{ + angle >>= ANGLETOFINESHIFT; + angle = (angle + 2048) & 8191; // 90 degrees + ds->planeripple.xfrac = FixedMul(FINECOSINE(angle), ds->bgofs); + ds->planeripple.yfrac = FixedMul(FINESINE(angle), ds->bgofs); +} + +static void R_UpdatePlaneRipple(drawspandata_t* ds) +{ + ds->waterofs = (leveltime & 1)*16384; + ds->planeripple.offset = ((leveltime-1)*140) + ((rendertimefrac*140) / FRACUNIT); +} + +static bool R_CheckMapPlane(const char* funcname, INT32 y, INT32 x1, INT32 x2) +{ + if (x1 == x2) + return true; + + if (x1 < x2 && x1 >= 0 && x2 < viewwidth && y >= 0 && y < viewheight) + return true; + + CONS_Debug(DBG_RENDER, "%s: x1=%d, x2=%d at y=%d\n", funcname, x1, x2, y); + return false; +} + +// +// R_MapPlane +// +// Uses global vars: +// basexscale +// baseyscale +// centerx +// viewx +// viewy +// viewsin +// viewcos +// viewheight +static void R_MapPlane(drawspandata_t *ds, spandrawfunc_t *localspanfunc, INT32 y, INT32 x1, INT32 x2, boolean allow_parallel) +{ + angle_t angle, planecos, planesin; + fixed_t distance = 0, span; + size_t pindex; + + (void)allow_parallel; + + if (!R_CheckMapPlane(__func__, y, x1, x2)) + return; + + angle = (ds->currentplane->viewangle + ds->currentplane->plangle)>>ANGLETOFINESHIFT; + planecos = FINECOSINE(angle); + planesin = FINESINE(angle); + + // [RH] Notice that I dumped the caching scheme used by Doom. + // It did not offer any appreciable speedup. + distance = FixedMul(ds->planeheight, yslope[y]); + span = abs(centery - y); + + if (span) // don't divide by zero + { + ds->xstep = FixedMul(planesin, ds->planeheight) / span; + ds->ystep = FixedMul(planecos, ds->planeheight) / span; + } + else + { + ds->xstep = FixedMul(distance, basexscale); + ds->ystep = FixedMul(distance, baseyscale); + } + + // [RH] Instead of using the xtoviewangle array, I calculated the fractional values + // at the middle of the screen, then used the calculated ds_xstep and ds_ystep + // to step from those to the proper texture coordinate to start drawing at. + // That way, the texture coordinate is always calculated by its position + // on the screen and not by its position relative to the edge of the visplane. + ds->xfrac = ds->xoffs + FixedMul(planecos, distance) + (x1 - centerx) * ds->xstep; + ds->yfrac = ds->yoffs - FixedMul(planesin, distance) + (x1 - centerx) * ds->ystep; + + if (ds->planeripple.active) + { + ds->bgofs = R_CalculateRippleOffset(ds, y); + + R_CalculatePlaneRipple(ds, ds->currentplane->viewangle + ds->currentplane->plangle); + + ds->xfrac += ds->planeripple.xfrac; + ds->yfrac += ds->planeripple.yfrac; + ds->bgofs >>= FRACBITS; + + if ((y + ds->bgofs) >= viewheight) + ds->bgofs = viewheight-y-1; + if ((y + ds->bgofs) < 0) + ds->bgofs = -y; + } + + pindex = std::min(distance >> LIGHTZSHIFT, MAXLIGHTZ - 1); + + ds->colormap = ds->planezlight[pindex]; + + if (encoremap && !ds->currentplane->noencore) + ds->colormap += COLORMAP_REMAPOFFSET; + + if (ds->currentplane->extra_colormap) + ds->colormap = ds->currentplane->extra_colormap->colormap + (ds->colormap - colormaps); + + ds->y = y; + ds->x1 = x1; + ds->x2 = x2; + + localspanfunc(ds); +} + +static void R_MapTiltedPlane(drawspandata_t *ds, spandrawfunc_t *localspanfunc, INT32 y, INT32 x1, INT32 x2, boolean allow_parallel) +{ + (void)allow_parallel; + + if (!R_CheckMapPlane(__func__, y, x1, x2)) + return; + + // Water ripple effect + if (ds->planeripple.active) + { + ds->bgofs = R_CalculateRippleOffset(ds, y); + + R_SetTiltedSpan(ds, std::clamp(y, 0, viewheight)); + + R_CalculatePlaneRipple(ds, ds->currentplane->viewangle + ds->currentplane->plangle); + R_SetSlopePlaneVectors(ds, ds->currentplane, y, (ds->xoffs + ds->planeripple.xfrac), (ds->yoffs + ds->planeripple.yfrac)); + + ds->bgofs >>= FRACBITS; + + if ((y + ds->bgofs) >= viewheight) + ds->bgofs = viewheight-y-1; + if ((y + ds->bgofs) < 0) + ds->bgofs = -y; + } + + if (ds->currentplane->extra_colormap) + ds->colormap = ds->currentplane->extra_colormap->colormap; + else + ds->colormap = colormaps; + + if (encoremap && !ds->currentplane->noencore) + { + ds->colormap += COLORMAP_REMAPOFFSET; + } + + ds->y = y; + ds->x1 = x1; + ds->x2 = x2; + + localspanfunc(ds); +} + +void R_ClearFFloorClips(void) +{ + INT32 p; + + // opening / clipping determination + for (p = 0; p < MAXFFLOORS; p++) + { + visffloor_t *fffloor = &ffloor[p]; + std::fill(fffloor->f_clip, fffloor->f_clip + viewwidth, static_cast(viewheight)); + std::fill(fffloor->c_clip, fffloor->c_clip + viewwidth, static_cast(-1)); + } + + numffloors = 0; +} + +// +// R_ClearPlanes +// At begining of frame. +// +void R_ClearPlanes(void) +{ + INT32 i; + angle_t angle; + + // opening / clipping determination + std::fill(floorclip, floorclip + viewwidth, static_cast(viewheight)); + std::fill(ceilingclip, ceilingclip + viewwidth, static_cast(-1)); + std::fill(frontscale, frontscale + viewwidth, INT32_MAX); + + R_ClearFFloorClips(); + + for (i = 0; i < MAXVISPLANES; i++) + for (*freehead = visplanes[i], visplanes[i] = NULL; + freehead && *freehead ;) + { + freehead = &(*freehead)->next; + } + + lastopening = openings; + + // left to right mapping + angle = (viewangle-ANGLE_90)>>ANGLETOFINESHIFT; + + // scale will be unit scale at SCREENWIDTH/2 distance + basexscale = FixedDiv (FINECOSINE(angle), centerxfrac); + baseyscale = -FixedDiv (FINESINE(angle), centerxfrac); +} + +static visplane_t *new_visplane(unsigned hash) +{ + visplane_t *check = freetail; + + if (!check) + { + check = static_cast(calloc(1, sizeof (*check))); + if (check == NULL) + I_Error("new_visplane: Out of memory"); + check->top_memory = static_cast(Z_Malloc(sizeof(UINT16) * (viewwidth + 2), PU_STATIC, NULL)); + check->bottom_memory = static_cast(Z_Malloc(sizeof(UINT16) * (viewwidth + 2), PU_STATIC, NULL)); + check->top = check->top_memory + 1; + check->bottom = check->bottom_memory + 1; + } + else + { + freetail = freetail->next; + if (!freetail) + freehead = &freetail; + } + + check->next = visplanes[hash]; + visplanes[hash] = check; + + return check; +} + +// +// R_FindPlane: Seek a visplane having the identical values: +// Same height, same flattexture, same lightlevel. +// If not, allocates another of them. +// +visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, + fixed_t xoff, fixed_t yoff, angle_t plangle, extracolormap_t *planecolormap + , ffloor_t *pfloor + , polyobj_t *polyobj + , pslope_t *slope + , boolean noencore + , boolean reverseLight, const sector_t *lighting_sector) +{ + visplane_t *check; + unsigned hash; + + if (!slope) // Don't mess with this right now if a slope is involved + { + if (plangle != 0) + { + // Must use 64-bit math to avoid an overflow! + INT64 vx = xoff + viewx; + INT64 vy = yoff - viewy; + + // Add the view offset, rotated by the plane angle. + float ang = ANG2RAD(plangle); + float x = vx / (float)FRACUNIT; + float y = vy / (float)FRACUNIT; + + vx = (x * cos(ang) + y * sin(ang)) * FRACUNIT; + vy = (-x * sin(ang) + y * cos(ang)) * FRACUNIT; + + xoff = vx; + yoff = vy; + } + else + { + xoff += viewx; + yoff -= viewy; + } + } + + if (polyobj) + { + if (polyobj->angle != 0) + { + float ang = ANG2RAD(polyobj->angle); + float x = FixedToFloat(polyobj->centerPt.x); + float y = FixedToFloat(polyobj->centerPt.y); + xoff -= FloatToFixed(x * cos(ang) + y * sin(ang)); + yoff -= FloatToFixed(x * sin(ang) - y * cos(ang)); + } + else + { + xoff -= polyobj->centerPt.x; + yoff += polyobj->centerPt.y; + } + } + + if (!pfloor) + { + if (slope != NULL && P_ApplyLightOffset(lightlevel >> LIGHTSEGSHIFT, lighting_sector)) + { + if (reverseLight) + { + lightlevel -= slope->lightOffset * 8; + } + else + { + lightlevel += slope->lightOffset * 8; + } + } + + hash = visplane_hash(picnum, lightlevel, height); + + for (check = visplanes[hash]; check; check = check->next) + { + if (polyobj != check->polyobj) + continue; + + if (height == check->height && picnum == check->picnum + && lightlevel == check->lightlevel + && xoff == check->xoffs && yoff == check->yoffs + && planecolormap == check->extra_colormap + && check->viewx == viewx && check->viewy == viewy && check->viewz == viewz + && check->viewangle == viewangle + && check->plangle == plangle + && check->slope == slope + && check->noencore == noencore) + { + return check; + } + } + } + else + { + // This appears to fix the Nimbus Ruins sky bug. + if (picnum == skyflatnum) + { + height = 0; // all skies map together + lightlevel = 0; + } + + hash = MAXVISPLANES - 1; + } + + check = new_visplane(hash); + + check->height = height; + check->picnum = picnum; + check->lightlevel = lightlevel; + check->minx = vid.width; + check->maxx = -1; + check->xoffs = xoff; + check->yoffs = yoff; + check->extra_colormap = planecolormap; + check->ffloor = pfloor; + check->viewx = viewx; + check->viewy = viewy; + check->viewz = viewz; + check->viewangle = viewangle; + check->plangle = plangle; + check->polyobj = polyobj; + check->slope = slope; + check->noencore = noencore; + check->cyan = levelflats[picnum].cyan; + + memset(check->top, 0xff, sizeof(*check->top) * viewwidth); + memset(check->bottom, 0x00, sizeof(*check->bottom) * viewwidth); + + return check; +} + +// +// R_CheckPlane: return same visplane or alloc a new one if needed +// +visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop) +{ + INT32 intrl, intrh; + INT32 unionl, unionh; + INT32 x; + + if (start < pl->minx) + { + intrl = pl->minx; + unionl = start; + } + else + { + unionl = pl->minx; + intrl = start; + } + + if (stop > pl->maxx) + { + intrh = pl->maxx; + unionh = stop; + } + else + { + unionh = pl->maxx; + intrh = stop; + } + + // 0xff is not equal to -1 with shorts... + for (x = intrl; x <= intrh; x++) + if (pl->top[x] != 0xffff || pl->bottom[x] != 0x0000) + break; + + if (x > intrh) /* Can use existing plane; extend range */ + { + pl->minx = unionl; + pl->maxx = unionh; + } + else /* Cannot use existing plane; create a new one */ + { + visplane_t *new_pl; + + if (pl->ffloor) + { + new_pl = new_visplane(MAXVISPLANES - 1); + } + else + { + unsigned hash = visplane_hash(pl->picnum, pl->lightlevel, pl->height); + new_pl = new_visplane(hash); + } + + new_pl->height = pl->height; + new_pl->picnum = pl->picnum; + new_pl->lightlevel = pl->lightlevel; + new_pl->xoffs = pl->xoffs; + new_pl->yoffs = pl->yoffs; + new_pl->extra_colormap = pl->extra_colormap; + new_pl->ffloor = pl->ffloor; + new_pl->viewx = pl->viewx; + new_pl->viewy = pl->viewy; + new_pl->viewz = pl->viewz; + new_pl->viewangle = pl->viewangle; + new_pl->plangle = pl->plangle; + new_pl->polyobj = pl->polyobj; + new_pl->slope = pl->slope; + new_pl->noencore = pl->noencore; + new_pl->cyan = pl->cyan; + pl = new_pl; + pl->minx = start; + pl->maxx = stop; + memset(pl->top, 0xff, sizeof(*pl->top) * viewwidth); + memset(pl->bottom, 0x00, sizeof(*pl->bottom) * viewwidth); + } + + return pl; +} + + +// +// R_ExpandPlane +// +// This function basically expands the visplane. +// The reason for this is that when creating 3D floor planes, there is no +// need to create new ones with R_CheckPlane, because 3D floor planes +// are created by subsector and there is no way a subsector can graphically +// overlap. +void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop) +{ + // Don't expand polyobject planes here - we do that on our own. + if (pl->polyobj) + return; + + if (pl->minx > start) pl->minx = start; + if (pl->maxx < stop) pl->maxx = stop; +} + +// +// R_MakeSpans +// +static void R_MakeSpans(void (*mapfunc)(drawspandata_t* ds, void(*spanfunc)(drawspandata_t*), INT32, INT32, INT32, boolean), spandrawfunc_t* localspanfunc, drawspandata_t* ds, INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2, boolean allow_parallel) +{ + const INT32 vidheight = vid.height; + + // Alam: from r_splats's R_RenderFloorSplat + if (t1 >= vidheight) t1 = vidheight-1; + if (b1 >= vidheight) b1 = vidheight-1; + if (t2 >= vidheight) t2 = vidheight-1; + if (b2 >= vidheight) b2 = vidheight-1; + if (x-1 >= vid.width) x = vid.width; + +#ifdef HAVE_THREADS + // We want to draw N spans per subtask to ensure the work is + // coarse enough to not be too slow due to task scheduling overhead. + // To safely do this, we need to copy part of spanstart to a local. + // This is essentially loop unrolling across threads. + constexpr const int kSpanTaskGranularity = 8; + drawspandata_t ds_copy = *ds; + while (t1 < t2 && t1 <= b1) + { + INT32 spanstartcopy[kSpanTaskGranularity] = {0}; + INT32 taskspans = 0; + for (int i = 0; i < kSpanTaskGranularity; i++) + { + if (!((t1 + i) < t2 && (t1 + i) <= b1)) + { + break; + } + spanstartcopy[i] = spanstart[t1 + i]; + taskspans += 1; + } + auto task = [=]() mutable -> void { + for (int i = 0; i < taskspans; i++) + { + mapfunc(&ds_copy, localspanfunc, t1 + i, spanstartcopy[i], x - 1, false); + } + }; + if (allow_parallel) + { + srb2::g_main_threadpool->schedule(std::move(task)); + } + else + { + (task)(); + } + t1 += taskspans; + } + while (b1 > b2 && b1 >= t1) + { + INT32 spanstartcopy[kSpanTaskGranularity] = {0}; + INT32 taskspans = 0; + for (int i = 0; i < kSpanTaskGranularity; i++) + { + if (!((b1 - i) > b2 && (b1 - i) >= t1)) + { + break; + } + spanstartcopy[i] = spanstart[b1 - i]; + taskspans += 1; + } + auto task = [=]() mutable -> void { + for (int i = 0; i < taskspans; i++) + { + mapfunc(&ds_copy, localspanfunc, b1 - i, spanstartcopy[i], x - 1, false); + } + }; + if (allow_parallel) + { + srb2::g_main_threadpool->schedule(std::move(task)); + } + else + { + (task)(); + } + b1 -= taskspans; + } +#else + (void)allow_parallel; + + while (t1 < t2 && t1 <= b1) + { + mapfunc(ds, localspanfunc, t1, spanstart[t1], x - 1, false); + t1++; + } + while (b1 > b2 && b1 >= t1) + { + mapfunc(ds, localspanfunc, b1, spanstart[b1], x - 1, false); + b1--; + } +#endif + + while (t2 < t1 && t2 <= b2) + spanstart[t2++] = x; + while (b2 > b1 && b2 >= t2) + spanstart[b2--] = x; +} + +void R_DrawPlanes(void) +{ + visplane_t *pl; + INT32 i; + drawspandata_t ds = {}; +#ifdef HAVE_THREADS + srb2::ThreadPool::Sema tp_sema; +#endif + + R_UpdatePlaneRipple(&ds); + +#ifdef HAVE_THREADS + srb2::g_main_threadpool->begin_sema(); +#endif + for (i = 0; i < MAXVISPLANES; i++, pl++) + { + for (pl = visplanes[i]; pl; pl = pl->next) + { + if (pl->ffloor != NULL || pl->polyobj != NULL) + continue; + + R_DrawSinglePlane(&ds, pl, cv_parallelsoftware.value); + } + } +#ifdef HAVE_THREADS + tp_sema = srb2::g_main_threadpool->end_sema(); + srb2::g_main_threadpool->notify_sema(tp_sema); + srb2::g_main_threadpool->wait_sema(tp_sema); +#endif +} + +static void R_DrawSkyPlane(visplane_t *pl, void(*colfunc2)(drawcolumndata_t*), boolean allow_parallel); + +void R_DrawSkyPlanes(void) +{ + visplane_t *pl; + INT32 i; + +#ifdef HAVE_THREADS + srb2::ThreadPool::Sema tp_sema; + srb2::g_main_threadpool->begin_sema(); +#endif + for (i = 0; i < MAXVISPLANES; i++, pl++) + { + for (pl = visplanes[i]; pl; pl = pl->next) + { + if (pl->picnum != skyflatnum || pl->ffloor || pl->polyobj) + continue; + + R_DrawSkyPlane(pl, colfunc, cv_parallelsoftware.value); + } + } +#ifdef HAVE_THREADS + tp_sema = srb2::g_main_threadpool->end_sema(); + srb2::g_main_threadpool->notify_sema(tp_sema); + srb2::g_main_threadpool->wait_sema(tp_sema); +#endif +} + +static void R_DrawSkyPlane(visplane_t *pl, void(*colfunc2)(drawcolumndata_t*), boolean allow_parallel) +{ + INT32 x; + + if (!(pl->minx <= pl->maxx)) + return; + + // If we're not supposed to draw the sky (e.g. for skyboxes), don't do anything! + // This probably utterly ruins sky rendering for FOFs and polyobjects, unfortunately + if (!newview->sky) + { + return; + } + + drawcolumndata_t dc = {}; + + // Reset column drawer function (note: couldn't we just call walldrawerfunc directly?) + // (that is, unless we'll need to switch drawers in future for some reason) + R_SetColumnFunc(BASEDRAWFUNC); + + // use correct aspect ratio scale + dc.iscale = skyscale; + + // Sky is always drawn full bright, + // i.e. colormaps[0] is used. + // Because of this hack, sky is not affected + // by INVUL inverse mapping. + dc.colormap = colormaps; + + if (encoremap) + dc.colormap += COLORMAP_REMAPOFFSET; + + dc.texturemid = skytexturemid; + dc.texheight = textureheight[skytexture] >>FRACBITS; + dc.sourcelength = dc.texheight; + + x = pl->minx; + + // Precache the texture so we don't corrupt the zoned heap off-main thread + if (!texturecache[texturetranslation[skytexture]]) + { + R_GenerateTexture(texturetranslation[skytexture]); + } + +#ifdef HAVE_THREADS + while (x <= pl->maxx) + { + // Tune concurrency granularity here to maximize throughput + // The cheaper colfunc is, the more coarse the task should be + constexpr const int kSkyPlaneMacroColumns = 8; + + auto thunk = [=]() mutable -> void { + for (int i = 0; i < kSkyPlaneMacroColumns && i + x <= pl->maxx; i++) + { + dc.yl = pl->top[x + i]; + dc.yh = pl->bottom[x + i]; + + if (dc.yl > dc.yh) + { + continue; + } + + INT32 angle = (pl->viewangle + xtoviewangle[x + i])>>ANGLETOSKYSHIFT; + angle -= (skytextureoffset >> FRACBITS); + + dc.iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x + i]>>ANGLETOFINESHIFT)); + dc.x = x + i; + dc.source = + R_GetColumn(texturetranslation[skytexture], + -angle); // get negative of angle for each column to display sky correct way round! --Monster Iestyn 27/01/18 + + colfunc2(&dc); + } + }; + + if (allow_parallel) + { + srb2::g_main_threadpool->schedule(std::move(thunk)); + } + else + { + (thunk)(); + } + + x += kSkyPlaneMacroColumns; + } +#else + (void)allow_parallel; + + for (x = pl->minx; x <= pl->maxx; x++) + { + dc.yl = pl->top[x]; + dc.yh = pl->bottom[x]; + + if (dc.yl > dc.yh) + { + continue; + } + + INT32 angle = (pl->viewangle + xtoviewangle[x])>>ANGLETOSKYSHIFT; + angle -= (skytextureoffset >> FRACBITS); + + dc.iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x]>>ANGLETOFINESHIFT)); + dc.x = x; + dc.source = + R_GetColumn(texturetranslation[skytexture], + -angle); // get negative of angle for each column to display sky correct way round! --Monster Iestyn 27/01/18 + + colfunc2(&dc); + } +#endif +} + +// Returns the height of the sloped plane at (x, y) as a 32.16 fixed_t +static INT64 R_GetSlopeZAt(const pslope_t *slope, fixed_t x, fixed_t y) +{ + INT64 x64 = ((INT64)x - (INT64)slope->o.x); + INT64 y64 = ((INT64)y - (INT64)slope->o.y); + + x64 = (x64 * (INT64)slope->d.x) / FRACUNIT; + y64 = (y64 * (INT64)slope->d.y) / FRACUNIT; + + return (INT64)slope->o.z + ((x64 + y64) * (INT64)slope->zdelta) / FRACUNIT; +} + +// Sets the texture origin vector of the sloped plane. +static void R_SetSlopePlaneOrigin(drawspandata_t *ds, pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xoff, fixed_t yoff, fixed_t angle) +{ + floatv3_t *p = &ds->slope_origin; + + INT64 vx = (INT64)xpos + (INT64)xoff; + INT64 vy = (INT64)ypos - (INT64)yoff; + + float vxf = vx / (float)FRACUNIT; + float vyf = vy / (float)FRACUNIT; + float ang = ANG2RAD(ANGLE_270 - angle); + + // p is the texture origin in view space + // Don't add in the offsets at this stage, because doing so can result in + // errors if the flat is rotated. + p->x = vxf * cos(ang) - vyf * sin(ang); + p->z = vxf * sin(ang) + vyf * cos(ang); + p->y = (R_GetSlopeZAt(slope, -xoff, yoff) - zpos) / (float)FRACUNIT; +} + +// This function calculates all of the vectors necessary for drawing a sloped plane. +static void R_SetSlopePlane(drawspandata_t* ds, pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xoff, fixed_t yoff, angle_t angle, angle_t plangle) +{ + // Potentially override other stuff for now cus we're mean. :< But draw a slope plane! + // I copied ZDoom's code and adapted it to SRB2... -Red + floatv3_t *m = &ds->slope_v, *n = &ds->slope_u; + fixed_t height, temp; + float ang; + + R_SetSlopePlaneOrigin(ds, slope, xpos, ypos, zpos, xoff, yoff, angle); + height = P_GetSlopeZAt(slope, xpos, ypos); + ds->zeroheight = FixedToFloat(height - zpos); + + // m is the v direction vector in view space + ang = ANG2RAD(ANGLE_180 - (angle + plangle)); + m->x = cos(ang); + m->z = sin(ang); + + // n is the u direction vector in view space + n->x = sin(ang); + n->z = -cos(ang); + + plangle >>= ANGLETOFINESHIFT; + temp = P_GetSlopeZAt(slope, xpos + FINESINE(plangle), ypos + FINECOSINE(plangle)); + m->y = FixedToFloat(temp - height); + temp = P_GetSlopeZAt(slope, xpos + FINECOSINE(plangle), ypos - FINESINE(plangle)); + n->y = FixedToFloat(temp - height); +} + +static void R_CalculateSlopeVectors(drawspandata_t* ds) +{ + float sfmult = 65536.f; + + // Eh. I tried making this stuff fixed-point and it exploded on me. Here's a macro for the only floating-point vector function I recall using. +#define CROSS(d, v1, v2) \ +d.x = (v1.y * v2.z) - (v1.z * v2.y);\ +d.y = (v1.z * v2.x) - (v1.x * v2.z);\ +d.z = (v1.x * v2.y) - (v1.y * v2.x) + CROSS(ds->sup, ds->slope_origin, ds->slope_v); + CROSS(ds->svp, ds->slope_origin, ds->slope_u); + CROSS(ds->szp, ds->slope_v, ds->slope_u); +#undef CROSS + + ds->sup.z *= focallengthf; + ds->svp.z *= focallengthf; + ds->szp.z *= focallengthf; + + // Premultiply the texture vectors with the scale factors + sfmult *= (1 << ds->nflatshiftup); + + ds->sup.x *= sfmult; + ds->sup.y *= sfmult; + ds->sup.z *= sfmult; + ds->svp.x *= sfmult; + ds->svp.y *= sfmult; + ds->svp.z *= sfmult; +} + +void R_SetTiltedSpan(drawspandata_t* ds, INT32 span) +{ + if (ds_su == NULL) + ds_su = static_cast(Z_Calloc(sizeof(*ds_su) * vid.height, PU_STATIC, NULL)); + if (ds_sv == NULL) + ds_sv = static_cast(Z_Calloc(sizeof(*ds_sv) * vid.height, PU_STATIC, NULL)); + if (ds_sz == NULL) + ds_sz = static_cast(Z_Calloc(sizeof(*ds_sz) * vid.height, PU_STATIC, NULL)); + + ds->sup = ds_su[span]; + ds->svp = ds_sv[span]; + ds->szp = ds_sz[span]; +} + +static void R_SetSlopePlaneVectors(drawspandata_t* ds, visplane_t *pl, INT32 y, fixed_t xoff, fixed_t yoff) +{ + R_SetTiltedSpan(ds, y); + R_SetSlopePlane(ds, pl->slope, pl->viewx, pl->viewy, pl->viewz, xoff, yoff, pl->viewangle, pl->plangle); + R_CalculateSlopeVectors(ds); +} + +static inline void R_AdjustSlopeCoordinates(drawspandata_t* ds, vector3_t *origin) +{ + const fixed_t modmask = ((1 << (32-ds->nflatshiftup)) - 1); + + const fixed_t ox = (origin->x & modmask); + const fixed_t oy = -(origin->y & modmask); + + ds->xoffs &= modmask; + ds->yoffs &= modmask; + + ds->xoffs -= (origin->x - ox); + ds->yoffs += (origin->y + oy); +} + +void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_parallel) +{ + INT32 light = 0; + INT32 x; + INT32 stop; + size_t size; + INT32 spanfunctype = BASEDRAWFUNC; + ffloor_t *rover; + levelflat_t *levelflat; + void (*mapfunc)(drawspandata_t*, void(*)(drawspandata_t*), INT32, INT32, INT32, boolean) = R_MapPlane; + + if (pl->minx > pl->maxx) + return; + + // sky flat + if (pl->picnum == skyflatnum) + { + // horrific + if (!newview->sky) + { + skyVisible = true; + } + + return; + } + + R_UpdatePlaneRipple(ds); + + ds->planeripple.active = false; + R_SetSpanFunc(BASEDRAWFUNC); + + if (pl->polyobj && pl->polyobj->translucency != 0) + { + spanfunctype = SPANDRAWFUNC_TRANS; + + // Hacked up support for alpha value in software mode Tails 09-24-2002 (sidenote: ported to polys 10-15-2014, there was no time travel involved -Red) + if (pl->polyobj->translucency >= NUMTRANSMAPS) + return; // Don't even draw it + else if (pl->polyobj->translucency > 0) + ds->transmap = R_GetTranslucencyTable(pl->polyobj->translucency); + else // Opaque, but allow transparent flat pixels + spanfunctype = SPANDRAWFUNC_SPLAT; + +#ifdef SHITPLANESPARENCY + if (spanfunc == spanfuncs[SPANDRAWFUNC_SPLAT] || (pl->extra_colormap && pl->extra_colormap->fog)) +#else + if (!pl->extra_colormap || !(pl->extra_colormap->fog & 2)) +#endif + light = (pl->lightlevel >> LIGHTSEGSHIFT); + else + light = LIGHTLEVELS-1; + } + else + { + if (pl->ffloor) + { + // Don't draw planes that shouldn't be drawn. + for (rover = pl->ffloor->target->ffloors; rover; rover = rover->next) + { + if ((pl->ffloor->flags & FF_CUTEXTRA) && (rover->flags & FF_EXTRA)) + { + if (!(rover->flags & FF_EXTRA)) + continue; + + // The plane is from an extra 3D floor... Check the flags so + // there are no undesired cuts. + if (((pl->ffloor->flags & (FF_FOG|FF_SWIMMABLE)) == (rover->flags & (FF_FOG|FF_SWIMMABLE))) + && pl->height < *rover->topheight + && pl->height > *rover->bottomheight) + return; + } + } + + if (cv_softcyancut.value && pl->cyan && !(pl->ffloor->flags & FF_RIPPLE)) + spanfunctype = SPANDRAWFUNC_SPLAT; + + if (pl->ffloor->flags & FF_TRANSLUCENT) + { + spanfunctype = SPANDRAWFUNC_TRANS; + + // Hacked up support for alpha value in software mode Tails 09-24-2002 + // ...unhacked by toaster 04-01-2021, re-hacked a little by sphere 19-11-2021 + // and mercilessly shoved into saturn by chearii 02-02-2025 + { + INT32 trans = (10*((256+12) - pl->ffloor->alpha))/255; + + if (trans >= 10) + return; // Don't even draw it + + if (pl->ffloor->blend) // additive, (reverse) subtractive, modulative + ds->transmap = R_GetBlendTable(pl->ffloor->blend, trans); + else if (!(ds->transmap = R_GetTranslucencyTable(trans)) || trans == 0) + spanfunctype = SPANDRAWFUNC_SPLAT; // Opaque, but allow transparent flat pixels + } + +#ifdef SHITPLANESPARENCY + if (spanfunc == spanfuncs[SPANDRAWFUNC_SPLAT] || (pl->extra_colormap && pl->extra_colormap->fog)) +#else + if (!pl->extra_colormap || !(pl->extra_colormap->fog & 2)) +#endif + light = (pl->lightlevel >> LIGHTSEGSHIFT); + else + light = LIGHTLEVELS-1; + } + else if (pl->ffloor->flags & FF_FOG) + { + spanfunctype = SPANDRAWFUNC_FOG; + light = (pl->lightlevel >> LIGHTSEGSHIFT); + } + else light = (pl->lightlevel >> LIGHTSEGSHIFT); + + if (pl->ffloor->flags & FF_RIPPLE && cv_ripplewater.value) + { + INT32 top, bottom; + + ds->planeripple.active = true; + + if (spanfunctype == SPANDRAWFUNC_TRANS) + { + spanfunctype = SPANDRAWFUNC_WATER; + + // Copy the current scene, ugh + top = std::max(0, pl->high - 8); + bottom = std::min(viewheight, pl->low + 8); + + // Only copy the part of the screen we need + UINT8 i = R_GetViewNumber(); + INT32 scrx = 0; + INT32 scry = top; + INT32 offset; + + if (splitscreen == 1) + { + if (i & 1) + { + scry += viewheight; + } + } + else + { + if (i & 1) + { + scrx += viewwidth; + } + + if (i / 2) + { + scry += viewheight; + } + } + + offset = (scry*vid.width) + scrx; + + // No idea if this works + VID_BlitLinearScreen(renderscreen + offset, + vid.screens[1] + (top*vid.width), // intentionally not +offset + viewwidth, bottom-top, + vid.width, vid.width); + } + } + } + else light = (pl->lightlevel >> LIGHTSEGSHIFT); + } + + ds->currentplane = pl; + + levelflat = &levelflats[pl->picnum]; + + // Get the texture + ds->source = (UINT8 *)W_CacheLumpNum(levelflat->lumpnum, PU_STATIC); // Stay here until Z_ChangeTag + + if (ds->source == NULL) + return; + + size = W_LumpLength(levelflat->lumpnum); + + switch (size) + { + case 4194304: // 2048x2048 lump + ds->nflatmask = 0x3FF800; + ds->nflatxshift = 21; + ds->nflatyshift = 10; + ds->nflatshiftup = 5; + break; + case 1048576: // 1024x1024 lump + ds->nflatmask = 0xFFC00; + ds->nflatxshift = 22; + ds->nflatyshift = 12; + ds->nflatshiftup = 6; + break; + case 262144:// 512x512 lump' + ds->nflatmask = 0x3FE00; + ds->nflatxshift = 23; + ds->nflatyshift = 14; + ds->nflatshiftup = 7; + break; + case 65536: // 256x256 lump + ds->nflatmask = 0xFF00; + ds->nflatxshift = 24; + ds->nflatyshift = 16; + ds->nflatshiftup = 8; + break; + case 16384: // 128x128 lump + ds->nflatmask = 0x3F80; + ds->nflatxshift = 25; + ds->nflatyshift = 18; + ds->nflatshiftup = 9; + break; + case 1024: // 32x32 lump + ds->nflatmask = 0x3E0; + ds->nflatxshift = 27; + ds->nflatyshift = 22; + ds->nflatshiftup = 11; + break; + default: // 64x64 lump + ds->nflatmask = 0xFC0; + ds->nflatxshift = 26; + ds->nflatyshift = 20; + ds->nflatshiftup = 10; + break; + } + + ds->xoffs = pl->xoffs; + ds->yoffs = pl->yoffs; + + light = CLAMP(light, 0, LIGHTLEVELS-1); + + if (pl->slope) + { + mapfunc = R_MapTiltedPlane; + + if (!pl->plangle) + { + R_AdjustSlopeCoordinates(ds, &pl->slope->o); + } + + if (ds->planeripple.active) + { + ds->planeheight = abs(P_GetSlopeZAt(pl->slope, pl->viewx, pl->viewy) - pl->viewz); + + R_PlaneBounds(pl); + + for (x = pl->high; x < pl->low; x++) + { + ds->bgofs = R_CalculateRippleOffset(ds, x); + R_CalculatePlaneRipple(ds, pl->viewangle + pl->plangle); + R_SetSlopePlaneVectors(ds, pl, x, (ds->xoffs + ds->planeripple.xfrac), (ds->yoffs + ds->planeripple.yfrac)); + } + } + else + R_SetSlopePlaneVectors(ds, pl, 0, ds->xoffs, ds->yoffs); + + switch (spanfunctype) + { + case SPANDRAWFUNC_WATER: + spanfunctype = SPANDRAWFUNC_TILTEDWATER; + break; + case SPANDRAWFUNC_TRANS: + spanfunctype = SPANDRAWFUNC_TILTEDTRANS; + break; + case SPANDRAWFUNC_SPLAT: + spanfunctype = SPANDRAWFUNC_TILTEDSPLAT; + break; + case SPANDRAWFUNC_TRANSSPLAT: + spanfunctype = SPANDRAWFUNC_TILTEDTRANSSPLAT; + break; + case SPANDRAWFUNC_FOG: + spanfunctype = SPANDRAWFUNC_TILTEDFOG; + break; + default: + spanfunctype = SPANDRAWFUNC_TILTED; + break; + } + + ds->planezlight = scalelight[light]; + } + else + { + // Don't mess with angle on slopes! We'll handle this ourselves later + if (viewangle != pl->viewangle + pl->plangle) + { + viewangle = pl->viewangle + pl->plangle; + } + + ds->planeheight = abs(pl->height - pl->viewz); + ds->planezlight = zlight[light]; + } + + R_SetSpanFunc(spanfunctype); + + // set the maximum value for unsigned + pl->top[pl->maxx+1] = pl->top[pl->minx-1] = 0xffff; + pl->bottom[pl->maxx+1] = pl->bottom[pl->minx-1] = 0x0000; + + stop = pl->maxx + 1; + + for (x = pl->minx; x <= stop; x++) + { + R_MakeSpans(mapfunc, spanfunc, ds, x, pl->top[x-1], pl->bottom[x-1], pl->top[x], pl->bottom[x], allow_parallel); + } + +/* +QUINCUNX anti-aliasing technique (sort of) + +Normally, Quincunx antialiasing staggers pixels +in a 5-die pattern like so: + +o o + o +o o + +To simulate this, we offset the plane by +FRACUNIT/4 in each direction, and draw +at 50% translucency. The result is +a 'smoothing' of the texture while +using the palette colors. +*/ +#ifdef QUINCUNX + if (spanfunc == spanfuncs[BASEDRAWFUNC]) + { + INT32 i; + + ds->transmap = R_GetTranslucencyTable(tr_trans50); + + R_SetSpanFunc(SPANDRAWFUNC_TRANS); + + for (i = 0; i < 4; i++) + { + ds->xoffs = pl->xoffs; + ds->yoffs = pl->yoffs; + + switch(i) + { + case 0: + ds->xoffs -= FRACUNIT/4; + ds->yoffs -= FRACUNIT/4; + break; + case 1: + ds->xoffs -= FRACUNIT/4; + ds->yoffs += FRACUNIT/4; + break; + case 2: + ds->xoffs += FRACUNIT/4; + ds->yoffs -= FRACUNIT/4; + break; + case 3: + ds->xoffs += FRACUNIT/4; + ds->yoffs += FRACUNIT/4; + break; + } + ds->planeheight = abs(pl->height - pl->viewz); + + if (light >= LIGHTLEVELS) + light = LIGHTLEVELS-1; + + if (light < 0) + light = 0; + + ds->planezlight = zlight[light]; + + // set the maximum value for unsigned + pl->top[pl->maxx+1] = 0xffff; + pl->top[pl->minx-1] = 0xffff; + pl->bottom[pl->maxx+1] = 0x0000; + pl->bottom[pl->minx-1] = 0x0000; + + stop = pl->maxx + 1; + + for (x = pl->minx; x <= stop; x++) + R_MakeSpans(x, pl->top[x-1], pl->bottom[x-1], + pl->top[x], pl->bottom[x]); + } + } +#endif + + Z_ChangeTag(ds->source, PU_CACHE); +} + +void R_PlaneBounds(visplane_t *plane) +{ + INT32 i; + INT32 hi, low; + + hi = plane->top[plane->minx]; + low = plane->bottom[plane->minx]; + + for (i = plane->minx + 1; i <= plane->maxx; i++) + { + if (plane->top[i] < hi) + hi = plane->top[i]; + if (plane->bottom[i] > low) + low = plane->bottom[i]; + } + + plane->high = hi; + plane->low = low; +} diff --git a/src/r_plane.h b/src/r_plane.h index 5f0db2c7c..f330baa3d 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -14,6 +14,10 @@ #ifndef __R_PLANE__ #define __R_PLANE__ +#ifdef __cplusplus +extern "C" { +#endif + #include "screen.h" // needs MAXVIDWIDTH/MAXVIDHEIGHT #include "r_data.h" #include "p_polyobj.h" @@ -43,9 +47,8 @@ typedef struct visplane_s // colormaps per sector extracolormap_t *extra_colormap; - // leave pads for [minx-1]/[maxx+1] - UINT16 padtopstart, top[MAXVIDWIDTH], padtopend; - UINT16 padbottomstart, bottom[MAXVIDWIDTH], padbottomend; + UINT16 *top, *top_memory; + UINT16 *bottom, *bottom_memory; INT32 high, low; // R_PlaneBounds should set these. fixed_t xoffs, yoffs; // Scrolling flats. @@ -55,8 +58,11 @@ typedef struct visplane_s pslope_t *slope; boolean noencore; + boolean cyan; } visplane_t; +extern visplane_t *visplanes[MAXVISPLANES]; + extern visplane_t *floorplane; extern visplane_t *ceilingplane; @@ -64,25 +70,19 @@ extern visplane_t *ceilingplane; extern INT16 *lastopening, *openings; extern size_t maxopenings; -extern INT16 floorclip[MAXVIDWIDTH], ceilingclip[MAXVIDWIDTH]; -extern fixed_t frontscale[MAXVIDWIDTH], yslopetab[MAXVIDHEIGHT*16]; -extern fixed_t cachedheight[MAXVIDHEIGHT]; -extern fixed_t cacheddistance[MAXVIDHEIGHT]; -extern fixed_t cachedxstep[MAXVIDHEIGHT]; -extern fixed_t cachedystep[MAXVIDHEIGHT]; +extern INT16 *floorclip, *ceilingclip; +extern fixed_t *frontscale, *yslopetab; extern fixed_t basexscale, baseyscale; extern fixed_t *yslope; -extern lighttable_t **planezlight; -void R_InitPlanes(void); +void R_AllocPlaneMemory(void); void R_ClearPlanes(void); void R_ClearFFloorClips (void); -void R_MapPlane(INT32 y, INT32 x1, INT32 x2); -void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2); +void R_DrawSkyPlanes(void); void R_DrawPlanes(void); -void R_CalculateSlopeVectors(pslope_t *slope, fixed_t planeviewx, fixed_t planeviewy, fixed_t planeviewz, fixed_t planexscale, fixed_t planeyscale, fixed_t planexoffset, fixed_t planeyoffset, angle_t planeviewangle, angle_t planeangle, float fudge); + visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, fixed_t xoff, fixed_t yoff, angle_t plangle, extracolormap_t *planecolormap, ffloor_t *ffloor , polyobj_t *polyobj @@ -93,9 +93,6 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop); void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop); void R_PlaneBounds(visplane_t *plane); -// Draws a single visplane. -void R_DrawSinglePlane(visplane_t *pl); - typedef struct planemgr_s { visplane_t *plane; @@ -104,8 +101,8 @@ typedef struct planemgr_s fixed_t b_pos; // B for Back sector fixed_t f_frac, f_step; fixed_t b_frac, b_step; - INT16 f_clip[MAXVIDWIDTH]; - INT16 c_clip[MAXVIDWIDTH]; + INT16 *f_clip; + INT16 *c_clip; // For slope rendering; the height at the other end fixed_t f_pos_slope; @@ -119,4 +116,9 @@ typedef struct planemgr_s extern visffloor_t ffloor[MAXFFLOORS]; extern INT32 numffloors; + +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/r_portal.c b/src/r_portal.c index afbcd46dd..432e3f50d 100644 --- a/src/r_portal.c +++ b/src/r_portal.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 KART //----------------------------------------------------------------------------- -// Copyright (C) 2024 by Kart Krew. +// Copyright (C) 2025 by Kart Krew. // Copyright (C) 2020 by Sonic Team Junior. // Copyright (C) 2000 by DooM Legacy Team. // Copyright (C) 1996 by id Software, Inc. @@ -14,7 +14,9 @@ #include "r_portal.h" #include "r_plane.h" -#include "r_main.h" // viewheight, viewwidth +#include "r_main.h" +#include "doomstat.h" +#include "p_spec.h" // Skybox viewpoints #include "z_zone.h" #include "r_things.h" #include "r_sky.h" @@ -36,7 +38,6 @@ void Portal_InitList (void) portal_base = portal_cap = NULL; } - /** Store the clipping window for a portal in its given range. * * The window is copied from the current window at the time @@ -63,7 +64,6 @@ static void Portal_ClipRange (portal_t* portal) } } - /** Apply the clipping window from a portal. */ void Portal_ClipApply (const portal_t* portal) @@ -91,6 +91,7 @@ void Portal_ClipApply (const portal_t* portal) floorclip[i] = -1; ceilingclip[i] = (INT16)viewheight; } + for (i = end; i < vid.width; i++) { floorclip[i] = -1; @@ -119,11 +120,11 @@ static portal_t* Portal_Add (const INT16 x1, const INT16 x2) portal->next = NULL; // Store clipping values so they can be restored once the portal is rendered. - portal->ceilingclip = ceilingclipsave; - portal->floorclip = floorclipsave; - portal->frontscale = frontscalesave; - portal->start = x1; - portal->end = x2; + portal->ceilingclip = ceilingclipsave; + portal->floorclip = floorclipsave; + portal->frontscale = frontscalesave; + portal->start = x1; + portal->end = x2; // Increase recursion level. portal->pass = portalrender+1; @@ -166,6 +167,10 @@ void Portal_Add2Lines (const INT32 line1, const INT32 line2, const INT32 x1, con vertex_t dest_c, start_c; + portal->viewx = viewx; + portal->viewy = viewy; + portal->viewz = viewz; + // looking glass center start_c.x = (start->v1->x + start->v2->x) / 2; start_c.y = (start->v1->y + start->v2->y) / 2; @@ -174,13 +179,24 @@ void Portal_Add2Lines (const INT32 line1, const INT32 line2, const INT32 x1, con dest_c.x = (dest->v1->x + dest->v2->x) / 2; dest_c.y = (dest->v1->y + dest->v2->y) / 2; - disttopoint = R_PointToDist2(start_c.x, start_c.y, viewx, viewy); - angtopoint = R_PointToAngle2(start_c.x, start_c.y, viewx, viewy); - angtopoint += dangle; - - portal->viewx = dest_c.x + FixedMul(FINECOSINE(angtopoint>>ANGLETOFINESHIFT), disttopoint); - portal->viewy = dest_c.y + FixedMul(FINESINE(angtopoint>>ANGLETOFINESHIFT), disttopoint); portal->viewz = viewz + dest->frontsector->floorheight - start->frontsector->floorheight; + + if (dangle == 0) + { + // the entrance goes straight opposite the exit, so we just need to mess with the offset. + portal->viewx += dest_c.x - start_c.x; + portal->viewy += dest_c.y - start_c.y; + } + else + { + disttopoint = R_PointToDist2(start_c.x, start_c.y, viewx, viewy); + angtopoint = R_PointToAngle2(start_c.x, start_c.y, viewx, viewy); + angtopoint += dangle; + + portal->viewx = dest_c.x + FixedMul(FINECOSINE(angtopoint>>ANGLETOFINESHIFT), disttopoint); + portal->viewy = dest_c.y + FixedMul(FINESINE(angtopoint>>ANGLETOFINESHIFT), disttopoint); + } + portal->viewangle = viewangle + dangle; portal->clipline = line2; @@ -190,4 +206,151 @@ void Portal_Add2Lines (const INT32 line1, const INT32 line2, const INT32 x1, con g_portal = portal; // this tells R_StoreWallRange that curline is a portal seg } +/** Store the clipping window for a portal using a visplane. + * + * Since visplanes top/bottom windows work in an identical way, + * it can just be copied almost directly. + */ +static void Portal_ClipVisplane (const visplane_t* plane, portal_t* portal) +{ + INT16 start = portal->start; + INT16 end = portal->end; + INT32 i; + + for (i = 0; i < end - start; i++) + { + // Invalid column. + if (plane->top[i + start] == 65535) + { + portal->ceilingclip[i] = -1; + portal->floorclip[i] = -1; + continue; + } + portal->ceilingclip[i] = plane->top[i + start] - 1; + portal->floorclip[i] = plane->bottom[i + start] + 1; + portal->frontscale[i] = INT32_MAX; + } +} + +extern INT32 viewwidth; + +static boolean TrimVisplaneBounds (const visplane_t* plane, INT16* start, INT16* end) +{ + *start = plane->minx; + *end = plane->maxx + 1; + + // Visplanes have 1-px pads on their sides (extra columns). + // Trim them, else it may render out of bounds. + if (*end > viewwidth) + *end = viewwidth; + + if (!(*start < *end)) + return true; + + + /** Trims a visplane's horizontal gap to match its render area. + * + * Visplanes' minx/maxx may sometimes exceed the area they're + * covering. This merely adjusts the boundaries to the next + * valid area. + */ + + while (plane->bottom[*start] == 0 && plane->top[*start] == 65535 && *start < *end) + { + (*start)++; + } + + + while (plane->bottom[*end - 1] == 0 && plane->top[*start] == 65535 && *end > *start) + { + (*end)--; + } + + return false; +} + +/** Creates a skybox portal out of a visplane. + * + * Applies the necessary offsets and rotation to give + * a depth illusion to the skybox. + */ +void Portal_AddSkybox(const visplane_t* plane) +{ + INT16 start, end; + mapheader_t *mh; + portal_t* portal; + + if (TrimVisplaneBounds(plane, &start, &end)) + return; + + portal = Portal_Add(start, end); + + Portal_ClipVisplane(plane, portal); + + portal->viewx = skyboxmo[0]->x; + portal->viewy = skyboxmo[0]->y; + portal->viewz = skyboxmo[0]->z; + if (skyboxmo[0]->spawnpoint) + portal->viewz = ((fixed_t)skyboxmo[0]->spawnpoint->angle)<viewangle = viewangle + skyboxmo[0]->angle; + + mh = mapheaderinfo[gamemap-1]; + + // If a relative viewpoint exists, offset the viewpoint. + if (skyboxmo[1]) + { + fixed_t x = 0, y = 0; + angle_t ang = skyboxmo[0]->angle>>ANGLETOFINESHIFT; + + if (mh->skybox_scalex > 0) + x = (viewx - skyboxmo[1]->x) / mh->skybox_scalex; + else if (mh->skybox_scalex < 0) + x = (viewx - skyboxmo[1]->x) * -mh->skybox_scalex; + + if (mh->skybox_scaley > 0) + y = (viewy - skyboxmo[1]->y) / mh->skybox_scaley; + else if (mh->skybox_scaley < 0) + y = (viewy - skyboxmo[1]->y) * -mh->skybox_scaley; + + // Apply transform to account for the skybox viewport angle. + portal->viewx += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang)); + portal->viewy += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang)); + } + + if (mh->skybox_scalez > 0) + portal->viewz += viewz / mh->skybox_scalez; + else if (mh->skybox_scalez < 0) + portal->viewz += viewz * -mh->skybox_scalez; + + portal->clipline = -1; +} + +/** Creates portals for the currently existing sky visplanes. + * The visplanes are also removed and cleared from the list. + */ +void Portal_AddSkyboxPortals(void) +{ + visplane_t *pl; + INT32 i; + UINT16 count = 0; + + for (i = 0; i < MAXVISPLANES; i++, pl++) + { + for (pl = visplanes[i]; pl; pl = pl->next) + { + if (pl->picnum == skyflatnum) + { + Portal_AddSkybox(pl); + + pl->minx = 0; + pl->maxx = -1; + + count++; + } + } + } + + CONS_Debug(DBG_RENDER, "Skybox portals: %d\n", count); +} diff --git a/src/r_portal.h b/src/r_portal.h index c944f46d0..223dd83be 100644 --- a/src/r_portal.h +++ b/src/r_portal.h @@ -14,10 +14,14 @@ #ifndef __R_PORTAL__ #define __R_PORTAL__ +#ifdef __cplusplus +extern "C" { +#endif + #include "r_data.h" +#include "r_plane.h" // visplanes - -/** Portal structure. +/** Portal structure for the software renderer. */ typedef struct portal_s { @@ -54,4 +58,11 @@ void Portal_Add2Lines (const INT32 line1, const INT32 line2, const INT32 x1, con void Portal_ClipApply (const portal_t* portal); +void Portal_AddSkybox(const visplane_t* plane); +void Portal_AddSkyboxPortals(void); + +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/r_segs.c b/src/r_segs.cpp similarity index 62% rename from src/r_segs.c rename to src/r_segs.cpp index f1954f0e7..6bc139a2d 100644 --- a/src/r_segs.c +++ b/src/r_segs.cpp @@ -17,6 +17,7 @@ #include "r_portal.h" #include "r_splats.h" +#include "r_fps.h" // newview #include "w_wad.h" #include "z_zone.h" @@ -26,6 +27,12 @@ #include "p_setup.h" #include "p_slopes.h" #include "console.h" // con_clipviewtop +#include "screen.h" + +#include "core/memory.h" + +#define HEIGHTBITS 12 +#define HEIGHTUNIT (1<topdelta != 0xff ;) - { - // calculate unclipped screen coordinates for post - topdelta = column->topdelta; - if (topdelta <= prevdelta) - topdelta += prevdelta; - prevdelta = topdelta; - topscreen = sprtopscreen + spryscale*topdelta; - bottomscreen = topscreen + spryscale*column->length; - - dc_yl = (topscreen+FRACUNIT-1)>>FRACBITS; - dc_yh = (bottomscreen-1)>>FRACBITS; - - if (dc_yh >= last_floorclip[dc_x]) - dc_yh = last_floorclip[dc_x] - 1; - if (dc_yl <= last_ceilingclip[dc_x]) - dc_yl = last_ceilingclip[dc_x] + 1; - if (dc_yl <= dc_yh && dl_yh < vid.height && yh > 0) - { - dc_source = (UINT8 *)column + 3; - dc_texturemid = basetexturemid - (topdelta<length + 4); - } - - dc_texturemid = basetexturemid; -} - -static void R_DrawWallSplats(void) -{ - wallsplat_t *splat; - seg_t *seg; - angle_t angle, angle1, angle2; - INT32 x1, x2; - size_t pindex; - column_t *col; - patch_t *patch; - fixed_t texturecolumn; - - splat = (wallsplat_t *)linedef->splats; - - I_Assert(splat != NULL); - - seg = ds_p->curline; - - // draw all splats from the line that touches the range of the seg - for (; splat; splat = splat->next) - { - angle1 = R_PointToAngle(splat->v1.x, splat->v1.y); - angle2 = R_PointToAngle(splat->v2.x, splat->v2.y); - angle1 = (angle1 - viewangle + ANGLE_90)>>ANGLETOFINESHIFT; - angle2 = (angle2 - viewangle + ANGLE_90)>>ANGLETOFINESHIFT; - // out of the viewangletox lut - /// \todo clip it to the screen - if (angle1 > FINEANGLES/2 || angle2 > FINEANGLES/2) - continue; - x1 = viewangletox[angle1]; - x2 = viewangletox[angle2]; - - if (x1 >= x2) - continue; // does not cross a pixel - - // splat is not in this seg range - if (x2 < ds_p->x1 || x1 > ds_p->x2) - continue; - - if (x1 < ds_p->x1) - x1 = ds_p->x1; - if (x2 > ds_p->x2) - x2 = ds_p->x2; - if (x2 <= x1) - continue; - - // calculate incremental stepping values for texture edges - rw_scalestep = ds_p->scalestep; - spryscale = ds_p->scale1 + (x1 - ds_p->x1)*rw_scalestep; - mfloorclip = floorclip; - mceilingclip = ceilingclip; - - patch = W_CachePatchNum(splat->patch, PU_SPRITE); - - dc_texturemid = splat->top + (patch->height<<(FRACBITS-1)) - viewz; - if (splat->yoffset) - dc_texturemid += *splat->yoffset; - - sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale); - - // set drawing mode - switch (splat->flags & SPLATDRAWMODE_MASK) - { - case SPLATDRAWMODE_OPAQUE: - colfunc = basecolfunc; - break; - case SPLATDRAWMODE_TRANS: - if (!cv_translucency.value) - colfunc = basecolfunc; - else - { - dc_transmap = R_GetTranslucencyTable(tr_trans50); - colfunc = fuzzcolfunc; - } - - break; - case SPLATDRAWMODE_SHADE: - colfunc = shadecolfunc; - break; - } - - dc_texheight = 0; - - // draw the columns - for (dc_x = x1; dc_x <= x2; dc_x++, spryscale += rw_scalestep) - { - pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; - if (pindex >= MAXLIGHTSCALE) - pindex = MAXLIGHTSCALE - 1; - dc_colormap = walllights[pindex]; - if (encoremap && !(seg->linedef->flags & ML_TFERLINE)) - dc_colormap += COLORMAP_REMAPOFFSET; - - if (frontsector->extra_colormap) - dc_colormap = frontsector->extra_colormap->colormap + (dc_colormap - colormaps); - - sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale); - dc_iscale = 0xffffffffu / (unsigned)spryscale; - - // find column of patch, from perspective - angle = (rw_centerangle + xtoviewangle[dc_x])>>ANGLETOFINESHIFT; - texturecolumn = rw_offset2 - splat->offset - - FixedMul(FINETANGENT(angle), rw_distance); - - // FIXME! - texturecolumn >>= FRACBITS; - if (texturecolumn < 0 || texturecolumn >= patch->width) - continue; - - // draw the texture - col = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); - R_DrawSplatColumn(col); - } - } // next splat - - colfunc = basecolfunc; -} - -#endif //WALLSPLATS - // ========================================================================== // R_RenderMaskedSegRange // ========================================================================== @@ -249,164 +91,126 @@ static void R_DrawWallSplats(void) // multi-patch textures. They are not normally needed as multi-patch // textures don't have holes in it. At least not for now. -static void R_Render2sidedMultiPatchColumn(column_t *column) +static void R_Render2sidedMultiPatchColumn(drawcolumndata_t* dc, column_t *column) { INT32 topscreen, bottomscreen; topscreen = sprtopscreen; // + spryscale*column->topdelta; topdelta is 0 for the wall bottomscreen = topscreen + spryscale * lengthcol; - dc_yl = (sprtopscreen+FRACUNIT-1)>>FRACBITS; - dc_yh = (bottomscreen-1)>>FRACBITS; + dc->yl = (sprtopscreen+FRACUNIT-1)>>FRACBITS; + dc->yh = (bottomscreen-1)>>FRACBITS; if (windowtop != INT32_MAX && windowbottom != INT32_MAX) { - dc_yl = ((windowtop + FRACUNIT)>>FRACBITS); - dc_yh = (windowbottom - 1)>>FRACBITS; + dc->yl = ((windowtop + FRACUNIT)>>FRACBITS); + dc->yh = (windowbottom - 1)>>FRACBITS; } - if (dc_yh >= mfloorclip[dc_x]) - dc_yh = mfloorclip[dc_x] - 1; - if (dc_yl <= mceilingclip[dc_x]) - dc_yl = mceilingclip[dc_x] + 1; + if (dc->yh >= mfloorclip[dc->x]) + dc->yh = mfloorclip[dc->x] - 1; + if (dc->yl <= mceilingclip[dc->x]) + dc->yl = mceilingclip[dc->x] + 1; - if (dc_yl >= vid.height || dc_yh < 0) + if (dc->yl >= vid.height || dc->yh < 0) return; - if (dc_yl <= dc_yh && dc_yh < vid.height && dc_yh > 0) + if (dc->yl <= dc->yh && dc->yh < vid.height && dc->yh > 0) { - dc_source = (UINT8 *)column + 3; - dc_sourcelength = lengthcol; + dc->source = (UINT8 *)column + 3; + dc->sourcelength = lengthcol; - if (colfunc == wallcolfunc) - twosmultipatchfunc(); - else if (colfunc == fuzzcolfunc) - twosmultipatchtransfunc(); - else - colfunc(); + // Drawn by R_DrawColumn. + drawcolumndata_t dc_copy = *dc; + coldrawfunc_t* colfunccopy = colfunc; + + // FIXME: do something better to look these up WITHOUT affecting global state... + if (R_CheckColumnFunc(BASEDRAWFUNC) == true) + { + colfunccopy = colfuncs[COLDRAWFUNC_TWOSMULTIPATCH]; + } + else if (R_CheckColumnFunc(COLDRAWFUNC_FUZZY) == true) + { + colfunccopy = colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS]; + } + + colfunccopy(const_cast(&dc_copy)); } } transnum_t R_GetLinedefTransTable(fixed_t alpha) { - return (20*(FRACUNIT - alpha - 1) + FRACUNIT) >> (FRACBITS+1); + return static_cast((20*(FRACUNIT - alpha - 1) + FRACUNIT) >> (FRACBITS+1)); } -void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) +static inline boolean R_OverflowTest(drawcolumndata_t* dc) +{ + INT64 overflow_test; + + overflow_test = (INT64)centeryfrac - (((INT64)dc->texturemid*spryscale)>>FRACBITS); + + if (overflow_test < 0) + overflow_test = -overflow_test; + + if ((UINT64)overflow_test&0xFFFFFFFF80000000ULL) + return true; + + return false; +} + +static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT32 x1, INT32 x2, INT32 texnum, void (*colfunc_2s)(drawcolumndata_t*, column_t *)) { size_t pindex; column_t *col; - INT32 lightnum, texnum, i; + INT32 lightnum, i; fixed_t height, realbot; lightlist_t *light; r_lightlist_t *rlight; - void (*colfunc_2s)(column_t *); - line_t *ldef; sector_t *front, *back; INT32 times, repeats; - INT64 overflow_test; INT32 range; + line_t *ldef; - // Calculate light table. - // Use different light tables - // for horizontal / vertical / diagonal. Diagonal? - // OPTIMIZE: get rid of LIGHTSEGSHIFT globally - curline = ds->curline; - frontsector = curline->frontsector; - backsector = curline->backsector; - texnum = R_GetTextureNum(curline->sidedef->midtexture); - windowbottom = windowtop = sprbotscreen = INT32_MAX; - - // hack translucent linedef types (900-909 for transtables 1-9) ldef = curline->linedef; - if (!ldef->alpha) - return; - - if (ldef->blendmode) - { - if (ldef->alpha == NUMTRANSMAPS || ldef->blendmode == AST_MODULATE) - dc_transmap = R_GetBlendTable(ldef->blendmode, 0); - else - dc_transmap = R_GetBlendTable(ldef->blendmode, R_GetLinedefTransTable(ldef->alpha)); - colfunc = fuzzcolfunc; - } - else if (ldef->alpha > 0 && ldef->alpha < FRACUNIT) - { - dc_transmap = R_GetTranslucencyTable(R_GetLinedefTransTable(ldef->alpha)); - colfunc = fuzzcolfunc; - } - else if (ldef->special == 909) - { - colfunc = R_DrawFogColumn_8; - windowtop = frontsector->ceilingheight; - windowbottom = frontsector->floorheight; - } - else - { - colfunc = wallcolfunc; - } - - if (curline->polyseg && curline->polyseg->translucency > 0) - { - if (curline->polyseg->translucency >= NUMTRANSMAPS) - return; - - dc_transmap = R_GetTranslucencyTable(curline->polyseg->translucency); - colfunc = fuzzcolfunc; - } - - range = max(ds->x2-ds->x1, 1); - rw_scalestep = ds->scalestep; - spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep; - - // Texture must be cached before setting colfunc_2s, - // otherwise texture[texnum]->holes may be false when it shouldn't be - R_CheckTextureCache(texnum); - // handle case where multipatch texture is drawn on a 2sided wall, multi-patch textures - // are not stored per-column with post info in SRB2 - if (textures[texnum]->holes) - colfunc_2s = R_DrawMaskedColumn; // render the usual 2sided single-patch packed texture - else - { - colfunc_2s = R_Render2sidedMultiPatchColumn; // render multipatch with no holes (no post_t info) - lengthcol = textures[texnum]->height; - } + range = std::max(drawseg->x2-drawseg->x1, 1); // Setup lighting based on the presence/lack-of 3D floors. - dc_numlights = 0; + dc->numlights = 0; + if (frontsector->numlights) { - dc_numlights = frontsector->numlights; - if (dc_numlights >= dc_maxlights) + dc->numlights = frontsector->numlights; + + if (dc->numlights > dc->maxlights) { - dc_maxlights = dc_numlights; - dc_lightlist = Z_Realloc(dc_lightlist, sizeof (*dc_lightlist) * dc_maxlights, PU_STATIC, NULL); + dc->maxlights = dc->numlights; + dc->lightlist = static_cast(Z_Frame_Alloc(sizeof (*dc->lightlist) * dc->maxlights)); } - for (i = 0; i < dc_numlights; i++) + for (i = 0; i < dc->numlights; i++) { fixed_t leftheight, rightheight; light = &frontsector->lightlist[i]; - rlight = &dc_lightlist[i]; + rlight = &dc->lightlist[i]; - leftheight = P_GetLightZAt(light, ds-> leftpos.x, ds-> leftpos.y); - rightheight = P_GetLightZAt(light, ds->rightpos.x, ds->rightpos.y); + leftheight = P_GetLightZAt(light, drawseg-> leftpos.x, drawseg-> leftpos.y); + rightheight = P_GetLightZAt(light, drawseg->rightpos.x, drawseg->rightpos.y); - leftheight -= viewz; + leftheight -= viewz; rightheight -= viewz; - rlight->height = (centeryfrac) - FixedMul(leftheight, ds->scale1); - rlight->heightstep = (centeryfrac) - FixedMul(rightheight, ds->scale2); - rlight->heightstep = (rlight->heightstep-rlight->height)/(range); - rlight->startheight = rlight->height; // keep starting value here to reset for each repeat - rlight->lightlevel = *light->lightlevel; + rlight->height = (centeryfrac) - FixedMul(leftheight, drawseg->scale1); + rlight->heightstep = (centeryfrac) - FixedMul(rightheight, drawseg->scale2); + rlight->heightstep = (rlight->heightstep-rlight->height)/(range); + rlight->startheight = rlight->height; // keep starting value here to reset for each repeat + rlight->lightlevel = *light->lightlevel; rlight->extra_colormap = light->extra_colormap; - rlight->flags = light->flags; + rlight->flags = static_cast(light->flags); if (rlight->flags & FF_FOG || (rlight->extra_colormap && rlight->extra_colormap->fog)) lightnum = (rlight->lightlevel >> LIGHTSEGSHIFT); - else if (colfunc == fuzzcolfunc) + else if (R_CheckColumnFunc(COLDRAWFUNC_FUZZY)) lightnum = LIGHTLEVELS - 1; else lightnum = (rlight->lightlevel >> LIGHTSEGSHIFT); @@ -421,17 +225,13 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) } else { - if (colfunc == fuzzcolfunc) - { - if (frontsector->extra_colormap && frontsector->extra_colormap->fog) - lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT); - else - lightnum = LIGHTLEVELS - 1; - } - else + if ((R_CheckColumnFunc(COLDRAWFUNC_FUZZY) == false) + || (frontsector->extra_colormap && frontsector->extra_colormap->fog)) lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT); + else + lightnum = LIGHTLEVELS - 1; - if (colfunc == R_DrawFogColumn_8 + if ((R_CheckColumnFunc(COLDRAWFUNC_FOG) == true) || (frontsector->extra_colormap && frontsector->extra_colormap->fog)) ; else if (P_ApplyLightOffset(lightnum, frontsector)) @@ -445,11 +245,6 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) walllights = scalelight[lightnum]; } - maskedtexturecol = ds->maskedtexturecol; - - mfloorclip = ds->sprbottomclip; - mceilingclip = ds->sprtopclip; - if (frontsector->heightsec != -1) front = §ors[frontsector->heightsec]; else @@ -460,8 +255,8 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) else back = backsector; - if (ds->curline->sidedef->repeatcnt) - repeats = 1 + ds->curline->sidedef->repeatcnt; + if (drawseg->curline->sidedef->repeatcnt) + repeats = 1 + drawseg->curline->sidedef->repeatcnt; else if (ldef->flags & ML_EFFECT5) { fixed_t high, low; @@ -487,76 +282,77 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) { if (times > 0) { - rw_scalestep = ds->scalestep; - spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep; - if (dc_numlights) + rw_scalestep = drawseg->scalestep; + spryscale = drawseg->scale1 + (x1 - drawseg->x1)*rw_scalestep; + if (dc->numlights) { // reset all lights to their starting heights - for (i = 0; i < dc_numlights; i++) + for (i = 0; i < dc->numlights; i++) { - rlight = &dc_lightlist[i]; + rlight = &dc->lightlist[i]; rlight->height = rlight->startheight; } } } - dc_texheight = textureheight[texnum]>>FRACBITS; + dc->texheight = textureheight[texnum]>>FRACBITS; // draw the columns - for (dc_x = x1; dc_x <= x2; dc_x++) + for (dc->x = x1; dc->x <= x2; dc->x++) { - dc_texturemid = ds->maskedtextureheight[dc_x]; + dc->texturemid = drawseg->maskedtextureheight[dc->x]; if (!!(curline->linedef->flags & ML_DONTPEGBOTTOM) ^ !!(curline->linedef->flags & ML_EFFECT3)) - dc_texturemid += (textureheight[texnum])*times + textureheight[texnum]; + dc->texturemid += (textureheight[texnum])*times + textureheight[texnum]; else - dc_texturemid -= (textureheight[texnum])*times; + dc->texturemid -= (textureheight[texnum])*times; + + const INT16 colnum = maskedtexturecol[dc->x]; + // calculate lighting - if (maskedtexturecol[dc_x] != INT16_MAX) + if (colnum != INT16_MAX) { // Check for overflows first - overflow_test = (INT64)centeryfrac - (((INT64)dc_texturemid*spryscale)>>FRACBITS); - if (overflow_test < 0) overflow_test = -overflow_test; - if ((UINT64)overflow_test&0xFFFFFFFF80000000ULL) + if (R_OverflowTest(dc)) { // Eh, no, go away, don't waste our time - if (dc_numlights) + if (dc->numlights) { - for (i = 0; i < dc_numlights; i++) + for (i = 0; i < dc->numlights; i++) { - rlight = &dc_lightlist[i]; + rlight = &dc->lightlist[i]; rlight->height += rlight->heightstep; } } + spryscale += rw_scalestep; continue; } - if (dc_numlights) + if (dc->numlights) { lighttable_t **xwalllights; sprbotscreen = INT32_MAX; - sprtopscreen = windowtop = (centeryfrac - FixedMul(dc_texturemid, spryscale)); + sprtopscreen = windowtop = (centeryfrac - FixedMul(dc->texturemid, spryscale)); realbot = windowbottom = FixedMul(textureheight[texnum], spryscale) + sprtopscreen; - dc_iscale = 0xffffffffu / (unsigned)spryscale; + dc->iscale = 0xffffffffu / (unsigned)spryscale; // draw the texture - col = (column_t *)((UINT8 *)R_GetColumn(texnum, maskedtexturecol[dc_x]) - 3); + col = (column_t *)((UINT8 *)R_GetColumn(texnum, colnum) - 3); - for (i = 0; i < dc_numlights; i++) + auto set_light_vars = [&](INT32 k) { - rlight = &dc_lightlist[i]; + rlight = &dc->lightlist[k]; - if ((rlight->flags & FF_NOSHADE)) - continue; + lightnum = rlight->lightnum; - if (rlight->lightnum < 0) + if (lightnum < 0) xwalllights = scalelight[0]; - else if (rlight->lightnum >= LIGHTLEVELS) + else if (lightnum >= LIGHTLEVELS) xwalllights = scalelight[LIGHTLEVELS-1]; else - xwalllights = scalelight[rlight->lightnum]; + xwalllights = scalelight[lightnum]; pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; @@ -567,15 +363,33 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) rlight->rcolormap = rlight->extra_colormap->colormap + (xwalllights[pindex] - colormaps); else rlight->rcolormap = xwalllights[pindex]; + }; + + auto set_colormap_below_light = [&] + { + dc->colormap = rlight->rcolormap; + if (encoremap && !(ldef->flags & ML_TFERLINE)) + dc->colormap += COLORMAP_REMAPOFFSET; + }; + + // Use the base sector's light level above the first FOF. + // You can imagine it as the sky casting its light on top of the highest FOF. + set_light_vars(0); + set_colormap_below_light(); + + for (i = 0; i < dc->numlights; i++) + { + if ((dc->lightlist[i].flags & FF_NOSHADE)) + continue; + + set_light_vars(i); height = rlight->height; rlight->height += rlight->heightstep; if (height <= windowtop) { - dc_colormap = rlight->rcolormap; - if (encoremap && !(ldef->flags & ML_TFERLINE)) - dc_colormap += COLORMAP_REMAPOFFSET; + set_colormap_below_light(); continue; } @@ -583,24 +397,23 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) if (windowbottom >= realbot) { windowbottom = realbot; - colfunc_2s(col); - for (i++; i < dc_numlights; i++) + colfunc_2s(dc, col); + for (i++; i < dc->numlights; i++) { - rlight = &dc_lightlist[i]; + rlight = &dc->lightlist[i]; rlight->height += rlight->heightstep; } continue; } - colfunc_2s(col); + colfunc_2s(dc, col); + windowtop = windowbottom + 1; - dc_colormap = rlight->rcolormap; - if (encoremap && !(ldef->flags & ML_TFERLINE)) - dc_colormap += COLORMAP_REMAPOFFSET; + set_colormap_below_light(); } windowbottom = realbot; if (windowtop < windowbottom) - colfunc_2s(col); + colfunc_2s(dc, col); spryscale += rw_scalestep; continue; @@ -612,47 +425,170 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE - 1; - dc_colormap = walllights[pindex]; + dc->colormap = walllights[pindex]; if (encoremap && !(ldef->flags & ML_TFERLINE)) - dc_colormap += COLORMAP_REMAPOFFSET; + dc->colormap += COLORMAP_REMAPOFFSET; if (frontsector->extra_colormap) - dc_colormap = frontsector->extra_colormap->colormap + (dc_colormap - colormaps); + dc->colormap = frontsector->extra_colormap->colormap + (dc->colormap - colormaps); - sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale); - dc_iscale = 0xffffffffu / (unsigned)spryscale; + sprtopscreen = centeryfrac - FixedMul(dc->texturemid, spryscale); + dc->iscale = 0xffffffffu / (unsigned)spryscale; // draw the texture - col = (column_t *)((UINT8 *)R_GetColumn(texnum, maskedtexturecol[dc_x]) - 3); + col = (column_t *)((UINT8 *)R_GetColumn(texnum, colnum) - 3); - colfunc_2s(col); + colfunc_2s(dc, col); } + spryscale += rw_scalestep; } } - colfunc = wallcolfunc; +} + +static boolean R_CheckBlendMode(drawcolumndata_t* dc, const line_t *ldef) +{ + if (!ldef->alpha) + return false; + + if (ldef->blendmode) + { + if (ldef->alpha == NUMTRANSMAPS || ldef->blendmode == AST_MODULATE) + dc->transmap = R_GetBlendTable(ldef->blendmode, 0); + else + dc->transmap = R_GetBlendTable(ldef->blendmode, R_GetLinedefTransTable(ldef->alpha)); + + R_SetColumnFunc(COLDRAWFUNC_FUZZY); + } + else if (ldef->alpha > 0 && ldef->alpha < FRACUNIT) + { + dc->transmap = R_GetTranslucencyTable(R_GetLinedefTransTable(ldef->alpha)); + R_SetColumnFunc(COLDRAWFUNC_FUZZY); + } + else if (ldef->special == 909) + { + windowtop = frontsector->ceilingheight; + windowbottom = frontsector->floorheight; + R_SetColumnFunc(COLDRAWFUNC_FOG); + } + else + { + R_SetColumnFunc(BASEDRAWFUNC); + } + + if (curline->polyseg && curline->polyseg->translucency > 0) + { + if (curline->polyseg->translucency >= NUMTRANSMAPS) + return false; + + dc->transmap = R_GetTranslucencyTable(curline->polyseg->translucency); + R_SetColumnFunc(COLDRAWFUNC_FUZZY); + } + + return true; +} + +void R_RenderMaskedSegRange(drawseg_t *drawseg, INT32 x1, INT32 x2) +{ + INT32 texnum; + line_t *ldef; + void (*colfunc_2s)(drawcolumndata_t* dc, column_t *); + drawcolumndata_t *dc = &g_dc; + + // Calculate light table. + // Use different light tables + // for horizontal / vertical / diagonal. Diagonal? + // OPTIMIZE: get rid of LIGHTSEGSHIFT globally + curline = drawseg->curline; + + frontsector = curline->frontsector; + backsector = curline->backsector; + texnum = R_GetTextureNum(curline->sidedef->midtexture); + windowbottom = windowtop = sprbotscreen = INT32_MAX; + + // hack translucent linedef types (900-909 for transtables 1-9) + ldef = curline->linedef; + + if (R_CheckBlendMode(dc, ldef) == false) + { + return; // does not render + } + + rw_scalestep = drawseg->scalestep; + spryscale = drawseg->scale1 + (x1 - drawseg->x1)*rw_scalestep; + + // Texture must be cached before setting colfunc_2s, + // otherwise texture[texnum]->holes may be false when it shouldn't be + R_CheckTextureCache(texnum); + + // handle case where multipatch texture is drawn on a 2sided wall, multi-patch textures + // are not stored per-column with post info in SRB2 + if (textures[texnum]->holes) + colfunc_2s = R_DrawMaskedColumn; // render the usual 2sided single-patch packed texture + else + { + colfunc_2s = R_Render2sidedMultiPatchColumn; // render multipatch with no holes (no post_t info) + lengthcol = textures[texnum]->height; + } + + maskedtexturecol = drawseg->maskedtexturecol; + + mfloorclip = drawseg->sprbottomclip; + mceilingclip = drawseg->sprtopclip; + + R_RenderMaskedSegLoop(dc, drawseg, x1, x2, texnum, colfunc_2s); + + R_SetColumnFunc(BASEDRAWFUNC); +} + +template +static constexpr T saturating_add(T x, T y) noexcept +{ + INT64 z = static_cast(x) + static_cast(y); + if (z > static_cast(std::numeric_limits::max())) + { + z = static_cast(std::numeric_limits::max()); + } + else if (z < static_cast(std::numeric_limits::min())) + { + z = static_cast(std::numeric_limits::min()); + } + return static_cast(z); +} + +template +static constexpr T saturating_mul(T x, T y) noexcept +{ + INT64 z = static_cast(x) * static_cast(y); + if (z > static_cast(std::numeric_limits::max())) + { + z = static_cast(std::numeric_limits::max()); + } + else if (z < static_cast(std::numeric_limits::min())) + { + z = static_cast(std::numeric_limits::min()); + } + return static_cast(z); } // Loop through R_DrawMaskedColumn calls -static void R_DrawRepeatMaskedColumn(column_t *col) +static void R_DrawRepeatMaskedColumn(drawcolumndata_t* dc, column_t *col) { - INT64 z; while (sprtopscreen < sprbotscreen) { - R_DrawMaskedColumn(col); - z = sprtopscreen + (INT64)dc_texheight*spryscale; - if (z > (INT64)INT32_MAX) // prevent overflow - sprtopscreen = INT32_MAX; - else - sprtopscreen = z; + R_DrawMaskedColumn(dc, col); + sprtopscreen = saturating_add(sprtopscreen, saturating_mul(dc->texheight, spryscale)); } } // Returns true if a fake floor is translucent. static boolean R_IsFFloorTranslucent(visffloor_t *pfloor) { + if (cv_softcyancut.value && pfloor->plane->cyan) + return true; + if (pfloor->polyobj) - return (pfloor->polyobj->translucency > 0); + return true; // Polyobjects have no ffloors, and they're handled in the conditional above. if (pfloor->ffloor != NULL) @@ -664,7 +600,7 @@ static boolean R_IsFFloorTranslucent(visffloor_t *pfloor) // // R_RenderThickSideRange // Renders all the thick sides in the given range. -void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) +void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pfloor) { size_t pindex = 0; column_t * col; @@ -689,31 +625,35 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) INT32 oldx = -1; fixed_t left_top, left_bottom; // needed here for slope skewing pslope_t *skewslope = NULL; + boolean fog = false; + boolean fuzzy = false; - void (*colfunc_2s) (column_t *); + drawcolumndata_t *dc = &g_dc; + + void (*colfunc_2s) (drawcolumndata_t* dc, column_t *); // Calculate light table. // Use different light tables // for horizontal / vertical / diagonal. Diagonal? // OPTIMIZE: get rid of LIGHTSEGSHIFT globally - curline = ds->curline; + curline = drawseg->curline; backsector = pfloor->target; frontsector = curline->frontsector == pfloor->target ? curline->backsector : curline->frontsector; texnum = R_GetTextureNum(sides[pfloor->master->sidenum[0]].midtexture); - colfunc = wallcolfunc; + R_SetColumnFunc(BASEDRAWFUNC); if (pfloor->master->flags & ML_TFERLINE) { - size_t linenum = min((size_t)(curline->linedef-backsector->lines[0]), pfloor->master->frontsector->linecount); + size_t linenum = std::min((size_t)(curline->linedef-backsector->lines[0]), pfloor->master->frontsector->linecount); newline = pfloor->master->frontsector->lines[0] + linenum; texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); } if (pfloor->flags & FF_TRANSLUCENT) { - boolean fuzzy = true; + fuzzy = true; // Hacked up support for alpha value in software mode Tails 09-24-2002 // ...unhacked by toaster 04-01-2021, re-hacked a little by sphere 19-11-2021 @@ -723,43 +663,55 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) if (trans >= 10) return; // Don't even draw it if (pfloor->blend) // additive, (reverse) subtractive, modulative - dc_transmap = R_GetBlendTable(pfloor->blend, trans); - else if (!(dc_transmap = R_GetTranslucencyTable(trans)) || trans == 0) + dc->transmap = R_GetBlendTable(pfloor->blend, trans); + else if (!(dc->transmap = R_GetTranslucencyTable(trans)) || trans == 0) fuzzy = false; // Opaque } - - if (fuzzy) - colfunc = fuzzcolfunc; } else if (pfloor->flags & FF_FOG) - colfunc = R_DrawFogColumn_8; + { + R_SetColumnFunc(COLDRAWFUNC_FOG); + fog = true; + } - range = max(ds->x2-ds->x1, 1); + range = std::max(drawseg->x2-drawseg->x1, 1); //SoM: Moved these up here so they are available for my lightlist calculations - rw_scalestep = ds->scalestep; - spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep; + rw_scalestep = drawseg->scalestep; + spryscale = drawseg->scale1 + (x1 - drawseg->x1)*rw_scalestep; - dc_numlights = 0; +#define CLAMPMAX INT32_MAX +#define CLAMPMIN (-INT32_MAX) // This is not INT32_MIN on purpose! INT32_MIN makes the drawers freak out. + auto overflow_clamp = [&](INT64 overflow_test) + { + return (overflow_test > (INT64)CLAMPMAX) ? CLAMPMAX : + (overflow_test > (INT64)CLAMPMIN) ? (fixed_t)overflow_test : + CLAMPMIN; + }; +#undef CLAMPMAX +#undef CLAMPMIN + + dc->numlights = 0; if (frontsector->numlights) { - dc_numlights = frontsector->numlights; - if (dc_numlights > dc_maxlights) + dc->numlights = frontsector->numlights; + + if (dc->numlights > dc->maxlights) { - dc_maxlights = dc_numlights; - dc_lightlist = Z_Realloc(dc_lightlist, sizeof (*dc_lightlist) * dc_maxlights, PU_STATIC, NULL); + dc->maxlights = dc->numlights; + dc->lightlist = static_cast(Z_Frame_Alloc(sizeof (*dc->lightlist) * dc->maxlights)); } - for (i = p = 0; i < dc_numlights; i++) + for (i = p = 0; i < dc->numlights; i++) { fixed_t leftheight, rightheight; fixed_t pfloorleft, pfloorright; INT64 overflow_test; light = &frontsector->lightlist[i]; - rlight = &dc_lightlist[p]; + rlight = &dc->lightlist[p]; #define SLOPEPARAMS(slope, end1, end2, normalheight) \ - end1 = P_GetZAt(slope, ds->leftpos.x, ds->leftpos.y, normalheight); \ - end2 = P_GetZAt(slope, ds->rightpos.x, ds->rightpos.y, normalheight); + end1 = P_GetZAt(slope, drawseg->leftpos.x, drawseg->leftpos.y, normalheight); \ + end2 = P_GetZAt(slope, drawseg->rightpos.x, drawseg->rightpos.y, normalheight); SLOPEPARAMS(light->slope, leftheight, rightheight, light->height) SLOPEPARAMS(*pfloor->b_slope, pfloorleft, pfloorright, *pfloor->bottomheight) @@ -769,31 +721,27 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) SLOPEPARAMS(*pfloor->t_slope, pfloorleft, pfloorright, *pfloor->topheight) - if (leftheight > pfloorleft && rightheight > pfloorright && i+1 < dc_numlights) + if (leftheight > pfloorleft && rightheight > pfloorright && i+1 < dc->numlights) { lightlist_t *nextlight = &frontsector->lightlist[i+1]; - if ((P_GetLightZAt(nextlight, ds->leftpos.x, ds->leftpos.y) > pfloorleft) - && (P_GetLightZAt(nextlight, ds->rightpos.x, ds->rightpos.y) > pfloorright)) + if ((P_GetLightZAt(nextlight, drawseg->leftpos.x, drawseg->leftpos.y) > pfloorleft) + && (P_GetLightZAt(nextlight, drawseg->rightpos.x, drawseg->rightpos.y) > pfloorright)) continue; } leftheight -= viewz; rightheight -= viewz; -#define CLAMPMAX INT32_MAX -#define CLAMPMIN (-INT32_MAX) // This is not INT32_MIN on purpose! INT32_MIN makes the drawers freak out. // Monster Iestyn (25/03/18): do not skip these lights if they fail overflow test, just clamp them instead so they behave. - overflow_test = (INT64)centeryfrac - (((INT64)leftheight*ds->scale1)>>FRACBITS); - if (overflow_test > (INT64)CLAMPMAX) rlight->height = CLAMPMAX; - else if (overflow_test > (INT64)CLAMPMIN) rlight->height = (fixed_t)overflow_test; - else rlight->height = CLAMPMIN; + overflow_test = (INT64)centeryfrac - (((INT64)leftheight*drawseg->scale1)>>FRACBITS); + rlight->height = overflow_clamp(overflow_test); + + overflow_test = (INT64)centeryfrac - (((INT64)rightheight*drawseg->scale2)>>FRACBITS); + rlight->heightstep = overflow_clamp(overflow_test); - overflow_test = (INT64)centeryfrac - (((INT64)rightheight*ds->scale2)>>FRACBITS); - if (overflow_test > (INT64)CLAMPMAX) rlight->heightstep = CLAMPMAX; - else if (overflow_test > (INT64)CLAMPMIN) rlight->heightstep = (fixed_t)overflow_test; - else rlight->heightstep = CLAMPMIN; rlight->heightstep = (rlight->heightstep-rlight->height)/(range); - rlight->flags = light->flags; + rlight->flags = static_cast(light->flags); + if (light->flags & FF_CUTLEVEL) { SLOPEPARAMS(*light->caster->b_slope, leftheight, rightheight, *light->caster->bottomheight) @@ -802,15 +750,12 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) rightheight -= viewz; // Monster Iestyn (25/03/18): do not skip these lights if they fail overflow test, just clamp them instead so they behave. - overflow_test = (INT64)centeryfrac - (((INT64)leftheight*ds->scale1)>>FRACBITS); - if (overflow_test > (INT64)CLAMPMAX) rlight->botheight = CLAMPMAX; - else if (overflow_test > (INT64)CLAMPMIN) rlight->botheight = (fixed_t)overflow_test; - else rlight->botheight = CLAMPMIN; + overflow_test = (INT64)centeryfrac - (((INT64)leftheight*drawseg->scale1)>>FRACBITS); + rlight->botheight = overflow_clamp(overflow_test); + + overflow_test = (INT64)centeryfrac - (((INT64)rightheight*drawseg->scale2)>>FRACBITS); + rlight->botheightstep = overflow_clamp(overflow_test); - overflow_test = (INT64)centeryfrac - (((INT64)rightheight*ds->scale2)>>FRACBITS); - if (overflow_test > (INT64)CLAMPMAX) rlight->botheightstep = CLAMPMAX; - else if (overflow_test > (INT64)CLAMPMIN) rlight->botheightstep = (fixed_t)overflow_test; - else rlight->botheightstep = CLAMPMIN; rlight->botheightstep = (rlight->botheightstep-rlight->botheight)/(range); } @@ -831,16 +776,16 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) p++; } - dc_numlights = p; + dc->numlights = p; } else { // Get correct light level! if ((frontsector->extra_colormap && frontsector->extra_colormap->fog)) lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT); - else if (pfloor->flags & FF_FOG) + else if (fog) lightnum = (pfloor->master->frontsector->lightlevel >> LIGHTSEGSHIFT); - else if (colfunc == fuzzcolfunc) + else if (fuzzy) lightnum = LIGHTLEVELS-1; else lightnum = R_FakeFlat(frontsector, &tempsec, &templight, &templight, false) @@ -859,15 +804,15 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) walllights = scalelight[lightnum]; } - maskedtexturecol = ds->thicksidecol; + maskedtexturecol = drawseg->thicksidecol; - mfloorclip = ds->sprbottomclip; - mceilingclip = ds->sprtopclip; - dc_texheight = textureheight[texnum]>>FRACBITS; + mfloorclip = drawseg->sprbottomclip; + mceilingclip = drawseg->sprtopclip; + dc->texheight = textureheight[texnum]>>FRACBITS; - // calculate both left ends - left_top = P_GetFFloorTopZAt (pfloor, ds->leftpos.x, ds->leftpos.y) - viewz; - left_bottom = P_GetFFloorBottomZAt(pfloor, ds->leftpos.x, ds->leftpos.y) - viewz; + // calculate both left endrawseg + left_top = P_GetFFloorTopZAt (pfloor, drawseg->leftpos.x, drawseg->leftpos.y) - viewz; + left_bottom = P_GetFFloorBottomZAt(pfloor, drawseg->leftpos.x, drawseg->leftpos.y) - viewz; skewslope = *pfloor->t_slope; // skew using top slope by default @@ -880,9 +825,9 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) slopeskew = true; if (slopeskew) - dc_texturemid = left_top; + dc->texturemid = left_top; else - dc_texturemid = *pfloor->topheight - viewz; + dc->texturemid = *pfloor->topheight - viewz; if (newline) { @@ -891,7 +836,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) { skewslope = *pfloor->b_slope; // skew using bottom slope if (slopeskew) - dc_texturemid = left_bottom; + dc->texturemid = left_bottom; else offsetvalue -= *pfloor->topheight - *pfloor->bottomheight; } @@ -903,29 +848,28 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) { skewslope = *pfloor->b_slope; // skew using bottom slope if (slopeskew) - dc_texturemid = left_bottom; + dc->texturemid = left_bottom; else offsetvalue -= *pfloor->topheight - *pfloor->bottomheight; } } - if (slopeskew) + if (slopeskew && skewslope) { angle_t lineangle = R_PointToAngle2(curline->v1->x, curline->v1->y, curline->v2->x, curline->v2->y); - - if (skewslope) - ffloortextureslide = FixedMul(skewslope->zdelta, FINECOSINE((lineangle-skewslope->xydirection)>>ANGLETOFINESHIFT)); + ffloortextureslide = FixedMul(skewslope->zdelta, FINECOSINE((lineangle-skewslope->xydirection)>>ANGLETOFINESHIFT)); } - dc_texturemid += offsetvalue; + dc->texturemid += offsetvalue; // Texture must be cached before setting colfunc_2s, // otherwise texture[texnum]->holes may be false when it shouldn't be R_CheckTextureCache(texnum); + //faB: handle case where multipatch texture is drawn on a 2sided wall, multi-patch textures // are not stored per-column with post info anymore in Doom Legacy if (textures[texnum]->holes) - colfunc_2s = R_DrawRepeatMaskedColumn; //render the usual 2sided single-patch packed texture + colfunc_2s = R_DrawRepeatMaskedColumn; //render the usual 2sided single-patch packed texture else { colfunc_2s = R_Render2sidedMultiPatchColumn; //render multipatch with no holes (no post_t info) @@ -937,229 +881,260 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) fixed_t right_top, right_bottom; // calculate right ends now - right_top = P_GetFFloorTopZAt (pfloor, ds->rightpos.x, ds->rightpos.y) - viewz; - right_bottom = P_GetFFloorBottomZAt(pfloor, ds->rightpos.x, ds->rightpos.y) - viewz; + right_top = P_GetFFloorTopZAt (pfloor, drawseg->rightpos.x, drawseg->rightpos.y) - viewz; + right_bottom = P_GetFFloorBottomZAt(pfloor, drawseg->rightpos.x, drawseg->rightpos.y) - viewz; // using INT64 to avoid 32bit overflow - top_frac = (INT64)centeryfrac - (((INT64)left_top * ds->scale1) >> FRACBITS); - bottom_frac = (INT64)centeryfrac - (((INT64)left_bottom * ds->scale1) >> FRACBITS); - top_step = (INT64)centeryfrac - (((INT64)right_top * ds->scale2) >> FRACBITS); - bottom_step = (INT64)centeryfrac - (((INT64)right_bottom * ds->scale2) >> FRACBITS); + top_frac = (INT64)centeryfrac - (((INT64)left_top * drawseg->scale1) >> FRACBITS); + bottom_frac = (INT64)centeryfrac - (((INT64)left_bottom * drawseg->scale1) >> FRACBITS); + top_step = (INT64)centeryfrac - (((INT64)right_top * drawseg->scale2) >> FRACBITS); + bottom_step = (INT64)centeryfrac - (((INT64)right_bottom * drawseg->scale2) >> FRACBITS); top_step = (top_step-top_frac)/(range); bottom_step = (bottom_step-bottom_frac)/(range); - top_frac += top_step * (x1 - ds->x1); - bottom_frac += bottom_step * (x1 - ds->x1); + top_frac += top_step * (x1 - drawseg->x1); + bottom_frac += bottom_step * (x1 - drawseg->x1); } // draw the columns - for (dc_x = x1; dc_x <= x2; dc_x++) + for (dc->x = x1; dc->x <= x2; dc->x++) { - if (maskedtexturecol[dc_x] == INT16_MAX) + if (maskedtexturecol[dc->x] == INT16_MAX) continue; + // skew FOF walls + if (ffloortextureslide) { - if (ffloortextureslide) { // skew FOF walls - if (oldx != -1) - dc_texturemid += FixedMul(ffloortextureslide, (maskedtexturecol[oldx]-maskedtexturecol[dc_x])<texturemid += FixedMul(ffloortextureslide, (maskedtexturecol[oldx]-maskedtexturecol[dc->x])<x; + } - if (top_frac > (INT64)CLAMPMAX) sprtopscreen = windowtop = CLAMPMAX; - else if (top_frac > (INT64)CLAMPMIN) sprtopscreen = windowtop = (fixed_t)top_frac; - else sprtopscreen = windowtop = CLAMPMIN; - if (bottom_frac > (INT64)CLAMPMAX) sprbotscreen = windowbottom = CLAMPMAX; - else if (bottom_frac > (INT64)CLAMPMIN) sprbotscreen = windowbottom = (fixed_t)bottom_frac; - else sprbotscreen = windowbottom = CLAMPMIN; + // Calculate bounds + // clamp the values if necessary to avoid overflows and rendering glitches caused by them + sprtopscreen = windowtop = overflow_clamp(top_frac); + sprbotscreen = windowbottom = overflow_clamp(bottom_frac); - top_frac += top_step; - bottom_frac += bottom_step; + top_frac += top_step; + bottom_frac += bottom_step; - // SoM: If column is out of range, why bother with it?? - if (windowbottom < topbounds || windowtop > bottombounds) + // SoM: If column is out of range, why bother with it?? + if (windowbottom < topbounds || windowtop > bottombounds) + { + if (dc->numlights) { - if (dc_numlights) + for (i = 0; i < dc->numlights; i++) { - for (i = 0; i < dc_numlights; i++) - { - rlight = &dc_lightlist[i]; - rlight->height += rlight->heightstep; - if (rlight->flags & FF_CUTLEVEL) - rlight->botheight += rlight->botheightstep; - } + rlight = &dc->lightlist[i]; + rlight->height += rlight->heightstep; + if (rlight->flags & FF_CUTLEVEL) + rlight->botheight += rlight->botheightstep; } - spryscale += rw_scalestep; - continue; } - dc_iscale = 0xffffffffu / (unsigned)spryscale; + spryscale += rw_scalestep; + continue; + } - // Get data for the column - col = (column_t *)((UINT8 *)R_GetColumn(texnum,maskedtexturecol[dc_x]) - 3); + // Get data for the column + col = (column_t *)((UINT8 *)R_GetColumn(texnum, maskedtexturecol[dc->x]) - 3); - // SoM: New code does not rely on R_DrawColumnShadowed_8 which - // will (hopefully) put less strain on the stack. - if (dc_numlights) + if (!fog) + { + dc->iscale = 0xffffffffu / (unsigned)spryscale; + + if (fuzzy) + R_SetColumnFunc(COLDRAWFUNC_FUZZY); + else + R_SetColumnFunc(BASEDRAWFUNC); + } + + // SoM: New code does not rely on R_DrawColumnShadowed which + // will (hopefully) put less strain on the stack. + if (dc->numlights) + { + lighttable_t **xwalllights; + fixed_t height; + fixed_t bheight = 0; + INT32 solid = 0; + + auto set_light_vars = [&](INT32 k) { - lighttable_t **xwalllights; - fixed_t height; - fixed_t bheight = 0; - INT32 solid = 0; - INT32 lighteffect = 0; + rlight = &dc->lightlist[k]; - for (i = 0; i < dc_numlights; i++) + lightnum = rlight->lightnum; + + if (lightnum < 0) + xwalllights = scalelight[0]; + else if (lightnum >= LIGHTLEVELS) + xwalllights = scalelight[LIGHTLEVELS-1]; + else + xwalllights = scalelight[lightnum]; + + pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; + + if (pindex >= MAXLIGHTSCALE) + pindex = MAXLIGHTSCALE-1; + + if (pfloor->flags & FF_FOG) { - // Check if the current light effects the colormap/lightlevel - rlight = &dc_lightlist[i]; - lighteffect = !(dc_lightlist[i].flags & FF_NOSHADE); + if (pfloor->master->frontsector->extra_colormap) + rlight->rcolormap = pfloor->master->frontsector->extra_colormap->colormap + (xwalllights[pindex] - colormaps); + else + rlight->rcolormap = xwalllights[pindex]; + } + else + { + if (rlight->extra_colormap) + rlight->rcolormap = rlight->extra_colormap->colormap + (xwalllights[pindex] - colormaps); + else + rlight->rcolormap = xwalllights[pindex]; + } + }; - if (lighteffect) + auto set_colormap_below_light = [&] + { + dc->colormap = rlight->rcolormap; + if (encoremap && !(curline->linedef->flags & ML_TFERLINE)) + dc->colormap += COLORMAP_REMAPOFFSET; + }; + + // Use the base sector's light level above the first FOF. + // You can imagine it as the sky casting its light on top of the highest FOF. + set_light_vars(0); + set_colormap_below_light(); + + for (i = 0; i < dc->numlights; i++) + { + // Check if the current light effects the colormap/lightlevel + rlight = &dc->lightlist[i]; + xwalllights = NULL; + + if (!(dc->lightlist[i].flags & FF_NOSHADE)) + set_light_vars(i); + + solid = 0; // don't carry over solid-cutting flag from the previous light + + // Check if the current light can cut the current 3D floor. + if (rlight->flags & FF_CUTSOLIDS && !(pfloor->flags & FF_EXTRA)) + { + solid = 1; + } + else if (rlight->flags & FF_CUTEXTRA && pfloor->flags & FF_EXTRA) + { + if (rlight->flags & FF_EXTRA) { - lightnum = rlight->lightnum; - - if (lightnum < 0) - xwalllights = scalelight[0]; - else if (lightnum >= LIGHTLEVELS) - xwalllights = scalelight[LIGHTLEVELS-1]; - else - xwalllights = scalelight[lightnum]; - - pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; - - if (pindex >= MAXLIGHTSCALE) - pindex = MAXLIGHTSCALE-1; - - if (pfloor->flags & FF_FOG) - { - if (pfloor->master->frontsector->extra_colormap) - rlight->rcolormap = pfloor->master->frontsector->extra_colormap->colormap + (xwalllights[pindex] - colormaps); - else - rlight->rcolormap = xwalllights[pindex]; - } - else - { - if (rlight->extra_colormap) - rlight->rcolormap = rlight->extra_colormap->colormap + (xwalllights[pindex] - colormaps); - else - rlight->rcolormap = xwalllights[pindex]; - } - } - - solid = 0; // don't carry over solid-cutting flag from the previous light - - // Check if the current light can cut the current 3D floor. - if (rlight->flags & FF_CUTSOLIDS && !(pfloor->flags & FF_EXTRA)) - solid = 1; - else if (rlight->flags & FF_CUTEXTRA && pfloor->flags & FF_EXTRA) - { - if (rlight->flags & FF_EXTRA) - { - // The light is from an extra 3D floor... Check the flags so - // there are no undesired cuts. - if ((rlight->flags & (FF_FOG|FF_SWIMMABLE)) == (pfloor->flags & (FF_FOG|FF_SWIMMABLE))) - solid = 1; - } - else + // The light is from an extra 3D floor... Check the flags so + // there are no undesired cuts. + if ((rlight->flags & (FF_FOG|FF_SWIMMABLE)) == (pfloor->flags & (FF_FOG|FF_SWIMMABLE))) solid = 1; } else - solid = 0; - - height = rlight->height; - rlight->height += rlight->heightstep; - - if (solid) - { - bheight = rlight->botheight - (FRACUNIT >> 1); - rlight->botheight += rlight->botheightstep; - } - - if (height <= windowtop) - { - if (lighteffect) - { - dc_colormap = rlight->rcolormap; - if (encoremap && !(curline->linedef->flags & ML_TFERLINE)) - dc_colormap += COLORMAP_REMAPOFFSET; - } - if (solid && windowtop < bheight) - windowtop = bheight; - continue; - } - - windowbottom = height; - if (windowbottom >= sprbotscreen) - { - windowbottom = sprbotscreen; - // draw the texture - colfunc_2s (col); - for (i++; i < dc_numlights; i++) - { - rlight = &dc_lightlist[i]; - rlight->height += rlight->heightstep; - if (rlight->flags & FF_CUTLEVEL) - rlight->botheight += rlight->botheightstep; - } - continue; - } - // draw the texture - colfunc_2s (col); - if (solid) - windowtop = bheight; - else - windowtop = windowbottom + 1; - if (lighteffect) - { - dc_colormap = rlight->rcolormap; - if (encoremap && !(curline->linedef->flags & ML_TFERLINE)) - dc_colormap += COLORMAP_REMAPOFFSET; - } + solid = 1; } - windowbottom = sprbotscreen; - // draw the texture, if there is any space left - if (windowtop < windowbottom) - colfunc_2s (col); + else + solid = 0; - spryscale += rw_scalestep; - continue; + height = rlight->height; + rlight->height += rlight->heightstep; + + if (solid) + { + bheight = rlight->botheight - (FRACUNIT >> 1); + rlight->botheight += rlight->botheightstep; + } + + if (height <= windowtop) + { + if (xwalllights) + { + set_colormap_below_light(); + } + + if (solid && windowtop < bheight) + { + windowtop = bheight; + } + + continue; + } + + windowbottom = height; + if (windowbottom >= sprbotscreen) + { + windowbottom = sprbotscreen; + + // draw the texture + colfunc_2s (dc, col); + for (i++; i < dc->numlights; i++) + { + rlight = &dc->lightlist[i]; + rlight->height += rlight->heightstep; + + if (rlight->flags & FF_CUTLEVEL) + rlight->botheight += rlight->botheightstep; + } + + continue; + } + + // draw the texture + colfunc_2s (dc, col); + + if (solid) + windowtop = bheight; + else + windowtop = windowbottom + 1; + + if (xwalllights) + { + set_colormap_below_light(); + } } - // calculate lighting - pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; + windowbottom = sprbotscreen; - if (pindex >= MAXLIGHTSCALE) - pindex = MAXLIGHTSCALE - 1; + // draw the texture, if there is any space left + if (windowtop < windowbottom) + { + colfunc_2s (dc, col); + } - dc_colormap = walllights[pindex]; - - if (encoremap && !(curline->linedef->flags & ML_TFERLINE)) - dc_colormap += COLORMAP_REMAPOFFSET; - - if (pfloor->flags & FF_FOG && pfloor->master->frontsector->extra_colormap) - dc_colormap = pfloor->master->frontsector->extra_colormap->colormap + (dc_colormap - colormaps); - else if (frontsector->extra_colormap) - dc_colormap = frontsector->extra_colormap->colormap + (dc_colormap - colormaps); - - // draw the texture - colfunc_2s (col); spryscale += rw_scalestep; + continue; } - } - colfunc = wallcolfunc; -#undef CLAMPMAX -#undef CLAMPMIN + // calculate lighting + pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; + + if (pindex >= MAXLIGHTSCALE) + pindex = MAXLIGHTSCALE - 1; + + dc->colormap = walllights[pindex]; + + if (encoremap && !(curline->linedef->flags & ML_TFERLINE)) + dc->colormap += COLORMAP_REMAPOFFSET; + + if (pfloor->flags & FF_FOG && pfloor->master->frontsector->extra_colormap) + dc->colormap = pfloor->master->frontsector->extra_colormap->colormap + (dc->colormap - colormaps); + else if (frontsector->extra_colormap) + dc->colormap = frontsector->extra_colormap->colormap + (dc->colormap - colormaps); + + // draw the texture + colfunc_2s (dc, col); + spryscale += rw_scalestep; + } + + R_SetColumnFunc(BASEDRAWFUNC); } // R_FFloorCanClip // // Returns true if a fake floor can clip a column away. -static boolean R_FFloorCanClip(visffloor_t *pfloor) +static inline boolean R_FFloorCanClip(visffloor_t *pfloor) { - return (cv_ffloorclip.value && !R_IsFFloorTranslucent(pfloor) && !pfloor->polyobj); + return (cv_ffloorclip.value && !R_IsFFloorTranslucent(pfloor)); } // R_ExpandPlaneY @@ -1182,10 +1157,28 @@ static inline void R_ExpandPlaneY(visplane_t *pl, INT32 x, INT16 top, INT16 bott // textures. // CALLED: CORE LOOPING ROUTINE. // -#define HEIGHTBITS 12 -#define HEIGHTUNIT (1<yl = yl; + dc->yh = yh; + dc->texturemid = mid; + dc->source = R_GetColumn(texture, texturecolumn); + dc->texheight = textureheight[texture] >> FRACBITS; + dc->sourcelength = dc->texheight; + R_SetColumnFunc(colfunctype); + coldrawfunc_t* colfunccopy = colfunc; + drawcolumndata_t dc_copy = *dc; + if (remap) + { + dc_copy.colormap += COLORMAP_REMAPOFFSET; + } + colfunccopy(const_cast(&dc_copy)); +} + +static boolean didsolidcol; // True if at least one column was marked solid + +static void R_RenderSegLoop(drawcolumndata_t* dc) { angle_t angle; size_t pindex; @@ -1199,6 +1192,7 @@ static void R_RenderSegLoop (void) INT32 bottom; INT32 i; + // Loop over width for (; rw_x < rw_stopx; rw_x++) { // mark floor / ceiling areas @@ -1266,11 +1260,12 @@ static void R_RenderSegLoop (void) bottom_w = bottom; // Polyobject-specific hack to fix plane leaking -Red - if (ffloor[i].polyobj && top_w >= bottom_w) { - ffloor[i].plane->top[rw_x] = ffloor[i].plane->bottom[rw_x] = 0xFFFF; - } else - - if (top_w <= bottom_w) + if (ffloor[i].polyobj && top_w >= bottom_w) + { + ffloor[i].plane->top[rw_x] = 0xFFFF; + ffloor[i].plane->bottom[rw_x] = 0x0000; // fix for sky plane drawing crashes - Monster Iestyn 25/05/18 + } + else if (top_w <= bottom_w) { fftop = (INT16)top_w; ffbottom = (INT16)bottom_w; @@ -1284,6 +1279,7 @@ static void R_RenderSegLoop (void) { rw_floormarked = true; floorclip[rw_x] = fftop; + if (yh > fftop) yh = fftop; @@ -1310,11 +1306,12 @@ static void R_RenderSegLoop (void) bottom_w = bottom; // Polyobject-specific hack to fix plane leaking -Red - if (ffloor[i].polyobj && top_w >= bottom_w) { - ffloor[i].plane->top[rw_x] = ffloor[i].plane->bottom[rw_x] = 0xFFFF; - } else - - if (top_w <= bottom_w) + if (ffloor[i].polyobj && top_w >= bottom_w) + { + ffloor[i].plane->top[rw_x] = 0xFFFF; + ffloor[i].plane->bottom[rw_x] = 0x0000; // fix for sky plane drawing crashes - Monster Iestyn 25/05/18 + } + else if (top_w <= bottom_w) { fftop = (INT16)top_w; ffbottom = (INT16)bottom_w; @@ -1328,6 +1325,7 @@ static void R_RenderSegLoop (void) { rw_ceilingmarked = true; ceilingclip[rw_x] = ffbottom; + if (yl < ffbottom) yl = ffbottom; @@ -1351,7 +1349,8 @@ static void R_RenderSegLoop (void) // Mask 4095 to guarantee this index is within bounds texturecolumn = rw_offset-FixedMul(FINETANGENT(angle & 4095),rw_distance); - if (oldtexturecolumn != -1) { + if (oldtexturecolumn != -1) + { rw_bottomtexturemid += FixedMul(rw_bottomtextureslide, oldtexturecolumn-texturecolumn); rw_midtexturemid += FixedMul(rw_midtextureslide, oldtexturecolumn-texturecolumn); rw_toptexturemid += FixedMul(rw_toptextureslide, oldtexturecolumn-texturecolumn); @@ -1370,25 +1369,25 @@ static void R_RenderSegLoop (void) if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE-1; - dc_colormap = walllights[pindex]; - if (encoremap && !(curline->linedef->flags & ML_TFERLINE)) - dc_colormap += COLORMAP_REMAPOFFSET; - dc_x = rw_x; - dc_iscale = 0xffffffffu / (unsigned)rw_scale; + dc->colormap = walllights[pindex]; + + dc->x = rw_x; + dc->iscale = 0xffffffffu / (unsigned)rw_scale; if (frontsector->extra_colormap) - dc_colormap = frontsector->extra_colormap->colormap + (dc_colormap - colormaps); + dc->colormap = frontsector->extra_colormap->colormap + (dc->colormap - colormaps); } - if (dc_numlights) + if (dc->numlights) { lighttable_t **xwalllights; - for (i = 0; i < dc_numlights; i++) + + for (i = 0; i < dc->numlights; i++) { INT32 lightnum; - lightnum = (dc_lightlist[i].lightlevel >> LIGHTSEGSHIFT); + lightnum = (dc->lightlist[i].lightlevel >> LIGHTSEGSHIFT); - if (dc_lightlist[i].extra_colormap) + if (dc->lightlist[i].extra_colormap) ; else if (P_ApplyLightOffset(lightnum, curline->frontsector)) lightnum += curline->lightOffset; @@ -1405,30 +1404,27 @@ static void R_RenderSegLoop (void) if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE-1; - if (dc_lightlist[i].extra_colormap) - dc_lightlist[i].rcolormap = dc_lightlist[i].extra_colormap->colormap + (xwalllights[pindex] - colormaps); + if (dc->lightlist[i].extra_colormap) + dc->lightlist[i].rcolormap = dc->lightlist[i].extra_colormap->colormap + (xwalllights[pindex] - colormaps); else - dc_lightlist[i].rcolormap = xwalllights[pindex]; + dc->lightlist[i].rcolormap = xwalllights[pindex]; - colfunc = R_DrawColumnShadowed_8; + R_SetColumnFunc(COLDRAWFUNC_SHADOWED); } } frontscale[rw_x] = rw_scale; + const INT16 topclip = (yl >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1; + const INT16 bottomclip = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight; + // draw the wall tiers if (midtexture) { // single sided line if (yl <= yh && yh >= 0 && yl < viewheight) { - dc_yl = yl; - dc_yh = yh; - dc_texturemid = rw_midtexturemid; - dc_source = R_GetColumn(midtexture,texturecolumn); - dc_texheight = textureheight[midtexture]>>FRACBITS; - dc_sourcelength = dc_texheight; - colfunc(); + R_DrawWallColumn(dc, yl, yh, rw_midtexturemid, texturecolumn, midtexture, midremap); // dont draw anything more for this column, since // a midtexture blocks the view @@ -1441,16 +1437,13 @@ static void R_RenderSegLoop (void) { // note: don't use min/max macros, since casting from INT32 to INT16 is involved here if (markceiling && (!rw_ceilingmarked)) - ceilingclip[rw_x] = (yl >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1; + ceilingclip[rw_x] = topclip; if (markfloor && (!rw_floormarked)) - floorclip[rw_x] = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight; + floorclip[rw_x] = bottomclip; } } else { - INT16 topclip = (yl >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1; - INT16 bottomclip = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight; - // two sided line if (toptexture) { @@ -1470,13 +1463,7 @@ static void R_RenderSegLoop (void) } else if (mid >= 0) // safe to draw top texture { - dc_yl = yl; - dc_yh = mid; - dc_texturemid = rw_toptexturemid; - dc_source = R_GetColumn(toptexture,texturecolumn); - dc_texheight = textureheight[toptexture]>>FRACBITS; - dc_sourcelength = dc_texheight; - colfunc(); + R_DrawWallColumn(dc, yl, mid, rw_toptexturemid, texturecolumn, toptexture, topremap); ceilingclip[rw_x] = (INT16)mid; } else if (!rw_ceilingmarked) // entirely off top of screen @@ -1507,14 +1494,7 @@ static void R_RenderSegLoop (void) } else if (mid < viewheight) // safe to draw bottom texture { - dc_yl = mid; - dc_yh = yh; - dc_texturemid = rw_bottomtexturemid; - dc_source = R_GetColumn(bottomtexture, - texturecolumn); - dc_texheight = textureheight[bottomtexture]>>FRACBITS; - dc_sourcelength = dc_texheight; - colfunc(); + R_DrawWallColumn(dc, mid, yh, rw_bottomtexturemid, texturecolumn, bottomtexture, bottomremap); floorclip[rw_x] = (INT16)mid; } else if (!rw_floormarked) // entirely off bottom of screen @@ -1527,25 +1507,33 @@ static void R_RenderSegLoop (void) floorclip[rw_x] = bottomclip; } + if ((markceiling || markfloor) && (floorclip[rw_x] <= ceilingclip[rw_x] + 1)) + { + solidcol[rw_x] = 1; + didsolidcol = true; + } + if (maskedtexture || numthicksides) { // save texturecol for backdrawing of masked mid texture maskedtexturecol[rw_x] = (INT16)texturecolumn; - if (maskedtextureheight != NULL) { + if (maskedtextureheight != NULL) + { maskedtextureheight[rw_x] = (!!(curline->linedef->flags & ML_DONTPEGBOTTOM) ^ !!(curline->linedef->flags & ML_EFFECT3) ? - max(rw_midtexturemid, rw_midtextureback) : - min(rw_midtexturemid, rw_midtextureback)); + std::max(rw_midtexturemid, rw_midtextureback) : + std::min(rw_midtexturemid, rw_midtextureback)); } } - if (dc_numlights) + if (dc->numlights) { - for (i = 0; i < dc_numlights; i++) + for (i = 0; i < dc->numlights; i++) { - dc_lightlist[i].height += dc_lightlist[i].heightstep; - if (dc_lightlist[i].flags & FF_CUTSOLIDS) - dc_lightlist[i].botheight += dc_lightlist[i].botheightstep; + dc->lightlist[i].height += dc->lightlist[i].heightstep; + + if (dc->lightlist[i].flags & FF_CUTSOLIDS) + dc->lightlist[i].botheight += dc->lightlist[i].botheightstep; } } @@ -1570,8 +1558,75 @@ static void R_RenderSegLoop (void) topfrac += topstep; bottomfrac += bottomstep; } +} - //colfunc = wallcolfunc; +static void R_MarkSegBounds(void) +{ + INT32 yl, yh; + INT32 top, bottom; + INT16 topclip, bottomclip; + + // Loop over width + for (; rw_x < rw_stopx; rw_x++) + { + // mark floor / ceiling areas + yl = (topfrac+HEIGHTUNIT-1)>>HEIGHTBITS; + + // no space above wall? + top = ceilingclip[rw_x]+1; + + // no space above wall? + if (yl < top) + yl = top; + + if (markceiling) + { + bottom = yl > floorclip[rw_x] ? floorclip[rw_x] : yl; + + if (top <= --bottom && ceilingplane) + { + R_ExpandPlaneY(ceilingplane, rw_x, top, bottom); + } + } + + yh = bottomfrac>>HEIGHTBITS; + + bottom = floorclip[rw_x]-1; + + if (yh > bottom) + yh = bottom; + + if (markfloor) + { + top = yh < ceilingclip[rw_x] ? ceilingclip[rw_x] : yh; + + if (++top <= bottom && floorplane) + { + R_ExpandPlaneY(floorplane, rw_x, top, bottom); + } + } + + frontscale[rw_x] = rw_scale; + + topclip = (yl >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1; + bottomclip = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight; + + if (markceiling) // no top wall + ceilingclip[rw_x] = topclip; + + if (markfloor) // no bottom wall + floorclip[rw_x] = bottomclip; + + if (floorclip[rw_x] <= ceilingclip[rw_x] + 1) + { + solidcol[rw_x] = 1; + didsolidcol = true; + } + + rw_scale += rw_scalestep; + topfrac += topstep; + bottomfrac += bottomstep; + } } // Uses precalculated seg->length @@ -1591,6 +1646,33 @@ static INT64 R_CalcSegDist(seg_t* seg, INT64 x2, INT64 y2) } } +static size_t maxdrawsegs = 0; + +static fixed_t *frontscaletable = NULL; +static fixed_t *maskedheighttable = NULL; + +void R_AllocSegMemory(void) +{ + if (!maxdrawsegs) + return; + + frontscaletable = static_cast(Z_Realloc(frontscaletable, sizeof(*frontscaletable) * (maxdrawsegs * viewwidth), PU_STATIC, NULL)); + maskedheighttable = static_cast(Z_Realloc(maskedheighttable, sizeof(*maskedheighttable) * (maxdrawsegs * viewwidth), PU_STATIC, NULL)); + + drawseg_t *lastseg = drawsegs + maxdrawsegs; + + fixed_t *frontscale_p = frontscaletable; + fixed_t *maskedheight_p = maskedheighttable; + + for (drawseg_t *ds = drawsegs; ds < lastseg; ds++) + { + ds->frontscale = frontscale_p; + ds->maskedtextureheight = maskedheight_p; + frontscale_p += viewwidth; + maskedheight_p += viewwidth; + } +} + // // R_StoreWallRange // A wall segment will be drawn @@ -1609,7 +1691,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) INT32 range; vertex_t segleft, segright; fixed_t ceilingfrontslide, floorfrontslide, ceilingbackslide, floorbackslide; - static size_t maxdrawsegs = 0; + drawcolumndata_t dc = {}; maskedtextureheight = NULL; //initialize segleft and segright @@ -1618,15 +1700,24 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (ds_p == drawsegs+maxdrawsegs) { + size_t curpos = curdrawsegs - drawsegs; size_t pos = ds_p - drawsegs; size_t newmax = maxdrawsegs ? maxdrawsegs*2 : 128; + if (firstseg) firstseg = (drawseg_t *)(firstseg - drawsegs); - drawsegs = Z_Realloc(drawsegs, newmax*sizeof (*drawsegs), PU_STATIC, NULL); + + drawsegs = static_cast(Z_Realloc(drawsegs, newmax*sizeof (*drawsegs), PU_STATIC, NULL)); + ds_p = drawsegs + pos; + maxdrawsegs = newmax; + curdrawsegs = drawsegs + curpos; + if (firstseg) firstseg = drawsegs + (size_t)firstseg; + + R_AllocSegMemory(); } sidedef = curline->sidedef; @@ -1659,6 +1750,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) { size_t pos = lastopening - openings; size_t need = (rw_stopx - start)*4 + pos; + if (need > maxopenings) { drawseg_t *ds; //needed for fix from *cough* zdoom *cough* @@ -1668,7 +1760,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) do maxopenings = maxopenings ? maxopenings*2 : 16384; while (need > maxopenings); - openings = Z_Realloc(openings, maxopenings * sizeof (*openings), PU_STATIC, NULL); + openings = static_cast(Z_Realloc(openings, maxopenings * sizeof (*openings), PU_STATIC, NULL)); lastopening = openings + pos; if (oldopenings == NULL) @@ -1679,7 +1771,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) // were already stored in drawsegs. for (ds = drawsegs; ds < ds_p; ds++) { -#define ADJUST(p) if (ds->p + ds->x1 >= oldopenings && ds->p + ds->x1 <= oldlast) ds->p = ds->p - oldopenings + openings; +#define ADJUST(p) if (ds->p + ds->x1 >= oldopenings && ds->p + ds->x1 <= oldlast) ds->p = (ds->p - oldopenings) + openings; ADJUST(maskedtexturecol); ADJUST(sprtopclip); ADJUST(sprbottomclip); @@ -1727,57 +1819,38 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (frontsector->hasslope || (backsector && backsector->hasslope)) // Commenting this out for FOFslop. -Red { angle_t temp; + double a1, b1, c1, a2, b2, c2, det; // 1 is the seg, 2 is the view angle vector... // left temp = xtoviewangle[start]+viewangle; -#define FIXED_TO_DOUBLE(x) (((double)(x)) / ((double)FRACUNIT)) -#define DOUBLE_TO_FIXED(x) (fixed_t)((x) * ((double)FRACUNIT)) + a1 = FixedToDouble(curline->v2->y-curline->v1->y); + b1 = FixedToDouble(curline->v1->x-curline->v2->x); + c1 = a1*FixedToDouble(curline->v1->x) + b1*FixedToDouble(curline->v1->y); - { - // Both lines can be written in slope-intercept form, so figure out line intersection - double a1, b1, c1, a2, b2, c2, det; // 1 is the seg, 2 is the view angle vector... - ///TODO: convert to fixed point + // Both lines can be written in slope-intercept form, so figure out line intersection - a1 = FIXED_TO_DOUBLE(curline->v2->y-curline->v1->y); - b1 = FIXED_TO_DOUBLE(curline->v1->x-curline->v2->x); - c1 = a1*FIXED_TO_DOUBLE(curline->v1->x) + b1*FIXED_TO_DOUBLE(curline->v1->y); + // left + a2 = -FixedToDouble(FINESINE(temp>>ANGLETOFINESHIFT)); + b2 = FixedToDouble(FINECOSINE(temp>>ANGLETOFINESHIFT)); + c2 = a2*FixedToDouble(viewx) + b2*FixedToDouble(viewy); - a2 = -FIXED_TO_DOUBLE(FINESINE(temp>>ANGLETOFINESHIFT)); - b2 = FIXED_TO_DOUBLE(FINECOSINE(temp>>ANGLETOFINESHIFT)); - c2 = a2*FIXED_TO_DOUBLE(viewx) + b2*FIXED_TO_DOUBLE(viewy); + det = a1*b2 - a2*b1; - det = a1*b2 - a2*b1; - - ds_p->leftpos.x = segleft.x = DOUBLE_TO_FIXED((b2*c1 - b1*c2)/det); - ds_p->leftpos.y = segleft.y = DOUBLE_TO_FIXED((a1*c2 - a2*c1)/det); - } + ds_p->leftpos.x = segleft.x = DoubleToFixed((b2*c1 - b1*c2)/det); + ds_p->leftpos.y = segleft.y = DoubleToFixed((a1*c2 - a2*c1)/det); // right temp = xtoviewangle[stop]+viewangle; - { - // Both lines can be written in slope-intercept form, so figure out line intersection - double a1, b1, c1, a2, b2, c2, det; // 1 is the seg, 2 is the view angle vector... - ///TODO: convert to fixed point + a2 = -FixedToDouble(FINESINE(temp>>ANGLETOFINESHIFT)); + b2 = FixedToDouble(FINECOSINE(temp>>ANGLETOFINESHIFT)); + c2 = a2*FixedToDouble(viewx) + b2*FixedToDouble(viewy); - a1 = FIXED_TO_DOUBLE(curline->v2->y-curline->v1->y); - b1 = FIXED_TO_DOUBLE(curline->v1->x-curline->v2->x); - c1 = a1*FIXED_TO_DOUBLE(curline->v1->x) + b1*FIXED_TO_DOUBLE(curline->v1->y); - - a2 = -FIXED_TO_DOUBLE(FINESINE(temp>>ANGLETOFINESHIFT)); - b2 = FIXED_TO_DOUBLE(FINECOSINE(temp>>ANGLETOFINESHIFT)); - c2 = a2*FIXED_TO_DOUBLE(viewx) + b2*FIXED_TO_DOUBLE(viewy); - - det = a1*b2 - a2*b1; - - ds_p->rightpos.x = segright.x = DOUBLE_TO_FIXED((b2*c1 - b1*c2)/det); - ds_p->rightpos.y = segright.y = DOUBLE_TO_FIXED((a1*c2 - a2*c1)/det); - } - -#undef FIXED_TO_DOUBLE -#undef DOUBLE_TO_FIXED + det = a1*b2 - a2*b1; + ds_p->rightpos.x = segright.x = DoubleToFixed((b2*c1 - b1*c2)/det); + ds_p->rightpos.y = segright.y = DoubleToFixed((a1*c2 - a2*c1)/det); } #define SLOPEPARAMS(slope, end1, end2, normalheight) \ @@ -1794,6 +1867,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) worldbottomslope -= viewz; midtexture = toptexture = bottomtexture = maskedtexture = 0; + midremap = topremap = bottomremap = false; ds_p->maskedtexturecol = NULL; ds_p->numthicksides = numthicksides = 0; ds_p->thicksidecol = NULL; @@ -1820,28 +1894,38 @@ void R_StoreWallRange(INT32 start, INT32 stop) rw_toptextureslide = rw_midtextureslide = rw_bottomtextureslide = 0; ceilingfrontslide = floorfrontslide = ceilingbackslide = floorbackslide = 0; - angle_t lineangle = R_PointToAngle2(curline->v1->x, curline->v1->y, curline->v2->x, curline->v2->y); + if (backsector || frontsector->f_slope || frontsector->c_slope) + { + angle_t lineangle = R_PointToAngle2(curline->v1->x, curline->v1->y, curline->v2->x, curline->v2->y); - if (frontsector->f_slope) - floorfrontslide = FixedMul(frontsector->f_slope->zdelta, FINECOSINE((lineangle-frontsector->f_slope->xydirection)>>ANGLETOFINESHIFT)); + if (frontsector->f_slope) + floorfrontslide = FixedMul(frontsector->f_slope->zdelta, FINECOSINE((lineangle-frontsector->f_slope->xydirection)>>ANGLETOFINESHIFT)); - if (frontsector->c_slope) - ceilingfrontslide = FixedMul(frontsector->c_slope->zdelta, FINECOSINE((lineangle-frontsector->c_slope->xydirection)>>ANGLETOFINESHIFT)); + if (frontsector->c_slope) + ceilingfrontslide = FixedMul(frontsector->c_slope->zdelta, FINECOSINE((lineangle-frontsector->c_slope->xydirection)>>ANGLETOFINESHIFT)); - if (backsector && backsector->f_slope) - floorbackslide = FixedMul(backsector->f_slope->zdelta, FINECOSINE((lineangle-backsector->f_slope->xydirection)>>ANGLETOFINESHIFT)); + if (backsector) + { + if (backsector->f_slope) + floorbackslide = FixedMul(backsector->f_slope->zdelta, FINECOSINE((lineangle-backsector->f_slope->xydirection)>>ANGLETOFINESHIFT)); - if (backsector && backsector->c_slope) - ceilingbackslide = FixedMul(backsector->c_slope->zdelta, FINECOSINE((lineangle-backsector->c_slope->xydirection)>>ANGLETOFINESHIFT)); + if (backsector->c_slope) + ceilingbackslide = FixedMul(backsector->c_slope->zdelta, FINECOSINE((lineangle-backsector->c_slope->xydirection)>>ANGLETOFINESHIFT)); + } + } if (!backsector) { fixed_t texheight; + // single sided line midtexture = R_GetTextureNum(sidedef->midtexture); + midremap = (encoremap && !(curline->linedef->flags & ML_TFERLINE)); texheight = textureheight[midtexture]; + // a single sided line is terminal, so it must mark ends markfloor = markceiling = true; + if (linedef->flags & ML_EFFECT2) { if (linedef->flags & ML_DONTPEGBOTTOM) @@ -1871,6 +1955,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) else { // two sided line + boolean bothceilingssky = false; // turned on if both back and front ceilings are sky + SLOPEPARAMS(backsector->c_slope, worldhigh, worldhighslope, backsector->ceilingheight) SLOPEPARAMS(backsector->f_slope, worldlow, worldlowslope, backsector->floorheight) worldhigh -= viewz; @@ -1885,6 +1971,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) { worldtopslope = worldhighslope = worldtop = worldhigh; + + bothceilingssky = true; } ds_p->sprtopclip = ds_p->sprbottomclip = NULL; @@ -1905,18 +1993,22 @@ void R_StoreWallRange(INT32 start, INT32 stop) // ds_p->sprbottomclip = negonearray; } - if (worldtopslope < worldhighslope || worldtop < worldhigh) + if (!bothceilingssky) { - ds_p->silhouette |= SIL_TOP; - if (P_GetSectorCeilingZAt(backsector, viewx, viewy) < viewz) + if (worldtopslope < worldhighslope || worldtop < worldhigh) + { + ds_p->silhouette |= SIL_TOP; + if (P_GetSectorCeilingZAt(backsector, viewx, viewy) < viewz) + ds_p->tsilheight = INT32_MIN; + else + ds_p->tsilheight = (frontsector->c_slope ? INT32_MIN : frontsector->ceilingheight); + } + else if (P_GetSectorCeilingZAt(backsector, viewx, viewy) < viewz) + { + ds_p->silhouette |= SIL_TOP; ds_p->tsilheight = INT32_MIN; - else - ds_p->tsilheight = (frontsector->c_slope ? INT32_MIN : frontsector->ceilingheight); - } - else if (P_GetSectorCeilingZAt(backsector, viewx, viewy) < viewz) - { - ds_p->silhouette |= SIL_TOP; - ds_p->tsilheight = INT32_MIN; + // ds_p->sprtopclip = screenheightarray; + } } if (viewsector != frontsector && viewsector != backsector) @@ -1941,18 +2033,18 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (worldlow != worldbottom || worldlowslope != worldbottomslope || backsector->f_slope != frontsector->f_slope - || backsector->floorpic != frontsector->floorpic - || backsector->lightlevel != frontsector->lightlevel - //SoM: 3/22/2000: Check floor x and y offsets. - || backsector->floor_xoffs != frontsector->floor_xoffs - || backsector->floor_yoffs != frontsector->floor_yoffs - || backsector->floorpic_angle != frontsector->floorpic_angle - //SoM: 3/22/2000: Prevents bleeding. - || frontsector->heightsec != -1 - || backsector->floorlightsec != frontsector->floorlightsec - //SoM: 4/3/2000: Check for colormaps - || frontsector->extra_colormap != backsector->extra_colormap - || (frontsector->ffloors != backsector->ffloors && frontsector->tag != backsector->tag)) + || backsector->floorpic != frontsector->floorpic + || backsector->lightlevel != frontsector->lightlevel + //SoM: 3/22/2000: Check floor x and y offsets. + || backsector->floor_xoffs != frontsector->floor_xoffs + || backsector->floor_yoffs != frontsector->floor_yoffs + || backsector->floorpic_angle != frontsector->floorpic_angle + //SoM: 3/22/2000: Prevents bleeding. + || frontsector->heightsec != -1 + || backsector->floorlightsec != frontsector->floorlightsec + //SoM: 4/3/2000: Check for colormaps + || frontsector->extra_colormap != backsector->extra_colormap + || (frontsector->ffloors != backsector->ffloors && frontsector->tag != backsector->tag)) { markfloor = true; } @@ -1965,18 +2057,18 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (worldhigh != worldtop || worldhighslope != worldtopslope || backsector->c_slope != frontsector->c_slope - || backsector->ceilingpic != frontsector->ceilingpic - || backsector->lightlevel != frontsector->lightlevel - //SoM: 3/22/2000: Check floor x and y offsets. - || backsector->ceiling_xoffs != frontsector->ceiling_xoffs - || backsector->ceiling_yoffs != frontsector->ceiling_yoffs - || backsector->ceilingpic_angle != frontsector->ceilingpic_angle - //SoM: 3/22/2000: Prevents bleeding. - || (frontsector->heightsec != -1 && frontsector->ceilingpic != skyflatnum) - || backsector->ceilinglightsec != frontsector->ceilinglightsec - //SoM: 4/3/2000: Check for colormaps - || frontsector->extra_colormap != backsector->extra_colormap - || (frontsector->ffloors != backsector->ffloors && frontsector->tag != backsector->tag)) + || backsector->ceilingpic != frontsector->ceilingpic + || backsector->lightlevel != frontsector->lightlevel + //SoM: 3/22/2000: Check floor x and y offsets. + || backsector->ceiling_xoffs != frontsector->ceiling_xoffs + || backsector->ceiling_yoffs != frontsector->ceiling_yoffs + || backsector->ceilingpic_angle != frontsector->ceilingpic_angle + //SoM: 3/22/2000: Prevents bleeding. + || (frontsector->heightsec != -1 && frontsector->ceilingpic != skyflatnum) + || backsector->ceilinglightsec != frontsector->ceilinglightsec + //SoM: 4/3/2000: Check for colormaps + || frontsector->extra_colormap != backsector->extra_colormap + || (frontsector->ffloors != backsector->ffloors && frontsector->tag != backsector->tag)) { markceiling = true; } @@ -1987,17 +2079,20 @@ void R_StoreWallRange(INT32 start, INT32 stop) } if (backsector->ceilingheight <= frontsector->floorheight || - backsector->floorheight >= frontsector->ceilingheight) + backsector->floorheight >= frontsector->ceilingheight) { // closed door markceiling = markfloor = true; } // check TOP TEXTURE - if (worldhigh < worldtop || worldhighslope < worldtopslope) + if (!bothceilingssky // never draw the top texture if on + && (worldhigh < worldtop || worldhighslope < worldtopslope)) { fixed_t texheight; // top texture + topremap = (encoremap && !(curline->linedef->flags & ML_TFERLINE)); + if ((linedef->flags & (ML_DONTPEGTOP) && (linedef->flags & ML_DONTPEGBOTTOM)) && linedef->sidenum[1] != 0xffff) { @@ -2034,11 +2129,13 @@ void R_StoreWallRange(INT32 start, INT32 stop) rw_toptextureslide = ceilingbackslide; } } + // check BOTTOM TEXTURE if (worldlow > worldbottom || worldlowslope > worldbottomslope) // Only if VISIBLE!!! { // bottom texture bottomtexture = R_GetTextureNum(sidedef->bottomtexture); + bottomremap = (encoremap && !(curline->linedef->flags & ML_TFERLINE)); if (!(linedef->flags & ML_EFFECT1)) // Ignore slopes for lower/upper textures unless flag is checked { @@ -2065,7 +2162,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) rw_bottomtexturemid += sidedef->rowoffset; // allocate space for masked texture tables - if (frontsector && backsector && frontsector->tag != backsector->tag && (backsector->ffloors || frontsector->ffloors)) + if (frontsector && backsector && (frontsector->tag != backsector->tag) && (backsector->ffloors || frontsector->ffloors)) { ffloor_t *rover; ffloor_t *r2; @@ -2080,10 +2177,18 @@ void R_StoreWallRange(INT32 start, INT32 stop) ds_p->thicksidecol = maskedtexturecol = lastopening - rw_x; lastopening += rw_stopx - rw_x; - lowcut = max(worldbottom, worldlow) + viewz; - highcut = min(worldtop, worldhigh) + viewz; - lowcutslope = max(worldbottomslope, worldlowslope) + viewz; - highcutslope = min(worldtopslope, worldhighslope) + viewz; + lowcut = std::max(worldbottom, worldlow) + viewz; + highcut = std::min(worldtop, worldhigh) + viewz; + lowcutslope = std::max(worldbottomslope, worldlowslope) + viewz; + highcutslope = std::min(worldtopslope, worldhighslope) + viewz; + + auto check_fof_offscreen = [&](INT32 bottom, INT32 bottomslope, INT32 top, INT32 topslope) + { + return ((P_GetFFloorTopZAt (rover, segleft .x, segleft .y) <= bottom + viewz + && P_GetFFloorTopZAt (rover, segright.x, segright.y) <= bottomslope + viewz) + || ( P_GetFFloorBottomZAt (rover, segleft .x, segleft .y) >= top + viewz + && P_GetFFloorBottomZAt (rover, segright.x, segright.y) >= topslope + viewz)); + }; if (frontsector->ffloors && backsector->ffloors) { @@ -2185,7 +2290,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) SLOPEPARAMS(*r2->t_slope, high2, highslope2, *r2->topheight) SLOPEPARAMS(*r2->b_slope, low2, lowslope2, *r2->bottomheight) - +#undef SLOPEPARAMS if ((high2 < lowcut || highslope2 < lowcutslope) || (low2 > highcut || lowslope2 > highcutslope)) continue; if ((high1 > high2 || highslope1 > highslope2) || (low1 < low2 || lowslope1 < lowslope2)) @@ -2206,14 +2311,12 @@ void R_StoreWallRange(INT32 start, INT32 stop) { if (!(rover->flags & FF_RENDERSIDES) || !(rover->flags & FF_EXISTS) || rover->flags & FF_INVERTSIDES) continue; + if (rover->norender == leveltime) continue; // Oy vey. - if ( ((P_GetFFloorTopZAt (rover, segleft .x, segleft .y)) <= worldbottom + viewz - && (P_GetFFloorTopZAt (rover, segright.x, segright.y)) <= worldbottomslope + viewz) - ||((P_GetFFloorBottomZAt(rover, segleft .x, segleft .y)) >= worldtop + viewz - && (P_GetFFloorBottomZAt(rover, segright.x, segright.y)) >= worldtopslope + viewz)) + if (check_fof_offscreen(worldbottom, worldbottomslope, worldtop, worldtopslope)) continue; ds_p->thicksides[i] = rover; @@ -2226,20 +2329,15 @@ void R_StoreWallRange(INT32 start, INT32 stop) { if (!(rover->flags & FF_RENDERSIDES) || !(rover->flags & FF_EXISTS) || !(rover->flags & FF_ALLSIDES)) continue; + if (rover->norender == leveltime) continue; // Oy vey. - if ( (P_GetFFloorTopZAt (rover, segleft .x, segleft .y) <= worldbottom + viewz - && P_GetFFloorTopZAt (rover, segright.x, segright.y) <= worldbottomslope + viewz) - ||(P_GetFFloorBottomZAt(rover, segleft .x, segleft .y) >= worldtop + viewz - && P_GetFFloorBottomZAt(rover, segright.x, segright.y) >= worldtopslope + viewz)) + if (check_fof_offscreen(worldbottom, worldbottomslope, worldtop, worldtopslope)) continue; - if ( (P_GetFFloorTopZAt (rover, segleft .x, segleft .y) <= worldlow + viewz - && P_GetFFloorTopZAt (rover, segright.x, segright.y) <= worldlowslope + viewz) - ||(P_GetFFloorBottomZAt(rover, segleft .x, segleft .y) >= worldhigh + viewz - && P_GetFFloorBottomZAt(rover, segright.x, segright.y) >= worldhighslope + viewz)) + if (check_fof_offscreen(worldlow, worldlowslope, worldhigh, worldhighslope)) continue; ds_p->thicksides[i] = rover; @@ -2268,9 +2366,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) rw_midtextureslide = rw_midtexturebackslide = 0; if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) - rw_midtexturemid = rw_midtextureback = max(curline->frontsector->floorheight, curline->backsector->floorheight) - viewz; + rw_midtexturemid = rw_midtextureback = std::max(curline->frontsector->floorheight, curline->backsector->floorheight) - viewz; else - rw_midtexturemid = rw_midtextureback = min(curline->frontsector->ceilingheight, curline->backsector->ceilingheight) - viewz; + rw_midtexturemid = rw_midtextureback = std::min(curline->frontsector->ceilingheight, curline->backsector->ceilingheight) - viewz; } else { @@ -2280,9 +2378,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) rw_midtextureslide = rw_midtexturebackslide = 0; if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) - rw_midtexturemid = rw_midtextureback = max(frontsector->floorheight, backsector->floorheight) - viewz; + rw_midtexturemid = rw_midtextureback = std::max(frontsector->floorheight, backsector->floorheight) - viewz; else - rw_midtexturemid = rw_midtextureback = min(frontsector->ceilingheight, backsector->ceilingheight) - viewz; + rw_midtexturemid = rw_midtextureback = std::min(frontsector->ceilingheight, backsector->ceilingheight) - viewz; } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) @@ -2308,7 +2406,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) } // calculate rw_offset (only needed for textured lines) - segtextured = midtexture || toptexture || bottomtexture || maskedtexture || (numthicksides > 0); + segtextured = (midtexture || toptexture || bottomtexture || maskedtexture || (numthicksides > 0)); if (segtextured) { @@ -2390,10 +2488,53 @@ void R_StoreWallRange(INT32 start, INT32 stop) } else { - topstep = -FixedMul (rw_scalestep, worldtop); - topfrac = (centeryfrac>>4) - FixedMul (worldtop, rw_scale); + // for anyone that sees this + // dont. + // this is absolute shit-tier hacks + // but i just cant determine this in any sane way + // but this checks a shitton of things to make software handle skies better - bottomstep = -FixedMul (rw_scalestep,worldbottom); + auto set_topstep_normal = [&] + { + topstep = -FixedMul (rw_scalestep, worldtop); + topfrac = (centeryfrac>>4) - FixedMul (worldtop, rw_scale); + }; + + // untextured seg + if (!segtextured && !curline->polyseg) + { + const bool tophigh = (worldhigh <= worldtop && worldhighslope <= worldtopslope); + + // if we cant see the goddamn skyplane, well there wont be any skybox + // we could kill skyVisible instead, but i want to keep the performance improvemnts it yields + // so we do this absolute trash + if ((tophigh + && (frontsector->floorpic != skyflatnum && frontsector->ceilingpic != skyflatnum)) // try to guess if its a "window" + && ((!backsector) // single sided + || ((backsector && (worldhigh != worldtop || worldhighslope != worldtopslope)) + && (backsector->floorheight >= frontsector->ceilingheight || backsector->ceilingheight <= frontsector->floorheight)))) // check if there is a "thok" sector behind it + skyVisible = true; + + // this is an attempt to fix issues with textureless single sided lines drawing nothing where they should just draw sky instead + if (tophigh && !backsector && frontsector->ceilingpic == skyflatnum) + { + topstep = -FixedMul (rw_scalestep, worldbottom); + topfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale); + + // account for slopes to try and get rid of sharp edges from the black void + if (frontsector->f_slope || (backsector && backsector->f_slope)) + { + topstep = -FixedMul (rw_scalestep, worldbottomslope); + topfrac = (centeryfrac>>4) - FixedMul (worldbottomslope, rw_scale); + } + } + else + set_topstep_normal(); + } + else + set_topstep_normal(); + + bottomstep = -FixedMul (rw_scalestep, worldbottom); bottomfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale); if (frontsector->c_slope) @@ -2401,6 +2542,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) fixed_t topfracend = (centeryfrac>>4) - FixedMul (worldtopslope, ds_p->scale2); topstep = (topfracend-topfrac)/(range); } + if (frontsector->f_slope) { fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldbottomslope, ds_p->scale2); @@ -2408,23 +2550,20 @@ void R_StoreWallRange(INT32 start, INT32 stop) } } - dc_numlights = 0; + dc.numlights = 0; if (frontsector->numlights) { - dc_numlights = frontsector->numlights; - if (dc_numlights >= dc_maxlights) - { - dc_maxlights = dc_numlights; - dc_lightlist = Z_Realloc(dc_lightlist, sizeof (*dc_lightlist) * dc_maxlights, PU_STATIC, NULL); - } + dc.numlights = frontsector->numlights; + dc.maxlights = dc.numlights; + dc.lightlist = static_cast(Z_Frame_Alloc(sizeof(*dc.lightlist) * dc.maxlights)); - for (i = p = 0; i < dc_numlights; i++) + for (i = p = 0; i < dc.numlights; i++) { fixed_t leftheight, rightheight; light = &frontsector->lightlist[i]; - rlight = &dc_lightlist[p]; + rlight = &dc.lightlist[p]; leftheight = P_GetLightZAt(light, segleft.x, segleft.y); rightheight = P_GetLightZAt(light, segright.x, segright.y); @@ -2444,14 +2583,14 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (leftheight < worldbottom && rightheight < worldbottomslope) continue; - if (leftheight > worldtop && rightheight > worldtopslope && i+1 < dc_numlights && frontsector->lightlist[i+1].height > frontsector->ceilingheight) + if (leftheight > worldtop && rightheight > worldtopslope && i+1 < dc.numlights && frontsector->lightlist[i+1].height > frontsector->ceilingheight) continue; } rlight->height = (centeryfrac>>4) - FixedMul(leftheight, rw_scale); rlight->heightstep = (centeryfrac>>4) - FixedMul(rightheight, ds_p->scale2); rlight->heightstep = (rlight->heightstep-rlight->height)/(range); - rlight->flags = light->flags; + rlight->flags = static_cast(light->flags); if (light->caster && light->caster->flags & FF_CUTSOLIDS) { @@ -2479,7 +2618,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) p++; } - dc_numlights = p; + dc.numlights = p; } if (numffloors) @@ -2512,13 +2651,13 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (toptexture) { - fixed_t topfracend = (centeryfrac>>4) - FixedMul (worldhighslope, ds_p->scale2); + fixed_t topfracend = (centeryfrac>>4) - FixedMul(worldhighslope, ds_p->scale2); pixhigh = (centeryfrac>>4) - FixedMul (worldhigh, rw_scale); pixhighstep = (topfracend-pixhigh)/(range); // If the lowest part of a ceiling stretching down covers the entire screen - if (min(pixhigh, topfracend)>>HEIGHTBITS >= viewheight-1) + if (std::min(pixhigh, topfracend)>>HEIGHTBITS >= viewheight-1) g_walloffscreen = true; } @@ -2530,7 +2669,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) pixlowstep = (bottomfracend-pixlow)/(range); // If the highest part of a floor stretching up covers the entire screen - if ((max(pixlow, bottomfracend)+HEIGHTUNIT-1)>>HEIGHTBITS <= 0) + if ((std::max(pixlow, bottomfracend)+HEIGHTUNIT-1)>>HEIGHTBITS <= 0) g_walloffscreen = true; } @@ -2540,12 +2679,25 @@ void R_StoreWallRange(INT32 start, INT32 stop) fixed_t planevistest; i = 0; + auto setup_back_fof = [&] + { + //ffloor[i].slope = *rover->b_slope; + ffloor[i].b_pos = roverleft; + ffloor[i].b_pos_slope = roverright; + ffloor[i].b_pos >>= 4; + ffloor[i].b_pos_slope >>= 4; + ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale); + ffloor[i].b_step = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos_slope, ds_p->scale2); + ffloor[i].b_step = (ffloor[i].b_step-ffloor[i].b_frac)/(range); + }; + if (backsector->ffloors) { for (rover = backsector->ffloors; rover && i < MAXFFLOORS; rover = rover->next) { if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES)) continue; + if (rover->norender == leveltime) continue; @@ -2558,18 +2710,11 @@ void R_StoreWallRange(INT32 start, INT32 stop) planevistest = P_GetFFloorBottomZAt(rover, viewx, viewy); if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) && - (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && - ((viewz < planevistest && !(rover->flags & FF_INVERTPLANES)) || - (viewz > planevistest && (rover->flags & FF_BOTHPLANES)))) + (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && + ((viewz < planevistest && !(rover->flags & FF_INVERTPLANES)) || + (viewz > planevistest && (rover->flags & FF_BOTHPLANES)))) { - //ffloor[i].slope = *rover->b_slope; - ffloor[i].b_pos = roverleft; - ffloor[i].b_pos_slope = roverright; - ffloor[i].b_pos >>= 4; - ffloor[i].b_pos_slope >>= 4; - ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale); - ffloor[i].b_step = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos_slope, ds_p->scale2); - ffloor[i].b_step = (ffloor[i].b_step-ffloor[i].b_frac)/(range); + setup_back_fof(); i++; } @@ -2581,18 +2726,11 @@ void R_StoreWallRange(INT32 start, INT32 stop) planevistest = P_GetFFloorTopZAt(rover, viewx, viewy); if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) && - (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && - ((viewz > planevistest && !(rover->flags & FF_INVERTPLANES)) || - (viewz < planevistest && (rover->flags & FF_BOTHPLANES)))) + (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && + ((viewz > planevistest && !(rover->flags & FF_INVERTPLANES)) || + (viewz < planevistest && (rover->flags & FF_BOTHPLANES)))) { - //ffloor[i].slope = *rover->t_slope; - ffloor[i].b_pos = roverleft; - ffloor[i].b_pos_slope = roverright; - ffloor[i].b_pos >>= 4; - ffloor[i].b_pos_slope >>= 4; - ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale); - ffloor[i].b_step = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos_slope, ds_p->scale2); - ffloor[i].b_step = (ffloor[i].b_step-ffloor[i].b_frac)/(range); + setup_back_fof(); i++; } } @@ -2615,18 +2753,11 @@ void R_StoreWallRange(INT32 start, INT32 stop) planevistest = P_GetFFloorBottomZAt(rover, viewx, viewy); if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) && - (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && - ((viewz < planevistest && !(rover->flags & FF_INVERTPLANES)) || - (viewz > planevistest && (rover->flags & FF_BOTHPLANES)))) + (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && + ((viewz < planevistest && !(rover->flags & FF_INVERTPLANES)) || + (viewz > planevistest && (rover->flags & FF_BOTHPLANES)))) { - //ffloor[i].slope = *rover->b_slope; - ffloor[i].b_pos = roverleft; - ffloor[i].b_pos_slope = roverright; - ffloor[i].b_pos >>= 4; - ffloor[i].b_pos_slope >>= 4; - ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale); - ffloor[i].b_step = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos_slope, ds_p->scale2); - ffloor[i].b_step = (ffloor[i].b_step-ffloor[i].b_frac)/(range); + setup_back_fof(); i++; } @@ -2638,18 +2769,11 @@ void R_StoreWallRange(INT32 start, INT32 stop) planevistest = P_GetFFloorTopZAt(rover, viewx, viewy); if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) && - (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && - ((viewz > planevistest && !(rover->flags & FF_INVERTPLANES)) || - (viewz < planevistest && (rover->flags & FF_BOTHPLANES)))) + (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && + ((viewz > planevistest && !(rover->flags & FF_INVERTPLANES)) || + (viewz < planevistest && (rover->flags & FF_BOTHPLANES)))) { - //ffloor[i].slope = *rover->t_slope; - ffloor[i].b_pos = roverleft; - ffloor[i].b_pos_slope = roverright; - ffloor[i].b_pos >>= 4; - ffloor[i].b_pos_slope >>= 4; - ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale); - ffloor[i].b_step = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos_slope, ds_p->scale2); - ffloor[i].b_step = (ffloor[i].b_step-ffloor[i].b_frac)/(range); + setup_back_fof(); i++; } } @@ -2657,6 +2781,21 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (curline->polyseg && frontsector && (curline->polyseg->flags & POF_RENDERPLANES)) { + auto setup_back_polyobj = [&](fixed_t height) + { + if (ffloor[i].plane->minx > ds_p->x1) + ffloor[i].plane->minx = ds_p->x1; + + if (ffloor[i].plane->maxx < ds_p->x2) + ffloor[i].plane->maxx = ds_p->x2; + + ffloor[i].slope = NULL; + ffloor[i].b_pos = height; + ffloor[i].b_pos = (ffloor[i].b_pos - viewz) >> 4; + ffloor[i].b_step = FixedMul(-rw_scalestep, ffloor[i].b_pos); + ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale); + }; + while (i < numffloors && ffloor[i].polyobj != curline->polyseg) i++; @@ -2664,17 +2803,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) backsector->floorheight >= frontsector->floorheight && (viewz < backsector->floorheight)) { - if (ffloor[i].plane->minx > ds_p->x1) - ffloor[i].plane->minx = ds_p->x1; - - if (ffloor[i].plane->maxx < ds_p->x2) - ffloor[i].plane->maxx = ds_p->x2; - - ffloor[i].slope = NULL; - ffloor[i].b_pos = backsector->floorheight; - ffloor[i].b_pos = (ffloor[i].b_pos - viewz) >> 4; - ffloor[i].b_step = FixedMul(-rw_scalestep, ffloor[i].b_pos); - ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale); + setup_back_polyobj(backsector->floorheight); i++; } @@ -2682,17 +2811,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) backsector->ceilingheight <= frontsector->ceilingheight && (viewz > backsector->ceilingheight)) { - if (ffloor[i].plane->minx > ds_p->x1) - ffloor[i].plane->minx = ds_p->x1; - - if (ffloor[i].plane->maxx < ds_p->x2) - ffloor[i].plane->maxx = ds_p->x2; - - ffloor[i].slope = NULL; - ffloor[i].b_pos = backsector->ceilingheight; - ffloor[i].b_pos = (ffloor[i].b_pos - viewz) >> 4; - ffloor[i].b_step = FixedMul(-rw_scalestep, ffloor[i].b_pos); - ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale); + setup_back_polyobj(backsector->ceilingheight); i++; } } @@ -2767,32 +2886,52 @@ void R_StoreWallRange(INT32 start, INT32 stop) } - rw_silhouette = &(ds_p->silhouette); - rw_tsilheight = &(ds_p->tsilheight); - rw_bsilheight = &(ds_p->bsilheight); + didsolidcol = false; -#ifdef WALLSPLATS - if (linedef->splats && cv_splats.value) + if (!segtextured && !numffloors) { - // Isn't a bit wasteful to copy the ENTIRE array for every drawseg? - M_Memcpy(last_ceilingclip + ds_p->x1, ceilingclip + ds_p->x1, - sizeof (INT16) * (ds_p->x2 - ds_p->x1 + 1)); - M_Memcpy(last_floorclip + ds_p->x1, floorclip + ds_p->x1, - sizeof (INT16) * (ds_p->x2 - ds_p->x1 + 1)); - R_RenderSegLoop(); - R_DrawWallSplats(); + if (markfloor || markceiling) + R_MarkSegBounds(); + else + { + for (; rw_x < rw_stopx; rw_x++) + { + frontscale[rw_x] = rw_scale; + rw_scale += rw_scalestep; + } + } } else -#endif + { + rw_silhouette = &ds_p->silhouette; + rw_tsilheight = &ds_p->tsilheight; + rw_bsilheight = &ds_p->bsilheight; - R_RenderSegLoop(); - colfunc = wallcolfunc; + R_RenderSegLoop(&dc); + } + + R_SetColumnFunc(BASEDRAWFUNC); if (g_portal) // if curline is a portal, set portalrender for drawseg ds_p->portalpass = portalrender+1; else ds_p->portalpass = 0; + // cph - if a column was made solid by this wall, we _must_ save full clipping info + if (backsector && didsolidcol) + { + if (!(ds_p->silhouette & SIL_BOTTOM)) + { + ds_p->silhouette |= SIL_BOTTOM; + ds_p->bsilheight = backsector->f_slope ? INT32_MAX : backsector->floorheight; + } + if (!(ds_p->silhouette & SIL_TOP)) + { + ds_p->silhouette |= SIL_TOP; + ds_p->tsilheight = backsector->c_slope ? INT32_MIN : backsector->ceilingheight; + } + } + // save sprite clipping info if (((ds_p->silhouette & SIL_TOP) || maskedtexture) && !ds_p->sprtopclip) { @@ -2808,15 +2947,20 @@ void R_StoreWallRange(INT32 start, INT32 stop) lastopening += rw_stopx - start; } - if (maskedtexture && !(ds_p->silhouette & SIL_TOP)) + if (maskedtexture) { - ds_p->silhouette |= SIL_TOP; - ds_p->tsilheight = (sidedef->midtexture > 0 && sidedef->midtexture < numtextures) ? INT32_MIN: INT32_MAX; - } - if (maskedtexture && !(ds_p->silhouette & SIL_BOTTOM)) - { - ds_p->silhouette |= SIL_BOTTOM; - ds_p->bsilheight = (sidedef->midtexture > 0 && sidedef->midtexture < numtextures) ? INT32_MAX: INT32_MIN; + if (!(ds_p->silhouette & SIL_TOP)) + { + ds_p->silhouette |= SIL_TOP; + ds_p->tsilheight = (sidedef->midtexture > 0 && sidedef->midtexture < numtextures) ? INT32_MIN: INT32_MAX; + } + + if (!(ds_p->silhouette & SIL_BOTTOM)) + { + ds_p->silhouette |= SIL_BOTTOM; + ds_p->bsilheight = (sidedef->midtexture > 0 && sidedef->midtexture < numtextures) ? INT32_MAX: INT32_MIN; + } } + ds_p++; } diff --git a/src/r_segs.h b/src/r_segs.h index 006e81279..27dbbe54f 100644 --- a/src/r_segs.h +++ b/src/r_segs.h @@ -14,13 +14,24 @@ #ifndef __R_SEGS__ #define __R_SEGS__ +#ifdef __cplusplus +extern "C" { +#endif + #ifdef __GNUG__ #pragma interface #endif -transnum_t R_GetLinedefTransTable(fixed_t alpha); void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2); void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pffloor); void R_StoreWallRange(INT32 start, INT32 stop); +void R_AllocSegMemory(void); + +transnum_t R_GetLinedefTransTable(fixed_t alpha); + +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/r_skins.c b/src/r_skins.c new file mode 100644 index 000000000..6bda9e263 --- /dev/null +++ b/src/r_skins.c @@ -0,0 +1,791 @@ +// SONIC ROBO BLAST 2 KART +//----------------------------------------------------------------------------- +// Copyright (C) 2025 by Vivian "toastergrl" Grannell. +// Copyright (C) 2025 by Kart Krew. +// Copyright (C) 2020 by Sonic Team Junior. +// Copyright (C) 2000 by DooM Legacy Team. +// Copyright (C) 1996 by id Software, Inc. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file r_skins.c +/// \brief Loading skins + +#include "dehacked.h" // get_number (for thok) +#include "doomdef.h" +#include "console.h" +#include "r_draw.h" +#include "r_things.h" +#include "r_skins.h" +#include "g_game.h" +#include "k_kart.h" // SRB2kart +#include "p_local.h" +#include "st_stuff.h" +#include "i_video.h" // rendermode +#include "w_wad.h" +#include "z_zone.h" + +#ifdef HWRENDER +#include "hardware/hw_md2.h" +#endif + +#include "qs22j.h" + +CV_PossibleValue_t Forceskin_cons_t[MAXSKINS+2]; + +INT32 numskins = 0; +INT32 numallskins = 0; +INT32 numlocalskins = 0; +skin_t skins[MAXSKINS]; +UINT8 skinstats[9][9][MAXSKINS]; +UINT8 skinstatscount[9][9] = { + {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 1, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0} +}; +UINT8 skinsorted[MAXSKINS]; +skin_t localskins[MAXLOCALSKINS]; +skin_t allskins[MAXSKINS+MAXLOCALSKINS]; + +// FIXTHIS: don't work because it must be inistilised before the config load +//#define SKINVALUES +#ifdef SKINVALUES +CV_PossibleValue_t skin_cons_t[MAXSKINS+1]; +CV_PossibleValue_t localskin_cons_t[MAXLOCALSKINS+1]; +#endif + +static void Sk_SetDefaultValue(skin_t *skin, boolean local) +{ + INT32 i; + // + // set default skin values + // + memset(skin, 0, sizeof (skin_t)); + snprintf(skin->name, sizeof skin->name, "skin %u", K_GetMobjSkinNum(skin, local)); + skin->name[sizeof skin->name - 1] = '\0'; + skin->wadnum = INT16_MAX; + strcpy(skin->sprite, ""); + + skin->flags = 0; + + strcpy(skin->realname, "Someone"); + strcpy(skin->hudname, "???"); + strncpy(skin->facerank, "PLAYRANK", 9); + strncpy(skin->facewant, "PLAYWANT", 9); + strncpy(skin->facemmap, "PLAYMMAP", 9); + + skin->starttranscolor = 160; + skin->prefcolor = SKINCOLOR_GREEN; + + // SRB2kart + skin->kartspeed = 5; + skin->kartweight = 5; + // + + skin->highresscale = FRACUNIT>>1; + + for (i = 0; i < sfx_skinsoundslot0; i++) + if (S_sfx[i].skinsound != -1) + skin->soundsid[S_sfx[i].skinsound] = i; +} + +// +// Initialize the basic skins +// +void R_InitSkins(void) +{ + skin_t *skin; +#ifdef SKINVALUES + INT32 i; + + for (i = 0; i <= MAXSKINS; i++) + { + skin_cons_t[i].value = 0; + skin_cons_t[i].strvalue = NULL; + } + for (i = 0; i <= MAXLOCALSKINS; i++) + { + localskin_cons_t[i].value = 0; + localskin_cons_t[i].strvalue = NULL; + } +#endif + + // skin[0] = Sonic skin + skin = &skins[0]; + numskins = 1; + Sk_SetDefaultValue(skin, false); + memset(skinstats, 0, sizeof(skinstats)); + memset(skinsorted, 0, sizeof(skinsorted)); + + // Hardcoded S_SKIN customizations for Sonic. + strcpy(skin->name, DEFAULTSKIN); +#ifdef SKINVALUES + skin_cons_t[0].strvalue = skins[0].name; +#endif + skin->flags = 0; + strcpy(skin->realname, "Sonic"); + strcpy(skin->hudname, "SONIC"); + + strncpy(skin->facerank, "PLAYRANK", 9); + strncpy(skin->facewant, "PLAYWANT", 9); + strncpy(skin->facemmap, "PLAYMMAP", 9); + skin->wadnum = 0; // god what have you brought to this world + skin->prefcolor = SKINCOLOR_BLUE; + skin->localskin = false; + skin->localnum = 0; + + // SRB2kart + skin->kartspeed = 8; + skin->kartweight = 2; + // + + skin->spritedef.numframes = sprites[SPR_PLAY].numframes; + skin->spritedef.spriteframes = sprites[SPR_PLAY].spriteframes; + skin->sprinfo = spriteinfo[SPR_PLAY]; + ST_LoadFaceGraphics(skin->facerank, skin->facewant, skin->facemmap, 0); + + // Set values for Sonic skin + Forceskin_cons_t[1].value = 0; + Forceskin_cons_t[1].strvalue = skin->name; + + //MD2 for sonic doesn't want to load in Linux. +#ifdef HWRENDER + if (rendermode == render_opengl) + HWR_AddPlayerMD2(0, false); +#endif + + // lets set it + allskins[0] = skins[0]; + numallskins = 1; +} + +// returns true if the skin name is found (loaded from pwad) +// warning return -1 if not found +INT32 R_SkinAvailable(const char *name) +{ + INT32 i; + + for (i = 0; i < numskins; i++) + { + if (stricmp(skins[i].name,name) == 0) + return i; + } + return -1; +} + +// returns true if the skin name is found (loaded from pwad) +// warning return -1 if not found +INT32 R_AnySkinAvailable(const char *name) +{ + INT32 i; + + for (i = 0; i < numallskins; i++) + { + if (stricmp(allskins[i].name,name) == 0) + return i; + } + return -1; +} + +INT32 R_LocalSkinAvailable(const char *name, boolean local) +{ + INT32 i; + + if (local) + { + for (i = 0; i < numlocalskins; i++) + { + if (stricmp(localskins[i].name,name) == 0) + return i; + } + return -1; + } + else + return R_SkinAvailable(name); +} + +// network code calls this when a 'skin change' is received +boolean SetPlayerSkin(INT32 playernum, const char *skinname) +{ + INT32 i; + player_t *player = &players[playernum]; + + for (i = 0; i < numskins; i++) + { + // search in the skin list + if (stricmp(skins[i].name, skinname) == 0) + { + SetPlayerSkinByNum(playernum, i); + return true; + } + } + + if (P_IsLocalPlayer(player)) + CONS_Alert(CONS_WARNING, M_GetText("Skin '%s' not found.\n"), skinname); + else if(server || IsPlayerAdmin(consoleplayer)) + CONS_Alert(CONS_WARNING, M_GetText("Player %d (%s) skin '%s' not found\n"), playernum, player_names[playernum], skinname); + + SetPlayerSkinByNum(playernum, 0); + return false; +} + +void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) +{ + INT32 i; + player_t *player = &players[playernum]; + + if (stricmp(skinname, "none")) + { + for (i = 0; i < numlocalskins; i++) + { + // search in the localskin list + if (stricmp(localskins[i].name, skinname) == 0) + { + player->localskin = 1 + i; + player->skinlocal = true; + if (player->mo) + { + player->mo->localskin = &localskins[i]; + player->mo->skinlocal = true; + } + + goto setcvar; + } + } + + for (i = 0; i < numskins; i++) + { + // search in the skin list + if (stricmp(skins[i].name, skinname) == 0) + { + player->localskin = 1 + i; + player->skinlocal = false; + if (player->mo) + { + player->mo->localskin = &skins[i]; + player->mo->skinlocal = false; + } + + goto setcvar; + } + } + } + else + { + player->localskin = 0; + player->skinlocal = false; + if (player->mo) + { + player->mo->localskin = 0; + player->mo->skinlocal = false; + } + } + +setcvar: + if (cvar != NULL) + { + if (player->localskin > 0) + { + CV_StealthSet(&cv_fakelocalskin, K_GetSkinArray(player->skinlocal)[player->localskin-1].name); + CV_StealthSet(cvar, K_GetSkinArray(player->skinlocal)[player->localskin-1].name); + + } + else + { + CV_StealthSet(&cv_fakelocalskin, "none"); + CV_StealthSet(cvar, "none"); + } + } +} + +// Same as SetPlayerSkin, but uses the skin #. +// network code calls this when a 'skin change' is received +void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum) +{ + player_t *player = &players[playernum]; + skin_t *skin = &skins[skinnum]; + + if (skinnum >= 0 && skinnum < numskins) // Make sure it exists! + { + player->skin = skinnum; + if (player->mo) + player->mo->skin = skin; + + player->charflags = (UINT32)skin->flags; + + // SRB2kart + player->kartspeed = skin->kartspeed; + player->kartweight = skin->kartweight; + + if (player->mo) + P_SetScale(player->mo, player->mo->scale); + + demo_extradata[playernum] |= DXD_SKIN; + + return; + } + + if (P_IsLocalPlayer(player)) + CONS_Alert(CONS_WARNING, M_GetText("Skin %d not found\n"), skinnum); + else if(server || IsPlayerAdmin(consoleplayer)) + CONS_Alert(CONS_WARNING, "Player %d (%s) skin %d not found\n", playernum, player_names[playernum], skinnum); + + SetPlayerSkinByNum(playernum, 0); // not found put the sonic skin +} + +// +// Add skins from a pwad, each skin preceded by 'S_SKIN' marker +// + +// Does the same is in w_wad, but check only for +// the first 6 characters (this is so we can have S_SKIN1, S_SKIN2.. +// for wad editors that don't like multiple resources of the same name) +// +static UINT16 W_CheckForSkinMarkerInPwad(UINT16 wadid, UINT16 startlump) +{ + UINT16 i; + const char *S_SKIN = "S_SKIN"; + lumpinfo_t *lump_p; + + // scan forward, start at + if (startlump < wadfiles[wadid]->numlumps) + { + lump_p = wadfiles[wadid]->lumpinfo + startlump; + for (i = startlump; i < wadfiles[wadid]->numlumps; i++, lump_p++) + if (memcmp(lump_p->name,S_SKIN,6)==0) + return i; + } + return INT16_MAX; // not found +} + +//sort function for sorting skin names +static int skinSortFunc(const void *a, const void *b) //tbh i have no clue what the naming conventions for local functions are +{ + const skin_t *in1 = &skins[*(const UINT8 *)a]; + const skin_t *in2 = &skins[*(const UINT8 *)b]; + INT32 temp = 0; + const UINT8 val_a = *((const UINT8 *)a); + const UINT8 val_b = *((const UINT8 *)b); + + //return (strcmp(in1->realname, in2->realname) < 0) || (strcmp(in1->realname, in2->realname) ==); + + switch (cv_skinselectgridsort.value) + { + case SKINMENUSORT_REALNAME: + //CONS_Printf("Sorting by realname\n"); + // check name + if ((temp = strcmp(in1->realname, in2->realname))) + return temp; + // sort by internal name + return strcmp(in1->name, in2->name); + break; + + case SKINMENUSORT_NAME: + //CONS_Printf("Sorting by name\n"); + return strcmp(in1->name, in2->name); + break; + + case SKINMENUSORT_SPEED: + //CONS_Printf("Sorting by speed\n"); + // check speed + if (in1->kartspeed < in2->kartspeed) + return -1; + else if (in2->kartspeed < in1->kartspeed) + return 1; + // then check weight + if (in1->kartweight < in2->kartweight) + return -1; + else if (in2->kartweight < in1->kartweight) + return 1; + // then check name + if ((temp = strcmp(in1->realname, in2->realname))) + return temp; + // sort by internal name + return strcmp(in1->name, in2->name); + break; + + case SKINMENUSORT_WEIGHT: + //CONS_Printf("Sorting by weight\n"); + // check weight + if (in1->kartweight < in2->kartweight) + return -1; + else if (in2->kartweight < in1->kartweight) + return 1; + // then check speed + if (in1->kartspeed < in2->kartspeed) + return -1; + else if (in2->kartspeed < in1->kartspeed) + return 1; + // then check name + if ((temp = strcmp(in1->realname, in2->realname))) + return temp; + // sort by internal name + return strcmp(in1->name, in2->name); + break; + + case SKINMENUSORT_PREFCOLOR: + //CONS_Printf("Sorting by prefcolor\n"); + // check prefcolor + if (in1->prefcolor < in2->prefcolor) + return -1; + else if (in2->prefcolor < in1->prefcolor) + return 1; + // then check name + if ((temp = strcmp(in1->realname, in2->realname))) + return temp; + // sort by internal name + return strcmp(in1->name, in2->name); + break; + + case SKINMENUSORT_ID: + //CONS_Printf("Sorting by id\n"); + //how do i do by ID????? + //wait why dont i just convert the inputs to UINT32s + //please tell me im allowed to define variables in here since its a block + + if (val_a == val_b) + return 0; + else if (val_a < val_b) + return -1; + else + return 1; + + default: + return strcmp(in1->name, in2->name); + break; + } + //im scared this somehow will sometimes end up here so im gonna add this here just to be safe + return strcmp(in1->name, in2->name); +} + +void sortSkinGrid(void) +{ + //CONS_Printf("Sorting skin list (%d)...\n", cv_skinselectgridsort.value); + qs22j(skinsorted, numskins, sizeof(UINT8), skinSortFunc); +} + +// +// Find skin sprites, sounds & optional status bar face, & add them +// +void R_AddSkins(UINT16 wadnum, boolean local) +{ + UINT16 lump, lastlump = 0; + char *buf; + char *buf2; + char *stoken; + char *value; + size_t size; + skin_t *skin; + boolean hudname, realname; + +#define lnumskins (local ? numlocalskins : numskins) + + // + // search for all skin markers in pwad + // + + while ((lump = W_CheckForSkinMarkerInPwad(wadnum, lastlump)) != INT16_MAX) + { + // advance by default + lastlump = lump + 1; + + if (!local && numskins >= MAXSKINS) + { + CONS_Alert(CONS_WARNING, M_GetText("Unable to add skin, too many characters are loaded (%d maximum)\n"), MAXSKINS); + continue; // so we know how many skins couldn't be added + } + if (local && numlocalskins >= MAXLOCALSKINS) + { + CONS_Alert(CONS_WARNING, M_GetText("Unable to add localskin, too many localskins are loaded (%d maximum)\n"), MAXLOCALSKINS); + continue; // so we know how many skins couldn't be added + } + + buf = W_CacheLumpNumPwad(wadnum, lump, PU_CACHE); + size = W_LumpLengthPwad(wadnum, lump); + + // for strtok + buf2 = malloc(size+1); + if (!buf2) + I_Error("R_AddSkins: No more free memory\n"); + M_Memcpy(buf2,buf,size); + buf2[size] = '\0'; + + // set defaults + skin = &K_GetSkinArray(local)[lnumskins]; + Sk_SetDefaultValue(skin, local); + skin->wadnum = wadnum; + hudname = realname = false; + // parse + stoken = strtok (buf2, "\r\n= "); + while (stoken) + { + if ((stoken[0] == '/' && stoken[1] == '/') + || (stoken[0] == '#'))// skip comments + { + stoken = strtok(NULL, "\r\n"); // skip end of line + goto next_token; // find the real next token + } + + value = strtok(NULL, "\r\n= "); + + if (!value) + I_Error("R_AddSkins: syntax error in S_SKIN lump# %d(%s) in WAD %s\n", lump, W_CheckNameForNumPwad(wadnum,lump), wadfiles[wadnum]->filename); + + if (!stricmp(stoken, "name")) + { + // the skin name must uniquely identify a single skin + // I'm lazy so if name is already used I leave the 'skin x' + // default skin name set in Sk_SetDefaultValue + if (R_LocalSkinAvailable(value, local) == -1) + { + STRBUFCPY(skin->name, value); + strlwr(skin->name); + } + // I'm not lazy, so if the name is already used I make the name 'namex' + // using the default skin name's number set above + else + { + const size_t stringspace = + strlen(value) + sizeof lnumskins + 1; + char *value2 = Z_Malloc(stringspace, PU_STATIC, NULL); + snprintf(value2, stringspace, + "%s%d", value, lnumskins); + value2[stringspace - 1] = '\0'; + if (R_LocalSkinAvailable(value2, local) == -1) + { + STRBUFCPY(skin->name, + value2); + strlwr(skin->name); + } + Z_Free(value2); + } + + // copy to hudname and fullname as a default. + if (!realname) + { + STRBUFCPY(skin->realname, skin->name); + for (value = skin->realname; *value; value++) + if (*value == '_') *value = ' '; // turn _ into spaces. + } + if (!hudname) + { + STRBUFCPY(skin->hudname, skin->name); + strupr(skin->hudname); + for (value = skin->hudname; *value; value++) + if (*value == '_') *value = ' '; // turn _ into spaces. + } + } + else if (!stricmp(stoken, "realname")) + { // Display name (eg. "Knuckles") + realname = true; + STRBUFCPY(skin->realname, value); + for (value = skin->realname; *value; value++) + if (*value == '_') *value = ' '; // turn _ into spaces. + if (!hudname) + STRBUFCPY(skin->hudname, skin->realname); + } + else if (!stricmp(stoken, "hudname")) + { // Life icon name (eg. "K.T.E") + hudname = true; + STRBUFCPY(skin->hudname, value); + for (value = skin->hudname; *value; value++) + if (*value == '_') *value = ' '; // turn _ into spaces. + if (!realname) + STRBUFCPY(skin->realname, skin->hudname); + } + + else if (!stricmp(stoken, "sprite")) + { + strupr(value); + memcpy(skin->sprite, value, sizeof skin->sprite); + } + else if (!stricmp(stoken, "facerank")) + { + strupr(value); + memcpy(skin->facerank, value, sizeof(skin->facerank)-1); + skin->facerank[sizeof(skin->facerank)-1] = '\0'; + } + else if (!stricmp(stoken, "facewant")) + { + strupr(value); + memcpy(skin->facewant, value, sizeof(skin->facewant)-1); + skin->facewant[sizeof(skin->facewant)-1] = '\0'; + } + else if (!stricmp(stoken, "facemmap")) + { + strupr(value); + strncpy(skin->facemmap, value, sizeof(skin->facemmap)-1); + skin->facemmap[sizeof(skin->facemmap)-1] = '\0'; + } + +#define FULLPROCESS(field) else if (!stricmp(stoken, #field)) skin->field = get_number(value); + // character type identification + FULLPROCESS(flags) +#undef FULLPROCESS + +#define GETKARTSTAT(field) \ + else if (!stricmp(stoken, #field)) \ + { \ + skin->field = atoi(value); \ + if (skin->field < 1) skin->field = 1; \ + if (skin->field > 9) skin->field = 9; \ + } + GETKARTSTAT(kartspeed) + GETKARTSTAT(kartweight) +#undef GETKARTSTAT + + // custom translation table + else if (!stricmp(stoken, "startcolor")) + skin->starttranscolor = atoi(value); + + else if (!stricmp(stoken, "prefcolor")) + skin->prefcolor = K_GetKartColorByName(value); + else if (!stricmp(stoken, "highresscale")) + skin->highresscale = FLOAT_TO_FIXED(atof(value)); + else + { + INT32 found = false; + sfxenum_t i; + // copy name of sounds that are remapped + // for this skin + for (i = 0; i < sfx_skinsoundslot0; i++) + { + if (!S_sfx[i].name) + continue; + if (S_sfx[i].skinsound != -1 + && !stricmp(S_sfx[i].name, + stoken + 2)) + { + skin->soundsid[S_sfx[i].skinsound] = + S_AddSoundFx(value+2, S_sfx[i].singularity, S_sfx[i].pitch, true); + found = true; + } + } + if (!found) + CONS_Debug(DBG_SETUP, "R_AddSkins: Unknown keyword '%s' in S_SKIN lump# %d (WAD %s)\n", stoken, lump, wadfiles[wadnum]->filename); + } +next_token: + stoken = strtok(NULL, "\r\n= "); + } + free(buf2); + + lump++; // if no sprite defined use spirte just after this one + if (skin->sprite[0] == '\0') + { + const char *csprname = W_CheckNameForNumPwad(wadnum, lump); + + // skip to end of this skin's frames + lastlump = lump; + while (W_CheckNameForNumPwad(wadnum,lastlump) && memcmp(W_CheckNameForNumPwad(wadnum, lastlump),csprname,4)==0) + lastlump++; + // allocate (or replace) sprite frames, and set spritedef + R_AddSingleSpriteDef(csprname, &skin->spritedef, wadnum, lump, lastlump); + } + else + { + // search in the normal sprite tables + size_t name; + boolean found = false; + const char *sprname = skin->sprite; + for (name = 0;sprnames[name][0] != '\0';name++) + if (strncmp(sprnames[name], sprname, 4) == 0) + { + found = true; + skin->spritedef = sprites[name]; + } + + // not found so make a new one + // go through the entire current wad looking for our sprite + // don't just mass add anything beginning with our four letters. + // "HOODFACE" is not a sprite name. + if (!found) + { + UINT16 localllump = 0, lstart = UINT16_MAX, lend = UINT16_MAX; + const char *lname; + + while ((lname = W_CheckNameForNumPwad(wadnum,localllump))) + { + // If this is a valid sprite... + if (!memcmp(lname,sprname,4) && lname[4] && lname[5] && lname[5] >= '0' && lname[5] <= '8') + { + if (lstart == UINT16_MAX) + lstart = localllump; + // If already set do nothing + } + else + { + if (lstart != UINT16_MAX) + { + lend = localllump; + break; + } + // If not already set do nothing + } + ++localllump; + } + + R_AddSingleSpriteDef(sprname, &skin->spritedef, wadnum, lstart, lend); + } + + // I don't particularly care about skipping to the end of the used frames. + // We could be using frames from ANYWHERE in the current WAD file, including + // right before us, which is a terrible idea. + // So just let the function in the while loop take care of it for us. + } + + R_FlushTranslationColormapCache(); + + CONS_Printf(M_GetText("Added skin '%s'\n"), skin->name); +#ifdef SKINVALUES + (local ? localskin_cons_t : skin_cons_t)[lnumskins].value = lnumskins; + (local ? localskin_cons_t : skin_cons_t)[lnumskins].strvalue = skin->name; +#endif + + if (!local) + { + // Update the forceskin possiblevalues + Forceskin_cons_t[numskins+1].value = numskins; + Forceskin_cons_t[numskins+1].strvalue = skins[numskins].name; + skin->localskin = false; + skin->localnum = numskins; + ST_LoadFaceGraphics(skin->facerank, skin->facewant, skin->facemmap, numskins); + } + else + { + skin->localskin = true; + skin->localnum = numlocalskins; + ST_LoadLocalFaceGraphics(skin->facerank, skin->facewant, skin->facemmap, numlocalskins); + } + +#ifdef HWRENDER + if (rendermode == render_opengl) + HWR_AddPlayerMD2(lnumskins, local); +#endif + if (!local) + { + skinstats[skin->kartspeed-1][skin->kartweight-1][skinstatscount[skin->kartspeed-1][skin->kartweight-1]] = numskins; + CONS_Debug(DBG_SETUP, M_GetText("Added %d to %d, %d\n"), numskins, skin->kartweight, skin->kartweight); + skinstatscount[skin->kartspeed-1][skin->kartweight-1]++; + CONS_Debug(DBG_SETUP, M_GetText("Incremented %d, %d to %d\n"), skin->kartspeed, skin->kartweight, skinstatscount[skin->kartspeed - 1][skin->kartweight - 1]); + skinsorted[numskins] = numskins; + } + + allskins[numallskins] = K_GetSkinArray(local)[lnumskins]; + + local ? numlocalskins++ : numskins++; + numallskins++; + } + +#undef lnumskins + //sortSkinGrid(); + + return; +} diff --git a/src/r_skins.h b/src/r_skins.h new file mode 100644 index 000000000..cada396f4 --- /dev/null +++ b/src/r_skins.h @@ -0,0 +1,152 @@ +// SONIC ROBO BLAST 2 KART +//----------------------------------------------------------------------------- +// Copyright (C) 2025 by Vivian "toastergrl" Grannell. +// Copyright (C) 2025 by Kart Krew. +// Copyright (C) 2020 by Sonic Team Junior. +// Copyright (C) 2000 by DooM Legacy Team. +// Copyright (C) 1996 by id Software, Inc. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file r_skins.h +/// \brief Skins stuff + +#ifndef __R_SKINS__ +#define __R_SKINS__ +#ifdef __cplusplus +extern "C" { +#endif + +#include "d_player.h" +#include "sounds.h" +#include "r_patch.h" + +// "Left" and "Right" character symbols for additional rotation functionality +#define ROT_L ('L' - '0') +#define ROT_R ('R' - '0') + +#define SKINNAMESIZE 16 +// should be all lowercase!! S_SKIN processing does a strlwr +#define DEFAULTSKIN "sonic" +#define DEFAULTSKIN2 "tails" // secondary player +#define DEFAULTSKIN3 "knuckles" // third player +#define DEFAULTSKIN4 "eggman" // fourth player + +typedef struct +{ + char name[SKINNAMESIZE+1]; // INT16 descriptive name of the skin + spritedef_t spritedef; + spriteinfo_t sprinfo; + UINT16 wadnum; + char sprite[4]; // Sprite name, if seperated from S_SKIN. + skinflags_t flags; + + char realname[SKINNAMESIZE+1]; // Display name for level completion. + char hudname[SKINNAMESIZE+1]; // HUD name to display (officially exactly 5 characters long) + char facerank[9], facewant[9], facemmap[9]; // Arbitrarily named patch lumps + + // SRB2kart + UINT8 kartspeed; + UINT8 kartweight; + // + + // Definable color translation table + UINT8 starttranscolor; + UINT8 prefcolor; + fixed_t highresscale; // scale of highres, default is 0.5 + + // specific sounds per skin + sfxenum_t soundsid[NUMSKINSOUNDS]; // sound # in S_sfx table + + boolean localskin; + INT32 localnum; +} skin_t; + +extern CV_PossibleValue_t Forceskin_cons_t[]; + +extern INT32 numskins; +extern INT32 numlocalskins; +extern INT32 numallskins; +extern skin_t skins[MAXSKINS]; +extern UINT8 skinstats[9][9][MAXSKINS]; +extern UINT8 skinstatscount[9][9]; +extern UINT8 skinsorted[MAXSKINS]; + +extern skin_t localskins[MAXLOCALSKINS]; +extern skin_t allskins[MAXSKINS+MAXLOCALSKINS]; + +//faB: find sprites in wadfile, replace existing, add new ones +// (only sprites from namelist are added or replaced) +void R_AddSpriteDefs(UINT16 wadnum); + +void R_InitSkins(void); +void R_AddSkins(UINT16 wadnum, boolean local); + +INT32 R_SkinAvailable(const char *name); +INT32 R_AnySkinAvailable(const char *name); +INT32 R_LocalSkinAvailable(const char *name, boolean local); + +// had to move those here Zzz... +INT32 K_GetSkinNum(player_t *player); +INT32 K_GetMobjSkinNum(const skin_t *skin, boolean local); +skin_t *K_GetPlayerSkin(player_t *player); +skin_t *K_GetMobjSkin(const mobj_t *mobj); +patch_t *K_GetFacePrefix(player_t *player, INT32 skinnum); +skin_t *K_GetSkinArray(boolean local); + +void sortSkinGrid(void); + +boolean SetPlayerSkin(INT32 playernum,const char *skinname); +void SetPlayerSkinByNum(INT32 playernum,INT32 skinnum); // Tails 03-16-2002 +void SetLocalPlayerSkin(INT32 playernum,const char *skinname, consvar_t *cvar); + +char *GetPlayerFacePic(INT32 skinnum); + +// Functions to go from sprite character ID to frame number +// for 2.1 compatibility this still uses the old 'A' + frame code +// The use of symbols tends to be painful for wad editors though +// So the future version of this tries to avoid using symbols +// as much as possible while also defining all 64 slots in a sane manner +// 2.1: [[ ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ]] +// Future: [[ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz!@ ]] +FUNCMATH FUNCINLINE static ATTRINLINE char R_Frame2Char(UINT8 frame) +{ +#if 1 // 2.1 compat + return 'A' + frame; +#else + if (frame < 26) return 'A' + frame; + if (frame < 36) return '0' + (frame - 26); + if (frame < 62) return 'a' + (frame - 36); + if (frame == 62) return '!'; + if (frame == 63) return '@'; + return '\xFF'; +#endif +} + +FUNCMATH FUNCINLINE static ATTRINLINE UINT8 R_Char2Frame(char cn) +{ +#if 1 // 2.1 compat + if (cn == '+') return '\\' - 'A'; // PK3 can't use backslash, so use + instead + return cn - 'A'; +#else + if (cn >= 'A' && cn <= 'Z') return cn - 'A'; + if (cn >= '0' && cn <= '9') return (cn - '0') + 26; + if (cn >= 'a' && cn <= 'z') return (cn - 'a') + 36; + if (cn == '!') return 62; + if (cn == '@') return 63; + return 255; +#endif +} + +FUNCMATH FUNCINLINE static ATTRINLINE boolean R_ValidSpriteAngle(UINT8 rotation) +{ + return ((rotation <= 8) || (rotation == ROT_L) || (rotation == ROT_R)); +} + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif //__R_SKINS__ diff --git a/src/r_sky.c b/src/r_sky.c index cb21092bb..8cbdd3a59 100644 --- a/src/r_sky.c +++ b/src/r_sky.c @@ -41,6 +41,10 @@ INT32 skytexture; */ INT32 skytexturemid; +/** \brief the x offset of the sky texture + */ +INT32 skytextureoffset; + /** \brief the scale of the sky */ fixed_t skyscale; @@ -50,6 +54,7 @@ fixed_t skyscale; INT32 levelskynum; INT32 globallevelskynum; + /** \brief The R_SetupSkyDraw function Called at loadlevel after skytexture is set, or when sky texture changes. @@ -61,12 +66,19 @@ INT32 globallevelskynum; */ void R_SetupSkyDraw(void) { - // the horizon line in a 256x128 sky texture - skytexturemid = (textures[skytexture]->height/2)<height / 2) << FRACBITS; + skytextureoffset = 0; - // get the right drawer, it was set by screen.c, depending on the - // current video mode bytes per pixel (quick fix) - wallcolfunc = walldrawerfunc; + if (textures[skytexture]->type == TEXTURETYPE_SINGLEPATCH) + { + // Sal: Allow for sky offsets + texpatch_t *const tex_patch = &textures[skytexture]->patches[0]; + patch_t *patch = W_CachePatchNumPwad(tex_patch->wad, tex_patch->lump, PU_CACHE); + + skytexturemid += (patch->topoffset << FRACBITS); + skytextureoffset += (patch->leftoffset << FRACBITS); + } R_SetSkyScale(); } @@ -79,5 +91,7 @@ void R_SetupSkyDraw(void) */ void R_SetSkyScale(void) { - skyscale = FixedDiv(fovtan, FixedDiv(vid.width*FRACUNIT, BASEVIDWIDTH*FRACUNIT)); + //skyscale = FixedDiv(fovtan, FixedDiv(vid.width*FRACUNIT, BASEVIDWIDTH*FRACUNIT)); + fixed_t difference = vid.fdupx-(vid.dupx<> VISSPRITECHUNKBITS] = {NULL}; + + // ========================================================================== // // Sprite loading routines: support sprites in pwad, dehacked sprite renaming, @@ -252,7 +264,7 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch // // Returns true if the sprite was succesfully added // -static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 wadnum, UINT16 startlump, UINT16 endlump) +boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 wadnum, UINT16 startlump, UINT16 endlump) { UINT16 l; UINT8 frame; @@ -402,8 +414,7 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, // allocate this sprite's frames if (!spritedef->spriteframes) - spritedef->spriteframes = - Z_Malloc(maxframe * sizeof (*spritedef->spriteframes), PU_STATIC, NULL); + spritedef->spriteframes = static_cast(Z_Malloc(maxframe * sizeof (*spritedef->spriteframes), PU_STATIC, NULL)); spritedef->numframes = maxframe; M_Memcpy(spritedef->spriteframes, sprtemp, maxframe*sizeof (spriteframe_t)); @@ -476,16 +487,6 @@ void R_AddSpriteDefs(UINT16 wadnum) CONS_Printf(M_GetText("%s added %d frames in %s sprites\n"), wadname, end-start, sizeu1(addsprites)); } - -// -// GAME FUNCTIONS -// -UINT32 visspritecount, numvisiblesprites; - -static UINT32 clippedvissprites; -static vissprite_t *visspritechunks[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {NULL}; - - // // R_InitSprites // Called at program start. @@ -498,11 +499,6 @@ void R_InitSprites(void) float fa; #endif - for (i = 0; i < MAXVIDWIDTH; i++) - { - negonearray[i] = -1; - } - #ifdef ROTSPRITE for (angle = 1; angle < ROTANGLES; angle++) { @@ -522,7 +518,7 @@ void R_InitSprites(void) if (!numsprites) I_Error("R_AddSpriteDefs: no sprites in namelist\n"); - sprites = Z_Calloc(numsprites * sizeof (*sprites), PU_STATIC, NULL); + sprites = static_cast(Z_Calloc(numsprites * sizeof (*sprites), PU_STATIC, NULL)); // find sprites in each -file added pwad for (i = 0; i < numwadfiles; i++) @@ -550,6 +546,34 @@ void R_ClearSprites(void) visspritecount = numvisiblesprites = clippedvissprites = 0; } +static INT16 *vissprite_clipbot[MAXVISSPRITES >> VISSPRITECHUNKBITS]; +static INT16 *vissprite_cliptop[MAXVISSPRITES >> VISSPRITECHUNKBITS]; + +static void R_AllocVisSpriteChunkMemory(UINT32 chunk) +{ + vissprite_clipbot[chunk] = static_cast(Z_Realloc(vissprite_clipbot[chunk], sizeof(INT16) * (VISSPRITESPERCHUNK * viewwidth), PU_STATIC, NULL)); + vissprite_cliptop[chunk] = static_cast(Z_Realloc(vissprite_cliptop[chunk], sizeof(INT16) * (VISSPRITESPERCHUNK * viewwidth), PU_STATIC, NULL)); + + for (unsigned i = 0; i < VISSPRITESPERCHUNK; i++) + { + vissprite_t *sprite = visspritechunks[chunk] + i; + + sprite->clipbot = vissprite_clipbot[chunk] + (viewwidth * i); + sprite->cliptop = vissprite_cliptop[chunk] + (viewwidth * i); + } +} + +void R_AllocVisSpriteMemory(void) +{ + unsigned numchunks = MAXVISSPRITES >> VISSPRITECHUNKBITS; + + for (unsigned i = 0; i < numchunks; i++) + { + if (visspritechunks[i]) + R_AllocVisSpriteChunkMemory(i); + } +} + // // R_NewVisSprite // @@ -561,7 +585,10 @@ static vissprite_t *R_GetVisSprite(UINT32 num) // Allocate chunk if necessary if (!visspritechunks[chunk]) + { Z_Malloc(sizeof(vissprite_t) * VISSPRITESPERCHUNK, PU_LEVEL, &visspritechunks[chunk]); + R_AllocVisSpriteChunkMemory(chunk); + } return visspritechunks[chunk] + (num & VISSPRITEINDEXMASK); } @@ -586,16 +613,16 @@ INT16 *mceilingclip; fixed_t spryscale = 0, sprtopscreen = 0, sprbotscreen = 0; fixed_t windowtop = 0, windowbottom = 0; -void R_DrawMaskedColumn(column_t *column) +void R_DrawMaskedColumn(drawcolumndata_t* dc, column_t *column) { INT32 topscreen; INT32 bottomscreen; fixed_t basetexturemid; INT32 topdelta, prevdelta = 0; - basetexturemid = dc_texturemid; + basetexturemid = dc->texturemid; - for (; column->topdelta != 0xff ;) + while (column->topdelta != 0xff) { // calculate unclipped screen coordinates // for post @@ -606,61 +633,56 @@ void R_DrawMaskedColumn(column_t *column) topscreen = sprtopscreen + spryscale*topdelta; bottomscreen = topscreen + spryscale*column->length; - dc_yl = (topscreen+FRACUNIT-1)>>FRACBITS; - dc_yh = (bottomscreen-1)>>FRACBITS; + dc->yl = (topscreen+FRACUNIT-1)>>FRACBITS; + dc->yh = (bottomscreen-1)>>FRACBITS; if (windowtop != INT32_MAX && windowbottom != INT32_MAX) { if (windowtop > topscreen) - dc_yl = (windowtop + FRACUNIT - 1)>>FRACBITS; + dc->yl = (windowtop + FRACUNIT - 1)>>FRACBITS; if (windowbottom < bottomscreen) - dc_yh = (windowbottom - 1)>>FRACBITS; + dc->yh = (windowbottom - 1)>>FRACBITS; } - if (dc_yh >= mfloorclip[dc_x]) - dc_yh = mfloorclip[dc_x]-1; - if (dc_yl <= mceilingclip[dc_x]) - dc_yl = mceilingclip[dc_x]+1; + if (dc->yh >= mfloorclip[dc->x]) + dc->yh = mfloorclip[dc->x]-1; + if (dc->yl <= mceilingclip[dc->x]) + dc->yl = mceilingclip[dc->x]+1; - if (dc_yl < 0) - dc_yl = 0; - if (dc_yh >= vid.height) - dc_yh = vid.height - 1; + if (dc->yl < 0) + dc->yl = 0; + if (dc->yh >= vid.height) + dc->yh = vid.height - 1; - if (dc_yl <= dc_yh && dc_yh > 0 && column->length != 0) + if (dc->yl <= dc->yh && dc->yh > 0 && column->length != 0) { - dc_source = (UINT8 *)column + 3; - dc_sourcelength = column->length; - dc_texturemid = basetexturemid - (topdelta<source = (UINT8 *)column + 3; + dc->sourcelength = column->length; + dc->texturemid = basetexturemid - (topdelta<(&dc_copy)); } column = (column_t *)((UINT8 *)column + column->length + 4); } - dc_texturemid = basetexturemid; + dc->texturemid = basetexturemid; } INT32 lengthcol; // column->length : for flipped column function pointers and multi-patch on 2sided wall = texture->height -static void R_DrawFlippedMaskedColumn(column_t *column) +static void R_DrawFlippedMaskedColumn(drawcolumndata_t* dc, column_t *column) { INT32 topscreen; INT32 bottomscreen; - fixed_t basetexturemid = dc_texturemid; + fixed_t basetexturemid = dc->texturemid; INT32 topdelta, prevdelta = -1; UINT8 *d,*s; - for (; column->topdelta != 0xff ;) + while (column->topdelta != 0xff) { // calculate unclipped screen coordinates // for post @@ -672,48 +694,54 @@ static void R_DrawFlippedMaskedColumn(column_t *column) topscreen = sprtopscreen + spryscale*topdelta; bottomscreen = sprbotscreen == INT32_MAX ? topscreen + spryscale*column->length : sprbotscreen + spryscale*column->length; - dc_yl = (topscreen+FRACUNIT-1)>>FRACBITS; - dc_yh = (bottomscreen-1)>>FRACBITS; + dc->yl = (topscreen+FRACUNIT-1)>>FRACBITS; + dc->yh = (bottomscreen-1)>>FRACBITS; if (windowtop != INT32_MAX && windowbottom != INT32_MAX) { if (windowtop > topscreen) - dc_yl = (windowtop + FRACUNIT - 1)>>FRACBITS; + dc->yl = (windowtop + FRACUNIT - 1)>>FRACBITS; if (windowbottom < bottomscreen) - dc_yh = (windowbottom - 1)>>FRACBITS; + dc->yh = (windowbottom - 1)>>FRACBITS; } - if (dc_yh >= mfloorclip[dc_x]) - dc_yh = mfloorclip[dc_x]-1; - if (dc_yl <= mceilingclip[dc_x]) - dc_yl = mceilingclip[dc_x]+1; - if (dc_yl < 0) - dc_yl = 0; - if (dc_yh >= vid.height) // dc_yl must be < vid.height, so reduces number of checks in tight loop - dc_yh = vid.height - 1; + if (dc->yh >= mfloorclip[dc->x]) + dc->yh = mfloorclip[dc->x]-1; + if (dc->yl <= mceilingclip[dc->x]) + dc->yl = mceilingclip[dc->x]+1; + if (dc->yl < 0) + dc->yl = 0; + if (dc->yh >= vid.height) // dc->yl must be < vid.height, so reduces number of checks in tight loop + dc->yh = vid.height - 1; - if (dc_yl <= dc_yh && dc_yh > 0 && column->length != 0) + if (dc->yl <= dc->yh && dc->yh > 0 && column->length != 0) { - dc_source = ZZ_Alloc(column->length); - dc_sourcelength = column->length; + dc->source = static_cast(ZZ_Alloc(column->length)); + dc->sourcelength = column->length; - for (s = (UINT8 *)column+2+column->length, d = dc_source; d < dc_source+column->length; --s) + for (s = (UINT8 *)column+2+column->length, d = dc->source; d < dc->source+column->length; --s) *d++ = *s; - dc_texturemid = basetexturemid - (topdelta<texturemid = basetexturemid - (topdelta<(&dc_copy)); + + Z_Free(dc->source); } column = (column_t *)((UINT8 *)column + column->length + 4); } - dc_texturemid = basetexturemid; + dc->texturemid = basetexturemid; +} + + +// Based off of R_GetLinedefTransTable +transnum_t R_GetThingTransTable(fixed_t alpha, transnum_t transmap) +{ + return static_cast((20*(FRACUNIT - ((alpha * (10 - transmap))/10) - 1) + FRACUNIT) >> (FRACBITS+1)); } // @@ -723,7 +751,7 @@ static void R_DrawFlippedMaskedColumn(column_t *column) static void R_DrawVisSprite(vissprite_t *vis) { column_t *column; - void (*localcolfunc)(column_t *); + void (*localcolfunc)(drawcolumndata_t*, column_t *); INT32 texturecolumn; INT32 pwidth; fixed_t frac; @@ -731,6 +759,7 @@ static void R_DrawVisSprite(vissprite_t *vis) fixed_t this_scale = vis->thingscale; INT32 x1, x2; INT64 overflow_test; + drawcolumndata_t dc = {}; if (!patch) return; @@ -756,76 +785,72 @@ static void R_DrawVisSprite(vissprite_t *vis) return; } - colfunc = basecolfunc; // hack: this isn't resetting properly somewhere. - dc_colormap = vis->colormap; + R_SetColumnFunc(BASEDRAWFUNC); // hack: this isn't resetting properly somewhere. + dc.colormap = vis->colormap; if ((vis->mobj->flags & MF_BOSS) && (vis->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash" { - // translate certain pixels to white - colfunc = transcolfunc; + R_SetColumnFunc(COLDRAWFUNC_TRANS); // translate certain pixels to white if (vis->mobj->type == MT_CYBRAKDEMON) - dc_translation = R_GetTranslationColormap(TC_ALLWHITE, 0, GTC_CACHE); + dc.translation = R_GetTranslationColormap(TC_ALLWHITE, SKINCOLOR_NONE, GTC_CACHE); else if (vis->mobj->type == MT_METALSONIC_BATTLE) - dc_translation = R_GetTranslationColormap(TC_METALSONIC, 0, GTC_CACHE); + dc.translation = R_GetTranslationColormap(TC_METALSONIC, SKINCOLOR_NONE, GTC_CACHE); else - dc_translation = R_GetTranslationColormap(TC_BOSS, 0, GTC_CACHE); + dc.translation = R_GetTranslationColormap(TC_BOSS, SKINCOLOR_NONE, GTC_CACHE); } else if (vis->mobj->color && vis->transmap) // Color mapping { - colfunc = transtransfunc; - dc_transmap = vis->transmap; + R_SetColumnFunc(COLDRAWFUNC_TRANSTRANS); + dc.transmap = vis->transmap; if (vis->mobj->colorized) - dc_translation = R_GetTranslationColormap(TC_RAINBOW, vis->mobj->color, GTC_CACHE); + dc.translation = R_GetTranslationColormap(TC_RAINBOW, static_cast(vis->mobj->color), GTC_CACHE); else if (vis->mobj->skin && vis->mobj->sprite == SPR_PLAY) // MT_GHOST LOOKS LIKE A PLAYER SO USE THE PLAYER TRANSLATION TABLES. >_> - dc_translation = R_GetLocalTranslationColormap(vis->mobj->skin, vis->mobj->localskin, vis->mobj->color, GTC_CACHE, vis->mobj->skinlocal); + dc.translation = R_GetLocalTranslationColormap(static_cast(vis->mobj->skin), static_cast(vis->mobj->localskin), static_cast(vis->mobj->color), GTC_CACHE, vis->mobj->skinlocal); else // Use the defaults - dc_translation = R_GetTranslationColormap(TC_DEFAULT, vis->mobj->color, GTC_CACHE); + dc.translation = R_GetTranslationColormap(TC_DEFAULT, static_cast(vis->mobj->color), GTC_CACHE); } else if (vis->transmap) { - colfunc = fuzzcolfunc; - dc_transmap = vis->transmap; //Fab : 29-04-98: translucency table + R_SetColumnFunc(COLDRAWFUNC_FUZZY); + dc.transmap = vis->transmap; //Fab : 29-04-98: translucency table } else if (vis->mobj->color) { // translate green skin to another color - colfunc = transcolfunc; + R_SetColumnFunc(COLDRAWFUNC_TRANS); // New colormap stuff for skins Tails 06-07-2002 if (vis->mobj->colorized) - dc_translation = R_GetTranslationColormap(TC_RAINBOW, vis->mobj->color, GTC_CACHE); + dc.translation = R_GetTranslationColormap(TC_RAINBOW, static_cast(vis->mobj->color), GTC_CACHE); else if (vis->mobj->skin && vis->mobj->sprite == SPR_PLAY) // This thing is a player! - dc_translation = R_GetLocalTranslationColormap(vis->mobj->skin, vis->mobj->localskin, vis->mobj->color, GTC_CACHE, vis->mobj->skinlocal); + dc.translation = R_GetLocalTranslationColormap(static_cast(vis->mobj->skin), static_cast(vis->mobj->localskin), static_cast(vis->mobj->color), GTC_CACHE, vis->mobj->skinlocal); else // Use the defaults - dc_translation = R_GetTranslationColormap(TC_DEFAULT, vis->mobj->color, GTC_CACHE); + dc.translation = R_GetTranslationColormap(TC_DEFAULT, static_cast(vis->mobj->color), GTC_CACHE); } else if (vis->mobj->sprite == SPR_PLAY) // Looks like a player, but doesn't have a color? Get rid of green sonic syndrome. { - colfunc = transcolfunc; - dc_translation = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_BLUE, GTC_CACHE); + R_SetColumnFunc(COLDRAWFUNC_TRANS); + dc.translation = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_BLUE, GTC_CACHE); } if (vis->extra_colormap) { - if (!dc_colormap) - dc_colormap = vis->extra_colormap->colormap; + if (!dc.colormap) + dc.colormap = vis->extra_colormap->colormap; else - dc_colormap = &vis->extra_colormap->colormap[dc_colormap - colormaps]; + dc.colormap = &vis->extra_colormap->colormap[dc.colormap - colormaps]; } - if (!dc_colormap) - dc_colormap = colormaps; + if (!dc.colormap) + dc.colormap = colormaps; if (encoremap && !vis->mobj->color && !(vis->mobj->flags & MF_DONTENCOREMAP)) - dc_colormap += COLORMAP_REMAPOFFSET; + dc.colormap += COLORMAP_REMAPOFFSET; - dc_texturemid = vis->texturemid; - dc_texheight = patch->height; + dc.texturemid = vis->texturemid; + dc.texheight = patch->height; frac = vis->startfrac; windowtop = windowbottom = sprbotscreen = INT32_MAX; - if ((vis->mobj->skin || vis->mobj->localskin) && K_GetMobjSkin(vis->mobj)->flags & SF_HIRES) - this_scale = FixedMul(this_scale, K_GetMobjSkin(vis->mobj)->highresscale); - if (this_scale <= 0) this_scale = 1; @@ -838,15 +863,15 @@ static void R_DrawVisSprite(vissprite_t *vis) vis->xiscale = FixedDiv(vis->xiscale, this_scale); vis->isScaled = true; } - dc_texturemid = FixedDiv(dc_texturemid, this_scale); + dc.texturemid = FixedDiv(dc.texturemid, this_scale); } spryscale = vis->scale; if (!(vis->scalestep)) { - sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale); - dc_iscale = FixedDiv(FRACUNIT, vis->scale); + sprtopscreen = centeryfrac - FixedMul(dc.texturemid, spryscale); + dc.iscale = FixedDiv(FRACUNIT, vis->scale); } x1 = vis->x1; @@ -872,9 +897,9 @@ static void R_DrawVisSprite(vissprite_t *vis) fixed_t scalestep = FixedMul(vis->scalestep, vis->spriteyscale); // Papersprite drawing loop - for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, spryscale += scalestep) + for (dc.x = vis->x1; dc.x <= vis->x2; dc.x++, spryscale += scalestep) { - angle_t angle = ((vis->centerangle + xtoviewangle[dc_x]) >> ANGLETOFINESHIFT) & 0xFFF; + angle_t angle = ((vis->centerangle + xtoviewangle[dc.x]) >> ANGLETOFINESHIFT) & 0xFFF; texturecolumn = (vis->paperoffset - FixedMul(FINETANGENT(angle), vis->paperdistance)) / horzscale; if (texturecolumn < 0 || texturecolumn >= pwidth) @@ -883,28 +908,26 @@ static void R_DrawVisSprite(vissprite_t *vis) if (vis->xiscale < 0) // Flipped sprite texturecolumn = pwidth - 1 - texturecolumn; - sprtopscreen = (centeryfrac - FixedMul(dc_texturemid, spryscale)); - dc_iscale = (0xffffffffu / (unsigned)spryscale); + sprtopscreen = (centeryfrac - FixedMul(dc.texturemid, spryscale)); + dc.iscale = (0xffffffffu / (unsigned)spryscale); column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); - localcolfunc (column); + localcolfunc(&dc, column); } } else { // Non-paper drawing loop - for (dc_x = vis->x1; dc_x <= vis->x2 && (frac>>FRACBITS) < pwidth; dc_x++, frac += vis->xiscale) + for (dc.x = vis->x1; dc.x <= vis->x2; dc.x++, frac += vis->xiscale) { texturecolumn = CLAMP(frac >> FRACBITS, 0, pwidth - 1); column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); - - localcolfunc (column); + localcolfunc(&dc, column); } } - colfunc = basecolfunc; - dc_hires = 0; + R_SetColumnFunc(BASEDRAWFUNC); vis->x1 = x1; vis->x2 = x2; @@ -919,9 +942,11 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) patch_t *patch; fixed_t this_scale = vis->thingscale; INT64 overflow_test; + drawcolumndata_t dc = {}; //Fab : R_InitSprites now sets a wad lump number patch = vis->patch; + if (!patch) return; @@ -932,21 +957,21 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) if (vis->transmap) { - colfunc = fuzzcolfunc; - dc_transmap = vis->transmap; //Fab : 29-04-98: translucency table + R_SetColumnFunc(COLDRAWFUNC_FUZZY); + dc.transmap = vis->transmap; //Fab : 29-04-98: translucency table } - dc_colormap = colormaps; + dc.colormap = colormaps; if (encoremap) - dc_colormap += COLORMAP_REMAPOFFSET; + dc.colormap += COLORMAP_REMAPOFFSET; - dc_iscale = FixedDiv(FRACUNIT, vis->scale); - dc_texturemid = FixedDiv(vis->texturemid, this_scale); - dc_texheight = patch->height; + dc.iscale = FixedDiv(FRACUNIT, vis->scale); + dc.texturemid = FixedDiv(vis->texturemid, this_scale); + dc.texheight = patch->height; frac = vis->startfrac; spryscale = vis->scale; - sprtopscreen = centeryfrac - FixedMul(dc_texturemid,spryscale); + sprtopscreen = centeryfrac - FixedMul(dc.texturemid,spryscale); windowtop = windowbottom = sprbotscreen = INT32_MAX; if (vis->x1 < 0) @@ -955,7 +980,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) if (vis->x2 >= vid.width) vis->x2 = vid.width-1; - for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale) + for (dc.x = vis->x1; dc.x <= vis->x2; dc.x++, frac += vis->xiscale) { texturecolumn = frac>>FRACBITS; @@ -967,10 +992,10 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); - R_DrawMaskedColumn(column); + R_DrawMaskedColumn(&dc, column); } - colfunc = basecolfunc; + R_SetColumnFunc(BASEDRAWFUNC); } // @@ -979,14 +1004,9 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) // static void R_SplitSprite(vissprite_t *sprite) { - INT32 i, lightnum, lindex; - INT16 cutfrac; - sector_t *sector; - vissprite_t *newsprite; + sector_t *sector = sprite->sector; - sector = sprite->sector; - - for (i = 1; i < sector->numlights; i++) + for (INT32 i = 1; i < sector->numlights; i++) { fixed_t testheight; @@ -1000,7 +1020,7 @@ static void R_SplitSprite(vissprite_t *sprite) if (testheight <= sprite->gz) return; - cutfrac = (INT16)((centeryfrac - FixedMul(testheight - viewz, sprite->sortscale))>>FRACBITS); + INT16 cutfrac = (INT16)((centeryfrac - FixedMul(testheight - viewz, sprite->sortscale))>>FRACBITS); if (cutfrac < 0) continue; if (cutfrac > viewheight) @@ -1008,9 +1028,18 @@ static void R_SplitSprite(vissprite_t *sprite) // Found a split! Make a new sprite, copy the old sprite to it, and // adjust the heights. - newsprite = M_Memcpy(R_NewVisSprite(), sprite, sizeof (vissprite_t)); + vissprite_t *newsprite = R_NewVisSprite(); - sprite->cut |= SC_BOTTOM; + // Needs to keep the new sprite's clipping tables + INT16 *cliptop = newsprite->cliptop; + INT16 *clipbot = newsprite->clipbot; + + M_Memcpy(newsprite, sprite, sizeof (vissprite_t)); + + newsprite->cliptop = cliptop; + newsprite->clipbot = clipbot; + + sprite->cut = static_cast(sprite->cut | SC_BOTTOM); sprite->gz = testheight; newsprite->gzt = sprite->gz; @@ -1028,10 +1057,11 @@ static void R_SplitSprite(vissprite_t *sprite) newsprite->szt -= 8; - newsprite->cut |= SC_TOP; + sprite->cut = static_cast(sprite->cut | SC_TOP); + if (!(sector->lightlist[i].caster->flags & FF_NOSHADE)) { - lightnum = (*sector->lightlist[i].lightlevel >> LIGHTSEGSHIFT); + INT32 lightnum = (*sector->lightlist[i].lightlevel >> LIGHTSEGSHIFT); if (lightnum < 0) spritelights = scalelight[0]; @@ -1045,7 +1075,7 @@ static void R_SplitSprite(vissprite_t *sprite) if (!((newsprite->cut & SC_FULLBRIGHT) && (!newsprite->extra_colormap || !(newsprite->extra_colormap->fog & 1)))) { - lindex = FixedMul(sprite->xscale, LIGHTRESOLUTIONFIX)>>(LIGHTSCALESHIFT); + INT32 lindex = FixedMul(sprite->xscale, LIGHTRESOLUTIONFIX)>>(LIGHTSCALESHIFT); // Mitigate against negative xscale and arithmetic overflow lindex = CLAMP(lindex, 0, MAXLIGHTSCALE - 1); @@ -1124,7 +1154,7 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) fixed_t R_GetSpriteDirectionalLighting(angle_t angle) { // Copied from P_UpdateSegLightOffset - const UINT8 contrast = min(max(0, maplighting.contrast - maplighting.backlight), UINT8_MAX); + const UINT8 contrast = std::min(std::max(0, maplighting.contrast - maplighting.backlight), UINT8_MAX); const fixed_t contrastFixed = ((fixed_t)contrast) * FRACUNIT; fixed_t light = FRACUNIT; @@ -1178,12 +1208,9 @@ static void R_ProjectSprite(mobj_t *thing) fixed_t offset, offset2; fixed_t paperoffset = 0, paperdistance = 0; angle_t centerangle = 0; - INT32 lightnum; - //SoM: 3/17/2000 fixed_t gz, gzt; INT32 heightsec, phs; - INT32 dist = -1; INT32 light = 0; lighttable_t **lights_array = spritelights; fixed_t this_scale; @@ -1200,7 +1227,7 @@ static void R_ProjectSprite(mobj_t *thing) angle_t sliptiderollangle = 0; #endif - if (P_MobjWasRemoved(thing) || thing->subsector == NULL) + if (!thing || thing->subsector == NULL) return; mobj_t *oldthing = thing; @@ -1210,14 +1237,11 @@ static void R_ProjectSprite(mobj_t *thing) const boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); const boolean papersprite = (thing->frame & FF_PAPERSPRITE); - if (cv_maxinterpdist.value) - dist = R_QuickCamDist(thing->x, thing->y); - // uncapped/interpolation - interpmobjstate_t interp = {0}; + interpmobjstate_t interp = {}; // do interpolation - if (R_UsingFrameInterpolation() && !paused && (!cv_maxinterpdist.value || dist < cv_maxinterpdist.value)) + if (R_UsingFrameInterpolation() && !paused && R_CheckInterpDist(oldthing)) { R_InterpolateMobjState(oldthing, rendertimefrac, &interp); } @@ -1244,7 +1268,7 @@ static void R_ProjectSprite(mobj_t *thing) tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); // sideways distance // too far off the side? - if (!papersprite && abs(tx) > tz<<2) // papersprite clipping is handled later + if (!papersprite && abs(tx) > (INT64)FixedMul(tz, fovtan)<<2) // papersprite clipping is handled later return; // aspect ratio stuff @@ -1470,7 +1494,7 @@ static void R_ProjectSprite(mobj_t *thing) tx2 = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); - if (max(tz, tz2) < FixedMul(MINZ, this_scale)) // non-papersprite clipping is handled earlier + if (std::max(tz, tz2) < FixedMul(MINZ, this_scale)) // non-papersprite clipping is handled earlier return; // Needs partially clipped @@ -1487,7 +1511,7 @@ static void R_ProjectSprite(mobj_t *thing) tz2 = FixedMul(MINZ, this_scale); } - if (tx2 < -(FixedMul(tz2, fovtan)<<2) || tx > FixedMul(tz, fovtan)<<2) // too far off the side? + if ((tx2 / 4) < -(FixedMul(tz2, fovtan)) || (tx / 4) > FixedMul(tz, fovtan)) // too far off the side? return; yscale = FixedDiv(projectiony, tz); @@ -1513,7 +1537,7 @@ static void R_ProjectSprite(mobj_t *thing) range++; // fencepost problem - if (range > 32767) + if (range > INT16_MAX) { // If the range happens to be too large for fixed_t, // abort the draw to avoid xscale becoming negative due to arithmetic overflow. @@ -1537,14 +1561,14 @@ static void R_ProjectSprite(mobj_t *thing) scalestep = 0; yscale = sortscale; tx += offset; - x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; + x1 = centerx + (FixedMul(tx,xscale) / FRACUNIT); // off the right side? if (x1 > viewwidth) return; tx += offset2; - x2 = ((centerxfrac + FixedMul(tx,xscale))>>FRACBITS); x2--; + x2 = (centerx + (FixedMul(tx,xscale) / FRACUNIT)) - 1; // off the left side if (x2 < 0) @@ -1561,13 +1585,13 @@ static void R_ProjectSprite(mobj_t *thing) return; } + // Determine the blendmode and translucency value INT32 blendmode; if (oldthing->frame & FF_BLENDMASK) blendmode = ((oldthing->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1; else blendmode = oldthing->blendmode; - // Determine the translucency value. if (oldthing->flags2 & MF2_SHADOW || thing->flags2 & MF2_SHADOW) // actually only the player should use this (temporary invisibility) trans = tr_trans80; // because now the translucency is set through FF_TRANSMASK else if (oldthing->frame & FF_TRANSMASK) @@ -1579,6 +1603,9 @@ static void R_ProjectSprite(mobj_t *thing) else trans = 0; + if (cv_playerfade.value && oldthing->player) + trans = static_cast(R_GetThingTransTable(R_DoPlayerFade(oldthing), static_cast(trans))); + //SoM: 3/17/2000: Disregard sprites that are out of view.. if (vflip) { @@ -1603,16 +1630,18 @@ static void R_ProjectSprite(mobj_t *thing) if (oldthing->frame & FF_ABSOLUTELIGHTLEVEL) { const UINT8 n = R_ThingLightLevel(oldthing); - // n = uint8 aka 0 - 255, so the shift will always be 0 - LIGHTLEVELS - 1 lights_array = scalelight[n >> LIGHTSEGSHIFT]; } else { + INT32 lightnum; + if (thing->subsector->sector->numlights) { light = thing->subsector->sector->numlights - 1; + // R_GetPlaneLight won't work on sloped lights! for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) { fixed_t h = P_GetLightZAt(&thing->subsector->sector->lightlist[lightnum], interp.x, interp.y); @@ -1633,7 +1662,7 @@ static void R_ProjectSprite(mobj_t *thing) lightnum = (lightnum + R_ThingLightLevel(thing)) >> LIGHTSEGSHIFT; - if (maplighting.directional == true && P_SectorUsesDirectionalLighting(thing->subsector->sector)) + if (maplighting.directional && P_SectorUsesDirectionalLighting(thing->subsector->sector)) { fixed_t extralight = R_GetSpriteDirectionalLighting(papersprite ? interp.angle + (ang >= ANGLE_180 ? -ANGLE_90 : ANGLE_90) @@ -1648,7 +1677,7 @@ static void R_ProjectSprite(mobj_t *thing) } // Less change in contrast in dark sectors - extralight = FixedMul(extralight, min(max(0, lightnum), LIGHTLEVELS - 1) * FRACUNIT / (LIGHTLEVELS - 1)); + extralight = FixedMul(extralight, std::min(std::max(0, lightnum), LIGHTLEVELS - 1) * FRACUNIT / (LIGHTLEVELS - 1)); if (papersprite) { @@ -1660,7 +1689,7 @@ static void R_ProjectSprite(mobj_t *thing) fixed_t n = FixedDiv(FixedMul(xscale, LIGHTRESOLUTIONFIX), ((MAXLIGHTSCALE-1) << LIGHTSCALESHIFT)); // Less change in contrast at further distances, to counteract DOOM diminished light - extralight = FixedMul(extralight, min(n, FRACUNIT)); + extralight = FixedMul(extralight, std::min(n, FRACUNIT)); // Contrast is stronger for normal sprites, stronger than wall lighting is at the same distance lightnum += FixedFloor((extralight / 4) + (FRACUNIT / 2)) / FRACUNIT; @@ -1676,23 +1705,20 @@ static void R_ProjectSprite(mobj_t *thing) } heightsec = thing->subsector->sector->heightsec; - if (viewplayer->mo && viewplayer->mo->subsector) + if (viewplayer && viewplayer->mo && viewplayer->mo->subsector) phs = viewplayer->mo->subsector->sector->heightsec; else phs = -1; if (heightsec != -1 && phs != -1) // only clip things which are in special sectors { - fixed_t top = gzt; - fixed_t bottom = interp.z; - if (viewz < sectors[phs].floorheight ? - bottom >= sectors[heightsec].floorheight : - top < sectors[heightsec].floorheight) + interp.z >= sectors[heightsec].floorheight : + gzt < sectors[heightsec].floorheight) return; if (viewz > sectors[phs].ceilingheight ? - top < sectors[heightsec].ceilingheight && viewz >= sectors[heightsec].ceilingheight : - bottom >= sectors[heightsec].ceilingheight) + gzt < sectors[heightsec].ceilingheight && viewz >= sectors[heightsec].ceilingheight : + interp.z >= sectors[heightsec].ceilingheight) return; } @@ -1765,11 +1791,11 @@ static void R_ProjectSprite(mobj_t *thing) vis->transmap = NULL; if (R_ThingIsFullBright(oldthing) || oldthing->flags2 & MF2_SHADOW || thing->flags2 & MF2_SHADOW) - vis->cut |= SC_FULLBRIGHT; + vis->cut = static_cast(vis->cut | SC_FULLBRIGHT); else if (R_ThingIsSemiBright(oldthing)) - vis->cut |= SC_SEMIBRIGHT; + vis->cut = static_cast(vis->cut | SC_SEMIBRIGHT); else if (R_ThingIsFullDark(oldthing)) - vis->cut |= SC_FULLDARK; + vis->cut = static_cast(vis->cut | SC_FULLDARK); // // determine the colormap (lightlevel & special effects) @@ -1804,7 +1830,7 @@ static void R_ProjectSprite(mobj_t *thing) vis->patch = rotsprite; else #endif - vis->patch = W_CachePatchNum(sprframe->lumppat[rot], PU_SPRITE); + vis->patch = static_cast(W_CachePatchNum(sprframe->lumppat[rot], PU_SPRITE)); vis->precip = false; @@ -1840,25 +1866,20 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) fixed_t gz, gzt; fixed_t this_scale; - INT32 dist = 1; - if (!thing || thing->subsector == NULL) return; - if (cv_maxinterpdist.value) - dist = R_QuickCamDist(thing->x, thing->y); - - // uncapped/interpolation - interpmobjstate_t interp = {0}; - // okay... this is a hack, but weather isn't networked, so it should be ok if (!P_PrecipThinker(thing)) { return; } + // uncapped/interpolation + interpmobjstate_t interp = {}; + // do interpolation - if (R_UsingFrameInterpolation() && !paused && (!cv_maxinterpdist.value || dist < cv_maxinterpdist.value)) + if (R_UsingFrameInterpolation() && !paused && R_CheckInterpDist((mobj_t*)thing)) { R_InterpolatePrecipMobjState(thing, rendertimefrac, &interp); } @@ -1892,7 +1913,6 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) // aspect ratio stuff : xscale = FixedDiv(projection, tz); - yscale = FixedDiv(projectiony, tz); // decide which patch to use for sprite relative to player #ifdef RANGECHECK @@ -1954,6 +1974,9 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) return; } + // aspect ratio stuff : + yscale = FixedDiv(projectiony, tz); + // store information in a vissprite vis = R_NewVisSprite(); vis->scale = FixedMul(yscale, this_scale); @@ -1964,7 +1987,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) vis->gy = interp.y; vis->gz = gz; vis->gzt = gzt; - vis->thingheight = 4*FRACUNIT; + vis->thingheight = 4 << FRACBITS; vis->pz = interp.z; vis->pzt = vis->pz + vis->thingheight; vis->texturemid = vis->gzt - viewz; @@ -1989,7 +2012,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) //Fab: lumppat is the lump number of the patch to use, this is different // than lumpid for sprites-in-pwad : the graphics are patched - vis->patch = W_CachePatchNum(sprframe->lumppat[0], PU_SPRITE); + vis->patch = static_cast(W_CachePatchNum(sprframe->lumppat[0], PU_SPRITE)); // specific translucency if ((thing->blendmode != AST_COPY) && cv_translucency.value) @@ -2108,9 +2131,7 @@ void R_AddPrecipitationSprites(void) // // R_SortVisSprites // -static vissprite_t vsprsortedhead; - -void R_SortVisSprites(void) +static void R_SortVisSprites(vissprite_t* vsprsortedhead, UINT32 start, UINT32 end) { UINT32 i; vissprite_t *ds, *dsprev, *dsnext, *dsfirst; @@ -2119,20 +2140,18 @@ void R_SortVisSprites(void) fixed_t bestscale; INT32 bestdispoffset; - if (!visspritecount) - return; - unsorted.next = unsorted.prev = &unsorted; - dsfirst = R_GetVisSprite(0); + dsfirst = R_GetVisSprite(start); // The first's prev and last's next will be set to // nonsense, but are fixed in a moment - for (i = 0, dsnext = dsfirst, ds = NULL; i < visspritecount; i++) + for (i = start, dsnext = dsfirst, ds = NULL; i < end; i++) { dsprev = ds; ds = dsnext; - if (i < visspritecount - 1) dsnext = R_GetVisSprite(i + 1); + if (i < end - 1) + dsnext = R_GetVisSprite(i + 1); ds->next = dsnext; ds->prev = dsprev; @@ -2146,8 +2165,8 @@ void R_SortVisSprites(void) unsorted.prev = ds; // pull the vissprites out by scale - vsprsortedhead.next = vsprsortedhead.prev = &vsprsortedhead; - for (i = 0; i < visspritecount; i++) + vsprsortedhead->next = vsprsortedhead->prev = vsprsortedhead; + for (i = start; i < end; i++) { bestscale = bestdispoffset = INT32_MAX; for (ds = unsorted.next; ds != &unsorted; ds = ds->next) @@ -2177,10 +2196,10 @@ void R_SortVisSprites(void) { best->next->prev = best->prev; best->prev->next = best->next; - best->next = &vsprsortedhead; - best->prev = vsprsortedhead.prev; - vsprsortedhead.prev->next = best; - vsprsortedhead.prev = best; + best->next = vsprsortedhead; + best->prev = vsprsortedhead->prev; + vsprsortedhead->prev->next = best; + vsprsortedhead->prev = best; } } } @@ -2191,28 +2210,29 @@ void R_SortVisSprites(void) static drawnode_t *R_CreateDrawNode(drawnode_t *link); static drawnode_t nodebankhead; -static drawnode_t nodehead; -static void R_CreateDrawNodes(void) +static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean tempskip) { drawnode_t *entry; drawseg_t *ds; INT32 i, p, best, x1, x2; fixed_t bestdelta, delta; vissprite_t *rover; + static vissprite_t vsprsortedhead; drawnode_t *r2; visplane_t *plane; INT32 sintersect; fixed_t scale = 0; + const INT32 vidheight = vid.height; // Add the 3D floors, thicksides, and masked textures... - for (ds = ds_p; ds-- > drawsegs ;) + for (ds = drawsegs + mask->drawsegs[1]; ds-- > drawsegs + mask->drawsegs[0];) { if (ds->numthicksides) { for (i = 0; i < ds->numthicksides; i++) { - entry = R_CreateDrawNode(&nodehead); + entry = R_CreateDrawNode(head); entry->thickseg = ds; entry->ffloor = ds->thicksides[i]; } @@ -2223,12 +2243,12 @@ static void R_CreateDrawNodes(void) plane = ds->curline->polyseg->visplane; R_PlaneBounds(plane); - if (plane->low < 0 || plane->high > vid.height || plane->high > plane->low) + if (plane->low < 0 || plane->high > vidheight || plane->high > plane->low) ; else { // Put it in! - entry = R_CreateDrawNode(&nodehead); + entry = R_CreateDrawNode(head); entry->plane = plane; entry->seg = ds; } @@ -2236,7 +2256,7 @@ static void R_CreateDrawNodes(void) } if (ds->maskedtexturecol) { - entry = R_CreateDrawNode(&nodehead); + entry = R_CreateDrawNode(head); entry->seg = ds; } if (ds->numffloorplanes) @@ -2253,7 +2273,7 @@ static void R_CreateDrawNodes(void) plane = ds->ffloorplanes[p]; R_PlaneBounds(plane); - if (plane->low < 0 || plane->high > vid.height || plane->high > plane->low || plane->polyobj) + if (plane->low < 0 || plane->high > vidheight || plane->high > plane->low || plane->polyobj) { ds->ffloorplanes[p] = NULL; continue; @@ -2268,7 +2288,7 @@ static void R_CreateDrawNodes(void) } if (best != -1) { - entry = R_CreateDrawNode(&nodehead); + entry = R_CreateDrawNode(head); entry->plane = ds->ffloorplanes[best]; entry->seg = ds; ds->ffloorplanes[best] = NULL; @@ -2279,6 +2299,9 @@ static void R_CreateDrawNodes(void) } } + if (tempskip) + return; + // find all the remaining polyobject planes and add them on the end of the list // probably this is a terrible idea if we wanted them to be sorted properly // but it works getting them in for now @@ -2290,31 +2313,32 @@ static void R_CreateDrawNodes(void) plane = PolyObjects[i].visplane; R_PlaneBounds(plane); - if (plane->low < 0 || plane->high > vid.height || plane->high > plane->low) + if (plane->low < 0 || plane->high > vidheight || plane->high > plane->low) { PolyObjects[i].visplane = NULL; continue; } - entry = R_CreateDrawNode(&nodehead); + entry = R_CreateDrawNode(head); entry->plane = plane; // note: no seg is set, for what should be obvious reasons PolyObjects[i].visplane = NULL; } - if (visspritecount == 0) + // No vissprites in this mask? + if (mask->vissprites[1] - mask->vissprites[0] == 0) return; - R_SortVisSprites(); + R_SortVisSprites(&vsprsortedhead, mask->vissprites[0], mask->vissprites[1]); for (rover = vsprsortedhead.prev; rover != &vsprsortedhead; rover = rover->prev) { - if (rover->szt > vid.height || rover->sz < 0) + if (rover->szt > vidheight || rover->sz < 0) continue; sintersect = (rover->x1 + rover->x2) / 2; - for (r2 = nodehead.next; r2 != &nodehead; r2 = r2->next) + for (r2 = head->next; r2 != head; r2 = r2->next) { if (r2->plane) { @@ -2326,21 +2350,17 @@ static void R_CreateDrawNodes(void) // Effective height may be different for each comparison in the case of slopes planeobjectz = P_GetZAt(r2->plane->slope, rover->gx, rover->gy, r2->plane->height); - planecameraz = P_GetZAt(r2->plane->slope, viewx, viewy, r2->plane->height); + planecameraz = P_GetZAt(r2->plane->slope, viewx, viewy, r2->plane->height); - if (rover->mobjflags & MF_NOCLIPHEIGHT) + // bird: if any part of the sprite peeks in front the plane + if (planecameraz < viewz) { - //Objects with NOCLIPHEIGHT can appear halfway in. - if (planecameraz < viewz && rover->pz+(rover->thingheight/2) >= planeobjectz) - continue; - if (planecameraz > viewz && rover->pzt-(rover->thingheight/2) <= planeobjectz) + if (rover->gzt >= planeobjectz) continue; } - else + else if (planecameraz > viewz) { - if (planecameraz < viewz && rover->pz >= planeobjectz) - continue; - if (planecameraz > viewz && rover->pzt <= planeobjectz) + if (rover->gz <= planeobjectz) continue; } @@ -2374,7 +2394,7 @@ static void R_CreateDrawNodes(void) } else if (r2->thickseg) { - fixed_t topplaneobjectz, topplanecameraz, botplaneobjectz, botplanecameraz; + //fixed_t topplaneobjectz, topplanecameraz, botplaneobjectz, botplanecameraz; if (rover->x1 > r2->thickseg->x2 || rover->x2 < r2->thickseg->x1) continue; @@ -2387,6 +2407,11 @@ static void R_CreateDrawNodes(void) if (scale <= rover->sortscale) continue; + // bird: Always sort sprites behind segs. This helps the plane + // sorting above too. Basically if the sprite gets sorted behind + // the seg here, it will be behind the plane too, since planes + // are added after segs in the list. +#if 0 topplaneobjectz = P_GetFFloorTopZAt (r2->ffloor, rover->gx, rover->gy); topplanecameraz = P_GetFFloorTopZAt (r2->ffloor, viewx, viewy); botplaneobjectz = P_GetFFloorBottomZAt(r2->ffloor, rover->gx, rover->gy); @@ -2395,6 +2420,7 @@ static void R_CreateDrawNodes(void) if ((topplanecameraz > viewz && botplanecameraz < viewz) || (topplanecameraz < viewz && rover->gzt < topplaneobjectz) || (botplanecameraz > viewz && rover->gz > botplaneobjectz)) +#endif { entry = R_CreateDrawNode(NULL); (entry->prev = r2->prev)->next = entry; @@ -2440,9 +2466,9 @@ static void R_CreateDrawNodes(void) } } } - if (r2 == &nodehead) + if (r2 == head) { - entry = R_CreateDrawNode(&nodehead); + entry = R_CreateDrawNode(head); entry->sprite = rover; } } @@ -2454,7 +2480,7 @@ static drawnode_t *R_CreateDrawNode(drawnode_t *link) if (node == &nodebankhead) { - node = malloc(sizeof (*node)); + node = static_cast(malloc(sizeof (*node))); if (!node) I_Error("No more free memory to CreateDrawNode"); } @@ -2486,25 +2512,24 @@ static void R_DoneWithNode(drawnode_t *node) (node->prev = &nodebankhead)->next = node; } -static void R_ClearDrawNodes(void) +static void R_ClearDrawNodes(drawnode_t* head) { drawnode_t *rover; drawnode_t *next; - for (rover = nodehead.next; rover != &nodehead ;) + for (rover = head->next; rover != head;) { next = rover->next; R_DoneWithNode(rover); rover = next; } - nodehead.next = nodehead.prev = &nodehead; + head->next = head->prev = head; } void R_InitDrawNodes(void) { nodebankhead.next = nodebankhead.prev = &nodebankhead; - nodehead.next = nodehead.prev = &nodehead; } // @@ -2543,7 +2568,7 @@ static boolean R_CheckSpriteVisible(vissprite_t *spr, INT32 x1, INT32 x2) scalestep = FixedMul(scalestep, spr->spriteyscale); if (spr->thingscale != FRACUNIT) - texturemid = FixedDiv(spr->texturemid, max(spr->thingscale, 1)); + texturemid = FixedDiv(spr->texturemid, std::max(spr->thingscale, 1)); else texturemid = spr->texturemid; } @@ -2568,7 +2593,7 @@ static boolean R_CheckSpriteVisible(vissprite_t *spr, INT32 x1, INT32 x2) // R_ClipVisSprite // Clips vissprites without drawing, so that portals can work. -Red -static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2) +static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, portal_t* portal) { drawseg_t *ds; INT32 x; @@ -2598,8 +2623,10 @@ static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2) while (++curr <= last) { + __builtin_prefetch(curr + 1, 0, 3); + // determine if the drawseg obscures the sprite - if (curr->x1 > spr->x2 || curr->x2 < spr->x1) + if (curr->x1 > x2 || curr->x2 < x1) { // does not cover sprite continue; @@ -2607,33 +2634,33 @@ static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2) ds = curr->user; - if (ds->portalpass > 0 && ds->portalpass <= portalrender) - continue; // is a portal - - r1 = ds->x1 < spr->x1 ? spr->x1 : ds->x1; - r2 = ds->x2 > spr->x2 ? spr->x2 : ds->x2; - - if (ds->scale1 > ds->scale2) + if (ds->portalpass != 66) // unused? { - lowscale = ds->scale2; - scale = ds->scale1; - } - else - { - lowscale = ds->scale1; - scale = ds->scale2; + if (ds->portalpass > 0 && ds->portalpass <= portalrender) + continue; // is a portal + + if (ds->scale1 > ds->scale2) + { + lowscale = ds->scale2; + scale = ds->scale1; + } + else + { + lowscale = ds->scale1; + scale = ds->scale2; + } + + if (scale < spr->sortscale || + (lowscale < spr->sortscale && + !R_PointOnSegSide(spr->gx, spr->gy, ds->curline))) + { + // seg is behind sprite + continue; + } } - if (scale < spr->sortscale || - (lowscale < spr->sortscale && - !R_PointOnSegSide (spr->gx, spr->gy, ds->curline))) - { - // masked mid texture? - /*if (ds->maskedtexturecol) - R_RenderMaskedSegRange (ds, r1, r2);*/ - // seg is behind sprite - continue; - } + r1 = ds->x1 < x1 ? x1 : ds->x1; + r2 = ds->x2 > x2 ? x2 : ds->x2; // clip this piece of the sprite silhouette = ds->silhouette; @@ -2675,20 +2702,21 @@ static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2) if (spr->heightsec != -1) // only things in specially marked sectors { fixed_t mh, h; - INT32 phs = viewplayer->mo->subsector->sector->heightsec; + const INT32 phs = viewplayer->mo->subsector->sector->heightsec; + if ((mh = sectors[spr->heightsec].floorheight) > spr->gz && (h = centeryfrac - FixedMul(mh -= viewz, spr->sortscale)) >= 0 && (h >>= FRACBITS) < viewheight) { if (mh <= 0 || (phs != -1 && viewz > sectors[phs].floorheight)) { // clip bottom - for (x = spr->x1; x <= spr->x2; x++) + for (x = x1; x <= x2; x++) if (spr->clipbot[x] == -2 || h < spr->clipbot[x]) spr->clipbot[x] = (INT16)h; } else // clip top { - for (x = spr->x1; x <= spr->x2; x++) + for (x = x1; x <= x2; x++) if (spr->cliptop[x] == -2 || h > spr->cliptop[x]) spr->cliptop[x] = (INT16)h; } @@ -2700,21 +2728,22 @@ static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2) { if (phs != -1 && viewz >= sectors[phs].ceilingheight) { // clip bottom - for (x = spr->x1; x <= spr->x2; x++) + for (x = x1; x <= x2; x++) if (spr->clipbot[x] == -2 || h < spr->clipbot[x]) spr->clipbot[x] = (INT16)h; } else // clip top { - for (x = spr->x1; x <= spr->x2; x++) + for (x = x1; x <= x2; x++) if (spr->cliptop[x] == -2 || h > spr->cliptop[x]) spr->cliptop[x] = (INT16)h; } } } + if (spr->cut & SC_TOP && spr->cut & SC_BOTTOM) { - for (x = spr->x1; x <= spr->x2; x++) + for (x = x1; x <= x2; x++) { if (spr->cliptop[x] == -2 || spr->szt > spr->cliptop[x]) spr->cliptop[x] = spr->szt; @@ -2725,7 +2754,7 @@ static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2) } else if (spr->cut & SC_TOP) { - for (x = spr->x1; x <= spr->x2; x++) + for (x = x1; x <= x2; x++) { if (spr->cliptop[x] == -2 || spr->szt > spr->cliptop[x]) spr->cliptop[x] = spr->szt; @@ -2733,7 +2762,7 @@ static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2) } else if (spr->cut & SC_BOTTOM) { - for (x = spr->x1; x <= spr->x2; x++) + for (x = x1; x <= x2; x++) { if (spr->clipbot[x] == -2 || spr->sz < spr->clipbot[x]) spr->clipbot[x] = spr->sz; @@ -2743,7 +2772,7 @@ static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2) // all clipping has been performed, so store the values - what, did you think we were drawing them NOW? // check for unclipped columns - for (x = spr->x1; x <= spr->x2; x++) + for (x = x1; x <= x2; x++) { if (spr->clipbot[x] == -2) spr->clipbot[x] = (INT16)viewheight; @@ -2757,13 +2786,37 @@ static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2) if (cv_spriteclip.value) { if (!R_CheckSpriteVisible(spr, x1, x2)) - spr->cut |= SC_NOTVISIBLE; + spr->cut = static_cast(spr->cut | SC_NOTVISIBLE); + } + + if (portal) + { + INT32 start_index = std::max(portal->start, x1); + INT32 end_index = std::min(portal->start + portal->end - portal->start, x2); + + for (x = x1; x < start_index; x++) + { + spr->clipbot[x] = -1; + spr->cliptop[x] = -1; + } + for (x = start_index; x <= end_index; x++) + { + if (spr->clipbot[x] > portal->floorclip[x - portal->start]) + spr->clipbot[x] = portal->floorclip[x - portal->start]; + if (spr->cliptop[x] < portal->ceilingclip[x - portal->start]) + spr->cliptop[x] = portal->ceilingclip[x - portal->start]; + } + for (x = end_index + 1; x <= x2; x++) + { + spr->clipbot[x] = -1; + spr->cliptop[x] = -1; + } } } -void R_ClipSprites(void) +void R_ClipSprites(drawseg_t* dsstart, portal_t* portal) { - const size_t maxdrawsegs = ds_p - drawsegs; + const size_t maxdrawsegs = ds_p - dsstart; const INT32 cx = viewwidth / 2; drawseg_t* ds; INT32 i; @@ -2788,15 +2841,15 @@ void R_ClipSprites(void) for (i = 0; i < DS_RANGES_COUNT; i++) { - drawsegs_xranges[i].items = Z_Realloc( + drawsegs_xranges[i].items = static_cast(Z_Realloc( drawsegs_xranges[i].items, drawsegs_xrange_size * sizeof(drawsegs_xranges[i].items[0]), PU_STATIC, NULL - ); + )); } } - for (ds = ds_p; ds-- > drawsegs;) + for (ds = ds_p; ds-- > dsstart;) { if (ds->silhouette || ds->maskedtexturecol) { @@ -2830,7 +2883,7 @@ void R_ClipSprites(void) if (cv_spriteclip.value && (spr->szt > vid.height || spr->sz < 0)) { - spr->cut |= SC_NOTVISIBLE; + spr->cut = static_cast(spr->cut | SC_NOTVISIBLE); continue; } @@ -2850,7 +2903,7 @@ void R_ClipSprites(void) drawsegs_xrange_count = drawsegs_xranges[0].count; } - R_ClipVisSprite(spr, spr->x1, spr->x2); + R_ClipVisSprite(spr, spr->x1, spr->x2, portal); if ((spr->cut & SC_NOTVISIBLE) == 0) numvisiblesprites++; @@ -2858,14 +2911,14 @@ void R_ClipSprites(void) } /* Check if thing may be drawn from our current view. */ -boolean R_ThingVisible (mobj_t *thing) +boolean R_ThingVisible(mobj_t *thing) { if (UNLIKELY((thing->sprite == SPR_NULL) || (thing->flags2 & MF2_DONTDRAW))) return false; - if (splitscreen) + if (UNLIKELY(splitscreen)) { - if ((viewssnum == 0 && (thing->eflags & MFE_DRAWONLYFORP1)) + if ((viewssnum == 0 && (thing->eflags & MFE_DRAWONLYFORP1)) || (viewssnum == 1 && (thing->eflags & MFE_DRAWONLYFORP2)) || (viewssnum == 2 && (thing->eflags & MFE_DRAWONLYFORP2)) || (viewssnum == 3 && (thing->eflags & MFE_DRAWONLYFORP4))) @@ -2879,7 +2932,7 @@ boolean R_ThingWithinDist(mobj_t *thing, INT32 limit_dist) { if (limit_dist) { - if (P_AproxDistance(viewx-thing->x, viewy-thing->y)/mapobjectscale > limit_dist) + if ((R_QuickCamDist(thing->x, thing->y) << FRACBITS)/mapobjectscale > limit_dist) { return false; } @@ -2888,6 +2941,42 @@ boolean R_ThingWithinDist(mobj_t *thing, INT32 limit_dist) return true; } +fixed_t R_DoPlayerFade(mobj_t *thing) +{ + fixed_t fadealpha = FRACUNIT; + static constexpr tic_t countdownstarttime = (15 * TICRATE) / 4; // starttime - (3*TICRATE) + + if (thing->player == viewplayer || viewplayer->exiting || camera[R_GetViewNumber()].freecam || leveltime < countdownstarttime) + return fadealpha; + + const INT32 playerdist = (FixedMul((thing->x - viewx), viewcos) + FixedMul((thing->y - viewy), viewsin)) >> FRACBITS; + const INT32 viewplayerdist = (FixedMul((viewplayer->mo->x - viewx), viewcos) + FixedMul((viewplayer->mo->y - viewy), viewsin)) >> FRACBITS; + + if (playerdist < viewplayerdist) + { + if (playerdist < viewplayerdist / 2) // stronger fade when very close + { + fadealpha = (playerdist * FRACUNIT) / (viewplayerdist / 2) / 3; + } + else + { + fadealpha = (playerdist * FRACUNIT) / viewplayerdist; + } + } + + return fadealpha; +} + +boolean R_CheckInterpDist(mobj_t *thing) +{ + if (!cv_maxinterpdist.value) + return true; + + const INT32 dist = R_QuickCamDist(thing->x, thing->y); + + return (dist < cv_maxinterpdist.value); +} + boolean R_ThingIsFullBright(mobj_t *thing) { return ((thing->frame & FF_BRIGHTMASK) == FF_FULLBRIGHT); @@ -2906,26 +2995,39 @@ boolean R_ThingIsFullDark(mobj_t *thing) // // R_DrawMasked // -void R_DrawMasked(void) +static void R_DrawMaskedList(drawnode_t* head) { drawnode_t *r2; drawnode_t *next; - R_CreateDrawNodes(); - - for (r2 = nodehead.next; r2 != &nodehead; r2 = r2->next) + for (r2 = head->next; r2 != head; r2 = r2->next) { if (r2->plane) { + drawspandata_t ds = {}; next = r2->prev; - R_DrawSinglePlane(r2->plane); + boolean parallel = cv_parallelsoftware.value && cv_paralleldrawmasked.value; +#ifdef HAVE_THREADS + srb2::ThreadPool::Sema tp_sema; + if (parallel) + srb2::g_main_threadpool->begin_sema(); +#endif + R_DrawSinglePlane(&ds, r2->plane, parallel); +#ifdef HAVE_THREADS + if (parallel) + { + tp_sema = srb2::g_main_threadpool->end_sema(); + srb2::g_main_threadpool->notify_sema(tp_sema); + srb2::g_main_threadpool->wait_sema(tp_sema); + } +#endif R_DoneWithNode(r2); r2 = next; } else if (r2->seg && r2->seg->maskedtexturecol != NULL) { next = r2->prev; - R_RenderMaskedSegRange(r2->seg, r2->seg->x1, r2->seg->x2); + R_RenderMaskedSegRange( r2->seg, r2->seg->x1, r2->seg->x2); r2->seg->maskedtexturecol = NULL; R_DoneWithNode(r2); r2 = next; @@ -2942,775 +3044,50 @@ void R_DrawMasked(void) next = r2->prev; // Tails 08-18-2002 - if (r2->sprite->precip == true) + if (r2->sprite->precip) + { R_DrawPrecipitationSprite(r2->sprite); + } else + { R_DrawSprite(r2->sprite); + } R_DoneWithNode(r2); r2 = next; } } - R_ClearDrawNodes(); } -// ========================================================================== -// -// SKINS CODE -// -// ========================================================================== - -INT32 numskins = 0; -INT32 numallskins = 0; -INT32 numlocalskins = 0; -skin_t skins[MAXSKINS]; -UINT8 skinstats[9][9][MAXSKINS]; -UINT8 skinstatscount[9][9] = { - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 1, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0} -}; -UINT8 skinsorted[MAXSKINS]; -skin_t localskins[MAXLOCALSKINS]; -skin_t allskins[MAXSKINS+MAXLOCALSKINS]; - -// FIXTHIS: don't work because it must be inistilised before the config load -//#define SKINVALUES -#ifdef SKINVALUES -CV_PossibleValue_t skin_cons_t[MAXSKINS+1]; -CV_PossibleValue_t localskin_cons_t[MAXLOCALSKINS+1]; -#endif - -static void Sk_SetDefaultValue(skin_t *skin, boolean local) +void R_DrawMasked(maskcount_t* masks, INT32 nummasks) { INT32 i; - // - // set default skin values - // - memset(skin, 0, sizeof (skin_t)); - snprintf(skin->name, sizeof skin->name, "skin %u", K_GetMobjSkinNum(skin, local)); - skin->name[sizeof skin->name - 1] = '\0'; - skin->wadnum = INT16_MAX; - strcpy(skin->sprite, ""); + drawnode_t *heads; /**< Drawnode lists; as many as number of views/portals. */ - skin->flags = 0; + heads = static_cast(calloc(nummasks, sizeof(drawnode_t))); - strcpy(skin->realname, "Someone"); - strcpy(skin->hudname, "???"); - strncpy(skin->facerank, "PLAYRANK", 9); - strncpy(skin->facewant, "PLAYWANT", 9); - strncpy(skin->facemmap, "PLAYMMAP", 9); + for (i = 0; i < nummasks; i++) + { + heads[i].next = heads[i].prev = &heads[i]; - skin->starttranscolor = 160; - skin->prefcolor = SKINCOLOR_GREEN; + viewx = masks[i].viewx; + viewy = masks[i].viewy; + viewz = masks[i].viewz; + viewsector = masks[i].viewsector; - // SRB2kart - skin->kartspeed = 5; - skin->kartweight = 5; - // + R_CreateDrawNodes(&masks[i], &heads[i], false); + } - skin->highresscale = FRACUNIT>>1; + for (; nummasks > 0; nummasks--) + { + viewx = masks[nummasks - 1].viewx; + viewy = masks[nummasks - 1].viewy; + viewz = masks[nummasks - 1].viewz; + viewsector = masks[nummasks - 1].viewsector; - for (i = 0; i < sfx_skinsoundslot0; i++) - if (S_sfx[i].skinsound != -1) - skin->soundsid[S_sfx[i].skinsound] = i; -} - -// -// Initialize the basic skins -// -void R_InitSkins(void) -{ - skin_t *skin; -#ifdef SKINVALUES - INT32 i; - - for (i = 0; i <= MAXSKINS; i++) - { - skin_cons_t[i].value = 0; - skin_cons_t[i].strvalue = NULL; - } - for (i = 0; i <= MAXLOCALSKINS; i++) - { - localskin_cons_t[i].value = 0; - localskin_cons_t[i].strvalue = NULL; - } -#endif - - // skin[0] = Sonic skin - skin = &skins[0]; - numskins = 1; - Sk_SetDefaultValue(skin, false); - memset(skinstats, 0, sizeof(skinstats)); - memset(skinsorted, 0, sizeof(skinsorted)); - - // Hardcoded S_SKIN customizations for Sonic. - strcpy(skin->name, DEFAULTSKIN); -#ifdef SKINVALUES - skin_cons_t[0].strvalue = skins[0].name; -#endif - skin->flags = 0; - strcpy(skin->realname, "Sonic"); - strcpy(skin->hudname, "SONIC"); - - strncpy(skin->facerank, "PLAYRANK", 9); - strncpy(skin->facewant, "PLAYWANT", 9); - strncpy(skin->facemmap, "PLAYMMAP", 9); - skin->wadnum = 0; // god what have you brought to this world - skin->prefcolor = SKINCOLOR_BLUE; - skin->localskin = false; - skin->localnum = 0; - - // SRB2kart - skin->kartspeed = 8; - skin->kartweight = 2; - // - - skin->spritedef.numframes = sprites[SPR_PLAY].numframes; - skin->spritedef.spriteframes = sprites[SPR_PLAY].spriteframes; - skin->sprinfo = spriteinfo[SPR_PLAY]; - ST_LoadFaceGraphics(skin->facerank, skin->facewant, skin->facemmap, 0); - - // Set values for Sonic skin - Forceskin_cons_t[1].value = 0; - Forceskin_cons_t[1].strvalue = skin->name; - - //MD2 for sonic doesn't want to load in Linux. -#ifdef HWRENDER - if (rendermode == render_opengl) - HWR_AddPlayerMD2(0, false); -#endif - - // lets set it - allskins[0] = skins[0]; - numallskins = 1; -} - -// returns true if the skin name is found (loaded from pwad) -// warning return -1 if not found -INT32 R_SkinAvailable(const char *name) -{ - INT32 i; - - for (i = 0; i < numskins; i++) - { - if (stricmp(skins[i].name,name) == 0) - return i; - } - return -1; -} - -// returns true if the skin name is found (loaded from pwad) -// warning return -1 if not found -INT32 R_AnySkinAvailable(const char *name) -{ - INT32 i; - - for (i = 0; i < numallskins; i++) - { - if (stricmp(allskins[i].name,name) == 0) - return i; - } - return -1; -} - -INT32 R_LocalSkinAvailable(const char *name, boolean local) -{ - INT32 i; - - if (local) - { - for (i = 0; i < numlocalskins; i++) - { - if (stricmp(localskins[i].name,name) == 0) - return i; - } - return -1; - } - else - return R_SkinAvailable(name); -} - -// network code calls this when a 'skin change' is received -boolean SetPlayerSkin(INT32 playernum, const char *skinname) -{ - INT32 i; - player_t *player = &players[playernum]; - - for (i = 0; i < numskins; i++) - { - // search in the skin list - if (stricmp(skins[i].name, skinname) == 0) - { - SetPlayerSkinByNum(playernum, i); - return true; - } + R_DrawMaskedList(&heads[nummasks - 1]); + R_ClearDrawNodes(&heads[nummasks - 1]); } - - if (P_IsLocalPlayer(player)) - CONS_Alert(CONS_WARNING, M_GetText("Skin '%s' not found.\n"), skinname); - else if(server || IsPlayerAdmin(consoleplayer)) - CONS_Alert(CONS_WARNING, M_GetText("Player %d (%s) skin '%s' not found\n"), playernum, player_names[playernum], skinname); - - SetPlayerSkinByNum(playernum, 0); - return false; -} - -void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) -{ - INT32 i; - player_t *player = &players[playernum]; - - if (stricmp(skinname, "none")) - { - for (i = 0; i < numlocalskins; i++) - { - // search in the localskin list - if (stricmp(localskins[i].name, skinname) == 0) - { - player->localskin = 1 + i; - player->skinlocal = true; - if (player->mo) - { - player->mo->localskin = &localskins[i]; - player->mo->skinlocal = true; - } - - goto setcvar; - } - } - - for (i = 0; i < numskins; i++) - { - // search in the skin list - if (stricmp(skins[i].name, skinname) == 0) - { - player->localskin = 1 + i; - player->skinlocal = false; - if (player->mo) - { - player->mo->localskin = &skins[i]; - player->mo->skinlocal = false; - } - - goto setcvar; - } - } - } - else - { - player->localskin = 0; - player->skinlocal = false; - if (player->mo) - { - player->mo->localskin = 0; - player->mo->skinlocal = false; - } - } - -setcvar: - if (cvar != NULL) - { - if (player->localskin > 0) - { - CV_StealthSet(&cv_fakelocalskin, K_GetSkinArray(player->skinlocal)[player->localskin-1].name); - CV_StealthSet(cvar, K_GetSkinArray(player->skinlocal)[player->localskin-1].name); - - } - else - { - CV_StealthSet(&cv_fakelocalskin, "none"); - CV_StealthSet(cvar, "none"); - } - } -} - -// Same as SetPlayerSkin, but uses the skin #. -// network code calls this when a 'skin change' is received -void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum) -{ - player_t *player = &players[playernum]; - skin_t *skin = &skins[skinnum]; - - if (skinnum >= 0 && skinnum < numskins) // Make sure it exists! - { - player->skin = skinnum; - if (player->mo) - player->mo->skin = skin; - - player->charflags = (UINT32)skin->flags; - - // SRB2kart - player->kartspeed = skin->kartspeed; - player->kartweight = skin->kartweight; - - if (player->mo) - P_SetScale(player->mo, player->mo->scale); - - demo_extradata[playernum] |= DXD_SKIN; - - return; - } - - if (P_IsLocalPlayer(player)) - CONS_Alert(CONS_WARNING, M_GetText("Skin %d not found\n"), skinnum); - else if(server || IsPlayerAdmin(consoleplayer)) - CONS_Alert(CONS_WARNING, "Player %d (%s) skin %d not found\n", playernum, player_names[playernum], skinnum); - - SetPlayerSkinByNum(playernum, 0); // not found put the sonic skin -} - -// -// Add skins from a pwad, each skin preceded by 'S_SKIN' marker -// - -// Does the same is in w_wad, but check only for -// the first 6 characters (this is so we can have S_SKIN1, S_SKIN2.. -// for wad editors that don't like multiple resources of the same name) -// -static UINT16 W_CheckForSkinMarkerInPwad(UINT16 wadid, UINT16 startlump) -{ - UINT16 i; - const char *S_SKIN = "S_SKIN"; - lumpinfo_t *lump_p; - - // scan forward, start at - if (startlump < wadfiles[wadid]->numlumps) - { - lump_p = wadfiles[wadid]->lumpinfo + startlump; - for (i = startlump; i < wadfiles[wadid]->numlumps; i++, lump_p++) - if (memcmp(lump_p->name,S_SKIN,6)==0) - return i; - } - return INT16_MAX; // not found -} - -//sort function for sorting skin names -static int skinSortFunc(const void *a, const void *b) //tbh i have no clue what the naming conventions for local functions are -{ - const skin_t *in1 = &skins[*(const UINT8 *)a]; - const skin_t *in2 = &skins[*(const UINT8 *)b]; - INT32 temp = 0; - const UINT8 val_a = *((const UINT8 *)a); - const UINT8 val_b = *((const UINT8 *)b); - - //return (strcmp(in1->realname, in2->realname) < 0) || (strcmp(in1->realname, in2->realname) ==); - - switch (cv_skinselectgridsort.value) - { - case SKINMENUSORT_REALNAME: - //CONS_Printf("Sorting by realname\n"); - // check name - if ((temp = strcmp(in1->realname, in2->realname))) - return temp; - // sort by internal name - return strcmp(in1->name, in2->name); - break; - - case SKINMENUSORT_NAME: - //CONS_Printf("Sorting by name\n"); - return strcmp(in1->name, in2->name); - break; - - case SKINMENUSORT_SPEED: - //CONS_Printf("Sorting by speed\n"); - // check speed - if (in1->kartspeed < in2->kartspeed) - return -1; - else if (in2->kartspeed < in1->kartspeed) - return 1; - // then check weight - if (in1->kartweight < in2->kartweight) - return -1; - else if (in2->kartweight < in1->kartweight) - return 1; - // then check name - if ((temp = strcmp(in1->realname, in2->realname))) - return temp; - // sort by internal name - return strcmp(in1->name, in2->name); - break; - - case SKINMENUSORT_WEIGHT: - //CONS_Printf("Sorting by weight\n"); - // check weight - if (in1->kartweight < in2->kartweight) - return -1; - else if (in2->kartweight < in1->kartweight) - return 1; - // then check speed - if (in1->kartspeed < in2->kartspeed) - return -1; - else if (in2->kartspeed < in1->kartspeed) - return 1; - // then check name - if ((temp = strcmp(in1->realname, in2->realname))) - return temp; - // sort by internal name - return strcmp(in1->name, in2->name); - break; - - case SKINMENUSORT_PREFCOLOR: - //CONS_Printf("Sorting by prefcolor\n"); - // check prefcolor - if (in1->prefcolor < in2->prefcolor) - return -1; - else if (in2->prefcolor < in1->prefcolor) - return 1; - // then check name - if ((temp = strcmp(in1->realname, in2->realname))) - return temp; - // sort by internal name - return strcmp(in1->name, in2->name); - break; - - case SKINMENUSORT_ID: - //CONS_Printf("Sorting by id\n"); - //how do i do by ID????? - //wait why dont i just convert the inputs to UINT32s - //please tell me im allowed to define variables in here since its a block - - if (val_a == val_b) - return 0; - else if (val_a < val_b) - return -1; - else - return 1; - - default: - return strcmp(in1->name, in2->name); - break; - } - //im scared this somehow will sometimes end up here so im gonna add this here just to be safe - return strcmp(in1->name, in2->name); -} - -void sortSkinGrid(void) -{ - //CONS_Printf("Sorting skin list (%d)...\n", cv_skinselectgridsort.value); - qs22j(skinsorted, numskins, sizeof(UINT8), skinSortFunc); -} - -// -// Find skin sprites, sounds & optional status bar face, & add them -// -void R_AddSkins(UINT16 wadnum, boolean local) -{ - UINT16 lump, lastlump = 0; - char *buf; - char *buf2; - char *stoken; - char *value; - size_t size; - skin_t *skin; - boolean hudname, realname; - -#define lnumskins (local ? numlocalskins : numskins) - - // - // search for all skin markers in pwad - // - - while ((lump = W_CheckForSkinMarkerInPwad(wadnum, lastlump)) != INT16_MAX) - { - // advance by default - lastlump = lump + 1; - - if (!local && numskins >= MAXSKINS) - { - CONS_Alert(CONS_WARNING, M_GetText("Unable to add skin, too many characters are loaded (%d maximum)\n"), MAXSKINS); - continue; // so we know how many skins couldn't be added - } - if (local && numlocalskins >= MAXLOCALSKINS) - { - CONS_Alert(CONS_WARNING, M_GetText("Unable to add localskin, too many localskins are loaded (%d maximum)\n"), MAXLOCALSKINS); - continue; // so we know how many skins couldn't be added - } - - buf = W_CacheLumpNumPwad(wadnum, lump, PU_CACHE); - size = W_LumpLengthPwad(wadnum, lump); - - // for strtok - buf2 = malloc(size+1); - if (!buf2) - I_Error("R_AddSkins: No more free memory\n"); - M_Memcpy(buf2,buf,size); - buf2[size] = '\0'; - - // set defaults - skin = &K_GetSkinArray(local)[lnumskins]; - Sk_SetDefaultValue(skin, local); - skin->wadnum = wadnum; - hudname = realname = false; - // parse - stoken = strtok (buf2, "\r\n= "); - while (stoken) - { - if ((stoken[0] == '/' && stoken[1] == '/') - || (stoken[0] == '#'))// skip comments - { - stoken = strtok(NULL, "\r\n"); // skip end of line - goto next_token; // find the real next token - } - - value = strtok(NULL, "\r\n= "); - - if (!value) - I_Error("R_AddSkins: syntax error in S_SKIN lump# %d(%s) in WAD %s\n", lump, W_CheckNameForNumPwad(wadnum,lump), wadfiles[wadnum]->filename); - - if (!stricmp(stoken, "name")) - { - // the skin name must uniquely identify a single skin - // I'm lazy so if name is already used I leave the 'skin x' - // default skin name set in Sk_SetDefaultValue - if (R_LocalSkinAvailable(value, local) == -1) - { - STRBUFCPY(skin->name, value); - strlwr(skin->name); - } - // I'm not lazy, so if the name is already used I make the name 'namex' - // using the default skin name's number set above - else - { - const size_t stringspace = - strlen(value) + sizeof lnumskins + 1; - char *value2 = Z_Malloc(stringspace, PU_STATIC, NULL); - snprintf(value2, stringspace, - "%s%d", value, lnumskins); - value2[stringspace - 1] = '\0'; - if (R_LocalSkinAvailable(value2, local) == -1) - { - STRBUFCPY(skin->name, - value2); - strlwr(skin->name); - } - Z_Free(value2); - } - - // copy to hudname and fullname as a default. - if (!realname) - { - STRBUFCPY(skin->realname, skin->name); - for (value = skin->realname; *value; value++) - if (*value == '_') *value = ' '; // turn _ into spaces. - } - if (!hudname) - { - STRBUFCPY(skin->hudname, skin->name); - strupr(skin->hudname); - for (value = skin->hudname; *value; value++) - if (*value == '_') *value = ' '; // turn _ into spaces. - } - } - else if (!stricmp(stoken, "realname")) - { // Display name (eg. "Knuckles") - realname = true; - STRBUFCPY(skin->realname, value); - for (value = skin->realname; *value; value++) - if (*value == '_') *value = ' '; // turn _ into spaces. - if (!hudname) - STRBUFCPY(skin->hudname, skin->realname); - } - else if (!stricmp(stoken, "hudname")) - { // Life icon name (eg. "K.T.E") - hudname = true; - STRBUFCPY(skin->hudname, value); - for (value = skin->hudname; *value; value++) - if (*value == '_') *value = ' '; // turn _ into spaces. - if (!realname) - STRBUFCPY(skin->realname, skin->hudname); - } - - else if (!stricmp(stoken, "sprite")) - { - strupr(value); - memcpy(skin->sprite, value, sizeof skin->sprite); - } - else if (!stricmp(stoken, "facerank")) - { - strupr(value); - memcpy(skin->facerank, value, sizeof(skin->facerank)-1); - skin->facerank[sizeof(skin->facerank)-1] = '\0'; - } - else if (!stricmp(stoken, "facewant")) - { - strupr(value); - memcpy(skin->facewant, value, sizeof(skin->facewant)-1); - skin->facewant[sizeof(skin->facewant)-1] = '\0'; - } - else if (!stricmp(stoken, "facemmap")) - { - strupr(value); - strncpy(skin->facemmap, value, sizeof(skin->facemmap)-1); - skin->facemmap[sizeof(skin->facemmap)-1] = '\0'; - } - -#define FULLPROCESS(field) else if (!stricmp(stoken, #field)) skin->field = get_number(value); - // character type identification - FULLPROCESS(flags) -#undef FULLPROCESS - -#define GETKARTSTAT(field) \ - else if (!stricmp(stoken, #field)) \ - { \ - skin->field = atoi(value); \ - if (skin->field < 1) skin->field = 1; \ - if (skin->field > 9) skin->field = 9; \ - } - GETKARTSTAT(kartspeed) - GETKARTSTAT(kartweight) -#undef GETKARTSTAT - - // custom translation table - else if (!stricmp(stoken, "startcolor")) - skin->starttranscolor = atoi(value); - - else if (!stricmp(stoken, "prefcolor")) - skin->prefcolor = K_GetKartColorByName(value); - else if (!stricmp(stoken, "highresscale")) - skin->highresscale = FLOAT_TO_FIXED(atof(value)); - else - { - INT32 found = false; - sfxenum_t i; - // copy name of sounds that are remapped - // for this skin - for (i = 0; i < sfx_skinsoundslot0; i++) - { - if (!S_sfx[i].name) - continue; - if (S_sfx[i].skinsound != -1 - && !stricmp(S_sfx[i].name, - stoken + 2)) - { - skin->soundsid[S_sfx[i].skinsound] = - S_AddSoundFx(value+2, S_sfx[i].singularity, S_sfx[i].pitch, true); - found = true; - } - } - if (!found) - CONS_Debug(DBG_SETUP, "R_AddSkins: Unknown keyword '%s' in S_SKIN lump# %d (WAD %s)\n", stoken, lump, wadfiles[wadnum]->filename); - } -next_token: - stoken = strtok(NULL, "\r\n= "); - } - free(buf2); - - lump++; // if no sprite defined use spirte just after this one - if (skin->sprite[0] == '\0') - { - const char *csprname = W_CheckNameForNumPwad(wadnum, lump); - - // skip to end of this skin's frames - lastlump = lump; - while (W_CheckNameForNumPwad(wadnum,lastlump) && memcmp(W_CheckNameForNumPwad(wadnum, lastlump),csprname,4)==0) - lastlump++; - // allocate (or replace) sprite frames, and set spritedef - R_AddSingleSpriteDef(csprname, &skin->spritedef, wadnum, lump, lastlump); - } - else - { - // search in the normal sprite tables - size_t name; - boolean found = false; - const char *sprname = skin->sprite; - for (name = 0;sprnames[name][0] != '\0';name++) - if (strncmp(sprnames[name], sprname, 4) == 0) - { - found = true; - skin->spritedef = sprites[name]; - } - - // not found so make a new one - // go through the entire current wad looking for our sprite - // don't just mass add anything beginning with our four letters. - // "HOODFACE" is not a sprite name. - if (!found) - { - UINT16 localllump = 0, lstart = UINT16_MAX, lend = UINT16_MAX; - const char *lname; - - while ((lname = W_CheckNameForNumPwad(wadnum,localllump))) - { - // If this is a valid sprite... - if (!memcmp(lname,sprname,4) && lname[4] && lname[5] && lname[5] >= '0' && lname[5] <= '8') - { - if (lstart == UINT16_MAX) - lstart = localllump; - // If already set do nothing - } - else - { - if (lstart != UINT16_MAX) - { - lend = localllump; - break; - } - // If not already set do nothing - } - ++localllump; - } - - R_AddSingleSpriteDef(sprname, &skin->spritedef, wadnum, lstart, lend); - } - - // I don't particularly care about skipping to the end of the used frames. - // We could be using frames from ANYWHERE in the current WAD file, including - // right before us, which is a terrible idea. - // So just let the function in the while loop take care of it for us. - } - - R_FlushTranslationColormapCache(); - - CONS_Printf(M_GetText("Added skin '%s'\n"), skin->name); -#ifdef SKINVALUES - (local ? localskin_cons_t : skin_cons_t)[lnumskins].value = lnumskins; - (local ? localskin_cons_t : skin_cons_t)[lnumskins].strvalue = skin->name; -#endif - - if (!local) - { - // Update the forceskin possiblevalues - Forceskin_cons_t[numskins+1].value = numskins; - Forceskin_cons_t[numskins+1].strvalue = skins[numskins].name; - skin->localskin = false; - skin->localnum = numskins; - ST_LoadFaceGraphics(skin->facerank, skin->facewant, skin->facemmap, numskins); - } - else - { - skin->localskin = true; - skin->localnum = numlocalskins; - ST_LoadLocalFaceGraphics(skin->facerank, skin->facewant, skin->facemmap, numlocalskins); - } - -#ifdef HWRENDER - if (rendermode == render_opengl) - HWR_AddPlayerMD2(lnumskins, local); -#endif - if (!local) - { - skinstats[skin->kartspeed-1][skin->kartweight-1][skinstatscount[skin->kartspeed-1][skin->kartweight-1]] = numskins; - CONS_Debug(DBG_SETUP, M_GetText("Added %d to %d, %d\n"), numskins, skin->kartweight, skin->kartweight); - skinstatscount[skin->kartspeed-1][skin->kartweight-1]++; - CONS_Debug(DBG_SETUP, M_GetText("Incremented %d, %d to %d\n"), skin->kartspeed, skin->kartweight, skinstatscount[skin->kartspeed - 1][skin->kartweight - 1]); - skinsorted[numskins] = numskins; - } - - allskins[numallskins] = K_GetSkinArray(local)[lnumskins]; - - local ? numlocalskins++ : numskins++; - numallskins++; - } - -#undef lnumskins - //sortSkinGrid(); - return; + free(heads); } diff --git a/src/r_things.h b/src/r_things.h index fe4f532b6..5eb383e93 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -1,4 +1,4 @@ -// SONIC ROBO BLAST 2 +// SONIC ROBO BLAST 2 KART //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. @@ -14,13 +14,12 @@ #ifndef __R_THINGS__ #define __R_THINGS__ -#include "sounds.h" -#include "r_plane.h" -#include "r_patch.h" +#ifdef __cplusplus +extern "C" { +#endif -// "Left" and "Right" character symbols for additional rotation functionality -#define ROT_L ('L' - '0') -#define ROT_R ('R' - '0') +#include "r_plane.h" +#include "r_portal.h" // number of sprite lumps for spritewidth,offset,topoffset lookup tables // Fab: this is a hack : should allocate the lookup tables per sprite @@ -40,12 +39,17 @@ // as an non-fixed-point integer. // It is very rough, tho it is used only for optimizing out unnecessary // interpolation, so it is kinda ok on big distances. + +#ifdef __cplusplus +#define R_QuickCamDist(x, y) std::max(std::abs(((x)>>FRACBITS) - (viewx>>FRACBITS)), std::abs(((y)>>FRACBITS) - (viewy>>FRACBITS))) +#else #define R_QuickCamDist(x, y) max(abs(((x)>>FRACBITS) - (viewx>>FRACBITS)), abs(((y)>>FRACBITS) - (viewy>>FRACBITS))) +#endif // Constant arrays used for psprite clipping // and initializing clipping. -extern INT16 negonearray[MAXVIDWIDTH]; -extern INT16 screenheightarray[MAXVIDWIDTH]; +extern INT16 *negonearray; +extern INT16 *screenheightarray; // vars for R_DrawMaskedColumn extern INT16 *mfloorclip; @@ -62,76 +66,37 @@ fixed_t R_GetSpriteDirectionalLighting(angle_t angle); fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope); -void R_DrawMaskedColumn(column_t *column); -void R_SortVisSprites(void); - -//faB: find sprites in wadfile, replace existing, add new ones -// (only sprites from namelist are added or replaced) -void R_AddSpriteDefs(UINT16 wadnum); - //SoM: 6/5/2000: Light sprites correctly! +boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 wadnum, UINT16 startlump, UINT16 endlump); void R_AddSprites(sector_t *sec, INT32 lightlevel); void R_AddPrecipitationSprites(void); void R_InitSprites(void); void R_ClearSprites(void); -void R_DrawMasked(void); - -boolean R_ThingVisible (mobj_t *thing); -boolean R_ThingWithinDist (mobj_t *thing, INT32 limit_dist); - -boolean R_ThingIsFullBright (mobj_t *thing); -boolean R_ThingIsSemiBright (mobj_t *thing); -boolean R_ThingIsFullDark (mobj_t *thing); - -// ----------- -// SKINS STUFF -// ----------- -#define SKINNAMESIZE 16 -// should be all lowercase!! S_SKIN processing does a strlwr -#define DEFAULTSKIN "sonic" -#define DEFAULTSKIN2 "tails" // secondary player -#define DEFAULTSKIN3 "knuckles" // third player -#define DEFAULTSKIN4 "eggman" // fourth player +/** Used to count the amount of masked elements + * per portal to later group them in separate + * drawnode lists. + */ typedef struct { - char name[SKINNAMESIZE+1]; // INT16 descriptive name of the skin - spritedef_t spritedef; - spriteinfo_t sprinfo; - UINT16 wadnum; - char sprite[4]; // Sprite name, if seperated from S_SKIN. - skinflags_t flags; + size_t drawsegs[2]; + size_t vissprites[2]; + fixed_t viewx, viewy, viewz; /**< View z stored at the time of the BSP traversal for the view/portal. Masked sorting/drawing needs it. */ + sector_t* viewsector; +} maskcount_t; - char realname[SKINNAMESIZE+1]; // Display name for level completion. - char hudname[SKINNAMESIZE+1]; // HUD name to display (officially exactly 5 characters long) - char facerank[9], facewant[9], facemmap[9]; // Arbitrarily named patch lumps +void R_DrawMasked(maskcount_t* masks, INT32 nummasks); - // SRB2kart - UINT8 kartspeed; - UINT8 kartweight; - // +transnum_t R_GetThingTransTable(fixed_t alpha, transnum_t transmap); - // Definable color translation table - UINT8 starttranscolor; - UINT8 prefcolor; - fixed_t highresscale; // scale of highres, default is 0.5 +boolean R_ThingVisible(mobj_t *thing); +boolean R_ThingWithinDist(mobj_t *thing, INT32 limit_dist); +boolean R_CheckInterpDist(mobj_t *thing); +fixed_t R_DoPlayerFade(mobj_t *thing); - // specific sounds per skin - sfxenum_t soundsid[NUMSKINSOUNDS]; // sound # in S_sfx table - - boolean localskin; - INT32 localnum; -} skin_t; - -extern CV_PossibleValue_t Forceskin_cons_t[]; - -// had to move those here Zzz... -INT32 K_GetSkinNum(player_t *player); -INT32 K_GetMobjSkinNum(const skin_t *skin, boolean local); -skin_t *K_GetPlayerSkin(player_t *player); -skin_t *K_GetMobjSkin(const mobj_t *mobj); -patch_t *K_GetFacePrefix(player_t *player, INT32 skinnum); -skin_t *K_GetSkinArray(boolean local); +boolean R_ThingIsFullBright(mobj_t *thing); +boolean R_ThingIsSemiBright(mobj_t *thing); +boolean R_ThingIsFullDark(mobj_t *thing); // ----------- // NOT SKINS STUFF ! @@ -201,7 +166,7 @@ typedef struct vissprite_s fixed_t spritexscale, spriteyscale; fixed_t spritexoffset, spriteyoffset; - INT16 clipbot[MAXVIDWIDTH], cliptop[MAXVIDWIDTH]; + INT16 *clipbot, *cliptop; boolean precip; boolean vflip; // Flip vertically @@ -211,10 +176,14 @@ typedef struct vissprite_s extern UINT32 visspritecount, numvisiblesprites; -void R_ClipSprites(void); +void R_ClipSprites(drawseg_t* dsstart, portal_t* portal); + +void R_AllocVisSpriteMemory(void); UINT8 *R_GetSpriteTranslation(vissprite_t *vis); +void R_InitDrawNodes(void); + // ---------- // DRAW NODES // ---------- @@ -233,69 +202,8 @@ typedef struct drawnode_s struct drawnode_s *prev; } drawnode_t; -extern INT32 numskins; -extern INT32 numlocalskins; -extern INT32 numallskins; -extern skin_t skins[MAXSKINS]; -extern UINT8 skinstats[9][9][MAXSKINS]; -extern UINT8 skinstatscount[9][9]; -extern UINT8 skinsorted[MAXSKINS]; - -void sortSkinGrid(void); -extern skin_t localskins[MAXLOCALSKINS]; -extern skin_t allskins[MAXSKINS+MAXLOCALSKINS]; - -boolean SetPlayerSkin(INT32 playernum,const char *skinname); -void SetPlayerSkinByNum(INT32 playernum,INT32 skinnum); // Tails 03-16-2002 -void SetLocalPlayerSkin(INT32 playernum,const char *skinname, consvar_t *cvar); -INT32 R_SkinAvailable(const char *name); -INT32 R_AnySkinAvailable(const char *name); -INT32 R_LocalSkinAvailable(const char *name, boolean local); -void R_AddSkins(UINT16 wadnum, boolean local); - -void R_InitDrawNodes(void); - -char *GetPlayerFacePic(INT32 skinnum); - -// Functions to go from sprite character ID to frame number -// for 2.1 compatibility this still uses the old 'A' + frame code -// The use of symbols tends to be painful for wad editors though -// So the future version of this tries to avoid using symbols -// as much as possible while also defining all 64 slots in a sane manner -// 2.1: [[ ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ]] -// Future: [[ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz!@ ]] -FUNCMATH FUNCINLINE static ATTRINLINE char R_Frame2Char(UINT8 frame) -{ -#if 1 // 2.1 compat - return 'A' + frame; -#else - if (frame < 26) return 'A' + frame; - if (frame < 36) return '0' + (frame - 26); - if (frame < 62) return 'a' + (frame - 36); - if (frame == 62) return '!'; - if (frame == 63) return '@'; - return '\xFF'; +#ifdef __cplusplus +} // extern "C" #endif -} - -FUNCMATH FUNCINLINE static ATTRINLINE UINT8 R_Char2Frame(char cn) -{ -#if 1 // 2.1 compat - if (cn == '+') return '\\' - 'A'; // PK3 can't use backslash, so use + instead - return cn - 'A'; -#else - if (cn >= 'A' && cn <= 'Z') return cn - 'A'; - if (cn >= '0' && cn <= '9') return (cn - '0') + 26; - if (cn >= 'a' && cn <= 'z') return (cn - 'a') + 36; - if (cn == '!') return 62; - if (cn == '@') return 63; - return 255; -#endif -} - -FUNCMATH FUNCINLINE static ATTRINLINE boolean R_ValidSpriteAngle(UINT8 rotation) -{ - return ((rotation <= 8) || (rotation == ROT_L) || (rotation == ROT_R)); -} #endif //__R_THINGS__ diff --git a/src/s_sound.c b/src/s_sound.c index 2f79e0540..c93570232 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -32,6 +32,7 @@ #include "m_menu.h" // bird music stuff #include "lua_hook.h" // MusicChange hook +#include "lua_hud.h" // LUA_HudEnabled(hud_musiccredit) static boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32 *vol, INT32 *sep, INT32 *pitch, sfxinfo_t *sfxinfo); static void SetChannelsNum(void); @@ -956,7 +957,7 @@ boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32 INT64 x, y, yl, yh, xl, xh; fixed_t newdist; - if (R_PointInSubsector(listensource.x, listensource.y)->sector->ceilingpic == skyflatnum) + if (R_PointInSubsectorFast(listensource.x, listensource.y)->sector->ceilingpic == skyflatnum) approx_dist = 0; else { @@ -969,7 +970,7 @@ boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32 for (y = yl; y <= yh; y += FRACUNIT*64) for (x = xl; x <= xh; x += FRACUNIT*64) { - if (R_PointInSubsector(x, y)->sector->ceilingpic == skyflatnum) + if (R_PointInSubsectorFast(x, y)->sector->ceilingpic == skyflatnum) { // Found the outdoors! newdist = S_CalculateSoundDistance(listensource.x, listensource.y, 0, x, y, 0); @@ -1202,8 +1203,58 @@ static consvar_t *music_refade_cv; /// Music Definitions /// ------------------------ -musicdef_t *musicdefstart = NULL; // First music definition -struct cursongcredit cursongcredit; // Currently displayed song credit info +// Similar system to vissprite allocation. Exists so external pointers to musicdefs are not invalidated +// when allocating more space for musicdefs +#define MUSICDEFCHUNKBITS 6 +#define MUSICDEFSPERCHUNK (1 << MUSICDEFCHUNKBITS) +#define MUSICDEFINDEXMASK (MUSICDEFSPERCHUNK - 1) +static musicdef_t **musicdefs = NULL; +static INT32 numchunks = 0; +INT32 nummusicdefs = 0; + +// +// S_GetMusicCredit +// +// Return music credit with given index. +// +musicdef_t *S_GetMusicCredit(INT32 i) +{ + if (i < 0 || i >= nummusicdefs) + return NULL; + + INT32 chunk = i >> MUSICDEFCHUNKBITS; + i &= MUSICDEFINDEXMASK; + + return &musicdefs[chunk][i]; +} + +// +// S_AddMusicCredit +// +// Return new music credit, allocates memory for it if needed. +// +static musicdef_t *S_AddMusicCredit(void) +{ + INT32 chunk = nummusicdefs >> MUSICDEFCHUNKBITS; + INT32 i = nummusicdefs & MUSICDEFINDEXMASK; + + // Allocate new chunk if needed. Other chunks stay valid + if (chunk == numchunks) + { + ++numchunks; + musicdefs = (musicdef_t**)Z_Realloc(musicdefs, sizeof(musicdef_t*)*numchunks, PU_STATIC, NULL); + musicdefs[chunk] = Z_Calloc(sizeof(musicdef_t)*MUSICDEFSPERCHUNK, PU_STATIC, NULL); + } + + // Store "id" of new musicdef (mostly exists only for lua) + musicdefs[chunk][i].num = nummusicdefs; + + ++nummusicdefs; + + return &musicdefs[chunk][i]; +} + +struct cursongcredit cursongcredit = {0}; // Currently displayed song credit info static boolean ReadMusicDefFields (UINT16 wadnum, int line, char *stoken, musicdef_t **defp) @@ -1231,14 +1282,11 @@ ReadMusicDefFields (UINT16 wadnum, int line, char *stoken, musicdef_t **defp) // Nothing found, add to the end. if (!def) { - def = Z_Calloc(sizeof (musicdef_t), PU_STATIC, NULL); + def = S_AddMusicCredit(); STRBUFCPY(def->name, value); strlwr(def->name); def->hash = quickncasehash (def->name, 6); - - def->next = musicdefstart; - musicdefstart = def; } (*defp) = def; @@ -1423,8 +1471,10 @@ musicdef_t *S_FindMusicCredit(const char *musname) UINT32 hash = quickncasehash (musname, 6); musicdef_t *def; - for (def = musicdefstart; def; def = def->next) + for (INT32 i = 0; i < nummusicdefs; ++i) { + def = S_GetMusicCredit(i); + if (hash != def->hash) continue; if (stricmp(def->name, musname)) @@ -1457,7 +1507,7 @@ void S_ShowSpecifiedMusicCredit(const char *musname) def = S_FindMusicCredit(musname); - if (def) + if (def && !LUA_HookMusicCredit(def)) { cursongcredit.def = def; cursongcredit.anim = 5*TICRATE; @@ -1476,41 +1526,6 @@ void S_ShowMusicCredit(void) S_ShowSpecifiedMusicCredit(music.name); } -musicdef_t **soundtestdefs = NULL; -INT32 numsoundtestdefs = 0; - -// -// S_PrepareSoundTest -// -// Prepare sound test. What am I, your butler? -// -boolean S_PrepareSoundTest(void) -{ - musicdef_t *def; - INT32 pos = numsoundtestdefs = 0; - - for (def = musicdefstart; def; def = def->next) - { - numsoundtestdefs++; - } - - if (!numsoundtestdefs) - return false; - - if (soundtestdefs) - Z_Free(soundtestdefs); - - if (!(soundtestdefs = Z_Malloc(numsoundtestdefs*sizeof(musicdef_t *), PU_STATIC, NULL))) - I_Error("S_PrepareSoundTest(): could not allocate soundtestdefs."); - - for (def = musicdefstart; def /*&& i < numsoundtestdefs*/; def = def->next) - { - soundtestdefs[pos++] = def; - } - - return true; -} - /// ------------------------ /// Music Status /// ------------------------ @@ -1703,15 +1718,15 @@ static boolean S_PlayMusic(boolean looping, UINT32 fadeinms) static void S_QueueMusic(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 fadeinms) { strncpy(queue.name, mmusic, 7); - queue.flags = mflags; - queue.looping = looping; + queue.flags = mflags; + queue.looping = looping; queue.position = position; queue.fadeinms = fadeinms; } static void S_ClearQueue(void) { - queue.name[0] = queue.flags = queue.looping = queue.position = queue.fadeinms = 0; + memset(&queue, 0, sizeof(music_t)); } static void S_ChangeMusicToQueue(void) @@ -1742,7 +1757,7 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 || demo.title) // SRB2Kart: Demos don't interrupt title screen music return; - strncpy(newmusic, mmusic, 6); + strncpy(newmusic, mmusic, 6); strncpy(checkmusic, mmusic, 6); if (LUA_HookMusicChange(music.name, &hook_param)) @@ -2015,7 +2030,7 @@ void S_KeepMusic(void) } // Sets up the map music in case it should be reloaded -// Special case for keep music +// Special case for keepmusic void S_HandleReloadResetMusic(void) { if (!(mapmusic.flags & MUSIC_RELOADRESET)) @@ -2040,23 +2055,24 @@ void S_HandleReloadResetMusic(void) static boolean S_SkipIntroMusic(void) { - boolean skip = cv_skipintromusic.value; + if (!cv_skipintromusic.value) + return false; - if (!skip) + // check if menu music is playing, otherwise it may continue playing + if (!stricmp(music.name, "titles")) return false; char *maptitle = G_BuildMapTitle(gamemap); // Zzz... - if (maptitle) + if (maptitle && !stricmp(maptitle, "Wandering Falls")) // wandering balls changes its song when the race starts Zzz... { - // check if menu music is playing, otherwise it may continue playing - if (!stricmp(music.name, "titles") || (maptitle && (!stricmp(maptitle, "Wandering Falls")))) // wandering balls changes its song when the race starts Zzz... - skip = false; + Z_Free(maptitle); + return false; } Z_Free(maptitle); - return skip; + return true; } // diff --git a/src/s_sound.h b/src/s_sound.h index eec99d802..ce16ce540 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -182,14 +182,9 @@ typedef struct musicdef_s char alttitle[256]; char authors[256]; boolean use_info; - struct musicdef_s *next; + size_t num; } musicdef_t; -extern musicdef_t *musicdefstart; -extern musicdef_t **soundtestdefs; -extern INT32 numsoundtestdefs; -extern UINT8 soundtestpage; - extern struct cursongcredit { musicdef_t *def; @@ -198,18 +193,18 @@ extern struct cursongcredit UINT8 trans; } cursongcredit; +extern INT32 nummusicdefs; void S_LoadMusicDefs(UINT16 wadnum); void S_InitMusicDefs(void); void S_LoadMTDefs(UINT16 wadnum); void S_InitMTDefs(void); +musicdef_t *S_GetMusicCredit(INT32 i); musicdef_t *S_FindMusicCredit(const char *musname); void S_ShowSpecifiedMusicCredit(const char *musname); void S_ShowMusicCredit(void); void S_ResetMusicCredit(void); -boolean S_PrepareSoundTest(void); - // // Music Seeking // diff --git a/src/screen.c b/src/screen.c index e41b5360f..eb6c2bc82 100644 --- a/src/screen.c +++ b/src/screen.c @@ -33,23 +33,6 @@ // SRB2Kart #include "r_fps.h" // R_GetFramerateCap -// -------------------------------------------- -// assembly or c drawer routines for 8bpp/16bpp -// -------------------------------------------- -void (*wallcolfunc)(void); // new wall column drawer to draw posts >128 high -void (*colfunc)(void); // standard column, up to 128 high posts - -void (*basecolfunc)(void); -void (*fuzzcolfunc)(void); // standard fuzzy effect column drawer -void (*transcolfunc)(void); // translation column drawer -void (*shadecolfunc)(void); // smokie test.. -void (*spanfunc)(void); // span drawer, use a 64x64 tile -void (*splatfunc)(void); // span drawer w/ transparency -void (*basespanfunc)(void); // default span func for color mode -void (*transtransfunc)(void); // translucent translated column drawer -void (*twosmultipatchfunc)(void); // for cols with transparent pixels -void (*twosmultipatchtransfunc)(void); // for cols with transparent pixels AND translucency - // ------------------ // global video state // ------------------ @@ -65,6 +48,9 @@ consvar_t cv_renderview = {"renderview", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, consvar_t cv_vhseffect = {"vhspause", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_shittyscreen = {"televisionsignal", "Okay", CV_NOSHOWHELP, shittyscreen_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_parallelsoftware = {"parallelsoftware", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_paralleldrawmasked = {"paralleldrawmasked", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + static CV_PossibleValue_t votescale_cons_t[] = {{0, "Vanilla"}, {1, "Adaptive"}, {2, "VerticalFill"}, {3, "HorizontalFill"}, {0, NULL}}; consvar_t cv_votebgscaling = {"votebgscaling", "Adaptive", CV_SAVE, votescale_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -89,13 +75,41 @@ consvar_t cv_accuratefps = {"fpssampling", "1", CV_SAVE, accuratefps_cons_t, NUL // SCREEN VARIABLES // ========================================================================= -INT32 scr_bpp; // current video mode bytes per pixel UINT8 *scr_borderpatch; // flat used to fill the reduced view borders set at ST_Init() // ========================================================================= -// Short and Tall sky drawer, for the current color mode -void (*walldrawerfunc)(void); +static void SCR_SetDrawFuncs(void) +{ + // + // setup the right draw routines + // + + spanfuncs[BASEDRAWFUNC] = R_DrawSpan; + spanfuncs[SPANDRAWFUNC_TRANS] = R_DrawTranslucentSpan; + spanfuncs[SPANDRAWFUNC_TILTED] = R_DrawSpan_Tilted; + spanfuncs[SPANDRAWFUNC_TILTEDTRANS] = R_DrawTranslucentSpan_Tilted; + spanfuncs[SPANDRAWFUNC_SPLAT] = R_DrawSplat; + spanfuncs[SPANDRAWFUNC_TRANSSPLAT] = R_DrawTranslucentSplat; + spanfuncs[SPANDRAWFUNC_TILTEDSPLAT] = R_DrawSplat_Tilted; + spanfuncs[SPANDRAWFUNC_TILTEDTRANSSPLAT] = R_DrawTranslucentSpan_Tilted; + spanfuncs[SPANDRAWFUNC_WATER] = R_DrawTranslucentWaterSpan; + spanfuncs[SPANDRAWFUNC_TILTEDWATER] = R_DrawTranslucentWaterSpan_Tilted; + spanfuncs[SPANDRAWFUNC_FOG] = R_DrawFogSpan; + spanfuncs[SPANDRAWFUNC_TILTEDFOG] = R_DrawFogSpan_Tilted; + + colfuncs[BASEDRAWFUNC] = R_DrawColumn; + colfuncs[COLDRAWFUNC_FUZZY] = R_DrawTranslucentColumn; + colfuncs[COLDRAWFUNC_TRANS] = R_DrawTranslatedColumn; + colfuncs[COLDRAWFUNC_SHADOWED] = R_DrawColumnShadowed; + colfuncs[COLDRAWFUNC_TRANSTRANS] = R_DrawTranslatedTranslucentColumn; + colfuncs[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn; + colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS] = R_Draw2sMultiPatchTranslucentColumn; + colfuncs[COLDRAWFUNC_FOG] = R_DrawFogColumn; + + R_SetColumnFunc(BASEDRAWFUNC); + R_SetSpanFunc(BASEDRAWFUNC); +} void SCR_SetMode(void) { @@ -109,22 +123,47 @@ void SCR_SetMode(void) V_SetPalette(0); - spanfunc = basespanfunc = R_DrawSpan_8; - splatfunc = R_DrawSplat_8; - transcolfunc = R_DrawTranslatedColumn_8; - transtransfunc = R_DrawTranslatedTranslucentColumn_8; - - colfunc = basecolfunc = R_DrawColumn_8; - shadecolfunc = R_DrawShadeColumn_8; - fuzzcolfunc = R_DrawTranslucentColumn_8; - walldrawerfunc = R_DrawWallColumn_8; - twosmultipatchfunc = R_Draw2sMultiPatchColumn_8; - twosmultipatchtransfunc = R_Draw2sMultiPatchTranslucentColumn_8; + SCR_SetDrawFuncs(); // set the apprpriate drawer for the sky (tall or INT16) setmodeneeded = 0; } +void R_SetColumnFunc(size_t id) +{ + I_Assert(id < COLDRAWFUNC_MAX); + + colfunctype = id; + colfunc = colfuncs[id]; +} + +void R_SetSpanFunc(size_t id) +{ + I_Assert(id < SPANDRAWFUNC_MAX); + spanfunc = spanfuncs[id]; +} + +boolean R_CheckColumnFunc(size_t id) +{ + size_t i; + + if (colfunc == NULL) + { + // Shouldn't happen. + return false; + } + + for (i = 0; i < COLDRAWFUNC_MAX; i++) + { + if (colfunc == colfuncs[id]) + { + return true; + } + } + + return false; +} + // do some initial settings for the game loading screen // void SCR_Startup(void) @@ -148,19 +187,9 @@ void SCR_Startup(void) vid.meddupx = (UINT8)(vid.dupx >> 1) + 1; vid.meddupy = (UINT8)(vid.dupy >> 1) + 1; -#ifdef HWRENDER - vid.fmeddupx = vid.meddupx*FRACUNIT; - vid.fmeddupy = vid.meddupy*FRACUNIT; -#endif vid.smalldupx = (UINT8)(vid.dupx / 3) + 1; vid.smalldupy = (UINT8)(vid.dupy / 3) + 1; -#ifdef HWRENDER - vid.fsmalldupx = vid.smalldupx*FRACUNIT; - vid.fsmalldupy = vid.smalldupy*FRACUNIT; -#endif - - vid.baseratio = FRACUNIT; V_Init(); CV_RegisterVar(&cv_highreshudscale); @@ -205,9 +234,6 @@ void SCR_Recalc(void) if (dedicated) return; - // bytes per pixel quick access - scr_bpp = vid.bpp; - // scale 1,2,3 times in x and y the patches for the menus and overlays... // calculated once and for all, used by routines in v_video.c vid.dupx = vid.width / BASEVIDWIDTH; @@ -226,22 +252,11 @@ void SCR_Recalc(void) vid.fdupx = vid.fdupy = (vid.fdupx < vid.fdupy ? vid.fdupx : vid.fdupy); - //vid.baseratio = FixedDiv(vid.height << FRACBITS, BASEVIDHEIGHT << FRACBITS); - vid.baseratio = FRACUNIT; - vid.meddupx = (UINT8)(vid.dupx >> 1) + 1; vid.meddupy = (UINT8)(vid.dupy >> 1) + 1; -#ifdef HWRENDER - vid.fmeddupx = vid.meddupx*FRACUNIT; - vid.fmeddupy = vid.meddupy*FRACUNIT; -#endif vid.smalldupx = (UINT8)(vid.dupx / 3) + 1; vid.smalldupy = (UINT8)(vid.dupy / 3) + 1; -#ifdef HWRENDER - vid.fsmalldupx = vid.smalldupx*FRACUNIT; - vid.fsmalldupy = vid.smalldupy*FRACUNIT; -#endif // toggle off (then back on) the automap because some screensize-dependent values will // be calculated next time the automap is activated. @@ -335,7 +350,7 @@ double averageFPS = 0.0f; #ifdef USE_FPS_SAMPLES #define MAX_FRAME_TIME (0.05) -#define NUM_FPS_SAMPLES (16) // Number of samples to store +#define NUM_FPS_SAMPLES (32) // Number of samples to store static double total_frame_time = 0.0; static int frame_index; diff --git a/src/screen.h b/src/screen.h index 224897def..38483b28d 100644 --- a/src/screen.h +++ b/src/screen.h @@ -39,113 +39,57 @@ // we try to re-allocate a minimum of buffers for stability of the memory, // so all the small-enough tables based on screen size, are allocated once // and for all at the maximum size. -#define MAXVIDWIDTH 5120 // don't set this too high because actually -#define MAXVIDHEIGHT 2880 // lots of tables are allocated with the MAX size. +#define MAXVIDWIDTH 8192 // don't set this too high because actually +#define MAXVIDHEIGHT 8192 // lots of tables are allocated with the MAX size. #define BASEVIDWIDTH 320 // NEVER CHANGE THIS! This is the original #define BASEVIDHEIGHT 200 // resolution of the graphics. -// max res for png capture; just here to prevent some crashes on very high resolutions; tho you should never go this high cause ogl allocs certain things with MAXVIDWIDTH and MAXVIDHEIGHT too Zzz... -#define MAXPNGWIDTH 7680 -#define MAXPNGHEIGHT 4320 - // global video state typedef struct viddef_s { INT32 modenum; // vidmode num indexes videomodes list + // Each screen is [vid.width*vid.height]; + UINT8 *screens[5]; + // screens[0] = main display window + // screens[1] = back screen, alternative blitting + // screens[2] = screenshot buffer, gif movie buffer + // screens[3] = fade screen start + // screens[4] = fade screen end, postimage tempoarary buffer + UINT8 *buffer; // invisible screens buffer size_t rowbytes; // bytes per scanline of the VIDEO mode INT32 width; // PIXELS per scanline INT32 height; - union { // don't need numpages for OpenGL, so we can use it for fullscreen/windowed mode - INT32 numpages; // always 1, page flipping todo - INT32 windowed; // windowed or fullscren mode? - } u; - INT32 recalc; // if true, recalc vid-based stuff - UINT8 *direct; // linear frame buffer, or vga base mem. + boolean recalc; // if true, recalc vid-based stuff INT32 dupx, dupy; // scale 1, 2, 3 value for menus & overlays INT32/*fixed_t*/ fdupx, fdupy; // same as dupx, dupy, but exact value when aspect ratio isn't 320/200 - INT32 bpp; // BYTES per pixel: 1 = 256color, 2 = highcolor - INT32 baseratio; // Used to get the correct value for lighting walls - - // for Win32 version - DNWH WndParent; // handle of the application's window UINT8 smalldupx, smalldupy; // factor for a little bit of scaling UINT8 meddupx, meddupy; // factor for moderate, but not full, scaling #ifdef HWRENDER - INT32/*fixed_t*/ fsmalldupx, fsmalldupy; - INT32/*fixed_t*/ fmeddupx, fmeddupy; INT32 glstate; #endif } viddef_t; -#define VIDWIDTH vid.width -#define VIDHEIGHT vid.height enum { - VID_GL_LIBRARY_LOADED = 1, + VID_GL_LIBRARY_LOADED = 1, VID_GL_LIBRARY_ERROR = -1, }; -// internal additional info for vesa modes only -typedef struct -{ - INT32 vesamode; // vesa mode number plus LINEAR_MODE bit - void *plinearmem; // linear address of start of frame buffer -} vesa_extra_t; - -// a video modes from the video modes list, -// note: video mode 0 is always standard VGA320x200. -typedef struct vmode_s -{ - struct vmode_s *pnext; - char *name; - UINT32 width, height; - UINT32 rowbytes; // bytes per scanline - UINT32 bytesperpixel; // 1 for 256c, 2 for highcolor - INT32 windowed; // if true this is a windowed mode - INT32 numpages; - vesa_extra_t *pextradata; // vesa mode extra data -#ifdef _WIN32 - INT32 (WINAPI *setmode)(viddef_t *lvid, struct vmode_s *pcurrentmode); -#else - INT32 (*setmode)(viddef_t *lvid, struct vmode_s *pcurrentmode); -#endif - INT32 misc; // misc for display driver (r_opengl.dll etc) -} vmode_t; - -#define NUMSPECIALMODES 4 -extern vmode_t specialmodes[NUMSPECIALMODES]; - -// --------------------------------------------- -// color mode dependent drawer function pointers -// --------------------------------------------- - -extern void (*wallcolfunc)(void); -extern void (*colfunc)(void); -extern void (*basecolfunc)(void); -extern void (*fuzzcolfunc)(void); -extern void (*transcolfunc)(void); -extern void (*shadecolfunc)(void); -extern void (*spanfunc)(void); -extern void (*basespanfunc)(void); -extern void (*splatfunc)(void); -extern void (*transtransfunc)(void); -extern void (*twosmultipatchfunc)(void); -extern void (*twosmultipatchtransfunc)(void); - // ---------------- // screen variables // ---------------- extern viddef_t vid; extern INT32 setmodeneeded; // mode number to set if needed, or 0 -extern double averageFPS; -extern INT32 scr_bpp; extern UINT8 *scr_borderpatch; // patch used to fill the view borders extern consvar_t cv_scr_width, cv_scr_height, cv_renderview, cv_fullscreen, cv_vhseffect, cv_shittyscreen; +extern consvar_t cv_parallelsoftware; +extern consvar_t cv_paralleldrawmasked; + extern consvar_t cv_highreshudscale; // wait for page flipping to end or not extern consvar_t cv_vidwait; @@ -155,8 +99,9 @@ extern consvar_t cv_alwaysgrabmouse; extern consvar_t cv_votebgscaling; -// quick fix for tall/short skies, depending on bytesperpixel -extern void (*walldrawerfunc)(void); +void R_SetColumnFunc(size_t id); +void R_SetSpanFunc(size_t id); +boolean R_CheckColumnFunc(size_t id); // Change video mode, only at the start of a refresh. void SCR_SetMode(void); diff --git a/src/sdl/endtxt.h b/src/sdl/endtxt.h index 41f8e51ad..5691312b4 100644 --- a/src/sdl/endtxt.h +++ b/src/sdl/endtxt.h @@ -19,6 +19,14 @@ #ifndef __ENDTXT__ #define __ENDTXT__ +#ifdef __cplusplus +extern "C" { +#endif + void ShowEndTxt (void); +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/sdl/i_system.c b/src/sdl/i_system.cpp similarity index 95% rename from src/sdl/i_system.c rename to src/sdl/i_system.cpp index 5b3d85421..eea00fb67 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.cpp @@ -180,6 +180,7 @@ static char returnWadPath[256]; #include "../screen.h" //vid.WndParent #include "../d_net.h" #include "../g_game.h" +#include "../g_demo.h" #include "../filesrch.h" #include "../z_zone.h" // Z_Free #include "endtxt.h" @@ -192,6 +193,8 @@ static char returnWadPath[256]; #include "../r_main.h" // Frame interpolation/uncapped #include "../r_fps.h" +#include "../s_sound.h" + #ifdef MAC_ALERT #include "macosx/mac_alert.h" #endif @@ -204,6 +207,11 @@ static char returnWadPath[256]; #include "../byteptr.h" #endif +#ifdef HAVE_THREADS +#include "../core/thread_pool.h" +static std::thread::id g_main_thread_id; +#endif + INT32 numcontrollers = 0; #ifdef HAVE_LIBBACKTRACE @@ -211,11 +219,13 @@ INT32 numcontrollers = 0; // TODO - move this to some header file instead extern struct backtrace_state *bt_state; +typedef enum { + BTCRASH_SIGNAL, + BTCRASH_ERRORMSG, +} bt_crash_type_t; + typedef struct bt_crash_reason_s { - enum { - BTCRASH_SIGNAL, - BTCRASH_ERRORMSG, - } type; + bt_crash_type_t type; union { INT32 signal; @@ -496,6 +506,16 @@ static void I_ReportSignal(int num, int coredumped) #ifndef NEWSIGNALHANDLER FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) { +#ifdef HAVE_THREADS + if (g_main_thread_id != std::this_thread::get_id()) + { + // Do not attempt any sort of recovery if this signal triggers off the main thread + signal(num, SIG_DFL); + raise(num); + exit(-2); + } +#endif + g_in_exiting_signal_handler = true; D_QuitNetGame(); // Fix server freezes @@ -514,6 +534,16 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) FUNCNORETURN static ATTRNORETURN void quit_handler(int num) { +#ifdef HAVE_THREADS + if (g_main_thread_id != std::this_thread::get_id()) + { + // Do not attempt any sort of recovery if this signal triggers off the main thread + signal(num, SIG_DFL); + raise(num); + exit(-2); + } +#endif + signal(num, SIG_DFL); //default signal action raise(num); I_Quit(); @@ -609,8 +639,8 @@ static void I_StartupConsole(void) signal(SIGTTIN, SIG_IGN); signal(SIGTTOU, SIG_IGN); - consolevent = !M_CheckParm("-noconsole"); - framebuffer = M_CheckParm("-framebuffer"); + consolevent = static_cast(!M_CheckParm("-noconsole")); + framebuffer = static_cast( M_CheckParm("-framebuffer")); if (framebuffer) consolevent = SDL_FALSE; @@ -650,8 +680,9 @@ static void I_StartupConsole(void) void I_GetConsoleEvents(void) { // we use this when sending back commands - event_t ev = {0,0,0,0}; + event_t ev = {}; char key = 0; + struct pollfd pfd = { .fd = STDIN_FILENO, @@ -857,6 +888,10 @@ static inline void I_ShutdownConsole(void){} // static void I_RegisterSignals (void) { +#ifdef HAVE_THREADS + g_main_thread_id = std::this_thread::get_id(); +#endif + #ifdef SIGINT signal(SIGINT , quit_handler); #endif @@ -914,7 +949,7 @@ void I_OutputMsg(const char *fmt, ...) if (len == 0) return; - txt = malloc(len+1); + txt = static_cast(malloc(len+1)); va_start(argptr,fmt); vsprintf(txt, fmt, argptr); va_end(argptr); @@ -981,7 +1016,7 @@ void I_OutputMsg(const char *fmt, ...) return; } - ReadConsoleOutputCharacter(co, oldLines, oldLength, coordNextWrite, &bytesWritten); + ReadConsoleOutputCharacter(co, (LPSTR)oldLines, oldLength, coordNextWrite, &bytesWritten); // Move to where we what to print - which is where we would've been, // had console input not been in the way, @@ -1204,7 +1239,7 @@ void I_ShutdownJoystick(UINT8 index) void I_GetJoystickEvents(UINT8 index) { - static event_t event = {0,0,0,0}; + static event_t event = {}; INT32 i = 0; UINT64 joyhats = 0; @@ -1527,7 +1562,7 @@ void I_SetGamepadIndicatorColor(INT32 playernum, UINT8 red, UINT8 green, UINT8 b #define DEG2RAD (0.017453292519943295769236907684883l) // TAU/360 or PI/180 #define MUMBLEUNIT (64.0f) // FRACUNITS in a Meter -static struct { +static struct mumble_s { #ifdef WINMUMBLE UINT32 uiVersion; DWORD uiTick; @@ -1557,10 +1592,12 @@ static void I_SetupMumble(void) { #ifdef WINMUMBLE HANDLE hMap = OpenFileMappingW(FILE_MAP_ALL_ACCESS, FALSE, L"MumbleLink"); + if (!hMap) return; - mumble = MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(*mumble)); + mumble = static_cast(MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(*mumble))); + if (!mumble) CloseHandle(hMap); #elif defined (HAVE_SHM) @@ -1570,10 +1607,11 @@ static void I_SetupMumble(void) snprintf(memname, 256, "/MumbleLink.%d", getuid()); shmfd = shm_open(memname, O_RDWR, S_IRUSR | S_IWUSR); - if(shmfd < 0) + if (shmfd < 0) return; - mumble = mmap(NULL, sizeof(*mumble), PROT_READ | PROT_WRITE, MAP_SHARED, shmfd, 0); + mumble = static_cast(mmap(NULL, sizeof(*mumble), PROT_READ | PROT_WRITE, MAP_SHARED, shmfd, 0)); + if (mumble == MAP_FAILED) mumble = NULL; #endif @@ -1588,8 +1626,9 @@ void I_UpdateMumble(const mobj_t *mobj, const listener_t listener) if (!mumble) return; - if(mumble->uiVersion != 2) { - wcsncpy(mumble->name, L"SRB2Kart "VERSIONSTRINGW, 256); + if (mumble->uiVersion != 2) + { + wcsncpy(mumble->name, L"SRB2Kart " VERSIONSTRINGW, 256); wcsncpy(mumble->description, L"Sonic Robo Blast 2 Kart with integrated Mumble Link support.", 2048); mumble->uiVersion = 2; } @@ -1608,11 +1647,12 @@ void I_UpdateMumble(const mobj_t *mobj, const listener_t listener) { UINT8 *p = mumble->context; WRITEMEM(p, server_context, 8); - WRITEINT16(p, gamemap); + WRITEINT16_2(p, gamemap); mumble->context_len = (UINT32)(p - mumble->context); } - if (mobj) { + if (mobj) + { mumble->fAvatarPosition[0] = FIXED_TO_FLOAT(mobj->x) / MUMBLEUNIT; mumble->fAvatarPosition[1] = FIXED_TO_FLOAT(mobj->z) / MUMBLEUNIT; mumble->fAvatarPosition[2] = FIXED_TO_FLOAT(mobj->y) / MUMBLEUNIT; @@ -1767,8 +1807,8 @@ void I_SleepDuration(precise_t duration) #if defined(__linux__) || defined(__FreeBSD__) || defined(__HAIKU__) UINT64 precision = I_GetPrecisePrecision(); struct timespec ts = { - .tv_sec = duration / precision, - .tv_nsec = duration * 1000000000 / precision % 1000000000, + .tv_sec = static_cast<__time_t>(duration / precision), + .tv_nsec = static_cast<__syscall_slong_t>(duration * 1000000000 / precision % 1000000000), }; int status; do status = clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, &ts); @@ -1903,6 +1943,8 @@ INT32 I_StartupSystem(void) #ifdef HAVE_THREADS I_start_threads(); I_AddExitFunc(I_stop_threads); + I_ThreadPoolInit(); + I_AddExitFunc(I_ThreadPoolShutdown); #endif I_RegisterSignals(); I_OutputMsg("Compiled for SDL version: %d.%d.%d\n", @@ -1993,6 +2035,14 @@ void I_Error(const char *error, ...) va_list argptr; char buffer[8192]; +#ifdef HAVE_THREADS + if (std::this_thread::get_id() != g_main_thread_id) + { + // Do not attempt a graceful shutdown. Errors off the main thread are unresolvable. + exit(-2); + } +#endif + // recursive error detecting if (shutdowning) { @@ -2026,7 +2076,7 @@ void I_Error(const char *error, ...) // which should fail gracefully if it can't put a message box up // on the target system SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "SRB2Kart "VERSIONSTRING" Recursive Error", + "SRB2Kart " VERSIONSTRING " Recursive Error", buffer, NULL); W_Shutdown(); @@ -2075,7 +2125,7 @@ void I_Error(const char *error, ...) // which should fail gracefully if it can't put a message box up // on the target system SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "SRB2Kart "VERSIONSTRING" Error", + "SRB2Kart " VERSIONSTRING " Error", buffer, NULL); // Note that SDL_ShowSimpleMessageBox does *not* require SDL to be // initialized at the time, so calling it after SDL_Quit() is @@ -2113,7 +2163,6 @@ void I_AddExitFunc(void (*func)()) } } - // // Removes a function from the list that need to be called by // I_SystemShutdown(). @@ -2376,7 +2425,7 @@ const char *I_ClipboardPaste(void) */ static boolean isWadPathOk(const char *path) { - char *wad3path = malloc(256); + char *wad3path = static_cast(malloc(256)); if (!wad3path) return false; @@ -2502,43 +2551,43 @@ static const char *locateWad(void) // examine default dirs #ifdef DEFAULTWADLOCATION1 - I_OutputMsg(","DEFAULTWADLOCATION1); + I_OutputMsg("," DEFAULTWADLOCATION1); strcpy(returnWadPath, DEFAULTWADLOCATION1); if (isWadPathOk(returnWadPath)) return returnWadPath; #endif #ifdef DEFAULTWADLOCATION2 - I_OutputMsg(","DEFAULTWADLOCATION2); + I_OutputMsg("," DEFAULTWADLOCATION2); strcpy(returnWadPath, DEFAULTWADLOCATION2); if (isWadPathOk(returnWadPath)) return returnWadPath; #endif #ifdef DEFAULTWADLOCATION3 - I_OutputMsg(","DEFAULTWADLOCATION3); + I_OutputMsg("," DEFAULTWADLOCATION3); strcpy(returnWadPath, DEFAULTWADLOCATION3); if (isWadPathOk(returnWadPath)) return returnWadPath; #endif #ifdef DEFAULTWADLOCATION4 - I_OutputMsg(","DEFAULTWADLOCATION4); + I_OutputMsg("," DEFAULTWADLOCATION4); strcpy(returnWadPath, DEFAULTWADLOCATION4); if (isWadPathOk(returnWadPath)) return returnWadPath; #endif #ifdef DEFAULTWADLOCATION5 - I_OutputMsg(","DEFAULTWADLOCATION5); + I_OutputMsg("," DEFAULTWADLOCATION5); strcpy(returnWadPath, DEFAULTWADLOCATION5); if (isWadPathOk(returnWadPath)) return returnWadPath; #endif #ifdef DEFAULTWADLOCATION6 - I_OutputMsg(","DEFAULTWADLOCATION6); + I_OutputMsg("," DEFAULTWADLOCATION6); strcpy(returnWadPath, DEFAULTWADLOCATION6); if (isWadPathOk(returnWadPath)) return returnWadPath; #endif #ifdef DEFAULTWADLOCATION7 - I_OutputMsg(","DEFAULTWADLOCATION7); + I_OutputMsg("," DEFAULTWADLOCATION7); strcpy(returnWadPath, DEFAULTWADLOCATION7); if (isWadPathOk(returnWadPath)) return returnWadPath; @@ -2548,7 +2597,7 @@ static const char *locateWad(void) I_OutputMsg(",HOME/" DEFAULTDIR); if ((envstr = I_GetEnv("HOME")) != NULL) { - char *tmp = malloc(strlen(envstr) + sizeof(PATHSEP) + sizeof(DEFAULTDIR)); + char *tmp = static_cast(malloc(strlen(envstr) + sizeof(PATHSEP) + sizeof(DEFAULTDIR))); strcpy(tmp, envstr); strcat(tmp, PATHSEP); strcat(tmp, DEFAULTDIR); @@ -2560,21 +2609,21 @@ static const char *locateWad(void) #endif #ifdef DEFAULTSEARCHPATH1 // find in /usr/local - I_OutputMsg(", in:"DEFAULTSEARCHPATH1); + I_OutputMsg(", in:" DEFAULTSEARCHPATH1); WadPath = searchWad(DEFAULTSEARCHPATH1); if (WadPath) return WadPath; #endif #ifdef DEFAULTSEARCHPATH2 // find in /usr/games - I_OutputMsg(", in:"DEFAULTSEARCHPATH2); + I_OutputMsg(", in:" DEFAULTSEARCHPATH2); WadPath = searchWad(DEFAULTSEARCHPATH2); if (WadPath) return WadPath; #endif #ifdef DEFAULTSEARCHPATH3 // find in ??? - I_OutputMsg(", in:"DEFAULTSEARCHPATH3); + I_OutputMsg(", in:" DEFAULTSEARCHPATH3); WadPath = searchWad(DEFAULTSEARCHPATH3); if (WadPath) return WadPath; @@ -2618,17 +2667,22 @@ const char *I_LocateWad(void) static long get_entry(const char* name, const char* buf) { long val; - char* hit = strstr(buf, name); - if (hit == NULL) { + const char* hit = strstr(buf, name); + + if (hit == NULL) + { return -1; } errno = 0; val = strtol(hit + strlen(name), NULL, 10); - if (errno != 0) { + + if (errno != 0) + { CONS_Alert(CONS_ERROR, M_GetText("get_entry: strtol() failed: %s\n"), strerror(errno)); return -1; } + return val; } #endif diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index faf4c67f7..f4a2c288c 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -122,7 +122,7 @@ static void KeyboardLayout_OnChange(void) boolean I_UseNativeKeyboard(void) { - return cv_keyboardlayout.value == 2 && (chat_on || CON_Ready() || (menu_text_input && menuactive)); + return (cv_keyboardlayout.value == 2) && (chat_on || CON_Ready() || (menu_text_input && menuactive)); } static CV_PossibleValue_t keyboardlayout_cons_t[] = {{1,"Default US"}, {2, "Native"}, {3, "AZERTY"}, {0, NULL}}; @@ -222,7 +222,6 @@ static INT32 custom_height = 0; 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_SetWindowIcon(void); static void SDLdoGrabMouse(void); @@ -254,102 +253,6 @@ static void mousegrabOnChange(void) SDLdoUngrabMouse(); } -static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) -{ - static SDL_bool wasfullscreen = SDL_FALSE; - Uint32 rmask; - Uint32 gmask; - Uint32 bmask; - Uint32 amask; - int bpp = 16; - int sw_texture_format = SDL_PIXELFORMAT_ABGR8888; - - realwidth = vid.width; - realheight = vid.height; - - if (window) - { - if (fullscreen) - { - wasfullscreen = SDL_TRUE; - SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP); - } - 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(SDL_GetWindowDisplayIndex(window)), - SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)) - ); - } - } - else - { - Impl_CreateWindow(fullscreen); - wasfullscreen = fullscreen; - SDL_SetWindowSize(window, width, height); - if (fullscreen) - { - SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP); - } - } - -#ifdef HWRENDER - if (rendermode == render_opengl) - { - I_CheckDesktopRes(); -#ifdef USE_FBO_OGL - I_DownSample(); -#endif - OglSdlSurface(vid.width, vid.height); - } -#endif - - if (rendermode == render_soft) - { - SDL_RenderClear(renderer); - SDL_RenderSetLogicalSize(renderer, width, height); - // Set up Texture - realwidth = width; - realheight = height; - if (texture != NULL) - { - SDL_DestroyTexture(texture); - } - - if (!usesdl2soft) - { - sw_texture_format = SDL_PIXELFORMAT_RGB565; - } - else - { - bpp = 32; - sw_texture_format = SDL_PIXELFORMAT_RGBA8888; - } - - texture = SDL_CreateTexture(renderer, sw_texture_format, SDL_TEXTUREACCESS_STREAMING, width, height); - - // Set up SW surface - if (vidSurface != NULL) - { - SDL_FreeSurface(vidSurface); - } - if (vid.buffer) - { - free(vid.buffer); - vid.buffer = NULL; - } - SDL_PixelFormatEnumToMasks(sw_texture_format, &bpp, &rmask, &gmask, &bmask, &amask); - vidSurface = SDL_CreateRGBSurface(0, width, height, bpp, rmask, gmask, bmask, amask); - } -} - static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code) { if (code >= SDL_SCANCODE_A && code <= SDL_SCANCODE_Z) @@ -357,6 +260,7 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code) // get lowercase ASCII return code - SDL_SCANCODE_A + 'a'; } + if (code >= SDL_SCANCODE_1 && code <= SDL_SCANCODE_9) { return code - SDL_SCANCODE_1 + '1'; @@ -365,10 +269,12 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code) { return '0'; } + if (code >= SDL_SCANCODE_F1 && code <= SDL_SCANCODE_F10) { return KEY_F1 + (code - SDL_SCANCODE_F1); } + switch (code) { // F11 and F12 are separated from the rest of the function keys @@ -436,6 +342,7 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code) case SDL_SCANCODE_RGUI: return KEY_RIGHTWIN; default: break; } + return 0; } @@ -445,19 +352,18 @@ static INT32 GetTypedChar(SDL_Keysym keysym) SDL_Event next_event; SDL_Keycode keycode = keysym.sym; SDL_Scancode scancode = keysym.scancode; - const boolean Text_Input_Only = (chat_on || CON_Ready() || (menu_text_input && menuactive)); // only use this this if on chat or console or the current menu wants inputs from us (except if its the control setup menu ig) - // Special cases, where we always return a fixed value. - switch (keycode) + if (I_UseNativeKeyboard()) // only use this this if on chat or console or the current menu wants inputs from us (except if its the control setup menu ig) { - case SDLK_BACKSPACE: return KEY_BACKSPACE; - case SDLK_RETURN: return KEY_ENTER; - default: - break; - } + // Special cases, where we always return a fixed value. + switch (keycode) + { + case SDLK_BACKSPACE: return KEY_BACKSPACE; + case SDLK_RETURN: return KEY_ENTER; + default: + break; + } - if (Text_Input_Only) - { if (SDL_PeepEvents(&next_event, 1, SDL_PEEKEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT) == 1 && next_event.type == SDL_TEXTINPUT) { if (next_event.text.text[1] == '\0') // limit to ASCII @@ -465,7 +371,7 @@ static INT32 GetTypedChar(SDL_Keysym keysym) } } - return Impl_SDL_Scancode_To_Keycode(scancode); // fallback + return Impl_SDL_Scancode_To_Keycode(scancode); // fallback to scancodes } static INT32 Impl_SDL_Keysym_To_Keycode(SDL_Keysym keysym) @@ -542,6 +448,7 @@ static INT32 Impl_SDL_Keysym_To_Keycode(SDL_Keysym keysym) default: break; } + return Impl_SDL_Scancode_To_Keycode(scancode); } @@ -549,6 +456,7 @@ static void SDLdoGrabMouse(void) { SDL_ShowCursor(SDL_DISABLE); SDL_SetWindowGrab(window, SDL_TRUE); + if (SDL_SetRelativeMouseMode(SDL_TRUE) == 0) // already warps mouse if successful wrapmouseok = SDL_TRUE; // TODO: is wrapmouseok or HalfWarpMouse needed anymore? } @@ -603,65 +511,26 @@ static void SurfaceInfo(const SDL_Surface *infoSurface, const char *SurfaceText) static void VID_Command_Info_f (void) { -#if 0 - SDL2STUB(); -#else -#if 0 - const SDL_VideoInfo *videoInfo; - videoInfo = SDL_GetVideoInfo(); //Alam: Double-Check - if (videoInfo) - { - CONS_Printf("%s", M_GetText("Video Interface Capabilities:\n")); - if (videoInfo->hw_available) - CONS_Printf("%s", M_GetText(" Hardware surfaces\n")); - if (videoInfo->wm_available) - CONS_Printf("%s", M_GetText(" Window manager\n")); - //UnusedBits1 :6 - //UnusedBits2 :1 - if (videoInfo->blit_hw) - CONS_Printf("%s", M_GetText(" Accelerated blits HW-2-HW\n")); - if (videoInfo->blit_hw_CC) - CONS_Printf("%s", M_GetText(" Accelerated blits HW-2-HW with Colorkey\n")); - if (videoInfo->wm_available) - CONS_Printf("%s", M_GetText(" Accelerated blits HW-2-HW with Alpha\n")); - if (videoInfo->blit_sw) - { - CONS_Printf("%s", M_GetText(" Accelerated blits SW-2-HW\n")); - if (!M_CheckParm("-noblit")) videoblitok = SDL_TRUE; - } - if (videoInfo->blit_sw_CC) - CONS_Printf("%s", M_GetText(" Accelerated blits SW-2-HW with Colorkey\n")); - if (videoInfo->blit_sw_A) - CONS_Printf("%s", M_GetText(" Accelerated blits SW-2-HW with Alpha\n")); - if (videoInfo->blit_fill) - CONS_Printf("%s", M_GetText(" Accelerated Color filling\n")); - //UnusedBits3 :16 - if (videoInfo->video_mem) - CONS_Printf(M_GetText(" There is %i KB of video memory\n"), videoInfo->video_mem); - else - CONS_Printf("%s", M_GetText(" There no video memory for SDL\n")); - //*vfmt - } -#else - if (!M_CheckParm("-noblit")) videoblitok = SDL_TRUE; -#endif + if (!M_CheckParm("-noblit")) + videoblitok = SDL_TRUE; + SurfaceInfo(bufSurface, M_GetText("Current Engine Mode")); SurfaceInfo(vidSurface, M_GetText("Current Video Mode")); -#endif } static void VID_Command_ModeList_f(void) { // List windowed modes INT32 i = 0; + CONS_Printf("NOTE: Under SDL2, all modes are supported on all platforms.\n"); CONS_Printf("Under opengl, fullscreen only supports native desktop resolution.\n"); CONS_Printf("Under software, the mode is stretched up to desktop resolution.\n"); + for (i = 0; i < MAXWINMODES; i++) { CONS_Printf("%2d: %dx%d\n", i, windowedModes[i][0], windowedModes[i][1]); } - } static void VID_Command_Mode_f (void) @@ -688,16 +557,23 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which) INT32 raxis = axis/32; UINT8 pid; - if (which == ev_joystick) - pid = 0; - else if (which == ev_joystick2) - pid = 1; - else if (which == ev_joystick3) - pid = 2; - else if (which == ev_joystick4) - pid = 3; - else - return 0; + switch (which) + { + case ev_joystick: + pid = 0; + break; + case ev_joystick2: + pid = 1; + break; + case ev_joystick3: + pid = 2; + break; + case ev_joystick4: + pid = 3; + break; + default: + return 0; + } if (Joystick[pid].bGamepadStyle) { @@ -721,6 +597,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which) return raxis; } +// Get the desktop resolution from the current display the gamewindow resides on static void I_CheckDesktopRes(void) { int currentDisplayIndex = -1; @@ -746,6 +623,7 @@ static void I_CheckDesktopRes(void) desktopheight = curmode.h; } +// Check if the game resolution matches the desktop resolution boolean I_CheckNativeRes(void) { return (vid.width == desktopwidth && vid.height == desktopheight); @@ -849,15 +727,15 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) { if (cv_usemouse.value) I_StartupMouse(); } - //else firsttimeonmouse = SDL_FALSE; } else if (!mousefocus && !kbfocus) { // Tell game we lost focus, pause music window_notinfocus = true; - if (! cv_playmusicifunfocused.value) + + if (!cv_playmusicifunfocused.value) I_SetMusicVolume(0); - if (! cv_playsoundifunfocused.value) + if (!cv_playsoundifunfocused.value) S_StopSounds(); if (!disable_mouse) @@ -879,17 +757,16 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type) { event_t event; - if (type == SDL_KEYUP) + switch (type) { - event.type = ev_keyup; - } - else if (type == SDL_KEYDOWN) - { - event.type = ev_keydown; - } - else - { - return; + case SDL_KEYUP: + event.type = ev_keyup; + break; + case SDL_KEYDOWN: + event.type = ev_keydown; + break; + default: + return; } switch (cv_keyboardlayout.value) @@ -905,7 +782,8 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type) break; } - if (event.data1) D_PostEvent(&event); + if (event.data1) + D_PostEvent(&event); } static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt) @@ -982,25 +860,37 @@ static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type) { SDL_memset(&event, 0, sizeof(event_t)); - if (type == SDL_MOUSEBUTTONUP) + switch (type) { - event.type = ev_keyup; + case SDL_MOUSEBUTTONUP: + event.type = ev_keyup; + break; + case SDL_MOUSEBUTTONDOWN: + event.type = ev_keydown; + break; + default: + return; } - else if (type == SDL_MOUSEBUTTONDOWN) + + switch (evt.button) { - event.type = ev_keydown; + case SDL_BUTTON_MIDDLE: + event.data1 = KEY_MOUSE1+2; + break; + case SDL_BUTTON_RIGHT: + event.data1 = KEY_MOUSE1+1; + break; + case SDL_BUTTON_LEFT: + event.data1 = KEY_MOUSE1; + break; + case SDL_BUTTON_X1: + event.data1 = KEY_MOUSE1+3; + break; + case SDL_BUTTON_X2: + event.data1 = KEY_MOUSE1+4; + break; } - else return; - if (evt.button == SDL_BUTTON_MIDDLE) - event.data1 = KEY_MOUSE1+2; - else if (evt.button == SDL_BUTTON_RIGHT) - event.data1 = KEY_MOUSE1+1; - else if (evt.button == SDL_BUTTON_LEFT) - event.data1 = KEY_MOUSE1; - else if (evt.button == SDL_BUTTON_X1) - event.data1 = KEY_MOUSE1+3; - else if (evt.button == SDL_BUTTON_X2) - event.data1 = KEY_MOUSE1+4; + if (event.type == ev_keyup || event.type == ev_keydown) { D_PostEvent(&event); @@ -1069,7 +959,8 @@ static void Impl_HandleControllerAxisEvent(SDL_ControllerAxisEvent evt) { event.type = ev_joystick4; } - else return; + else + return; //axis if (evt.axis > JOYAXISSET*2) @@ -1121,7 +1012,7 @@ static void Impl_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint joyid[i] = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(JoyInfo[i].dev)); } - if (evt.button == SDL_CONTROLLER_BUTTON_DPAD_UP + if ( evt.button == SDL_CONTROLLER_BUTTON_DPAD_UP || evt.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN || evt.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT || evt.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT) @@ -1146,35 +1037,180 @@ static void Impl_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint { event.data1 = KEY_4JOY1; } - else return; + else + return; - if (type == SDL_CONTROLLERBUTTONUP) + switch (type) { - event.type = ev_keyup; + case SDL_CONTROLLERBUTTONUP: + event.type = ev_keyup; + break; + case SDL_CONTROLLERBUTTONDOWN: + event.type = ev_keydown; + break; + default: + return; } - else if (type == SDL_CONTROLLERBUTTONDOWN) - { - event.type = ev_keydown; - } - else return; if (evt.button < JOYBUTTONS) { event.data1 += evt.button; } - else return; + else + return; - if (event.type != ev_console) D_PostEvent(&event); + if (event.type != ev_console) + D_PostEvent(&event); +} + +static void Impl_HandleControllerAddedEvent(SDL_Event evt) +{ + INT32 i; + + // OH BOY are you in for a good time! #abominationstation + SDL_GameController *newcontroller = SDL_GameControllerOpen(evt.cdevice.which); + + CONS_Debug(DBG_GAMELOGIC, "Joystick device index %d added\n", evt.jdevice.which + 1); + + //////////////////////////////////////////////////////////// + // Because SDL's device index is unstable, we're going to cheat here a bit: + // For the first joystick setting that is NOT active: + // + // 1. Set cv_usejoystickX.value to the new device index (this does not change what is written to config.cfg) + // + // 2. Set OTHERS' cv_usejoystickX.value to THEIR new device index, because it likely changed + // * If device doesn't exist, switch cv_usejoystick back to default value (.string) + // * BUT: If that default index is being occupied, use ANOTHER cv_usejoystick's default value! + //////////////////////////////////////////////////////////// + + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + if (newcontroller && (!JoyInfo[i].dev || !SDL_GameControllerGetAttached(JoyInfo[i].dev))) + { + UINT8 j; + + for (j = 0; j < MAXSPLITSCREENPLAYERS; j++) + { + if (i == j) + continue; + + if (JoyInfo[j].dev == newcontroller) + break; + } + + if (j == MAXSPLITSCREENPLAYERS) + { + // ensures we aren't overriding a currently active device + cv_usejoystick[i].value = evt.jdevice.which + 1; + I_UpdateJoystickDeviceIndices(0); + } + } + } + + //////////////////////////////////////////////////////////// + // Was cv_usejoystick disabled in settings? + //////////////////////////////////////////////////////////// + + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + if (!strcmp(cv_usejoystick[i].string, "0") || !cv_usejoystick[i].value) + cv_usejoystick[i].value = 0; + else if (atoi(cv_usejoystick[i].string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys + && cv_usejoystick[i].value) // update the cvar ONLY if a device exists + CV_SetValue(&cv_usejoystick[i], cv_usejoystick[i].value); + } + + //////////////////////////////////////////////////////////// + // Update all joysticks' init states + // This is a little wasteful since cv_usejoystick already calls this, but + // we need to do this in case CV_SetValue did nothing because the string was already same. + // if the device is already active, this should do nothing, effectively. + //////////////////////////////////////////////////////////// + + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + I_InitJoystick(i); + G_SetPlayerGamepadIndicatorColor(i, G_GetSkinColor(i)); // gotta update the controller led again on reconnect + } + + //////////////////////////////////////////////////////////// + + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + CONS_Debug(DBG_GAMELOGIC, "Joystick%d device index: %d\n", i+1, JoyInfo[i].oldjoy); + + // update the menu + if (currentMenu == &OP_JoystickSetDef) + M_SetupJoystickMenu(0); + + numcontrollers = I_NumJoys(); + + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + if (JoyInfo[i].dev == newcontroller) + break; + } + + if (i == MAXSPLITSCREENPLAYERS) + SDL_GameControllerClose(newcontroller); +} + +static void Impl_HandleControllerRemovedEvent(void) +{ + INT32 i; + + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + if (JoyInfo[i].dev && !SDL_GameControllerGetAttached(JoyInfo[i].dev)) + { + CONS_Debug(DBG_GAMELOGIC, "Joystick%d removed, device index: %d\n", i+1, JoyInfo[i].oldjoy); + I_ShutdownJoystick(i); + } + } + + //////////////////////////////////////////////////////////// + // Update the device indexes, because they likely changed + // * If device doesn't exist, switch cv_usejoystick back to default value (.string) + // * BUT: If that default index is being occupied, use ANOTHER cv_usejoystick's default value! + //////////////////////////////////////////////////////////// + + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + I_UpdateJoystickDeviceIndex(i); + } + + //////////////////////////////////////////////////////////// + // Was cv_usejoystick disabled in settings? + //////////////////////////////////////////////////////////// + + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + if (!strcmp(cv_usejoystick[i].string, "0")) + { + cv_usejoystick[i].value = 0; + } + else if (atoi(cv_usejoystick[i].string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys + && cv_usejoystick[i].value) // update the cvar ONLY if a device exists + { + CV_SetValue(&cv_usejoystick[i], cv_usejoystick[i].value); + } + } + + //////////////////////////////////////////////////////////// + + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + CONS_Debug(DBG_GAMELOGIC, "Joystick%d device index: %d\n", i+1, JoyInfo[i].oldjoy); + + // update the menu + if (currentMenu == &OP_JoystickSetDef) + M_SetupJoystickMenu(0); + + numcontrollers = I_NumJoys(); } void I_GetEvent(void) { SDL_Event evt; char* dropped_filedir; - // We only want the first motion event, - // otherwise we'll end up catching the warp back to center. - //int mouseMotionOnce = 0; - INT32 i; if (!graphics_started) { @@ -1195,9 +1231,7 @@ void I_GetEvent(void) Impl_HandleKeyboardEvent(evt.key, evt.type); break; case SDL_MOUSEMOTION: - //if (!mouseMotionOnce) Impl_HandleMouseMotionEvent(evt.motion); - //mouseMotionOnce = 1; break; case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONDOWN: @@ -1209,160 +1243,15 @@ void I_GetEvent(void) case SDL_CONTROLLERAXISMOTION: Impl_HandleControllerAxisEvent(evt.caxis); break; -#if 0 - case SDL_JOYHATMOTION: - Impl_HandleJoystickHatEvent(evt.jhat) - break; -#endif case SDL_CONTROLLERBUTTONUP: case SDL_CONTROLLERBUTTONDOWN: Impl_HandleControllerButtonEvent(evt.cbutton, evt.type); break; - - //////////////////////////////////////////////////////////// - case SDL_CONTROLLERDEVICEADDED: - { - // OH BOY are you in for a good time! #abominationstation - - SDL_GameController *newcontroller = SDL_GameControllerOpen(evt.cdevice.which); - - CONS_Debug(DBG_GAMELOGIC, "Joystick device index %d added\n", evt.jdevice.which + 1); - - //////////////////////////////////////////////////////////// - // Because SDL's device index is unstable, we're going to cheat here a bit: - // For the first joystick setting that is NOT active: - // - // 1. Set cv_usejoystickX.value to the new device index (this does not change what is written to config.cfg) - // - // 2. Set OTHERS' cv_usejoystickX.value to THEIR new device index, because it likely changed - // * If device doesn't exist, switch cv_usejoystick back to default value (.string) - // * BUT: If that default index is being occupied, use ANOTHER cv_usejoystick's default value! - //////////////////////////////////////////////////////////// - - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - if (newcontroller && (!JoyInfo[i].dev || !SDL_GameControllerGetAttached(JoyInfo[i].dev))) - { - UINT8 j; - - for (j = 0; j < MAXSPLITSCREENPLAYERS; j++) - { - if (i == j) - continue; - - if (JoyInfo[j].dev == newcontroller) - break; - } - - if (j == MAXSPLITSCREENPLAYERS) - { - // ensures we aren't overriding a currently active device - cv_usejoystick[i].value = evt.jdevice.which + 1; - I_UpdateJoystickDeviceIndices(0); - } - } - } - - //////////////////////////////////////////////////////////// - // Was cv_usejoystick disabled in settings? - //////////////////////////////////////////////////////////// - - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - if (!strcmp(cv_usejoystick[i].string, "0") || !cv_usejoystick[i].value) - cv_usejoystick[i].value = 0; - else if (atoi(cv_usejoystick[i].string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys - && cv_usejoystick[i].value) // update the cvar ONLY if a device exists - CV_SetValue(&cv_usejoystick[i], cv_usejoystick[i].value); - } - - //////////////////////////////////////////////////////////// - // Update all joysticks' init states - // This is a little wasteful since cv_usejoystick already calls this, but - // we need to do this in case CV_SetValue did nothing because the string was already same. - // if the device is already active, this should do nothing, effectively. - //////////////////////////////////////////////////////////// - - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - I_InitJoystick(i); - G_SetPlayerGamepadIndicatorColor(i, G_GetSkinColor(i)); // gotta update the controller led again on reconnect - } - - //////////////////////////////////////////////////////////// - - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - CONS_Debug(DBG_GAMELOGIC, "Joystick%d device index: %d\n", i+1, JoyInfo[i].oldjoy); - - // update the menu - if (currentMenu == &OP_JoystickSetDef) - M_SetupJoystickMenu(0); - - numcontrollers = I_NumJoys(); - - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - if (JoyInfo[i].dev == newcontroller) - break; - } - - if (i == MAXSPLITSCREENPLAYERS) - SDL_GameControllerClose(newcontroller); - } + Impl_HandleControllerAddedEvent(evt); break; - - //////////////////////////////////////////////////////////// - case SDL_CONTROLLERDEVICEREMOVED: - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - if (JoyInfo[i].dev && !SDL_GameControllerGetAttached(JoyInfo[i].dev)) - { - CONS_Debug(DBG_GAMELOGIC, "Joystick%d removed, device index: %d\n", i+1, JoyInfo[i].oldjoy); - I_ShutdownJoystick(i); - } - } - - //////////////////////////////////////////////////////////// - // Update the device indexes, because they likely changed - // * If device doesn't exist, switch cv_usejoystick back to default value (.string) - // * BUT: If that default index is being occupied, use ANOTHER cv_usejoystick's default value! - //////////////////////////////////////////////////////////// - - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - I_UpdateJoystickDeviceIndex(i); - } - - //////////////////////////////////////////////////////////// - // Was cv_usejoystick disabled in settings? - //////////////////////////////////////////////////////////// - - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - if (!strcmp(cv_usejoystick[i].string, "0")) - { - cv_usejoystick[i].value = 0; - } - else if (atoi(cv_usejoystick[i].string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys - && cv_usejoystick[i].value) // update the cvar ONLY if a device exists - { - CV_SetValue(&cv_usejoystick[i], cv_usejoystick[i].value); - } - } - - //////////////////////////////////////////////////////////// - - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - CONS_Debug(DBG_GAMELOGIC, "Joystick%d device index: %d\n", i+1, JoyInfo[i].oldjoy); - - // update the menu - if (currentMenu == &OP_JoystickSetDef) - M_SetupJoystickMenu(0); - - numcontrollers = I_NumJoys(); - + Impl_HandleControllerRemovedEvent(); break; case SDL_DROPFILE: dropped_filedir = evt.drop.file; @@ -1382,7 +1271,6 @@ void I_GetEvent(void) 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)); @@ -1408,6 +1296,7 @@ void I_StartupMouse(void) } else firsttimeonmouse = SDL_FALSE; + if (cv_usemouse.value || cv_alwaysgrabmouse.value) SDLdoGrabMouse(); else @@ -1424,9 +1313,11 @@ void I_OsPolling(void) if (consolevent) I_GetConsoleEvents(); + if (SDL_WasInit(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) == (SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER)) { SDL_GameControllerUpdate(); + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) I_GetJoystickEvents(i); } @@ -1446,6 +1337,105 @@ void I_OsPolling(void) if (mod & KMOD_CAPS) capslock = true; } +static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) +{ + static SDL_bool wasfullscreen = SDL_FALSE; + Uint32 rmask, gmask, bmask, amask; + int bpp = 16; + int sw_texture_format = SDL_PIXELFORMAT_ABGR8888; + + realwidth = vid.width; + realheight = vid.height; + + if (window) + { + if (fullscreen) + { + wasfullscreen = SDL_TRUE; + SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP); + } + 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(SDL_GetWindowDisplayIndex(window)), + SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)) + ); + } + } + else + { + Impl_CreateWindow(fullscreen); + wasfullscreen = fullscreen; + SDL_SetWindowSize(window, width, height); + + if (fullscreen) + { + SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP); + } + } + +#ifdef HWRENDER + if (rendermode == render_opengl) + { + I_CheckDesktopRes(); +#ifdef USE_FBO_OGL + I_DownSample(); +#endif + OglSdlSurface(vid.width, vid.height); + } +#endif + + if (rendermode == render_soft) + { + SDL_RenderClear(renderer); + SDL_RenderSetLogicalSize(renderer, width, height); + + // Set up Texture + realwidth = width; + realheight = height; + + if (texture != NULL) + { + SDL_DestroyTexture(texture); + } + + if (!usesdl2soft) + { + sw_texture_format = SDL_PIXELFORMAT_RGB565; + } + else + { + bpp = 32; + sw_texture_format = SDL_PIXELFORMAT_RGBA8888; + } + + texture = SDL_CreateTexture(renderer, sw_texture_format, SDL_TEXTUREACCESS_STREAMING, width, height); + + // Set up SW surface + if (vidSurface != NULL) + { + SDL_FreeSurface(vidSurface); + } + + if (vid.buffer) + { + free(vid.buffer); + vid.buffer = NULL; + } + + SDL_PixelFormatEnumToMasks(sw_texture_format, &bpp, &rmask, &gmask, &bmask, &amask); + vidSurface = SDL_CreateRGBSurface(0, width, height, bpp, rmask, gmask, bmask, amask); + } +} + // // I_UpdateNoBlit // @@ -1453,6 +1443,7 @@ void I_UpdateNoBlit(void) { if (rendermode == render_none) return; + if (exposevideo) { #ifdef HWRENDER @@ -1468,6 +1459,7 @@ void I_UpdateNoBlit(void) SDL_RenderPresent(renderer); } } + exposevideo = SDL_FALSE; } @@ -1497,7 +1489,7 @@ void I_FinishUpdate(void) ST_AskToJoinEnvelope(); #endif - if (rendermode == render_soft && screens[0]) + if (rendermode == render_soft && vid.screens[0]) { if (!bufSurface) //Double-Check { @@ -1517,7 +1509,6 @@ void I_FinishUpdate(void) SDL_RenderCopy(renderer, texture, &src_rect, NULL); SDL_RenderPresent(renderer); } - #ifdef HWRENDER else if (rendermode == render_opengl) { @@ -1547,9 +1538,7 @@ void I_ReadScreen(UINT8 *scr) if (rendermode != render_soft) I_Error ("I_ReadScreen: called while in non-software mode"); else - VID_BlitLinearScreen(screens[0], scr, - vid.width*vid.bpp, vid.height, - vid.rowbytes, vid.rowbytes); + VID_BlitLinearScreen(vid.screens[0], scr, vid.width, vid.height, vid.rowbytes, vid.rowbytes); } // @@ -1558,12 +1547,14 @@ void I_ReadScreen(UINT8 *scr) void I_SetPalette(RGBA_t *palette) { size_t i; - for (i=0; i<256; i++) + + for (i = 0; i < 256; i++) { localPalette[i].r = palette[i].s.red; localPalette[i].g = palette[i].s.green; localPalette[i].b = palette[i].s.blue; } + //if (vidSurface) SDL_SetPaletteColors(vidSurface->format->palette, localPalette, 0, 256); // Fury -- SDL2 vidSurface is a 32-bit surface buffer copied to the texture. It's not palletized, like bufSurface. if (bufSurface) SDL_SetPaletteColors(bufSurface->format->palette, localPalette, 0, 256); @@ -1580,37 +1571,25 @@ INT32 VID_NumModes(void) const char *VID_GetModeName(INT32 modeNum) { -#if 0 - if (USE_FULLSCREEN && numVidModes != -1) // fullscreen modes - { - modeNum += firstEntry; - if (modeNum >= numVidModes) - return NULL; - - sprintf(&vidModeName[modeNum][0], "%dx%d", - modeList[modeNum]->w, - modeList[modeNum]->h); - } - else // windowed modes - { -#endif if (modeNum == -1) { return fallback_resolution_name; } - if (modeNum > MAXWINMODES) - return NULL; - sprintf(&vidModeName[modeNum][0], "%dx%d", - windowedModes[modeNum][0], - windowedModes[modeNum][1]); - //} + if (modeNum > MAXWINMODES) + return NULL; + + sprintf(&vidModeName[modeNum][0], "%dx%d", + windowedModes[modeNum][0], + windowedModes[modeNum][1]); + return &vidModeName[modeNum][0]; } INT32 VID_GetModeForSize(INT32 w, INT32 h) { int i; + for (i = 0; i < MAXWINMODES; i++) { if (windowedModes[i][0] == w && windowedModes[i][1] == h) @@ -1618,6 +1597,7 @@ INT32 VID_GetModeForSize(INT32 w, INT32 h) return i; } } + // did not find mode from list, make custom resolution if the values somewhat make sense // opengl mode does not mind about max resolution defined in screen.h // if not using opengl, check against the maximum as well @@ -1628,104 +1608,14 @@ INT32 VID_GetModeForSize(INT32 w, INT32 h) custom_height = h; return CUSTOMMODENUM; } + return -1; -#if 0 - INT32 matchMode = -1, i; - VID_PrepareModeList(); - if (USE_FULLSCREEN && numVidModes != -1) - { - for (i=firstEntry; iw == w && - modeList[i]->h == h) - { - matchMode = i; - break; - } - } - if (-1 == matchMode) // use smaller mode - { - w -= w%BASEVIDWIDTH; - h -= h%BASEVIDHEIGHT; - for (i=firstEntry; iw == w && - modeList[i]->h == h) - { - matchMode = i; - break; - } - } - if (-1 == matchMode) // use smallest mode - matchMode = numVidModes-1; - } - matchMode -= firstEntry; - } - else - { - for (i=0; iw <= MAXVIDWIDTH && - modeList[i]->h <= MAXVIDHEIGHT) - { - firstEntry = i; - break; - } - } - } - } - allow_fullscreen = true; -#endif } static UINT32 refresh_rate; @@ -1753,8 +1643,7 @@ INT32 VID_SetMode(INT32 modeNum) { SDLdoUngrabMouse(); - vid.recalc = 1; - vid.bpp = 1; + vid.recalc = true; if (modeNum >= 0 && modeNum < MAXWINMODES) { @@ -1786,7 +1675,6 @@ INT32 VID_SetMode(INT32 modeNum) } vid.modenum = -1; } - //Impl_SetWindowName("SRB2Kart "VERSIONSTRING); SDLSetMode(vid.width, vid.height, USE_FULLSCREEN); Impl_VideoSetupBuffer(); @@ -1818,11 +1706,13 @@ static SDL_bool Impl_CreateContext(void) { if (!sdlglcontext) sdlglcontext = SDL_GL_CreateContext(window); + if (sdlglcontext == NULL) { SDL_DestroyWindow(window); I_Error("Failed to create a GL context: %s\n", SDL_GetError()); } + SDL_GL_MakeCurrent(window, sdlglcontext); } else @@ -1915,24 +1805,13 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen) return Impl_CreateContext(); } -/* -static void Impl_SetWindowName(const char *title) -{ - if (window == NULL) - { - return; - } - SDL_SetWindowTitle(window, title); -} -*/ - static void Impl_SetWindowIcon(void) { if (window == NULL || icoSurface == NULL) { return; } - //SDL2STUB(); // Monster Iestyn: why is this stubbed? + SDL_SetWindowIcon(window, icoSurface); } @@ -1944,16 +1823,9 @@ static void Impl_VideoSetupSDLBuffer(void) bufSurface = NULL; } // Set up the SDL palletized buffer (copied to vidbuffer before being rendered to texture) - if (vid.bpp == 1) - { - bufSurface = SDL_CreateRGBSurfaceFrom(screens[0],vid.width,vid.height,8, - (int)vid.rowbytes,0x00000000,0x00000000,0x00000000,0x00000000); // 256 mode - } - else if (vid.bpp == 2) // Fury -- don't think this is used at all anymore - { - bufSurface = SDL_CreateRGBSurfaceFrom(screens[0],vid.width,vid.height,15, - (int)vid.rowbytes,0x00007C00,0x000003E0,0x0000001F,0x00000000); // 555 mode - } + bufSurface = SDL_CreateRGBSurfaceFrom(vid.screens[0], vid.width, vid.height, 8, + (int)vid.rowbytes, 0x00000000, 0x00000000, 0x00000000, 0x00000000); // 256 mode + if (bufSurface) { SDL_SetPaletteColors(bufSurface->format->palette, localPalette, 0, 256); @@ -1967,17 +1839,16 @@ static void Impl_VideoSetupSDLBuffer(void) static void Impl_VideoSetupBuffer(void) { // Set up game's software render buffer - //if (rendermode == render_soft) + vid.rowbytes = vid.width; + + if (vid.buffer) + free(vid.buffer); + + vid.buffer = calloc(vid.rowbytes*vid.height, NUMSCREENS); + + if (!vid.buffer) { - vid.rowbytes = vid.width * vid.bpp; - vid.direct = NULL; - if (vid.buffer) - free(vid.buffer); - vid.buffer = calloc(vid.rowbytes*vid.height, NUMSCREENS); - if (!vid.buffer) - { - I_Error("%s", M_GetText("Not enough memory for video buffer\n")); - } + I_Error("%s", M_GetText("Not enough memory for video buffer\n")); } } @@ -1995,6 +1866,7 @@ void I_StartupGraphics(void) rendermode = render_none; return; } + if (graphics_started) return; @@ -2061,6 +1933,7 @@ void I_StartupGraphics(void) char line[16]; char * word; FILE * file = OpenRendererFile("r"); + if (file != NULL) { while (fgets(line, sizeof line, file) != NULL) @@ -2177,16 +2050,11 @@ void I_StartupGraphics(void) // SDL_GL_LoadLibrary to work well on Windows // Create window - //Impl_CreateWindow(USE_FULLSCREEN); - //Impl_SetWindowName("SRB2Kart "VERSIONSTRING); VID_SetMode(VID_GetModeForSize(BASEVIDWIDTH, BASEVIDHEIGHT)); vid.width = BASEVIDWIDTH; // Default size for startup vid.height = BASEVIDHEIGHT; // BitsPerPixel is the SDL interface's vid.recalc = true; // Set up the console stufff - vid.direct = NULL; // Maybe direct access? - vid.bpp = 1; // This is the game engine's Bpp - vid.WndParent = NULL; //For the window? #ifdef HAVE_TTF I_ShutdownTTF(); @@ -2201,16 +2069,7 @@ void I_StartupGraphics(void) if (M_CheckParm("-nomousegrab")) mousegrabok = SDL_FALSE; -#if 0 // defined (_DEBUG) - else - { - char videodriver[4] = {'S','D','L',0}; - if (!M_CheckParm("-mousegrab") && - *strncpy(videodriver, SDL_GetCurrentVideoDriver(), 4) != '\0' && - strncasecmp("x11",videodriver,4) == 0) - mousegrabok = SDL_FALSE; //X11's XGrabPointer not good - } -#endif + realwidth = (Uint16)vid.width; realheight = (Uint16)vid.height; @@ -2232,15 +2091,23 @@ void I_ShutdownGraphics(void) const rendermode_t oldrendermode = rendermode; rendermode = render_none; - if (icoSurface) SDL_FreeSurface(icoSurface); + + if (icoSurface) + SDL_FreeSurface(icoSurface); icoSurface = NULL; + if (oldrendermode == render_soft) { - if (vidSurface) SDL_FreeSurface(vidSurface); + if (vidSurface) + SDL_FreeSurface(vidSurface); vidSurface = NULL; - if (vid.buffer) free(vid.buffer); + + if (vid.buffer) + free(vid.buffer); vid.buffer = NULL; - if (bufSurface) SDL_FreeSurface(bufSurface); + + if (bufSurface) + SDL_FreeSurface(bufSurface); bufSurface = NULL; } @@ -2252,6 +2119,7 @@ void I_ShutdownGraphics(void) I_OutputMsg("graphics never started\n"); return; } + graphics_started = false; I_OutputMsg("shut down\n"); diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 9035e8241..9dbfdde15 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -276,7 +276,7 @@ void I_UpdateSound(void) // sorry. more asm needed. static Mix_Chunk *ds2chunk(void *stream) { - UINT16 ver,freq; + UINT16 ver, freq; UINT32 samples, i, newsamples; UINT8 *sound; diff --git a/src/sdl/sdlmain.h b/src/sdl/sdlmain.h index b0def402d..0c5bfaeff 100644 --- a/src/sdl/sdlmain.h +++ b/src/sdl/sdlmain.h @@ -19,6 +19,10 @@ #ifndef __sdlmain__ #define __sdlmain__ +#ifdef __cplusplus +extern "C" { +#endif + extern SDL_bool consolevent; extern SDL_bool framebuffer; @@ -84,4 +88,8 @@ void SDLforceUngrabMouse(void); // Needed for some WIN32 functions extern SDL_Window *window; +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/sounds.c b/src/sounds.c index c3d92c853..bdfc19b86 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -1037,6 +1037,7 @@ sfxenum_t S_AddSoundFx(const char *name, boolean singular, INT32 flags, boolean S_sfx[i].data = I_GetSfx(&S_sfx[i]); else S_sfx[i].data = NULL; + return i; } } diff --git a/src/st_stuff.c b/src/st_stuff.c index 4f5401aae..16a45ea59 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -34,6 +34,7 @@ #include "i_time.h" #include "k_kart.h" // SRB2kart +#include "k_hud.h" //random index #include "m_random.h" @@ -167,48 +168,50 @@ boolean ST_SameTeam(player_t *a, player_t *b) static boolean st_stopped = true; -void ST_Ticker(void) -{ - if (st_stopped) - return; -} - // 0 is default, any others are special palettes. INT32 st_palette = 0; -void ST_doPaletteStuff(void) +void ST_ResetPaletteStuff(void) { - INT32 palette; + st_palette = 0; + V_SetPalette(0); +} - if (stplyr && stplyr->flashcount) - palette = stplyr->flashpal; - else - palette = 0; +static void ST_doPaletteStuff(void) +{ + INT32 palette = 0; #ifdef HWRENDER if (rendermode == render_opengl && !HWR_PalRenderFlashpal()) - palette = 0; // Don't set the palette to a flashpal in OpenGL's truecolor mode + return; #endif - palette = min(max(palette, 0), 13); + if (stplyr && stplyr->flashcount) + palette = CLAMP(stplyr->flashpal, 0, 13); if (palette != st_palette) { st_palette = palette; -#ifdef HWRENDER - if (rendermode == render_soft || (rendermode == render_opengl && HWR_PalRenderFlashpal())) -#else - if (rendermode != render_none) -#endif + if (!splitscreen) { - //V_SetPaletteLump(GetPalette()); // Reset the palette -- is this needed? - if (!splitscreen) - V_SetPalette(palette); + V_SetPalette(palette); } } } +void ST_Ticker(void) +{ + if (st_stopped) + return; + + // Do red-/gold-shifts from damage/items + //25/08/99: Hurdler: palette changes is done for all players, + // not only player1! That's why this part + // of code is moved somewhere else. + ST_doPaletteStuff(); +} + void ST_UnloadGraphics(void) { Patch_FreeTag(PU_HUDGFX); @@ -306,9 +309,7 @@ static inline void ST_Stop(void) void ST_Start(void) { - if (!st_stopped) - ST_Stop(); - + ST_Stop(); ST_InitData(); if (!dedicated) @@ -757,15 +758,6 @@ void ST_Drawer(void) if (vid.recalc) st_palette = -1; - // Do red-/gold-shifts from damage/items -#ifdef HWRENDER - //25/08/99: Hurdler: palette changes is done for all players, - // not only player1! That's why this part - // of code is moved somewhere else. - if (rendermode == render_soft || (rendermode == render_opengl && HWR_PalRenderFlashpal())) -#endif - if (rendermode != render_none) ST_doPaletteStuff(); - if (st_overlay) { if (renderisnewtic) diff --git a/src/st_stuff.h b/src/st_stuff.h index 54d2483ee..5ffb3334f 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -14,6 +14,10 @@ #ifndef __STSTUFF_H__ #define __STSTUFF_H__ +#ifdef __cplusplus +extern "C" { +#endif + #include "doomtype.h" #include "d_event.h" #include "d_player.h" @@ -28,6 +32,8 @@ extern tic_t directortoggletimer; // Called by main loop. void ST_Ticker(void); +void ST_ResetPaletteStuff(void); + // Called when naming a replay. void ST_DrawDemoTitleEntry(void); @@ -56,8 +62,6 @@ void ST_LoadFaceGraphics(char *rankstr, char *wantstr, char *mmapstr, INT32 play void ST_LoadLocalFaceGraphics(char *rankstr, char *wantstr, char *mmapstr, INT32 playernum); void ST_ReloadSkinFaceGraphics(void); -void ST_doPaletteStuff(void); - // return if player a is in the same team as player b boolean ST_SameTeam(player_t *a, player_t *b); @@ -142,4 +146,8 @@ extern UINT16 objectsdrawn; extern consvar_t cv_lessflicker; extern consvar_t cv_stagetitle; +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/tables.h b/src/tables.h index 4856c90ea..2f492bebb 100644 --- a/src/tables.h +++ b/src/tables.h @@ -14,6 +14,10 @@ #ifndef __TABLES__ #define __TABLES__ +#ifdef __cplusplus +extern "C" { +#endif + #ifdef LINUX #include #endif @@ -134,4 +138,8 @@ void FM_Rotate(matrix_t *dest, angle_t angle, fixed_t x, fixed_t y, fixed_t z); #define FSIN(n) FINESINE(ANGLETOFINE(n)) #define FCOS(n) FINECOSINE(ANGLETOFINE(n)) +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/v_video.c b/src/v_video.c index 7df5cacea..247272dcb 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -35,14 +35,6 @@ #include "hardware/r_opengl/r_opengl.h" #endif -// Each screen is [vid.width*vid.height]; -UINT8 *screens[5]; -// screens[0] = main display window -// screens[1] = back screen, alternative blitting -// screens[2] = screenshot buffer, gif movie buffer -// screens[3] = fade screen start -// screens[4] = fade screen end, postimage tempoarary buffer - static CV_PossibleValue_t fps_cons_t[] = {{0, "No"}, {1, "Normal"}, {2, "Compact"}, {3, "Old"}, {4, "Old Compact"}, {0, NULL}}; consvar_t cv_ticrate = {"showfps", "No", CV_SAVE, fps_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -644,29 +636,17 @@ UINT8 hudtrans = 0; static const UINT8 *v_colormap = NULL; static const UINT8 *v_translevel = NULL; -FUNCINLINE static ATTRINLINE UINT8 standardpdraw(const UINT8 *dest, const UINT8 *source, fixed_t ofs) -{ - (void)dest; return source[ofs>>FRACBITS]; -} -FUNCINLINE static ATTRINLINE UINT8 mappedpdraw(const UINT8 *dest, const UINT8 *source, fixed_t ofs) -{ - (void)dest; return *(v_colormap + source[ofs>>FRACBITS]); -} -FUNCINLINE static ATTRINLINE UINT8 translucentpdraw(const UINT8 *dest, const UINT8 *source, fixed_t ofs) -{ - return *(v_translevel + ((source[ofs>>FRACBITS]<<8)&0xff00) + (*dest&0xff)); -} -FUNCINLINE static ATTRINLINE UINT8 transmappedpdraw(const UINT8 *dest, const UINT8 *source, fixed_t ofs) -{ - return *(v_translevel + (((*(v_colormap + source[ofs>>FRACBITS]))<<8)&0xff00) + (*dest&0xff)); -} +#define STANDARDDRAW 1 +#define MAPPEDDRAW 2 +#define TRANSLUCENTDRAW 3 +#define TRANSMAPPEDDRAW 4 // Draws a patch scaled to arbitrary size. void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 scrn, patch_t *patch, const UINT8 *colormap, INT32 bflags) { - UINT8 (*patchdrawfunc)(const UINT8*, const UINT8*, fixed_t); - UINT32 alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT); - UINT32 blendmode = ((bflags & V_BLENDMASK) >> V_BLENDSHIFT); + UINT8 patchdrawtype; + UINT32 alphalevel; + UINT32 blendmode; fixed_t col, ofs, colfrac, rowfrac, fdup, vdup; INT32 dupx, dupy; @@ -676,10 +656,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca fixed_t pwidth; // patch width fixed_t offx = 0; // x offset - if (rendermode == render_none) - return; - - if (!patch) + if (rendermode == render_none || !patch) return; #ifdef HWRENDER @@ -691,17 +668,26 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca } #endif - patchdrawfunc = standardpdraw; + alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT); + blendmode = ((bflags & V_BLENDMASK) >> V_BLENDSHIFT); + + patchdrawtype = STANDARDDRAW; v_translevel = NULL; if (alphalevel || blendmode) { - if (alphalevel == 13) - alphalevel = hudminusalpha[hudtrans]; - else if (alphalevel == 14) - alphalevel = 10 - hudtrans; - else if (alphalevel == 15) - alphalevel = hudplusalpha[hudtrans]; + switch (alphalevel) + { + case 13: + alphalevel = hudminusalpha[hudtrans]; + break; + case 14: + alphalevel = (10 - hudtrans); + break; + case 15: + alphalevel = hudplusalpha[hudtrans]; + break; + } if (alphalevel >= 10) return; // invis @@ -709,7 +695,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca if (alphalevel || blendmode) { v_translevel = R_GetBlendTable(blendmode+1, alphalevel); - patchdrawfunc = translucentpdraw; + patchdrawtype = TRANSLUCENTDRAW; } } @@ -718,7 +704,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca if (colormap) { v_colormap = colormap; - patchdrawfunc = (v_translevel) ? transmappedpdraw : mappedpdraw; + patchdrawtype = (v_translevel) ? TRANSMAPPEDDRAW : MAPPEDDRAW; } dupx = vid.dupx; @@ -786,7 +772,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca if (scrn & V_HORZSCREEN) x += (BASEVIDWIDTH/2)<>FRACBITS) < patch->width; col += colfrac, ++offx, desttop++) { INT32 topdelta, prevdelta = -1; @@ -866,37 +854,111 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca { if (x+pwidth-offx < 0) // don't draw off the left of the screen (WRAP PREVENTION) break; - if (x+pwidth-offx >= vid.width) // don't draw off the right of the screen (WRAP PREVENTION) + if (x+pwidth-offx >= stride) // don't draw off the right of the screen (WRAP PREVENTION) continue; } else { if (x+offx < 0) // don't draw off the left of the screen (WRAP PREVENTION) continue; - if (x+offx >= vid.width) // don't draw off the right of the screen (WRAP PREVENTION) + if (x+offx >= stride) // don't draw off the right of the screen (WRAP PREVENTION) break; } column = (const column_t *)((const UINT8 *)(patch->columns) + (patch->columnofs[col>>FRACBITS])); - while (column->topdelta != 0xff) + switch (patchdrawtype) { - topdelta = column->topdelta; - if (topdelta <= prevdelta) - topdelta += prevdelta; - prevdelta = topdelta; - source = (const UINT8 *)(column) + 3; - dest = desttop; - if (scrn & V_FLIP) - dest = deststart + (destend - desttop); - dest += FixedInt(FixedMul(topdelta<topdelta != 0xff) + { + topdelta = column->topdelta; + if (topdelta <= prevdelta) + topdelta += prevdelta; + prevdelta = topdelta; + source = (const UINT8 *)(column) + 3; + dest = desttop; + if (scrn & V_FLIP) + dest = deststart + (destend - desttop); + dest += FixedInt(FixedMul(topdelta<>FRACBITS) < column->length; ofs += rowfrac) - { - if (dest >= screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION) - *dest = patchdrawfunc(dest, source, ofs); - dest += vid.width; - } - column = (const column_t *)((const UINT8 *)column + column->length + 4); + for (ofs = 0; dest < deststop && (ofs>>FRACBITS) < column->length; ofs += rowfrac) + { + if (dest >= vid.screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION) + *dest = source[ofs>>FRACBITS]; + dest += stride; + } + column = (const column_t *)((const UINT8 *)column + column->length + 4); + } + break; + + case MAPPEDDRAW: + while (column->topdelta != 0xff) + { + topdelta = column->topdelta; + if (topdelta <= prevdelta) + topdelta += prevdelta; + prevdelta = topdelta; + source = (const UINT8 *)(column) + 3; + dest = desttop; + if (scrn & V_FLIP) + dest = deststart + (destend - desttop); + dest += FixedInt(FixedMul(topdelta<>FRACBITS) < column->length; ofs += rowfrac) + { + if (dest >= vid.screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION) + *dest = *(v_colormap + source[ofs>>FRACBITS]); + dest += stride; + } + column = (const column_t *)((const UINT8 *)column + column->length + 4); + } + break; + + case TRANSLUCENTDRAW: + while (column->topdelta != 0xff) + { + topdelta = column->topdelta; + if (topdelta <= prevdelta) + topdelta += prevdelta; + prevdelta = topdelta; + source = (const UINT8 *)(column) + 3; + dest = desttop; + if (scrn & V_FLIP) + dest = deststart + (destend - desttop); + dest += FixedInt(FixedMul(topdelta<>FRACBITS) < column->length; ofs += rowfrac) + { + if (dest >= vid.screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION) + *dest = *(v_translevel + ((source[ofs>>FRACBITS]<<8)&0xff00) + (*dest&0xff)); + dest += stride; + } + column = (const column_t *)((const UINT8 *)column + column->length + 4); + } + break; + + case TRANSMAPPEDDRAW: + while (column->topdelta != 0xff) + { + topdelta = column->topdelta; + if (topdelta <= prevdelta) + topdelta += prevdelta; + prevdelta = topdelta; + source = (const UINT8 *)(column) + 3; + dest = desttop; + if (scrn & V_FLIP) + dest = deststart + (destend - desttop); + dest += FixedInt(FixedMul(topdelta<>FRACBITS) < column->length; ofs += rowfrac) + { + if (dest >= vid.screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION) + *dest = *(v_translevel + (((*(v_colormap + source[ofs>>FRACBITS]))<<8)&0xff00) + (*dest&0xff)); + dest += stride; + } + column = (const column_t *)((const UINT8 *)column + column->length + 4); + } + break; } } } @@ -904,9 +966,8 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca // Draws a patch cropped and scaled to arbitrary size. void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t *patch, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h) { - UINT8 (*patchdrawfunc)(const UINT8*, const UINT8*, fixed_t); + UINT8 patchdrawtype; UINT32 alphalevel = 0; - // boolean flip = false; fixed_t col, ofs, colfrac, rowfrac, fdup; INT32 dupx, dupy; @@ -914,10 +975,7 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ UINT8 *desttop, *dest; const UINT8 *source, *deststop; - if (rendermode == render_none) - return; - - if (!patch) + if (rendermode == render_none || !patch) return; #ifdef HWRENDER @@ -928,17 +986,23 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ } #endif - patchdrawfunc = standardpdraw; + patchdrawtype = STANDARDDRAW; v_translevel = NULL; if ((alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT))) { - if (alphalevel == 13) - alphalevel = hudminusalpha[hudtrans]; - else if (alphalevel == 14) - alphalevel = 10 - hudtrans; - else if (alphalevel == 15) - alphalevel = hudplusalpha[hudtrans]; + switch (alphalevel) + { + case 13: + alphalevel = hudminusalpha[hudtrans]; + break; + case 14: + alphalevel = (10 - hudtrans); + break; + case 15: + alphalevel = hudplusalpha[hudtrans]; + break; + } if (alphalevel >= 10) return; // invis @@ -946,7 +1010,7 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ if (alphalevel) { v_translevel = transtables + ((alphalevel-1)<topoffset<leftoffset<>FRACBITS) < patch->width && ((col>>FRACBITS) - sx) < w; col += colfrac, ++x, desttop++) { INT32 topdelta, prevdelta = -1; + if (x < 0) // don't draw off the left of the screen (WRAP PREVENTION) continue; - if (x >= vid.width) // don't draw off the right of the screen (WRAP PREVENTION) + + if (x >= stride) // don't draw off the right of the screen (WRAP PREVENTION) break; + column = (const column_t *)((const UINT8 *)(patch->columns) + (patch->columnofs[col>>FRACBITS])); - while (column->topdelta != 0xff) + switch (patchdrawtype) { - topdelta = column->topdelta; - if (topdelta <= prevdelta) - topdelta += prevdelta; - prevdelta = topdelta; - source = (const UINT8 *)(column) + 3; - dest = desttop; - if (topdelta-sy > 0) - { - dest += FixedInt(FixedMul((topdelta-sy)<topdelta != 0xff) + { + topdelta = column->topdelta; + if (topdelta <= prevdelta) + topdelta += prevdelta; + prevdelta = topdelta; + source = (const UINT8 *)(column) + 3; + dest = desttop; + if (topdelta-sy > 0) + { + dest += FixedInt(FixedMul((topdelta-sy)<>FRACBITS) < column->length && (((ofs>>FRACBITS) - sy) + topdelta) < h; ofs += rowfrac) - { - if (dest >= screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION) - *dest = patchdrawfunc(dest, source, ofs); - dest += vid.width; - } - column = (const column_t *)((const UINT8 *)column + column->length + 4); + for (; dest < deststop && (ofs>>FRACBITS) < column->length && (((ofs>>FRACBITS) - sy) + topdelta) < h; ofs += rowfrac) + { + if (dest >= vid.screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION) + *dest = source[ofs>>FRACBITS]; + dest += stride; + } + column = (const column_t *)((const UINT8 *)column + column->length + 4); + } + break; + + case TRANSLUCENTDRAW: + while (column->topdelta != 0xff) + { + topdelta = column->topdelta; + if (topdelta <= prevdelta) + topdelta += prevdelta; + prevdelta = topdelta; + source = (const UINT8 *)(column) + 3; + dest = desttop; + if (topdelta-sy > 0) + { + dest += FixedInt(FixedMul((topdelta-sy)<>FRACBITS) < column->length && (((ofs>>FRACBITS) - sy) + topdelta) < h; ofs += rowfrac) + { + if (dest >= vid.screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION) + *dest = *(v_translevel + ((source[ofs>>FRACBITS]<<8)&0xff00) + (*dest&0xff)); + dest += stride; + } + column = (const column_t *)((const UINT8 *)column + column->length + 4); + } + break; } } } @@ -1076,8 +1177,8 @@ void V_DrawBlock(INT32 x, INT32 y, INT32 scrn, INT32 width, INT32 height, const I_Error("Bad V_DrawBlock"); #endif - dest = screens[scrn] + y*vid.width + x; - deststop = screens[scrn] + vid.rowbytes * vid.height; + dest = vid.screens[scrn] + y*vid.width + x; + deststop = vid.screens[scrn] + vid.rowbytes * vid.height; while (height--) { @@ -1117,7 +1218,7 @@ void V_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) if (x == 0 && y == 0 && w == BASEVIDWIDTH && h == BASEVIDHEIGHT) { // Clear the entire screen, from dest to deststop. Yes, this really works. - memset(screens[0], (c&255), vid.width * vid.height * vid.bpp); + memset(vid.screens[0], (c&255), vid.width * vid.height); return; } @@ -1144,6 +1245,7 @@ void V_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) else if (!(c & V_SNAPTOTOP)) y += (vid.height - (BASEVIDHEIGHT * dupy)) / 2; } + if (c & V_SPLITSCREEN) y += (BASEVIDHEIGHT * dupy)/2; if (c & V_HORZSCREEN) @@ -1172,17 +1274,23 @@ void V_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) if (y + h > vid.height) h = vid.height-y; - dest = screens[0] + y*vid.width + x; - deststop = screens[0] + vid.rowbytes * vid.height; + dest = vid.screens[0] + y*vid.width + x; + deststop = vid.screens[0] + vid.rowbytes * vid.height; if (alphalevel) { - if (alphalevel == 13) - alphalevel = hudminusalpha[hudtrans]; - else if (alphalevel == 14) - alphalevel = 10 - hudtrans; - else if (alphalevel == 15) - alphalevel = hudplusalpha[hudtrans]; + switch (alphalevel) + { + case 13: + alphalevel = hudminusalpha[hudtrans]; + break; + case 14: + alphalevel = (10 - hudtrans); + break; + case 15: + alphalevel = hudplusalpha[hudtrans]; + break; + } if (alphalevel >= 10) return; // invis @@ -1202,7 +1310,7 @@ void V_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) else { for (;(--h >= 0) && dest < deststop; dest += vid.width) - memset(dest, c, w * vid.bpp); + memset(dest, c, w); } } @@ -1259,7 +1367,7 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) if (rendermode == render_opengl) { UINT32 hwcolor = V_GetHWConsBackColor(); - HWR_DrawConsoleFill(x, y, w, h, hwcolor, c); // we still use the regular color stuff but only for flags. actual draw color is "hwcolor" for this. + HWR_DrawConsoleFill(x, y, w, h, hwcolor, c); // we still use the regular color stuff but only for flags. actual draw color is "hwcolor" for this. return; } #endif @@ -1270,7 +1378,7 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) if (x == 0 && y == 0 && w == BASEVIDWIDTH && h == BASEVIDHEIGHT) { // Clear the entire screen, from dest to deststop. Yes, this really works. - memset(screens[0], (UINT8)(c&255), vid.width * vid.height * vid.bpp); + memset(vid.screens[0], (UINT8)(c&255), vid.width * vid.height); return; } @@ -1317,16 +1425,22 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) if (y + h > vid.height) h = vid.height-y; - dest = screens[0] + y*vid.width + x; + dest = vid.screens[0] + y*vid.width + x; if ((alphalevel = ((c & V_ALPHAMASK) >> V_ALPHASHIFT))) { - if (alphalevel == 13) - alphalevel = hudminusalpha[hudtrans]; - else if (alphalevel == 14) - alphalevel = 10 - hudtrans; - else if (alphalevel == 15) - alphalevel = hudplusalpha[hudtrans]; + switch (alphalevel) + { + case 13: + alphalevel = hudminusalpha[hudtrans]; + break; + case 14: + alphalevel = (10 - hudtrans); + break; + case 15: + alphalevel = hudplusalpha[hudtrans]; + break; + } if (alphalevel >= 10) return; // invis @@ -1334,13 +1448,18 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) c &= 255; - if (!alphalevel) { - for (v = 0; v < h; v++, dest += vid.width) { - for (u = 0; u < w; u++) { + if (!alphalevel) + { + for (v = 0; v < h; v++, dest += vid.width) + { + for (u = 0; u < w; u++) + { dest[u] = consolebgmap[dest[u]]; } } - } else { // mpc 12-04-2018 + } + else + { // mpc 12-04-2018 const UINT8 *fadetable = ((UINT8 *)transtables + ((alphalevel-1)<y) ? y : x w = clip(w,vid.width); @@ -1440,14 +1559,14 @@ void V_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 c) if (h > w) h = w; - dest = screens[0] + y*vid.width + x; - deststop = screens[0] + vid.rowbytes * vid.height; + dest = vid.screens[0] + y*vid.width + x; + deststop = vid.screens[0] + vid.rowbytes * vid.height; c &= 255; for (;(--h >= 0) && dest < deststop; dest += vid.width) { - memset(dest, c, w * vid.bpp); + memset(dest, c, w); if (wait) wait--; else @@ -1512,8 +1631,8 @@ void V_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatnum) dupx = dupy = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); - dest = screens[0] + y*dupy*vid.width + x*dupx; - deststop = screens[0] + vid.rowbytes * vid.height; + dest = vid.screens[0] + y*dupy*vid.width + x*dupx; + deststop = vid.screens[0] + vid.rowbytes * vid.height; // from V_DrawScaledPatch if (vid.width != BASEVIDWIDTH * dupx) @@ -1614,7 +1733,7 @@ void V_DrawVhsEffect(boolean rewind) { static fixed_t upbary = 100*FRACUNIT, downbary = 150*FRACUNIT; - UINT8 *buf = screens[0], *tmp = screens[4]; + UINT8 *buf = vid.screens[0], *tmp = vid.screens[4]; UINT16 y; UINT32 x, pos = 0; @@ -1670,7 +1789,7 @@ void V_DrawVhsEffect(boolean rewind) if (y == 0 && offs < 0) offs = 0; else if (y >= vid.height-2 && offs > 0) offs = 0; - for (x = pos+vid.rowbytes*2; pos < x; pos++) + for (x = min(pos+vid.rowbytes*2, vid.rowbytes*vid.height); pos < x; pos++) { tmp[pos] = thismapstart[buf[pos+offs]]; #ifdef HQ_VHS @@ -1707,8 +1826,8 @@ void V_DrawFadeScreen(UINT16 color, UINT8 strength) : ((color & 0xFF00) // Color is not palette index? ? ((UINT8 *)colormaps + strength*256) // Do COLORMAP fade. : ((UINT8 *)transtables + ((9-strength)<postimg & POSTIMG_WATER) { @@ -3482,7 +3601,7 @@ void V_DoPostProcessor(INT32 view, INT32 param) /* Unoptimized version - for (x = 0; x < vid.width*vid.bpp; x++) + for (x = 0; x < vid.width; x++) { newpix = (x + sine); @@ -3579,7 +3698,7 @@ void V_DoPostProcessor(INT32 view, INT32 param) INT32 y, x, x2; for (y = yoffset; y < yoffset+viewheight; y++) - for (x = xoffset, x2 = xoffset+((viewwidth*vid.bpp)-1); x < xoffset+(viewwidth*vid.bpp); x++, x2--) + for (x = xoffset, x2 = xoffset+(viewwidth-1); x < xoffset+viewwidth; x++, x2--) tmpscr[y*vid.width + x2] = srcscr[y*vid.width + x]; UINT8 *tmp = tmpscr; @@ -3599,8 +3718,8 @@ void V_DoPostProcessor(INT32 view, INT32 param) srcscr = tmp; } - VID_BlitLinearScreen(srcscr+vid.width*vid.bpp*yoffset+xoffset, tmpscr+vid.width*vid.bpp*yoffset+xoffset, - viewwidth*vid.bpp, viewheight, vid.width*vid.bpp, vid.width); + VID_BlitLinearScreen(srcscr+vid.width*yoffset+xoffset, tmpscr+vid.width*yoffset+xoffset, + viewwidth, viewheight, vid.width, vid.width); #endif } @@ -3660,18 +3779,15 @@ void V_Init(void) const INT32 screensize = vid.rowbytes * vid.height; for (i = 0; i < NUMSCREENS; i++) - screens[i] = NULL; + vid.screens[i] = NULL; // start address of NUMSCREENS * width*height vidbuffers if (base) { for (i = 0; i < NUMSCREENS; i++) - screens[i] = base + i*screensize; + vid.screens[i] = base + i*screensize; } - if (vid.direct) - screens[0] = vid.direct; - #ifdef DEBUG CONS_Debug(DBG_RENDER, "V_Init done:\n"); for (i = 0; i < NUMSCREENS; i++) diff --git a/src/v_video.h b/src/v_video.h index 3a8cf7396..d5a4adf5e 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -14,6 +14,10 @@ #ifndef __V_VIDEO__ #define __V_VIDEO__ +#ifdef __cplusplus +extern "C" { +#endif + #include "doomdef.h" #include "doomtype.h" #include "r_defs.h" @@ -23,11 +27,6 @@ // VIDEO // -// Screen 0 is the screen updated by I_Update screen. -// Screen 1 is an extra buffer. - -extern UINT8 *screens[5]; - extern consvar_t cv_ticrate, cv_accuratefps, cv_allcaps, cv_constextsize, cv_menucaps, cv_globalgamma, cv_globalsaturation, cv_rhue, cv_yhue, cv_ghue, cv_chue, cv_bhue, cv_mhue, @@ -290,4 +289,8 @@ void V_DrawHorizontallyScaledFullScreenPatch(patch_t *patch); void VID_BlitLinearScreen(const UINT8 *srcptr, UINT8 *destptr, INT32 width, INT32 height, size_t srcrowbytes, size_t destrowbytes); +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/w_wad.c b/src/w_wad.c index 15d968b87..6490f561d 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -65,6 +65,7 @@ #include "st_stuff.h" #include "m_misc.h" // M_MapNumber #include "p_setup.h" // P_PartialAddFile mayb +#include "k_hud.h" #ifdef HWRENDER #include "r_data.h" diff --git a/src/w_wad.h b/src/w_wad.h index 12ad8cea7..9b1035fa2 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -14,6 +14,10 @@ #ifndef __W_WAD__ #define __W_WAD__ +#ifdef __cplusplus +extern "C" { +#endif + #ifdef HWRENDER #include "hardware/hw_data.h" #endif @@ -233,4 +237,8 @@ int W_VerifyNMUSlumps(const char *filename); int W_CheckPostLoadList(const char *filename); +#ifdef __cplusplus +} // extern "C" +#endif + #endif // __W_WAD__ diff --git a/src/win32/Srb2win.rc b/src/win32/Srb2win.rc index d7a26dc85..da6c64d82 100644 --- a/src/win32/Srb2win.rc +++ b/src/win32/Srb2win.rc @@ -1,5 +1,3 @@ -#include - //Microsoft Developer Studio generated resource script. // #include "resource.h" diff --git a/src/y_inter.c b/src/y_inter.c index 3c0a77ac1..068115f4f 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -40,6 +40,7 @@ #include "m_random.h" // M_RandomKey #include "g_input.h" // PLAYER1INPUTDOWN #include "k_kart.h" // colortranslations +#include "k_hud.h" #include "console.h" // cons_menuhighlight #include "lua_hook.h" // IntermissionThinker hook #include "lua_hud.h" // intermission hud hook @@ -57,30 +58,15 @@ typedef struct static y_data_t data; - // graphics -static patch_t *bgpatch = NULL; // INTERSCR -static patch_t *widebgpatch = NULL; // INTERSCW static patch_t *bgtile = NULL; // SPECTILE/SRB2BACK + static INT32 timer; static INT32 intertic; static INT32 endtic = -1; static INT32 sorttic = -1; -patch_t *animVoteFramesPatches = NULL; -// VEXTRN - Vote (V) Extra (EXT) Race (R) Normal (N - Normal sized patch) -// VEXTBN - Vote (V) Extra (EXT) Battle (B) Normal (N - Normal sized patch) -// VEXTBW - Vote (V) Extra (EXT) Battle (B) Normal (W - Wide patch used in software) -// VEXTRW - Vote (V) Extra (EXT) Race (R) Normal (W - Wide patch used in software) -char animPrefix[] = "INTSC"; -char animWidePrefix[] = "INTSW"; -char *luaVoteScreen = NULL; - -INT32 currentAnimFrame = 0; -static INT32 foundAnimVoteFrames = 0; -static INT32 foundAnimVoteWideFrames = 0; - intertype_t intertype = int_none; static huddrawlist_h luahuddrawlist_intermission = NULL; @@ -118,17 +104,13 @@ typedef struct boolean loaded; } y_voteclient; +// votescreen stuff +votescreen_t VoteScreen = {0}; + static y_votelvlinfo levelinfo[5]; static y_voteclient voteclient; static INT32 votetic; static INT32 voteendtic = -1; -static patch_t *cursor = NULL; -static patch_t *cursor1 = NULL; -static patch_t *cursor2 = NULL; -static patch_t *cursor3 = NULL; -static patch_t *cursor4 = NULL; -static patch_t *randomlvl = NULL; -static patch_t *rubyicon = NULL; static void Y_UnloadVoteData(void); @@ -287,49 +269,6 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32)) } } -// -// Y_AnimatedVoteScreenCheck -// -// Check if the lumps exist (checking for VEXTR(N|W)xx for race and VEXTRB(N|W)xx for battle) -static void Y_AnimatedVoteScreenCheck(void) -{ - char tmpPrefix[] = "INTS"; - - if (luaVoteScreen) - strncpy(tmpPrefix, luaVoteScreen, 4); - else if (G_BattleGametype()) - strcpy(tmpPrefix, "BTLS"); - - strncpy(animPrefix, tmpPrefix, 4); - animPrefix[4] = 'C'; - strncpy(animWidePrefix, tmpPrefix, 4); - animWidePrefix[4] = 'W'; - - foundAnimVoteFrames = foundAnimVoteWideFrames = 0; - currentAnimFrame = 0; - - INT32 i = 1; - - for (;;) - { - boolean normalLumpExists = W_LumpExists(va("%sC%d", tmpPrefix, i)); - boolean wideLumpExists = W_LumpExists(va("%sW%d", tmpPrefix, i)); - - if (normalLumpExists || wideLumpExists) - { - if (normalLumpExists) - foundAnimVoteFrames++; - - if (wideLumpExists) - foundAnimVoteWideFrames++; - } - else // If we don't find at least frame 1 (e.g VEXTRN1), let's just stop looking - break; - - i++; - } -} - // Y_PlayerStandingsDrawer // // Handles drawing the center-of-screen player standings. @@ -512,7 +451,7 @@ void Y_IntermissionDrawer(void) else { if (rendermode == render_soft) - VID_BlitLinearScreen(screens[1], screens[0], vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.rowbytes); + VID_BlitLinearScreen(vid.screens[1], vid.screens[0], vid.width, vid.height, vid.width, vid.rowbytes); #ifdef HWRENDER else if (rendermode == render_opengl) HWR_DrawIntermissionBG(); @@ -863,7 +802,8 @@ void Y_StartIntermission(void) // void Y_EndIntermission(void) { - Y_UnloadData(); + if (!dedicated) + Y_UnloadData(); endtic = -1; sorttic = -1; @@ -881,28 +821,72 @@ static void Y_FollowIntermission(void) G_AfterIntermission(); } -#define UNLOAD(x) if (x) {Patch_Free(x);} x = NULL; +#define UNLOAD(x) {if ((x) != NULL) {Patch_Free(x);} x = NULL;} // // Y_UnloadData // static void Y_UnloadData(void) { - // In hardware mode, don't Z_ChangeTag a pointer returned by W_CachePatchName(). - // It doesn't work and is unnecessary. - if (rendermode != render_soft) - return; - // unload the background patches - UNLOAD(bgpatch); - UNLOAD(widebgpatch); + UNLOAD(VoteScreen.bgpatch); + UNLOAD(VoteScreen.widebgpatch); UNLOAD(bgtile); //UNLOAD(interpic); } // SRB2Kart: Voting! -static void Y_DrawVoteBackground(patch_t *patch) +// +// Y_VoteScreenCheck +// +static void Y_VoteScreenCheck(void) +{ + strcpy(VoteScreen.Prefix, "INTS"); + + if (VoteScreen.luaPrefix[0] != 0) + strlcpy(VoteScreen.Prefix, VoteScreen.luaPrefix, sizeof(VoteScreen.Prefix)); + else if (G_BattleGametype()) + strcpy(VoteScreen.Prefix, "BTLS"); + + VoteScreen.foundLuaVoteFrames = VoteScreen.foundLuaVoteWideFrames = 0; + VoteScreen.currentAnimFrame = 0; + + INT32 i = 1; + + // check for lua vote background replacements + for (;;) + { + // Check if the lumps exist (checking for VEXTR(N|W)xx for race and VEXTRB(N|W)xx for battle) + boolean normalLumpExists = W_LumpExists(va("%sC%d", VoteScreen.Prefix, i)); + boolean wideLumpExists = W_LumpExists(va("%sW%d", VoteScreen.Prefix, i)); + + if (normalLumpExists || wideLumpExists) + { + if (normalLumpExists) + VoteScreen.foundLuaVoteFrames++; + + if (wideLumpExists) + VoteScreen.foundLuaVoteWideFrames++; + } + else // If we don't find at least frame 1 (e.g VEXTRN1), let's just stop looking + break; + + i++; + } + + // non lua vote background handling + boolean prefbattletype = ((votelevels[0][1] & ~0x80) == GT_MATCH); + VoteScreen.widebgpatch = W_CachePatchName((prefbattletype ? "BATTLSCW" : "INTERSCW"), PU_PATCH); + VoteScreen.bgpatch = W_CachePatchName((prefbattletype ? "BATTLSCR" : "INTERSCR"), PU_PATCH); +} + +// +// Y_VoteBackgroundDrawer +// +// Determines which patch drawer to use for scaling +// +static void Y_VoteBackgroundDrawer(patch_t *patch) { switch (cv_votebgscaling.value) { @@ -924,57 +908,74 @@ static void Y_DrawVoteBackground(patch_t *patch) } } -// Y_DrawAnimatedVoteScreenPatch // -// Draw animated patch based on frame counter on vote screen +// Y_DrawLuaVoteScreenPatch // -static void Y_DrawAnimatedVoteScreenPatch(boolean widePatch) +// Handles votebackgrounds set by "setVoteBackground" +// Aswell as animated patches +// +static void Y_DrawLuaVoteScreenPatch(boolean widePatch) { INT32 nextframe = 0; patch_t *votebg = NULL; - char tempAnimPrefix[7]; - const INT32 tempFoundAnimVoteFrames = ((widePatch ? foundAnimVoteWideFrames : foundAnimVoteFrames) - 1); + char tempPrefix[6]; + const INT32 tempfoundAnimLuaVoteFrames = ((widePatch ? VoteScreen.foundLuaVoteWideFrames : VoteScreen.foundLuaVoteFrames) - 1); - strcpy(tempAnimPrefix, (widePatch ? animWidePrefix : animPrefix)); + strcpy(tempPrefix, va("%s%s", VoteScreen.Prefix, (widePatch ? "W" : "C"))); + + // Draw non animated patch + if (!tempfoundAnimLuaVoteFrames) + { + votebg = W_CachePatchName(va("%s1", tempPrefix), PU_PATCH); + Y_VoteBackgroundDrawer(votebg); + return; + } + + // Draw animated patch based on frame counter on vote screen // Just in case someone provides LESS widescreen frames than normal frames or vice versa, reset the frame counter to 0 - if (currentAnimFrame > tempFoundAnimVoteFrames) - currentAnimFrame = 0; + if (VoteScreen.currentAnimFrame > tempfoundAnimLuaVoteFrames) + VoteScreen.currentAnimFrame = 0; - nextframe = (currentAnimFrame + 1); + nextframe = (VoteScreen.currentAnimFrame + 1); - votebg = W_CachePatchName(va("%s%d", (widePatch ? animWidePrefix : animPrefix), nextframe), PU_PATCH); + votebg = W_CachePatchName(va("%s%d", tempPrefix, nextframe), PU_PATCH); - Y_DrawVoteBackground(votebg); + Y_VoteBackgroundDrawer(votebg); if (renderisnewtic && (votetic % 2 == 0) && !paused) - currentAnimFrame = (nextframe > tempFoundAnimVoteFrames) ? 0 : nextframe; + VoteScreen.currentAnimFrame = (nextframe > tempfoundAnimLuaVoteFrames) ? 0 : nextframe; } +// +// Y_DrawVoteScreenPatch +// static void Y_DrawVoteScreenPatch(void) { patch_t *votebg = NULL; const boolean widescreen = (vid.width / vid.dupx > 320); - if (foundAnimVoteWideFrames || foundAnimVoteFrames) + if (VoteScreen.foundLuaVoteWideFrames || VoteScreen.foundLuaVoteFrames) { - Y_DrawAnimatedVoteScreenPatch((foundAnimVoteWideFrames && widescreen)); + Y_DrawLuaVoteScreenPatch(((widescreen && VoteScreen.foundLuaVoteWideFrames) || !VoteScreen.foundLuaVoteFrames)); return; } - votebg = bgpatch; // non widescreen patch + // non widescreen patch + votebg = VoteScreen.bgpatch; UINT8 prefgametype = (votelevels[0][1] & ~0x80); - const boolean widebgreplaced = (prefgametype == GT_MATCH) ? widebattlereplaced : wideracereplaced; - const boolean bgreplaced = (prefgametype == GT_MATCH) ? battlereplaced : racereplaced; + const boolean widebgreplaced = (prefgametype == GT_MATCH) ? VoteScreen.replaced.widebattle : VoteScreen.replaced.widerace; + const boolean bgreplaced = (prefgametype == GT_MATCH) ? VoteScreen.replaced.battle : VoteScreen.replaced.race; + // we check a bunch of stuff to always have a "valid" fallback if ((widescreen && (widebgreplaced || !bgreplaced)) || (!widescreen && (widebgreplaced && !bgreplaced))) { - votebg = widebgpatch; + votebg = VoteScreen.widebgpatch; // widescreen patch } - Y_DrawVoteBackground(votebg); + Y_VoteBackgroundDrawer(votebg); } // @@ -1037,7 +1038,7 @@ void Y_VoteDrawer(void) if (i == 3) { str = "RANDOM"; - pic = randomlvl; + pic = VoteScreen.randomlvl; } else { @@ -1061,7 +1062,7 @@ void Y_VoteDrawer(void) if (!splitscreen) { - thiscurs = cursor; + thiscurs = VoteScreen.cursor[0]; p = consoleplayer; color = levelinfo[i].gtc; colormap = NULL; @@ -1071,19 +1072,19 @@ void Y_VoteDrawer(void) switch (j) { case 1: - thiscurs = cursor2; + thiscurs = VoteScreen.cursor[2]; p = displayplayers[1]; break; case 2: - thiscurs = cursor3; + thiscurs = VoteScreen.cursor[3]; p = displayplayers[2]; break; case 3: - thiscurs = cursor4; + thiscurs = VoteScreen.cursor[4]; p = displayplayers[3]; break; default: - thiscurs = cursor1; + thiscurs = VoteScreen.cursor[1]; p = displayplayers[0]; break; } @@ -1111,7 +1112,7 @@ void Y_VoteDrawer(void) else { V_DrawFixedPatch((BASEVIDWIDTH-20)<= 3 && (i != pickedvote || voteendtic == -1)) - pic = randomlvl; + pic = VoteScreen.randomlvl; else pic = levelinfo[votes[i]].pic; if (!timer && i == voteclient.ranim) { - V_DrawScaledPatch(x-18, y+9, V_SNAPTOLEFT, cursor); + V_DrawScaledPatch(x-18, y+9, V_SNAPTOLEFT, VoteScreen.cursor[0]); if (voteendtic != -1 && !(votetic % 4)) V_DrawFill(x-1, y-1, 42, 27, 120|V_SNAPTOLEFT); else @@ -1182,7 +1183,7 @@ void Y_VoteDrawer(void) else { V_DrawFixedPatch((x+40)< #include "doomdef.h" #include "doomtype.h" @@ -153,4 +157,8 @@ size_t Z_TagsUsage(INT32 lowtag, INT32 hightag); // char *Z_StrDup(const char *in); +#ifdef __cplusplus +} // extern "C" +#endif + #endif