El Foro

[Script] GOG.com - Ultima 4, 5, 6

Autor Respuestas
daemonburrito Wednesday 3 September 2014 at 3:03
daemonburritoAnonymous

First attempt at a script... Based on MindLikeWater's Ultima 1,2,3, with a workaround for the bug in shortize.py. All three directories have spaces, and to work around the bug I create symlinks.

 

First pass without the meta or the pngs. Also available for comments/changes on github: https://github.com/daemonburrito/playonlinux_scripts/blob/master/GOGcom__Ultima_4_5_6.sh. Tips welcome. Also let me know if I'm doing formatting, etc. right for this forum.

 

#!/usr/bin/env bash
[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"

GOGID="ultima_456"
PREFIX="Ultima456_gog"
WORKING_WINE_VERSION="1.6.2-dos_support_0.6"

TITLE="GOG.com - Ultima 4, 5, 6"
DEVELOPER="Origin Systems / Electronic Arts"
INSTALL_FILE_HASH="ce753da8c97e34473f281591eaf7f45a"
INSTALL_DIR="Ultima Second Trilogy"
GAME_DIR1="Ultima 4"
GAME_DIR2="Ultima 5"
GAME_DIR3="Ultima 6"
GAME_DIR1_SHORT="Ultima4"
GAME_DIR2_SHORT="Ultima5"
GAME_DIR3_SHORT="Ultima6"

EXEC1="ULTIMA.COM"
EXEC2="ULTIMA.EXE"
EXEC3="ULTIMA6.EXE"
MANUAL1="manual.pdf"
MANUAL2="manual.pdf"
MANUAL3="manual.pdf"
SHORTCUT_NAME1="Ultima 4: Quest of the Avatar (Bundled)"
SHORTCUT_NAME2="Ultima 5: Warriors of Destiny"
SHORTCUT_NAME3="Ultima 6: The False Prophet"

POL_SetupWindow_Init
POL_Debug_Init

POL_SetupWindow_presentation "$TITLE" "$DEVELOPER" "http://www.gog.com/gamecard/$GOGID" "daemonburrito" "$PREFIX"

POL_Call POL_GoG_setup "$GOGID" "$INSTALL_FILE_HASH"
 
POL_Wine_SelectPrefix "$PREFIX"
POL_Wine_PrefixCreate "$WORKING_WINE_VERSION"
 
POL_Call POL_GoG_install

cat <<_EOFCFG_ >> "$WINEPREFIX/playonlinux_dos.cfg"
cpu_core=auto
cpu_cycles=500
dosbox_memsize=16
sblaster_sbtype=sbpro1
sblaster_sbbase=220
sblaster_irq=5
sblaster_dma=1
sblaster_hdma=5
sblaster_mixer=true
sblaster_oplmode=auto
_EOFCFG_

[ "$POL_OS" = "Linux" ] && echo "render_scaler=hq2x" >> "$WINEPREFIX/playonlinux_dos.cfg"

POL_SetupWindow_wait "Moving game dirs to shortened names" "$TITLE"
# workaround for shortize bug
cd "$WINEPREFIX/drive_c/GOG Games/$INSTALL_DIR"
ln -s "$GAME_DIR1" "$GAME_DIR1_SHORT"
ln -s "$GAME_DIR2" "$GAME_DIR2_SHORT"
ln -s "$GAME_DIR3" "$GAME_DIR3_SHORT"
cd "$WINEPREFIX/drive_c/"

POL_Shortcut "GOG Games/$INSTALL_DIR/$GAME_DIR1_SHORT/$EXEC1" "$SHORTCUT_NAME1" "$SHORTCUT_NAME1.png" "" "Game;RolePlaying;"
POL_Shortcut_Document "$SHORTCUT_NAME1" "$WINEPREFIX/drive_c/GOG Games/$INSTALL_DIR/$GAME_DIR1/$MANUAL1"
 
POL_Shortcut "GOG Games/$INSTALL_DIR/$GAME_DIR2_SHORT/$EXEC2" "$SHORTCUT_NAME2" "$SHORTCUT_NAME2.png" "" "Game;RolePlaying;"
POL_Shortcut_Document "$SHORTCUT_NAME2" "$WINEPREFIX/drive_c/GOG Games/$INSTALL_DIR/$GAME_DIR2/$MANUAL2"
 
POL_Shortcut "GOG Games/$INSTALL_DIR/$GAME_DIR3_SHORT/$EXEC3" "$SHORTCUT_NAME3" "$SHORTCUT_NAME3.png" "" "Game;RolePlaying;"
POL_Shortcut_Document "$SHORTCUT_NAME3" "$WINEPREFIX/drive_c/GOG Games/$INSTALL_DIR/$GAME_DIR3/$MANUAL3"
 
POL_SetupWindow_Close

exit 0

Editado por: Tinou

petch Wednesday 3 September 2014 at 23:43
petch
Developer

     Hi daemonburrito,

Your script looks quite ok, and having the games myself I could even check that it does the job ;)

