[Scummvm-cvs-logs] scummvm master -> 6477525db0094825be56ffedb3b12ade14bb66ae

clone2727 clone2727 at gmail.com
Sat Dec 14 17:20:45 CET 2013


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
6477525db0 PEGASUS: Fix regression with Prehistoric AI rules ordering


Commit: 6477525db0094825be56ffedb3b12ade14bb66ae
    https://github.com/scummvm/scummvm/commit/6477525db0094825be56ffedb3b12ade14bb66ae
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2013-12-14T08:18:32-08:00

Commit Message:
PEGASUS: Fix regression with Prehistoric AI rules ordering

Changed paths:
    engines/pegasus/neighborhood/prehistoric/prehistoric.cpp
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp b/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp
index d62b069..578ce57 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 3bd29ce..0148470 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 07e6d8f..59637e3 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);






More information about the Scummvm-git-logs mailing list