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/^.*/dev/null | sed -e 's/^Address=//'`
- ;;
-
- # OpenOffice addresses
- */UserProfile.xml)
- addresses="$addresses "`sed -n -e '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/^/' -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/^/' -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/^/' -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/^/' -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/^.*/dev/null | sed -e 's/^Address=//'`
- ;;
-
- # OpenOffice addresses
- */UserProfile.xml)
- addresses="$addresses "`sed -n -e '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/^/' -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/^/' -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/^/' -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/^/' -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