Lines 3-13
Link Here
|
3 |
# $FreeBSD$ |
3 |
# $FreeBSD$ |
4 |
# |
4 |
# |
5 |
|
5 |
|
6 |
NWNDATADIR="%%NWNDATADIR%%" |
6 |
nwn_datadir="%%NWNDATADIR%%" |
7 |
NWNCLIENTDIR="%%NWNCLIENTDIR%%" |
7 |
nwn_clientdir="%%NWNCLIENTDIR%%" |
8 |
NWNUSERDIR="${HOME}/.nwn" |
8 |
nwn_userdir=${NWN_USERDIR:-"${HOME}/.nwn"} |
9 |
NWNMOVIEDIR="${NWNUSERDIR}/nwmovies" |
9 |
nwn_moviedir="${nwn_userdir}/nwmovies" |
10 |
LCDIRS="ambient data dmvault hak localvault music override portraits" |
10 |
lc_dirs="ambient data dmvault hak localvault music override portraits" |
11 |
|
11 |
|
12 |
set -e |
12 |
set -e |
13 |
|
13 |
|
Lines 30-46
Link Here
|
30 |
set -e |
30 |
set -e |
31 |
cd "$1" |
31 |
cd "$1" |
32 |
find . -type d | cut -c 3- | while read dir ; do |
32 |
find . -type d | cut -c 3- | while read dir ; do |
33 |
[ -d "${NWNUSERDIR}/${dir}" ] || |
33 |
[ -d "${nwn_userdir}/${dir}" ] || |
34 |
mkdir "${NWNUSERDIR}/${dir}" |
34 |
mkdir "${nwn_userdir}/${dir}" |
35 |
done |
35 |
done |
36 |
find . -type l | cut -c 3- | while read file ; do |
36 |
find . -type l | cut -c 3- | while read file ; do |
37 |
[ -L "${NWNUSERDIR}/${file}" ] || |
37 |
[ -L "${nwn_userdir}/${file}" ] || |
38 |
cp -R "${file}" "${NWNUSERDIR}/${file}" |
38 |
cp -R "${file}" "${nwn_userdir}/${file}" |
39 |
done |
39 |
done |
40 |
find . -type f | cut -c 3- | while read file ; do |
40 |
find . -type f | cut -c 3- | while read file ; do |
41 |
[ -e "${NWNUSERDIR}/${file}" -o \ |
41 |
[ -e "${nwn_userdir}/${file}" -o \ |
42 |
-e "$(tolower ${NWNUSERDIR}/${file})" ] || |
42 |
-e "$(tolower ${nwn_userdir}/${file})" ] || |
43 |
ln -s "${1}/${file}" "${NWNUSERDIR}/${file}" |
43 |
ln -s "${1}/${file}" "${nwn_userdir}/${file}" |
44 |
done |
44 |
done |
45 |
} |
45 |
} |
46 |
|
46 |
|
Lines 47-75
Link Here
|
47 |
# Create user directory. Will also update a user directory if anything is |
47 |
# Create user directory. Will also update a user directory if anything is |
48 |
# different due to running NWN with different versions of the game. |
48 |
# different due to running NWN with different versions of the game. |
49 |
rebuilduserdir() { |
49 |
rebuilduserdir() { |
50 |
# Copy ${NWNCLIENTDIR} first since it may contain files which |
50 |
# Copy ${nwn_clientdir} first since it may contain files which |
51 |
# override parts of ${NWNDATADIR} |
51 |
# override parts of ${nwn_datadir} |
52 |
copydir "${NWNCLIENTDIR}" |
52 |
copydir "${nwn_clientdir}" |
53 |
copydir "${NWNDATADIR}" |
53 |
copydir "${nwn_datadir}" |
54 |
|
54 |
|
55 |
# Some files need to have their names converted to lowercase. Create |
55 |
# Some files need to have their names converted to lowercase. Create |
56 |
# the directories if missing due to differences between versions of NWN. |
56 |
# the directories if missing due to differences between versions of NWN. |
57 |
cd "${NWNUSERDIR}" |
57 |
cd "${nwn_userdir}" |
58 |
mkdir -p ${LCDIRS} |
58 |
mkdir -p ${lc_dirs} |
59 |
lowerdir ${LCDIRS} |
59 |
lowerdir ${lc_dirs} |
60 |
} |
60 |
} |
61 |
|
61 |
|
62 |
if [ ! -d "${NWNUSERDIR}" ] ; then |
62 |
if [ ! -d "${nwn_userdir}" ] ; then |
63 |
echo "Creating user directory" |
63 |
echo "Creating user directory" |
64 |
mkdir "${NWNUSERDIR}" |
64 |
mkdir "${nwn_userdir}" |
65 |
|
65 |
|
66 |
# Copy the ini file so the user can tweak it |
66 |
# Copy the ini file so the user can tweak it |
67 |
cp "${NWNCLIENTDIR}/nwn.ini" "${NWNUSERDIR}" |
67 |
cp "${nwn_clientdir}/nwn.ini" "${nwn_userdir}" |
68 |
|
68 |
|
69 |
# Create a non-empty CD key file to work around a bug in the |
69 |
# Create a non-empty CD key file to work around a bug in the |
70 |
# client: it will ask for the key twice if the file is |
70 |
# client: it will ask for the key twice if the file is |
71 |
# initally empty or missing |
71 |
# initally empty or missing |
72 |
echo '[CDKEY]' >"${NWNUSERDIR}/nwncdkey.ini" |
72 |
echo '[CDKEY]' >"${nwn_userdir}/nwncdkey.ini" |
73 |
|
73 |
|
74 |
rebuilduserdir |
74 |
rebuilduserdir |
75 |
|
75 |
|
Lines 79-100
Link Here
|
79 |
else |
79 |
else |
80 |
# Remove dead links from different versions (e.g., original versus |
80 |
# Remove dead links from different versions (e.g., original versus |
81 |
# Diamond Edition) of NWN as they could confuse the game. |
81 |
# Diamond Edition) of NWN as they could confuse the game. |
82 |
find -L ${NWNUSERDIR} -type l -exec rm -- {} + |
82 |
find -L ${nwn_userdir} -type l -exec rm -- {} + |
83 |
|
83 |
|
84 |
rebuilduserdir |
84 |
rebuilduserdir |
85 |
fi |
85 |
fi |
86 |
|
86 |
|
87 |
echo "Saved games will be stored in ${NWNUSERDIR}/saves/" |
87 |
echo "Saved games will be stored in ${nwn_userdir}/saves/" |
88 |
|
88 |
|
89 |
cd "${NWNUSERDIR}" |
89 |
cd "${nwn_userdir}" |
90 |
|
90 |
|
91 |
# Remove old movie log file. |
91 |
# Remove old movie log file. |
92 |
rm -f ${NWNUSERDIR}/nwmovies.log |
92 |
rm -f ${nwn_userdir}/nwmovies.log |
93 |
|
93 |
|
94 |
# Prevent flickering at beginning and ending of playing a movie. |
|
|
95 |
# NOTE: this breaks using an external player (i.e., ffplay, mpv). |
96 |
#export NWMOVIES_GRAB_HACK=1 |
97 |
|
98 |
# SDL settings |
94 |
# SDL settings |
99 |
export SDL_MOUSE_RELATIVE=0 |
95 |
export SDL_MOUSE_RELATIVE=0 |
100 |
export SDL_VIDEO_X11_DGAMOUSE=0 |
96 |
export SDL_VIDEO_X11_DGAMOUSE=0 |
Lines 101-128
Link Here
|
101 |
export SDL_AUDIODRIVER=${SDL_AUDIODRIVER:-"dsp"} |
97 |
export SDL_AUDIODRIVER=${SDL_AUDIODRIVER:-"dsp"} |
102 |
|
98 |
|
103 |
# Library locations |
99 |
# Library locations |
104 |
export LD_LIBRARY_PATH="${NWNUSERDIR}/lib:${NWNUSERDIR}/miles" |
100 |
export LD_LIBRARY_PATH="${nwn_userdir}/lib:${nwn_userdir}/miles" |
105 |
|
101 |
|
106 |
# Prevent core files from NWN. |
102 |
# Prevent saving core files from NWN. |
107 |
ulimit -c 0 |
103 |
ulimit -c 0 |
108 |
|
104 |
|
109 |
echo "Starting Neverwinter Nights..." |
105 |
echo "Starting Neverwinter Nights..." |
110 |
if [ -e ${NWNMOVIEDIR}/nwmovies.so ] ; then |
106 |
if [ -e ${nwn_moviedir}/nwmovies.so ] ; then |
111 |
if [ ! -e ${NWNUSERDIR}/lib/libdisasm.so ] |
107 |
if [ ! -e ${nwn_userdir}/lib/libdisasm.so ] |
112 |
then |
108 |
then |
113 |
# Needed for generation of nwmovies.ini. Linked here since the code |
109 |
# Needed for generation of nwmovies.ini. Linked here since the |
114 |
# calls dlopen() from the user directory. |
110 |
# code calls dlopen() from the user directory. |
115 |
ln -sf ${NWNMOVIEDIR}/libdis/libdisasm.so \ |
111 |
ln -sf ${nwn_moviedir}/libdis/libdisasm.so \ |
116 |
${NWNUSERDIR}/lib/libdisasm.so |
112 |
${nwn_userdir}/lib/libdisasm.so |
117 |
fi |
113 |
fi |
118 |
|
114 |
|
119 |
export LD_PRELOAD=${NWNMOVIEDIR}/nwmovies.so |
115 |
export LD_PRELOAD=${nwn_moviedir}/nwmovies.so:%%LINUXBASE%%/lib/libz.so.1 |
120 |
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${NWNMOVIEDIR}" |
116 |
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${nwn_moviedir}" |
121 |
|
117 |
|
122 |
# Support for newer nwmovies.so that can use an external application. |
118 |
# Support for newer nwmovies.so that can use an external application. |
123 |
# Does not work all that well at the moment. |
119 |
# It requires LD_PRELOAD to be removed else the player will fail when it |
124 |
export NWMOVIES_PLAY_COMMAND="mpv --fullscreen --keep-open=no" \ |
120 |
# attempts to preload any Linux libraries. To make it easier, use a |
125 |
"--no-config --no-input-cursor --no-osc --no-terminal" \ |
121 |
# script that removes it instead of changing the movie playing library. |
126 |
"--osd-level=0" |
122 |
export NWMOVIES_PLAY_COMMAND="${nwn_userdir}/nwmovies.sh" |
127 |
fi |
123 |
fi |
128 |
./nwmain "${@}" |
124 |
./nwmain "${@}" |