#!/bin/sh
# SPDX-License-Identifier: ACSL
# SPDX-FileCopyrightText: © 2022 Antoine Le Gonidec <vv221@dotslashplay.it>
set -o errexit

###
# Old World
# send your bug reports to bugs@dotslashplay.it
###

script_version=20260412.1

PLAYIT_COMPATIBILITY_LEVEL='2.35'

GAME_ID='old-world'
GAME_NAME='Old World'

ARCHIVE_BASE_7_NAME='setup_old_world_83082_(64bit)_(90044).exe'
ARCHIVE_BASE_7_MD5='454f7314a55e444195aa7e5452ff37b7'
ARCHIVE_BASE_7_TYPE='innosetup'
ARCHIVE_BASE_7_PART1_NAME='setup_old_world_83082_(64bit)_(90044)-1.bin'
ARCHIVE_BASE_7_PART1_MD5='ac71831c9c3121535bb5caa28dace60a'
ARCHIVE_BASE_7_PART2_NAME='setup_old_world_83082_(64bit)_(90044)-2.bin'
ARCHIVE_BASE_7_PART2_MD5='9b0e952dee0e7c15c19a2c1221bcfd52'
ARCHIVE_BASE_7_SIZE='7683341'
ARCHIVE_BASE_7_VERSION='1.0.83082-gog90044'
ARCHIVE_BASE_7_URL='https://www.gog.com/game/old_world'

ARCHIVE_BASE_6_NAME='setup_old_world_82741_(64bit)_(89513).exe'
ARCHIVE_BASE_6_MD5='c9d75b181bf645a55e0ebc57a43738fb'
ARCHIVE_BASE_6_TYPE='innosetup'
ARCHIVE_BASE_6_PART1_NAME='setup_old_world_82741_(64bit)_(89513)-1.bin'
ARCHIVE_BASE_6_PART1_MD5='019892fcc44beacc94caf1dc24f9e63a'
ARCHIVE_BASE_6_PART2_NAME='setup_old_world_82741_(64bit)_(89513)-2.bin'
ARCHIVE_BASE_6_PART2_MD5='1f51e7c95445816c2d27bb6c878a405f'
ARCHIVE_BASE_6_SIZE='7677197'
ARCHIVE_BASE_6_VERSION='1.0.82741-gog89513'

ARCHIVE_BASE_5_NAME='setup_old_world_75717_(64bit)_(79269).exe'
ARCHIVE_BASE_5_MD5='5a714c53191c614b0f116b5ff7724276'
ARCHIVE_BASE_5_TYPE='innosetup'
ARCHIVE_BASE_5_PART1_NAME='setup_old_world_75717_(64bit)_(79269)-1.bin'
ARCHIVE_BASE_5_PART1_MD5='ca0c7357294b1127f13e82f4aad9c6dd'
ARCHIVE_BASE_5_PART2_NAME='setup_old_world_75717_(64bit)_(79269)-2.bin'
ARCHIVE_BASE_5_PART2_MD5='1f55824e657014585f972f8168fbdd48'
ARCHIVE_BASE_5_SIZE='7307636'
ARCHIVE_BASE_5_VERSION='1.0.75717-gog79269'

ARCHIVE_BASE_4_NAME='setup_old_world_73323_(64bit)_(75059).exe'
ARCHIVE_BASE_4_MD5='85c6f18dab6b3a4afa10f8692ddc37f4'
ARCHIVE_BASE_4_TYPE='innosetup'
ARCHIVE_BASE_4_PART1_NAME='setup_old_world_73323_(64bit)_(75059)-1.bin'
ARCHIVE_BASE_4_PART1_MD5='76088aa2846f040a9f847a4c1d37fefa'
ARCHIVE_BASE_4_SIZE='6770335'
ARCHIVE_BASE_4_VERSION='1.0.73323-gog75059'
ARCHIVE_BASE_4_URL='https://www.gog.com/game/old_world'

ARCHIVE_BASE_3_NAME='setup_old_world_63874_(64bit)_(60139).exe'
ARCHIVE_BASE_3_MD5='b437df7671daf99926d7bcff6843348e'
ARCHIVE_BASE_3_TYPE='innosetup'
ARCHIVE_BASE_3_PART1_NAME='setup_old_world_63874_(64bit)_(60139)-1.bin'
ARCHIVE_BASE_3_PART1_MD5='9dc2fcaec2c5e31c5c7256ec978ff5de'
ARCHIVE_BASE_3_PART2_NAME='setup_old_world_63874_(64bit)_(60139)-2.bin'
ARCHIVE_BASE_3_PART2_MD5='8aec1dbb9dea13dc7a9dcf818c51b22c'
ARCHIVE_BASE_3_SIZE='7900000'
ARCHIVE_BASE_3_VERSION='1.0.63874-gog60139'

