diff options
author | Johannes Schickel | 2011-07-02 20:25:32 +0200 |
---|---|---|
committer | Johannes Schickel | 2011-07-02 21:07:55 +0200 |
commit | 09501be85bee9f686a7815fc0f47a1e16008f38d (patch) | |
tree | 5aecb20411d3300a185214f3a6590888f4559b35 /engines/savestate.cpp | |
parent | a5b0792295f46ebcf5d30df975bd2056bc4a695f (diff) | |
download | scummvm-rg350-09501be85bee9f686a7815fc0f47a1e16008f38d.tar.gz scummvm-rg350-09501be85bee9f686a7815fc0f47a1e16008f38d.tar.bz2 scummvm-rg350-09501be85bee9f686a7815fc0f47a1e16008f38d.zip |
ENGINES: Clean up SaveStateDescriptor.
Now SaveStateDescriptor no longer subclasses HashMap. Instead all possible
saved meta data is included directly into SaveStateDescriptor.
This is slightly less flexible, but we never needed that flexibility so far.
On the other hand it should reduce the memory usage. At least on my system
(Linux/amd64) the old SaveStateDescriptor had a size of 928 and the new
SaveStateDescriptor has a size of 200.
Diffstat (limited to 'engines/savestate.cpp')
-rw-r--r-- | engines/savestate.cpp | 43 |
1 files changed, 14 insertions, 29 deletions
diff --git a/engines/savestate.cpp b/engines/savestate.cpp index 551c39b880..0b187ce630 100644 --- a/engines/savestate.cpp +++ b/engines/savestate.cpp @@ -24,49 +24,34 @@ #include "graphics/surface.h" #include "common/textconsole.h" -void SaveStateDescriptor::setThumbnail(Graphics::Surface *t) { - if (_thumbnail.get() == t) - return; - - _thumbnail = Common::SharedPtr<Graphics::Surface>(t, Graphics::SharedPtrSurfaceDeleter()); +SaveStateDescriptor::SaveStateDescriptor() + // FIXME: default to 0 (first slot) or to -1 (invalid slot) ? + : _slot(-1), _description(), _isDeletable(true), _isWriteProtected(false), + _saveDate(), _saveTime(), _playTime(), _thumbnail() { } -bool SaveStateDescriptor::getBool(const Common::String &key) const { - if (contains(key)) { - const Common::String value = getVal(key); - bool valueAsBool; - if (Common::parseBool(value, valueAsBool)) - return valueAsBool; - error("SaveStateDescriptor: %s '%s' has unknown value '%s' for boolean '%s'", - save_slot().c_str(), description().c_str(), value.c_str(), key.c_str()); - } - return false; +SaveStateDescriptor::SaveStateDescriptor(int s, const Common::String &d) + : _slot(s), _description(d), _isDeletable(true), _isWriteProtected(false), + _saveDate(), _saveTime(), _playTime(), _thumbnail() { } -void SaveStateDescriptor::setDeletableFlag(bool state) { - setVal("is_deletable", state ? "true" : "false"); -} +void SaveStateDescriptor::setThumbnail(Graphics::Surface *t) { + if (_thumbnail.get() == t) + return; -void SaveStateDescriptor::setWriteProtectedFlag(bool state) { - setVal("is_write_protected", state ? "true" : "false"); + _thumbnail = Common::SharedPtr<Graphics::Surface>(t, Graphics::SharedPtrSurfaceDeleter()); } void SaveStateDescriptor::setSaveDate(int year, int month, int day) { - Common::String buffer; - buffer = Common::String::format("%.2d.%.2d.%.4d", day, month, year); - setVal("save_date", buffer); + _saveDate = Common::String::format("%.2d.%.2d.%.4d", day, month, year); } void SaveStateDescriptor::setSaveTime(int hour, int min) { - Common::String buffer; - buffer = Common::String::format("%.2d:%.2d", hour, min); - setVal("save_time", buffer); + _saveTime = Common::String::format("%.2d:%.2d", hour, min); } void SaveStateDescriptor::setPlayTime(int hours, int minutes) { - Common::String buffer; - buffer = Common::String::format("%.2d:%.2d", hours, minutes); - setVal("play_time", buffer); + _playTime = Common::String::format("%.2d:%.2d", hours, minutes); } void SaveStateDescriptor::setPlayTime(uint32 msecs) { |