diff options
author | Matthew Hoops | 2013-12-14 11:10:13 -0500 |
---|---|---|
committer | Matthew Hoops | 2013-12-14 11:18:32 -0500 |
commit | 6477525db0094825be56ffedb3b12ade14bb66ae (patch) | |
tree | 971e2aa3adbbe58939521fcff775dc85df643716 /engines | |
parent | 42c04c8735fde38532edba8ee36c9c03eef2c465 (diff) | |
download | scummvm-rg350-6477525db0094825be56ffedb3b12ade14bb66ae.tar.gz scummvm-rg350-6477525db0094825be56ffedb3b12ade14bb66ae.tar.bz2 scummvm-rg350-6477525db0094825be56ffedb3b12ade14bb66ae.zip |
PEGASUS: Fix regression with Prehistoric AI rules ordering
Diffstat (limited to 'engines')
-rw-r--r-- | engines/pegasus/neighborhood/prehistoric/prehistoric.cpp | 12 | ||||
-rw-r--r-- | engines/pegasus/pegasus.cpp | 34 | ||||
-rw-r--r-- | engines/pegasus/pegasus.h | 2 |
3 files changed, 39 insertions, 9 deletions
diff --git a/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp b/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp index d62b069e46..578ce57f26 100644 --- a/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp +++ b/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp @@ -124,11 +124,6 @@ void Prehistoric::setUpAIRules() { AIHasItemCondition *hasLogCondition = new AIHasItemCondition(kHistoricalLog); AIRule *rule = new AIRule(hasLogCondition, doneAction); g_AIArea->addAIRule(rule); - } else { - AIPlayMessageAction *messageAction = new AIPlayMessageAction("Images/AI/Prehistoric/XP25W", false); - AIHasItemCondition *hasLogCondition = new AIHasItemCondition(kHistoricalLog); - AIRule *rule = new AIRule(hasLogCondition, messageAction); - g_AIArea->addAIRule(rule); } if (!_vm->isOldDemo()) { @@ -167,6 +162,13 @@ void Prehistoric::setUpAIRules() { rule = new AIRule(timerCondition, messageAction); g_AIArea->addAIRule(rule); } + + if (!_vm->isDemo()) { + AIPlayMessageAction *messageAction = new AIPlayMessageAction("Images/AI/Prehistoric/XP25W", false); + AIHasItemCondition *hasLogCondition = new AIHasItemCondition(kHistoricalLog); + AIRule *rule = new AIRule(hasLogCondition, messageAction); + g_AIArea->addAIRule(rule); + } } } 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(); diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h index 07e6d8f761..59637e38df 100644 --- a/engines/pegasus/pegasus.h +++ b/engines/pegasus/pegasus.h @@ -249,7 +249,7 @@ private: Common::List<TimeBase *> _timeBases; // Save/Load - bool loadFromStream(Common::ReadStream *stream); + bool loadFromStream(Common::SeekableReadStream *stream); bool writeToStream(Common::WriteStream *stream, int saveType); void loadFromContinuePoint(); void writeContinueStream(Common::WriteStream *stream); |