From 04a0c4ead6e76f4eb4dcef8faa1d8d3138465289 Mon Sep 17 00:00:00 2001 From: whiterandrek Date: Fri, 25 May 2018 17:44:21 +0300 Subject: PINK: add saving/loading state of WalkMgr --- engines/pink/objects/walk/walk_mgr.cpp | 22 ++++++++++++++++++++++ engines/pink/objects/walk/walk_mgr.h | 3 +++ 2 files changed, 25 insertions(+) (limited to 'engines/pink/objects') diff --git a/engines/pink/objects/walk/walk_mgr.cpp b/engines/pink/objects/walk/walk_mgr.cpp index 5b57107a44..0df4a544fc 100644 --- a/engines/pink/objects/walk/walk_mgr.cpp +++ b/engines/pink/objects/walk/walk_mgr.cpp @@ -143,4 +143,26 @@ void WalkMgr::end() { _leadActor->onWalkEnd(); } +void WalkMgr::loadState(Archive &archive) { + _isWalking = archive.readByte(); + _current.name = archive.readString(); + if (!_current.name.empty()) { + _current.coord = getLocationCoordinates(_current.name); + } + if (_isWalking) { + _next.name = archive.readString(); + _destination = findLocation(archive.readString()); + _next.coord = getLocationCoordinates(_next.name); + } +} + +void WalkMgr::saveState(Archive &archive) { + archive.writeByte(_isWalking); + archive.writeString(_current.name); + if (_isWalking) { + archive.writeString(_next.name); + archive.writeString(_destination->getName()); + } +} + } // End of namespace Pink diff --git a/engines/pink/objects/walk/walk_mgr.h b/engines/pink/objects/walk/walk_mgr.h index 9060f08a20..2decdd861c 100644 --- a/engines/pink/objects/walk/walk_mgr.h +++ b/engines/pink/objects/walk/walk_mgr.h @@ -45,6 +45,9 @@ public: double getLengthBetweenLocations(WalkLocation *first, WalkLocation *second); void setCurrentWayPoint(WalkLocation *location); + void loadState(Archive &archive); + void saveState(Archive &archive); + private: struct Coordinates { int x; -- cgit v1.2.3