From 6477525db0094825be56ffedb3b12ade14bb66ae Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sat, 14 Dec 2013 11:10:13 -0500 Subject: PEGASUS: Fix regression with Prehistoric AI rules ordering --- engines/pegasus/pegasus.cpp | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'engines/pegasus/pegasus.cpp') diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp index 3bd29ce8dd..0148470cd5 100644 --- a/engines/pegasus/pegasus.cpp +++ b/engines/pegasus/pegasus.cpp @@ -429,7 +429,7 @@ void PegasusEngine::removeTimeBase(TimeBase *timeBase) { _timeBases.remove(timeBase); } -bool PegasusEngine::loadFromStream(Common::ReadStream *stream) { +bool PegasusEngine::loadFromStream(Common::SeekableReadStream *stream) { // Dispose currently running stuff useMenu(0); useNeighborhood(0); @@ -520,8 +520,36 @@ bool PegasusEngine::loadFromStream(Common::ReadStream *stream) { performJump(GameState.getCurrentNeighborhood()); // AI rules - if (g_AIArea) - g_AIArea->readAIRules(stream); + if (g_AIArea) { + // HACK: clone2727 accidentally changed some Prehistoric code to output some bad saves + // at one point. That's fixed now, but I don't want to leave the other users high + // and dry. + if (GameState.getCurrentNeighborhood() == kPrehistoricID && !isDemo()) { + uint32 pos = stream->pos(); + stream->seek(0x208); + uint32 roomView = stream->readUint32BE(); + stream->seek(pos); + + if (roomView == 0x30019) { + // This is a bad save -> Let's fix the data + // One byte should be put at the end instead + uint32 size = stream->size() - pos; + byte *data = (byte *)malloc(size); + data[0] = stream->readByte(); + data[1] = stream->readByte(); + data[2] = stream->readByte(); + byte wrongData = stream->readByte(); + stream->read(data + 3, size - 4); + data[size - 1] = wrongData; + Common::MemoryReadStream tempStream(data, size, DisposeAfterUse::YES); + g_AIArea->readAIRules(&tempStream); + } else { + g_AIArea->readAIRules(stream); + } + } else { + g_AIArea->readAIRules(stream); + } + } startNeighborhood(); -- cgit v1.2.3