blob: 81351502c564cf5b8f2ea3fa26a7d73f8b72302e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
#!/bin/sh
NWNDATADIR="%%NWNDATADIR%%"
NWNCLIENTDIR="%%NWNCLIENTDIR%%"
NWNUSERDIR="${HOME}/.nwn"
NWNMOVIEDIR="${NWNUSERDIR}/nwmovies"
LCDIRS="ambient data dmvault hak localvault music override portraits"
set -e
# Print arguments in lowercase
tolower() {
set -e
echo "$@" | tr '[:upper:]' '[:lower:]'
}
# Rename all files in a directory to lowercase
lowerdir() {
set -e
find "$@" -name '*[A-Z]*' | while read name ; do
mv -v "${name}" "$(tolower ${name})"
done
}
# Copy a directory structure and symlink its contents
copydir() {
set -e
cd "$1"
find . -type d | cut -c 3- | while read dir ; do
[ -d "${NWNUSERDIR}/${dir}" ] ||
mkdir "${NWNUSERDIR}/${dir}"
done
find . -type l | cut -c 3- | while read file ; do
[ -L "${NWNUSERDIR}/${file}" ] ||
cp -R "${file}" "${NWNUSERDIR}/${file}"
done
find . -type f | cut -c 3- | while read file ; do
[ -e "${NWNUSERDIR}/${file}" -o \
-e "$(tolower ${NWNUSERDIR}/${file})" ] ||
ln -s "${1}/${file}" "${NWNUSERDIR}/${file}"
done
}
# Create user directory. Will also update a user directory if anything is
# different due to running NWN with different versions of the game.
rebuilduserdir() {
# Copy ${NWNCLIENTDIR} first since it may contain files which
# override parts of ${NWNDATADIR}
copydir "${NWNCLIENTDIR}"
copydir "${NWNDATADIR}"
# Some files need to have their names converted to lowercase. Create
# the directories if missing due to differences between versions of NWN.
cd "${NWNUSERDIR}"
mkdir -p ${LCDIRS}
lowerdir ${LCDIRS}
}
if [ ! -d "${NWNUSERDIR}" ] ; then
echo "Creating user directory"
mkdir "${NWNUSERDIR}"
# Copy the ini file so the user can tweak it
cp "${NWNCLIENTDIR}/nwn.ini" "${NWNUSERDIR}"
# Create a non-empty CD key file to work around a bug in the
# client: it will ask for the key twice if the file is
# initally empty or missing
echo '[CDKEY]' >"${NWNUSERDIR}/nwncdkey.ini"
rebuilduserdir
echo "Your Neverwinter Nights directory (~/.nwn) has now been"
echo "created and populated. Press ENTER to start the game."
read dummy
else
# Remove dead links from different versions (e.g., original versus
# Diamond Edition) of NWN as they could confuse the game.
find -L ${NWNUSERDIR} -type l -exec rm -- {} +
rebuilduserdir
fi
echo "Saved games will be stored in ${NWNUSERDIR}/saves/"
cd "${NWNUSERDIR}"
# Remove old movie log file.
rm -f ${NWNUSERDIR}/nwmovies.log
# Prevent flickering at beginning and ending of playing a movie.
# NOTE: this breaks using an external player (i.e., ffplay, mpv).
#export NWMOVIES_GRAB_HACK=1
# SDL settings
export SDL_MOUSE_RELATIVE=0
export SDL_VIDEO_X11_DGAMOUSE=0
export SDL_AUDIODRIVER=${SDL_AUDIODRIVER:-"dsp"}
# Library locations
export LD_LIBRARY_PATH="${NWNUSERDIR}/lib:${NWNUSERDIR}/miles"
# Prevent core files from NWN.
ulimit -c 0
echo "Starting Neverwinter Nights..."
if [ -e ${NWNMOVIEDIR}/nwmovies.so ] ; then
if [ ! -e ${NWNUSERDIR}/lib/libdisasm.so ]
then
# Needed for generation of nwmovies.ini. Linked here since the code
# calls dlopen() from the user directory.
ln -sf ${NWNMOVIEDIR}/libdis/libdisasm.so \
${NWNUSERDIR}/lib/libdisasm.so
fi
export LD_PRELOAD=${NWNMOVIEDIR}/nwmovies.so
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${NWNMOVIEDIR}"
# Support for newer nwmovies.so that can use an external application.
# Does not work all that well at the moment.
export NWMOVIES_PLAY_COMMAND="mpv --fullscreen --keep-open=no" \
"--no-config --no-input-cursor --no-osc --no-terminal" \
"--osd-level=0"
fi
./nwmain "${@}"
|