ARCHIVE_BASE_2_NAME='setup_old_world_62874_(64bit)_(58888).exe'
ARCHIVE_BASE_2_MD5='3a99a52001d9a8c610b761a0dbd0eaa8'
ARCHIVE_BASE_2_TYPE='innosetup'
ARCHIVE_BASE_2_PART1_NAME='setup_old_world_62874_(64bit)_(58888)-1.bin'
ARCHIVE_BASE_2_PART1_MD5='6d31bb8588a9a470f8b0fc8560b01d5e'
ARCHIVE_BASE_2_PART2_NAME='setup_old_world_62874_(64bit)_(58888)-2.bin'
ARCHIVE_BASE_2_PART2_MD5='2ced4111b8b6fd2e33e4b76301055bb1'
ARCHIVE_BASE_2_SIZE='7900000'
ARCHIVE_BASE_2_VERSION='1.0.62874-gog58888'

ARCHIVE_BASE_1_NAME='setup_old_world_62798_(64bit)_(58769).exe'
ARCHIVE_BASE_1_MD5='4d733db625917e8a837be046ec899749'
ARCHIVE_BASE_1_TYPE='innosetup'
ARCHIVE_BASE_1_PART1_NAME='setup_old_world_62798_(64bit)_(58769)-1.bin'
ARCHIVE_BASE_1_PART1_MD5='91d87895e8ffbc1b8d84096df5dc3efb'
ARCHIVE_BASE_1_PART2_NAME='setup_old_world_62798_(64bit)_(58769)-2.bin'
ARCHIVE_BASE_1_PART2_MD5='8e2d4632a8bd92ecf58d8f167740c255'
ARCHIVE_BASE_1_SIZE='7900000'
ARCHIVE_BASE_1_VERSION='1.0.62798-gog58769'

ARCHIVE_BASE_0_NAME='setup_old_world_62443_(64bit)_(58285).exe'
ARCHIVE_BASE_0_MD5='9d4c86d9c1de385ed3dcf61faf0fd3c9'
ARCHIVE_BASE_0_TYPE='innosetup'
ARCHIVE_BASE_0_PART1_NAME='setup_old_world_62443_(64bit)_(58285)-1.bin'
ARCHIVE_BASE_0_PART1_MD5='f1e9ae7126b81bd023e48003642ae310'
ARCHIVE_BASE_0_PART2_NAME='setup_old_world_62443_(64bit)_(58285)-2.bin'
ARCHIVE_BASE_0_PART2_MD5='1b676c5d29f196efbab51fdac0cade5a'
ARCHIVE_BASE_0_SIZE='7900000'
ARCHIVE_BASE_0_VERSION='1.0.62443-gog58285'

UNITY3D_NAME='OldWorld'
# TODO: Include an explicit list of Unity3D plugins.

CONTENT_PATH_DEFAULT='.'
CONTENT_GAME0_DATA_FILES='
Reference'

WINE_PERSISTENT_DIRECTORIES='
users/${USER}/Documents/My Games/OldWorld'

PACKAGES_LIST='
PKG_BIN
PKG_DATA'

PKG_BIN_ARCH='64'
PKG_BIN_DEPENDENCIES_SIBLINGS='
PKG_DATA'

PKG_DATA_ID="${GAME_ID}-data"
PKG_DATA_DESCRIPTION='data'

# Load common functions.

if [ -z "$PLAYIT_LIB2" ]; then
	for playit_lib_dir in \
		"$PWD" \
		"${HOME}/.local/lib/play.it" \
		'/usr/local/lib/play.it' \
		'/usr/lib/play.it'
	do
		playit_lib_path="${playit_lib_dir}/libplayit.sh.2"
		if [ -e "$playit_lib_path" ]; then
			PLAYIT_LIB2="$playit_lib_path"
			break
		fi
	done
fi
if [ -z "$PLAYIT_LIB2" ]; then
	printf '\n\033[1;31mError:\033[0m\n'
	printf 'libplayit.sh.2 not found.\n'
	exit 1
fi
# shellcheck source=libplayit.sh.2
. "$PLAYIT_LIB2"

# Run default initialisation actions.

initialization_default "$@"

# Extract game data.

archive_extraction_default

# Include game data.

content_inclusion_icons 'PKG_DATA'
content_inclusion_default

# Write launchers.

launchers_generation

# Build packages.

packages_generation
print_instructions

# Clean up.

working_directory_cleanup

exit 0
