PEGASUS: Fix regression with Prehistoric AI rules ordering

This commit is contained in:
Matthew Hoops 2013-12-14 11:10:13 -05:00
parent 42c04c8735
commit 6477525db0
3 changed files with 39 additions and 9 deletions

View File

@ -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);
}
}
}

View File

@ -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();

View File

@ -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);