From 1d4efdcaa1807140f735a908a23ce3e346eace75 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 10 Jan 2008 09:42:51 +0000 Subject: Added proper reset of barmen data when game is restarted, and added missing barman data to savegames svn-id: r30367 --- engines/lure/luredefs.h | 2 +- engines/lure/res.cpp | 1 + engines/lure/res_struct.cpp | 12 ++++++++++-- engines/lure/res_struct.h | 1 + 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/engines/lure/luredefs.h b/engines/lure/luredefs.h index b47ec75cf5..4cdee1343f 100644 --- a/engines/lure/luredefs.h +++ b/engines/lure/luredefs.h @@ -36,7 +36,7 @@ namespace Lure { #define LURE_DAT_MAJOR 1 #define LURE_DAT_MINOR 28 #define LURE_MIN_SAVEGAME_MINOR 25 -#define LURE_SAVEGAME_MINOR 29 +#define LURE_SAVEGAME_MINOR 30 #define LURE_DEBUG 1 diff --git a/engines/lure/res.cpp b/engines/lure/res.cpp index b6c08cf570..fd6fe357aa 100644 --- a/engines/lure/res.cpp +++ b/engines/lure/res.cpp @@ -97,6 +97,7 @@ void Resources::reset() { freeData(); _fieldList.reset(); + _barmanLists.reset(); _talkState = TALK_NONE; _activeTalkData = NULL; diff --git a/engines/lure/res_struct.cpp b/engines/lure/res_struct.cpp index 4a39f2db20..991eca7b7f 100644 --- a/engines/lure/res_struct.cpp +++ b/engines/lure/res_struct.cpp @@ -1153,6 +1153,11 @@ BarmanLists::BarmanLists() { _barList[index] = default_barList[index]; } +void BarmanLists::reset() { + for (int index = 0; index < 3; ++index) + _barList[index] = default_barList[index]; +} + BarEntry &BarmanLists::getDetails(uint16 roomNumber) { for (int index = 0; index < 3; ++index) if (_barList[index].roomNumber == roomNumber) @@ -1161,7 +1166,7 @@ BarEntry &BarmanLists::getDetails(uint16 roomNumber) { } void BarmanLists::saveToStream(Common::WriteStream *stream) { - for (int index = 0; index < 2; ++index) { + for (int index = 0; index < 3; ++index) { uint16 value = (_barList[index].currentCustomer == NULL) ? 0 : (_barList[index].currentCustomer - &_barList[index].customers[0]) / sizeof(BarEntry) + 1; stream->writeUint16LE(value); @@ -1173,7 +1178,10 @@ void BarmanLists::saveToStream(Common::WriteStream *stream) { } void BarmanLists::loadFromStream(Common::ReadStream *stream) { - for (int index = 0; index < 2; ++index) { + uint8 saveVersion = LureEngine::getReference().saveVersion(); + int numEntries = (saveVersion >= 30) ? 3 : 2; + + for (int index = 0; index < numEntries; ++index) { int16 value = stream->readUint16LE(); _barList[index].currentCustomer = (value == 0) ? NULL : &_barList[index].customers[value - 1]; diff --git a/engines/lure/res_struct.h b/engines/lure/res_struct.h index ad012a568b..ea2836080e 100644 --- a/engines/lure/res_struct.h +++ b/engines/lure/res_struct.h @@ -774,6 +774,7 @@ class BarmanLists { public: BarmanLists(); + void reset(); BarEntry &getDetails(uint16 roomNumber); void saveToStream(Common::WriteStream *stream); void loadFromStream(Common::ReadStream *stream); -- cgit v1.2.3