Skip to content

Commit

Permalink
ADL: Clean up AdlMetaEngine
Browse files Browse the repository at this point in the history
  • Loading branch information
waltervn committed Mar 9, 2016
1 parent 58e7c53 commit 07d0997
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 40 deletions.
10 changes: 1 addition & 9 deletions engines/adl/adl.cpp
Expand Up @@ -37,6 +37,7 @@

#include "adl/adl.h"
#include "adl/display.h"
#include "adl/detection.h"

namespace Adl {

Expand Down Expand Up @@ -1071,13 +1072,4 @@ void AdlEngine::drawLineArt(const Common::Array<byte> &lineArt, const Common::Po
}
}

AdlEngine *AdlEngine::create(GameType type, OSystem *syst, const AdlGameDescription *gd) {
switch(type) {
case kGameTypeHires1:
return HiRes1Engine__create(syst, gd);
default:
error("Unknown GameType");
}
}

} // End of namespace Adl
11 changes: 0 additions & 11 deletions engines/adl/adl.h
Expand Up @@ -34,20 +34,11 @@ class SeekableReadStream;
}

namespace Adl {

#define SAVEGAME_VERSION 0
#define SAVEGAME_NAME_LEN 32

class Display;
class Parser;
class Console;
struct AdlGameDescription;

enum GameType {
kGameTypeNone = 0,
kGameTypeHires1
};

struct StringOffset {
int stringIdx;
uint offset;
Expand Down Expand Up @@ -167,8 +158,6 @@ class AdlEngine : public Engine {
public:
virtual ~AdlEngine();

static AdlEngine *create(GameType type, OSystem *syst, const AdlGameDescription *gd);

protected:
AdlEngine(OSystem *syst, const AdlGameDescription *gd);

Expand Down
35 changes: 21 additions & 14 deletions engines/adl/detection.cpp
Expand Up @@ -28,7 +28,7 @@

#include "engines/advancedDetector.h"

#include "adl/adl.h"
#include "adl/detection.h"

namespace Adl {

Expand Down Expand Up @@ -59,18 +59,12 @@ static const ADExtraGuiOptionsMap optionsList[] = {
AD_EXTRA_GUI_OPTIONS_TERMINATOR
};

struct AdlGameDescription {
ADGameDescription desc;
GameType gameType;
};

static const PlainGameDescriptor adlGames[] = {
{"hires1", "Hi-Res Adventure #1: Mystery House"},
{0, 0}
};

static const AdlGameDescription gameDescriptions[] = {

{ // MD5 by waltervn
{
"hires1", 0,
Expand All @@ -85,9 +79,9 @@ static const AdlGameDescription gameDescriptions[] = {
ADGF_NO_FLAGS,
GUIO2(GAMEOPTION_COLOR, GAMEOPTION_SCANLINES)
},
kGameTypeHires1
GAME_TYPE_HIRES1
},
{AD_TABLE_END_MARKER, kGameTypeNone}
{ AD_TABLE_END_MARKER, GAME_TYPE_NONE }
};

class AdlMetaEngine : public AdvancedMetaEngine {
Expand Down Expand Up @@ -189,7 +183,7 @@ SaveStateList AdlMetaEngine::listSaves(const char *target) const {
const Common::String &fileName = files[i];
Common::InSaveFile *inFile = saveFileMan->openForLoading(fileName);
if (!inFile) {
warning("Cannot open save file %s", fileName.c_str());
warning("Cannot open save file '%s'", fileName.c_str());
continue;
}

Expand All @@ -201,7 +195,7 @@ SaveStateList AdlMetaEngine::listSaves(const char *target) const {

byte saveVersion = inFile->readByte();
if (saveVersion != SAVEGAME_VERSION) {
warning("Save game version %i not supported in '%s'", saveVersion, fileName.c_str());
warning("Unsupported save game version %i found in '%s'", saveVersion, fileName.c_str());
delete inFile;
continue;
}
Expand All @@ -225,10 +219,23 @@ void AdlMetaEngine::removeSaveState(const char *target, int slot) const {
g_system->getSavefileManager()->removeSavefile(fileName);
}

Engine *HiRes1Engine_create(OSystem *syst, const AdlGameDescription *gd);

bool AdlMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const {
if (gd)
*engine = AdlEngine::create(((const AdlGameDescription *)gd)->gameType, syst, (const AdlGameDescription *)gd);
return gd != nullptr;
if (!gd)
return false;

const AdlGameDescription *adlGd = (const AdlGameDescription *)gd;

switch (adlGd->gameType) {
case GAME_TYPE_HIRES1:
*engine = HiRes1Engine_create(syst, adlGd);
break;
default:
error("Unknown GameType");
}

return true;
}

} // End of namespace Adl
Expand Down
45 changes: 45 additions & 0 deletions engines/adl/detection.h
@@ -0,0 +1,45 @@
/* 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.
*
*/

#ifndef ADL_DETECTION_H
#define ADL_DETECTION_H

#include "engines/advancedDetector.h"

namespace Adl {

#define SAVEGAME_VERSION 0
#define SAVEGAME_NAME_LEN 32

enum GameType {
GAME_TYPE_NONE,
GAME_TYPE_HIRES1
};

struct AdlGameDescription {
ADGameDescription desc;
GameType gameType;
};

} // End of namespace Adl

#endif
6 changes: 1 addition & 5 deletions engines/adl/hires1.cpp
Expand Up @@ -98,10 +98,6 @@ static const StringOffset stringOffsets[] = {
#define IDI_HR1_OFS_VERBS 0x3800
#define IDI_HR1_OFS_NOUNS 0x0f00

HiRes1Engine::HiRes1Engine(OSystem *syst, const AdlGameDescription *gd) :
AdlEngine(syst, gd) {
}

void HiRes1Engine::runIntro() {
Common::File file;

Expand Down Expand Up @@ -462,7 +458,7 @@ void HiRes1Engine::drawLine(const Common::Point &p1, const Common::Point &p2, by
}
}

AdlEngine *HiRes1Engine__create(OSystem *syst, const AdlGameDescription *gd) {
Engine *HiRes1Engine_create(OSystem *syst, const AdlGameDescription *gd) {
return new HiRes1Engine(syst, gd);
}

Expand Down
2 changes: 1 addition & 1 deletion engines/adl/hires1.h
Expand Up @@ -34,7 +34,7 @@ namespace Adl {

class HiRes1Engine : public AdlEngine {
public:
HiRes1Engine(OSystem *syst, const AdlGameDescription *gd);
HiRes1Engine(OSystem *syst, const AdlGameDescription *gd) : AdlEngine(syst, gd) { }

private:
void restartGame();
Expand Down

0 comments on commit 07d0997

Please sign in to comment.