1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-09 01:06:07 +02:00

- fixed incorrect appearence of hero in battle

- vcmibuilder works with spaces in filenames
- by default output directory for vcmibuilder is ~/.vcmi
This commit is contained in:
Ivan Savenko
2013-02-09 12:34:49 +00:00
parent 0003d30991
commit a269b22741
2 changed files with 48 additions and 44 deletions

View File

@ -256,9 +256,9 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
{ {
std::string battleImage; std::string battleImage;
if ( hero2->sex ) if ( hero2->sex )
battleImage = hero1->type->heroClass->imageBattleFemale; battleImage = hero2->type->heroClass->imageBattleFemale;
else else
battleImage = hero1->type->heroClass->imageBattleMale; battleImage = hero2->type->heroClass->imageBattleMale;
defendingHero = new CBattleHero(battleImage, true, hero2->tempOwner, hero2->tempOwner == curInt->playerID ? hero2 : NULL, this); defendingHero = new CBattleHero(battleImage, true, hero2->tempOwner, hero2->tempOwner == curInt->playerID ? hero2 : NULL, this);
defendingHero->pos = genRect(defendingHero->dh->ourImages[0].bitmap->h, defendingHero->dh->ourImages[0].bitmap->w, pos.x + 693, pos.y - 19); defendingHero->pos = genRect(defendingHero->dh->ourImages[0].bitmap->h, defendingHero->dh->ourImages[0].bitmap->w, pos.x + 693, pos.y - 19);

View File

@ -27,6 +27,7 @@ do
--cd2) cd2_dir=$2 ; shift 2 ;; --cd2) cd2_dir=$2 ; shift 2 ;;
--gog) gog_file=$2 ; shift 2 ;; --gog) gog_file=$2 ; shift 2 ;;
--data) data_dir=$2 ; shift 2 ;; --data) data_dir=$2 ; shift 2 ;;
--dest) dest_dir=$2 ; shift 2 ;;
--wog) wog_archive=$2 ; shift 2 ;; --wog) wog_archive=$2 ; shift 2 ;;
--vcmi) vcmi_archive=$2 ; shift 2 ;; --vcmi) vcmi_archive=$2 ; shift 2 ;;
--download) download=true ; shift 1 ;; --download) download=true ; shift 1 ;;
@ -59,8 +60,10 @@ then
echo " --download " "If specified vcmibuilder will download packages using wget" echo " --download " "If specified vcmibuilder will download packages using wget"
echo " " "Requires wget and Internet connection" echo " " "Requires wget and Internet connection"
echo echo
echo " --dest DIRECTORY " "Path where resulting data will be placed. Default is ~/.vcmi"
echo
echo " --validate " "If specified vcmibuilder will run basic validness checks" echo " --validate " "If specified vcmibuilder will run basic validness checks"
exit 1 exit 0
fi fi
# test presence of program $1, $2 will be passed as parameters to test presence # test presence of program $1, $2 will be passed as parameters to test presence
@ -74,6 +77,8 @@ fail ()
{ {
$2 $2
echo "$1" 1>&2 echo "$1" 1>&2
rm -rf "$temp_dir"
exit 1 exit 1
} }
@ -114,7 +119,7 @@ if [[ -n "$download" ]]
then then
if [[ -n "$wog_archive" ]] && [[ -n "$vcmi_archive" ]] if [[ -n "$wog_archive" ]] && [[ -n "$vcmi_archive" ]]
then then
warning "Warning: Both wog and vcmi options were specified. Download option will not be used" warning "Warning: Both wog and vcmi archives were specified. Download option will not be used"
unset download unset download
else else
test_utility "wget" "-V" test_utility "wget" "-V"
@ -147,27 +152,36 @@ then
fi fi
fi fi
if [[ -z "$dest_dir" ]]
then
dest_dir="$HOME/.vcmi"
fi
temp_dir="$dest_dir"/buildertmp
# start installation # start installation
dest_dir="./vcmi" mkdir -p "$dest_dir"
mkdir -p $dest_dir mkdir -p "$temp_dir"
if [[ -n "$gog_file" ]] if [[ -n "$gog_file" ]]
then then
data_dir="./app"
# innoextract always reports error (iconv 84 error). Just test file for presence # innoextract always reports error (iconv 84 error). Just test file for presence
test -f $gog_file || fail "Error: gog.com executable was not found!" test -f "$gog_file" || fail "Error: gog.com executable was not found!"
innoextract -s -p 1 $gog_file innoextract -s -p 1 "$gog_file"
mv ./app "$temp_dir"
data_dir="$temp_dir"/app
fi fi
if [[ -n "$cd1_dir" ]] if [[ -n "$cd1_dir" ]]
then then
data_dir="./cddir" data_dir="$temp_dir"/cddir
mkdir -p "$data_dir" mkdir -p "$data_dir"
unshield -d "$data_dir" x $cd1_dir/_setup/data1.cab || fail "Error: failed to extract from Install Shield installer!" "rm -rf ./cddir" unshield -d "$data_dir" x "$cd1_dir"/_setup/data1.cab || fail "Error: failed to extract from Install Shield installer!" "rm -rf $data_dir"
# a bit tricky - different releases have different root directory. Move extracted files to data_dir # a bit tricky - different releases have different root directory. Move extracted files to data_dir
if [ -d "$data_dir"/"Heroes3" ] if [ -d "$data_dir"/Heroes3 ]
then then
mv "$data_dir"/Heroes3/* "$data_dir" mv "$data_dir"/Heroes3/* "$data_dir"
elif [ -d "$data_dir""/Program_Files" ] elif [ -d "$data_dir""/Program_Files" ]
@ -184,30 +198,30 @@ fi
if [[ -n "$cd2_dir" ]] if [[ -n "$cd2_dir" ]]
then then
mkdir -p $dest_dir/Data mkdir -p "$dest_dir"/Data
if [ -d $cd2_dir/heroes3 ] if [ -d "$cd2_dir"/heroes3 ]
then then
cp $cd2_dir/heroes3/Data/Heroes3.vid $dest_dir/Data/VIDEO.VID cp "$cd2_dir"/heroes3/Data/Heroes3.vid "$dest_dir"/Data/VIDEO.VID
cp $cd2_dir/heroes3/Data/Heroes3.snd $dest_dir/Data/Heroes3-cd2.snd cp "$cd2_dir"/heroes3/Data/Heroes3.snd "$dest_dir"/Data/Heroes3-cd2.snd
else else
cp $cd2_dir/Heroes3/Data/Heroes3.vid $dest_dir/Data/VIDEO.VID cp "$cd2_dir"/Heroes3/Data/Heroes3.vid "$dest_dir"/Data/VIDEO.VID
cp $cd2_dir/Heroes3/Data/Heroes3.snd $dest_dir/Data/Heroes3-cd2.snd cp "$cd2_dir"/Heroes3/Data/Heroes3.snd "$dest_dir"/Data/Heroes3-cd2.snd
fi fi
fi fi
if [[ -n "$data_dir" ]] if [[ -n "$data_dir" ]]
then then
cp -r "$data_dir"/Data $dest_dir cp -r "$data_dir"/Data "$dest_dir"
cp -r "$data_dir"/Maps $dest_dir cp -r "$data_dir"/Maps "$dest_dir"
# this folder is named differently from time to time # this folder is named differently from time to time
# vcmi can handle any case but script can't # vcmi can handle any case but script can't
if [ -d "$data_dir"/MP3 ] if [ -d "$data_dir"/MP3 ]
then then
cp -r "$data_dir"/MP3 $dest_dir cp -r "$data_dir"/MP3 "$dest_dir"
else else
cp -r "$data_dir"/Mp3 $dest_dir cp -r "$data_dir"/Mp3 "$dest_dir"
fi fi
fi fi
@ -215,46 +229,36 @@ if [[ -n "$download" ]]
then then
if [[ -z "$wog_archive" ]] if [[ -z "$wog_archive" ]]
then then
wget "http://download.vcmi.eu/WoG/wog.zip" -O wog.zip || fail "Error: failed to download WoG archive!" "rm -f wog.zip" wget "http://download.vcmi.eu/WoG/wog.zip" -O "$temp_dir"/wog.zip || fail "Error: failed to download WoG archive!" "rm -f wog.zip"
wog_archive="./wog.zip" wog_archive="$temp_dir"/wog.zip
fi fi
if [[ -z "$vcmi_archive" ]] if [[ -z "$vcmi_archive" ]]
then then
wget "http://download.vcmi.eu/core.zip" -O core.zip || fail "Error: failed to download VCMI archive!" "rm -f core.zip" wget "http://download.vcmi.eu/core.zip" -O "$temp_dir"/core.zip || fail "Error: failed to download VCMI archive!" "rm -f core.zip"
vcmi_archive="./core.zip" vcmi_archive="$temp_dir"/core.zip
fi fi
fi fi
if [[ -n "$wog_archive" ]] if [[ -n "$wog_archive" ]]
then then
echo "decompressing $wog_archive" echo "decompressing $wog_archive"
unzip -qo $wog_archive -d $dest_dir || fail "Error: failed to extract WoG archive!" unzip -qo "$wog_archive" -d "$dest_dir" || fail "Error: failed to extract WoG archive!"
fi fi
if [[ -n "$vcmi_archive" ]] if [[ -n "$vcmi_archive" ]]
then then
echo "decompressing $vcmi_archive" echo "decompressing $vcmi_archive"
# exlude *json - temporary solution for autotools -> cmake transition period unzip -qo "$vcmi_archive" -d "$dest_dir" || fail "Error: failed to extract VCMI archive!"
# 0.90 packages made by autotools do not have .json files available in svn
# cmake however can install them correctly so they should not be extracted from .zip in case of cmake package
unzip -qo $vcmi_archive -d $dest_dir -x "*.json" "*.txt" "*.PAL" || fail "Error: failed to extract VCMI archive!"
fi fi
if [[ -n "$validate" ]] if [[ -n "$validate" ]]
then then
test -f $dest_dir/Data/H3bitmap.lod || fail "Error: Heroes 3 data files are missing!" test -f "$dest_dir"/Data/H3bitmap.lod || fail "Error: Heroes 3 data files are missing!"
test -f $dest_dir/Data/H3sprite.lod || fail "Error: Heroes 3 data files are missing!" test -f "$dest_dir"/Data/H3sprite.lod || fail "Error: Heroes 3 data files are missing!"
test -f $dest_dir/Data/VIDEO.VID || fail "Error: Heroes 3 data files (CD2) are missing!" test -f "$dest_dir"/Data/VIDEO.VID || fail "Error: Heroes 3 data files (CD2) are missing!"
test -d $dest_dir/Mods/WoG/Data || fail "Error: WoG data files are missing!" test -d "$dest_dir"/Mods/WoG/Data || fail "Error: WoG data files are missing!"
test -d $dest_dir/Mods/vcmi/Data || fail "Error: VCMI data files are missing!" test -d "$dest_dir"/Mods/vcmi/Data || fail "Error: VCMI data files are missing!"
fi fi
#TODO: Cleanup? How? rm -rf "$temp_dir"
echo
echo "vcmibuilder finished succesfully"
echo "resulting data was placed into $PWD/vcmi"
echo "any other files in current directory can be removed"
echo