Forums

[script] Blade Runner

Can play on linux check correct CD is in drive each time game is launched?

Auteur Réponses
Okto Mercredi 15 Octobre 2014 à 20:35
OktoAnonymous

#!/bin/bash
# Date : (2014-10-15 20-12)
# Wine version used : 1.7.28
# Distribution used to test : OpenSuse 13.1
# Author : Benjamin Hardy

[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"
 
TITLE="Blade Runner"
PREFIX="bladerunner"
# The installer has issues identifying a sound card with 1.6.2, but works correctly with 1.7.28
WORKING_WINE_VERSION="1.7.28"
SHORTCUT_NAME="Blade Runner"

POL_SetupWindow_Init
POL_Debug_Init

POL_SetupWindow_presentation "$TITLE" "Westwood Studios" "" "Benjamin Hardy" "$PREFIX"  

POL_SetupWindow_message "This script has been designed for the original 4-CD release. Please place disc one in the drive now." ""

POL_System_SetArch "x86"
POL_Wine_SelectPrefix "$PREFIX"
POL_Wine_PrefixCreate "$WORKING_WINE_VERSION"

POL_SetupWindow_cdrom
POL_SetupWindow_check_cdrom "cd1/outtake1.mix"

POL_Wine_WaitBefore "$TITLE"
POL_Wine start /unix "$CDROM/setup/install.exe"
POL_Wine_WaitExit "$TITLE"

POL_Shortcut "blade.exe" "$SHORTCUT_NAME" "" "" "Game;AdventureGame;"

POL_Wine_reboot

POL_SetupWindow_message "Please ensure that disc one is in the drive each time before the game is launched." "$TITLE has now been installed."

POL_SetupWindow_Close
 
exit 0

 

This script installs well and the game runs fine. However, it has one issue I'd like to try to solve before submitting it. The game checks if CD-1 is in the drive for copy protection reasons, which works, but if there's no CD, the wrong CD, or the CD drive is spun down it crashes without explanation. I think this could be confusing for users, and would like to add some code that spins up the CD drive and confirms it's the correct disc (perhaps by looking for a disctinctive known file on the disc) before attempting to launch the game -  that way it would be possible to give a "please insert CD-1" message rather than have an unexplained crash. I tried a few commands with POL_Shortcut_InsertBeforeWine, but I can't yet find a way that works.

Any suggestions welcome?

Okto Samedi 18 Octobre 2014 à 20:37
OktoAnonymous

In case anyone is curious, I've been through this in more detail. It turns out that everything is fine, provided the CD has been mounted first. That's the only requirement it seems. I didn't think much about it before, but KDE automatically mounts it for me under most situations. I didn't realise it doesn't under one specific situation - when I turn off the computer with the disc in, then restart it and attempt to run the game without first mounting the cd.

As the terminal commands to mount the disc need root, it can't be included in a script. So, I'm going to place a suitable reminder to the user and upload it.
petch Samedi 18 Octobre 2014 à 21:54
petch

Hi,

For the script review:

POL_SetupWindow_message "This script has been designed for the original 4-CD release. Please place disc one in the drive now." ""
...
POL_SetupWindow_message "Please ensure that disc one is in the drive each time before the game is launched." "$TITLE has now been installed."
All user oriented messages should support localization: see http://www.playonmac.com/en/dev-documentation-10.html
POL_System_SetArch "x86"

Just for information that's the default (but specifying it doesn't hurt).

POL_Wine_WaitBefore "$TITLE"
POL_Wine start /unix "$CDROM/setup/install.exe"
POL_Wine_WaitExit "$TITLE"
start /unix is usually unnecessary, and has a side effects (makes programs started with Wine to run asynchronously, so they aren't killed automatically if the script is aborted), so if should be avoid if possible.
Using both POL_Wine_WaitBefore and POL_Wine_WaitExit around a Wine command should never be necessary, as one is useful for programs running synchronously, and the other for programs running asynchronously. If you manage to get rid of start /unix, POL_Wine_WaitBefore may be sufficient.
 
That's all I can think of right now...
Pierre.
 
Okto Dimanche 19 Octobre 2014 à 17:22
OktoAnonymous

Hi Pierre, thank you for your help, I now understand these things much better. I have made the suggested changes, tested it, and uploaded the installer again.

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-notice@playonlinux.com