aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Hoops2012-04-03 10:32:32 -0400
committerMatthew Hoops2012-04-03 10:32:32 -0400
commitd5341b2fc7a43d63c38e72d671053d28de42e156 (patch)
treedf60ccc15b59b75ea3bcb4185e3393bb892bdbdf
parente72f2c3c57b8c0d8fad785702ad5922f0ff0ae85 (diff)
downloadscummvm-rg350-d5341b2fc7a43d63c38e72d671053d28de42e156.tar.gz
scummvm-rg350-d5341b2fc7a43d63c38e72d671053d28de42e156.tar.bz2
scummvm-rg350-d5341b2fc7a43d63c38e72d671053d28de42e156.zip
PEGASUS: Implement saving/restoring the in-game AI data
AI data should now be restored properly after the space chase
-rwxr-xr-xengines/pegasus/ai/ai_area.cpp16
-rw-r--r--engines/pegasus/pegasus.cpp2
-rw-r--r--engines/pegasus/pegasus.h1
3 files changed, 17 insertions, 2 deletions
diff --git a/engines/pegasus/ai/ai_area.cpp b/engines/pegasus/ai/ai_area.cpp
index 9eacb038bd..b9b5ce9a51 100755
--- a/engines/pegasus/ai/ai_area.cpp
+++ b/engines/pegasus/ai/ai_area.cpp
@@ -23,6 +23,8 @@
*
*/
+#include "common/memstream.h"
+
#include "pegasus/cursor.h"
#include "pegasus/pegasus.h"
#include "pegasus/ai/ai_area.h"
@@ -72,11 +74,21 @@ AIArea::~AIArea() {
// Save last state of AI rules...
void AIArea::saveAIState() {
- // TODO
+ PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+ delete vm->_aiSaveStream;
+
+ Common::MemoryWriteStreamDynamic out;
+ writeAIRules(&out);
+
+ vm->_aiSaveStream = new Common::MemoryReadStream(out.getData(), out.size(), DisposeAfterUse::YES);
}
void AIArea::restoreAIState() {
- // TODO
+ PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+ if (vm->_aiSaveStream)
+ readAIRules(vm->_aiSaveStream);
}
void AIArea::writeAIRules(Common::WriteStream *stream) {
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index a346af581a..46aea7328b 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -90,6 +90,7 @@ PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamede
_idlerHead = 0;
_currentCD = 1;
_introTimer = 0;
+ _aiSaveStream = 0;
}
PegasusEngine::~PegasusEngine() {
@@ -101,6 +102,7 @@ PegasusEngine::~PegasusEngine() {
delete _neighborhood;
delete _rnd;
delete _introTimer;
+ delete _aiSaveStream;
// NOTE: This must be deleted last!
delete _gfx;
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index c6d4c80b76..349856d27b 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -162,6 +162,7 @@ public:
bool canSolve();
void prepareForAIHint(const Common::String &);
void cleanUpAfterAIHint(const Common::String &);
+ Common::SeekableReadStream *_aiSaveStream;
// Neighborhood
void jumpToNewEnvironment(const NeighborhoodID, const RoomID, const DirectionConstant);