aboutsummaryrefslogtreecommitdiff
path: root/engines/pegasus/pegasus.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2013-12-14 11:10:13 -0500
committerMatthew Hoops2013-12-14 11:18:32 -0500
commit6477525db0094825be56ffedb3b12ade14bb66ae (patch)
tree971e2aa3adbbe58939521fcff775dc85df643716 /engines/pegasus/pegasus.cpp
parent42c04c8735fde38532edba8ee36c9c03eef2c465 (diff)
downloadscummvm-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/pegasus/pegasus.cpp')
-rw-r--r--engines/pegasus/pegasus.cpp34
1 files changed, 31 insertions, 3 deletions
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();