update to fheroes2 0.9.18, based on diff from paco@. Note updated instructions in README
This commit is contained in:
parent
41f4d78256
commit
3979b2d96c
@ -2,11 +2,10 @@ COMMENT = engine recreation for Heroes of Might and Magic 2
|
||||
|
||||
GH_ACCOUNT = ihhub
|
||||
GH_PROJECT = fheroes2
|
||||
GH_TAGNAME = 0.9.14
|
||||
GH_TAGNAME = 0.9.18
|
||||
CATEGORIES = games
|
||||
HOMEPAGE = https://ihhub.github.io/fheroes2/
|
||||
MAINTAINER = Thomas Frohwein <thfr@openbsd.org>
|
||||
REVISION = 0
|
||||
|
||||
# GPLv2.0+, LGPLv2.1+ (src/thirdparty/libsmacker)
|
||||
PERMIT_PACKAGE = Yes
|
||||
@ -22,6 +21,7 @@ LIB_DEPENDS = devel/sdl2-mixer
|
||||
MAKE_FLAGS += FHEROES2_DATA=${PREFIX}/share/fheroes2
|
||||
USE_GMAKE = Yes
|
||||
NO_TEST = Yes
|
||||
PATCHORIG = .orig.port
|
||||
|
||||
# needs gsed
|
||||
do-gen:
|
||||
@ -30,7 +30,6 @@ do-gen:
|
||||
|
||||
do-install:
|
||||
${INSTALL_DATA_DIR} ${PREFIX}/share/fheroes2/files/data
|
||||
${INSTALL_DATA} ${WRKSRC}/fheroes2.key ${PREFIX}/share/fheroes2/
|
||||
${INSTALL_DATA} ${WRKSRC}/files/data/resurrection.h2d \
|
||||
${PREFIX}/share/fheroes2/files/data/
|
||||
${INSTALL_DATA_DIR} ${PREFIX}/share/fheroes2/files/lang
|
||||
@ -39,5 +38,7 @@ do-install:
|
||||
${INSTALL_PROGRAM} ${WRKBUILD}/fheroes2 ${PREFIX}/bin/
|
||||
${INSTALL_SCRIPT} ${WRKBUILD}/script/demo/download_demo_version.sh \
|
||||
${PREFIX}/share/fheroes2/download_demo_version.sh
|
||||
${INSTALL_SCRIPT} ${WRKBUILD}/script/homm2/extract_homm2_resources.sh \
|
||||
${PREFIX}/share/fheroes2/extract_homm2_resources.sh
|
||||
|
||||
.include <bsd.port.mk>
|
||||
|
@ -1,2 +1,2 @@
|
||||
SHA256 (fheroes2-0.9.14.tar.gz) = VTL6hEO42PVPz8VmKPECBHCtIV4SKF14yEUOSeqZRL4=
|
||||
SIZE (fheroes2-0.9.14.tar.gz) = 3628240
|
||||
SHA256 (fheroes2-0.9.18.tar.gz) = vNmvznuGljD5fP23E2aPD33M9p/Gsx2xynSsL2NSSo0=
|
||||
SIZE (fheroes2-0.9.18.tar.gz) = 5117381
|
||||
|
@ -3,7 +3,7 @@ also build translation files (*.mo)
|
||||
Index: Makefile
|
||||
--- Makefile.orig
|
||||
+++ Makefile
|
||||
@@ -37,6 +37,7 @@ PROJECT_VERSION := 0.9.14
|
||||
@@ -37,6 +37,7 @@ PROJECT_VERSION := $(file < version.txt)
|
||||
|
||||
all:
|
||||
$(MAKE) -C src
|
||||
|
@ -1,60 +0,0 @@
|
||||
used UTF-8 so that sed doesn't fail because of different string lengths
|
||||
add in missing instructions for languages (hu, lt, nl, sv, pt, tr)
|
||||
|
||||
Index: files/lang/Makefile
|
||||
--- files/lang/Makefile.orig
|
||||
+++ files/lang/Makefile
|
||||
@@ -31,14 +31,14 @@ merge:
|
||||
# Spanish: drop accents transliterated with `"` (which breaks translation file format)
|
||||
# and transliterate the rest using the es_ES.UTF-8 locale
|
||||
es.mo: es.po
|
||||
- sed -e 'y/äëïöőüűÄËÏŐÖÜŰ/aeioouuAEIOOUU/' $< > $<.tmp
|
||||
+ LANG=es_ES.UTF-8 LC_CTYPE=es_ES.UTF-8 sed -e 'y/äëïöőüűÄËÏŐÖÜŰ/aeioouuAEIOOUU/' $< > $<.tmp
|
||||
LANG=es_ES.UTF-8 LC_ALL=es_ES.UTF-8 LC_CTYPE=es_ES.UTF-8 iconv -f utf-8 -t ascii//TRANSLIT $<.tmp > $<.2.tmp
|
||||
msgfmt $<.2.tmp -o $@
|
||||
|
||||
# In French, accented characters are mapped to unused ASCII characters
|
||||
# Non-mapped characters are replaced by their non-accented equivalents
|
||||
fr.mo: fr.po
|
||||
- sed -e 'y/àâçéèêîïôùûüÉÊÀ/@*^~`|><#&$$uEEA/' $< > $<.tmp
|
||||
+ LANG=fr_FR.UTF-8 LC_CTYPE=fr_FR.UTF-8 sed -e 'y/àâçéèêîïôùûüÉÊÀ/@*^~`|><#&$$uEEA/' $< > $<.tmp
|
||||
sed -i~ -e 's/œ/oe/g' $<.tmp
|
||||
msgfmt $<.tmp -o $@
|
||||
|
||||
@@ -78,6 +78,36 @@ nb.mo: nb.po
|
||||
it.mo: it.po
|
||||
iconv -f utf-8 -t CP1252 $< > $<.tmp
|
||||
LANG=it.CP1252 LC_ALL=it.CP1252 LC_CTYPE=it.CP1252 sed -e 's/UTF-8/CP1252/' $<.tmp > $<.2.tmp
|
||||
+ msgfmt $<.2.tmp -o $@
|
||||
+
|
||||
+hu.mo: hu.po
|
||||
+ LANG=hu_HU.UTF-8 LC_ALL=hu_HU.UTF-8 LC_CTYPE=hu_HU.UTF-8 sed -e 'y/äëïöőüűÄËÏŐÖÜŰ/aeioouuAEIOOUU/' $< > $<.tmp
|
||||
+ iconv -f utf-8 -t ascii//TRANSLIT $<.tmp > $<.2.tmp
|
||||
+ msgfmt $<.2.tmp -o $@
|
||||
+
|
||||
+lt.mo: lt.po
|
||||
+ LANG=lt_LT.UTF-8 LC_ALL=lt_LT.UTF-8 LC_CTYPE=lt_LT.UTF-8 sed -e 'y/äëïöőüűÄËÏŐÖÜŰ/aeioouuAEIOOUU/' $< > $<.tmp
|
||||
+ iconv -f utf-8 -t ascii//TRANSLIT $<.tmp > $<.2.tmp
|
||||
+ msgfmt $<.2.tmp -o $@
|
||||
+
|
||||
+nl.mo: nl.po
|
||||
+ LANG=nl_NL.UTF-8 LC_ALL=nl_NL.UTF-8 LC_CTYPE=nl_NL.UTF-8 sed -e 'y/äëïöőüűÄËÏŐÖÜŰ/aeioouuAEIOOUU/' $< > $<.tmp
|
||||
+ iconv -f utf-8 -t ascii//TRANSLIT $<.tmp > $<.2.tmp
|
||||
+ msgfmt $<.2.tmp -o $@
|
||||
+
|
||||
+sv.mo: sv.po
|
||||
+ LANG=sv_SV.UTF-8 LC_ALL=sv_SV.UTF-8 LC_CTYPE=sv_SV.UTF-8 sed -e 'y/äëïöőüűÄËÏŐÖÜŰ/aeioouuAEIOOUU/' $< > $<.tmp
|
||||
+ iconv -f utf-8 -t ascii//TRANSLIT $<.tmp > $<.2.tmp
|
||||
+ msgfmt $<.2.tmp -o $@
|
||||
+
|
||||
+pt.mo: pt.po
|
||||
+ LANG=pt_PT.UTF-8 LC_ALL=pt_PT.UTF-8 LC_CTYPE=pt_PT.UTF-8 sed -e 'y/äëïöőüűÄËÏŐÖÜŰ/aeioouuAEIOOUU/' $< > $<.tmp
|
||||
+ iconv -f utf-8 -t ascii//TRANSLIT $<.tmp > $<.2.tmp
|
||||
+ msgfmt $<.2.tmp -o $@
|
||||
+
|
||||
+tr.mo: tr.po
|
||||
+ LANG=tr_TR.UTF-8 LC_ALL=tr_TR.UTF-8 LC_CTYPE=tr_TR.UTF-8 sed -e 'y/äëïöőüűÄËÏŐÖÜŰ/aeioouuAEIOOUU/' $< > $<.tmp
|
||||
+ iconv -f utf-8 -t ascii//TRANSLIT $<.tmp > $<.2.tmp
|
||||
msgfmt $<.2.tmp -o $@
|
||||
|
||||
# All other languages: drop accents transliterated with `"` (which breaks translation file format)
|
@ -7,7 +7,7 @@ Index: script/demo/download_demo_version.sh
|
||||
|
||||
set -e
|
||||
|
||||
@@ -58,12 +58,12 @@ else
|
||||
@@ -60,12 +60,12 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -21,5 +21,5 @@ Index: script/demo/download_demo_version.sh
|
||||
+elif [[ "$(command -v sha256)" != "" ]]; then
|
||||
+ sha256 -C checksums h2demo.zip
|
||||
else
|
||||
echo_red "shasum or sha256sum not found in your system. Unable to verify downloaded file. Installation aborted."
|
||||
echo_red "Neither shasum nor sha256sum were found in your system. Unable to verify the downloaded file. Installation aborted."
|
||||
exit 1
|
||||
|
@ -0,0 +1,26 @@
|
||||
use python3 binary in the helper script because not all users will have set a
|
||||
python symlink
|
||||
|
||||
Index: script/homm2/extract_homm2_resources.sh
|
||||
--- script/homm2/extract_homm2_resources.sh.orig
|
||||
+++ script/homm2/extract_homm2_resources.sh
|
||||
@@ -82,8 +82,8 @@ if [[ ! -f "$HOMM2_PATH/homm2.gog" ]]; then
|
||||
fi
|
||||
|
||||
# Special case - CD image from GOG
|
||||
-if [[ "$(command -v python)" == "" ]]; then
|
||||
- echo_yellow "python was not found in your system. Please install it and re-run this script to extract animation resources."
|
||||
+if [[ "$(command -v python3)" == "" ]]; then
|
||||
+ echo_yellow "python3 was not found in your system. Please install it and re-run this script to extract animation resources."
|
||||
exit 0
|
||||
fi
|
||||
if [[ "$(command -v bsdtar)" == "" ]]; then
|
||||
@@ -93,7 +93,7 @@ fi
|
||||
|
||||
echo_green "Extracting animation resources, please wait..."
|
||||
|
||||
-python - << EOF
|
||||
+python3 - << EOF
|
||||
with open("$HOMM2_PATH/homm2.gog", "rb") as raw_file:
|
||||
with open("homm2.iso", "wb") as iso_file:
|
||||
while True:
|
@ -4,7 +4,7 @@ use bsd platform path
|
||||
Index: src/Makefile
|
||||
--- src/Makefile.orig
|
||||
+++ src/Makefile
|
||||
@@ -35,8 +35,6 @@ LDFLAGS := -pthread
|
||||
@@ -39,8 +39,6 @@ LDLIBS := $(LDLIBS)
|
||||
|
||||
ifdef FHEROES2_WITH_DEBUG
|
||||
CCFLAGS := $(CCFLAGS) -O0 -g
|
||||
@ -13,7 +13,7 @@ Index: src/Makefile
|
||||
endif
|
||||
|
||||
ifneq ($(or $(FHEROES2_WITH_ASAN),$(FHEROES2_WITH_TSAN)),)
|
||||
@@ -66,6 +64,9 @@ ifeq ($(OS),Windows_NT)
|
||||
@@ -70,6 +68,9 @@ ifeq ($(OS),Windows_NT)
|
||||
PLATFORM := mingw
|
||||
endif
|
||||
ifeq ($(OS),FreeBSD)
|
||||
|
@ -1,163 +0,0 @@
|
||||
Fix failing music file search
|
||||
GH PR 5278
|
||||
|
||||
Index: src/fheroes2/agg/agg.cpp
|
||||
--- src/fheroes2/agg/agg.cpp.orig
|
||||
+++ src/fheroes2/agg/agg.cpp
|
||||
@@ -22,6 +22,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include <algorithm>
|
||||
+#include <array>
|
||||
#include <cassert>
|
||||
#include <condition_variable>
|
||||
#include <map>
|
||||
@@ -33,21 +34,31 @@
|
||||
#include "agg_file.h"
|
||||
#include "audio.h"
|
||||
#include "dir.h"
|
||||
-#include "embedded_image.h"
|
||||
#include "game.h"
|
||||
#include "localevent.h"
|
||||
#include "logging.h"
|
||||
#include "m82.h"
|
||||
#include "mus.h"
|
||||
-#include "screen.h"
|
||||
#include "settings.h"
|
||||
#include "system.h"
|
||||
#include "tools.h"
|
||||
#include "xmi.h"
|
||||
-#include "zzlib.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
+ struct MusicFileType
|
||||
+ {
|
||||
+ explicit MusicFileType( const MUS::EXTERNAL_MUSIC_TYPE type_ )
|
||||
+ : type( type_ )
|
||||
+ {
|
||||
+ // Do nothing.
|
||||
+ }
|
||||
+
|
||||
+ MUS::EXTERNAL_MUSIC_TYPE type = MUS::EXTERNAL_MUSIC_TYPE::WIN_VERSION;
|
||||
+
|
||||
+ std::array<std::string, 3> extension{ ".ogg", ".mp3", ".flac" };
|
||||
+ };
|
||||
+
|
||||
const std::string externalMusicDirectory( "music" );
|
||||
|
||||
std::vector<std::string> getMusicDirectories()
|
||||
@@ -63,46 +74,58 @@ namespace
|
||||
return directories;
|
||||
}
|
||||
|
||||
- std::string getExternalMusicFile( const int musicTrackId, const MUS::EXTERNAL_MUSIC_TYPE musicType, const std::vector<std::string> & directories )
|
||||
+ bool findMusicFile( const std::vector<std::string> & directories, const std::string & fileName, std::string & fullPath )
|
||||
{
|
||||
+ for ( const std::string & dir : directories ) {
|
||||
+ ListFiles musicFilePaths;
|
||||
+ musicFilePaths.ReadDir( dir, fileName, false );
|
||||
+ if ( musicFilePaths.empty() ) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ std::string correctFilePath = System::ConcatePath( dir, fileName );
|
||||
+ correctFilePath = StringLower( correctFilePath );
|
||||
+
|
||||
+ for ( const std::string & path : musicFilePaths ) {
|
||||
+ const std::string temp = StringLower( path );
|
||||
+ if ( temp == correctFilePath ) {
|
||||
+ fullPath = path;
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ std::string getExternalMusicFile( const int musicTrackId, const std::vector<std::string> & directories, MusicFileType & musicType )
|
||||
+ {
|
||||
if ( directories.empty() ) {
|
||||
// Nothing to search.
|
||||
return {};
|
||||
}
|
||||
|
||||
- // Instead of relying some generic functions we want to have maximum performance as I/O operations are the slowest.
|
||||
- std::vector<std::string> possibleFilenames;
|
||||
- possibleFilenames.reserve( directories.size() );
|
||||
+ std::string fullPath;
|
||||
|
||||
- for ( const std::string & dir : directories ) {
|
||||
- possibleFilenames.emplace_back( System::ConcatePath( dir, MUS::getFileName( musicTrackId, musicType, ".flac" ) ) );
|
||||
+ std::string fileName = MUS::getFileName( musicTrackId, musicType.type, musicType.extension[0].c_str() );
|
||||
+ if ( findMusicFile( directories, fileName, fullPath ) ) {
|
||||
+ return fullPath;
|
||||
}
|
||||
|
||||
- // Search for FLAC files as they have the best audio quality.
|
||||
- for ( const std::string & filename : possibleFilenames ) {
|
||||
- if ( System::IsFile( filename ) ) {
|
||||
- return filename;
|
||||
- }
|
||||
+ fheroes2::replaceStringEnding( fileName, musicType.extension[0].c_str(), musicType.extension[1].c_str() );
|
||||
+ if ( findMusicFile( directories, fileName, fullPath ) ) {
|
||||
+ // Swap extensions to improve cache hit.
|
||||
+ std::swap( musicType.extension[0], musicType.extension[1] );
|
||||
+ return fullPath;
|
||||
}
|
||||
|
||||
- // None of FLAC files found. Try OGG files.
|
||||
- for ( std::string & filename : possibleFilenames ) {
|
||||
- fheroes2::replaceStringEnding( filename, ".flac", ".ogg" );
|
||||
-
|
||||
- if ( System::IsFile( filename ) ) {
|
||||
- return filename;
|
||||
- }
|
||||
+ fheroes2::replaceStringEnding( fileName, musicType.extension[1].c_str(), musicType.extension[2].c_str() );
|
||||
+ if ( findMusicFile( directories, fileName, fullPath ) ) {
|
||||
+ // Swap extensions to improve cache hit.
|
||||
+ std::swap( musicType.extension[0], musicType.extension[2] );
|
||||
+ return fullPath;
|
||||
}
|
||||
|
||||
- // No luck with even OGG. Try with MP3.
|
||||
- for ( std::string & filename : possibleFilenames ) {
|
||||
- fheroes2::replaceStringEnding( filename, ".ogg", ".mp3" );
|
||||
-
|
||||
- if ( System::IsFile( filename ) ) {
|
||||
- return filename;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
// Looks like music file does not exist.
|
||||
return {};
|
||||
}
|
||||
@@ -582,13 +605,21 @@ void AGG::PlayMusicInternally( const int mus, const Mu
|
||||
if ( musicType == MUSIC_EXTERNAL ) {
|
||||
const std::vector<std::string> & musicDirectories = getMusicDirectories();
|
||||
|
||||
- std::string filename = getExternalMusicFile( mus, MUS::EXTERNAL_MUSIC_TYPE::DOS_VERSION, musicDirectories );
|
||||
- if ( filename.empty() ) {
|
||||
- filename = getExternalMusicFile( mus, MUS::EXTERNAL_MUSIC_TYPE::WIN_VERSION, musicDirectories );
|
||||
- }
|
||||
+ // To avoid extra I/O calls to data storage it might be useful to remember the last successful type of music and try to search for it next time.
|
||||
+ static std::array<MusicFileType, 3> musicFileTypes{ MusicFileType( MUS::EXTERNAL_MUSIC_TYPE::DOS_VERSION ),
|
||||
+ MusicFileType( MUS::EXTERNAL_MUSIC_TYPE::WIN_VERSION ), MusicFileType( MUS::EXTERNAL_MUSIC_TYPE::MAPPED ) };
|
||||
|
||||
- if ( filename.empty() ) {
|
||||
- filename = getExternalMusicFile( mus, MUS::EXTERNAL_MUSIC_TYPE::MAPPED, musicDirectories );
|
||||
+ std::string filename;
|
||||
+
|
||||
+ for ( size_t i = 0; i < musicFileTypes.size(); ++i ) {
|
||||
+ filename = getExternalMusicFile( mus, musicDirectories, musicFileTypes[i] );
|
||||
+ if ( !filename.empty() ) {
|
||||
+ if ( i > 0 ) {
|
||||
+ // Swap music types to improve cache hit.
|
||||
+ std::swap( musicFileTypes[0], musicFileTypes[i] );
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
}
|
||||
|
||||
if ( filename.empty() ) {
|
@ -2,22 +2,21 @@
|
||||
share/doc/pkg-readmes/${PKGSTEM}
|
||||
share/fheroes2/
|
||||
share/fheroes2/download_demo_version.sh
|
||||
share/fheroes2/fheroes2.key
|
||||
share/fheroes2/extract_homm2_resources.sh
|
||||
share/fheroes2/files/
|
||||
share/fheroes2/files/data/
|
||||
share/fheroes2/files/data/resurrection.h2d
|
||||
share/fheroes2/files/lang/
|
||||
share/fheroes2/files/lang/be.mo
|
||||
share/fheroes2/files/lang/bg.mo
|
||||
share/fheroes2/files/lang/cs.mo
|
||||
share/fheroes2/files/lang/de.mo
|
||||
share/fheroes2/files/lang/es.mo
|
||||
share/fheroes2/files/lang/fr.mo
|
||||
share/fheroes2/files/lang/hu.mo
|
||||
share/fheroes2/files/lang/it.mo
|
||||
share/fheroes2/files/lang/lt.mo
|
||||
share/fheroes2/files/lang/nb.mo
|
||||
share/fheroes2/files/lang/nl.mo
|
||||
share/fheroes2/files/lang/pl.mo
|
||||
share/fheroes2/files/lang/pt.mo
|
||||
share/fheroes2/files/lang/ro.mo
|
||||
share/fheroes2/files/lang/ru.mo
|
||||
share/fheroes2/files/lang/sv.mo
|
||||
share/fheroes2/files/lang/tr.mo
|
||||
share/fheroes2/files/lang/uk.mo
|
||||
|
@ -6,20 +6,21 @@ Installing Game Data
|
||||
====================
|
||||
|
||||
You need the original game data of Heroes of Might & Magic 2, or alternatively
|
||||
download the free demo version of the game. Then copy at least the directories
|
||||
DATA, MAPS, and MUSIC to ~/.fheroes2/:
|
||||
download the free demo version of the game.
|
||||
|
||||
# cp -R /path/to/game/{ANIM,DATA,MAPS,MUSIC} ~/.fheroes2/
|
||||
The port comes with 2 (bash) helper scripts to assist with this:
|
||||
|
||||
${PREFIX}/share/fheroes2/download_demo_version.sh
|
||||
${PREFIX}/share/fheroes2/extract_homm2_resources.sh
|
||||
|
||||
Alternatively, you can manually copy the directories ANIM, DATA, MAPS, and MUSIC
|
||||
to ~/.fheroes2/. (Note: The GOG version keeps 'ANIM' in the DosBox emulated
|
||||
image.)
|
||||
|
||||
If you need to run the game from a different data location, you can use the
|
||||
environment variable FHEROES2_DATA:
|
||||
|
||||
$ env FHEROES2_DATA=/path/to/game fheroes2
|
||||
|
||||
Key bindings can be adjusted in the file fheroes2.key. Copy it first to
|
||||
~/.fheroes2/ to work with it:
|
||||
|
||||
$ cp ${PREFIX}/share/fheroes2/fheroes2.key ~/.fheroes2/
|
||||
|
||||
The port includes a script to download the freeware demo data at
|
||||
${PREFIX}/share/fheroes2/download_demo_version.sh.
|
||||
Key bindings can be adjusted in the file ~/.fheroes2/fheroes2.key.
|
||||
It's automatically created on first run.
|
||||
|
Loading…
x
Reference in New Issue
Block a user