freebsd-ports/games/linux-nwnclient/files/nwmovies.pl
Sean Farley b4508067f1 Update client to v1.69 which is the final release from BioWare.
Remove ARCH requirement for i386; let the install of the Linux base
determine if the port is allowed or not.

Detect if the original or Diamond game files were installed in
games/nwndata to install the appropriate client.

Add an option to install the NWMovies/BinkPlayer patch to play in-game
movies for the Diamond client.  This includes a rewritten script (from
Perl to shell) to remove the need for Linux Perl to run it.  The script
includes a method to skip movies, especially the intro movies, as noted in
pkg-message.  Default to off.

In the nwn script, remove dead links in and rebuild ${HOME}/.nwn.  This
allows moving between the original and Diamond editions without confusing
(resulting in segmentation faults) the client.

Set SDL_AUDIODRIVER to dsp by default to remove warnings from SDL
concerning audio setup.

Disallow core files as these are commonly seen when the game exits.
Fortunately, the segmentation fault does not affect play nor the
configuration files.

Approved by:	wxs
2010-09-27 18:32:05 +00:00

76 lines
1.9 KiB
Bash

#!/bin/sh
#
# $FreeBSD$
#
# There is a Perl script that accompanies the NWMovies distfile, however, it
# would require Linux Perl to be installed when a simple shell script will
# suffice. Since the name of the Perl script is hardcoded into the binary, this
# file has a .pl extension even though it is Bourne shell.
# Initialization.
NWNUSERDIR="${HOME}/.nwn"
NWNSKIPFILE=${NWNUSERDIR}/nwmovies.skip
NWNMOVIEDIR=${NWNUSERDIR}/movies
NWNMOVIES=${NWNUSERDIR}/nwmovies
NWNINI=${NWNUSERDIR}/nwn.ini
# Print arguments in lowercase
tolower() {
set -e
echo "$@" | tr '[:upper:]' '[:lower:]'
}
# Determine case-insensitive movie name to play prior to setting LD_PRELOAD.
reqmovie="$(tolower ${NWNMOVIEDIR}/${1}).bik"
for m in ${NWNMOVIEDIR}/*
do
if [ ${reqmovie} = $(tolower ${m}) ]
then
movie="${m}"
break
fi
done
if [ -z "${movie}" ]
then
echo "${reqmovie} not found"
exit 1
fi
# Skip movies request by user.
if [ -e ${NWNSKIPFILE} ]
then
reqmovie="$(tolower ${1})"
for m in `cat ${NWNSKIPFILE}`
do
if [ ${reqmovie} = $(tolower ${m}) ]
then
echo "Skipping ${1} as requested"
exit 0
fi
done
fi
# Prevent core files from BinkPlayer.
ulimit -c 0
# Configure movie display (default to 800x600 if not in .ini file).
BINK_WIDTH=`grep -i width ${NWNINI} | cut -f 2 -d '='` 2> /dev/null
export BINK_WIDTH=${BINK_WIDTH:-800}
BINK_HEIGHT=`grep -i height ${NWNINI} | cut -f 2 -d '='` 2> /dev/null
export BINK_HEIGHT=${BINK_HEIGHT:-600}
export BINK_FULLSCREEN=1
# Silence warnings from SDL.
export SDL_AUDIODRIVER=${SDL_AUDIODRIVER:-"dsp"}
# Configure for needed libraries (some are only needed if running standalone).
if [ ! -e ${NWNMOVIES}/libX11.so ]
then
ln -sf /compat/linux/usr/lib/libX11.so.6 ${NWNMOVIES}/libX11.so
fi
export LD_LIBRARY_PATH=${NWNUSERDIR}/nwmovies:${LD_LIBRARY_PATH}
export LD_PRELOAD=./nwmovies/binklib.so
# Play movie.
./nwmovies/BinkPlayer ${movie}