SUMMARY="A 3D fantasy MMORPG"
DESCRIPTION="So why play Eternal Lands, when there are so many free MMORPGs out there? \
Well, there are many reasons why, but here are a few:

* Friendly community. Most of the people here are friendly, and they will try to \
help you if they can.
* There are 12 skills in the game: Attack, Defense, Harvest, Alchemy, Magic, Potion, \
Summoning, Manufacturing, Crafting, Engineering, Tailoring and Ranging.
* There are no fixed class restrictions, so you can develop your character in any way \
you wish. You, as a player, determine exactly how you develop your character. If you \
make mistakes, or decide to change or adjust your build, you can do so.
* Eternal Lands is not just about combat. Many players focus on more peaceful activities \
such as collecting resources, creating items, summoning monsters and so on. But if you \
like combat, there is plenty of it as well, both PvP and PvE.
* The game client is relatively small, the download being only 50MB. That's under a \
minute on a cable modem, and a few minutes on a DSL connection.
* Eternal Lands is a multiplatform game, running on Windows, Linux, Haiku and OSX (Mac). \
The client is open source.."
HOMEPAGE="http://www.eternal-lands.com/"
COPYRIGHT="2003-2021 Eternal Lands Team"
LICENSE="ELCPL 1.0"
REVISION="1"
srcGitRev="eadf3ac8cd24ab925391c3dcb27015cc3e81c452"
SOURCE_URI="https://github.com/raduprv/Eternal-Lands/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="a439ae0a40fdde703a367071387d65714b605e9b4e0802ced0d62627580325f5"
SOURCE_DIR="Eternal-Lands-$srcGitRev"
SOURCE_URI_2="https://github.com/raduprv/Eternal-Lands/releases/download/1.9.5.7/el_195_p7_data_files.zip"
CHECKSUM_SHA256_2="32fc28333058955f1b1c11e21ee514d9596743ee6a3628c3bbbba2e4de7d533f"
SOURCE_URI_3="http://www.gm.fh-koeln.de/~linke/EL-Downloads/EL_sound_191.zip"
CHECKSUM_SHA256_3="94dfcb37ab85f154fa33309a7bf10ca9998a68c5865f85f3d31797625da18f86"
SOURCE_URI_4="http://www.gm.fh-koeln.de/~linke/EL-Downloads/EL_music_full.zip"
CHECKSUM_SHA256_4="1ea4de25081034ac684aaebf127ab6ca8524ba5367532863d84d63837dd631ec"

PATCHES="eternal_lands-$portVersion.patchset"
ADDITIONAL_FILES="eternal_lands.rdef.in"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	eternal_lands$secondaryArchSuffix = $portVersion
	app:EternalLands
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libcal3d$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libGLU$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libogg$secondaryArchSuffix
	lib:libopenal$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libSDL2_2.0$secondaryArchSuffix
	lib:libSDL2_image_2.0$secondaryArchSuffix
	lib:libSDL2_net_2.0$secondaryArchSuffix
	lib:libSDL2_ttf_2.0$secondaryArchSuffix
	lib:libvorbis$secondaryArchSuffix
	lib:libvorbisfile$secondaryArchSuffix
	lib:libxml2$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcal3d$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libGLU$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:libogg$secondaryArchSuffix
	devel:libopenal$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libSDL2$secondaryArchSuffix
	devel:libSDL2_image$secondaryArchSuffix
	devel:libSDL2_net$secondaryArchSuffix
	devel:libSDL2_ttf$secondaryArchSuffix
	devel:libvorbis$secondaryArchSuffix
	devel:libvorbisfile$secondaryArchSuffix
	devel:libxml2$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	devel:nlohmann_json
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	mkdir -p build
	cd build
	cmake .. \
		-DCMAKE_BUILD_TYPE=Release \
		-DSDL2_INCLUDE_DIR=/system/$relativeIncludeDir \
		-DSDL2TTF_INCLUDE_DIR=/system/$relativeIncludeDir \
		-DFSAA=OFF

	make $jobArgs
}

INSTALL()
{
	mkdir -p $appsDir/EternalLands/music
	cp -R $sourceDir2/el_data/* $appsDir/EternalLands
	cp -R $sourceDir3/sound $appsDir/EternalLands
	cp $sourceDir4/* $appsDir/EternalLands/music

	cp build/EternalLands $appsDir/EternalLands
	cp dev-data-files/cursors2.dds $appsDir/EternalLands/textures
	cp dev-data-files/{item_info.txt,item_knowledge_info.txt,main_icon_window.xml} $appsDir/EternalLands

	local APP_SIGNATURE="application/x-vnd.eternal-lands"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3 | cut -d~ -f1`"
	local LONG_INFO="$SUMMARY"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/eternal_lands.rdef.in > $sourceDir/eternal_lands.rdef

	addResourcesToBinaries  $sourceDir/eternal_lands.rdef $appsDir/EternalLands/EternalLands

	addAppDeskbarSymlink $appsDir/EternalLands/EternalLands "Eternal Lands"
}
