The forum

Civilization IV

Author Replies
marco_g Sunday 16 May 2010 at 16:55
marco_gAnonymous

Hello,

Here is the script I wrote to install Civilization IV on PlayOnLinux. After this script was finished I noticed there was already an unsupported version with French comments. So I am sorry for the duplicated work. Feel free to submit this to your repository if you like it. If something has to be improved or added, please tell me. Since I do not know the community I simply put the license to my favorite license: GPLv3. Is this acceptable for you?

The installer installs the game as one might expect. To patch the game, you will have to do that via "Configure this application" which will download the patch and install it.

I have tested this script with wine version 1.1.43 (which is enforced). The game I own is a DVD version of the game (verson 1.63). A cracked .exe is not required. Please let me know if you own a different version of the game and if it does or doesn't work with this script.

Is this the right way to submit scripts? Is there a VC repository or a mailinglist?

Regards,
Marco

#!/bin/bash
# Date : (2010-05-16)
# Last revision : (2010-05-16)
# Wine version used : 1.1.43
# Distribution used to test : Ubuntu 9.10
# Author : Marco Gerards
# Licence : GPLv3
# Depend : d3dx9, msxml3

# This script was tested using the DVD version of `Civilization IV'
# version 1.61, bought in the Netherlands in 2010.

[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"

TITLE="Civilization IV"
AUTHOR="Marco Gerards"
PREFIX="Civilization4"
PREFIXDIR="$HOME/.PlayOnLinux/wineprefix/$PREFIX"
WORKINGWINEVERSION="1.1.43"

POL_SetupWindow_Init

POL_SetupWindow_presentation "$TITLE" "Firaxis Games" "http://www.firaxis.com/" "$AUTHOR" "$PREFIX"
select_prefix "$PREFIXDIR"

# Make sure the right wine version is used, otherwise
# the user will run into a problem with copyright protection.
POL_SetupWindow_install_wine "$WORKINGWINEVERSION"

Use_WineVersion "$WORKINGWINEVERSION"

# Let the user select a CDROM
POL_SetupWindow_cdrom

# Check if this CDROM is the Civilization IV CDROM
POL_SetupWindow_check_cdrom "/Autorun/Civ4Installer.ico"

# Create the prefix for Civilization IV, a directory called `Civilization4'
POL_SetupWindow_prefixcreate

PROGRAMFILES="Program Files" 
POL_LoadVar_PROGRAMFILES

# Install DirectX9
POL_Call POL_Install_d3dx9

# Run the installer
wine start /unix "$CDROM/setup.exe"
POL_SetupWindow_message "Running installer\\nClick next when the installer is finished"

# Setup an icon for the game
cd "$PREFIXDIR/drive_c/$PROGRAMFILES/Firaxis Games/Sid Meier's Civilization 4/Assets/res"
convert Civ4Game.ico Civ4Game.png
cp Civ4Game-1.png "$HOME/.PlayOnLinux/icones/32/$TITLE"

# Install MS XML 3, this should be done after the game is installed,
# otherwise it will not work.
POL_Call POL_Install_msxml3

# Make a configuration which is capable of installing the patch
cat << EOF > "$REPERTOIRE/configurations/configurators/$TITLE"
#!/bin/bash
if [ "$PLAYONLINUX" = "" ]
then
  exit 0
fi
source "$PLAYONLINUX/lib/sources" 
POL_SetupWindow_Init
 
# Patch the game
POL_SetupWindow_message "The patch v1.74 for $TITLE will be downloaded and installed"

cd "$HOME/.PlayOnLinux/ressources"
if [ ! -e Civ4Patch1.74_Final.exe ]; then
  POL_SetupWindow_download "Downloading $TITLE patch 1.74" "Civilization 4 patch 1.74" "http://www.firaxis.com/downloads/Patch/Civ4Patch1.74_Final.exe" 
fi
POL_SetupWindow_wait_next_signal "Patching game..." "$TITLE"
wine Civ4Patch1.74_Final.exe
POL_SetupWindow_detect_exit

POL_SetupWindow_Close
EOF

# Make a short cut
POL_SetupWindow_make_shortcut "$PREFIX" "Program Files/Firaxis Games/Sid Meier's Civilization 4" "Civilization4.exe" "" "$TITLE"
Set_WineVersion_Assign "$WORKINGWINEVERSION" "$TITLE"

# Done!
POL_SetupWindow_message "$TITLE installed"

POL_SetupWindow_Close
exit


NSLW Sunday 16 May 2010 at 21:52
NSLW

Here is the script I wrote to install Civilization IV on PlayOnLinux. After this script was finished I noticed there was already an unsupported version with French comments. So I am sorry for the duplicated work. Feel free to submit this to your repository if you like it.

Quote from marco_g

There is no official script for Civilization IV so I think this could be candidate for it.

The installer installs the game as one might expect. To patch the game, you will have to do that via "Configure this application" which will download the patch and install it.

Quote from marco_g

It would be better if you create separate script for that. From some time we've got new category in POL named patches.

Is this the right way to submit scripts? Is there a VC repository or a mailinglist?

Quote from marco_g

It's OK to post scripts here. There is no mailing list.

If something has to be improved or added, please tell me.

Quote from marco_g

You should download Wine after checking if the user has correct DVD.
You should use PROGRAMFILES variable instead of Program Files
You should use WINEPREFIX variable instead of PREFIXDIR. Variable is available after select_prefix
marco_g Monday 17 May 2010 at 18:02
marco_gAnonymous

Thank you for your fast reply. Here are two scripts, one to install Civilization IV and one to patch it to version 1.74 of the game. All issues have been fixed. Please let me know if something has to be changed.

To install the game:

#!/bin/bash
# Date : (2010-05-16)
# Last revision : (2010-05-16)
# Wine version used : 1.1.43
# Distribution used to test : Ubuntu 9.10
# Author : Marco Gerards
# Licence : GPLv3
# Depend : d3dx9, msxml3

# This script was tested using the DVD version of `Civilization IV'
# version 1.61, bought in the Netherlands in 2010.

[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"

TITLE="Civilization IV"
AUTHOR="Marco Gerards"
PREFIX="Civilization4"
PREFIXDIR="$HOME/.PlayOnLinux/wineprefix/$PREFIX"
WORKINGWINEVERSION="1.1.43"

POL_SetupWindow_Init

POL_SetupWindow_presentation "$TITLE" "Firaxis Games" "http://www.firaxis.com/" "$AUTHOR" "$PREFIX"
select_prefix "$PREFIXDIR"

# Let the user select a CDROM
POL_SetupWindow_cdrom

# Check if this CDROM is the Civilization IV CDROM
POL_SetupWindow_check_cdrom "/Autorun/Civ4Installer.ico"

# Make sure the right wine version is used, otherwise
# the user will run into a problem regarding copyright protection.
POL_SetupWindow_install_wine "$WORKINGWINEVERSION"

Use_WineVersion "$WORKINGWINEVERSION"

# Create the prefix for Civilization IV, a directory called `Civilization4'
POL_SetupWindow_prefixcreate

PROGRAMFILES="Program Files" 
POL_LoadVar_PROGRAMFILES

# Install DirectX9
POL_Call POL_Install_d3dx9

# Run the installer
wine start /unix "$CDROM/setup.exe"
POL_SetupWindow_message "Running installer\\nClick next when the installer is finished"

# Setup an icon for the game
cd "$WINEPREFIX/drive_c/$PROGRAMFILES/Firaxis Games/Sid Meier's Civilization 4/Assets/res"
convert Civ4Game.ico Civ4Game.png
cp Civ4Game-1.png "$HOME/.PlayOnLinux/icones/32/$TITLE"

# Install MS XML 3, this should be done after the game is installed,
# otherwise it will not work.
POL_Call POL_Install_msxml3

# Make a short cut
POL_SetupWindow_make_shortcut "$PREFIX" "$PROGRAMFILES/Firaxis Games/Sid Meier's Civilization 4" "Civilization4.exe" "" "$TITLE"
Set_WineVersion_Assign "$WORKINGWINEVERSION" "$TITLE"

# Done!
POL_SetupWindow_message "$TITLE installed"

POL_SetupWindow_Close
exit


To patch the game:

if [ "$PLAYONLINUX" = "" ]
then
  exit 0
fi
source "$PLAYONLINUX/lib/sources" 

TITLE="Civilization IV patch 1.74"
AUTHOR="Marco Gerards"
PREFIX="Civilization4"
PREFIXDIR="$HOME/.PlayOnLinux/wineprefix/$PREFIX"
WORKINGWINEVERSION="1.1.43"

POL_SetupWindow_Init

verifier_installation_e "$PREFIX"
POL_SetupWindow_presentation "$TITLE" "Firaxis Games" "http://www.firaxis.com/" "$AUTHOR" "$PREFIX"
select_prefix "$PREFIXDIR"
Use_WineVersion "$WORKINGWINEVERSION"

# Patch the game
POL_SetupWindow_message "The patch v1.74 for $TITLE will be downloaded and installed"

cd "$HOME/.PlayOnLinux/ressources"
if [ ! -e Civ4Patch1.74_Final.exe ]; then
  POL_SetupWindow_download "Downloading $TITLE" "$TITLE
" "http://www.firaxis.com/downloads/Patch/Civ4Patch1.74_Final.exe" 
fi
POL_SetupWindow_wait_next_signal "Patching game..." "$TITLE"
wine Civ4Patch1.74_Final.exe
POL_SetupWindow_detect_exit

POL_SetupWindow_Close

Berillions Monday 17 May 2010 at 22:50
Berillions

Hello marco_go

Use this :
POL_SetupWindow_checkexist()
{	
	if [ ! -e $REPERTOIRE/wineprefix/$1 ]; then
		if [ "$POL_LANG" == "fr" ]; then
			LNG_PREFIX_NOT_EXIST="Le jeu n'est pas installé."
		else
			LNG_PREFIX_NOT_EXIST="The Game is not installed."
		fi
		POL_SetupWindow_message_image "$LNG_PREFIX_NOT_EXIST" "Prefix Checker" "$PLAYONLINUX/themes/tango/warning.png"
		exit
	fi
}
 
POL_SetupWindow_checkexist "$PREFIX"


Instead of :
verifier_installation_e "$PREFIX"


And other question. How many DVD this game have?
If one DVD, you don't need to use wine start /unix "$CDROM/setup.exe". Only if the game has more than 1 DVD.

Edited by Berillions


marco_g Tuesday 18 May 2010 at 8:06
marco_gAnonymous


And other question. How many DVD this game have?
If one DVD, you don't need to use wine start /unix "$CDROM/setup.exe". Only if the game has more than 1 DVD.

Quote from Berillions


The version I have has one DVD. However, according to Wikipedia, there are versions with 2 CDROMS. Thus it might help if someone tests this script for the CDROM version and post results, or send me an e-mail.

One more small issue, which is more general. When I run Use_Wineversion, Wine wants to install Gecko and fails since it hangs on downloading. It seems like there is nothing I can do about this. If the user clicks cancel, the installer continues. Civilization 4 does not require Gecko.

Here is the new version of the patching script:

if [ "$PLAYONLINUX" = "" ]
then
  exit 0
fi
source "$PLAYONLINUX/lib/sources" 

TITLE="Civilization IV patch 1.74"
AUTHOR="Marco Gerards"
PREFIX="Civilization4"
PREFIXDIR="$HOME/.PlayOnLinux/wineprefix/$PREFIX"
WORKINGWINEVERSION="1.1.43"

POL_SetupWindow_Init

POL_SetupWindow_checkexist()
{	
	if [ ! -e $REPERTOIRE/wineprefix/$1 ]; then
		if [ "$POL_LANG" == "fr" ]; then
			LNG_PREFIX_NOT_EXIST="Le jeu n'est pas installé."
		else
			LNG_PREFIX_NOT_EXIST="The Game is not installed."
		fi
		POL_SetupWindow_message_image "$LNG_PREFIX_NOT_EXIST" "Prefix Checker" "$PLAYONLINUX/themes/tango/warning.png"
		exit
	fi
}
 
POL_SetupWindow_checkexist "$PREFIX"

POL_SetupWindow_presentation "$TITLE" "Firaxis Games" "http://www.firaxis.com/" "$AUTHOR" "$PREFIX"
select_prefix "$PREFIXDIR"
Use_WineVersion "$WORKINGWINEVERSION"

# Patch the game
POL_SetupWindow_message "The patch v1.74 for $TITLE will be downloaded and installed"

cd "$HOME/.PlayOnLinux/ressources"
if [ ! -e Civ4Patch1.74_Final.exe ]; then
  POL_SetupWindow_download "Downloading $TITLE" "$TITLE
" "http://www.firaxis.com/downloads/Patch/Civ4Patch1.74_Final.exe" 
fi
POL_SetupWindow_wait_next_signal "Patching game..." "$TITLE"
wine Civ4Patch1.74_Final.exe
POL_SetupWindow_detect_exit

POL_SetupWindow_Close

NSLW Tuesday 18 May 2010 at 9:39
NSLW

The version I have has one DVD. However, according to Wikipedia, there are versions with 2 CDROMS. Thus it might help if someone tests this script for the CDROM version and post results, or send me an e-mail.

Quote from marco_g

If the game is distributed on various kind of medias you could resolve that by asking user about what version he has as it was done here

One more small issue, which is more general. When I run Use_Wineversion, Wine wants to install Gecko and fails since it hangs on downloading. It seems like there is nothing I can do about this. If the user clicks cancel, the installer continues. Civilization 4 does not require Gecko.

Quote from marco_g

Wine always asks about gecko at prefix creation. For me that is a unwise decision made by Wine developers and I think you cannot do anything about it now. I think that it could be fixed in POL code.
marco_g Tuesday 18 May 2010 at 9:58
marco_gAnonymous

The version I have has one DVD. However, according to Wikipedia, there are versions with 2 CDROMS. Thus it might help if someone tests this script for the CDROM version and post results, or send me an e-mail.

Quote from NSLW

If the game is distributed on various kind of medias you could resolve that by asking user about what version he has as it was done here

Quote from marco_g


Unfortunately, I do not have the CDROM version. What do you prefer? Simply using `wine "$CDROM/setup.exe"'? If someone wants support for the CDROM version it can be added later. I do not think it is very useful to add support for something based on speculations only. Perhaps it might be possible to detect if a DVD or CDROM is used. For instance, the file data2.cab is >1GB on the DVD. Although there might be better clues which can be used. I can also add the code you mentioned, but I am not sure if it will make sense or work at all.
NSLW Tuesday 18 May 2010 at 15:29
NSLW

Adding speculated CD support doesn't change anything for user with DVD and it can help user with CD to switch disks during installation. It's unlikely that CD version has other setup executable than DVD version so it's only about facilitating disk change.
marco_g Tuesday 18 May 2010 at 16:25
marco_gAnonymous

Adding speculated CD support doesn't change anything for user with DVD and it can help user with CD to switch disks during installation. It's unlikely that CD version has other setup executable than DVD version so it's only about facilitating disk change.

Quote from NSLW


Right and at does not break anything for me :). I have added the feature you suggested, see the script below. If I find the CDROM version of this game sometime, I might consider adding an autodetection feature if it is appreciated. However, I doubt it will happen soon.

#!/bin/bash
# Date : (2010-05-16)
# Last revision : (2010-05-18)
# Wine version used : 1.1.43
# Distribution used to test : Ubuntu 9.10
# Author : Marco Gerards
# Licence : GPLv3
# Depend : d3dx9, msxml3

# This script was tested using the DVD version of `Civilization IV'
# version 1.61, bought in the Netherlands in 2010.

[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"

TITLE="Civilization IV"
AUTHOR="Marco Gerards"
PREFIX="Civilization4"
PREFIXDIR="$HOME/.PlayOnLinux/wineprefix/$PREFIX"
WORKINGWINEVERSION="1.1.43"

POL_SetupWindow_Init

POL_SetupWindow_presentation "$TITLE" "Firaxis Games" "http://www.firaxis.com/" "$AUTHOR" "$PREFIX"
select_prefix "$PREFIXDIR"

# Let the user select a CDROM
POL_SetupWindow_cdrom

# Check if this CDROM is the Civilization IV CDROM
POL_SetupWindow_check_cdrom "/Autorun/Civ4Installer.ico"

# Make sure the right wine version is used, otherwise
# the user will run into a problem regarding copyright protection.
POL_SetupWindow_install_wine "$WORKINGWINEVERSION"

Use_WineVersion "$WORKINGWINEVERSION"

# Create the prefix for Civilization IV, a directory called `Civilization4'
POL_SetupWindow_prefixcreate

PROGRAMFILES="Program Files" 
POL_LoadVar_PROGRAMFILES

# Install DirectX9
POL_Call POL_Install_d3dx9

# Run the installer
POL_SetupWindow_menu "Which installation medium do you want to use?" "Medium" "DVD~CDROM" "~"
wine start /unix "$CDROM/setup.exe"
if [ "$APP_ANSWER" == "CDROM" ]; then
POL_SetupWindow_message "When the installer asks you for the second CDROM, click Forward." "$TITLE"
wine eject
fi

POL_SetupWindow_message "Click Forward when the installation is finished" "$TITLE"
wine eject

# Setup an icon for the game
cd "$WINEPREFIX/drive_c/$PROGRAMFILES/Firaxis Games/Sid Meier's Civilization 4/Assets/res"
convert Civ4Game.ico Civ4Game.png
cp Civ4Game-1.png "$HOME/.PlayOnLinux/icones/32/$TITLE"

# Install MS XML 3, this should be done after the game is installed,
# otherwise it will not work.
POL_Call POL_Install_msxml3

# Make a short cut
POL_SetupWindow_make_shortcut "$PREFIX" "$PROGRAMFILES/Firaxis Games/Sid Meier's Civilization 4" "Civilization4.exe" "" "$TITLE"
Set_WineVersion_Assign "$WORKINGWINEVERSION" "$TITLE"

# Done!
POL_SetupWindow_message "$TITLE installed"

POL_SetupWindow_Close
exit

NSLW Tuesday 18 May 2010 at 18:06
NSLW

I think you can send this script to validation so I could add it to official database.

Edited by NSLW

marco_g Tuesday 18 May 2010 at 18:48
marco_gAnonymous

I think you can send this script to validation so I could add it to official database.

Quote from NSLW


Sorry, what do you mean by that? Do I have to post the script elsewhere? This is my first script, so I do not know all the procedures yet. If I missed something in the documentation, can you please refer me to it?
NSLW Tuesday 18 May 2010 at 19:47
NSLW

You need to go here Click on Add a new script and send your script for validation after pasting it in right fields.
marco_g Tuesday 18 May 2010 at 20:06
marco_gAnonymous

You need to go here Click on Add a new script and send your script for validation after pasting it in right fields.

Quote from NSLW


Thanks, I have done this. Unfortunately it was not possible to call the script "Civilization 4" or "Civilization IV". I have called the script "Civilization4" (without the space). When sending in the script for the patch, I did not encounter such problems (it was possible to include a space). Can you see what went wrong, or is it ok this way?
marco_g Tuesday 18 May 2010 at 20:45
marco_gAnonymous

You need to go here Click on Add a new script and send your script for validation after pasting it in right fields.

Quote from marco_g


Thanks, I have done this. Unfortunately it was not possible to call the script "Civilization 4" or "Civilization IV". I have called the script "Civilization4" (without the space). When sending in the script for the patch, I did not encounter such problems (it was possible to include a space). Can you see what went wrong, or is it ok this way?

Quote from NSLW


Correction: I did not send in the scripts for validation yet. I will do that after I am able to change the name of the script, Most likely some other script is available with the same name? If the name "Civilization4" is ok or can be changed by the maintainer, I will send it in now.
NSLW Wednesday 19 May 2010 at 7:42
NSLW

There were scripts with that name but I removed them but It seems that they cause troubles again. I'll post message to Tinou (other admin) to fix this.
marco_g Sunday 23 May 2010 at 11:00
marco_gAnonymous

There were scripts with that name but I removed them but It seems that they cause troubles again. I'll post message to Tinou (other admin) to fix this.

Quote from NSLW


I forgot to mention that I succeeded in sending in this script for validation.
MrLeek Saturday 17 December 2011 at 21:23
MrLeekAnonymous

So did this installer script ever make it past beta? I can see the patch script made it, but the install script remains stuck in beta.

Probably a good thing to be honest given that the test to make sure the DVD is in the drive doesn't work (the code looks spot on, it just doesn't like it). Before I dive into this (after Christmas job most likely) where are we on this? Is marco still around?

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