The forum

Starflight 1 & 2 (GoG)

Author Replies
petch Saturday 3 December 2011 at 15:44
petch

Hi, here's my script to install Starflight 1 and 2 from GoG.
Nothing really special, except maybe that since they're DOS games, I'm using native dosbox instead of Windows dosbox. This has been tested to work with latest stable release of dosbox, 0.74, which actually is the same version as the Windows one.

A notice of warning, not related to this installer but to Starflight games: current savegame files are being modified as you play, so you cannot revert back to the state when you last saved by quitting the game without saving then restarting it: it would result in a corrupted savegame and you would not be able to continue.
To do this, you must keep around backups of your savegames (Starflight comes with a shell script wrapper to help you in this), and restore a previous copy. In this context "quitting without saving" makes sense to skip the time needed to make your current savegame consistent on disk when you know you're just about to restore a previous one over it.

Now the script:
https://raw.github.com/petchema/playonlinux/master/starflight1&2-gog
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#!/bin/bash
# Date : (2011-12-01 22-38)
# Last revision : (2011-12-01 22-38)
# Wine version used :
# Distribution used to test : Debian Sid (Unstable)
# Author : Pierre Etchemaite petchema@concept-micro.com
# Script licence : GPL v.2
# Program licence : Retail
# Depend : dosbox
 
# prefer native dosbox version
 
[ -z "$PLAYONLINUX" ] && exit 0
source "$PLAYONLINUX/lib/sources"
 
abort () {
    POL_SetupWindow_message_image "$LNG_ABORTED" "$TITLE" "$PLAYONLINUX/themes/tango/warning.png"
    POL_SetupWindow_Close
    exit 1
}
 
check_install_archive () {
    POL_SetupWindow_wait_next_signal "$LNG_CHECK_ARCHIVE" "$TITLE"
 
    EXPECTED_NAME='setup_starflight_1_2.exe'
    EXPECTED_SIZE=44526203
    EXPECTED_MD5="4b3e884d1bbe066470338456991dc73e"
 
    # Temporarily prevent word splitting
    OLDIFS="$IFS"
    IFS=''
    NAME="$(basename $ARCHIVE)"
    SIZE="$(stat -c%s $ARCHIVE)"
    MD5="$(POL_MD5_file $ARCHIVE)"
    IFS="$OLDIFS"
 
    POL_SetupWindow_detect_exit
 
    if [ $SIZE -ne $EXPECTED_SIZE -o "$MD5" != "$EXPECTED_MD5" ]; then
        POL_SetupWindow_message_image "$LNG_ARCHIVE_MISMATCH\\nName: $NAME (expected $EXPECTED_NAME)\\nSize: $SIZE (expected $EXPECTED_SIZE)\\nMD5: $MD5\\n     (expected $EXPECTED_MD5)" "$TITLE" "$PLAYONLINUX/themes/tango/warning.png"
        POL_SetupWindow_question "$LNG_CONTINUE" "$TITLE"
        [ "$APP_ANSWER" != "TRUE" ] && abort
    fi
}
 
 
PREFIX="Starflight_1_2_gog"
WORKING_WINE_VERSION="1.3.23"
# GoG tools (graphic mode setup, code wheel work _almost_ ok with 1.3.23
 
case "$POL_LANG" in
    fr)
        TITLE="Starflight 1 et 2 (version GoG)"
        SHORTCUT1_NAME="Starflight 1"
        SHORTCUT1_CODEWHEEL="Starflight 1 - Roue de codes"
        SHORTCUT1_DOC="Starflight 1 - Manuel d'utilisation"
        SHORTCUT1_MAP="Starflight 1 - Carte stellaire"
        SHORTCUT2_NAME="Starflight 2"
        SHORTCUT2_DOC="Starflight 2 - Manuel d'utilisation"
        SHORTCUT2_MAP="Starflight 2 - Carte stellaire"
        LNG_ABORTED="Une erreur est survenue, l'installation est interrompue."
        LNG_CHECK_ARCHIVE="Test de l'archive d'installation..."
        LNG_ARCHIVE_MISMATCH="L'archive ne correspond pas.\\nOu bien elle est corrompue, ou ce n'est pas la version attendue.\\nCe script ne peut pas garantir que l'installation se passera bien, pensez à communiquer le résultat de l'installation sur le forum de PlayOnLinux."
    LNG_CONTINUE="Continuer ?"
        LNG_ARCHIVE_LOCATION="Indiquez l'emplacement de l'archive d'installation"
        LNG_SELECT_FILE="Sélectionnez le fichier"
        LNG_INSTALLING="Installation de $TITLE..."
        ;;
    *)
        TITLE="Starflight 1 and 2 (GoG release)"
        SHORTCUT1_NAME="Starflight 1"
        SHORTCUT1_CODEWHEEL="Starflight 1 - Code wheel"
        SHORTCUT1_DOC="Starflight 1 - User manual"
        SHORTCUT1_MAP="Starflight 1 - Stellar map"
        SHORTCUT2_NAME="Starflight 2"
        SHORTCUT2_DOC="Starflight 2 - User manual"
        SHORTCUT2_MAP="Starflight 2 - Stellar map"
        LNG_ABORTED="An error occurred, the installation is aborted."
        LNG_CHECK_ARCHIVE="Checking install archive..."
        LNG_ARCHIVE_MISMATCH="Install archive mismatch.\\nEither your install archive is corrupted, or is not the expected version.\\nThis script cannot guarantee that installation will work correctly. Please report success or failure to PlayOnLinux forums."
        LNG_CONTINUE="Continue?"
        LNG_ARCHIVE_LOCATION="Please select the location of the install file"
        LNG_SELECT_FILE="Select file"
        LNG_INSTALLING="Installing $TITLE..."
        ;;
