From 03eba05b09e5c9e5a351f8111185934b92a3fed3 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Wed, 21 Dec 2011 12:09:01 -0500 Subject: PEGASUS: Use correct CD when outputting saves For better compatibility when loading saves with the original interpreter --- engines/pegasus/pegasus.cpp | 37 ++++++++++++++++++++++++++++++++----- engines/pegasus/pegasus.h | 2 ++ 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp index 2e352bdc6b..19ebfeac2e 100644 --- a/engines/pegasus/pegasus.cpp +++ b/engines/pegasus/pegasus.cpp @@ -88,6 +88,7 @@ PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamede _draggingItem = 0; _dragType = kDragNoDrag; _idlerHead = 0; + _currentCD = 1; } PegasusEngine::~PegasusEngine() { @@ -423,6 +424,7 @@ bool PegasusEngine::loadFromStream(Common::ReadStream *stream) { case kPegasusPrimeDisk2GameType: case kPegasusPrimeDisk3GameType: case kPegasusPrimeDisk4GameType: + _currentCD = gameType - kPegasusPrimeDisk1GameType + 1; saveType = kNormalSave; break; case kPegasusPrimeContinueType: @@ -505,12 +507,10 @@ bool PegasusEngine::writeToStream(Common::WriteStream *stream, int saveType) { // Signature stream->writeUint32BE(kPegasusPrimeCreator); - if (saveType == kNormalSave) { - // TODO: Disc check - stream->writeUint32BE(kPegasusPrimeDisk1GameType); - } else { // Continue + if (saveType == kNormalSave) + stream->writeUint32BE(kPegasusPrimeDisk1GameType + _currentCD - 1); + else // Continue stream->writeUint32BE(kPegasusPrimeContinueType); - } stream->writeUint32BE(kPegasusPrimeVersion); @@ -1326,6 +1326,9 @@ void PegasusEngine::performJump(NeighborhoodID neighborhoodID) { Neighborhood *neighborhood; makeNeighborhood(neighborhoodID, neighborhood); useNeighborhood(neighborhood); + + // Update the CD variable (used just for saves currently) + _currentCD = getNeighborhoodCD(neighborhoodID); } void PegasusEngine::startNeighborhood() { @@ -2135,4 +2138,28 @@ ItemID PegasusEngine::pickItemToDestroy() { return kNoItemID; } +uint PegasusEngine::getNeighborhoodCD(const NeighborhoodID neighborhood) const { + switch (neighborhood) { + case kCaldoriaID: + case kNoradAlphaID: + case kNoradSubChaseID: + return 1; + case kFullTSAID: + case kPrehistoricID: + return 2; + case kMarsID: + return 3; + case kWSCID: + case kNoradDeltaID: + return 4; + case kTinyTSAID: + // Tiny TSA exists on three of the CD's, so just continue + // with the CD we're on + return _currentCD; + } + + // Can't really happen, but it's a good fallback anyway :P + return 1; +} + } // End of namespace Pegasus diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h index bd8f04b17b..ef05585f4c 100644 --- a/engines/pegasus/pegasus.h +++ b/engines/pegasus/pegasus.h @@ -248,6 +248,8 @@ private: void shellGameInput(const Input &input, const Hotspot *cursorSpot); Common::RandomSource *_rnd; void doSubChase(); + uint getNeighborhoodCD(const NeighborhoodID neighborhood) const; + uint _currentCD; // Menu GameMenu *_gameMenu; -- cgit v1.2.3