2019-12-01 10:19:47 -08:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-12-11 22:38:03 -08:00
|
|
|
#include "ultima/detection.h"
|
2019-12-01 10:19:47 -08:00
|
|
|
#include "base/plugins.h"
|
|
|
|
#include "common/savefile.h"
|
|
|
|
#include "common/str-array.h"
|
|
|
|
#include "common/memstream.h"
|
|
|
|
#include "common/system.h"
|
|
|
|
#include "common/translation.h"
|
2019-12-20 22:09:29 -08:00
|
|
|
#ifdef ENABLE_ULTIMA6
|
|
|
|
#include "ultima/ultima6/ultima6.h"
|
|
|
|
#endif
|
2019-12-15 21:28:15 -08:00
|
|
|
#ifdef ENABLE_ULTIMA8
|
|
|
|
#include "ultima/ultima8/ultima8.h"
|
|
|
|
#endif
|
2019-12-01 10:19:47 -08:00
|
|
|
|
2019-12-11 22:38:03 -08:00
|
|
|
static const PlainGameDescriptor ULTIMA_GAMES[] = {
|
2019-12-17 07:49:53 -08:00
|
|
|
#ifdef ENABLE_ULTIMA6
|
|
|
|
{ "ultima6", "Ultima VI - The False Prophet" },
|
|
|
|
#endif
|
2019-12-11 22:38:03 -08:00
|
|
|
#ifdef ENABLE_ULTIMA8
|
2019-12-01 10:19:47 -08:00
|
|
|
{ "ultima8", "Ultima 8 - Pagan" },
|
2019-12-11 22:38:03 -08:00
|
|
|
#endif
|
2019-12-12 18:03:43 -08:00
|
|
|
{ 0, 0 }
|
2019-12-01 10:19:47 -08:00
|
|
|
};
|
|
|
|
|
2019-12-11 22:38:03 -08:00
|
|
|
#include "ultima/detection_tables.h"
|
2019-12-01 10:19:47 -08:00
|
|
|
|
2020-01-01 20:48:52 -10:00
|
|
|
namespace Ultima {
|
|
|
|
UltimaMetaEngine *g_metaEngine;
|
|
|
|
}; // End of namespace Ultima
|
|
|
|
|
|
|
|
|
2019-12-11 22:38:03 -08:00
|
|
|
UltimaMetaEngine::UltimaMetaEngine() : AdvancedMetaEngine(Ultima::GAME_DESCRIPTIONS,
|
|
|
|
sizeof(Ultima::UltimaGameDescription), ULTIMA_GAMES) {
|
2020-01-01 20:48:52 -10:00
|
|
|
Ultima::g_metaEngine = this;
|
2019-12-11 22:38:03 -08:00
|
|
|
#ifdef ENABLE_ULTIMA8
|
2019-12-12 18:03:43 -08:00
|
|
|
static const char *const DIRECTORY_GLOBS[2] = { "usecode", 0 };
|
2019-12-09 21:15:08 -08:00
|
|
|
_maxScanDepth = 2;
|
|
|
|
_directoryGlobs = DIRECTORY_GLOBS;
|
2019-12-11 22:38:03 -08:00
|
|
|
#endif
|
2019-12-01 10:19:47 -08:00
|
|
|
}
|
|
|
|
|
2020-01-01 20:48:52 -10:00
|
|
|
UltimaMetaEngine::~UltimaMetaEngine() {
|
|
|
|
Ultima::g_metaEngine = nullptr;
|
|
|
|
}
|
|
|
|
|
2019-12-11 22:38:03 -08:00
|
|
|
bool UltimaMetaEngine::hasFeature(MetaEngineFeature f) const {
|
2019-12-01 10:19:47 -08:00
|
|
|
return
|
2019-12-14 19:40:48 -08:00
|
|
|
(f == kSupportsListSaves) ||
|
|
|
|
(f == kSupportsDeleteSave) ||
|
|
|
|
(f == kSavesSupportMetaInfo) ||
|
|
|
|
(f == kSavesSupportThumbnail) ||
|
|
|
|
(f == kSavesSupportCreationDate) ||
|
|
|
|
(f == kSavesSupportPlayTime) ||
|
|
|
|
(f == kSupportsLoadingDuringStartup) ||
|
|
|
|
(f == kSavesUseExtendedFormat);
|
2019-12-01 10:19:47 -08:00
|
|
|
}
|
|
|
|
|
2019-12-11 22:38:03 -08:00
|
|
|
bool UltimaMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
|
|
|
|
const Ultima::UltimaGameDescription *gd = (const Ultima::UltimaGameDescription *)desc;
|
2019-12-01 10:19:47 -08:00
|
|
|
if (gd) {
|
2019-12-11 22:38:03 -08:00
|
|
|
switch (gd->gameId) {
|
2019-12-20 22:09:29 -08:00
|
|
|
#ifdef ENABLE_ULTIMA6
|
|
|
|
case Ultima::GAME_ULTIMA6:
|
|
|
|
*engine = new Ultima::Ultima6::Ultima6Engine(syst, gd);
|
|
|
|
break;
|
|
|
|
#endif
|
2019-12-15 21:28:15 -08:00
|
|
|
#ifdef ENABLE_ULTIMA8
|
2019-12-11 22:38:03 -08:00
|
|
|
case Ultima::GAME_ULTIMA8:
|
2019-12-16 21:32:17 -08:00
|
|
|
*engine = new Ultima::Ultima8::Ultima8Engine(syst, gd);
|
2019-12-11 22:38:03 -08:00
|
|
|
break;
|
2019-12-15 21:28:15 -08:00
|
|
|
#endif
|
2019-12-11 22:38:03 -08:00
|
|
|
default:
|
|
|
|
error("Unsupported game specified");
|
|
|
|
}
|
2019-12-01 10:19:47 -08:00
|
|
|
}
|
|
|
|
return gd != 0;
|
|
|
|
}
|
|
|
|
|
2019-12-11 22:38:03 -08:00
|
|
|
int UltimaMetaEngine::getMaximumSaveSlot() const {
|
2019-12-01 10:19:47 -08:00
|
|
|
return MAX_SAVES;
|
|
|
|
}
|
|
|
|
|
2019-12-14 21:53:58 -08:00
|
|
|
const char *UltimaMetaEngine::getSavegamePattern(const char *target) const {
|
|
|
|
static char buffer[100];
|
|
|
|
snprintf(buffer, 200, "%s.###", target == nullptr ? getEngineId() : target);
|
2019-12-01 10:19:47 -08:00
|
|
|
|
2019-12-14 21:53:58 -08:00
|
|
|
return buffer;
|
2019-12-01 10:19:47 -08:00
|
|
|
}
|
|
|
|
|
2020-01-01 20:48:52 -10:00
|
|
|
const char *UltimaMetaEngine::getSavegameFile(int saveGameIdx, const char *target) const {
|
|
|
|
static char buffer[100];
|
|
|
|
snprintf(buffer, 200, "%s.%.3d", target == nullptr ? getEngineId() : target, saveGameIdx);
|
|
|
|
|
|
|
|
return buffer;
|
2020-01-01 14:26:48 -10:00
|
|
|
}
|
|
|
|
|
2019-12-11 22:38:03 -08:00
|
|
|
#if PLUGIN_ENABLED_DYNAMIC(ULTIMA)
|
|
|
|
REGISTER_PLUGIN_DYNAMIC(ULTIMA, PLUGIN_TYPE_ENGINE, UltimaMetaEngine);
|
2019-12-01 10:19:47 -08:00
|
|
|
#else
|
2019-12-11 22:38:03 -08:00
|
|
|
REGISTER_PLUGIN_STATIC(ULTIMA, PLUGIN_TYPE_ENGINE, UltimaMetaEngine);
|
2019-12-01 10:19:47 -08:00
|
|
|
#endif
|