esac
 
POL_SetupWindow_Init
POL_SetupWindow_presentation "$TITLE" "Binary Systems / Electronic Arts" "http://www.gog.com/en/gamecard/starflight_1_2" "Pierre Etchemaite" "$PREFIX"
 
check_one "dosbox" "dosbox"
POL_SetupWindow_missing
  
POL_Wine_SelectPrefix "$PREFIX"
POL_Wine_PrefixCreate
 
cd $HOME
POL_SetupWindow_browse "$LNG_ARCHIVE_LOCATION" "$LNG_SELECT_FILE"
ARCHIVE="$APP_ANSWER"
 
check_install_archive
 
if [ -n "$WORKING_WINE_VERSION" ]; then
    POL_Wine_InstallVersion "$WORKING_WINE_VERSION"
    export WINEVERSION="$WORKING_WINE_VERSION"
fi
 
 
POL_SetupWindow_wait_next_signal "$LNG_INSTALLING" "$TITLE"
 
# Associate .PDF with native app
# http://wiki.winehq.org/FAQ#head-91bf3f0a8ccbfab8dee96f82fae2f1a489e0d243
# Do it before installing the game, so you have the possibility to open
# PDFs with Win32 reader if you choose to install it
cat <<'EOF' > $REPERTOIRE/tmp/pdfnativereader.reg
[HKEY_CLASSES_ROOT\\.pdf]
@="PDFfile"
"Content Type"="application/pdf"
[HKEY_CLASSES_ROOT\\PDFfile\\Shell\\Open\\command]
@="winebrowser \\"%1\\""
EOF
POL_Wine regedit $REPERTOIRE/tmp/pdfnativereader.reg
 
POL_Wine "$ARCHIVE" || abort
 
# GoG work!
Set_OS winxp
 
 
POL_SetupWindow_detect_exit
 
# Doesn't hurt ;)
POL_Wine_reboot
 
# Sadly, it seems GoG installer unpacks both games even if you only ask for 1
# So test below is uneffective and all shortcuts are always created
if [ -d "$WINEPREFIX/drive_c/$PROGRAMFILES/GOG.com/Starflight 1 and 2/Starflight 1" ]; then
    # Better default settings in my opinion
    sed -i.orig -e 's/^fullscreen=.*/fullscreen=false/; s/^scaler=.*/scaler=hq2x/' "$WINEPREFIX/drive_c/$PROGRAMFILES/GOG.com/Starflight 1 and 2/Starflight 1/dosboxSF1.conf"
 
    POL_SetupWindow_make_shortcut "$PREFIX" "$PROGRAMFILES/GOG.com/Starflight 1 and 2/Starflight 1/" "C:/$PROGRAMFILES/GOG.com/Starflight 1 and 2/DOSBOX/DOSBox.exe" "-conf dosboxSF1.conf -noconsole" "$SHORTCUT1_NAME"
    cp -n "$WINEPREFIX/drive_c/$PROGRAMFILES/GOG.com/Starflight 1 and 2/Starflight 1/gfw_high.ico" "$REPERTOIRE/icones/32/$SHORTCUT1_NAME"
    # Thanks to exec, will only start W32 dosbox if native dosbox fails to start
    POL_Shortcut_InsertBeforeWine "$SHORTCUT1_NAME" "exec dosbox -conf dosboxSF1.conf"
    if [ -n "$WORKING_WINE_VERSION" ]; then
        Set_WineVersion_Assign "$WORKING_WINE_VERSION" "$SHORTCUT1_NAME"
    fi
 
    POL_Shortcut "Starflight_codes_by_gog.exe" "$SHORTCUT1_CODEWHEEL"
 
    POL_SetupWindow_make_shortcut "$PREFIX" "/windows/command" "start.exe" "" "$SHORTCUT1_DOC" "" "'C:/$PROGRAMFILES/GOG.com/Starflight 1 and 2/Starflight 1/manual.pdf'"
 
    POL_SetupWindow_make_shortcut "$PREFIX" "/windows/command" "start.exe" "" "$SHORTCUT1_MAP" "" "'C:/$PROGRAMFILES/GOG.com/Starflight 1 and 2/Starflight 1/map.pdf'"
