summaryrefslogtreecommitdiff
path: root/patches/nethack.sh-maemo2
blob: c69dac3e589de5cc0563d2c9156cae85d9866921 (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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#!/bin/sh
# This is a special .sh file for Maemo
# All user data is stored in the home directory because we can't set a suid bit in Nethack and 
# we want backups to be made from the nethack data.

HACKDIR=~/.nethackdir
export HACKDIR
MAXNROFPLAYERS=4

INSTALL_HACKDIR=/usr/games/lib/nethackdir
HACK=$INSTALL_HACKDIR/nethack

# Since Nethack.ad is installed in HACKDIR, add it to XUSERFILESEARCHPATH
case "x$XUSERFILESEARCHPATH" in
x)	XUSERFILESEARCHPATH="$HACKDIR/%N.ad"
	;;
*)	XUSERFILESEARCHPATH="$XUSERFILESEARCHPATH:$HACKDIR/%N.ad"
	;;
esac
export XUSERFILESEARCHPATH

# see if we can find the full path name of PAGER, so help files work properly
# assume that if someone sets up a special variable (HACKPAGER) for NetHack,
# it will already be in a form acceptable to NetHack
# ideas from brian@radio.astro.utoronto.ca
if test \( "xxx$PAGER" != xxx \) -a \( "xxx$HACKPAGER" = xxx \)
then

	HACKPAGER=$PAGER

#	use only the first word of the pager variable
#	this prevents problems when looking for file names with trailing
#	options, but also makes the options unavailable for later use from
#	NetHack
	for i in $HACKPAGER
	do
		HACKPAGER=$i
		break
	done

	if test ! -f $HACKPAGER
	then
		IFS=:
		for i in $PATH
		do
			if test -f $i/$HACKPAGER
			then
				HACKPAGER=$i/$HACKPAGER
				export HACKPAGER
				break
			fi
		done
		IFS=' 	'
	fi
	if test ! -f $HACKPAGER
	then
		echo Cannot find $PAGER -- unsetting PAGER.
		unset HACKPAGER
		unset PAGER
	fi
fi


#    create links to INSTALL_NETHACKDIR and setup the other things in the user homedirectory
if test ! -d $HACKDIR
then
    mkdir $HACKDIR
fi

if test ! -f $HACKDIR/equip.png
then
    ln -s $INSTALL_HACKDIR/equip.png $HACKDIR/equip.png
fi

if test ! -f $HACKDIR/gold24.png
then
    ln -s $INSTALL_HACKDIR/gold24.png $HACKDIR/gold24.png
fi

if test ! -f $HACKDIR/gtk2hack.png
then
    ln -s $INSTALL_HACKDIR/gtk2hack.png $HACKDIR/gtk2hack.png
fi

if test ! -f $HACKDIR/pad_unclicked.png
then
    ln -s $INSTALL_HACKDIR/pad_unclicked.png $HACKDIR/pad_unclicked.png
fi

if test ! -f $HACKDIR/pad_clicked.png
then
    ln -s $INSTALL_HACKDIR/pad_clicked.png $HACKDIR/pad_clicked.png
fi

if test ! -d $HACKDIR/locale
then
    ln -s $INSTALL_HACKDIR/locale $HACKDIR/locale
fi

if test ! -f $HACKDIR/logfile
then
    touch $HACKDIR/logfile
fi

if test ! -f $HACKDIR/mapbg.xpm
then
    ln -s $INSTALL_HACKDIR/mapbg.xpm $HACKDIR/mapbg.xpm
fi

if test ! -f $HACKDIR/nhdat
then
    ln -s $INSTALL_HACKDIR/nhdat $HACKDIR/nhdat
fi

if test ! -f $HACKDIR/perm
then
    touch $HACKDIR/perm
fi

if test ! -f $HACKDIR/record
then
    touch $HACKDIR/record
fi

if test ! -f $HACKDIR/recover
then
    ln -s $INSTALL_HACKDIR/recover $HACKDIR/recover
fi

if test ! -f $HACKDIR/rip.xpm
then
    ln -s $INSTALL_HACKDIR/rip.xpm $HACKDIR/rip.xpm
fi

if test ! -d $HACKDIR/save
then
    mkdir $HACKDIR/save
fi

if test ! -f $HACKDIR/x11tiles
then
    ln -s $INSTALL_HACKDIR/x11tiles $HACKDIR/x11tiles
fi

if test ! -f $HACKDIR/tiles32.png
then
    ln -s $INSTALL_HACKDIR/tiles32.png $HACKDIR/tiles32.png
fi

if test ! -f $HACKDIR/ClassicBW.png
then
    ln -s $INSTALL_HACKDIR/ClassicBW.png $HACKDIR/ClassicBW.png
fi

if test ! -f $HACKDIR/ClassicWB.png
then
    ln -s $INSTALL_HACKDIR/ClassicWB.png $HACKDIR/ClassicWB.png
fi

if test ! -f $HACKDIR/ClassicColor.png
then
    ln -s $INSTALL_HACKDIR/ClassicColor.png $HACKDIR/ClassicColor.png
fi

if test ! -f $HACKDIR/gtk2hackrc
then
    ln -s $INSTALL_HACKDIR/gtk2hackrc $HACKDIR/gtk2hackrc
fi

if test ! -f ~/.nethackrc
then
    ln -s $INSTALL_HACKDIR/dot.nethackrc ~/.nethackrc
fi

if test ! -d ~/MyDocs/.documents/.games/Nethack
then
    ln -s $HACKDIR/save/ ~/MyDocs/.documents/.games/Nethack
#ln -s /home/user/$HACKDIR/save/ /home/user/MyDocs/.documents/.games/Nethack
fi
# we want to ask the username in HILDON

cd $HACKDIR
case $1 in
	-s*)
		exec $HACK "$@"
		;;
	*)
		exec $HACK "$@" $MAXNROFPLAYERS
		;;
esac