AGI: Refactor away agiDetectGame

This commit is contained in:
sluicebox 2024-03-21 07:37:27 -07:00
parent 2ae4cb8acb
commit c5995d64e7
3 changed files with 10 additions and 22 deletions

View File

@ -437,17 +437,23 @@ void AgiEngine::initialize() {
_game.name[0] = '\0';
debugC(2, kDebugLevelMain, "Detect game");
if (getVersion() <= 0x2001) {
_loader = new AgiLoader_v1(this);
} else if (getVersion() <= 0x2999) {
_loader = new AgiLoader_v2(this);
} else {
_loader = new AgiLoader_v3(this);
}
if (agiDetectGame() == errOK) {
debugC(2, kDebugLevelMain, "Detect game");
int ec = _loader->detectGame();
if (ec == errOK) {
debugC(2, kDebugLevelMain, "game loaded");
} else {
warning("Could not open AGI game");
}
// finally set up actual VM opcodes, because we should now have figured out the right AGI version
setupOpCodes(getVersion());
debugC(2, kDebugLevelMain, "Init sound");
}
bool AgiEngine::promptIsEnabled() {

View File

@ -873,7 +873,6 @@ public:
int agiInit();
void agiDeinit();
int agiDetectGame();
int agiLoadResource(int16 resourceType, int16 resourceNr);
void agiUnloadResource(int16 resourceType, int16 resourceNr);
void agiUnloadResources();

View File

@ -435,21 +435,4 @@ bool AgiBase::canSaveGameStateCurrently(Common::U32String *msg) {
return false;
}
int AgiEngine::agiDetectGame() {
int ec = errOK;
assert(_gameDescription != nullptr);
if (getVersion() <= 0x2001) {
_loader = new AgiLoader_v1(this);
} else if (getVersion() <= 0x2999) {
_loader = new AgiLoader_v2(this);
} else {
_loader = new AgiLoader_v3(this);
}
ec = _loader->detectGame();
return ec;
}
} // End of namespace Agi