Let's go on with the review:

EXEC1="ULTIMA.COM"
EXEC2="ULTIMA.EXE"
EXEC3="ULTIMA6.EXE"
MANUAL1="manual.pdf"
MANUAL2="manual.pdf"
MANUAL3="manual.pdf"

While I understand the urge for modern developers to put symbolic names on things, and agree that it's a good thing on most environments, I'm not sure sure of the benefit in short shell scripts:

- you can't make them immutable, so they're variables used as constants;

- unless you use set -u you may not notice typos in variable names, so it makes code more brittle;

- functions can inadvertly override variables (unless they carefully use "local", which is not always the case);

- benefits are not so obvious for 20 or 30 lines of code.

So I'm not very convinced by this practice in the context of PlayOnLinux install scripts.

POL_SetupWindow_wait "Moving game dirs to shortened names" "$TITLE"

Messages to the user should be enclosed in $(eval_gettext '') to handle localization. However creating 3 symlinks is so far that the message may be better simply be left off.

cd "$WINEPREFIX/drive_c/GOG Games/$INSTALL_DIR"

POL_Call POL_GoG_install sets $GOGROOT to the base GOG install directory, so this can be simplified as

cd "$GOGROOT/$INSTALL_DIR"

 

cd "$WINEPREFIX/drive_c/"

That line is not necessary, POL_Shortcut take either filenames or paths relative to drive_c, no matter the current directory.

Just one last note,

#!/usr/bin/env bash

That would mean that what follows is a Bash script, and that if you set the executable bit on it, you'd like Bash to be used to actually interpret it.

But while it's technically a Bash script, it's actually a PlayOnLinux script, that uses Bash as an extension language. Having it executed straight from Bash won't get you anything (the first test will just terminate the script right from the start). So it's rather just misleading.

If anything, you could say that you want it to be interpreted by playonlinux-bash, and that would actually work.

But that's usually not how PlayOnLinux script are evaluated, so this first line should better be omitted.

 

That's it for me, feel free to submit the script to the official repository!

Pierre.

 

petch Wednesday 3 September 2014 at 23:51
petch
Developer

One other thing I noticed, functional this time: GOG uses different DOSBox settings for games, for example for Ultima 6 they use

[cpu]
core=simple
cputype=386_slow
cycles=3000

It's not very simple to replicate this with PlayOnLinux DOSBox support, that expects one game per virtual drive, but this can be done using wrapper batch scripts that use CONFIG -set statements.

See for example the Alien Breen and Tower Assault script, ll. 75-81.

 

Editado por: petch

petch Thursday 4 September 2014 at 0:12
petch
Developer

[...] with a workaround for the bug in shortize.py. All three directories have spaces, and to work around the bug I create symlinks.

That one is interesting too, if you want to look into it, because the problem is not exactly the spaces: shortize.py actually handles "GOG Games" or  "Ultima Second Trilogy", at the levels above, just right. You can also run its unit tests (test_shortize.py, next to it) that contain tests involving spaces.

The problem is that once there's more than one name side by side that have the same name short prefix, the renaming mechanisms inside DOSBox stop behaving as a function: "Ultima 5" gets translated to "ULTIMA~2" only because there's also an "Ultima 4" right next to it, or something like that. That looks very complicated to get right.

daemonburrito Thursday 4 September 2014 at 5:29
daemonburritoAnonymous

