diff -Nru trigger-rally-0.5.2.1/config.h.in trigger-rally-0.6.0/config.h.in --- trigger-rally-0.5.2.1/config.h.in 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/config.h.in 2011-10-07 17:10:49.000000000 +0000 @@ -48,6 +48,9 @@ /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME +/* Define to the home page for this package. */ +#undef PACKAGE_URL + /* Define to the version of this package. */ #undef PACKAGE_VERSION diff -Nru trigger-rally-0.5.2.1/configure trigger-rally-0.6.0/configure --- trigger-rally-0.5.2.1/configure 2006-10-20 19:22:12.000000000 +0000 +++ trigger-rally-0.6.0/configure 2011-10-07 17:10:49.000000000 +0000 @@ -1,83 +1,418 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for trigger 0.5.2. +# Generated by GNU Autoconf 2.67 for trigger 0.6.0. +# +# Report bugs to . +# +# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software +# Foundation, Inc. # -# Report bugs to . # -# Copyright (C) 2003 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' -elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then - set -o posix + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac fi -DUALCASE=1; export DUALCASE # for MKS sh -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } fi -# Work around bugs in pre-3.0 UWIN ksh. -$as_unset ENV MAIL MAILPATH +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. -for as_var in \ - LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ - LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ - LC_TELEPHONE LC_TIME +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do - if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then - eval $as_var=C; export $as_var + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + # We cannot yet assume a decent shell, so we have to provide a + # neutralization value for shells without unset; and this also + # works around shells that cannot unset nonexistent variables. + BASH_ENV=/dev/null + ENV=/dev/null + (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." else - $as_unset $as_var + $as_echo "$0: Please tell bug-autoconf@gnu.org and jas@jareiko.net +$0: about your system, including any error possibly output +$0: before this message. Then install a modern shell, or +$0: manually run the script under such a shell if you do +$0: have one." fi -done + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error -# Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1; then +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi -if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi -# Name of the executable. -as_me=`$as_basename "$0" || +as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)$' \| \ - . : '\(.\)' 2>/dev/null || -echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } - /^X\/\(\/\/\)$/{ s//\1/; q; } - /^X\/\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` - -# PATH needs CR, and LINENO needs CR and PATH. # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' @@ -85,146 +420,107 @@ as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" || { - # Find who we are. Look in the path if we contain no path at all - # relative or not. - case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done - - ;; - esac - # We did not find ourselves, most probably we were run as `sh COMMAND' - # in which case we are not to be found in the path. - if test "x$as_myself" = x; then - as_myself=$0 - fi - if test ! -f "$as_myself"; then - { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 - { (exit 1); exit 1; }; } - fi - case $CONFIG_SHELL in - '') - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for as_base in sh bash ksh sh5; do - case $as_dir in - /*) - if ("$as_dir/$as_base" -c ' - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then - $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } - $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } - CONFIG_SHELL=$as_dir/$as_base - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$0" ${1+"$@"} - fi;; - esac - done -done -;; - esac - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line before each line; the second 'sed' does the real - # work. The second script uses 'N' to pair each line-number line - # with the numbered line, and appends trailing '-' during - # substitution so that $LINENO is not a special case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) - sed '=' <$as_myself | + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno N - s,$,-, - : loop - s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop - s,-$,, - s,^['$as_cr_digits']*\n,, + s/-\n.*// ' >$as_me.lineno && - chmod +x $as_me.lineno || - { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensible to this). - . ./$as_me.lineno + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" # Exit status is that of the last command. exit } - -case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in - *c*,-n*) ECHO_N= ECHO_C=' -' ECHO_T=' ' ;; - *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; - *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; esac -if expr a : '\(a\)' >/dev/null 2>&1; then - as_expr=expr +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file else - as_expr=false + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null fi - -rm -f conf$$ conf$$.exe conf$$.file -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - # We could just check for DJGPP; but this test a) works b) is more generic - # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). - if test -f conf$$.exe; then - # Don't use ln at all; we don't have any links - as_ln_s='cp -p' - else +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' fi -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln else as_ln_s='cp -p' fi -rm -f conf$$ conf$$.exe conf$$.file +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then - as_mkdir_p=: + as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi -as_executable_p="test -f" +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -233,90 +529,198 @@ as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" -# IFS -# We need space, tab and new line, in precisely that order. -as_nl=' -' -IFS=" $as_nl" - -# CDPATH. -$as_unset CDPATH - +test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. -# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` -exec 6>&1 - # # Initializations. # ac_default_prefix=/usr/local +ac_clean_files= ac_config_libobj_dir=. +LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} - -# Maximum number of lines to put in a shell here document. -# This variable seems obsolete. It should probably be removed, and -# only ac_max_sed_lines should be used. -: ${ac_max_here_lines=38} # Identity of this package. PACKAGE_NAME='trigger' PACKAGE_TARNAME='trigger' -PACKAGE_VERSION='0.5.2' -PACKAGE_STRING='trigger 0.5.2' -PACKAGE_BUGREPORT='jaz@positro.net' +PACKAGE_VERSION='0.6.0' +PACKAGE_STRING='trigger 0.6.0' +PACKAGE_BUGREPORT='jas@jareiko.net' +PACKAGE_URL='' ac_unique_file="src/trigger/main.cpp" # Factoring default headers for most tests. ac_includes_default="\ #include -#if HAVE_SYS_TYPES_H +#ifdef HAVE_SYS_TYPES_H # include #endif -#if HAVE_SYS_STAT_H +#ifdef HAVE_SYS_STAT_H # include #endif -#if STDC_HEADERS +#ifdef STDC_HEADERS # include # include #else -# if HAVE_STDLIB_H +# ifdef HAVE_STDLIB_H # include # endif #endif -#if HAVE_STRING_H -# if !STDC_HEADERS && HAVE_MEMORY_H +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif -#if HAVE_STRINGS_H +#ifdef HAVE_STRINGS_H # include #endif -#if HAVE_INTTYPES_H +#ifdef HAVE_INTTYPES_H # include -#else -# if HAVE_STDINT_H -# include -# endif #endif -#if HAVE_UNISTD_H +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H # include #endif" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os VARIANT CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA SDL_CONFIG CC CFLAGS ac_ct_CC SDL_CFLAGS SDL_LIBS SDLIMAGE_AVAILABLE SDLIMAGE_CFLAGS SDLIMAGE_LIBS AUDIOLIB_AVAILABLE AUDIOLIB_CFLAGS AUDIOLIB_LIBS PHYSFS_AVAILABLE PHYSFS_CFLAGS PHYSFS_LIBS CPP acx_pthread_config PTHREAD_CC PTHREAD_LIBS PTHREAD_CFLAGS EGREP GL_CFLAGS GL_LIBS GLU_CFLAGS GLU_LIBS INSTALL LIBOBJS LTLIBOBJS' +ac_subst_vars='LTLIBOBJS +LIBOBJS +INSTALL +GLU_LIBS +GLU_CFLAGS +GL_LIBS +GL_CFLAGS +EGREP +GREP +PTHREAD_CFLAGS +PTHREAD_LIBS +PTHREAD_CC +acx_pthread_config +CPP +XMKMF +PHYSFS_LIBS +PHYSFS_CFLAGS +PHYSFS_AVAILABLE +AUDIOLIB_LIBS +AUDIOLIB_CFLAGS +AUDIOLIB_AVAILABLE +SDLIMAGE_LIBS +SDLIMAGE_CFLAGS +SDLIMAGE_AVAILABLE +SDL_LIBS +SDL_CFLAGS +ac_ct_CC +CFLAGS +CC +SDL_CONFIG +INSTALL_DATA +INSTALL_SCRIPT +INSTALL_PROGRAM +OBJEXT +EXEEXT +ac_ct_CXX +CPPFLAGS +LDFLAGS +CXXFLAGS +CXX +VARIANT +target_os +target_vendor +target_cpu +target +host_os +host_vendor +host_cpu +host +build_os +build_vendor +build_cpu +build +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' ac_subst_files='' +ac_user_opts=' +enable_option_checking +enable_optimize +enable_debug +enable_profile +with_sdl_prefix +with_sdl_exec_prefix +enable_sdltest +with_libSDL_image +with_libFMOD +with_libAlut +with_libPhysFS +with_x +with_apple_opengl_framework +' + ac_precious_vars='build_alias +host_alias +target_alias +CXX +CXXFLAGS +LDFLAGS +LIBS +CPPFLAGS +CCC +CC +CFLAGS +XMKMF +CPP' + # Initialize some variables set by options. ac_init_help= ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null @@ -339,34 +743,49 @@ # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' -datadir='${prefix}/share' +datarootdir='${prefix}/share' +datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' -libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' -infodir='${prefix}/info' -mandir='${prefix}/man' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' ac_prev= +ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then - eval "$ac_prev=\$ac_option" + eval $ac_prev=\$ac_option ac_prev= continue fi - ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` + case $ac_option in + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; + esac # Accept the important Cygnus configure options, so we can diagnose typos. - case $ac_option in + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; @@ -388,33 +807,59 @@ --config-cache | -C) cache_file=config.cache ;; - -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ - | --da=*) + -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + -disable-* | --disable-*) - ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid feature name: $ac_feature" >&2 - { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` - eval "enable_$ac_feature=no" ;; + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; -enable-* | --enable-*) - ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid feature name: $ac_feature" >&2 - { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` - case $ac_option in - *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; - *) ac_optarg=yes ;; + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; esac - eval "enable_$ac_feature='$ac_optarg'" ;; + eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ @@ -441,6 +886,12 @@ -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; @@ -465,13 +916,16 @@ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst \ - | --locals | --local | --loca | --loc | --lo) + | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* \ - | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) @@ -536,6 +990,16 @@ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; @@ -586,26 +1050,36 @@ ac_init_version=: ;; -with-* | --with-*) - ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid package name: $ac_package" >&2 - { (exit 1); exit 1; }; } - ac_package=`echo $ac_package| sed 's/-/_/g'` - case $ac_option in - *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; - *) ac_optarg=yes ;; + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; esac - eval "with_$ac_package='$ac_optarg'" ;; + eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) - ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid package name: $ac_package" >&2 - { (exit 1); exit 1; }; } - ac_package=`echo $ac_package | sed 's/-/_/g'` - eval "with_$ac_package=no" ;; + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. @@ -625,26 +1099,25 @@ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; - -*) { echo "$as_me: error: unrecognized option: $ac_option -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. - expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 - { (exit 1); exit 1; }; } - ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` - eval "$ac_envvar='$ac_optarg'" + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. - echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; @@ -653,31 +1126,36 @@ if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` - { echo "$as_me: error: missing argument to $ac_option" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "missing argument to $ac_option" fi -# Be sure to have absolute paths. -for ac_var in exec_prefix prefix -do - eval ac_val=$`echo $ac_var` - case $ac_val in - [\\/$]* | ?:[\\/]* | NONE | '' ) ;; - *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; };; +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac -done +fi -# Be sure to have absolute paths. -for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ - localstatedir libdir includedir oldincludedir infodir mandir +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir do - eval ac_val=$`echo $ac_var` + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. case $ac_val in - [\\/$]* | ?:[\\/]* ) ;; - *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; };; + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' @@ -691,8 +1169,8 @@ if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used." >&2 + $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -704,82 +1182,72 @@ test "$silent" = yes && exec 6>/dev/null +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error $? "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error $? "pwd does not report name of working directory" + + # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes - # Try the directory containing this script, then its parent. - ac_confdir=`(dirname "$0") 2>/dev/null || -$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$0" : 'X\(//\)[^/]' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$0" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` srcdir=$ac_confdir - if test ! -r $srcdir/$ac_unique_file; then + if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi -if test ! -r $srcdir/$ac_unique_file; then - if test "$ac_srcdir_defaulted" = yes; then - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 - { (exit 1); exit 1; }; } - else - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 - { (exit 1); exit 1; }; } - fi -fi -(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || - { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 - { (exit 1); exit 1; }; } -srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` -ac_env_build_alias_set=${build_alias+set} -ac_env_build_alias_value=$build_alias -ac_cv_env_build_alias_set=${build_alias+set} -ac_cv_env_build_alias_value=$build_alias -ac_env_host_alias_set=${host_alias+set} -ac_env_host_alias_value=$host_alias -ac_cv_env_host_alias_set=${host_alias+set} -ac_cv_env_host_alias_value=$host_alias -ac_env_target_alias_set=${target_alias+set} -ac_env_target_alias_value=$target_alias -ac_cv_env_target_alias_set=${target_alias+set} -ac_cv_env_target_alias_value=$target_alias -ac_env_CXX_set=${CXX+set} -ac_env_CXX_value=$CXX -ac_cv_env_CXX_set=${CXX+set} -ac_cv_env_CXX_value=$CXX -ac_env_CXXFLAGS_set=${CXXFLAGS+set} -ac_env_CXXFLAGS_value=$CXXFLAGS -ac_cv_env_CXXFLAGS_set=${CXXFLAGS+set} -ac_cv_env_CXXFLAGS_value=$CXXFLAGS -ac_env_LDFLAGS_set=${LDFLAGS+set} -ac_env_LDFLAGS_value=$LDFLAGS -ac_cv_env_LDFLAGS_set=${LDFLAGS+set} -ac_cv_env_LDFLAGS_value=$LDFLAGS -ac_env_CPPFLAGS_set=${CPPFLAGS+set} -ac_env_CPPFLAGS_value=$CPPFLAGS -ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} -ac_cv_env_CPPFLAGS_value=$CPPFLAGS -ac_env_CC_set=${CC+set} -ac_env_CC_value=$CC -ac_cv_env_CC_set=${CC+set} -ac_cv_env_CC_value=$CC -ac_env_CFLAGS_set=${CFLAGS+set} -ac_env_CFLAGS_value=$CFLAGS -ac_cv_env_CFLAGS_set=${CFLAGS+set} -ac_cv_env_CFLAGS_value=$CFLAGS -ac_env_CPP_set=${CPP+set} -ac_env_CPP_value=$CPP -ac_cv_env_CPP_set=${CPP+set} -ac_cv_env_CPP_value=$CPP +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done # # Report the --help message. @@ -788,7 +1256,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures trigger 0.5.2 to adapt to many kinds of systems. +\`configure' configures trigger 0.6.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -802,20 +1270,17 @@ --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking...' messages + -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] -_ACEOF - - cat <<_ACEOF Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] + [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] + [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify @@ -825,18 +1290,25 @@ For better control, use the options below. Fine tuning of the installation directories: - --bindir=DIR user executables [EPREFIX/bin] - --sbindir=DIR system admin executables [EPREFIX/sbin] - --libexecdir=DIR program executables [EPREFIX/libexec] - --datadir=DIR read-only architecture-independent data [PREFIX/share] - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] - --infodir=DIR info documentation [PREFIX/info] - --mandir=DIR man documentation [PREFIX/man] + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/trigger] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF @@ -854,11 +1326,12 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of trigger 0.5.2:";; + short | recursive ) echo "Configuration of trigger 0.6.0:";; esac cat <<\_ACEOF Optional Features: + --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-optimize build with optimizations enabled (default YES) @@ -888,172 +1361,469 @@ CXXFLAGS C++ compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory - CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have - headers in a nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if + you have headers in a nonstandard directory CC C compiler command CFLAGS C compiler flags + XMKMF Path to xmkmf, Makefile generator for X Window System CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. -Report bugs to . +Report bugs to . _ACEOF +ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. - ac_popdir=`pwd` for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d $ac_dir || continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue ac_builddir=. -if test "$ac_dir" != .; then - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix case $srcdir in - .) # No --srcdir option. We are building in place. + .) # We are building in place. ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; -esac - -# Do not use `cd foo && pwd` to compute absolute paths, because -# the directories may not exist. -case `pwd` in -.) ac_abs_builddir="$ac_dir";; -*) - case "$ac_dir" in - .) ac_abs_builddir=`pwd`;; - [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; - *) ac_abs_builddir=`pwd`/"$ac_dir";; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_builddir=${ac_top_builddir}.;; -*) - case ${ac_top_builddir}. in - .) ac_abs_top_builddir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; - *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_srcdir=$ac_srcdir;; -*) - case $ac_srcdir in - .) ac_abs_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; - *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_srcdir=$ac_top_srcdir;; -*) - case $ac_top_srcdir in - .) ac_abs_top_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; - *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; - esac;; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - cd $ac_dir - # Check for guested configure; otherwise get Cygnus style configure. - if test -f $ac_srcdir/configure.gnu; then - echo - $SHELL $ac_srcdir/configure.gnu --help=recursive - elif test -f $ac_srcdir/configure; then - echo - $SHELL $ac_srcdir/configure --help=recursive - elif test -f $ac_srcdir/configure.ac || - test -f $ac_srcdir/configure.in; then - echo - $ac_configure --help + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive else - echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi - cd "$ac_popdir" + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } done fi -test -n "$ac_init_help" && exit 0 +test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -trigger configure 0.5.2 -generated by GNU Autoconf 2.59 +trigger configure 0.6.0 +generated by GNU Autoconf 2.67 -Copyright (C) 2003 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF - exit 0 + exit fi -exec 5>config.log -cat >&5 <<_ACEOF -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by trigger $as_me 0.5.2, which was -generated by GNU Autoconf 2.59. Invocation command line was - $ $0 $@ - -_ACEOF +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_cxx_try_compile LINENO +# ---------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_cxx_try_compile () { -cat <<_ASUNAME -## --------- ## -## Platform. ## -## --------- ## - -hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval -/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -hostinfo = `(hostinfo) 2>/dev/null || echo unknown` -/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` -/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` +} # ac_fn_cxx_try_compile -_ASUNAME +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - echo "PATH: $as_dir" -done + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval -} >&5 +} # ac_fn_c_try_compile -cat >&5 <<_ACEOF +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -## ----------- ## -## Core tests. ## -## ----------- ## + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if eval "test \"\${$3+set}\"" = set; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval "test \"\${$3+set}\"" = set; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.i conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} +( $as_echo "## ------------------------------ ## +## Report this to jas@jareiko.net ## +## ------------------------------ ##" + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval "test \"\${$3+set}\"" = set; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_header_mongrel + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval "test \"\${$3+set}\"" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_header_compile +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by trigger $as_me 0.6.0, which was +generated by GNU Autoconf 2.67. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## _ACEOF @@ -1066,7 +1836,6 @@ ac_configure_args= ac_configure_args0= ac_configure_args1= -ac_sep= ac_must_keep_next=false for ac_pass in 1 2 do @@ -1077,13 +1846,13 @@ -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) - ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in - 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) - ac_configure_args1="$ac_configure_args1 '$ac_arg'" + as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else @@ -1099,104 +1868,115 @@ -* ) ac_must_keep_next=true ;; esac fi - ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" - # Get rid of the leading space. - ac_sep=" " + as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done -$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } -$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. -# WARNING: Be sure not to use single quotes in there, as some shells, -# such as our DU 5.0 friend, will then `close' the trap. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo - cat <<\_ASBOX -## ---------------- ## + $as_echo "## ---------------- ## ## Cache variables. ## -## ---------------- ## -_ASBOX +## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, -{ +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done (set) 2>&1 | - case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in - *ac_space=\ *) + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) sed -n \ - "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" - ;; + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( *) - sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; - esac; -} + esac | + sort +) echo - cat <<\_ASBOX -## ----------------- ## + $as_echo "## ----------------- ## ## Output variables. ## -## ----------------- ## -_ASBOX +## ----------------- ##" echo for ac_var in $ac_subst_vars do - eval ac_val=$`echo $ac_var` - echo "$ac_var='"'"'$ac_val'"'"'" + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then - cat <<\_ASBOX -## ------------- ## -## Output files. ## -## ------------- ## -_ASBOX + $as_echo "## ------------------- ## +## File substitutions. ## +## ------------------- ##" echo for ac_var in $ac_subst_files do - eval ac_val=$`echo $ac_var` - echo "$ac_var='"'"'$ac_val'"'"'" + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then - cat <<\_ASBOX -## ----------- ## + $as_echo "## ----------- ## ## confdefs.h. ## -## ----------- ## -_ASBOX +## ----------- ##" echo - sed "/^$/d" confdefs.h | sort + cat confdefs.h echo fi test "$ac_signal" != 0 && - echo "$as_me: caught signal $ac_signal" - echo "$as_me: exit $exit_status" + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" } >&5 - rm -f core *.core && - rm -rf conftest* confdefs* conf$$* $ac_clean_files && + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status - ' 0 +' 0 for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo >confdefs.h +rm -f -r conftest* confdefs.h + +$as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. @@ -1204,112 +1984,137 @@ #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF - cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF - cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF - cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF - cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + # Let the site file select an alternate cache file if it wants to. -# Prefer explicitly selected file to automatically selected ones. -if test -z "$CONFIG_SITE"; then - if test "x$prefix" != xNONE; then - CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" - else - CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" - fi +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site fi -for ac_site_file in $CONFIG_SITE; do - if test -r "$ac_site_file"; then - { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 -echo "$as_me: loading site script $ac_site_file" >&6;} +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5 ; } fi done if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special - # files actually), so we avoid doing that. - if test -f "$cache_file"; then - { echo "$as_me:$LINENO: loading cache $cache_file" >&5 -echo "$as_me: loading cache $cache_file" >&6;} + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in - [\\/]* | ?:[\\/]* ) . $cache_file;; - *) . ./$cache_file;; + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; esac fi else - { echo "$as_me:$LINENO: creating cache $cache_file" >&5 -echo "$as_me: creating cache $cache_file" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false -for ac_var in `(set) 2>&1 | - sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do +for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val="\$ac_cv_env_${ac_var}_value" - eval ac_new_val="\$ac_env_${ac_var}_value" + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) - { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) - { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 -echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then - { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 -echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 -echo "$as_me: former value: $ac_old_val" >&2;} - { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 -echo "$as_me: current value: $ac_new_val" >&2;} - ac_cache_corrupted=: + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) - ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then - { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 -echo "$as_me: error: changes in the environment can compromise the build" >&2;} - { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 -echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} - { (exit 1); exit 1; }; } -fi + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -1319,131 +2124,138 @@ - - - - - - - - - - - - - - - - - - - - - - - - - ac_aux_dir= -for ac_dir in mk/autoconf $srcdir/mk/autoconf; do - if test -f $ac_dir/install-sh; then +for ac_dir in mk/autoconf "$srcdir"/mk/autoconf; do + if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break - elif test -f $ac_dir/install.sh; then + elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break - elif test -f $ac_dir/shtool; then + elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then - { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in mk/autoconf $srcdir/mk/autoconf" >&5 -echo "$as_me: error: cannot find install-sh or install.sh in mk/autoconf $srcdir/mk/autoconf" >&2;} - { (exit 1); exit 1; }; } -fi -ac_config_guess="$SHELL $ac_aux_dir/config.guess" -ac_config_sub="$SHELL $ac_aux_dir/config.sub" -ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. + as_fn_error $? "cannot find install-sh, install.sh, or shtool in mk/autoconf \"$srcdir\"/mk/autoconf" "$LINENO" 5 +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + # Make sure we can run config.sub. -$ac_config_sub sun4 >/dev/null 2>&1 || - { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5 -echo "$as_me: error: cannot run $ac_config_sub" >&2;} - { (exit 1); exit 1; }; } - -echo "$as_me:$LINENO: checking build system type" >&5 -echo $ECHO_N "checking build system type... $ECHO_C" >&6 -if test "${ac_cv_build+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_build_alias=$build_alias -test -z "$ac_cv_build_alias" && - ac_cv_build_alias=`$ac_config_guess` -test -z "$ac_cv_build_alias" && - { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 -echo "$as_me: error: cannot guess build type; you must specify one" >&2;} - { (exit 1); exit 1; }; } -ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || - { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5 -echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;} - { (exit 1); exit 1; }; } +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 -fi -echo "$as_me:$LINENO: result: $ac_cv_build" >&5 -echo "${ECHO_T}$ac_cv_build" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 +$as_echo_n "checking build system type... " >&6; } +if test "${ac_cv_build+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 +$as_echo "$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5 ;; +esac build=$ac_cv_build -build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` - - -echo "$as_me:$LINENO: checking host system type" >&5 -echo $ECHO_N "checking host system type... $ECHO_C" >&6 -if test "${ac_cv_host+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_host_alias=$host_alias -test -z "$ac_cv_host_alias" && - ac_cv_host_alias=$ac_cv_build_alias -ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || - { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5 -echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} - { (exit 1); exit 1; }; } +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 +$as_echo_n "checking host system type... " >&6; } +if test "${ac_cv_host+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 +fi fi -echo "$as_me:$LINENO: result: $ac_cv_host" >&5 -echo "${ECHO_T}$ac_cv_host" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 +$as_echo "$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5 ;; +esac host=$ac_cv_host -host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` - - -echo "$as_me:$LINENO: checking target system type" >&5 -echo $ECHO_N "checking target system type... $ECHO_C" >&6 -if test "${ac_cv_target+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_target_alias=$target_alias -test "x$ac_cv_target_alias" = "x" && - ac_cv_target_alias=$ac_cv_host_alias -ac_cv_target=`$ac_config_sub $ac_cv_target_alias` || - { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_target_alias failed" >&5 -echo "$as_me: error: $ac_config_sub $ac_cv_target_alias failed" >&2;} - { (exit 1); exit 1; }; } +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 +$as_echo_n "checking target system type... " >&6; } +if test "${ac_cv_target+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "x$target_alias" = x; then + ac_cv_target=$ac_cv_host +else + ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5 +fi fi -echo "$as_me:$LINENO: result: $ac_cv_target" >&5 -echo "${ECHO_T}$ac_cv_target" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5 +$as_echo "$ac_cv_target" >&6; } +case $ac_cv_target in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5 ;; +esac target=$ac_cv_target -target_cpu=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -target_vendor=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -target_os=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_target +shift +target_cpu=$1 +target_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +target_os=$* +IFS=$ac_save_IFS +case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac # The aliases save the names the user supplied, while $host etc. @@ -1456,7 +2268,7 @@ #---------------------------------------------------------------------------- # Configuration header #---------------------------------------------------------------------------- - ac_config_headers="$ac_config_headers config.h" +ac_config_headers="$ac_config_headers config.h" # stupid autoconf is adding default -g -O2 flags which we don't want :-/ @@ -1466,22 +2278,20 @@ #---------------------------------------------------------------------------- # Check for operating system #---------------------------------------------------------------------------- -echo "$as_me:$LINENO: checking for target host" >&5 -echo $ECHO_N "checking for target host... $ECHO_C" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for target host" >&5 +$as_echo_n "checking for target host... " >&6; } case $host_os in mingw*|cygwin*) - echo "$as_me:$LINENO: result: WIN32" >&5 -echo "${ECHO_T}WIN32" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: WIN32" >&5 +$as_echo "WIN32" >&6; } #AC_DEFINE([WIN32], [], [define when compiling for a win32 system]) #actually don't define it... gcc does automatically for w32 host ;; *) - echo "$as_me:$LINENO: result: assuming unix" >&5 -echo "${ECHO_T}assuming unix" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: assuming unix" >&5 +$as_echo "assuming unix" >&6; } -cat >>confdefs.h <<\_ACEOF -#define UNIX -_ACEOF +$as_echo "#define UNIX /**/" >>confdefs.h ;; esac @@ -1490,42 +2300,46 @@ # Check for build variant (debug, profile, optimize) #---------------------------------------------------------------------------- VARIANT=optimize -# Check whether --enable-optimize or --disable-optimize was given. -if test "${enable_optimize+set}" = set; then - enableval="$enable_optimize" - test "$enableval" = "yes" && VARIANT=optimize -fi; - -# Check whether --enable-debug or --disable-debug was given. -if test "${enable_debug+set}" = set; then - enableval="$enable_debug" - test "$enableval" = "yes" && VARIANT=debug -fi; - -# Check whether --enable-profile or --disable-profile was given. -if test "${enable_profile+set}" = set; then - enableval="$enable_profile" - test "$enableval" = "yes" && VARIANT=profile -fi; +# Check whether --enable-optimize was given. +if test "${enable_optimize+set}" = set; then : + enableval=$enable_optimize; test "$enableval" = "yes" && VARIANT=optimize +fi + + +# Check whether --enable-debug was given. +if test "${enable_debug+set}" = set; then : + enableval=$enable_debug; test "$enableval" = "yes" && VARIANT=debug +fi + + +# Check whether --enable-profile was given. +if test "${enable_profile+set}" = set; then : + enableval=$enable_profile; test "$enableval" = "yes" && VARIANT=profile +fi + #---------------------------------------------------------------------------- # find applications #---------------------------------------------------------------------------- -ac_ext=cc +ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -if test -n "$ac_tool_prefix"; then - for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC +if test -z "$CXX"; then + if test -n "$CCC"; then + CXX=$CCC + else + if test -n "$ac_tool_prefix"; then + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CXX+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CXX+set}" = set; then : + $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. @@ -1535,39 +2349,41 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done +IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then - echo "$as_me:$LINENO: result: $CXX" >&5 -echo "${ECHO_T}$CXX" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 +$as_echo "$CXX" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi + test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX - for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then : + $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. @@ -1577,59 +2393,72 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CXX="$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done +IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then - echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 -echo "${ECHO_T}$ac_ct_CXX" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 +$as_echo "$ac_ct_CXX" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi + test -n "$ac_ct_CXX" && break done -test -n "$ac_ct_CXX" || ac_ct_CXX="g++" - CXX=$ac_ct_CXX + if test "x$ac_ct_CXX" = x; then + CXX="g++" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_ct_CXX + fi fi - + fi +fi # Provide some information about the compiler. -echo "$as_me:$LINENO:" \ - "checking for C++ compiler version" >&5 -ac_compiler=`set X $ac_compile; echo $2` -{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 - (eval $ac_compiler --version &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 - (eval $ac_compiler -v &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 - (eval $ac_compiler -V &5) 2>&5 +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -1641,112 +2470,108 @@ } _ACEOF ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.exe b.out" +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -echo "$as_me:$LINENO: checking for C++ compiler default output file name" >&5 -echo $ECHO_N "checking for C++ compiler default output file name... $ECHO_C" >&6 -ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` -if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 - (eval $ac_link_default) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - # Find the output, starting from the most likely. This scheme is -# not robust to junk in `.', hence go to wildcards (a.*) only as a last -# resort. - -# Be careful to initialize this variable, since it used to be cached. -# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. -ac_cv_exeext= -# b.out is created by i960 compilers. -for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler works" >&5 +$as_echo_n "checking whether the C++ compiler works... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) - ;; - conftest.$ac_ext ) - # This is the source file. + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - # FIXME: I believe we export ac_cv_exeext for Libtool, - # but it would be cool to find out if it's true. Does anybody - # maintain Libtool? --akim. - export ac_cv_exeext + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. break;; * ) break;; esac done -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +test "$ac_cv_exeext" = no && ac_cv_exeext= -{ { echo "$as_me:$LINENO: error: C++ compiler cannot create executables -See \`config.log' for more details." >&5 -echo "$as_me: error: C++ compiler cannot create executables -See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } +else + ac_file='' fi +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "C++ compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5 ; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler default output file name" >&5 +$as_echo_n "checking for C++ compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext -echo "$as_me:$LINENO: result: $ac_file" >&5 -echo "${ECHO_T}$ac_file" >&6 - -# Check the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -echo "$as_me:$LINENO: checking whether the C++ compiler works" >&5 -echo $ECHO_N "checking whether the C++ compiler works... $ECHO_C" >&6 -# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 -# If not cross compiling, check that we can run a simple program. -if test "$cross_compiling" != yes; then - if { ac_try='./$ac_file' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { echo "$as_me:$LINENO: error: cannot run C++ compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot run C++ compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } - fi - fi -fi -echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 -rm -f a.out a.exe conftest$ac_cv_exeext b.out +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save -# Check the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 -echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 -echo "$as_me:$LINENO: result: $cross_compiling" >&5 -echo "${ECHO_T}$cross_compiling" >&6 - -echo "$as_me:$LINENO: checking for suffix of executables" >&5 -echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with @@ -1754,38 +2579,90 @@ for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - export ac_cv_exeext break;; * ) break;; esac done else - { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi - -rm -f conftest$ac_cv_exeext -echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 -echo "${ECHO_T}$ac_cv_exeext" >&6 + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5 ; } +fi +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT -echo "$as_me:$LINENO: checking for suffix of object files" >&5 -echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 -if test "${ac_cv_objext+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} _ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C++ compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5 ; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if test "${ac_cv_objext+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -1797,45 +2674,46 @@ } _ACEOF rm -f conftest.o conftest.obj -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else - echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5 ; } fi - rm -f conftest.$ac_cv_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 -echo "${ECHO_T}$ac_cv_objext" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT -echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 -echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6 -if test "${ac_cv_cxx_compiler_gnu+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 +$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } +if test "${ac_cv_cxx_compiler_gnu+set}" = set; then : + $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -1849,54 +2727,34 @@ return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then +if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_compiler_gnu=no + ac_compiler_gnu=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi -echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 -echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6 -GXX=`test $ac_compiler_gnu = yes && echo yes` +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 +$as_echo "$ac_cv_cxx_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GXX=yes +else + GXX= +fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS -CXXFLAGS="-g" -echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 -echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6 -if test "${ac_cv_prog_cxx_g+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 +$as_echo_n "checking whether $CXX accepts -g... " >&6; } +if test "${ac_cv_prog_cxx_g+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_save_cxx_werror_flag=$ac_cxx_werror_flag + ac_cxx_werror_flag=yes + ac_cv_prog_cxx_g=no + CXXFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -1907,157 +2765,64 @@ return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then +if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_prog_cxx_g=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 -echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6 -if test "$ac_test_CXXFLAGS" = set; then - CXXFLAGS=$ac_save_CXXFLAGS -elif test $ac_cv_prog_cxx_g = yes; then - if test "$GXX" = yes; then - CXXFLAGS="-g -O2" - else - CXXFLAGS="-g" - fi -else - if test "$GXX" = yes; then - CXXFLAGS="-O2" - else - CXXFLAGS= - fi -fi -for ac_declaration in \ - '' \ - 'extern "C" void std::exit (int) throw (); using std::exit;' \ - 'extern "C" void std::exit (int); using std::exit;' \ - 'extern "C" void exit (int) throw ();' \ - 'extern "C" void exit (int);' \ - 'void exit (int);' -do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + CXXFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -$ac_declaration -#include + int main () { -exit (42); + ; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_cxx_try_compile "$LINENO"; then : -continue -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +else + ac_cxx_werror_flag=$ac_save_cxx_werror_flag + CXXFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -$ac_declaration + int main () { -exit (42); + ; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cxx_g=yes fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -done -rm -f conftest* -if test -n "$ac_declaration"; then - echo '#ifdef __cplusplus' >>confdefs.h - echo $ac_declaration >>confdefs.h - echo '#endif' >>confdefs.h +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cxx_werror_flag=$ac_save_cxx_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 +$as_echo "$ac_cv_prog_cxx_g" >&6; } +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS=$ac_save_CXXFLAGS +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi fi - ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -2077,22 +2842,23 @@ # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. -echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 -echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 +# Reject install programs that cannot install multiple files. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then -if test "${ac_cv_path_install+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +if test "${ac_cv_path_install+set}" = set; then : + $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in - ./ | .// | /cC/* | \ + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in #(( + ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ - ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. @@ -2100,7 +2866,7 @@ # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. @@ -2110,30 +2876,43 @@ # program-specific install script used by HP pwplus--don't use. : else - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" - break 3 + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi fi fi done done ;; esac -done + done +IFS=$as_save_IFS + +rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else - # As a last resort, use the slow shell script. We don't cache a - # path for INSTALL within a source directory, because that will + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is - # removed, or if the path is relative. + # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi -echo "$as_me:$LINENO: result: $INSTALL" >&5 -echo "${ECHO_T}$INSTALL" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. @@ -2156,10 +2935,10 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. @@ -2169,35 +2948,37 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done +IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi + fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. @@ -2207,39 +2988,50 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done +IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi - CC=$ac_ct_CC + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. @@ -2249,77 +3041,37 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done +IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi - CC=$ac_ct_CC -else - CC="$ac_cv_prog_CC" -fi + fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. @@ -2330,18 +3082,19 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done +IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. @@ -2359,24 +3112,25 @@ fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi + fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then - for ac_prog in cl + for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. @@ -2386,39 +3140,41 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done +IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi + test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC - for ac_prog in cl + for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. @@ -2428,71 +3184,83 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done +IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi + test -n "$ac_ct_CC" && break done - CC=$ac_ct_CC + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi fi fi -test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&5 -echo "$as_me: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5 ; } # Provide some information about the compiler. -echo "$as_me:$LINENO:" \ - "checking for C compiler version" >&5 -ac_compiler=`set X $ac_compile; echo $2` -{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 - (eval $ac_compiler --version &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 - (eval $ac_compiler -v &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 - (eval $ac_compiler -V &5) 2>&5 +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - -echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 -echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 -if test "${ac_cv_c_compiler_gnu+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if test "${ac_cv_c_compiler_gnu+set}" = set; then : + $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -2506,54 +3274,34 @@ return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then +if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_compiler_gnu=no + ac_compiler_gnu=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi -echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 -echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 -GCC=`test $ac_compiler_gnu = yes && echo yes` +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS -CFLAGS="-g" -echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 -echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 -if test "${ac_cv_prog_cc_g+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if test "${ac_cv_prog_cc_g+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -2564,38 +3312,49 @@ return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ -ac_cv_prog_cc_g=no + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then @@ -2611,18 +3370,14 @@ CFLAGS= fi fi -echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 -echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 -if test "${ac_cv_prog_cc_stdc+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then : + $as_echo_n "(cached) " >&6 else - ac_cv_prog_cc_stdc=no + ac_cv_prog_cc_c89=no ac_save_CC=$CC -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -2650,12 +3405,17 @@ /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std1 is added to get + as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std1. */ + that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; @@ -2670,201 +3430,37 @@ return 0; } _ACEOF -# Don't try gcc -ansi; that turns off useful extensions and -# breaks some systems' header files. -# AIX -qlanglvl=ansi -# Ultrix and OSF/1 -std1 -# HP-UX 10.20 and later -Ae -# HP-UX older versions -Aa -D_HPUX_SOURCE -# SVR4 -Xc -D__EXTENSIONS__ -for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" - rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_prog_cc_stdc=$ac_arg -break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg fi -rm -f conftest.err conftest.$ac_objext +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break done -rm -f conftest.$ac_ext conftest.$ac_objext +rm -f conftest.$ac_ext CC=$ac_save_CC fi - -case "x$ac_cv_prog_cc_stdc" in - x|xno) - echo "$as_me:$LINENO: result: none needed" >&5 -echo "${ECHO_T}none needed" >&6 ;; +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; *) - echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 - CC="$CC $ac_cv_prog_cc_stdc" ;; + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac - -# Some people use a C++ compiler to compile C. Since we use `exit', -# in C++ we need to declare it. In case someone uses the same compiler -# for both compiling C and C++ we need to have the C++ compiler decide -# the declaration of exit, since it's the most demanding environment. -cat >conftest.$ac_ext <<_ACEOF -#ifndef __cplusplus - choke me -#endif -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - for ac_declaration in \ - '' \ - 'extern "C" void std::exit (int) throw (); using std::exit;' \ - 'extern "C" void std::exit (int); using std::exit;' \ - 'extern "C" void exit (int) throw ();' \ - 'extern "C" void exit (int);' \ - 'void exit (int);' -do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_declaration -#include -int -main () -{ -exit (42); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -continue -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_declaration -int -main () -{ -exit (42); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if test "x$ac_cv_prog_cc_c89" != xno; then : fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -done -rm -f conftest* -if test -n "$ac_declaration"; then - echo '#ifdef __cplusplus' >>confdefs.h - echo $ac_declaration >>confdefs.h - echo '#endif' >>confdefs.h -fi - -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -2873,28 +3469,28 @@ -# Check whether --with-sdl-prefix or --without-sdl-prefix was given. -if test "${with_sdl_prefix+set}" = set; then - withval="$with_sdl_prefix" - sdl_prefix="$withval" +# Check whether --with-sdl-prefix was given. +if test "${with_sdl_prefix+set}" = set; then : + withval=$with_sdl_prefix; sdl_prefix="$withval" else sdl_prefix="" -fi; +fi -# Check whether --with-sdl-exec-prefix or --without-sdl-exec-prefix was given. -if test "${with_sdl_exec_prefix+set}" = set; then - withval="$with_sdl_exec_prefix" - sdl_exec_prefix="$withval" + +# Check whether --with-sdl-exec-prefix was given. +if test "${with_sdl_exec_prefix+set}" = set; then : + withval=$with_sdl_exec_prefix; sdl_exec_prefix="$withval" else sdl_exec_prefix="" -fi; -# Check whether --enable-sdltest or --disable-sdltest was given. -if test "${enable_sdltest+set}" = set; then - enableval="$enable_sdltest" +fi +# Check whether --enable-sdltest was given. +if test "${enable_sdltest+set}" = set; then : + enableval=$enable_sdltest; else enable_sdltest=yes -fi; +fi + if test x$sdl_exec_prefix != x ; then sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" @@ -2913,10 +3509,10 @@ PATH="$prefix/bin:$prefix/usr/bin:$PATH" # Extract the first word of "sdl-config", so it can be a program name with args. set dummy sdl-config; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_SDL_CONFIG+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_SDL_CONFIG+set}" = set; then : + $as_echo_n "(cached) " >&6 else case $SDL_CONFIG in [\\/]* | ?:[\\/]*) @@ -2928,32 +3524,33 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_SDL_CONFIG="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done +IFS=$as_save_IFS test -z "$ac_cv_path_SDL_CONFIG" && ac_cv_path_SDL_CONFIG="no" ;; esac fi SDL_CONFIG=$ac_cv_path_SDL_CONFIG - if test -n "$SDL_CONFIG"; then - echo "$as_me:$LINENO: result: $SDL_CONFIG" >&5 -echo "${ECHO_T}$SDL_CONFIG" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SDL_CONFIG" >&5 +$as_echo "$SDL_CONFIG" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi + min_sdl_version=1.2.5 - echo "$as_me:$LINENO: checking for SDL - version >= $min_sdl_version" >&5 -echo $ECHO_N "checking for SDL - version >= $min_sdl_version... $ECHO_C" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SDL - version >= $min_sdl_version" >&5 +$as_echo_n "checking for SDL - version >= $min_sdl_version... " >&6; } no_sdl="" if test "$SDL_CONFIG" = "no" ; then no_sdl=yes @@ -2973,14 +3570,10 @@ CFLAGS="$CFLAGS $SDL_CFLAGS" LIBS="$LIBS $SDL_LIBS" rm -f conf.sdltest - if test "$cross_compiling" = yes; then + if test "$cross_compiling" = yes; then : echo $ac_n "cross compiling; assumed OK... $ac_c" else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -3041,39 +3634,26 @@ _ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_c_try_run "$LINENO"; then : -( exit $ac_status ) -no_sdl=yes +else + no_sdl=yes fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext fi + CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" fi fi if test "x$no_sdl" = x ; then - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } : else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } if test "$SDL_CONFIG" = "no" ; then echo "*** The sdl-config script installed by SDL could not be found" echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" @@ -3086,11 +3666,7 @@ echo "*** Could not run SDL test program, checking why..." CFLAGS="$CFLAGS $SDL_CFLAGS" LIBS="$LIBS $SDL_LIBS" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -3109,27 +3685,7 @@ return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then +if ac_fn_c_try_link "$LINENO"; then : echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding SDL or finding the wrong" echo "*** version of SDL. If it is not finding SDL, you'll need to set your" @@ -3140,25 +3696,20 @@ echo "*** If you have an old version installed, it is best to remove it, although" echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** The test program failed to compile or link. See the file config.log for the" echo "*** exact error that occured. This usually means SDL was incorrectly installed" echo "*** or that you have moved SDL since it was installed. In the latter case, you" echo "*** may want to edit the sdl-config script: $SDL_CONFIG" fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" fi fi SDL_CFLAGS="" SDL_LIBS="" - { { echo "$as_me:$LINENO: error: Please install libsdl >= 1.2.5" >&5 -echo "$as_me: error: Please install libsdl >= 1.2.5" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Please install libsdl >= 1.2.5" "$LINENO" 5 fi @@ -3167,11 +3718,11 @@ -# Check whether --with-libSDL_image or --without-libSDL_image was given. -if test "${with_libSDL_image+set}" = set; then - withval="$with_libSDL_image" +# Check whether --with-libSDL_image was given. +if test "${with_libSDL_image+set}" = set; then : + withval=$with_libSDL_image; +fi -fi; save_CFLAGS="$CFLAGS" save_CPPFLAGS="$CPPFLAGS" @@ -3183,7 +3734,7 @@ CPPFLAGS="$CPPFLAGS $SDL_CFLAGS" LIBS="$LIBS -lSDL_image $SDL_LIBS" - if test -n "$with_libSDL_image"; then + if test -n "$with_libSDL_image"; then : CFLAGS="-I$with_libSDL_image/include $CFLAGS" CPPFLAGS="-I$with_libSDL_image/include $CPPFLAGS" @@ -3193,11 +3744,11 @@ fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SDL_image >= 1.2" >&5 +$as_echo_n "checking for SDL_image >= 1.2... " >&6; } - echo "$as_me:$LINENO: checking for SDL_image >= 1.2" >&5 -echo $ECHO_N "checking for SDL_image >= 1.2... $ECHO_C" >&6 - - cat >conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ #include "SDL_image.h" int main(int argc, char** argv) @@ -3208,50 +3759,27 @@ } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then +if ac_fn_c_try_link "$LINENO"; then : buildok=yes else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -buildok=no + buildok=no fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$save_LIBS CPPFLAGS=$save_CPPFLAGS CFLAGS=$save_CFLAGS - if test $buildok = yes; then - echo "$as_me:$LINENO: result: found" >&5 -echo "${ECHO_T}found" >&6 + if test $buildok = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 +$as_echo "found" >&6; } SDLIMAGE_AVAILABLE=yes SDLIMAGE_CFLAGS="$RESCFLAGS" SDLIMAGE_LIBS="$RESLIBS" else - echo "$as_me:$LINENO: result: not found" >&5 -echo "${ECHO_T}not found" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } SDLIMAGE_AVAILABLE=no SDLIMAGE_CFLAGS="" SDLIMAGE_LIBS="" @@ -3261,18 +3789,14 @@ - - if test $buildok = yes; then + if test $buildok = yes; then : : else - { { echo "$as_me:$LINENO: error: Please install SDLImage >= 1.2" >&5 -echo "$as_me: error: Please install SDLImage >= 1.2" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Please install SDLImage >= 1.2" "$LINENO" 5 fi - #AX_FINDLIB([AUDIOLIB], [SDL_mixer], [SDL_mixer >= 1.2.1], # AX_LANG_PROGRAM([#include "SDL_mixer.h"], [Mix_OpenAudio(0,0,0,0);]), # [], [-lSDL_mixer], @@ -3287,11 +3811,11 @@ -# Check whether --with-libFMOD or --without-libFMOD was given. -if test "${with_libFMOD+set}" = set; then - withval="$with_libFMOD" +# Check whether --with-libFMOD was given. +if test "${with_libFMOD+set}" = set; then : + withval=$with_libFMOD; +fi -fi; save_CFLAGS="$CFLAGS" save_CPPFLAGS="$CPPFLAGS" @@ -3303,7 +3827,7 @@ CPPFLAGS="$CPPFLAGS " LIBS="$LIBS -lfmod " - if test -n "$with_libFMOD"; then + if test -n "$with_libFMOD"; then : CFLAGS="-I$with_libFMOD/include $CFLAGS" CPPFLAGS="-I$with_libFMOD/include $CPPFLAGS" @@ -3313,11 +3837,11 @@ fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FMOD" >&5 +$as_echo_n "checking for FMOD... " >&6; } - echo "$as_me:$LINENO: checking for FMOD" >&5 -echo $ECHO_N "checking for FMOD... $ECHO_C" >&6 - - cat >conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ #include int main(int argc, char** argv) @@ -3328,50 +3852,27 @@ } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then +if ac_fn_c_try_link "$LINENO"; then : buildok=yes else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -buildok=no + buildok=no fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$save_LIBS CPPFLAGS=$save_CPPFLAGS CFLAGS=$save_CFLAGS - if test $buildok = yes; then - echo "$as_me:$LINENO: result: found" >&5 -echo "${ECHO_T}found" >&6 + if test $buildok = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 +$as_echo "found" >&6; } AUDIOLIB_AVAILABLE=yes AUDIOLIB_CFLAGS="$RESCFLAGS" AUDIOLIB_LIBS="$RESLIBS" else - echo "$as_me:$LINENO: result: not found" >&5 -echo "${ECHO_T}not found" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } AUDIOLIB_AVAILABLE=no AUDIOLIB_CFLAGS="" AUDIOLIB_LIBS="" @@ -3381,17 +3882,13 @@ - - if test $buildok = yes; then + if test $buildok = yes; then : : else - { { echo "$as_me:$LINENO: error: Please install FMOD" >&5 -echo "$as_me: error: Please install FMOD" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Please install FMOD" "$LINENO" 5 fi - ;; # assume UNIX system @@ -3399,11 +3896,11 @@ -# Check whether --with-libAlut or --without-libAlut was given. -if test "${with_libAlut+set}" = set; then - withval="$with_libAlut" +# Check whether --with-libAlut was given. +if test "${with_libAlut+set}" = set; then : + withval=$with_libAlut; +fi -fi; save_CFLAGS="$CFLAGS" save_CPPFLAGS="$CPPFLAGS" @@ -3415,7 +3912,7 @@ CPPFLAGS="$CPPFLAGS " LIBS="$LIBS -lopenal -lalut " - if test -n "$with_libAlut"; then + if test -n "$with_libAlut"; then : CFLAGS="-I$with_libAlut/include $CFLAGS" CPPFLAGS="-I$with_libAlut/include $CPPFLAGS" @@ -3425,11 +3922,11 @@ fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Alut" >&5 +$as_echo_n "checking for Alut... " >&6; } - echo "$as_me:$LINENO: checking for Alut" >&5 -echo $ECHO_N "checking for Alut... $ECHO_C" >&6 - - cat >conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ #include int main(int argc, char** argv) @@ -3440,50 +3937,27 @@ } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then +if ac_fn_c_try_link "$LINENO"; then : buildok=yes else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -buildok=no + buildok=no fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$save_LIBS CPPFLAGS=$save_CPPFLAGS CFLAGS=$save_CFLAGS - if test $buildok = yes; then - echo "$as_me:$LINENO: result: found" >&5 -echo "${ECHO_T}found" >&6 + if test $buildok = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 +$as_echo "found" >&6; } AUDIOLIB_AVAILABLE=yes AUDIOLIB_CFLAGS="$RESCFLAGS" AUDIOLIB_LIBS="$RESLIBS" else - echo "$as_me:$LINENO: result: not found" >&5 -echo "${ECHO_T}not found" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } AUDIOLIB_AVAILABLE=no AUDIOLIB_CFLAGS="" AUDIOLIB_LIBS="" @@ -3493,40 +3967,36 @@ - - if test $buildok = yes; then + if test $buildok = yes; then : : else - { { echo "$as_me:$LINENO: error: Please install FreeALUT/OpenAL" >&5 -echo "$as_me: error: Please install FreeALUT/OpenAL" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Please install FreeALUT/OpenAL" "$LINENO" 5 fi - ;; esac -# Check whether --with-libPhysFS or --without-libPhysFS was given. -if test "${with_libPhysFS+set}" = set; then - withval="$with_libPhysFS" +# Check whether --with-libPhysFS was given. +if test "${with_libPhysFS+set}" = set; then : + withval=$with_libPhysFS; +fi -fi; save_CFLAGS="$CFLAGS" save_CPPFLAGS="$CPPFLAGS" save_LIBS="$LIBS" RESCFLAGS="" - RESLIBS="-lphysfs -lz" + RESLIBS="-lphysfs" CFLAGS="$CFLAGS " CPPFLAGS="$CPPFLAGS " - LIBS="$LIBS -lphysfs -lz " + LIBS="$LIBS -lphysfs " - if test -n "$with_libPhysFS"; then + if test -n "$with_libPhysFS"; then : CFLAGS="-I$with_libPhysFS/include $CFLAGS" CPPFLAGS="-I$with_libPhysFS/include $CPPFLAGS" @@ -3536,11 +4006,11 @@ fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PhysFS" >&5 +$as_echo_n "checking for PhysFS... " >&6; } - echo "$as_me:$LINENO: checking for PhysFS" >&5 -echo $ECHO_N "checking for PhysFS... $ECHO_C" >&6 - - cat >conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ #include int main(int argc, char** argv) @@ -3551,50 +4021,27 @@ } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then +if ac_fn_c_try_link "$LINENO"; then : buildok=yes else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -buildok=no + buildok=no fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$save_LIBS CPPFLAGS=$save_CPPFLAGS CFLAGS=$save_CFLAGS - if test $buildok = yes; then - echo "$as_me:$LINENO: result: found" >&5 -echo "${ECHO_T}found" >&6 + if test $buildok = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 +$as_echo "found" >&6; } PHYSFS_AVAILABLE=yes PHYSFS_CFLAGS="$RESCFLAGS" PHYSFS_LIBS="$RESLIBS" else - echo "$as_me:$LINENO: result: not found" >&5 -echo "${ECHO_T}not found" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } PHYSFS_AVAILABLE=no PHYSFS_CFLAGS="" PHYSFS_LIBS="" @@ -3604,31 +4051,27 @@ - - if test $buildok = yes; then + if test $buildok = yes; then : : else - { { echo "$as_me:$LINENO: error: Please install PhysFS" >&5 -echo "$as_me: error: Please install PhysFS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Please install PhysFS" "$LINENO" 5 fi - ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu -echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 -echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + if test "${ac_cv_prog_CPP+set}" = set; then : + $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" @@ -3642,11 +4085,7 @@ # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include @@ -3655,78 +4094,34 @@ #endif Syntax error _ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_c_try_cpp "$LINENO"; then : +else # Broken: fails on valid input. continue fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext - # OK, works on sane cases. Now check whether non-existent headers + # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then +if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - # Passes both tests. ac_preproc_ok=: break fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : break fi @@ -3738,8 +4133,8 @@ else ac_cv_prog_CPP=$CPP fi -echo "$as_me:$LINENO: result: $CPP" >&5 -echo "${ECHO_T}$CPP" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do @@ -3749,11 +4144,7 @@ # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include @@ -3762,85 +4153,40 @@ #endif Syntax error _ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_c_try_cpp "$LINENO"; then : +else # Broken: fails on valid input. continue fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext - # OK, works on sane cases. Now check whether non-existent headers + # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then +if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - # Passes both tests. ac_preproc_ok=: break fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - : +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + else - { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&5 -echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5 ; } fi ac_ext=c @@ -3850,45 +4196,47 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -echo "$as_me:$LINENO: checking for X" >&5 -echo $ECHO_N "checking for X... $ECHO_C" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for X" >&5 +$as_echo_n "checking for X... " >&6; } -ac_path_x_has_been_run=yes -# Check whether --with-x or --without-x was given. -if test "${with_x+set}" = set; then - withval="$with_x" +# Check whether --with-x was given. +if test "${with_x+set}" = set; then : + withval=$with_x; +fi -fi; # $have_x is `yes', `no', `disabled', or empty when we do not yet know. if test "x$with_x" = xno; then # The user explicitly disabled X. have_x=disabled else - if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then - # Both variables are already set. - have_x=yes - else - if test "${ac_cv_have_x+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + case $x_includes,$x_libraries in #( + *\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5 ;; #( + *,NONE | NONE,*) if test "${ac_cv_have_x+set}" = set; then : + $as_echo_n "(cached) " >&6 else # One or both of the vars are not set, and there is no cached value. ac_x_includes=no ac_x_libraries=no -rm -fr conftest.dir +rm -f -r conftest.dir if mkdir conftest.dir; then cd conftest.dir - # Make sure to not put "make" in the Imakefile rules, since we grep it out. cat >Imakefile <<'_ACEOF' -acfindx: - @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"' -_ACEOF - if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then - # GNU make sometimes prints "make[1]: Entering...", which would confuse us. - eval `${MAKE-make} acfindx 2>/dev/null | grep -v make` +incroot: + @echo incroot='${INCROOT}' +usrlibdir: + @echo usrlibdir='${USRLIBDIR}' +libdir: + @echo libdir='${LIBDIR}' +_ACEOF + if (export CC; ${XMKMF-xmkmf}) >/dev/null 2>/dev/null && test -f Makefile; then + # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. + for ac_var in incroot usrlibdir libdir; do + eval "ac_im_$ac_var=\`\${MAKE-make} $ac_var 2>/dev/null | sed -n 's/^$ac_var=//p'\`" + done # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR. - for ac_extension in a so sl; do - if test ! -f $ac_im_usrlibdir/libX11.$ac_extension && - test -f $ac_im_libdir/libX11.$ac_extension; then + for ac_extension in a so sl dylib la dll; do + if test ! -f "$ac_im_usrlibdir/libX11.$ac_extension" && + test -f "$ac_im_libdir/libX11.$ac_extension"; then ac_im_usrlibdir=$ac_im_libdir; break fi done @@ -3896,37 +4244,41 @@ # bogus both because they are the default anyway, and because # using them would break gcc on systems where it needs fixed includes. case $ac_im_incroot in - /usr/include) ;; + /usr/include) ac_x_includes= ;; *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;; esac case $ac_im_usrlibdir in - /usr/lib | /lib) ;; + /usr/lib | /usr/lib64 | /lib | /lib64) ;; *) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;; esac fi cd .. - rm -fr conftest.dir + rm -f -r conftest.dir fi # Standard set of common directories for X headers. # Check X11 before X11Rn because it is often a symlink to the current release. ac_x_header_dirs=' /usr/X11/include +/usr/X11R7/include /usr/X11R6/include /usr/X11R5/include /usr/X11R4/include /usr/include/X11 +/usr/include/X11R7 /usr/include/X11R6 /usr/include/X11R5 /usr/include/X11R4 /usr/local/X11/include +/usr/local/X11R7/include /usr/local/X11R6/include /usr/local/X11R5/include /usr/local/X11R4/include /usr/local/include/X11 +/usr/local/include/X11R7 /usr/local/include/X11R6 /usr/local/include/X11R5 /usr/local/include/X11R4 @@ -3946,40 +4298,16 @@ /usr/openwin/share/include' if test "$ac_x_includes" = no; then - # Guess where to find include files, by looking for a specified header file. + # Guess where to find include files, by looking for Xlib.h. # First, try using that file with no special directory specified. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then +if ac_fn_c_try_cpp "$LINENO"; then : # We can compile using X headers with no special include directory. ac_x_includes= else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - for ac_dir in $ac_x_header_dirs; do if test -r "$ac_dir/X11/Xlib.h"; then ac_x_includes=$ac_dir @@ -3987,7 +4315,7 @@ fi done fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext fi # $ac_x_includes = no if test "$ac_x_libraries" = no; then @@ -3996,11 +4324,7 @@ # Don't add to $LIBS permanently. ac_save_LIBS=$LIBS LIBS="-lX11 $LIBS" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int @@ -4011,87 +4335,63 @@ return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then +if ac_fn_c_try_link "$LINENO"; then : LIBS=$ac_save_LIBS # We can link X programs with no special library path. ac_x_libraries= else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -LIBS=$ac_save_LIBS -for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g` + LIBS=$ac_save_LIBS +for ac_dir in `$as_echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g` do # Don't even attempt the hair of trying to link an X program! - for ac_extension in a so sl; do - if test -r $ac_dir/libX11.$ac_extension; then + for ac_extension in a so sl dylib la dll; do + if test -r "$ac_dir/libX11.$ac_extension"; then ac_x_libraries=$ac_dir break 2 fi done done fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext fi # $ac_x_libraries = no -if test "$ac_x_includes" = no || test "$ac_x_libraries" = no; then - # Didn't find X anywhere. Cache the known absence of X. - ac_cv_have_x="have_x=no" -else - # Record where we found X for the cache. - ac_cv_have_x="have_x=yes \ - ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries" -fi +case $ac_x_includes,$ac_x_libraries in #( + no,* | *,no | *\'*) + # Didn't find X, or a directory has "'" in its name. + ac_cv_have_x="have_x=no";; #( + *) + # Record where we found X for the cache. + ac_cv_have_x="have_x=yes\ + ac_x_includes='$ac_x_includes'\ + ac_x_libraries='$ac_x_libraries'" +esac fi - - fi +;; #( + *) have_x=yes;; + esac eval "$ac_cv_have_x" fi # $with_x != no if test "$have_x" != yes; then - echo "$as_me:$LINENO: result: $have_x" >&5 -echo "${ECHO_T}$have_x" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_x" >&5 +$as_echo "$have_x" >&6; } no_x=yes else # If each of the values was on the command line, it overrides each guess. test "x$x_includes" = xNONE && x_includes=$ac_x_includes test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries # Update the cache value to reflect the command line values. - ac_cv_have_x="have_x=yes \ - ac_x_includes=$x_includes ac_x_libraries=$x_libraries" - # It might be that x_includes is empty (headers are found in the - # standard search path. Then output the corresponding message - ac_out_x_includes=$x_includes - test "x$x_includes" = x && ac_out_x_includes="in standard search path" - echo "$as_me:$LINENO: result: libraries $x_libraries, headers $ac_out_x_includes" >&5 -echo "${ECHO_T}libraries $x_libraries, headers $ac_out_x_includes" >&6 + ac_cv_have_x="have_x=yes\ + ac_x_includes='$x_includes'\ + ac_x_libraries='$x_libraries'" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: libraries $x_libraries, headers $x_includes" >&5 +$as_echo "libraries $x_libraries, headers $x_includes" >&6; } fi - ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -4112,61 +4412,33 @@ CFLAGS="$CFLAGS $PTHREAD_CFLAGS" save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" - echo "$as_me:$LINENO: checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS" >&5 -echo $ECHO_N "checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS... $ECHO_C" >&6 - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS" >&5 +$as_echo_n "checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -/* Override any gcc2 internal prototype to avoid an error. */ +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ char pthread_join (); int main () { -pthread_join (); +return pthread_join (); ; return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then +if ac_fn_c_try_link "$LINENO"; then : acx_pthread_ok=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - echo "$as_me:$LINENO: result: $acx_pthread_ok" >&5 -echo "${ECHO_T}$acx_pthread_ok" >&6 +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_ok" >&5 +$as_echo "$acx_pthread_ok" >&6; } if test x"$acx_pthread_ok" = xno; then PTHREAD_LIBS="" PTHREAD_CFLAGS="" @@ -4226,23 +4498,23 @@ case $flag in none) - echo "$as_me:$LINENO: checking whether pthreads work without any flags" >&5 -echo $ECHO_N "checking whether pthreads work without any flags... $ECHO_C" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work without any flags" >&5 +$as_echo_n "checking whether pthreads work without any flags... " >&6; } ;; -*) - echo "$as_me:$LINENO: checking whether pthreads work with $flag" >&5 -echo $ECHO_N "checking whether pthreads work with $flag... $ECHO_C" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work with $flag" >&5 +$as_echo_n "checking whether pthreads work with $flag... " >&6; } PTHREAD_CFLAGS="$flag" ;; pthread-config) # Extract the first word of "pthread-config", so it can be a program name with args. set dummy pthread-config; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_acx_pthread_config+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_acx_pthread_config+set}" = set; then : + $as_echo_n "(cached) " >&6 else if test -n "$acx_pthread_config"; then ac_cv_prog_acx_pthread_config="$acx_pthread_config" # Let the user override the test. @@ -4252,35 +4524,37 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_acx_pthread_config="yes" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done +IFS=$as_save_IFS test -z "$ac_cv_prog_acx_pthread_config" && ac_cv_prog_acx_pthread_config="no" fi fi acx_pthread_config=$ac_cv_prog_acx_pthread_config if test -n "$acx_pthread_config"; then - echo "$as_me:$LINENO: result: $acx_pthread_config" >&5 -echo "${ECHO_T}$acx_pthread_config" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_config" >&5 +$as_echo "$acx_pthread_config" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi + if test x"$acx_pthread_config" = xno; then continue; fi PTHREAD_CFLAGS="`pthread-config --cflags`" PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" ;; *) - echo "$as_me:$LINENO: checking for the pthreads library -l$flag" >&5 -echo $ECHO_N "checking for the pthreads library -l$flag... $ECHO_C" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the pthreads library -l$flag" >&5 +$as_echo_n "checking for the pthreads library -l$flag... " >&6; } PTHREAD_LIBS="-l$flag" ;; esac @@ -4299,11 +4573,7 @@ # pthread_cleanup_push because it is one of the few pthread # functions on Solaris that doesn't have a non-functional libc stub. # We try pthread_create on general principles. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int @@ -4316,41 +4586,17 @@ return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then +if ac_fn_c_try_link "$LINENO"; then : acx_pthread_ok=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" - echo "$as_me:$LINENO: result: $acx_pthread_ok" >&5 -echo "${ECHO_T}$acx_pthread_ok" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_ok" >&5 +$as_echo "$acx_pthread_ok" >&6; } if test "x$acx_pthread_ok" = xyes; then break; fi @@ -4369,13 +4615,9 @@ # Detect AIX lossage: threads are created detached by default # and the JOINABLE attribute has a nonstandard name (UNDETACHED). - echo "$as_me:$LINENO: checking for joinable pthread attribute" >&5 -echo $ECHO_N "checking for joinable pthread attribute... $ECHO_C" >&6 - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for joinable pthread attribute" >&5 +$as_echo_n "checking for joinable pthread attribute... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int @@ -4386,42 +4628,15 @@ return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then +if ac_fn_c_try_link "$LINENO"; then : ok=PTHREAD_CREATE_JOINABLE else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ok=unknown + ok=unknown fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext if test x"$ok" = xunknown; then - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int @@ -4432,60 +4647,35 @@ return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then +if ac_fn_c_try_link "$LINENO"; then : ok=PTHREAD_CREATE_UNDETACHED else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ok=unknown + ok=unknown fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext fi if test x"$ok" != xPTHREAD_CREATE_JOINABLE; then -cat >>confdefs.h <<\_ACEOF -#define PTHREAD_CREATE_JOINABLE $ok -_ACEOF +$as_echo "#define PTHREAD_CREATE_JOINABLE \$ok" >>confdefs.h fi - echo "$as_me:$LINENO: result: ${ok}" >&5 -echo "${ECHO_T}${ok}" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${ok}" >&5 +$as_echo "${ok}" >&6; } if test x"$ok" = xunknown; then - { echo "$as_me:$LINENO: WARNING: we do not know how to create joinable pthreads" >&5 -echo "$as_me: WARNING: we do not know how to create joinable pthreads" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: we do not know how to create joinable pthreads" >&5 +$as_echo "$as_me: WARNING: we do not know how to create joinable pthreads" >&2;} fi - echo "$as_me:$LINENO: checking if more special flags are required for pthreads" >&5 -echo $ECHO_N "checking if more special flags are required for pthreads... $ECHO_C" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if more special flags are required for pthreads" >&5 +$as_echo_n "checking if more special flags are required for pthreads... " >&6; } flag=no case "${host_cpu}-${host_os}" in *-aix* | *-freebsd*) flag="-D_THREAD_SAFE";; *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; esac - echo "$as_me:$LINENO: result: ${flag}" >&5 -echo "${ECHO_T}${flag}" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${flag}" >&5 +$as_echo "${flag}" >&6; } if test "x$flag" != xno; then PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" fi @@ -4496,10 +4686,10 @@ # More AIX lossage: must compile with cc_r # Extract the first word of "cc_r", so it can be a program name with args. set dummy cc_r; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_PTHREAD_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_PTHREAD_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 else if test -n "$PTHREAD_CC"; then ac_cv_prog_PTHREAD_CC="$PTHREAD_CC" # Let the user override the test. @@ -4509,27 +4699,29 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_PTHREAD_CC="cc_r" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done +IFS=$as_save_IFS test -z "$ac_cv_prog_PTHREAD_CC" && ac_cv_prog_PTHREAD_CC="${CC}" fi fi PTHREAD_CC=$ac_cv_prog_PTHREAD_CC if test -n "$PTHREAD_CC"; then - echo "$as_me:$LINENO: result: $PTHREAD_CC" >&5 -echo "${ECHO_T}$PTHREAD_CC" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PTHREAD_CC" >&5 +$as_echo "$PTHREAD_CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi + else PTHREAD_CC="$CC" fi @@ -4541,9 +4733,7 @@ # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: if test x"$acx_pthread_ok" = xyes; then -cat >>confdefs.h <<\_ACEOF -#define HAVE_PTHREAD 1 -_ACEOF +$as_echo "#define HAVE_PTHREAD 1" >>confdefs.h : else @@ -4557,31 +4747,142 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -echo "$as_me:$LINENO: checking for egrep" >&5 -echo $ECHO_N "checking for egrep... $ECHO_C" >&6 -if test "${ac_cv_prog_egrep+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if echo a | (grep -E '(a|b)') >/dev/null 2>&1 - then ac_cv_prog_egrep='grep -E' - else ac_cv_prog_egrep='egrep' +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if test "${ac_cv_path_GREP+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + fi -echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 -echo "${ECHO_T}$ac_cv_prog_egrep" >&6 - EGREP=$ac_cv_prog_egrep +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" -echo "$as_me:$LINENO: checking for ANSI C header files" >&5 -echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 -if test "${ac_cv_header_stdc+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if test "${ac_cv_path_EGREP+set}" = set; then : + $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if test "${ac_cv_header_stdc+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -4596,50 +4897,23 @@ return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_header_stdc=no + ac_cv_header_stdc=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then - : + $EGREP "memchr" >/dev/null 2>&1; then : + else ac_cv_header_stdc=no fi @@ -4649,18 +4923,14 @@ if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then - : + $EGREP "free" >/dev/null 2>&1; then : + else ac_cv_header_stdc=no fi @@ -4670,16 +4940,13 @@ if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then + if test "$cross_compiling" = yes; then : : else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include +#include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) @@ -4699,108 +4966,39 @@ for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) - exit(2); - exit (0); + return 2; + return 0; } _ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_c_try_run "$LINENO"; then : -( exit $ac_status ) -ac_cv_header_stdc=no +else + ac_cv_header_stdc=no fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext fi + fi fi -echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 -echo "${ECHO_T}$ac_cv_header_stdc" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then -cat >>confdefs.h <<\_ACEOF -#define STDC_HEADERS 1 -_ACEOF +$as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. - - - - - - - - - for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default - -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - eval "$as_ac_Header=yes" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -eval "$as_ac_Header=no" -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -if test `eval echo '${'$as_ac_Header'}'` = yes; then +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -4815,16 +5013,14 @@ # alternative GL implementation (e.g., Mesa), which may or may not depend on X. # -# Check whether --with-apple-opengl-framework or --without-apple-opengl-framework was given. -if test "${with_apple_opengl_framework+set}" = set; then - withval="$with_apple_opengl_framework" +# Check whether --with-apple-opengl-framework was given. +if test "${with_apple_opengl_framework+set}" = set; then : + withval=$with_apple_opengl_framework; +fi -fi; if test "X$with_apple_opengl_framework" = "Xyes"; then -cat >>confdefs.h <<\_ACEOF -#define HAVE_APPLE_OPENGL_FRAMEWORK 1 -_ACEOF +$as_echo "#define HAVE_APPLE_OPENGL_FRAMEWORK 1" >>confdefs.h GL_LIBS="-framework OpenGL" else @@ -4854,160 +5050,23 @@ fi fi - -for ac_header in windows.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -else - # Is the header compilable? -echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> + for ac_header in windows.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "windows.h" "ac_cv_header_windows_h" "$ac_includes_default" +if test "x$ac_cv_header_windows_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_WINDOWS_H 1 _ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_header_compiler=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 -ac_header_compiler=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6 -# Is the header present? -echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +done - ac_header_preproc=no -fi -rm -f conftest.err conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6 -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( - cat <<\_ASBOX -## ------------------------------ ## -## Report this to jaz@positro.net ## -## ------------------------------ ## -_ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - - echo "$as_me:$LINENO: checking for OpenGL library" >&5 -echo $ECHO_N "checking for OpenGL library... $ECHO_C" >&6 -if test "${ax_cv_check_gl_libgl+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL library" >&5 +$as_echo_n "checking for OpenGL library... " >&6; } +if test "${ax_cv_check_gl_libgl+set}" = set; then : + $as_echo_n "(cached) " >&6 else ax_cv_check_gl_libgl="no" ax_save_CPPFLAGS="${CPPFLAGS}" @@ -5022,11 +5081,7 @@ ax_try_lib="${ax_lib}" fi LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # if HAVE_WINDOWS_H && defined(_WIN32) @@ -5041,41 +5096,17 @@ return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then +if ac_fn_c_try_link "$LINENO"; then : ax_cv_check_gl_libgl="${ax_try_lib}"; break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext done LIBS=${ax_save_LIBS} CPPFLAGS=${ax_save_CPPFLAGS} fi -echo "$as_me:$LINENO: result: $ax_cv_check_gl_libgl" >&5 -echo "${ECHO_T}$ax_cv_check_gl_libgl" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_gl_libgl" >&5 +$as_echo "$ax_cv_check_gl_libgl" >&6; } if test "X${ax_cv_check_gl_libgl}" = "Xno"; then no_gl="yes" @@ -5096,17 +5127,15 @@ if test "x$GL_CFLAGS" = "x" -a "x$GL_LIBS" = "x"; then - { { echo "$as_me:$LINENO: error: Couldn't find OpenGL library and headers" >&5 -echo "$as_me: error: Couldn't find OpenGL library and headers" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Couldn't find OpenGL library and headers" "$LINENO" 5 fi GLU_CFLAGS="${GL_CFLAGS}" if test "X${with_apple_opengl_framework}" != "Xyes"; then - echo "$as_me:$LINENO: checking for OpenGL Utility library" >&5 -echo $ECHO_N "checking for OpenGL Utility library... $ECHO_C" >&6 -if test "${ax_cv_check_glu_libglu+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL Utility library" >&5 +$as_echo_n "checking for OpenGL Utility library... " >&6; } +if test "${ax_cv_check_glu_libglu+set}" = set; then : + $as_echo_n "(cached) " >&6 else ax_cv_check_glu_libglu="no" ax_save_CPPFLAGS="${CPPFLAGS}" @@ -5127,7 +5156,7 @@ # "conftest.cc"; and Microsoft cl doesn't know what to do with such a # file. # - ac_ext=cc + ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' @@ -5141,11 +5170,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu fi - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # if HAVE_WINDOWS_H && defined(_WIN32) @@ -5160,37 +5185,13 @@ return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then +if ac_fn_c_try_link "$LINENO"; then : ax_cv_check_glu_libglu="${ax_try_lib}"; break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext if test X$ax_compiler_ms = Xyes; then - ac_ext=cc + ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' @@ -5207,8 +5208,8 @@ LIBS=${ax_save_LIBS} CPPFLAGS=${ax_save_CPPFLAGS} fi -echo "$as_me:$LINENO: result: $ax_cv_check_glu_libglu" >&5 -echo "${ECHO_T}$ax_cv_check_glu_libglu" >&6 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_glu_libglu" >&5 +$as_echo "$ax_cv_check_glu_libglu" >&6; } if test "X${ax_cv_check_glu_libglu}" = "Xno"; then no_glu="yes" GLU_CFLAGS="" @@ -5221,9 +5222,7 @@ if test "x$GLU_CFLAGS" = "x" -a "x$GLU_LIBS" = "x"; then - { { echo "$as_me:$LINENO: error: Couldn't find GLU library and headers" >&5 -echo "$as_me: error: Couldn't find GLU library and headers" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "Couldn't find GLU library and headers" "$LINENO" 5 fi # Um, can't get this to substitute [app]datadir :/ @@ -5232,25 +5231,23 @@ # do jam specific fixes - ac_config_commands="$ac_config_commands Jamfile" + ac_config_commands="$ac_config_commands Jamfile" # Handle the case when no prefix is given. And the special case when a path # contains more than 2 slashes, these paths seem to be correct but jam fails # on them. -if test $prefix = NONE; then +if test $prefix = NONE; then : prefix="$ac_default_prefix" else prefix=`echo "$prefix" | sed -e 's:///*:/:g'` fi - -if test $exec_prefix = NONE; then +if test $exec_prefix = NONE; then : exec_prefix="\$(prefix)" else exec_prefix=`echo "$exec_prefix" | sed -e 's:///*:/:g'` fi - prefix=`echo "$prefix" | sed -e 's/\${\([a-zA-Z_][a-zA-Z_]*\)}/$(\1)/g' -e 's/\\\\/\\\\\\\\/g'` exec_prefix=`echo "$exec_prefix" | sed -e 's/\${\([a-zA-Z_][a-zA-Z_]*\)}/$(\1)/g' -e 's/\\\\/\\\\\\\\/g'` bindir=`echo "$bindir" | sed -e 's/\${\([a-zA-Z_][a-zA-Z_]*\)}/$(\1)/g' -e 's/\\\\/\\\\\\\\/g'` @@ -5297,7 +5294,7 @@ # finally output Jamconfig - ac_config_files="$ac_config_files Jamconfig" +ac_config_files="$ac_config_files Jamconfig" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -5317,39 +5314,59 @@ # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. -# So, don't put newlines in cache variables' values. +# So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. -{ +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | - case `(ac_space=' '; set | grep ac_space) 2>&1` in - *ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \). + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; + ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; - esac; -} | + esac | + sort +) | sed ' + /^ac_cv_env_/b end t clear - : clear + :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end - /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - : end' >>confcache -if diff $cache_file confcache >/dev/null 2>&1; then :; else - if test -w $cache_file; then - test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + test "x$cache_file" != "x/dev/null" && + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else - echo "not updating unwritable cache $cache_file" + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache @@ -5358,32 +5375,19 @@ # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/; -s/:*\${srcdir}:*/:/; -s/:*@srcdir@:*/:/; -s/^\([^=]*=[ ]*\):*/\1/; -s/:*$//; -s/^[^=]*=[ ]*$//; -}' -fi - DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= +U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. - ac_i=`echo "$ac_i" | - sed 's/\$U\././;s/\.o$//;s/\.obj$//'` - # 2. Add them. - ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" - ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs @@ -5392,11 +5396,13 @@ : ${CONFIG_STATUS=./config.status} +ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 -echo "$as_me: creating $CONFIG_STATUS" >&6;} -cat >$CONFIG_STATUS <<_ACEOF +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. @@ -5406,81 +5412,252 @@ debug=false ac_cs_recheck=false ac_cs_silent=false -SHELL=\${CONFIG_SHELL-$SHELL} -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' -elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then - set -o posix + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac fi -DUALCASE=1; export DUALCASE # for MKS sh -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' fi +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS -# Work around bugs in pre-3.0 UWIN ksh. -$as_unset ENV MAIL MAILPATH + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. -for as_var in \ - LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ - LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ - LC_TELEPHONE LC_TIME -do - if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then - eval $as_var=C; export $as_var - else - $as_unset $as_var - fi -done +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + -# Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1; then +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi -if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi -# Name of the executable. -as_me=`$as_basename "$0" || +as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)$' \| \ - . : '\(.\)' 2>/dev/null || -echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } - /^X\/\(\/\/\)$/{ s//\1/; q; } - /^X\/\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` - -# PATH needs CR, and LINENO needs CR and PATH. # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' @@ -5488,148 +5665,123 @@ as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" || { - # Find who we are. Look in the path if we contain no path at all - # relative or not. - case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done - - ;; - esac - # We did not find ourselves, most probably we were run as `sh COMMAND' - # in which case we are not to be found in the path. - if test "x$as_myself" = x; then - as_myself=$0 - fi - if test ! -f "$as_myself"; then - { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 -echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} - { (exit 1); exit 1; }; } - fi - case $CONFIG_SHELL in - '') - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for as_base in sh bash ksh sh5; do - case $as_dir in - /*) - if ("$as_dir/$as_base" -c ' - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then - $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } - $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } - CONFIG_SHELL=$as_dir/$as_base - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$0" ${1+"$@"} - fi;; - esac - done -done -;; - esac - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line before each line; the second 'sed' does the real - # work. The second script uses 'N' to pair each line-number line - # with the numbered line, and appends trailing '-' during - # substitution so that $LINENO is not a special case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) - sed '=' <$as_myself | - sed ' - N - s,$,-, - : loop - s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, - t loop - s,-$,, - s,^['$as_cr_digits']*\n,, - ' >$as_me.lineno && - chmod +x $as_me.lineno || - { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 -echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} - { (exit 1); exit 1; }; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensible to this). - . ./$as_me.lineno - # Exit status is that of the last command. - exit -} - - -case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in - *c*,-n*) ECHO_N= ECHO_C=' -' ECHO_T=' ' ;; - *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; - *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; esac -if expr a : '\(a\)' >/dev/null 2>&1; then - as_expr=expr +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file else - as_expr=false + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null fi - -rm -f conf$$ conf$$.exe conf$$.file -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - # We could just check for DJGPP; but this test a) works b) is more generic - # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). - if test -f conf$$.exe; then - # Don't use ln at all; we don't have any links - as_ln_s='cp -p' - else +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' fi -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln else as_ln_s='cp -p' fi -rm -f conf$$ conf$$.exe conf$$.file +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then - as_mkdir_p=: + as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi -as_executable_p="test -f" +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -5638,31 +5790,20 @@ as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" -# IFS -# We need space, tab and new line, in precisely that order. -as_nl=' -' -IFS=" $as_nl" - -# CDPATH. -$as_unset CDPATH - exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 -# Open the log real soon, to keep \$[0] and so on meaningful, and to +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. Logging --version etc. is OK. -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX -} >&5 -cat >&5 <<_CSEOF - -This file was extended by trigger $as_me 0.5.2, which was -generated by GNU Autoconf 2.59. Invocation command line was +# values after options handling. +ac_log=" +This file was extended by trigger $as_me 0.6.0, which was +generated by GNU Autoconf 2.67. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -5670,45 +5811,47 @@ CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ -_CSEOF -echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 -echo >&5 +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + _ACEOF -# Files that config.status was made for. -if test -n "$ac_config_files"; then - echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS -fi +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac -if test -n "$ac_config_headers"; then - echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS -fi +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac -if test -n "$ac_config_links"; then - echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS -fi -if test -n "$ac_config_commands"; then - echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS -fi +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" +config_commands="$ac_config_commands" -cat >>$CONFIG_STATUS <<\_ACEOF +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ -\`$as_me' instantiates files from templates according to the -current configuration. +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. -Usage: $0 [OPTIONS] [FILE]... +Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit - -V, --version print version number, then exit - -q, --quiet do not print progress messages + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - --header=FILE[:TEMPLATE] - instantiate the configuration header FILE + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE Configuration files: $config_files @@ -5719,84 +5862,90 @@ Configuration commands: $config_commands -Report bugs to ." -_ACEOF +Report bugs to ." -cat >>$CONFIG_STATUS <<_ACEOF +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -trigger config.status 0.5.2 -configured by $0, generated by GNU Autoconf 2.59, - with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" +trigger config.status 0.6.0 +configured by $0, generated by GNU Autoconf 2.67, + with options \\"\$ac_cs_config\\" -Copyright (C) 2003 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." -srcdir=$srcdir -INSTALL="$INSTALL" + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' +test -n "\$AWK" || AWK=awk _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -# If no file are specified by the user, then we need to provide default -# value. By we need to know if files were specified by the user. +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in - --*=*) - ac_option=`expr "x$1" : 'x\([^=]*\)='` - ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= ac_shift=: ;; - -*) + *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; - *) # This is not an option, so the user has probably given explicit - # arguments. - ac_option=$1 - ac_need_defaults=false;; esac case $ac_option in # Handling of the options. -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; - --version | --vers* | -V ) - echo "$ac_cs_version"; exit 0 ;; - --he | --h) - # Conflict between --help and --header - { { echo "$as_me:$LINENO: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&5 -echo "$as_me: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&2;} - { (exit 1); exit 1; }; };; - --help | --hel | -h ) - echo "$ac_cs_usage"; exit 0 ;; - --debug | --d* | -d ) + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift - CONFIG_FILES="$CONFIG_FILES $ac_optarg" + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift - CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. - -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&5 -echo "$as_me: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&2;} - { (exit 1); exit 1; }; } ;; + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; - *) ac_config_targets="$ac_config_targets $1" ;; + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; esac shift @@ -5810,32 +5959,46 @@ fi _ACEOF -cat >>$CONFIG_STATUS <<_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then - echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 - exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" fi _ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - - -cat >>$CONFIG_STATUS <<\_ACEOF +# Handling of arguments. for ac_config_target in $ac_config_targets do - case "$ac_config_target" in - # Handling of arguments. - "Jamconfig" ) CONFIG_FILES="$CONFIG_FILES Jamconfig" ;; - "Jamfile" ) CONFIG_COMMANDS="$CONFIG_COMMANDS Jamfile" ;; - "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; - *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 -echo "$as_me: error: invalid argument: $ac_config_target" >&2;} - { (exit 1); exit 1; }; };; + case $ac_config_target in + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "Jamfile") CONFIG_COMMANDS="$CONFIG_COMMANDS Jamfile" ;; + "Jamconfig") CONFIG_FILES="$CONFIG_FILES Jamconfig" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;; esac done + # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely @@ -5847,720 +6010,560 @@ fi # Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason to put it here, and in addition, +# simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. -# Create a temporary directory, and hook for its removal unless debugging. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. $debug || { - trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 - trap '{ (exit 1); exit 1; }' 1 2 13 15 + tmp= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 } - # Create a (secure) tmp directory for tmp files. { - tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { - tmp=./confstat$$-$RANDOM - (umask 077 && mkdir $tmp) -} || + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$tmp/subs1.awk" && +_ACEOF + + { - echo "$me: cannot create a temporary directory in ." >&2 - { (exit 1); exit 1; } + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\)..*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\)..*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line } +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF -cat >>$CONFIG_STATUS <<_ACEOF +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +}' +fi -# -# CONFIG_FILES section. -# +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" -# No need to generate the scripts if there are no CONFIG_FILES. -# This happens for instance when ./config.status config.h -if test -n "\$CONFIG_FILES"; then - # Protect against being on the right side of a sed subst in config.status. - sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; - s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF -s,@SHELL@,$SHELL,;t t -s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t -s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t -s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t -s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t -s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t -s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t -s,@exec_prefix@,$exec_prefix,;t t -s,@prefix@,$prefix,;t t -s,@program_transform_name@,$program_transform_name,;t t -s,@bindir@,$bindir,;t t -s,@sbindir@,$sbindir,;t t -s,@libexecdir@,$libexecdir,;t t -s,@datadir@,$datadir,;t t -s,@sysconfdir@,$sysconfdir,;t t -s,@sharedstatedir@,$sharedstatedir,;t t -s,@localstatedir@,$localstatedir,;t t -s,@libdir@,$libdir,;t t -s,@includedir@,$includedir,;t t -s,@oldincludedir@,$oldincludedir,;t t -s,@infodir@,$infodir,;t t -s,@mandir@,$mandir,;t t -s,@build_alias@,$build_alias,;t t -s,@host_alias@,$host_alias,;t t -s,@target_alias@,$target_alias,;t t -s,@DEFS@,$DEFS,;t t -s,@ECHO_C@,$ECHO_C,;t t -s,@ECHO_N@,$ECHO_N,;t t -s,@ECHO_T@,$ECHO_T,;t t -s,@LIBS@,$LIBS,;t t -s,@build@,$build,;t t -s,@build_cpu@,$build_cpu,;t t -s,@build_vendor@,$build_vendor,;t t -s,@build_os@,$build_os,;t t -s,@host@,$host,;t t -s,@host_cpu@,$host_cpu,;t t -s,@host_vendor@,$host_vendor,;t t -s,@host_os@,$host_os,;t t -s,@target@,$target,;t t -s,@target_cpu@,$target_cpu,;t t -s,@target_vendor@,$target_vendor,;t t -s,@target_os@,$target_os,;t t -s,@VARIANT@,$VARIANT,;t t -s,@CXX@,$CXX,;t t -s,@CXXFLAGS@,$CXXFLAGS,;t t -s,@LDFLAGS@,$LDFLAGS,;t t -s,@CPPFLAGS@,$CPPFLAGS,;t t -s,@ac_ct_CXX@,$ac_ct_CXX,;t t -s,@EXEEXT@,$EXEEXT,;t t -s,@OBJEXT@,$OBJEXT,;t t -s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t -s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t -s,@INSTALL_DATA@,$INSTALL_DATA,;t t -s,@SDL_CONFIG@,$SDL_CONFIG,;t t -s,@CC@,$CC,;t t -s,@CFLAGS@,$CFLAGS,;t t -s,@ac_ct_CC@,$ac_ct_CC,;t t -s,@SDL_CFLAGS@,$SDL_CFLAGS,;t t -s,@SDL_LIBS@,$SDL_LIBS,;t t -s,@SDLIMAGE_AVAILABLE@,$SDLIMAGE_AVAILABLE,;t t -s,@SDLIMAGE_CFLAGS@,$SDLIMAGE_CFLAGS,;t t -s,@SDLIMAGE_LIBS@,$SDLIMAGE_LIBS,;t t -s,@AUDIOLIB_AVAILABLE@,$AUDIOLIB_AVAILABLE,;t t -s,@AUDIOLIB_CFLAGS@,$AUDIOLIB_CFLAGS,;t t -s,@AUDIOLIB_LIBS@,$AUDIOLIB_LIBS,;t t -s,@PHYSFS_AVAILABLE@,$PHYSFS_AVAILABLE,;t t -s,@PHYSFS_CFLAGS@,$PHYSFS_CFLAGS,;t t -s,@PHYSFS_LIBS@,$PHYSFS_LIBS,;t t -s,@CPP@,$CPP,;t t -s,@acx_pthread_config@,$acx_pthread_config,;t t -s,@PTHREAD_CC@,$PTHREAD_CC,;t t -s,@PTHREAD_LIBS@,$PTHREAD_LIBS,;t t -s,@PTHREAD_CFLAGS@,$PTHREAD_CFLAGS,;t t -s,@EGREP@,$EGREP,;t t -s,@GL_CFLAGS@,$GL_CFLAGS,;t t -s,@GL_LIBS@,$GL_LIBS,;t t -s,@GLU_CFLAGS@,$GLU_CFLAGS,;t t -s,@GLU_LIBS@,$GLU_LIBS,;t t -s,@INSTALL@,$INSTALL,;t t -s,@LIBOBJS@,$LIBOBJS,;t t -s,@LTLIBOBJS@,$LTLIBOBJS,;t t -CEOF - -_ACEOF - - cat >>$CONFIG_STATUS <<\_ACEOF - # Split the substitutions into bite-sized pieces for seds with - # small command number limits, like on Digital OSF/1 and HP-UX. - ac_max_sed_lines=48 - ac_sed_frag=1 # Number of current file. - ac_beg=1 # First line for current file. - ac_end=$ac_max_sed_lines # Line after last line for current file. - ac_more_lines=: - ac_sed_cmds= - while $ac_more_lines; do - if test $ac_beg -gt 1; then - sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag - else - sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag - fi - if test ! -s $tmp/subs.frag; then - ac_more_lines=false - else - # The purpose of the label and of the branching condition is to - # speed up the sed processing (if there are no `@' at all, there - # is no need to browse any of the substitutions). - # These are the two extra sed commands mentioned above. - (echo ':t - /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed - if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" - else - ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" - fi - ac_sed_frag=`expr $ac_sed_frag + 1` - ac_beg=$ac_end - ac_end=`expr $ac_end + $ac_max_sed_lines` - fi - done - if test -z "$ac_sed_cmds"; then - ac_sed_cmds=cat +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$tmp/defines.awk" <<\_ACAWK || +BEGIN { +_ACEOF + +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_t=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_t"; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi -fi # test -n "$CONFIG_FILES" +done +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. + +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' >$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case $ac_file in - - | *:- | *:-:* ) # input from stdin - cat >$tmp/stdin - ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - * ) ac_file_in=$ac_file.in ;; +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; esac - # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. - ac_dir=`(dirname "$ac_file") 2>/dev/null || + ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - { if $as_mkdir_p; then - mkdir -p "$ac_dir" - else - as_dir="$ac_dir" - as_dirs= - while test ! -d "$as_dir"; do - as_dirs="$as_dir $as_dirs" - as_dir=`(dirname "$as_dir") 2>/dev/null || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - done - test ! -n "$as_dirs" || mkdir $as_dirs - fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 -echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} - { (exit 1); exit 1; }; }; } - + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. -if test "$ac_dir" != .; then - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix case $srcdir in - .) # No --srcdir option. We are building in place. + .) # We are building in place. ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix -# Do not use `cd foo && pwd` to compute absolute paths, because -# the directories may not exist. -case `pwd` in -.) ac_abs_builddir="$ac_dir";; -*) - case "$ac_dir" in - .) ac_abs_builddir=`pwd`;; - [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; - *) ac_abs_builddir=`pwd`/"$ac_dir";; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_builddir=${ac_top_builddir}.;; -*) - case ${ac_top_builddir}. in - .) ac_abs_top_builddir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; - *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_srcdir=$ac_srcdir;; -*) - case $ac_srcdir in - .) ac_abs_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; - *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_srcdir=$ac_top_srcdir;; -*) - case $ac_top_srcdir in - .) ac_abs_top_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; - *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; - esac;; -esac + case $ac_mode in + :F) + # + # CONFIG_FILE + # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; - *) ac_INSTALL=$ac_top_builddir$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac +_ACEOF - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - if test x"$ac_file" = x-; then - configure_input= - else - configure_input="$ac_file. " - fi - configure_input=$configure_input"Generated from `echo $ac_file_in | - sed 's,.*/,,'` by configure." - - # First look for the input files in the build tree, otherwise in the - # src tree. - ac_file_inputs=`IFS=: - for f in $ac_file_in; do - case $f in - -) echo $tmp/stdin ;; - [\\/$]*) - # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - echo "$f";; - *) # Relative - if test -f "$f"; then - # Build tree - echo "$f" - elif test -f "$srcdir/$f"; then - # Source tree - echo "$srcdir/$f" - else - # /dev/null tree - { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - fi;; - esac - done` || { (exit 1); exit 1; } - - if test x"$ac_file" != x-; then - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - rm -f "$ac_file" - fi +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac _ACEOF -cat >>$CONFIG_STATUS <<_ACEOF - sed "$ac_vpsub + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub $extrasub _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s,@configure_input@,$configure_input,;t t -s,@srcdir@,$ac_srcdir,;t t -s,@abs_srcdir@,$ac_abs_srcdir,;t t -s,@top_srcdir@,$ac_top_srcdir,;t t -s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t -s,@builddir@,$ac_builddir,;t t -s,@abs_builddir@,$ac_abs_builddir,;t t -s,@top_builddir@,$ac_top_builddir,;t t -s,@abs_top_builddir@,$ac_abs_top_builddir,;t t -s,@INSTALL@,$ac_INSTALL,;t t -" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out - rm -f $tmp/stdin - if test x"$ac_file" != x-; then - mv $tmp/out $ac_file - else - cat $tmp/out - rm -f $tmp/out - fi - -done -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF - -# -# CONFIG_HEADER section. -# - -# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where -# NAME is the cpp macro being defined and VALUE is the value it is being given. -# -# ac_d sets the value in "#define NAME VALUE" lines. -ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' -ac_dB='[ ].*$,\1#\2' -ac_dC=' ' -ac_dD=',;t' -# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". -ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_uB='$,\1#\2define\3' -ac_uC=' ' -ac_uD=',;t' +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} -for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + rm -f "$tmp/stdin" case $ac_file in - - | *:- | *:-:* ) # input from stdin - cat >$tmp/stdin - ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - * ) ac_file_in=$ac_file.in ;; - esac - - test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - - # First look for the input files in the build tree, otherwise in the - # src tree. - ac_file_inputs=`IFS=: - for f in $ac_file_in; do - case $f in - -) echo $tmp/stdin ;; - [\\/$]*) - # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - # Do quote $f, to prevent DOS paths from being IFS'd. - echo "$f";; - *) # Relative - if test -f "$f"; then - # Build tree - echo "$f" - elif test -f "$srcdir/$f"; then - # Source tree - echo "$srcdir/$f" - else - # /dev/null tree - { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - fi;; - esac - done` || { (exit 1); exit 1; } - # Remove the trailing spaces. - sed 's/[ ]*$//' $ac_file_inputs >$tmp/in - -_ACEOF - -# Transform confdefs.h into two sed scripts, `conftest.defines' and -# `conftest.undefs', that substitutes the proper values into -# config.h.in to produce config.h. The first handles `#define' -# templates, and the second `#undef' templates. -# And first: Protect against being on the right side of a sed subst in -# config.status. Protect against being in an unquoted here document -# in config.status. -rm -f conftest.defines conftest.undefs -# Using a here document instead of a string reduces the quoting nightmare. -# Putting comments in sed scripts is not portable. -# -# `end' is used to avoid that the second main sed command (meant for -# 0-ary CPP macros) applies to n-ary macro definitions. -# See the Autoconf documentation for `clear'. -cat >confdef2sed.sed <<\_ACEOF -s/[\\&,]/\\&/g -s,[\\$`],\\&,g -t clear -: clear -s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp -t end -s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp -: end -_ACEOF -# If some macros were called several times there might be several times -# the same #defines, which is useless. Nevertheless, we may not want to -# sort them, since we want the *last* AC-DEFINE to be honored. -uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines -sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs -rm -f confdef2sed.sed - -# This sed command replaces #undef with comments. This is necessary, for -# example, in the case of _POSIX_SOURCE, which is predefined and required -# on some systems where configure will not decide to define it. -cat >>conftest.undefs <<\_ACEOF -s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, -_ACEOF - -# Break up conftest.defines because some shells have a limit on the size -# of here documents, and old seds have small limits too (100 cmds). -echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS -echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS -echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS -echo ' :' >>$CONFIG_STATUS -rm -f conftest.tail -while grep . conftest.defines >/dev/null -do - # Write a limited-size here document to $tmp/defines.sed. - echo ' cat >$tmp/defines.sed <>$CONFIG_STATUS - # Speed up: don't consider the non `#define' lines. - echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS - # Work around the forget-to-reset-the-flag bug. - echo 't clr' >>$CONFIG_STATUS - echo ': clr' >>$CONFIG_STATUS - sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS - echo 'CEOF - sed -f $tmp/defines.sed $tmp/in >$tmp/out - rm -f $tmp/in - mv $tmp/out $tmp/in -' >>$CONFIG_STATUS - sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail - rm -f conftest.defines - mv conftest.tail conftest.defines -done -rm -f conftest.defines -echo ' fi # grep' >>$CONFIG_STATUS -echo >>$CONFIG_STATUS - -# Break up conftest.undefs because some shells have a limit on the size -# of here documents, and old seds have small limits too (100 cmds). -echo ' # Handle all the #undef templates' >>$CONFIG_STATUS -rm -f conftest.tail -while grep . conftest.undefs >/dev/null -do - # Write a limited-size here document to $tmp/undefs.sed. - echo ' cat >$tmp/undefs.sed <>$CONFIG_STATUS - # Speed up: don't consider the non `#undef' - echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS - # Work around the forget-to-reset-the-flag bug. - echo 't clr' >>$CONFIG_STATUS - echo ': clr' >>$CONFIG_STATUS - sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS - echo 'CEOF - sed -f $tmp/undefs.sed $tmp/in >$tmp/out - rm -f $tmp/in - mv $tmp/out $tmp/in -' >>$CONFIG_STATUS - sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail - rm -f conftest.undefs - mv conftest.tail conftest.undefs -done -rm -f conftest.undefs - -cat >>$CONFIG_STATUS <<\_ACEOF - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - if test x"$ac_file" = x-; then - echo "/* Generated by configure. */" >$tmp/config.h - else - echo "/* $ac_file. Generated by configure. */" >$tmp/config.h - fi - cat $tmp/in >>$tmp/config.h - rm -f $tmp/in + -) cat "$tmp/out" && rm -f "$tmp/out";; + *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # + # CONFIG_HEADER + # if test x"$ac_file" != x-; then - if diff $ac_file $tmp/config.h >/dev/null 2>&1; then - { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 -echo "$as_me: $ac_file is unchanged" >&6;} + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" + } >"$tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} else - ac_dir=`(dirname "$ac_file") 2>/dev/null || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - { if $as_mkdir_p; then - mkdir -p "$ac_dir" - else - as_dir="$ac_dir" - as_dirs= - while test ! -d "$as_dir"; do - as_dirs="$as_dir $as_dirs" - as_dir=`(dirname "$as_dir") 2>/dev/null || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - done - test ! -n "$as_dirs" || mkdir $as_dirs - fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 -echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} - { (exit 1); exit 1; }; }; } - - rm -f $ac_file - mv $tmp/config.h $ac_file + rm -f "$ac_file" + mv "$tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else - cat $tmp/config.h - rm -f $tmp/config.h + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 fi -done -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF - -# -# CONFIG_COMMANDS section. -# -for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue - ac_dest=`echo "$ac_file" | sed 's,:.*,,'` - ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_dir=`(dirname "$ac_dest") 2>/dev/null || -$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_dest" : 'X\(//\)[^/]' \| \ - X"$ac_dest" : 'X\(//\)$' \| \ - X"$ac_dest" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$ac_dest" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - { if $as_mkdir_p; then - mkdir -p "$ac_dir" - else - as_dir="$ac_dir" - as_dirs= - while test ! -d "$as_dir"; do - as_dirs="$as_dir $as_dirs" - as_dir=`(dirname "$as_dir") 2>/dev/null || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - done - test ! -n "$as_dirs" || mkdir $as_dirs - fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 -echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} - { (exit 1); exit 1; }; }; } - - ac_builddir=. - -if test "$ac_dir" != .; then - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi - -case $srcdir in - .) # No --srcdir option. We are building in place. - ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; -esac + ;; -# Do not use `cd foo && pwd` to compute absolute paths, because -# the directories may not exist. -case `pwd` in -.) ac_abs_builddir="$ac_dir";; -*) - case "$ac_dir" in - .) ac_abs_builddir=`pwd`;; - [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; - *) ac_abs_builddir=`pwd`/"$ac_dir";; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_builddir=${ac_top_builddir}.;; -*) - case ${ac_top_builddir}. in - .) ac_abs_top_builddir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; - *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_srcdir=$ac_srcdir;; -*) - case $ac_srcdir in - .) ac_abs_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; - *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_srcdir=$ac_top_srcdir;; -*) - case $ac_top_srcdir in - .) ac_abs_top_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; - *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; - esac;; -esac + :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 +$as_echo "$as_me: executing $ac_file commands" >&6;} + ;; + esac - { echo "$as_me:$LINENO: executing $ac_dest commands" >&5 -echo "$as_me: executing $ac_dest commands" >&6;} - case $ac_dest in - Jamfile ) if test ! -f "${ac_top_builddir}Jamfile"; then + case $ac_file$ac_mode in + "Jamfile":C) if test ! -f "${ac_top_builddir}Jamfile"; then : echo Installing Jamfile wrapper. echo "# This file was automatically create by config.status" > Jamfile echo "top_srcdir ?= $ac_top_srcdir ;" >> Jamfile echo "top_builddir ?= . ;" >> Jamfile echo "include \$(TOP)/Jamfile ;" >> Jamfile -fi - ;; +fi ;; + esac -done -_ACEOF +done # for ac_tag -cat >>$CONFIG_STATUS <<\_ACEOF -{ (exit 0); exit 0; } +as_fn_exit 0 _ACEOF -chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save +test $ac_write_fail = 0 || + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 + # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. @@ -6580,16 +6583,20 @@ exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. - $ac_cs_success || { (exit 1); exit 1; } + $ac_cs_success || as_fn_exit 1 +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi # a notice for the users -{ echo "$as_me:$LINENO: +{ $as_echo "$as_me:${as_lineno-$LINENO}: Please note that this project uses jam (and not make) as build tool. " >&5 -echo "$as_me: +$as_echo "$as_me: Please note that this project uses jam (and not make) as build tool. " >&6;} diff -Nru trigger-rally-0.5.2.1/configure.ac trigger-rally-0.6.0/configure.ac --- trigger-rally-0.5.2.1/configure.ac 2006-10-20 18:45:14.000000000 +0000 +++ trigger-rally-0.6.0/configure.ac 2011-10-07 17:10:49.000000000 +0000 @@ -4,7 +4,7 @@ #---------------------------------------------------------------------------- AC_PREREQ([2.54]) -AC_INIT([trigger], [0.5.2], [jaz@positro.net]) +AC_INIT([trigger], [0.6.0], [jas@jareiko.net]) AC_CONFIG_SRCDIR([src/trigger/main.cpp]) AC_CONFIG_AUX_DIR([mk/autoconf]) @@ -109,7 +109,7 @@ AX_FINDLIB([PHYSFS], [PhysFS], [PhysFS], AX_LANG_PROGRAM([#include ], [PHYSFS_init(0);]), - [], [-lphysfs -lz], + [], [-lphysfs], [], [AC_MSG_ERROR([Please install PhysFS])]) diff -Nru trigger-rally-0.5.2.1/debian/changelog trigger-rally-0.6.0/debian/changelog --- trigger-rally-0.5.2.1/debian/changelog 2010-04-10 10:30:59.000000000 +0000 +++ trigger-rally-0.6.0/debian/changelog 2011-11-25 21:08:18.000000000 +0000 @@ -1,3 +1,23 @@ +trigger-rally (0.6.0-1) unstable; urgency=low + + * New upstream release. + * debian/patches/05_Makefile.am.patch: dropped, included upstream. + * Refresh debian/patches/10_system_glew.patch. + * debian/control: + + drop transitional package. + + bump Standards-Version to 3.9.2, no changes needed apart + from dropping the transitional package. + + add libtinyxml-dev to build-depends. + + Update versioned depends against data files. + + Update long description. + * debian/trigger-rally.6.sgml: Fix grammar error in copyright description. + * debian/rules: + + add build-arch/build-indep target. + + remove shipped tinyxml files before configuring the package. + * debian/patches/20_system_tinyxml.patch: link against system tinyxml. + + -- Stefan Potyra Fri, 25 Nov 2011 22:08:15 +0100 + trigger-rally (0.5.2.1-2) unstable; urgency=low [ Gonéri Le Bouder ] diff -Nru trigger-rally-0.5.2.1/debian/control trigger-rally-0.6.0/debian/control --- trigger-rally-0.5.2.1/debian/control 2010-04-10 08:37:04.000000000 +0000 +++ trigger-rally-0.6.0/debian/control 2011-11-25 21:05:03.000000000 +0000 @@ -10,8 +10,9 @@ libsdl-image1.2-dev, docbook-to-man, automake (>= 1.9), - libglew1.5-dev -Standards-Version: 3.8.4 + libglew1.5-dev, + libtinyxml-dev +Standards-Version: 3.9.2 Uploaders: Stefan Potyra , Alexander Reichle-Schmehl , Barry deFreese @@ -22,19 +23,17 @@ Package: trigger-rally Architecture: any -Depends: ${shlibs:Depends}, trigger-rally-data (>= 0.5.2-2), ${misc:Depends} +Depends: ${shlibs:Depends}, trigger-rally-data (>= 0.6.0-1), ${misc:Depends} Conflicts: trigger (<< 0.5.2.1) Description: free 3D rally racing car game - Trigger is a free 3D rally car racing game. Fun for all the family! - You race a sequence of 6 courses, with increasing levels of difficulty. + Trigger is a free 3D rally car racing game. Fun for all the family! + . + Trigger comes with a number of challenges where you have to race several + tracks to finish each challenge. + . + When racing a track, you have to reach several locations marked by pulsating + rings in sequence. You win a race if you reach the last location in time. . Trigger is highly customisable, and it's easy to add new levels and vehicles. . System Requirements consist of an OpenGL accelerated video card. - -Package: trigger -Architecture: all -Depends: trigger-rally, ${misc:Depends} -Description: transitional dummy package for trigger - This is a transitional dummy package for trigger-rally, it can be safely - removed. diff -Nru trigger-rally-0.5.2.1/debian/patches/05_Makefile.am.patch trigger-rally-0.6.0/debian/patches/05_Makefile.am.patch --- trigger-rally-0.5.2.1/debian/patches/05_Makefile.am.patch 2010-04-10 09:21:33.000000000 +0000 +++ trigger-rally-0.6.0/debian/patches/05_Makefile.am.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -Description: trigger-rally doesn't directly use any of the zlib symbols, - don't link against libz hence. -Origin: http://trigger-rally.svn.sourceforge.net/viewvc/trigger-rally/configure.ac?r1=1&r2=3 -diff -Nur trigger-0.5.2/configure.ac trigger-0.5.2.new/configure.ac ---- trigger-0.5.2/configure.ac 2006-01-14 11:09:19.000000000 +0100 -+++ trigger-0.5.2.new/configure.ac 2006-09-25 23:06:12.000000000 +0200 -@@ -109,7 +109,7 @@ - - AX_FINDLIB([PHYSFS], [PhysFS], [PhysFS], - AX_LANG_PROGRAM([#include ], [PHYSFS_init(0);]), -- [], [-lphysfs -lz], -+ [], [-lphysfs], - [], - [AC_MSG_ERROR([Please install PhysFS])]) - diff -Nru trigger-rally-0.5.2.1/debian/patches/10_system_glew.patch trigger-rally-0.6.0/debian/patches/10_system_glew.patch --- trigger-rally-0.5.2.1/debian/patches/10_system_glew.patch 2010-04-10 09:21:33.000000000 +0000 +++ trigger-rally-0.6.0/debian/patches/10_system_glew.patch 2011-11-25 19:45:10.000000000 +0000 @@ -3,10 +3,10 @@ . It's not clean enough yet to be committed upstream, I'll work on this. Author: Stefan Potyra -Index: trigger-rally-0.5.2.1/autogen.sh +Index: trigger-rally-0.6.0/autogen.sh =================================================================== ---- trigger-rally-0.5.2.1.orig/autogen.sh 2010-03-28 15:52:27.155526849 +0200 -+++ trigger-rally-0.5.2.1/autogen.sh 2010-03-28 15:49:28.356327937 +0200 +--- trigger-rally-0.6.0.orig/autogen.sh 2011-10-07 19:10:49.000000000 +0200 ++++ trigger-rally-0.6.0/autogen.sh 2011-11-11 22:26:28.891511342 +0100 @@ -18,6 +18,7 @@ # seems autoconf --trace misses some things :-/ echo 'INSTALL ?= "@INSTALL@" ;' >> Jamconfig.in @@ -15,10 +15,10 @@ # autoheader/config.h not used by trigger yet autoheader -Index: trigger-rally-0.5.2.1/configure.ac +Index: trigger-rally-0.6.0/configure.ac =================================================================== ---- trigger-rally-0.5.2.1.orig/configure.ac 2010-03-28 15:52:26.705514097 +0200 -+++ trigger-rally-0.5.2.1/configure.ac 2010-03-28 15:49:08.525590227 +0200 +--- trigger-rally-0.6.0.orig/configure.ac 2011-10-07 19:10:49.000000000 +0200 ++++ trigger-rally-0.6.0/configure.ac 2011-11-11 22:26:28.891511342 +0100 @@ -123,6 +123,12 @@ AC_MSG_ERROR([Couldn't find GLU library and headers]) fi @@ -32,10 +32,10 @@ # Um, can't get this to substitute [app]datadir :/ #AC_DEFINE([DATADIR], [$(datadir)], [comment]) -Index: trigger-rally-0.5.2.1/src/Jamfile +Index: trigger-rally-0.6.0/src/Jamfile =================================================================== ---- trigger-rally-0.5.2.1.orig/src/Jamfile 2010-03-28 15:52:26.975526812 +0200 -+++ trigger-rally-0.5.2.1/src/Jamfile 2010-03-28 15:50:28.346233037 +0200 +--- trigger-rally-0.6.0.orig/src/Jamfile 2011-10-07 19:10:02.000000000 +0200 ++++ trigger-rally-0.6.0/src/Jamfile 2011-11-11 22:26:28.891511342 +0100 @@ -7,7 +7,10 @@ C++FLAGS += -DDATADIR='\"$(datadir)\"' ; @@ -48,10 +48,10 @@ SubInclude TOP src pengine ; SubInclude TOP src psim ; SubInclude TOP src trigger ; -Index: trigger-rally-0.5.2.1/src/pengine/Jamfile +Index: trigger-rally-0.6.0/src/pengine/Jamfile =================================================================== ---- trigger-rally-0.5.2.1.orig/src/pengine/Jamfile 2010-03-28 15:52:26.805523301 +0200 -+++ trigger-rally-0.5.2.1/src/pengine/Jamfile 2010-03-28 15:52:19.539998764 +0200 +--- trigger-rally-0.6.0.orig/src/pengine/Jamfile 2011-10-07 19:10:01.000000000 +0200 ++++ trigger-rally-0.6.0/src/pengine/Jamfile 2011-11-11 22:26:28.895511341 +0100 @@ -4,6 +4,8 @@ Library pengine : [ Wildcard *.c *.cpp *.h ] [ Wildcard GL : *.h ] ; @@ -63,23 +63,21 @@ + LinkWith pengine : glew ; + IncludeDir pengine : ../glew ; +} -Index: trigger-rally-0.5.2.1/src/pengine/pengine.h +Index: trigger-rally-0.6.0/src/pengine/pengine.h =================================================================== ---- trigger-rally-0.5.2.1.orig/src/pengine/pengine.h 2010-03-28 15:52:26.875527960 +0200 -+++ trigger-rally-0.5.2.1/src/pengine/pengine.h 2010-03-28 15:51:25.717564253 +0200 -@@ -30,11 +30,12 @@ - // The PhysicsFS game file system - #include - -- --// This is a slightly modified GLEW for internal build -+#ifdef HAVE_GLEW_H -+#include -+#else /* use statically shipped version */ - #define GLEW_STATIC - #include "GL/glew.h" -- -+#endif - - // TinyXML is built into the pengine library - #include "tinyxml.h" +--- trigger-rally-0.6.0.orig/src/pengine/pengine.h 2011-10-07 19:10:01.000000000 +0200 ++++ trigger-rally-0.6.0/src/pengine/pengine.h 2011-11-11 22:28:38.447505433 +0100 +@@ -31,9 +31,13 @@ + #include + + ++#ifdef HAVE_GLEW_H ++#include ++#else /* use statically shipped version */ + // This is a slightly modified GLEW for internal build + #define GLEW_STATIC + #include "GL/glew.h" ++#endif /* HAVE_GLEW_H */ + + + // TinyXML is built into the pengine library diff -Nru trigger-rally-0.5.2.1/debian/patches/20_system_tinyxml.patch trigger-rally-0.6.0/debian/patches/20_system_tinyxml.patch --- trigger-rally-0.5.2.1/debian/patches/20_system_tinyxml.patch 1970-01-01 00:00:00.000000000 +0000 +++ trigger-rally-0.6.0/debian/patches/20_system_tinyxml.patch 2011-11-25 19:45:10.000000000 +0000 @@ -0,0 +1,20 @@ +Description: trigger-rally ships an internal copy of tinyxml + This patch enables trigger to use the system tinxml library. + . + It's not clean enough yet to be committed upstream. + Author: Stefan Potyra + +Index: trigger-rally-0.6.0/configure.ac +=================================================================== +--- trigger-rally-0.6.0.orig/configure.ac 2011-11-18 22:54:53.000000000 +0100 ++++ trigger-rally-0.6.0/configure.ac 2011-11-18 23:10:10.963885333 +0100 +@@ -129,6 +129,9 @@ + AC_SUBST([HAVE_GLEW]) + AC_SEARCH_LIBS([__glewActiveTextureARB], [GLEW]) + ++# link against system tinyxml (if toElement() is available) ++AC_SEARCH_LIBS([_ZN12TiXmlElement9ToElementEv], [tinyxml]) ++ + # Um, can't get this to substitute [app]datadir :/ + #AC_DEFINE([DATADIR], [$(datadir)], [comment]) + diff -Nru trigger-rally-0.5.2.1/debian/patches/series trigger-rally-0.6.0/debian/patches/series --- trigger-rally-0.5.2.1/debian/patches/series 2010-03-28 14:13:49.000000000 +0000 +++ trigger-rally-0.6.0/debian/patches/series 2011-11-25 19:45:10.000000000 +0000 @@ -1,2 +1,2 @@ -05_Makefile.am.patch 10_system_glew.patch +20_system_tinyxml.patch diff -Nru trigger-rally-0.5.2.1/debian/rules trigger-rally-0.6.0/debian/rules --- trigger-rally-0.5.2.1/debian/rules 2010-04-10 10:21:01.000000000 +0000 +++ trigger-rally-0.6.0/debian/rules 2011-11-25 19:45:10.000000000 +0000 @@ -31,6 +31,13 @@ configure: configure.ac # make sure that the shipped glew is not used during build $(RM) -r src/glew + # same goes for tinyxml + $(RM) src/pengine/tinyxml.h + $(RM) src/pengine/tinyxmlparser.cpp + $(RM) src/pengine/tinyxml.cpp + $(RM) src/pengine/tinystr.cpp + $(RM) src/pengine/tinyxmlerror.cpp + $(RM) src/pengine/tinystr.h ./autogen.sh config.status: configure @@ -44,7 +51,7 @@ --datadir=$(DATADIR) -build: build-stamp +build: build-arch build-indep build-stamp: config.status dh_testdir @@ -93,5 +100,9 @@ dh_md5sums dh_builddeb +build-arch: build-stamp +build-indep: build-stamp + binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install +.PHONY: build clean binary-indep binary-arch binary install build-arch \ + build-indep diff -Nru trigger-rally-0.5.2.1/debian/trigger-rally.6.sgml trigger-rally-0.6.0/debian/trigger-rally.6.sgml --- trigger-rally-0.5.2.1/debian/trigger-rally.6.sgml 2007-06-22 16:17:46.000000000 +0000 +++ trigger-rally-0.6.0/debian/trigger-rally.6.sgml 2011-11-25 19:45:10.000000000 +0000 @@ -77,8 +77,8 @@ This manual page was written by &dhusername; &dhemail; for the &debian; system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under - the terms of the &gnu; General Public License, Version 2 any - later version published by the Free Software Foundation. + the terms of the &gnu; General Public License, Version 2 or any + later version as published by the Free Software Foundation. On Debian systems, the complete text of the GNU General Public diff -Nru trigger-rally-0.5.2.1/doc/README.txt trigger-rally-0.6.0/doc/README.txt --- trigger-rally-0.5.2.1/doc/README.txt 2006-10-20 21:25:56.000000000 +0000 +++ trigger-rally-0.6.0/doc/README.txt 2011-10-07 17:10:00.000000000 +0000 @@ -1,14 +1,14 @@ /////////////////////////// -// Trigger v0.5.x README // +// Trigger v0.6.x README // /////////////////////////// Thanks for downloading Trigger! I hope you enjoy the game. For updates, please visit: - http://www.positro.net/trigger/ + http://trigger-rally.sourceforge.net/ Before playing, building, or copying, please read @@ -90,17 +90,61 @@ (http://www.fmod.org/) (i386-mingw32msvc is the only tested build) -To build trigger: +To build trigger open a terminal and, in the top level of +the trigger source directory, do: ./configure jam -You'll probably want to check ./configure --help for -available options, although the defaults are usually -fine. Those interested in packaging trigger will want -to specify --datadir=... +Thanks to Matze Braun for this excellent build system. -Thanks to Matze Braun for this excellent new build system. +To run trigger without installing, copy the trigger +executable to the data sub-directory and run it from +there. That is: + +cp ./trigger data +./data/trigger + +If you are hacking on trigger and rebuilding often, you may +find it convenient to specify the --datadir option to +configure, then you will not need to copy the executable +after each build. The --datadir option expects a full path. + +./configure --datadir=/home/$USER/projects/trigger-rally/data +jam +./trigger + +Adjust the path to suit your system. Every time the options +to configure are changed run: + +jam clean + +before running 'jam' again. This ensures that trigger uses +the new configure settings. + + +////////////////// +// Installation // +////////////////// + + +If you wish to install trigger you'll need to specify the +--prefix and --datadir options to configure. The prefix +directory controls where trigger will be installed. + +Here is a full example, adjust the paths to suit: + +./configure --prefix=/home/$USER/local/trigger-rally \ + --datadir=/home/$USER/local/trigger-rally/data +jam +jam install +rsync -av --exclude='.svn' data/ /home/$USER/local/trigger-rally/data + +Now you can run trigger, for example: + +./local/trigger-rally/bin/trigger + +will start trigger. ///////////////////// @@ -108,25 +152,34 @@ ///////////////////// -If something goes wrong, the first thing to check is -your settings in data/trigger.conf. - -Failing that, check back to the game website to see -if the bug has been discovered (I may have posted a -workaround.) - -If it still doesn't work, please send me an email at: +If something goes wrong, the you should check +your settings in ~/.trigger/trigger.config. You can +delete that file to reset everything to default. (It +will be recreated next time you run Trigger.) -jaz@positro.net +Failing that, please visit Sourceforge to ask for help +on the forums or file a bug on the tracker: -and I'll get back to you as soon as I can. I can't -promise to be able to fix the bug however :| +http://sourceforge.net/projects/trigger-rally/support ///////////////////// // Version history // ///////////////////// +08/10/2011 - Trigger 0.6.0 + - New (and old) contributed tracks and events + - New Practice Mode + - Paging on the Single Races screen to show all the available tracks + - Option to show speedometer in KPH or MPH + - Option to show digital speed on the speed dial ('hybrid' style) + - Fading track comment and GO at race start + - Freezing course time when passing through a checkpoint + - Tweak menu colours for more contrast + +4/07/2010 - Trigger 0.5.3 + - Removed splash screen delay + - Updated contact email address 20/10/2006 - Trigger 0.5.2.1 - gcc 4 fixes @@ -144,7 +197,7 @@ - Switch to ARB multitex from core GL to support older cards - Added some code to take screenshots -05/10/2004 - Trigger 0.4.5 (bumped up to 0.5.0) +05/10/2004 - Trigger 0.5.0 (was 0.4.5) - Chuck Sites has contributed a stereo patch, so now we have quadbuffer and anaglyph stereo! @@ -196,8 +249,8 @@ ///////////// -Code Jasmine Langridge -Art & sfx Richard Langridge +Code Jasmine Langridge +Art & sfx Richard Langridge Build system and Jamrules Matze Braun @@ -207,6 +260,8 @@ Fixes & distro LavaPunk support Bernhard Kaindl Stefan Potyra + Liviu Andronic + Ishmael Turner New levels Tim Wintle David Pagnier Jared Buckner @@ -214,6 +269,10 @@ Ivan Viktor Radnai Pierre-Alexis + Bruno "Fuddl" Kleinert + Agnius Vasiliauskas + Matthias Keysermann + Márcio Bremm Splash screens Alex Roberto D�z Gonz�ez @@ -226,5 +285,5 @@ I haven't been keeping strict records of who has contributed what. If you've been left out, or if you'd like your email to be listed, please email -me. (jaz@positro.net) +me. (ja-reiko@users.sourceforge.net) diff -Nru trigger-rally-0.5.2.1/Jamconfig.in trigger-rally-0.6.0/Jamconfig.in --- trigger-rally-0.5.2.1/Jamconfig.in 2006-10-20 19:22:25.000000000 +0000 +++ trigger-rally-0.6.0/Jamconfig.in 2011-10-07 17:10:49.000000000 +0000 @@ -5,29 +5,37 @@ PACKAGE_VERSION ?= "@PACKAGE_VERSION@" ; PACKAGE_STRING ?= "@PACKAGE_STRING@" ; PACKAGE_BUGREPORT ?= "@PACKAGE_BUGREPORT@" ; +PACKAGE_URL ?= "@PACKAGE_URL@" ; exec_prefix ?= "@exec_prefix@" ; prefix ?= "@prefix@" ; program_transform_name ?= "@program_transform_name@" ; bindir ?= "@bindir@" ; sbindir ?= "@sbindir@" ; libexecdir ?= "@libexecdir@" ; +datarootdir ?= "@datarootdir@" ; datadir ?= "@datadir@" ; sysconfdir ?= "@sysconfdir@" ; sharedstatedir ?= "@sharedstatedir@" ; localstatedir ?= "@localstatedir@" ; -libdir ?= "@libdir@" ; includedir ?= "@includedir@" ; oldincludedir ?= "@oldincludedir@" ; +docdir ?= "@docdir@" ; infodir ?= "@infodir@" ; +htmldir ?= "@htmldir@" ; +dvidir ?= "@dvidir@" ; +pdfdir ?= "@pdfdir@" ; +psdir ?= "@psdir@" ; +libdir ?= "@libdir@" ; +localedir ?= "@localedir@" ; mandir ?= "@mandir@" ; -build_alias ?= "@build_alias@" ; -host_alias ?= "@host_alias@" ; -target_alias ?= "@target_alias@" ; DEFS ?= "@DEFS@" ; ECHO_C ?= "@ECHO_C@" ; ECHO_N ?= "@ECHO_N@" ; ECHO_T ?= "@ECHO_T@" ; LIBS ?= "@LIBS@" ; +build_alias ?= "@build_alias@" ; +host_alias ?= "@host_alias@" ; +target_alias ?= "@target_alias@" ; build ?= "@build@" ; build_cpu ?= "@build_cpu@" ; build_vendor ?= "@build_vendor@" ; @@ -44,6 +52,7 @@ CXX ?= "@CXX@" ; CXXFLAGS ?= "@CXXFLAGS@" ; LDFLAGS ?= "@LDFLAGS@" ; +LIBS ?= "@LIBS@" ; CPPFLAGS ?= "@CPPFLAGS@" ; CXX ?= "@CXX@" ; ac_ct_CXX ?= "@ac_ct_CXX@" ; @@ -56,11 +65,10 @@ CC ?= "@CC@" ; CFLAGS ?= "@CFLAGS@" ; LDFLAGS ?= "@LDFLAGS@" ; +LIBS ?= "@LIBS@" ; CPPFLAGS ?= "@CPPFLAGS@" ; CC ?= "@CC@" ; -ac_ct_CC ?= "@ac_ct_CC@" ; CC ?= "@CC@" ; -ac_ct_CC ?= "@ac_ct_CC@" ; CC ?= "@CC@" ; CC ?= "@CC@" ; ac_ct_CC ?= "@ac_ct_CC@" ; @@ -78,6 +86,7 @@ PHYSFS_AVAILABLE ?= "@PHYSFS_AVAILABLE@" ; PHYSFS_CFLAGS ?= "@PHYSFS_CFLAGS@" ; PHYSFS_LIBS ?= "@PHYSFS_LIBS@" ; +XMKMF ?= "@XMKMF@" ; CPP ?= "@CPP@" ; CPPFLAGS ?= "@CPPFLAGS@" ; CPP ?= "@CPP@" ; @@ -86,6 +95,7 @@ PTHREAD_LIBS ?= "@PTHREAD_LIBS@" ; PTHREAD_CFLAGS ?= "@PTHREAD_CFLAGS@" ; PTHREAD_CC ?= "@PTHREAD_CC@" ; +GREP ?= "@GREP@" ; EGREP ?= "@EGREP@" ; GL_CFLAGS ?= "@GL_CFLAGS@" ; GL_LIBS ?= "@GL_LIBS@" ; diff -Nru trigger-rally-0.5.2.1/src/glew/glew.cpp trigger-rally-0.6.0/src/glew/glew.cpp --- trigger-rally-0.5.2.1/src/glew/glew.cpp 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/glew/glew.cpp 2011-10-07 17:10:02.000000000 +0000 @@ -172,12 +172,12 @@ { GLuint i=0; while (i < nb && (*a)+i != NULL && b+i != NULL && (*a)[i] == b[i]) i++; - if(i == nb) - { - *a = *a + nb; - *na = *na - nb; - return GL_TRUE; - } + if(i == nb) + { + *a = *a + nb; + *na = *na - nb; + return GL_TRUE; + } } return GL_FALSE; } @@ -188,12 +188,12 @@ { GLuint i=0; while (i < nb && (*a)+i != NULL && b+i != NULL && (*a)[i] == b[i]) i++; - if(i == nb) - { - *a = *a + nb; - *na = *na - nb; - return GL_TRUE; - } + if(i == nb) + { + *a = *a + nb; + *na = *na - nb; + return GL_TRUE; + } } return GL_FALSE; } @@ -4732,67 +4732,67 @@ return GLEW_ERROR_NO_GL_VERSION; if (s[major] == '1' && s[minor] == '0') { - return GLEW_ERROR_GL_VERSION_10_ONLY; + return GLEW_ERROR_GL_VERSION_10_ONLY; } else { - if (s[major] >= '2') - { - GLEW_VERSION_1_1 = GL_TRUE; - GLEW_VERSION_1_2 = GL_TRUE; + if (s[major] >= '2') + { + GLEW_VERSION_1_1 = GL_TRUE; + GLEW_VERSION_1_2 = GL_TRUE; GLEW_VERSION_1_3 = GL_TRUE; GLEW_VERSION_1_4 = GL_TRUE; - GLEW_VERSION_1_5 = GL_TRUE; - GLEW_VERSION_2_0 = GL_TRUE; - } - else - { - if (s[minor] >= '5') - { - GLEW_VERSION_1_1 = GL_TRUE; - GLEW_VERSION_1_2 = GL_TRUE; - GLEW_VERSION_1_3 = GL_TRUE; - GLEW_VERSION_1_4 = GL_TRUE; - GLEW_VERSION_1_5 = GL_TRUE; - GLEW_VERSION_2_0 = GL_FALSE; - } - if (s[minor] == '4') - { - GLEW_VERSION_1_1 = GL_TRUE; - GLEW_VERSION_1_2 = GL_TRUE; - GLEW_VERSION_1_3 = GL_TRUE; - GLEW_VERSION_1_4 = GL_TRUE; - GLEW_VERSION_1_5 = GL_FALSE; - GLEW_VERSION_2_0 = GL_FALSE; - } - if (s[minor] == '3') - { - GLEW_VERSION_1_1 = GL_TRUE; - GLEW_VERSION_1_2 = GL_TRUE; - GLEW_VERSION_1_3 = GL_TRUE; - GLEW_VERSION_1_4 = GL_FALSE; - GLEW_VERSION_1_5 = GL_FALSE; - GLEW_VERSION_2_0 = GL_FALSE; - } - if (s[minor] == '2') - { - GLEW_VERSION_1_1 = GL_TRUE; - GLEW_VERSION_1_2 = GL_TRUE; - GLEW_VERSION_1_3 = GL_FALSE; - GLEW_VERSION_1_4 = GL_FALSE; - GLEW_VERSION_1_5 = GL_FALSE; - GLEW_VERSION_2_0 = GL_FALSE; - } - if (s[minor] < '2') - { - GLEW_VERSION_1_1 = GL_TRUE; - GLEW_VERSION_1_2 = GL_FALSE; - GLEW_VERSION_1_3 = GL_FALSE; - GLEW_VERSION_1_4 = GL_FALSE; - GLEW_VERSION_1_5 = GL_FALSE; - GLEW_VERSION_2_0 = GL_FALSE; - } - } + GLEW_VERSION_1_5 = GL_TRUE; + GLEW_VERSION_2_0 = GL_TRUE; + } + else + { + if (s[minor] >= '5') + { + GLEW_VERSION_1_1 = GL_TRUE; + GLEW_VERSION_1_2 = GL_TRUE; + GLEW_VERSION_1_3 = GL_TRUE; + GLEW_VERSION_1_4 = GL_TRUE; + GLEW_VERSION_1_5 = GL_TRUE; + GLEW_VERSION_2_0 = GL_FALSE; + } + if (s[minor] == '4') + { + GLEW_VERSION_1_1 = GL_TRUE; + GLEW_VERSION_1_2 = GL_TRUE; + GLEW_VERSION_1_3 = GL_TRUE; + GLEW_VERSION_1_4 = GL_TRUE; + GLEW_VERSION_1_5 = GL_FALSE; + GLEW_VERSION_2_0 = GL_FALSE; + } + if (s[minor] == '3') + { + GLEW_VERSION_1_1 = GL_TRUE; + GLEW_VERSION_1_2 = GL_TRUE; + GLEW_VERSION_1_3 = GL_TRUE; + GLEW_VERSION_1_4 = GL_FALSE; + GLEW_VERSION_1_5 = GL_FALSE; + GLEW_VERSION_2_0 = GL_FALSE; + } + if (s[minor] == '2') + { + GLEW_VERSION_1_1 = GL_TRUE; + GLEW_VERSION_1_2 = GL_TRUE; + GLEW_VERSION_1_3 = GL_FALSE; + GLEW_VERSION_1_4 = GL_FALSE; + GLEW_VERSION_1_5 = GL_FALSE; + GLEW_VERSION_2_0 = GL_FALSE; + } + if (s[minor] < '2') + { + GLEW_VERSION_1_1 = GL_TRUE; + GLEW_VERSION_1_2 = GL_FALSE; + GLEW_VERSION_1_3 = GL_FALSE; + GLEW_VERSION_1_4 = GL_FALSE; + GLEW_VERSION_1_5 = GL_FALSE; + GLEW_VERSION_2_0 = GL_FALSE; + } + } } /* initialize extensions */ #ifdef GL_VERSION_1_2 @@ -6871,7 +6871,7 @@ GLuint len = _glewStrLen((const GLubyte*)name); /* if (glXQueryExtensionsString == NULL || glXGetCurrentDisplay == NULL) return GL_FALSE; */ /* p = (GLubyte*)glXQueryExtensionsString(glXGetCurrentDisplay(), DefaultScreen(glXGetCurrentDisplay())); */ - if (glXGetClientString == NULL || glXGetCurrentDisplay == NULL) return GL_FALSE; + if (/*glXGetClientString == NULL || */glXGetCurrentDisplay == NULL) return GL_FALSE; p = (GLubyte*)glXGetClientString(glXGetCurrentDisplay(), GLX_EXTENSIONS); if (0 == p) return GL_FALSE; end = p + _glewStrLen(p); diff -Nru trigger-rally-0.5.2.1/src/pengine/app.cpp trigger-rally-0.6.0/src/pengine/app.cpp --- trigger-rally-0.5.2.1/src/pengine/app.cpp 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/pengine/app.cpp 2011-10-07 17:10:01.000000000 +0000 @@ -1,7 +1,7 @@ // app.cpp [pengine] -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net // License: GPL version 2 (see included gpl.txt) @@ -40,31 +40,31 @@ void PApp::setScreenModeAutoWindow() { #ifdef WIN32 - cy = GetSystemMetrics(SM_CYSCREEN) * 6 / 7; - cx = cy * 4 / 3; + cy = GetSystemMetrics(SM_CYSCREEN) * 6 / 7; + cx = cy * 4 / 3; #else - //#error COMPLETE FOR PLATFORM - cy = 1024 * 6 / 7; - cx = cy * 4 / 3; + //#error COMPLETE FOR PLATFORM + cy = 1024 * 6 / 7; + cx = cy * 4 / 3; #endif - fullscr = false; + fullscr = false; } void PApp::setScreenModeFastFullScreen() { #ifdef WIN32 - cx = GetSystemMetrics(SM_CXSCREEN); - cy = GetSystemMetrics(SM_CYSCREEN); + cx = GetSystemMetrics(SM_CXSCREEN); + cy = GetSystemMetrics(SM_CYSCREEN); #else - //#error COMPLETE FOR PLATFORM - cx = 1280; - cy = 1024; + //#error COMPLETE FOR PLATFORM + cx = 1280; + cy = 1024; #endif - fullscr = false; + fullscr = false; - noframe = true; + noframe = true; } /* This routine performs the perspective projection for one eye's subfield. @@ -86,672 +86,672 @@ */ void PApp::stereoGLProject(float xmin, float xmax, float ymin, float ymax, float znear, float zfar, float zzps, float dist, float eye) { - float xmid, ymid, clip_near, clip_far, top, bottom, left, right, dx, dy, n_over_d; + float xmid, ymid, clip_near, clip_far, top, bottom, left, right, dx, dy, n_over_d; - dx = xmax - xmin; - dy = ymax - ymin; + dx = xmax - xmin; + dy = ymax - ymin; - xmid = (xmax + xmin) / 2.0; - ymid = (ymax + ymin) / 2.0; + xmid = (xmax + xmin) / 2.0; + ymid = (ymax + ymin) / 2.0; - clip_near = dist + zzps - znear; - clip_far = dist + zzps - zfar; + clip_near = dist + zzps - znear; + clip_far = dist + zzps - zfar; - n_over_d = clip_near / dist; + n_over_d = clip_near / dist; - top = n_over_d * dy / 2.0; - bottom = -top; - right = n_over_d * (dx / 2.0 - eye); - left = n_over_d * (-dx / 2.0 - eye); + top = n_over_d * dy / 2.0; + bottom = -top; + right = n_over_d * (dx / 2.0 - eye); + left = n_over_d * (-dx / 2.0 - eye); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glFrustum(left, right, bottom, top, clip_near, clip_far); - glTranslatef(-xmid - eye, -ymid, -zzps - dist); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(left, right, bottom, top, clip_near, clip_far); + glTranslatef(-xmid - eye, -ymid, -zzps - dist); } // I'm afraid I didn't understand how stereoGLProject worked, so I rewrote it void PApp::stereoFrustum(float xmin, float xmax, float ymin, float ymax, float znear, float zfar, float zzps, float eye) { - // xmove = eye * (zzps - znear) / zzps - eye, simplifies to - - float xmove = -eye * znear / zzps; - - glFrustum(xmin + xmove, xmax + xmove, ymin, ymax, znear, zfar); + // xmove = eye * (zzps - znear) / zzps - eye, simplifies to + + float xmove = -eye * znear / zzps; + + glFrustum(xmin + xmove, xmax + xmove, ymin, ymax, znear, zfar); } int PApp::run(int argc, char *argv[]) { - outLog() << apptitle << " init" << std::endl; - - outLog() << "Build: " << PACKAGE_VERSION << " on " << __DATE__ << " at " << __TIME__ << std::endl; - - if (exit_requested) { - outLog() << "Exit requested" << std::endl; - return 0; - } - - outLog() << "Initialising PhysFS" << std::endl; - - if (PHYSFS_init((argc >= 1) ? argv[0] : null) == 0) { - outLog() << "PhysFS failed to initialise" << std::endl; - outLog() << "PhysFS: " << PHYSFS_getLastError() << std::endl; - return 1; - } - - PHYSFS_permitSymbolicLinks(1); - - { - std::string lsdbuff; - - lsdbuff = (std::string)PHYSFS_getUserDir(); - - // this is a hack because PhysFS doesn't appear to live - // up to its claim of creating the WriteDir if necessary. - // set write dir to home, create ~/.whatever, then change - // over to that dir. - + outLog() << apptitle << " init" << std::endl; + + outLog() << "Build: " << PACKAGE_VERSION << " on " << __DATE__ << " at " << __TIME__ << std::endl; + + if (exit_requested) { + outLog() << "Exit requested" << std::endl; + return 0; + } + + outLog() << "Initialising PhysFS" << std::endl; + + if (PHYSFS_init((argc >= 1) ? argv[0] : null) == 0) { + outLog() << "PhysFS failed to initialise" << std::endl; + outLog() << "PhysFS: " << PHYSFS_getLastError() << std::endl; + return 1; + } + + PHYSFS_permitSymbolicLinks(1); + + { + std::string lsdbuff; + + lsdbuff = (std::string)PHYSFS_getUserDir(); + + // this is a hack because PhysFS doesn't appear to live + // up to its claim of creating the WriteDir if necessary. + // set write dir to home, create ~/.whatever, then change + // over to that dir. + #if 1 - outLog() << "Set writable user directory to \"" << lsdbuff << "\"" << std::endl; - - if (PHYSFS_setWriteDir(lsdbuff.c_str()) == 0) { - outLog() << "Failed to set PhysFS writable directory to \"" << lsdbuff << "\"" << std::endl - << "PhysFS: " << PHYSFS_getLastError() << std::endl; - } - - if (PHYSFS_mkdir(appname.c_str()) == 0) { - outLog() << "Failed to create directory \"" << appname << "\"" << std::endl - << "PhysFS: " << PHYSFS_getLastError() << std::endl; - } + outLog() << "Set writable user directory to \"" << lsdbuff << "\"" << std::endl; + + if (PHYSFS_setWriteDir(lsdbuff.c_str()) == 0) { + outLog() << "Failed to set PhysFS writable directory to \"" << lsdbuff << "\"" << std::endl + << "PhysFS: " << PHYSFS_getLastError() << std::endl; + } + + if (PHYSFS_mkdir(appname.c_str()) == 0) { + outLog() << "Failed to create directory \"" << appname << "\"" << std::endl + << "PhysFS: " << PHYSFS_getLastError() << std::endl; + } #endif - - lsdbuff += appname; - - outLog() << "Reset writable user directory to \"" << lsdbuff << "\"" << std::endl; - - if (PHYSFS_setWriteDir(lsdbuff.c_str()) == 0) { - outLog() << "Failed to set PhysFS writable directory to \"" << lsdbuff << "\"" << std::endl - << "PhysFS: " << PHYSFS_getLastError() << std::endl; - } - - // Adding "." to the search path seems to add more trouble than it's worth + + lsdbuff += appname; + + outLog() << "Reset writable user directory to \"" << lsdbuff << "\"" << std::endl; + + if (PHYSFS_setWriteDir(lsdbuff.c_str()) == 0) { + outLog() << "Failed to set PhysFS writable directory to \"" << lsdbuff << "\"" << std::endl + << "PhysFS: " << PHYSFS_getLastError() << std::endl; + } + + // Adding "." to the search path seems to add more trouble than it's worth #if 0 - if (PHYSFS_addToSearchPath(".", 1) == 0) { - outLog() << "Failed to add PhysFS search directory \".\"" << std::endl - << "PhysFS: " << PHYSFS_getLastError() << std::endl; - } + if (PHYSFS_addToSearchPath(".", 1) == 0) { + outLog() << "Failed to add PhysFS search directory \".\"" << std::endl + << "PhysFS: " << PHYSFS_getLastError() << std::endl; + } #endif - - std::string basedir = PHYSFS_getBaseDir(); - PUtil::outLog() << "Application base directory \"" << basedir << '\"' << std::endl; - if (PHYSFS_addToSearchPath(basedir.c_str(), 1) == 0) { - outLog() << "Failed to add PhysFS search directory \"" << basedir << "\"" << std::endl - << "PhysFS: " << PHYSFS_getLastError() << std::endl; - } - - if (PHYSFS_addToSearchPath(lsdbuff.c_str(), 1) == 0) { - outLog() << "Failed to add PhysFS search directory \"" << lsdbuff << "\"" << std::endl - << "PhysFS: " << PHYSFS_getLastError() << std::endl; - } - - std::string ddbuff = DATADIR; - - outLog() << "Main game data directory datadir=\"" << ddbuff << "\"" << std::endl; - - if (PHYSFS_addToSearchPath(ddbuff.c_str(), 1) == 0) { - outLog() << "Failed to add PhysFS search directory \"" << ddbuff << "\"" << std::endl - << "PhysFS: " << PHYSFS_getLastError() << std::endl; - } - - // Find any .zip files and add them to search path - std::list zipfiles = PUtil::findFiles("", ".zip"); - - for (std::list::iterator i = zipfiles.begin(); - i != zipfiles.end(); i++) { - - const char *realpath = PHYSFS_getRealDir(i->c_str()); - - if (realpath) { - std::string fullpath = (std::string)realpath + *i; - - if (PHYSFS_addToSearchPath(fullpath.c_str(), 1) == 0) { - outLog() << "Failed to add archive \"" << fullpath << "\"" << std::endl - << "PhysFS: " << PHYSFS_getLastError() << std::endl; - } - } else { - outLog() << "Failed to find path of archive \"" << *i << "\"" << std::endl - << "PhysFS: " << PHYSFS_getLastError() << std::endl; - } - } - } - - try - { - config (); - } - catch (PException e) - { - PUtil::outLog() << "Config failed: " << e.what () << std::endl; - - if (PHYSFS_deinit() == 0) { - outLog() << "PhysFS: " << PHYSFS_getLastError() << std::endl; - } - return 1; - } - - outLog() << "Initialising SDL" << std::endl; - - SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE); - //SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK); - - srand(SDL_GetTicks()); - - SDL_WM_SetCaption(apptitle.c_str(), null); - - outLog() << "Create window and set video mode" << std::endl; - - SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); - - if (reqRGB) { - SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 ); - SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 ); - SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 ); - } - - if (reqAlpha) { - SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 ); - } - - if (reqDepth) { - SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 ); - } - - if (reqStencil) - SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 ); - - if (stereo == StereoQuadBuffer) { - SDL_GL_SetAttribute( SDL_GL_STEREO, 1 ); - } - - if (cx <= 0 || cy <= 0) setScreenModeAutoWindow(); - - screen = SDL_SetVideoMode(cx,cy,bpp, - SDL_OPENGL | - (fullscr ? SDL_FULLSCREEN : 0) | - (noframe ? SDL_NOFRAME : 0)); - - if (!screen) { - outLog() << "Failed to create window or set video mode" << std::endl; - outLog() << "SDL error: " << SDL_GetError() << std::endl; - outLog() << "Try changing your video settings in data/trigger.config" << std::endl; - SDL_Quit(); - if (PHYSFS_deinit() == 0) { - outLog() << "PhysFS: " << PHYSFS_getLastError() << std::endl; - } - return 1; - } - - sdl_mousemap = 0; - - sdl_joy.resize(SDL_NumJoysticks()); - - outLog() << "Found " << sdl_joy.size() << " joystick" << - (sdl_joy.size() == 1 ? "" : "s") << std::endl; - - for (unsigned int i=0; i zipfiles = PUtil::findFiles("", ".zip"); + + for (std::list::iterator i = zipfiles.begin(); + i != zipfiles.end(); i++) { + + const char *realpath = PHYSFS_getRealDir(i->c_str()); + + if (realpath) { + std::string fullpath = (std::string)realpath + *i; + + if (PHYSFS_addToSearchPath(fullpath.c_str(), 1) == 0) { + outLog() << "Failed to add archive \"" << fullpath << "\"" << std::endl + << "PhysFS: " << PHYSFS_getLastError() << std::endl; + } + } else { + outLog() << "Failed to find path of archive \"" << *i << "\"" << std::endl + << "PhysFS: " << PHYSFS_getLastError() << std::endl; + } + } + } + + try + { + config (); + } + catch (PException e) + { + PUtil::outLog() << "Config failed: " << e.what () << std::endl; + + if (PHYSFS_deinit() == 0) { + outLog() << "PhysFS: " << PHYSFS_getLastError() << std::endl; + } + return 1; + } + + outLog() << "Initialising SDL" << std::endl; + + SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE); + //SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK); + + srand(SDL_GetTicks()); + + SDL_WM_SetCaption(apptitle.c_str(), null); + + outLog() << "Create window and set video mode" << std::endl; + + SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + + if (reqRGB) { + SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 ); + } + + if (reqAlpha) { + SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 ); + } + + if (reqDepth) { + SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 ); + } + + if (reqStencil) + SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 ); + + if (stereo == StereoQuadBuffer) { + SDL_GL_SetAttribute( SDL_GL_STEREO, 1 ); + } + + if (cx <= 0 || cy <= 0) setScreenModeAutoWindow(); + + screen = SDL_SetVideoMode(cx,cy,bpp, + SDL_OPENGL | + (fullscr ? SDL_FULLSCREEN : 0) | + (noframe ? SDL_NOFRAME : 0)); + + if (!screen) { + outLog() << "Failed to create window or set video mode" << std::endl; + outLog() << "SDL error: " << SDL_GetError() << std::endl; + outLog() << "Try changing your video settings in data/trigger.config" << std::endl; + SDL_Quit(); + if (PHYSFS_deinit() == 0) { + outLog() << "PhysFS: " << PHYSFS_getLastError() << std::endl; + } + return 1; + } + + sdl_mousemap = 0; + + sdl_joy.resize(SDL_NumJoysticks()); + + outLog() << "Found " << sdl_joy.size() << " joystick" << + (sdl_joy.size() == 1 ? "" : "s") << std::endl; + + for (unsigned int i=0; i 100) timepassed = 100; - if (timepassed > 0) { - float delta = (float)timepassed * 0.001 * TIMESCALE; - - tick(delta); - - for (std::list::iterator i = sslist.begin(); - i != sslist.end(); ++i) { - (*i)->tick(delta, cam_pos, cam_orimat, cam_linvel); - } - } - } - - curtime = nowtime; - - if (exit_requested) break; - - if (active || repaint) { - switch (stereo) { - - case StereoNone: // Normal, non-stereo rendering - - render(0.0f); - glFlush(); - SDL_GL_SwapBuffers(); - break; - - case StereoQuadBuffer: // Hardware quad buffer stereo - - glDrawBuffer(GL_BACK_LEFT); - render(-stereoEyeTranslation); - glFlush(); - - glDrawBuffer(GL_BACK_RIGHT); - render(stereoEyeTranslation); - glFlush(); - - SDL_GL_SwapBuffers(); - break; - - case StereoRedBlue: // Red-blue anaglyph stereo - - // Green will not be rendered to, so clear it - glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_TRUE); - glClearColor(0.5, 0.5, 0.5, 0.5); - glClear(GL_COLOR_BUFFER_BIT); - - glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_TRUE); - render(-stereoEyeTranslation); - glFlush(); - - glColorMask(GL_FALSE, GL_FALSE, GL_TRUE, GL_TRUE); - render(stereoEyeTranslation); - glFlush(); - - SDL_GL_SwapBuffers(); - break; - - case StereoRedGreen: // Red-green anaglyph stereo - - // Blue will not be rendered to, so clear it - glColorMask(GL_FALSE, GL_FALSE, GL_TRUE, GL_TRUE); - glClearColor(0.5, 0.5, 0.5, 0.5); - glClear(GL_COLOR_BUFFER_BIT); - - glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_TRUE); - render(-stereoEyeTranslation); - glFlush(); - - glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_TRUE); - render(stereoEyeTranslation); - glFlush(); - - SDL_GL_SwapBuffers(); - break; - - case StereoRedCyan: // Red-cyan anaglyph stereo - - glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_TRUE); - render(-stereoEyeTranslation); - glFlush(); - - glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE); - render(stereoEyeTranslation); - glFlush(); - - SDL_GL_SwapBuffers(); - break; - - case StereoYellowBlue: // Yellow-blue anaglyph stereo - - glColorMask(GL_TRUE, GL_TRUE, GL_FALSE, GL_TRUE); - render(-stereoEyeTranslation); - glFlush(); - - glColorMask(GL_FALSE, GL_FALSE, GL_TRUE, GL_TRUE); - render(stereoEyeTranslation); - glFlush(); - - SDL_GL_SwapBuffers(); - break; - } - repaint = false; - - if (screenshot_requested) { - glReadBuffer(GL_FRONT); - unsigned char *data1 = new unsigned char[cx*(cy+1)*3]; - glReadPixels(0, 0, cx, cy, GL_RGB, GL_UNSIGNED_BYTE, data1); - glReadBuffer(GL_BACK); - const int rowsize = cx * 3; - for(int i = 0; i < cy/2; ++i) { - memcpy(&data1[(cy) * rowsize], &data1[(cy-1-i) * rowsize], rowsize); - memcpy(&data1[(cy-1-i) * rowsize], &data1[(i) * rowsize], rowsize); - memcpy(&data1[(i) * rowsize], &data1[(cy) * rowsize], rowsize); - //memset(&data1[(i) * rowsize], 128, rowsize); - } - char buff[200]; - sprintf(buff, "P6\n" - "# CREATOR: Trigger PNM Screenshot\n" - "%i %i\n255\n", cx, cy); - char filename[100]; - sprintf(filename, "screen-%09u.ppm", SDL_GetTicks()); - PUtil::outLog() << "Writing screenshot \"" << filename << "\"" << std::endl; - PHYSFS_file* pfile = PHYSFS_openWrite(filename); - if (pfile) { - PHYSFS_write(pfile, buff, strlen(buff), 1); - PHYSFS_write(pfile, data1, cx*cy*3, 1); - PHYSFS_close(pfile); - } else { - PUtil::outLog() << "Screenshot write failed" << std::endl; - PUtil::outLog() << "PhysFS: " << PHYSFS_getLastError() << std::endl; - } - delete[] data1; - screenshot_requested = false; - } - - } else { - SDL_WaitEvent(null); - } - - if (exit_requested) break; - } - - outLog() << "Exit requested" << std::endl; - - unload(); - - while (!sslist.empty()) { - delete sslist.back(); - sslist.pop_back(); - } - - SDL_WM_GrabInput(SDL_GRAB_OFF); - SDL_ShowCursor(SDL_ENABLE); - - SDL_Quit(); - - if (PHYSFS_deinit() == 0) { - outLog() << "PhysFS: " << PHYSFS_getLastError() << std::endl; - } - - outLog() << "Shutdown complete" << std::endl; - - return 0; + if (1) {//if (active) { + uint32 timepassed = nowtime - curtime; + if (timepassed > 100) timepassed = 100; + if (timepassed > 0) { + float delta = (float)timepassed * 0.001 * TIMESCALE; + + tick(delta); + + for (std::list::iterator i = sslist.begin(); + i != sslist.end(); ++i) { + (*i)->tick(delta, cam_pos, cam_orimat, cam_linvel); + } + } + } + + curtime = nowtime; + + if (exit_requested) break; + + if (active || repaint) { + switch (stereo) { + + case StereoNone: // Normal, non-stereo rendering + + render(0.0f); + glFlush(); + SDL_GL_SwapBuffers(); + break; + + case StereoQuadBuffer: // Hardware quad buffer stereo + + glDrawBuffer(GL_BACK_LEFT); + render(-stereoEyeTranslation); + glFlush(); + + glDrawBuffer(GL_BACK_RIGHT); + render(stereoEyeTranslation); + glFlush(); + + SDL_GL_SwapBuffers(); + break; + + case StereoRedBlue: // Red-blue anaglyph stereo + + // Green will not be rendered to, so clear it + glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_TRUE); + glClearColor(0.5, 0.5, 0.5, 0.5); + glClear(GL_COLOR_BUFFER_BIT); + + glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_TRUE); + render(-stereoEyeTranslation); + glFlush(); + + glColorMask(GL_FALSE, GL_FALSE, GL_TRUE, GL_TRUE); + render(stereoEyeTranslation); + glFlush(); + + SDL_GL_SwapBuffers(); + break; + + case StereoRedGreen: // Red-green anaglyph stereo + + // Blue will not be rendered to, so clear it + glColorMask(GL_FALSE, GL_FALSE, GL_TRUE, GL_TRUE); + glClearColor(0.5, 0.5, 0.5, 0.5); + glClear(GL_COLOR_BUFFER_BIT); + + glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_TRUE); + render(-stereoEyeTranslation); + glFlush(); + + glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_TRUE); + render(stereoEyeTranslation); + glFlush(); + + SDL_GL_SwapBuffers(); + break; + + case StereoRedCyan: // Red-cyan anaglyph stereo + + glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_TRUE); + render(-stereoEyeTranslation); + glFlush(); + + glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE); + render(stereoEyeTranslation); + glFlush(); + + SDL_GL_SwapBuffers(); + break; + + case StereoYellowBlue: // Yellow-blue anaglyph stereo + + glColorMask(GL_TRUE, GL_TRUE, GL_FALSE, GL_TRUE); + render(-stereoEyeTranslation); + glFlush(); + + glColorMask(GL_FALSE, GL_FALSE, GL_TRUE, GL_TRUE); + render(stereoEyeTranslation); + glFlush(); + + SDL_GL_SwapBuffers(); + break; + } + repaint = false; + + if (screenshot_requested) { + glReadBuffer(GL_FRONT); + unsigned char *data1 = new unsigned char[cx*(cy+1)*3]; + glReadPixels(0, 0, cx, cy, GL_RGB, GL_UNSIGNED_BYTE, data1); + glReadBuffer(GL_BACK); + const int rowsize = cx * 3; + for(int i = 0; i < cy/2; ++i) { + memcpy(&data1[(cy) * rowsize], &data1[(cy-1-i) * rowsize], rowsize); + memcpy(&data1[(cy-1-i) * rowsize], &data1[(i) * rowsize], rowsize); + memcpy(&data1[(i) * rowsize], &data1[(cy) * rowsize], rowsize); + //memset(&data1[(i) * rowsize], 128, rowsize); + } + char buff[200]; + sprintf(buff, "P6\n" + "# CREATOR: Trigger PNM Screenshot\n" + "%i %i\n255\n", cx, cy); + char filename[100]; + sprintf(filename, "screen-%09u.ppm", SDL_GetTicks()); + PUtil::outLog() << "Writing screenshot \"" << filename << "\"" << std::endl; + PHYSFS_file* pfile = PHYSFS_openWrite(filename); + if (pfile) { + PHYSFS_write(pfile, buff, strlen(buff), 1); + PHYSFS_write(pfile, data1, cx*cy*3, 1); + PHYSFS_close(pfile); + } else { + PUtil::outLog() << "Screenshot write failed" << std::endl; + PUtil::outLog() << "PhysFS: " << PHYSFS_getLastError() << std::endl; + } + delete[] data1; + screenshot_requested = false; + } + + } else { + SDL_WaitEvent(null); + } + + if (exit_requested) break; + } + + outLog() << "Exit requested" << std::endl; + + unload(); + + while (!sslist.empty()) { + delete sslist.back(); + sslist.pop_back(); + } + + SDL_WM_GrabInput(SDL_GRAB_OFF); + SDL_ShowCursor(SDL_ENABLE); + + SDL_Quit(); + + if (PHYSFS_deinit() == 0) { + outLog() << "PhysFS: " << PHYSFS_getLastError() << std::endl; + } + + outLog() << "Shutdown complete" << std::endl; + + return 0; } void PApp::grabMouse(bool grab) { - //SDL_WM_GrabInput(grab ? SDL_GRAB_ON : SDL_GRAB_OFF); - SDL_ShowCursor(grab ? SDL_DISABLE : SDL_ENABLE); + //SDL_WM_GrabInput(grab ? SDL_GRAB_ON : SDL_GRAB_OFF); + SDL_ShowCursor(grab ? SDL_DISABLE : SDL_ENABLE); - grabinput = grab; + grabinput = grab; } void PApp::drawModel(PModel &model) { - for (std::vector::iterator mesh = model.mesh.begin(); - mesh != model.mesh.end(); - mesh++) { - if (!mesh->effect) - mesh->effect = getSSEffect().loadEffect(mesh->fxname); - - int numPasses = 0; - if (mesh->effect->renderBegin(&numPasses, getSSTexture())) { - for (int i=0; ieffect->renderPass(i); - glBegin(GL_TRIANGLES); - for (unsigned int f=0; fface.size(); f++) { - //glNormal3fv(mesh->face[f].facenormal); - - glNormal3fv(mesh->norm[mesh->face[f].nr[0]]); - glTexCoord2fv(mesh->texco[mesh->face[f].tc[0]]); - glVertex3fv(mesh->vert[mesh->face[f].vt[0]]); - - glNormal3fv(mesh->norm[mesh->face[f].nr[1]]); - glTexCoord2fv(mesh->texco[mesh->face[f].tc[1]]); - glVertex3fv(mesh->vert[mesh->face[f].vt[1]]); - - glNormal3fv(mesh->norm[mesh->face[f].nr[2]]); - glTexCoord2fv(mesh->texco[mesh->face[f].tc[2]]); - glVertex3fv(mesh->vert[mesh->face[f].vt[2]]); - } - glEnd(); - } - mesh->effect->renderEnd(); - } - } + for (std::vector::iterator mesh = model.mesh.begin(); + mesh != model.mesh.end(); + mesh++) { + if (!mesh->effect) + mesh->effect = getSSEffect().loadEffect(mesh->fxname); + + int numPasses = 0; + if (mesh->effect->renderBegin(&numPasses, getSSTexture())) { + for (int i=0; ieffect->renderPass(i); + glBegin(GL_TRIANGLES); + for (unsigned int f=0; fface.size(); f++) { + //glNormal3fv(mesh->face[f].facenormal); + + glNormal3fv(mesh->norm[mesh->face[f].nr[0]]); + glTexCoord2fv(mesh->texco[mesh->face[f].tc[0]]); + glVertex3fv(mesh->vert[mesh->face[f].vt[0]]); + + glNormal3fv(mesh->norm[mesh->face[f].nr[1]]); + glTexCoord2fv(mesh->texco[mesh->face[f].tc[1]]); + glVertex3fv(mesh->vert[mesh->face[f].vt[1]]); + + glNormal3fv(mesh->norm[mesh->face[f].nr[2]]); + glTexCoord2fv(mesh->texco[mesh->face[f].tc[2]]); + glVertex3fv(mesh->vert[mesh->face[f].vt[2]]); + } + glEnd(); + } + mesh->effect->renderEnd(); + } + } } @@ -771,7 +771,7 @@ void PApp::tick(float delta) { - delta = delta; + delta = delta; } void PApp::resize() @@ -780,44 +780,44 @@ void PApp::render(float eyetranslation) { - eyetranslation = eyetranslation; - - glClearColor(0.5, 0.5, 0.5, 0.0); - - glClear(GL_COLOR_BUFFER_BIT); + eyetranslation = eyetranslation; + + glClearColor(0.5, 0.5, 0.5, 0.0); + + glClear(GL_COLOR_BUFFER_BIT); } void PApp::keyEvent(const SDL_KeyboardEvent &ke) { - if (ke.type != SDL_KEYDOWN) return; + if (ke.type != SDL_KEYDOWN) return; - switch (ke.keysym.sym) { - case SDLK_ESCAPE: - requestExit(); - break; - default: - break; - } + switch (ke.keysym.sym) { + case SDLK_ESCAPE: + requestExit(); + break; + default: + break; + } } void PApp::mouseButtonEvent(const SDL_MouseButtonEvent &mbe) { - int unused = mbe.type; unused = unused; + int unused = mbe.type; unused = unused; } void PApp::mouseMoveEvent(int dx, int dy) { - dx = dx; dy = dy; + dx = dx; dy = dy; } void PApp::cursorMoveEvent(int posx, int posy) { - posx = posx; posy = posy; + posx = posx; posy = posy; } void PApp::joyButtonEvent(int which, int button, bool down) { - which = which; button = button; down = down; + which = which; button = button; down = down; } diff -Nru trigger-rally-0.5.2.1/src/pengine/app.h trigger-rally-0.6.0/src/pengine/app.h --- trigger-rally-0.5.2.1/src/pengine/app.h 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/pengine/app.h 2011-10-07 17:10:01.000000000 +0000 @@ -1,147 +1,147 @@ - -// app.h [pengine] - -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net -// License: GPL version 2 (see included gpl.txt) - - - -struct joystick_s { - SDL_Joystick *sdl_joystick; - std::string name; - std::vector axis; - std::vector button; - std::vector hat; -}; - -class PApp { -public: - - enum StereoMode { - StereoNone, - StereoQuadBuffer, - StereoRedBlue, - StereoRedGreen, - StereoRedCyan, - StereoYellowBlue - }; - -private: - std::string appname, apptitle; - - SDL_Surface *screen; - int cx, cy, bpp; - bool fullscr, noframe; - bool reqRGB, reqAlpha, reqDepth, reqStencil; - bool grabinput; - - StereoMode stereo; - float stereoEyeTranslation; - - uint8* sdl_keymap; - int sdl_numkeys; - uint8 sdl_mousemap; - std::vector sdl_joy; - - bool exit_requested, screenshot_requested; - - PSSRender *ssrdr; - PSSTexture *sstex; - PSSEffect *ssfx; - PSSModel *ssmod; - PSSAudio *ssaud; - -protected: - // the derived app should keep these up to date - vec3f cam_pos; - mat44f cam_orimat; - vec3f cam_linvel; - -public: - PApp(const std::string &title = "PGame", const std::string &name = ".pgame") { - appname = name; // for ~/.name - apptitle = title; // for window title - cx = cy = 0; bpp = 0; fullscr = false; noframe = false; - exit_requested = false; - screenshot_requested = false; - reqRGB = reqAlpha = reqDepth = reqStencil = false; - stereo = StereoNone; - stereoEyeTranslation = 0.0f; - grabinput = false; - } - virtual ~PApp() { } - - int run(int argc, char *argv[]); - -public: - std::ostream &outLog() { return std::cout; } // superceded by PUtil::outLog, remove? - - int getWidth() { return cx; } - int getHeight() { return cy; } - int getNumJoysticks() { return (sdl_joy.size()); } - int getJoyNumAxes(int j) { return (sdl_joy[j].axis.size()); } - int getJoyNumButtons(int j) { return (sdl_joy[j].button.size()); } - int getJoyNumHats(int j) { return (sdl_joy[j].hat.size()); } - float getJoyAxis(int j, int a) { return (sdl_joy[j].axis[a]); } - bool getJoyButton(int j, int b) { return (sdl_joy[j].button[b]); } - const vec2i &getJoyHat(int j, int h) { return (sdl_joy[j].hat[h]); } - - PSSRender &getSSRender() { return *ssrdr; } - PSSTexture &getSSTexture() { return *sstex; } - PSSEffect &getSSEffect() { return *ssfx; } - PSSModel &getSSModel() { return *ssmod; } - PSSAudio &getSSAudio() { return *ssaud; } - -protected: - bool keyDown(int key) { return (sdl_keymap[key] != 0); } - bool mouseButtonDown(int bt) { return ((sdl_mousemap & SDL_BUTTON(bt)) != 0); } - - void requestExit() { - exit_requested = true; - } - - void saveScreenshot() { - screenshot_requested = true; - } - - void grabMouse(bool grab = true); - - void drawModel(PModel &model); - - void stereoGLProject(float xmin, float xmax, float ymin, float ymax, float znear, float zfar, float zzps, float dist, float eye); - void stereoFrustum(float xmin, float xmax, float ymin, float ymax, float znear, float zfar, float zzps, float eye); - - // config stuff - - void setScreenMode(int w, int h, bool fullScreen = false, bool hideFrame = false) - { cx = w; cy = h; fullscr = fullScreen; noframe = hideFrame; } - void setScreenBPP(int _bpp) - { bpp = _bpp; } - void setScreenModeAutoWindow(); - void setScreenModeFastFullScreen(); - void requireRGB(bool req = true) { reqRGB = req; } - void requireAlpha(bool req = true) { reqAlpha = req; } - void requireDepth(bool req = true) { reqDepth = req; } - void requireStencil(bool req = true) { reqStencil = req; } - - void setStereoMode(StereoMode mode) { stereo = mode; } - void setStereoEyeSeperation(float distance) { stereoEyeTranslation = distance * 0.5f; } - - // callbacks for derived classes - - virtual void config() /* throw (PUserException) */ ; // very light setup/config func - virtual void load() /* throw (PUserException) */ ; // main resource loading - virtual void unload(); // free resources - - virtual void tick(float delta); - virtual void resize(); - virtual void render(float eyetranslation); - virtual void keyEvent(const SDL_KeyboardEvent &ke); - virtual void mouseButtonEvent(const SDL_MouseButtonEvent &mbe); - virtual void mouseMoveEvent(int dx, int dy); - virtual void cursorMoveEvent(int posx, int posy); - virtual void joyButtonEvent(int which, int button, bool down); -}; - - - + +// app.h [pengine] + +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net +// License: GPL version 2 (see included gpl.txt) + + + +struct joystick_s { + SDL_Joystick *sdl_joystick; + std::string name; + std::vector axis; + std::vector button; + std::vector hat; +}; + +class PApp { +public: + + enum StereoMode { + StereoNone, + StereoQuadBuffer, + StereoRedBlue, + StereoRedGreen, + StereoRedCyan, + StereoYellowBlue + }; + +private: + std::string appname, apptitle; + + SDL_Surface *screen; + int cx, cy, bpp; + bool fullscr, noframe; + bool reqRGB, reqAlpha, reqDepth, reqStencil; + bool grabinput; + + StereoMode stereo; + float stereoEyeTranslation; + + uint8* sdl_keymap; + int sdl_numkeys; + uint8 sdl_mousemap; + std::vector sdl_joy; + + bool exit_requested, screenshot_requested; + + PSSRender *ssrdr; + PSSTexture *sstex; + PSSEffect *ssfx; + PSSModel *ssmod; + PSSAudio *ssaud; + +protected: + // the derived app should keep these up to date + vec3f cam_pos; + mat44f cam_orimat; + vec3f cam_linvel; + +public: + PApp(const std::string &title = "PGame", const std::string &name = ".pgame") { + appname = name; // for ~/.name + apptitle = title; // for window title + cx = cy = 0; bpp = 0; fullscr = false; noframe = false; + exit_requested = false; + screenshot_requested = false; + reqRGB = reqAlpha = reqDepth = reqStencil = false; + stereo = StereoNone; + stereoEyeTranslation = 0.0f; + grabinput = false; + } + virtual ~PApp() { } + + int run(int argc, char *argv[]); + +public: + std::ostream &outLog() { return std::cout; } // superceded by PUtil::outLog, remove? + + int getWidth() { return cx; } + int getHeight() { return cy; } + int getNumJoysticks() { return (sdl_joy.size()); } + int getJoyNumAxes(int j) { return (sdl_joy[j].axis.size()); } + int getJoyNumButtons(int j) { return (sdl_joy[j].button.size()); } + int getJoyNumHats(int j) { return (sdl_joy[j].hat.size()); } + float getJoyAxis(int j, int a) { return (sdl_joy[j].axis[a]); } + bool getJoyButton(int j, int b) { return (sdl_joy[j].button[b]); } + const vec2i &getJoyHat(int j, int h) { return (sdl_joy[j].hat[h]); } + + PSSRender &getSSRender() { return *ssrdr; } + PSSTexture &getSSTexture() { return *sstex; } + PSSEffect &getSSEffect() { return *ssfx; } + PSSModel &getSSModel() { return *ssmod; } + PSSAudio &getSSAudio() { return *ssaud; } + +protected: + bool keyDown(int key) { return (sdl_keymap[key] != 0); } + bool mouseButtonDown(int bt) { return ((sdl_mousemap & SDL_BUTTON(bt)) != 0); } + + void requestExit() { + exit_requested = true; + } + + void saveScreenshot() { + screenshot_requested = true; + } + + void grabMouse(bool grab = true); + + void drawModel(PModel &model); + + void stereoGLProject(float xmin, float xmax, float ymin, float ymax, float znear, float zfar, float zzps, float dist, float eye); + void stereoFrustum(float xmin, float xmax, float ymin, float ymax, float znear, float zfar, float zzps, float eye); + + // config stuff + + void setScreenMode(int w, int h, bool fullScreen = false, bool hideFrame = false) + { cx = w; cy = h; fullscr = fullScreen; noframe = hideFrame; } + void setScreenBPP(int _bpp) + { bpp = _bpp; } + void setScreenModeAutoWindow(); + void setScreenModeFastFullScreen(); + void requireRGB(bool req = true) { reqRGB = req; } + void requireAlpha(bool req = true) { reqAlpha = req; } + void requireDepth(bool req = true) { reqDepth = req; } + void requireStencil(bool req = true) { reqStencil = req; } + + void setStereoMode(StereoMode mode) { stereo = mode; } + void setStereoEyeSeperation(float distance) { stereoEyeTranslation = distance * 0.5f; } + + // callbacks for derived classes + + virtual void config() /* throw (PUserException) */ ; // very light setup/config func + virtual void load() /* throw (PUserException) */ ; // main resource loading + virtual void unload(); // free resources + + virtual void tick(float delta); + virtual void resize(); + virtual void render(float eyetranslation); + virtual void keyEvent(const SDL_KeyboardEvent &ke); + virtual void mouseButtonEvent(const SDL_MouseButtonEvent &mbe); + virtual void mouseMoveEvent(int dx, int dy); + virtual void cursorMoveEvent(int posx, int posy); + virtual void joyButtonEvent(int which, int button, bool down); +}; + + + diff -Nru trigger-rally-0.5.2.1/src/pengine/audio.cpp trigger-rally-0.6.0/src/pengine/audio.cpp --- trigger-rally-0.5.2.1/src/pengine/audio.cpp 2006-10-20 18:45:28.000000000 +0000 +++ trigger-rally-0.6.0/src/pengine/audio.cpp 2011-10-07 17:10:01.000000000 +0000 @@ -1,7 +1,7 @@ // audio.cpp [pengine] -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net // License: GPL version 2 (see included gpl.txt) @@ -42,23 +42,23 @@ PAudioSample *PSSAudio::loadSample(const std::string &name, bool positional3D) { - PAudioSample *samp = samplist.find(name); - - if (!samp) - { - try - { - samp = new PAudioSample(name, positional3D); - } - catch (PException e) - { - if (PUtil::isDebugLevel(DEBUGLEVEL_ENDUSER)) - PUtil::outLog() << "Failed to load " << name << ": " << e.what () << std::endl; - return null; - } - samplist.add(samp); - } - return samp; + PAudioSample *samp = samplist.find(name); + + if (!samp) + { + try + { + samp = new PAudioSample(name, positional3D); + } + catch (PException e) + { + if (PUtil::isDebugLevel(DEBUGLEVEL_ENDUSER)) + PUtil::outLog() << "Failed to load " << name << ": " << e.what () << std::endl; + return null; + } + samplist.add(samp); + } + return samp; } @@ -69,34 +69,34 @@ PSSAudio::PSSAudio(PApp &parentApp) : PSubsystem(parentApp) { - PUtil::outLog() << "Initialising audio subsystem [NULL]" << std::endl; + PUtil::outLog() << "Initialising audio subsystem [NULL]" << std::endl; } PSSAudio::~PSSAudio() { - PUtil::outLog() << "Shutting down audio subsystem" << std::endl; - - samplist.clear(); + PUtil::outLog() << "Shutting down audio subsystem" << std::endl; + + samplist.clear(); } PAudioSample *PSSAudio::loadSample(const std::string &name, bool positional3D) { - PAudioSample *samp = samplist.find(name); - - return samp; + PAudioSample *samp = samplist.find(name); + + return samp; } PAudioSample::PAudioSample (const std::string &filename, bool positional3D) { - buffer = 0; - - if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) - PUtil::outLog() << "Loading sample \"" << filename << "\"" << std::endl; - - unload(); - - name = filename; + buffer = 0; + + if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) + PUtil::outLog() << "Loading sample \"" << filename << "\"" << std::endl; + + unload(); + + name = filename; } void PAudioSample::unload() @@ -104,7 +104,7 @@ } PAudioInstance::PAudioInstance(PAudioSample *_samp, bool looping) : - samp(_samp) + samp(_samp) { } @@ -140,7 +140,7 @@ bool PAudioInstance::isPlaying() { - return false; + return false; } #endif // USE_NULL @@ -156,132 +156,132 @@ PSSAudio::PSSAudio(PApp &parentApp) : PSubsystem(parentApp) { - PUtil::outLog() << "Initialising audio subsystem [OpenAL]" << std::endl; - - if (alutInit(0, null) != AL_TRUE) { - throw MakePException("ALUT:alutInit() error: " + PUtil::outLog() << "Initialising audio subsystem [OpenAL]" << std::endl; + + if (alutInit(0, null) != AL_TRUE) { + throw MakePException("ALUT:alutInit() error: " + alutGetErrorString(alutGetError())); - } + } } PSSAudio::~PSSAudio() { - PUtil::outLog() << "Shutting down audio subsystem" << std::endl; + PUtil::outLog() << "Shutting down audio subsystem" << std::endl; - samplist.clear(); + samplist.clear(); - alutExit(); + alutExit(); } PAudioSample::PAudioSample (const std::string &filename, bool positional3D) { - buffer = 0; - positional3D = positional3D; // unused (atm) - - if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) - PUtil::outLog() << "Loading sample \"" << filename << "\"" << std::endl; - - unload(); - /* load contents from file into memory using physfs functions */ - name = filename; - PHYSFS_file *pfile = PHYSFS_openRead(filename.c_str()); - - if (!pfile) { - throw MakePException ("Load failed: PhysFS: " + PHYSFS_getLastError()); - } - - int filesize = PHYSFS_fileLength(pfile); - - char *wavbuffer = new char[filesize]; - - PHYSFS_read(pfile, wavbuffer, filesize, 1); - PHYSFS_close(pfile); - - /* create the alut buffer from memory contents */ - this->buffer = alutCreateBufferFromFileImage( - reinterpret_cast(wavbuffer), - filesize); - - /* clean up */ - delete [] wavbuffer; - - /* check if loading was successful */ - if (AL_NONE == this->buffer) { - throw MakePException("Sample load failed:" - + alutGetErrorString(alutGetError())); - } + buffer = 0; + positional3D = positional3D; // unused (atm) + + if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) + PUtil::outLog() << "Loading sample \"" << filename << "\"" << std::endl; + + unload(); + /* load contents from file into memory using physfs functions */ + name = filename; + PHYSFS_file *pfile = PHYSFS_openRead(filename.c_str()); + + if (!pfile) { + throw MakePException ("Load failed: PhysFS: " + PHYSFS_getLastError()); + } + + int filesize = PHYSFS_fileLength(pfile); + + char *wavbuffer = new char[filesize]; + + PHYSFS_read(pfile, wavbuffer, filesize, 1); + PHYSFS_close(pfile); + + /* create the alut buffer from memory contents */ + this->buffer = alutCreateBufferFromFileImage( + reinterpret_cast(wavbuffer), + filesize); + + /* clean up */ + delete [] wavbuffer; + + /* check if loading was successful */ + if (AL_NONE == this->buffer) { + throw MakePException("Sample load failed:" + + alutGetErrorString(alutGetError())); + } } void PAudioSample::unload() { - if (buffer) { - alDeleteBuffers(1, &buffer); - buffer = 0; - } + if (buffer) { + alDeleteBuffers(1, &buffer); + buffer = 0; + } } PAudioInstance::PAudioInstance(PAudioSample *_samp, bool looping) { - samp = _samp; + samp = _samp; - alGenSources(1, &source); + alGenSources(1, &source); - alSourcei(source, AL_BUFFER, samp->buffer); - alSourcei(source, AL_LOOPING, looping ? AL_TRUE : AL_FALSE); + alSourcei(source, AL_BUFFER, samp->buffer); + alSourcei(source, AL_LOOPING, looping ? AL_TRUE : AL_FALSE); - alSourcePlay(source); + alSourcePlay(source); } PAudioInstance::~PAudioInstance() { - if (isPlaying()) stop(); - alDeleteSources(1, &source); + if (isPlaying()) stop(); + alDeleteSources(1, &source); } void PAudioInstance::update(const vec3f &pos, const vec3f &vel) { - alSourcefv(source, AL_POSITION, (vec3f)pos); - alSourcefv(source, AL_VELOCITY, (vec3f)vel); + alSourcefv(source, AL_POSITION, (vec3f)pos); + alSourcefv(source, AL_VELOCITY, (vec3f)vel); } void PAudioInstance::setGain(float gain) { - //alSourcef(source, AL_MIN_GAIN, gain); - //alSourcef(source, AL_MAX_GAIN, gain); - alSourcef(source, AL_GAIN, gain); + //alSourcef(source, AL_MIN_GAIN, gain); + //alSourcef(source, AL_MAX_GAIN, gain); + alSourcef(source, AL_GAIN, gain); } void PAudioInstance::setHalfDistance(float lambda) { - alSourcef(source, AL_REFERENCE_DISTANCE, lambda); + alSourcef(source, AL_REFERENCE_DISTANCE, lambda); } void PAudioInstance::setPitch(float pitch) { - alSourcef(source, AL_PITCH, pitch); + alSourcef(source, AL_PITCH, pitch); } void PAudioInstance::play() { - alSourceRewind(source); - alSourcePlay(source); + alSourceRewind(source); + alSourcePlay(source); } void PAudioInstance::stop() { - alSourceStop(source); + alSourceStop(source); } bool PAudioInstance::isPlaying() { - int state = AL_STOPPED; - alGetSourcei(source, AL_SOURCE_STATE, &state); - return (state == AL_PLAYING); + int state = AL_STOPPED; + alGetSourcei(source, AL_SOURCE_STATE, &state); + return (state == AL_PLAYING); } #endif // USE_OPENAL @@ -300,175 +300,175 @@ void * F_CALLBACKAPI fsound_open(const char *name) { - PHYSFS_file *pfile = PHYSFS_openRead(name); - - if (!pfile) - PUtil::outLog() << "PhysFS: " << PHYSFS_getLastError() << std::endl; - - return pfile; + PHYSFS_file *pfile = PHYSFS_openRead(name); + + if (!pfile) + PUtil::outLog() << "PhysFS: " << PHYSFS_getLastError() << std::endl; + + return pfile; } void F_CALLBACKAPI fsound_close(void *handle) { - PHYSFS_file *pfile = reinterpret_cast< PHYSFS_file * > (handle); + PHYSFS_file *pfile = reinterpret_cast< PHYSFS_file * > (handle); - if (pfile) - PHYSFS_close(pfile); + if (pfile) + PHYSFS_close(pfile); } int F_CALLBACKAPI fsound_read(void *buffer, int size, void *handle) { - PHYSFS_file *pfile = reinterpret_cast< PHYSFS_file * > (handle); - - return PHYSFS_read(pfile, buffer, size, 1); + PHYSFS_file *pfile = reinterpret_cast< PHYSFS_file * > (handle); + + return PHYSFS_read(pfile, buffer, size, 1); } int F_CALLBACKAPI fsound_seek(void *handle, int pos, signed char mode) { - PHYSFS_file *pfile = reinterpret_cast< PHYSFS_file * > (handle); - - int target; - - int curpos = PHYSFS_tell(pfile); - - switch (mode) { - default: - case SEEK_SET: - target = pos; - break; - case SEEK_CUR: - target = curpos + pos; - break; - case SEEK_END: - target = PHYSFS_fileLength(pfile) + pos; - break; - } - - PHYSFS_seek(pfile, target); - - return curpos; + PHYSFS_file *pfile = reinterpret_cast< PHYSFS_file * > (handle); + + int target; + + int curpos = PHYSFS_tell(pfile); + + switch (mode) { + default: + case SEEK_SET: + target = pos; + break; + case SEEK_CUR: + target = curpos + pos; + break; + case SEEK_END: + target = PHYSFS_fileLength(pfile) + pos; + break; + } + + PHYSFS_seek(pfile, target); + + return curpos; } int F_CALLBACKAPI fsound_tell(void *handle) { - PHYSFS_file *pfile = reinterpret_cast< PHYSFS_file * > (handle); - - return PHYSFS_tell(pfile); + PHYSFS_file *pfile = reinterpret_cast< PHYSFS_file * > (handle); + + return PHYSFS_tell(pfile); } PSSAudio::PSSAudio(PApp &parentApp) : PSubsystem(parentApp) { - PUtil::outLog() << "Initialising audio subsystem [FMOD]" << std::endl; - - if (!FSOUND_Init(22050, 16, 0)) { - throw MakePException ("FMOD initialisation failed"); - } - - FSOUND_File_SetCallbacks( - fsound_open, - fsound_close, - fsound_read, - fsound_seek, - fsound_tell); + PUtil::outLog() << "Initialising audio subsystem [FMOD]" << std::endl; + + if (!FSOUND_Init(22050, 16, 0)) { + throw MakePException ("FMOD initialisation failed"); + } + + FSOUND_File_SetCallbacks( + fsound_open, + fsound_close, + fsound_read, + fsound_seek, + fsound_tell); } PSSAudio::~PSSAudio() { - PUtil::outLog() << "Shutting down audio subsystem" << std::endl; + PUtil::outLog() << "Shutting down audio subsystem" << std::endl; - samplist.clear(); + samplist.clear(); - FSOUND_Close(); + FSOUND_Close(); } PAudioSample::PAudioSample (const std::string &filename, bool positional3D) { - buffer = 0; - - if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) - PUtil::outLog() << "Loading sample \"" << filename << "\"" << std::endl; + buffer = 0; + + if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) + PUtil::outLog() << "Loading sample \"" << filename << "\"" << std::endl; - unload(); + unload(); - name = filename; + name = filename; - buffer = (uint32) FSOUND_Sample_Load(FSOUND_FREE, filename.c_str(), - positional3D ? FSOUND_HW3D : FSOUND_HW2D, 0, 0); + buffer = (uint32) FSOUND_Sample_Load(FSOUND_FREE, filename.c_str(), + positional3D ? FSOUND_HW3D : FSOUND_HW2D, 0, 0); - if (!buffer) { - throw MakePException ("Sample load failed"); - } + if (!buffer) { + throw MakePException ("Sample load failed"); + } } void PAudioSample::unload() { - if (buffer) { - FSOUND_Sample_Free((FSOUND_SAMPLE *)buffer); - buffer = 0; - } + if (buffer) { + FSOUND_Sample_Free((FSOUND_SAMPLE *)buffer); + buffer = 0; + } } PAudioInstance::PAudioInstance(PAudioSample *_samp, bool looping) : - samp(_samp) + samp(_samp) { - //FSOUND_Sample_SetMode((FSOUND_SAMPLE *)samp->buffer, - // looping ? FSOUND_LOOP_NORMAL : FSOUND_LOOP_OFF); + //FSOUND_Sample_SetMode((FSOUND_SAMPLE *)samp->buffer, + // looping ? FSOUND_LOOP_NORMAL : FSOUND_LOOP_OFF); - source = (uint32) FSOUND_PlaySoundEx(FSOUND_FREE, - (FSOUND_SAMPLE *)samp->buffer, null, TRUE); + source = (uint32) FSOUND_PlaySoundEx(FSOUND_FREE, + (FSOUND_SAMPLE *)samp->buffer, null, TRUE); - *((float*)&reserved1) = (float)FSOUND_GetFrequency((int)source); + *((float*)&reserved1) = (float)FSOUND_GetFrequency((int)source); - FSOUND_SetLoopMode((int)source, - looping ? FSOUND_LOOP_NORMAL : FSOUND_LOOP_OFF); + FSOUND_SetLoopMode((int)source, + looping ? FSOUND_LOOP_NORMAL : FSOUND_LOOP_OFF); } PAudioInstance::~PAudioInstance() { - if (isPlaying()) stop(); + if (isPlaying()) stop(); } void PAudioInstance::update(const vec3f &pos, const vec3f &vel) { - // TODO + // TODO } void PAudioInstance::setGain(float gain) { - CLAMP(gain, 0.0f, 1.0f); - FSOUND_SetVolume((int)source, (int)(gain * 255.0f)); + CLAMP(gain, 0.0f, 1.0f); + FSOUND_SetVolume((int)source, (int)(gain * 255.0f)); } void PAudioInstance::setHalfDistance(float lambda) { - // TODO + // TODO } void PAudioInstance::setPitch(float pitch) { - FSOUND_SetFrequency((int)source, (int)(pitch * *((float*)&reserved1))); + FSOUND_SetFrequency((int)source, (int)(pitch * *((float*)&reserved1))); } void PAudioInstance::play() { - FSOUND_SetPaused((int)source, FALSE); + FSOUND_SetPaused((int)source, FALSE); } void PAudioInstance::stop() { - FSOUND_StopSound((int)source); + FSOUND_StopSound((int)source); } bool PAudioInstance::isPlaying() { - return (FSOUND_IsPlaying((int)source) == TRUE); + return (FSOUND_IsPlaying((int)source) == TRUE); } #endif // USE_FMOD @@ -480,85 +480,85 @@ PSSAudio::PSSAudio(PApp &parentApp) : PSubsystem(parentApp) { - PUtil::outLog() << "Initialising audio subsystem [SDL_mixer]" << std::endl; - - if (Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 1, 2048) != 0) { - PUtil::outLog() << "SDL_mixer failed to initialise" << std::endl; - PUtil::outLog() << "SDL_mixer: " << Mix_GetError() << std::endl; - return PException (); - } + PUtil::outLog() << "Initialising audio subsystem [SDL_mixer]" << std::endl; + + if (Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 1, 2048) != 0) { + PUtil::outLog() << "SDL_mixer failed to initialise" << std::endl; + PUtil::outLog() << "SDL_mixer: " << Mix_GetError() << std::endl; + return PException (); + } } PSSAudio::~PSSAudio() { - PUtil::outLog() << "Shutting down audio subsystem" << std::endl; - - samplist.clear(); - - Mix_CloseAudio(); + PUtil::outLog() << "Shutting down audio subsystem" << std::endl; + + samplist.clear(); + + Mix_CloseAudio(); } PAudioSample::PAudioSample (const std::string &filename, bool positional3D) { - buffer = 0; - - if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) - PUtil::outLog() << "Loading sample \"" << filename << "\"" << std::endl; - - unload(); - - name = filename; - - PHYSFS_file *pfile = PHYSFS_openRead(filename.c_str()); - - if (!pfile) { - PUtil::outLog() << "Load failed: PhysFS: " << PHYSFS_getLastError() << std::endl; - throw PFileException (); - } - - buffer = (uint32) Mix_LoadWAV_RW(PUtil::allocPhysFSops(pfile), 1); - - PHYSFS_close(pfile); - - if (!buffer) { - PUtil::outLog() << "Sample load failed" << std::endl; - PUtil::outLog() << "SDL_mixer: " << Mix_GetError() << std::endl; - throw PFileException (); - } + buffer = 0; + + if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) + PUtil::outLog() << "Loading sample \"" << filename << "\"" << std::endl; + + unload(); + + name = filename; + + PHYSFS_file *pfile = PHYSFS_openRead(filename.c_str()); + + if (!pfile) { + PUtil::outLog() << "Load failed: PhysFS: " << PHYSFS_getLastError() << std::endl; + throw PFileException (); + } + + buffer = (uint32) Mix_LoadWAV_RW(PUtil::allocPhysFSops(pfile), 1); + + PHYSFS_close(pfile); + + if (!buffer) { + PUtil::outLog() << "Sample load failed" << std::endl; + PUtil::outLog() << "SDL_mixer: " << Mix_GetError() << std::endl; + throw PFileException (); + } } void PAudioSample::unload() { - if (buffer) - Mix_FreeChunk((Mix_Chunk *) buffer); - buffer = 0; - } + if (buffer) + Mix_FreeChunk((Mix_Chunk *) buffer); + buffer = 0; + } } PAudioInstance::PAudioInstance(PAudioSample *_samp, bool looping) : - samp(_samp) + samp(_samp) { - source = (uint32) Mix_PlayChannel(-1 - (Mix_Chunk *)samp->buffer, looping ? -1 : 0); + source = (uint32) Mix_PlayChannel(-1 + (Mix_Chunk *)samp->buffer, looping ? -1 : 0); - *((float*)&reserved1) = (float)FSOUND_GetFrequency((int)source); + *((float*)&reserved1) = (float)FSOUND_GetFrequency((int)source); - FSOUND_SetLoopMode((int)source, - looping ? FSOUND_LOOP_NORMAL : FSOUND_LOOP_OFF); + FSOUND_SetLoopMode((int)source, + looping ? FSOUND_LOOP_NORMAL : FSOUND_LOOP_OFF); } PAudioInstance::~PAudioInstance() { - if (source != -1) { - } + if (source != -1) { + } } void PAudioInstance::update(const vec3f &pos, const vec3f &vel) { - // TODO + // TODO } void PAudioInstance::setGain(float gain) @@ -567,7 +567,7 @@ void PAudioInstance::setHalfDistance(float lambda) { - // TODO + // TODO } void PAudioInstance::setPitch(float pitch) @@ -585,7 +585,7 @@ bool PAudioInstance::isPlaying() { - return false; + return false; } #endif // USE_SDL_MIXER diff -Nru trigger-rally-0.5.2.1/src/pengine/audio.h trigger-rally-0.6.0/src/pengine/audio.h --- trigger-rally-0.5.2.1/src/pengine/audio.h 2006-10-20 18:53:43.000000000 +0000 +++ trigger-rally-0.6.0/src/pengine/audio.h 2011-10-07 17:10:01.000000000 +0000 @@ -1,78 +1,78 @@ - -// audio.h [pengine] - -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net -// License: GPL version 2 (see included gpl.txt) - - -// Ubuntu patch "15_fixup_physfs_alut_interaction.patch" includes -// the OpenAL header so that ALuint can be used for PAudioSample::buffer. -// I don't like exposing OpenAL to the rest of the engine, so I'm -// omitting it, but if you find it causes build problems, you may -// want to re-enable it below. - jaz 20/10/2006 - -#if 0 // defined( USE_OPENAL ) -#define INCLUDE_OPENAL_HEADER -#endif - -#if defined( INCLUDE_OPENAL_HEADER ) -#include -#endif - -class PSSAudio : public PSubsystem { -private: - PResourceList samplist; - -public: - PSSAudio(PApp &parentApp); - ~PSSAudio(); - - // TODO: tick - - PAudioSample *loadSample(const std::string &name, bool positional3D = true); -}; - -class PAudioSample : public PResource { -private: -#if defined( INCLUDE_OPENAL_HEADER ) - ALuint buffer; -#else - unsigned int buffer; -#endif - -public: - PAudioSample(const std::string &filename, bool positional3D = false); - ~PAudioSample() { unload(); } - - void unload(); - - friend class PAudioInstance; -}; - -class PAudioInstance { -private: - PAudioSample *samp; - //uint32 source; - //uint32 reserved1; - unsigned int source; - unsigned int reserved1; - -public: - PAudioInstance(PAudioSample *_samp, bool looping = false); - ~PAudioInstance(); - - void update(const vec3f &pos, const vec3f &vel); - void setGain(float gain); // 0-1 - void setHalfDistance(float lambda); - void setPitch(float pitch); // 1 is normal - - void play(); - void stop(); - bool isPlaying(); -}; - - -#ifdef INCLUDE_OPENAL_HEADER -#undef INCLUDE_OPENAL_HEADER -#endif - + +// audio.h [pengine] + +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net +// License: GPL version 2 (see included gpl.txt) + + +// Ubuntu patch "15_fixup_physfs_alut_interaction.patch" includes +// the OpenAL header so that ALuint can be used for PAudioSample::buffer. +// I don't like exposing OpenAL to the rest of the engine, so I'm +// omitting it, but if you find it causes build problems, you may +// want to re-enable it below. - jaz 20/10/2006 + +#if 0 // defined( USE_OPENAL ) +#define INCLUDE_OPENAL_HEADER +#endif + +#if defined( INCLUDE_OPENAL_HEADER ) +#include +#endif + +class PSSAudio : public PSubsystem { +private: + PResourceList samplist; + +public: + PSSAudio(PApp &parentApp); + ~PSSAudio(); + + // TODO: tick + + PAudioSample *loadSample(const std::string &name, bool positional3D = true); +}; + +class PAudioSample : public PResource { +private: +#if defined( INCLUDE_OPENAL_HEADER ) + ALuint buffer; +#else + unsigned int buffer; +#endif + +public: + PAudioSample(const std::string &filename, bool positional3D = false); + ~PAudioSample() { unload(); } + + void unload(); + + friend class PAudioInstance; +}; + +class PAudioInstance { +private: + PAudioSample *samp; + //uint32 source; + //uint32 reserved1; + unsigned int source; + unsigned int reserved1; + +public: + PAudioInstance(PAudioSample *_samp, bool looping = false); + ~PAudioInstance(); + + void update(const vec3f &pos, const vec3f &vel); + void setGain(float gain); // 0-1 + void setHalfDistance(float lambda); + void setPitch(float pitch); // 1 is normal + + void play(); + void stop(); + bool isPlaying(); +}; + + +#ifdef INCLUDE_OPENAL_HEADER +#undef INCLUDE_OPENAL_HEADER +#endif + diff -Nru trigger-rally-0.5.2.1/src/pengine/exception.h trigger-rally-0.6.0/src/pengine/exception.h --- trigger-rally-0.5.2.1/src/pengine/exception.h 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/pengine/exception.h 2011-10-07 17:10:01.000000000 +0000 @@ -1,31 +1,31 @@ - -// exception.h [pengine] - -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net -// License: GPL version 2 (see included gpl.txt) - - - -class PException : public std::exception -{ -public: - PException (const std::string &text) : text_ (text) { } - - ~PException () throw () { } - - const char *what () const throw () - { - return text_.c_str (); - } - -private: - std::string text_; -}; - - - -#define makestring2(x) #x -#define makestring(x) makestring2(x) - -#define MakePException(text) PException (std::string () + text + std::string (" at " __FILE__ ":" makestring(__LINE__))) - + +// exception.h [pengine] + +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net +// License: GPL version 2 (see included gpl.txt) + + + +class PException : public std::exception +{ +public: + PException (const std::string &text) : text_ (text) { } + + ~PException () throw () { } + + const char *what () const throw () + { + return text_.c_str (); + } + +private: + std::string text_; +}; + + + +#define makestring2(x) #x +#define makestring(x) makestring2(x) + +#define MakePException(text) PException (std::string () + text + std::string (" at " __FILE__ ":" makestring(__LINE__))) + diff -Nru trigger-rally-0.5.2.1/src/pengine/fxman.cpp trigger-rally-0.6.0/src/pengine/fxman.cpp --- trigger-rally-0.5.2.1/src/pengine/fxman.cpp 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/pengine/fxman.cpp 2011-10-07 17:10:01.000000000 +0000 @@ -1,598 +1,598 @@ - -// fxman.cpp [pengine] - -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net -// License: GPL version 2 (see included gpl.txt) - - -#include "pengine.h" - - -fx_renderstate_s def_rs; - - -int max_tex_units; - - - -PSSEffect::PSSEffect(PApp &parentApp) : PSubsystem(parentApp) -{ - app.outLog() << "Initialising effects subsystem" << std::endl; - - def_rs.depthtest = true; - - def_rs.lighting = true; - def_rs.lightmodeltwoside = false; - - def_rs.alphatest.func = GL_ALWAYS; - def_rs.alphatest.ref = 0.0; // not important for GL_ALWAYS anyway - - def_rs.cullface = CULLFACE_CW; - - def_rs.blendmode = BLEND_NONE; - - def_rs.texunit[0].texindex = -1; - - glGetIntegerv(GL_MAX_TEXTURE_UNITS, &max_tex_units); -} - -PSSEffect::~PSSEffect() -{ - app.outLog() << "Shutting down effects subsystem" << std::endl; - - fxlist.clear(); -} - - -PEffect *PSSEffect::loadEffect(const std::string &name) -{ - PEffect *fx = fxlist.find(name); - if (!fx) { - try - { - fx = new PEffect (name); - } - catch (PException e) - { - if (PUtil::isDebugLevel(DEBUGLEVEL_ENDUSER)) - PUtil::outLog() << "Failed to load " << name << ": " << e.what () << std::endl; - return null; - } - fx->setFirstValidTechnique(); - fxlist.add(fx); - } - return fx; -} - - -#define con_printf(...) - - - - -PEffect::~PEffect() -{ - unload (); -} - -void PEffect::unload() -{ - tex.clear (); - tech.clear (); -} - -PEffect::PEffect(const std::string &filename) -{ - cur_tech = -1; - - if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) - PUtil::outLog() << "Loading fx shader \"" << filename << "\"" << std::endl; - - unload(); - - //FILE *file = fopen(filename.c_str(),"rb"); - PHYSFS_file *pfile = PHYSFS_openRead(filename.c_str()); - if (pfile == null) { - con_printf("Cannot find effect file \"%s\"\n",filename); - throw MakePException ("PhysFS: " + PHYSFS_getLastError()); - } - - name = filename; - - int leng = PHYSFS_fileLength(pfile); - - char *source = new char [leng+1]; - - PHYSFS_read(pfile, source, leng, 1); - PHYSFS_close(pfile); - - source[leng] = '\0'; - - -#define SKIPWHITESPACE \ - while (*scan == ' ' || *scan == '\t' || *scan == '\n' || *scan == '\r') { \ - if (*scan == '\n') linec++; \ - scan++; \ - } - -#define READTOKEN \ - token = buff1; \ - if (*scan == '\"') { \ - scan++; \ - while ((*scan) && (*scan != '\"')) { \ - *(token++) = *(scan++); \ - } *token = '\0'; token = buff1; scan++; \ - } else { \ - while ((*scan >= 'a' && *scan <= 'z') || \ - (*scan >= 'A' && *scan <= 'Z') || \ - (*scan >= '0' && *scan <= '9') || \ - (*scan == '_')) { \ - *(token++) = *(scan++); \ - } *token = '\0'; token = buff1; \ - } - -#define READNUMERICALTOKEN \ - token = buff1; \ - while ((*scan >= '0' && *scan <= '9') || \ - (*scan == '-' || *scan == '.')) { \ - *(token++) = *(scan++); \ - } *token = '\0'; token = buff1; - - char buff1[512]; - char *scan = (char*)source; - char *token; - char detail[512] = "parse error"; - - int linec = 1; - bool parseerror = false; - - while (1) { - SKIPWHITESPACE; if (!*scan) break; - - READTOKEN; if (!*scan) { parseerror = true; break; } - - if (!strcmp(token, "texture")) { - tex.push_back(fx_texture_s()); - fx_texture_s *curtex = &tex.back(); - - curtex->texobject = null; - - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - - READTOKEN; if (!*scan) { parseerror = true; break; } - curtex->name = token; - - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan != '{') { parseerror = true; break; } - scan++; - - while (1) { - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan == '}') { scan++; break; } - - READTOKEN; if (!*scan) { parseerror = true; break; } - - // type = [ TEX_2D | TEX_3D | TEX_CUBE ]; - if (!strcmp(token, "type")) { - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan != '=') { parseerror = true; break; } - scan++; - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - READTOKEN; if (!*scan) { parseerror = true; break; } - if (!strcmp(token,"TEX_2D")) curtex->type = GL_TEXTURE_2D; - else if (!strcmp(token,"TEX_3D")) curtex->type = GL_TEXTURE_3D; - else if (!strcmp(token,"TEX_CUBE")) curtex->type = GL_TEXTURE_CUBE_MAP; - else { parseerror = true; break; } - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan != ';') { parseerror = true; break; } - scan++; - } else - // src = "blah.png"; - if (!strcmp(token, "src")) { - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan != '=') { parseerror = true; break; } - scan++; - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - READTOKEN; if (!*scan) { parseerror = true; break; } - curtex->filename = PUtil::assemblePath(token, filename); - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan != ';') { parseerror = true; break; } - scan++; - } else { - parseerror = true; break; - } - } - } else - if (!strcmp(token, "technique")) { - tech.push_back(fx_technique_s()); - fx_technique_s *curtech = &tech.back(); - - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - - READTOKEN; if (!*scan) { parseerror = true; break; } - curtech->name = token; - - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan != '{') { parseerror = true; break; } - scan++; - - while (1) { - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan == '}') { scan++; break; } - - READTOKEN; if (!*scan) { parseerror = true; break; } - - if (!strcmp(token, "pass")) { - curtech->pass.push_back(fx_pass_s()); - fx_pass_s *curpass = &curtech->pass.back(); - fx_renderstate_s *currs = &curpass->rs; - // set default render state for pass -#if 0 - if (curtech->pass.size() > 1) - *currs = curtech->pass[curtech->pass.size()-2].rs; - else - *currs = def_rs; -#else - *currs = def_rs; -#endif - - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan != '{') { parseerror = true; break; } - scan++; - - while (1) { - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan == '}') { scan++; break; } - - READTOKEN; if (!*scan) { parseerror = true; break; } - - // depthtest = [ true | false ]; - if (!strcmp(token, "depthtest")) { - //con_printf("depthtest\n"); - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan != '=') { parseerror = true; break; } - scan++; - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - READTOKEN; if (!*scan) { parseerror = true; break; } - if (0); - else if (!strcmp(token,"true")) currs->depthtest = true; - else if (!strcmp(token,"false")) currs->depthtest = false; - else { parseerror = true; break; } - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan != ';') { parseerror = true; break; } - scan++; - } else - // alphatest = { FUNC, value }; - if (!strcmp(token, "alphatest")) { - //con_printf("alphatest\n"); - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan != '=') { parseerror = true; break; } - scan++; - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan != '{') { parseerror = true; break; } - scan++; - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - READTOKEN; if (!*scan) { parseerror = true; break; } - if (0); - else if (!strcmp(token,"LESS")) currs->alphatest.func = GL_LESS; - else if (!strcmp(token,"EQUAL")) currs->alphatest.func = GL_EQUAL; - else if (!strcmp(token,"LEQUAL")) currs->alphatest.func = GL_LEQUAL; - else if (!strcmp(token,"GREATER")) currs->alphatest.func = GL_GREATER; - else if (!strcmp(token,"NOTEQUAL")) currs->alphatest.func = GL_NOTEQUAL; - else if (!strcmp(token,"GEQUAL")) currs->alphatest.func = GL_GEQUAL; - else if (!strcmp(token,"ALWAYS")) currs->alphatest.func = GL_ALWAYS; - else { strcpy(detail,"invalid alphatest func"); parseerror = true; break; } - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan != ',') { parseerror = true; break; } - scan++; - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - READNUMERICALTOKEN; if (!*scan) { parseerror = true; break; } - currs->alphatest.ref = atof(token); - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan != '}') { parseerror = true; break; } - scan++; - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan != ';') { parseerror = true; break; } - scan++; - } else - // cullface - if (!strcmp(token, "cullface")) { - //con_printf("cullface\n"); - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan != '=') { parseerror = true; break; } - scan++; - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - READTOKEN; if (!*scan) { parseerror = true; break; } - if (0); - else if (!strcmp(token,"NONE")) currs->cullface = CULLFACE_NONE; - else if (!strcmp(token,"CW")) currs->cullface = CULLFACE_CW; - else if (!strcmp(token,"CCW")) currs->cullface = CULLFACE_CCW; - else { strcpy(detail,"invalid cullface mode"); parseerror = true; break; } - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan != ';') { parseerror = true; break; } - scan++; - } else - // blendmode - if (!strcmp(token, "blendmode")) { - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan != '=') { parseerror = true; break; } - scan++; - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - READTOKEN; if (!*scan) { parseerror = true; break; } - if (0); - else if (!strcmp(token,"NONE")) currs->blendmode = BLEND_NONE; - else if (!strcmp(token,"ADD")) currs->blendmode = BLEND_ADD; - else if (!strcmp(token,"MULTIPLY")) currs->blendmode = BLEND_MULTIPLY; - else if (!strcmp(token,"ALPHA")) currs->blendmode = BLEND_ALPHA; - else if (!strcmp(token,"PREMULTALPHA")) currs->blendmode = BLEND_PREMULTALPHA; - else { strcpy(detail,"invalid blendmode mode"); parseerror = true; break; } - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan != ';') { parseerror = true; break; } - scan++; - } else - // texunit0 = ; - if (!strcmp(token, "texunit0")) { - //con_printf("texunit0\n"); - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan != '=') { parseerror = true; break; } - scan++; - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - READTOKEN; if (!*scan) { parseerror = true; break; } - unsigned int iter; - for (iter=0; itertexunit[0].texindex = iter; - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan != ';') { parseerror = true; break; } - scan++; - } else - if (!strcmp(token, "lighting")) { - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan != '=') { parseerror = true; break; } - scan++; - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - READTOKEN; if (!*scan) { parseerror = true; break; } - if (0); - else if (!strcmp(token,"true")) currs->lighting = true; - else if (!strcmp(token,"false")) currs->lighting = false; - else { parseerror = true; break; } - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan != ';') { parseerror = true; break; } - scan++; - } else - if (!strcmp(token, "lightmodeltwoside")) { - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan != '=') { parseerror = true; break; } - scan++; - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - READTOKEN; if (!*scan) { parseerror = true; break; } - if (0); - else if (!strcmp(token,"true")) currs->lightmodeltwoside = true; - else if (!strcmp(token,"false")) currs->lightmodeltwoside = false; - else { parseerror = true; break; } - SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } - if (*scan != ';') { parseerror = true; break; } - scan++; - } else - { - strcpy(detail,"invalid render state"); - parseerror = true; break; - } - } - } else { - parseerror = true; break; - } - if (parseerror) break; - } - } else { - parseerror = true; break; - } - if (parseerror) break; - } - - delete [] source; - - if (parseerror) { - con_printf("\"%s\": error at line %i : %s\n",name.c_str(),linec,detail); - //*scan = '\0'; - //con_printf("[%s]\n",source); - unload(); - throw MakePException (name + ": error at line " + PUtil::formatInt (linec) + " : " + detail); - } - - con_printf("Load complete\n"); -} - -int PEffect::getNumTechniques() -{ - return tech.size(); -} - -bool PEffect::validateTechnique(int technique) -{ - // todo: determine real validity - - // even for fixed-function, this includes (eg) tex unit count - - if (technique >= 0 && technique < (int)tech.size()) { - tech[technique].validated = true; - return tech[technique].validated; - } else { - return false; - } -} - -const std::string &PEffect::getTechniqueName(int technique) -{ - static std::string notfound = "[invalid technique index]"; - if (technique >= 0 && technique < (int)tech.size()) { - return tech[technique].name; - } else { - return notfound; - } -} - -bool PEffect::findTechnique(const std::string &techname, int *technique) -{ - for (unsigned int i=0; i= 0 && technique < (int)tech.size()) { - if (tech[technique].validated) { - cur_tech = technique; - return true; - } else { - con_printf("Effect::setCurrentTechnique(): technique not validated\n"); - return false; - } - } else { - con_printf("Effect::setCurrentTechnique(): invalid technique index\n"); - return false; - } -} - -int PEffect::getCurrentTechnique() -{ - return cur_tech; -} - -bool PEffect::setFirstValidTechnique() -{ - for (int i=0; itextures_ready) { - for (unsigned int i=0; ipass.size(); i++) { - int texindex = curtech->pass[i].rs.texunit[0].texindex; - if (texindex != -1 && !tex[texindex].texobject) - tex[texindex].texobject = sstex.loadTexture(tex[texindex].filename); - } - curtech->textures_ready = true; - } - - if (numPasses) *numPasses = curtech->pass.size(); - - return true; -} - -// utility func to set GL state -void PEffect::migrateRenderState(fx_renderstate_s *rs_old, fx_renderstate_s *rs_new) -{ - if (rs_old->depthtest != rs_new->depthtest) { - if (rs_new->depthtest) glEnable(GL_DEPTH_TEST); - else glDisable(GL_DEPTH_TEST); - } - - if (rs_old->lighting != rs_new->lighting) { - if (rs_new->lighting) glEnable(GL_LIGHTING); - else glDisable(GL_LIGHTING); - } - - if (rs_old->lightmodeltwoside != rs_new->lightmodeltwoside) { - glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, rs_new->lightmodeltwoside ? GL_TRUE : GL_FALSE); - } - - if (rs_old->alphatest.func != rs_new->alphatest.func || - (rs_new->alphatest.func != GL_ALWAYS && - rs_old->alphatest.ref != rs_new->alphatest.ref)) { - if (rs_old->alphatest.func == GL_ALWAYS) { - // enabling alpha test - glEnable(GL_ALPHA_TEST); - glAlphaFunc(rs_new->alphatest.func, rs_new->alphatest.ref); - } else if (rs_new->alphatest.func == GL_ALWAYS) { - // disabling alpha test - glDisable(GL_ALPHA_TEST); - } else { - // changing alpha test - glAlphaFunc(rs_new->alphatest.func, rs_new->alphatest.ref); - } - } - - if (rs_old->cullface != rs_new->cullface) { - if (rs_old->cullface == CULLFACE_NONE) { - glEnable(GL_CULL_FACE); - glCullFace(rs_new->cullface == CULLFACE_CW ? GL_BACK : GL_FRONT); - } else if (rs_new->cullface == CULLFACE_NONE) { - glDisable(GL_CULL_FACE); - } else { - glCullFace(rs_new->cullface == CULLFACE_CW ? GL_BACK : GL_FRONT); - } - } - - if (rs_old->blendmode != rs_new->blendmode) { - switch (rs_new->blendmode) { - default: - glBlendFunc(GL_ONE,GL_ZERO); - break; - case BLEND_ADD: - glBlendFunc(GL_ONE,GL_ONE); - break; - case BLEND_MULTIPLY: - glBlendFunc(GL_DST_COLOR,GL_SRC_COLOR); - break; - case BLEND_ALPHA: - glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); - break; - case BLEND_PREMULTALPHA: - glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA); - break; - } - } - - int texindex = rs_new->texunit[0].texindex; - if (texindex != -1 && tex[texindex].texobject) - tex[texindex].texobject->bind(); - else - PTexture::unbind(); -} - -void PEffect::renderPass(int pass) -{ - // assume pass is valid - - if (pass == 0) - migrateRenderState(&def_rs, - &tech[cur_tech].pass[0].rs); - else - migrateRenderState(&tech[cur_tech].pass[pass-1].rs, - &tech[cur_tech].pass[pass].rs); -} - -void PEffect::renderEnd() -{ - migrateRenderState(&tech[cur_tech].pass.back().rs, - &def_rs); -} - - - - - - + +// fxman.cpp [pengine] + +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net +// License: GPL version 2 (see included gpl.txt) + + +#include "pengine.h" + + +fx_renderstate_s def_rs; + + +int max_tex_units; + + + +PSSEffect::PSSEffect(PApp &parentApp) : PSubsystem(parentApp) +{ + app.outLog() << "Initialising effects subsystem" << std::endl; + + def_rs.depthtest = true; + + def_rs.lighting = true; + def_rs.lightmodeltwoside = false; + + def_rs.alphatest.func = GL_ALWAYS; + def_rs.alphatest.ref = 0.0; // not important for GL_ALWAYS anyway + + def_rs.cullface = CULLFACE_CW; + + def_rs.blendmode = BLEND_NONE; + + def_rs.texunit[0].texindex = -1; + + glGetIntegerv(GL_MAX_TEXTURE_UNITS, &max_tex_units); +} + +PSSEffect::~PSSEffect() +{ + app.outLog() << "Shutting down effects subsystem" << std::endl; + + fxlist.clear(); +} + + +PEffect *PSSEffect::loadEffect(const std::string &name) +{ + PEffect *fx = fxlist.find(name); + if (!fx) { + try + { + fx = new PEffect (name); + } + catch (PException e) + { + if (PUtil::isDebugLevel(DEBUGLEVEL_ENDUSER)) + PUtil::outLog() << "Failed to load " << name << ": " << e.what () << std::endl; + return null; + } + fx->setFirstValidTechnique(); + fxlist.add(fx); + } + return fx; +} + + +#define con_printf(...) + + + + +PEffect::~PEffect() +{ + unload (); +} + +void PEffect::unload() +{ + tex.clear (); + tech.clear (); +} + +PEffect::PEffect(const std::string &filename) +{ + cur_tech = -1; + + if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) + PUtil::outLog() << "Loading fx shader \"" << filename << "\"" << std::endl; + + unload(); + + //FILE *file = fopen(filename.c_str(),"rb"); + PHYSFS_file *pfile = PHYSFS_openRead(filename.c_str()); + if (pfile == null) { + con_printf("Cannot find effect file \"%s\"\n",filename); + throw MakePException ("PhysFS: " + PHYSFS_getLastError()); + } + + name = filename; + + int leng = PHYSFS_fileLength(pfile); + + char *source = new char [leng+1]; + + PHYSFS_read(pfile, source, leng, 1); + PHYSFS_close(pfile); + + source[leng] = '\0'; + + +#define SKIPWHITESPACE \ + while (*scan == ' ' || *scan == '\t' || *scan == '\n' || *scan == '\r') { \ + if (*scan == '\n') linec++; \ + scan++; \ + } + +#define READTOKEN \ + token = buff1; \ + if (*scan == '\"') { \ + scan++; \ + while ((*scan) && (*scan != '\"')) { \ + *(token++) = *(scan++); \ + } *token = '\0'; token = buff1; scan++; \ + } else { \ + while ((*scan >= 'a' && *scan <= 'z') || \ + (*scan >= 'A' && *scan <= 'Z') || \ + (*scan >= '0' && *scan <= '9') || \ + (*scan == '_')) { \ + *(token++) = *(scan++); \ + } *token = '\0'; token = buff1; \ + } + +#define READNUMERICALTOKEN \ + token = buff1; \ + while ((*scan >= '0' && *scan <= '9') || \ + (*scan == '-' || *scan == '.')) { \ + *(token++) = *(scan++); \ + } *token = '\0'; token = buff1; + + char buff1[512]; + char *scan = (char*)source; + char *token; + char detail[512] = "parse error"; + + int linec = 1; + bool parseerror = false; + + while (1) { + SKIPWHITESPACE; if (!*scan) break; + + READTOKEN; if (!*scan) { parseerror = true; break; } + + if (!strcmp(token, "texture")) { + tex.push_back(fx_texture_s()); + fx_texture_s *curtex = &tex.back(); + + curtex->texobject = null; + + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + + READTOKEN; if (!*scan) { parseerror = true; break; } + curtex->name = token; + + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan != '{') { parseerror = true; break; } + scan++; + + while (1) { + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan == '}') { scan++; break; } + + READTOKEN; if (!*scan) { parseerror = true; break; } + + // type = [ TEX_2D | TEX_3D | TEX_CUBE ]; + if (!strcmp(token, "type")) { + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan != '=') { parseerror = true; break; } + scan++; + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + READTOKEN; if (!*scan) { parseerror = true; break; } + if (!strcmp(token,"TEX_2D")) curtex->type = GL_TEXTURE_2D; + else if (!strcmp(token,"TEX_3D")) curtex->type = GL_TEXTURE_3D; + else if (!strcmp(token,"TEX_CUBE")) curtex->type = GL_TEXTURE_CUBE_MAP; + else { parseerror = true; break; } + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan != ';') { parseerror = true; break; } + scan++; + } else + // src = "blah.png"; + if (!strcmp(token, "src")) { + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan != '=') { parseerror = true; break; } + scan++; + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + READTOKEN; if (!*scan) { parseerror = true; break; } + curtex->filename = PUtil::assemblePath(token, filename); + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan != ';') { parseerror = true; break; } + scan++; + } else { + parseerror = true; break; + } + } + } else + if (!strcmp(token, "technique")) { + tech.push_back(fx_technique_s()); + fx_technique_s *curtech = &tech.back(); + + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + + READTOKEN; if (!*scan) { parseerror = true; break; } + curtech->name = token; + + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan != '{') { parseerror = true; break; } + scan++; + + while (1) { + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan == '}') { scan++; break; } + + READTOKEN; if (!*scan) { parseerror = true; break; } + + if (!strcmp(token, "pass")) { + curtech->pass.push_back(fx_pass_s()); + fx_pass_s *curpass = &curtech->pass.back(); + fx_renderstate_s *currs = &curpass->rs; + // set default render state for pass +#if 0 + if (curtech->pass.size() > 1) + *currs = curtech->pass[curtech->pass.size()-2].rs; + else + *currs = def_rs; +#else + *currs = def_rs; +#endif + + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan != '{') { parseerror = true; break; } + scan++; + + while (1) { + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan == '}') { scan++; break; } + + READTOKEN; if (!*scan) { parseerror = true; break; } + + // depthtest = [ true | false ]; + if (!strcmp(token, "depthtest")) { + //con_printf("depthtest\n"); + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan != '=') { parseerror = true; break; } + scan++; + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + READTOKEN; if (!*scan) { parseerror = true; break; } + if (0); + else if (!strcmp(token,"true")) currs->depthtest = true; + else if (!strcmp(token,"false")) currs->depthtest = false; + else { parseerror = true; break; } + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan != ';') { parseerror = true; break; } + scan++; + } else + // alphatest = { FUNC, value }; + if (!strcmp(token, "alphatest")) { + //con_printf("alphatest\n"); + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan != '=') { parseerror = true; break; } + scan++; + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan != '{') { parseerror = true; break; } + scan++; + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + READTOKEN; if (!*scan) { parseerror = true; break; } + if (0); + else if (!strcmp(token,"LESS")) currs->alphatest.func = GL_LESS; + else if (!strcmp(token,"EQUAL")) currs->alphatest.func = GL_EQUAL; + else if (!strcmp(token,"LEQUAL")) currs->alphatest.func = GL_LEQUAL; + else if (!strcmp(token,"GREATER")) currs->alphatest.func = GL_GREATER; + else if (!strcmp(token,"NOTEQUAL")) currs->alphatest.func = GL_NOTEQUAL; + else if (!strcmp(token,"GEQUAL")) currs->alphatest.func = GL_GEQUAL; + else if (!strcmp(token,"ALWAYS")) currs->alphatest.func = GL_ALWAYS; + else { strcpy(detail,"invalid alphatest func"); parseerror = true; break; } + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan != ',') { parseerror = true; break; } + scan++; + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + READNUMERICALTOKEN; if (!*scan) { parseerror = true; break; } + currs->alphatest.ref = atof(token); + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan != '}') { parseerror = true; break; } + scan++; + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan != ';') { parseerror = true; break; } + scan++; + } else + // cullface + if (!strcmp(token, "cullface")) { + //con_printf("cullface\n"); + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan != '=') { parseerror = true; break; } + scan++; + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + READTOKEN; if (!*scan) { parseerror = true; break; } + if (0); + else if (!strcmp(token,"NONE")) currs->cullface = CULLFACE_NONE; + else if (!strcmp(token,"CW")) currs->cullface = CULLFACE_CW; + else if (!strcmp(token,"CCW")) currs->cullface = CULLFACE_CCW; + else { strcpy(detail,"invalid cullface mode"); parseerror = true; break; } + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan != ';') { parseerror = true; break; } + scan++; + } else + // blendmode + if (!strcmp(token, "blendmode")) { + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan != '=') { parseerror = true; break; } + scan++; + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + READTOKEN; if (!*scan) { parseerror = true; break; } + if (0); + else if (!strcmp(token,"NONE")) currs->blendmode = BLEND_NONE; + else if (!strcmp(token,"ADD")) currs->blendmode = BLEND_ADD; + else if (!strcmp(token,"MULTIPLY")) currs->blendmode = BLEND_MULTIPLY; + else if (!strcmp(token,"ALPHA")) currs->blendmode = BLEND_ALPHA; + else if (!strcmp(token,"PREMULTALPHA")) currs->blendmode = BLEND_PREMULTALPHA; + else { strcpy(detail,"invalid blendmode mode"); parseerror = true; break; } + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan != ';') { parseerror = true; break; } + scan++; + } else + // texunit0 = ; + if (!strcmp(token, "texunit0")) { + //con_printf("texunit0\n"); + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan != '=') { parseerror = true; break; } + scan++; + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + READTOKEN; if (!*scan) { parseerror = true; break; } + unsigned int iter; + for (iter=0; itertexunit[0].texindex = iter; + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan != ';') { parseerror = true; break; } + scan++; + } else + if (!strcmp(token, "lighting")) { + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan != '=') { parseerror = true; break; } + scan++; + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + READTOKEN; if (!*scan) { parseerror = true; break; } + if (0); + else if (!strcmp(token,"true")) currs->lighting = true; + else if (!strcmp(token,"false")) currs->lighting = false; + else { parseerror = true; break; } + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan != ';') { parseerror = true; break; } + scan++; + } else + if (!strcmp(token, "lightmodeltwoside")) { + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan != '=') { parseerror = true; break; } + scan++; + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + READTOKEN; if (!*scan) { parseerror = true; break; } + if (0); + else if (!strcmp(token,"true")) currs->lightmodeltwoside = true; + else if (!strcmp(token,"false")) currs->lightmodeltwoside = false; + else { parseerror = true; break; } + SKIPWHITESPACE; if (!*scan) { parseerror = true; break; } + if (*scan != ';') { parseerror = true; break; } + scan++; + } else + { + strcpy(detail,"invalid render state"); + parseerror = true; break; + } + } + } else { + parseerror = true; break; + } + if (parseerror) break; + } + } else { + parseerror = true; break; + } + if (parseerror) break; + } + + delete [] source; + + if (parseerror) { + con_printf("\"%s\": error at line %i : %s\n",name.c_str(),linec,detail); + //*scan = '\0'; + //con_printf("[%s]\n",source); + unload(); + throw MakePException (name + ": error at line " + PUtil::formatInt (linec) + " : " + detail); + } + + con_printf("Load complete\n"); +} + +int PEffect::getNumTechniques() +{ + return tech.size(); +} + +bool PEffect::validateTechnique(int technique) +{ + // todo: determine real validity + + // even for fixed-function, this includes (eg) tex unit count + + if (technique >= 0 && technique < (int)tech.size()) { + tech[technique].validated = true; + return tech[technique].validated; + } else { + return false; + } +} + +const std::string &PEffect::getTechniqueName(int technique) +{ + static std::string notfound = "[invalid technique index]"; + if (technique >= 0 && technique < (int)tech.size()) { + return tech[technique].name; + } else { + return notfound; + } +} + +bool PEffect::findTechnique(const std::string &techname, int *technique) +{ + for (unsigned int i=0; i= 0 && technique < (int)tech.size()) { + if (tech[technique].validated) { + cur_tech = technique; + return true; + } else { + con_printf("Effect::setCurrentTechnique(): technique not validated\n"); + return false; + } + } else { + con_printf("Effect::setCurrentTechnique(): invalid technique index\n"); + return false; + } +} + +int PEffect::getCurrentTechnique() +{ + return cur_tech; +} + +bool PEffect::setFirstValidTechnique() +{ + for (int i=0; itextures_ready) { + for (unsigned int i=0; ipass.size(); i++) { + int texindex = curtech->pass[i].rs.texunit[0].texindex; + if (texindex != -1 && !tex[texindex].texobject) + tex[texindex].texobject = sstex.loadTexture(tex[texindex].filename); + } + curtech->textures_ready = true; + } + + if (numPasses) *numPasses = curtech->pass.size(); + + return true; +} + +// utility func to set GL state +void PEffect::migrateRenderState(fx_renderstate_s *rs_old, fx_renderstate_s *rs_new) +{ + if (rs_old->depthtest != rs_new->depthtest) { + if (rs_new->depthtest) glEnable(GL_DEPTH_TEST); + else glDisable(GL_DEPTH_TEST); + } + + if (rs_old->lighting != rs_new->lighting) { + if (rs_new->lighting) glEnable(GL_LIGHTING); + else glDisable(GL_LIGHTING); + } + + if (rs_old->lightmodeltwoside != rs_new->lightmodeltwoside) { + glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, rs_new->lightmodeltwoside ? GL_TRUE : GL_FALSE); + } + + if (rs_old->alphatest.func != rs_new->alphatest.func || + (rs_new->alphatest.func != GL_ALWAYS && + rs_old->alphatest.ref != rs_new->alphatest.ref)) { + if (rs_old->alphatest.func == GL_ALWAYS) { + // enabling alpha test + glEnable(GL_ALPHA_TEST); + glAlphaFunc(rs_new->alphatest.func, rs_new->alphatest.ref); + } else if (rs_new->alphatest.func == GL_ALWAYS) { + // disabling alpha test + glDisable(GL_ALPHA_TEST); + } else { + // changing alpha test + glAlphaFunc(rs_new->alphatest.func, rs_new->alphatest.ref); + } + } + + if (rs_old->cullface != rs_new->cullface) { + if (rs_old->cullface == CULLFACE_NONE) { + glEnable(GL_CULL_FACE); + glCullFace(rs_new->cullface == CULLFACE_CW ? GL_BACK : GL_FRONT); + } else if (rs_new->cullface == CULLFACE_NONE) { + glDisable(GL_CULL_FACE); + } else { + glCullFace(rs_new->cullface == CULLFACE_CW ? GL_BACK : GL_FRONT); + } + } + + if (rs_old->blendmode != rs_new->blendmode) { + switch (rs_new->blendmode) { + default: + glBlendFunc(GL_ONE,GL_ZERO); + break; + case BLEND_ADD: + glBlendFunc(GL_ONE,GL_ONE); + break; + case BLEND_MULTIPLY: + glBlendFunc(GL_DST_COLOR,GL_SRC_COLOR); + break; + case BLEND_ALPHA: + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + break; + case BLEND_PREMULTALPHA: + glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA); + break; + } + } + + int texindex = rs_new->texunit[0].texindex; + if (texindex != -1 && tex[texindex].texobject) + tex[texindex].texobject->bind(); + else + PTexture::unbind(); +} + +void PEffect::renderPass(int pass) +{ + // assume pass is valid + + if (pass == 0) + migrateRenderState(&def_rs, + &tech[cur_tech].pass[0].rs); + else + migrateRenderState(&tech[cur_tech].pass[pass-1].rs, + &tech[cur_tech].pass[pass].rs); +} + +void PEffect::renderEnd() +{ + migrateRenderState(&tech[cur_tech].pass.back().rs, + &def_rs); +} + + + + + + diff -Nru trigger-rally-0.5.2.1/src/pengine/model.cpp trigger-rally-0.6.0/src/pengine/model.cpp --- trigger-rally-0.5.2.1/src/pengine/model.cpp 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/pengine/model.cpp 2011-10-07 17:10:01.000000000 +0000 @@ -1,7 +1,7 @@ // model.cpp [pengine] -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net // License: GPL version 2 (see included gpl.txt) @@ -10,34 +10,34 @@ PSSModel::PSSModel(PApp &parentApp) : PSubsystem(parentApp) { - app.outLog() << "Initialising model subsystem" << std::endl; + app.outLog() << "Initialising model subsystem" << std::endl; } PSSModel::~PSSModel() { - app.outLog() << "Shutting down model subsystem" << std::endl; + app.outLog() << "Shutting down model subsystem" << std::endl; - modlist.clear(); + modlist.clear(); } PModel *PSSModel::loadModel(const std::string &name) { - PModel *mdl = modlist.find(name); - if (!mdl) { - try - { - mdl = new PModel (name); - } - catch (PException e) - { - if (PUtil::isDebugLevel(DEBUGLEVEL_ENDUSER)) - PUtil::outLog() << "Failed to load " << name << ": " << e.what () << std::endl; - return null; - } - modlist.add(mdl); - } - return mdl; + PModel *mdl = modlist.find(name); + if (!mdl) { + try + { + mdl = new PModel (name); + } + catch (PException e) + { + if (PUtil::isDebugLevel(DEBUGLEVEL_ENDUSER)) + PUtil::outLog() << "Failed to load " << name << ": " << e.what () << std::endl; + return null; + } + modlist.add(mdl); + } + return mdl; } @@ -47,68 +47,68 @@ char *strtok2(char *input) { - static char *inputstore = null; + static char *inputstore = null; - if (input != null) inputstore = input; + if (input != null) inputstore = input; - if (!inputstore) return null; + if (!inputstore) return null; - // eat whitespace - while (*inputstore == ' ' || *inputstore == '\t' || *inputstore == '\n' || *inputstore == '\r') inputstore++; + // eat whitespace + while (*inputstore == ' ' || *inputstore == '\t' || *inputstore == '\n' || *inputstore == '\r') inputstore++; - char *tokstart = inputstore; - - if (*inputstore == '\"') { - tokstart++; inputstore++; - while ((*inputstore)) { - if (*inputstore == '\"') { - *inputstore = 0; - inputstore++; - break; - } - inputstore++; - } - } else { - while ((*inputstore)) { - if (*inputstore == ' ' || *inputstore == '\t' || *inputstore == '\n' || *inputstore == '\r') break; - inputstore++; - } - } - - if (*inputstore) { - char *nullout = inputstore; - // eat whitespace - while (*inputstore == ' ' || *inputstore == '\t' || *inputstore == '\n' || *inputstore == '\r') inputstore++; - *nullout = 0; - if (!*inputstore) - inputstore = null; - } else { - inputstore = null; - } + char *tokstart = inputstore; + + if (*inputstore == '\"') { + tokstart++; inputstore++; + while ((*inputstore)) { + if (*inputstore == '\"') { + *inputstore = 0; + inputstore++; + break; + } + inputstore++; + } + } else { + while ((*inputstore)) { + if (*inputstore == ' ' || *inputstore == '\t' || *inputstore == '\n' || *inputstore == '\r') break; + inputstore++; + } + } + + if (*inputstore) { + char *nullout = inputstore; + // eat whitespace + while (*inputstore == ' ' || *inputstore == '\t' || *inputstore == '\n' || *inputstore == '\r') inputstore++; + *nullout = 0; + if (!*inputstore) + inputstore = null; + } else { + inputstore = null; + } - return tokstart; + return tokstart; } char *fgets2 (char *s, int size, PHYSFS_file *pfile) { - int i; - for (i = 0; i < size-1; i++) { - - // check for EOF - if (PHYSFS_eof(pfile)) return null; - - int ret = PHYSFS_read(pfile, s + i, 1, 1); - - if (s[i] == '\n') break; - - if (ret == -1) return null; // major error - if (ret == 0) { i--; break; } // er, must be end of file anyway - } - - s[i+1] = '\0'; - - return s; + int i; + for (i = 0; i < size-1; i++) { + + // check for EOF + if (PHYSFS_eof(pfile)) return null; + + int ret = PHYSFS_read(pfile, s + i, 1, 1); + + if (s[i] == '\n') break; + + if (ret == -1) return null; // major error + if (ret == 0) { i--; break; } // er, must be end of file anyway + } + + s[i+1] = '\0'; + + return s; } // PModel @@ -117,284 +117,284 @@ std::pair PModel::getExtents() const { - vec3f v_min(1000000000.0, 1000000000.0, 1000000000.0), - v_max(-1000000000.0, -1000000000.0, -1000000000.0); + vec3f v_min(1000000000.0, 1000000000.0, 1000000000.0), + v_max(-1000000000.0, -1000000000.0, -1000000000.0); - for (unsigned int a=0; a mesh[a].vert[b].x) - v_min.x = mesh[a].vert[b].x; - if (v_max.x < mesh[a].vert[b].x) - v_max.x = mesh[a].vert[b].x; - if (v_min.y > mesh[a].vert[b].y) - v_min.y = mesh[a].vert[b].y; - if (v_max.y < mesh[a].vert[b].y) - v_max.y = mesh[a].vert[b].y; - if (v_min.z > mesh[a].vert[b].z) - v_min.z = mesh[a].vert[b].z; - if (v_max.z < mesh[a].vert[b].z) - v_max.z = mesh[a].vert[b].z; - } - } + for (unsigned int a=0; a mesh[a].vert[b].x) + v_min.x = mesh[a].vert[b].x; + if (v_max.x < mesh[a].vert[b].x) + v_max.x = mesh[a].vert[b].x; + if (v_min.y > mesh[a].vert[b].y) + v_min.y = mesh[a].vert[b].y; + if (v_max.y < mesh[a].vert[b].y) + v_max.y = mesh[a].vert[b].y; + if (v_min.z > mesh[a].vert[b].z) + v_min.z = mesh[a].vert[b].z; + if (v_max.z < mesh[a].vert[b].z) + v_max.z = mesh[a].vert[b].z; + } + } - return std::pair (v_min, v_max); + return std::pair (v_min, v_max); } struct matl_s { - std::string filename; + std::string filename; }; PModel::PModel (const std::string &filename, float globalScale) { - loadASE (filename, globalScale); + loadASE (filename, globalScale); } void PModel::loadASE (const std::string &filename, float globalScale) { - if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) - PUtil::outLog() << "Loading model \"" << filename << "\"" << std::endl; + if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) + PUtil::outLog() << "Loading model \"" << filename << "\"" << std::endl; - PHYSFS_file *pfile = PHYSFS_openRead(filename.c_str()); - if (pfile == null) { - throw MakePException (filename + ", PhysFS: " + PHYSFS_getLastError()); - } + PHYSFS_file *pfile = PHYSFS_openRead(filename.c_str()); + if (pfile == null) { + throw MakePException (filename + ", PhysFS: " + PHYSFS_getLastError()); + } - std::vector matlist; + std::vector matlist; - char buff[1000],buff2[1000],buff3[1000]; - std::vector tok; + char buff[1000],buff2[1000],buff3[1000]; + std::vector tok; - int unknowndepth = 0; + int unknowndepth = 0; #define TOKENIZE_LINE_AND_CHECK \ - { \ - char *thistok; \ - tok.clear(); \ - thistok = strtok2(buff); \ - while (thistok) { \ - tok.push_back(thistok); \ - thistok = strtok2(NULL); \ - } \ - } \ - if (!tok.size()) continue; \ - if (unknowndepth > 0) { \ - if (!strcmp(tok[0],"}")) \ - unknowndepth--; \ - continue; \ - } - - while (fgets2(buff,1000,pfile)) { - dcon_printf("\"%s\"
\n",buff); - TOKENIZE_LINE_AND_CHECK - if (tok.size() == 2 && !strcmp(tok[1],"{")) { - if (!strcmp(tok[0],"*MATERIAL_LIST")) { - dcon_printf("*MATERIAL_LIST
\n"); - while (fgets2(buff,1000,pfile)) { - strcpy(buff2,buff); - TOKENIZE_LINE_AND_CHECK - if (!strcmp(tok[0],"}")) break; + { \ + char *thistok; \ + tok.clear(); \ + thistok = strtok2(buff); \ + while (thistok) { \ + tok.push_back(thistok); \ + thistok = strtok2(NULL); \ + } \ + } \ + if (!tok.size()) continue; \ + if (unknowndepth > 0) { \ + if (!strcmp(tok[0],"}")) \ + unknowndepth--; \ + continue; \ + } + + while (fgets2(buff,1000,pfile)) { + dcon_printf("\"%s\"
\n",buff); + TOKENIZE_LINE_AND_CHECK + if (tok.size() == 2 && !strcmp(tok[1],"{")) { + if (!strcmp(tok[0],"*MATERIAL_LIST")) { + dcon_printf("*MATERIAL_LIST
\n"); + while (fgets2(buff,1000,pfile)) { + strcpy(buff2,buff); + TOKENIZE_LINE_AND_CHECK + if (!strcmp(tok[0],"}")) break; #if 0 - if (!strcmp(tok[0],"*MATERIAL")) { - dcon_printf("*MATERIAL
\n"); - int matind = atoi(tok[1]); - dcon_printf("index = %i, matlist.size() = %i
\n",matind,matlist.size()); - if (matind < 0) continue; - if (matind >= matlist.size()) matlist.resize(matind+1); - while (fgets2(buff,1000,pfile)) { - strcpy(buff2,buff); - TOKENIZE_LINE_AND_CHECK - if (!strcmp(tok[0],"}")) break; - if (!strcmp(tok[0],"*MAP_DIFFUSE")) { - dcon_printf("*MAP_DIFFUSE
\n"); - while (fgets2(buff,1000,pfile)) { - strcpy(buff2,buff); - TOKENIZE_LINE_AND_CHECK - if (!strcmp(tok[0],"}")) break; - if (sscanf(buff2," *BITMAP \"%[^\"]\"",buff3) == 1) { - matlist[matind].filename = PUtil::assemblePath(buff3, filename); - } - } - } - } - } + if (!strcmp(tok[0],"*MATERIAL")) { + dcon_printf("*MATERIAL
\n"); + int matind = atoi(tok[1]); + dcon_printf("index = %i, matlist.size() = %i
\n",matind,matlist.size()); + if (matind < 0) continue; + if (matind >= matlist.size()) matlist.resize(matind+1); + while (fgets2(buff,1000,pfile)) { + strcpy(buff2,buff); + TOKENIZE_LINE_AND_CHECK + if (!strcmp(tok[0],"}")) break; + if (!strcmp(tok[0],"*MAP_DIFFUSE")) { + dcon_printf("*MAP_DIFFUSE
\n"); + while (fgets2(buff,1000,pfile)) { + strcpy(buff2,buff); + TOKENIZE_LINE_AND_CHECK + if (!strcmp(tok[0],"}")) break; + if (sscanf(buff2," *BITMAP \"%[^\"]\"",buff3) == 1) { + matlist[matind].filename = PUtil::assemblePath(buff3, filename); + } + } + } + } + } #else - unsigned int matind; - if (sscanf(buff2," *MATERIAL %u \"%[^\"]\"",&matind,buff3) == 2) { - //if (matind >= 0) { - if (matind >= matlist.size()) matlist.resize(matind+1); - matlist[matind].filename = PUtil::assemblePath(buff3, filename); - //} - } + unsigned int matind; + if (sscanf(buff2," *MATERIAL %u \"%[^\"]\"",&matind,buff3) == 2) { + //if (matind >= 0) { + if (matind >= matlist.size()) matlist.resize(matind+1); + matlist[matind].filename = PUtil::assemblePath(buff3, filename); + //} + } #endif - } - } else if (!strcmp(tok[0],"*GEOMOBJECT")) { - dcon_printf("*GEOMOBJECT
\n"); - vec3f tm[4]; - int tempi; - PMesh *curmesh = null; - tm[0] = vec3f(1,0,0); - tm[1] = vec3f(0,1,0); - tm[2] = vec3f(0,0,1); - tm[3] = vec3f::zero(); + } + } else if (!strcmp(tok[0],"*GEOMOBJECT")) { + dcon_printf("*GEOMOBJECT
\n"); + vec3f tm[4]; + int tempi; + PMesh *curmesh = null; + tm[0] = vec3f(1,0,0); + tm[1] = vec3f(0,1,0); + tm[2] = vec3f(0,0,1); + tm[3] = vec3f::zero(); #define DO_TM2(v) (vec3f((v)*tm[0],(v)*tm[1],(v)*tm[2])) - while (fgets2(buff,1000,pfile)) { - strcpy(buff2,buff); - TOKENIZE_LINE_AND_CHECK - if (!strcmp(tok[0],"}")) break; - if (tok.size() == 2 && !strcmp(tok[1],"{")) { - if (!strcmp(tok[0],"*MESH")) { - dcon_printf("*MESH
\n"); - mesh.push_back(PMesh()); - curmesh = &mesh.back(); - curmesh->effect = null; - while (fgets2(buff,1000,pfile)) { - TOKENIZE_LINE_AND_CHECK - if (!strcmp(tok[0],"}")) break; - if (tok.size() == 2 && !strcmp(tok[1],"{")) { - if (!strcmp(tok[0],"*MESH_VERTEX_LIST")) { - unsigned int vnum; - vec3f vpos; - while (fgets2(buff,1000,pfile)) { - strcpy(buff2,buff); - TOKENIZE_LINE_AND_CHECK - if (!strcmp(tok[0],"}")) break; - if (sscanf(buff2," *MESH_VERTEX %i %f %f %f",&vnum,&vpos.x,&vpos.y,&vpos.z) == 4) { - if (vnum < curmesh->vert.size()) - curmesh->vert[vnum] = vpos * globalScale; - } - } - } else if (!strcmp(tok[0],"*MESH_TVERTLIST")) { - unsigned int vnum; - vec2f vco; - while (fgets2(buff,1000,pfile)) { - strcpy(buff2,buff); - TOKENIZE_LINE_AND_CHECK - if (!strcmp(tok[0],"}")) break; - if (sscanf(buff2," *MESH_TVERT %i %f %f",&vnum,&vco.x,&vco.y) == 3) { - if (vnum < curmesh->texco.size()) { - curmesh->texco[vnum] = vco; - //curmesh->texco[vnum].y *= -1.0; - } - } - } - } else if (!strcmp(tok[0],"*MESH_FACE_LIST")) { - unsigned int fnum; - int fvt[3]; - while (fgets2(buff,1000,pfile)) { - strcpy(buff2,buff); - TOKENIZE_LINE_AND_CHECK - if (!strcmp(tok[0],"}")) break; - if (sscanf(buff2," *MESH_FACE %i: A: %i B: %i C: %i",&fnum,&fvt[0],&fvt[1],&fvt[2]) == 4) { - if (fnum < curmesh->face.size()) { - curmesh->face[fnum].vt[0] = fvt[0]; - curmesh->face[fnum].vt[1] = fvt[1]; - curmesh->face[fnum].vt[2] = fvt[2]; - } - } - } - } else if (!strcmp(tok[0],"*MESH_TFACELIST")) { - unsigned int fnum; - int fvt[3]; - while (fgets2(buff,1000,pfile)) { - strcpy(buff2,buff); - TOKENIZE_LINE_AND_CHECK - if (!strcmp(tok[0],"}")) break; - if (sscanf(buff2," *MESH_TFACE %i %i %i %i",&fnum,&fvt[0],&fvt[1],&fvt[2]) == 4) { - if (fnum < curmesh->face.size()) { - curmesh->face[fnum].tc[0] = fvt[0]; - curmesh->face[fnum].tc[1] = fvt[1]; - curmesh->face[fnum].tc[2] = fvt[2]; - } - } - } - } else if (!strcmp(tok[0],"*MESH_NORMALS")) { - unsigned int fnum, vnum; - vec3f nrm; - while (fgets2(buff,1000,pfile)) { - strcpy(buff2,buff); - TOKENIZE_LINE_AND_CHECK - if (!strcmp(tok[0],"}")) break; - if (sscanf(buff2," *MESH_FACENORMAL %i %f %f %f",&fnum,&nrm.x,&nrm.y,&nrm.z) == 4) { - if (fnum < curmesh->face.size()) { - curmesh->face[fnum].facenormal = DO_TM2(nrm); - curmesh->face[fnum].facenormal.normalize(); - curmesh->face[fnum].nr[0] = fnum*3+0; - curmesh->face[fnum].nr[1] = fnum*3+1; - curmesh->face[fnum].nr[2] = fnum*3+2; - } - } else if (sscanf(buff2," *MESH_VERTEXNORMAL %i %f %f %f",&vnum,&nrm.x,&nrm.y,&nrm.z) == 4) { - if (vnum == curmesh->face[fnum].vt[0]) { - curmesh->norm[fnum*3+0] = DO_TM2(nrm); - curmesh->norm[fnum*3+0].normalize(); - } else if (vnum == curmesh->face[fnum].vt[1]) { - curmesh->norm[fnum*3+1] = DO_TM2(nrm); - curmesh->norm[fnum*3+1].normalize(); - } else if (vnum == curmesh->face[fnum].vt[2]) { - curmesh->norm[fnum*3+2] = DO_TM2(nrm); - curmesh->norm[fnum*3+2].normalize(); - } - } - } - } else { - unknowndepth++; - } - } else if (!strcmp(tok[0],"*MESH_NUMVERTEX")) { - curmesh->vert.resize(atoi(tok[1])); - } else if (!strcmp(tok[0],"*MESH_NUMFACES")) { - curmesh->face.resize(atoi(tok[1])); - curmesh->norm.resize(atoi(tok[1])*3); // 3 normals per face - } else if (!strcmp(tok[0],"*MESH_NUMTVERTEX")) { - curmesh->texco.resize(atoi(tok[1])); - } - } - } else if (!strcmp(tok[0],"*NODE_TM")) { - dcon_printf("*NODE_TM
\n"); - while (fgets2(buff,1000,pfile)) { - strcpy(buff2,buff); - TOKENIZE_LINE_AND_CHECK - if (!strcmp(tok[0],"}")) { - // end of NODE_TM, do some processing - vec3f st[3] = { tm[0], tm[1], tm[2] }; - tm[0] = vec3f(st[0].x, st[1].x, st[2].x); - tm[1] = vec3f(st[0].y, st[1].y, st[2].y); - tm[2] = vec3f(st[0].z, st[1].z, st[2].z); - break; - } - if (sscanf(buff2," *TM_ROW0 %f %f %f",&tm[0].x,&tm[0].y,&tm[0].z) == 3) { - // do nothing! - } else if (sscanf(buff2," *TM_ROW1 %f %f %f",&tm[1].x,&tm[1].y,&tm[1].z) == 3) { - // do nothing! - } else if (sscanf(buff2," *TM_ROW2 %f %f %f",&tm[2].x,&tm[2].y,&tm[2].z) == 3) { - // do nothing! - } else if (sscanf(buff2," *TM_ROW3 %f %f %f",&tm[3].x,&tm[3].y,&tm[3].z) == 3) { - // do nothing! - } - } - } else { - unknowndepth++; - } - } else if (sscanf(buff2," *MATERIAL_REF %i",&tempi) == 1) { - dcon_printf("*MATERIAL_REF
\n"); - if (!curmesh) { - PUtil::outLog () << "warning: material ref before mesh in \"" << filename << "\"" << std::endl; - continue; - } - if (0 <= tempi && tempi < (int)matlist.size()) { - curmesh->fxname = matlist[tempi].filename; - } - } - } - } else { - unknowndepth++; - } - } - } + while (fgets2(buff,1000,pfile)) { + strcpy(buff2,buff); + TOKENIZE_LINE_AND_CHECK + if (!strcmp(tok[0],"}")) break; + if (tok.size() == 2 && !strcmp(tok[1],"{")) { + if (!strcmp(tok[0],"*MESH")) { + dcon_printf("*MESH
\n"); + mesh.push_back(PMesh()); + curmesh = &mesh.back(); + curmesh->effect = null; + while (fgets2(buff,1000,pfile)) { + TOKENIZE_LINE_AND_CHECK + if (!strcmp(tok[0],"}")) break; + if (tok.size() == 2 && !strcmp(tok[1],"{")) { + if (!strcmp(tok[0],"*MESH_VERTEX_LIST")) { + unsigned int vnum; + vec3f vpos; + while (fgets2(buff,1000,pfile)) { + strcpy(buff2,buff); + TOKENIZE_LINE_AND_CHECK + if (!strcmp(tok[0],"}")) break; + if (sscanf(buff2," *MESH_VERTEX %i %f %f %f",&vnum,&vpos.x,&vpos.y,&vpos.z) == 4) { + if (vnum < curmesh->vert.size()) + curmesh->vert[vnum] = vpos * globalScale; + } + } + } else if (!strcmp(tok[0],"*MESH_TVERTLIST")) { + unsigned int vnum; + vec2f vco; + while (fgets2(buff,1000,pfile)) { + strcpy(buff2,buff); + TOKENIZE_LINE_AND_CHECK + if (!strcmp(tok[0],"}")) break; + if (sscanf(buff2," *MESH_TVERT %i %f %f",&vnum,&vco.x,&vco.y) == 3) { + if (vnum < curmesh->texco.size()) { + curmesh->texco[vnum] = vco; + //curmesh->texco[vnum].y *= -1.0; + } + } + } + } else if (!strcmp(tok[0],"*MESH_FACE_LIST")) { + unsigned int fnum; + int fvt[3]; + while (fgets2(buff,1000,pfile)) { + strcpy(buff2,buff); + TOKENIZE_LINE_AND_CHECK + if (!strcmp(tok[0],"}")) break; + if (sscanf(buff2," *MESH_FACE %i: A: %i B: %i C: %i",&fnum,&fvt[0],&fvt[1],&fvt[2]) == 4) { + if (fnum < curmesh->face.size()) { + curmesh->face[fnum].vt[0] = fvt[0]; + curmesh->face[fnum].vt[1] = fvt[1]; + curmesh->face[fnum].vt[2] = fvt[2]; + } + } + } + } else if (!strcmp(tok[0],"*MESH_TFACELIST")) { + unsigned int fnum; + int fvt[3]; + while (fgets2(buff,1000,pfile)) { + strcpy(buff2,buff); + TOKENIZE_LINE_AND_CHECK + if (!strcmp(tok[0],"}")) break; + if (sscanf(buff2," *MESH_TFACE %i %i %i %i",&fnum,&fvt[0],&fvt[1],&fvt[2]) == 4) { + if (fnum < curmesh->face.size()) { + curmesh->face[fnum].tc[0] = fvt[0]; + curmesh->face[fnum].tc[1] = fvt[1]; + curmesh->face[fnum].tc[2] = fvt[2]; + } + } + } + } else if (!strcmp(tok[0],"*MESH_NORMALS")) { + unsigned int fnum, vnum; + vec3f nrm; + while (fgets2(buff,1000,pfile)) { + strcpy(buff2,buff); + TOKENIZE_LINE_AND_CHECK + if (!strcmp(tok[0],"}")) break; + if (sscanf(buff2," *MESH_FACENORMAL %i %f %f %f",&fnum,&nrm.x,&nrm.y,&nrm.z) == 4) { + if (fnum < curmesh->face.size()) { + curmesh->face[fnum].facenormal = DO_TM2(nrm); + curmesh->face[fnum].facenormal.normalize(); + curmesh->face[fnum].nr[0] = fnum*3+0; + curmesh->face[fnum].nr[1] = fnum*3+1; + curmesh->face[fnum].nr[2] = fnum*3+2; + } + } else if (sscanf(buff2," *MESH_VERTEXNORMAL %i %f %f %f",&vnum,&nrm.x,&nrm.y,&nrm.z) == 4) { + if (vnum == curmesh->face[fnum].vt[0]) { + curmesh->norm[fnum*3+0] = DO_TM2(nrm); + curmesh->norm[fnum*3+0].normalize(); + } else if (vnum == curmesh->face[fnum].vt[1]) { + curmesh->norm[fnum*3+1] = DO_TM2(nrm); + curmesh->norm[fnum*3+1].normalize(); + } else if (vnum == curmesh->face[fnum].vt[2]) { + curmesh->norm[fnum*3+2] = DO_TM2(nrm); + curmesh->norm[fnum*3+2].normalize(); + } + } + } + } else { + unknowndepth++; + } + } else if (!strcmp(tok[0],"*MESH_NUMVERTEX")) { + curmesh->vert.resize(atoi(tok[1])); + } else if (!strcmp(tok[0],"*MESH_NUMFACES")) { + curmesh->face.resize(atoi(tok[1])); + curmesh->norm.resize(atoi(tok[1])*3); // 3 normals per face + } else if (!strcmp(tok[0],"*MESH_NUMTVERTEX")) { + curmesh->texco.resize(atoi(tok[1])); + } + } + } else if (!strcmp(tok[0],"*NODE_TM")) { + dcon_printf("*NODE_TM
\n"); + while (fgets2(buff,1000,pfile)) { + strcpy(buff2,buff); + TOKENIZE_LINE_AND_CHECK + if (!strcmp(tok[0],"}")) { + // end of NODE_TM, do some processing + vec3f st[3] = { tm[0], tm[1], tm[2] }; + tm[0] = vec3f(st[0].x, st[1].x, st[2].x); + tm[1] = vec3f(st[0].y, st[1].y, st[2].y); + tm[2] = vec3f(st[0].z, st[1].z, st[2].z); + break; + } + if (sscanf(buff2," *TM_ROW0 %f %f %f",&tm[0].x,&tm[0].y,&tm[0].z) == 3) { + // do nothing! + } else if (sscanf(buff2," *TM_ROW1 %f %f %f",&tm[1].x,&tm[1].y,&tm[1].z) == 3) { + // do nothing! + } else if (sscanf(buff2," *TM_ROW2 %f %f %f",&tm[2].x,&tm[2].y,&tm[2].z) == 3) { + // do nothing! + } else if (sscanf(buff2," *TM_ROW3 %f %f %f",&tm[3].x,&tm[3].y,&tm[3].z) == 3) { + // do nothing! + } + } + } else { + unknowndepth++; + } + } else if (sscanf(buff2," *MATERIAL_REF %i",&tempi) == 1) { + dcon_printf("*MATERIAL_REF
\n"); + if (!curmesh) { + PUtil::outLog () << "warning: material ref before mesh in \"" << filename << "\"" << std::endl; + continue; + } + if (0 <= tempi && tempi < (int)matlist.size()) { + curmesh->fxname = matlist[tempi].filename; + } + } + } + } else { + unknowndepth++; + } + } + } - PHYSFS_close(pfile); + PHYSFS_close(pfile); - name = filename; + name = filename; } diff -Nru trigger-rally-0.5.2.1/src/pengine/pengine.h trigger-rally-0.6.0/src/pengine/pengine.h --- trigger-rally-0.5.2.1/src/pengine/pengine.h 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/pengine/pengine.h 2011-10-07 17:10:01.000000000 +0000 @@ -1,133 +1,133 @@ - -// pengine.h [pengine] - -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net -// License: GPL version 2 (see included gpl.txt) - - -#ifndef PENGINE_H_INCLUDED -#define PENGINE_H_INCLUDED - - -#include "../../config.h" - -#include - -#include - -#include -#include -#include -#include - - -// "SDL.h" is supposed to be the portable way, but it -// doesn't seem to work in some circumstances... -#include "SDL.h" -//#include - - -// The PhysicsFS game file system -#include - - -// This is a slightly modified GLEW for internal build -#define GLEW_STATIC -#include "GL/glew.h" - - -// TinyXML is built into the pengine library -#include "tinyxml.h" - - -// Some maths utils and macros -#include "vmath.h" - - -#define null 0 - - -class PUtil; - -class PApp; -class PSubsystem; -class PSSRender; -class PParticleType; -struct PParticle_s; -class PSSTexture; -class PImage; -class PTexture; -class PSSAudio; -class PAudioSample; -class PAudioInstance; -class PSSEffect; -class PEffect; -class PSSModel; -class PFace; -class PMesh; -class PModel; -class PTerrain; - -class PException; -class PUserException; -class PFileException; -class PParseException; - - -#include "exception.h" - - -// Utility - -#define DEBUGLEVEL_CRITICAL 0 -#define DEBUGLEVEL_ENDUSER 10 -#define DEBUGLEVEL_TEST 20 -#define DEBUGLEVEL_DEVELOPER 30 - - -class PUtil { -private: - PUtil() { } // cannot be constructed - - static int deblev; - -public: - // Output streams - static std::ostream &outLog() { return std::cout; } - - // Debug level - static bool isDebugLevel(int debugLevel) { return deblev >= debugLevel; } - static void setDebugLevel(int debugLevel) { deblev = debugLevel; } - - - // Given "data/blah/pic.jpg" will return "data/blah/" - static std::string extractPathFromFilename(const std::string &filename); - - static std::string assemblePath(const std::string &relativefile, const std::string &parentfile); - - // Load XML file and return the root element of given name (failure: null) - static TiXmlElement *loadRootElement(TiXmlDocument &doc, const char *rootName); - - static bool copyFile(const std::string &fileFrom, const std::string &fileTo); - static std::list findFiles(const std::string &basedir, const std::string &extension); - - static std::string formatInt(int value, int width); - static std::string formatInt(int value); - - static std::string formatTime(float seconds); - - // RWops created must be freed by using SDL freesrc on load - static SDL_RWops *allocPhysFSops(PHYSFS_file *pfile); -}; - - - -#include "app.h" -#include "subsys.h" -#include "audio.h" -#include "render.h" - - -#endif // PENGINE_H_INCLUDED - - + +// pengine.h [pengine] + +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net +// License: GPL version 2 (see included gpl.txt) + + +#ifndef PENGINE_H_INCLUDED +#define PENGINE_H_INCLUDED + + +#include "../../config.h" + +#include + +#include + +#include +#include +#include +#include + + +// "SDL.h" is supposed to be the portable way, but it +// doesn't seem to work in some circumstances... +#include "SDL.h" +//#include + + +// The PhysicsFS game file system +#include + + +// This is a slightly modified GLEW for internal build +#define GLEW_STATIC +#include "GL/glew.h" + + +// TinyXML is built into the pengine library +#include "tinyxml.h" + + +// Some maths utils and macros +#include "vmath.h" + + +#define null 0 + + +class PUtil; + +class PApp; +class PSubsystem; +class PSSRender; +class PParticleType; +struct PParticle_s; +class PSSTexture; +class PImage; +class PTexture; +class PSSAudio; +class PAudioSample; +class PAudioInstance; +class PSSEffect; +class PEffect; +class PSSModel; +class PFace; +class PMesh; +class PModel; +class PTerrain; + +class PException; +class PUserException; +class PFileException; +class PParseException; + + +#include "exception.h" + + +// Utility + +#define DEBUGLEVEL_CRITICAL 0 +#define DEBUGLEVEL_ENDUSER 10 +#define DEBUGLEVEL_TEST 20 +#define DEBUGLEVEL_DEVELOPER 30 + + +class PUtil { +private: + PUtil() { } // cannot be constructed + + static int deblev; + +public: + // Output streams + static std::ostream &outLog() { return std::cout; } + + // Debug level + static bool isDebugLevel(int debugLevel) { return deblev >= debugLevel; } + static void setDebugLevel(int debugLevel) { deblev = debugLevel; } + + + // Given "data/blah/pic.jpg" will return "data/blah/" + static std::string extractPathFromFilename(const std::string &filename); + + static std::string assemblePath(const std::string &relativefile, const std::string &parentfile); + + // Load XML file and return the root element of given name (failure: null) + static TiXmlElement *loadRootElement(TiXmlDocument &doc, const char *rootName); + + static bool copyFile(const std::string &fileFrom, const std::string &fileTo); + static std::list findFiles(const std::string &basedir, const std::string &extension); + + static std::string formatInt(int value, int width); + static std::string formatInt(int value); + + static std::string formatTime(float seconds); + + // RWops created must be freed by using SDL freesrc on load + static SDL_RWops *allocPhysFSops(PHYSFS_file *pfile); +}; + + + +#include "app.h" +#include "subsys.h" +#include "audio.h" +#include "render.h" + + +#endif // PENGINE_H_INCLUDED + + diff -Nru trigger-rally-0.5.2.1/src/pengine/physfs_rw.cpp trigger-rally-0.6.0/src/pengine/physfs_rw.cpp --- trigger-rally-0.5.2.1/src/pengine/physfs_rw.cpp 2006-10-20 19:09:56.000000000 +0000 +++ trigger-rally-0.6.0/src/pengine/physfs_rw.cpp 2011-10-07 17:10:01.000000000 +0000 @@ -1,73 +1,73 @@ - -// physfs_rw.cpp [pengine] - -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net -// License: GPL version 2 (see included gpl.txt) - - -#include "pengine.h" - - - -int physfs_seek(SDL_RWops *context, int offset, int whence) -{ - PHYSFS_file *pfile = (PHYSFS_file *)context->hidden.unknown.data1; - - int target; - - int curpos = PHYSFS_tell(pfile); - - switch (whence) { - default: - case SEEK_SET: - target = offset; - break; - case SEEK_CUR: - target = curpos + offset; - break; - case SEEK_END: - target = PHYSFS_fileLength(pfile) + offset; - break; - } - - int result = PHYSFS_seek(pfile, target); - if (! result) { - throw MakePException("Error seeking: " + PHYSFS_getLastError()); - } - - return PHYSFS_tell(pfile); - - PHYSFS_seek(pfile, target); - - return curpos; -} - - -int physfs_read(SDL_RWops *context, void *ptr, int size, int maxnum) -{ - PHYSFS_file *pfile = (PHYSFS_file *)context->hidden.unknown.data1; - - return PHYSFS_read(pfile, ptr, size, maxnum); -} - - -int physfs_write(SDL_RWops *context, const void *ptr, int size, int num) -{ - PHYSFS_file *pfile = (PHYSFS_file *)context->hidden.unknown.data1; - - return PHYSFS_write(pfile, ptr, size, num); -} - - -int physfs_close(SDL_RWops *context) -{ - PHYSFS_file *pfile = (PHYSFS_file *)context->hidden.unknown.data1; - - PHYSFS_close(pfile); - - SDL_FreeRW(context); - - return 0; -} - - + +// physfs_rw.cpp [pengine] + +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net +// License: GPL version 2 (see included gpl.txt) + + +#include "pengine.h" + + + +int physfs_seek(SDL_RWops *context, int offset, int whence) +{ + PHYSFS_file *pfile = (PHYSFS_file *)context->hidden.unknown.data1; + + int target; + + int curpos = PHYSFS_tell(pfile); + + switch (whence) { + default: + case SEEK_SET: + target = offset; + break; + case SEEK_CUR: + target = curpos + offset; + break; + case SEEK_END: + target = PHYSFS_fileLength(pfile) + offset; + break; + } + + int result = PHYSFS_seek(pfile, target); + if (! result) { + throw MakePException("Error seeking: " + PHYSFS_getLastError()); + } + + return PHYSFS_tell(pfile); + + PHYSFS_seek(pfile, target); + + return curpos; +} + + +int physfs_read(SDL_RWops *context, void *ptr, int size, int maxnum) +{ + PHYSFS_file *pfile = (PHYSFS_file *)context->hidden.unknown.data1; + + return PHYSFS_read(pfile, ptr, size, maxnum); +} + + +int physfs_write(SDL_RWops *context, const void *ptr, int size, int num) +{ + PHYSFS_file *pfile = (PHYSFS_file *)context->hidden.unknown.data1; + + return PHYSFS_write(pfile, ptr, size, num); +} + + +int physfs_close(SDL_RWops *context) +{ + PHYSFS_file *pfile = (PHYSFS_file *)context->hidden.unknown.data1; + + PHYSFS_close(pfile); + + SDL_FreeRW(context); + + return 0; +} + + diff -Nru trigger-rally-0.5.2.1/src/pengine/render.cpp trigger-rally-0.6.0/src/pengine/render.cpp --- trigger-rally-0.5.2.1/src/pengine/render.cpp 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/pengine/render.cpp 2011-10-07 17:10:01.000000000 +0000 @@ -1,185 +1,185 @@ - -// render.cpp [pengine] - -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net -// License: GPL version 2 (see included gpl.txt) - - -#include "pengine.h" - - - -PSSRender::PSSRender(PApp &parentApp) : PSubsystem(parentApp) -{ - app.outLog() << "Initialising render subsystem" << std::endl; -} - -PSSRender::~PSSRender() -{ - app.outLog() << "Shutting down render subsystem" << std::endl; -} - - -void PSSRender::tick(float delta, const vec3f &eyepos, const mat44f &eyeori, const vec3f &eyevel) -{ - float unused = delta; unused = eyevel.x; - - cam_pos = eyepos; - cam_orimat = eyeori; -} - - -void PSSRender::render(PParticleSystem *psys) -{ - vec3f pushx = makevec3f(cam_orimat.row[0]); - vec3f pushy = makevec3f(cam_orimat.row[1]); - vec3f vert; - - glBlendFunc(psys->blendparam1, psys->blendparam2); - - if (psys->tex) psys->tex->bind(); - else glDisable(GL_TEXTURE_2D); - - glBegin(GL_QUADS); - for (unsigned int i=0; ipart.size(); i++) { - PParticle_s &part = psys->part[i]; - float sizenow = INTERP(psys->endsize, psys->startsize, part.life); - vec3f pushxt = pushx * sizenow; - vec3f pushyt = pushy * sizenow; - vec3f pushx2 = pushxt * part.orix.x + pushyt * part.orix.y; - vec3f pushy2 = pushxt * part.oriy.x + pushyt * part.oriy.y; - - glColor4f(INTERP(psys->colorend[0], psys->colorstart[0], part.life), - INTERP(psys->colorend[1], psys->colorstart[1], part.life), - INTERP(psys->colorend[2], psys->colorstart[2], part.life), - INTERP(psys->colorend[3], psys->colorstart[3], part.life)); - - vert = part.pos - pushx2 - pushy2; - glTexCoord2i(0,0); - glVertex3fv(vert); - vert = part.pos + pushx2 - pushy2; - glTexCoord2i(1,0); - glVertex3fv(vert); - vert = part.pos + pushx2 + pushy2; - glTexCoord2i(1,1); - glVertex3fv(vert); - vert = part.pos - pushx2 + pushy2; - glTexCoord2i(0,1); - glVertex3fv(vert); - } - glEnd(); - - if (!psys->tex) glEnable(GL_TEXTURE_2D); -} - -void PSSRender::drawModel(PModel &model, PSSEffect &ssEffect, PSSTexture &ssTexture) -{ - for (std::vector::iterator mesh = model.mesh.begin(); - mesh != model.mesh.end(); - mesh++) { - if (!mesh->effect) - mesh->effect = ssEffect.loadEffect(mesh->fxname); - - int numPasses = 0; - if (mesh->effect->renderBegin(&numPasses, ssTexture)) { - for (int i=0; ieffect->renderPass(i); - glBegin(GL_TRIANGLES); - for (unsigned int f=0; fface.size(); f++) { - //glNormal3fv(mesh->face[f].facenormal); - - glNormal3fv(mesh->norm[mesh->face[f].nr[0]]); - glTexCoord2fv(mesh->texco[mesh->face[f].tc[0]]); - glVertex3fv(mesh->vert[mesh->face[f].vt[0]]); - - glNormal3fv(mesh->norm[mesh->face[f].nr[1]]); - glTexCoord2fv(mesh->texco[mesh->face[f].tc[1]]); - glVertex3fv(mesh->vert[mesh->face[f].vt[1]]); - - glNormal3fv(mesh->norm[mesh->face[f].nr[2]]); - glTexCoord2fv(mesh->texco[mesh->face[f].tc[2]]); - glVertex3fv(mesh->vert[mesh->face[f].vt[2]]); - } - glEnd(); - } - mesh->effect->renderEnd(); - } - } -} - -void PSSRender::drawText(const std::string &text, uint32 flags) -{ - const float font_aspect = 0.6f; - - glPushMatrix(); - - if (flags & PTEXT_VTA_CENTER) - glTranslatef(0.0f, -0.5f, 0.0f); - else if (flags & PTEXT_VTA_TOP) - glTranslatef(0.0f, -1.0f, 0.0f); - - if (flags & PTEXT_HZA_CENTER) - glTranslatef(-((float)text.length()) * 0.5f * font_aspect, 0.0f, 0.0f); - else if (flags & PTEXT_HZA_RIGHT) - glTranslatef(-((float)text.length()) * font_aspect, 0.0f, 0.0f); - - for (std::string::const_iterator c = text.begin(); c != text.end(); c++) { - float tx = ((float)(*c % 16) + 0.5f - font_aspect*0.5f) / 16.0f, addx = font_aspect / 16.0f; - float ty = (*c / 16) / 16.0f, addy = 1 / 16.0f; - glBegin(GL_TRIANGLE_STRIP); - glTexCoord2f(tx,ty); - glVertex2f(0.0f,0.0f); - glTexCoord2f(tx+addx,ty); - glVertex2f(font_aspect,0.0f); - glTexCoord2f(tx,ty+addy); - glVertex2f(0.0f,1.0f); - glTexCoord2f(tx+addx,ty+addy); - glVertex2f(font_aspect,1.0f); - glEnd(); - glTranslatef(font_aspect,0,0); - } - - glPopMatrix(); -} - -vec2f PSSRender::getTextDims(const std::string &text) -{ - const float font_aspect = 0.6f; - - return vec2f((float)text.length() * font_aspect, 1.0f); -} - - -void PParticleSystem::addParticle(const vec3f &pos, const vec3f &linvel) -{ - part.push_back(PParticle_s()); - part.back().pos = pos; - part.back().linvel = linvel; - part.back().life = 1.0; - - float ang = randm11 * PI; - part.back().orix = vec2f(cos(ang),sin(ang)); - part.back().oriy = vec2f(-sin(ang),cos(ang)); -} - - -void PParticleSystem::tick(float delta) -{ - float decr = delta * decay; - - // update life and delete dead particles - unsigned int j=0; - for (unsigned int i=0; i 0.0) j++; - } - part.resize(j); - - for (unsigned int i=0; iblendparam1, psys->blendparam2); + + if (psys->tex) psys->tex->bind(); + else glDisable(GL_TEXTURE_2D); + + glBegin(GL_QUADS); + for (unsigned int i=0; ipart.size(); i++) { + PParticle_s &part = psys->part[i]; + float sizenow = INTERP(psys->endsize, psys->startsize, part.life); + vec3f pushxt = pushx * sizenow; + vec3f pushyt = pushy * sizenow; + vec3f pushx2 = pushxt * part.orix.x + pushyt * part.orix.y; + vec3f pushy2 = pushxt * part.oriy.x + pushyt * part.oriy.y; + + glColor4f(INTERP(psys->colorend[0], psys->colorstart[0], part.life), + INTERP(psys->colorend[1], psys->colorstart[1], part.life), + INTERP(psys->colorend[2], psys->colorstart[2], part.life), + INTERP(psys->colorend[3], psys->colorstart[3], part.life)); + + vert = part.pos - pushx2 - pushy2; + glTexCoord2i(0,0); + glVertex3fv(vert); + vert = part.pos + pushx2 - pushy2; + glTexCoord2i(1,0); + glVertex3fv(vert); + vert = part.pos + pushx2 + pushy2; + glTexCoord2i(1,1); + glVertex3fv(vert); + vert = part.pos - pushx2 + pushy2; + glTexCoord2i(0,1); + glVertex3fv(vert); + } + glEnd(); + + if (!psys->tex) glEnable(GL_TEXTURE_2D); +} + +void PSSRender::drawModel(PModel &model, PSSEffect &ssEffect, PSSTexture &ssTexture) +{ + for (std::vector::iterator mesh = model.mesh.begin(); + mesh != model.mesh.end(); + mesh++) { + if (!mesh->effect) + mesh->effect = ssEffect.loadEffect(mesh->fxname); + + int numPasses = 0; + if (mesh->effect->renderBegin(&numPasses, ssTexture)) { + for (int i=0; ieffect->renderPass(i); + glBegin(GL_TRIANGLES); + for (unsigned int f=0; fface.size(); f++) { + //glNormal3fv(mesh->face[f].facenormal); + + glNormal3fv(mesh->norm[mesh->face[f].nr[0]]); + glTexCoord2fv(mesh->texco[mesh->face[f].tc[0]]); + glVertex3fv(mesh->vert[mesh->face[f].vt[0]]); + + glNormal3fv(mesh->norm[mesh->face[f].nr[1]]); + glTexCoord2fv(mesh->texco[mesh->face[f].tc[1]]); + glVertex3fv(mesh->vert[mesh->face[f].vt[1]]); + + glNormal3fv(mesh->norm[mesh->face[f].nr[2]]); + glTexCoord2fv(mesh->texco[mesh->face[f].tc[2]]); + glVertex3fv(mesh->vert[mesh->face[f].vt[2]]); + } + glEnd(); + } + mesh->effect->renderEnd(); + } + } +} + +void PSSRender::drawText(const std::string &text, uint32 flags) +{ + const float font_aspect = 0.6f; + + glPushMatrix(); + + if (flags & PTEXT_VTA_CENTER) + glTranslatef(0.0f, -0.5f, 0.0f); + else if (flags & PTEXT_VTA_TOP) + glTranslatef(0.0f, -1.0f, 0.0f); + + if (flags & PTEXT_HZA_CENTER) + glTranslatef(-((float)text.length()) * 0.5f * font_aspect, 0.0f, 0.0f); + else if (flags & PTEXT_HZA_RIGHT) + glTranslatef(-((float)text.length()) * font_aspect, 0.0f, 0.0f); + + for (std::string::const_iterator c = text.begin(); c != text.end(); c++) { + float tx = ((float)(*c % 16) + 0.5f - font_aspect*0.5f) / 16.0f, addx = font_aspect / 16.0f; + float ty = (*c / 16) / 16.0f, addy = 1 / 16.0f; + glBegin(GL_TRIANGLE_STRIP); + glTexCoord2f(tx,ty); + glVertex2f(0.0f,0.0f); + glTexCoord2f(tx+addx,ty); + glVertex2f(font_aspect,0.0f); + glTexCoord2f(tx,ty+addy); + glVertex2f(0.0f,1.0f); + glTexCoord2f(tx+addx,ty+addy); + glVertex2f(font_aspect,1.0f); + glEnd(); + glTranslatef(font_aspect,0,0); + } + + glPopMatrix(); +} + +vec2f PSSRender::getTextDims(const std::string &text) +{ + const float font_aspect = 0.6f; + + return vec2f((float)text.length() * font_aspect, 1.0f); +} + + +void PParticleSystem::addParticle(const vec3f &pos, const vec3f &linvel) +{ + part.push_back(PParticle_s()); + part.back().pos = pos; + part.back().linvel = linvel; + part.back().life = 1.0; + + float ang = randm11 * PI; + part.back().orix = vec2f(cos(ang),sin(ang)); + part.back().oriy = vec2f(-sin(ang),cos(ang)); +} + + +void PParticleSystem::tick(float delta) +{ + float decr = delta * decay; + + // update life and delete dead particles + unsigned int j=0; + for (unsigned int i=0; i 0.0) j++; + } + part.resize(j); + + for (unsigned int i=0; i part; - -public: - PParticleSystem() { - colorstart[0] = colorstart[1] = colorstart[2] = colorstart[3] = 1.0; - colorend[0] = colorend[1] = colorend[2] = 1.0; colorend[3] = 0.0; - startsize = 0.0; - endsize = 1.0; - decay = 1.0; - tex = null; - blendparam1 = GL_SRC_ALPHA; - blendparam2 = GL_ONE; - } - -public: - void setColorStart(float r, float g, float b, float a) { - colorstart[0] = r; colorstart[1] = g; colorstart[2] = b; colorstart[3] = a; - } - void setColorEnd(float r, float g, float b, float a) { - colorend[0] = r; colorend[1] = g; colorend[2] = b; colorend[3] = a; - } - void setColor(float r, float g, float b) { - colorstart[0] = colorend[0] = r; - colorstart[1] = colorend[1] = g; - colorstart[2] = colorend[2] = b; - } - void setSize(float start, float end) { - startsize = start; endsize = end; - } - void setDecay(float _decay) { - decay = _decay; - } - void setTexture(const PTexture *texptr) { - tex = texptr; - } - void setBlend(GLenum b1, GLenum b2) { - blendparam1 = b1; - blendparam2 = b2; - } - - void addParticle(const vec3f &pos, const vec3f &linvel); - - void tick(float delta); - - friend class PSSRender; -}; - -struct PVert_tv { - vec2f st; - vec3f xyz; -}; - -#define PTEXT_HZA_LEFT 0x00000000 // default -#define PTEXT_HZA_CENTER 0x00000001 -#define PTEXT_HZA_RIGHT 0x00000002 -#define PTEXT_VTA_BOTTOM 0x00000000 // default -#define PTEXT_VTA_CENTER 0x00000100 -#define PTEXT_VTA_TOP 0x00000200 - -class PSSRender : public PSubsystem { -private: - vec3f cam_pos; - mat44f cam_orimat; - -public: - PSSRender(PApp &parentApp); - ~PSSRender(); - - void tick(float delta, const vec3f &eyepos, const mat44f &eyeori, const vec3f &eyevel); - - void render(PParticleSystem *psys); - - void drawModel(PModel &model, PSSEffect &ssEffect, PSSTexture &ssTexture); - - void drawText(const std::string &text, uint32 flags); - vec2f getTextDims(const std::string &text); -}; - - - -class PSSTexture : public PSubsystem { -private: - PResourceList texlist; - -public: - PSSTexture(PApp &parentApp); - ~PSSTexture(); - - PTexture *loadTexture(const std::string &name, bool genMipmaps = true, bool clamp = false); -}; - - -class PImage { -private: - uint8 *data; - int cx,cy,cc; - -public: - PImage () : data (null) { } - PImage (const std::string &filename) : data (null) { load (filename); } - PImage (int _cx, int _cy, int _cc) : data (null) { load (_cx, _cy, _cc); } - ~PImage (); - - void load (const std::string &filename); - void load (int _cx, int _cy, int _cc); - void unload (); - - void expandChannels(); - - int getcx() const { return cx; } - int getcy() const { return cy; } - int getcc() const { return cc; } - uint8 *getData() { return data; } - - void swap (PImage &other) throw () - { - { uint8 *tmp = data; data = other.data; other.data = tmp; } - { int tmp = cx; cx = other.cx; other.cx = tmp; } - { int tmp = cy; cy = other.cy; other.cy = tmp; } - { int tmp = cc; cc = other.cc; other.cc = tmp; } - } -}; - - -class PTexture : public PResource { -private: - GLuint texid; - GLenum textarget; - -public: - PTexture () : texid (0) { } - PTexture (const std::string &filename, bool genMipmaps, bool clamp) : texid (0) { load (filename, genMipmaps, clamp); } - PTexture (PImage &img, bool genMipmaps, bool clamp) : texid (0) { load (img, genMipmaps, clamp); } - ~PTexture() { unload (); } - - void load (const std::string &filename, bool genMipmaps, bool clamp); - void load(PImage &img, bool genMipmaps = true, bool clamp = false); - void loadPiece(PImage &img, int offx, int offy, int sizex, int sizey, bool genMipmaps = true, bool clamp = false); - void loadAlpha(const std::string &filename, bool genMipmaps = true, bool clamp = false); - void loadAlpha(PImage &img, bool genMipmaps = true, bool clamp = false); - void loadCubeMap(const std::string &filenamePrefix, const std::string &filenameSuffix, bool genMipmaps = true); - void unload(); - - void bind() const; - - static void unbind(); -}; - - - - -class PSSEffect : public PSubsystem { -private: - PResourceList fxlist; - -public: - PSSEffect(PApp &parentApp); - ~PSSEffect(); - - PEffect *loadEffect(const std::string &name); -}; - - - -#define CULLFACE_NONE 0 -#define CULLFACE_CW 1 -#define CULLFACE_CCW 2 - -#define BLEND_NONE 0 -#define BLEND_ADD 1 -#define BLEND_MULTIPLY 2 -#define BLEND_ALPHA 3 -#define BLEND_PREMULTALPHA 4 - - -struct fx_renderstate_s { - bool depthtest; - - bool lighting; - bool lightmodeltwoside; - - struct { - GLenum func; - float ref; - } alphatest; - - int cullface; - - int blendmode; - - struct { - int texindex; - } texunit[1]; -}; - - -struct fx_pass_s { - fx_renderstate_s rs; -}; - -struct fx_technique_s { - std::string name; - - std::vector pass; - - bool validated; - bool textures_ready; - - fx_technique_s() { - validated = false; - textures_ready = false; - } -}; - -struct fx_texture_s { - std::string name; - - std::string filename; - - GLenum type; - - // This is filled in just before rendering - PTexture *texobject; - - fx_texture_s() { - texobject = null; - } -}; - - -class PEffect : public PResource { -private: - // resources - std::vector tex; - - // techniques - std::vector tech; - - int cur_tech; - -public: - PEffect(const std::string &filename); - ~PEffect(); - - void unload(); - - int getNumTechniques(); - bool validateTechnique(int technique); - const std::string &getTechniqueName(int technique); - bool findTechnique(const std::string &techname, int *technique); - - bool setCurrentTechnique(int technique); - int getCurrentTechnique(); - - bool setFirstValidTechnique(); - - bool renderBegin(int *numPasses, PSSTexture &sstex); - void renderPass(int pass); - void renderEnd(); - -private: - void migrateRenderState(fx_renderstate_s *rs_old, fx_renderstate_s *rs_new); -}; - - - - -class PSSModel : public PSubsystem { -private: - PResourceList modlist; - -public: - PSSModel(PApp &parentApp); - ~PSSModel(); - - PModel *loadModel(const std::string &name); -}; - - -class PFace { -public: - vec3f facenormal; - uint32 vt[3]; - uint32 tc[3]; - uint32 nr[3]; - -public: -// PFace(vec -}; - - -class PMesh { -public: - std::vector vert; - std::vector texco; - std::vector norm; - std::vector face; - - std::string fxname; - PEffect *effect; -}; - - -class PModel : public PResource { -public: - std::vector mesh; - - std::pair getExtents() const; - -public: - PModel (const std::string &filename, float globalScale = 1.0); - -private: - void loadASE (const std::string &filename, float globalScale); -}; - -struct PTerrainFoliageBand { - float middle, range; - float density; - int trycount; - - PTexture *sprite_tex; - int sprite_count; -}; - -struct PTerrainFoliage { - vec3f pos; - float ang; - float scale; -}; - -struct PTerrainFoliageSet { - std::vector inst; - - PVBuffer buff[2]; - int numvert, numelem; -}; - -struct PTerrainTile { - int posx, posy; - int lru_counter; - - PVBuffer vert; - int numverts; - - PTexture tex; - - vec3f mins,maxs; // AABB - - // - - std::vector foliage; -}; - - -class PTerrain // TODO: make this RAII conformant -{ -protected: - bool loaded; - - int tilesize, tilecount, totsize, totmask, totsizesq; - - float scale_hz, scale_vt, scale_hz_inv, scale_vt_inv, scale_tile_inv; - - int cmaptotsize, cmaptilesize, cmaptotmask; - - //std::vector hmap; - std::vector hmap; - - PImage cmap; - - std::vector fmap; - std::vector foliageband; - - std::list tile; - - // tiles share index buffers - PVBuffer ind; - int numinds; - - PTexture *tex_hud_map; - -protected: - - PTerrainTile *getTile(int x, int y); - - float getInterp(float x, float y, float *data) { - x *= scale_hz_inv; - int xi = (int)x; - if (x < 0.0) xi--; - x -= (float)xi; - int xiw = xi & totmask, xiw2 = (xiw+1) & totmask; - - y *= scale_hz_inv; - int yi = (int)y; - if (y < 0.0) yi--; - y -= (float)yi; - int yiw = yi & totmask, yiw2 = (yiw+1) & totmask; - - const int cx = totsize; - - float xv1,xv2; - if (y > 0.0) { - if (y < 1.0) { - if (x < y) { - xv1 = data[yiw*cx+xiw]; - xv2 = INTERP(data[yiw2*cx+xiw],data[yiw2*cx+xiw2],x/y); - } else { - xv1 = INTERP(data[yiw*cx+xiw],data[yiw*cx+xiw2],(x-y)/(1.0-y)); - xv2 = data[yiw2*cx+xiw2]; - } - return INTERP(xv1,xv2,y); - } else { - return INTERP(data[yiw2*cx+xiw],data[yiw2*cx+xiw2],x); - } - } else { - return INTERP(data[yiw*cx+xiw],data[yiw*cx+xiw2],x); - } - } - -public: - PTerrain(TiXmlElement *element, const std::string &filepath, PSSTexture &ssTexture); - ~PTerrain(); - - void unload(); - - void render(const vec3f &campos, const mat44f &camorim); - - void drawSplat(float x, float y, float scale, float angle); - - - struct ContactInfo { - vec3f pos; - vec3f normal; - }; - - void getContactInfo(ContactInfo &tci) { - float x = tci.pos.x * scale_hz_inv; - int xi = (int)x; - if (x < 0.0) xi--; - x -= (float)xi; - int xiw = xi & totmask, xiw2 = (xi+1) & totmask; - - float y = tci.pos.y * scale_hz_inv; - int yi = (int)y; - if (y < 0.0) yi--; - y -= (float)yi; - int yiw = yi & totmask, yiw2 = (yi+1) & totmask; - - float *data = &hmap[0]; - const int cx = totsize; - - float xv1,xv2; - if (y > 0.0) { - if (y < 1.0) { - if (x < y) { - tci.normal.x = data[yiw2*cx+xiw] - data[yiw2*cx+xiw2]; - tci.normal.y = data[yiw*cx+xiw] - data[yiw2*cx+xiw]; - xv1 = data[yiw*cx+xiw]; - xv2 = INTERP(data[yiw2*cx+xiw],data[yiw2*cx+xiw2],x/y); - } else { - tci.normal.x = data[yiw*cx+xiw] - data[yiw*cx+xiw2]; - tci.normal.y = data[yiw*cx+xiw2] - data[yiw2*cx+xiw2]; - xv1 = INTERP(data[yiw*cx+xiw],data[yiw*cx+xiw2],(x-y)/(1.0-y)); - xv2 = data[yiw2*cx+xiw2]; - } - tci.pos.z = INTERP(xv1,xv2,y); - } else { - tci.normal.x = data[yiw2*cx+xiw] - data[yiw2*cx+xiw2]; - tci.normal.y = data[yiw*cx+xiw] - data[yiw2*cx+xiw]; - tci.pos.z = INTERP(data[yiw2*cx+xiw],data[yiw2*cx+xiw2],x); - } - } else { - tci.normal.x = data[yiw*cx+xiw] - data[yiw*cx+xiw2]; - tci.normal.y = data[yiw*cx+xiw2] - data[yiw2*cx+xiw2]; - tci.pos.z = INTERP(data[yiw*cx+xiw],data[yiw*cx+xiw2],x); - } - tci.normal.z = scale_hz; - tci.normal.normalize(); - } - - float getHeight(float x, float y) { - return getInterp(x, y, &hmap[0]); - } - - float getFoliageLevel(float x, float y) { - return getInterp(x, y, &fmap[0]); - } - - PTexture *getHUDMapTexture() { return tex_hud_map; } - - float getMapSize() { return totsize * scale_hz; } -}; - - - - + +// render.h [pengine] + +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net +// License: GPL version 2 (see included gpl.txt) + + + +#include "vbuffer.h" + + + +struct PParticle_s { + vec3f pos,linvel; + float life; + + vec2f orix,oriy; // orientation vectors (2d) +}; + +class PParticleSystem { +protected: + float colorstart[4],colorend[4]; + float startsize, endsize; + float decay; + const PTexture *tex; + GLenum blendparam1, blendparam2; + + std::vector part; + +public: + PParticleSystem() { + colorstart[0] = colorstart[1] = colorstart[2] = colorstart[3] = 1.0; + colorend[0] = colorend[1] = colorend[2] = 1.0; colorend[3] = 0.0; + startsize = 0.0; + endsize = 1.0; + decay = 1.0; + tex = null; + blendparam1 = GL_SRC_ALPHA; + blendparam2 = GL_ONE; + } + +public: + void setColorStart(float r, float g, float b, float a) { + colorstart[0] = r; colorstart[1] = g; colorstart[2] = b; colorstart[3] = a; + } + void setColorEnd(float r, float g, float b, float a) { + colorend[0] = r; colorend[1] = g; colorend[2] = b; colorend[3] = a; + } + void setColor(float r, float g, float b) { + colorstart[0] = colorend[0] = r; + colorstart[1] = colorend[1] = g; + colorstart[2] = colorend[2] = b; + } + void setSize(float start, float end) { + startsize = start; endsize = end; + } + void setDecay(float _decay) { + decay = _decay; + } + void setTexture(const PTexture *texptr) { + tex = texptr; + } + void setBlend(GLenum b1, GLenum b2) { + blendparam1 = b1; + blendparam2 = b2; + } + + void addParticle(const vec3f &pos, const vec3f &linvel); + + void tick(float delta); + + friend class PSSRender; +}; + +struct PVert_tv { + vec2f st; + vec3f xyz; +}; + +#define PTEXT_HZA_LEFT 0x00000000 // default +#define PTEXT_HZA_CENTER 0x00000001 +#define PTEXT_HZA_RIGHT 0x00000002 +#define PTEXT_VTA_BOTTOM 0x00000000 // default +#define PTEXT_VTA_CENTER 0x00000100 +#define PTEXT_VTA_TOP 0x00000200 + +class PSSRender : public PSubsystem { +private: + vec3f cam_pos; + mat44f cam_orimat; + +public: + PSSRender(PApp &parentApp); + ~PSSRender(); + + void tick(float delta, const vec3f &eyepos, const mat44f &eyeori, const vec3f &eyevel); + + void render(PParticleSystem *psys); + + void drawModel(PModel &model, PSSEffect &ssEffect, PSSTexture &ssTexture); + + void drawText(const std::string &text, uint32 flags); + vec2f getTextDims(const std::string &text); +}; + + + +class PSSTexture : public PSubsystem { +private: + PResourceList texlist; + +public: + PSSTexture(PApp &parentApp); + ~PSSTexture(); + + PTexture *loadTexture(const std::string &name, bool genMipmaps = true, bool clamp = false); +}; + + +class PImage { +private: + uint8 *data; + int cx,cy,cc; + +public: + PImage () : data (null) { } + PImage (const std::string &filename) : data (null) { load (filename); } + PImage (int _cx, int _cy, int _cc) : data (null) { load (_cx, _cy, _cc); } + ~PImage (); + + void load (const std::string &filename); + void load (int _cx, int _cy, int _cc); + void unload (); + + void expandChannels(); + + int getcx() const { return cx; } + int getcy() const { return cy; } + int getcc() const { return cc; } + uint8 *getData() { return data; } + + void swap (PImage &other) throw () + { + { uint8 *tmp = data; data = other.data; other.data = tmp; } + { int tmp = cx; cx = other.cx; other.cx = tmp; } + { int tmp = cy; cy = other.cy; other.cy = tmp; } + { int tmp = cc; cc = other.cc; other.cc = tmp; } + } +}; + + +class PTexture : public PResource { +private: + GLuint texid; + GLenum textarget; + +public: + PTexture () : texid (0) { } + PTexture (const std::string &filename, bool genMipmaps, bool clamp) : texid (0) { load (filename, genMipmaps, clamp); } + PTexture (PImage &img, bool genMipmaps, bool clamp) : texid (0) { load (img, genMipmaps, clamp); } + ~PTexture() { unload (); } + + void load (const std::string &filename, bool genMipmaps, bool clamp); + void load(PImage &img, bool genMipmaps = true, bool clamp = false); + void loadPiece(PImage &img, int offx, int offy, int sizex, int sizey, bool genMipmaps = true, bool clamp = false); + void loadAlpha(const std::string &filename, bool genMipmaps = true, bool clamp = false); + void loadAlpha(PImage &img, bool genMipmaps = true, bool clamp = false); + void loadCubeMap(const std::string &filenamePrefix, const std::string &filenameSuffix, bool genMipmaps = true); + void unload(); + + void bind() const; + + static void unbind(); +}; + + + + +class PSSEffect : public PSubsystem { +private: + PResourceList fxlist; + +public: + PSSEffect(PApp &parentApp); + ~PSSEffect(); + + PEffect *loadEffect(const std::string &name); +}; + + + +#define CULLFACE_NONE 0 +#define CULLFACE_CW 1 +#define CULLFACE_CCW 2 + +#define BLEND_NONE 0 +#define BLEND_ADD 1 +#define BLEND_MULTIPLY 2 +#define BLEND_ALPHA 3 +#define BLEND_PREMULTALPHA 4 + + +struct fx_renderstate_s { + bool depthtest; + + bool lighting; + bool lightmodeltwoside; + + struct { + GLenum func; + float ref; + } alphatest; + + int cullface; + + int blendmode; + + struct { + int texindex; + } texunit[1]; +}; + + +struct fx_pass_s { + fx_renderstate_s rs; +}; + +struct fx_technique_s { + std::string name; + + std::vector pass; + + bool validated; + bool textures_ready; + + fx_technique_s() { + validated = false; + textures_ready = false; + } +}; + +struct fx_texture_s { + std::string name; + + std::string filename; + + GLenum type; + + // This is filled in just before rendering + PTexture *texobject; + + fx_texture_s() { + texobject = null; + } +}; + + +class PEffect : public PResource { +private: + // resources + std::vector tex; + + // techniques + std::vector tech; + + int cur_tech; + +public: + PEffect(const std::string &filename); + ~PEffect(); + + void unload(); + + int getNumTechniques(); + bool validateTechnique(int technique); + const std::string &getTechniqueName(int technique); + bool findTechnique(const std::string &techname, int *technique); + + bool setCurrentTechnique(int technique); + int getCurrentTechnique(); + + bool setFirstValidTechnique(); + + bool renderBegin(int *numPasses, PSSTexture &sstex); + void renderPass(int pass); + void renderEnd(); + +private: + void migrateRenderState(fx_renderstate_s *rs_old, fx_renderstate_s *rs_new); +}; + + + + +class PSSModel : public PSubsystem { +private: + PResourceList modlist; + +public: + PSSModel(PApp &parentApp); + ~PSSModel(); + + PModel *loadModel(const std::string &name); +}; + + +class PFace { +public: + vec3f facenormal; + uint32 vt[3]; + uint32 tc[3]; + uint32 nr[3]; + +public: +// PFace(vec +}; + + +class PMesh { +public: + std::vector vert; + std::vector texco; + std::vector norm; + std::vector face; + + std::string fxname; + PEffect *effect; +}; + + +class PModel : public PResource { +public: + std::vector mesh; + + std::pair getExtents() const; + +public: + PModel (const std::string &filename, float globalScale = 1.0); + +private: + void loadASE (const std::string &filename, float globalScale); +}; + +struct PTerrainFoliageBand { + float middle, range; + float density; + int trycount; + + PTexture *sprite_tex; + int sprite_count; +}; + +struct PTerrainFoliage { + vec3f pos; + float ang; + float scale; +}; + +struct PTerrainFoliageSet { + std::vector inst; + + PVBuffer buff[2]; + int numvert, numelem; +}; + +struct PTerrainTile { + int posx, posy; + int lru_counter; + + PVBuffer vert; + int numverts; + + PTexture tex; + + vec3f mins,maxs; // AABB + + // + + std::vector foliage; +}; + + +class PTerrain // TODO: make this RAII conformant +{ +protected: + bool loaded; + + int tilesize, tilecount, totsize, totmask, totsizesq; + + float scale_hz, scale_vt, scale_hz_inv, scale_vt_inv, scale_tile_inv; + + int cmaptotsize, cmaptilesize, cmaptotmask; + + //std::vector hmap; + std::vector hmap; + + PImage cmap; + + std::vector fmap; + std::vector foliageband; + + std::list tile; + + // tiles share index buffers + PVBuffer ind; + int numinds; + + PTexture *tex_hud_map; + +protected: + + PTerrainTile *getTile(int x, int y); + + float getInterp(float x, float y, float *data) { + x *= scale_hz_inv; + int xi = (int)x; + if (x < 0.0) xi--; + x -= (float)xi; + int xiw = xi & totmask, xiw2 = (xiw+1) & totmask; + + y *= scale_hz_inv; + int yi = (int)y; + if (y < 0.0) yi--; + y -= (float)yi; + int yiw = yi & totmask, yiw2 = (yiw+1) & totmask; + + const int cx = totsize; + + float xv1,xv2; + if (y > 0.0) { + if (y < 1.0) { + if (x < y) { + xv1 = data[yiw*cx+xiw]; + xv2 = INTERP(data[yiw2*cx+xiw],data[yiw2*cx+xiw2],x/y); + } else { + xv1 = INTERP(data[yiw*cx+xiw],data[yiw*cx+xiw2],(x-y)/(1.0-y)); + xv2 = data[yiw2*cx+xiw2]; + } + return INTERP(xv1,xv2,y); + } else { + return INTERP(data[yiw2*cx+xiw],data[yiw2*cx+xiw2],x); + } + } else { + return INTERP(data[yiw*cx+xiw],data[yiw*cx+xiw2],x); + } + } + +public: + PTerrain(TiXmlElement *element, const std::string &filepath, PSSTexture &ssTexture); + ~PTerrain(); + + void unload(); + + void render(const vec3f &campos, const mat44f &camorim); + + void drawSplat(float x, float y, float scale, float angle); + + + struct ContactInfo { + vec3f pos; + vec3f normal; + }; + + void getContactInfo(ContactInfo &tci) { + float x = tci.pos.x * scale_hz_inv; + int xi = (int)x; + if (x < 0.0) xi--; + x -= (float)xi; + int xiw = xi & totmask, xiw2 = (xi+1) & totmask; + + float y = tci.pos.y * scale_hz_inv; + int yi = (int)y; + if (y < 0.0) yi--; + y -= (float)yi; + int yiw = yi & totmask, yiw2 = (yi+1) & totmask; + + float *data = &hmap[0]; + const int cx = totsize; + + float xv1,xv2; + if (y > 0.0) { + if (y < 1.0) { + if (x < y) { + tci.normal.x = data[yiw2*cx+xiw] - data[yiw2*cx+xiw2]; + tci.normal.y = data[yiw*cx+xiw] - data[yiw2*cx+xiw]; + xv1 = data[yiw*cx+xiw]; + xv2 = INTERP(data[yiw2*cx+xiw],data[yiw2*cx+xiw2],x/y); + } else { + tci.normal.x = data[yiw*cx+xiw] - data[yiw*cx+xiw2]; + tci.normal.y = data[yiw*cx+xiw2] - data[yiw2*cx+xiw2]; + xv1 = INTERP(data[yiw*cx+xiw],data[yiw*cx+xiw2],(x-y)/(1.0-y)); + xv2 = data[yiw2*cx+xiw2]; + } + tci.pos.z = INTERP(xv1,xv2,y); + } else { + tci.normal.x = data[yiw2*cx+xiw] - data[yiw2*cx+xiw2]; + tci.normal.y = data[yiw*cx+xiw] - data[yiw2*cx+xiw]; + tci.pos.z = INTERP(data[yiw2*cx+xiw],data[yiw2*cx+xiw2],x); + } + } else { + tci.normal.x = data[yiw*cx+xiw] - data[yiw*cx+xiw2]; + tci.normal.y = data[yiw*cx+xiw2] - data[yiw2*cx+xiw2]; + tci.pos.z = INTERP(data[yiw*cx+xiw],data[yiw*cx+xiw2],x); + } + tci.normal.z = scale_hz; + tci.normal.normalize(); + } + + float getHeight(float x, float y) { + return getInterp(x, y, &hmap[0]); + } + + float getFoliageLevel(float x, float y) { + return getInterp(x, y, &fmap[0]); + } + + PTexture *getHUDMapTexture() { return tex_hud_map; } + + float getMapSize() { return totsize * scale_hz; } +}; + + + + diff -Nru trigger-rally-0.5.2.1/src/pengine/subsys.h trigger-rally-0.6.0/src/pengine/subsys.h --- trigger-rally-0.5.2.1/src/pengine/subsys.h 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/pengine/subsys.h 2011-10-07 17:10:01.000000000 +0000 @@ -1,62 +1,62 @@ - -// subsys.h [pengine] - -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net -// License: GPL version 2 (see included gpl.txt) - - - -class PResource { -protected: - std::string name; - -public: - const std::string &getName() { return name; } -}; - -template -class PResourceList { -private: - std::vector reslist; - -public: - - ~PResourceList() { clear(); } - - T *add(T *newresource) { - reslist.push_back(newresource); - return newresource; - } - T *find(const std::string &name) { - for (typename std::vector::iterator i = reslist.begin(); i != reslist.end(); i++) - if (name == (*i)->getName()) - return *i; - return null; - } - - void clear() { - for (typename std::vector::iterator i = reslist.begin(); i != reslist.end(); i++) { - delete *i; - } - reslist.clear(); - } -}; - - -class PSubsystem { -protected: - PApp &app; - -private: - // init() is deprecated, should use RAII now - virtual bool init() { return true; } - -public: - PSubsystem(PApp &parentApp) : app(parentApp) { } - virtual ~PSubsystem() { } - virtual void tick(float delta, const vec3f &eyepos, const mat44f &eyeori, const vec3f &eyevel) - { float blah = delta; blah = eyepos.x; blah = eyeori.row[0][0]; blah = eyevel.x; } -}; - - - + +// subsys.h [pengine] + +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net +// License: GPL version 2 (see included gpl.txt) + + + +class PResource { +protected: + std::string name; + +public: + const std::string &getName() { return name; } +}; + +template +class PResourceList { +private: + std::vector reslist; + +public: + + ~PResourceList() { clear(); } + + T *add(T *newresource) { + reslist.push_back(newresource); + return newresource; + } + T *find(const std::string &name) { + for (typename std::vector::iterator i = reslist.begin(); i != reslist.end(); i++) + if (name == (*i)->getName()) + return *i; + return null; + } + + void clear() { + for (typename std::vector::iterator i = reslist.begin(); i != reslist.end(); i++) { + delete *i; + } + reslist.clear(); + } +}; + + +class PSubsystem { +protected: + PApp &app; + +private: + // init() is deprecated, should use RAII now + virtual bool init() { return true; } + +public: + PSubsystem(PApp &parentApp) : app(parentApp) { } + virtual ~PSubsystem() { } + virtual void tick(float delta, const vec3f &eyepos, const mat44f &eyeori, const vec3f &eyevel) + { float blah = delta; blah = eyepos.x; blah = eyeori.row[0][0]; blah = eyevel.x; } +}; + + + diff -Nru trigger-rally-0.5.2.1/src/pengine/terrain.cpp trigger-rally-0.6.0/src/pengine/terrain.cpp --- trigger-rally-0.5.2.1/src/pengine/terrain.cpp 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/pengine/terrain.cpp 2011-10-07 17:10:01.000000000 +0000 @@ -1,7 +1,7 @@ // terrain.cpp [pengine] -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net // License: GPL version 2 (see included gpl.txt) @@ -11,676 +11,676 @@ PTerrain::~PTerrain () { - unload(); + unload(); } void PTerrain::unload() { - loaded = false; + loaded = false; - tile.clear(); + tile.clear(); - hmap.clear(); + hmap.clear(); } PTerrain::PTerrain (TiXmlElement *element, const std::string &filepath, PSSTexture &ssTexture) : - loaded (false) + loaded (false) { - unload(); - - std::string heightmap, colormap, foliagemap, hudmap; - - scale_hz = 1.0; - scale_vt = 1.0; - - const char *val; - - val = element->Attribute("tilesize"); - if (val) tilesize = atoi(val); - - val = element->Attribute("horizontalscale"); - if (val) scale_hz = atof(val); - - val = element->Attribute("verticalscale"); - if (val) scale_vt = atof(val); - - val = element->Attribute("heightmap"); - if (val) heightmap = val; - - val = element->Attribute("colormap"); - if (val) colormap = val; - - val = element->Attribute("foliagemap"); - if (val) foliagemap = val; - - val = element->Attribute("hudmap"); - if (val) hudmap = val; - - for (TiXmlElement *walk = element->FirstChildElement(); - walk; walk = walk->NextSiblingElement()) { - - if (!strcmp(walk->Value(), "foliageband")) { - - PTerrainFoliageBand tfb; - tfb.middle = 0.5f; - tfb.range = 0.5f; - tfb.density = 1.0f; - //tfb.model = null; - //tfb.modelscale = 1.0f; - tfb.sprite_tex = null; - tfb.sprite_count = 1; - - val = walk->Attribute("middle"); - if (val) tfb.middle = atof(val); - - val = walk->Attribute("range"); - if (val) tfb.range = atof(val); - - val = walk->Attribute("density"); - if (val) tfb.density = atof(val); - - /* - val = walk->Attribute("model"); - if (val) tfb.model = ssModel.loadModel(PUtil::assemblePath(val, filepath)); - - val = walk->Attribute("modelscale"); - if (val) tfb.modelscale = atof(val); - */ - - val = walk->Attribute("sprite"); - if (val) tfb.sprite_tex = ssTexture.loadTexture(PUtil::assemblePath(val, filepath)); - - val = walk->Attribute("spritecount"); - if (val) tfb.sprite_count = atoi(val); - - foliageband.push_back(tfb); - } - } - - - if (!heightmap.length()) { - throw MakePException ("Load failed: terrain has no heightmap"); - } - - if (!colormap.length()) { - throw MakePException ("Load failed: terrain has no colormap"); - } - - if (tilesize != tilesize & (-tilesize) || - tilesize < 4) { - throw MakePException ("Load failed: tile size not power of two dimension, or too small"); - } - - if (scale_hz <= 0.0 || scale_vt == 0.0) { - throw MakePException ("Load failed: invalid scale value"); - } - - scale_hz_inv = 1.0 / scale_hz; - scale_vt_inv = 1.0 / scale_vt; - scale_tile_inv = scale_hz_inv / (float)tilesize; - - PImage img; - try - { - img.load (PUtil::assemblePath (heightmap, filepath)); - } - catch (...) - { - PUtil::outLog() << "Load failed: couldn't open heightmap \"" << heightmap << "\"\n"; - throw; - } - - totsize = img.getcx(); - if (totsize != img.getcy() || - totsize != totsize & (-totsize) || - totsize < 16) { - throw MakePException ("Load failed: heightmap not square, or not power of two dimension, or too small"); - } - - totsizesq = totsize * totsize; - - if (tilesize > totsize) tilesize = totsize; - - tilecount = totsize / tilesize; - totmask = totsize - 1; - - //PUtil::outLog() << "img: " << totsize << " squared, " << img.getcc() << " cc\n"; - - hmap.resize(totsizesq); - + unload(); + + std::string heightmap, colormap, foliagemap, hudmap; + + scale_hz = 1.0; + scale_vt = 1.0; + + const char *val; + + val = element->Attribute("tilesize"); + if (val) tilesize = atoi(val); + + val = element->Attribute("horizontalscale"); + if (val) scale_hz = atof(val); + + val = element->Attribute("verticalscale"); + if (val) scale_vt = atof(val); + + val = element->Attribute("heightmap"); + if (val) heightmap = val; + + val = element->Attribute("colormap"); + if (val) colormap = val; + + val = element->Attribute("foliagemap"); + if (val) foliagemap = val; + + val = element->Attribute("hudmap"); + if (val) hudmap = val; + + for (TiXmlElement *walk = element->FirstChildElement(); + walk; walk = walk->NextSiblingElement()) { + + if (!strcmp(walk->Value(), "foliageband")) { + + PTerrainFoliageBand tfb; + tfb.middle = 0.5f; + tfb.range = 0.5f; + tfb.density = 1.0f; + //tfb.model = null; + //tfb.modelscale = 1.0f; + tfb.sprite_tex = null; + tfb.sprite_count = 1; + + val = walk->Attribute("middle"); + if (val) tfb.middle = atof(val); + + val = walk->Attribute("range"); + if (val) tfb.range = atof(val); + + val = walk->Attribute("density"); + if (val) tfb.density = atof(val); + + /* + val = walk->Attribute("model"); + if (val) tfb.model = ssModel.loadModel(PUtil::assemblePath(val, filepath)); + + val = walk->Attribute("modelscale"); + if (val) tfb.modelscale = atof(val); + */ + + val = walk->Attribute("sprite"); + if (val) tfb.sprite_tex = ssTexture.loadTexture(PUtil::assemblePath(val, filepath)); + + val = walk->Attribute("spritecount"); + if (val) tfb.sprite_count = atoi(val); + + foliageband.push_back(tfb); + } + } + + + if (!heightmap.length()) { + throw MakePException ("Load failed: terrain has no heightmap"); + } + + if (!colormap.length()) { + throw MakePException ("Load failed: terrain has no colormap"); + } + + if (tilesize != (tilesize & (-tilesize)) || + tilesize < 4) { + throw MakePException ("Load failed: tile size not power of two dimension, or too small"); + } + + if (scale_hz <= 0.0 || scale_vt == 0.0) { + throw MakePException ("Load failed: invalid scale value"); + } + + scale_hz_inv = 1.0 / scale_hz; + scale_vt_inv = 1.0 / scale_vt; + scale_tile_inv = scale_hz_inv / (float)tilesize; + + PImage img; + try + { + img.load (PUtil::assemblePath (heightmap, filepath)); + } + catch (...) + { + PUtil::outLog() << "Load failed: couldn't open heightmap \"" << heightmap << "\"\n"; + throw; + } + + totsize = img.getcx(); + if (totsize != img.getcy() || + totsize != (totsize & (-totsize)) || + totsize < 16) { + throw MakePException ("Load failed: heightmap not square, or not power of two dimension, or too small"); + } + + totsizesq = totsize * totsize; + + if (tilesize > totsize) tilesize = totsize; + + tilecount = totsize / tilesize; + totmask = totsize - 1; + + //PUtil::outLog() << "img: " << totsize << " squared, " << img.getcc() << " cc\n"; + + hmap.resize(totsizesq); + #if 0 - if (img.getcc() != 1) { - if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) - PUtil::outLog() << "Warning: heightmap is not single channel\n"; - int cc = img.getcc(); - uint8 *dat = img.getData(); - for (int s=0, d=0; d 0) { - index = 0 + add1; - ramfile.write(&index, sizeof(uint16)); - numinds += 1; - } - for (int x=0; x 0) { + index = 0 + add1; + ramfile.write(&index, sizeof(uint16)); + numinds += 1; + } + for (int x=0; x::iterator iter = tile.begin(); - iter != tile.end(); ++iter) { - if (iter->posx == tilex && iter->posy == tiley) { - iter->lru_counter = 0; - //PUtil::outLog() << "1: " << tilex << " " << tiley << std::endl; - return &*iter; - } - - if (best_lru < iter->lru_counter) { - best_lru = iter->lru_counter; - tileptr = &*iter; - } - - if (iter->lru_counter > 1) ++unused; - } - - // if there aren't enough unused tiles, create a new one - - if (unused < 10 || best_lru <= 1) { - tile.push_back(PTerrainTile()); - tileptr = &tile.back(); - } - - tileptr->posx = tilex; - tileptr->posy = tiley; - tileptr->lru_counter = 0; - - tileptr->mins = vec3f((float)tilex * scale_hz, (float)tiley * scale_hz, 1000000000.0); - tileptr->maxs = vec3f((float)(tilex+1) * scale_hz, (float)(tiley+1) * scale_hz, -1000000000.0); - - // TODO: quadtree based thing - - //std::vector - - static PRamFile ramfile1, ramfile2; - - ramfile1.clear(); - - int tileoffsety = tiley * tilesize; - int tileoffsetx = tilex * tilesize; - int tilesizep1 = tilesize + 1; - for (int y=0; ymins.z > vert.z) - tileptr->mins.z = vert.z; - if (tileptr->maxs.z < vert.z) - tileptr->maxs.z = vert.z; - } - } - tileptr->vert.create(ramfile1.getSize(), PVBuffer::VertexContent, PVBuffer::StaticUsage, ramfile1.getData()); - - //tileptr->maxs.z += 10.0; - - //tileptr->mins = vec3f((float)tilex * scale_hz, (float)tiley * scale_hz, 0.0); - //tileptr->maxs = vec3f((float)(tilex+1) * scale_hz, (float)(tiley+1) * scale_hz, 100.0); - - tileptr->numverts = tilesizep1 * tilesizep1; - - tileptr->tex.loadPiece(cmap, - (tilex * cmaptilesize) & cmaptotmask, (tiley * cmaptilesize) & cmaptotmask, - cmaptilesize, cmaptilesize, true, true); - - // Create foliage - - srand(1); - - tileptr->foliage.resize(foliageband.size()); - - for (unsigned int b = 0; b < foliageband.size(); b++) { - - tileptr->foliage[b].inst.clear(); - - // Create foliage instances - - for (int i = 0; i < foliageband[b].trycount; i++) { - - vec2f ftry = vec2f( - (float)((tileptr->posx * tilesize) + rand01 * tilesize) * scale_hz, - (float)((tileptr->posy * tilesize) + rand01 * tilesize) * scale_hz); - - float fol = getFoliageLevel(ftry.x, ftry.y); - - if ((1.0 - fabs((fol - foliageband[b].middle) / foliageband[b].range)) < rand01) continue; - - tileptr->foliage[b].inst.push_back(PTerrainFoliage()); - tileptr->foliage[b].inst.back().pos.x = ftry.x; - tileptr->foliage[b].inst.back().pos.y = ftry.y; - tileptr->foliage[b].inst.back().pos.z = getHeight(ftry.x, ftry.y); - tileptr->foliage[b].inst.back().ang = rand01 * PI*2.0f; - tileptr->foliage[b].inst.back().scale = (1.0f + fol * 0.5f) * (rand01 * rand01 + 0.5) * 1.4; - } - - // Create vertex buffers for rendering - + // find the least recently used tile while searching for x,y + int best_lru = 0, unused = 0; + PTerrainTile *tileptr = null; + for (std::list::iterator iter = tile.begin(); + iter != tile.end(); ++iter) { + if (iter->posx == tilex && iter->posy == tiley) { + iter->lru_counter = 0; + //PUtil::outLog() << "1: " << tilex << " " << tiley << std::endl; + return &*iter; + } + + if (best_lru < iter->lru_counter) { + best_lru = iter->lru_counter; + tileptr = &*iter; + } + + if (iter->lru_counter > 1) ++unused; + } + + // if there aren't enough unused tiles, create a new one + + if (unused < 10 || best_lru <= 1) { + tile.push_back(PTerrainTile()); + tileptr = &tile.back(); + } + + tileptr->posx = tilex; + tileptr->posy = tiley; + tileptr->lru_counter = 0; + + tileptr->mins = vec3f((float)tilex * scale_hz, (float)tiley * scale_hz, 1000000000.0); + tileptr->maxs = vec3f((float)(tilex+1) * scale_hz, (float)(tiley+1) * scale_hz, -1000000000.0); + + // TODO: quadtree based thing + + //std::vector + + static PRamFile ramfile1, ramfile2; + + ramfile1.clear(); + + int tileoffsety = tiley * tilesize; + int tileoffsetx = tilex * tilesize; + int tilesizep1 = tilesize + 1; + for (int y=0; ymins.z > vert.z) + tileptr->mins.z = vert.z; + if (tileptr->maxs.z < vert.z) + tileptr->maxs.z = vert.z; + } + } + tileptr->vert.create(ramfile1.getSize(), PVBuffer::VertexContent, PVBuffer::StaticUsage, ramfile1.getData()); + + //tileptr->maxs.z += 10.0; + + //tileptr->mins = vec3f((float)tilex * scale_hz, (float)tiley * scale_hz, 0.0); + //tileptr->maxs = vec3f((float)(tilex+1) * scale_hz, (float)(tiley+1) * scale_hz, 100.0); + + tileptr->numverts = tilesizep1 * tilesizep1; + + tileptr->tex.loadPiece(cmap, + (tilex * cmaptilesize) & cmaptotmask, (tiley * cmaptilesize) & cmaptotmask, + cmaptilesize, cmaptilesize, true, true); + + // Create foliage + + srand(1); + + tileptr->foliage.resize(foliageband.size()); + + for (unsigned int b = 0; b < foliageband.size(); b++) { + + tileptr->foliage[b].inst.clear(); + + // Create foliage instances + + for (int i = 0; i < foliageband[b].trycount; i++) { + + vec2f ftry = vec2f( + (float)((tileptr->posx * tilesize) + rand01 * tilesize) * scale_hz, + (float)((tileptr->posy * tilesize) + rand01 * tilesize) * scale_hz); + + float fol = getFoliageLevel(ftry.x, ftry.y); + + if ((1.0 - fabs((fol - foliageband[b].middle) / foliageband[b].range)) < rand01) continue; + + tileptr->foliage[b].inst.push_back(PTerrainFoliage()); + tileptr->foliage[b].inst.back().pos.x = ftry.x; + tileptr->foliage[b].inst.back().pos.y = ftry.y; + tileptr->foliage[b].inst.back().pos.z = getHeight(ftry.x, ftry.y); + tileptr->foliage[b].inst.back().ang = rand01 * PI*2.0f; + tileptr->foliage[b].inst.back().scale = (1.0f + fol * 0.5f) * (rand01 * rand01 + 0.5) * 1.4; + } + + // Create vertex buffers for rendering + #define HMULT 1.0 #define VMULT 2.0 - - ramfile1.clear(); - ramfile2.clear(); - - tileptr->foliage[b].numvert = 0; - tileptr->foliage[b].numelem = 0; - - float angincr = PI / (float)foliageband[b].sprite_count; - for (unsigned int j=0; jfoliage[b].inst.size(); j++) { - for (float anga = 0.0f; anga < PI - 0.01f; anga += angincr) { - float interang = tileptr->foliage[b].inst[j].ang + anga; - int stv = tileptr->foliage[b].numvert; - PVert_tv tmpv; - - tmpv.xyz = tileptr->foliage[b].inst[j].pos + - vec3f(cos(interang)*HMULT,sin(interang)*HMULT,0.0f) * tileptr->foliage[b].inst[j].scale; - tmpv.st = vec2f(1.0f,0.0f); - ramfile1.write(&tmpv,sizeof(PVert_tv)); - tileptr->foliage[b].numvert++; - - tmpv.xyz = tileptr->foliage[b].inst[j].pos + - vec3f(-cos(interang)*HMULT,-sin(interang)*HMULT,0.0f) * tileptr->foliage[b].inst[j].scale; - tmpv.st = vec2f(0.0f,0.0f); - ramfile1.write(&tmpv,sizeof(PVert_tv)); - tileptr->foliage[b].numvert++; - - tmpv.xyz = tileptr->foliage[b].inst[j].pos + - vec3f(-cos(interang)*HMULT,-sin(interang)*HMULT,VMULT) * tileptr->foliage[b].inst[j].scale; - tmpv.st = vec2f(0.0f,1.0f-1.0f/32.0f); - ramfile1.write(&tmpv,sizeof(PVert_tv)); - tileptr->foliage[b].numvert++; - - tmpv.xyz = tileptr->foliage[b].inst[j].pos + - vec3f(cos(interang)*HMULT,sin(interang)*HMULT,VMULT) * tileptr->foliage[b].inst[j].scale; - tmpv.st = vec2f(1.0f,1.0f-1.0f/32.0f); - ramfile1.write(&tmpv,sizeof(PVert_tv)); - tileptr->foliage[b].numvert++; - - int ind; - ind = stv + 0; - ramfile2.write(&ind,sizeof(uint32)); - tileptr->foliage[b].numelem++; - ind = stv + 1; - ramfile2.write(&ind,sizeof(uint32)); - tileptr->foliage[b].numelem++; - ind = stv + 2; - ramfile2.write(&ind,sizeof(uint32)); - tileptr->foliage[b].numelem++; - ind = stv + 0; - ramfile2.write(&ind,sizeof(uint32)); - tileptr->foliage[b].numelem++; - ind = stv + 2; - ramfile2.write(&ind,sizeof(uint32)); - tileptr->foliage[b].numelem++; - ind = stv + 3; - ramfile2.write(&ind,sizeof(uint32)); - tileptr->foliage[b].numelem++; - } - } - - if (tileptr->foliage[b].numelem) { - tileptr->foliage[b].buff[0].create(ramfile1.getSize(), - PVBuffer::VertexContent, PVBuffer::StaticUsage, ramfile1.getData()); - tileptr->foliage[b].buff[1].create(ramfile2.getSize(), - PVBuffer::IndexContent, PVBuffer::StaticUsage, ramfile2.getData()); - } - } - - //PUtil::outLog() << "2: " << tileptr->posx << " " << tileptr->posy << std::endl; - return tileptr; + + ramfile1.clear(); + ramfile2.clear(); + + tileptr->foliage[b].numvert = 0; + tileptr->foliage[b].numelem = 0; + + float angincr = PI / (float)foliageband[b].sprite_count; + for (unsigned int j=0; jfoliage[b].inst.size(); j++) { + for (float anga = 0.0f; anga < PI - 0.01f; anga += angincr) { + float interang = tileptr->foliage[b].inst[j].ang + anga; + int stv = tileptr->foliage[b].numvert; + PVert_tv tmpv; + + tmpv.xyz = tileptr->foliage[b].inst[j].pos + + vec3f(cos(interang)*HMULT,sin(interang)*HMULT,0.0f) * tileptr->foliage[b].inst[j].scale; + tmpv.st = vec2f(1.0f,0.0f); + ramfile1.write(&tmpv,sizeof(PVert_tv)); + tileptr->foliage[b].numvert++; + + tmpv.xyz = tileptr->foliage[b].inst[j].pos + + vec3f(-cos(interang)*HMULT,-sin(interang)*HMULT,0.0f) * tileptr->foliage[b].inst[j].scale; + tmpv.st = vec2f(0.0f,0.0f); + ramfile1.write(&tmpv,sizeof(PVert_tv)); + tileptr->foliage[b].numvert++; + + tmpv.xyz = tileptr->foliage[b].inst[j].pos + + vec3f(-cos(interang)*HMULT,-sin(interang)*HMULT,VMULT) * tileptr->foliage[b].inst[j].scale; + tmpv.st = vec2f(0.0f,1.0f-1.0f/32.0f); + ramfile1.write(&tmpv,sizeof(PVert_tv)); + tileptr->foliage[b].numvert++; + + tmpv.xyz = tileptr->foliage[b].inst[j].pos + + vec3f(cos(interang)*HMULT,sin(interang)*HMULT,VMULT) * tileptr->foliage[b].inst[j].scale; + tmpv.st = vec2f(1.0f,1.0f-1.0f/32.0f); + ramfile1.write(&tmpv,sizeof(PVert_tv)); + tileptr->foliage[b].numvert++; + + int ind; + ind = stv + 0; + ramfile2.write(&ind,sizeof(uint32)); + tileptr->foliage[b].numelem++; + ind = stv + 1; + ramfile2.write(&ind,sizeof(uint32)); + tileptr->foliage[b].numelem++; + ind = stv + 2; + ramfile2.write(&ind,sizeof(uint32)); + tileptr->foliage[b].numelem++; + ind = stv + 0; + ramfile2.write(&ind,sizeof(uint32)); + tileptr->foliage[b].numelem++; + ind = stv + 2; + ramfile2.write(&ind,sizeof(uint32)); + tileptr->foliage[b].numelem++; + ind = stv + 3; + ramfile2.write(&ind,sizeof(uint32)); + tileptr->foliage[b].numelem++; + } + } + + if (tileptr->foliage[b].numelem) { + tileptr->foliage[b].buff[0].create(ramfile1.getSize(), + PVBuffer::VertexContent, PVBuffer::StaticUsage, ramfile1.getData()); + tileptr->foliage[b].buff[1].create(ramfile2.getSize(), + PVBuffer::IndexContent, PVBuffer::StaticUsage, ramfile2.getData()); + } + } + + //PUtil::outLog() << "2: " << tileptr->posx << " " << tileptr->posy << std::endl; + return tileptr; } void PTerrain::render(const vec3f &campos, const mat44f &camorim) { - float blah = camorim.row[0][0]; blah = blah; // unused - - // increase all lru counters - for (std::list::iterator iter = tile.begin(); - iter != tile.end(); ++iter) ++iter->lru_counter; - - // get frustum - frustumf frust; - { - mat44f mat_mv, mat_p, mat_c; - - glGetFloatv(GL_MODELVIEW_MATRIX, mat_mv); - glGetFloatv(GL_PROJECTION_MATRIX, mat_p); - - mat_c = mat_mv.concatenate(mat_p); - - frust.construct(mat_c); - } - - int ctx = (int)(campos.x * scale_tile_inv); - if (campos.x < 0.0) --ctx; - int cty = (int)(campos.y * scale_tile_inv); - if (campos.y < 0.0) --cty; - - int mintx = ctx - 3, - maxtx = ctx + 4, - minty = cty - 3, - maxty = cty + 4; - - // Determine list of tiles to draw - - std::list drawtile; - - for (int ty = minty; ty < maxty; ++ty) { - for (int tx = mintx; tx < maxtx; ++tx) { - drawtile.push_back(getTile(tx,ty)); - } - } - - // Draw terrain - - glEnable(GL_TEXTURE_GEN_S); - glEnable(GL_TEXTURE_GEN_T); - - float tgens[] = { scale_tile_inv, 0.0, 0.0, 0.0 }; - float tgent[] = { 0.0, scale_tile_inv, 0.0, 0.0 }; - glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); - glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); - - glEnableClientState(GL_VERTEX_ARRAY); - - for (std::list::iterator t = drawtile.begin(); t != drawtile.end(); t++) { - //if (frust.isAABBOutside(tileptr->mins, tileptr->maxs)) - // glColor3f(1,0,0); - //else - // glColor3f(1,1,1); - - tgens[3] = (float) (- (*t)->posx); - tgent[3] = (float) (- (*t)->posy); - - glTexGenfv(GL_S, GL_OBJECT_PLANE, tgens); - glTexGenfv(GL_T, GL_OBJECT_PLANE, tgent); - - // Texture - (*t)->tex.bind(); - - // Vertex buffers - (*t)->vert.bind(); - ind.bind(); - glVertexPointer(3, GL_FLOAT, sizeof(vec3f), (*t)->vert.getPointer(0)); - - glDrawRangeElements(GL_TRIANGLE_STRIP, 0, (*t)->numverts, - numinds, GL_UNSIGNED_SHORT, ind.getPointer(0)); - } - - glDisableClientState(GL_VERTEX_ARRAY); - - PVBuffer::unbind(); - - glDisable(GL_TEXTURE_GEN_S); - glDisable(GL_TEXTURE_GEN_T); - - // Draw foliage - #if 1 - glAlphaFunc(GL_GEQUAL, 0.5); - glEnable(GL_ALPHA_TEST); - glDisable(GL_CULL_FACE); - glColor3f(1.0f, 1.0f, 1.0f); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glEnableClientState(GL_VERTEX_ARRAY); - - for (unsigned int b = 0; b < foliageband.size(); b++) { - - foliageband[b].sprite_tex->bind(); - - for (std::list::iterator t = drawtile.begin(); t != drawtile.end(); t++) { - - if ((*t)->foliage[b].numelem) { - (*t)->foliage[b].buff[0].bind(); // vert data - (*t)->foliage[b].buff[1].bind(); // indices - - glTexCoordPointer(2, GL_FLOAT, sizeof(PVert_tv), (*t)->foliage[b].buff[0].getPointer(0)); - glVertexPointer(3, GL_FLOAT, sizeof(PVert_tv), (*t)->foliage[b].buff[0].getPointer(sizeof(float)*2)); - - glDrawRangeElements(GL_TRIANGLES, - 0,(*t)->foliage[b].numvert,(*t)->foliage[b].numelem, - GL_UNSIGNED_INT,(*t)->foliage[b].buff[1].getPointer(0)); - } - - #if 0 - for (std::vector::iterator f = (*t)->foliage.begin(); f != (*t)->foliage.end(); f++) { - - #if 0 - glBegin(GL_LINES); - vec3f pos = f->pos; - glVertex3fv(pos); - pos += vec3f(0.0f, 0.0f, 2.0f); - glVertex3fv(pos); - glEnd(); - #endif - - #if 0 - if (!f->tfb->model) continue; - - glPushMatrix(); - vec3f &pos = f->pos; - glTranslatef(pos.x, pos.y, pos.z); - glScalef(f->tfb->modelscale, f->tfb->modelscale, f->tfb->modelscale); - ssRender.drawModel(*f->tfb->model, ssEffect, ssTexture); - glPopMatrix(); - #endif - } - #endif - } - } - #endif - - PVBuffer::unbind(); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); - glEnable(GL_CULL_FACE); - glDisable(GL_ALPHA_TEST); + float blah = camorim.row[0][0]; blah = blah; // unused + + // increase all lru counters + for (std::list::iterator iter = tile.begin(); + iter != tile.end(); ++iter) ++iter->lru_counter; + + // get frustum + frustumf frust; + { + mat44f mat_mv, mat_p, mat_c; + + glGetFloatv(GL_MODELVIEW_MATRIX, mat_mv); + glGetFloatv(GL_PROJECTION_MATRIX, mat_p); + + mat_c = mat_mv.concatenate(mat_p); + + frust.construct(mat_c); + } + + int ctx = (int)(campos.x * scale_tile_inv); + if (campos.x < 0.0) --ctx; + int cty = (int)(campos.y * scale_tile_inv); + if (campos.y < 0.0) --cty; + + int mintx = ctx - 3, + maxtx = ctx + 4, + minty = cty - 3, + maxty = cty + 4; + + // Determine list of tiles to draw + + std::list drawtile; + + for (int ty = minty; ty < maxty; ++ty) { + for (int tx = mintx; tx < maxtx; ++tx) { + drawtile.push_back(getTile(tx,ty)); + } + } + + // Draw terrain + + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_GEN_T); + + float tgens[] = { scale_tile_inv, 0.0, 0.0, 0.0 }; + float tgent[] = { 0.0, scale_tile_inv, 0.0, 0.0 }; + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); + + glEnableClientState(GL_VERTEX_ARRAY); + + for (std::list::iterator t = drawtile.begin(); t != drawtile.end(); t++) { + //if (frust.isAABBOutside(tileptr->mins, tileptr->maxs)) + // glColor3f(1,0,0); + //else + // glColor3f(1,1,1); + + tgens[3] = (float) (- (*t)->posx); + tgent[3] = (float) (- (*t)->posy); + + glTexGenfv(GL_S, GL_OBJECT_PLANE, tgens); + glTexGenfv(GL_T, GL_OBJECT_PLANE, tgent); + + // Texture + (*t)->tex.bind(); + + // Vertex buffers + (*t)->vert.bind(); + ind.bind(); + glVertexPointer(3, GL_FLOAT, sizeof(vec3f), (*t)->vert.getPointer(0)); + + glDrawRangeElements(GL_TRIANGLE_STRIP, 0, (*t)->numverts, + numinds, GL_UNSIGNED_SHORT, ind.getPointer(0)); + } + + glDisableClientState(GL_VERTEX_ARRAY); + + PVBuffer::unbind(); + + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + + // Draw foliage + #if 1 + glAlphaFunc(GL_GEQUAL, 0.5); + glEnable(GL_ALPHA_TEST); + glDisable(GL_CULL_FACE); + glColor3f(1.0f, 1.0f, 1.0f); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glEnableClientState(GL_VERTEX_ARRAY); + + for (unsigned int b = 0; b < foliageband.size(); b++) { + + foliageband[b].sprite_tex->bind(); + + for (std::list::iterator t = drawtile.begin(); t != drawtile.end(); t++) { + + if ((*t)->foliage[b].numelem) { + (*t)->foliage[b].buff[0].bind(); // vert data + (*t)->foliage[b].buff[1].bind(); // indices + + glTexCoordPointer(2, GL_FLOAT, sizeof(PVert_tv), (*t)->foliage[b].buff[0].getPointer(0)); + glVertexPointer(3, GL_FLOAT, sizeof(PVert_tv), (*t)->foliage[b].buff[0].getPointer(sizeof(float)*2)); + + glDrawRangeElements(GL_TRIANGLES, + 0,(*t)->foliage[b].numvert,(*t)->foliage[b].numelem, + GL_UNSIGNED_INT,(*t)->foliage[b].buff[1].getPointer(0)); + } + + #if 0 + for (std::vector::iterator f = (*t)->foliage.begin(); f != (*t)->foliage.end(); f++) { + + #if 0 + glBegin(GL_LINES); + vec3f pos = f->pos; + glVertex3fv(pos); + pos += vec3f(0.0f, 0.0f, 2.0f); + glVertex3fv(pos); + glEnd(); + #endif + + #if 0 + if (!f->tfb->model) continue; + + glPushMatrix(); + vec3f &pos = f->pos; + glTranslatef(pos.x, pos.y, pos.z); + glScalef(f->tfb->modelscale, f->tfb->modelscale, f->tfb->modelscale); + ssRender.drawModel(*f->tfb->model, ssEffect, ssTexture); + glPopMatrix(); + #endif + } + #endif + } + } + #endif + + PVBuffer::unbind(); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_VERTEX_ARRAY); + glEnable(GL_CULL_FACE); + glDisable(GL_ALPHA_TEST); } void PTerrain::drawSplat(float x, float y, float scale, float angle) { - float *hmd = &hmap[0]; - int cx = totsize; - int cy = totsize; - - x *= scale_hz_inv; - y *= scale_hz_inv; - - scale *= 0.5f; - - int miny = (int)(y - scale); - if ((y - scale) < 0.0f) miny--; - int maxy = (int)(y + scale) + 1; - if ((y + scale) < 0.0f) maxy--; - int minx = (int)(x - scale); - if ((x - scale) < 0.0f) minx--; - int maxx = (int)(x + scale) + 2; - if ((x + scale) < 0.0f) maxx--; - - glMatrixMode(GL_TEXTURE); - - glPushMatrix(); - glTranslatef(0.5f, 0.5f, 0.0f); - glRotatef(DEGREES(angle), 0.0f, 0.0f, 1.0f); - glScalef(0.5f / scale, 0.5f / scale, 1.0f); - glTranslatef(-x, -y, 0.0f); - - for (int y2=miny; y2 - - - -// SDL_image doesn't need init/shutdown code - -PSSTexture::PSSTexture(PApp &parentApp) : PSubsystem(parentApp) -{ - app.outLog() << "Initialising texture subsystem [SDL_Image]" << std::endl; -} - -PSSTexture::~PSSTexture() -{ - app.outLog() << "Shutting down texture subsystem" << std::endl; - - texlist.clear(); -} - - - -PTexture *PSSTexture::loadTexture(const std::string &name, bool genMipmaps, bool clamp) -{ - PTexture *tex = texlist.find(name); - if (!tex) { - try - { - tex = new PTexture(name,genMipmaps,clamp); - } - catch (PException e) - { - if (PUtil::isDebugLevel(DEBUGLEVEL_ENDUSER)) - PUtil::outLog() << "Failed to load " << name << ": " << e.what () << std::endl; - return null; - } - texlist.add(tex); - } - return tex; -} - - - -PImage::~PImage() -{ - unload (); -} - -void PImage::unload () -{ - delete[] data; - data = null; -} - -void PImage::load (const std::string &filename) -{ - data = null; - - if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) - PUtil::outLog() << "Loading image \"" << filename << "\"" << std::endl; - - // PhysFS / SDL integration with SDL_rwops - - PHYSFS_file *pfile = PHYSFS_openRead(filename.c_str()); - - if (pfile == null) { - throw MakePException (filename + ", PhysFS: " + PHYSFS_getLastError ()); - } - - SDL_RWops *rwops = PUtil::allocPhysFSops(pfile); - - SDL_Surface *img = IMG_Load_RW(rwops, 1); // this closes file and frees rwops - - if (!img) { - throw MakePException (filename + ", SDL_image: " + IMG_GetError ()); - } - - if (SDL_MUSTLOCK(img)) SDL_LockSurface(img); - - // TGA COLOUR SWITCH HACK - int colmap_normal[] = { 0,1,2,3 }; - int colmap_flipped[] = { 2,1,0,3 }; - int *colmap = colmap_normal; - const char *fname = filename.c_str(); - int len = strlen(fname); - if (len > 4) { - if (!strcmp(fname+len-4,".tga")) colmap = colmap_flipped; - } - - cx = img->w; - cy = img->h; - cc = img->format->BytesPerPixel; - data = new uint8 [cx * cy * cc]; - - for (int y=0; ypixels)[(cy-y-1)*img->pitch + x*cc + c]; - data[(y*cx+x)*cc+c] = ((uint8*)img->pixels)[(cy-y-1)*img->pitch + x*cc + colmap[c]]; - } - } - } - - if (SDL_MUSTLOCK(img)) SDL_UnlockSurface(img); - SDL_FreeSurface(img); -} - -void PImage::load (int _cx, int _cy, int _cc) -{ - cx = _cx; - cy = _cy; - cc = _cc; - - data = new uint8 [cx * cy * cc]; -} - - - -void PTexture::unload() -{ - if (texid) - { - glDeleteTextures (1, &texid); - texid = 0; - } -} - -void PTexture::load (const std::string &filename, bool genMipmaps, bool clamp) -{ - PImage image (filename); - load (image, genMipmaps, clamp); - name = filename; -} - -void PTexture::load (PImage &img, bool genMipmaps, bool clamp) -{ - unload(); - - textarget = GL_TEXTURE_2D; - -#ifdef USE_GEN_MIPMAPS - if (genMipmaps && !extgl_Extensions.SGIS_generate_mipmap) { - PUtil::outLog() << "warning: can't generate mipmaps for texture" << std::endl; - genMipmaps = false; - } -#endif - - GLuint fmt,fmt2; - - switch (img.getcc()) { - case 1: - fmt = GL_LUMINANCE; fmt2 = GL_LUMINANCE8; break; - case 2: - fmt = GL_LUMINANCE_ALPHA; fmt2 = GL_LUMINANCE8_ALPHA8; break; - case 3: - fmt = GL_RGB; fmt2 = GL_RGB8; break; - case 4: - fmt = GL_RGBA; fmt2 = GL_RGBA8; break; - default: - throw MakePException ("loading texture failed, unknown image format"); - } - - int cx = img.getcx(), cy = img.getcy(); - int newcx=1, newcy=1, max; - while (newcx < cx) newcx *= 2; - while (newcy < cy) newcy *= 2; - glGetIntegerv(GL_MAX_TEXTURE_SIZE,&max); - if (newcx > max) newcx = max; - if (newcy > max) newcy = max; - - //PImage *useimg = &img; - - if (newcx != cx || newcy != cy) { - PImage newimage (newcx, newcy, img.getcc ()); - - gluScaleImage (fmt, - cx, cy, GL_UNSIGNED_BYTE, img.getData (), - newcx, newcy, GL_UNSIGNED_BYTE, newimage.getData ()); - - img.swap (newimage); - } - - glGenTextures(1,&texid); - bind(); - - glTexParameteri(textarget,GL_TEXTURE_MAG_FILTER,GL_LINEAR); - if (genMipmaps) - glTexParameteri(textarget,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR); - else - glTexParameteri(textarget,GL_TEXTURE_MIN_FILTER,GL_LINEAR); - - if (clamp) { - glTexParameteri(textarget,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE); - glTexParameteri(textarget,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE); - } else { - glTexParameteri(textarget,GL_TEXTURE_WRAP_S,GL_REPEAT); - glTexParameteri(textarget,GL_TEXTURE_WRAP_T,GL_REPEAT); - } - - glPixelStorei(GL_UNPACK_ALIGNMENT,1); - - if (genMipmaps) { -#ifdef USE_GEN_MIPMAPS - - glTexParameteri(textarget, GL_GENERATE_MIPMAP_SGIS, GL_TRUE); - - glTexImage2D(GL_TEXTURE_2D,0,fmt2, - newcx,newcy, - 0,fmt,GL_UNSIGNED_BYTE,img.getData()); - -#else - - int level = 0; - uint8 *imd = img.getData(); - int cc = img.getcc(); - while (1) { - glTexImage2D(GL_TEXTURE_2D,level,fmt2, - newcx,newcy, - 0,fmt,GL_UNSIGNED_BYTE,imd); - - if (newcx <= 1 && newcy <= 1) break; - - if (newcx > 1) newcx /= 2; - if (newcy > 1) newcy /= 2; - level++; - - for (int y=0; y max) newcx = max; - if (newcy > max) newcy = max; - - if (newcx != cx || newcy != cy) { - PImage newimage (newcx, newcy, img.getcc ()); - - gluScaleImage (fmt, - cx, cy, GL_UNSIGNED_BYTE, img.getData (), - newcx, newcy, GL_UNSIGNED_BYTE, newimage.getData ()); - - img.swap (newimage); - } - - glGenTextures(1,&texid); - bind(); - - glTexParameteri(textarget,GL_TEXTURE_MAG_FILTER,GL_LINEAR); - if (genMipmaps) - glTexParameteri(textarget,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR); - else - glTexParameteri(textarget,GL_TEXTURE_MIN_FILTER,GL_LINEAR); - - if (clamp) { - glTexParameteri(textarget,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE); - glTexParameteri(textarget,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE); - } else { - glTexParameteri(textarget,GL_TEXTURE_WRAP_S,GL_REPEAT); - glTexParameteri(textarget,GL_TEXTURE_WRAP_T,GL_REPEAT); - } - - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - - glPixelStorei(GL_UNPACK_ROW_LENGTH, img.getcx()); - glPixelStorei(GL_UNPACK_SKIP_ROWS, offy); - glPixelStorei(GL_UNPACK_SKIP_PIXELS, offx); - - //uint8 *offsetdata = img.getData() + ((offy*img.getcx())+offx)*img.getcc(); - - if (genMipmaps) - glTexParameteri(textarget, GL_GENERATE_MIPMAP_SGIS, GL_TRUE); - - glTexImage2D(GL_TEXTURE_2D,0,fmt2, - newcx,newcy, - 0,fmt,GL_UNSIGNED_BYTE,img.getData()); - - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); - glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); - glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); -} - -void PTexture::loadAlpha(const std::string &filename, bool genMipmaps, bool clamp) -{ - PImage image (filename); - loadAlpha (image, genMipmaps, clamp); - name = filename; -} - -void PTexture::loadAlpha(PImage &img, bool genMipmaps, bool clamp) -{ - unload(); - - textarget = GL_TEXTURE_2D; - -#ifdef USE_GEN_MIPMAPS - if (genMipmaps && !extgl_Extensions.SGIS_generate_mipmap) { - PUtil::outLog() << "warning: can't generate mipmaps for texture" << std::endl; - genMipmaps = false; - } -#endif - - GLuint fmt,fmt2; - - switch (img.getcc()) { - case 1: - fmt = GL_ALPHA; fmt2 = GL_ALPHA8; break; - case 2: - fmt = GL_LUMINANCE_ALPHA; fmt2 = GL_LUMINANCE8_ALPHA8; - PUtil::outLog() << "Warning: loadAlpha() has been used for image with 2 channels" << std::endl; - break; - case 3: - fmt = GL_RGB; fmt2 = GL_RGB8; - PUtil::outLog() << "Warning: loadAlpha() has been used for RGB image" << std::endl; - break; - case 4: - fmt = GL_RGBA; fmt2 = GL_RGBA8; - PUtil::outLog() << "Warning: loadAlpha() has been used for RGBA image" << std::endl; - break; - default: - throw MakePException ("loading texture failed, unknown image format"); - } - - int cx = img.getcx(), cy = img.getcy(); - int newcx=1, newcy=1, max; - while (newcx < cx) newcx *= 2; - while (newcy < cy) newcy *= 2; - glGetIntegerv(GL_MAX_TEXTURE_SIZE,&max); - if (newcx > max) newcx = max; - if (newcy > max) newcy = max; - - if (newcx != cx || newcy != cy) { - PImage newimage (newcx, newcy, img.getcc ()); - - gluScaleImage (fmt, - cx, cy, GL_UNSIGNED_BYTE, img.getData (), - newcx, newcy, GL_UNSIGNED_BYTE, newimage.getData ()); - - img.swap (newimage); - } - - glGenTextures(1,&texid); - bind(); - - glTexParameteri(textarget,GL_TEXTURE_MAG_FILTER,GL_LINEAR); - if (genMipmaps) - glTexParameteri(textarget,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR); - else - glTexParameteri(textarget,GL_TEXTURE_MIN_FILTER,GL_LINEAR); - - if (clamp) { - glTexParameteri(textarget,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE); - glTexParameteri(textarget,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE); - } else { - glTexParameteri(textarget,GL_TEXTURE_WRAP_S,GL_REPEAT); - glTexParameteri(textarget,GL_TEXTURE_WRAP_T,GL_REPEAT); - } - - glPixelStorei(GL_UNPACK_ALIGNMENT,1); - - if (genMipmaps) { -#ifdef USE_GEN_MIPMAPS - - glTexParameteri(textarget, GL_GENERATE_MIPMAP_SGIS, GL_TRUE); - - glTexImage2D(GL_TEXTURE_2D,0,fmt2, - newcx,newcy, - 0,fmt,GL_UNSIGNED_BYTE,img.getData()); - -#else - - int level = 0; - uint8 *imd = img.getData(); - int cc = img.getcc(); - while (1) { - glTexImage2D(GL_TEXTURE_2D,level,fmt2, - newcx,newcy, - 0,fmt,GL_UNSIGNED_BYTE,imd); - - if (newcx <= 1 && newcy <= 1) break; - - if (newcx > 1) newcx /= 2; - if (newcy > 1) newcy /= 2; - level++; - - for (int y=0; y max) newcx = max; - if (newcy > max) newcy = max; - - if (newcx != cx || newcy != cy) { - PImage newimage (newcx, newcy, img.getcc ()); - - gluScaleImage (fmt, - cx, cy, GL_UNSIGNED_BYTE, img.getData (), - newcx, newcy, GL_UNSIGNED_BYTE, newimage.getData ()); - - img.swap (newimage); - } - - glTexParameteri(textarget,GL_TEXTURE_MAG_FILTER,GL_LINEAR); - if (genMipmaps) - glTexParameteri(textarget,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR); - else - glTexParameteri(textarget,GL_TEXTURE_MIN_FILTER,GL_LINEAR); - - glTexParameteri(textarget,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE); - glTexParameteri(textarget,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE); - - glPixelStorei(GL_UNPACK_ALIGNMENT,1); - - if (genMipmaps) { -#ifdef USE_GEN_MIPMAPS - - glTexParameteri(textarget, GL_GENERATE_MIPMAP_SGIS, GL_TRUE); - - glTexImage2D(sidetarget[side],0,fmt2, - newcx,newcy, - 0,fmt,GL_UNSIGNED_BYTE,img.getData()); - -#else - - int level = 0; - uint8 *imd = img.getData(); - int cc = img.getcc(); - while (1) { - glTexImage2D(GL_TEXTURE_2D,level,fmt2, - newcx,newcy, - 0,fmt,GL_UNSIGNED_BYTE,imd); - //break; - if (newcx <= 1 && newcy <= 1) break; - - if (newcx > 1) newcx /= 2; - if (newcy > 1) newcy /= 2; - level++; - - for (int y=0; y + + + +// SDL_image doesn't need init/shutdown code + +PSSTexture::PSSTexture(PApp &parentApp) : PSubsystem(parentApp) +{ + app.outLog() << "Initialising texture subsystem [SDL_Image]" << std::endl; +} + +PSSTexture::~PSSTexture() +{ + app.outLog() << "Shutting down texture subsystem" << std::endl; + + texlist.clear(); +} + + + +PTexture *PSSTexture::loadTexture(const std::string &name, bool genMipmaps, bool clamp) +{ + PTexture *tex = texlist.find(name); + if (!tex) { + try + { + tex = new PTexture(name,genMipmaps,clamp); + } + catch (PException e) + { + if (PUtil::isDebugLevel(DEBUGLEVEL_ENDUSER)) + PUtil::outLog() << "Failed to load " << name << ": " << e.what () << std::endl; + return null; + } + texlist.add(tex); + } + return tex; +} + + + +PImage::~PImage() +{ + unload (); +} + +void PImage::unload () +{ + delete[] data; + data = null; +} + +void PImage::load (const std::string &filename) +{ + data = null; + + if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) + PUtil::outLog() << "Loading image \"" << filename << "\"" << std::endl; + + // PhysFS / SDL integration with SDL_rwops + + PHYSFS_file *pfile = PHYSFS_openRead(filename.c_str()); + + if (pfile == null) { + throw MakePException (filename + ", PhysFS: " + PHYSFS_getLastError ()); + } + + SDL_RWops *rwops = PUtil::allocPhysFSops(pfile); + + SDL_Surface *img = IMG_Load_RW(rwops, 1); // this closes file and frees rwops + + if (!img) { + throw MakePException (filename + ", SDL_image: " + IMG_GetError ()); + } + + if (SDL_MUSTLOCK(img)) SDL_LockSurface(img); + + // TGA COLOUR SWITCH HACK + int colmap_normal[] = { 0,1,2,3 }; + int colmap_flipped[] = { 2,1,0,3 }; + int *colmap = colmap_normal; + const char *fname = filename.c_str(); + int len = strlen(fname); + if (len > 4) { + if (!strcmp(fname+len-4,".tga")) colmap = colmap_flipped; + } + + cx = img->w; + cy = img->h; + cc = img->format->BytesPerPixel; + data = new uint8 [cx * cy * cc]; + + for (int y=0; ypixels)[(cy-y-1)*img->pitch + x*cc + c]; + data[(y*cx+x)*cc+c] = ((uint8*)img->pixels)[(cy-y-1)*img->pitch + x*cc + colmap[c]]; + } + } + } + + if (SDL_MUSTLOCK(img)) SDL_UnlockSurface(img); + SDL_FreeSurface(img); +} + +void PImage::load (int _cx, int _cy, int _cc) +{ + cx = _cx; + cy = _cy; + cc = _cc; + + data = new uint8 [cx * cy * cc]; +} + + + +void PTexture::unload() +{ + if (texid) + { + glDeleteTextures (1, &texid); + texid = 0; + } +} + +void PTexture::load (const std::string &filename, bool genMipmaps, bool clamp) +{ + PImage image (filename); + load (image, genMipmaps, clamp); + name = filename; +} + +void PTexture::load (PImage &img, bool genMipmaps, bool clamp) +{ + unload(); + + textarget = GL_TEXTURE_2D; + +#ifdef USE_GEN_MIPMAPS + if (genMipmaps && !extgl_Extensions.SGIS_generate_mipmap) { + PUtil::outLog() << "warning: can't generate mipmaps for texture" << std::endl; + genMipmaps = false; + } +#endif + + GLuint fmt,fmt2; + + switch (img.getcc()) { + case 1: + fmt = GL_LUMINANCE; fmt2 = GL_LUMINANCE8; break; + case 2: + fmt = GL_LUMINANCE_ALPHA; fmt2 = GL_LUMINANCE8_ALPHA8; break; + case 3: + fmt = GL_RGB; fmt2 = GL_RGB8; break; + case 4: + fmt = GL_RGBA; fmt2 = GL_RGBA8; break; + default: + throw MakePException ("loading texture failed, unknown image format"); + } + + int cx = img.getcx(), cy = img.getcy(); + int newcx=1, newcy=1, max; + while (newcx < cx) newcx *= 2; + while (newcy < cy) newcy *= 2; + glGetIntegerv(GL_MAX_TEXTURE_SIZE,&max); + if (newcx > max) newcx = max; + if (newcy > max) newcy = max; + + //PImage *useimg = &img; + + if (newcx != cx || newcy != cy) { + PImage newimage (newcx, newcy, img.getcc ()); + + gluScaleImage (fmt, + cx, cy, GL_UNSIGNED_BYTE, img.getData (), + newcx, newcy, GL_UNSIGNED_BYTE, newimage.getData ()); + + img.swap (newimage); + } + + glGenTextures(1,&texid); + bind(); + + glTexParameteri(textarget,GL_TEXTURE_MAG_FILTER,GL_LINEAR); + if (genMipmaps) + glTexParameteri(textarget,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR); + else + glTexParameteri(textarget,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + + if (clamp) { + glTexParameteri(textarget,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE); + glTexParameteri(textarget,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE); + } else { + glTexParameteri(textarget,GL_TEXTURE_WRAP_S,GL_REPEAT); + glTexParameteri(textarget,GL_TEXTURE_WRAP_T,GL_REPEAT); + } + + glPixelStorei(GL_UNPACK_ALIGNMENT,1); + + if (genMipmaps) { +#ifdef USE_GEN_MIPMAPS + + glTexParameteri(textarget, GL_GENERATE_MIPMAP_SGIS, GL_TRUE); + + glTexImage2D(GL_TEXTURE_2D,0,fmt2, + newcx,newcy, + 0,fmt,GL_UNSIGNED_BYTE,img.getData()); + +#else + + int level = 0; + uint8 *imd = img.getData(); + int cc = img.getcc(); + while (1) { + glTexImage2D(GL_TEXTURE_2D,level,fmt2, + newcx,newcy, + 0,fmt,GL_UNSIGNED_BYTE,imd); + + if (newcx <= 1 && newcy <= 1) break; + + if (newcx > 1) newcx /= 2; + if (newcy > 1) newcy /= 2; + level++; + + for (int y=0; y max) newcx = max; + if (newcy > max) newcy = max; + + if (newcx != cx || newcy != cy) { + PImage newimage (newcx, newcy, img.getcc ()); + + gluScaleImage (fmt, + cx, cy, GL_UNSIGNED_BYTE, img.getData (), + newcx, newcy, GL_UNSIGNED_BYTE, newimage.getData ()); + + img.swap (newimage); + } + + glGenTextures(1,&texid); + bind(); + + glTexParameteri(textarget,GL_TEXTURE_MAG_FILTER,GL_LINEAR); + if (genMipmaps) + glTexParameteri(textarget,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR); + else + glTexParameteri(textarget,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + + if (clamp) { + glTexParameteri(textarget,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE); + glTexParameteri(textarget,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE); + } else { + glTexParameteri(textarget,GL_TEXTURE_WRAP_S,GL_REPEAT); + glTexParameteri(textarget,GL_TEXTURE_WRAP_T,GL_REPEAT); + } + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + glPixelStorei(GL_UNPACK_ROW_LENGTH, img.getcx()); + glPixelStorei(GL_UNPACK_SKIP_ROWS, offy); + glPixelStorei(GL_UNPACK_SKIP_PIXELS, offx); + + //uint8 *offsetdata = img.getData() + ((offy*img.getcx())+offx)*img.getcc(); + + if (genMipmaps) + glTexParameteri(textarget, GL_GENERATE_MIPMAP_SGIS, GL_TRUE); + + glTexImage2D(GL_TEXTURE_2D,0,fmt2, + newcx,newcy, + 0,fmt,GL_UNSIGNED_BYTE,img.getData()); + + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); + glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); + glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); +} + +void PTexture::loadAlpha(const std::string &filename, bool genMipmaps, bool clamp) +{ + PImage image (filename); + loadAlpha (image, genMipmaps, clamp); + name = filename; +} + +void PTexture::loadAlpha(PImage &img, bool genMipmaps, bool clamp) +{ + unload(); + + textarget = GL_TEXTURE_2D; + +#ifdef USE_GEN_MIPMAPS + if (genMipmaps && !extgl_Extensions.SGIS_generate_mipmap) { + PUtil::outLog() << "warning: can't generate mipmaps for texture" << std::endl; + genMipmaps = false; + } +#endif + + GLuint fmt,fmt2; + + switch (img.getcc()) { + case 1: + fmt = GL_ALPHA; fmt2 = GL_ALPHA8; break; + case 2: + fmt = GL_LUMINANCE_ALPHA; fmt2 = GL_LUMINANCE8_ALPHA8; + PUtil::outLog() << "Warning: loadAlpha() has been used for image with 2 channels" << std::endl; + break; + case 3: + fmt = GL_RGB; fmt2 = GL_RGB8; + PUtil::outLog() << "Warning: loadAlpha() has been used for RGB image" << std::endl; + break; + case 4: + fmt = GL_RGBA; fmt2 = GL_RGBA8; + PUtil::outLog() << "Warning: loadAlpha() has been used for RGBA image" << std::endl; + break; + default: + throw MakePException ("loading texture failed, unknown image format"); + } + + int cx = img.getcx(), cy = img.getcy(); + int newcx=1, newcy=1, max; + while (newcx < cx) newcx *= 2; + while (newcy < cy) newcy *= 2; + glGetIntegerv(GL_MAX_TEXTURE_SIZE,&max); + if (newcx > max) newcx = max; + if (newcy > max) newcy = max; + + if (newcx != cx || newcy != cy) { + PImage newimage (newcx, newcy, img.getcc ()); + + gluScaleImage (fmt, + cx, cy, GL_UNSIGNED_BYTE, img.getData (), + newcx, newcy, GL_UNSIGNED_BYTE, newimage.getData ()); + + img.swap (newimage); + } + + glGenTextures(1,&texid); + bind(); + + glTexParameteri(textarget,GL_TEXTURE_MAG_FILTER,GL_LINEAR); + if (genMipmaps) + glTexParameteri(textarget,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR); + else + glTexParameteri(textarget,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + + if (clamp) { + glTexParameteri(textarget,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE); + glTexParameteri(textarget,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE); + } else { + glTexParameteri(textarget,GL_TEXTURE_WRAP_S,GL_REPEAT); + glTexParameteri(textarget,GL_TEXTURE_WRAP_T,GL_REPEAT); + } + + glPixelStorei(GL_UNPACK_ALIGNMENT,1); + + if (genMipmaps) { +#ifdef USE_GEN_MIPMAPS + + glTexParameteri(textarget, GL_GENERATE_MIPMAP_SGIS, GL_TRUE); + + glTexImage2D(GL_TEXTURE_2D,0,fmt2, + newcx,newcy, + 0,fmt,GL_UNSIGNED_BYTE,img.getData()); + +#else + + int level = 0; + uint8 *imd = img.getData(); + int cc = img.getcc(); + while (1) { + glTexImage2D(GL_TEXTURE_2D,level,fmt2, + newcx,newcy, + 0,fmt,GL_UNSIGNED_BYTE,imd); + + if (newcx <= 1 && newcy <= 1) break; + + if (newcx > 1) newcx /= 2; + if (newcy > 1) newcy /= 2; + level++; + + for (int y=0; y max) newcx = max; + if (newcy > max) newcy = max; + + if (newcx != cx || newcy != cy) { + PImage newimage (newcx, newcy, img.getcc ()); + + gluScaleImage (fmt, + cx, cy, GL_UNSIGNED_BYTE, img.getData (), + newcx, newcy, GL_UNSIGNED_BYTE, newimage.getData ()); + + img.swap (newimage); + } + + glTexParameteri(textarget,GL_TEXTURE_MAG_FILTER,GL_LINEAR); + if (genMipmaps) + glTexParameteri(textarget,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR); + else + glTexParameteri(textarget,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + + glTexParameteri(textarget,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE); + glTexParameteri(textarget,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE); + + glPixelStorei(GL_UNPACK_ALIGNMENT,1); + + if (genMipmaps) { +#ifdef USE_GEN_MIPMAPS + + glTexParameteri(textarget, GL_GENERATE_MIPMAP_SGIS, GL_TRUE); + + glTexImage2D(sidetarget[side],0,fmt2, + newcx,newcy, + 0,fmt,GL_UNSIGNED_BYTE,img.getData()); + +#else + + int level = 0; + uint8 *imd = img.getData(); + int cc = img.getcc(); + while (1) { + glTexImage2D(GL_TEXTURE_2D,level,fmt2, + newcx,newcy, + 0,fmt,GL_UNSIGNED_BYTE,imd); + //break; + if (newcx <= 1 && newcy <= 1) break; + + if (newcx > 1) newcx /= 2; + if (newcy > 1) newcy /= 2; + level++; + + for (int y=0; y 0 ); - } - return false; + if ( allocated && compare.allocated ) + { + assert( cstring ); + assert( compare.cstring ); + return ( strcmp( cstring, compare.cstring ) > 0 ); + } + return false; } bool TiXmlString::operator > (const TiXmlString & compare) const { - if ( allocated && compare.allocated ) - { - assert( cstring ); - assert( compare.cstring ); - return ( strcmp( cstring, compare.cstring ) < 0 ); - } - return false; + if ( allocated && compare.allocated ) + { + assert( cstring ); + assert( compare.cstring ); + return ( strcmp( cstring, compare.cstring ) < 0 ); + } + return false; } -#endif // TIXML_USE_STL +#endif // TIXML_USE_STL diff -Nru trigger-rally-0.5.2.1/src/pengine/tinystr.h trigger-rally-0.6.0/src/pengine/tinystr.h --- trigger-rally-0.5.2.1/src/pengine/tinystr.h 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/pengine/tinystr.h 2011-10-07 17:10:01.000000000 +0000 @@ -86,21 +86,21 @@ TiXmlString& operator += (const char * suffix) { append (suffix); - return *this; + return *this; } // += operator. Maps to append TiXmlString& operator += (char single) { append (single); - return *this; + return *this; } // += operator. Maps to append TiXmlString& operator += (TiXmlString & suffix) { append (suffix); - return *this; + return *this; } bool operator == (const TiXmlString & compare) const; bool operator < (const TiXmlString & compare) const; @@ -113,8 +113,8 @@ } // Checks if a TiXmlString contains only whitespace (same rules as isspace) - // Not actually used in tinyxml. Conflicts with a C macro, "isblank", - // which is a problem. Commenting out. -lee + // Not actually used in tinyxml. Conflicts with a C macro, "isblank", + // which is a problem. Commenting out. -lee // bool isblank () const; // single char extraction @@ -133,8 +133,8 @@ // find a char in a string from an offset. Return TiXmlString::notfound if not found unsigned find (char tofind, unsigned offset) const; - /* Function to reserve a big amount of data when we know we'll need it. Be aware that this - function clears the content of the TiXmlString if any exists. + /* Function to reserve a big amount of data when we know we'll need it. Be aware that this + function clears the content of the TiXmlString if any exists. */ void reserve (unsigned size) { @@ -155,7 +155,7 @@ } // Error value for find primitive - enum { notfound = 0xffffffff, + enum { notfound = 0xffffffff, npos = notfound }; void append (const char *str, int len ); @@ -226,7 +226,7 @@ } } ; -#endif // TIXML_STRING_INCLUDED -#endif // TIXML_USE_STL +#endif // TIXML_STRING_INCLUDED +#endif // TIXML_USE_STL diff -Nru trigger-rally-0.5.2.1/src/pengine/tinyxml.cpp trigger-rally-0.6.0/src/pengine/tinyxml.cpp --- trigger-rally-0.5.2.1/src/pengine/tinyxml.cpp 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/pengine/tinyxml.cpp 2011-10-07 17:10:01.000000000 +0000 @@ -29,1042 +29,1042 @@ void TiXmlBase::PutString( const TIXML_STRING& str, TIXML_OSTREAM* stream ) { - TIXML_STRING buffer; - PutString( str, &buffer ); - (*stream) << buffer; + TIXML_STRING buffer; + PutString( str, &buffer ); + (*stream) << buffer; } void TiXmlBase::PutString( const TIXML_STRING& str, TIXML_STRING* outString ) { - int i=0; + int i=0; - while( i<(int)str.length() ) - { - int c = str[i]; - - if ( c == '&' - && i < ( (int)str.length() - 2 ) - && str[i+1] == '#' - && str[i+2] == 'x' ) - { - // Hexadecimal character reference. - // Pass through unchanged. - // © -- copyright symbol, for example. - while ( i<(int)str.length() ) - { - outString->append( str.c_str() + i, 1 ); - ++i; - if ( str[i] == ';' ) - break; - } - } - else if ( c == '&' ) - { - outString->append( entity[0].str, entity[0].strLength ); - ++i; - } - else if ( c == '<' ) - { - outString->append( entity[1].str, entity[1].strLength ); - ++i; - } - else if ( c == '>' ) - { - outString->append( entity[2].str, entity[2].strLength ); - ++i; - } - else if ( c == '\"' ) - { - outString->append( entity[3].str, entity[3].strLength ); - ++i; - } - else if ( c == '\'' ) - { - outString->append( entity[4].str, entity[4].strLength ); - ++i; - } - else if ( c < 32 || c > 126 ) - { - // Easy pass at non-alpha/numeric/symbol - // 127 is the delete key. Below 32 is symbolic. - char buf[ 32 ]; - sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) ); - outString->append( buf, strlen( buf ) ); - ++i; - } - else - { - char realc = (char) c; - outString->append( &realc, 1 ); - ++i; - } - } + while( i<(int)str.length() ) + { + int c = str[i]; + + if ( c == '&' + && i < ( (int)str.length() - 2 ) + && str[i+1] == '#' + && str[i+2] == 'x' ) + { + // Hexadecimal character reference. + // Pass through unchanged. + // © -- copyright symbol, for example. + while ( i<(int)str.length() ) + { + outString->append( str.c_str() + i, 1 ); + ++i; + if ( str[i] == ';' ) + break; + } + } + else if ( c == '&' ) + { + outString->append( entity[0].str, entity[0].strLength ); + ++i; + } + else if ( c == '<' ) + { + outString->append( entity[1].str, entity[1].strLength ); + ++i; + } + else if ( c == '>' ) + { + outString->append( entity[2].str, entity[2].strLength ); + ++i; + } + else if ( c == '\"' ) + { + outString->append( entity[3].str, entity[3].strLength ); + ++i; + } + else if ( c == '\'' ) + { + outString->append( entity[4].str, entity[4].strLength ); + ++i; + } + else if ( c < 32 || c > 126 ) + { + // Easy pass at non-alpha/numeric/symbol + // 127 is the delete key. Below 32 is symbolic. + char buf[ 32 ]; + sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) ); + outString->append( buf, strlen( buf ) ); + ++i; + } + else + { + char realc = (char) c; + outString->append( &realc, 1 ); + ++i; + } + } } // <-- Strange class for a bug fix. Search for STL_STRING_BUG TiXmlBase::StringToBuffer::StringToBuffer( const TIXML_STRING& str ) { - buffer = new char[ str.length()+1 ]; - if ( buffer ) - { - strcpy( buffer, str.c_str() ); - } + buffer = new char[ str.length()+1 ]; + if ( buffer ) + { + strcpy( buffer, str.c_str() ); + } } TiXmlBase::StringToBuffer::~StringToBuffer() { - delete [] buffer; + delete [] buffer; } // End strange bug fix. --> TiXmlNode::TiXmlNode( NodeType _type ) { - parent = 0; - type = _type; - firstChild = 0; - lastChild = 0; - prev = 0; - next = 0; - userData = 0; + parent = 0; + type = _type; + firstChild = 0; + lastChild = 0; + prev = 0; + next = 0; + userData = 0; } TiXmlNode::~TiXmlNode() { - TiXmlNode* node = firstChild; - TiXmlNode* temp = 0; + TiXmlNode* node = firstChild; + TiXmlNode* temp = 0; - while ( node ) - { - temp = node; - node = node->next; - delete temp; - } + while ( node ) + { + temp = node; + node = node->next; + delete temp; + } } void TiXmlNode::Clear() { - TiXmlNode* node = firstChild; - TiXmlNode* temp = 0; + TiXmlNode* node = firstChild; + TiXmlNode* temp = 0; - while ( node ) - { - temp = node; - node = node->next; - delete temp; - } + while ( node ) + { + temp = node; + node = node->next; + delete temp; + } - firstChild = 0; - lastChild = 0; + firstChild = 0; + lastChild = 0; } TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node ) { - node->parent = this; + node->parent = this; - node->prev = lastChild; - node->next = 0; + node->prev = lastChild; + node->next = 0; - if ( lastChild ) - lastChild->next = node; - else - firstChild = node; // it was an empty list. + if ( lastChild ) + lastChild->next = node; + else + firstChild = node; // it was an empty list. - lastChild = node; - return node; + lastChild = node; + return node; } TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis ) { - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; + TiXmlNode* node = addThis.Clone(); + if ( !node ) + return 0; - return LinkEndChild( node ); + return LinkEndChild( node ); } TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ) -{ - if ( !beforeThis || beforeThis->parent != this ) - return 0; - - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; - node->parent = this; - - node->next = beforeThis; - node->prev = beforeThis->prev; - if ( beforeThis->prev ) - { - beforeThis->prev->next = node; - } - else - { - assert( firstChild == beforeThis ); - firstChild = node; - } - beforeThis->prev = node; - return node; +{ + if ( !beforeThis || beforeThis->parent != this ) + return 0; + + TiXmlNode* node = addThis.Clone(); + if ( !node ) + return 0; + node->parent = this; + + node->next = beforeThis; + node->prev = beforeThis->prev; + if ( beforeThis->prev ) + { + beforeThis->prev->next = node; + } + else + { + assert( firstChild == beforeThis ); + firstChild = node; + } + beforeThis->prev = node; + return node; } TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ) { - if ( !afterThis || afterThis->parent != this ) - return 0; + if ( !afterThis || afterThis->parent != this ) + return 0; - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; - node->parent = this; - - node->prev = afterThis; - node->next = afterThis->next; - if ( afterThis->next ) - { - afterThis->next->prev = node; - } - else - { - assert( lastChild == afterThis ); - lastChild = node; - } - afterThis->next = node; - return node; + TiXmlNode* node = addThis.Clone(); + if ( !node ) + return 0; + node->parent = this; + + node->prev = afterThis; + node->next = afterThis->next; + if ( afterThis->next ) + { + afterThis->next->prev = node; + } + else + { + assert( lastChild == afterThis ); + lastChild = node; + } + afterThis->next = node; + return node; } TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ) { - if ( replaceThis->parent != this ) - return 0; + if ( replaceThis->parent != this ) + return 0; - TiXmlNode* node = withThis.Clone(); - if ( !node ) - return 0; - - node->next = replaceThis->next; - node->prev = replaceThis->prev; - - if ( replaceThis->next ) - replaceThis->next->prev = node; - else - lastChild = node; - - if ( replaceThis->prev ) - replaceThis->prev->next = node; - else - firstChild = node; - - delete replaceThis; - node->parent = this; - return node; + TiXmlNode* node = withThis.Clone(); + if ( !node ) + return 0; + + node->next = replaceThis->next; + node->prev = replaceThis->prev; + + if ( replaceThis->next ) + replaceThis->next->prev = node; + else + lastChild = node; + + if ( replaceThis->prev ) + replaceThis->prev->next = node; + else + firstChild = node; + + delete replaceThis; + node->parent = this; + return node; } bool TiXmlNode::RemoveChild( TiXmlNode* removeThis ) { - if ( removeThis->parent != this ) - { - assert( 0 ); - return false; - } - - if ( removeThis->next ) - removeThis->next->prev = removeThis->prev; - else - lastChild = removeThis->prev; - - if ( removeThis->prev ) - removeThis->prev->next = removeThis->next; - else - firstChild = removeThis->next; + if ( removeThis->parent != this ) + { + assert( 0 ); + return false; + } + + if ( removeThis->next ) + removeThis->next->prev = removeThis->prev; + else + lastChild = removeThis->prev; + + if ( removeThis->prev ) + removeThis->prev->next = removeThis->next; + else + firstChild = removeThis->next; - delete removeThis; - return true; + delete removeThis; + return true; } TiXmlNode* TiXmlNode::FirstChild( const char * value ) const { - TiXmlNode* node; - for ( node = firstChild; node; node = node->next ) - { - if ( node->SValue() == TIXML_STRING( value )) - return node; - } - return 0; + TiXmlNode* node; + for ( node = firstChild; node; node = node->next ) + { + if ( node->SValue() == TIXML_STRING( value )) + return node; + } + return 0; } TiXmlNode* TiXmlNode::LastChild( const char * value ) const { - TiXmlNode* node; - for ( node = lastChild; node; node = node->prev ) - { - if ( node->SValue() == TIXML_STRING (value)) - return node; - } - return 0; + TiXmlNode* node; + for ( node = lastChild; node; node = node->prev ) + { + if ( node->SValue() == TIXML_STRING (value)) + return node; + } + return 0; } TiXmlNode* TiXmlNode::IterateChildren( TiXmlNode* previous ) const { - if ( !previous ) - { - return FirstChild(); - } - else - { - assert( previous->parent == this ); - return previous->NextSibling(); - } + if ( !previous ) + { + return FirstChild(); + } + else + { + assert( previous->parent == this ); + return previous->NextSibling(); + } } TiXmlNode* TiXmlNode::IterateChildren( const char * val, TiXmlNode* previous ) const { - if ( !previous ) - { - return FirstChild( val ); - } - else - { - assert( previous->parent == this ); - return previous->NextSibling( val ); - } + if ( !previous ) + { + return FirstChild( val ); + } + else + { + assert( previous->parent == this ); + return previous->NextSibling( val ); + } } TiXmlNode* TiXmlNode::NextSibling( const char * value ) const { - TiXmlNode* node; - for ( node = next; node; node = node->next ) - { - if ( node->SValue() == TIXML_STRING (value)) - return node; - } - return 0; + TiXmlNode* node; + for ( node = next; node; node = node->next ) + { + if ( node->SValue() == TIXML_STRING (value)) + return node; + } + return 0; } TiXmlNode* TiXmlNode::PreviousSibling( const char * value ) const { - TiXmlNode* node; - for ( node = prev; node; node = node->prev ) - { - if ( node->SValue() == TIXML_STRING (value)) - return node; - } - return 0; + TiXmlNode* node; + for ( node = prev; node; node = node->prev ) + { + if ( node->SValue() == TIXML_STRING (value)) + return node; + } + return 0; } void TiXmlElement::RemoveAttribute( const char * name ) { - TiXmlAttribute* node = attributeSet.Find( name ); - if ( node ) - { - attributeSet.Remove( node ); - delete node; - } + TiXmlAttribute* node = attributeSet.Find( name ); + if ( node ) + { + attributeSet.Remove( node ); + delete node; + } } TiXmlElement* TiXmlNode::FirstChildElement() const { - TiXmlNode* node; + TiXmlNode* node; - for ( node = FirstChild(); - node; - node = node->NextSibling() ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; + for ( node = FirstChild(); + node; + node = node->NextSibling() ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; } TiXmlElement* TiXmlNode::FirstChildElement( const char * value ) const { - TiXmlNode* node; + TiXmlNode* node; - for ( node = FirstChild( value ); - node; - node = node->NextSibling( value ) ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; + for ( node = FirstChild( value ); + node; + node = node->NextSibling( value ) ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; } TiXmlElement* TiXmlNode::NextSiblingElement() const { - TiXmlNode* node; + TiXmlNode* node; - for ( node = NextSibling(); - node; - node = node->NextSibling() ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; + for ( node = NextSibling(); + node; + node = node->NextSibling() ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; } TiXmlElement* TiXmlNode::NextSiblingElement( const char * value ) const { - TiXmlNode* node; + TiXmlNode* node; - for ( node = NextSibling( value ); - node; - node = node->NextSibling( value ) ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; + for ( node = NextSibling( value ); + node; + node = node->NextSibling( value ) ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; } TiXmlDocument* TiXmlNode::GetDocument() const { - const TiXmlNode* node; + const TiXmlNode* node; - for( node = this; node; node = node->parent ) - { - if ( node->ToDocument() ) - return node->ToDocument(); - } - return 0; + for( node = this; node; node = node->parent ) + { + if ( node->ToDocument() ) + return node->ToDocument(); + } + return 0; } TiXmlElement::TiXmlElement (const char * _value) : TiXmlNode( TiXmlNode::ELEMENT ) { - firstChild = lastChild = 0; - value = _value; + firstChild = lastChild = 0; + value = _value; } TiXmlElement::~TiXmlElement() { - while( attributeSet.First() ) - { - TiXmlAttribute* node = attributeSet.First(); - attributeSet.Remove( node ); - delete node; - } + while( attributeSet.First() ) + { + TiXmlAttribute* node = attributeSet.First(); + attributeSet.Remove( node ); + delete node; + } } const char * TiXmlElement::Attribute( const char * name ) const { - TiXmlAttribute* node = attributeSet.Find( name ); + TiXmlAttribute* node = attributeSet.Find( name ); - if ( node ) - return node->Value(); + if ( node ) + return node->Value(); - return 0; + return 0; } const char * TiXmlElement::Attribute( const char * name, int* i ) const { - const char * s = Attribute( name ); - if ( i ) - { - if ( s ) - *i = atoi( s ); - else - *i = 0; - } - return s; + const char * s = Attribute( name ); + if ( i ) + { + if ( s ) + *i = atoi( s ); + else + *i = 0; + } + return s; } void TiXmlElement::SetAttribute( const char * name, int val ) -{ - char buf[64]; - sprintf( buf, "%d", val ); - SetAttribute( name, buf ); +{ + char buf[64]; + sprintf( buf, "%d", val ); + SetAttribute( name, buf ); } void TiXmlElement::SetAttribute( const char * name, const char * value ) { - TiXmlAttribute* node = attributeSet.Find( name ); - if ( node ) - { - node->SetValue( value ); - return; - } - - TiXmlAttribute* attrib = new TiXmlAttribute( name, value ); - if ( attrib ) - { - attributeSet.Add( attrib ); - } - else - { - TiXmlDocument* document = GetDocument(); - if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY ); - } + TiXmlAttribute* node = attributeSet.Find( name ); + if ( node ) + { + node->SetValue( value ); + return; + } + + TiXmlAttribute* attrib = new TiXmlAttribute( name, value ); + if ( attrib ) + { + attributeSet.Add( attrib ); + } + else + { + TiXmlDocument* document = GetDocument(); + if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY ); + } } void TiXmlElement::Print( FILE* cfile, int depth ) const { - int i; - for ( i=0; iNext() ) - { - fprintf( cfile, " " ); - attrib->Print( cfile, depth ); - } - - // There are 3 different formatting approaches: - // 1) An element without children is printed as a node - // 2) An element with only a text child is printed as text - // 3) An element with children is printed on multiple lines. - TiXmlNode* node; - if ( !firstChild ) - { - fprintf( cfile, " />" ); - } - else if ( firstChild == lastChild && firstChild->ToText() ) - { - fprintf( cfile, ">" ); - firstChild->Print( cfile, depth + 1 ); - fprintf( cfile, "", value.c_str() ); - } - else - { - fprintf( cfile, ">" ); - - for ( node = firstChild; node; node=node->NextSibling() ) - { - if ( !node->ToText() ) - { - fprintf( cfile, "\n" ); - } - node->Print( cfile, depth+1 ); - } - fprintf( cfile, "\n" ); - for( i=0; i", value.c_str() ); - } + int i; + for ( i=0; iNext() ) + { + fprintf( cfile, " " ); + attrib->Print( cfile, depth ); + } + + // There are 3 different formatting approaches: + // 1) An element without children is printed as a node + // 2) An element with only a text child is printed as text + // 3) An element with children is printed on multiple lines. + TiXmlNode* node; + if ( !firstChild ) + { + fprintf( cfile, " />" ); + } + else if ( firstChild == lastChild && firstChild->ToText() ) + { + fprintf( cfile, ">" ); + firstChild->Print( cfile, depth + 1 ); + fprintf( cfile, "", value.c_str() ); + } + else + { + fprintf( cfile, ">" ); + + for ( node = firstChild; node; node=node->NextSibling() ) + { + if ( !node->ToText() ) + { + fprintf( cfile, "\n" ); + } + node->Print( cfile, depth+1 ); + } + fprintf( cfile, "\n" ); + for( i=0; i", value.c_str() ); + } } void TiXmlElement::StreamOut( TIXML_OSTREAM * stream ) const { - (*stream) << "<" << value; + (*stream) << "<" << value; - TiXmlAttribute* attrib; - for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() ) - { - (*stream) << " "; - attrib->StreamOut( stream ); - } - - // If this node has children, give it a closing tag. Else - // make it an empty tag. - TiXmlNode* node; - if ( firstChild ) - { - (*stream) << ">"; - - for ( node = firstChild; node; node=node->NextSibling() ) - { - node->StreamOut( stream ); - } - (*stream) << ""; - } - else - { - (*stream) << " />"; - } + TiXmlAttribute* attrib; + for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() ) + { + (*stream) << " "; + attrib->StreamOut( stream ); + } + + // If this node has children, give it a closing tag. Else + // make it an empty tag. + TiXmlNode* node; + if ( firstChild ) + { + (*stream) << ">"; + + for ( node = firstChild; node; node=node->NextSibling() ) + { + node->StreamOut( stream ); + } + (*stream) << ""; + } + else + { + (*stream) << " />"; + } } TiXmlNode* TiXmlElement::Clone() const { - TiXmlElement* clone = new TiXmlElement( Value() ); - if ( !clone ) - return 0; - - CopyToClone( clone ); - - // Clone the attributes, then clone the children. - TiXmlAttribute* attribute = 0; - for( attribute = attributeSet.First(); - attribute; - attribute = attribute->Next() ) - { - clone->SetAttribute( attribute->Name(), attribute->Value() ); - } - - TiXmlNode* node = 0; - for ( node = firstChild; node; node = node->NextSibling() ) - { - clone->LinkEndChild( node->Clone() ); - } - return clone; + TiXmlElement* clone = new TiXmlElement( Value() ); + if ( !clone ) + return 0; + + CopyToClone( clone ); + + // Clone the attributes, then clone the children. + TiXmlAttribute* attribute = 0; + for( attribute = attributeSet.First(); + attribute; + attribute = attribute->Next() ) + { + clone->SetAttribute( attribute->Name(), attribute->Value() ); + } + + TiXmlNode* node = 0; + for ( node = firstChild; node; node = node->NextSibling() ) + { + clone->LinkEndChild( node->Clone() ); + } + return clone; } TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::DOCUMENT ) { - error = false; - // ignoreWhiteSpace = true; + error = false; + // ignoreWhiteSpace = true; } TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::DOCUMENT ) { - // ignoreWhiteSpace = true; - value = documentName; - error = false; + // ignoreWhiteSpace = true; + value = documentName; + error = false; } bool TiXmlDocument::LoadFile() { - // See STL_STRING_BUG below. - StringToBuffer buf( value ); + // See STL_STRING_BUG below. + StringToBuffer buf( value ); - if ( buf.buffer && LoadFile( buf.buffer ) ) - return true; + if ( buf.buffer && LoadFile( buf.buffer ) ) + return true; - return false; + return false; } bool TiXmlDocument::SaveFile() const { - // See STL_STRING_BUG below. - StringToBuffer buf( value ); + // See STL_STRING_BUG below. + StringToBuffer buf( value ); - if ( buf.buffer && SaveFile( buf.buffer ) ) - return true; + if ( buf.buffer && SaveFile( buf.buffer ) ) + return true; - return false; + return false; } bool TiXmlDocument::LoadFile( const char* filename ) { - // Delete the existing data: - Clear(); + // Delete the existing data: + Clear(); - // There was a really terrifying little bug here. The code: - // value = filename - // in the STL case, cause the assignment method of the std::string to - // be called. What is strange, is that the std::string had the same - // address as it's c_str() method, and so bad things happen. Looks - // like a bug in the Microsoft STL implementation. - // See STL_STRING_BUG above. - // Fixed with the StringToBuffer class. - value = filename; - - FILE* file = fopen( value.c_str (), "r" ); - - if ( file ) - { - // Get the file size, so we can pre-allocate the string. HUGE speed impact. - long length = 0; - fseek( file, 0, SEEK_END ); - length = ftell( file ); - fseek( file, 0, SEEK_SET ); - - // Strange case, but good to handle up front. - if ( length == 0 ) - { - fclose( file ); - return false; - } - - // If we have a file, assume it is all one big XML file, and read it in. - // The document parser may decide the document ends sooner than the entire file, however. - TIXML_STRING data; - data.reserve( length ); - - const int BUF_SIZE = 2048; - char buf[BUF_SIZE]; - - while( fgets( buf, BUF_SIZE, file ) ) - { - data += buf; - } - fclose( file ); - - Parse( data.c_str() ); - if ( !Error() ) - { - return true; - } - } - SetError( TIXML_ERROR_OPENING_FILE ); - return false; + // There was a really terrifying little bug here. The code: + // value = filename + // in the STL case, cause the assignment method of the std::string to + // be called. What is strange, is that the std::string had the same + // address as it's c_str() method, and so bad things happen. Looks + // like a bug in the Microsoft STL implementation. + // See STL_STRING_BUG above. + // Fixed with the StringToBuffer class. + value = filename; + + FILE* file = fopen( value.c_str (), "r" ); + + if ( file ) + { + // Get the file size, so we can pre-allocate the string. HUGE speed impact. + long length = 0; + fseek( file, 0, SEEK_END ); + length = ftell( file ); + fseek( file, 0, SEEK_SET ); + + // Strange case, but good to handle up front. + if ( length == 0 ) + { + fclose( file ); + return false; + } + + // If we have a file, assume it is all one big XML file, and read it in. + // The document parser may decide the document ends sooner than the entire file, however. + TIXML_STRING data; + data.reserve( length ); + + const int BUF_SIZE = 2048; + char buf[BUF_SIZE]; + + while( fgets( buf, BUF_SIZE, file ) ) + { + data += buf; + } + fclose( file ); + + Parse( data.c_str() ); + if ( !Error() ) + { + return true; + } + } + SetError( TIXML_ERROR_OPENING_FILE ); + return false; } bool TiXmlDocument::SaveFile( const char * filename ) const { - // The old c stuff lives on... - FILE* fp = fopen( filename, "w" ); - if ( fp ) - { - Print( fp, 0 ); - fclose( fp ); - return true; - } - return false; + // The old c stuff lives on... + FILE* fp = fopen( filename, "w" ); + if ( fp ) + { + Print( fp, 0 ); + fclose( fp ); + return true; + } + return false; } TiXmlNode* TiXmlDocument::Clone() const { - TiXmlDocument* clone = new TiXmlDocument(); - if ( !clone ) - return 0; - - CopyToClone( clone ); - clone->error = error; - clone->errorDesc = errorDesc.c_str (); - - TiXmlNode* node = 0; - for ( node = firstChild; node; node = node->NextSibling() ) - { - clone->LinkEndChild( node->Clone() ); - } - return clone; + TiXmlDocument* clone = new TiXmlDocument(); + if ( !clone ) + return 0; + + CopyToClone( clone ); + clone->error = error; + clone->errorDesc = errorDesc.c_str (); + + TiXmlNode* node = 0; + for ( node = firstChild; node; node = node->NextSibling() ) + { + clone->LinkEndChild( node->Clone() ); + } + return clone; } void TiXmlDocument::Print( FILE* cfile, int depth ) const { - TiXmlNode* node; - for ( node=FirstChild(); node; node=node->NextSibling() ) - { - node->Print( cfile, depth ); - fprintf( cfile, "\n" ); - } + TiXmlNode* node; + for ( node=FirstChild(); node; node=node->NextSibling() ) + { + node->Print( cfile, depth ); + fprintf( cfile, "\n" ); + } } void TiXmlDocument::StreamOut( TIXML_OSTREAM * out ) const { - TiXmlNode* node; - for ( node=FirstChild(); node; node=node->NextSibling() ) - { - node->StreamOut( out ); - - // Special rule for streams: stop after the root element. - // The stream in code will only read one element, so don't - // write more than one. - if ( node->ToElement() ) - break; - } + TiXmlNode* node; + for ( node=FirstChild(); node; node=node->NextSibling() ) + { + node->StreamOut( out ); + + // Special rule for streams: stop after the root element. + // The stream in code will only read one element, so don't + // write more than one. + if ( node->ToElement() ) + break; + } } TiXmlAttribute* TiXmlAttribute::Next() const { - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( next->value.empty() && next->name.empty() ) - return 0; - return next; + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( next->value.empty() && next->name.empty() ) + return 0; + return next; } TiXmlAttribute* TiXmlAttribute::Previous() const { - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( prev->value.empty() && prev->name.empty() ) - return 0; - return prev; + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( prev->value.empty() && prev->name.empty() ) + return 0; + return prev; } void TiXmlAttribute::Print( FILE* cfile, int /*depth*/ ) const { - TIXML_STRING n, v; + TIXML_STRING n, v; - PutString( Name(), &n ); - PutString( Value(), &v ); + PutString( Name(), &n ); + PutString( Value(), &v ); - if (value.find ('\"') == TIXML_STRING::npos) - fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() ); - else - fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() ); + if (value.find ('\"') == TIXML_STRING::npos) + fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() ); + else + fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() ); } void TiXmlAttribute::StreamOut( TIXML_OSTREAM * stream ) const { - if (value.find( '\"' ) != TIXML_STRING::npos) - { - PutString( name, stream ); - (*stream) << "=" << "'"; - PutString( value, stream ); - (*stream) << "'"; - } - else - { - PutString( name, stream ); - (*stream) << "=" << "\""; - PutString( value, stream ); - (*stream) << "\""; - } + if (value.find( '\"' ) != TIXML_STRING::npos) + { + PutString( name, stream ); + (*stream) << "=" << "'"; + PutString( value, stream ); + (*stream) << "'"; + } + else + { + PutString( name, stream ); + (*stream) << "=" << "\""; + PutString( value, stream ); + (*stream) << "\""; + } } void TiXmlAttribute::SetIntValue( int value ) { - char buf [64]; - sprintf (buf, "%d", value); - SetValue (buf); + char buf [64]; + sprintf (buf, "%d", value); + SetValue (buf); } void TiXmlAttribute::SetDoubleValue( double value ) { - char buf [64]; - sprintf (buf, "%lf", value); - SetValue (buf); + char buf [64]; + sprintf (buf, "%lf", value); + SetValue (buf); } const int TiXmlAttribute::IntValue() const { - return atoi (value.c_str ()); + return atoi (value.c_str ()); } const double TiXmlAttribute::DoubleValue() const { - return atof (value.c_str ()); + return atof (value.c_str ()); } void TiXmlComment::Print( FILE* cfile, int depth ) const { - for ( int i=0; i", value.c_str() ); + for ( int i=0; i", value.c_str() ); } void TiXmlComment::StreamOut( TIXML_OSTREAM * stream ) const { - (*stream) << ""; + (*stream) << ""; } TiXmlNode* TiXmlComment::Clone() const { - TiXmlComment* clone = new TiXmlComment(); + TiXmlComment* clone = new TiXmlComment(); - if ( !clone ) - return 0; + if ( !clone ) + return 0; - CopyToClone( clone ); - return clone; + CopyToClone( clone ); + return clone; } void TiXmlText::Print( FILE* cfile, int /*depth*/ ) const { - TIXML_STRING buffer; - PutString( value, &buffer ); - fprintf( cfile, "%s", buffer.c_str() ); + TIXML_STRING buffer; + PutString( value, &buffer ); + fprintf( cfile, "%s", buffer.c_str() ); } void TiXmlText::StreamOut( TIXML_OSTREAM * stream ) const { - PutString( value, stream ); + PutString( value, stream ); } TiXmlNode* TiXmlText::Clone() const -{ - TiXmlText* clone = 0; - clone = new TiXmlText( "" ); +{ + TiXmlText* clone = 0; + clone = new TiXmlText( "" ); - if ( !clone ) - return 0; + if ( !clone ) + return 0; - CopyToClone( clone ); - return clone; + CopyToClone( clone ); + return clone; } TiXmlDeclaration::TiXmlDeclaration( const char * _version, - const char * _encoding, - const char * _standalone ) + const char * _encoding, + const char * _standalone ) : TiXmlNode( TiXmlNode::DECLARATION ) { - version = _version; - encoding = _encoding; - standalone = _standalone; + version = _version; + encoding = _encoding; + standalone = _standalone; } void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/ ) const { - fprintf (cfile, ""); + if ( !version.empty() ) + fprintf (cfile, "version=\"%s\" ", version.c_str ()); + if ( !encoding.empty() ) + fprintf (cfile, "encoding=\"%s\" ", encoding.c_str ()); + if ( !standalone.empty() ) + fprintf (cfile, "standalone=\"%s\" ", standalone.c_str ()); + fprintf (cfile, "?>"); } void TiXmlDeclaration::StreamOut( TIXML_OSTREAM * stream ) const { - (*stream) << ""; + if ( !version.empty() ) + { + (*stream) << "version=\""; + PutString( version, stream ); + (*stream) << "\" "; + } + if ( !encoding.empty() ) + { + (*stream) << "encoding=\""; + PutString( encoding, stream ); + (*stream ) << "\" "; + } + if ( !standalone.empty() ) + { + (*stream) << "standalone=\""; + PutString( standalone, stream ); + (*stream) << "\" "; + } + (*stream) << "?>"; } TiXmlNode* TiXmlDeclaration::Clone() const -{ - TiXmlDeclaration* clone = new TiXmlDeclaration(); +{ + TiXmlDeclaration* clone = new TiXmlDeclaration(); - if ( !clone ) - return 0; + if ( !clone ) + return 0; - CopyToClone( clone ); - clone->version = version; - clone->encoding = encoding; - clone->standalone = standalone; - return clone; + CopyToClone( clone ); + clone->version = version; + clone->encoding = encoding; + clone->standalone = standalone; + return clone; } void TiXmlUnknown::Print( FILE* cfile, int depth ) const { - for ( int i=0; i"; // Don't use entities hear! It is unknown. + (*stream) << "<" << value << ">"; // Don't use entities hear! It is unknown. } TiXmlNode* TiXmlUnknown::Clone() const { - TiXmlUnknown* clone = new TiXmlUnknown(); + TiXmlUnknown* clone = new TiXmlUnknown(); - if ( !clone ) - return 0; + if ( !clone ) + return 0; - CopyToClone( clone ); - return clone; + CopyToClone( clone ); + return clone; } TiXmlAttributeSet::TiXmlAttributeSet() { - sentinel.next = &sentinel; - sentinel.prev = &sentinel; + sentinel.next = &sentinel; + sentinel.prev = &sentinel; } TiXmlAttributeSet::~TiXmlAttributeSet() { - assert( sentinel.next == &sentinel ); - assert( sentinel.prev == &sentinel ); + assert( sentinel.next == &sentinel ); + assert( sentinel.prev == &sentinel ); } void TiXmlAttributeSet::Add( TiXmlAttribute* addMe ) { - assert( !Find( addMe->Name() ) ); // Shouldn't be multiply adding to the set. + assert( !Find( addMe->Name() ) ); // Shouldn't be multiply adding to the set. - addMe->next = &sentinel; - addMe->prev = sentinel.prev; + addMe->next = &sentinel; + addMe->prev = sentinel.prev; - sentinel.prev->next = addMe; - sentinel.prev = addMe; + sentinel.prev->next = addMe; + sentinel.prev = addMe; } void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe ) { - TiXmlAttribute* node; + TiXmlAttribute* node; - for( node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( node == removeMe ) - { - node->prev->next = node->next; - node->next->prev = node->prev; - node->next = 0; - node->prev = 0; - return; - } - } - assert( 0 ); // we tried to remove a non-linked attribute. + for( node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( node == removeMe ) + { + node->prev->next = node->next; + node->next->prev = node->prev; + node->next = 0; + node->prev = 0; + return; + } + } + assert( 0 ); // we tried to remove a non-linked attribute. } -TiXmlAttribute* TiXmlAttributeSet::Find( const char * name ) const +TiXmlAttribute* TiXmlAttributeSet::Find( const char * name ) const { - TiXmlAttribute* node; + TiXmlAttribute* node; - for( node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( node->name == name ) - return node; - } - return 0; + for( node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( node->name == name ) + return node; + } + return 0; } -#ifdef TIXML_USE_STL +#ifdef TIXML_USE_STL TIXML_ISTREAM & operator >> (TIXML_ISTREAM & in, TiXmlNode & base) { - TIXML_STRING tag; - tag.reserve( 8 * 1000 ); - base.StreamIn( &in, &tag ); + TIXML_STRING tag; + tag.reserve( 8 * 1000 ); + base.StreamIn( &in, &tag ); - base.Parse( tag.c_str() ); - return in; + base.Parse( tag.c_str() ); + return in; } #endif TIXML_OSTREAM & operator<< (TIXML_OSTREAM & out, const TiXmlNode & base) { - base.StreamOut (& out); - return out; + base.StreamOut (& out); + return out; } diff -Nru trigger-rally-0.5.2.1/src/pengine/tinyxmlerror.cpp trigger-rally-0.6.0/src/pengine/tinyxmlerror.cpp --- trigger-rally-0.5.2.1/src/pengine/tinyxmlerror.cpp 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/pengine/tinyxmlerror.cpp 2011-10-07 17:10:01.000000000 +0000 @@ -33,18 +33,18 @@ const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] = { - "No error", - "Error", - "Failed to open file", - "Memory allocation failed.", - "Error parsing Element.", - "Failed to read Element name", - "Error reading Element value.", - "Error reading Attributes.", - "Error: empty tag.", - "Error reading end tag.", - "Error parsing Unknown.", - "Error parsing Comment.", - "Error parsing Declaration.", - "Error document empty." + "No error", + "Error", + "Failed to open file", + "Memory allocation failed.", + "Error parsing Element.", + "Failed to read Element name", + "Error reading Element value.", + "Error reading Attributes.", + "Error: empty tag.", + "Error reading end tag.", + "Error parsing Unknown.", + "Error parsing Comment.", + "Error parsing Declaration.", + "Error document empty." }; diff -Nru trigger-rally-0.5.2.1/src/pengine/tinyxml.h trigger-rally-0.6.0/src/pengine/tinyxml.h --- trigger-rally-0.5.2.1/src/pengine/tinyxml.h 2006-10-20 19:03:06.000000000 +0000 +++ trigger-rally-0.6.0/src/pengine/tinyxml.h 2011-10-07 17:10:01.000000000 +0000 @@ -51,14 +51,14 @@ #ifdef TIXML_USE_STL - #include - #define TIXML_STRING std::string - #define TIXML_ISTREAM std::istream - #define TIXML_OSTREAM std::ostream + #include + #define TIXML_STRING std::string + #define TIXML_ISTREAM std::istream + #define TIXML_OSTREAM std::ostream #else - #include "tinystr.h" - #define TIXML_STRING TiXmlString - #define TIXML_OSTREAM TiXmlOutStream + #include "tinystr.h" + #define TIXML_STRING TiXmlString + #define TIXML_OSTREAM TiXmlOutStream #endif class TiXmlDocument; @@ -71,662 +71,662 @@ /** TiXmlBase is a base class for every class in TinyXml. - It does little except to establish that TinyXml classes - can be printed and provide some utility functions. + It does little except to establish that TinyXml classes + can be printed and provide some utility functions. - In XML, the document and elements can contain - other elements and other types of nodes. + In XML, the document and elements can contain + other elements and other types of nodes. - @verbatim - A Document can contain: Element (container or leaf) - Comment (leaf) - Unknown (leaf) - Declaration( leaf ) - - An Element can contain: Element (container or leaf) - Text (leaf) - Attributes (not on tree) - Comment (leaf) - Unknown (leaf) + @verbatim + A Document can contain: Element (container or leaf) + Comment (leaf) + Unknown (leaf) + Declaration( leaf ) + + An Element can contain: Element (container or leaf) + Text (leaf) + Attributes (not on tree) + Comment (leaf) + Unknown (leaf) - A Decleration contains: Attributes (not on tree) - @endverbatim + A Decleration contains: Attributes (not on tree) + @endverbatim */ class TiXmlBase { - friend class TiXmlNode; - friend class TiXmlElement; - friend class TiXmlDocument; + friend class TiXmlNode; + friend class TiXmlElement; + friend class TiXmlDocument; public: - TiXmlBase() {} - virtual ~TiXmlBase() {} + TiXmlBase() {} + virtual ~TiXmlBase() {} - /** All TinyXml classes can print themselves to a filestream. - This is a formatted print, and will insert tabs and newlines. - - (For an unformatted stream, use the << operator.) - */ - virtual void Print( FILE* cfile, int depth ) const = 0; - - /** The world does not agree on whether white space should be kept or - not. In order to make everyone happy, these global, static functions - are provided to set whether or not TinyXml will condense all white space - into a single space or not. The default is to condense. Note changing these - values is not thread safe. - */ - static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; } + /** All TinyXml classes can print themselves to a filestream. + This is a formatted print, and will insert tabs and newlines. + + (For an unformatted stream, use the << operator.) + */ + virtual void Print( FILE* cfile, int depth ) const = 0; + + /** The world does not agree on whether white space should be kept or + not. In order to make everyone happy, these global, static functions + are provided to set whether or not TinyXml will condense all white space + into a single space or not. The default is to condense. Note changing these + values is not thread safe. + */ + static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; } - /// Return the current white space setting. - static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; } + /// Return the current white space setting. + static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; } protected: - // See STL_STRING_BUG - // Utility class to overcome a bug. - class StringToBuffer - { - public: - StringToBuffer( const TIXML_STRING& str ); - ~StringToBuffer(); - char* buffer; - }; - - static const char* SkipWhiteSpace( const char* ); - inline static bool IsWhiteSpace( int c ) { return ( isspace( c ) || c == '\n' || c == '\r' ); } - - virtual void StreamOut (TIXML_OSTREAM *) const = 0; - - #ifdef TIXML_USE_STL - static bool StreamWhiteSpace( TIXML_ISTREAM * in, TIXML_STRING * tag ); - static bool StreamTo( TIXML_ISTREAM * in, int character, TIXML_STRING * tag ); - #endif - - /* Reads an XML name into the string provided. Returns - a pointer just past the last character of the name, - or 0 if the function has an error. - */ - static const char* ReadName( const char* p, TIXML_STRING* name ); - - /* Reads text. Returns a pointer past the given end tag. - Wickedly complex options, but it keeps the (sensitive) code in one place. - */ - static const char* ReadText( const char* in, // where to start - TIXML_STRING* text, // the string read - bool ignoreWhiteSpace, // whether to keep the white space - const char* endTag, // what ends this text - bool ignoreCase ); // whether to ignore case in the end tag - virtual const char* Parse( const char* p ) = 0; - - // If an entity has been found, transform it into a character. - static const char* GetEntity( const char* in, char* value ); - - // Get a character, while interpreting entities. - inline static const char* GetChar( const char* p, char* value ) - { - assert( p ); - if ( *p == '&' ) - { - return GetEntity( p, value ); - } - else - { - *value = *p; - return p+1; - } - } - - // Puts a string to a stream, expanding entities as it goes. - // Note this should not contian the '<', '>', etc, or they will be transformed into entities! - static void PutString( const TIXML_STRING& str, TIXML_OSTREAM* out ); - - static void PutString( const TIXML_STRING& str, TIXML_STRING* out ); - - // Return true if the next characters in the stream are any of the endTag sequences. - static bool StringEqual( const char* p, - const char* endTag, - bool ignoreCase ); - - - enum - { - TIXML_NO_ERROR = 0, - TIXML_ERROR, - TIXML_ERROR_OPENING_FILE, - TIXML_ERROR_OUT_OF_MEMORY, - TIXML_ERROR_PARSING_ELEMENT, - TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, - TIXML_ERROR_READING_ELEMENT_VALUE, - TIXML_ERROR_READING_ATTRIBUTES, - TIXML_ERROR_PARSING_EMPTY, - TIXML_ERROR_READING_END_TAG, - TIXML_ERROR_PARSING_UNKNOWN, - TIXML_ERROR_PARSING_COMMENT, - TIXML_ERROR_PARSING_DECLARATION, - TIXML_ERROR_DOCUMENT_EMPTY, - - TIXML_ERROR_STRING_COUNT - }; - static const char* errorString[ TIXML_ERROR_STRING_COUNT ]; + // See STL_STRING_BUG + // Utility class to overcome a bug. + class StringToBuffer + { + public: + StringToBuffer( const TIXML_STRING& str ); + ~StringToBuffer(); + char* buffer; + }; + + static const char* SkipWhiteSpace( const char* ); + inline static bool IsWhiteSpace( int c ) { return ( isspace( c ) || c == '\n' || c == '\r' ); } + + virtual void StreamOut (TIXML_OSTREAM *) const = 0; + + #ifdef TIXML_USE_STL + static bool StreamWhiteSpace( TIXML_ISTREAM * in, TIXML_STRING * tag ); + static bool StreamTo( TIXML_ISTREAM * in, int character, TIXML_STRING * tag ); + #endif + + /* Reads an XML name into the string provided. Returns + a pointer just past the last character of the name, + or 0 if the function has an error. + */ + static const char* ReadName( const char* p, TIXML_STRING* name ); + + /* Reads text. Returns a pointer past the given end tag. + Wickedly complex options, but it keeps the (sensitive) code in one place. + */ + static const char* ReadText( const char* in, // where to start + TIXML_STRING* text, // the string read + bool ignoreWhiteSpace, // whether to keep the white space + const char* endTag, // what ends this text + bool ignoreCase ); // whether to ignore case in the end tag + virtual const char* Parse( const char* p ) = 0; + + // If an entity has been found, transform it into a character. + static const char* GetEntity( const char* in, char* value ); + + // Get a character, while interpreting entities. + inline static const char* GetChar( const char* p, char* value ) + { + assert( p ); + if ( *p == '&' ) + { + return GetEntity( p, value ); + } + else + { + *value = *p; + return p+1; + } + } + + // Puts a string to a stream, expanding entities as it goes. + // Note this should not contian the '<', '>', etc, or they will be transformed into entities! + static void PutString( const TIXML_STRING& str, TIXML_OSTREAM* out ); + + static void PutString( const TIXML_STRING& str, TIXML_STRING* out ); + + // Return true if the next characters in the stream are any of the endTag sequences. + static bool StringEqual( const char* p, + const char* endTag, + bool ignoreCase ); + + + enum + { + TIXML_NO_ERROR = 0, + TIXML_ERROR, + TIXML_ERROR_OPENING_FILE, + TIXML_ERROR_OUT_OF_MEMORY, + TIXML_ERROR_PARSING_ELEMENT, + TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, + TIXML_ERROR_READING_ELEMENT_VALUE, + TIXML_ERROR_READING_ATTRIBUTES, + TIXML_ERROR_PARSING_EMPTY, + TIXML_ERROR_READING_END_TAG, + TIXML_ERROR_PARSING_UNKNOWN, + TIXML_ERROR_PARSING_COMMENT, + TIXML_ERROR_PARSING_DECLARATION, + TIXML_ERROR_DOCUMENT_EMPTY, + + TIXML_ERROR_STRING_COUNT + }; + static const char* errorString[ TIXML_ERROR_STRING_COUNT ]; private: - struct Entity - { - const char* str; - unsigned int strLength; - char chr; - }; - enum - { - NUM_ENTITY = 5, - MAX_ENTITY_LENGTH = 6 - - }; - static Entity entity[ NUM_ENTITY ]; - static bool condenseWhiteSpace; + struct Entity + { + const char* str; + unsigned int strLength; + char chr; + }; + enum + { + NUM_ENTITY = 5, + MAX_ENTITY_LENGTH = 6 + + }; + static Entity entity[ NUM_ENTITY ]; + static bool condenseWhiteSpace; }; /** The parent class for everything in the Document Object Model. - (Except for attributes, which are contained in elements.) - Nodes have siblings, a parent, and children. A node can be - in a document, or stand on its own. The type of a TiXmlNode - can be queried, and it can be cast to its more defined type. + (Except for attributes, which are contained in elements.) + Nodes have siblings, a parent, and children. A node can be + in a document, or stand on its own. The type of a TiXmlNode + can be queried, and it can be cast to its more defined type. */ class TiXmlNode : public TiXmlBase { - friend class TiXmlDocument; - friend class TiXmlElement; + friend class TiXmlDocument; + friend class TiXmlElement; public: - #ifdef TIXML_USE_STL + #ifdef TIXML_USE_STL - /** An input stream operator, for every class. Tolerant of newlines and - formatting, but doesn't expect them. - */ - friend std::istream& operator >> (std::istream& in, TiXmlNode& base); - - /** An output stream operator, for every class. Note that this outputs - without any newlines or formatting, as opposed to Print(), which - includes tabs and new lines. - - The operator<< and operator>> are not completely symmetric. Writing - a node to a stream is very well defined. You'll get a nice stream - of output, without any extra whitespace or newlines. - - But reading is not as well defined. (As it always is.) If you create - a TiXmlElement (for example) and read that from an input stream, - the text needs to define an element or junk will result. This is - true of all input streams, but it's worth keeping in mind. - - A TiXmlDocument will read nodes until it reads a root element. - */ - friend std::ostream & operator<< (std::ostream& out, const TiXmlNode& base); - - #else - // Used internally, not part of the public API. - friend TIXML_OSTREAM& operator<< (TIXML_OSTREAM& out, const TiXmlNode& base); - #endif - - /** The types of XML nodes supported by TinyXml. (All the - unsupported types are picked up by UNKNOWN.) - */ - enum NodeType - { - DOCUMENT, - ELEMENT, - COMMENT, - UNKNOWN, - TEXT, - DECLARATION, - TYPECOUNT - }; - - virtual ~TiXmlNode(); - - /** The meaning of 'value' changes for the specific type of - TiXmlNode. - @verbatim - Document: filename of the xml file - Element: name of the element - Comment: the comment text - Unknown: the tag contents - Text: the text string - @endverbatim - - The subclasses will wrap this function. - */ - const char * Value () const { return value.c_str (); } - - /** Changes the value of the node. Defined as: - @verbatim - Document: filename of the xml file - Element: name of the element - Comment: the comment text - Unknown: the tag contents - Text: the text string - @endverbatim - */ - void SetValue (const char * _value) { value = _value;} + /** An input stream operator, for every class. Tolerant of newlines and + formatting, but doesn't expect them. + */ + friend std::istream& operator >> (std::istream& in, TiXmlNode& base); + + /** An output stream operator, for every class. Note that this outputs + without any newlines or formatting, as opposed to Print(), which + includes tabs and new lines. + + The operator<< and operator>> are not completely symmetric. Writing + a node to a stream is very well defined. You'll get a nice stream + of output, without any extra whitespace or newlines. + + But reading is not as well defined. (As it always is.) If you create + a TiXmlElement (for example) and read that from an input stream, + the text needs to define an element or junk will result. This is + true of all input streams, but it's worth keeping in mind. + + A TiXmlDocument will read nodes until it reads a root element. + */ + friend std::ostream & operator<< (std::ostream& out, const TiXmlNode& base); + + #else + // Used internally, not part of the public API. + friend TIXML_OSTREAM& operator<< (TIXML_OSTREAM& out, const TiXmlNode& base); + #endif + + /** The types of XML nodes supported by TinyXml. (All the + unsupported types are picked up by UNKNOWN.) + */ + enum NodeType + { + DOCUMENT, + ELEMENT, + COMMENT, + UNKNOWN, + TEXT, + DECLARATION, + TYPECOUNT + }; + + virtual ~TiXmlNode(); + + /** The meaning of 'value' changes for the specific type of + TiXmlNode. + @verbatim + Document: filename of the xml file + Element: name of the element + Comment: the comment text + Unknown: the tag contents + Text: the text string + @endverbatim + + The subclasses will wrap this function. + */ + const char * Value () const { return value.c_str (); } + + /** Changes the value of the node. Defined as: + @verbatim + Document: filename of the xml file + Element: name of the element + Comment: the comment text + Unknown: the tag contents + Text: the text string + @endverbatim + */ + void SetValue (const char * _value) { value = _value;} #ifdef TIXML_USE_STL - /// STL std::string form. - void SetValue( const std::string& value ) - { - StringToBuffer buf( value ); - SetValue( buf.buffer ? buf.buffer : "" ); - } - #endif - - /// Delete all the children of this node. Does not affect 'this'. - void Clear(); + /// STL std::string form. + void SetValue( const std::string& value ) + { + StringToBuffer buf( value ); + SetValue( buf.buffer ? buf.buffer : "" ); + } + #endif + + /// Delete all the children of this node. Does not affect 'this'. + void Clear(); - /// One step up the DOM. - TiXmlNode* Parent() const { return parent; } + /// One step up the DOM. + TiXmlNode* Parent() const { return parent; } - TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children. - TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found. + TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children. + TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found. - TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children. - TiXmlNode* LastChild( const char * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children. + TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children. + TiXmlNode* LastChild( const char * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children. #ifdef TIXML_USE_STL - TiXmlNode* FirstChild( const std::string& value ) const { return FirstChild (value.c_str ()); } ///< STL std::string form. - TiXmlNode* LastChild( const std::string& value ) const { return LastChild (value.c_str ()); } ///< STL std::string form. - #endif - - /** An alternate way to walk the children of a node. - One way to iterate over nodes is: - @verbatim - for( child = parent->FirstChild(); child; child = child->NextSibling() ) - @endverbatim - - IterateChildren does the same thing with the syntax: - @verbatim - child = 0; - while( child = parent->IterateChildren( child ) ) - @endverbatim - - IterateChildren takes the previous child as input and finds - the next one. If the previous child is null, it returns the - first. IterateChildren will return null when done. - */ - TiXmlNode* IterateChildren( TiXmlNode* previous ) const; + TiXmlNode* FirstChild( const std::string& value ) const { return FirstChild (value.c_str ()); } ///< STL std::string form. + TiXmlNode* LastChild( const std::string& value ) const { return LastChild (value.c_str ()); } ///< STL std::string form. + #endif + + /** An alternate way to walk the children of a node. + One way to iterate over nodes is: + @verbatim + for( child = parent->FirstChild(); child; child = child->NextSibling() ) + @endverbatim + + IterateChildren does the same thing with the syntax: + @verbatim + child = 0; + while( child = parent->IterateChildren( child ) ) + @endverbatim + + IterateChildren takes the previous child as input and finds + the next one. If the previous child is null, it returns the + first. IterateChildren will return null when done. + */ + TiXmlNode* IterateChildren( TiXmlNode* previous ) const; - /// This flavor of IterateChildren searches for children with a particular 'value' - TiXmlNode* IterateChildren( const char * value, TiXmlNode* previous ) const; + /// This flavor of IterateChildren searches for children with a particular 'value' + TiXmlNode* IterateChildren( const char * value, TiXmlNode* previous ) const; #ifdef TIXML_USE_STL - TiXmlNode* IterateChildren( const std::string& value, TiXmlNode* previous ) const { return IterateChildren (value.c_str (), previous); } ///< STL std::string form. - #endif + TiXmlNode* IterateChildren( const std::string& value, TiXmlNode* previous ) const { return IterateChildren (value.c_str (), previous); } ///< STL std::string form. + #endif - /** Add a new node related to this. Adds a child past the LastChild. - Returns a pointer to the new object or NULL if an error occured. - */ - TiXmlNode* InsertEndChild( const TiXmlNode& addThis ); - - /** Add a new node related to this. Adds a child before the specified child. - Returns a pointer to the new object or NULL if an error occured. - */ - TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ); - - /** Add a new node related to this. Adds a child after the specified child. - Returns a pointer to the new object or NULL if an error occured. - */ - TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ); - - /** Replace a child of this node. - Returns a pointer to the new object or NULL if an error occured. - */ - TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ); + /** Add a new node related to this. Adds a child past the LastChild. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* InsertEndChild( const TiXmlNode& addThis ); + + /** Add a new node related to this. Adds a child before the specified child. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ); + + /** Add a new node related to this. Adds a child after the specified child. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ); + + /** Replace a child of this node. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ); - /// Delete a child of this node. - bool RemoveChild( TiXmlNode* removeThis ); + /// Delete a child of this node. + bool RemoveChild( TiXmlNode* removeThis ); - /// Navigate to a sibling node. - TiXmlNode* PreviousSibling() const { return prev; } + /// Navigate to a sibling node. + TiXmlNode* PreviousSibling() const { return prev; } - /// Navigate to a sibling node. - TiXmlNode* PreviousSibling( const char * ) const; + /// Navigate to a sibling node. + TiXmlNode* PreviousSibling( const char * ) const; #ifdef TIXML_USE_STL - TiXmlNode* PreviousSibling( const std::string& value ) const { return PreviousSibling (value.c_str ()); } ///< STL std::string form. - TiXmlNode* NextSibling( const std::string& value) const { return NextSibling (value.c_str ()); } ///< STL std::string form. - #endif - - /// Navigate to a sibling node. - TiXmlNode* NextSibling() const { return next; } - - /// Navigate to a sibling node with the given 'value'. - TiXmlNode* NextSibling( const char * ) const; - - /** Convenience function to get through elements. - Calls NextSibling and ToElement. Will skip all non-Element - nodes. Returns 0 if there is not another element. - */ - TiXmlElement* NextSiblingElement() const; - - /** Convenience function to get through elements. - Calls NextSibling and ToElement. Will skip all non-Element - nodes. Returns 0 if there is not another element. - */ - TiXmlElement* NextSiblingElement( const char * ) const; + TiXmlNode* PreviousSibling( const std::string& value ) const { return PreviousSibling (value.c_str ()); } ///< STL std::string form. + TiXmlNode* NextSibling( const std::string& value) const { return NextSibling (value.c_str ()); } ///< STL std::string form. + #endif + + /// Navigate to a sibling node. + TiXmlNode* NextSibling() const { return next; } + + /// Navigate to a sibling node with the given 'value'. + TiXmlNode* NextSibling( const char * ) const; + + /** Convenience function to get through elements. + Calls NextSibling and ToElement. Will skip all non-Element + nodes. Returns 0 if there is not another element. + */ + TiXmlElement* NextSiblingElement() const; + + /** Convenience function to get through elements. + Calls NextSibling and ToElement. Will skip all non-Element + nodes. Returns 0 if there is not another element. + */ + TiXmlElement* NextSiblingElement( const char * ) const; #ifdef TIXML_USE_STL - TiXmlElement* NextSiblingElement( const std::string& value) const { return NextSiblingElement (value.c_str ()); } ///< STL std::string form. - #endif + TiXmlElement* NextSiblingElement( const std::string& value) const { return NextSiblingElement (value.c_str ()); } ///< STL std::string form. + #endif - /// Convenience function to get through elements. - TiXmlElement* FirstChildElement() const; + /// Convenience function to get through elements. + TiXmlElement* FirstChildElement() const; - /// Convenience function to get through elements. - TiXmlElement* FirstChildElement( const char * value ) const; + /// Convenience function to get through elements. + TiXmlElement* FirstChildElement( const char * value ) const; #ifdef TIXML_USE_STL - TiXmlElement* FirstChildElement( const std::string& value ) const { return FirstChildElement (value.c_str ()); } ///< STL std::string form. - #endif + TiXmlElement* FirstChildElement( const std::string& value ) const { return FirstChildElement (value.c_str ()); } ///< STL std::string form. + #endif - /// Query the type (as an enumerated value, above) of this node. - virtual int Type() const { return type; } + /// Query the type (as an enumerated value, above) of this node. + virtual int Type() const { return type; } - /** Return a pointer to the Document this node lives in. - Returns null if not in a document. - */ - TiXmlDocument* GetDocument() const; - - /// Returns true if this node has no children. - bool NoChildren() const { return !firstChild; } - - TiXmlDocument* ToDocument() const { return ( this && type == DOCUMENT ) ? (TiXmlDocument*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type. - TiXmlElement* ToElement() const { return ( this && type == ELEMENT ) ? (TiXmlElement*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type. - TiXmlComment* ToComment() const { return ( this && type == COMMENT ) ? (TiXmlComment*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type. - TiXmlUnknown* ToUnknown() const { return ( this && type == UNKNOWN ) ? (TiXmlUnknown*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type. - TiXmlText* ToText() const { return ( this && type == TEXT ) ? (TiXmlText*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type. - TiXmlDeclaration* ToDeclaration() const { return ( this && type == DECLARATION ) ? (TiXmlDeclaration*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type. + /** Return a pointer to the Document this node lives in. + Returns null if not in a document. + */ + TiXmlDocument* GetDocument() const; + + /// Returns true if this node has no children. + bool NoChildren() const { return !firstChild; } + + TiXmlDocument* ToDocument() const { return ( this && type == DOCUMENT ) ? (TiXmlDocument*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type. + TiXmlElement* ToElement() const { return ( this && type == ELEMENT ) ? (TiXmlElement*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type. + TiXmlComment* ToComment() const { return ( this && type == COMMENT ) ? (TiXmlComment*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type. + TiXmlUnknown* ToUnknown() const { return ( this && type == UNKNOWN ) ? (TiXmlUnknown*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type. + TiXmlText* ToText() const { return ( this && type == TEXT ) ? (TiXmlText*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type. + TiXmlDeclaration* ToDeclaration() const { return ( this && type == DECLARATION ) ? (TiXmlDeclaration*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlNode* Clone() const = 0; + virtual TiXmlNode* Clone() const = 0; - void SetUserData( void* user ) { userData = user; } - void* GetUserData() { return userData; } + void SetUserData( void* user ) { userData = user; } + void* GetUserData() { return userData; } protected: - TiXmlNode( NodeType type ); + TiXmlNode( NodeType type ); - #ifdef TIXML_USE_STL - // The real work of the input operator. - virtual void StreamIn( TIXML_ISTREAM* in, TIXML_STRING* tag ) = 0; - #endif + #ifdef TIXML_USE_STL + // The real work of the input operator. + virtual void StreamIn( TIXML_ISTREAM* in, TIXML_STRING* tag ) = 0; + #endif - // The node is passed in by ownership. This object will delete it. - TiXmlNode* LinkEndChild( TiXmlNode* addThis ); + // The node is passed in by ownership. This object will delete it. + TiXmlNode* LinkEndChild( TiXmlNode* addThis ); - // Figure out what is at *p, and parse it. Returns null if it is not an xml node. - TiXmlNode* Identify( const char* start ); - void CopyToClone( TiXmlNode* target ) const { target->SetValue (value.c_str() ); - target->userData = userData; } + // Figure out what is at *p, and parse it. Returns null if it is not an xml node. + TiXmlNode* Identify( const char* start ); + void CopyToClone( TiXmlNode* target ) const { target->SetValue (value.c_str() ); + target->userData = userData; } - // Internal Value function returning a TIXML_STRING - TIXML_STRING SValue() const { return value ; } + // Internal Value function returning a TIXML_STRING + TIXML_STRING SValue() const { return value ; } - TiXmlNode* parent; - NodeType type; + TiXmlNode* parent; + NodeType type; - TiXmlNode* firstChild; - TiXmlNode* lastChild; + TiXmlNode* firstChild; + TiXmlNode* lastChild; - TIXML_STRING value; + TIXML_STRING value; - TiXmlNode* prev; - TiXmlNode* next; - void* userData; + TiXmlNode* prev; + TiXmlNode* next; + void* userData; }; /** An attribute is a name-value pair. Elements have an arbitrary - number of attributes, each with a unique name. + number of attributes, each with a unique name. - @note The attributes are not TiXmlNodes, since they are not - part of the tinyXML document object model. There are other - suggested ways to look at this problem. + @note The attributes are not TiXmlNodes, since they are not + part of the tinyXML document object model. There are other + suggested ways to look at this problem. - @note Attributes have a parent + @note Attributes have a parent */ class TiXmlAttribute : public TiXmlBase { - friend class TiXmlAttributeSet; + friend class TiXmlAttributeSet; public: - /// Construct an empty attribute. - TiXmlAttribute() : prev( 0 ), next( 0 ) {} + /// Construct an empty attribute. + TiXmlAttribute() : prev( 0 ), next( 0 ) {} - #ifdef TIXML_USE_STL - /// std::string constructor. - TiXmlAttribute( const std::string& _name, const std::string& _value ) - { - name = _name; - value = _value; - } - #endif - - /// Construct an attribute with a name and value. - TiXmlAttribute( const char * _name, const char * _value ): name( _name ), value( _value ), prev( 0 ), next( 0 ) {} - const char* Name() const { return name.c_str (); } ///< Return the name of this attribute. - const char* Value() const { return value.c_str (); } ///< Return the value of this attribute. - const int IntValue() const; ///< Return the value of this attribute, converted to an integer. - const double DoubleValue() const; ///< Return the value of this attribute, converted to a double. + #ifdef TIXML_USE_STL + /// std::string constructor. + TiXmlAttribute( const std::string& _name, const std::string& _value ) + { + name = _name; + value = _value; + } + #endif + + /// Construct an attribute with a name and value. + TiXmlAttribute( const char * _name, const char * _value ): name( _name ), value( _value ), prev( 0 ), next( 0 ) {} + const char* Name() const { return name.c_str (); } ///< Return the name of this attribute. + const char* Value() const { return value.c_str (); } ///< Return the value of this attribute. + const int IntValue() const; ///< Return the value of this attribute, converted to an integer. + const double DoubleValue() const; ///< Return the value of this attribute, converted to a double. - void SetName( const char* _name ) { name = _name; } ///< Set the name of this attribute. - void SetValue( const char* _value ) { value = _value; } ///< Set the value. + void SetName( const char* _name ) { name = _name; } ///< Set the name of this attribute. + void SetValue( const char* _value ) { value = _value; } ///< Set the value. - void SetIntValue( int value ); ///< Set the value from an integer. - void SetDoubleValue( double value ); ///< Set the value from a double. + void SetIntValue( int value ); ///< Set the value from an integer. + void SetDoubleValue( double value ); ///< Set the value from a double. #ifdef TIXML_USE_STL - /// STL std::string form. - void SetName( const std::string& _name ) - { - StringToBuffer buf( _name ); - SetName ( buf.buffer ? buf.buffer : "error" ); - } - /// STL std::string form. - void SetValue( const std::string& _value ) - { - StringToBuffer buf( _value ); - SetValue( buf.buffer ? buf.buffer : "error" ); - } - #endif - - /// Get the next sibling attribute in the DOM. Returns null at end. - TiXmlAttribute* Next() const; - /// Get the previous sibling attribute in the DOM. Returns null at beginning. - TiXmlAttribute* Previous() const; - - bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; } - bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; } - bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; } - - /* [internal use] - Attribtue parsing starts: first letter of the name - returns: the next char after the value end quote - */ - virtual const char* Parse( const char* p ); - - // [internal use] - virtual void Print( FILE* cfile, int depth ) const; - - virtual void StreamOut( TIXML_OSTREAM * out ) const; - // [internal use] - // Set the document pointer so the attribute can report errors. - void SetDocument( TiXmlDocument* doc ) { document = doc; } + /// STL std::string form. + void SetName( const std::string& _name ) + { + StringToBuffer buf( _name ); + SetName ( buf.buffer ? buf.buffer : "error" ); + } + /// STL std::string form. + void SetValue( const std::string& _value ) + { + StringToBuffer buf( _value ); + SetValue( buf.buffer ? buf.buffer : "error" ); + } + #endif + + /// Get the next sibling attribute in the DOM. Returns null at end. + TiXmlAttribute* Next() const; + /// Get the previous sibling attribute in the DOM. Returns null at beginning. + TiXmlAttribute* Previous() const; + + bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; } + bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; } + bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; } + + /* [internal use] + Attribtue parsing starts: first letter of the name + returns: the next char after the value end quote + */ + virtual const char* Parse( const char* p ); + + // [internal use] + virtual void Print( FILE* cfile, int depth ) const; + + virtual void StreamOut( TIXML_OSTREAM * out ) const; + // [internal use] + // Set the document pointer so the attribute can report errors. + void SetDocument( TiXmlDocument* doc ) { document = doc; } private: - TiXmlDocument* document; // A pointer back to a document, for error reporting. - TIXML_STRING name; - TIXML_STRING value; - TiXmlAttribute* prev; - TiXmlAttribute* next; + TiXmlDocument* document; // A pointer back to a document, for error reporting. + TIXML_STRING name; + TIXML_STRING value; + TiXmlAttribute* prev; + TiXmlAttribute* next; }; -/* A class used to manage a group of attributes. - It is only used internally, both by the ELEMENT and the DECLARATION. - - The set can be changed transparent to the Element and Declaration - classes that use it, but NOT transparent to the Attribute - which has to implement a next() and previous() method. Which makes - it a bit problematic and prevents the use of STL. - - This version is implemented with circular lists because: - - I like circular lists - - it demonstrates some independence from the (typical) doubly linked list. +/* A class used to manage a group of attributes. + It is only used internally, both by the ELEMENT and the DECLARATION. + + The set can be changed transparent to the Element and Declaration + classes that use it, but NOT transparent to the Attribute + which has to implement a next() and previous() method. Which makes + it a bit problematic and prevents the use of STL. + + This version is implemented with circular lists because: + - I like circular lists + - it demonstrates some independence from the (typical) doubly linked list. */ class TiXmlAttributeSet { public: - TiXmlAttributeSet(); - ~TiXmlAttributeSet(); + TiXmlAttributeSet(); + ~TiXmlAttributeSet(); - void Add( TiXmlAttribute* attribute ); - void Remove( TiXmlAttribute* attribute ); + void Add( TiXmlAttribute* attribute ); + void Remove( TiXmlAttribute* attribute ); - TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } - TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } - TiXmlAttribute* Find( const char * name ) const; + TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } + TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } + TiXmlAttribute* Find( const char * name ) const; private: - TiXmlAttribute sentinel; + TiXmlAttribute sentinel; }; /** The element is a container class. It has a value, the element name, - and can contain other elements, text, comments, and unknowns. - Elements also contain an arbitrary number of attributes. + and can contain other elements, text, comments, and unknowns. + Elements also contain an arbitrary number of attributes. */ class TiXmlElement : public TiXmlNode { public: - /// Construct an element. - TiXmlElement (const char * in_value); + /// Construct an element. + TiXmlElement (const char * in_value); - #ifdef TIXML_USE_STL - /// std::string constructor. - TiXmlElement( const std::string& _value ) : TiXmlNode( TiXmlNode::ELEMENT ) - { - firstChild = lastChild = 0; - value = _value; - } - #endif - - virtual ~TiXmlElement(); - - /** Given an attribute name, attribute returns the value - for the attribute of that name, or null if none exists. - */ - const char* Attribute( const char* name ) const; - - /** Given an attribute name, attribute returns the value - for the attribute of that name, or null if none exists. - If the attribute exists and can be converted to an integer, - the integer value will be put in the return 'i', if 'i' - is non-null. - */ - const char* Attribute( const char* name, int* i ) const; - - /** Sets an attribute of name to a given value. The attribute - will be created if it does not exist, or changed if it does. - */ - void SetAttribute( const char* name, const char * value ); + #ifdef TIXML_USE_STL + /// std::string constructor. + TiXmlElement( const std::string& _value ) : TiXmlNode( TiXmlNode::ELEMENT ) + { + firstChild = lastChild = 0; + value = _value; + } + #endif + + virtual ~TiXmlElement(); + + /** Given an attribute name, attribute returns the value + for the attribute of that name, or null if none exists. + */ + const char* Attribute( const char* name ) const; + + /** Given an attribute name, attribute returns the value + for the attribute of that name, or null if none exists. + If the attribute exists and can be converted to an integer, + the integer value will be put in the return 'i', if 'i' + is non-null. + */ + const char* Attribute( const char* name, int* i ) const; + + /** Sets an attribute of name to a given value. The attribute + will be created if it does not exist, or changed if it does. + */ + void SetAttribute( const char* name, const char * value ); #ifdef TIXML_USE_STL - const char* Attribute( const std::string& name ) const { return Attribute( name.c_str() ); } - const char* Attribute( const std::string& name, int* i ) const { return Attribute( name.c_str(), i ); } + const char* Attribute( const std::string& name ) const { return Attribute( name.c_str() ); } + const char* Attribute( const std::string& name, int* i ) const { return Attribute( name.c_str(), i ); } - /// STL std::string form. - void SetAttribute( const std::string& name, const std::string& value ) - { - StringToBuffer n( name ); - StringToBuffer v( value ); - if ( n.buffer && v.buffer ) - SetAttribute (n.buffer, v.buffer ); - } - ///< STL std::string form. - void SetAttribute( const std::string& name, int value ) - { - StringToBuffer n( name ); - if ( n.buffer ) - SetAttribute (n.buffer, value); - } - #endif - - /** Sets an attribute of name to a given value. The attribute - will be created if it does not exist, or changed if it does. - */ - void SetAttribute( const char * name, int value ); - - /** Deletes an attribute with the given name. - */ - void RemoveAttribute( const char * name ); + /// STL std::string form. + void SetAttribute( const std::string& name, const std::string& value ) + { + StringToBuffer n( name ); + StringToBuffer v( value ); + if ( n.buffer && v.buffer ) + SetAttribute (n.buffer, v.buffer ); + } + ///< STL std::string form. + void SetAttribute( const std::string& name, int value ) + { + StringToBuffer n( name ); + if ( n.buffer ) + SetAttribute (n.buffer, value); + } + #endif + + /** Sets an attribute of name to a given value. The attribute + will be created if it does not exist, or changed if it does. + */ + void SetAttribute( const char * name, int value ); + + /** Deletes an attribute with the given name. + */ + void RemoveAttribute( const char * name ); #ifdef TIXML_USE_STL - void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); } ///< STL std::string form. - #endif + void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); } ///< STL std::string form. + #endif - TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); } ///< Access the first attribute in this element. - TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); } ///< Access the last attribute in this element. + TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); } ///< Access the first attribute in this element. + TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); } ///< Access the last attribute in this element. - // [internal use] Creates a new Element and returs it. - virtual TiXmlNode* Clone() const; - // [internal use] + // [internal use] Creates a new Element and returs it. + virtual TiXmlNode* Clone() const; + // [internal use] - virtual void Print( FILE* cfile, int depth ) const; + virtual void Print( FILE* cfile, int depth ) const; protected: - // Used to be public [internal use] - #ifdef TIXML_USE_STL - virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ); - #endif - virtual void StreamOut( TIXML_OSTREAM * out ) const; - - /* [internal use] - Attribtue parsing starts: next char past '<' - returns: next char past '>' - */ - virtual const char* Parse( const char* p ); - - /* [internal use] - Reads the "value" of the element -- another element, or text. - This should terminate with the current end tag. - */ - const char* ReadValue( const char* in ); + // Used to be public [internal use] + #ifdef TIXML_USE_STL + virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ); + #endif + virtual void StreamOut( TIXML_OSTREAM * out ) const; + + /* [internal use] + Attribtue parsing starts: next char past '<' + returns: next char past '>' + */ + virtual const char* Parse( const char* p ); + + /* [internal use] + Reads the "value" of the element -- another element, or text. + This should terminate with the current end tag. + */ + const char* ReadValue( const char* in ); private: - TiXmlAttributeSet attributeSet; + TiXmlAttributeSet attributeSet; }; -/** An XML comment. +/** An XML comment. */ class TiXmlComment : public TiXmlNode { public: - /// Constructs an empty comment. - TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {} - virtual ~TiXmlComment() {} - - // [internal use] Creates a new Element and returs it. - virtual TiXmlNode* Clone() const; - // [internal use] - virtual void Print( FILE* cfile, int depth ) const; + /// Constructs an empty comment. + TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {} + virtual ~TiXmlComment() {} + + // [internal use] Creates a new Element and returs it. + virtual TiXmlNode* Clone() const; + // [internal use] + virtual void Print( FILE* cfile, int depth ) const; protected: - // used to be public - #ifdef TIXML_USE_STL - virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ); - #endif - virtual void StreamOut( TIXML_OSTREAM * out ) const; - /* [internal use] - Attribtue parsing starts: at the ! of the !-- - returns: next char past '>' - */ - virtual const char* Parse( const char* p ); + // used to be public + #ifdef TIXML_USE_STL + virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ); + #endif + virtual void StreamOut( TIXML_OSTREAM * out ) const; + /* [internal use] + Attribtue parsing starts: at the ! of the !-- + returns: next char past '>' + */ + virtual const char* Parse( const char* p ); }; @@ -734,238 +734,238 @@ */ class TiXmlText : public TiXmlNode { - friend class TiXmlElement; + friend class TiXmlElement; public: - /// Constructor. - TiXmlText (const char * initValue) : TiXmlNode (TiXmlNode::TEXT) - { - SetValue( initValue ); - } - virtual ~TiXmlText() {} - - #ifdef TIXML_USE_STL - /// Constructor. - TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT) - { - SetValue( initValue ); - } - #endif + /// Constructor. + TiXmlText (const char * initValue) : TiXmlNode (TiXmlNode::TEXT) + { + SetValue( initValue ); + } + virtual ~TiXmlText() {} + + #ifdef TIXML_USE_STL + /// Constructor. + TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT) + { + SetValue( initValue ); + } + #endif protected : - // [internal use] Creates a new Element and returns it. - virtual TiXmlNode* Clone() const; - // [internal use] - virtual void Print( FILE* cfile, int depth ) const; - virtual void StreamOut ( TIXML_OSTREAM * out ) const; - // [internal use] - bool Blank() const; // returns true if all white space and new lines - /* [internal use] - Attribtue parsing starts: First char of the text - returns: next char past '>' - */ - virtual const char* Parse( const char* p ); - // [internal use] - #ifdef TIXML_USE_STL - virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ); - #endif + // [internal use] Creates a new Element and returns it. + virtual TiXmlNode* Clone() const; + // [internal use] + virtual void Print( FILE* cfile, int depth ) const; + virtual void StreamOut ( TIXML_OSTREAM * out ) const; + // [internal use] + bool Blank() const; // returns true if all white space and new lines + /* [internal use] + Attribtue parsing starts: First char of the text + returns: next char past '>' + */ + virtual const char* Parse( const char* p ); + // [internal use] + #ifdef TIXML_USE_STL + virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ); + #endif }; /** In correct XML the declaration is the first entry in the file. - @verbatim - - @endverbatim - - TinyXml will happily read or write files without a declaration, - however. There are 3 possible attributes to the declaration: - version, encoding, and standalone. - - Note: In this version of the code, the attributes are - handled as special cases, not generic attributes, simply - because there can only be at most 3 and they are always the same. + @verbatim + + @endverbatim + + TinyXml will happily read or write files without a declaration, + however. There are 3 possible attributes to the declaration: + version, encoding, and standalone. + + Note: In this version of the code, the attributes are + handled as special cases, not generic attributes, simply + because there can only be at most 3 and they are always the same. */ class TiXmlDeclaration : public TiXmlNode { public: - /// Construct an empty declaration. - TiXmlDeclaration() : TiXmlNode( TiXmlNode::DECLARATION ) {} + /// Construct an empty declaration. + TiXmlDeclaration() : TiXmlNode( TiXmlNode::DECLARATION ) {} #ifdef TIXML_USE_STL - /// Constructor. - TiXmlDeclaration( - const std::string& _version, - const std::string& _encoding, - const std::string& _standalone ) - : TiXmlNode( TiXmlNode::DECLARATION ) - { - version = _version; - encoding = _encoding; - standalone = _standalone; - } + /// Constructor. + TiXmlDeclaration( + const std::string& _version, + const std::string& _encoding, + const std::string& _standalone ) + : TiXmlNode( TiXmlNode::DECLARATION ) + { + version = _version; + encoding = _encoding; + standalone = _standalone; + } #endif - /// Construct. - TiXmlDeclaration( const char * _version, - const char * _encoding, - const char * _standalone ); - - virtual ~TiXmlDeclaration() {} - - /// Version. Will return empty if none was found. - const char * Version() const { return version.c_str (); } - /// Encoding. Will return empty if none was found. - const char * Encoding() const { return encoding.c_str (); } - /// Is this a standalone document? - const char * Standalone() const { return standalone.c_str (); } - - // [internal use] Creates a new Element and returs it. - virtual TiXmlNode* Clone() const; - // [internal use] - virtual void Print( FILE* cfile, int depth ) const; + /// Construct. + TiXmlDeclaration( const char * _version, + const char * _encoding, + const char * _standalone ); + + virtual ~TiXmlDeclaration() {} + + /// Version. Will return empty if none was found. + const char * Version() const { return version.c_str (); } + /// Encoding. Will return empty if none was found. + const char * Encoding() const { return encoding.c_str (); } + /// Is this a standalone document? + const char * Standalone() const { return standalone.c_str (); } + + // [internal use] Creates a new Element and returs it. + virtual TiXmlNode* Clone() const; + // [internal use] + virtual void Print( FILE* cfile, int depth ) const; protected: - // used to be public - #ifdef TIXML_USE_STL - virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ); - #endif - virtual void StreamOut ( TIXML_OSTREAM * out) const; - // [internal use] - // Attribtue parsing starts: next char past '<' - // returns: next char past '>' + // used to be public + #ifdef TIXML_USE_STL + virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ); + #endif + virtual void StreamOut ( TIXML_OSTREAM * out) const; + // [internal use] + // Attribtue parsing starts: next char past '<' + // returns: next char past '>' - virtual const char* Parse( const char* p ); + virtual const char* Parse( const char* p ); private: - TIXML_STRING version; - TIXML_STRING encoding; - TIXML_STRING standalone; + TIXML_STRING version; + TIXML_STRING encoding; + TIXML_STRING standalone; }; /** Any tag that tinyXml doesn't recognize is save as an - unknown. It is a tag of text, but should not be modified. - It will be written back to the XML, unchanged, when the file - is saved. + unknown. It is a tag of text, but should not be modified. + It will be written back to the XML, unchanged, when the file + is saved. */ class TiXmlUnknown : public TiXmlNode { public: - TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN ) {} - virtual ~TiXmlUnknown() {} + TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN ) {} + virtual ~TiXmlUnknown() {} - // [internal use] - virtual TiXmlNode* Clone() const; - // [internal use] - virtual void Print( FILE* cfile, int depth ) const; + // [internal use] + virtual TiXmlNode* Clone() const; + // [internal use] + virtual void Print( FILE* cfile, int depth ) const; protected: - // used to be public - #ifdef TIXML_USE_STL - virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ); - #endif - virtual void StreamOut ( TIXML_OSTREAM * out ) const; - /* [internal use] - Attribute parsing starts: First char of the text - returns: next char past '>' - */ - virtual const char* Parse( const char* p ); + // used to be public + #ifdef TIXML_USE_STL + virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ); + #endif + virtual void StreamOut ( TIXML_OSTREAM * out ) const; + /* [internal use] + Attribute parsing starts: First char of the text + returns: next char past '>' + */ + virtual const char* Parse( const char* p ); }; /** Always the top level node. A document binds together all the - XML pieces. It can be saved, loaded, and printed to the screen. - The 'value' of a document node is the xml file name. + XML pieces. It can be saved, loaded, and printed to the screen. + The 'value' of a document node is the xml file name. */ class TiXmlDocument : public TiXmlNode { public: - /// Create an empty document, that has no name. - TiXmlDocument(); - /// Create a document with a name. The name of the document is also the filename of the xml. - TiXmlDocument( const char * documentName ); - - #ifdef TIXML_USE_STL - /// Constructor. - TiXmlDocument( const std::string& documentName ) : - TiXmlNode( TiXmlNode::DOCUMENT ) - { + /// Create an empty document, that has no name. + TiXmlDocument(); + /// Create a document with a name. The name of the document is also the filename of the xml. + TiXmlDocument( const char * documentName ); + + #ifdef TIXML_USE_STL + /// Constructor. + TiXmlDocument( const std::string& documentName ) : + TiXmlNode( TiXmlNode::DOCUMENT ) + { value = documentName; - error = false; - } - #endif - - virtual ~TiXmlDocument() {} - - /** Load a file using the current document value. - Returns true if successful. Will delete any existing - document data before loading. - */ - bool LoadFile(); - /// Save a file using the current document value. Returns true if successful. - bool SaveFile() const; - /// Load a file using the given filename. Returns true if successful. - bool LoadFile( const char * filename ); - /// Save a file using the given filename. Returns true if successful. - bool SaveFile( const char * filename ) const; - - #ifdef TIXML_USE_STL - bool LoadFile( const std::string& filename ) ///< STL std::string version. - { - StringToBuffer f( filename ); - return ( f.buffer && LoadFile( f.buffer )); - } - bool SaveFile( const std::string& filename ) const ///< STL std::string version. - { - StringToBuffer f( filename ); - return ( f.buffer && SaveFile( f.buffer )); - } - #endif - - /// Parse the given null terminated block of xml data. - virtual const char* Parse( const char* p ); - - /** Get the root element -- the only top level element -- of the document. - In well formed XML, there should only be one. TinyXml is tolerant of - multiple elements at the document level. - */ - TiXmlElement* RootElement() const { return FirstChildElement(); } - - /// If, during parsing, a error occurs, Error will be set to true. - bool Error() const { return error; } - - /// Contains a textual (english) description of the error if one occurs. - const char * ErrorDesc() const { return errorDesc.c_str (); } - - /** Generally, you probably want the error string ( ErrorDesc() ). But if you - prefer the ErrorId, this function will fetch it. - */ - const int ErrorId() const { return errorId; } - - /// If you have handled the error, it can be reset with this call. - void ClearError() { error = false; errorId = 0; errorDesc = ""; } - - /** Dump the document to standard out. */ - void Print() const { Print( stdout, 0 ); } - - // [internal use] - virtual void Print( FILE* cfile, int depth = 0 ) const; - // [internal use] - void SetError( int err ) { assert( err > 0 && err < TIXML_ERROR_STRING_COUNT ); - error = true; - errorId = err; - errorDesc = errorString[ errorId ]; } + error = false; + } + #endif + + virtual ~TiXmlDocument() {} + + /** Load a file using the current document value. + Returns true if successful. Will delete any existing + document data before loading. + */ + bool LoadFile(); + /// Save a file using the current document value. Returns true if successful. + bool SaveFile() const; + /// Load a file using the given filename. Returns true if successful. + bool LoadFile( const char * filename ); + /// Save a file using the given filename. Returns true if successful. + bool SaveFile( const char * filename ) const; + + #ifdef TIXML_USE_STL + bool LoadFile( const std::string& filename ) ///< STL std::string version. + { + StringToBuffer f( filename ); + return ( f.buffer && LoadFile( f.buffer )); + } + bool SaveFile( const std::string& filename ) const ///< STL std::string version. + { + StringToBuffer f( filename ); + return ( f.buffer && SaveFile( f.buffer )); + } + #endif + + /// Parse the given null terminated block of xml data. + virtual const char* Parse( const char* p ); + + /** Get the root element -- the only top level element -- of the document. + In well formed XML, there should only be one. TinyXml is tolerant of + multiple elements at the document level. + */ + TiXmlElement* RootElement() const { return FirstChildElement(); } + + /// If, during parsing, a error occurs, Error will be set to true. + bool Error() const { return error; } + + /// Contains a textual (english) description of the error if one occurs. + const char * ErrorDesc() const { return errorDesc.c_str (); } + + /** Generally, you probably want the error string ( ErrorDesc() ). But if you + prefer the ErrorId, this function will fetch it. + */ + const int ErrorId() const { return errorId; } + + /// If you have handled the error, it can be reset with this call. + void ClearError() { error = false; errorId = 0; errorDesc = ""; } + + /** Dump the document to standard out. */ + void Print() const { Print( stdout, 0 ); } + + // [internal use] + virtual void Print( FILE* cfile, int depth = 0 ) const; + // [internal use] + void SetError( int err ) { assert( err > 0 && err < TIXML_ERROR_STRING_COUNT ); + error = true; + errorId = err; + errorDesc = errorString[ errorId ]; } protected : - virtual void StreamOut ( TIXML_OSTREAM * out) const; - // [internal use] - virtual TiXmlNode* Clone() const; - #ifdef TIXML_USE_STL - virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ); - #endif + virtual void StreamOut ( TIXML_OSTREAM * out) const; + // [internal use] + virtual TiXmlNode* Clone() const; + #ifdef TIXML_USE_STL + virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ); + #endif private: - bool error; - int errorId; - TIXML_STRING errorDesc; + bool error; + int errorId; + TIXML_STRING errorDesc; }; #endif diff -Nru trigger-rally-0.5.2.1/src/pengine/tinyxmlparser.cpp trigger-rally-0.6.0/src/pengine/tinyxmlparser.cpp --- trigger-rally-0.5.2.1/src/pengine/tinyxmlparser.cpp 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/pengine/tinyxmlparser.cpp 2011-10-07 17:10:01.000000000 +0000 @@ -29,911 +29,911 @@ // Note tha "PutString" hardcodes the same list. This // is less flexible than it appears. Changing the entries -// or order will break putstring. +// or order will break putstring. TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] = { - { "&", 5, '&' }, - { "<", 4, '<' }, - { ">", 4, '>' }, - { """, 6, '\"' }, - { "'", 6, '\'' } + { "&", 5, '&' }, + { "<", 4, '<' }, + { ">", 4, '>' }, + { """, 6, '\"' }, + { "'", 6, '\'' } }; const char* TiXmlBase::SkipWhiteSpace( const char* p ) { - if ( !p || !*p ) - { - return 0; - } - while ( p && *p ) - { - if ( isspace( *p ) || *p == '\n' || *p =='\r' ) // Still using old rules for white space. - ++p; - else - break; - } + if ( !p || !*p ) + { + return 0; + } + while ( p && *p ) + { + if ( isspace( *p ) || *p == '\n' || *p =='\r' ) // Still using old rules for white space. + ++p; + else + break; + } - return p; + return p; } #ifdef TIXML_USE_STL /*static*/ bool TiXmlBase::StreamWhiteSpace( TIXML_ISTREAM * in, TIXML_STRING * tag ) { - for( ;; ) - { - if ( !in->good() ) return false; - - int c = in->peek(); - if ( !IsWhiteSpace( c ) ) - return true; - *tag += in->get(); - } + for( ;; ) + { + if ( !in->good() ) return false; + + int c = in->peek(); + if ( !IsWhiteSpace( c ) ) + return true; + *tag += in->get(); + } } /*static*/ bool TiXmlBase::StreamTo( TIXML_ISTREAM * in, int character, TIXML_STRING * tag ) { - while ( in->good() ) - { - int c = in->peek(); - if ( c == character ) - return true; - - in->get(); - *tag += c; - } - return false; + while ( in->good() ) + { + int c = in->peek(); + if ( c == character ) + return true; + + in->get(); + *tag += c; + } + return false; } #endif const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name ) { - *name = ""; - assert( p ); + *name = ""; + assert( p ); - // Names start with letters or underscores. - // After that, they can be letters, underscores, numbers, - // hyphens, or colons. (Colons are valid ony for namespaces, - // but tinyxml can't tell namespaces from names.) - if ( p && *p - && ( isalpha( (unsigned char) *p ) || *p == '_' ) ) - { - while( p && *p - && ( isalnum( (unsigned char ) *p ) - || *p == '_' - || *p == '-' - || *p == ':' ) ) - { - (*name) += *p; - ++p; - } - return p; - } - return 0; + // Names start with letters or underscores. + // After that, they can be letters, underscores, numbers, + // hyphens, or colons. (Colons are valid ony for namespaces, + // but tinyxml can't tell namespaces from names.) + if ( p && *p + && ( isalpha( (unsigned char) *p ) || *p == '_' ) ) + { + while( p && *p + && ( isalnum( (unsigned char ) *p ) + || *p == '_' + || *p == '-' + || *p == ':' ) ) + { + (*name) += *p; + ++p; + } + return p; + } + return 0; } const char* TiXmlBase::GetEntity( const char* p, char* value ) { - // Presume an entity, and pull it out. + // Presume an entity, and pull it out. TIXML_STRING ent; - int i; + int i; - // Ignore the &#x entities. - if ( strncmp( "&#x", p, 3 ) == 0 - && *(p+3) - && *(p+4) ) - { - *value = 0; - - if ( isalpha( *(p+3) ) ) *value += ( tolower( *(p+3) ) - 'a' + 10 ) * 16; - else *value += ( *(p+3) - '0' ) * 16; - - if ( isalpha( *(p+4) ) ) *value += ( tolower( *(p+4) ) - 'a' + 10 ); - else *value += ( *(p+4) - '0' ); - - return p+6; - } - - // Now try to match it. - for( i=0; i" so the - // sub-tag can orient itself. - - if ( !StreamTo( in, '<', tag ) ) - { - SetError( TIXML_ERROR_PARSING_EMPTY ); - return; - } - - while ( in->good() ) - { - int tagIndex = tag->length(); - while ( in->good() && in->peek() != '>' ) - { - int c = in->get(); - (*tag) += (char) c; - } - - if ( in->good() ) - { - // We now have something we presume to be a node of - // some sort. Identify it, and call the node to - // continue streaming. - TiXmlNode* node = Identify( tag->c_str() + tagIndex ); - - if ( node ) - { - node->StreamIn( in, tag ); - bool isElement = node->ToElement() != 0; - delete node; - node = 0; - - // If this is the root element, we're done. Parsing will be - // done by the >> operator. - if ( isElement ) - { - return; - } - } - else - { - SetError( TIXML_ERROR ); - return; - } - } - } - // We should have returned sooner. - SetError( TIXML_ERROR ); + // The basic issue with a document is that we don't know what we're + // streaming. Read something presumed to be a tag (and hope), then + // identify it, and call the appropriate stream method on the tag. + // + // This "pre-streaming" will never read the closing ">" so the + // sub-tag can orient itself. + + if ( !StreamTo( in, '<', tag ) ) + { + SetError( TIXML_ERROR_PARSING_EMPTY ); + return; + } + + while ( in->good() ) + { + int tagIndex = tag->length(); + while ( in->good() && in->peek() != '>' ) + { + int c = in->get(); + (*tag) += (char) c; + } + + if ( in->good() ) + { + // We now have something we presume to be a node of + // some sort. Identify it, and call the node to + // continue streaming. + TiXmlNode* node = Identify( tag->c_str() + tagIndex ); + + if ( node ) + { + node->StreamIn( in, tag ); + bool isElement = node->ToElement() != 0; + delete node; + node = 0; + + // If this is the root element, we're done. Parsing will be + // done by the >> operator. + if ( isElement ) + { + return; + } + } + else + { + SetError( TIXML_ERROR ); + return; + } + } + } + // We should have returned sooner. + SetError( TIXML_ERROR ); } #endif const char* TiXmlDocument::Parse( const char* p ) { - // Parse away, at the document level. Since a document - // contains nothing but other tags, most of what happens - // here is skipping white space. - // - // In this variant (as opposed to stream and Parse) we - // read everything we can. + // Parse away, at the document level. Since a document + // contains nothing but other tags, most of what happens + // here is skipping white space. + // + // In this variant (as opposed to stream and Parse) we + // read everything we can. - if ( !p || !*p ) - { - SetError( TIXML_ERROR_DOCUMENT_EMPTY ); - return false; - } + if ( !p || !*p ) + { + SetError( TIXML_ERROR_DOCUMENT_EMPTY ); + return false; + } p = SkipWhiteSpace( p ); - if ( !p ) - { - SetError( TIXML_ERROR_DOCUMENT_EMPTY ); - return false; - } - - while ( p && *p ) - { - TiXmlNode* node = Identify( p ); - if ( node ) - { - p = node->Parse( p ); - LinkEndChild( node ); - } - else - { - break; - } - p = SkipWhiteSpace( p ); - } - // All is well. - return p; + if ( !p ) + { + SetError( TIXML_ERROR_DOCUMENT_EMPTY ); + return false; + } + + while ( p && *p ) + { + TiXmlNode* node = Identify( p ); + if ( node ) + { + p = node->Parse( p ); + LinkEndChild( node ); + } + else + { + break; + } + p = SkipWhiteSpace( p ); + } + // All is well. + return p; } TiXmlNode* TiXmlNode::Identify( const char* p ) { - TiXmlNode* returnNode = 0; + TiXmlNode* returnNode = 0; - p = SkipWhiteSpace( p ); - if( !p || !*p || *p != '<' ) - { - return 0; - } - - TiXmlDocument* doc = GetDocument(); - p = SkipWhiteSpace( p ); - - if ( !p || !*p ) - { - return 0; - } - - // What is this thing? - // - Elements start with a letter or underscore, but xml is reserved. - // - Comments: "; - - if ( !StringEqual( p, startTag, false ) ) - { - document->SetError( TIXML_ERROR_PARSING_COMMENT ); - return 0; - } - p += strlen( startTag ); - p = ReadText( p, &value, false, endTag, false ); - return p; + p = SkipWhiteSpace( p ); + const char* startTag = ""; + + if ( !StringEqual( p, startTag, false ) ) + { + document->SetError( TIXML_ERROR_PARSING_COMMENT ); + return 0; + } + p += strlen( startTag ); + p = ReadText( p, &value, false, endTag, false ); + return p; } const char* TiXmlAttribute::Parse( const char* p ) { - p = SkipWhiteSpace( p ); - if ( !p || !*p ) return 0; + p = SkipWhiteSpace( p ); + if ( !p || !*p ) return 0; - // Read the name, the '=' and the value. - p = ReadName( p, &name ); - if ( !p || !*p ) - { - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES ); - return 0; - } - p = SkipWhiteSpace( p ); - if ( !p || !*p || *p != '=' ) - { - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES ); - return 0; - } - - ++p; // skip '=' - p = SkipWhiteSpace( p ); - if ( !p || !*p ) - { - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES ); - return 0; - } - - const char* end; - - if ( *p == '\'' ) - { - ++p; - end = "\'"; - p = ReadText( p, &value, false, end, false ); - } - else if ( *p == '"' ) - { - ++p; - end = "\""; - p = ReadText( p, &value, false, end, false ); - } - else - { - // All attribute values should be in single or double quotes. - // But this is such a common error that the parser will try - // its best, even without them. - value = ""; - while ( p && *p // existence - && !isspace( *p ) && *p != '\n' && *p != '\r' // whitespace - && *p != '/' && *p != '>' ) // tag end - { - value += *p; - ++p; - } - } - return p; + // Read the name, the '=' and the value. + p = ReadName( p, &name ); + if ( !p || !*p ) + { + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES ); + return 0; + } + p = SkipWhiteSpace( p ); + if ( !p || !*p || *p != '=' ) + { + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES ); + return 0; + } + + ++p; // skip '=' + p = SkipWhiteSpace( p ); + if ( !p || !*p ) + { + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES ); + return 0; + } + + const char* end; + + if ( *p == '\'' ) + { + ++p; + end = "\'"; + p = ReadText( p, &value, false, end, false ); + } + else if ( *p == '"' ) + { + ++p; + end = "\""; + p = ReadText( p, &value, false, end, false ); + } + else + { + // All attribute values should be in single or double quotes. + // But this is such a common error that the parser will try + // its best, even without them. + value = ""; + while ( p && *p // existence + && !isspace( *p ) && *p != '\n' && *p != '\r' // whitespace + && *p != '/' && *p != '>' ) // tag end + { + value += *p; + ++p; + } + } + return p; } #ifdef TIXML_USE_STL void TiXmlText::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ) { - while ( in->good() ) - { - int c = in->peek(); - if ( c == '<' ) - return; - - (*tag) += c; - in->get(); - } + while ( in->good() ) + { + int c = in->peek(); + if ( c == '<' ) + return; + + (*tag) += c; + in->get(); + } } #endif const char* TiXmlText::Parse( const char* p ) { - value = ""; + value = ""; - //TiXmlDocument* doc = GetDocument(); - bool ignoreWhite = true; -// if ( doc && !doc->IgnoreWhiteSpace() ) ignoreWhite = false; - - const char* end = "<"; - p = ReadText( p, &value, ignoreWhite, end, false ); - if ( p ) - return p-1; // don't truncate the '<' - return 0; + //TiXmlDocument* doc = GetDocument(); + bool ignoreWhite = true; +// if ( doc && !doc->IgnoreWhiteSpace() ) ignoreWhite = false; + + const char* end = "<"; + p = ReadText( p, &value, ignoreWhite, end, false ); + if ( p ) + return p-1; // don't truncate the '<' + return 0; } #ifdef TIXML_USE_STL void TiXmlDeclaration::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ) { - while ( in->good() ) - { - int c = in->get(); - (*tag) += c; - - if ( c == '>' ) - { - // All is well. - return; - } - } + while ( in->good() ) + { + int c = in->get(); + (*tag) += c; + + if ( c == '>' ) + { + // All is well. + return; + } + } } #endif const char* TiXmlDeclaration::Parse( const char* p ) { - p = SkipWhiteSpace( p ); - // Find the beginning, find the end, and look for - // the stuff in-between. - TiXmlDocument* document = GetDocument(); - if ( !p || !*p || !StringEqual( p, "SetError( TIXML_ERROR_PARSING_DECLARATION ); - return 0; - } - - p += 5; -// const char* start = p+5; -// const char* end = strstr( start, "?>" ); - - version = ""; - encoding = ""; - standalone = ""; - - while ( p && *p ) - { - if ( *p == '>' ) - { - ++p; - return p; - } - - p = SkipWhiteSpace( p ); - if ( StringEqual( p, "version", true ) ) - { -// p += 7; - TiXmlAttribute attrib; - p = attrib.Parse( p ); - version = attrib.Value(); - } - else if ( StringEqual( p, "encoding", true ) ) - { -// p += 8; - TiXmlAttribute attrib; - p = attrib.Parse( p ); - encoding = attrib.Value(); - } - else if ( StringEqual( p, "standalone", true ) ) - { -// p += 10; - TiXmlAttribute attrib; - p = attrib.Parse( p ); - standalone = attrib.Value(); - } - else - { - // Read over whatever it is. - while( p && *p && *p != '>' && !isspace( *p ) ) - ++p; - } - } - return 0; + p = SkipWhiteSpace( p ); + // Find the beginning, find the end, and look for + // the stuff in-between. + TiXmlDocument* document = GetDocument(); + if ( !p || !*p || !StringEqual( p, "SetError( TIXML_ERROR_PARSING_DECLARATION ); + return 0; + } + + p += 5; +// const char* start = p+5; +// const char* end = strstr( start, "?>" ); + + version = ""; + encoding = ""; + standalone = ""; + + while ( p && *p ) + { + if ( *p == '>' ) + { + ++p; + return p; + } + + p = SkipWhiteSpace( p ); + if ( StringEqual( p, "version", true ) ) + { +// p += 7; + TiXmlAttribute attrib; + p = attrib.Parse( p ); + version = attrib.Value(); + } + else if ( StringEqual( p, "encoding", true ) ) + { +// p += 8; + TiXmlAttribute attrib; + p = attrib.Parse( p ); + encoding = attrib.Value(); + } + else if ( StringEqual( p, "standalone", true ) ) + { +// p += 10; + TiXmlAttribute attrib; + p = attrib.Parse( p ); + standalone = attrib.Value(); + } + else + { + // Read over whatever it is. + while( p && *p && *p != '>' && !isspace( *p ) ) + ++p; + } + } + return 0; } bool TiXmlText::Blank() const { - for ( unsigned i=0; i element, possibly invalid file type" << std::endl; - PUtil::outLog() << "TinyXML: " << doc.ErrorDesc() << std::endl; - return null; - } - - TiXmlElement *rootelem = rootnode->ToElement(); - if (!rootelem) { - PUtil::outLog() << "Load failed: TinyXML error" << std::endl; - PUtil::outLog() << "TinyXML: " << doc.ErrorDesc() << std::endl; - return null; - } - - return rootelem; -} - - -bool PUtil::copyFile(const std::string &fileFrom, const std::string &fileTo) -{ - PUtil::outLog() << "Copying \"" << fileFrom << "\" to \"" << fileTo << "\"" << std::endl; - - // PhysFS doesn't implement copy, so do it the hard way - - PHYSFS_file *pfile_from, *pfile_to; - - // Open source file - - pfile_from = PHYSFS_openRead(fileFrom.c_str()); - - if (!pfile_from) { - PUtil::outLog() << "Copy failed: PhysFS: " << PHYSFS_getLastError() << std::endl; - return false; - } - - // Make dest directory - - std::string filepath = extractPathFromFilename(fileTo); - - if (!PHYSFS_mkdir(filepath.c_str())) { - const char *errstr = PHYSFS_getLastError(); - if (strcmp(errstr, "File exists")) { - PUtil::outLog() << "Couldn't mkdir \"" << filepath << "\", attempting copy anyway" << std::endl; - PUtil::outLog() << "PhysFS: " << errstr << std::endl; - } - } - - // Open dest file - - pfile_to = PHYSFS_openWrite(fileTo.c_str()); - - if (!pfile_to) { - PHYSFS_close(pfile_from); - PUtil::outLog() << "Copy failed: PhysFS: " << PHYSFS_getLastError() << std::endl; - return false; - } - - // Copy over the data in chunks - - const int blocksize = 4096; - char block[blocksize]; - - int readcount; - do { - - readcount = PHYSFS_read(pfile_from, block, 1, blocksize); - - PHYSFS_write(pfile_to, block, 1, readcount); - - } while (readcount == blocksize); - - // Close up shop - - PHYSFS_close(pfile_from); - PHYSFS_close(pfile_to); - - return true; -} - -std::list PUtil::findFiles(const std::string &basedir, const std::string &extension) -{ - std::list results; - - char **filelist = PHYSFS_enumerateFiles(basedir.c_str()); - - for (char **i = filelist; *i; i++) { - - std::string thisfile = basedir + '/' + *i; - - if (PHYSFS_isDirectory(thisfile.c_str())) { - - // Recurse into subdirectory - std::list moreresults = findFiles(thisfile, extension); - results.insert(results.end(), moreresults.begin(), moreresults.end()); - - } else { - - // Check to see if file has correct extension - if (thisfile.length() >= extension.length() && - thisfile.substr(thisfile.length() - extension.length()) == extension) - results.push_back(thisfile); - } - } - - PHYSFS_freeList(filelist); - - return results; -} - -std::string PUtil::formatInt(int value, int width) -{ - std::string text(width, '0'); - - for (std::string::reverse_iterator c = text.rbegin(); c != text.rend(); c++) { - - *c = '0' + (value % 10); - - value /= 10; - } - - return text; -} - -std::string PUtil::formatInt(int value) -{ - std::string text; - - bool neg = false; - - if (value < 0) { neg = true; value = -value; } - else if (value == 0) return std::string ("0"); - - for ( ; value; value /= 10) - text = ((char)('0' + (value % 10))) + text; - - return (neg) ? ('-' + text) : (text); -} - -std::string PUtil::formatTime(float seconds) -{ - int time_mins = (int)(seconds / 60.0f); - seconds -= time_mins * 60; - int time_secs = (int)(seconds); - seconds -= time_secs; - int time_centis = (int)(seconds * 100.0f); - - return - formatInt(time_mins, 2) + ':' + - formatInt(time_secs, 2) + '.' + - formatInt(time_centis, 2); -} - - -// These are implemented over in physfs_rw.cpp - -int physfs_seek(SDL_RWops *context, int offset, int whence); -int physfs_read(SDL_RWops *context, void *ptr, int size, int maxnum); -int physfs_write(SDL_RWops *context, const void *ptr, int size, int num); -int physfs_close(SDL_RWops *context); - -SDL_RWops *PUtil::allocPhysFSops(PHYSFS_file *pfile) -{ - SDL_RWops *rwops = SDL_AllocRW(); - - rwops->seek = physfs_seek; - rwops->read = physfs_read; - rwops->write = physfs_write; - rwops->close = physfs_close; - rwops->hidden.unknown.data1 = (void *) pfile; - - return rwops; -} - + +// util.cpp [pengine] + +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net +// License: GPL version 2 (see included gpl.txt) + + +#include "pengine.h" + + + +std::string PUtil::extractPathFromFilename(const std::string &filename) +{ + std::string::size_type found = filename.find_last_of('/'); + + if (found == std::string::npos) return std::string(""); + + return filename.substr(0, found + 1); +} + +std::string PUtil::assemblePath(const std::string &relativefile, const std::string &parentfile) +{ + // This function is required because PhysFS doesn't allow ".."s in path names + + std::string totalpath; + + if (relativefile[0] == '/') { + // relativefile is an absolute path + totalpath = relativefile.substr(1); + } else { + // relativefile is indeed relative, so concat with parent path + totalpath = extractPathFromFilename(parentfile) + relativefile; + } + + std::string totalpath_hold = totalpath; + + std::string::size_type found; + + while (true) { + + // attempt to find a ".." to crunch back + + found = totalpath.find("../"); + + if (found == std::string::npos) break; // no more ".."s + + if (found < 2) { + // ".." is too close to start of path + PUtil::outLog() << "Error: above local root: \"" << totalpath_hold << "\"" << std::endl; + return std::string(); + } + + std::string::size_type crunch = totalpath.substr(0, found-1).find_last_of('/'); + + if (crunch == std::string::npos) { + // Crunch back to root (special case) + crunch = 0; + found += 1; + } + + // remove the "/dir/.." chunk + + totalpath.erase(crunch, found + 2 - crunch); + } + + return totalpath; +} + + +TiXmlElement *PUtil::loadRootElement(TiXmlDocument &doc, const char *rootName) +{ + // Old direct file code + /* + if (!doc.LoadFile()) { + PUtil::outLog() << "Load failed: TinyXML couldn't load file, possibly file not found or invalid XML" << std::endl; + PUtil::outLog() << "TinyXML: " << xmlfile.ErrorDesc() << std::endl; + return null; + } + */ + + // New PhysFS handler + + PHYSFS_file *pfile = PHYSFS_openRead(doc.Value()); + if (pfile == null) { + PUtil::outLog() << "Load failed: PhysFS: " << PHYSFS_getLastError() << std::endl; + return null; + } + + int filesize = PHYSFS_fileLength(pfile); + + char *xmlbuffer = new char[filesize + 1]; + + PHYSFS_read(pfile, xmlbuffer, filesize, 1); + PHYSFS_close(pfile); + + xmlbuffer[filesize] = '\0'; + + doc.Parse(xmlbuffer); + + delete [] xmlbuffer; + + TiXmlNode *rootnode; + rootnode = doc.FirstChild(rootName); + if (!rootnode) { + PUtil::outLog() << "Couldn't process <" << rootName << "> element, possibly invalid file type" << std::endl; + PUtil::outLog() << "TinyXML: " << doc.ErrorDesc() << std::endl; + return null; + } + + TiXmlElement *rootelem = rootnode->ToElement(); + if (!rootelem) { + PUtil::outLog() << "Load failed: TinyXML error" << std::endl; + PUtil::outLog() << "TinyXML: " << doc.ErrorDesc() << std::endl; + return null; + } + + return rootelem; +} + + +bool PUtil::copyFile(const std::string &fileFrom, const std::string &fileTo) +{ + PUtil::outLog() << "Copying \"" << fileFrom << "\" to \"" << fileTo << "\"" << std::endl; + + // PhysFS doesn't implement copy, so do it the hard way + + PHYSFS_file *pfile_from, *pfile_to; + + // Open source file + + pfile_from = PHYSFS_openRead(fileFrom.c_str()); + + if (!pfile_from) { + PUtil::outLog() << "Copy failed: PhysFS: " << PHYSFS_getLastError() << std::endl; + return false; + } + + // Make dest directory + + std::string filepath = extractPathFromFilename(fileTo); + + if (!PHYSFS_mkdir(filepath.c_str())) { + const char *errstr = PHYSFS_getLastError(); + if (strcmp(errstr, "File exists")) { + PUtil::outLog() << "Couldn't mkdir \"" << filepath << "\", attempting copy anyway" << std::endl; + PUtil::outLog() << "PhysFS: " << errstr << std::endl; + } + } + + // Open dest file + + pfile_to = PHYSFS_openWrite(fileTo.c_str()); + + if (!pfile_to) { + PHYSFS_close(pfile_from); + PUtil::outLog() << "Copy failed: PhysFS: " << PHYSFS_getLastError() << std::endl; + return false; + } + + // Copy over the data in chunks + + const int blocksize = 4096; + char block[blocksize]; + + int readcount; + do { + + readcount = PHYSFS_read(pfile_from, block, 1, blocksize); + + PHYSFS_write(pfile_to, block, 1, readcount); + + } while (readcount == blocksize); + + // Close up shop + + PHYSFS_close(pfile_from); + PHYSFS_close(pfile_to); + + return true; +} + +std::list PUtil::findFiles(const std::string &basedir, const std::string &extension) +{ + std::list results; + + char **filelist = PHYSFS_enumerateFiles(basedir.c_str()); + + for (char **i = filelist; *i; i++) { + + std::string thisfile = basedir + '/' + *i; + + if (PHYSFS_isDirectory(thisfile.c_str())) { + + // Recurse into subdirectory + std::list moreresults = findFiles(thisfile, extension); + results.insert(results.end(), moreresults.begin(), moreresults.end()); + + } else { + + // Check to see if file has correct extension + if (thisfile.length() >= extension.length() && + thisfile.substr(thisfile.length() - extension.length()) == extension) + results.push_back(thisfile); + } + } + + PHYSFS_freeList(filelist); + + return results; +} + +std::string PUtil::formatInt(int value, int width) +{ + std::string text(width, '0'); + + for (std::string::reverse_iterator c = text.rbegin(); c != text.rend(); c++) { + + *c = '0' + (value % 10); + + value /= 10; + } + + return text; +} + +std::string PUtil::formatInt(int value) +{ + std::string text; + + bool neg = false; + + if (value < 0) { neg = true; value = -value; } + else if (value == 0) return std::string ("0"); + + for ( ; value; value /= 10) + text = ((char)('0' + (value % 10))) + text; + + return (neg) ? ('-' + text) : (text); +} + +std::string PUtil::formatTime(float seconds) +{ + int time_mins = (int)(seconds / 60.0f); + seconds -= time_mins * 60; + int time_secs = (int)(seconds); + seconds -= time_secs; + int time_centis = (int)(seconds * 100.0f); + + return + formatInt(time_mins, 2) + ':' + + formatInt(time_secs, 2) + '.' + + formatInt(time_centis, 2); +} + + +// These are implemented over in physfs_rw.cpp + +int physfs_seek(SDL_RWops *context, int offset, int whence); +int physfs_read(SDL_RWops *context, void *ptr, int size, int maxnum); +int physfs_write(SDL_RWops *context, const void *ptr, int size, int num); +int physfs_close(SDL_RWops *context); + +SDL_RWops *PUtil::allocPhysFSops(PHYSFS_file *pfile) +{ + SDL_RWops *rwops = SDL_AllocRW(); + + rwops->seek = physfs_seek; + rwops->read = physfs_read; + rwops->write = physfs_write; + rwops->close = physfs_close; + rwops->hidden.unknown.data1 = (void *) pfile; + + return rwops; +} + diff -Nru trigger-rally-0.5.2.1/src/pengine/vbuffer.cpp trigger-rally-0.6.0/src/pengine/vbuffer.cpp --- trigger-rally-0.5.2.1/src/pengine/vbuffer.cpp 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/pengine/vbuffer.cpp 2011-10-07 17:10:01.000000000 +0000 @@ -1,182 +1,182 @@ - -// vbuffer.cpp [pengine] - -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net -// License: GPL version 2 (see included gpl.txt) - - -#include "pengine.h" - - -#define USE_VBO_ARB (GLEW_ARB_vertex_buffer_object) -//#define USE_VBO_ARB (false) - -// emulation of GL buffer binding functionality -//PVBuffer *PVBuffer::bound = null; -//PVBuffer *PVBuffer::boundelem = null; - - -PVBuffer::~PVBuffer() -{ - unload(); -} - - -void PVBuffer::unload() -{ - if (USE_VBO_ARB) { - if (buffid) glDeleteBuffersARB(1, &buffid); - buffid = 0; - } else { - if (buffer) delete[] buffer; - buffer = null; - } -} - - -bool PVBuffer::create(int buffsize, contenttype type, usagemode usage, const void *data) -{ - unload(); - - pr_type = type; - - if (USE_VBO_ARB) { - switch (type) { - default: - case VertexContent: - target = GL_ARRAY_BUFFER_ARB; - break; - case IndexContent: - target = GL_ELEMENT_ARRAY_BUFFER_ARB; - break; - } - - glGenBuffersARB(1, &buffid); - bind(); - - GLenum gl_usage; - switch (usage) { - case StreamUsage: - gl_usage = GL_STREAM_DRAW_ARB; - break; - default: - case StaticUsage: - gl_usage = GL_STATIC_DRAW_ARB; - break; - case DynamicUsage: - gl_usage = GL_DYNAMIC_DRAW_ARB; - break; - } - - glGetError(); - - //int getter; - //glGetIntegerv(GL_ARRAY_BUFFER_BINDING_ARB,&getter); - //con_printf("bufferdata with object %i bound\n",getter); - - glBufferDataARB(target, buffsize, data, gl_usage); - - unbind(); - - int err = glGetError(); - if (err != GL_NO_ERROR) { - PUtil::outLog() << buffsize << " byte buffer creation failed, "; - switch (err) { - case GL_INVALID_OPERATION: - PUtil::outLog() << "invalid operation\n"; - break; - case GL_INVALID_ENUM: - PUtil::outLog() << "invalid enum\n"; - break; - case GL_OUT_OF_MEMORY: - PUtil::outLog() << "out of memory\n"; - break; - default: - PUtil::outLog() << "GL error code " << err << "\n"; - break; - } - unload(); - buffid = 0; - return false; - } - } else { - buffer = new uint8 [buffsize]; - if (!buffer) { - PUtil::outLog() << buffsize << " byte buffer creation failed (out of memory)\n"; - return false; - } - - memcpy(buffer, data, buffsize); - - //buffersize = buffsize; - } - - return true; -} - -void PVBuffer::update(int offset, int buffsize, const void *data) -{ - if (USE_VBO_ARB) { - bind(); - glBufferSubDataARB(target, offset, buffsize, data); - unbind(); - } else { - memcpy(buffer + offset, data, buffsize); - } -} - -uint8 *PVBuffer::getPointer(int offset) -{ - if (USE_VBO_ARB) { - return ((uint8*)null + offset); - } else { - return ((uint8*)buffer + offset); - } -} - -void PVBuffer::bind() -{ - if (USE_VBO_ARB) { - glBindBufferARB(target, buffid); - } else { - // don't bind if buffer hasn't been allocated - //switch (pr_type) { - //case VertexContent: bound = buffer ? this : null; break; - //case IndexContent: boundelem = buffer ? this : null; break; - //} - } -} - -// static -void PVBuffer::unbind() -{ - if (USE_VBO_ARB) { - glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); - glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); - } else { - //bound = null; - //boundelem = null; - } -} - - -// RamFile - - -void PRamFile::write(const void *data, int datasize) -{ - int newextent = cursor + datasize; - int buffsize = buffer.size(); - if (newextent > buffsize) { - buffer.resize(newextent); - if (cursor > buffsize) - memset(&buffer[buffsize], 0, cursor-buffsize); - } - - memcpy(&buffer[cursor], data, datasize); - cursor += datasize; -} - - - - + +// vbuffer.cpp [pengine] + +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net +// License: GPL version 2 (see included gpl.txt) + + +#include "pengine.h" + + +#define USE_VBO_ARB (GLEW_ARB_vertex_buffer_object) +//#define USE_VBO_ARB (false) + +// emulation of GL buffer binding functionality +//PVBuffer *PVBuffer::bound = null; +//PVBuffer *PVBuffer::boundelem = null; + + +PVBuffer::~PVBuffer() +{ + unload(); +} + + +void PVBuffer::unload() +{ + if (USE_VBO_ARB) { + if (buffid) glDeleteBuffersARB(1, &buffid); + buffid = 0; + } else { + if (buffer) delete[] buffer; + buffer = null; + } +} + + +bool PVBuffer::create(int buffsize, contenttype type, usagemode usage, const void *data) +{ + unload(); + + pr_type = type; + + if (USE_VBO_ARB) { + switch (type) { + default: + case VertexContent: + target = GL_ARRAY_BUFFER_ARB; + break; + case IndexContent: + target = GL_ELEMENT_ARRAY_BUFFER_ARB; + break; + } + + glGenBuffersARB(1, &buffid); + bind(); + + GLenum gl_usage; + switch (usage) { + case StreamUsage: + gl_usage = GL_STREAM_DRAW_ARB; + break; + default: + case StaticUsage: + gl_usage = GL_STATIC_DRAW_ARB; + break; + case DynamicUsage: + gl_usage = GL_DYNAMIC_DRAW_ARB; + break; + } + + glGetError(); + + //int getter; + //glGetIntegerv(GL_ARRAY_BUFFER_BINDING_ARB,&getter); + //con_printf("bufferdata with object %i bound\n",getter); + + glBufferDataARB(target, buffsize, data, gl_usage); + + unbind(); + + int err = glGetError(); + if (err != GL_NO_ERROR) { + PUtil::outLog() << buffsize << " byte buffer creation failed, "; + switch (err) { + case GL_INVALID_OPERATION: + PUtil::outLog() << "invalid operation\n"; + break; + case GL_INVALID_ENUM: + PUtil::outLog() << "invalid enum\n"; + break; + case GL_OUT_OF_MEMORY: + PUtil::outLog() << "out of memory\n"; + break; + default: + PUtil::outLog() << "GL error code " << err << "\n"; + break; + } + unload(); + buffid = 0; + return false; + } + } else { + buffer = new uint8 [buffsize]; + if (!buffer) { + PUtil::outLog() << buffsize << " byte buffer creation failed (out of memory)\n"; + return false; + } + + memcpy(buffer, data, buffsize); + + //buffersize = buffsize; + } + + return true; +} + +void PVBuffer::update(int offset, int buffsize, const void *data) +{ + if (USE_VBO_ARB) { + bind(); + glBufferSubDataARB(target, offset, buffsize, data); + unbind(); + } else { + memcpy(buffer + offset, data, buffsize); + } +} + +uint8 *PVBuffer::getPointer(int offset) +{ + if (USE_VBO_ARB) { + return ((uint8*)null + offset); + } else { + return ((uint8*)buffer + offset); + } +} + +void PVBuffer::bind() +{ + if (USE_VBO_ARB) { + glBindBufferARB(target, buffid); + } else { + // don't bind if buffer hasn't been allocated + //switch (pr_type) { + //case VertexContent: bound = buffer ? this : null; break; + //case IndexContent: boundelem = buffer ? this : null; break; + //} + } +} + +// static +void PVBuffer::unbind() +{ + if (USE_VBO_ARB) { + glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + } else { + //bound = null; + //boundelem = null; + } +} + + +// RamFile + + +void PRamFile::write(const void *data, int datasize) +{ + int newextent = cursor + datasize; + int buffsize = buffer.size(); + if (newextent > buffsize) { + buffer.resize(newextent); + if (cursor > buffsize) + memset(&buffer[buffsize], 0, cursor-buffsize); + } + + memcpy(&buffer[cursor], data, datasize); + cursor += datasize; +} + + + + diff -Nru trigger-rally-0.5.2.1/src/pengine/vbuffer.h trigger-rally-0.6.0/src/pengine/vbuffer.h --- trigger-rally-0.5.2.1/src/pengine/vbuffer.h 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/pengine/vbuffer.h 2011-10-07 17:10:01.000000000 +0000 @@ -1,75 +1,75 @@ - -// vbuffer.h [pengine] - -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net -// License: GPL version 2 (see included gpl.txt) - - - -#define BUFFER_OFFSET(i) ((char *)null + (i)) - - -class PVBuffer { -public: - enum contenttype { - VertexContent, IndexContent - }; - enum usagemode { - StreamUsage, StaticUsage, DynamicUsage - }; - -protected: - GLuint buffid; - GLenum target; - - contenttype pr_type; - - // emulation: - - uint8 *buffer; - //int buffersize; // not used anyway - - // in order to implement vbuffer emulation, need to add - // DrawRangeElements type call to this class - - //static PVBuffer *bound, *boundelem; - -public: - PVBuffer() { buffid = 0; buffer = null; } - ~PVBuffer(); - - bool create(int buffsize, contenttype type, usagemode usage, const void *data = null); - void update(int offset, int buffsize, const void *data); - void unload(); - - uint8 *getPointer(int offset); - - void bind(); - - static void unbind(); -}; - - -class PRamFile { -protected: - std::vector buffer; - int cursor; - -public: - PRamFile() { cursor = 0; } - - void write(const void *data, int datasize); - - void seek_cur(int pos) { seek_set(pos + cursor); } - void seek_end(int pos) { seek_set(pos + buffer.size()); } - void seek_set(int pos) { cursor = (pos >= 0) ? pos : 0; } - int tell() { return cursor; } - - void clear() { buffer.clear(); cursor = 0; } - - void *getData() { return &buffer[0]; } - int getSize() { return buffer.size(); } -}; - - - + +// vbuffer.h [pengine] + +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net +// License: GPL version 2 (see included gpl.txt) + + + +#define BUFFER_OFFSET(i) ((char *)null + (i)) + + +class PVBuffer { +public: + enum contenttype { + VertexContent, IndexContent + }; + enum usagemode { + StreamUsage, StaticUsage, DynamicUsage + }; + +protected: + GLuint buffid; + GLenum target; + + contenttype pr_type; + + // emulation: + + uint8 *buffer; + //int buffersize; // not used anyway + + // in order to implement vbuffer emulation, need to add + // DrawRangeElements type call to this class + + //static PVBuffer *bound, *boundelem; + +public: + PVBuffer() { buffid = 0; buffer = null; } + ~PVBuffer(); + + bool create(int buffsize, contenttype type, usagemode usage, const void *data = null); + void update(int offset, int buffsize, const void *data); + void unload(); + + uint8 *getPointer(int offset); + + void bind(); + + static void unbind(); +}; + + +class PRamFile { +protected: + std::vector buffer; + int cursor; + +public: + PRamFile() { cursor = 0; } + + void write(const void *data, int datasize); + + void seek_cur(int pos) { seek_set(pos + cursor); } + void seek_end(int pos) { seek_set(pos + buffer.size()); } + void seek_set(int pos) { cursor = (pos >= 0) ? pos : 0; } + int tell() { return cursor; } + + void clear() { buffer.clear(); cursor = 0; } + + void *getData() { return &buffer[0]; } + int getSize() { return buffer.size(); } +}; + + + diff -Nru trigger-rally-0.5.2.1/src/pengine/vmath.cpp trigger-rally-0.6.0/src/pengine/vmath.cpp --- trigger-rally-0.5.2.1/src/pengine/vmath.cpp 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/pengine/vmath.cpp 2011-10-07 17:10:01.000000000 +0000 @@ -1,94 +1,94 @@ - -// vmath.cpp [pengine] - -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net -// License: GPL version 2 (see included gpl.txt) - - -#include "pengine.h" - - - -template -frustum &frustum::construct(const mat44 &mat) -{ - side[SideRight] = plane( - mat.row[0][3] - mat.row[0][0], - mat.row[1][3] - mat.row[1][0], - mat.row[2][3] - mat.row[2][0], - mat.row[3][3] - mat.row[3][0]); - side[SideRight].normalize(); - - side[SideLeft] = plane( - mat.row[0][3] + mat.row[0][0], - mat.row[1][3] + mat.row[1][0], - mat.row[2][3] + mat.row[2][0], - mat.row[3][3] + mat.row[3][0]); - side[SideLeft].normalize(); - - side[SideTop] = plane( - mat.row[0][3] - mat.row[0][1], - mat.row[1][3] - mat.row[1][1], - mat.row[2][3] - mat.row[2][1], - mat.row[3][3] - mat.row[3][1]); - side[SideTop].normalize(); - - side[SideBottom] = plane( - mat.row[0][3] + mat.row[0][1], - mat.row[1][3] + mat.row[1][1], - mat.row[2][3] + mat.row[2][1], - mat.row[3][3] + mat.row[3][1]); - side[SideBottom].normalize(); - - side[SideNear] = plane( - mat.row[0][3] - mat.row[0][2], - mat.row[1][3] - mat.row[1][2], - mat.row[2][3] - mat.row[2][2], - mat.row[3][3] - mat.row[3][2]); - side[SideNear].normalize(); - - side[SideFar] = plane( - mat.row[0][3] + mat.row[0][2], - mat.row[1][3] + mat.row[1][2], - mat.row[2][3] + mat.row[2][2], - mat.row[3][3] + mat.row[3][2]); - side[SideFar].normalize(); - - return *this; -} -template frustum &frustum::construct(const mat44 &mat); -template frustum &frustum::construct(const mat44 &mat); - -template -bool frustum::isAABBOutside(const vec3 &mins, const vec3 &maxs) const -{ - vec3 pts[8] = { - vec3(mins.x, mins.y, mins.z), - vec3(maxs.x, mins.y, mins.z), - vec3(mins.x, maxs.y, mins.z), - vec3(maxs.x, maxs.y, mins.z), - vec3(mins.x, mins.y, maxs.z), - vec3(maxs.x, mins.y, maxs.z), - vec3(mins.x, maxs.y, maxs.z), - vec3(maxs.x, maxs.y, maxs.z) - }; - for (int s = 0; s < 1; ++s) { - bool outside = true; - for (int p = 0; p < 8; ++p) { - //if (side[s].normal * pts[p] + side[s].offset >= 0.0) { - if (side[s].normal * pts[p] >= 0.0) { - outside = false; - break; - } - } - if (outside) return true; - } - - return false; -} -template bool frustum::isAABBOutside(const vec3 &mins, const vec3 &maxs) const; -template bool frustum::isAABBOutside(const vec3 &mins, const vec3 &maxs) const; - - - - + +// vmath.cpp [pengine] + +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net +// License: GPL version 2 (see included gpl.txt) + + +#include "pengine.h" + + + +template +frustum &frustum::construct(const mat44 &mat) +{ + side[SideRight] = plane( + mat.row[0][3] - mat.row[0][0], + mat.row[1][3] - mat.row[1][0], + mat.row[2][3] - mat.row[2][0], + mat.row[3][3] - mat.row[3][0]); + side[SideRight].normalize(); + + side[SideLeft] = plane( + mat.row[0][3] + mat.row[0][0], + mat.row[1][3] + mat.row[1][0], + mat.row[2][3] + mat.row[2][0], + mat.row[3][3] + mat.row[3][0]); + side[SideLeft].normalize(); + + side[SideTop] = plane( + mat.row[0][3] - mat.row[0][1], + mat.row[1][3] - mat.row[1][1], + mat.row[2][3] - mat.row[2][1], + mat.row[3][3] - mat.row[3][1]); + side[SideTop].normalize(); + + side[SideBottom] = plane( + mat.row[0][3] + mat.row[0][1], + mat.row[1][3] + mat.row[1][1], + mat.row[2][3] + mat.row[2][1], + mat.row[3][3] + mat.row[3][1]); + side[SideBottom].normalize(); + + side[SideNear] = plane( + mat.row[0][3] - mat.row[0][2], + mat.row[1][3] - mat.row[1][2], + mat.row[2][3] - mat.row[2][2], + mat.row[3][3] - mat.row[3][2]); + side[SideNear].normalize(); + + side[SideFar] = plane( + mat.row[0][3] + mat.row[0][2], + mat.row[1][3] + mat.row[1][2], + mat.row[2][3] + mat.row[2][2], + mat.row[3][3] + mat.row[3][2]); + side[SideFar].normalize(); + + return *this; +} +template frustum &frustum::construct(const mat44 &mat); +template frustum &frustum::construct(const mat44 &mat); + +template +bool frustum::isAABBOutside(const vec3 &mins, const vec3 &maxs) const +{ + vec3 pts[8] = { + vec3(mins.x, mins.y, mins.z), + vec3(maxs.x, mins.y, mins.z), + vec3(mins.x, maxs.y, mins.z), + vec3(maxs.x, maxs.y, mins.z), + vec3(mins.x, mins.y, maxs.z), + vec3(maxs.x, mins.y, maxs.z), + vec3(mins.x, maxs.y, maxs.z), + vec3(maxs.x, maxs.y, maxs.z) + }; + for (int s = 0; s < 1; ++s) { + bool outside = true; + for (int p = 0; p < 8; ++p) { + //if (side[s].normal * pts[p] + side[s].offset >= 0.0) { + if (side[s].normal * pts[p] >= 0.0) { + outside = false; + break; + } + } + if (outside) return true; + } + + return false; +} +template bool frustum::isAABBOutside(const vec3 &mins, const vec3 &maxs) const; +template bool frustum::isAABBOutside(const vec3 &mins, const vec3 &maxs) const; + + + + diff -Nru trigger-rally-0.5.2.1/src/pengine/vmath.h trigger-rally-0.6.0/src/pengine/vmath.h --- trigger-rally-0.5.2.1/src/pengine/vmath.h 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/pengine/vmath.h 2011-10-07 17:10:01.000000000 +0000 @@ -1,656 +1,656 @@ - -// vmath.h [pengine] - -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net -// License: GPL version 2 (see included gpl.txt) - - -#include - - -#define PI 3.1415926535897932384626433832795 - -#define RADIANS(a) ((a)*PI/180.0) -#define DEGREES(a) ((a)*180.0/PI) - -#define rand01 ((float)rand() / (float)RAND_MAX) -#define randm11 (2.0f * (float)rand() / (float)RAND_MAX - 1.0f) - -#define MAX(a,b) (((a) >= (b)) ? (a) : (b)) -#define MIN(a,b) (((a) <= (b)) ? (a) : (b)) -#define CLAMP_UPPER(v,max) v = MIN(v, max) -#define CLAMP_LOWER(v,min) v = MAX(v, min) -#define CLAMP(v,min,max) v = MAX(MIN(v, max), min) -#define INTERP(a,b,f) ((a) + ((b) - (a)) * (f)) - -#define SQUARED(x) ((x)*(x)) - -#define PULLTOWARD(val,target,delta) (val = (target) + (val-(target)) / (1.0 + (delta))) - -#define DEADZONE(val, zone) (val = \ - (val > (zone)) ? ((val - (zone)) / (1.0 - (zone))) : \ - ((val < (-zone)) ? ((val + (zone)) / (1.0 - (zone))) : 0.0)) - -#define RANGEADJUST(val, premin, premax, postmin, postmax) (val = \ - ((val - (premin)) * ((postmax) - (postmin)) / ((premax) - (premin)) + (postmin))) - -#define makevec2f(vec) (vec2f(vec.x,vec.y)) -#define makevec3f(vec) (vec3f(vec.x,vec.y,vec.z)) -#define makevec4f(vec) (vec4f(vec.x,vec.y,vec.z,vec.w)) - -#define makevec4d(vec) (vec4d(vec.x,vec.y,vec.z,vec.w)) - - -template -class vec2 -{ -public: - T x,y; - - vec2 () { } - vec2 (T _x, T _y) { x=_x; y=_y; } - vec2 (const vec2 &vec) { x=vec.x; y=vec.y; } - - T &operator [] (int i) { return (&x)[i]; } - operator const T* () const { return &x; } - operator T* () { return &x; } - - vec2 &operator = (const vec2 &vec) { x=vec.x; y=vec.y; return *this; } - vec2 &operator += (const vec2 &vec) { x+=vec.x; y+=vec.y; return *this; } - vec2 &operator -= (const vec2 &vec) { x-=vec.x; y-=vec.y; return *this; } - vec2 &operator *= (T factor) { x*=factor; y*=factor; return *this; } - vec2 &operator /= (const T factor) { x/=factor; y/=factor; return *this; } - - vec2 operator + (const vec2 &vec) const { return vec2(x+vec.x, y+vec.y); } - vec2 operator - (const vec2 &vec) const { return vec2(x-vec.x, y-vec.y); } - - vec2 operator * (T factor) const { return vec2(x*factor, y*factor); } - vec2 operator / (T factor) const { return vec2(x/factor, y/factor); } - - T dot (const vec2 &vec) const { return (x*vec.x + y*vec.y); } - T operator * (const vec2 &vec) const { return dot(vec); } - - T lengthsq () const { return (x*x + y*y); } - T length () const { return (T)sqrt(lengthsq()); } - void normalize () { - T len = length(); - if (len) { - x /= len; - y /= len; - } else { - *this = vec2((T)1,(T)0); - } - } - - static const vec2 zero () { return vec2(0,0); } - - static vec2 rand() { - vec2 ret; - do { ret=vec2((T)2 * (T)::rand() / (T)RAND_MAX - (T)1, - (T)2 * (T)::rand() / (T)RAND_MAX - (T)1); } - while (ret.lengthsq() > (T)1); - return ret; - } -}; - -template inline vec2 operator - (const vec2 &vec) { return vec2(-vec.x,-vec.y); } - - -template -class vec3 -{ -public: - T x,y,z; - - vec3 () { } - vec3 (T _x, T _y, T _z) { x=_x; y=_y; z=_z; } - vec3 (const vec3 &vec) { x=vec.x; y=vec.y; z=vec.z; } - vec3 (const T *vecptr) { x=vecptr[0]; y=vecptr[1]; z=vecptr[2]; } - - T &operator [] (int i) { return (&x)[i]; } - operator const T* () const { return &x; } - operator T* () { return &x; } - - //operator vec2 () const { return vec2(x,y); } - - vec3 operator + (const vec3 &vec) const { return vec3(x+vec.x, y+vec.y, z+vec.z); } - vec3 operator - (const vec3 &vec) const { return vec3(x-vec.x, y-vec.y, z-vec.z); } - vec3 operator * (T factor) const { return vec3(x*factor, y*factor, z*factor); } - vec3 operator / (T divisor) const { - float factor = divisor != ((T)0) ? ((T)1) / divisor : ((T)0); - return vec3(x*factor, y*factor, z*factor); - } - - vec3 &operator += (const vec3 &vec) { *this = *this + vec; return *this; } - vec3 &operator -= (const vec3 &vec) { *this = *this - vec; return *this; } - vec3 &operator *= (const T factor) { *this = *this * factor; return *this; } - vec3 &operator /= (const T factor) { *this = *this / factor; return *this; } - - - T dot (const vec3 &vec) const { return (x*vec.x + y*vec.y + z*vec.z); } - T operator * (const vec3 &vec) const { return dot(vec); } - - vec3 cross (const vec3 &vec) const { return vec3(y*vec.z-z*vec.y, z*vec.x-x*vec.z, x*vec.y-y*vec.x); } - vec3 operator ^ (const vec3 &vec) const { return cross(vec); } - - vec3 modulate (const vec3 &vec) const { return vec3(x*vec.x, y*vec.y, z*vec.z); } - - T lengthsq () const { return (x*x + y*y + z*z); } - T length () const { return (T)sqrt(lengthsq()); } - void normalize () { - T len = length(); - if (len) { - len = (T)1 / len; - x *= len; - y *= len; - z *= len; - } else { - *this = vec3((T)0,(T)0,(T)1); - } - } - - void copyTo(T *dest) const { dest[0] = x; dest[1] = y; dest[2] = z; } - void copyFrom(const T *src) { x = src[0]; y = src[1]; z = src[2]; } - - static vec3 zero () { return vec3(0,0,0); } - - static vec3 rand() { - vec3 ret; - do { ret=vec3((T)2 * (T)::rand() / (T)RAND_MAX - (T)1, - (T)2 * (T)::rand() / (T)RAND_MAX - (T)1, - (T)2 * (T)::rand() / (T)RAND_MAX - (T)1); } - while (ret.lengthsq() > (T)1); - return ret; - } -}; - -template inline vec3 operator - (const vec3 &vec) { return vec3(-vec.x,-vec.y,-vec.z); } - -template inline vec3 operator * (const T &fac, const vec3 &vec) { return vec * fac; } - -template -class vec4 -{ -public: - T x,y,z,w; - - vec4 () { } - vec4 (T _x, T _y, T _z, T _w) { x=_x; y=_y; z=_z; w=_w; } - vec4 (const vec3 &vec) { x=vec.x; y=vec.y; z=vec.z; } - vec4 (const vec4 &vec) { x=vec.x; y=vec.y; z=vec.z; w=vec.w; } - vec4 (const vec3 &vec, T _w) { x=vec.x; y=vec.y; z=vec.z; w=_w; } - - T &operator [] (int i) { return (&x)[i]; } - operator const T* () const { return &x; } - operator T* () { return &x; } - - //operator vec3 () const { return vec3(x,y,z); } - - vec4 operator + (const vec4 &vec) const { return vec4(x+vec.x, y+vec.y, z+vec.z, w+vec.w); } - vec4 operator - (const vec4 &vec) const { return vec4(x-vec.x, y-vec.y, z-vec.z, w-vec.w); } - vec4 operator * (T factor) const { return vec4(x*factor, y*factor, z*factor, w*factor); } - - vec4 &operator += (const vec4 &vec) { *this = *this + vec; return *this; } - vec4 &operator -= (const vec4 &vec) { *this = *this - vec; return *this; } - vec4 &operator *= (const T factor) { *this = *this * factor; return *this; } - - T dot (const vec4 &vec) const { return (x*vec.x + y*vec.y + z*vec.z + w*vec.w); } - T operator * (const vec4 &vec) const { return dot(vec); } - - T lengthsq () const { return (x*x + y*y + z*z + w*w); } - T length () const { return sqrt(lengthsq()); } - void normalize3a () { - T len = sqrt(x*x + y*y + z*z); - if (len) { - len = (T)1 / len; - x *= len; - y *= len; - z *= len; - w *= len; - } else { - *this = vec4((T)0,(T)0,(T)1,(T)0); - } - } - void normalize3b () { - if (w) { - T len = (T)1 / w; - x *= len; - y *= len; - z *= len; - w = (T)1; - } else { - *this = vec4((T)0,(T)0,(T)0,(T)1); - } - } - void normalize3c () { - T len = sqrt(x*x + y*y + z*z); - if (len) { - len = (T)1 / len; - x *= len; - y *= len; - z *= len; - } else { - x = (T)0; - y = (T)0; - z = (T)1; - } - } - void normalize4 () { - T len = length(); - if (len) { - len = (T)1 / len; - x *= len; - y *= len; - z *= len; - w *= len; - } else { - *this = vec4((T)0,(T)0,(T)0,(T)1); - } - } - - void copyTo(T *dest) const { dest[0] = x; dest[1] = y; dest[2] = z; dest[3] = w; } - void copyFrom(const T *src) { x = src[0]; y = src[1]; z = src[2]; w = src[3]; } -}; - -template -class ray -{ -public: - vec3 start; - vec3 direction; - - ray () { } - ray (const vec3 &_start, const vec3 &_direction) : start(_start), direction(_direction) { } - - void fromTwoPoints(const vec3 &_start, const vec3 &_pt) { - start = _start; - direction = _pt - _start; - } - - vec3 getPt(T lambda) const { - return start + direction * lambda; - } - - bool getSphereIntersection(const vec3 ¢er, T radius, T &outLambda) const - { - vec3 temp = start - center; - - T a = direction.lengthsq(), - b = 2.0 * (direction * temp), - c = temp.lengthsq() - radius*radius, - determinant = b * b - (T)4 * a * c; - - if (determinant < (T)0) return false; - - T rootdet = sqrt(determinant), - t = (-b - rootdet) / ((T)2 * a); - - outLambda = t; - return true; - } -}; - -// this plane class is of form (x,y,z) . normal + offset = 0 -// ie, increasing offset moves plane backwards along its normal -template -class plane -{ -public: - vec3 normal; - T offset; - - plane () { } - plane (const vec3 &_normal, T _offset) : normal(_normal), offset(_offset) { } - plane (T _a, T _b, T _c, T _d) : normal(_a, _b, _c), offset(_d) { } - - void normalize() { - T len = normal.length(); - if (len) { - len = (T)1 / len; - normal *= len; - offset *= len; - } - } -}; - -template -class mat44 -{ -public: - vec4 row[4]; - - mat44 () { } - - T &operator [] (int i) { return row[0][i]; } - operator T* () { return &row[0].x; } - operator const T* () const { return &row[0].x; } - - mat44 &assemble(const vec4 &r0, const vec4 &r1, const vec4 &r2, const vec4 &r3) { - row[0] = r0; row[1] = r1; row[2] = r2; row[3] = r3; - return *this; - } - mat44 &assemble(const vec3 &r0, const vec3 &r1, const vec3 &r2) { - row[0] = vec4(r0.x, r0.y, r0.z, (T)0); - row[1] = vec4(r1.x, r1.y, r1.z, (T)0); - row[2] = vec4(r2.x, r2.y, r2.z, (T)0); - row[3] = vec4((T)0, (T)0, (T)0, (T)1); - return *this; - } - - mat44 concatenate(const mat44 &mat) const { - mat44 ret; - ret.row[0][0] = row[0][0]*mat.row[0][0] + row[0][1]*mat.row[1][0] + row[0][2]*mat.row[2][0] + row[0][3]*mat.row[3][0]; - ret.row[0][1] = row[0][0]*mat.row[0][1] + row[0][1]*mat.row[1][1] + row[0][2]*mat.row[2][1] + row[0][3]*mat.row[3][1]; - ret.row[0][2] = row[0][0]*mat.row[0][2] + row[0][1]*mat.row[1][2] + row[0][2]*mat.row[2][2] + row[0][3]*mat.row[3][2]; - ret.row[0][3] = row[0][0]*mat.row[0][3] + row[0][1]*mat.row[1][3] + row[0][2]*mat.row[2][3] + row[0][3]*mat.row[3][3]; - ret.row[1][0] = row[1][0]*mat.row[0][0] + row[1][1]*mat.row[1][0] + row[1][2]*mat.row[2][0] + row[1][3]*mat.row[3][0]; - ret.row[1][1] = row[1][0]*mat.row[0][1] + row[1][1]*mat.row[1][1] + row[1][2]*mat.row[2][1] + row[1][3]*mat.row[3][1]; - ret.row[1][2] = row[1][0]*mat.row[0][2] + row[1][1]*mat.row[1][2] + row[1][2]*mat.row[2][2] + row[1][3]*mat.row[3][2]; - ret.row[1][3] = row[1][0]*mat.row[0][3] + row[1][1]*mat.row[1][3] + row[1][2]*mat.row[2][3] + row[1][3]*mat.row[3][3]; - ret.row[2][0] = row[2][0]*mat.row[0][0] + row[2][1]*mat.row[1][0] + row[2][2]*mat.row[2][0] + row[2][3]*mat.row[3][0]; - ret.row[2][1] = row[2][0]*mat.row[0][1] + row[2][1]*mat.row[1][1] + row[2][2]*mat.row[2][1] + row[2][3]*mat.row[3][1]; - ret.row[2][2] = row[2][0]*mat.row[0][2] + row[2][1]*mat.row[1][2] + row[2][2]*mat.row[2][2] + row[2][3]*mat.row[3][2]; - ret.row[2][3] = row[2][0]*mat.row[0][3] + row[2][1]*mat.row[1][3] + row[2][2]*mat.row[2][3] + row[2][3]*mat.row[3][3]; - ret.row[3][0] = row[3][0]*mat.row[0][0] + row[3][1]*mat.row[1][0] + row[3][2]*mat.row[2][0] + row[3][3]*mat.row[3][0]; - ret.row[3][1] = row[3][0]*mat.row[0][1] + row[3][1]*mat.row[1][1] + row[3][2]*mat.row[2][1] + row[3][3]*mat.row[3][1]; - ret.row[3][2] = row[3][0]*mat.row[0][2] + row[3][1]*mat.row[1][2] + row[3][2]*mat.row[2][2] + row[3][3]*mat.row[3][2]; - ret.row[3][3] = row[3][0]*mat.row[0][3] + row[3][1]*mat.row[1][3] + row[3][2]*mat.row[2][3] + row[3][3]*mat.row[3][3]; - return ret; - } - - mat44 concatenateReverse(const mat44 &mat) const { - return mat.concatenate(*this); - } - - mat44 transpose() const { - mat44 ret; - ret.row[0] = vec4(row[0].x, row[1].x, row[2].x, row[3].x); - ret.row[1] = vec4(row[0].y, row[1].y, row[2].y, row[3].y); - ret.row[2] = vec4(row[0].z, row[1].z, row[2].z, row[3].z); - ret.row[3] = vec4(row[0].w, row[1].w, row[2].w, row[3].w); - return ret; - } - - mat44 &translate(const vec3 &vec) { - row[0].w += vec.x; - row[1].w += vec.y; - row[2].w += vec.z; - return *this; - } - - vec3 transform1(const vec3 &vec) const { - return vec3 ( - row[0].x * vec.x + row[0].y * vec.y + row[0].z * vec.z + row[0].w, - row[1].x * vec.x + row[1].y * vec.y + row[1].z * vec.z + row[1].w, - row[2].x * vec.x + row[2].y * vec.y + row[2].z * vec.z + row[2].w - ); - } - - vec4 transform1(const vec4 &vec) const { - return vec4 ( - row[0].x * vec.x + row[0].y * vec.y + row[0].z * vec.z + row[0].w * vec.w, - row[1].x * vec.x + row[1].y * vec.y + row[1].z * vec.z + row[1].w * vec.w, - row[2].x * vec.x + row[2].y * vec.y + row[2].z * vec.z + row[2].w * vec.w, - row[3].x * vec.x + row[3].y * vec.y + row[3].z * vec.z + row[3].w * vec.w - ); - } - - vec3 transform2(const vec3 &vec) const { - return vec3 ( - row[0].x * vec.x + row[1].x * vec.y + row[2].x * vec.z + row[3].x, - row[0].y * vec.x + row[1].y * vec.y + row[2].y * vec.z + row[3].y, - row[0].z * vec.x + row[1].z * vec.y + row[2].z * vec.z + row[3].z - ); - } - - vec4 transform2(const vec4 &vec) const { - return vec4 ( - row[0].x * vec.x + row[1].x * vec.y + row[2].x * vec.z + row[3].x * vec.w, - row[0].y * vec.x + row[1].y * vec.y + row[2].y * vec.z + row[3].y * vec.w, - row[0].z * vec.x + row[1].z * vec.y + row[2].z * vec.z + row[3].z * vec.w, - row[0].w * vec.x + row[1].w * vec.y + row[2].w * vec.z + row[3].w * vec.w - ); - } - - vec3 transformNormal(const vec3 &vec) const { - return vec3 ( - row[0].x * vec.x + row[0].y * vec.y + row[0].z * vec.z, - row[1].x * vec.x + row[1].y * vec.y + row[1].z * vec.z, - row[2].x * vec.x + row[2].y * vec.y + row[2].z * vec.z - ); - } - - static mat44 identity() { - mat44 ret; - ret.row[0] = vec4(1,0,0,0); - ret.row[1] = vec4(0,1,0,0); - ret.row[2] = vec4(0,0,1,0); - ret.row[3] = vec4(0,0,0,1); - return ret; - } -}; - - -template -class quat { -public: - T x,y,z,w; - -public: - quat() { } - quat(T _x, T _y, T _z, T _w) : x(_x), y(_y), z(_z), w(_w) { } - - quat operator + (const quat &q) const { - return quat(x+q.x, y+q.y, z+q.z, w+q.w); - } - quat operator - (const quat &q) const { - return quat(x-q.x, y-q.y, z-q.z, w-q.w); - } - quat operator * (T val) const { - return quat(x*val, y*val, z*val, w*val); - } - quat operator / (T val) const { - T mult = (T)1 / val; - return quat(x*mult, y*mult, z*mult, w*mult); - } - - quat operator * (const quat &q) const { - return quat( - w*q.x + x*q.w + y*q.z - z*q.y, - w*q.y - x*q.z + y*q.w + z*q.x, - w*q.z + x*q.y - y*q.x + z*q.w, - w*q.w - x*q.x - y*q.y - z*q.z); - } - - quat &operator += (const quat &q) { - *this = *this + q; - return *this; - } - // operator *= has to assume an order - // since quaternion mult is not commutative, it's - // better to force the user to think about it - - float dot(const quat &q) { - return (x * q.x + y * q.y + z * q.z + w * q.w); - } - - void fromAxisAngle(const vec3 &axis, T angle) { - T len = axis.length(); - if (len > (T)0) { - T sinA = sin(angle/(T)2) / len; - x = sinA * axis.x; - y = sinA * axis.y; - z = sinA * axis.z; - w = cos(angle/(T)2); - } else { - *this = identity(); - } - } - void fromXAngle(T angle) { - x = sin(angle/(T)2); - y = z = (T)0; - w = cos(angle/(T)2); - } - void fromYAngle(T angle) { - y = sin(angle/(T)2); - x = z = (T)0; - w = cos(angle/(T)2); - } - void fromZAngle(T angle) { - z = sin(angle/(T)2); - x = y = (T)0; - w = cos(angle/(T)2); - } - void fromThreeAxisAngle(const vec3 &vec) { - quat temp; - fromXAngle(vec.x); - temp.fromYAngle(vec.y); - *this = *this * temp; - temp.fromZAngle(vec.z); - *this = *this * temp; - } - - void normalize() { - T len = x*x + y*y + z*z + w*w; - if (len > (T)0) { - len = (T)1 / (T)sqrt(len); - x *= len; - y *= len; - z *= len; - w *= len; - } else { - *this = identity(); - } - } - - mat44 getMatrix() const { - T norm = x*x + y*y + z*z + w*w, - s = (norm > (T)0) ? (T)2/norm : (T)0, - - xx = x * x * s, - yy = y * y * s, - zz = z * z * s, - xy = x * y * s, - xz = x * z * s, - yz = y * z * s, - wx = w * x * s, - wy = w * y * s, - wz = w * z * s; - - mat44 m; - m.assemble( - vec3((T)1 - (yy + zz), xy + wz, xz - wy), - vec3(xy - wz, (T)1 - (xx + zz), yz + wx), - vec3(xz + wy, yz - wx, (T)1 - (xx + yy))); - - return m; -/* - m.el[0] = (T)1 - (yy + zz); - m.el[4] = xy + wz; - m.el[8] = xz - wy; - - m.el[1] = xy - wz; - m.el[5] = (T)1 - (xx + zz); - m.el[9] = yz + wx; - - m.el[2] = xz + wy; - m.el[6] = yz - wx; - m.el[10] = (T)1 - (xx + yy); - - m.el[12] = m.el[13] = m.el[14] = m.el[3] = m.el[7] = m.el[11] = (T)0; - m.el[15] = (T)1; -*/ - } - - static quat identity () { return quat(0,0,0,1); } - - static quat rand() { - quat ret; - float lengthsq; - do { ret=quat((T)2 * (T)::rand() / (T)RAND_MAX - (T)1, - (T)2 * (T)::rand() / (T)RAND_MAX - (T)1, - (T)2 * (T)::rand() / (T)RAND_MAX - (T)1, - (T)2 * (T)::rand() / (T)RAND_MAX - (T)1); - lengthsq = ret.x*ret.x + ret.y*ret.y + ret.z*ret.z + ret.w*ret.w; - } while (lengthsq > (T)1 || lengthsq <= (T)0); - float mult = (T)1 / (T)sqrt(lengthsq); - ret.x *= mult; ret.y *= mult; ret.z *= mult; ret.w *= mult; - return ret; - } -}; - -template -class frustum { -public: - - enum { - SideRight, - SideLeft, - SideTop, - SideBottom, - SideNear, - SideFar, - SideCount - }; - - plane side[SideCount]; - -public: - frustum() { } - frustum(const mat44 &mat) { construct(mat); } - - frustum &construct(const mat44 &mat); - - bool isAABBOutside(const vec3 &mins, const vec3 &maxs) const; -}; - - -typedef signed char int8; -typedef unsigned char uint8; -typedef signed short int16; -typedef unsigned short uint16; -typedef signed int int32; -typedef unsigned int uint32; - -typedef vec2 vec2f; -typedef vec2 vec2d; -typedef vec2 vec2i; -typedef vec2 vec2ub; - -typedef vec3 vec3f; -typedef vec3 vec3d; -typedef vec3 vec3i; -typedef vec3 vec3ub; - -typedef vec4 vec4f; -typedef vec4 vec4d; -typedef vec4 vec4i; -typedef vec4 vec4ub; - -typedef quat quatf; -typedef quat quatd; - -typedef ray rayf; -typedef ray rayd; - -typedef plane planef; -typedef plane planed; - -typedef mat44 mat44f; -typedef mat44 mat44d; - -typedef frustum frustumf; -typedef frustum frustumd; - -template inline T intersect_plane_ray(const plane &pln, const vec3 &linept, const vec3 &linedir) -{ - T denom = pln.normal * linedir; - if (denom) { - return - (pln.normal * linept + pln.offset) / denom; - } else { - return (T)0; - } -} - - - + +// vmath.h [pengine] + +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net +// License: GPL version 2 (see included gpl.txt) + + +#include + + +#define PI 3.1415926535897932384626433832795 + +#define RADIANS(a) ((a)*PI/180.0) +#define DEGREES(a) ((a)*180.0/PI) + +#define rand01 ((float)rand() / (float)RAND_MAX) +#define randm11 (2.0f * (float)rand() / (float)RAND_MAX - 1.0f) + +#define MAX(a,b) (((a) >= (b)) ? (a) : (b)) +#define MIN(a,b) (((a) <= (b)) ? (a) : (b)) +#define CLAMP_UPPER(v,max) v = MIN(v, max) +#define CLAMP_LOWER(v,min) v = MAX(v, min) +#define CLAMP(v,min,max) v = MAX(MIN(v, max), min) +#define INTERP(a,b,f) ((a) + ((b) - (a)) * (f)) + +#define SQUARED(x) ((x)*(x)) + +#define PULLTOWARD(val,target,delta) (val = (target) + (val-(target)) / (1.0 + (delta))) + +#define DEADZONE(val, zone) (val = \ + (val > (zone)) ? ((val - (zone)) / (1.0 - (zone))) : \ + ((val < (-zone)) ? ((val + (zone)) / (1.0 - (zone))) : 0.0)) + +#define RANGEADJUST(val, premin, premax, postmin, postmax) (val = \ + ((val - (premin)) * ((postmax) - (postmin)) / ((premax) - (premin)) + (postmin))) + +#define makevec2f(vec) (vec2f(vec.x,vec.y)) +#define makevec3f(vec) (vec3f(vec.x,vec.y,vec.z)) +#define makevec4f(vec) (vec4f(vec.x,vec.y,vec.z,vec.w)) + +#define makevec4d(vec) (vec4d(vec.x,vec.y,vec.z,vec.w)) + + +template +class vec2 +{ +public: + T x,y; + + vec2 () { } + vec2 (T _x, T _y) { x=_x; y=_y; } + vec2 (const vec2 &vec) { x=vec.x; y=vec.y; } + + T &operator [] (int i) { return (&x)[i]; } + operator const T* () const { return &x; } + operator T* () { return &x; } + + vec2 &operator = (const vec2 &vec) { x=vec.x; y=vec.y; return *this; } + vec2 &operator += (const vec2 &vec) { x+=vec.x; y+=vec.y; return *this; } + vec2 &operator -= (const vec2 &vec) { x-=vec.x; y-=vec.y; return *this; } + vec2 &operator *= (T factor) { x*=factor; y*=factor; return *this; } + vec2 &operator /= (const T factor) { x/=factor; y/=factor; return *this; } + + vec2 operator + (const vec2 &vec) const { return vec2(x+vec.x, y+vec.y); } + vec2 operator - (const vec2 &vec) const { return vec2(x-vec.x, y-vec.y); } + + vec2 operator * (T factor) const { return vec2(x*factor, y*factor); } + vec2 operator / (T factor) const { return vec2(x/factor, y/factor); } + + T dot (const vec2 &vec) const { return (x*vec.x + y*vec.y); } + T operator * (const vec2 &vec) const { return dot(vec); } + + T lengthsq () const { return (x*x + y*y); } + T length () const { return (T)sqrt(lengthsq()); } + void normalize () { + T len = length(); + if (len) { + x /= len; + y /= len; + } else { + *this = vec2((T)1,(T)0); + } + } + + static const vec2 zero () { return vec2(0,0); } + + static vec2 rand() { + vec2 ret; + do { ret=vec2((T)2 * (T)::rand() / (T)RAND_MAX - (T)1, + (T)2 * (T)::rand() / (T)RAND_MAX - (T)1); } + while (ret.lengthsq() > (T)1); + return ret; + } +}; + +template inline vec2 operator - (const vec2 &vec) { return vec2(-vec.x,-vec.y); } + + +template +class vec3 +{ +public: + T x,y,z; + + vec3 () { } + vec3 (T _x, T _y, T _z) { x=_x; y=_y; z=_z; } + vec3 (const vec3 &vec) { x=vec.x; y=vec.y; z=vec.z; } + vec3 (const T *vecptr) { x=vecptr[0]; y=vecptr[1]; z=vecptr[2]; } + + T &operator [] (int i) { return (&x)[i]; } + operator const T* () const { return &x; } + operator T* () { return &x; } + + //operator vec2 () const { return vec2(x,y); } + + vec3 operator + (const vec3 &vec) const { return vec3(x+vec.x, y+vec.y, z+vec.z); } + vec3 operator - (const vec3 &vec) const { return vec3(x-vec.x, y-vec.y, z-vec.z); } + vec3 operator * (T factor) const { return vec3(x*factor, y*factor, z*factor); } + vec3 operator / (T divisor) const { + float factor = divisor != ((T)0) ? ((T)1) / divisor : ((T)0); + return vec3(x*factor, y*factor, z*factor); + } + + vec3 &operator += (const vec3 &vec) { *this = *this + vec; return *this; } + vec3 &operator -= (const vec3 &vec) { *this = *this - vec; return *this; } + vec3 &operator *= (const T factor) { *this = *this * factor; return *this; } + vec3 &operator /= (const T factor) { *this = *this / factor; return *this; } + + + T dot (const vec3 &vec) const { return (x*vec.x + y*vec.y + z*vec.z); } + T operator * (const vec3 &vec) const { return dot(vec); } + + vec3 cross (const vec3 &vec) const { return vec3(y*vec.z-z*vec.y, z*vec.x-x*vec.z, x*vec.y-y*vec.x); } + vec3 operator ^ (const vec3 &vec) const { return cross(vec); } + + vec3 modulate (const vec3 &vec) const { return vec3(x*vec.x, y*vec.y, z*vec.z); } + + T lengthsq () const { return (x*x + y*y + z*z); } + T length () const { return (T)sqrt(lengthsq()); } + void normalize () { + T len = length(); + if (len) { + len = (T)1 / len; + x *= len; + y *= len; + z *= len; + } else { + *this = vec3((T)0,(T)0,(T)1); + } + } + + void copyTo(T *dest) const { dest[0] = x; dest[1] = y; dest[2] = z; } + void copyFrom(const T *src) { x = src[0]; y = src[1]; z = src[2]; } + + static vec3 zero () { return vec3(0,0,0); } + + static vec3 rand() { + vec3 ret; + do { ret=vec3((T)2 * (T)::rand() / (T)RAND_MAX - (T)1, + (T)2 * (T)::rand() / (T)RAND_MAX - (T)1, + (T)2 * (T)::rand() / (T)RAND_MAX - (T)1); } + while (ret.lengthsq() > (T)1); + return ret; + } +}; + +template inline vec3 operator - (const vec3 &vec) { return vec3(-vec.x,-vec.y,-vec.z); } + +template inline vec3 operator * (const T &fac, const vec3 &vec) { return vec * fac; } + +template +class vec4 +{ +public: + T x,y,z,w; + + vec4 () { } + vec4 (T _x, T _y, T _z, T _w) { x=_x; y=_y; z=_z; w=_w; } + vec4 (const vec3 &vec) { x=vec.x; y=vec.y; z=vec.z; } + vec4 (const vec4 &vec) { x=vec.x; y=vec.y; z=vec.z; w=vec.w; } + vec4 (const vec3 &vec, T _w) { x=vec.x; y=vec.y; z=vec.z; w=_w; } + + T &operator [] (int i) { return (&x)[i]; } + operator const T* () const { return &x; } + operator T* () { return &x; } + + //operator vec3 () const { return vec3(x,y,z); } + + vec4 operator + (const vec4 &vec) const { return vec4(x+vec.x, y+vec.y, z+vec.z, w+vec.w); } + vec4 operator - (const vec4 &vec) const { return vec4(x-vec.x, y-vec.y, z-vec.z, w-vec.w); } + vec4 operator * (T factor) const { return vec4(x*factor, y*factor, z*factor, w*factor); } + + vec4 &operator += (const vec4 &vec) { *this = *this + vec; return *this; } + vec4 &operator -= (const vec4 &vec) { *this = *this - vec; return *this; } + vec4 &operator *= (const T factor) { *this = *this * factor; return *this; } + + T dot (const vec4 &vec) const { return (x*vec.x + y*vec.y + z*vec.z + w*vec.w); } + T operator * (const vec4 &vec) const { return dot(vec); } + + T lengthsq () const { return (x*x + y*y + z*z + w*w); } + T length () const { return sqrt(lengthsq()); } + void normalize3a () { + T len = sqrt(x*x + y*y + z*z); + if (len) { + len = (T)1 / len; + x *= len; + y *= len; + z *= len; + w *= len; + } else { + *this = vec4((T)0,(T)0,(T)1,(T)0); + } + } + void normalize3b () { + if (w) { + T len = (T)1 / w; + x *= len; + y *= len; + z *= len; + w = (T)1; + } else { + *this = vec4((T)0,(T)0,(T)0,(T)1); + } + } + void normalize3c () { + T len = sqrt(x*x + y*y + z*z); + if (len) { + len = (T)1 / len; + x *= len; + y *= len; + z *= len; + } else { + x = (T)0; + y = (T)0; + z = (T)1; + } + } + void normalize4 () { + T len = length(); + if (len) { + len = (T)1 / len; + x *= len; + y *= len; + z *= len; + w *= len; + } else { + *this = vec4((T)0,(T)0,(T)0,(T)1); + } + } + + void copyTo(T *dest) const { dest[0] = x; dest[1] = y; dest[2] = z; dest[3] = w; } + void copyFrom(const T *src) { x = src[0]; y = src[1]; z = src[2]; w = src[3]; } +}; + +template +class ray +{ +public: + vec3 start; + vec3 direction; + + ray () { } + ray (const vec3 &_start, const vec3 &_direction) : start(_start), direction(_direction) { } + + void fromTwoPoints(const vec3 &_start, const vec3 &_pt) { + start = _start; + direction = _pt - _start; + } + + vec3 getPt(T lambda) const { + return start + direction * lambda; + } + + bool getSphereIntersection(const vec3 ¢er, T radius, T &outLambda) const + { + vec3 temp = start - center; + + T a = direction.lengthsq(), + b = 2.0 * (direction * temp), + c = temp.lengthsq() - radius*radius, + determinant = b * b - (T)4 * a * c; + + if (determinant < (T)0) return false; + + T rootdet = sqrt(determinant), + t = (-b - rootdet) / ((T)2 * a); + + outLambda = t; + return true; + } +}; + +// this plane class is of form (x,y,z) . normal + offset = 0 +// ie, increasing offset moves plane backwards along its normal +template +class plane +{ +public: + vec3 normal; + T offset; + + plane () { } + plane (const vec3 &_normal, T _offset) : normal(_normal), offset(_offset) { } + plane (T _a, T _b, T _c, T _d) : normal(_a, _b, _c), offset(_d) { } + + void normalize() { + T len = normal.length(); + if (len) { + len = (T)1 / len; + normal *= len; + offset *= len; + } + } +}; + +template +class mat44 +{ +public: + vec4 row[4]; + + mat44 () { } + + T &operator [] (int i) { return row[0][i]; } + operator T* () { return &row[0].x; } + operator const T* () const { return &row[0].x; } + + mat44 &assemble(const vec4 &r0, const vec4 &r1, const vec4 &r2, const vec4 &r3) { + row[0] = r0; row[1] = r1; row[2] = r2; row[3] = r3; + return *this; + } + mat44 &assemble(const vec3 &r0, const vec3 &r1, const vec3 &r2) { + row[0] = vec4(r0.x, r0.y, r0.z, (T)0); + row[1] = vec4(r1.x, r1.y, r1.z, (T)0); + row[2] = vec4(r2.x, r2.y, r2.z, (T)0); + row[3] = vec4((T)0, (T)0, (T)0, (T)1); + return *this; + } + + mat44 concatenate(const mat44 &mat) const { + mat44 ret; + ret.row[0][0] = row[0][0]*mat.row[0][0] + row[0][1]*mat.row[1][0] + row[0][2]*mat.row[2][0] + row[0][3]*mat.row[3][0]; + ret.row[0][1] = row[0][0]*mat.row[0][1] + row[0][1]*mat.row[1][1] + row[0][2]*mat.row[2][1] + row[0][3]*mat.row[3][1]; + ret.row[0][2] = row[0][0]*mat.row[0][2] + row[0][1]*mat.row[1][2] + row[0][2]*mat.row[2][2] + row[0][3]*mat.row[3][2]; + ret.row[0][3] = row[0][0]*mat.row[0][3] + row[0][1]*mat.row[1][3] + row[0][2]*mat.row[2][3] + row[0][3]*mat.row[3][3]; + ret.row[1][0] = row[1][0]*mat.row[0][0] + row[1][1]*mat.row[1][0] + row[1][2]*mat.row[2][0] + row[1][3]*mat.row[3][0]; + ret.row[1][1] = row[1][0]*mat.row[0][1] + row[1][1]*mat.row[1][1] + row[1][2]*mat.row[2][1] + row[1][3]*mat.row[3][1]; + ret.row[1][2] = row[1][0]*mat.row[0][2] + row[1][1]*mat.row[1][2] + row[1][2]*mat.row[2][2] + row[1][3]*mat.row[3][2]; + ret.row[1][3] = row[1][0]*mat.row[0][3] + row[1][1]*mat.row[1][3] + row[1][2]*mat.row[2][3] + row[1][3]*mat.row[3][3]; + ret.row[2][0] = row[2][0]*mat.row[0][0] + row[2][1]*mat.row[1][0] + row[2][2]*mat.row[2][0] + row[2][3]*mat.row[3][0]; + ret.row[2][1] = row[2][0]*mat.row[0][1] + row[2][1]*mat.row[1][1] + row[2][2]*mat.row[2][1] + row[2][3]*mat.row[3][1]; + ret.row[2][2] = row[2][0]*mat.row[0][2] + row[2][1]*mat.row[1][2] + row[2][2]*mat.row[2][2] + row[2][3]*mat.row[3][2]; + ret.row[2][3] = row[2][0]*mat.row[0][3] + row[2][1]*mat.row[1][3] + row[2][2]*mat.row[2][3] + row[2][3]*mat.row[3][3]; + ret.row[3][0] = row[3][0]*mat.row[0][0] + row[3][1]*mat.row[1][0] + row[3][2]*mat.row[2][0] + row[3][3]*mat.row[3][0]; + ret.row[3][1] = row[3][0]*mat.row[0][1] + row[3][1]*mat.row[1][1] + row[3][2]*mat.row[2][1] + row[3][3]*mat.row[3][1]; + ret.row[3][2] = row[3][0]*mat.row[0][2] + row[3][1]*mat.row[1][2] + row[3][2]*mat.row[2][2] + row[3][3]*mat.row[3][2]; + ret.row[3][3] = row[3][0]*mat.row[0][3] + row[3][1]*mat.row[1][3] + row[3][2]*mat.row[2][3] + row[3][3]*mat.row[3][3]; + return ret; + } + + mat44 concatenateReverse(const mat44 &mat) const { + return mat.concatenate(*this); + } + + mat44 transpose() const { + mat44 ret; + ret.row[0] = vec4(row[0].x, row[1].x, row[2].x, row[3].x); + ret.row[1] = vec4(row[0].y, row[1].y, row[2].y, row[3].y); + ret.row[2] = vec4(row[0].z, row[1].z, row[2].z, row[3].z); + ret.row[3] = vec4(row[0].w, row[1].w, row[2].w, row[3].w); + return ret; + } + + mat44 &translate(const vec3 &vec) { + row[0].w += vec.x; + row[1].w += vec.y; + row[2].w += vec.z; + return *this; + } + + vec3 transform1(const vec3 &vec) const { + return vec3 ( + row[0].x * vec.x + row[0].y * vec.y + row[0].z * vec.z + row[0].w, + row[1].x * vec.x + row[1].y * vec.y + row[1].z * vec.z + row[1].w, + row[2].x * vec.x + row[2].y * vec.y + row[2].z * vec.z + row[2].w + ); + } + + vec4 transform1(const vec4 &vec) const { + return vec4 ( + row[0].x * vec.x + row[0].y * vec.y + row[0].z * vec.z + row[0].w * vec.w, + row[1].x * vec.x + row[1].y * vec.y + row[1].z * vec.z + row[1].w * vec.w, + row[2].x * vec.x + row[2].y * vec.y + row[2].z * vec.z + row[2].w * vec.w, + row[3].x * vec.x + row[3].y * vec.y + row[3].z * vec.z + row[3].w * vec.w + ); + } + + vec3 transform2(const vec3 &vec) const { + return vec3 ( + row[0].x * vec.x + row[1].x * vec.y + row[2].x * vec.z + row[3].x, + row[0].y * vec.x + row[1].y * vec.y + row[2].y * vec.z + row[3].y, + row[0].z * vec.x + row[1].z * vec.y + row[2].z * vec.z + row[3].z + ); + } + + vec4 transform2(const vec4 &vec) const { + return vec4 ( + row[0].x * vec.x + row[1].x * vec.y + row[2].x * vec.z + row[3].x * vec.w, + row[0].y * vec.x + row[1].y * vec.y + row[2].y * vec.z + row[3].y * vec.w, + row[0].z * vec.x + row[1].z * vec.y + row[2].z * vec.z + row[3].z * vec.w, + row[0].w * vec.x + row[1].w * vec.y + row[2].w * vec.z + row[3].w * vec.w + ); + } + + vec3 transformNormal(const vec3 &vec) const { + return vec3 ( + row[0].x * vec.x + row[0].y * vec.y + row[0].z * vec.z, + row[1].x * vec.x + row[1].y * vec.y + row[1].z * vec.z, + row[2].x * vec.x + row[2].y * vec.y + row[2].z * vec.z + ); + } + + static mat44 identity() { + mat44 ret; + ret.row[0] = vec4(1,0,0,0); + ret.row[1] = vec4(0,1,0,0); + ret.row[2] = vec4(0,0,1,0); + ret.row[3] = vec4(0,0,0,1); + return ret; + } +}; + + +template +class quat { +public: + T x,y,z,w; + +public: + quat() { } + quat(T _x, T _y, T _z, T _w) : x(_x), y(_y), z(_z), w(_w) { } + + quat operator + (const quat &q) const { + return quat(x+q.x, y+q.y, z+q.z, w+q.w); + } + quat operator - (const quat &q) const { + return quat(x-q.x, y-q.y, z-q.z, w-q.w); + } + quat operator * (T val) const { + return quat(x*val, y*val, z*val, w*val); + } + quat operator / (T val) const { + T mult = (T)1 / val; + return quat(x*mult, y*mult, z*mult, w*mult); + } + + quat operator * (const quat &q) const { + return quat( + w*q.x + x*q.w + y*q.z - z*q.y, + w*q.y - x*q.z + y*q.w + z*q.x, + w*q.z + x*q.y - y*q.x + z*q.w, + w*q.w - x*q.x - y*q.y - z*q.z); + } + + quat &operator += (const quat &q) { + *this = *this + q; + return *this; + } + // operator *= has to assume an order + // since quaternion mult is not commutative, it's + // better to force the user to think about it + + float dot(const quat &q) { + return (x * q.x + y * q.y + z * q.z + w * q.w); + } + + void fromAxisAngle(const vec3 &axis, T angle) { + T len = axis.length(); + if (len > (T)0) { + T sinA = sin(angle/(T)2) / len; + x = sinA * axis.x; + y = sinA * axis.y; + z = sinA * axis.z; + w = cos(angle/(T)2); + } else { + *this = identity(); + } + } + void fromXAngle(T angle) { + x = sin(angle/(T)2); + y = z = (T)0; + w = cos(angle/(T)2); + } + void fromYAngle(T angle) { + y = sin(angle/(T)2); + x = z = (T)0; + w = cos(angle/(T)2); + } + void fromZAngle(T angle) { + z = sin(angle/(T)2); + x = y = (T)0; + w = cos(angle/(T)2); + } + void fromThreeAxisAngle(const vec3 &vec) { + quat temp; + fromXAngle(vec.x); + temp.fromYAngle(vec.y); + *this = *this * temp; + temp.fromZAngle(vec.z); + *this = *this * temp; + } + + void normalize() { + T len = x*x + y*y + z*z + w*w; + if (len > (T)0) { + len = (T)1 / (T)sqrt(len); + x *= len; + y *= len; + z *= len; + w *= len; + } else { + *this = identity(); + } + } + + mat44 getMatrix() const { + T norm = x*x + y*y + z*z + w*w, + s = (norm > (T)0) ? (T)2/norm : (T)0, + + xx = x * x * s, + yy = y * y * s, + zz = z * z * s, + xy = x * y * s, + xz = x * z * s, + yz = y * z * s, + wx = w * x * s, + wy = w * y * s, + wz = w * z * s; + + mat44 m; + m.assemble( + vec3((T)1 - (yy + zz), xy + wz, xz - wy), + vec3(xy - wz, (T)1 - (xx + zz), yz + wx), + vec3(xz + wy, yz - wx, (T)1 - (xx + yy))); + + return m; +/* + m.el[0] = (T)1 - (yy + zz); + m.el[4] = xy + wz; + m.el[8] = xz - wy; + + m.el[1] = xy - wz; + m.el[5] = (T)1 - (xx + zz); + m.el[9] = yz + wx; + + m.el[2] = xz + wy; + m.el[6] = yz - wx; + m.el[10] = (T)1 - (xx + yy); + + m.el[12] = m.el[13] = m.el[14] = m.el[3] = m.el[7] = m.el[11] = (T)0; + m.el[15] = (T)1; +*/ + } + + static quat identity () { return quat(0,0,0,1); } + + static quat rand() { + quat ret; + float lengthsq; + do { ret=quat((T)2 * (T)::rand() / (T)RAND_MAX - (T)1, + (T)2 * (T)::rand() / (T)RAND_MAX - (T)1, + (T)2 * (T)::rand() / (T)RAND_MAX - (T)1, + (T)2 * (T)::rand() / (T)RAND_MAX - (T)1); + lengthsq = ret.x*ret.x + ret.y*ret.y + ret.z*ret.z + ret.w*ret.w; + } while (lengthsq > (T)1 || lengthsq <= (T)0); + float mult = (T)1 / (T)sqrt(lengthsq); + ret.x *= mult; ret.y *= mult; ret.z *= mult; ret.w *= mult; + return ret; + } +}; + +template +class frustum { +public: + + enum { + SideRight, + SideLeft, + SideTop, + SideBottom, + SideNear, + SideFar, + SideCount + }; + + plane side[SideCount]; + +public: + frustum() { } + frustum(const mat44 &mat) { construct(mat); } + + frustum &construct(const mat44 &mat); + + bool isAABBOutside(const vec3 &mins, const vec3 &maxs) const; +}; + + +typedef signed char int8; +typedef unsigned char uint8; +typedef signed short int16; +typedef unsigned short uint16; +typedef signed int int32; +typedef unsigned int uint32; + +typedef vec2 vec2f; +typedef vec2 vec2d; +typedef vec2 vec2i; +typedef vec2 vec2ub; + +typedef vec3 vec3f; +typedef vec3 vec3d; +typedef vec3 vec3i; +typedef vec3 vec3ub; + +typedef vec4 vec4f; +typedef vec4 vec4d; +typedef vec4 vec4i; +typedef vec4 vec4ub; + +typedef quat quatf; +typedef quat quatd; + +typedef ray rayf; +typedef ray rayd; + +typedef plane planef; +typedef plane planed; + +typedef mat44 mat44f; +typedef mat44 mat44d; + +typedef frustum frustumf; +typedef frustum frustumd; + +template inline T intersect_plane_ray(const plane &pln, const vec3 &linept, const vec3 &linedir) +{ + T denom = pln.normal * linedir; + if (denom) { + return - (pln.normal * linept + pln.offset) / denom; + } else { + return (T)0; + } +} + + + diff -Nru trigger-rally-0.5.2.1/src/psim/psim.h trigger-rally-0.6.0/src/psim/psim.h --- trigger-rally-0.5.2.1/src/psim/psim.h 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/psim/psim.h 2011-10-07 17:10:01.000000000 +0000 @@ -1,175 +1,175 @@ - -// psim.h [psim] - -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net -// License: GPL version 2 (see included gpl.txt) - - -#include "../pengine/pengine.h" - -/* -#include -#include -#include -#include -#include -*/ - - -class PSim; -class PRigidBody; - -class PMotor; -class PGearbox; - -class ClipSet; -class ClipNode; -class ClipMesh; - -class PVehicleType; -class PVehicleTypePart; -class PVehicle; - - - -class PReferenceFrame { -public: - vec3f pos; - quatf ori; - - mat44f ori_mat, ori_mat_inv; - -public: - PReferenceFrame() : pos(vec3f::zero()), ori(quatf::identity()) { - updateMatrices(); - } - - void updateMatrices() { - ori.normalize(); - ori_mat = ori.getMatrix(); - ori_mat_inv = ori_mat.transpose(); - } - - void setPosition(const vec3f &_pos) { pos = _pos; } - vec3f getPosition() { return pos; } - - void setOrientation(const quatf &_ori) { ori = _ori; } - quatf getOrientation() { return ori; } - mat44f getOrientationMatrix() { return ori_mat; } - mat44f getInverseOrientationMatrix() { return ori_mat_inv; } - - vec3f getLocToWorldVector(const vec3f &pt) { - return ori_mat.transform1(pt); - } - vec3f getWorldToLocVector(const vec3f &pt) { - return ori_mat.transform2(pt); - } - vec3f getLocToWorldPoint(const vec3f &pt) { - return pos + ori_mat.transform1(pt); - } - vec3f getWorldToLocPoint(const vec3f &pt) { - return ori_mat.transform2(pt - pos); - } -}; - - -class PRigidBody : public PReferenceFrame { -private: - - PSim ∼ - - // config - float mass, mass_inv; - vec3f angmass, angmass_inv; // inertial tensor approximation - - // state - vec3f linvel; - vec3f angvel; - - vec3f accum_force; - vec3f accum_torque; - - // TODO: intelligent friction calc - -public: - PRigidBody(PSim &sim_parent); - ~PRigidBody(); - -public: - void setMassCuboid(float _mass, const vec3f &dim); - - void setLinearVel(const vec3f &vel) { linvel = vel; } - const vec3f &getLinearVel() { return linvel; } - - void setAngularVel(const vec3f &vel) { angvel = vel; } - const vec3f &getAngularVel() { return angvel; } - - void addForce(const vec3f &frc); - void addLocForce(const vec3f &frc); - void addForceAtPoint(const vec3f &frc, const vec3f &pt); - void addLocForceAtPoint(const vec3f &frc, const vec3f &pt); - void addForceAtLocPoint(const vec3f &frc, const vec3f &pt); - void addLocForceAtLocPoint(const vec3f &frc, const vec3f &pt); - - void addTorque(const vec3f &trq); - void addLocTorque(const vec3f &trq); - - vec3f getLinearVelAtPoint(const vec3f &pt); - vec3f getLinearVelAtLocPoint(const vec3f &pt); - - void tick(float delta); - - friend class PSim; -}; - - - - -#include "vehicle.h" - - - -class PSim { -private: - - PTerrain *terrain; - - PResourceList vtypelist; - - std::vector body; - - std::vector vehicle; - - vec3f gravity; - -public: - PSim(); - ~PSim(); - -public: - void setTerrain(PTerrain *_terrain) { terrain = _terrain; } - - void setGravity(const vec3f &_gravity) { gravity = _gravity; } - - PVehicleType *loadVehicleType(const std::string &filename, PSSModel &ssModel); - - PRigidBody *createRigidBody(); - - PVehicle *createVehicle(TiXmlElement *element, const std::string &filepath, PSSModel &ssModel); - PVehicle *createVehicle(const std::string &type, const vec3f &pos, const quatf &ori, const std::string &filepath, PSSModel &ssModel); - PVehicle *createVehicle(PVehicleType *type, const vec3f &pos, const quatf &ori, PSSModel &ssModel); - - // Remove all bodies and vehicles - void clear(); - - // Step the simulation delta seconds - void tick(float delta); - - - PTerrain *getTerrain() { return terrain; } - -public: - - friend class PRigidBody; - friend class PVehicle; -}; + +// psim.h [psim] + +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net +// License: GPL version 2 (see included gpl.txt) + + +#include "../pengine/pengine.h" + +/* +#include +#include +#include +#include +#include +*/ + + +class PSim; +class PRigidBody; + +class PMotor; +class PGearbox; + +class ClipSet; +class ClipNode; +class ClipMesh; + +class PVehicleType; +class PVehicleTypePart; +class PVehicle; + + + +class PReferenceFrame { +public: + vec3f pos; + quatf ori; + + mat44f ori_mat, ori_mat_inv; + +public: + PReferenceFrame() : pos(vec3f::zero()), ori(quatf::identity()) { + updateMatrices(); + } + + void updateMatrices() { + ori.normalize(); + ori_mat = ori.getMatrix(); + ori_mat_inv = ori_mat.transpose(); + } + + void setPosition(const vec3f &_pos) { pos = _pos; } + vec3f getPosition() { return pos; } + + void setOrientation(const quatf &_ori) { ori = _ori; } + quatf getOrientation() { return ori; } + mat44f getOrientationMatrix() { return ori_mat; } + mat44f getInverseOrientationMatrix() { return ori_mat_inv; } + + vec3f getLocToWorldVector(const vec3f &pt) { + return ori_mat.transform1(pt); + } + vec3f getWorldToLocVector(const vec3f &pt) { + return ori_mat.transform2(pt); + } + vec3f getLocToWorldPoint(const vec3f &pt) { + return pos + ori_mat.transform1(pt); + } + vec3f getWorldToLocPoint(const vec3f &pt) { + return ori_mat.transform2(pt - pos); + } +}; + + +class PRigidBody : public PReferenceFrame { +private: + + PSim ∼ + + // config + float mass, mass_inv; + vec3f angmass, angmass_inv; // inertial tensor approximation + + // state + vec3f linvel; + vec3f angvel; + + vec3f accum_force; + vec3f accum_torque; + + // TODO: intelligent friction calc + +public: + PRigidBody(PSim &sim_parent); + ~PRigidBody(); + +public: + void setMassCuboid(float _mass, const vec3f &dim); + + void setLinearVel(const vec3f &vel) { linvel = vel; } + const vec3f &getLinearVel() { return linvel; } + + void setAngularVel(const vec3f &vel) { angvel = vel; } + const vec3f &getAngularVel() { return angvel; } + + void addForce(const vec3f &frc); + void addLocForce(const vec3f &frc); + void addForceAtPoint(const vec3f &frc, const vec3f &pt); + void addLocForceAtPoint(const vec3f &frc, const vec3f &pt); + void addForceAtLocPoint(const vec3f &frc, const vec3f &pt); + void addLocForceAtLocPoint(const vec3f &frc, const vec3f &pt); + + void addTorque(const vec3f &trq); + void addLocTorque(const vec3f &trq); + + vec3f getLinearVelAtPoint(const vec3f &pt); + vec3f getLinearVelAtLocPoint(const vec3f &pt); + + void tick(float delta); + + friend class PSim; +}; + + + + +#include "vehicle.h" + + + +class PSim { +private: + + PTerrain *terrain; + + PResourceList vtypelist; + + std::vector body; + + std::vector vehicle; + + vec3f gravity; + +public: + PSim(); + ~PSim(); + +public: + void setTerrain(PTerrain *_terrain) { terrain = _terrain; } + + void setGravity(const vec3f &_gravity) { gravity = _gravity; } + + PVehicleType *loadVehicleType(const std::string &filename, PSSModel &ssModel); + + PRigidBody *createRigidBody(); + + PVehicle *createVehicle(TiXmlElement *element, const std::string &filepath, PSSModel &ssModel); + PVehicle *createVehicle(const std::string &type, const vec3f &pos, const quatf &ori, const std::string &filepath, PSSModel &ssModel); + PVehicle *createVehicle(PVehicleType *type, const vec3f &pos, const quatf &ori, PSSModel &ssModel); + + // Remove all bodies and vehicles + void clear(); + + // Step the simulation delta seconds + void tick(float delta); + + + PTerrain *getTerrain() { return terrain; } + +public: + + friend class PRigidBody; + friend class PVehicle; +}; diff -Nru trigger-rally-0.5.2.1/src/psim/rigidbody.cpp trigger-rally-0.6.0/src/psim/rigidbody.cpp --- trigger-rally-0.5.2.1/src/psim/rigidbody.cpp 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/psim/rigidbody.cpp 2011-10-07 17:10:01.000000000 +0000 @@ -1,166 +1,166 @@ - -// rigidbody.cpp [psim] - -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net -// License: GPL version 2 (see included gpl.txt) - -#include "psim.h" - - - - -PRigidBody::PRigidBody(PSim &sim_parent) : PReferenceFrame(), sim(sim_parent) -{ - linvel = vec3f::zero(); - angvel = vec3f::zero(); - - mass = 1.0; - mass_inv = 1.0; - angmass = vec3f(1.0,1.0,1.0); - angmass_inv = vec3f(1.0,1.0,1.0); - - accum_force = vec3f::zero(); - accum_torque = vec3f::zero(); -} - -PRigidBody::~PRigidBody() -{ -} - - -void PRigidBody::setMassCuboid(float _mass, const vec3f &rad) -{ - if (mass <= 0.0 || - rad.x <= 0.0 || - rad.y <= 0.0 || - rad.z <= 0.0) return; - - mass = _mass; - mass_inv = 1.0 / mass; - -#if 1 - angmass = vec3f(rad.y*rad.z, rad.z*rad.x, rad.x*rad.y) * (mass * 0.4); -#else - angmass = vec3f(1.0, 1.0, 1.0) * (mass * 4.0); -#endif - - angmass_inv.x = 1.0 / angmass.x; - angmass_inv.y = 1.0 / angmass.y; - angmass_inv.z = 1.0 / angmass.z; -} - - -void PRigidBody::addForce(const vec3f &frc) -{ - accum_force += frc; -} - -void PRigidBody::addLocForce(const vec3f &frc) -{ - addForce(getLocToWorldVector(frc)); -} - -void PRigidBody::addForceAtPoint(const vec3f &frc, const vec3f &pt) -{ - accum_force += frc; - - vec3f wdiff = pt - pos; - - accum_torque += frc ^ wdiff; - //accum_torque -= wdiff ^ frc; -} - -void PRigidBody::addLocForceAtPoint(const vec3f &frc, const vec3f &pt) -{ - addForceAtPoint(getLocToWorldVector(frc), pt); -} - -void PRigidBody::addForceAtLocPoint(const vec3f &frc, const vec3f &pt) -{ - addForceAtPoint(frc, getLocToWorldPoint(pt)); -} - -void PRigidBody::addLocForceAtLocPoint(const vec3f &frc, const vec3f &pt) -{ - addForceAtPoint(getLocToWorldVector(frc), getLocToWorldPoint(pt)); -} - -void PRigidBody::addTorque(const vec3f &trq) -{ - accum_torque += trq; -} - -void PRigidBody::addLocTorque(const vec3f &trq) -{ - addTorque(getLocToWorldVector(trq)); -} - -vec3f PRigidBody::getLinearVelAtPoint(const vec3f &pt) -{ - vec3f usept = pt - pos; - return (linvel + (usept ^ angvel)); -} - -vec3f PRigidBody::getLinearVelAtLocPoint(const vec3f &pt) -{ - return getLinearVelAtPoint(getLocToWorldPoint(pt)); -} - - -//#define CLAMPVEL - -void PRigidBody::tick(float delta) -{ - linvel += (accum_force * mass_inv + sim.gravity) * delta; - -#ifdef CLAMPVEL - CLAMP(linvel.x, -20.0, 20.0); - CLAMP(linvel.y, -20.0, 20.0); - CLAMP(linvel.z, -20.0, 20.0); -#endif - - pos += linvel * delta; - -#if 0 - mat44f ori_mat2; - ori_mat2.assemble( - vec3f(ori_mat.row[0][0]*0.5+0.5, ori_mat.row[0][1]*0.5+0.5, ori_mat.row[0][2]*0.5+0.5), - vec3f(ori_mat.row[1][0]*0.5+0.5, ori_mat.row[1][1]*0.5+0.5, ori_mat.row[1][2]*0.5+0.5), - vec3f(ori_mat.row[2][0]*0.5+0.5, ori_mat.row[2][1]*0.5+0.5, ori_mat.row[2][2]*0.5+0.5)); - - vec3f angmass_inv_world = ori_mat2.transform2(angmass_inv); -#else - vec3f angmass_inv_world = angmass_inv; -#endif - - vec3f ang_accel = vec3f( - accum_torque.x * angmass_inv_world.x, - accum_torque.y * angmass_inv_world.y, - accum_torque.z * angmass_inv_world.z); - - angvel += ang_accel * delta; - -#ifdef CLAMPVEL - CLAMP(angvel.x, -20.0, 20.0); - CLAMP(angvel.y, -20.0, 20.0); - CLAMP(angvel.z, -20.0, 20.0); -#endif - - quatf angdelta; - angdelta.fromThreeAxisAngle(angvel * delta); - - ori = ori * angdelta; - //ori = angdelta * ori; - - //PULLTOWARD(linvel, vec3f::zero(), delta * 0.1); - //PULLTOWARD(angvel, vec3f::zero(), delta * 0.1); - - accum_force = vec3f::zero(); - accum_torque = vec3f::zero(); - - PReferenceFrame::updateMatrices(); -} - - - - + +// rigidbody.cpp [psim] + +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net +// License: GPL version 2 (see included gpl.txt) + +#include "psim.h" + + + + +PRigidBody::PRigidBody(PSim &sim_parent) : PReferenceFrame(), sim(sim_parent) +{ + linvel = vec3f::zero(); + angvel = vec3f::zero(); + + mass = 1.0; + mass_inv = 1.0; + angmass = vec3f(1.0,1.0,1.0); + angmass_inv = vec3f(1.0,1.0,1.0); + + accum_force = vec3f::zero(); + accum_torque = vec3f::zero(); +} + +PRigidBody::~PRigidBody() +{ +} + + +void PRigidBody::setMassCuboid(float _mass, const vec3f &rad) +{ + if (mass <= 0.0 || + rad.x <= 0.0 || + rad.y <= 0.0 || + rad.z <= 0.0) return; + + mass = _mass; + mass_inv = 1.0 / mass; + +#if 1 + angmass = vec3f(rad.y*rad.z, rad.z*rad.x, rad.x*rad.y) * (mass * 0.4); +#else + angmass = vec3f(1.0, 1.0, 1.0) * (mass * 4.0); +#endif + + angmass_inv.x = 1.0 / angmass.x; + angmass_inv.y = 1.0 / angmass.y; + angmass_inv.z = 1.0 / angmass.z; +} + + +void PRigidBody::addForce(const vec3f &frc) +{ + accum_force += frc; +} + +void PRigidBody::addLocForce(const vec3f &frc) +{ + addForce(getLocToWorldVector(frc)); +} + +void PRigidBody::addForceAtPoint(const vec3f &frc, const vec3f &pt) +{ + accum_force += frc; + + vec3f wdiff = pt - pos; + + accum_torque += frc ^ wdiff; + //accum_torque -= wdiff ^ frc; +} + +void PRigidBody::addLocForceAtPoint(const vec3f &frc, const vec3f &pt) +{ + addForceAtPoint(getLocToWorldVector(frc), pt); +} + +void PRigidBody::addForceAtLocPoint(const vec3f &frc, const vec3f &pt) +{ + addForceAtPoint(frc, getLocToWorldPoint(pt)); +} + +void PRigidBody::addLocForceAtLocPoint(const vec3f &frc, const vec3f &pt) +{ + addForceAtPoint(getLocToWorldVector(frc), getLocToWorldPoint(pt)); +} + +void PRigidBody::addTorque(const vec3f &trq) +{ + accum_torque += trq; +} + +void PRigidBody::addLocTorque(const vec3f &trq) +{ + addTorque(getLocToWorldVector(trq)); +} + +vec3f PRigidBody::getLinearVelAtPoint(const vec3f &pt) +{ + vec3f usept = pt - pos; + return (linvel + (usept ^ angvel)); +} + +vec3f PRigidBody::getLinearVelAtLocPoint(const vec3f &pt) +{ + return getLinearVelAtPoint(getLocToWorldPoint(pt)); +} + + +//#define CLAMPVEL + +void PRigidBody::tick(float delta) +{ + linvel += (accum_force * mass_inv + sim.gravity) * delta; + +#ifdef CLAMPVEL + CLAMP(linvel.x, -20.0, 20.0); + CLAMP(linvel.y, -20.0, 20.0); + CLAMP(linvel.z, -20.0, 20.0); +#endif + + pos += linvel * delta; + +#if 0 + mat44f ori_mat2; + ori_mat2.assemble( + vec3f(ori_mat.row[0][0]*0.5+0.5, ori_mat.row[0][1]*0.5+0.5, ori_mat.row[0][2]*0.5+0.5), + vec3f(ori_mat.row[1][0]*0.5+0.5, ori_mat.row[1][1]*0.5+0.5, ori_mat.row[1][2]*0.5+0.5), + vec3f(ori_mat.row[2][0]*0.5+0.5, ori_mat.row[2][1]*0.5+0.5, ori_mat.row[2][2]*0.5+0.5)); + + vec3f angmass_inv_world = ori_mat2.transform2(angmass_inv); +#else + vec3f angmass_inv_world = angmass_inv; +#endif + + vec3f ang_accel = vec3f( + accum_torque.x * angmass_inv_world.x, + accum_torque.y * angmass_inv_world.y, + accum_torque.z * angmass_inv_world.z); + + angvel += ang_accel * delta; + +#ifdef CLAMPVEL + CLAMP(angvel.x, -20.0, 20.0); + CLAMP(angvel.y, -20.0, 20.0); + CLAMP(angvel.z, -20.0, 20.0); +#endif + + quatf angdelta; + angdelta.fromThreeAxisAngle(angvel * delta); + + ori = ori * angdelta; + //ori = angdelta * ori; + + //PULLTOWARD(linvel, vec3f::zero(), delta * 0.1); + //PULLTOWARD(angvel, vec3f::zero(), delta * 0.1); + + accum_force = vec3f::zero(); + accum_torque = vec3f::zero(); + + PReferenceFrame::updateMatrices(); +} + + + + diff -Nru trigger-rally-0.5.2.1/src/psim/sim.cpp trigger-rally-0.6.0/src/psim/sim.cpp --- trigger-rally-0.5.2.1/src/psim/sim.cpp 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/psim/sim.cpp 2011-10-07 17:10:01.000000000 +0000 @@ -1,7 +1,7 @@ // psim.cpp [psim] -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net // License: GPL version 2 (see included gpl.txt) #include "psim.h" @@ -15,124 +15,124 @@ PSim::~PSim() { - clear(); + clear(); } PVehicleType *PSim::loadVehicleType(const std::string &filename, PSSModel &ssModel) { - PVehicleType *vtype = vtypelist.find(filename); - if (!vtype) { - vtype = new PVehicleType(); - if (!vtype->load(filename, ssModel)) { - if (PUtil::isDebugLevel(DEBUGLEVEL_ENDUSER)) - PUtil::outLog() << "Failed to load " << filename << "\n"; - return null; - } - vtypelist.add(vtype); - } - return vtype; + PVehicleType *vtype = vtypelist.find(filename); + if (!vtype) { + vtype = new PVehicleType(); + if (!vtype->load(filename, ssModel)) { + if (PUtil::isDebugLevel(DEBUGLEVEL_ENDUSER)) + PUtil::outLog() << "Failed to load " << filename << "\n"; + return null; + } + vtypelist.add(vtype); + } + return vtype; } PRigidBody *PSim::createRigidBody() { - PRigidBody *newbody = new PRigidBody(*this); + PRigidBody *newbody = new PRigidBody(*this); - body.push_back(newbody); + body.push_back(newbody); - return newbody; + return newbody; } PVehicle *PSim::createVehicle(TiXmlElement *element, const std::string &filepath, PSSModel &ssModel) { - const char *val; - - const char *type = element->Attribute("type"); - if (!type) { - PUtil::outLog() << "Vehicle has no type\n"; - return null; - } - - vec3f pos = vec3f::zero(); - - val = element->Attribute("pos"); - if (val) sscanf(val, "%f , %f , %f", &pos.x, &pos.y, &pos.z); - - quatf ori = quatf::identity(); - - val = element->Attribute("ori"); - if (val) sscanf(val, "%f , %f , %f , %f", &ori.w, &ori.x, &ori.y, &ori.z); - - return createVehicle(type, pos, ori, filepath, ssModel); + const char *val; + + const char *type = element->Attribute("type"); + if (!type) { + PUtil::outLog() << "Vehicle has no type\n"; + return null; + } + + vec3f pos = vec3f::zero(); + + val = element->Attribute("pos"); + if (val) sscanf(val, "%f , %f , %f", &pos.x, &pos.y, &pos.z); + + quatf ori = quatf::identity(); + + val = element->Attribute("ori"); + if (val) sscanf(val, "%f , %f , %f , %f", &ori.w, &ori.x, &ori.y, &ori.z); + + return createVehicle(type, pos, ori, filepath, ssModel); } PVehicle *PSim::createVehicle(const std::string &type, const vec3f &pos, const quatf &ori, const std::string &filepath, PSSModel &ssModel) { - PVehicleType *vtype = loadVehicleType(PUtil::assemblePath(type, filepath), ssModel); - - return createVehicle(vtype, pos, ori, ssModel); + PVehicleType *vtype = loadVehicleType(PUtil::assemblePath(type, filepath), ssModel); + + return createVehicle(vtype, pos, ori, ssModel); } PVehicle *PSim::createVehicle(PVehicleType *type, const vec3f &pos, const quatf &ori, PSSModel &ssModel) { - PSSModel *unused = &ssModel; unused = unused; - - if (!type) return null; - - PVehicle *newvehicle = new PVehicle(*this, type); - - vec3f vpos = pos; - if (terrain) vpos.z += terrain->getHeight(vpos.x, vpos.y); - newvehicle->getBody().setPosition(vpos); - - newvehicle->getBody().setOrientation(ori); - newvehicle->getBody().updateMatrices(); - - newvehicle->updateParts(); - - vehicle.push_back(newvehicle); - return newvehicle; + PSSModel *unused = &ssModel; unused = unused; + + if (!type) return null; + + PVehicle *newvehicle = new PVehicle(*this, type); + + vec3f vpos = pos; + if (terrain) vpos.z += terrain->getHeight(vpos.x, vpos.y); + newvehicle->getBody().setPosition(vpos); + + newvehicle->getBody().setOrientation(ori); + newvehicle->getBody().updateMatrices(); + + newvehicle->updateParts(); + + vehicle.push_back(newvehicle); + return newvehicle; } void PSim::clear() { - for (unsigned int i=0; itick(timeslice); - } - - for (unsigned int i=0; itick(timeslice); - } - - for (unsigned int i=0; iupdateParts(); - } - } + float timeslice = 0.005; + int num = (int)(delta / timeslice) + 1; + timeslice = delta / (float)num; + + for (int timestep=0; timesteptick(timeslice); + } + + for (unsigned int i=0; itick(timeslice); + } + + for (unsigned int i=0; iupdateParts(); + } + } } diff -Nru trigger-rally-0.5.2.1/src/psim/vehicle.cpp trigger-rally-0.6.0/src/psim/vehicle.cpp --- trigger-rally-0.5.2.1/src/psim/vehicle.cpp 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/psim/vehicle.cpp 2011-10-07 17:10:01.000000000 +0000 @@ -1,7 +1,7 @@ // vehicle.cpp -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net // License: GPL version 2 (see included gpl.txt) #include "psim.h" @@ -13,94 +13,94 @@ float PDriveSystem::getPowerAtRPS(float rps) { - unsigned int p; - float power; - - // find which curve points rps lies between - for (p = 0; p < powercurve.size() && powercurve[p].x < rps; p++); - - if (p == 0) { - // to the left of the graph - power = powercurve[0].y * (rps / powercurve[0].x); - } else if (p < powercurve.size()) { - // on the graph - power = powercurve[p-1].y + (powercurve[p].y - powercurve[p-1].y) * - ( (rps - powercurve[p-1].x) / (powercurve[p].x - powercurve[p-1].x) ); - } else { - // to the right of the graph - power = powercurve[p-1].y + (0.0f - powercurve[p-1].y) * - ( (rps - powercurve[p-1].x) / (powercurve.back().x - powercurve[p-1].x) ); - } - - return power; + unsigned int p; + float power; + + // find which curve points rps lies between + for (p = 0; p < powercurve.size() && powercurve[p].x < rps; p++); + + if (p == 0) { + // to the left of the graph + power = powercurve[0].y * (rps / powercurve[0].x); + } else if (p < powercurve.size()) { + // on the graph + power = powercurve[p-1].y + (powercurve[p].y - powercurve[p-1].y) * + ( (rps - powercurve[p-1].x) / (powercurve[p].x - powercurve[p-1].x) ); + } else { + // to the right of the graph + power = powercurve[p-1].y + (0.0f - powercurve[p-1].y) * + ( (rps - powercurve[p-1].x) / (powercurve.back().x - powercurve[p-1].x) ); + } + + return power; } void PDriveSystemInstance::tick(float delta, float throttle, float wheel_rps) { - rps = wheel_rps * dsys->gear[currentgear].y; - - bool wasreverse = reverse; - reverse = (throttle < 0.0f); - - if (wasreverse != reverse) flag_gearchange = true; - - if (reverse) { - rps *= -1.0f; - throttle *= -1.0f; - } - - CLAMP_UPPER(throttle, 1.0f); - CLAMP(rps, dsys->minRPS, dsys->maxRPS); - - if (reverse) { - currentgear = 0; - } - - out_torque = dsys->getPowerAtRPS(rps) * dsys->gear[currentgear].y / rps; - - if (!reverse) { - int newtarget_rel = 0; - - if (currentgear < (int)dsys->gear.size()-1) { - float nextrate = rps / dsys->gear[currentgear].y * dsys->gear[currentgear+1].y; - CLAMP(nextrate, dsys->minRPS, dsys->maxRPS); - float nexttorque = dsys->getPowerAtRPS(nextrate) * dsys->gear[currentgear+1].y / nextrate; - if (nexttorque > out_torque) - newtarget_rel = 1; - } - - // don't test for down if already decided to go up - if (currentgear > 0 && newtarget_rel == 0) { - float nextrate = rps / dsys->gear[currentgear].y * dsys->gear[currentgear-1].y; - CLAMP(nextrate, dsys->minRPS, dsys->maxRPS); - float nexttorque = dsys->getPowerAtRPS(nextrate) * dsys->gear[currentgear-1].y / nextrate; - if (nexttorque > out_torque) - newtarget_rel = -1; - } - - if (newtarget_rel != 0 && newtarget_rel == targetgear_rel) { - if ((gearch -= delta) <= 0.0f) - { - float nextrate = rps / dsys->gear[currentgear].y * dsys->gear[currentgear + targetgear_rel].y; - CLAMP(nextrate, dsys->minRPS, dsys->maxRPS); - out_torque = dsys->getPowerAtRPS(nextrate) * dsys->gear[currentgear + targetgear_rel].y / nextrate; - currentgear += targetgear_rel; - gearch = dsys->gearch_repeat; - flag_gearchange = true; - } - } else { - gearch = dsys->gearch_first; - targetgear_rel = newtarget_rel; - } - } - - out_torque *= throttle; - - if (reverse) { - out_torque *= -1.0; - } - - out_torque -= wheel_rps * 0.1f; + rps = wheel_rps * dsys->gear[currentgear].y; + + bool wasreverse = reverse; + reverse = (throttle < 0.0f); + + if (wasreverse != reverse) flag_gearchange = true; + + if (reverse) { + rps *= -1.0f; + throttle *= -1.0f; + } + + CLAMP_UPPER(throttle, 1.0f); + CLAMP(rps, dsys->minRPS, dsys->maxRPS); + + if (reverse) { + currentgear = 0; + } + + out_torque = dsys->getPowerAtRPS(rps) * dsys->gear[currentgear].y / rps; + + if (!reverse) { + int newtarget_rel = 0; + + if (currentgear < (int)dsys->gear.size()-1) { + float nextrate = rps / dsys->gear[currentgear].y * dsys->gear[currentgear+1].y; + CLAMP(nextrate, dsys->minRPS, dsys->maxRPS); + float nexttorque = dsys->getPowerAtRPS(nextrate) * dsys->gear[currentgear+1].y / nextrate; + if (nexttorque > out_torque) + newtarget_rel = 1; + } + + // don't test for down if already decided to go up + if (currentgear > 0 && newtarget_rel == 0) { + float nextrate = rps / dsys->gear[currentgear].y * dsys->gear[currentgear-1].y; + CLAMP(nextrate, dsys->minRPS, dsys->maxRPS); + float nexttorque = dsys->getPowerAtRPS(nextrate) * dsys->gear[currentgear-1].y / nextrate; + if (nexttorque > out_torque) + newtarget_rel = -1; + } + + if (newtarget_rel != 0 && newtarget_rel == targetgear_rel) { + if ((gearch -= delta) <= 0.0f) + { + float nextrate = rps / dsys->gear[currentgear].y * dsys->gear[currentgear + targetgear_rel].y; + CLAMP(nextrate, dsys->minRPS, dsys->maxRPS); + out_torque = dsys->getPowerAtRPS(nextrate) * dsys->gear[currentgear + targetgear_rel].y / nextrate; + currentgear += targetgear_rel; + gearch = dsys->gearch_repeat; + flag_gearchange = true; + } + } else { + gearch = dsys->gearch_first; + targetgear_rel = newtarget_rel; + } + } + + out_torque *= throttle; + + if (reverse) { + out_torque *= -1.0; + } + + out_torque -= wheel_rps * 0.1f; } @@ -109,373 +109,373 @@ bool PVehicleType::load(const std::string &filename, PSSModel &ssModel) { - if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) - PUtil::outLog() << "Loading vehicle type \"" << filename << "\"\n"; + if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) + PUtil::outLog() << "Loading vehicle type \"" << filename << "\"\n"; - name = filename; + name = filename; - unload(); + unload(); - // defaults + // defaults - proper_name = "Vehicle"; - - mass = 1.0; - dims = vec3f(1.0,1.0,1.0); - - wheelscale = 1.0; - wheelmodel = null; - - ctrlrate.setDefaultRates(); - - param.speed = 0.0; - param.turnspeed = vec3f::zero(); - param.turnspeed_a = 1.0; - param.turnspeed_b = 0.0; - param.drag = vec3f::zero(); - param.angdrag = 0.0; - param.lift = vec2f::zero(); - param.fineffect = vec2f::zero(); - - float allscale = 1.0; - - float drive_total = 0.0f; - - wheel_speed_multiplier = 0.0f; - - // - - TiXmlDocument xmlfile(filename.c_str()); - TiXmlElement *rootelem = PUtil::loadRootElement(xmlfile, "vehicle"); - if (!rootelem) { - PUtil::outLog() << "Load failed: TinyXML error\n"; - return false; - } - - const char *val; - - val = rootelem->Attribute("name"); - if (val) proper_name = val; - - val = rootelem->Attribute("allscale"); - if (val) allscale = atof(val); - - val = rootelem->Attribute("type"); - if (!val || !strlen(val)) { - if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) - PUtil::outLog() << "Warning: element without type attribute\n"; - return false; - } - - // VEHICLE TYPE POINT - - if (false) ; - else if (!strcmp(val, "tank")) coretype = VCTYPE_TANK; - else if (!strcmp(val, "helicopter")) coretype = VCTYPE_HELICOPTER; - else if (!strcmp(val, "plane")) coretype = VCTYPE_PLANE; - else if (!strcmp(val, "hovercraft")) coretype = VCTYPE_HOVERCRAFT; - else if (!strcmp(val, "car")) coretype = VCTYPE_CAR; - else { - if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) - PUtil::outLog() << "Error: has unrecognised type \"" << val << "\"\n"; - return false; - } - - for (TiXmlElement *walk = rootelem->FirstChildElement(); - walk; walk = walk->NextSiblingElement()) { - - if (false) { - } else if (!strcmp(walk->Value(), "genparams")) { - - val = walk->Attribute("mass"); - if (val) mass = atof(val); - - val = walk->Attribute("dimensions"); - if (val) { - sscanf(val, "%f , %f , %f", &dims.x, &dims.y, &dims.z); - dims *= allscale; - } - - val = walk->Attribute("wheelscale"); - if (val) wheelscale = atof(val); - - val = walk->Attribute("wheelmodel"); - if (val) wheelmodel = ssModel.loadModel(PUtil::assemblePath(val, filename)); - - } else if (!strcmp(walk->Value(), "ctrlparams")) { - - val = walk->Attribute("speed"); - if (val) param.speed = atof(val); - - val = walk->Attribute("turnspeed"); - if (val) sscanf(val, "%f , %f , %f", ¶m.turnspeed.x, ¶m.turnspeed.y, ¶m.turnspeed.z); - - val = walk->Attribute("drag"); - if (val) sscanf(val, "%f , %f , %f", ¶m.drag.x, ¶m.drag.y, ¶m.drag.z); - - val = walk->Attribute("angdrag"); - if (val) param.angdrag = atof(val); - - val = walk->Attribute("lift"); - if (val) sscanf(val, "%f , %f", ¶m.lift.x, ¶m.lift.y); - - - val = walk->Attribute("speedrate"); - if (val) ctrlrate.throttle = atof(val); - - val = walk->Attribute("turnspeedrate"); - if (val) sscanf(val, "%f , %f , %f", &ctrlrate.turn.x, &ctrlrate.turn.y, &ctrlrate.turn.z); - - val = walk->Attribute("turnspeedcoefficients"); - if (val) sscanf(val, "%f , %f", ¶m.turnspeed_a, ¶m.turnspeed_b); - - val = walk->Attribute("fineffect"); - if (val) sscanf(val, "%f , %f", ¶m.fineffect.x, ¶m.fineffect.y); - - } else if (!strcmp(walk->Value(), "drivesystem")) { - - for (TiXmlElement *walk2 = walk->FirstChildElement(); - walk2; walk2 = walk2->NextSiblingElement()) { - if (!strcmp(walk2->Value(), "engine")) { - - float powerscale = 1.0f; - - val = walk2->Attribute("powerscale"); - if (val) powerscale = atof(val); - - for (TiXmlElement *walk3 = walk2->FirstChildElement(); - walk3; walk3 = walk3->NextSiblingElement()) { - - if (!strcmp(walk3->Value(), "powerpoint")) { - - float in_rpm, in_power; - - val = walk3->Attribute("rpm"); - if (!val) { - PUtil::outLog() << "Warning: failed to read engine RPM value\n"; - continue; - } - in_rpm = atof(val); - - val = walk3->Attribute("power"); - if (!val) { - PUtil::outLog() << "Warning: failed to read engine power value\n"; - continue; - } - in_power = atof(val); - - dsys.addPowerCurvePoint(in_rpm, in_power * powerscale); - } - } - - } else if (!strcmp(walk2->Value(), "gearbox")) { - - for (TiXmlElement *walk3 = walk2->FirstChildElement(); - walk3; walk3 = walk3->NextSiblingElement()) { - - if (!strcmp(walk3->Value(), "gear")) { - - val = walk3->Attribute("absolute"); - if (val) { - dsys.addGear(atof(val)); - } else { - val = walk3->Attribute("relative"); - if (!val) { - PUtil::outLog() << "Warning: gear has neither absolute nor relative value\n"; - continue; - } - - if (!dsys.hasGears()) { - PUtil::outLog() << "Warning: first gear cannot use relative value\n"; - continue; - } - - dsys.addGear(dsys.getLastGearRatio() * atof(val)); - } - } - } - - } - } - - } else if (!strcmp(walk->Value(), "part")) { - part.push_back(PVehicleTypePart()); - PVehicleTypePart *vtp = &part.back(); - - vtp->parent = -1; - //vtp->ref_local.setPosition(vec3f::zero()); - //vtp->ref_local.setOrientation(vec3f::zero()); - vtp->model = null; - vtp->scale = 1.0; - - val = walk->Attribute("name"); - if (val) vtp->name = val; - - val = walk->Attribute("parent"); - if (val) vtp->parentname = val; - - val = walk->Attribute("pos"); - if (val) { - vec3f pos; - if (sscanf(val, "%f , %f , %f", &pos.x, &pos.y, &pos.z) == 3) - vtp->ref_local.setPosition(pos * allscale); - } - - val = walk->Attribute("ori"); - if (val) { - quatf ori; - // note: w first, as per usual mathematical notation - if (sscanf(val, "%f , %f , %f , %f", &ori.w, &ori.x, &ori.y, &ori.z) == 3) - vtp->ref_local.setOrientation(ori); - } - - val = walk->Attribute("scale"); - if (val) vtp->scale = atof(val); - - val = walk->Attribute("model"); - if (val) vtp->model = ssModel.loadModel(PUtil::assemblePath(val, filename)); - - for (TiXmlElement *walk2 = walk->FirstChildElement(); - walk2; walk2 = walk2->NextSiblingElement()) { - if (!strcmp(walk2->Value(), "clip")) { - vehicle_clip_s vc; - - vc.force = 0.0f; - vc.dampening = 0.0f; - - val = walk2->Attribute("type"); - if (!val || !strlen(val)) { - if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) - PUtil::outLog() << "Warning: element without type attribute\n"; - continue; - } - - if (false) ; - else if (!strcmp(val, "body")) vc.type = VCLIP_BODY; - else if (!strcmp(val, "drive-left")) vc.type = VCLIP_DRIVE_LEFT; - else if (!strcmp(val, "drive-right")) vc.type = VCLIP_DRIVE_RIGHT; - else if (!strcmp(val, "hover")) vc.type = VCLIP_HOVER; - else { - if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) - PUtil::outLog() << "Warning: has unrecognised type \"" << val << "\"\n"; - continue; - } - - val = walk2->Attribute("pos"); - if (!val) { - if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) - PUtil::outLog() << "Warning: has no pos attribute\n"; - continue; - } - sscanf(val, "%f , %f , %f", &vc.pt.x, &vc.pt.y, &vc.pt.z); - vc.pt *= allscale; - - val = walk2->Attribute("force"); - if (val) vc.force = atof(val); - - val = walk2->Attribute("dampening"); - if (val) vc.dampening = atof(val); - - vtp->clip.push_back(vc); - } else if (!strcmp(walk2->Value(), "wheel")) { - PVehicleTypeWheel vtw; - - vtw.radius = 1.0f; - vtw.drive = 0.0f; - vtw.steer = 0.0f; - vtw.brake1 = 0.0f; - vtw.brake2 = 0.0f; - - vtw.force = 0.0f; - vtw.dampening = 0.0f; - - val = walk2->Attribute("pos"); - if (!val) { - if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) - PUtil::outLog() << "Warning: has no pos attribute\n"; - continue; - } - sscanf(val, "%f , %f , %f", &vtw.pt.x, &vtw.pt.y, &vtw.pt.z); - vtw.pt *= allscale; - - val = walk2->Attribute("radius"); - if (val) vtw.radius = atof(val); - - val = walk2->Attribute("drive"); - if (val) vtw.drive = atof(val); - - val = walk2->Attribute("steer"); - if (val) vtw.steer = atof(val); - - val = walk2->Attribute("brake1"); - if (val) vtw.brake1 = atof(val); - - val = walk2->Attribute("brake2"); - if (val) vtw.brake2 = atof(val); - - val = walk2->Attribute("force"); - if (val) vtw.force = atof(val); - - val = walk2->Attribute("dampening"); - if (val) vtw.dampening = atof(val); - - vtp->wheel.push_back(vtw); - drive_total += vtw.drive; - wheel_speed_multiplier += 1.0f; - } else if (!strcmp(walk2->Value(), "jetflame")) { - vtp->flame.push_back(PReferenceFrame()); - - val = walk2->Attribute("pos"); - if (val) { - vec3f pos; - if (sscanf(val, "%f , %f , %f", &pos.x, &pos.y, &pos.z) == 3) - vtp->flame.back().setPosition(pos * allscale); - } - - val = walk2->Attribute("ori"); - if (val) { - quatf ori; - if (sscanf(val, "%f , %f , %f , %f", &ori.w, &ori.x, &ori.y, &ori.z) == 4) - vtp->flame.back().setOrientation(ori); - } - } - } - - vtp->ref_local.updateMatrices(); - } - } - - for (unsigned int i=0; i 0) { - unsigned int j; - for (j=0; j= part.size() && - PUtil::isDebugLevel(DEBUGLEVEL_TEST)) - PUtil::outLog() << "Warning: part \"" << part[i].name << - "\" references non-existant parent \"" << part[i].parentname << "\"\n"; - } - } - - if (drive_total > 0.0f) - inverse_drive_total = 1.0f / drive_total; - else - inverse_drive_total = 0.0f; - - if (wheel_speed_multiplier > 0.0f) - wheel_speed_multiplier = 1.0f / wheel_speed_multiplier; - - return true; + proper_name = "Vehicle"; + + mass = 1.0; + dims = vec3f(1.0,1.0,1.0); + + wheelscale = 1.0; + wheelmodel = null; + + ctrlrate.setDefaultRates(); + + param.speed = 0.0; + param.turnspeed = vec3f::zero(); + param.turnspeed_a = 1.0; + param.turnspeed_b = 0.0; + param.drag = vec3f::zero(); + param.angdrag = 0.0; + param.lift = vec2f::zero(); + param.fineffect = vec2f::zero(); + + float allscale = 1.0; + + float drive_total = 0.0f; + + wheel_speed_multiplier = 0.0f; + + // + + TiXmlDocument xmlfile(filename.c_str()); + TiXmlElement *rootelem = PUtil::loadRootElement(xmlfile, "vehicle"); + if (!rootelem) { + PUtil::outLog() << "Load failed: TinyXML error\n"; + return false; + } + + const char *val; + + val = rootelem->Attribute("name"); + if (val) proper_name = val; + + val = rootelem->Attribute("allscale"); + if (val) allscale = atof(val); + + val = rootelem->Attribute("type"); + if (!val || !strlen(val)) { + if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) + PUtil::outLog() << "Warning: element without type attribute\n"; + return false; + } + + // VEHICLE TYPE POINT + + if (false) ; + else if (!strcmp(val, "tank")) coretype = VCTYPE_TANK; + else if (!strcmp(val, "helicopter")) coretype = VCTYPE_HELICOPTER; + else if (!strcmp(val, "plane")) coretype = VCTYPE_PLANE; + else if (!strcmp(val, "hovercraft")) coretype = VCTYPE_HOVERCRAFT; + else if (!strcmp(val, "car")) coretype = VCTYPE_CAR; + else { + if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) + PUtil::outLog() << "Error: has unrecognised type \"" << val << "\"\n"; + return false; + } + + for (TiXmlElement *walk = rootelem->FirstChildElement(); + walk; walk = walk->NextSiblingElement()) { + + if (false) { + } else if (!strcmp(walk->Value(), "genparams")) { + + val = walk->Attribute("mass"); + if (val) mass = atof(val); + + val = walk->Attribute("dimensions"); + if (val) { + sscanf(val, "%f , %f , %f", &dims.x, &dims.y, &dims.z); + dims *= allscale; + } + + val = walk->Attribute("wheelscale"); + if (val) wheelscale = atof(val); + + val = walk->Attribute("wheelmodel"); + if (val) wheelmodel = ssModel.loadModel(PUtil::assemblePath(val, filename)); + + } else if (!strcmp(walk->Value(), "ctrlparams")) { + + val = walk->Attribute("speed"); + if (val) param.speed = atof(val); + + val = walk->Attribute("turnspeed"); + if (val) sscanf(val, "%f , %f , %f", ¶m.turnspeed.x, ¶m.turnspeed.y, ¶m.turnspeed.z); + + val = walk->Attribute("drag"); + if (val) sscanf(val, "%f , %f , %f", ¶m.drag.x, ¶m.drag.y, ¶m.drag.z); + + val = walk->Attribute("angdrag"); + if (val) param.angdrag = atof(val); + + val = walk->Attribute("lift"); + if (val) sscanf(val, "%f , %f", ¶m.lift.x, ¶m.lift.y); + + + val = walk->Attribute("speedrate"); + if (val) ctrlrate.throttle = atof(val); + + val = walk->Attribute("turnspeedrate"); + if (val) sscanf(val, "%f , %f , %f", &ctrlrate.turn.x, &ctrlrate.turn.y, &ctrlrate.turn.z); + + val = walk->Attribute("turnspeedcoefficients"); + if (val) sscanf(val, "%f , %f", ¶m.turnspeed_a, ¶m.turnspeed_b); + + val = walk->Attribute("fineffect"); + if (val) sscanf(val, "%f , %f", ¶m.fineffect.x, ¶m.fineffect.y); + + } else if (!strcmp(walk->Value(), "drivesystem")) { + + for (TiXmlElement *walk2 = walk->FirstChildElement(); + walk2; walk2 = walk2->NextSiblingElement()) { + if (!strcmp(walk2->Value(), "engine")) { + + float powerscale = 1.0f; + + val = walk2->Attribute("powerscale"); + if (val) powerscale = atof(val); + + for (TiXmlElement *walk3 = walk2->FirstChildElement(); + walk3; walk3 = walk3->NextSiblingElement()) { + + if (!strcmp(walk3->Value(), "powerpoint")) { + + float in_rpm, in_power; + + val = walk3->Attribute("rpm"); + if (!val) { + PUtil::outLog() << "Warning: failed to read engine RPM value\n"; + continue; + } + in_rpm = atof(val); + + val = walk3->Attribute("power"); + if (!val) { + PUtil::outLog() << "Warning: failed to read engine power value\n"; + continue; + } + in_power = atof(val); + + dsys.addPowerCurvePoint(in_rpm, in_power * powerscale); + } + } + + } else if (!strcmp(walk2->Value(), "gearbox")) { + + for (TiXmlElement *walk3 = walk2->FirstChildElement(); + walk3; walk3 = walk3->NextSiblingElement()) { + + if (!strcmp(walk3->Value(), "gear")) { + + val = walk3->Attribute("absolute"); + if (val) { + dsys.addGear(atof(val)); + } else { + val = walk3->Attribute("relative"); + if (!val) { + PUtil::outLog() << "Warning: gear has neither absolute nor relative value\n"; + continue; + } + + if (!dsys.hasGears()) { + PUtil::outLog() << "Warning: first gear cannot use relative value\n"; + continue; + } + + dsys.addGear(dsys.getLastGearRatio() * atof(val)); + } + } + } + + } + } + + } else if (!strcmp(walk->Value(), "part")) { + part.push_back(PVehicleTypePart()); + PVehicleTypePart *vtp = &part.back(); + + vtp->parent = -1; + //vtp->ref_local.setPosition(vec3f::zero()); + //vtp->ref_local.setOrientation(vec3f::zero()); + vtp->model = null; + vtp->scale = 1.0; + + val = walk->Attribute("name"); + if (val) vtp->name = val; + + val = walk->Attribute("parent"); + if (val) vtp->parentname = val; + + val = walk->Attribute("pos"); + if (val) { + vec3f pos; + if (sscanf(val, "%f , %f , %f", &pos.x, &pos.y, &pos.z) == 3) + vtp->ref_local.setPosition(pos * allscale); + } + + val = walk->Attribute("ori"); + if (val) { + quatf ori; + // note: w first, as per usual mathematical notation + if (sscanf(val, "%f , %f , %f , %f", &ori.w, &ori.x, &ori.y, &ori.z) == 3) + vtp->ref_local.setOrientation(ori); + } + + val = walk->Attribute("scale"); + if (val) vtp->scale = atof(val); + + val = walk->Attribute("model"); + if (val) vtp->model = ssModel.loadModel(PUtil::assemblePath(val, filename)); + + for (TiXmlElement *walk2 = walk->FirstChildElement(); + walk2; walk2 = walk2->NextSiblingElement()) { + if (!strcmp(walk2->Value(), "clip")) { + vehicle_clip_s vc; + + vc.force = 0.0f; + vc.dampening = 0.0f; + + val = walk2->Attribute("type"); + if (!val || !strlen(val)) { + if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) + PUtil::outLog() << "Warning: element without type attribute\n"; + continue; + } + + if (false) ; + else if (!strcmp(val, "body")) vc.type = VCLIP_BODY; + else if (!strcmp(val, "drive-left")) vc.type = VCLIP_DRIVE_LEFT; + else if (!strcmp(val, "drive-right")) vc.type = VCLIP_DRIVE_RIGHT; + else if (!strcmp(val, "hover")) vc.type = VCLIP_HOVER; + else { + if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) + PUtil::outLog() << "Warning: has unrecognised type \"" << val << "\"\n"; + continue; + } + + val = walk2->Attribute("pos"); + if (!val) { + if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) + PUtil::outLog() << "Warning: has no pos attribute\n"; + continue; + } + sscanf(val, "%f , %f , %f", &vc.pt.x, &vc.pt.y, &vc.pt.z); + vc.pt *= allscale; + + val = walk2->Attribute("force"); + if (val) vc.force = atof(val); + + val = walk2->Attribute("dampening"); + if (val) vc.dampening = atof(val); + + vtp->clip.push_back(vc); + } else if (!strcmp(walk2->Value(), "wheel")) { + PVehicleTypeWheel vtw; + + vtw.radius = 1.0f; + vtw.drive = 0.0f; + vtw.steer = 0.0f; + vtw.brake1 = 0.0f; + vtw.brake2 = 0.0f; + + vtw.force = 0.0f; + vtw.dampening = 0.0f; + + val = walk2->Attribute("pos"); + if (!val) { + if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) + PUtil::outLog() << "Warning: has no pos attribute\n"; + continue; + } + sscanf(val, "%f , %f , %f", &vtw.pt.x, &vtw.pt.y, &vtw.pt.z); + vtw.pt *= allscale; + + val = walk2->Attribute("radius"); + if (val) vtw.radius = atof(val); + + val = walk2->Attribute("drive"); + if (val) vtw.drive = atof(val); + + val = walk2->Attribute("steer"); + if (val) vtw.steer = atof(val); + + val = walk2->Attribute("brake1"); + if (val) vtw.brake1 = atof(val); + + val = walk2->Attribute("brake2"); + if (val) vtw.brake2 = atof(val); + + val = walk2->Attribute("force"); + if (val) vtw.force = atof(val); + + val = walk2->Attribute("dampening"); + if (val) vtw.dampening = atof(val); + + vtp->wheel.push_back(vtw); + drive_total += vtw.drive; + wheel_speed_multiplier += 1.0f; + } else if (!strcmp(walk2->Value(), "jetflame")) { + vtp->flame.push_back(PReferenceFrame()); + + val = walk2->Attribute("pos"); + if (val) { + vec3f pos; + if (sscanf(val, "%f , %f , %f", &pos.x, &pos.y, &pos.z) == 3) + vtp->flame.back().setPosition(pos * allscale); + } + + val = walk2->Attribute("ori"); + if (val) { + quatf ori; + if (sscanf(val, "%f , %f , %f , %f", &ori.w, &ori.x, &ori.y, &ori.z) == 4) + vtp->flame.back().setOrientation(ori); + } + } + } + + vtp->ref_local.updateMatrices(); + } + } + + for (unsigned int i=0; i 0) { + unsigned int j; + for (j=0; j= part.size() && + PUtil::isDebugLevel(DEBUGLEVEL_TEST)) + PUtil::outLog() << "Warning: part \"" << part[i].name << + "\" references non-existant parent \"" << part[i].parentname << "\"\n"; + } + } + + if (drive_total > 0.0f) + inverse_drive_total = 1.0f / drive_total; + else + inverse_drive_total = 0.0f; + + if (wheel_speed_multiplier > 0.0f) + wheel_speed_multiplier = 1.0f / wheel_speed_multiplier; + + return true; } void PVehicleType::unload() { - part.clear(); + part.clear(); } @@ -485,572 +485,572 @@ //TNL_IMPLEMENT_NETOBJECT(PVehicle); PVehicle::PVehicle(PSim &sim_parent, PVehicleType *_type) : - sim(sim_parent), type(_type), dsysi(&_type->dsys) + sim(sim_parent), type(_type), dsysi(&_type->dsys) { - body = sim.createRigidBody(); - - body->setMassCuboid(type->mass, type->dims); - - state.setZero(); - ctrl.setZero(); - - forwardspeed = 0.0f; - - blade_ang1 = 0.0; - - nextcp = 0; - - wheel_angvel = 0.0f; - - reset_trigger_time = 0.0f; - - reset_time = 0.0f; - - crunch_level = 0.0f; - crunch_level_prev = 0.0f; - - part.resize(type->part.size()); - for (unsigned int i=0; ipart[i].ref_local; - - part[i].wheel.resize(type->part[i].wheel.size()); - - for (unsigned int j=0; jsetMassCuboid(type->mass, type->dims); + + state.setZero(); + ctrl.setZero(); + + forwardspeed = 0.0f; + + blade_ang1 = 0.0; + + nextcp = 0; + + wheel_angvel = 0.0f; + + reset_trigger_time = 0.0f; + + reset_time = 0.0f; + + crunch_level = 0.0f; + crunch_level_prev = 0.0f; + + part.resize(type->part.size()); + for (unsigned int i=0; ipart[i].ref_local; + + part[i].wheel.resize(type->part[i].wheel.size()); + + for (unsigned int j=0; jpos + vec3f(0.0f, 0.0f, 2.0f); - - vec3f forw = makevec3f(body->getOrientationMatrix().row[0]); - float forwangle = atan2(forw.y, forw.x); - - quatf temp; - temp.fromZAngle(forwangle); - - if (body->ori.dot(temp) < 0.0f) temp = temp * -1.0f; - - reset_ori = temp; - - reset_time = 3.0f; - - crunch_level = 0.0f; - crunch_level_prev = 0.0f; - - for (unsigned int i=0; ipos + vec3f(0.0f, 0.0f, 2.0f); + + vec3f forw = makevec3f(body->getOrientationMatrix().row[0]); + float forwangle = atan2(forw.y, forw.x); + + quatf temp; + temp.fromZAngle(forwangle); + + if (body->ori.dot(temp) < 0.0f) temp = temp * -1.0f; + + reset_ori = temp; + + reset_time = 3.0f; + + crunch_level = 0.0f; + crunch_level_prev = 0.0f; + + for (unsigned int i=0; ictrlrate.throttle * delta); - PULLTOWARD(state.brake1, ctrl.brake1, type->ctrlrate.brake1 * delta); - PULLTOWARD(state.brake2, ctrl.brake2, type->ctrlrate.brake2 * delta); - PULLTOWARD(state.turn.x, ctrl.turn.x, type->ctrlrate.turn.x * delta); - PULLTOWARD(state.turn.y, ctrl.turn.y, type->ctrlrate.turn.y * delta); - PULLTOWARD(state.turn.z, ctrl.turn.z, type->ctrlrate.turn.z * delta); - //PULLTOWARD(state.aim.x, ctrl.aim.x, type->ctrlrate.aim.x * delta); - //PULLTOWARD(state.aim.y, ctrl.aim.y, type->ctrlrate.aim.y * delta); - PULLTOWARD(state.collective, ctrl.collective, type->ctrlrate.collective * delta); - - // prepare some useful data - vec3f pos = body->getPosition(); - vec3f linvel = body->getLinearVel(); - mat44f orimatt = body->getInverseOrientationMatrix(); - vec3f angvel = body->getAngularVel(); - - if (orimatt.row[2].z <= 0.1f) { - reset_trigger_time += delta; - - if (reset_trigger_time >= 4.0f) - doReset(); - } else - reset_trigger_time = 0.0f; - - vec3f loclinvel = body->getWorldToLocVector(linvel); - vec3f locangvel = body->getWorldToLocVector(angvel); - //vec3f locangvel = body->getLocToWorldVector(angvel); - //vec3f locangvel = angvel; - - // check for resetting (if the vehicle has been flipped or something) - if (reset_time != 0.0f) { - if (reset_time > 0.0f) { - PULLTOWARD(body->pos, reset_pos, delta * 2.0f); - PULLTOWARD(body->ori, reset_ori, delta * 2.0f); - - body->setLinearVel(vec3f::zero()); - body->setAngularVel(vec3f::zero()); - - body->updateMatrices(); - - reset_time -= delta; - if (reset_time <= 0.0f) - reset_time = -2.0f; - - return; - - } else { - reset_time += delta; - - if (reset_time > 0.0f) - reset_time = 0.0f; - } - } - - forwardspeed = loclinvel.y; - - // body turn control - vec3f desiredturn = vec3f( - state.turn.x * type->param.turnspeed.x, - state.turn.y * type->param.turnspeed.y, - state.turn.z * type->param.turnspeed.z); - body->addLocTorque(desiredturn * type->param.turnspeed_a); - - body->addLocTorque((desiredturn - locangvel) * (type->param.turnspeed_b * loclinvel.y)); - - // fin effect (torque due to drag) - body->addLocTorque(vec3f(-loclinvel.z * type->param.fineffect.y, 0.0, loclinvel.x * type->param.fineffect.x)); - - // angular drag - body->addTorque(angvel * -type->param.angdrag); - - // linear drag - vec3f frc = -vec3f( - loclinvel.x * type->param.drag.x, - loclinvel.y * type->param.drag.y, - loclinvel.z * type->param.drag.z); - - // lift - frc += -vec3f( - loclinvel.x * type->param.lift.x * loclinvel.y, - 0.0, - loclinvel.z * type->param.lift.y * loclinvel.y); - - // VEHICLE TYPE POINT - - // vehicle-specific code - switch (type->coretype) { - default: break; - - case VCTYPE_TANK: - if (part.size() >= 3) { - state.aim.x += ctrl.aim.x * delta * 0.5; - if (state.aim.x < -PI) state.aim.x += 2.0*PI; - if (state.aim.x >= PI) state.aim.x -= 2.0*PI; - state.aim.y += ctrl.aim.y * delta * 0.5; - CLAMP(state.aim.y, 0.0, 0.5); - - part[1].ref_local.ori.fromThreeAxisAngle( - vec3f(0.0,0.0,-state.aim.x)); - - part[2].ref_local.ori.fromThreeAxisAngle( - vec3f(-state.aim.y,0.0,0.0)); - - part[1].ref_local.updateMatrices(); - part[2].ref_local.updateMatrices(); - } - break; - - case VCTYPE_HELICOPTER: - break; - - case VCTYPE_PLANE: - { - frc.y += state.throttle * type->param.speed; - } - break; - - case VCTYPE_HOVERCRAFT: - { - blade_ang1 = fmod(blade_ang1 + delta * 50.0 * state.throttle, 2.0*PI); - - if (part.size() >= 4) { - state.aim.x += ctrl.aim.x * delta * 0.5; - if (state.aim.x < -PI) state.aim.x += 2.0*PI; - if (state.aim.x >= PI) state.aim.x -= 2.0*PI; - state.aim.y += ctrl.aim.y * delta * 0.5; - CLAMP(state.aim.y, 0.0, 0.5); - - part[1].ref_local.ori.fromThreeAxisAngle(vec3f(0.0, blade_ang1, 0.0)); - - part[2].ref_local.ori.fromThreeAxisAngle(vec3f(0.0, 0.0, state.turn.z * -0.5)); - - part[1].ref_local.updateMatrices(); - part[2].ref_local.updateMatrices(); - } - - frc.y += state.throttle * type->param.speed; - } - break; - - case VCTYPE_CAR: - break; - } - - body->addLocForce(frc); - - vec3f forwarddir = makevec3f(body->getInverseOrientationMatrix().row[1]); - vec3f rightdir = makevec3f(body->getInverseOrientationMatrix().row[0]); - - dsysi.tick(delta, state.throttle, wheel_angvel); - - float drivetorque = dsysi.getOutputTorque(); - //float drivetorque = 0.0f; - - float turnfactor = state.turn.z;// / - //(1.0f + fabsf(wheel_angvel) / 70.0f); - - wheel_angvel = 0.0f; - - wheel_speed = 0.0f; - - skid_level = 0.0f; - - for (unsigned int i=0; ipart[i].clip.size(); ++j) { - - vec3f lclip = type->part[i].clip[j].pt; - - vec3f wclip = part[i].ref_world.getLocToWorldPoint(lclip); - - PTerrain::ContactInfo tci; - tci.pos.x = wclip.x; - tci.pos.y = wclip.y; - - sim.getTerrain()->getContactInfo(tci); - - if (type->part[i].clip[j].type == VCLIP_HOVER) { - if (tci.pos.z < 40.3) { - tci.pos.z = 40.3; - tci.normal = vec3f(0,0,1); - } - } - - if (wclip.z <= tci.pos.z) { - - float depth = (tci.pos - wclip) * tci.normal; - vec3f ptvel = body->getLinearVelAtPoint(wclip); - - vec3f frc = vec3f::zero(); - - switch (type->part[i].clip[j].type) { - default: - case VCLIP_BODY: - { - #if 0 - frc += vec3f(0.0, 0.0, type->part[i].clip[j].force); - - frc += ptvel * -type->part[i].clip[j].dampening; - - frc *= depth; - #else - vec3f rightdir; - if (tci.normal.x > 0.5f) - rightdir = vec3f(0.0f, 1.0f, 0.0f); - else - rightdir = vec3f(1.0f, 0.0f, 0.0f); - - //float testval = tci.normal * rightdir; - - vec3f surf_forward = tci.normal ^ rightdir; - surf_forward.normalize(); - vec3f surf_right = surf_forward ^ tci.normal; - surf_right.normalize(); - - vec3f surfvel( - ptvel * surf_right, - ptvel * surf_forward, - ptvel * tci.normal); - - float perpforce = depth * type->part[i].clip[j].force - - surfvel.z * type->part[i].clip[j].dampening; - - // check we have positive normal force - - if (perpforce > 0.0f) { - vec2f friction = vec2f(-surfvel.x, -surfvel.y) * 10000.0f; - - float maxfriction = perpforce * 0.9f; - float testfriction = perpforce * 1.2f; - - float leng = friction.length(); - - if (leng > 0.0f && leng > testfriction) - friction *= (maxfriction / leng); - - frc += (tci.normal * perpforce + - surf_right * friction.x + - surf_forward * friction.y); - - CLAMP_LOWER(crunch_level, perpforce * 0.00001f); - } - #endif - } break; - - case VCLIP_DRIVE_LEFT: - { - frc += vec3f(0.0, 0.0, type->part[i].clip[j].force); - - vec3f drivevec = forwarddir * - (state.throttle * type->param.speed + - state.turn.z * type->param.turnspeed.z); - - vec3f relvel = drivevec - tci.normal * (drivevec * tci.normal); - - frc += (ptvel - relvel) * -type->part[i].clip[j].dampening; - - frc *= depth; - } break; - - case VCLIP_DRIVE_RIGHT: - { - frc += vec3f(0.0, 0.0, type->part[i].clip[j].force); - - vec3f drivevec = forwarddir * - (state.throttle * type->param.speed - - state.turn.z * type->param.turnspeed.z); - - vec3f relvel = drivevec - tci.normal * (drivevec * tci.normal); - - frc += (ptvel - relvel) * -type->part[i].clip[j].dampening; - - frc *= depth; - } break; - - case VCLIP_HOVER: - { - float surfvelz = ptvel * tci.normal; - - float perpfrc = type->part[i].clip[j].force; - if (surfvelz < 0.0) perpfrc += surfvelz * -type->part[i].clip[j].dampening; - - frc += (tci.normal * perpfrc) * depth; - } break; - } - - body->addForceAtPoint(frc, wclip); - } - } - - for (unsigned int j=0; jpart[i].wheel.size(); ++j) { - - PVehicleWheel &wheel = part[i].wheel[j]; - PVehicleTypeWheel &typewheel = type->part[i].wheel[j]; - - vec3f wclip = wheel.ref_world.getPosition(); - - //vec3f wclip = vec3f(0,0,2000); - - // TODO: calc wclip along wheel plane instead of just straight down - wclip.z -= typewheel.radius; - - wclip.z += INTERP(wheel.bumplast, wheel.bumpnext, wheel.bumptravel); - - wheel.spin_vel += drivetorque * typewheel.drive * delta; - - float desiredchange = (state.brake1 * typewheel.brake1 + - state.brake2 * typewheel.brake2) * delta; - if (wheel.spin_vel > desiredchange) - wheel.spin_vel -= desiredchange; - else if (wheel.spin_vel < -desiredchange) - wheel.spin_vel += desiredchange; - else - wheel.spin_vel = 0.0f; - - wheel.spin_pos += wheel.spin_vel * delta; - - wheel.turn_pos = turnfactor * typewheel.steer; - - wheel.dirtthrow = 0.0f; - - float suspension_force = wheel.ride_pos * typewheel.force; - - wheel.ride_vel += - (-suspension_force - - wheel.ride_vel * typewheel.dampening) * 0.02 * delta; - wheel.ride_pos += wheel.ride_vel * delta; - - PTerrain::ContactInfo tci; - tci.pos.x = wclip.x; - tci.pos.y = wclip.y; - - sim.getTerrain()->getContactInfo(tci); - - if (wclip.z <= tci.pos.z) { - - wheel.bumptravel += fabsf(wheel.spin_vel) * 0.6f * delta; - - if (wheel.bumptravel >= 1.0f) { - wheel.bumplast = wheel.bumpnext; - wheel.bumptravel -= (int)wheel.bumptravel; - - wheel.bumpnext = randm11 * rand01 * typewheel.radius * 0.1f; - } - - float depth = (tci.pos - wclip) * tci.normal; - vec3f ptvel = body->getLinearVelAtPoint(wclip); - - vec3f frc = vec3f::zero(); - - vec3f rightdir = makevec3f(wheel.ref_world.getInverseOrientationMatrix().row[0]); - - //float testval = tci.normal * rightdir; - - vec3f surf_forward = tci.normal ^ rightdir; - surf_forward.normalize(); - vec3f surf_right = surf_forward ^ tci.normal; - surf_right.normalize(); - - // add wheel rotation speed to ptvel - ptvel += surf_forward * (-wheel.spin_vel * typewheel.radius); - - vec3f surfvel( - ptvel * surf_right, - ptvel * surf_forward, - ptvel * tci.normal); - - float perpforce = suspension_force; - if (surfvel.z < 0.0f) perpforce -= surfvel.z * typewheel.dampening; - - wheel.ride_pos += depth; - - float maxdepth = typewheel.radius * 0.7f; - - if (wheel.ride_pos > maxdepth) { - float overdepth = wheel.ride_pos - maxdepth; - - wheel.ride_pos = maxdepth; - - perpforce -= overdepth * surfvel.z * typewheel.dampening * 5.0f; - } - - if (wheel.ride_vel < -surfvel.z) - wheel.ride_vel = -surfvel.z; - - // check we have positive normal force - - if (perpforce > 0.0f) { - vec2f friction = vec2f(-surfvel.x, -surfvel.y) * 10000.0f; - - float maxfriction = perpforce * 1.0f; - float testfriction = perpforce * 1.0f; - - float leng = friction.length(); - - if (leng > 0.0f && leng > testfriction) - friction *= (maxfriction / leng) + 0.02f; - - frc += (tci.normal * perpforce + - surf_right * friction.x + - surf_forward * friction.y); - - wheel.spin_vel -= (friction.y * typewheel.radius) * 0.1f * delta; - - //wheel.turn_vel -= friction.x * 1.0f * delta; - - body->addForceAtPoint(frc, wclip); - - wheel.dirtthrow = leng / maxfriction; - skid_level += wheel.dirtthrow; - - vec3f downward = surf_forward ^ rightdir; - downward.normalize(); - - if (wheel.spin_vel > 0.0f) - downward += surf_forward * -0.3f; - else - downward += surf_forward * 0.3f; - downward.normalize(); - - wheel.dirtthrowpos = wheel.ref_world.getPosition() + - downward * typewheel.radius; - wheel.dirtthrowvec = - body->getLinearVelAtPoint(wheel.dirtthrowpos) + - (downward ^ rightdir) * (wheel.spin_vel * typewheel.radius); - } - } - - //wheel.spin_vel /= 1.0f + delta * 0.6f; - - wheel.spin_pos = fmodf(wheel.spin_pos, PI*2.0f); - - wheel_angvel += wheel.spin_vel * typewheel.drive; - - wheel_speed += wheel.spin_vel * typewheel.radius; - } - } - - wheel_angvel *= type->inverse_drive_total; - - wheel_speed *= type->wheel_speed_multiplier; - - skid_level *= type->wheel_speed_multiplier; + // ensure control values are in valid range + ctrl.clamp(); + + // handle crunch noise level + PULLTOWARD(crunch_level_prev, crunch_level, delta * 5.0f); + PULLTOWARD(crunch_level, 0.0f, delta * 5.0f); + + // smooth out control values + PULLTOWARD(state.throttle, ctrl.throttle, type->ctrlrate.throttle * delta); + PULLTOWARD(state.brake1, ctrl.brake1, type->ctrlrate.brake1 * delta); + PULLTOWARD(state.brake2, ctrl.brake2, type->ctrlrate.brake2 * delta); + PULLTOWARD(state.turn.x, ctrl.turn.x, type->ctrlrate.turn.x * delta); + PULLTOWARD(state.turn.y, ctrl.turn.y, type->ctrlrate.turn.y * delta); + PULLTOWARD(state.turn.z, ctrl.turn.z, type->ctrlrate.turn.z * delta); + //PULLTOWARD(state.aim.x, ctrl.aim.x, type->ctrlrate.aim.x * delta); + //PULLTOWARD(state.aim.y, ctrl.aim.y, type->ctrlrate.aim.y * delta); + PULLTOWARD(state.collective, ctrl.collective, type->ctrlrate.collective * delta); + + // prepare some useful data + vec3f pos = body->getPosition(); + vec3f linvel = body->getLinearVel(); + mat44f orimatt = body->getInverseOrientationMatrix(); + vec3f angvel = body->getAngularVel(); + + if (orimatt.row[2].z <= 0.1f) { + reset_trigger_time += delta; + + if (reset_trigger_time >= 4.0f) + doReset(); + } else + reset_trigger_time = 0.0f; + + vec3f loclinvel = body->getWorldToLocVector(linvel); + vec3f locangvel = body->getWorldToLocVector(angvel); + //vec3f locangvel = body->getLocToWorldVector(angvel); + //vec3f locangvel = angvel; + + // check for resetting (if the vehicle has been flipped or something) + if (reset_time != 0.0f) { + if (reset_time > 0.0f) { + PULLTOWARD(body->pos, reset_pos, delta * 2.0f); + PULLTOWARD(body->ori, reset_ori, delta * 2.0f); + + body->setLinearVel(vec3f::zero()); + body->setAngularVel(vec3f::zero()); + + body->updateMatrices(); + + reset_time -= delta; + if (reset_time <= 0.0f) + reset_time = -2.0f; + + return; + + } else { + reset_time += delta; + + if (reset_time > 0.0f) + reset_time = 0.0f; + } + } + + forwardspeed = loclinvel.y; + + // body turn control + vec3f desiredturn = vec3f( + state.turn.x * type->param.turnspeed.x, + state.turn.y * type->param.turnspeed.y, + state.turn.z * type->param.turnspeed.z); + body->addLocTorque(desiredturn * type->param.turnspeed_a); + + body->addLocTorque((desiredturn - locangvel) * (type->param.turnspeed_b * loclinvel.y)); + + // fin effect (torque due to drag) + body->addLocTorque(vec3f(-loclinvel.z * type->param.fineffect.y, 0.0, loclinvel.x * type->param.fineffect.x)); + + // angular drag + body->addTorque(angvel * -type->param.angdrag); + + // linear drag + vec3f frc = -vec3f( + loclinvel.x * type->param.drag.x, + loclinvel.y * type->param.drag.y, + loclinvel.z * type->param.drag.z); + + // lift + frc += -vec3f( + loclinvel.x * type->param.lift.x * loclinvel.y, + 0.0, + loclinvel.z * type->param.lift.y * loclinvel.y); + + // VEHICLE TYPE POINT + + // vehicle-specific code + switch (type->coretype) { + default: break; + + case VCTYPE_TANK: + if (part.size() >= 3) { + state.aim.x += ctrl.aim.x * delta * 0.5; + if (state.aim.x < -PI) state.aim.x += 2.0*PI; + if (state.aim.x >= PI) state.aim.x -= 2.0*PI; + state.aim.y += ctrl.aim.y * delta * 0.5; + CLAMP(state.aim.y, 0.0, 0.5); + + part[1].ref_local.ori.fromThreeAxisAngle( + vec3f(0.0,0.0,-state.aim.x)); + + part[2].ref_local.ori.fromThreeAxisAngle( + vec3f(-state.aim.y,0.0,0.0)); + + part[1].ref_local.updateMatrices(); + part[2].ref_local.updateMatrices(); + } + break; + + case VCTYPE_HELICOPTER: + break; + + case VCTYPE_PLANE: + { + frc.y += state.throttle * type->param.speed; + } + break; + + case VCTYPE_HOVERCRAFT: + { + blade_ang1 = fmod(blade_ang1 + delta * 50.0 * state.throttle, 2.0*PI); + + if (part.size() >= 4) { + state.aim.x += ctrl.aim.x * delta * 0.5; + if (state.aim.x < -PI) state.aim.x += 2.0*PI; + if (state.aim.x >= PI) state.aim.x -= 2.0*PI; + state.aim.y += ctrl.aim.y * delta * 0.5; + CLAMP(state.aim.y, 0.0, 0.5); + + part[1].ref_local.ori.fromThreeAxisAngle(vec3f(0.0, blade_ang1, 0.0)); + + part[2].ref_local.ori.fromThreeAxisAngle(vec3f(0.0, 0.0, state.turn.z * -0.5)); + + part[1].ref_local.updateMatrices(); + part[2].ref_local.updateMatrices(); + } + + frc.y += state.throttle * type->param.speed; + } + break; + + case VCTYPE_CAR: + break; + } + + body->addLocForce(frc); + + vec3f forwarddir = makevec3f(body->getInverseOrientationMatrix().row[1]); + vec3f rightdir = makevec3f(body->getInverseOrientationMatrix().row[0]); + + dsysi.tick(delta, state.throttle, wheel_angvel); + + float drivetorque = dsysi.getOutputTorque(); + //float drivetorque = 0.0f; + + float turnfactor = state.turn.z;// / + //(1.0f + fabsf(wheel_angvel) / 70.0f); + + wheel_angvel = 0.0f; + + wheel_speed = 0.0f; + + skid_level = 0.0f; + + for (unsigned int i=0; ipart[i].clip.size(); ++j) { + + vec3f lclip = type->part[i].clip[j].pt; + + vec3f wclip = part[i].ref_world.getLocToWorldPoint(lclip); + + PTerrain::ContactInfo tci; + tci.pos.x = wclip.x; + tci.pos.y = wclip.y; + + sim.getTerrain()->getContactInfo(tci); + + if (type->part[i].clip[j].type == VCLIP_HOVER) { + if (tci.pos.z < 40.3) { + tci.pos.z = 40.3; + tci.normal = vec3f(0,0,1); + } + } + + if (wclip.z <= tci.pos.z) { + + float depth = (tci.pos - wclip) * tci.normal; + vec3f ptvel = body->getLinearVelAtPoint(wclip); + + vec3f frc = vec3f::zero(); + + switch (type->part[i].clip[j].type) { + default: + case VCLIP_BODY: + { + #if 0 + frc += vec3f(0.0, 0.0, type->part[i].clip[j].force); + + frc += ptvel * -type->part[i].clip[j].dampening; + + frc *= depth; + #else + vec3f rightdir; + if (tci.normal.x > 0.5f) + rightdir = vec3f(0.0f, 1.0f, 0.0f); + else + rightdir = vec3f(1.0f, 0.0f, 0.0f); + + //float testval = tci.normal * rightdir; + + vec3f surf_forward = tci.normal ^ rightdir; + surf_forward.normalize(); + vec3f surf_right = surf_forward ^ tci.normal; + surf_right.normalize(); + + vec3f surfvel( + ptvel * surf_right, + ptvel * surf_forward, + ptvel * tci.normal); + + float perpforce = depth * type->part[i].clip[j].force - + surfvel.z * type->part[i].clip[j].dampening; + + // check we have positive normal force + + if (perpforce > 0.0f) { + vec2f friction = vec2f(-surfvel.x, -surfvel.y) * 10000.0f; + + float maxfriction = perpforce * 0.9f; + float testfriction = perpforce * 1.2f; + + float leng = friction.length(); + + if (leng > 0.0f && leng > testfriction) + friction *= (maxfriction / leng); + + frc += (tci.normal * perpforce + + surf_right * friction.x + + surf_forward * friction.y); + + CLAMP_LOWER(crunch_level, perpforce * 0.00001f); + } + #endif + } break; + + case VCLIP_DRIVE_LEFT: + { + frc += vec3f(0.0, 0.0, type->part[i].clip[j].force); + + vec3f drivevec = forwarddir * + (state.throttle * type->param.speed + + state.turn.z * type->param.turnspeed.z); + + vec3f relvel = drivevec - tci.normal * (drivevec * tci.normal); + + frc += (ptvel - relvel) * -type->part[i].clip[j].dampening; + + frc *= depth; + } break; + + case VCLIP_DRIVE_RIGHT: + { + frc += vec3f(0.0, 0.0, type->part[i].clip[j].force); + + vec3f drivevec = forwarddir * + (state.throttle * type->param.speed - + state.turn.z * type->param.turnspeed.z); + + vec3f relvel = drivevec - tci.normal * (drivevec * tci.normal); + + frc += (ptvel - relvel) * -type->part[i].clip[j].dampening; + + frc *= depth; + } break; + + case VCLIP_HOVER: + { + float surfvelz = ptvel * tci.normal; + + float perpfrc = type->part[i].clip[j].force; + if (surfvelz < 0.0) perpfrc += surfvelz * -type->part[i].clip[j].dampening; + + frc += (tci.normal * perpfrc) * depth; + } break; + } + + body->addForceAtPoint(frc, wclip); + } + } + + for (unsigned int j=0; jpart[i].wheel.size(); ++j) { + + PVehicleWheel &wheel = part[i].wheel[j]; + PVehicleTypeWheel &typewheel = type->part[i].wheel[j]; + + vec3f wclip = wheel.ref_world.getPosition(); + + //vec3f wclip = vec3f(0,0,2000); + + // TODO: calc wclip along wheel plane instead of just straight down + wclip.z -= typewheel.radius; + + wclip.z += INTERP(wheel.bumplast, wheel.bumpnext, wheel.bumptravel); + + wheel.spin_vel += drivetorque * typewheel.drive * delta; + + float desiredchange = (state.brake1 * typewheel.brake1 + + state.brake2 * typewheel.brake2) * delta; + if (wheel.spin_vel > desiredchange) + wheel.spin_vel -= desiredchange; + else if (wheel.spin_vel < -desiredchange) + wheel.spin_vel += desiredchange; + else + wheel.spin_vel = 0.0f; + + wheel.spin_pos += wheel.spin_vel * delta; + + wheel.turn_pos = turnfactor * typewheel.steer; + + wheel.dirtthrow = 0.0f; + + float suspension_force = wheel.ride_pos * typewheel.force; + + wheel.ride_vel += + (-suspension_force - + wheel.ride_vel * typewheel.dampening) * 0.02 * delta; + wheel.ride_pos += wheel.ride_vel * delta; + + PTerrain::ContactInfo tci; + tci.pos.x = wclip.x; + tci.pos.y = wclip.y; + + sim.getTerrain()->getContactInfo(tci); + + if (wclip.z <= tci.pos.z) { + + wheel.bumptravel += fabsf(wheel.spin_vel) * 0.6f * delta; + + if (wheel.bumptravel >= 1.0f) { + wheel.bumplast = wheel.bumpnext; + wheel.bumptravel -= (int)wheel.bumptravel; + + wheel.bumpnext = randm11 * rand01 * typewheel.radius * 0.1f; + } + + float depth = (tci.pos - wclip) * tci.normal; + vec3f ptvel = body->getLinearVelAtPoint(wclip); + + vec3f frc = vec3f::zero(); + + vec3f rightdir = makevec3f(wheel.ref_world.getInverseOrientationMatrix().row[0]); + + //float testval = tci.normal * rightdir; + + vec3f surf_forward = tci.normal ^ rightdir; + surf_forward.normalize(); + vec3f surf_right = surf_forward ^ tci.normal; + surf_right.normalize(); + + // add wheel rotation speed to ptvel + ptvel += surf_forward * (-wheel.spin_vel * typewheel.radius); + + vec3f surfvel( + ptvel * surf_right, + ptvel * surf_forward, + ptvel * tci.normal); + + float perpforce = suspension_force; + if (surfvel.z < 0.0f) perpforce -= surfvel.z * typewheel.dampening; + + wheel.ride_pos += depth; + + float maxdepth = typewheel.radius * 0.7f; + + if (wheel.ride_pos > maxdepth) { + float overdepth = wheel.ride_pos - maxdepth; + + wheel.ride_pos = maxdepth; + + perpforce -= overdepth * surfvel.z * typewheel.dampening * 5.0f; + } + + if (wheel.ride_vel < -surfvel.z) + wheel.ride_vel = -surfvel.z; + + // check we have positive normal force + + if (perpforce > 0.0f) { + vec2f friction = vec2f(-surfvel.x, -surfvel.y) * 10000.0f; + + float maxfriction = perpforce * 1.0f; + float testfriction = perpforce * 1.0f; + + float leng = friction.length(); + + if (leng > 0.0f && leng > testfriction) + friction *= (maxfriction / leng) + 0.02f; + + frc += (tci.normal * perpforce + + surf_right * friction.x + + surf_forward * friction.y); + + wheel.spin_vel -= (friction.y * typewheel.radius) * 0.1f * delta; + + //wheel.turn_vel -= friction.x * 1.0f * delta; + + body->addForceAtPoint(frc, wclip); + + wheel.dirtthrow = leng / maxfriction; + skid_level += wheel.dirtthrow; + + vec3f downward = surf_forward ^ rightdir; + downward.normalize(); + + if (wheel.spin_vel > 0.0f) + downward += surf_forward * -0.3f; + else + downward += surf_forward * 0.3f; + downward.normalize(); + + wheel.dirtthrowpos = wheel.ref_world.getPosition() + + downward * typewheel.radius; + wheel.dirtthrowvec = + body->getLinearVelAtPoint(wheel.dirtthrowpos) + + (downward ^ rightdir) * (wheel.spin_vel * typewheel.radius); + } + } + + //wheel.spin_vel /= 1.0f + delta * 0.6f; + + wheel.spin_pos = fmodf(wheel.spin_pos, PI*2.0f); + + wheel_angvel += wheel.spin_vel * typewheel.drive; + + wheel_speed += wheel.spin_vel * typewheel.radius; + } + } + + wheel_angvel *= type->inverse_drive_total; + + wheel_speed *= type->wheel_speed_multiplier; + + skid_level *= type->wheel_speed_multiplier; } void PVehicle::updateParts() { - for (unsigned int i=0; ipart[i].parent > -1) - parent = &part[type->part[i].parent].ref_world; - else - parent = body; - - part[i].ref_world.ori = part[i].ref_local.ori * parent->ori; - - part[i].ref_world.updateMatrices(); - - part[i].ref_world.pos = parent->pos + - parent->getOrientationMatrix().transform1(part[i].ref_local.pos); - - for (unsigned int j=0; jpart[i].wheel[j].pt + - vec3f(0.0f, 0.0f, part[i].wheel[j].ride_pos); - - part[i].wheel[j].ref_world.setPosition(part[i].ref_world.getLocToWorldPoint(locpos)); - - quatf turnang, spinang; - turnang.fromZAngle(part[i].wheel[j].turn_pos); - spinang.fromXAngle(part[i].wheel[j].spin_pos); - - part[i].wheel[j].ref_world.ori = spinang * turnang * part[i].ref_world.ori; - - part[i].wheel[j].ref_world.updateMatrices(); - } - } + for (unsigned int i=0; ipart[i].parent > -1) + parent = &part[type->part[i].parent].ref_world; + else + parent = body; + + part[i].ref_world.ori = part[i].ref_local.ori * parent->ori; + + part[i].ref_world.updateMatrices(); + + part[i].ref_world.pos = parent->pos + + parent->getOrientationMatrix().transform1(part[i].ref_local.pos); + + for (unsigned int j=0; jpart[i].wheel[j].pt + + vec3f(0.0f, 0.0f, part[i].wheel[j].ride_pos); + + part[i].wheel[j].ref_world.setPosition(part[i].ref_world.getLocToWorldPoint(locpos)); + + quatf turnang, spinang; + turnang.fromZAngle(part[i].wheel[j].turn_pos); + spinang.fromXAngle(part[i].wheel[j].spin_pos); + + part[i].wheel[j].ref_world.ori = spinang * turnang * part[i].ref_world.ori; + + part[i].wheel[j].ref_world.updateMatrices(); + } + } } diff -Nru trigger-rally-0.5.2.1/src/psim/vehicle.h trigger-rally-0.6.0/src/psim/vehicle.h --- trigger-rally-0.5.2.1/src/psim/vehicle.h 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/psim/vehicle.h 2011-10-07 17:10:01.000000000 +0000 @@ -1,380 +1,396 @@ - -// vehicle.h [psim] - -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net -// License: GPL version 2 (see included gpl.txt) - - - -// vehicle core types - -#define VCTYPE_TANK 1 -#define VCTYPE_HELICOPTER 2 -#define VCTYPE_PLANE 3 -#define VCTYPE_HOVERCRAFT 4 -#define VCTYPE_CAR 5 - - -// vehicle clip point types - -#define VCLIP_BODY 10 -#define VCLIP_DRIVE_LEFT 30 -#define VCLIP_DRIVE_RIGHT 31 -#define VCLIP_HOVER 40 - - -// RPM = revolutions per minute -// RPS = radians per second - -#define RPM_TO_RPS(x) ((x) * (PI / 30.0f)) -#define RPS_TO_RPM(x) ((x) * (30.0f / PI)) - -// MPS = metres per second -// KPH = kilometres per hour -// MPH = miles per hour - -#define MPS_TO_KPH(x) ((x) * 3.6f) -#define MPS_TO_MPH(x) ((x) * 2.23693629f) // thanks Google! - - -struct v_control_s { - // shared - float throttle; - float brake1,brake2; - vec3f turn; - vec2f aim; - - // helicopter - float collective; - - // -- utility -- - - void setZero() { - throttle = 0.0f; - brake1 = 0.0f; - brake2 = 0.0f; - turn = vec3f::zero(); - aim = vec2f::zero(); - collective = 0.0f; - } - - void setDefaultRates() { - throttle = 10.0f; - brake1 = 10.0f; - brake2 = 10.0f; - turn = vec3f(10.0f,10.0f,10.0f); - aim = vec2f(10.0f,10.0f); - collective = 10.0f; - } - - void clamp() { - CLAMP(throttle, -1.0f, 1.0f); - CLAMP(brake1, 0.0f, 1.0f); - CLAMP(brake2, 0.0f, 1.0f); - CLAMP(turn.x, -1.0f, 1.0f); - CLAMP(turn.y, -1.0f, 1.0f); - CLAMP(turn.z, -1.0f, 1.0f); - CLAMP(aim.x, -1.0f, 1.0f); - CLAMP(aim.y, -1.0f, 1.0f); - CLAMP(collective, -1.0f, 1.0f); - } -}; - -typedef v_control_s v_state_s; - - -class PDriveSystem { -private: - std::vector powercurve; - - std::vector gear; - - float gearch_first, gearch_repeat; - - float minRPS, maxRPS; - -protected: - float getPowerAtRPS(float rps); - -public: - PDriveSystem() : - gearch_first(0.4f), - gearch_repeat(0.15f), - minRPS(10000000.0f), - maxRPS(0.0f) { } - - void addPowerCurvePoint(float rpm, float power) { - if (rpm <= 0.0f) return; - - float rps = RPM_TO_RPS(rpm); - - powercurve.push_back(vec2f(rps, power)); - - if (minRPS > rps) minRPS = rps; - if (maxRPS < rps) maxRPS = rps; - } - - void addGear(float ratio) { - if (hasGears()) { - if (ratio <= getLastGearRatio()) return; - } else { - if (ratio <= 0.0f) return; - } - - gear.push_back(vec2f(ratio, 1.0f / ratio)); - } - - bool hasGears() { return !gear.empty(); } - float getLastGearRatio() { return gear.back().x; } - - friend class PDriveSystemInstance; -}; - -class PDriveSystemInstance { -private: - - PDriveSystem *dsys; - - float rps; - - int currentgear, targetgear_rel; - float gearch; - - bool reverse; - - float out_torque; - - bool flag_gearchange; - -public: - PDriveSystemInstance(PDriveSystem *system) : - dsys(system), - currentgear(0), - targetgear_rel(0), - gearch(0.0f), - reverse(false), - out_torque(0.0f), - flag_gearchange(false) { } - - void tick(float delta, float throttle, float wheel_rps); - - float getOutputTorque() { return out_torque; } - - float getEngineRPS() { return rps; } - float getEngineRPM() { return RPS_TO_RPM(rps); } - - int getCurrentGear() { return reverse ? -1 : currentgear; } - - bool getFlagGearChange() { - bool ret = flag_gearchange; - flag_gearchange = false; - return ret; - } - - void doReset() { - rps = dsys->minRPS; - currentgear = 0; - targetgear_rel = 0; - gearch = 0.0f; - out_torque = 0.0f; - } -}; - - -struct vehicle_clip_s { - vec3f pt; - int type; - float force, dampening; -}; - - -struct PVehicleTypeWheel { - vec3f pt; - float radius; - float drive, steer, brake1, brake2; - float force, dampening; -}; - - -struct PVehicleTypePart { - std::string name, parentname; - int parent; - - PReferenceFrame ref_local; - - std::vector clip; - - std::vector wheel; - - std::vector flame; - - float scale; - PModel *model; -}; - - -class PVehicleType : public PResource { -public: - std::string proper_name; - - int coretype; - - float mass; - vec3f dims; - - std::vector part; - - float wheelscale; - PModel *wheelmodel; - - PDriveSystem dsys; - - float inverse_drive_total; - - float wheel_speed_multiplier; - -public: - struct { - // shared - float speed; - vec3f turnspeed; - float turnspeed_a, turnspeed_b; // turnspeed = a + b * speed - vec3f drag; - float angdrag; - vec2f lift; // x = fin lift (hz), y = wing lift (vt) - vec2f fineffect; // x = rudder/fin (hz), y = tail (vt) - } param; - - v_control_s ctrlrate; - -public: - PVehicleType() { } - ~PVehicleType() { unload(); } - -public: - bool load(const std::string &filename, PSSModel &ssModel); - void unload(); -}; - - - -struct PVehicleWheel { - float ride_pos, ride_vel; // ride = suspension travel - float spin_pos, spin_vel; // spin = driving axis rotation - float turn_pos; // turn = steering axis rotation - - PReferenceFrame ref_world; - - float skidding, dirtthrow; - vec3f dirtthrowpos, dirtthrowvec; - - float bumplast, bumpnext, bumptravel; - - PVehicleWheel() { - ride_pos = 0.0f; - ride_vel = 0.0f; - spin_pos = 0.0f; - spin_vel = 0.0f; - turn_pos = 0.0f; - bumplast = 0.0f; - bumpnext = 0.0f; - bumptravel = 0.0f; - } -}; - - -struct PVehiclePart { - - // ref_local is initted from vehicle type, but may change per-vehicle - - PReferenceFrame ref_local, ref_world; - - std::vector wheel; -}; - - - -class PVehicle { -//class PVehicle : public NetObject { -//typedef NetObject Parent; - -public: - PSim ∼ - - PVehicleType *type; - - PRigidBody *body; - - std::vector part; - - v_state_s state; - - PDriveSystemInstance dsysi; - - // helicopter-specific - float blade_ang1; - - int nextcp; - - // for vehicle resetting, after being flipped - float reset_trigger_time; - vec3f reset_pos; - quatf reset_ori; - float reset_time; - - // for body crash/impact noises - float crunch_level, crunch_level_prev; - -public: - v_control_s ctrl; - - // info - float forwardspeed; - float wheel_angvel; - float wheel_speed; - float skid_level; - -public: -/* - enum StateBits { - InitialBit = BIT(0), - KinematicsBit = BIT(1), - ControlBit = BIT(2), - }; -*/ -public: - PVehicle(PSim &sim_parent, PVehicleType *_type); - //~PVehicle() { unload(); } // body unloaded by sim - -public: - PRigidBody &getBody() { return *body; } - - /* - // NetObject stuff - void performScopeQuery(GhostConnection *connection); - U32 packUpdate(GhostConnection *connection, U32 updateMask, BitStream *stream); - void unpackUpdate(GhostConnection *connection, BitStream *stream); - */ - - - void tick(float delta); - - void updateParts(); - - void doReset(); - - float getEngineRPM() { return dsysi.getEngineRPM(); } - int getCurrentGear() { return dsysi.getCurrentGear(); } - bool getFlagGearChange() { return dsysi.getFlagGearChange(); } - float getCrashNoiseLevel() { - if (crunch_level > crunch_level_prev) { - float tmp = crunch_level - crunch_level_prev; - crunch_level_prev = crunch_level; - return tmp; - } else { - return 0.0f; - } - } - float getWheelSpeed() { return wheel_speed; } - float getSkidLevel() { return skid_level; } -}; + +// vehicle.h [psim] + +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net +// License: GPL version 2 (see included gpl.txt) + + + +// vehicle core types + +#define VCTYPE_TANK 1 +#define VCTYPE_HELICOPTER 2 +#define VCTYPE_PLANE 3 +#define VCTYPE_HOVERCRAFT 4 +#define VCTYPE_CAR 5 + + +// vehicle clip point types + +#define VCLIP_BODY 10 +#define VCLIP_DRIVE_LEFT 30 +#define VCLIP_DRIVE_RIGHT 31 +#define VCLIP_HOVER 40 + + +// RPM = revolutions per minute +// RPS = radians per second + +#define RPM_TO_RPS(x) ((x) * (PI / 30.0f)) +#define RPS_TO_RPM(x) ((x) * (30.0f / PI)) + +// MPS = metres per second +// KPH = kilometres per hour +// MPH = miles per hour + +#define MPS_TO_MPH(x) ((x) * 2.23693629f) // thanks Google! +#define MPS_TO_KPH(x) ((x) * 3.6f) + +// Starting position in degrees, measured counter-clockwise from the x-axis. +#define MPH_ZERO_DEG 210 +#define KPH_ZERO_DEG 220 + +// Degrees to rotate the speedo needle for each unit of speed +#define DEG_PER_MPH 1.5f +#define DEG_PER_KPH 1.0f + +// Multiplier for mps to speed in some unit +const float MPS_MPH_SPEED_MULT = 2.23693629f; +const float MPS_KPH_SPEED_MULT = 3.6f; + +// Multiplier for mps to degs on the speedo dial +const float MPS_MPH_DEG_MULT = MPS_MPH_SPEED_MULT * DEG_PER_MPH; +const float MPS_KPH_DEG_MULT = MPS_KPH_SPEED_MULT * DEG_PER_KPH; + + +struct v_control_s { + // shared + float throttle; + float brake1,brake2; + vec3f turn; + vec2f aim; + + // helicopter + float collective; + + // -- utility -- + + void setZero() { + throttle = 0.0f; + brake1 = 0.0f; + brake2 = 0.0f; + turn = vec3f::zero(); + aim = vec2f::zero(); + collective = 0.0f; + } + + void setDefaultRates() { + throttle = 10.0f; + brake1 = 10.0f; + brake2 = 10.0f; + turn = vec3f(10.0f,10.0f,10.0f); + aim = vec2f(10.0f,10.0f); + collective = 10.0f; + } + + void clamp() { + CLAMP(throttle, -1.0f, 1.0f); + CLAMP(brake1, 0.0f, 1.0f); + CLAMP(brake2, 0.0f, 1.0f); + CLAMP(turn.x, -1.0f, 1.0f); + CLAMP(turn.y, -1.0f, 1.0f); + CLAMP(turn.z, -1.0f, 1.0f); + CLAMP(aim.x, -1.0f, 1.0f); + CLAMP(aim.y, -1.0f, 1.0f); + CLAMP(collective, -1.0f, 1.0f); + } +}; + +typedef v_control_s v_state_s; + + +class PDriveSystem { +private: + std::vector powercurve; + + std::vector gear; + + float gearch_first, gearch_repeat; + + float minRPS, maxRPS; + +protected: + float getPowerAtRPS(float rps); + +public: + PDriveSystem() : + gearch_first(0.4f), + gearch_repeat(0.15f), + minRPS(10000000.0f), + maxRPS(0.0f) { } + + void addPowerCurvePoint(float rpm, float power) { + if (rpm <= 0.0f) return; + + float rps = RPM_TO_RPS(rpm); + + powercurve.push_back(vec2f(rps, power)); + + if (minRPS > rps) minRPS = rps; + if (maxRPS < rps) maxRPS = rps; + } + + void addGear(float ratio) { + if (hasGears()) { + if (ratio <= getLastGearRatio()) return; + } else { + if (ratio <= 0.0f) return; + } + + gear.push_back(vec2f(ratio, 1.0f / ratio)); + } + + bool hasGears() { return !gear.empty(); } + float getLastGearRatio() { return gear.back().x; } + + friend class PDriveSystemInstance; +}; + +class PDriveSystemInstance { +private: + + PDriveSystem *dsys; + + float rps; + + int currentgear, targetgear_rel; + float gearch; + + bool reverse; + + float out_torque; + + bool flag_gearchange; + +public: + PDriveSystemInstance(PDriveSystem *system) : + dsys(system), + currentgear(0), + targetgear_rel(0), + gearch(0.0f), + reverse(false), + out_torque(0.0f), + flag_gearchange(false) { } + + void tick(float delta, float throttle, float wheel_rps); + + float getOutputTorque() { return out_torque; } + + float getEngineRPS() { return rps; } + float getEngineRPM() { return RPS_TO_RPM(rps); } + + int getCurrentGear() { return reverse ? -1 : currentgear; } + + bool getFlagGearChange() { + bool ret = flag_gearchange; + flag_gearchange = false; + return ret; + } + + void doReset() { + rps = dsys->minRPS; + currentgear = 0; + targetgear_rel = 0; + gearch = 0.0f; + out_torque = 0.0f; + } +}; + + +struct vehicle_clip_s { + vec3f pt; + int type; + float force, dampening; +}; + + +struct PVehicleTypeWheel { + vec3f pt; + float radius; + float drive, steer, brake1, brake2; + float force, dampening; +}; + + +struct PVehicleTypePart { + std::string name, parentname; + int parent; + + PReferenceFrame ref_local; + + std::vector clip; + + std::vector wheel; + + std::vector flame; + + float scale; + PModel *model; +}; + + +class PVehicleType : public PResource { +public: + std::string proper_name; + + int coretype; + + float mass; + vec3f dims; + + std::vector part; + + float wheelscale; + PModel *wheelmodel; + + PDriveSystem dsys; + + float inverse_drive_total; + + float wheel_speed_multiplier; + +public: + struct { + // shared + float speed; + vec3f turnspeed; + float turnspeed_a, turnspeed_b; // turnspeed = a + b * speed + vec3f drag; + float angdrag; + vec2f lift; // x = fin lift (hz), y = wing lift (vt) + vec2f fineffect; // x = rudder/fin (hz), y = tail (vt) + } param; + + v_control_s ctrlrate; + +public: + PVehicleType() { } + ~PVehicleType() { unload(); } + +public: + bool load(const std::string &filename, PSSModel &ssModel); + void unload(); +}; + + + +struct PVehicleWheel { + float ride_pos, ride_vel; // ride = suspension travel + float spin_pos, spin_vel; // spin = driving axis rotation + float turn_pos; // turn = steering axis rotation + + PReferenceFrame ref_world; + + float skidding, dirtthrow; + vec3f dirtthrowpos, dirtthrowvec; + + float bumplast, bumpnext, bumptravel; + + PVehicleWheel() { + ride_pos = 0.0f; + ride_vel = 0.0f; + spin_pos = 0.0f; + spin_vel = 0.0f; + turn_pos = 0.0f; + bumplast = 0.0f; + bumpnext = 0.0f; + bumptravel = 0.0f; + } +}; + + +struct PVehiclePart { + + // ref_local is initted from vehicle type, but may change per-vehicle + + PReferenceFrame ref_local, ref_world; + + std::vector wheel; +}; + + + +class PVehicle { +//class PVehicle : public NetObject { +//typedef NetObject Parent; + +public: + PSim ∼ + + PVehicleType *type; + + PRigidBody *body; + + std::vector part; + + v_state_s state; + + PDriveSystemInstance dsysi; + + // helicopter-specific + float blade_ang1; + + int nextcp; + + // for vehicle resetting, after being flipped + float reset_trigger_time; + vec3f reset_pos; + quatf reset_ori; + float reset_time; + + // for body crash/impact noises + float crunch_level, crunch_level_prev; + +public: + v_control_s ctrl; + + // info + float forwardspeed; + float wheel_angvel; + float wheel_speed; + float skid_level; + +public: +/* + enum StateBits { + InitialBit = BIT(0), + KinematicsBit = BIT(1), + ControlBit = BIT(2), + }; +*/ +public: + PVehicle(PSim &sim_parent, PVehicleType *_type); + //~PVehicle() { unload(); } // body unloaded by sim + +public: + PRigidBody &getBody() { return *body; } + + /* + // NetObject stuff + void performScopeQuery(GhostConnection *connection); + U32 packUpdate(GhostConnection *connection, U32 updateMask, BitStream *stream); + void unpackUpdate(GhostConnection *connection, BitStream *stream); + */ + + + void tick(float delta); + + void updateParts(); + + void doReset(); + + float getEngineRPM() { return dsysi.getEngineRPM(); } + int getCurrentGear() { return dsysi.getCurrentGear(); } + bool getFlagGearChange() { return dsysi.getFlagGearChange(); } + float getCrashNoiseLevel() { + if (crunch_level > crunch_level_prev) { + float tmp = crunch_level - crunch_level_prev; + crunch_level_prev = crunch_level; + return tmp; + } else { + return 0.0f; + } + } + float getWheelSpeed() { return wheel_speed; } + float getSkidLevel() { return skid_level; } +}; diff -Nru trigger-rally-0.5.2.1/src/trigger/game.cpp trigger-rally-0.6.0/src/trigger/game.cpp --- trigger-rally-0.5.2.1/src/trigger/game.cpp 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/trigger/game.cpp 2011-10-07 17:10:01.000000000 +0000 @@ -1,7 +1,7 @@ // game.cpp -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net // License: GPL version 2 (see included gpl.txt) @@ -11,302 +11,305 @@ TriggerGame::TriggerGame(MainApp *parent) { - app = parent; - - sim = null; - terrain = null; - - randomseed = 0; + app = parent; + + sim = null; + terrain = null; + + randomseed = 0; } TriggerGame::~TriggerGame() { - if (sim) delete sim; - if (terrain) delete terrain; + if (sim) delete sim; + if (terrain) delete terrain; } bool TriggerGame::loadLevel(const std::string &filename) { - - if (PUtil::isDebugLevel(DEBUGLEVEL_TEST)) - PUtil::outLog() << "Loading level \"" << filename << "\"\n"; - - if (sim == null) - sim = new PSim(); - - sim->setGravity(vec3f(0.0,0.0,-9.81)); - - start_pos = vec3f::zero(); - start_ori = quatf::identity(); - - targettime = 754.567f; - - weather.cloud.texname = std::string(""); - weather.cloud.scrollrate = 0.001f; - weather.fog.color = vec3f(1.0f, 1.0f, 1.0f); - weather.fog.density = 0.01f; - weather.fog.density_sky = 0.8f; - weather.precip.rain = 0.0f; - - TiXmlDocument xmlfile(filename.c_str()); - TiXmlElement *rootelem = PUtil::loadRootElement(xmlfile, "level"); - if (!rootelem) return false; - - const char *val; - - val = rootelem->Attribute("comment"); - if (val) comment = val; - - for (TiXmlElement *walk = rootelem->FirstChildElement(); - walk; walk = walk->NextSiblingElement()) { - - if (!strcmp(walk->Value(), "terrain")) { - try - { - terrain = new PTerrain (walk, filename, app->getSSTexture ()); - } - catch (PException e) - { - PUtil::outLog () << "Terrain problem: " << e.what () << std::endl; - return false; - } - sim->setTerrain(terrain); - } else if (!strcmp(walk->Value(), "vehicle")) { - PVehicle *vh = sim->createVehicle(walk, filename, app->getSSModel()); - if (vh) { - vehicle.push_back(vh); - } else { - PUtil::outLog() << "Warning: failed to load vehicle\n"; - } - } else if (!strcmp(walk->Value(), "vehicleoption")) { - - val = walk->Attribute("type"); - - if (val) { - PVehicleType *vt = sim->loadVehicleType(PUtil::assemblePath(val, filename), app->getSSModel()); - if (vt) { - vehiclechoices.push_back(vt); - } else { - PUtil::outLog() << "Warning: failed to load vehicle option\n"; - } - } else { - PUtil::outLog() << "Warning: vehicle option has no type\n"; - } - } else if (!strcmp(walk->Value(), "race")) { - - // TODO: check race type... laps? once only? - - vec2f coordscale = vec2f(1.0f, 1.0f); - val = walk->Attribute("coordscale"); - if (val) sscanf(val, "%f , %f", &coordscale.x, &coordscale.y); - - val = walk->Attribute("targettime"); - if (val) targettime = atof(val); - - for (TiXmlElement *walk2 = walk->FirstChildElement(); - walk2; walk2 = walk2->NextSiblingElement()) { - - if (!strcmp(walk2->Value(), "checkpoint")) { - val = walk2->Attribute("coords"); - if (val) { - vec2f coords; - if (sscanf(val, "%f , %f", &coords.x, &coords.y) == 2) { - coords.x *= coordscale.x; - coords.y *= coordscale.y; - checkpt.push_back(vec3f(coords.x, coords.y, terrain->getHeight(coords.x, coords.y))); - } else - PUtil::outLog() << "Error reading checkpoint coords\n"; - } else { - PUtil::outLog() << "Warning: checkpoint has no coords\n"; - } - } else if (!strcmp(walk2->Value(), "startposition")) { - - val = walk2->Attribute("pos"); - if (val) sscanf(val, "%f , %f , %f", &start_pos.x, &start_pos.y, &start_pos.z); - - start_pos.x *= coordscale.x; - start_pos.y *= coordscale.y; - - val = walk2->Attribute("oridegrees"); - if (val) { - float deg = atof(val); - start_ori.fromZAngle(-RADIANS(deg)); - } - - val = walk2->Attribute("ori"); - if (val) sscanf(val, "%f , %f , %f , %f", &start_ori.w, &start_ori.x, &start_ori.y, &start_ori.z); - } - } - } else if (!strcmp(walk->Value(), "weather")) { - - val = walk->Attribute("cloudtexture"); - if (val) weather.cloud.texname = PUtil::assemblePath(val, filename); - - val = walk->Attribute("cloudscrollrate"); - if (val) weather.cloud.scrollrate = atof(val); - - val = walk->Attribute("fogcolor"); - if (val) sscanf(val, "%f , %f , %f", &weather.fog.color.x, &weather.fog.color.y, &weather.fog.color.z); - - val = walk->Attribute("fogdensity"); - if (val) weather.fog.density = atof(val); - - val = walk->Attribute("fogdensitysky"); - if (val) weather.fog.density_sky = atof(val); - - val = walk->Attribute("rain"); - if (val) weather.precip.rain = atof(val); - } - } - - srand(1000); - - if (checkpt.size() == 0) { - int cpsize = 3; - - std::vector temp1; - - temp1.resize(cpsize); - - float ang = randm11 * PI; - - temp1[0] = vec2f(cosf(ang),sinf(ang)) * (100.0f + rand01 * 300.0f); - - for (int i=1; igetHeight(coords.x, coords.y)); - } - } - - for (unsigned int i=0; ictrl.brake1 = 1.0f; - } - - // get cars on ground - for (float t = 0.0f; t < 2.0f; t += 0.01f) - sim->tick(0.01f); - - /* - for (int i=1; isetGravity(vec3f(0.0,0.0,-9.81)); + + start_pos = vec3f::zero(); + start_ori = quatf::identity(); + + targettime = 754.567f; + + weather.cloud.texname = std::string(""); + weather.cloud.scrollrate = 0.001f; + weather.fog.color = vec3f(1.0f, 1.0f, 1.0f); + weather.fog.density = 0.01f; + weather.fog.density_sky = 0.8f; + weather.precip.rain = 0.0f; + + TiXmlDocument xmlfile(filename.c_str()); + TiXmlElement *rootelem = PUtil::loadRootElement(xmlfile, "level"); + if (!rootelem) return false; + + const char *val; + + val = rootelem->Attribute("comment"); + if (val) comment = val; + + for (TiXmlElement *walk = rootelem->FirstChildElement(); + walk; walk = walk->NextSiblingElement()) { + + if (!strcmp(walk->Value(), "terrain")) { + try + { + terrain = new PTerrain (walk, filename, app->getSSTexture ()); + } + catch (PException e) + { + PUtil::outLog () << "Terrain problem: " << e.what () << std::endl; + return false; + } + sim->setTerrain(terrain); + } else if (!strcmp(walk->Value(), "vehicle")) { + PVehicle *vh = sim->createVehicle(walk, filename, app->getSSModel()); + if (vh) { + vehicle.push_back(vh); + } else { + PUtil::outLog() << "Warning: failed to load vehicle\n"; + } + } else if (!strcmp(walk->Value(), "vehicleoption")) { + + val = walk->Attribute("type"); + + if (val) { + PVehicleType *vt = sim->loadVehicleType(PUtil::assemblePath(val, filename), app->getSSModel()); + if (vt) { + vehiclechoices.push_back(vt); + } else { + PUtil::outLog() << "Warning: failed to load vehicle option\n"; + } + } else { + PUtil::outLog() << "Warning: vehicle option has no type\n"; + } + } else if (!strcmp(walk->Value(), "race")) { + + // TODO: check race type... laps? once only? + + vec2f coordscale = vec2f(1.0f, 1.0f); + val = walk->Attribute("coordscale"); + if (val) sscanf(val, "%f , %f", &coordscale.x, &coordscale.y); + + val = walk->Attribute("targettime"); + if (val) targettime = atof(val); + + for (TiXmlElement *walk2 = walk->FirstChildElement(); + walk2; walk2 = walk2->NextSiblingElement()) { + + if (!strcmp(walk2->Value(), "checkpoint")) { + val = walk2->Attribute("coords"); + if (val) { + vec2f coords; + if (sscanf(val, "%f , %f", &coords.x, &coords.y) == 2) { + coords.x *= coordscale.x; + coords.y *= coordscale.y; + checkpt.push_back(vec3f(coords.x, coords.y, terrain->getHeight(coords.x, coords.y))); + } else + PUtil::outLog() << "Error reading checkpoint coords\n"; + } else { + PUtil::outLog() << "Warning: checkpoint has no coords\n"; + } + } else if (!strcmp(walk2->Value(), "startposition")) { + + val = walk2->Attribute("pos"); + if (val) sscanf(val, "%f , %f , %f", &start_pos.x, &start_pos.y, &start_pos.z); + + start_pos.x *= coordscale.x; + start_pos.y *= coordscale.y; + + val = walk2->Attribute("oridegrees"); + if (val) { + float deg = atof(val); + start_ori.fromZAngle(-RADIANS(deg)); + } + + val = walk2->Attribute("ori"); + if (val) sscanf(val, "%f , %f , %f , %f", &start_ori.w, &start_ori.x, &start_ori.y, &start_ori.z); + } + } + } else if (!strcmp(walk->Value(), "weather")) { + + val = walk->Attribute("cloudtexture"); + if (val) weather.cloud.texname = PUtil::assemblePath(val, filename); + + val = walk->Attribute("cloudscrollrate"); + if (val) weather.cloud.scrollrate = atof(val); + + val = walk->Attribute("fogcolor"); + if (val) sscanf(val, "%f , %f , %f", &weather.fog.color.x, &weather.fog.color.y, &weather.fog.color.z); + + val = walk->Attribute("fogdensity"); + if (val) weather.fog.density = atof(val); + + val = walk->Attribute("fogdensitysky"); + if (val) weather.fog.density_sky = atof(val); + + val = walk->Attribute("rain"); + if (val) weather.precip.rain = atof(val); + } + } + + srand(1000); + + if (checkpt.size() == 0) { + int cpsize = 3; + + std::vector temp1; + + temp1.resize(cpsize); + + float ang = randm11 * PI; + + temp1[0] = vec2f(cosf(ang),sinf(ang)) * (100.0f + rand01 * 300.0f); + + for (int i=1; igetHeight(coords.x, coords.y)); + } + } + + for (unsigned int i=0; ictrl.brake1 = 1.0f; + } + + // get cars on ground + for (float t = 0.0f; t < 2.0f; t += 0.01f) + sim->tick(0.01f); + + /* + for (int i=1; icreateVehicle(type, start_pos, start_ori, app->getSSModel()); - - if (vh) vehicle.push_back(vh); - else PUtil::outLog() << "Warning: failed to load vehicle\n"; + vec3f pos = vec3f::zero(); + + quatf ori = quatf::identity(); + + PVehicle *vh = sim->createVehicle(type, start_pos, start_ori, app->getSSModel()); + + if (vh) vehicle.push_back(vh); + else PUtil::outLog() << "Warning: failed to load vehicle\n"; } void TriggerGame::tick(float delta) { - - switch (gamestate) { - case GS_COUNTDOWN: - othertime -= delta; - if (othertime <= 0.0f) { - othertime = 5.0f; - gamestate = GS_RACING; - } - - for (unsigned int i=0; ictrl.setZero(); - vehicle[i]->ctrl.brake1 = 1.0f; - vehicle[i]->ctrl.brake2 = 1.0f; - } - //return; - break; - case GS_RACING: - coursetime += delta; - - if (coursetime > targettime) { - gamestate = GS_FINISHED; - } - break; - case GS_FINISHED: - othertime -= delta; - - for (unsigned int i=0; ictrl.setZero(); - vehicle[i]->ctrl.brake1 = 1.0f; - vehicle[i]->ctrl.brake2 = 1.0f; - } - - break; - } - - //vehic->getBody().addLocTorque(vec3f(50.0,0.0,0.0)); - - sim->tick(delta); - - for (unsigned int i=0; inextcp].pt) - makevec2f(vehicle[i]->body->getPosition()); - if (diff.lengthsq() < 30.0f * 30.0f) { - //vehicle[i]->nextcp = (vehicle[i]->nextcp + 1) % checkpt.size(); - if (++vehicle[i]->nextcp >= (int)checkpt.size()) { - vehicle[i]->nextcp = 0; - if (i == 0) gamestate = GS_FINISHED; - } - } - } - - /* - for (int i=0; inextcp].pt) - makevec2f(vehic->body->getPosition()); - float diffangle = -atan2(diff.y, diff.x); - - vec2f diff2 = makevec2f(checkpt[(vehic->nextcp+1)%checkpt.size()].pt) - makevec2f(checkpt[vehic->nextcp].pt); - float diff2angle = -atan2(diff2.y, diff2.x); - - vec3f forw = makevec3f(vehic->body->getOrientationMatrix().row[0]); - float forwangle = atan2(forw.y, forw.x); - - float correction = diffangle - forwangle + PI*0.5f + vehic->body->getAngularVel().z * -1.0f; - - #if 0 - float fact = diff.length() * 0.01f; - if (fact > 0.3f) fact = 0.3f; - correction += (diffangle - diff2angle) * fact; - #endif - - if (correction >= PI) { correction -= PI*2.0f; if (correction >= PI) correction -= PI*2.0f; } - if (correction < -PI) { correction += PI*2.0f; if (correction < -PI) correction += PI*2.0f; } - - vehic->ctrl.turn.z = correction * 2.0f + randm11 * 0.2f; - - vehic->ctrl.throttle = 1.0f - fabsf(correction) * 0.8f; - if (vehic->ctrl.throttle < 0.1f) - vehic->ctrl.throttle = 0.1f; - - vehic->ctrl.brake1 = 0.0f; - } - */ + + switch (gamestate) { + case GS_COUNTDOWN: + othertime -= delta; + if (othertime <= 0.0f) { + othertime = 5.0f; + gamestate = GS_RACING; + } + + for (unsigned int i=0; ictrl.setZero(); + vehicle[i]->ctrl.brake1 = 1.0f; + vehicle[i]->ctrl.brake2 = 1.0f; + } + //return; + break; + case GS_RACING: + coursetime += delta; + + if (coursetime > targettime) { + gamestate = GS_FINISHED; + } + break; + case GS_FINISHED: + othertime -= delta; + + for (unsigned int i=0; ictrl.setZero(); + vehicle[i]->ctrl.brake1 = 1.0f; + vehicle[i]->ctrl.brake2 = 1.0f; + } + + break; + } + + //vehic->getBody().addLocTorque(vec3f(50.0,0.0,0.0)); + + sim->tick(delta); + + for (unsigned int i=0; inextcp].pt) - makevec2f(vehicle[i]->body->getPosition()); + if (diff.lengthsq() < 30.0f * 30.0f) { + //vehicle[i]->nextcp = (vehicle[i]->nextcp + 1) % checkpt.size(); + cptime = coursetime; + if (++vehicle[i]->nextcp >= (int)checkpt.size()) { + vehicle[i]->nextcp = 0; + if (i == 0) gamestate = GS_FINISHED; + } + } + } + + /* + for (int i=0; inextcp].pt) - makevec2f(vehic->body->getPosition()); + float diffangle = -atan2(diff.y, diff.x); + + vec2f diff2 = makevec2f(checkpt[(vehic->nextcp+1)%checkpt.size()].pt) - makevec2f(checkpt[vehic->nextcp].pt); + float diff2angle = -atan2(diff2.y, diff2.x); + + vec3f forw = makevec3f(vehic->body->getOrientationMatrix().row[0]); + float forwangle = atan2(forw.y, forw.x); + + float correction = diffangle - forwangle + PI*0.5f + vehic->body->getAngularVel().z * -1.0f; + + #if 0 + float fact = diff.length() * 0.01f; + if (fact > 0.3f) fact = 0.3f; + correction += (diffangle - diff2angle) * fact; + #endif + + if (correction >= PI) { correction -= PI*2.0f; if (correction >= PI) correction -= PI*2.0f; } + if (correction < -PI) { correction += PI*2.0f; if (correction < -PI) correction += PI*2.0f; } + + vehic->ctrl.turn.z = correction * 2.0f + randm11 * 0.2f; + + vehic->ctrl.throttle = 1.0f - fabsf(correction) * 0.8f; + if (vehic->ctrl.throttle < 0.1f) + vehic->ctrl.throttle = 0.1f; + + vehic->ctrl.brake1 = 0.0f; + } + */ } diff -Nru trigger-rally-0.5.2.1/src/trigger/main.cpp trigger-rally-0.6.0/src/trigger/main.cpp --- trigger-rally-0.5.2.1/src/trigger/main.cpp 2006-10-20 19:35:26.000000000 +0000 +++ trigger-rally-0.6.0/src/trigger/main.cpp 2011-10-07 17:10:01.000000000 +0000 @@ -1,7 +1,7 @@ // main.cpp -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net // License: GPL version 2 (see included gpl.txt) @@ -13,966 +13,1009 @@ void MainApp::config() { - PUtil::setDebugLevel(DEBUGLEVEL_DEVELOPER); - - loadConfig(); - - setScreenMode(cfg_video_cx, cfg_video_cy, cfg_video_fullscreen); + PUtil::setDebugLevel(DEBUGLEVEL_DEVELOPER); + + loadConfig(); + + setScreenMode(cfg_video_cx, cfg_video_cy, cfg_video_fullscreen); } void MainApp::load() { - psys_dirt = null; - - audinst_engine = null; - audinst_wind = null; - audinst_gravel = null; - game = null; - - // use PUtil, not boost - //std::string buff = boost::str(boost::format("textures/splash/splash%u.jpg") % ((rand() % 3) + 1)); - //if (!(tex_splash_screen = getSSTexture().loadTexture(buff))) return false; - - if (!(tex_splash_screen = getSSTexture().loadTexture("textures/splash/splash.jpg"))) throw MakePException ("boink!"); - - appstate = AS_LOAD_1; - - loadscreencount = 3; - - splashtimeout = 2.0f; - - // Check that controls are available where requested - // (can't be done in config because joy info not available) - - for (int i = 0; i < ActionCount; i++) { - - switch(ctrl.map[i].type) { - case UserControl::TypeUnassigned: - break; - - case UserControl::TypeKey: - if (ctrl.map[i].key.sym <= 0 || ctrl.map[i].key.sym >= SDLK_LAST) - ctrl.map[i].type = UserControl::TypeUnassigned; - break; - - case UserControl::TypeJoyButton: - if (0 >= getNumJoysticks() || ctrl.map[i].joybutton.button >= getJoyNumButtons(0)) - ctrl.map[i].type = UserControl::TypeUnassigned; - break; - - case UserControl::TypeJoyAxis: - if (0 >= getNumJoysticks() || ctrl.map[i].joyaxis.axis >= getJoyNumAxes(0)) - ctrl.map[i].type = UserControl::TypeUnassigned; - break; - } - } + psys_dirt = null; + + audinst_engine = null; + audinst_wind = null; + audinst_gravel = null; + game = null; + + // use PUtil, not boost + //std::string buff = boost::str(boost::format("textures/splash/splash%u.jpg") % ((rand() % 3) + 1)); + //if (!(tex_splash_screen = getSSTexture().loadTexture(buff))) return false; + + if (!(tex_splash_screen = getSSTexture().loadTexture("textures/splash/splash.jpg"))) throw MakePException ("Failed to load splash screen"); + + appstate = AS_LOAD_1; + + loadscreencount = 3; + + splashtimeout = 0.0f; + + // Check that controls are available where requested + // (can't be done in config because joy info not available) + + for (int i = 0; i < ActionCount; i++) { + + switch(ctrl.map[i].type) { + case UserControl::TypeUnassigned: + break; + + case UserControl::TypeKey: + if (ctrl.map[i].key.sym <= 0 || ctrl.map[i].key.sym >= SDLK_LAST) + ctrl.map[i].type = UserControl::TypeUnassigned; + break; + + case UserControl::TypeJoyButton: + if (0 >= getNumJoysticks() || ctrl.map[i].joybutton.button >= getJoyNumButtons(0)) + ctrl.map[i].type = UserControl::TypeUnassigned; + break; + + case UserControl::TypeJoyAxis: + if (0 >= getNumJoysticks() || ctrl.map[i].joyaxis.axis >= getJoyNumAxes(0)) + ctrl.map[i].type = UserControl::TypeUnassigned; + break; + } + } } void MainApp::loadConfig() { - PUtil::outLog() << "Loading game configuration" << std::endl; - - // Set defaults - - cfg_video_cx = 640; - cfg_video_cy = 480; - cfg_video_fullscreen = false; - - cfg_drivingassist = 1.0f; - cfg_enable_sound = true; - - ctrl.action_name[ActionForward] = std::string("forward"); - ctrl.action_name[ActionBack] = std::string("back"); - ctrl.action_name[ActionLeft] = std::string("left"); - ctrl.action_name[ActionRight] = std::string("right"); - ctrl.action_name[ActionHandbrake] = std::string("handbrake"); - ctrl.action_name[ActionRecover] = std::string("recover"); - ctrl.action_name[ActionCamMode] = std::string("cammode"); - ctrl.action_name[ActionCamLeft] = std::string("camleft"); - ctrl.action_name[ActionCamRight] = std::string("camright"); - ctrl.action_name[ActionShowMap] = std::string("showmap"); - - for (int i = 0; i < ActionCount; i++) { - ctrl.map[i].type = UserControl::TypeUnassigned; - ctrl.map[i].value = 0.0f; - } - - // Do config file management - - std::string cfgfilename = "trigger.config"; - - if (!PHYSFS_exists(cfgfilename.c_str())) { - - PUtil::outLog() << "No user config file, copying over defaults" << std::endl; - - std::string cfgdefaults = "trigger.config.defs"; - - if (!PUtil::copyFile(cfgdefaults, cfgfilename)) { - - PUtil::outLog() << "Couldn't create user config file. Proceeding with defaults." << std::endl; - - cfgfilename = cfgdefaults; - } - } - - // Load actual settings from file - - TiXmlDocument xmlfile(cfgfilename.c_str()); - - TiXmlElement *rootelem = PUtil::loadRootElement(xmlfile, "config"); - if (!rootelem) { - PUtil::outLog() << "Error: Couldn't load configuration file" << std::endl; - PUtil::outLog() << "TinyXML: " << xmlfile.ErrorDesc() << std::endl; - PUtil::outLog() << "Your data paths are probably not set up correctly" << std::endl; - throw MakePException ("Boink"); - } - - const char *val; - - for (TiXmlElement *walk = rootelem->FirstChildElement(); - walk; walk = walk->NextSiblingElement()) { - - if (!strcmp(walk->Value(), "video")) { - - val = walk->Attribute("width"); - if (val) cfg_video_cx = atoi(val); - - val = walk->Attribute("height"); - if (val) cfg_video_cy = atoi(val); - - val = walk->Attribute("fullscreen"); - if (val) { - if (!strcmp(val, "yes")) - cfg_video_fullscreen = true; - else if (!strcmp(val, "no")) - cfg_video_fullscreen = false; - } - - val = walk->Attribute("requirergb"); - if (val) { - if (!strcmp(val, "yes")) - requireRGB(true); - else if (!strcmp(val, "no")) - requireRGB(false); - } - - val = walk->Attribute("requirealpha"); - if (val) { - if (!strcmp(val, "yes")) - requireAlpha(true); - else if (!strcmp(val, "no")) - requireAlpha(false); - } - - val = walk->Attribute("requiredepth"); - if (val) { - if (!strcmp(val, "yes")) - requireDepth(true); - else if (!strcmp(val, "no")) - requireDepth(false); - } - - val = walk->Attribute("requirestencil"); - if (val) { - if (!strcmp(val, "yes")) - requireStencil(true); - else if (!strcmp(val, "no")) - requireStencil(false); - } - - val = walk->Attribute("stereo"); - if (val) { - if (!strcmp(val, "none")) - setStereoMode(PApp::StereoNone); - else if (!strcmp(val, "quadbuffer")) - setStereoMode(PApp::StereoQuadBuffer); - else if (!strcmp(val, "red-blue")) - setStereoMode(PApp::StereoRedBlue); - else if (!strcmp(val, "red-green")) - setStereoMode(PApp::StereoRedGreen); - else if (!strcmp(val, "red-cyan")) - setStereoMode(PApp::StereoRedCyan); - else if (!strcmp(val, "yellow-blue")) - setStereoMode(PApp::StereoYellowBlue); - } - - float sepMult = 1.0f; - val = walk->Attribute("stereoswapeyes"); - if (val && !strcmp(val, "yes")) - sepMult = -1.0f; - - val = walk->Attribute("stereoeyeseparation"); - if (val) { - setStereoEyeSeperation(atof(val) * sepMult); - } - - } else if (!strcmp(walk->Value(), "parameters")) { - - val = walk->Attribute("drivingassist"); - if (val) cfg_drivingassist = atof(val); - - val = walk->Attribute("enablesound"); - if (val) { - if (!strcmp(val, "yes")) - cfg_enable_sound = true; - else if (!strcmp(val, "no")) - cfg_enable_sound = false; - } - - } else if (!strcmp(walk->Value(), "controls")) { - - for (TiXmlElement *walk2 = walk->FirstChildElement(); - walk2; walk2 = walk2->NextSiblingElement()) { - - if (!strcmp(walk2->Value(), "keyboard")) { - - val = walk2->Attribute("enable"); - if (val && !strcmp(val, "no")) - continue; - - for (TiXmlElement *walk3 = walk2->FirstChildElement(); - walk3; walk3 = walk3->NextSiblingElement()) { - - if (!strcmp(walk3->Value(), "key")) { - - val = walk3->Attribute("action"); - - int a; - for (a = 0; a < ActionCount; a++) - if (ctrl.action_name[a] == val) break; - - if (a >= ActionCount) { - PUtil::outLog() << "Config ctrls: Unknown action \"" << val << "\"" << std::endl; - continue; - } - - // TODO: implement string to keycode mapping - val = walk3->Attribute("code"); - if (!val) { - PUtil::outLog() << "Config ctrls: Key has no code" << std::endl; - continue; - } - - ctrl.map[a].type = UserControl::TypeKey; - ctrl.map[a].key.sym = (SDLKey) atoi(val); - } - } - - } else if (!strcmp(walk2->Value(), "joystick")) { - - val = walk2->Attribute("enable"); - if (val && !strcmp(val, "no")) - continue; - - for (TiXmlElement *walk3 = walk2->FirstChildElement(); - walk3; walk3 = walk3->NextSiblingElement()) { - - if (!strcmp(walk3->Value(), "button")) { - - val = walk3->Attribute("action"); - - int a; - for (a = 0; a < ActionCount; a++) - if (ctrl.action_name[a] == val) break; - - if (a >= ActionCount) { - PUtil::outLog() << "Config ctrls: Unknown action \"" << val << "\"" << std::endl; - continue; - } - - val = walk3->Attribute("index"); - if (!val) { - PUtil::outLog() << "Config ctrls: Joy button has no index" << std::endl; - continue; - } - - ctrl.map[a].type = UserControl::TypeJoyButton; - ctrl.map[a].joybutton.button = atoi(val); - - } else if (!strcmp(walk3->Value(), "axis")) { - - val = walk3->Attribute("action"); - - int a; - for (a = 0; a < ActionCount; a++) - if (ctrl.action_name[a] == val) break; - - if (a >= ActionCount) { - PUtil::outLog() << "Config ctrls: Unknown action \"" << val << "\"" << std::endl; - continue; - } - - val = walk3->Attribute("index"); - if (!val) { - PUtil::outLog() << "Config ctrls: Joy axis has no index" << std::endl; - continue; - } - - int index = atoi(val); - - bool positive; - - val = walk3->Attribute("direction"); - if (!val) { - PUtil::outLog() << "Config ctrls: Joy axis has no direction" << std::endl; - continue; - } - if (!strcmp(val, "+")) - positive = true; - else if (!strcmp(val, "-")) - positive = false; - else { - PUtil::outLog() << "Config ctrls: Joy axis direction \"" << val << - "\" is neither \"+\" nor \"-\"" << std::endl; - continue; - } - - ctrl.map[a].type = UserControl::TypeJoyAxis; - ctrl.map[a].joyaxis.axis = index; - ctrl.map[a].joyaxis.sign = positive ? 1.0f : -1.0f; - ctrl.map[a].joyaxis.deadzone = 0.0f; - ctrl.map[a].joyaxis.maxrange = 1.0f; - - val = walk3->Attribute("deadzone"); - if (val) ctrl.map[a].joyaxis.deadzone = atof(val); - - val = walk3->Attribute("maxrange"); - if (val) ctrl.map[a].joyaxis.maxrange = atof(val); - } - } - } - } - } - } + PUtil::outLog() << "Loading game configuration" << std::endl; + + // Set defaults + + cfg_video_cx = 640; + cfg_video_cy = 480; + cfg_video_fullscreen = false; + + cfg_drivingassist = 1.0f; + cfg_enable_sound = true; + cfg_speed_unit = mph; + cfg_speed_style = analogue; + + hud_speedo_start_deg = MPH_ZERO_DEG; + hud_speedo_mps_deg_mult = MPS_MPH_DEG_MULT; + hud_speedo_mps_speed_mult = MPS_MPH_SPEED_MULT; + + ctrl.action_name[ActionForward] = std::string("forward"); + ctrl.action_name[ActionBack] = std::string("back"); + ctrl.action_name[ActionLeft] = std::string("left"); + ctrl.action_name[ActionRight] = std::string("right"); + ctrl.action_name[ActionHandbrake] = std::string("handbrake"); + ctrl.action_name[ActionRecover] = std::string("recover"); + ctrl.action_name[ActionCamMode] = std::string("cammode"); + ctrl.action_name[ActionCamLeft] = std::string("camleft"); + ctrl.action_name[ActionCamRight] = std::string("camright"); + ctrl.action_name[ActionShowMap] = std::string("showmap"); + + for (int i = 0; i < ActionCount; i++) { + ctrl.map[i].type = UserControl::TypeUnassigned; + ctrl.map[i].value = 0.0f; + } + + // Do config file management + + std::string cfgfilename = "trigger.config"; + + if (!PHYSFS_exists(cfgfilename.c_str())) { + + PUtil::outLog() << "No user config file, copying over defaults" << std::endl; + + std::string cfgdefaults = "trigger.config.defs"; + + if (!PUtil::copyFile(cfgdefaults, cfgfilename)) { + + PUtil::outLog() << "Couldn't create user config file. Proceeding with defaults." << std::endl; + + cfgfilename = cfgdefaults; + } + } + + // Load actual settings from file + + TiXmlDocument xmlfile(cfgfilename.c_str()); + + TiXmlElement *rootelem = PUtil::loadRootElement(xmlfile, "config"); + if (!rootelem) { + PUtil::outLog() << "Error: Couldn't load configuration file" << std::endl; + PUtil::outLog() << "TinyXML: " << xmlfile.ErrorDesc() << std::endl; + PUtil::outLog() << "Your data paths are probably not set up correctly" << std::endl; + throw MakePException ("Boink"); + } + + const char *val; + + for (TiXmlElement *walk = rootelem->FirstChildElement(); + walk; walk = walk->NextSiblingElement()) { + + if (!strcmp(walk->Value(), "video")) { + + val = walk->Attribute("width"); + if (val) cfg_video_cx = atoi(val); + + val = walk->Attribute("height"); + if (val) cfg_video_cy = atoi(val); + + val = walk->Attribute("fullscreen"); + if (val) { + if (!strcmp(val, "yes")) + cfg_video_fullscreen = true; + else if (!strcmp(val, "no")) + cfg_video_fullscreen = false; + } + + val = walk->Attribute("requirergb"); + if (val) { + if (!strcmp(val, "yes")) + requireRGB(true); + else if (!strcmp(val, "no")) + requireRGB(false); + } + + val = walk->Attribute("requirealpha"); + if (val) { + if (!strcmp(val, "yes")) + requireAlpha(true); + else if (!strcmp(val, "no")) + requireAlpha(false); + } + + val = walk->Attribute("requiredepth"); + if (val) { + if (!strcmp(val, "yes")) + requireDepth(true); + else if (!strcmp(val, "no")) + requireDepth(false); + } + + val = walk->Attribute("requirestencil"); + if (val) { + if (!strcmp(val, "yes")) + requireStencil(true); + else if (!strcmp(val, "no")) + requireStencil(false); + } + + val = walk->Attribute("stereo"); + if (val) { + if (!strcmp(val, "none")) + setStereoMode(PApp::StereoNone); + else if (!strcmp(val, "quadbuffer")) + setStereoMode(PApp::StereoQuadBuffer); + else if (!strcmp(val, "red-blue")) + setStereoMode(PApp::StereoRedBlue); + else if (!strcmp(val, "red-green")) + setStereoMode(PApp::StereoRedGreen); + else if (!strcmp(val, "red-cyan")) + setStereoMode(PApp::StereoRedCyan); + else if (!strcmp(val, "yellow-blue")) + setStereoMode(PApp::StereoYellowBlue); + } + + float sepMult = 1.0f; + val = walk->Attribute("stereoswapeyes"); + if (val && !strcmp(val, "yes")) + sepMult = -1.0f; + + val = walk->Attribute("stereoeyeseparation"); + if (val) { + setStereoEyeSeperation(atof(val) * sepMult); + } + + } else if (!strcmp(walk->Value(), "parameters")) { + + val = walk->Attribute("drivingassist"); + if (val) cfg_drivingassist = atof(val); + + val = walk->Attribute("enablesound"); + if (val) { + if (!strcmp(val, "yes")) + cfg_enable_sound = true; + else if (!strcmp(val, "no")) + cfg_enable_sound = false; + } + + val = walk->Attribute("speedunit"); + if (val) { + if (!strcmp(val, "mph")) { + cfg_speed_unit = mph; + hud_speedo_start_deg = MPH_ZERO_DEG; + hud_speedo_mps_deg_mult = MPS_MPH_DEG_MULT; + hud_speedo_mps_speed_mult = MPS_MPH_SPEED_MULT; + } + else if (!strcmp(val, "kph")) { + cfg_speed_unit = kph; + hud_speedo_start_deg = KPH_ZERO_DEG; + hud_speedo_mps_deg_mult = MPS_KPH_DEG_MULT; + hud_speedo_mps_speed_mult = MPS_KPH_SPEED_MULT; + } + } + val = walk->Attribute("speedstyle"); + if (val) { + if (!strcmp(val, "analogue")) { + cfg_speed_style = analogue; + } + else if (!strcmp(val, "hybrid")) { + cfg_speed_style = hybrid; + } + } + + } else if (!strcmp(walk->Value(), "controls")) { + + for (TiXmlElement *walk2 = walk->FirstChildElement(); + walk2; walk2 = walk2->NextSiblingElement()) { + + if (!strcmp(walk2->Value(), "keyboard")) { + + val = walk2->Attribute("enable"); + if (val && !strcmp(val, "no")) + continue; + + for (TiXmlElement *walk3 = walk2->FirstChildElement(); + walk3; walk3 = walk3->NextSiblingElement()) { + + if (!strcmp(walk3->Value(), "key")) { + + val = walk3->Attribute("action"); + + int a; + for (a = 0; a < ActionCount; a++) + if (ctrl.action_name[a] == val) break; + + if (a >= ActionCount) { + PUtil::outLog() << "Config ctrls: Unknown action \"" << val << "\"" << std::endl; + continue; + } + + // TODO: implement string to keycode mapping + val = walk3->Attribute("code"); + if (!val) { + PUtil::outLog() << "Config ctrls: Key has no code" << std::endl; + continue; + } + + ctrl.map[a].type = UserControl::TypeKey; + ctrl.map[a].key.sym = (SDLKey) atoi(val); + } + } + + } else if (!strcmp(walk2->Value(), "joystick")) { + + val = walk2->Attribute("enable"); + if (val && !strcmp(val, "no")) + continue; + + for (TiXmlElement *walk3 = walk2->FirstChildElement(); + walk3; walk3 = walk3->NextSiblingElement()) { + + if (!strcmp(walk3->Value(), "button")) { + + val = walk3->Attribute("action"); + + int a; + for (a = 0; a < ActionCount; a++) + if (ctrl.action_name[a] == val) break; + + if (a >= ActionCount) { + PUtil::outLog() << "Config ctrls: Unknown action \"" << val << "\"" << std::endl; + continue; + } + + val = walk3->Attribute("index"); + if (!val) { + PUtil::outLog() << "Config ctrls: Joy button has no index" << std::endl; + continue; + } + + ctrl.map[a].type = UserControl::TypeJoyButton; + ctrl.map[a].joybutton.button = atoi(val); + + } else if (!strcmp(walk3->Value(), "axis")) { + + val = walk3->Attribute("action"); + + int a; + for (a = 0; a < ActionCount; a++) + if (ctrl.action_name[a] == val) break; + + if (a >= ActionCount) { + PUtil::outLog() << "Config ctrls: Unknown action \"" << val << "\"" << std::endl; + continue; + } + + val = walk3->Attribute("index"); + if (!val) { + PUtil::outLog() << "Config ctrls: Joy axis has no index" << std::endl; + continue; + } + + int index = atoi(val); + + bool positive; + + val = walk3->Attribute("direction"); + if (!val) { + PUtil::outLog() << "Config ctrls: Joy axis has no direction" << std::endl; + continue; + } + if (!strcmp(val, "+")) + positive = true; + else if (!strcmp(val, "-")) + positive = false; + else { + PUtil::outLog() << "Config ctrls: Joy axis direction \"" << val << + "\" is neither \"+\" nor \"-\"" << std::endl; + continue; + } + + ctrl.map[a].type = UserControl::TypeJoyAxis; + ctrl.map[a].joyaxis.axis = index; + ctrl.map[a].joyaxis.sign = positive ? 1.0f : -1.0f; + ctrl.map[a].joyaxis.deadzone = 0.0f; + ctrl.map[a].joyaxis.maxrange = 1.0f; + + val = walk3->Attribute("deadzone"); + if (val) ctrl.map[a].joyaxis.deadzone = atof(val); + + val = walk3->Attribute("maxrange"); + if (val) ctrl.map[a].joyaxis.maxrange = atof(val); + } + } + } + } + } + } } bool MainApp::loadLevel(TriggerLevel &tl) { - tl.name = "Untitled"; - tl.comment = ""; - tl.author = ""; - - TiXmlDocument xmlfile(tl.filename.c_str()); - TiXmlElement *rootelem = PUtil::loadRootElement(xmlfile, "level"); - if (!rootelem) { - PUtil::outLog() << "Couldn't read level \"" << tl.filename << "\"" << std::endl; - return false; - } - - const char *val; - - val = rootelem->Attribute("name"); - if (val) tl.name = val; - val = rootelem->Attribute("comment"); - if (val) tl.comment = val; - val = rootelem->Attribute("author"); - if (val) tl.author = val; - - return true; + tl.name = "Untitled"; + tl.comment = ""; + tl.author = ""; + + TiXmlDocument xmlfile(tl.filename.c_str()); + TiXmlElement *rootelem = PUtil::loadRootElement(xmlfile, "level"); + if (!rootelem) { + PUtil::outLog() << "Couldn't read level \"" << tl.filename << "\"" << std::endl; + return false; + } + + const char *val; + + val = rootelem->Attribute("name"); + if (val) tl.name = val; + val = rootelem->Attribute("comment"); + if (val) tl.comment = val; + val = rootelem->Attribute("author"); + if (val) tl.author = val; + + return true; } bool MainApp::loadLevelsAndEvents() { - PUtil::outLog() << "Loading levels and events" << std::endl; - - // Find levels - - std::list results = PUtil::findFiles("/maps", ".level"); - - for (std::list::iterator i = results.begin(); - i != results.end(); i++) { - - TriggerLevel tl; - tl.filename = *i; - - if (!loadLevel(tl)) continue; - - // Insert level in alphabetical order - std::vector::iterator j = levels.begin(); - while (j != levels.end() && j->name < tl.name) j++; - levels.insert(j, tl); - } - - // Find events - - results = PUtil::findFiles("/events", ".event"); - - for (std::list::iterator i = results.begin(); - i != results.end(); i++) { - - TriggerEvent te; - - TiXmlDocument xmlfile(i->c_str()); - TiXmlElement *rootelem = PUtil::loadRootElement(xmlfile, "event"); - if (!rootelem) { - PUtil::outLog() << "Couldn't read event \"" << *i << "\"" << std::endl; - continue; - } - - const char *val; - - val = rootelem->Attribute("name"); - if (val) te.name = val; - val = rootelem->Attribute("comment"); - if (val) te.comment = val; - val = rootelem->Attribute("author"); - if (val) te.author = val; - - for (TiXmlElement *walk = rootelem->FirstChildElement(); - walk; walk = walk->NextSiblingElement()) { - - if (!strcmp(walk->Value(), "level")) { - - TriggerLevel tl; - - val = walk->Attribute("file"); - if (!val) { - PUtil::outLog() << "Warning: Event level has no filename" << std::endl; - continue; - } - tl.filename = PUtil::assemblePath(val, *i); - - if (loadLevel(tl)) - te.levels.push_back(tl); - - PUtil::outLog() << tl.filename << std::endl; - } - } - - if (te.levels.size() <= 0) { - PUtil::outLog() << "Warning: Event has no levels" << std::endl; - continue; - } - - // Insert event in alphabetical order - std::vector::iterator j = events.begin(); - while (j != events.end() && j->name < te.name) j++; - events.insert(j, te); - } - - return true; + PUtil::outLog() << "Loading levels and events" << std::endl; + + // Find levels + + std::list results = PUtil::findFiles("/maps", ".level"); + + for (std::list::iterator i = results.begin(); + i != results.end(); i++) { + + TriggerLevel tl; + tl.filename = *i; + + if (!loadLevel(tl)) continue; + + // Insert level in alphabetical order + std::vector::iterator j = levels.begin(); + while (j != levels.end() && j->name < tl.name) j++; + levels.insert(j, tl); + } + + // Find events + + results = PUtil::findFiles("/events", ".event"); + + for (std::list::iterator i = results.begin(); + i != results.end(); i++) { + + TriggerEvent te; + + TiXmlDocument xmlfile(i->c_str()); + TiXmlElement *rootelem = PUtil::loadRootElement(xmlfile, "event"); + if (!rootelem) { + PUtil::outLog() << "Couldn't read event \"" << *i << "\"" << std::endl; + continue; + } + + const char *val; + + val = rootelem->Attribute("name"); + if (val) te.name = val; + val = rootelem->Attribute("comment"); + if (val) te.comment = val; + val = rootelem->Attribute("author"); + if (val) te.author = val; + + for (TiXmlElement *walk = rootelem->FirstChildElement(); + walk; walk = walk->NextSiblingElement()) { + + if (!strcmp(walk->Value(), "level")) { + + TriggerLevel tl; + + val = walk->Attribute("file"); + if (!val) { + PUtil::outLog() << "Warning: Event level has no filename" << std::endl; + continue; + } + tl.filename = PUtil::assemblePath(val, *i); + + if (loadLevel(tl)) + te.levels.push_back(tl); + + PUtil::outLog() << tl.filename << std::endl; + } + } + + if (te.levels.size() <= 0) { + PUtil::outLog() << "Warning: Event has no levels" << std::endl; + continue; + } + + // Insert event in alphabetical order + std::vector::iterator j = events.begin(); + while (j != events.end() && j->name < te.name) j++; + events.insert(j, te); + } + + return true; } bool MainApp::loadAll() { - if (!(tex_font = getSSTexture().loadTexture("/textures/consolefont.png"))) return false; - - if (!(tex_end_screen = getSSTexture().loadTexture("/textures/splash/endgame.jpg"))) return false; - - if (!(tex_hud_life = getSSTexture().loadTexture("/textures/life_helmet.png"))) return false; - if (!(tex_hud_arrow = getSSTexture().loadTexture("/textures/arrow.png"))) return false; - - if (!(tex_detail = getSSTexture().loadTexture("/textures/detail.jpg"))) return false; - if (!(tex_dirt = getSSTexture().loadTexture("/textures/dust.png"))) return false; - if (!(tex_shadow = getSSTexture().loadTexture("/textures/shadow.png", true, true))) return false; - - if (!(tex_hud_revs = getSSTexture().loadTexture("/textures/dial_rev.png"))) return false; - if (!(tex_hud_speedo = getSSTexture().loadTexture("/textures/dial_speed.png"))) return false; - if (!(tex_hud_gear = getSSTexture().loadTexture("/textures/dial_gear.png"))) return false; - - if (cfg_enable_sound) { - if (!(aud_engine = getSSAudio().loadSample("/sounds/engine1.wav", false))) return false; - if (!(aud_wind = getSSAudio().loadSample("/sounds/wind.wav", false))) return false; - if (!(aud_gearchange = getSSAudio().loadSample("/sounds/evo_sound/clank1.wav", false))) return false; - if (!(aud_gravel = getSSAudio().loadSample("/sounds/gravel2.wav", false))) return false; - if (!(aud_crash1 = getSSAudio().loadSample("/sounds/evo_sound/clank3.wav", false))) return false; - } - - if (!loadLevelsAndEvents()) { - PUtil::outLog() << "Couldn't load levels/events" << std::endl; - return false; - } - - //quatf tempo; - //tempo.fromThreeAxisAngle(vec3f(-0.38, -0.38, 0.0)); - //vehic->getBody().setOrientation(tempo); - - campos = campos_prev = vec3f(-15.0,0.0,30.0); - //camori.fromThreeAxisAngle(vec3f(-1.0,0.0,1.5)); - camori = quatf::identity(); - - camvel = vec3f::zero(); - - cloudscroll = 0.0f; - - cprotate = 0.0f; - - cameraview = 0; - camera_user_angle = 0.0f; - - showmap = true; - - crashnoise_timeout = 0.0f; - - psys_dirt = new DirtParticleSystem(); - psys_dirt->setColorStart(0.5f, 0.4f, 0.2f, 1.0f); - psys_dirt->setColorEnd(0.5f, 0.4f, 0.2f, 0.0f); - psys_dirt->setSize(0.1f, 0.5f); - psys_dirt->setDecay(7.0f); - psys_dirt->setTexture(tex_dirt); - psys_dirt->setBlend(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - // - - choose_type = 0; - - choose_spin = 0.0f; - - return true; + if (!(tex_font = getSSTexture().loadTexture("/textures/consolefont.png"))) return false; + + if (!(tex_end_screen = getSSTexture().loadTexture("/textures/splash/endgame.jpg"))) return false; + + if (!(tex_hud_life = getSSTexture().loadTexture("/textures/life_helmet.png"))) return false; + if (!(tex_hud_arrow = getSSTexture().loadTexture("/textures/arrow.png"))) return false; + + if (!(tex_detail = getSSTexture().loadTexture("/textures/detail.jpg"))) return false; + if (!(tex_dirt = getSSTexture().loadTexture("/textures/dust.png"))) return false; + if (!(tex_shadow = getSSTexture().loadTexture("/textures/shadow.png", true, true))) return false; + + if (!(tex_hud_revs = getSSTexture().loadTexture("/textures/dial_rev.png"))) return false; + if (cfg_speed_unit == mph) { + if (cfg_speed_style) { + if (!(tex_hud_speedo = getSSTexture().loadTexture("/textures/dial_speed_hybrid_mph.png"))) return false; + } else { + if (!(tex_hud_speedo = getSSTexture().loadTexture("/textures/dial_speed_mph.png"))) return false; + } + } else if (cfg_speed_unit == kph) { + if (cfg_speed_style) { + if (!(tex_hud_speedo = getSSTexture().loadTexture("/textures/dial_speed_hybrid_kph.png"))) return false; + } else { + if (!(tex_hud_speedo = getSSTexture().loadTexture("/textures/dial_speed_kph.png"))) return false; + } + } + if (!(tex_hud_gear = getSSTexture().loadTexture("/textures/dial_gear.png"))) return false; + + if (cfg_enable_sound) { + if (!(aud_engine = getSSAudio().loadSample("/sounds/engine1.wav", false))) return false; + if (!(aud_wind = getSSAudio().loadSample("/sounds/wind.wav", false))) return false; + if (!(aud_gearchange = getSSAudio().loadSample("/sounds/evo_sound/clank1.wav", false))) return false; + if (!(aud_gravel = getSSAudio().loadSample("/sounds/gravel2.wav", false))) return false; + if (!(aud_crash1 = getSSAudio().loadSample("/sounds/evo_sound/clank3.wav", false))) return false; + } + + if (!loadLevelsAndEvents()) { + PUtil::outLog() << "Couldn't load levels/events" << std::endl; + return false; + } + + //quatf tempo; + //tempo.fromThreeAxisAngle(vec3f(-0.38, -0.38, 0.0)); + //vehic->getBody().setOrientation(tempo); + + campos = campos_prev = vec3f(-15.0,0.0,30.0); + //camori.fromThreeAxisAngle(vec3f(-1.0,0.0,1.5)); + camori = quatf::identity(); + + camvel = vec3f::zero(); + + cloudscroll = 0.0f; + + cprotate = 0.0f; + + cameraview = 0; + camera_user_angle = 0.0f; + + showmap = true; + + crashnoise_timeout = 0.0f; + + psys_dirt = new DirtParticleSystem(); + psys_dirt->setColorStart(0.5f, 0.4f, 0.2f, 1.0f); + psys_dirt->setColorEnd(0.5f, 0.4f, 0.2f, 0.0f); + psys_dirt->setSize(0.1f, 0.5f); + psys_dirt->setDecay(7.0f); + psys_dirt->setTexture(tex_dirt); + psys_dirt->setBlend(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + // + + choose_type = 0; + + choose_spin = 0.0f; + + return true; } void MainApp::unload() { - endGame(GF_NOT_FINISHED); - - delete psys_dirt; + endGame(GF_NOT_FINISHED); + + delete psys_dirt; } bool MainApp::startGame(const std::string &filename) { - PUtil::outLog() << "Starting level \"" << filename << "\"" << std::endl; - - grabMouse(true); - - game = new TriggerGame(this); - - if (!game->loadLevel(filename)) { - PUtil::outLog() << "Error: failed to load level" << std::endl; - return false; - } - - choose_type = game->vehiclechoices.size() - 1; - - if (game->vehiclechoices.size() > 1) { - appstate = AS_CHOOSE_VEHICLE; - } else { - game->chooseVehicle(game->vehiclechoices[choose_type]); - startGame2(); - appstate = AS_IN_GAME; - } - - tex_sky[0] = null; - - if (game->weather.cloud.texname.length() > 0) - tex_sky[0] = getSSTexture().loadTexture(game->weather.cloud.texname); - - if (tex_sky[0] == null) { - tex_sky[0] = getSSTexture().loadTexture("textures/sky/blue.jpg"); - - if (tex_sky[0] == null) tex_sky[0] = tex_detail; // last fallback... - } - - return true; + PUtil::outLog() << "Starting level \"" << filename << "\"" << std::endl; + + grabMouse(true); + + game = new TriggerGame(this); + + if (!game->loadLevel(filename)) { + PUtil::outLog() << "Error: failed to load level" << std::endl; + return false; + } + + choose_type = game->vehiclechoices.size() - 1; + + if (game->vehiclechoices.size() > 1) { + appstate = AS_CHOOSE_VEHICLE; + } else { + game->chooseVehicle(game->vehiclechoices[choose_type]); + startGame2(); + appstate = AS_IN_GAME; + } + + tex_sky[0] = null; + + if (game->weather.cloud.texname.length() > 0) + tex_sky[0] = getSSTexture().loadTexture(game->weather.cloud.texname); + + if (tex_sky[0] == null) { + tex_sky[0] = getSSTexture().loadTexture("textures/sky/blue.jpg"); + + if (tex_sky[0] == null) tex_sky[0] = tex_detail; // last fallback... + } + + return true; } void MainApp::startGame2() { - if (cfg_enable_sound) { - audinst_engine = new PAudioInstance(aud_engine, true); - audinst_engine->setGain(0.0); - audinst_engine->play(); - - audinst_wind = new PAudioInstance(aud_wind, true); - audinst_wind->setGain(0.0); - audinst_wind->play(); - - audinst_gravel = new PAudioInstance(aud_gravel, true); - audinst_gravel->setGain(0.0); - audinst_gravel->play(); - } + if (cfg_enable_sound) { + audinst_engine = new PAudioInstance(aud_engine, true); + audinst_engine->setGain(0.0); + audinst_engine->play(); + + audinst_wind = new PAudioInstance(aud_wind, true); + audinst_wind->setGain(0.0); + audinst_wind->play(); + + audinst_gravel = new PAudioInstance(aud_gravel, true); + audinst_gravel->setGain(0.0); + audinst_gravel->play(); + } } void MainApp::endGame(int gamestate) { - float coursetime = (gamestate == GF_NOT_FINISHED) ? 0.0f : game->coursetime; - - if (audinst_engine) { - delete audinst_engine; - audinst_engine = null; - } - - if (audinst_wind) { - delete audinst_wind; - audinst_wind = null; - } - - if (audinst_gravel) { - delete audinst_gravel; - audinst_gravel = null; - } - - for (unsigned int i=0; icoursetime; + + if (audinst_engine) { + delete audinst_engine; + audinst_engine = null; + } + + if (audinst_wind) { + delete audinst_wind; + audinst_wind = null; + } + + if (audinst_gravel) { + delete audinst_gravel; + audinst_gravel = null; + } + + for (unsigned int i=0; i= 1.0f) - requestExit(); - break; - } + switch (appstate) { + case AS_LOAD_1: + splashtimeout -= delta; + if (--loadscreencount <= 0) + appstate = AS_LOAD_2; + break; + case AS_LOAD_2: + splashtimeout -= delta; + if (!loadAll()) { + requestExit(); + return; + } + appstate = AS_LOAD_3; + break; + case AS_LOAD_3: + splashtimeout -= delta; + if (splashtimeout <= 0.0f) + levelScreenAction(AA_INIT, 0); + break; + + case AS_LEVEL_SCREEN: + tickStateLevel(delta); + break; + + case AS_CHOOSE_VEHICLE: + tickStateChoose(delta); + break; + + case AS_IN_GAME: + tickStateGame(delta); + break; + + case AS_END_SCREEN: + splashtimeout += delta * 0.04f; + if (splashtimeout >= 1.0f) + requestExit(); + break; + } } void MainApp::tickStateChoose(float delta) { - choose_spin += delta * 2.0f; + choose_spin += delta * 2.0f; } void MainApp::tickStateGame(float delta) { - PVehicle *vehic = game->vehicle[0]; - - if (game->isFinished()) { - - int gfs = game->getFinishState(); - - endGame(gfs); - - return; - } - - cloudscroll = fmodf(cloudscroll + delta * game->weather.cloud.scrollrate, 1.0f); - - cprotate = fmodf(cprotate + delta * 1.0f, 1000.0f); - - // Do input/control processing - - for (int a = 0; a < ActionCount; a++) { - - switch(ctrl.map[a].type) { - case UserControl::TypeUnassigned: - break; - - case UserControl::TypeKey: - ctrl.map[a].value = keyDown(ctrl.map[a].key.sym) ? 1.0f : 0.0f; - break; - - case UserControl::TypeJoyButton: - ctrl.map[a].value = getJoyButton(0, ctrl.map[a].joybutton.button) ? 1.0f : 0.0f; - break; - - case UserControl::TypeJoyAxis: - ctrl.map[a].value = ctrl.map[a].joyaxis.sign * - getJoyAxis(0, ctrl.map[a].joyaxis.axis); - - RANGEADJUST(ctrl.map[a].value, ctrl.map[a].joyaxis.deadzone, ctrl.map[a].joyaxis.maxrange, 0.0f, 1.0f); - - CLAMP_LOWER(ctrl.map[a].value, 0.0f); - break; - } - } - - // Bit of a hack for turning, because you simply can't handle analogue - // and digital steering the same way, afaics - - if (ctrl.map[ActionLeft].type == UserControl::TypeJoyAxis || - ctrl.map[ActionRight].type == UserControl::TypeJoyAxis) { - - // Analogue mode - - vehic->ctrl.turn.z = 0.0f; - vehic->ctrl.turn.z -= ctrl.map[ActionLeft].value; - vehic->ctrl.turn.z += ctrl.map[ActionRight].value; - - } else { - - // Digital mode - - static float turnaccel = 0.0f; - - if (ctrl.map[ActionLeft].value > 0.0f) { - if (turnaccel > -0.0f) turnaccel = -0.0f; - turnaccel -= 8.0f * delta; - vehic->ctrl.turn.z += turnaccel * delta; - } else if (ctrl.map[ActionRight].value > 0.0f) { - if (turnaccel < 0.0f) turnaccel = 0.0f; - turnaccel += 8.0f * delta; - vehic->ctrl.turn.z += turnaccel * delta; - } else { - PULLTOWARD(turnaccel, 0.0f, delta * 5.0f); - PULLTOWARD(vehic->ctrl.turn.z, 0.0f, delta * 5.0f); - } - } - - // Computer aided steering - if (vehic->forwardspeed > 1.0f) - vehic->ctrl.turn.z -= vehic->body->getAngularVel().z * cfg_drivingassist / (1.0f + vehic->forwardspeed); - - - float throttletarget = 0.0f; - float braketarget = 0.0f; - - if (ctrl.map[ActionForward].value > 0.0f) { - if (vehic->wheel_angvel > -10.0f) - throttletarget = ctrl.map[ActionForward].value; - else - braketarget = ctrl.map[ActionForward].value; - } - if (ctrl.map[ActionBack].value > 0.0f) { - if (vehic->wheel_angvel < 10.0f) - throttletarget = -ctrl.map[ActionBack].value; - else - braketarget = ctrl.map[ActionBack].value; - } - - PULLTOWARD(vehic->ctrl.throttle, throttletarget, delta * 15.0f); - PULLTOWARD(vehic->ctrl.brake1, braketarget, delta * 25.0f); - - vehic->ctrl.brake2 = ctrl.map[ActionHandbrake].value; - - - //PULLTOWARD(vehic->ctrl.aim.x, 0.0, delta * 2.0); - //PULLTOWARD(vehic->ctrl.aim.y, 0.0, delta * 2.0); - - game->tick(delta); - - #if 1 - for (unsigned int i=0; ivehicle.size(); i++) { - for (unsigned int j=0; jvehicle[i]->part.size(); j++) { - for (unsigned int k=0; kvehicle[i]->part[j].wheel.size(); k++) { - if (rand01 * 20.0f < game->vehicle[i]->part[j].wheel[k].dirtthrow) - psys_dirt->addParticle( - game->vehicle[i]->part[j].wheel[k].dirtthrowpos, - game->vehicle[i]->part[j].wheel[k].dirtthrowvec + vec3f::rand() * 10.0f); - } - } - } - #endif - - float angtarg = 0.0f; - angtarg -= ctrl.map[ActionCamLeft].value; - angtarg += ctrl.map[ActionCamRight].value; - angtarg *= PI*0.75f; - - PULLTOWARD(camera_user_angle, angtarg, delta * 4.0f); - - quatf tempo; - //tempo.fromThreeAxisAngle(vec3f(-1.3,0.0,0.0)); - - // allow temporary camera view changes for this frame - int cameraview_mod = cameraview; - - if (game->gamestate == GS_FINISHED) { - cameraview_mod = 0; - static float spinner = 0.0f; - spinner += 1.4f * delta; - tempo.fromThreeAxisAngle(vec3f(-PI*0.5f,0.0f,spinner)); - } else { - tempo.fromThreeAxisAngle(vec3f(-PI*0.5f,0.0f,0.0f)); - } - - renderowncar = (cameraview_mod != 1); - - campos_prev = campos; - - //PReferenceFrame *rf = &vehic->part[2].ref_world; - PReferenceFrame *rf = &vehic->getBody(); - - vec3f forw = makevec3f(rf->getOrientationMatrix().row[0]); - float forwangle = atan2(forw.y, forw.x); - - mat44f cammat; - - switch (cameraview_mod) { + PVehicle *vehic = game->vehicle[0]; + + if (game->isFinished()) { + + int gfs = game->getFinishState(); + + endGame(gfs); + + return; + } + + cloudscroll = fmodf(cloudscroll + delta * game->weather.cloud.scrollrate, 1.0f); + + cprotate = fmodf(cprotate + delta * 1.0f, 1000.0f); + + // Do input/control processing + + for (int a = 0; a < ActionCount; a++) { + + switch(ctrl.map[a].type) { + case UserControl::TypeUnassigned: + break; + + case UserControl::TypeKey: + ctrl.map[a].value = keyDown(ctrl.map[a].key.sym) ? 1.0f : 0.0f; + break; + + case UserControl::TypeJoyButton: + ctrl.map[a].value = getJoyButton(0, ctrl.map[a].joybutton.button) ? 1.0f : 0.0f; + break; + + case UserControl::TypeJoyAxis: + ctrl.map[a].value = ctrl.map[a].joyaxis.sign * + getJoyAxis(0, ctrl.map[a].joyaxis.axis); + + RANGEADJUST(ctrl.map[a].value, ctrl.map[a].joyaxis.deadzone, ctrl.map[a].joyaxis.maxrange, 0.0f, 1.0f); + + CLAMP_LOWER(ctrl.map[a].value, 0.0f); + break; + } + } + + // Bit of a hack for turning, because you simply can't handle analogue + // and digital steering the same way, afaics + + if (ctrl.map[ActionLeft].type == UserControl::TypeJoyAxis || + ctrl.map[ActionRight].type == UserControl::TypeJoyAxis) { + + // Analogue mode + + vehic->ctrl.turn.z = 0.0f; + vehic->ctrl.turn.z -= ctrl.map[ActionLeft].value; + vehic->ctrl.turn.z += ctrl.map[ActionRight].value; + + } else { + + // Digital mode + + static float turnaccel = 0.0f; + + if (ctrl.map[ActionLeft].value > 0.0f) { + if (turnaccel > -0.0f) turnaccel = -0.0f; + turnaccel -= 8.0f * delta; + vehic->ctrl.turn.z += turnaccel * delta; + } else if (ctrl.map[ActionRight].value > 0.0f) { + if (turnaccel < 0.0f) turnaccel = 0.0f; + turnaccel += 8.0f * delta; + vehic->ctrl.turn.z += turnaccel * delta; + } else { + PULLTOWARD(turnaccel, 0.0f, delta * 5.0f); + PULLTOWARD(vehic->ctrl.turn.z, 0.0f, delta * 5.0f); + } + } + + // Computer aided steering + if (vehic->forwardspeed > 1.0f) + vehic->ctrl.turn.z -= vehic->body->getAngularVel().z * cfg_drivingassist / (1.0f + vehic->forwardspeed); + + + float throttletarget = 0.0f; + float braketarget = 0.0f; + + if (ctrl.map[ActionForward].value > 0.0f) { + if (vehic->wheel_angvel > -10.0f) + throttletarget = ctrl.map[ActionForward].value; + else + braketarget = ctrl.map[ActionForward].value; + } + if (ctrl.map[ActionBack].value > 0.0f) { + if (vehic->wheel_angvel < 10.0f) + throttletarget = -ctrl.map[ActionBack].value; + else + braketarget = ctrl.map[ActionBack].value; + } + + PULLTOWARD(vehic->ctrl.throttle, throttletarget, delta * 15.0f); + PULLTOWARD(vehic->ctrl.brake1, braketarget, delta * 25.0f); + + vehic->ctrl.brake2 = ctrl.map[ActionHandbrake].value; + + + //PULLTOWARD(vehic->ctrl.aim.x, 0.0, delta * 2.0); + //PULLTOWARD(vehic->ctrl.aim.y, 0.0, delta * 2.0); + + game->tick(delta); + + #if 1 + for (unsigned int i=0; ivehicle.size(); i++) { + for (unsigned int j=0; jvehicle[i]->part.size(); j++) { + for (unsigned int k=0; kvehicle[i]->part[j].wheel.size(); k++) { + if (rand01 * 20.0f < game->vehicle[i]->part[j].wheel[k].dirtthrow) + psys_dirt->addParticle( + game->vehicle[i]->part[j].wheel[k].dirtthrowpos, + game->vehicle[i]->part[j].wheel[k].dirtthrowvec + vec3f::rand() * 10.0f); + } + } + } + #endif + + float angtarg = 0.0f; + angtarg -= ctrl.map[ActionCamLeft].value; + angtarg += ctrl.map[ActionCamRight].value; + angtarg *= PI*0.75f; + + PULLTOWARD(camera_user_angle, angtarg, delta * 4.0f); + + quatf tempo; + //tempo.fromThreeAxisAngle(vec3f(-1.3,0.0,0.0)); + + // allow temporary camera view changes for this frame + int cameraview_mod = cameraview; + + if (game->gamestate == GS_FINISHED) { + cameraview_mod = 0; + static float spinner = 0.0f; + spinner += 1.4f * delta; + tempo.fromThreeAxisAngle(vec3f(-PI*0.5f,0.0f,spinner)); + } else { + tempo.fromThreeAxisAngle(vec3f(-PI*0.5f,0.0f,0.0f)); + } + + renderowncar = (cameraview_mod != 1); + + campos_prev = campos; + + //PReferenceFrame *rf = &vehic->part[2].ref_world; + PReferenceFrame *rf = &vehic->getBody(); + + vec3f forw = makevec3f(rf->getOrientationMatrix().row[0]); + float forwangle = atan2(forw.y, forw.x); + + mat44f cammat; + + switch (cameraview_mod) { default: - case 0: { - quatf temp2; - temp2.fromZAngle(forwangle + camera_user_angle); - - quatf target = tempo * temp2; - - if (target.dot(camori) < 0.0f) target = target * -1.0f; - - PULLTOWARD(camori, target, delta * 3.0f); - - camori.normalize(); - - cammat = camori.getMatrix(); - cammat = cammat.transpose(); - //campos = rf->getPosition() + makevec3f(cammat.row[2]) * 100.0; - campos = rf->getPosition() + - makevec3f(cammat.row[1]) * 1.6f + - makevec3f(cammat.row[2]) * 5.0f; - } break; - - case 1: { - quatf temp2; - temp2.fromZAngle(camera_user_angle); - - quatf target = tempo * temp2 * rf->ori; - - if (target.dot(camori) < 0.0f) target = target * -1.0f; - - PULLTOWARD(camori, target, delta * 25.0f); - - camori.normalize(); - - cammat = camori.getMatrix(); - cammat = cammat.transpose(); - const mat44f &rfmat = rf->getInverseOrientationMatrix(); - //campos = rf->getPosition() + makevec3f(cammat.row[2]) * 100.0; - campos = rf->getPosition() + - makevec3f(rfmat.row[1]) * 1.7f + - makevec3f(rfmat.row[2]) * 0.4f; - } break; - - case 2: { - quatf temp2; - temp2.fromZAngle(camera_user_angle); - - quatf target = tempo * temp2 * rf->ori; - - if (target.dot(camori) < 0.0f) target = target * -1.0f; - - //PULLTOWARD(camori, target, delta * 25.0f); - camori = target; - - camori.normalize(); - - cammat = camori.getMatrix(); - cammat = cammat.transpose(); - const mat44f &rfmat = rf->getInverseOrientationMatrix(); - //campos = rf->getPosition() + makevec3f(cammat.row[2]) * 100.0; - campos = rf->getPosition() + - makevec3f(rfmat.row[0]) * 1.1f + - makevec3f(rfmat.row[1]) * 0.3f + - makevec3f(rfmat.row[2]) * 0.1f; - } break; - } - - forw = makevec3f(cammat.row[0]); - camera_angle = atan2(forw.y, forw.x); - - vec2f diff = makevec2f(game->checkpt[vehic->nextcp].pt) - makevec2f(vehic->body->getPosition()); - nextcpangle = -atan2(diff.y, diff.x) - forwangle + PI*0.5f; - - if (cfg_enable_sound) { - audinst_engine->setGain(0.5f); - audinst_engine->setPitch(vehic->getEngineRPM() / 7500.0f); - - float windlevel = fabsf(vehic->forwardspeed) * 0.6f; - - audinst_wind->setGain(windlevel * 0.03f); - audinst_wind->setPitch(windlevel * 0.02f + 0.9f); - - audinst_gravel->setGain(vehic->getSkidLevel() * 0.2f); - audinst_gravel->setPitch(1.0f);//vehic->getEngineRPM() / 7500.0f); - - if (vehic->getFlagGearChange()) { - audinst.push_back(new PAudioInstance(aud_gearchange)); - audinst.back()->setPitch(1.0f + randm11*0.02f); - audinst.back()->setGain(0.4f); - audinst.back()->play(); - } - - if (crashnoise_timeout <= 0.0f) { - float crashlevel = vehic->getCrashNoiseLevel(); - if (crashlevel > 0.0f) { - audinst.push_back(new PAudioInstance(aud_crash1)); - audinst.back()->setPitch(1.0f + randm11*0.02f); - audinst.back()->setGain(logf(1.0f + crashlevel)); - audinst.back()->play(); - } - crashnoise_timeout = rand01 * 0.1f + 0.01f; - } else { - crashnoise_timeout -= delta; - } - - for (unsigned int i=0; iisPlaying()) { - delete audinst[i]; - audinst.erase(audinst.begin() + i); - i--; - continue; - } - } - } - - psys_dirt->tick(delta); - + case 0: { + quatf temp2; + temp2.fromZAngle(forwangle + camera_user_angle); + + quatf target = tempo * temp2; + + if (target.dot(camori) < 0.0f) target = target * -1.0f; + + PULLTOWARD(camori, target, delta * 3.0f); + + camori.normalize(); + + cammat = camori.getMatrix(); + cammat = cammat.transpose(); + //campos = rf->getPosition() + makevec3f(cammat.row[2]) * 100.0; + campos = rf->getPosition() + + makevec3f(cammat.row[1]) * 1.6f + + makevec3f(cammat.row[2]) * 5.0f; + } break; + + case 1: { + quatf temp2; + temp2.fromZAngle(camera_user_angle); + + quatf target = tempo * temp2 * rf->ori; + + if (target.dot(camori) < 0.0f) target = target * -1.0f; + + PULLTOWARD(camori, target, delta * 25.0f); + + camori.normalize(); + + cammat = camori.getMatrix(); + cammat = cammat.transpose(); + const mat44f &rfmat = rf->getInverseOrientationMatrix(); + //campos = rf->getPosition() + makevec3f(cammat.row[2]) * 100.0; + campos = rf->getPosition() + + makevec3f(rfmat.row[1]) * 1.7f + + makevec3f(rfmat.row[2]) * 0.4f; + } break; + + case 2: { + quatf temp2; + temp2.fromZAngle(camera_user_angle); + + quatf target = tempo * temp2 * rf->ori; + + if (target.dot(camori) < 0.0f) target = target * -1.0f; + + //PULLTOWARD(camori, target, delta * 25.0f); + camori = target; + + camori.normalize(); + + cammat = camori.getMatrix(); + cammat = cammat.transpose(); + const mat44f &rfmat = rf->getInverseOrientationMatrix(); + //campos = rf->getPosition() + makevec3f(cammat.row[2]) * 100.0; + campos = rf->getPosition() + + makevec3f(rfmat.row[0]) * 1.1f + + makevec3f(rfmat.row[1]) * 0.3f + + makevec3f(rfmat.row[2]) * 0.1f; + } break; + } + + forw = makevec3f(cammat.row[0]); + camera_angle = atan2(forw.y, forw.x); + + vec2f diff = makevec2f(game->checkpt[vehic->nextcp].pt) - makevec2f(vehic->body->getPosition()); + nextcpangle = -atan2(diff.y, diff.x) - forwangle + PI*0.5f; + + if (cfg_enable_sound) { + audinst_engine->setGain(0.5f); + audinst_engine->setPitch(vehic->getEngineRPM() / 7500.0f); + + float windlevel = fabsf(vehic->forwardspeed) * 0.6f; + + audinst_wind->setGain(windlevel * 0.03f); + audinst_wind->setPitch(windlevel * 0.02f + 0.9f); + + audinst_gravel->setGain(vehic->getSkidLevel() * 0.2f); + audinst_gravel->setPitch(1.0f);//vehic->getEngineRPM() / 7500.0f); + + if (vehic->getFlagGearChange()) { + audinst.push_back(new PAudioInstance(aud_gearchange)); + audinst.back()->setPitch(1.0f + randm11*0.02f); + audinst.back()->setGain(0.4f); + audinst.back()->play(); + } + + if (crashnoise_timeout <= 0.0f) { + float crashlevel = vehic->getCrashNoiseLevel(); + if (crashlevel > 0.0f) { + audinst.push_back(new PAudioInstance(aud_crash1)); + audinst.back()->setPitch(1.0f + randm11*0.02f); + audinst.back()->setGain(logf(1.0f + crashlevel)); + audinst.back()->play(); + } + crashnoise_timeout = rand01 * 0.1f + 0.01f; + } else { + crashnoise_timeout -= delta; + } + + for (unsigned int i=0; iisPlaying()) { + delete audinst[i]; + audinst.erase(audinst.begin() + i); + i--; + continue; + } + } + } + + psys_dirt->tick(delta); + #define RAIN_START_LIFE 0.6f #define RAIN_POS_RANDOM 15.0f #define RAIN_VEL_RANDOM 2.0f - - const vec3f def_drop_vect(2.5f,0.0f,17.0f); - - vec3f camvel = (campos - campos_prev) * (1.0f / delta); - - // randomised number of drops calculation - float numdrops = game->weather.precip.rain * delta; - int inumdrops = (int)numdrops; - if (rand01 < numdrops - inumdrops) inumdrops++; - for (int i=0; iterrain->getHeight(rain.back().drop_pt.x, rain.back().drop_pt.y); - rain.back().drop_vect = def_drop_vect + vec3f::rand() * RAIN_VEL_RANDOM; - rain.back().life = RAIN_START_LIFE; - } - - // update life and delete dead raindrops - unsigned int j=0; - for (unsigned int i = 0; i < rain.size(); i++) { - if (rain[i].life <= 0.0f) continue; - rain[j] = rain[i]; - rain[j].prevlife = rain[j].life; - rain[j].life -= delta; - if (rain[j].life < 0.0f) - rain[j].life = 0.0f; // will be deleted next time round - j++; - } - rain.resize(j); - - // update stuff for SSRender - - cam_pos = campos; - cam_orimat = cammat; - cam_linvel = camvel; + + const vec3f def_drop_vect(2.5f,0.0f,17.0f); + + vec3f camvel = (campos - campos_prev) * (1.0f / delta); + + // randomised number of drops calculation + float numdrops = game->weather.precip.rain * delta; + int inumdrops = (int)numdrops; + if (rand01 < numdrops - inumdrops) inumdrops++; + for (int i=0; iterrain->getHeight(rain.back().drop_pt.x, rain.back().drop_pt.y); + rain.back().drop_vect = def_drop_vect + vec3f::rand() * RAIN_VEL_RANDOM; + rain.back().life = RAIN_START_LIFE; + } + + // update life and delete dead raindrops + unsigned int j=0; + for (unsigned int i = 0; i < rain.size(); i++) { + if (rain[i].life <= 0.0f) continue; + rain[j] = rain[i]; + rain[j].prevlife = rain[j].life; + rain[j].life -= delta; + if (rain[j].life < 0.0f) + rain[j].life = 0.0f; // will be deleted next time round + j++; + } + rain.resize(j); + + // update stuff for SSRender + + cam_pos = campos; + cam_orimat = cammat; + cam_linvel = camvel; } // TODO: mark instant events with flags, deal with them in tick() @@ -981,167 +1024,167 @@ void MainApp::keyEvent(const SDL_KeyboardEvent &ke) { - if (ke.type == SDL_KEYDOWN) { - - if (ke.keysym.sym == SDLK_F12) { - saveScreenshot(); - return; - } - - switch (appstate) { - case AS_LOAD_1: - case AS_LOAD_2: - // no hitting escape allowed... end screen not loaded! - return; - case AS_LOAD_3: - levelScreenAction(AA_INIT, 0); - return; - case AS_LEVEL_SCREEN: - handleLevelScreenKey(ke); - return; - case AS_CHOOSE_VEHICLE: - - if (ctrl.map[ActionLeft].type == UserControl::TypeKey && - ctrl.map[ActionLeft].key.sym == ke.keysym.sym) { - if (--choose_type < 0) - choose_type = (int)game->vehiclechoices.size()-1; - return; - } - if (ctrl.map[ActionRight].type == UserControl::TypeKey && - ctrl.map[ActionRight].key.sym == ke.keysym.sym) { - if (++choose_type >= (int)game->vehiclechoices.size()) - choose_type = 0; - return; - } - - switch (ke.keysym.sym) { - case SDLK_RETURN: - case SDLK_KP_ENTER: - startGame2(); - game->chooseVehicle(game->vehiclechoices[choose_type]); - appstate = AS_IN_GAME; - return; - case SDLK_ESCAPE: - endGame(GF_NOT_FINISHED); - return; - default: - break; - } - break; - case AS_IN_GAME: - - if (ctrl.map[ActionRecover].type == UserControl::TypeKey && - ctrl.map[ActionRecover].key.sym == ke.keysym.sym) { - game->vehicle[0]->doReset(); - return; - } - if (ctrl.map[ActionCamMode].type == UserControl::TypeKey && - ctrl.map[ActionCamMode].key.sym == ke.keysym.sym) { - cameraview = (cameraview + 1) % 3; - camera_user_angle = 0.0f; - return; - } - if (ctrl.map[ActionShowMap].type == UserControl::TypeKey && - ctrl.map[ActionShowMap].key.sym == ke.keysym.sym) { - showmap = !showmap; - return; - } - - switch (ke.keysym.sym) { - case SDLK_ESCAPE: - endGame(GF_FAIL); - return; - default: - break; - } - break; - case AS_END_SCREEN: - requestExit(); - return; - } - - switch (ke.keysym.sym) { - case SDLK_ESCAPE: - quitGame(); - return; - default: - break; - } - } + if (ke.type == SDL_KEYDOWN) { + + if (ke.keysym.sym == SDLK_F12) { + saveScreenshot(); + return; + } + + switch (appstate) { + case AS_LOAD_1: + case AS_LOAD_2: + // no hitting escape allowed... end screen not loaded! + return; + case AS_LOAD_3: + levelScreenAction(AA_INIT, 0); + return; + case AS_LEVEL_SCREEN: + handleLevelScreenKey(ke); + return; + case AS_CHOOSE_VEHICLE: + + if (ctrl.map[ActionLeft].type == UserControl::TypeKey && + ctrl.map[ActionLeft].key.sym == ke.keysym.sym) { + if (--choose_type < 0) + choose_type = (int)game->vehiclechoices.size()-1; + return; + } + if (ctrl.map[ActionRight].type == UserControl::TypeKey && + ctrl.map[ActionRight].key.sym == ke.keysym.sym) { + if (++choose_type >= (int)game->vehiclechoices.size()) + choose_type = 0; + return; + } + + switch (ke.keysym.sym) { + case SDLK_RETURN: + case SDLK_KP_ENTER: + startGame2(); + game->chooseVehicle(game->vehiclechoices[choose_type]); + appstate = AS_IN_GAME; + return; + case SDLK_ESCAPE: + endGame(GF_NOT_FINISHED); + return; + default: + break; + } + break; + case AS_IN_GAME: + + if (ctrl.map[ActionRecover].type == UserControl::TypeKey && + ctrl.map[ActionRecover].key.sym == ke.keysym.sym) { + game->vehicle[0]->doReset(); + return; + } + if (ctrl.map[ActionCamMode].type == UserControl::TypeKey && + ctrl.map[ActionCamMode].key.sym == ke.keysym.sym) { + cameraview = (cameraview + 1) % 3; + camera_user_angle = 0.0f; + return; + } + if (ctrl.map[ActionShowMap].type == UserControl::TypeKey && + ctrl.map[ActionShowMap].key.sym == ke.keysym.sym) { + showmap = !showmap; + return; + } + + switch (ke.keysym.sym) { + case SDLK_ESCAPE: + endGame(GF_FAIL); + return; + default: + break; + } + break; + case AS_END_SCREEN: + requestExit(); + return; + } + + switch (ke.keysym.sym) { + case SDLK_ESCAPE: + quitGame(); + return; + default: + break; + } + } } void MainApp::mouseMoveEvent(int dx, int dy) { - //PVehicle *vehic = game->vehicle[0]; - - //vehic->ctrl.tank.turret_turn.x += dx * -0.002; - //vehic->ctrl.tank.turret_turn.y += dy * 0.002; - - //vehic->ctrl.turn.x += dy * 0.005; - //vehic->ctrl.turn.y += dx * -0.005; - - dy = dy; - - if (appstate == AS_IN_GAME) { - PVehicle *vehic = game->vehicle[0]; - vehic->ctrl.turn.z += dx * 0.01f; - } + //PVehicle *vehic = game->vehicle[0]; + + //vehic->ctrl.tank.turret_turn.x += dx * -0.002; + //vehic->ctrl.tank.turret_turn.y += dy * 0.002; + + //vehic->ctrl.turn.x += dy * 0.005; + //vehic->ctrl.turn.y += dx * -0.005; + + dy = dy; + + if (appstate == AS_IN_GAME) { + PVehicle *vehic = game->vehicle[0]; + vehic->ctrl.turn.z += dx * 0.01f; + } } void MainApp::joyButtonEvent(int which, int button, bool down) { - if (which == 0 && down) { - - switch (appstate) { - case AS_CHOOSE_VEHICLE: - - if (ctrl.map[ActionLeft].type == UserControl::TypeJoyButton && - ctrl.map[ActionLeft].joybutton.button == button) { - if (--choose_type < 0) - choose_type = (int)game->vehiclechoices.size()-1; - return; - } - if (ctrl.map[ActionRight].type == UserControl::TypeJoyButton && - ctrl.map[ActionRight].joybutton.button == button) { - if (++choose_type >= (int)game->vehiclechoices.size()) - choose_type = 0; - return; - } - - break; - - case AS_IN_GAME: - - if (ctrl.map[ActionRecover].type == UserControl::TypeJoyButton && - ctrl.map[ActionRecover].joybutton.button == button) { - game->vehicle[0]->doReset(); - return; - } - if (ctrl.map[ActionCamMode].type == UserControl::TypeJoyButton && - ctrl.map[ActionCamMode].joybutton.button == button) { - cameraview = (cameraview + 1) % 3; - camera_user_angle = 0.0f; - return; - } - if (ctrl.map[ActionShowMap].type == UserControl::TypeJoyButton && - ctrl.map[ActionShowMap].joybutton.button == button) { - showmap = !showmap; - return; - } - } - } + if (which == 0 && down) { + + switch (appstate) { + case AS_CHOOSE_VEHICLE: + + if (ctrl.map[ActionLeft].type == UserControl::TypeJoyButton && + ctrl.map[ActionLeft].joybutton.button == button) { + if (--choose_type < 0) + choose_type = (int)game->vehiclechoices.size()-1; + return; + } + if (ctrl.map[ActionRight].type == UserControl::TypeJoyButton && + ctrl.map[ActionRight].joybutton.button == button) { + if (++choose_type >= (int)game->vehiclechoices.size()) + choose_type = 0; + return; + } + + break; + + case AS_IN_GAME: + + if (ctrl.map[ActionRecover].type == UserControl::TypeJoyButton && + ctrl.map[ActionRecover].joybutton.button == button) { + game->vehicle[0]->doReset(); + return; + } + if (ctrl.map[ActionCamMode].type == UserControl::TypeJoyButton && + ctrl.map[ActionCamMode].joybutton.button == button) { + cameraview = (cameraview + 1) % 3; + camera_user_angle = 0.0f; + return; + } + if (ctrl.map[ActionShowMap].type == UserControl::TypeJoyButton && + ctrl.map[ActionShowMap].joybutton.button == button) { + showmap = !showmap; + return; + } + } + } } int main(int argc, char *argv[]) { - MainApp *game = new MainApp("Trigger", ".trigger"); + MainApp *game = new MainApp("Trigger", ".trigger"); - int ret = game->run(argc, argv); + int ret = game->run(argc, argv); - delete game; + delete game; - return ret; + return ret; } diff -Nru trigger-rally-0.5.2.1/src/trigger/main.h trigger-rally-0.6.0/src/trigger/main.h --- trigger-rally-0.5.2.1/src/trigger/main.h 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/trigger/main.h 2011-10-07 17:10:01.000000000 +0000 @@ -1,344 +1,361 @@ - -// main.h - -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net -// License: GPL version 2 (see included gpl.txt) - - -#include "../pengine/pengine.h" - -#include "../psim/psim.h" - - - -// Forward declaration for TriggerGame to use -class MainApp; - - - - -struct CheckPoint { - vec3f pt; - - CheckPoint(const vec3f &_pt) : pt(_pt) { } -}; - -/* -struct AIDriver { - int vehic; - - AIDriver(int v) : vehic(v) { } -}; -*/ - - -#define GS_COUNTDOWN 0 -#define GS_RACING 1 -#define GS_FINISHED 2 - -#define GF_NOT_FINISHED 0 -#define GF_PASS 1 -#define GF_FAIL 2 - - -class TriggerGame { - friend class MainApp; - -private: - MainApp *app; - - PSim *sim; - - int randomseed; - - std::vector vehicle; - - //std::vector aid; - - PTerrain *terrain; - - std::vector checkpt; - - int gamestate; - - float coursetime; - float othertime; // used pre and post race - float targettime; // the time needed to win - - std::string comment; // level comment string - - vec3f start_pos; - quatf start_ori; - - struct { - struct { - std::string texname; - float scrollrate; - } cloud; - struct { - vec3f color; - float density; - float density_sky; - } fog; - struct { - float rain; - } precip; - } weather; - -public: - std::vector vehiclechoices; - -public: - TriggerGame(MainApp *parent); - ~TriggerGame(); - - bool loadLevel(const std::string &filename); - - void chooseVehicle(PVehicleType *type); - - void tick(float delta); - - bool isFinished() { return (gamestate == GS_FINISHED) && (othertime <= 0.0f); } - int getFinishState() { - if (gamestate != GS_FINISHED) return GF_NOT_FINISHED; - if (coursetime <= targettime) return GF_PASS; - else return GF_FAIL; - } -}; - - -#include "menu.h" - - -#define AS_LOAD_1 1 -#define AS_LOAD_2 2 -#define AS_LOAD_3 3 -#define AS_LEVEL_SCREEN 10 -#define AS_CHOOSE_VEHICLE 11 -#define AS_IN_GAME 12 -#define AS_END_SCREEN 13 - - - -struct TriggerLevel { - std::string filename, name, comment, author; -}; - -struct TriggerEvent { - std::string filename, name, comment, author; - - // Note that levels are not linked to... they are - // stored in the event because an event may have - // "hidden" levels not otherwise available - - std::vector levels; -}; - - -class DirtParticleSystem : public PParticleSystem { -public: - void tick(float delta) { - - PParticleSystem::tick(delta); - - for (unsigned int i=0; i levels; - std::vector events; - - // for level screen - Gui gui; - LevelState lss; - - // - - TriggerGame *game; - - PVehicleType *vt_tank; - - PTexture *tex_font; - - PTexture *tex_detail, - *tex_sky[1], - *tex_water, - *tex_dirt, - *tex_shadow, - *tex_hud_revs, - *tex_hud_speedo, - *tex_hud_gear, - *tex_hud_life, - *tex_hud_arrow, - *tex_splash_screen, - *tex_end_screen; - - DirtParticleSystem *psys_dirt; - - PAudioSample *aud_engine, - *aud_wind, - *aud_gearchange, - *aud_gravel, - *aud_crash1; - - PAudioInstance *audinst_engine, *audinst_wind, *audinst_gravel; - std::vector audinst; - - float cloudscroll; - - vec3f campos, campos_prev; - quatf camori; - - vec3f camvel; - - float nextcpangle; - - float cprotate; - - int cameraview; - float camera_angle; - float camera_user_angle; - - bool renderowncar; // this is determined from cameraview - - bool showmap; - - float crashnoise_timeout; - - std::vector rain; - - // - - int loadscreencount; - - float choose_spin; - - int choose_type; - -protected: - void renderWater(); - void renderSky(const mat44f &cammat); - - bool startGame(const std::string &filename); - void startGame2(); - void endGame(int gamestate); - - void quitGame() { - endGame(GF_NOT_FINISHED); - splashtimeout = 0.0f; - appstate = AS_END_SCREEN; - } - - void levelScreenAction(int action, int index); - void handleLevelScreenKey(const SDL_KeyboardEvent &ke); - void finishRace(int gamestate, float coursetime); - -public: - MainApp(const std::string &title, const std::string &name) : PApp(title, name) { } - //MainApp::~MainApp(); // should not have destructor, use unload - - void config(); - void load(); - void unload(); - - void loadConfig(); - bool loadAll(); - bool loadLevelsAndEvents(); - bool loadLevel(TriggerLevel &tl); - - void tick(float delta); - - void resize(); - void render(float eyetranslation); - - void renderStateLoading(float eyetranslation); - void renderStateEnd(float eyetranslation); - void tickStateLevel(float delta); - void renderStateLevel(float eyetranslation); - void tickStateChoose(float delta); - void renderStateChoose(float eyetranslation); - void tickStateGame(float delta); - void renderStateGame(float eyetranslation); - - void keyEvent(const SDL_KeyboardEvent &ke); - void mouseMoveEvent(int dx, int dy); - void cursorMoveEvent(int posx, int posy); - void mouseButtonEvent(const SDL_MouseButtonEvent &mbe); - void joyButtonEvent(int which, int button, bool down); -}; - - - - + +// main.h + +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net +// License: GPL version 2 (see included gpl.txt) + + +#include "../pengine/pengine.h" + +#include "../psim/psim.h" + + + +// Forward declaration for TriggerGame to use +class MainApp; + + + + +struct CheckPoint { + vec3f pt; + + CheckPoint(const vec3f &_pt) : pt(_pt) { } +}; + +/* +struct AIDriver { + int vehic; + + AIDriver(int v) : vehic(v) { } +}; +*/ + + +#define GS_COUNTDOWN 0 +#define GS_RACING 1 +#define GS_FINISHED 2 + +#define GF_NOT_FINISHED 0 +#define GF_PASS 1 +#define GF_FAIL 2 + + +class TriggerGame { + friend class MainApp; + +private: + MainApp *app; + + PSim *sim; + + int randomseed; + + std::vector vehicle; + + //std::vector aid; + + PTerrain *terrain; + + std::vector checkpt; + + int gamestate; + + float coursetime; + float othertime; // used pre and post race + float cptime; // checkpoint time + float targettime; // the time needed to win + + std::string comment; // level comment string + + vec3f start_pos; + quatf start_ori; + + struct { + struct { + std::string texname; + float scrollrate; + } cloud; + struct { + vec3f color; + float density; + float density_sky; + } fog; + struct { + float rain; + } precip; + } weather; + +public: + std::vector vehiclechoices; + +public: + TriggerGame(MainApp *parent); + ~TriggerGame(); + + bool loadLevel(const std::string &filename); + + void chooseVehicle(PVehicleType *type); + + void tick(float delta); + + bool isFinished() { return (gamestate == GS_FINISHED) && (othertime <= 0.0f); } + int getFinishState() { + if (gamestate != GS_FINISHED) return GF_NOT_FINISHED; + if (coursetime <= targettime) return GF_PASS; + else return GF_FAIL; + } +}; + + +#include "menu.h" + + +#define AS_LOAD_1 1 +#define AS_LOAD_2 2 +#define AS_LOAD_3 3 +#define AS_LEVEL_SCREEN 10 +#define AS_CHOOSE_VEHICLE 11 +#define AS_IN_GAME 12 +#define AS_END_SCREEN 13 + + + +struct TriggerLevel { + std::string filename, name, comment, author; +}; + +struct TriggerEvent { + std::string filename, name, comment, author; + + // Note that levels are not linked to... they are + // stored in the event because an event may have + // "hidden" levels not otherwise available + + std::vector levels; +}; + + +class DirtParticleSystem : public PParticleSystem { +public: + void tick(float delta) { + + PParticleSystem::tick(delta); + + for (unsigned int i=0; i levels; + std::vector events; + + // for level screen + Gui gui; + LevelState lss; + + // + + TriggerGame *game; + + PVehicleType *vt_tank; + + PTexture *tex_font; + + PTexture *tex_detail, + *tex_sky[1], + *tex_water, + *tex_dirt, + *tex_shadow, + *tex_hud_revs, + *tex_hud_speedo, + *tex_hud_gear, + *tex_hud_life, + *tex_hud_arrow, + *tex_splash_screen, + *tex_end_screen; + + DirtParticleSystem *psys_dirt; + + PAudioSample *aud_engine, + *aud_wind, + *aud_gearchange, + *aud_gravel, + *aud_crash1; + + PAudioInstance *audinst_engine, *audinst_wind, *audinst_gravel; + std::vector audinst; + + float cloudscroll; + + vec3f campos, campos_prev; + quatf camori; + + vec3f camvel; + + float nextcpangle; + + float cprotate; + + int cameraview; + float camera_angle; + float camera_user_angle; + + bool renderowncar; // this is determined from cameraview + + bool showmap; + + float crashnoise_timeout; + + std::vector rain; + + // + + int loadscreencount; + + float choose_spin; + + int choose_type; + +protected: + void renderWater(); + void renderSky(const mat44f &cammat); + + bool startGame(const std::string &filename); + void startGame2(); + void endGame(int gamestate); + + void quitGame() { + endGame(GF_NOT_FINISHED); + splashtimeout = 0.0f; + appstate = AS_END_SCREEN; + } + + void levelScreenAction(int action, int index); + void handleLevelScreenKey(const SDL_KeyboardEvent &ke); + void finishRace(int gamestate, float coursetime); + +public: + MainApp(const std::string &title, const std::string &name) : PApp(title, name) { } + //MainApp::~MainApp(); // should not have destructor, use unload + + void config(); + void load(); + void unload(); + + void loadConfig(); + bool loadAll(); + bool loadLevelsAndEvents(); + bool loadLevel(TriggerLevel &tl); + + void tick(float delta); + + void resize(); + void render(float eyetranslation); + + void renderStateLoading(float eyetranslation); + void renderStateEnd(float eyetranslation); + void tickStateLevel(float delta); + void renderStateLevel(float eyetranslation); + void tickStateChoose(float delta); + void renderStateChoose(float eyetranslation); + void tickStateGame(float delta); + void renderStateGame(float eyetranslation); + + void keyEvent(const SDL_KeyboardEvent &ke); + void mouseMoveEvent(int dx, int dy); + void cursorMoveEvent(int posx, int posy); + void mouseButtonEvent(const SDL_MouseButtonEvent &mbe); + void joyButtonEvent(int which, int button, bool down); +}; + + + + diff -Nru trigger-rally-0.5.2.1/src/trigger/menu.cpp trigger-rally-0.6.0/src/trigger/menu.cpp --- trigger-rally-0.5.2.1/src/trigger/menu.cpp 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/trigger/menu.cpp 2011-10-07 17:10:01.000000000 +0000 @@ -1,762 +1,850 @@ - -// menu.cpp - -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net -// License: GPL version 2 (see included gpl.txt) - - -#include "main.h" - - -void MainApp::levelScreenAction(int action, int index) -{ - appstate = AS_LEVEL_SCREEN; - - switch (action) { - case AA_INIT: - lss.state = AM_TOP; - break; - case AA_RESUME: - // lss.state should be AM_TOP_EVT_PREP, continuing event - break; - case AA_GO_TOP: - lss.state = AM_TOP; - break; - case AA_GO_EVT: - if (lss.state == AM_TOP_EVT_PREP && - lss.currentlevel > 0 && - lss.currentlevel < (int)events[lss.currentevent].levels.size()) { - lss.state = AM_TOP_EVT_ABANDON; - } else { - lss.state = AM_TOP_EVT; - } - break; - case AA_PICK_EVT: - lss.currentevent = index; - lss.currentlevel = 0; - lss.livesleft = 3; - lss.leveltimes.clear (); - lss.totaltime = 0.0f; - lss.state = AM_TOP_EVT_PREP; - break; - case AA_RESUME_EVT: - lss.state = AM_TOP_EVT_PREP; - break; - case AA_RESTART_EVT: - lss.currentlevel = 0; - lss.livesleft = 3; - lss.leveltimes.clear (); - lss.totaltime = 0.0f; - lss.state = AM_TOP_EVT_PREP; - break; - case AA_GO_LVL: - lss.state = AM_TOP_LVL; - break; - case AA_PICK_LVL: - lss.currentlevel = index; - lss.state = AM_TOP_LVL_PREP; - break; - case AA_GO_QUIT: - lss.state = AM_TOP_QUIT; - break; - case AA_QUIT_CONFIRM: - quitGame(); - break; - - case AA_START_EVT: - startGame(events[lss.currentevent].levels[lss.currentlevel].filename); - return; - case AA_START_LVL: - startGame(levels[lss.currentlevel].filename); - return; - - default: - PUtil::outLog() << "ERROR: invalid action code " << action << std::endl; - requestExit(); - return; - } - - gui.setSSRender(getSSRender()); - - gui.setFont(tex_font); - - grabMouse(false); - - gui.clear(); - - gui.addLabel(10.0f,590.0f, (std::string)"Trigger " + PACKAGE_VERSION, PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 30.0f); - - { - // Switch the icky M D Y date format to D M Y - // TODO: do this at startup - - const char *ickydate = __DATE__; - char pieces[3][10]; - char resultdate[30]; - sscanf(ickydate, "%s %s %s", pieces[0], pieces[1], pieces[2]); - sprintf(resultdate, "%s %s %s", pieces[1], pieces[0], pieces[2]); - - gui.addLabel(10.0f,10.0f, - (std::string)"Build: " + resultdate + " at " + __TIME__, - PTEXT_HZA_LEFT | PTEXT_VTA_BOTTOM, 20.0f); - } - - switch (lss.state) { - case AM_TOP: - gui.makeClickable( - gui.addLabel(400.0f,350.0f, "Enter an Event", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 40.0f), AA_GO_EVT, 0); - gui.makeClickable( - gui.addLabel(400.0f,300.0f, "Single Race", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 40.0f), AA_GO_LVL, 0); - gui.makeClickable( - gui.addLabel(400.0f,250.0f, "Quit", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 40.0f), AA_GO_QUIT, 0); - break; - case AM_TOP_EVT: - gui.makeClickable( - gui.addLabel(400.0f,590.0f, "(back)", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 30.0f), AA_GO_TOP, 0); - gui.addLabel(790.0f,590.0f, "Event", PTEXT_HZA_RIGHT | PTEXT_VTA_TOP, 30.0f); - gui.addLabel(100.0f,470.0f, "Choose Event:", PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 30.0f); - for (unsigned int i = 0; i < events.size(); i++) { - gui.makeClickable( - gui.addLabel(100.0f,420.0f - (float)i * 30.0f, - events[i].name, PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 25.0f), AA_PICK_EVT, i); - } - break; - case AM_TOP_EVT_PREP: - gui.makeClickable( - gui.addLabel(400.0f,590.0f, "(back)", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 30.0f), AA_GO_EVT, 0); - gui.addLabel(790.0f,590.0f, "Event", PTEXT_HZA_RIGHT | PTEXT_VTA_TOP, 30.0f); - gui.addLabel(100.0f,470.0f, "Races:", PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 30.0f); - for (unsigned int i = 0; i < events[lss.currentevent].levels.size(); i++) { - gui.addLabel(100.0f,420.0f - (float)i * 30.0f, - events[lss.currentevent].levels[i].name, PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 25.0f); - std::string infotext = "Not yet raced"; - if (lss.currentlevel > (int)i) - infotext = PUtil::formatTime(lss.leveltimes[i]); - else if (lss.currentlevel == (int)i) - infotext = "NEXT"; - gui.addLabel(700.0f,420.0f - (float)i * 30.0f, - infotext, PTEXT_HZA_RIGHT | PTEXT_VTA_TOP, 25.0f); - } - gui.addLabel(700.0f,420.0f - (float)events[lss.currentevent].levels.size() * 30.0f, - "Total: " + PUtil::formatTime(lss.totaltime), PTEXT_HZA_RIGHT | PTEXT_VTA_TOP, 25.0f); - if (lss.livesleft <= 0) { - gui.addLabel(400.0f,150.0f, "No tries remaining", PTEXT_HZA_CENTER | PTEXT_VTA_CENTER, 30.0f); - gui.makeClickable( - gui.addLabel(400.0f,100.0f, "Restart Event", PTEXT_HZA_CENTER | PTEXT_VTA_CENTER, 30.0f), - AA_RESTART_EVT, 0); - } else if (lss.currentlevel >= (int)events[lss.currentevent].levels.size()) { - gui.addLabel(400.0f,150.0f, "CONGRATULATIONS!", PTEXT_HZA_CENTER | PTEXT_VTA_CENTER, 40.0f); - gui.addLabel(400.0f,100.0f, "EVENT COMPLETED", PTEXT_HZA_CENTER | PTEXT_VTA_CENTER, 40.0f); - } else { - gui.addLabel(300.0f,100.0f, "Tries remaining:", PTEXT_HZA_RIGHT | PTEXT_VTA_CENTER, 30.0f); - for (int i = 0; i < lss.livesleft; i++) { - gui.addGraphic(325.0f + i * 50.0f,75.0f, 50.0f,50.0f, tex_hud_life); - } - gui.makeDefault( - gui.makeClickable( - gui.addLabel(650.0f,100.0f, "START RACE", PTEXT_HZA_CENTER | PTEXT_VTA_CENTER, 40.0f), - AA_START_EVT, 0)); - } - break; - case AM_TOP_EVT_ABANDON: - gui.addLabel(400.0f,350.0f, "Really leave event?", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 40.0f); - gui.makeClickable( - gui.addLabel(300.0f,250.0f, "Yes", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 40.0f), - AA_GO_EVT, 0); - gui.makeClickable( - gui.addLabel(500.0f,250.0f, "No", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 40.0f), - AA_RESUME_EVT, 0); - break; - case AM_TOP_LVL: - gui.makeClickable( - gui.addLabel(400.0f,590.0f, "(back)", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 30.0f), - AA_GO_TOP, 0); - gui.addLabel(790.0f,590.0f, "Single Race", PTEXT_HZA_RIGHT | PTEXT_VTA_TOP, 30.0f); - gui.addLabel(100.0f,470.0f, "Choose Race:", PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 30.0f); - for (unsigned int i = 0; i < levels.size(); i++) { - gui.makeClickable( - gui.addLabel(100.0f,420.0f - (float)i * 30.0f, - levels[i].name, PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 25.0f), - AA_PICK_LVL, i); - } - break; - case AM_TOP_LVL_PREP: - gui.makeClickable( - gui.addLabel(400.0f,590.0f, "(back)", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 30.0f), - AA_GO_LVL, 0); - gui.addLabel(790.0f,590.0f, "Single Race", PTEXT_HZA_RIGHT | PTEXT_VTA_TOP, 30.0f); - gui.addLabel(200.0f,450.0f, "Name", PTEXT_HZA_RIGHT | PTEXT_VTA_TOP, 30.0f); - gui.addLabel(250.0f,450.0f, levels[lss.currentlevel].name, PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 30.0f); - gui.addLabel(200.0f,400.0f, "Author", PTEXT_HZA_RIGHT | PTEXT_VTA_TOP, 30.0f); - gui.addLabel(250.0f,400.0f, levels[lss.currentlevel].author, PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 30.0f); - gui.makeDefault( - gui.makeClickable( - gui.addLabel(400.0f,100.0f, "START RACE", PTEXT_HZA_CENTER | PTEXT_VTA_CENTER, 40.0f), - AA_START_LVL, 0)); - break; - case AM_TOP_QUIT: - gui.addLabel(400.0f,350.0f, "Really quit?", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 40.0f); - gui.makeClickable( - gui.addLabel(300.0f,250.0f, "Yes", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 40.0f), - AA_QUIT_CONFIRM, 0); - gui.makeClickable( - gui.addLabel(500.0f,250.0f, "No", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 40.0f), - AA_GO_TOP, 0); - break; - default: - gui.addLabel(400.0f,300.0f, "Error in menu system, sorry", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 30.0f); - gui.makeClickable( - gui.addLabel(400.0f,150.0f, "Go to top menu", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 30.0f), - AA_GO_TOP, 0); - break; - } - - //gui.doLayout(); -} - -void MainApp::finishRace(int gamestate, float coursetime) -{ - switch (lss.state) { - case AM_TOP_EVT_PREP: - switch (gamestate) { - case GF_PASS: - lss.leveltimes.resize(events[lss.currentevent].levels.size(), 0.0f); - lss.leveltimes[lss.currentlevel] += coursetime; - lss.totaltime += coursetime; - lss.currentlevel++; - break; - case GF_FAIL: - lss.totaltime += coursetime; - lss.livesleft--; - break; - default: - break; - } - levelScreenAction(AA_RESUME, 0); - break; - case AM_TOP_LVL_PREP: - levelScreenAction(AA_GO_LVL, 0); - break; - } - -} - -void MainApp::tickStateLevel(float delta) -{ - gui.tick(delta); -} - -void MainApp::cursorMoveEvent(int posx, int posy) -{ - if (appstate != AS_LEVEL_SCREEN) return; - - gui.setCursorPos( - (float)posx / (float)getWidth() * 800.0f, - (1.0f - (float)posy / (float)getHeight()) * 600.0f); -} - -void MainApp::mouseButtonEvent(const SDL_MouseButtonEvent &mbe) -{ - if (mbe.type != SDL_MOUSEBUTTONDOWN) return; - - switch (appstate) { - case AS_LEVEL_SCREEN: - break; - case AS_LOAD_3: - levelScreenAction(AA_INIT, 0); - break; - default: - return; - } - - gui.setCursorPos( - (float)mbe.x / (float)getWidth() * 800.0f, - (1.0f - (float)mbe.y / (float)getHeight()) * 600.0f); - - int action, index; - - if (!gui.getClickAction(action, index)) return; - - levelScreenAction(action, index); -} - -void MainApp::handleLevelScreenKey(const SDL_KeyboardEvent &ke) -{ - switch (ke.keysym.sym) { - case SDLK_ESCAPE: - switch(lss.state) { - case AM_TOP: - levelScreenAction(AA_GO_QUIT, 0); - break; - case AM_TOP_EVT_PREP: - case AM_TOP_EVT_ABANDON: - levelScreenAction(AA_GO_EVT, 0); - break; - case AM_TOP_LVL_PREP: - levelScreenAction(AA_GO_LVL, 0); - break; - case AM_TOP_QUIT: - quitGame(); - break; - default: - levelScreenAction(AA_GO_TOP, 0); - break; - } - break; - case SDLK_RETURN: - case SDLK_KP_ENTER: { - int data1, data2; - - if (gui.getDefaultAction(data1, data2)) - levelScreenAction(data1, data2); - } break; - default: - break; - } -} - - -void MainApp::renderStateLevel(float eyetranslation) -{ - eyetranslation = eyetranslation; - - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - glOrtho(0.0f, 800.0f, 0.0f, 600.0f, -1.0f, 1.0f); - glMatrixMode(GL_MODELVIEW); - - // draw background image - - glBlendFunc(GL_ONE, GL_ZERO); - glDisable(GL_DEPTH_TEST); - glDisable(GL_FOG); - glDisable(GL_LIGHTING); - - tex_splash_screen->bind(); - - glColor4f(0.0f, 0.0f, 0.2f, 1.0f); - - glBegin(GL_QUADS); - glTexCoord2f(1.0f,1.0f); glVertex2f(800.0f,600.0f); - glTexCoord2f(0.0f,1.0f); glVertex2f(0.0f,600.0f); - glTexCoord2f(0.0f,0.0f); glVertex2f(0.0f,0.0f); - glTexCoord2f(1.0f,0.0f); glVertex2f(800.0f,0.0f); - glEnd(); - - // draw GUI - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - glColor4f(1.0f, 1.0f, 1.0f, 0.2f); - - tex_font->bind(); - - glPushMatrix(); // 0 - - gui.render(); - - glPopMatrix(); // 0 - - glBlendFunc(GL_ONE, GL_ZERO); - glEnable(GL_DEPTH_TEST); - glEnable(GL_FOG); - glEnable(GL_LIGHTING); - - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); -} - - -void Gui::tick(float delta) -{ - float decay = delta * 3.0f; - - for (unsigned int i = 0; i < widget.size(); i++) - { - widget[i].glow -= decay; - CLAMP_LOWER(widget[i].glow, 0.0f); - } - - if (highlight != -1) { - widget[highlight].glow = 1.0f; - } - - defflash = fmodf(defflash + delta * 50.0f, PI*2.0f); -} - -void Gui::setCursorPos(float x, float y) -{ - highlight = -1; - - for (unsigned int i = 0; i < widget.size(); i++) { - - if (!widget[i].clickable) continue; - - if (x >= widget[i].pos.x && - y >= widget[i].pos.y && - x < widget[i].pos.x + widget[i].dims_min.x && - y < widget[i].pos.y + widget[i].dims_min.y) - highlight = i; - } -} - -bool Gui::getClickAction(int &data1, int &data2) -{ - if (highlight == -1) return false; - - data1 = widget[highlight].d1; - data2 = widget[highlight].d2; - - return true; -} - -bool Gui::getDefaultAction(int &data1, int &data2) -{ - if (defwidget == -1) return false; - - data1 = widget[defwidget].d1; - data2 = widget[defwidget].d2; - - return true; -} - -void Gui::render() -{ - for (unsigned int i = 0; i < widget.size(); i++) { - - switch(widget[i].type) { - case GWT_LABEL: { - vec4f colc; - if (widget[i].clickable) { - vec4f cola = vec4f(1.0f, 0.8f, 0.7f, 0.6f); - vec4f colb = vec4f(0.6f, 0.8f, 1.0f, 1.0f); - colc = INTERP(cola, colb, widget[i].glow); - } else { - colc = vec4f(1.0f, 1.0f, 1.0f, 0.6f); - } - - if ((int)i == defwidget) - colc += vec4f(0.1f, -0.1f, -0.1f, 0.0f) * sinf(defflash); - - glPushMatrix(); - - vec2f ctr = widget[i].pos; - glTranslatef(ctr.x, ctr.y, 0.0f); - - glScalef(widget[i].fontsize, widget[i].fontsize, 1.0f); - - fonttex->bind(); - - glColor4fv(colc); - ssRender->drawText(widget[i].text, PTEXT_HZA_LEFT | PTEXT_VTA_BOTTOM); - glPopMatrix(); - } break; - - case GWT_GRAPHIC: { - - vec2f min = widget[i].pos; - vec2f max = widget[i].pos + widget[i].dims_min; - - widget[i].tex->bind(); - - glColor3f(1.0f, 1.0f, 1.0f); - - glBegin(GL_QUADS); - glTexCoord2f(0.0f, 0.0f); glVertex2f(min.x, min.y); - glTexCoord2f(1.0f, 0.0f); glVertex2f(max.x, min.y); - glTexCoord2f(1.0f, 1.0f); glVertex2f(max.x, max.y); - glTexCoord2f(0.0f, 1.0f); glVertex2f(min.x, max.y); - glEnd(); - } break; - } - } -} - -// Widget tree stuff wasn't working properly, so I removed it for -// now. If I need ultra-snazzy menus, I may finish this code - -#if 0 - -void Gui::doLayout() -{ - // Calculate sizes - for (unsigned int i = 0; i < widget.size(); i++) { - if (widget[i].parent == GWPARENT_NONE) { - measureWidgetTree(i); - placeWidgetTree(i); - } - } -} - -void Gui::measureWidgetTree(int w) -{ - widget[w].childcount = 0; - widget[w].fillercount = 0; - - switch (widget[w].type) { - default: - - widget[w].dims_measure = widget[w].dims_min; - - break; - - case GWT_CONTAINER: { - - vec2f measure = vec2f(0.0f, 0.0f); - - for (unsigned int i = 0; i < widget.size(); i++) { - if (widget[i].parent == w) { - measureWidgetTree(i); - - widget[w].childcount++; - - if (widget[i].type == GWT_FILLER) - widget[w].fillercount++; - - if (widget[w].vert) { - CLAMP_LOWER(measure.x, widget[i].dims_measure.x); - measure.y += widget[i].dims_measure.y; - } else { - measure.x += widget[i].dims_measure.x; - CLAMP_LOWER(measure.y, widget[i].dims_measure.y); - } - } - } - - widget[w].dims_measure = measure; - - } break; - } -} - -void Gui::placeWidgetTree(int w) -{ - if (widget[w].childcount <= 0) return; - - float extraspace = widget[w].vert ? - - widget[w].dims_measure.x : - - widget[w].dims_measure.y; - if (widget[w].parent == GWPARENT_NONE) { - extraspace += widget[w].vert ? - widget[w].dims_min.x : - widget[w].dims_min.y; - } - - CLAMP_LOWER(extraspace, 0.0f); - - //CLAMP_LOWER(widget[w].dims_measure.x, widget[w].dims_min.x); - //CLAMP_LOWER(widget[w].dims_measure.y, widget[w].dims_min.y); - - float - addtofillers = 0.0f, - addtochildren = 0.0f; - /* - if (widget[w].fillercount > 0) - addtofillers = extraspace / (float)widget[w].fillercount; - else - addtochildren = extraspace / (float)widget[w].childcount;*/ - - if (widget[w].vert) { - float distrib = widget[w].pos.y; - - for (unsigned int i = 0; i < widget.size(); i++) { - if (widget[i].parent == w) { - - widget[i].pos.x = widget[w].pos.x; - widget[i].pos.y = distrib; - - widget[i].dims_measure.x = widget[w].dims_measure.x; - - switch (widget[i].type) { - case GWT_FILLER: - widget[i].dims_measure.y += addtofillers; - break; - case GWT_CONTAINER: - widget[i].dims_measure.y += addtochildren; - placeWidgetTree(i); - break; - default: - widget[i].dims_measure.y += addtochildren; - break; - } - - distrib += widget[i].dims_measure.y; - } - } - } else { - float distrib = widget[w].pos.x; - - for (unsigned int i = 0; i < widget.size(); i++) { - if (widget[i].parent == w) { - - widget[i].pos.x = distrib; - widget[i].pos.y = widget[w].pos.y; - - widget[i].dims_measure.y = widget[w].dims_measure.y; - - switch (widget[i].type) { - case GWT_FILLER: - widget[i].dims_measure.x += addtofillers; - break; - case GWT_CONTAINER: - widget[i].dims_measure.x += addtochildren; - placeWidgetTree(i); - break; - default: - widget[i].dims_measure.x += addtochildren; - break; - } - - distrib += widget[i].dims_measure.x; - } - } - } -} - -void Gui::render() -{ - // Render trees of all root containers - - for (unsigned int i = 0; i < widget.size(); i++) { - if (widget[i].parent == GWPARENT_NONE) - renderWidgetTree(i); - } -} - -void Gui::renderWidgetTree(int w) -{ - vec2f min, max; - - switch (widget[w].type) { - case GWT_CONTAINER: - glColor4f(1.0f,0.0f,0.0f,0.2f); - break; - case GWT_FILLER: - glColor4f(0.0f,1.0f,0.0f,0.2f); - break; - case GWT_LABEL: - glColor4f(0.0f,0.0f,1.0f,0.2f); - break; - } - - min = widget[w].pos; - max = widget[w].pos + widget[w].dims_measure; - - glDisable(GL_TEXTURE_2D); - glBegin(GL_QUADS); - glVertex2f(min.x, min.y); - glVertex2f(max.x, min.y); - glVertex2f(max.x, max.y); - glVertex2f(min.x, max.y); - glEnd(); - glEnable(GL_TEXTURE_2D); - - // Render this widget - switch (widget[w].type) { - default: - break; - - case GWT_LABEL: { - glPushMatrix(); - vec2f ctr = widget[w].pos + widget[w].dims_measure * 0.5f; - glTranslatef(ctr.x, ctr.y, 0.0f); - glScalef(widget[w].fontsize, widget[w].fontsize, 1.0f); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - ssRender->drawText(widget[w].text, PTEXT_HZA_CENTER | PTEXT_VTA_CENTER); - glPopMatrix(); - } break; - } - - // Render children - switch (widget[w].type) { - case GWT_CONTAINER: - for (unsigned int i = 0; i < widget.size(); i++) { - if (widget[i].parent == w) - renderWidgetTree(i); - } - break; - } -} - -#endif - -int Gui::getFreeWidget() -{ - for (unsigned int i = 0; i < widget.size(); i++) { - if (widget[i].type == GWT_FREE) - return i; - } - widget.push_back(GuiWidget(GWT_FREE)); - return widget.size() - 1; -} - -#if 0 -int Gui::addRootContainer(float x, float y, float width, float height, bool vert) -{ - int w = getFreeWidget(); - widget[w].type = GWT_CONTAINER; - widget[w].vert = vert; - widget[w].parent = GWPARENT_NONE; - widget[w].dims_min = vec2f(width, height); - widget[w].pos = vec2f(x, y); - - return w; -} - -int Gui::addFiller(int parent, float minwidth, float minheight) -{ - int w = getFreeWidget(); - widget[w].type = GWT_FILLER; - widget[w].parent = parent; - widget[w].dims_min = vec2f(minwidth, minheight); - - return w; -} - -int Gui::addContainer(float x, float y, float width, float height, bool vert) -{ - int w = getFreeWidget(); - widget[w].type = GWT_CONTAINER; - widget[w].vert = vert; - widget[w].parent = parent; - widget[w].dims_min = vec2f(minwidth, minheight); - - return w; -} -#endif - -int Gui::addLabel(float x, float y, const std::string &text, uint32 flags, float fontsize) -{ - int w = getFreeWidget(); - widget[w].type = GWT_LABEL; - widget[w].text = text; - widget[w].fontsize = fontsize; - widget[w].dims_min = ssRender->getTextDims(text) * fontsize; - widget[w].pos = vec2f(x, y); - - if (flags & PTEXT_HZA_CENTER) - widget[w].pos.x -= widget[w].dims_min.x * 0.5f; - else if (flags & PTEXT_HZA_RIGHT) - widget[w].pos.x -= widget[w].dims_min.x; - - if (flags & PTEXT_VTA_CENTER) - widget[w].pos.y -= widget[w].dims_min.y * 0.5f; - else if (flags & PTEXT_VTA_TOP) - widget[w].pos.y -= widget[w].dims_min.y; - - return w; -} - -int Gui::addGraphic(float x, float y, float width, float height, PTexture *tex) -{ - int w = getFreeWidget(); - widget[w].type = GWT_GRAPHIC; - widget[w].dims_min = vec2f(width, height); - widget[w].pos = vec2f(x, y); - widget[w].tex = tex; - - return w; -} - + +// menu.cpp + +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net +// License: GPL version 2 (see included gpl.txt) + +#include +#include "main.h" + +const int MAX_RACES_ON_SCREEN = 10; + + +void MainApp::levelScreenAction(int action, int index) +{ + appstate = AS_LEVEL_SCREEN; + + switch (action) { + case AA_INIT: + lss.state = AM_TOP; + break; + case AA_RESUME: + // lss.state should be AM_TOP_EVT_PREP, continuing event + break; + case AA_GO_TOP: + lss.state = AM_TOP; + break; + case AA_GO_EVT: + if (lss.state == AM_TOP_EVT_PREP && + lss.currentlevel > 0 && + lss.currentlevel < (int)events[lss.currentevent].levels.size()) { + lss.state = AM_TOP_EVT_ABANDON; + } else { + lss.state = AM_TOP_EVT; + } + break; + case AA_PICK_EVT: + lss.currentevent = index; + lss.currentlevel = 0; + lss.livesleft = 3; + lss.leveltimes.clear(); + lss.totaltime = 0.0f; + lss.state = AM_TOP_EVT_PREP; + break; + case AA_RESUME_EVT: + lss.state = AM_TOP_EVT_PREP; + break; + case AA_RESTART_EVT: + lss.currentlevel = 0; + lss.livesleft = 3; + lss.leveltimes.clear(); + lss.totaltime = 0.0f; + lss.state = AM_TOP_EVT_PREP; + break; + case AA_GO_PRAC: + lss.state = AM_TOP_PRAC; + break; + case AA_PICK_PRAC: + lss.currentevent = index; + lss.state = AM_TOP_PRAC_SEL; + break; + case AA_PICK_PRAC_LVL: + lss.currentlevel = index; + lss.state = AM_TOP_PRAC_SEL_PREP; + break; + case AA_GO_LVL: + lss.state = AM_TOP_LVL; + break; + case AA_PICK_LVL: + lss.currentlevel = index; + lss.state = AM_TOP_LVL_PREP; + break; + case AA_GO_QUIT: + lss.state = AM_TOP_QUIT; + break; + case AA_QUIT_CONFIRM: + quitGame(); + break; + + case AA_START_EVT: + startGame(events[lss.currentevent].levels[lss.currentlevel].filename); + return; + case AA_START_PRAC: + startGame(events[lss.currentevent].levels[lss.currentlevel].filename); + return; + case AA_START_LVL: + startGame(levels[lss.currentlevel].filename); + return; + + default: + PUtil::outLog() << "ERROR: invalid action code " << action << std::endl; + requestExit(); + return; + } + + gui.setSSRender(getSSRender()); + + gui.setFont(tex_font); + + grabMouse(false); + + gui.clear(); + + gui.addLabel(10.0f,590.0f, (std::string)"Trigger " + PACKAGE_VERSION, PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 30.0f); + + { + // Switch the icky M D Y date format to D M Y + // TODO: do this at startup + + const char *ickydate = __DATE__; + char pieces[3][10]; + char resultdate[30]; + sscanf(ickydate, "%s %s %s", pieces[0], pieces[1], pieces[2]); + sprintf(resultdate, "%s %s %s", pieces[1], pieces[0], pieces[2]); + + gui.addLabel(10.0f,10.0f, + (std::string)"Build: " + resultdate + " at " + __TIME__, + PTEXT_HZA_LEFT | PTEXT_VTA_BOTTOM, 20.0f); + } + + switch (lss.state) { + case AM_TOP: + gui.makeClickable( + gui.addLabel(400.0f,400.0f, "Enter an Event", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 40.0f), AA_GO_EVT, 0); + gui.makeClickable( + gui.addLabel(400.0f,350.0f, "Practice", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 40.0f), AA_GO_PRAC, 0); + gui.makeClickable( + gui.addLabel(400.0f,300.0f, "Single Race", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 40.0f), AA_GO_LVL, 0); + gui.makeClickable( + gui.addLabel(400.0f,250.0f, "Quit", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 40.0f), AA_GO_QUIT, 0); + break; + case AM_TOP_EVT: + gui.makeClickable( + gui.addLabel(400.0f,590.0f, "(back)", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 30.0f), AA_GO_TOP, 0); + gui.addLabel(790.0f,590.0f, "Event", PTEXT_HZA_RIGHT | PTEXT_VTA_TOP, 30.0f); + gui.addLabel(100.0f,470.0f, "Choose Event:", PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 30.0f); + for (unsigned int i = 0; i < events.size(); i++) { + gui.makeClickable( + gui.addLabel(100.0f,420.0f - (float)i * 30.0f, + events[i].name, PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 25.0f), AA_PICK_EVT, i); + } + break; + case AM_TOP_EVT_PREP: + gui.makeClickable( + gui.addLabel(400.0f,590.0f, "(back)", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 30.0f), AA_GO_EVT, 0); + gui.addLabel(790.0f,590.0f, "Event", PTEXT_HZA_RIGHT | PTEXT_VTA_TOP, 30.0f); + gui.addLabel(100.0f,470.0f, "Races:", PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 30.0f); + for (unsigned int i = 0; i < events[lss.currentevent].levels.size(); i++) { + gui.addLabel(100.0f,420.0f - (float)i * 30.0f, + events[lss.currentevent].levels[i].name, PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 25.0f); + std::string infotext = "Not yet raced"; + if (lss.currentlevel > (int)i) + infotext = PUtil::formatTime(lss.leveltimes[i]); + else if (lss.currentlevel == (int)i) + infotext = "NEXT"; + gui.addLabel(700.0f,420.0f - (float)i * 30.0f, + infotext, PTEXT_HZA_RIGHT | PTEXT_VTA_TOP, 25.0f); + } + gui.addLabel(700.0f,420.0f - (float)events[lss.currentevent].levels.size() * 30.0f, + "Total: " + PUtil::formatTime(lss.totaltime), PTEXT_HZA_RIGHT | PTEXT_VTA_TOP, 25.0f); + if (lss.livesleft <= 0) { + gui.addLabel(400.0f,150.0f, "No tries remaining", PTEXT_HZA_CENTER | PTEXT_VTA_CENTER, 30.0f); + gui.makeClickable( + gui.addLabel(400.0f,100.0f, "Restart Event", PTEXT_HZA_CENTER | PTEXT_VTA_CENTER, 30.0f), + AA_RESTART_EVT, 0); + } else if (lss.currentlevel >= (int)events[lss.currentevent].levels.size()) { + gui.addLabel(400.0f,150.0f, "CONGRATULATIONS!", PTEXT_HZA_CENTER | PTEXT_VTA_CENTER, 40.0f); + gui.addLabel(400.0f,100.0f, "EVENT COMPLETED", PTEXT_HZA_CENTER | PTEXT_VTA_CENTER, 40.0f); + } else { + gui.addLabel(300.0f,100.0f, "Tries remaining:", PTEXT_HZA_RIGHT | PTEXT_VTA_CENTER, 30.0f); + for (int i = 0; i < lss.livesleft; i++) { + gui.addGraphic(325.0f + i * 50.0f,75.0f, 50.0f,50.0f, tex_hud_life); + } + gui.makeDefault( + gui.makeClickable( + gui.addLabel(650.0f,100.0f, "START RACE", PTEXT_HZA_CENTER | PTEXT_VTA_CENTER, 40.0f), + AA_START_EVT, 0)); + } + break; + case AM_TOP_EVT_ABANDON: + gui.addLabel(400.0f,350.0f, "Really leave event?", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 40.0f); + gui.makeClickable( + gui.addLabel(300.0f,250.0f, "Yes", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 40.0f), + AA_GO_EVT, 0); + gui.makeClickable( + gui.addLabel(500.0f,250.0f, "No", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 40.0f), + AA_RESUME_EVT, 0); + break; + case AM_TOP_PRAC: + gui.makeClickable( + gui.addLabel(400.0f,590.0f, "(back)", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 30.0f), AA_GO_TOP, 0); + gui.addLabel(790.0f,590.0f, "Practice", PTEXT_HZA_RIGHT | PTEXT_VTA_TOP, 30.0f); + gui.addLabel(100.0f,470.0f, "Choose Event:", PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 30.0f); + for (unsigned int i = 0; i < events.size(); i++) { + gui.makeClickable( + gui.addLabel(100.0f,420.0f - (float)i * 30.0f, + events[i].name, PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 25.0f), AA_PICK_PRAC, i); + } + break; + case AM_TOP_PRAC_SEL: + gui.makeClickable( + gui.addLabel(400.0f,590.0f, "(back)", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 30.0f), + AA_GO_PRAC, 0); + gui.addLabel(790.0f,590.0f, "Practice", PTEXT_HZA_RIGHT | PTEXT_VTA_TOP, 30.0f); + gui.addLabel(100.0f,470.0f, "Choose Race:", PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 30.0f); + for (unsigned int i = 0; i < events[lss.currentevent].levels.size(); i++) { + gui.makeClickable( + gui.addLabel(100.0f,420.0f - (float)i * 30.0f, + events[lss.currentevent].levels[i].name, PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 25.0f), + AA_PICK_PRAC_LVL, i); + } + break; + case AM_TOP_PRAC_SEL_PREP: + gui.makeClickable( + gui.addLabel(400.0f,590.0f, "(back)", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 30.0f), + AA_PICK_PRAC, lss.currentevent); + gui.addLabel(790.0f,590.0f, "Practice", PTEXT_HZA_RIGHT | PTEXT_VTA_TOP, 30.0f); + gui.addLabel(200.0f,450.0f, "Event", PTEXT_HZA_RIGHT | PTEXT_VTA_TOP, 30.0f); + gui.addLabel(250.0f,450.0f, events[lss.currentevent].name, PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 30.0f); + gui.addLabel(200.0f,400.0f, "Name", PTEXT_HZA_RIGHT | PTEXT_VTA_TOP, 30.0f); + gui.addLabel(250.0f,400.0f, events[lss.currentevent].levels[lss.currentlevel].name, PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 30.0f); + gui.addLabel(200.0f,350.0f, "Author", PTEXT_HZA_RIGHT | PTEXT_VTA_TOP, 30.0f); + gui.addLabel(250.0f,350.0f, events[lss.currentevent].levels[lss.currentlevel].author, PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 30.0f); + gui.makeDefault( + gui.makeClickable( + gui.addLabel(400.0f,100.0f, "START PRACTICE", PTEXT_HZA_CENTER | PTEXT_VTA_CENTER, 40.0f), + AA_START_PRAC, 0)); + break; + case AM_TOP_LVL: + { + gui.makeClickable( + gui.addLabel(400.0f,590.0f, "(back)", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 30.0f), + AA_GO_TOP, 0); + gui.addLabel(790.0f,590.0f, "Single Race", PTEXT_HZA_RIGHT | PTEXT_VTA_TOP, 30.0f); + gui.addLabel(100.0f,470.0f, "Choose Race:", PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 30.0f); + + int firstraceindex = index; + int prevlabel = gui.addLabel(100.0f, 90.0f, "(prev)", PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 30.0f); + if (firstraceindex > 0) { + gui.makeClickable(prevlabel, AA_GO_LVL, firstraceindex - MAX_RACES_ON_SCREEN); + } + int racesonscreencount = levels.size() - firstraceindex; + int nextlabel = gui.addLabel(380.0f, 90.0f, "(next)", PTEXT_HZA_RIGHT | PTEXT_VTA_TOP, 30.0f); + if (racesonscreencount > MAX_RACES_ON_SCREEN) { + racesonscreencount = MAX_RACES_ON_SCREEN; + gui.makeClickable( nextlabel, AA_GO_LVL, firstraceindex + MAX_RACES_ON_SCREEN); + } + std::stringstream racecountmsg; + racecountmsg << "Races " << firstraceindex + 1 << "-" << firstraceindex + racesonscreencount << " of " << levels.size(); + gui.addLabel(790.0f, 10.0f, racecountmsg.str(), PTEXT_HZA_RIGHT | PTEXT_VTA_BOTTOM, 20.0f); + + for (int i = firstraceindex; i < firstraceindex + racesonscreencount; i++) { + gui.makeClickable( + gui.addLabel(100.0f, 420.0f - (float)(i - firstraceindex) * 30.0f, + levels[i].name, PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 25.0f), + AA_PICK_LVL, i); + } + } + break; + case AM_TOP_LVL_PREP: + gui.makeClickable( + gui.addLabel(400.0f,590.0f, "(back)", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 30.0f), + AA_GO_LVL, (lss.currentlevel / MAX_RACES_ON_SCREEN) * MAX_RACES_ON_SCREEN); + gui.addLabel(790.0f,590.0f, "Single Race", PTEXT_HZA_RIGHT | PTEXT_VTA_TOP, 30.0f); + gui.addLabel(200.0f,450.0f, "Name", PTEXT_HZA_RIGHT | PTEXT_VTA_TOP, 30.0f); + gui.addLabel(250.0f,450.0f, levels[lss.currentlevel].name, PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 30.0f); + gui.addLabel(200.0f,400.0f, "Author", PTEXT_HZA_RIGHT | PTEXT_VTA_TOP, 30.0f); + gui.addLabel(250.0f,400.0f, levels[lss.currentlevel].author, PTEXT_HZA_LEFT | PTEXT_VTA_TOP, 30.0f); + gui.makeDefault( + gui.makeClickable( + gui.addLabel(400.0f,100.0f, "START RACE", PTEXT_HZA_CENTER | PTEXT_VTA_CENTER, 40.0f), + AA_START_LVL, 0)); + break; + case AM_TOP_QUIT: + gui.addLabel(400.0f,350.0f, "Really quit?", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 40.0f); + gui.makeClickable( + gui.addLabel(300.0f,250.0f, "Yes", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 40.0f), + AA_QUIT_CONFIRM, 0); + gui.makeClickable( + gui.addLabel(500.0f,250.0f, "No", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 40.0f), + AA_GO_TOP, 0); + break; + default: + gui.addLabel(400.0f,300.0f, "Error in menu system, sorry", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 30.0f); + gui.makeClickable( + gui.addLabel(400.0f,150.0f, "Go to top menu", PTEXT_HZA_CENTER | PTEXT_VTA_TOP, 30.0f), + AA_GO_TOP, 0); + break; + } + + //gui.doLayout(); +} + +void MainApp::finishRace(int gamestate, float coursetime) +{ + switch (lss.state) { + case AM_TOP_EVT_PREP: + switch (gamestate) { + case GF_PASS: + lss.leveltimes.resize(events[lss.currentevent].levels.size(), 0.0f); + lss.leveltimes[lss.currentlevel] += coursetime; + lss.totaltime += coursetime; + lss.currentlevel++; + break; + case GF_FAIL: + lss.totaltime += coursetime; + lss.livesleft--; + break; + default: + break; + } + levelScreenAction(AA_RESUME, 0); + break; + case AM_TOP_PRAC_SEL_PREP: + levelScreenAction(AA_PICK_PRAC_LVL, lss.currentlevel); + break; + case AM_TOP_LVL_PREP: + // Calculate the index of first level in the page by truncating the current level index to the nearest 10 + levelScreenAction(AA_GO_LVL, (lss.currentlevel / MAX_RACES_ON_SCREEN) * MAX_RACES_ON_SCREEN ); + break; + default: + PUtil::outLog() << "Race finished in invalid state " << lss.state << std::endl; + break; + } +} + +void MainApp::tickStateLevel(float delta) +{ + gui.tick(delta); +} + +void MainApp::cursorMoveEvent(int posx, int posy) +{ + if (appstate != AS_LEVEL_SCREEN) return; + + gui.setCursorPos( + (float)posx / (float)getWidth() * 800.0f, + (1.0f - (float)posy / (float)getHeight()) * 600.0f); +} + +void MainApp::mouseButtonEvent(const SDL_MouseButtonEvent &mbe) +{ + if (mbe.type != SDL_MOUSEBUTTONDOWN) return; + + switch (appstate) { + case AS_LEVEL_SCREEN: + break; + case AS_LOAD_3: + levelScreenAction(AA_INIT, 0); + break; + default: + return; + } + + gui.setCursorPos( + (float)mbe.x / (float)getWidth() * 800.0f, + (1.0f - (float)mbe.y / (float)getHeight()) * 600.0f); + + int action, index; + + if (!gui.getClickAction(action, index)) return; + + levelScreenAction(action, index); +} + +void MainApp::handleLevelScreenKey(const SDL_KeyboardEvent &ke) +{ + switch (ke.keysym.sym) { + case SDLK_ESCAPE: + switch(lss.state) { + case AM_TOP: + levelScreenAction(AA_GO_QUIT, 0); + break; + case AM_TOP_EVT_PREP: + case AM_TOP_EVT_ABANDON: + levelScreenAction(AA_GO_EVT, 0); + break; + case AM_TOP_PRAC_SEL: + levelScreenAction(AA_GO_PRAC, 0); + break; + case AM_TOP_PRAC_SEL_PREP: + levelScreenAction(AA_PICK_PRAC, lss.currentevent); + break; + case AM_TOP_LVL_PREP: + levelScreenAction(AA_GO_LVL, (lss.currentlevel / MAX_RACES_ON_SCREEN) * MAX_RACES_ON_SCREEN); + break; + case AM_TOP_QUIT: + quitGame(); + break; + default: + levelScreenAction(AA_GO_TOP, 0); + break; + } + break; + case SDLK_RETURN: + case SDLK_KP_ENTER: { + int data1, data2; + + if (gui.getDefaultAction(data1, data2)) + levelScreenAction(data1, data2); + } break; + default: + break; + } +} + + +void MainApp::renderStateLevel(float eyetranslation) +{ + eyetranslation = eyetranslation; + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0.0f, 800.0f, 0.0f, 600.0f, -1.0f, 1.0f); + glMatrixMode(GL_MODELVIEW); + + // draw background image + + glBlendFunc(GL_ONE, GL_ZERO); + glDisable(GL_DEPTH_TEST); + glDisable(GL_FOG); + glDisable(GL_LIGHTING); + + tex_splash_screen->bind(); + + glColor4f(0.0f, 0.0f, 0.2f, 1.0f); + + glBegin(GL_QUADS); + glTexCoord2f(1.0f,1.0f); glVertex2f(800.0f,600.0f); + glTexCoord2f(0.0f,1.0f); glVertex2f(0.0f,600.0f); + glTexCoord2f(0.0f,0.0f); glVertex2f(0.0f,0.0f); + glTexCoord2f(1.0f,0.0f); glVertex2f(800.0f,0.0f); + glEnd(); + + // draw GUI + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glColor4f(1.0f, 1.0f, 1.0f, 0.2f); + + tex_font->bind(); + + glPushMatrix(); // 0 + + gui.render(); + + glPopMatrix(); // 0 + + glBlendFunc(GL_ONE, GL_ZERO); + glEnable(GL_DEPTH_TEST); + glEnable(GL_FOG); + glEnable(GL_LIGHTING); + + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); +} + + +void Gui::tick(float delta) +{ + float decay = delta * 3.0f; + + for (unsigned int i = 0; i < widget.size(); i++) + { + widget[i].glow -= decay; + CLAMP_LOWER(widget[i].glow, 0.0f); + } + + if (highlight != -1) { + widget[highlight].glow = 1.0f; + } + + defflash = fmodf(defflash + delta * 50.0f, PI*2.0f); +} + +void Gui::setCursorPos(float x, float y) +{ + highlight = -1; + + for (unsigned int i = 0; i < widget.size(); i++) { + + if (!widget[i].clickable) continue; + + if (x >= widget[i].pos.x && + y >= widget[i].pos.y && + x < widget[i].pos.x + widget[i].dims_min.x && + y < widget[i].pos.y + widget[i].dims_min.y) + highlight = i; + } +} + +bool Gui::getClickAction(int &data1, int &data2) +{ + if (highlight == -1) return false; + + data1 = widget[highlight].d1; + data2 = widget[highlight].d2; + + return true; +} + +bool Gui::getDefaultAction(int &data1, int &data2) +{ + if (defwidget == -1) return false; + + data1 = widget[defwidget].d1; + data2 = widget[defwidget].d2; + + return true; +} + +void Gui::render() +{ + for (unsigned int i = 0; i < widget.size(); i++) { + + switch(widget[i].type) { + case GWT_LABEL: { + vec4f colc; + if (widget[i].clickable) { + vec4f cola = vec4f(1.0f, 0.6f, 0.6f, 0.7f); + vec4f colb = vec4f(0.4f, 0.8f, 1.0f, 0.85f); + colc = INTERP(cola, colb, widget[i].glow); + } else { + colc = vec4f(1.0f, 1.0f, 1.0f, 0.8f); + } + + if ((int)i == defwidget) + colc += vec4f(0.1f, -0.1f, -0.1f, 0.0f) * sinf(defflash); + + glPushMatrix(); + + vec2f ctr = widget[i].pos; + glTranslatef(ctr.x, ctr.y, 0.0f); + + glScalef(widget[i].fontsize, widget[i].fontsize, 1.0f); + + fonttex->bind(); + + glColor4fv(colc); + ssRender->drawText(widget[i].text, PTEXT_HZA_LEFT | PTEXT_VTA_BOTTOM); + glPopMatrix(); + } break; + + case GWT_GRAPHIC: { + + vec2f min = widget[i].pos; + vec2f max = widget[i].pos + widget[i].dims_min; + + widget[i].tex->bind(); + + glColor3f(1.0f, 1.0f, 1.0f); + + glBegin(GL_QUADS); + glTexCoord2f(0.0f, 0.0f); glVertex2f(min.x, min.y); + glTexCoord2f(1.0f, 0.0f); glVertex2f(max.x, min.y); + glTexCoord2f(1.0f, 1.0f); glVertex2f(max.x, max.y); + glTexCoord2f(0.0f, 1.0f); glVertex2f(min.x, max.y); + glEnd(); + } break; + } + } +} + +// Widget tree stuff wasn't working properly, so I removed it for +// now. If I need ultra-snazzy menus, I may finish this code + +#if 0 + +void Gui::doLayout() +{ + // Calculate sizes + for (unsigned int i = 0; i < widget.size(); i++) { + if (widget[i].parent == GWPARENT_NONE) { + measureWidgetTree(i); + placeWidgetTree(i); + } + } +} + +void Gui::measureWidgetTree(int w) +{ + widget[w].childcount = 0; + widget[w].fillercount = 0; + + switch (widget[w].type) { + default: + + widget[w].dims_measure = widget[w].dims_min; + + break; + + case GWT_CONTAINER: { + + vec2f measure = vec2f(0.0f, 0.0f); + + for (unsigned int i = 0; i < widget.size(); i++) { + if (widget[i].parent == w) { + measureWidgetTree(i); + + widget[w].childcount++; + + if (widget[i].type == GWT_FILLER) + widget[w].fillercount++; + + if (widget[w].vert) { + CLAMP_LOWER(measure.x, widget[i].dims_measure.x); + measure.y += widget[i].dims_measure.y; + } else { + measure.x += widget[i].dims_measure.x; + CLAMP_LOWER(measure.y, widget[i].dims_measure.y); + } + } + } + + widget[w].dims_measure = measure; + + } break; + } +} + +void Gui::placeWidgetTree(int w) +{ + if (widget[w].childcount <= 0) return; + + float extraspace = widget[w].vert ? + - widget[w].dims_measure.x : + - widget[w].dims_measure.y; + if (widget[w].parent == GWPARENT_NONE) { + extraspace += widget[w].vert ? + widget[w].dims_min.x : + widget[w].dims_min.y; + } + + CLAMP_LOWER(extraspace, 0.0f); + + //CLAMP_LOWER(widget[w].dims_measure.x, widget[w].dims_min.x); + //CLAMP_LOWER(widget[w].dims_measure.y, widget[w].dims_min.y); + + float + addtofillers = 0.0f, + addtochildren = 0.0f; + /* + if (widget[w].fillercount > 0) + addtofillers = extraspace / (float)widget[w].fillercount; + else + addtochildren = extraspace / (float)widget[w].childcount;*/ + + if (widget[w].vert) { + float distrib = widget[w].pos.y; + + for (unsigned int i = 0; i < widget.size(); i++) { + if (widget[i].parent == w) { + + widget[i].pos.x = widget[w].pos.x; + widget[i].pos.y = distrib; + + widget[i].dims_measure.x = widget[w].dims_measure.x; + + switch (widget[i].type) { + case GWT_FILLER: + widget[i].dims_measure.y += addtofillers; + break; + case GWT_CONTAINER: + widget[i].dims_measure.y += addtochildren; + placeWidgetTree(i); + break; + default: + widget[i].dims_measure.y += addtochildren; + break; + } + + distrib += widget[i].dims_measure.y; + } + } + } else { + float distrib = widget[w].pos.x; + + for (unsigned int i = 0; i < widget.size(); i++) { + if (widget[i].parent == w) { + + widget[i].pos.x = distrib; + widget[i].pos.y = widget[w].pos.y; + + widget[i].dims_measure.y = widget[w].dims_measure.y; + + switch (widget[i].type) { + case GWT_FILLER: + widget[i].dims_measure.x += addtofillers; + break; + case GWT_CONTAINER: + widget[i].dims_measure.x += addtochildren; + placeWidgetTree(i); + break; + default: + widget[i].dims_measure.x += addtochildren; + break; + } + + distrib += widget[i].dims_measure.x; + } + } + } +} + +void Gui::render() +{ + // Render trees of all root containers + + for (unsigned int i = 0; i < widget.size(); i++) { + if (widget[i].parent == GWPARENT_NONE) + renderWidgetTree(i); + } +} + +void Gui::renderWidgetTree(int w) +{ + vec2f min, max; + + switch (widget[w].type) { + case GWT_CONTAINER: + glColor4f(1.0f,0.0f,0.0f,0.2f); + break; + case GWT_FILLER: + glColor4f(0.0f,1.0f,0.0f,0.2f); + break; + case GWT_LABEL: + glColor4f(0.0f,0.0f,1.0f,0.2f); + break; + } + + min = widget[w].pos; + max = widget[w].pos + widget[w].dims_measure; + + glDisable(GL_TEXTURE_2D); + glBegin(GL_QUADS); + glVertex2f(min.x, min.y); + glVertex2f(max.x, min.y); + glVertex2f(max.x, max.y); + glVertex2f(min.x, max.y); + glEnd(); + glEnable(GL_TEXTURE_2D); + + // Render this widget + switch (widget[w].type) { + default: + break; + + case GWT_LABEL: { + glPushMatrix(); + vec2f ctr = widget[w].pos + widget[w].dims_measure * 0.5f; + glTranslatef(ctr.x, ctr.y, 0.0f); + glScalef(widget[w].fontsize, widget[w].fontsize, 1.0f); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + ssRender->drawText(widget[w].text, PTEXT_HZA_CENTER | PTEXT_VTA_CENTER); + glPopMatrix(); + } break; + } + + // Render children + switch (widget[w].type) { + case GWT_CONTAINER: + for (unsigned int i = 0; i < widget.size(); i++) { + if (widget[i].parent == w) + renderWidgetTree(i); + } + break; + } +} + +#endif + +int Gui::getFreeWidget() +{ + for (unsigned int i = 0; i < widget.size(); i++) { + if (widget[i].type == GWT_FREE) + return i; + } + widget.push_back(GuiWidget(GWT_FREE)); + return widget.size() - 1; +} + +#if 0 +int Gui::addRootContainer(float x, float y, float width, float height, bool vert) +{ + int w = getFreeWidget(); + widget[w].type = GWT_CONTAINER; + widget[w].vert = vert; + widget[w].parent = GWPARENT_NONE; + widget[w].dims_min = vec2f(width, height); + widget[w].pos = vec2f(x, y); + + return w; +} + +int Gui::addFiller(int parent, float minwidth, float minheight) +{ + int w = getFreeWidget(); + widget[w].type = GWT_FILLER; + widget[w].parent = parent; + widget[w].dims_min = vec2f(minwidth, minheight); + + return w; +} + +int Gui::addContainer(float x, float y, float width, float height, bool vert) +{ + int w = getFreeWidget(); + widget[w].type = GWT_CONTAINER; + widget[w].vert = vert; + widget[w].parent = parent; + widget[w].dims_min = vec2f(minwidth, minheight); + + return w; +} +#endif + +int Gui::addLabel(float x, float y, const std::string &text, uint32 flags, float fontsize) +{ + int w = getFreeWidget(); + widget[w].type = GWT_LABEL; + widget[w].text = text; + widget[w].fontsize = fontsize; + widget[w].dims_min = ssRender->getTextDims(text) * fontsize; + widget[w].pos = vec2f(x, y); + + if (flags & PTEXT_HZA_CENTER) + widget[w].pos.x -= widget[w].dims_min.x * 0.5f; + else if (flags & PTEXT_HZA_RIGHT) + widget[w].pos.x -= widget[w].dims_min.x; + + if (flags & PTEXT_VTA_CENTER) + widget[w].pos.y -= widget[w].dims_min.y * 0.5f; + else if (flags & PTEXT_VTA_TOP) + widget[w].pos.y -= widget[w].dims_min.y; + + return w; +} + +int Gui::addGraphic(float x, float y, float width, float height, PTexture *tex) +{ + int w = getFreeWidget(); + widget[w].type = GWT_GRAPHIC; + widget[w].dims_min = vec2f(width, height); + widget[w].pos = vec2f(x, y); + widget[w].tex = tex; + + return w; +} + diff -Nru trigger-rally-0.5.2.1/src/trigger/menu.h trigger-rally-0.6.0/src/trigger/menu.h --- trigger-rally-0.5.2.1/src/trigger/menu.h 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/trigger/menu.h 2011-10-07 17:10:01.000000000 +0000 @@ -1,148 +1,155 @@ - -// menu.h - -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net -// License: GPL version 2 (see included gpl.txt) - - -/* - -The organisation of this is horrible, I'm afraid... the menu.* files -contain both menu GUI implementation and level progress logic for -the game. Ick. - -*/ - -// menus -#define AM_TOP 21 -#define AM_TOP_EVT 22 -#define AM_TOP_EVT_PREP 23 -#define AM_TOP_LVL 24 -#define AM_TOP_LVL_PREP 25 -#define AM_TOP_QUIT 26 -#define AM_TOP_EVT_ABANDON 27 - -// actions -#define AA_INIT 1 -#define AA_RESUME 2 -#define AA_GO_TOP 11 -#define AA_GO_EVT 21 -#define AA_PICK_EVT 22 -#define AA_START_EVT 23 -#define AA_RESUME_EVT 24 -#define AA_RESTART_EVT 25 -#define AA_GO_LVL 31 -#define AA_PICK_LVL 32 -#define AA_START_LVL 33 -#define AA_GO_QUIT 41 -#define AA_QUIT_CONFIRM 42 - - -struct LevelState { - - int state; - - int currentevent; - int currentlevel; - - int livesleft; - float totaltime; - - std::vector leveltimes; -}; - - -#define GWT_FREE 0 -#define GWT_CONTAINER 10 -#define GWT_FILLER 11 -#define GWT_LABEL 12 -#define GWT_GRAPHIC 13 - -#define GWPARENT_NONE -1 - -struct GuiWidget { - - int type; - - bool clickable; - int d1, d2; - - std::string text; - float fontsize; - - vec2f - dims_min, - pos; - - float glow; - - PTexture *tex; - - GuiWidget(int t) : type(t), clickable(false), glow(0.0f) { } -}; - - -class Gui { - -private: - std::vector widget; - - PSSRender *ssRender; - - vec2f cursor; - - int highlight, defwidget; - - float defflash; - - PTexture *fonttex; - -protected: - int getFreeWidget(); - - void measureWidgetTree(int w); - void placeWidgetTree(int w); - - void renderWidgetTree(int w); - -public: - Gui() : cursor(vec2f::zero()), defflash(0.0f) { } - - void setSSRender(PSSRender &render) { ssRender = &render; } - void setFont(PTexture *tex) { fonttex = tex; } - - void tick(float delta); - - void setCursorPos(float x, float y); - - bool getClickAction(int &data1, int &data2); - bool getDefaultAction(int &data1, int &data2); - - void doLayout(); - - void render(); - - void clear() { widget.clear(); highlight = -1; defwidget = -1; } - - int addContainer(int parent, float minwidth, float minheight, bool vert); - - int addLabel(float x, float y, const std::string &text, uint32 flags, float fontsize); - - int addGraphic(float x, float y, float width, float height, PTexture *tex); - - int makeClickable(int w, int data1, int data2) { - widget[w].clickable = true; - widget[w].d1 = data1; - widget[w].d2 = data2; - return w; - } - - int makeUnclickable(int w) { - widget[w].clickable = false; - return w; - } - - void makeDefault(int w) { defwidget = w; } -}; - - + +// menu.h + +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net +// License: GPL version 2 (see included gpl.txt) + + +/* + +The organisation of this is horrible, I'm afraid... the menu.* files +contain both menu GUI implementation and level progress logic for +the game. Ick. + +*/ + +// menus +#define AM_TOP 21 // Event / Practice / Single race / Quit +#define AM_TOP_EVT 22 // Choose event to race +#define AM_TOP_EVT_PREP 23 // Shows event progress +#define AM_TOP_EVT_ABANDON 24 // Really leave event? +#define AM_TOP_PRAC 25 // Choose event to practice +#define AM_TOP_PRAC_SEL 26 // Choose level to practice +#define AM_TOP_PRAC_SEL_PREP 27 // Show track info (practice) +#define AM_TOP_LVL 28 // Choose single race +#define AM_TOP_LVL_PREP 29 // Show track info (single race) +#define AM_TOP_QUIT 30 // Are you sure you want to quit? + +// actions +#define AA_INIT 1 +#define AA_RESUME 2 +#define AA_GO_TOP 11 +#define AA_GO_EVT 21 +#define AA_PICK_EVT 22 +#define AA_START_EVT 23 +#define AA_RESUME_EVT 24 +#define AA_RESTART_EVT 25 +#define AA_GO_PRAC 31 +#define AA_PICK_PRAC 32 +#define AA_PICK_PRAC_LVL 33 +#define AA_START_PRAC 34 +#define AA_GO_LVL 41 +#define AA_PICK_LVL 42 +#define AA_START_LVL 43 +#define AA_GO_QUIT 51 +#define AA_QUIT_CONFIRM 52 + + +struct LevelState { + + int state; + + int currentevent; + int currentlevel; + + int livesleft; + float totaltime; + + std::vector leveltimes; +}; + + +#define GWT_FREE 0 +#define GWT_CONTAINER 10 +#define GWT_FILLER 11 +#define GWT_LABEL 12 +#define GWT_GRAPHIC 13 + +#define GWPARENT_NONE -1 + +struct GuiWidget { + + int type; + + bool clickable; + int d1, d2; + + std::string text; + float fontsize; + + vec2f + dims_min, + pos; + + float glow; + + PTexture *tex; + + GuiWidget(int t) : type(t), clickable(false), glow(0.0f) { } +}; + + +class Gui { + +private: + std::vector widget; + + PSSRender *ssRender; + + vec2f cursor; + + int highlight, defwidget; + + float defflash; + + PTexture *fonttex; + +protected: + int getFreeWidget(); + + void measureWidgetTree(int w); + void placeWidgetTree(int w); + + void renderWidgetTree(int w); + +public: + Gui() : cursor(vec2f::zero()), defflash(0.0f) { } + + void setSSRender(PSSRender &render) { ssRender = &render; } + void setFont(PTexture *tex) { fonttex = tex; } + + void tick(float delta); + + void setCursorPos(float x, float y); + + bool getClickAction(int &data1, int &data2); + bool getDefaultAction(int &data1, int &data2); + + void doLayout(); + + void render(); + + void clear() { widget.clear(); highlight = -1; defwidget = -1; } + + int addContainer(int parent, float minwidth, float minheight, bool vert); + + int addLabel(float x, float y, const std::string &text, uint32 flags, float fontsize); + + int addGraphic(float x, float y, float width, float height, PTexture *tex); + + int makeClickable(int w, int data1, int data2) { + widget[w].clickable = true; + widget[w].d1 = data1; + widget[w].d2 = data2; + return w; + } + + int makeUnclickable(int w) { + widget[w].clickable = false; + return w; + } + + void makeDefault(int w) { defwidget = w; } +}; + + diff -Nru trigger-rally-0.5.2.1/src/trigger/render.cpp trigger-rally-0.6.0/src/trigger/render.cpp --- trigger-rally-0.5.2.1/src/trigger/render.cpp 2006-01-14 10:09:20.000000000 +0000 +++ trigger-rally-0.6.0/src/trigger/render.cpp 2011-10-07 17:10:01.000000000 +0000 @@ -1,1054 +1,1093 @@ - -// render.cpp - -// Copyright 2004-2006 Jasmine Langridge, jaz at positro.net -// License: GPL version 2 (see included gpl.txt) - - -#include "main.h" - -void MainApp::resize() -{ - glClearColor(1.0,1.0,1.0,1.0); - glEnable(GL_TEXTURE_2D); - - glEnable(GL_BLEND); - glBlendFunc(GL_ONE,GL_ZERO); - - glDepthFunc(GL_LEQUAL); - glEnable(GL_DEPTH_TEST); - glClearDepth(1.0); - - glEnable(GL_CULL_FACE); - - glEnable(GL_FOG); - glFogi(GL_FOG_MODE, GL_EXP); - - glEnable(GL_LIGHT0); - glEnable(GL_LIGHTING); - - float ambcol[] = { 0.1,0.1,0.1,0.0 }; - glLightModelfv(GL_LIGHT_MODEL_AMBIENT,ambcol); - - float white[] = { 1.0,1.0,1.0,1.0 }; - //float black[] = { 0.0,0.0,0.0,1.0 }; - glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE,white); - - float spec[] = { 0.3f, 0.5f, 0.5f, 1.0f }; - glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec); - glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 6.0f); - - float litcol[] = { 0.6,0.6,0.6,0.0 }; - glLightfv(GL_LIGHT0,GL_DIFFUSE,litcol); - glLightfv(GL_LIGHT0,GL_SPECULAR,litcol); - - glEnable(GL_NORMALIZE); -} - -void drawBlades(float radius, float ang, float trace) -{ - float invtrace = 1.0 / trace; - glPushMatrix(); - glScalef(radius, radius, 1.0); - for (float ba=0; babind(); - { - float tgens[] = { 0.5,0,0,0 }; - float tgent[] = { 0,0.5,0,0 }; - glTexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR); - glTexGenfv(GL_S,GL_OBJECT_PLANE,tgens); - glTexGeni(GL_T,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR); - glTexGenfv(GL_T,GL_OBJECT_PLANE,tgent); - } - glEnable(GL_TEXTURE_GEN_S); - glEnable(GL_TEXTURE_GEN_T); - glPushMatrix(); - glScalef(20.0,20.0,1.0); - glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - { - int minx = (int)(campos.x / 20.0)-20, - maxx = minx + 40, - miny = (int)(campos.y / 20.0)-20, - maxy = miny + 40; - for (int y=miny; yterrain->getHeight((x)*20.0,(y+1)*20.0); - alpha = 1.0 - exp(ht-40.3); - CLAMP(alpha,0.0,0.5); - glColor4f(1.0,1.0,1.0,alpha); - glVertex3f(x,y+1,40.3); - ht = game->terrain->getHeight((x)*20.0,(y)*20.0); - alpha = 1.0 - exp(ht-40.3); - CLAMP(alpha,0.0,0.5); - glColor4f(1.0,1.0,1.0,alpha); - glVertex3f(x,y,40.3); - } - glEnd(); - } - } - glPopMatrix(); - glBlendFunc(GL_ONE,GL_ZERO); - - glDisable(GL_TEXTURE_GEN_S); - glDisable(GL_TEXTURE_GEN_T); -} - -void MainApp::renderSky(const mat44f &cammat) -{ - glFogf(GL_FOG_DENSITY, game->weather.fog.density_sky); - glDepthRange(0.999,1.0); - glDisable(GL_CULL_FACE); - glPushMatrix(); // 1 - glLoadIdentity(); - glMultMatrixf(cammat); - tex_sky[0]->bind(); -#define CLRANGE 10 -#define CLFACTOR 0.02//0.014 - glMatrixMode(GL_TEXTURE); - glPushMatrix(); - glTranslatef(cloudscroll,0.0,0.0); - glRotatef(30.0,0.0,0.0,1.0); - glScalef(0.4,0.4,1.0); - for (int y=-CLRANGE; yweather.fog.density); -} - -void MainApp::render(float eyetranslation) -{ - switch (appstate) { - case AS_LOAD_1: - renderStateLoading(eyetranslation); - break; - - case AS_LOAD_2: - case AS_LOAD_3: - break; - - case AS_LEVEL_SCREEN: - renderStateLevel(eyetranslation); - break; - - case AS_CHOOSE_VEHICLE: - renderStateChoose(eyetranslation); - break; - - case AS_IN_GAME: - renderStateGame(eyetranslation); - break; - - case AS_END_SCREEN: - renderStateEnd(eyetranslation); - break; - } - - glFinish(); -} - -void MainApp::renderStateLoading(float eyetranslation) -{ - eyetranslation = eyetranslation; - - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - glOrtho(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f); - glMatrixMode(GL_MODELVIEW); - - tex_splash_screen->bind(); - - glDisable(GL_DEPTH_TEST); - glDisable(GL_FOG); - glDisable(GL_LIGHTING); - glBlendFunc(GL_ONE, GL_ZERO); - - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - - glBegin(GL_QUADS); - glTexCoord2f(1.0f,1.0f); glVertex2f(1.0f,1.0f); - glTexCoord2f(0.0f,1.0f); glVertex2f(-1.0f,1.0f); - glTexCoord2f(0.0f,0.0f); glVertex2f(-1.0f,-1.0f); - glTexCoord2f(1.0f,0.0f); glVertex2f(1.0f,-1.0f); - glEnd(); - - glEnable(GL_DEPTH_TEST); - glEnable(GL_FOG); - glEnable(GL_LIGHTING); - - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); -} - -char *creditstext[] = { - "Trigger " PACKAGE_VERSION, - "", - "Copyright (C) 2004-2006", - "Jasmine Langridge and Richard Langridge", - "Posit Interactive", - "", - "", - "", - "Coding", - "Jasmine Langridge", - "", - "Art & SFX", - "Richard Langridge", - "", - "", - "", - "Contributors", - "", - "Build system", - "Matze Braune", - "", - "Stereo support", - "Chuck Sites", - "", - "Mac OS X porting", - "Tim Douglas", - "", - "Fixes", - "LavaPunk", - "Bernhard Kaindl", - "", - "New levels", - "Tim Wintle", - "David Pagnier", - "Jared Buckner", - "Andreas Rosdal", - "Ivan", - "Viktor Radnai", - "Pierre-Alexis", - "", - "Graphics", - "Alex", - "Roberto Diez Gonzalez", - "", - "", - "", - "", - "", - "Thanks to Jonathan C. Hatfull", - "", - "", - "", - "", - "And thanks to Simon Brown too", - "", - "", - "", - "", - "", - "", - "Thanks for playing Trigger" -}; -#define NUMCREDITSTRINGS (sizeof(creditstext) / sizeof(char*)) - -void MainApp::renderStateEnd(float eyetranslation) -{ - eyetranslation = eyetranslation; - - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - glOrtho(-1.33f, 1.33f, -1.0f, 1.0f, -1.0f, 1.0f); - glMatrixMode(GL_MODELVIEW); - - tex_end_screen->bind(); - - glDisable(GL_DEPTH_TEST); - glDisable(GL_FOG); - glDisable(GL_LIGHTING); - glBlendFunc(GL_ONE, GL_ZERO); - - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - - glBegin(GL_QUADS); - glTexCoord2f(1.0f,1.0f); glVertex2f(1.33f,1.0f); - glTexCoord2f(0.0f,1.0f); glVertex2f(-1.33f,1.0f); - glTexCoord2f(0.0f,0.0f); glVertex2f(-1.33f,-1.0f); - glTexCoord2f(1.0f,0.0f); glVertex2f(1.33f,-1.0f); - glEnd(); - - tex_font->bind(); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - glPushMatrix(); - - float scroll = splashtimeout; - const float maxscroll = (float)(NUMCREDITSTRINGS - 1) * 2.0f; - RANGEADJUST(scroll, 0.0f, 0.9f, -10.0f, maxscroll); - CLAMP_UPPER(scroll, maxscroll); - - glScalef(0.1f, 0.1f, 1.0f); - - glTranslatef(0.0f, scroll, 0.0f); - - for (int i = 0; i < (int)NUMCREDITSTRINGS; i++) { - float level = fabsf(scroll + (float)i * -2.0f); - RANGEADJUST(level, 0.0f, 9.0f, 3.0f, 0.0f); - - if (level > 0.0f) { - CLAMP_UPPER(level, 1.0f); - - glPushMatrix(); - glTranslatef(0.0f, (float)i * -2.0f, 0.0f); - - float enlarge = 1.0f; - - #if 1 - if (splashtimeout > 0.9f) { - float amt = (splashtimeout - 0.9f) * 10.0f; - float amt2 = amt * amt; - - enlarge += amt2 / ((1.0001f - amt) * (1.0001f - amt)); - level -= amt2; - } - #endif - - glScalef(enlarge, enlarge, 0.0f); - glColor4f(1.0f, 1.0f, 1.0f, level); - - getSSRender().drawText(creditstext[i], PTEXT_HZA_CENTER | PTEXT_VTA_CENTER); - glPopMatrix(); - } - } - - glPopMatrix(); - - glEnable(GL_DEPTH_TEST); - glEnable(GL_FOG); - glEnable(GL_LIGHTING); - - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); -} - -void MainApp::renderStateChoose(float eyetranslation) -{ - PVehicleType *vtype = game->vehiclechoices[choose_type]; - - glClearColor(0.0, 0.0, 0.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - float fnear = 0.1f, fov = 0.6f; - float aspect = (float)getWidth() / (float)getHeight(); - stereoFrustum(-fnear*aspect*fov,fnear*aspect*fov,-fnear*fov,fnear*fov,fnear,100000.0f, - 0.8f, eyetranslation); - glMatrixMode(GL_MODELVIEW); - - - glPushMatrix(); // 0 - - glTranslatef(-eyetranslation, -0.3f, -3.0f); - - glDisable(GL_FOG); - glEnable(GL_LIGHTING); - - vec4f lpos = vec4f(0.0f, 1.0f, 0.0f, 0.0f); - glLightfv(GL_LIGHT0, GL_POSITION, lpos); - - float tmp = sinf(choose_spin * 2.0f) * 0.5f; - tmp += choose_spin; - glRotatef(90.0f, -1.0f, 0.0f, 0.0f); - glRotatef(DEGREES(tmp), 0.0f, 0.0f, 1.0f); - - { - for (unsigned int i=0; ipart.size(); ++i) { - glPushMatrix(); // 1 - - vec3f vpos = vtype->part[i].ref_local.pos; - glTranslatef(vpos.x, vpos.y, vpos.z); - - mat44f vorim = vtype->part[i].ref_local.ori_mat_inv; - glMultMatrixf(vorim); - if (vtype->part[i].model) { - - glPushMatrix(); // 2 - - float scale = vtype->part[i].scale; - glScalef(scale,scale,scale); - drawModel(*vtype->part[i].model); - - glPopMatrix(); // 2 - } - - if (vtype->wheelmodel) { - for (unsigned int j=0; jpart[i].wheel.size(); j++) { - - glPushMatrix(); // 2 - - vec3f &wpos = vtype->part[i].wheel[j].pt; - glTranslatef(wpos.x, wpos.y, wpos.z); - - float scale = vtype->wheelscale * vtype->part[i].wheel[j].radius; - glScalef(scale,scale,scale); - - drawModel(*vtype->wheelmodel); - - glPopMatrix(); // 2 - } - } - - glPopMatrix(); // 1 - } - } - - glPopMatrix(); // 0 - - glDisable(GL_LIGHTING); - - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - glOrtho(-1.33f, 1.33f, -1.0f, 1.0f, -1.0f, 1.0f); - glMatrixMode(GL_MODELVIEW); - - tex_font->bind(); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glDisable(GL_DEPTH_TEST); - glDisable(GL_LIGHTING); - - glPushMatrix(); // 0 - - glPushMatrix(); // 1 - glTranslatef(0.0f, 0.8f, 0.0f); - glScalef(0.1f, 0.1f, 1.0f); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - getSSRender().drawText("Choose Vehicle", PTEXT_HZA_CENTER | PTEXT_VTA_CENTER); - glPopMatrix(); // 1 - - glPushMatrix(); // 1 - glTranslatef(0.0f, 0.7f, 0.0f); - glScalef(0.1f, 0.1f, 1.0f); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - getSSRender().drawText( - PUtil::formatInt(choose_type + 1, 2) + " of " + - PUtil::formatInt(game->vehiclechoices.size(), 2), - PTEXT_HZA_CENTER | PTEXT_VTA_CENTER); - glPopMatrix(); // 1 - - glPushMatrix(); // 1 - - glTranslatef(0.0f, -0.8f, 0.0f); - glScalef(0.1f, 0.1f, 1.0f); - - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - - getSSRender().drawText(vtype->proper_name, PTEXT_HZA_CENTER | PTEXT_VTA_CENTER); - - glPopMatrix(); // 1 - - glPopMatrix(); // 0 - - glBlendFunc(GL_ONE, GL_ZERO); - glEnable(GL_DEPTH_TEST); - glEnable(GL_FOG); - glEnable(GL_LIGHTING); - - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); -} - -void MainApp::renderStateGame(float eyetranslation) -{ - PVehicle *vehic = game->vehicle[0]; - - glClear(GL_DEPTH_BUFFER_BIT); - //glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - float fnear = 0.1f, fov = 0.6f; - float aspect = (float)getWidth() / (float)getHeight(); - stereoFrustum(-fnear*aspect*fov,fnear*aspect*fov,-fnear*fov,fnear*fov,fnear,100000.0f, - 0.8f, eyetranslation); - glMatrixMode(GL_MODELVIEW); - - glColor3f(1.0,1.0,1.0); - - vec4f fogcolor(game->weather.fog.color, 1.0f); - glFogfv(GL_FOG_COLOR, fogcolor); - - glDepthRange(0.0,0.999); - - glPushMatrix(); // 0 - - mat44f cammat = camori.getMatrix(); - mat44f cammat_inv = cammat.transpose(); - - //glTranslatef(0.0,0.0,-40.0); - glTranslatef(-eyetranslation, 0.0f, 0.0f); - - glMultMatrixf(cammat); - - glTranslatef(-campos.x, -campos.y, -campos.z); - - float lpos[] = { 0.2, 0.5, 1.0, 0.0 }; - glLightfv(GL_LIGHT0, GL_POSITION, lpos); - - glColor3ub(255,255,255); - - glDisable(GL_LIGHTING); - - glActiveTextureARB(GL_TEXTURE1_ARB); - glEnable(GL_TEXTURE_2D); - glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE); - glTexEnvi(GL_TEXTURE_ENV,GL_COMBINE_RGB,GL_ADD_SIGNED); - glTexEnvi(GL_TEXTURE_ENV,GL_COMBINE_ALPHA,GL_MODULATE); - tex_detail->bind(); - glTexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR); - glTexGeni(GL_T,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR); - float tgens[] = { 0.05, 0.0, 0.0, 0.0 }; - float tgent[] = { 0.0, 0.05, 0.0, 0.0 }; - glTexGenfv(GL_S,GL_OBJECT_PLANE,tgens); - glTexGenfv(GL_T,GL_OBJECT_PLANE,tgent); - glEnable(GL_TEXTURE_GEN_S); - glEnable(GL_TEXTURE_GEN_T); - glActiveTextureARB(GL_TEXTURE0_ARB); - - // draw terrain - game->terrain->render(campos, cammat_inv); - - glDisable(GL_TEXTURE_GEN_S); - glDisable(GL_TEXTURE_GEN_T); - - glActiveTextureARB(GL_TEXTURE1_ARB); - glDisable(GL_TEXTURE_2D); - glActiveTextureARB(GL_TEXTURE0_ARB); - - if (renderowncar) { - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - tex_shadow->bind(); - - glColor4f(1.0f, 1.0f, 1.0f, 0.7f); - - vec3f vpos = game->vehicle[0]->body->pos; - vec3f forw = makevec3f(game->vehicle[0]->body->getOrientationMatrix().row[0]); - float forwangle = atan2(forw.y, forw.x); - game->terrain->drawSplat(vpos.x, vpos.y, 1.4f, forwangle + PI*0.5f); - - glBlendFunc(GL_ONE, GL_ZERO); - } - - renderSky(cammat); - - glEnable(GL_LIGHTING); - - for (unsigned int v=0; vvehicle.size(); ++v) { - - if (!renderowncar && v == 0) continue; - - PVehicle *vehic = game->vehicle[v]; - for (unsigned int i=0; ipart.size(); ++i) { - if (vehic->type->part[i].model) { - glPushMatrix(); // 1 - - vec3f vpos = vehic->part[i].ref_world.pos; - glTranslatef(vpos.x, vpos.y, vpos.z); - - mat44f vorim = vehic->part[i].ref_world.ori_mat_inv; - glMultMatrixf(vorim); - - float scale = vehic->type->part[i].scale; - glScalef(scale,scale,scale); - - drawModel(*vehic->type->part[i].model); - - glPopMatrix(); // 1 - } - - if (vehic->type->wheelmodel) { - for (unsigned int j=0; jtype->part[i].wheel.size(); j++) { - - glPushMatrix(); // 1 - - vec3f wpos = vehic->part[i].wheel[j].ref_world.getPosition(); - glTranslatef(wpos.x,wpos.y,wpos.z); - - mat44f worim = vehic->part[i].wheel[j].ref_world.ori_mat_inv; - glMultMatrixf(worim); - - float scale = vehic->type->wheelscale * vehic->type->part[i].wheel[j].radius; - glScalef(scale,scale,scale); - - drawModel(*vehic->type->wheelmodel); - - glPopMatrix(); // 1 - } - } - } - } - - glDisable(GL_LIGHTING); - - glDepthMask(GL_FALSE); - glDisable(GL_CULL_FACE); - - glDisable(GL_TEXTURE_2D); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - -#define RAINDROP_WIDTH 0.015 - const vec4f raindrop_col(0.5,0.5,0.5,0.4); - - vec3f offsetdrops = campos - campos_prev; - - for (unsigned int i = 0; i < rain.size(); i++) { - vec3f tempv; - const float prevlife = rain[i].prevlife; - vec3f pt1 = rain[i].drop_pt + rain[i].drop_vect * prevlife + offsetdrops; - vec3f pt2 = rain[i].drop_pt + rain[i].drop_vect * rain[i].life; - vec3f zag = campos - rain[i].drop_pt; - zag = zag.cross(rain[i].drop_vect); - zag *= RAINDROP_WIDTH / zag.length(); - glBegin(GL_TRIANGLE_STRIP); - glColor4f(raindrop_col[0],raindrop_col[1],raindrop_col[2],0.0); - tempv = pt1 - zag; - glVertex3fv(tempv); - tempv = pt2 - zag; - glVertex3fv(tempv); - - glColor4fv(raindrop_col); - glVertex3fv(pt1); - glVertex3fv(pt2); - - glColor4f(raindrop_col[0],raindrop_col[1],raindrop_col[2],0.0); - tempv = pt1 + zag; - glVertex3fv(tempv); - tempv = pt2 + zag; - glVertex3fv(tempv); - glEnd(); - } - - const vec4f checkpoint_col[3] = { - vec4f(1.0f, 0.0f, 0.0f, 0.8f), // 0 = next checkpoint - vec4f(0.7f, 0.7f, 0.1f, 0.6f), // 1 = checkpoint after next - vec4f(0.2f, 0.8f, 0.2f, 0.4f) // 2 = all other checkpoints - }; - - for (unsigned int i=0; icheckpt.size(); i++) { - - vec4f colr = checkpoint_col[2]; - - if ((int)i == vehic->nextcp) - colr = checkpoint_col[0]; - else if ((int)i == (vehic->nextcp + 1) % (int)game->checkpt.size()) - colr = checkpoint_col[1]; - - glPushMatrix(); // 1 - - glTranslatef(game->checkpt[i].pt.x, game->checkpt[i].pt.y, game->checkpt[i].pt.z); - - glScalef(25.0f, 25.0f, 1.0f); - - #if 0 - glBegin(GL_TRIANGLE_STRIP); - - for (float a = 0.0f; a < 0.99f; a += 0.05f) { - glColor4f(colr[0], colr[1], colr[2], colr[3] * a); - float ang = cprotate + a * 6.0f; - float ht = sinf(ang * 1.7f) * 7.0f + 8.0f; - glVertex3f(cosf(ang), sinf(ang), ht - 1.0f); - glVertex3f(cosf(ang), sinf(ang), ht + 1.0f); - } - - for (float a = 1.0f; a < 2.01f; a += 0.05f) { - glColor4f(colr[0], colr[1], colr[2], colr[3] * (2.0f - a)); - float ang = cprotate + a * 6.0f; - float ht = sinf(ang * 1.7f) * 7.0f + 8.0f; - glVertex3f(cosf(ang), sinf(ang), ht - 1.0f); - glVertex3f(cosf(ang), sinf(ang), ht + 1.0f); - } - - glEnd(); - #else - glBegin(GL_TRIANGLE_STRIP); - float ht = sinf(cprotate * 6.0f) * 7.0f + 8.0f; - glColor4f(colr[0], colr[1], colr[2], 0.0f); - glVertex3f(1.0f, 0.0f, ht - 1.0f); - glColor4f(colr[0], colr[1], colr[2], colr[3]); - glVertex3f(1.0f, 0.0f, ht + 0.0f); - for (float a = PI/10.0f; a < PI*2.0f-0.01f; a += PI/10.0f) { - glColor4f(colr[0], colr[1], colr[2], 0.0f); - glVertex3f(cosf(a), sinf(a), ht - 1.0f); - glColor4f(colr[0], colr[1], colr[2], colr[3]); - glVertex3f(cosf(a), sinf(a), ht + 0.0f); - } - glColor4f(colr[0], colr[1], colr[2], 0.0f); - glVertex3f(1.0f, 0.0f, ht - 1.0f); - glColor4f(colr[0], colr[1], colr[2], colr[3]); - glVertex3f(1.0f, 0.0f, ht + 0.0f); - glEnd(); - - glBegin(GL_TRIANGLE_STRIP); - glColor4f(colr[0], colr[1], colr[2], colr[3]); - glVertex3f(1.0f, 0.0f, ht - 0.0f); - glColor4f(colr[0], colr[1], colr[2], 0.0f); - glVertex3f(1.0f, 0.0f, ht + 1.0f); - for (float a = PI/10.0f; a < PI*2.0f-0.01f; a += PI/10.0f) { - glColor4f(colr[0], colr[1], colr[2], colr[3]); - glVertex3f(cosf(a), sinf(a), ht - 0.0f); - glColor4f(colr[0], colr[1], colr[2], 0.0f); - glVertex3f(cosf(a), sinf(a), ht + 1.0f); - } - glColor4f(colr[0], colr[1], colr[2], colr[3]); - glVertex3f(1.0f, 0.0f, ht - 0.0f); - glColor4f(colr[0], colr[1], colr[2], 0.0f); - glVertex3f(1.0f, 0.0f, ht + 1.0f); - glEnd(); - #endif - - glPopMatrix(); // 1 - } - - glEnable(GL_TEXTURE_2D); - - //renderWater(); - - getSSRender().render(psys_dirt); - - glDepthMask(GL_TRUE); - glBlendFunc(GL_ONE,GL_ZERO); - glEnable(GL_LIGHTING); - glEnable(GL_CULL_FACE); - glEnable(GL_FOG); - - glDisable(GL_LIGHTING); - - glPopMatrix(); // 0 - - glDisable(GL_DEPTH_TEST); - - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - glOrtho(-1.33f, 1.33f, -1.0f, 1.0f, -1.0f, 1.0f); - glMatrixMode(GL_MODELVIEW); - - glPushMatrix(); // 0 - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - glPushMatrix(); // 1 - glTranslatef(1.0f, -0.7f, 0.0f); - glScalef(0.25f, 0.25f, 1.0f); - - tex_hud_revs->bind(); - glColor3f(1.0f, 1.0f, 1.0f); - glBegin(GL_QUADS); - glTexCoord2f(1.0f,1.0f); glVertex2f(1.0f,1.0f); - glTexCoord2f(0.0f,1.0f); glVertex2f(-1.0f,1.0f); - glTexCoord2f(0.0f,0.0f); glVertex2f(-1.0f,-1.0f); - glTexCoord2f(1.0f,0.0f); glVertex2f(1.0f,-1.0f); - glEnd(); - - glDisable(GL_TEXTURE_2D); - - glRotatef(210.0f - vehic->getEngineRPM() * 20.0f / 1000.0f, 0.0f, 0.0f, 1.0f); - - glColor3f(1.0f, 0.0f, 0.0f); - glBegin(GL_TRIANGLES); - glVertex2f(0.9f, 0.0f); glVertex2f(-0.2f, 0.05f); glVertex2f(-0.2f, -0.05f); - glEnd(); - - glPopMatrix(); // 1 - - glEnable(GL_TEXTURE_2D); - - glPushMatrix(); // 1 - glTranslatef(1.0f, -0.2f, 0.0f); - glScalef(0.25f, 0.25f, 1.0f); - - tex_hud_speedo->bind(); - glColor3f(1.0f, 1.0f, 1.0f); - glBegin(GL_QUADS); - glTexCoord2f(1.0f,1.0f); glVertex2f(1.0f,1.0f); - glTexCoord2f(0.0f,1.0f); glVertex2f(-1.0f,1.0f); - glTexCoord2f(0.0f,0.0f); glVertex2f(-1.0f,-1.0f); - glTexCoord2f(1.0f,0.0f); glVertex2f(1.0f,-1.0f); - glEnd(); - - glDisable(GL_TEXTURE_2D); - - glRotatef(210.0f - MPS_TO_MPH(fabsf(vehic->getWheelSpeed())) * 15.0f / 10.0f, 0.0f, 0.0f, 1.0f); - - glColor3f(1.0f, 0.0f, 0.0f); - glBegin(GL_TRIANGLES); - glVertex2f(0.9f, 0.0f); glVertex2f(-0.2f, 0.05f); glVertex2f(-0.2f, -0.05f); - glEnd(); - - glPopMatrix(); // 1 - - #if 0 - glPushMatrix(); // 1 - - glTranslatef(0.0f, 0.8f, 0.0f); - - glScalef(0.2f, 0.2f, 0.2f); - - glRotatef(-30.0f, 1.0f, 0.0f, 0.0f); - glRotatef(DEGREES(nextcpangle), 0.0f, -1.0f, 0.0f); - - glBegin(GL_TRIANGLES); - glColor4f(0.8f, 0.4f, 0.4f, 0.6f); - glVertex3f(0.0f, 0.0f, -2.0f); - glColor4f(0.8f, 0.8f, 0.8f, 0.6f); - glVertex3f(1.0f, 0.0f, 1.0f); - glVertex3f(-1.0f, 0.0f, 1.0f); - glEnd(); - glBegin(GL_TRIANGLE_STRIP); - glColor4f(0.8f, 0.4f, 0.4f, 0.6f); - glVertex3f(0.0f, 0.0f, -2.0f); - glColor4f(1.0f, 0.5f, 0.5f, 0.6f); - glVertex3f(0.0f, 0.2f, -2.0f); - glColor4f(0.8f, 0.8f, 0.8f, 0.6f); - glVertex3f(1.0f, 0.0f, 1.0f); - glColor4f(1.0f, 1.0f, 1.0f, 0.6f); - glVertex3f(1.0f, 0.2f, 1.0f); - glColor4f(0.8f, 0.8f, 0.8f, 0.6f); - glVertex3f(-1.0f, 0.0f, 1.0f); - glColor4f(1.0f, 1.0f, 1.0f, 0.6f); - glVertex3f(-1.0f, 0.2f, 1.0f); - glColor4f(0.8f, 0.4f, 0.4f, 0.6f); - glVertex3f(0.0f, 0.0f, -2.0f); - glColor4f(1.0f, 0.5f, 0.5f, 0.6f); - glVertex3f(0.0f, 0.2f, -2.0f); - glEnd(); - - glPopMatrix(); // 1 - #endif - - if (showmap) { - glViewport(10, 10, getHeight()/3, getHeight()/3); - - glPushMatrix(); // 1 - glScalef(1.33f, 1.0f, 1.0f); - - if (game->terrain->getHUDMapTexture()) { - glEnable(GL_TEXTURE_2D); - game->terrain->getHUDMapTexture()->bind(); - } - - glMatrixMode(GL_TEXTURE); - glPushMatrix(); - float scalefac = 1.0f / game->terrain->getMapSize(); - glScalef(scalefac, scalefac, 1.0f); - glTranslatef(campos.x, campos.y, 0.0f); - glRotatef(DEGREES(camera_angle), 0.0f, 0.0f, 1.0f); - glScalef(1.0f / 0.003f, 1.0f / 0.003f, 1.0f); - - glBegin(GL_QUADS); - glColor4f(1.0f, 1.0f, 1.0f, 0.7f); - glTexCoord2f(1.0f, 1.0f); glVertex2f(1.0f, 1.0f); - glTexCoord2f(-1.0f, 1.0f); glVertex2f(-1.0f, 1.0f); - glTexCoord2f(-1.0f, -1.0f); glVertex2f(-1.0f, -1.0f); - glTexCoord2f(1.0f, -1.0f); glVertex2f(1.0f, -1.0f); - glEnd(); - - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - - glDisable(GL_TEXTURE_2D); - - glPushMatrix(); // 2 - glScalef(0.003f, 0.003f, 1.0f); - glRotatef(DEGREES(-camera_angle), 0.0f, 0.0f, 1.0f); - glTranslatef(-campos.x, -campos.y, 0.0f); - for (unsigned int i=0; icheckpt.size(); i++) { - glPushMatrix(); - vec3f vpos = game->checkpt[i].pt; - glTranslatef(vpos.x, vpos.y, 0.0f); - glRotatef(DEGREES(camera_angle), 0.0f, 0.0f, 1.0f); - glScalef(30.0f, 30.0f, 1.0f); - vec4f colr = checkpoint_col[2]; - if ((int)i == vehic->nextcp) { - float sc = 1.5f + sinf(cprotate * 10.0f) * 0.5f; - glScalef(sc, sc, 1.0f); - colr = checkpoint_col[0]; - } else if ((int)i == (vehic->nextcp + 1) % (int)game->checkpt.size()) { - colr = checkpoint_col[1]; - } - glBegin(GL_TRIANGLE_FAN); - glColor4fv(colr); - glVertex2f(0.0f, 0.0f); - glColor4f(colr[0], colr[1], colr[2], 0.0f); - //glColor4f(1.0f, 1.0f, 1.0f, 0.0f); - glVertex2f(1.0f, 0.0f); - glVertex2f(0.0f, 1.0f); - glVertex2f(-1.0f, 0.0f); - glVertex2f(0.0f, -1.0f); - glVertex2f(1.0f, 0.0f); - glEnd(); - glPopMatrix(); - } - for (unsigned int i=0; ivehicle.size(); i++) { - glPushMatrix(); - vec3f vpos = game->vehicle[i]->body->getPosition(); - glTranslatef(vpos.x, vpos.y, 0.0f); - glRotatef(DEGREES(camera_angle), 0.0f, 0.0f, 1.0f); - glScalef(30.0f, 30.0f, 1.0f); - glBegin(GL_TRIANGLE_FAN); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glVertex2f(0.0f, 0.0f); - glColor4f(1.0f, 1.0f, 1.0f, 0.0f); - glVertex2f(1.0f, 0.0f); - glVertex2f(0.0f, 1.0f); - glVertex2f(-1.0f, 0.0f); - glVertex2f(0.0f, -1.0f); - glVertex2f(1.0f, 0.0f); - glEnd(); - glPopMatrix(); - } - glPopMatrix(); // 2 - - glPopMatrix(); // 1 - - glViewport(0, 0, getWidth(), getHeight()); - } - - glEnable(GL_TEXTURE_2D); - - glPushMatrix(); // 1 - - tex_hud_gear->bind(); - glPushMatrix(); // 2 - - glTranslatef(1.0f, 0.35f, 0.0f); - glScalef(0.2f, 0.2f, 1.0f); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glBegin(GL_QUADS); - glTexCoord2f(1.0f,1.0f); glVertex2f(1.0f,1.0f); - glTexCoord2f(0.0f,1.0f); glVertex2f(-1.0f,1.0f); - glTexCoord2f(0.0f,0.0f); glVertex2f(-1.0f,-1.0f); - glTexCoord2f(1.0f,0.0f); glVertex2f(1.0f,-1.0f); - glEnd(); - - glPopMatrix(); // 2 - - tex_font->bind(); - - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glPushMatrix(); // 2 - glTranslatef(-1.2f, 0.9f, 0.0f); - glScalef(0.1f, 0.1f, 1.0f); - getSSRender().drawText( - PUtil::formatTime(game->coursetime), - PTEXT_HZA_LEFT | PTEXT_VTA_TOP); - glPopMatrix(); // 2 - - glColor4f(0.5f, 1.0f, 0.5f, 1.0f); - glPushMatrix(); // 2 - glTranslatef(-1.2f, 0.8f, 0.0f); - glScalef(0.1f, 0.1f, 1.0f); - getSSRender().drawText( - PUtil::formatTime(game->targettime), - PTEXT_HZA_LEFT | PTEXT_VTA_TOP); - glPopMatrix(); // 2 - - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glPushMatrix(); // 2 - glTranslatef(1.17f, 0.52f, 0.0f); - glScalef(0.2f, 0.2f, 1.0f); - { - int gear = vehic->getCurrentGear(); - std::string buff = (gear >= 0) ? - PUtil::formatInt(gear + 1, 1) : "R"; - getSSRender().drawText(buff, PTEXT_HZA_RIGHT | PTEXT_VTA_TOP); - } - glPopMatrix(); // 2 - - glColor4f(1.0f, 0.0f, 0.0f, 1.0f); - glPushMatrix(); // 2 - glTranslatef(0.0f, 0.2f, 0.0f); - glScalef(0.6f, 0.6f, 1.0f); - if (game->gamestate == GS_COUNTDOWN) { - float sizer = fmodf(game->othertime, 1.0f) + 0.5f; - glScalef(sizer, sizer, 1.0f); - getSSRender().drawText( - PUtil::formatInt(((int)game->othertime + 1), 1), - PTEXT_HZA_CENTER | PTEXT_VTA_CENTER); - } else if (game->gamestate == GS_FINISHED) { - if (game->getFinishState() == GF_PASS) { - glColor4f(0.5f, 1.0f, 0.5f, 1.0f); - getSSRender().drawText("WIN", PTEXT_HZA_CENTER | PTEXT_VTA_CENTER); - } else { - glScalef(0.5f, 0.5f, 1.0f); - glColor4f(0.5f, 0.0f, 0.0f, 1.0f); - getSSRender().drawText("TIME EXCEEDED", PTEXT_HZA_CENTER | PTEXT_VTA_CENTER); - } - } else if (game->coursetime < 1.0f) { - getSSRender().drawText("GO!", PTEXT_HZA_CENTER | PTEXT_VTA_CENTER); - } - glPopMatrix(); // 2 - - if (game->gamestate == GS_COUNTDOWN) { - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glPushMatrix(); // 2 - glTranslatef(0.0f, 0.5f, 0.0f); - glScalef(0.08f, 0.08f, 1.0f); - getSSRender().drawText(game->comment, PTEXT_HZA_CENTER | PTEXT_VTA_CENTER); - glPopMatrix(); // 2 - } - - glPopMatrix(); // 1 - - glPopMatrix(); // 0 - - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - - glBlendFunc(GL_ONE, GL_ZERO); - - glEnable(GL_DEPTH_TEST); - glEnable(GL_LIGHTING); -} - - - + +// render.cpp + +// Copyright 2004-2006 Jasmine Langridge, jas@jareiko.net +// License: GPL version 2 (see included gpl.txt) + + +#include "main.h" + +void MainApp::resize() +{ + glClearColor(1.0,1.0,1.0,1.0); + glEnable(GL_TEXTURE_2D); + + glEnable(GL_BLEND); + glBlendFunc(GL_ONE,GL_ZERO); + + glDepthFunc(GL_LEQUAL); + glEnable(GL_DEPTH_TEST); + glClearDepth(1.0); + + glEnable(GL_CULL_FACE); + + glEnable(GL_FOG); + glFogi(GL_FOG_MODE, GL_EXP); + + glEnable(GL_LIGHT0); + glEnable(GL_LIGHTING); + + float ambcol[] = { 0.1,0.1,0.1,0.0 }; + glLightModelfv(GL_LIGHT_MODEL_AMBIENT,ambcol); + + float white[] = { 1.0,1.0,1.0,1.0 }; + //float black[] = { 0.0,0.0,0.0,1.0 }; + glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE,white); + + float spec[] = { 0.3f, 0.5f, 0.5f, 1.0f }; + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec); + glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 6.0f); + + float litcol[] = { 0.6,0.6,0.6,0.0 }; + glLightfv(GL_LIGHT0,GL_DIFFUSE,litcol); + glLightfv(GL_LIGHT0,GL_SPECULAR,litcol); + + glEnable(GL_NORMALIZE); +} + +void drawBlades(float radius, float ang, float trace) +{ + float invtrace = 1.0 / trace; + glPushMatrix(); + glScalef(radius, radius, 1.0); + for (float ba=0; babind(); + { + float tgens[] = { 0.5,0,0,0 }; + float tgent[] = { 0,0.5,0,0 }; + glTexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR); + glTexGenfv(GL_S,GL_OBJECT_PLANE,tgens); + glTexGeni(GL_T,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR); + glTexGenfv(GL_T,GL_OBJECT_PLANE,tgent); + } + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_GEN_T); + glPushMatrix(); + glScalef(20.0,20.0,1.0); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + { + int minx = (int)(campos.x / 20.0)-20, + maxx = minx + 40, + miny = (int)(campos.y / 20.0)-20, + maxy = miny + 40; + for (int y=miny; yterrain->getHeight((x)*20.0,(y+1)*20.0); + alpha = 1.0 - exp(ht-40.3); + CLAMP(alpha,0.0,0.5); + glColor4f(1.0,1.0,1.0,alpha); + glVertex3f(x,y+1,40.3); + ht = game->terrain->getHeight((x)*20.0,(y)*20.0); + alpha = 1.0 - exp(ht-40.3); + CLAMP(alpha,0.0,0.5); + glColor4f(1.0,1.0,1.0,alpha); + glVertex3f(x,y,40.3); + } + glEnd(); + } + } + glPopMatrix(); + glBlendFunc(GL_ONE,GL_ZERO); + + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); +} + +void MainApp::renderSky(const mat44f &cammat) +{ + glFogf(GL_FOG_DENSITY, game->weather.fog.density_sky); + glDepthRange(0.999,1.0); + glDisable(GL_CULL_FACE); + glPushMatrix(); // 1 + glLoadIdentity(); + glMultMatrixf(cammat); + tex_sky[0]->bind(); +#define CLRANGE 10 +#define CLFACTOR 0.02//0.014 + glMatrixMode(GL_TEXTURE); + glPushMatrix(); + glTranslatef(cloudscroll,0.0,0.0); + glRotatef(30.0,0.0,0.0,1.0); + glScalef(0.4,0.4,1.0); + for (int y=-CLRANGE; yweather.fog.density); +} + +void MainApp::render(float eyetranslation) +{ + switch (appstate) { + case AS_LOAD_1: + renderStateLoading(eyetranslation); + break; + + case AS_LOAD_2: + case AS_LOAD_3: + break; + + case AS_LEVEL_SCREEN: + renderStateLevel(eyetranslation); + break; + + case AS_CHOOSE_VEHICLE: + renderStateChoose(eyetranslation); + break; + + case AS_IN_GAME: + renderStateGame(eyetranslation); + break; + + case AS_END_SCREEN: + renderStateEnd(eyetranslation); + break; + } + + glFinish(); +} + +void MainApp::renderStateLoading(float eyetranslation) +{ + eyetranslation = eyetranslation; + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f); + glMatrixMode(GL_MODELVIEW); + + tex_splash_screen->bind(); + + glDisable(GL_DEPTH_TEST); + glDisable(GL_FOG); + glDisable(GL_LIGHTING); + glBlendFunc(GL_ONE, GL_ZERO); + + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + + glBegin(GL_QUADS); + glTexCoord2f(1.0f,1.0f); glVertex2f(1.0f,1.0f); + glTexCoord2f(0.0f,1.0f); glVertex2f(-1.0f,1.0f); + glTexCoord2f(0.0f,0.0f); glVertex2f(-1.0f,-1.0f); + glTexCoord2f(1.0f,0.0f); glVertex2f(1.0f,-1.0f); + glEnd(); + + glEnable(GL_DEPTH_TEST); + glEnable(GL_FOG); + glEnable(GL_LIGHTING); + + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); +} + +const char *creditstext[] = { + "Trigger " PACKAGE_VERSION, + "", + "Copyright (C) 2004-2006", + "Jasmine Langridge and Richard Langridge", + "Posit Interactive", + "", + "", + "", + "Coding", + "Jasmine Langridge", + "", + "Art & SFX", + "Richard Langridge", + "", + "", + "", + "Contributors", + "", + "Build system", + "Matze Braune", + "", + "Stereo support", + "Chuck Sites", + "", + "Mac OS X porting", + "Tim Douglas", + "", + "Fixes", + "LavaPunk", + "Bernhard Kaindl", + "Liviu Andronic", + "Ishmael Turner", + "", + "New levels", + "Tim Wintle", + "David Pagnier", + "Jared Buckner", + "Andreas Rosdal", + "Ivan", + "Viktor Radnai", + "Pierre-Alexis", + "", + "Graphics", + "Alex", + "Roberto Diez Gonzalez", + "", + "", + "", + "", + "", + "Thanks to Jonathan C. Hatfull", + "", + "", + "", + "", + "And thanks to Simon Brown too", + "", + "", + "", + "", + "", + "", + "Thanks for playing Trigger" +}; +#define NUMCREDITSTRINGS (sizeof(creditstext) / sizeof(char*)) + +void MainApp::renderStateEnd(float eyetranslation) +{ + eyetranslation = eyetranslation; + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(-1.33f, 1.33f, -1.0f, 1.0f, -1.0f, 1.0f); + glMatrixMode(GL_MODELVIEW); + + tex_end_screen->bind(); + + glDisable(GL_DEPTH_TEST); + glDisable(GL_FOG); + glDisable(GL_LIGHTING); + glBlendFunc(GL_ONE, GL_ZERO); + + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + + glBegin(GL_QUADS); + glTexCoord2f(1.0f,1.0f); glVertex2f(1.33f,1.0f); + glTexCoord2f(0.0f,1.0f); glVertex2f(-1.33f,1.0f); + glTexCoord2f(0.0f,0.0f); glVertex2f(-1.33f,-1.0f); + glTexCoord2f(1.0f,0.0f); glVertex2f(1.33f,-1.0f); + glEnd(); + + tex_font->bind(); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glPushMatrix(); + + float scroll = splashtimeout; + const float maxscroll = (float)(NUMCREDITSTRINGS - 1) * 2.0f; + RANGEADJUST(scroll, 0.0f, 0.9f, -10.0f, maxscroll); + CLAMP_UPPER(scroll, maxscroll); + + glScalef(0.1f, 0.1f, 1.0f); + + glTranslatef(0.0f, scroll, 0.0f); + + for (int i = 0; i < (int)NUMCREDITSTRINGS; i++) { + float level = fabsf(scroll + (float)i * -2.0f); + RANGEADJUST(level, 0.0f, 9.0f, 3.0f, 0.0f); + + if (level > 0.0f) { + CLAMP_UPPER(level, 1.0f); + + glPushMatrix(); + glTranslatef(0.0f, (float)i * -2.0f, 0.0f); + + float enlarge = 1.0f; + + #if 1 + if (splashtimeout > 0.9f) { + float amt = (splashtimeout - 0.9f) * 10.0f; + float amt2 = amt * amt; + + enlarge += amt2 / ((1.0001f - amt) * (1.0001f - amt)); + level -= amt2; + } + #endif + + glScalef(enlarge, enlarge, 0.0f); + glColor4f(1.0f, 1.0f, 1.0f, level); + + getSSRender().drawText(creditstext[i], PTEXT_HZA_CENTER | PTEXT_VTA_CENTER); + glPopMatrix(); + } + } + + glPopMatrix(); + + glEnable(GL_DEPTH_TEST); + glEnable(GL_FOG); + glEnable(GL_LIGHTING); + + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); +} + +void MainApp::renderStateChoose(float eyetranslation) +{ + PVehicleType *vtype = game->vehiclechoices[choose_type]; + + glClearColor(0.0, 0.0, 0.0, 1.0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + float fnear = 0.1f, fov = 0.6f; + float aspect = (float)getWidth() / (float)getHeight(); + stereoFrustum(-fnear*aspect*fov,fnear*aspect*fov,-fnear*fov,fnear*fov,fnear,100000.0f, + 0.8f, eyetranslation); + glMatrixMode(GL_MODELVIEW); + + + glPushMatrix(); // 0 + + glTranslatef(-eyetranslation, -0.3f, -3.0f); + + glDisable(GL_FOG); + glEnable(GL_LIGHTING); + + vec4f lpos = vec4f(0.0f, 1.0f, 0.0f, 0.0f); + glLightfv(GL_LIGHT0, GL_POSITION, lpos); + + float tmp = sinf(choose_spin * 2.0f) * 0.5f; + tmp += choose_spin; + glRotatef(90.0f, -1.0f, 0.0f, 0.0f); + glRotatef(DEGREES(tmp), 0.0f, 0.0f, 1.0f); + + { + for (unsigned int i=0; ipart.size(); ++i) { + glPushMatrix(); // 1 + + vec3f vpos = vtype->part[i].ref_local.pos; + glTranslatef(vpos.x, vpos.y, vpos.z); + + mat44f vorim = vtype->part[i].ref_local.ori_mat_inv; + glMultMatrixf(vorim); + if (vtype->part[i].model) { + + glPushMatrix(); // 2 + + float scale = vtype->part[i].scale; + glScalef(scale,scale,scale); + drawModel(*vtype->part[i].model); + + glPopMatrix(); // 2 + } + + if (vtype->wheelmodel) { + for (unsigned int j=0; jpart[i].wheel.size(); j++) { + + glPushMatrix(); // 2 + + vec3f &wpos = vtype->part[i].wheel[j].pt; + glTranslatef(wpos.x, wpos.y, wpos.z); + + float scale = vtype->wheelscale * vtype->part[i].wheel[j].radius; + glScalef(scale,scale,scale); + + drawModel(*vtype->wheelmodel); + + glPopMatrix(); // 2 + } + } + + glPopMatrix(); // 1 + } + } + + glPopMatrix(); // 0 + + glDisable(GL_LIGHTING); + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(-1.33f, 1.33f, -1.0f, 1.0f, -1.0f, 1.0f); + glMatrixMode(GL_MODELVIEW); + + tex_font->bind(); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glDisable(GL_DEPTH_TEST); + glDisable(GL_LIGHTING); + + glPushMatrix(); // 0 + + glPushMatrix(); // 1 + glTranslatef(0.0f, 0.8f, 0.0f); + glScalef(0.1f, 0.1f, 1.0f); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + getSSRender().drawText("Choose Vehicle", PTEXT_HZA_CENTER | PTEXT_VTA_CENTER); + glPopMatrix(); // 1 + + glPushMatrix(); // 1 + glTranslatef(0.0f, 0.7f, 0.0f); + glScalef(0.1f, 0.1f, 1.0f); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + getSSRender().drawText( + PUtil::formatInt(choose_type + 1, 2) + " of " + + PUtil::formatInt(game->vehiclechoices.size(), 2), + PTEXT_HZA_CENTER | PTEXT_VTA_CENTER); + glPopMatrix(); // 1 + + glPushMatrix(); // 1 + + glTranslatef(0.0f, -0.8f, 0.0f); + glScalef(0.1f, 0.1f, 1.0f); + + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + + getSSRender().drawText(vtype->proper_name, PTEXT_HZA_CENTER | PTEXT_VTA_CENTER); + + glPopMatrix(); // 1 + + glPopMatrix(); // 0 + + glBlendFunc(GL_ONE, GL_ZERO); + glEnable(GL_DEPTH_TEST); + glEnable(GL_FOG); + glEnable(GL_LIGHTING); + + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); +} + +void MainApp::renderStateGame(float eyetranslation) +{ + PVehicle *vehic = game->vehicle[0]; + + glClear(GL_DEPTH_BUFFER_BIT); + //glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + float fnear = 0.1f, fov = 0.6f; + float aspect = (float)getWidth() / (float)getHeight(); + stereoFrustum(-fnear*aspect*fov,fnear*aspect*fov,-fnear*fov,fnear*fov,fnear,100000.0f, + 0.8f, eyetranslation); + glMatrixMode(GL_MODELVIEW); + + glColor3f(1.0,1.0,1.0); + + vec4f fogcolor(game->weather.fog.color, 1.0f); + glFogfv(GL_FOG_COLOR, fogcolor); + + glDepthRange(0.0,0.999); + + glPushMatrix(); // 0 + + mat44f cammat = camori.getMatrix(); + mat44f cammat_inv = cammat.transpose(); + + //glTranslatef(0.0,0.0,-40.0); + glTranslatef(-eyetranslation, 0.0f, 0.0f); + + glMultMatrixf(cammat); + + glTranslatef(-campos.x, -campos.y, -campos.z); + + float lpos[] = { 0.2, 0.5, 1.0, 0.0 }; + glLightfv(GL_LIGHT0, GL_POSITION, lpos); + + glColor3ub(255,255,255); + + glDisable(GL_LIGHTING); + + glActiveTextureARB(GL_TEXTURE1_ARB); + glEnable(GL_TEXTURE_2D); + glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE); + glTexEnvi(GL_TEXTURE_ENV,GL_COMBINE_RGB,GL_ADD_SIGNED); + glTexEnvi(GL_TEXTURE_ENV,GL_COMBINE_ALPHA,GL_MODULATE); + tex_detail->bind(); + glTexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR); + glTexGeni(GL_T,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR); + float tgens[] = { 0.05, 0.0, 0.0, 0.0 }; + float tgent[] = { 0.0, 0.05, 0.0, 0.0 }; + glTexGenfv(GL_S,GL_OBJECT_PLANE,tgens); + glTexGenfv(GL_T,GL_OBJECT_PLANE,tgent); + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_GEN_T); + glActiveTextureARB(GL_TEXTURE0_ARB); + + // draw terrain + game->terrain->render(campos, cammat_inv); + + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + + glActiveTextureARB(GL_TEXTURE1_ARB); + glDisable(GL_TEXTURE_2D); + glActiveTextureARB(GL_TEXTURE0_ARB); + + if (renderowncar) { + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + tex_shadow->bind(); + + glColor4f(1.0f, 1.0f, 1.0f, 0.7f); + + vec3f vpos = game->vehicle[0]->body->pos; + vec3f forw = makevec3f(game->vehicle[0]->body->getOrientationMatrix().row[0]); + float forwangle = atan2(forw.y, forw.x); + game->terrain->drawSplat(vpos.x, vpos.y, 1.4f, forwangle + PI*0.5f); + + glBlendFunc(GL_ONE, GL_ZERO); + } + + renderSky(cammat); + + glEnable(GL_LIGHTING); + + for (unsigned int v=0; vvehicle.size(); ++v) { + + if (!renderowncar && v == 0) continue; + + PVehicle *vehic = game->vehicle[v]; + for (unsigned int i=0; ipart.size(); ++i) { + if (vehic->type->part[i].model) { + glPushMatrix(); // 1 + + vec3f vpos = vehic->part[i].ref_world.pos; + glTranslatef(vpos.x, vpos.y, vpos.z); + + mat44f vorim = vehic->part[i].ref_world.ori_mat_inv; + glMultMatrixf(vorim); + + float scale = vehic->type->part[i].scale; + glScalef(scale,scale,scale); + + drawModel(*vehic->type->part[i].model); + + glPopMatrix(); // 1 + } + + if (vehic->type->wheelmodel) { + for (unsigned int j=0; jtype->part[i].wheel.size(); j++) { + + glPushMatrix(); // 1 + + vec3f wpos = vehic->part[i].wheel[j].ref_world.getPosition(); + glTranslatef(wpos.x,wpos.y,wpos.z); + + mat44f worim = vehic->part[i].wheel[j].ref_world.ori_mat_inv; + glMultMatrixf(worim); + + float scale = vehic->type->wheelscale * vehic->type->part[i].wheel[j].radius; + glScalef(scale,scale,scale); + + drawModel(*vehic->type->wheelmodel); + + glPopMatrix(); // 1 + } + } + } + } + + glDisable(GL_LIGHTING); + + glDepthMask(GL_FALSE); + glDisable(GL_CULL_FACE); + + glDisable(GL_TEXTURE_2D); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + +#define RAINDROP_WIDTH 0.015 + const vec4f raindrop_col(0.5,0.5,0.5,0.4); + + vec3f offsetdrops = campos - campos_prev; + + for (unsigned int i = 0; i < rain.size(); i++) { + vec3f tempv; + const float prevlife = rain[i].prevlife; + vec3f pt1 = rain[i].drop_pt + rain[i].drop_vect * prevlife + offsetdrops; + vec3f pt2 = rain[i].drop_pt + rain[i].drop_vect * rain[i].life; + vec3f zag = campos - rain[i].drop_pt; + zag = zag.cross(rain[i].drop_vect); + zag *= RAINDROP_WIDTH / zag.length(); + glBegin(GL_TRIANGLE_STRIP); + glColor4f(raindrop_col[0],raindrop_col[1],raindrop_col[2],0.0); + tempv = pt1 - zag; + glVertex3fv(tempv); + tempv = pt2 - zag; + glVertex3fv(tempv); + + glColor4fv(raindrop_col); + glVertex3fv(pt1); + glVertex3fv(pt2); + + glColor4f(raindrop_col[0],raindrop_col[1],raindrop_col[2],0.0); + tempv = pt1 + zag; + glVertex3fv(tempv); + tempv = pt2 + zag; + glVertex3fv(tempv); + glEnd(); + } + + const vec4f checkpoint_col[3] = { + vec4f(1.0f, 0.0f, 0.0f, 0.8f), // 0 = next checkpoint + vec4f(0.7f, 0.7f, 0.1f, 0.6f), // 1 = checkpoint after next + vec4f(0.2f, 0.8f, 0.2f, 0.4f) // 2 = all other checkpoints + }; + + for (unsigned int i=0; icheckpt.size(); i++) { + + vec4f colr = checkpoint_col[2]; + + if ((int)i == vehic->nextcp) + colr = checkpoint_col[0]; + else if ((int)i == (vehic->nextcp + 1) % (int)game->checkpt.size()) + colr = checkpoint_col[1]; + + glPushMatrix(); // 1 + + glTranslatef(game->checkpt[i].pt.x, game->checkpt[i].pt.y, game->checkpt[i].pt.z); + + glScalef(25.0f, 25.0f, 1.0f); + + #if 0 + glBegin(GL_TRIANGLE_STRIP); + + for (float a = 0.0f; a < 0.99f; a += 0.05f) { + glColor4f(colr[0], colr[1], colr[2], colr[3] * a); + float ang = cprotate + a * 6.0f; + float ht = sinf(ang * 1.7f) * 7.0f + 8.0f; + glVertex3f(cosf(ang), sinf(ang), ht - 1.0f); + glVertex3f(cosf(ang), sinf(ang), ht + 1.0f); + } + + for (float a = 1.0f; a < 2.01f; a += 0.05f) { + glColor4f(colr[0], colr[1], colr[2], colr[3] * (2.0f - a)); + float ang = cprotate + a * 6.0f; + float ht = sinf(ang * 1.7f) * 7.0f + 8.0f; + glVertex3f(cosf(ang), sinf(ang), ht - 1.0f); + glVertex3f(cosf(ang), sinf(ang), ht + 1.0f); + } + + glEnd(); + #else + glBegin(GL_TRIANGLE_STRIP); + float ht = sinf(cprotate * 6.0f) * 7.0f + 8.0f; + glColor4f(colr[0], colr[1], colr[2], 0.0f); + glVertex3f(1.0f, 0.0f, ht - 1.0f); + glColor4f(colr[0], colr[1], colr[2], colr[3]); + glVertex3f(1.0f, 0.0f, ht + 0.0f); + for (float a = PI/10.0f; a < PI*2.0f-0.01f; a += PI/10.0f) { + glColor4f(colr[0], colr[1], colr[2], 0.0f); + glVertex3f(cosf(a), sinf(a), ht - 1.0f); + glColor4f(colr[0], colr[1], colr[2], colr[3]); + glVertex3f(cosf(a), sinf(a), ht + 0.0f); + } + glColor4f(colr[0], colr[1], colr[2], 0.0f); + glVertex3f(1.0f, 0.0f, ht - 1.0f); + glColor4f(colr[0], colr[1], colr[2], colr[3]); + glVertex3f(1.0f, 0.0f, ht + 0.0f); + glEnd(); + + glBegin(GL_TRIANGLE_STRIP); + glColor4f(colr[0], colr[1], colr[2], colr[3]); + glVertex3f(1.0f, 0.0f, ht - 0.0f); + glColor4f(colr[0], colr[1], colr[2], 0.0f); + glVertex3f(1.0f, 0.0f, ht + 1.0f); + for (float a = PI/10.0f; a < PI*2.0f-0.01f; a += PI/10.0f) { + glColor4f(colr[0], colr[1], colr[2], colr[3]); + glVertex3f(cosf(a), sinf(a), ht - 0.0f); + glColor4f(colr[0], colr[1], colr[2], 0.0f); + glVertex3f(cosf(a), sinf(a), ht + 1.0f); + } + glColor4f(colr[0], colr[1], colr[2], colr[3]); + glVertex3f(1.0f, 0.0f, ht - 0.0f); + glColor4f(colr[0], colr[1], colr[2], 0.0f); + glVertex3f(1.0f, 0.0f, ht + 1.0f); + glEnd(); + #endif + + glPopMatrix(); // 1 + } + + glEnable(GL_TEXTURE_2D); + + //renderWater(); + + getSSRender().render(psys_dirt); + + glDepthMask(GL_TRUE); + glBlendFunc(GL_ONE,GL_ZERO); + glEnable(GL_LIGHTING); + glEnable(GL_CULL_FACE); + glEnable(GL_FOG); + + glDisable(GL_LIGHTING); + + glPopMatrix(); // 0 + + glDisable(GL_DEPTH_TEST); + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(-1.33f, 1.33f, -1.0f, 1.0f, -1.0f, 1.0f); + glMatrixMode(GL_MODELVIEW); + + glPushMatrix(); // 0 + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glPushMatrix(); // 1 + glTranslatef(1.0f, -0.7f, 0.0f); + glScalef(0.25f, 0.25f, 1.0f); + + tex_hud_revs->bind(); + glColor3f(1.0f, 1.0f, 1.0f); + glBegin(GL_QUADS); + glTexCoord2f(1.0f,1.0f); glVertex2f(1.0f,1.0f); + glTexCoord2f(0.0f,1.0f); glVertex2f(-1.0f,1.0f); + glTexCoord2f(0.0f,0.0f); glVertex2f(-1.0f,-1.0f); + glTexCoord2f(1.0f,0.0f); glVertex2f(1.0f,-1.0f); + glEnd(); + + glDisable(GL_TEXTURE_2D); + + glRotatef(210.0f - vehic->getEngineRPM() * 20.0f / 1000.0f, 0.0f, 0.0f, 1.0f); + + glColor3f(1.0f, 0.0f, 0.0f); + glBegin(GL_TRIANGLES); + glVertex2f(0.9f, 0.0f); glVertex2f(-0.2f, 0.05f); glVertex2f(-0.2f, -0.05f); + glEnd(); + + glPopMatrix(); // 1 + + glEnable(GL_TEXTURE_2D); + + glPushMatrix(); // 1 + glTranslatef(1.0f, -0.2f, 0.0f); + glScalef(0.25f, 0.25f, 1.0f); + + tex_hud_speedo->bind(); + glColor3f(1.0f, 1.0f, 1.0f); + glBegin(GL_QUADS); + glTexCoord2f(1.0f,1.0f); glVertex2f(1.0f,1.0f); + glTexCoord2f(0.0f,1.0f); glVertex2f(-1.0f,1.0f); + glTexCoord2f(0.0f,0.0f); glVertex2f(-1.0f,-1.0f); + glTexCoord2f(1.0f,0.0f); glVertex2f(1.0f,-1.0f); + glEnd(); + + glDisable(GL_TEXTURE_2D); + + glRotatef(hud_speedo_start_deg - fabsf(vehic->getWheelSpeed()) * hud_speedo_mps_deg_mult, 0.0f, 0.0f, 1.0f); + + glColor3f(1.0f, 0.0f, 0.0f); + glBegin(GL_TRIANGLES); + glVertex2f(0.9f, 0.0f); glVertex2f(-0.2f, 0.05f); glVertex2f(-0.2f, -0.05f); + glEnd(); + + glPopMatrix(); // 1 + + #if 0 + glPushMatrix(); // 1 + + glTranslatef(0.0f, 0.8f, 0.0f); + + glScalef(0.2f, 0.2f, 0.2f); + + glRotatef(-30.0f, 1.0f, 0.0f, 0.0f); + glRotatef(DEGREES(nextcpangle), 0.0f, -1.0f, 0.0f); + + glBegin(GL_TRIANGLES); + glColor4f(0.8f, 0.4f, 0.4f, 0.6f); + glVertex3f(0.0f, 0.0f, -2.0f); + glColor4f(0.8f, 0.8f, 0.8f, 0.6f); + glVertex3f(1.0f, 0.0f, 1.0f); + glVertex3f(-1.0f, 0.0f, 1.0f); + glEnd(); + glBegin(GL_TRIANGLE_STRIP); + glColor4f(0.8f, 0.4f, 0.4f, 0.6f); + glVertex3f(0.0f, 0.0f, -2.0f); + glColor4f(1.0f, 0.5f, 0.5f, 0.6f); + glVertex3f(0.0f, 0.2f, -2.0f); + glColor4f(0.8f, 0.8f, 0.8f, 0.6f); + glVertex3f(1.0f, 0.0f, 1.0f); + glColor4f(1.0f, 1.0f, 1.0f, 0.6f); + glVertex3f(1.0f, 0.2f, 1.0f); + glColor4f(0.8f, 0.8f, 0.8f, 0.6f); + glVertex3f(-1.0f, 0.0f, 1.0f); + glColor4f(1.0f, 1.0f, 1.0f, 0.6f); + glVertex3f(-1.0f, 0.2f, 1.0f); + glColor4f(0.8f, 0.4f, 0.4f, 0.6f); + glVertex3f(0.0f, 0.0f, -2.0f); + glColor4f(1.0f, 0.5f, 0.5f, 0.6f); + glVertex3f(0.0f, 0.2f, -2.0f); + glEnd(); + + glPopMatrix(); // 1 + #endif + + if (showmap) { + glViewport(10, 10, getHeight()/3, getHeight()/3); + + glPushMatrix(); // 1 + glScalef(1.33f, 1.0f, 1.0f); + + if (game->terrain->getHUDMapTexture()) { + glEnable(GL_TEXTURE_2D); + game->terrain->getHUDMapTexture()->bind(); + } + + glMatrixMode(GL_TEXTURE); + glPushMatrix(); + float scalefac = 1.0f / game->terrain->getMapSize(); + glScalef(scalefac, scalefac, 1.0f); + glTranslatef(campos.x, campos.y, 0.0f); + glRotatef(DEGREES(camera_angle), 0.0f, 0.0f, 1.0f); + glScalef(1.0f / 0.003f, 1.0f / 0.003f, 1.0f); + + glBegin(GL_QUADS); + glColor4f(1.0f, 1.0f, 1.0f, 0.7f); + glTexCoord2f(1.0f, 1.0f); glVertex2f(1.0f, 1.0f); + glTexCoord2f(-1.0f, 1.0f); glVertex2f(-1.0f, 1.0f); + glTexCoord2f(-1.0f, -1.0f); glVertex2f(-1.0f, -1.0f); + glTexCoord2f(1.0f, -1.0f); glVertex2f(1.0f, -1.0f); + glEnd(); + + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + + glDisable(GL_TEXTURE_2D); + + glPushMatrix(); // 2 + glScalef(0.003f, 0.003f, 1.0f); + glRotatef(DEGREES(-camera_angle), 0.0f, 0.0f, 1.0f); + glTranslatef(-campos.x, -campos.y, 0.0f); + for (unsigned int i=0; icheckpt.size(); i++) { + glPushMatrix(); + vec3f vpos = game->checkpt[i].pt; + glTranslatef(vpos.x, vpos.y, 0.0f); + glRotatef(DEGREES(camera_angle), 0.0f, 0.0f, 1.0f); + glScalef(30.0f, 30.0f, 1.0f); + vec4f colr = checkpoint_col[2]; + if ((int)i == vehic->nextcp) { + float sc = 1.5f + sinf(cprotate * 10.0f) * 0.5f; + glScalef(sc, sc, 1.0f); + colr = checkpoint_col[0]; + } else if ((int)i == (vehic->nextcp + 1) % (int)game->checkpt.size()) { + colr = checkpoint_col[1]; + } + glBegin(GL_TRIANGLE_FAN); + glColor4fv(colr); + glVertex2f(0.0f, 0.0f); + glColor4f(colr[0], colr[1], colr[2], 0.0f); + //glColor4f(1.0f, 1.0f, 1.0f, 0.0f); + glVertex2f(1.0f, 0.0f); + glVertex2f(0.0f, 1.0f); + glVertex2f(-1.0f, 0.0f); + glVertex2f(0.0f, -1.0f); + glVertex2f(1.0f, 0.0f); + glEnd(); + glPopMatrix(); + } + for (unsigned int i=0; ivehicle.size(); i++) { + glPushMatrix(); + vec3f vpos = game->vehicle[i]->body->getPosition(); + glTranslatef(vpos.x, vpos.y, 0.0f); + glRotatef(DEGREES(camera_angle), 0.0f, 0.0f, 1.0f); + glScalef(30.0f, 30.0f, 1.0f); + glBegin(GL_TRIANGLE_FAN); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glVertex2f(0.0f, 0.0f); + glColor4f(1.0f, 1.0f, 1.0f, 0.0f); + glVertex2f(1.0f, 0.0f); + glVertex2f(0.0f, 1.0f); + glVertex2f(-1.0f, 0.0f); + glVertex2f(0.0f, -1.0f); + glVertex2f(1.0f, 0.0f); + glEnd(); + glPopMatrix(); + } + glPopMatrix(); // 2 + + glPopMatrix(); // 1 + + glViewport(0, 0, getWidth(), getHeight()); + } + + glEnable(GL_TEXTURE_2D); + + glPushMatrix(); // 1 + + tex_hud_gear->bind(); + glPushMatrix(); // 2 + + glTranslatef(1.0f, 0.35f, 0.0f); + glScalef(0.2f, 0.2f, 1.0f); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glBegin(GL_QUADS); + glTexCoord2f(1.0f,1.0f); glVertex2f(1.0f,1.0f); + glTexCoord2f(0.0f,1.0f); glVertex2f(-1.0f,1.0f); + glTexCoord2f(0.0f,0.0f); glVertex2f(-1.0f,-1.0f); + glTexCoord2f(1.0f,0.0f); glVertex2f(1.0f,-1.0f); + glEnd(); + + glPopMatrix(); // 2 + + tex_font->bind(); + + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glPushMatrix(); // 2 + glTranslatef(-1.2f, 0.9f, 0.0f); + glScalef(0.1f, 0.1f, 1.0f); + if (game->gamestate == GS_FINISHED){ + getSSRender().drawText( + PUtil::formatTime(game->coursetime), + PTEXT_HZA_LEFT | PTEXT_VTA_TOP); + } else if (game->coursetime < game->cptime + 1.50f) { + getSSRender().drawText( + PUtil::formatTime(game->cptime), + PTEXT_HZA_LEFT | PTEXT_VTA_TOP); + } else if (game->coursetime < game->cptime + 3.50f) { + float a = (((game->cptime + 3.50f) - game->coursetime) / 2); + glColor4f(1.0f, 1.0f, 1.0f, a); + getSSRender().drawText( + PUtil::formatTime(game->cptime), + PTEXT_HZA_LEFT | PTEXT_VTA_TOP); + } else { + getSSRender().drawText( + PUtil::formatTime(game->coursetime), + PTEXT_HZA_LEFT | PTEXT_VTA_TOP); + } + glPopMatrix(); // 2 + + glColor4f(0.5f, 1.0f, 0.5f, 1.0f); + glPushMatrix(); // 2 + glTranslatef(-1.2f, 0.8f, 0.0f); + glScalef(0.1f, 0.1f, 1.0f); + getSSRender().drawText( + PUtil::formatTime(game->targettime), + PTEXT_HZA_LEFT | PTEXT_VTA_TOP); + glPopMatrix(); // 2 + + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glPushMatrix(); // 2 + glTranslatef(1.17f, 0.52f, 0.0f); + glScalef(0.2f, 0.2f, 1.0f); + { + int gear = vehic->getCurrentGear(); + std::string buff = (gear >= 0) ? + PUtil::formatInt(gear + 1, 1) : "R"; + getSSRender().drawText(buff, PTEXT_HZA_RIGHT | PTEXT_VTA_TOP); + } + glPopMatrix(); // 2 + + if (cfg_speed_style == MainApp::hybrid ) { + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glPushMatrix(); // 2 + glTranslatef(1.0725f, -0.298f, 0.0f); + glScalef(0.08f, 0.08f, 1.0f); + int speed = fabsf(vehic->getWheelSpeed()) * hud_speedo_mps_speed_mult; + std::string speedstr = PUtil::formatInt(speed); + getSSRender().drawText(speedstr, PTEXT_HZA_RIGHT | PTEXT_VTA_TOP); + glPopMatrix(); // 2 + } + + glColor4f(1.0f, 0.0f, 0.0f, 1.0f); + glPushMatrix(); // 2 + glTranslatef(0.0f, 0.2f, 0.0f); + glScalef(0.6f, 0.6f, 1.0f); + if (game->gamestate == GS_COUNTDOWN) { + float sizer = fmodf(game->othertime, 1.0f) + 0.5f; + glScalef(sizer, sizer, 1.0f); + getSSRender().drawText( + PUtil::formatInt(((int)game->othertime + 1), 1), + PTEXT_HZA_CENTER | PTEXT_VTA_CENTER); + } else if (game->gamestate == GS_FINISHED) { + if (game->getFinishState() == GF_PASS) { + glColor4f(0.5f, 1.0f, 0.5f, 1.0f); + getSSRender().drawText("WIN", PTEXT_HZA_CENTER | PTEXT_VTA_CENTER); + } else { + glScalef(0.5f, 0.5f, 1.0f); + glColor4f(0.5f, 0.0f, 0.0f, 1.0f); + getSSRender().drawText("TIME EXCEEDED", PTEXT_HZA_CENTER | PTEXT_VTA_CENTER); + } + } else if (game->coursetime < 1.0f) { + glColor4f(0.5f, 1.0f, 0.5f, 1.0f); + getSSRender().drawText("GO!", PTEXT_HZA_CENTER | PTEXT_VTA_CENTER); + } else if (game->coursetime < 2.0f) { + float a = 1.0f - (game->coursetime - 1.0f); + glColor4f(0.5f, 1.0f, 0.5f, a); + getSSRender().drawText("GO!", PTEXT_HZA_CENTER | PTEXT_VTA_CENTER); + } + glPopMatrix(); // 2 + + if (game->gamestate == GS_COUNTDOWN) { + glPushMatrix(); // 2 + glTranslatef(0.0f, 0.6f, 0.0f); + glScalef(0.08f, 0.08f, 1.0f); + if (game->othertime < 1.0f) { + glColor4f(1.0f, 1.0f, 1.0f, game->othertime); + getSSRender().drawText(game->comment, PTEXT_HZA_CENTER | PTEXT_VTA_CENTER); + } else { + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + getSSRender().drawText(game->comment, PTEXT_HZA_CENTER | PTEXT_VTA_CENTER); + } + glPopMatrix(); // 2 + } + + glPopMatrix(); // 1 + + glPopMatrix(); // 0 + + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + + glBlendFunc(GL_ONE, GL_ZERO); + + glEnable(GL_DEPTH_TEST); + glEnable(GL_LIGHTING); +} + + +