fi
 
if [ -d "$WINEPREFIX/drive_c/$PROGRAMFILES/GOG.com/Starflight 1 and 2/Starflight 2" ]; then
    # Better default settings in my opinion
    sed -i.orig -e 's/^fullscreen=.*/fullscreen=false/; s/^scaler=.*/scaler=hq2x/' "$WINEPREFIX/drive_c/$PROGRAMFILES/GOG.com/Starflight 1 and 2/Starflight 2/dosboxSF2.conf"
 
    POL_SetupWindow_make_shortcut "$PREFIX" "$PROGRAMFILES/GOG.com/Starflight 1 and 2/Starflight 2/" "C:/$PROGRAMFILES/GOG.com/Starflight 1 and 2/DOSBOX/DOSBox.exe" "-conf dosboxSF2.conf -noconsole" "$SHORTCUT2_NAME"
    cp -n "$WINEPREFIX/drive_c/$PROGRAMFILES/GOG.com/Starflight 1 and 2/Starflight 2/gfw_high.ico" "$REPERTOIRE/icones/32/$SHORTCUT2_NAME"
    # Thanks to exec, will only start W32 dosbox if native dosbox fails to start
    POL_Shortcut_InsertBeforeWine "$SHORTCUT2_NAME" "exec dosbox -conf dosboxSF2.conf"
    if [ -n "$WORKING_WINE_VERSION" ]; then
        Set_WineVersion_Assign "$WORKING_WINE_VERSION" "$SHORTCUT2_NAME"
    fi
 
    POL_SetupWindow_make_shortcut "$PREFIX" "/windows/command" "start.exe" "" "$SHORTCUT2_DOC" "" "'C:/$PROGRAMFILES/GOG.com/Starflight 1 and 2/Starflight 2/manual.pdf'"
 
    POL_SetupWindow_make_shortcut "$PREFIX" "/windows/command" "start.exe" "" "$SHORTCUT2_MAP" "" "'C:/$PROGRAMFILES/GOG.com/Starflight 1 and 2/Starflight 2/map.pdf'"
fi
 
POL_SetupWindow_Close
 
cat <<EOF > $REPERTOIRE/configurations/configurators/"$SHORTCUT1_NAME"
#!/bin/bash
[ -z "\\$PLAYONLINUX" ] && exit 0
source "\\$PLAYONLINUX/lib/sources"
export WINEPREFIX="$REPERTOIRE/wineprefix/$PREFIX"
export WINEDEBUG=""
 
POL_LoadVar_PROGRAMFILES
 
cd "$WINEPREFIX/drive_c/$PROGRAMFILES/GOG.com/Starflight 1 and 2/" || exit
 
# Make sure that if user presses "start game", it will launch the right dosbox
DOSBOX="`which dosbox`"
if [ -n "\\$DOSBOX" ]; then
    cat <<-EOFINI > $REPERTOIRE/tmp/sf1nativedosbox.reg
    REGEDIT4
 
    [HKEY_LOCAL_MACHINE\\Software\\GOG.com\\GOGSTARFLIGHT1]
    "LAUNCHCOMMAND"="\\$DOSBOX -conf dosboxSF1.conf"
    EOFINI
    POL_Wine regedit $REPERTOIRE/tmp/sf1nativedosbox.reg
fi
 
POL_Wine "Graphic mode setup.exe" "GOGSTARFLIGHT1"
exit
EOF
 
cat <<EOF > $REPERTOIRE/configurations/configurators/"$SHORTCUT2_NAME"
#!/bin/bash
[ -z "\\$PLAYONLINUX" ] && exit 0
source "\\$PLAYONLINUX/lib/sources"
export WINEPREFIX="$REPERTOIRE/wineprefix/$PREFIX"
export WINEDEBUG=""
 
POL_LoadVar_PROGRAMFILES
 
cd "$WINEPREFIX/drive_c/$PROGRAMFILES/GOG.com/Starflight 1 and 2/" || exit
# Make sure that if user presses "start game", it will launch the right dosbox
DOSBOX="`which dosbox`"
if [ -n "\\$DOSBOX" ]; then
    cat <<-EOFINI > $REPERTOIRE/tmp/sf2nativedosbox.reg
    REGEDIT4
 
    [HKEY_LOCAL_MACHINE\\Software\\GOG.com\\GOGSTARFLIGHT2]
    "LAUNCHCOMMAND"="\\$DOSBOX -conf dosboxSF2.conf"
    EOFINI
    POL_Wine regedit $REPERTOIRE/tmp/sf2nativedosbox.reg
fi
 
POL_Wine "Graphic mode setup.exe" "GOGSTARFLIGHT2"
exit
EOF
 
exit

Edited by petch

This site allows content generated by members, and we promptly remove any content that infringes copyright according to our Terms of Service. To report copyright infringement, please send a notice to dmca@playonlinux.com