Regarding the shortize bug... you are right, and that is what I meant to express. All directories end up as "ULTIMA~1" to shortize. By the spaces causing it, I mean that if there were no spaces, shortize would not try to fix them ;). The problem is only in the creation of the shortcuts... All three will end up pointing to the same directory.

Thank you for the tip about Ultima 6 and splitting up games from multi-installers into multiple prefixes. It's probably worth it for me to try to get that right in the next iteration, and the technique is probably going to come in handy for the next couple of collections (the old Sierra games, which coincidentally also have problematic directory names).

Thanks especially for the notes on the idioms. I was doing as the Romans do from what I've seen, and I appreciate the guidance. Also, thanks for your github wiki!

Oh, and one last question: Where is the official repo? Thanks again.

daemonburrito Thursday 4 September 2014 at 5:31
daemonburritoAnonymous

Oh crap, I found the sticky regarding submission, sorry, nm.smiley

petch Thursday 4 September 2014 at 14:06
petch
Developer

Thank you for the tip about Ultima 6 and splitting up games from multi-installers into multiple prefixes.

It's not using multiple prefixes, just using the fact that many (most?) DOSBox settings can also be modified dynamically; Hence we can set common DOSBox settings at the prefix level, and adjust the specific settings for each game using dynamic settings.

daemonburrito Thursday 11 September 2014 at 3:55
daemonburritoAnonymous

Sorry for the delay, day job coding interfering with gaming.

I wrote a Python script that I thought you might find handy, as it's inspired by the batch file trick you showed me. I'm using it to make much-improved POL scripts with perfect-ish dosbox settings (or at least in perfect agreement with GOG in their multi-packs).

https://github.com/daemonburrito/playonlinux_scripts/blob/master/cfg_parser.py

Just a little thing to compare any number of configs and return the common settings, and a list of unique settings. Right now, it just pretty-prints the Python dict, but I'll add support for other output formats soon, including ini and a format that can be pasted into the heredoc, as in the example.

Editado por: daemonburrito

daemonburrito Saturday 13 September 2014 at 21:30
daemonburritoAnonymous

Updated, and art done:

https://github.com/daemonburrito/playonlinux_scripts/blob/master/GOGcom__Ultima_4_5_6.sh

Pretty much the same, but with batch file launchers with individual dosbox configs, and all of your other suggestions.

daemonburrito Saturday 13 September 2014 at 21:58
daemonburritoAnonymous

Something seems to have gone horribly wrong with submitting the script:

http://www.playonlinux.com/en/app-2269-GOGcom__Ultima_4_5_6.html

I thought I was following the directions here, but I didn't see where to save the script and clicked "Edit". So the submission is empty... Very confused. Was I supposed to paste the code into the "Description" editor?

Saddening, would love to contribute.

EDIT: Posted the code in an update. Would still love to know how to do it right or fix it.

Got help on irc, uploaded assets to:

https://github.com/daemonburrito/playonlinux_scripts/tree/master/GOGcom__Ultima_4_5_6

Editado por: daemonburrito

petch Tuesday 16 September 2014 at 22:09
petch
Developer

I validated the script; For the icons I used the "original" VGA ones, because downscaled GOG ones are not really recognizable. I don't know what to use for installer icon, I thought about downscaling the same image used for "top" gfx, but 22x22 is small ;)

About DOSBox setup, I think something much shorter should be possible:

- settings are default values, hardcoded in the DOSBox support; So those values are optional in conf files;

- some settings are "decorative": if [gus] gus=false is set, no other gus related setting is effective;

- Ultima 5 and Ultima 6 settings are the same, or at least very close; So their settings can be used as defaults, and only use CONFIG -set in the Ultima 4 wrapper script.

But anyway, that's an optimization only...

petch Tuesday 16 September 2014 at 22:15
petch
Developer

By the way, if you're already familiar with git, I actually manage the GOG scripts using github too; And I have the resources stored in the same layout as the sftp server, so that I can update them with just one command.

For example for this script the commit looks like:

https://github.com/petchema/playonlinux/commit/f975e5c455671e4e7cb3bdcf13177ee380c184ba

So sending resources could be a simple merge request :)