diff --git a/engines/grim/bitmap.cpp b/engines/grim/bitmap.cpp index 10debb4f4a5..1313aeac0e2 100644 --- a/engines/grim/bitmap.cpp +++ b/engines/grim/bitmap.cpp @@ -305,9 +305,6 @@ Bitmap::~Bitmap() { g_grim->killBitmap(this); } -void Bitmap::restoreState(SaveGame *state) { -} - void BitmapData::convertToColorFormat(int num, int format) { // Supports 1555->RGBA, RGBA->565 unsigned char red = 0, green = 0, blue = 0, alpha = 0; diff --git a/engines/grim/bitmap.h b/engines/grim/bitmap.h index 37b54854991..70abb6add8e 100644 --- a/engines/grim/bitmap.h +++ b/engines/grim/bitmap.h @@ -70,8 +70,6 @@ public: Bitmap(const char *data, int width, int height, int bpp, const char *filename); Bitmap(); - void restoreState(SaveGame *state); - const Common::String &getFilename() const { return _data->_fname; } void draw() const; diff --git a/engines/grim/color.cpp b/engines/grim/color.cpp new file mode 100644 index 00000000000..33ad448757d --- /dev/null +++ b/engines/grim/color.cpp @@ -0,0 +1,69 @@ +/* Residual - A 3D game interpreter + * + * Residual is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * + */ + +#include "engines/grim/color.h" +#include "engines/grim/savegame.h" + +namespace Grim { + +Color::Color(byte r, byte g, byte b) : + Object() { + _vals[0] = r; + _vals[1] = g; + _vals[2] = b; +} + +Color::Color(const Color& c) : + Object() { + _vals[0] = c._vals[0]; + _vals[1] = c._vals[1]; + _vals[2] = c._vals[2]; +} + +Color& Color::operator =(const Color &c) { + _vals[0] = c._vals[0]; + _vals[1] = c._vals[1]; + _vals[2] = c._vals[2]; + return *this; +} + +Color& Color::operator =(Color *c) { + _vals[0] = c->_vals[0]; + _vals[1] = c->_vals[1]; + _vals[2] = c->_vals[2]; + return *this; +} + +void Color::restoreState(SaveGame *state) { + getRed() = state->readByte(); + getGreen() = state->readByte(); + getBlue() = state->readByte(); +} + +void Color::saveState(SaveGame *state) { + state->writeByte(getRed()); + state->writeByte(getGreen()); + state->writeByte(getBlue()); +} + +} // end of namespace Grim + diff --git a/engines/grim/grim.cpp b/engines/grim/grim.cpp index f0b925d6246..fb868d78fa6 100644 --- a/engines/grim/grim.cpp +++ b/engines/grim/grim.cpp @@ -1151,22 +1151,13 @@ void GrimEngine::savegameRestore() { g_movie->pause(true); // free all resource - killColors(); - killBitmaps(); - killFonts(); - killObjectStates(); - killScenes(); - killTextObjects(); - killPrimitiveObjects(); - killActors(); - // lock resources _selectedActor = NULL; _talkingActor = NULL; - //if (_currScene) - // removeScene(_currScene); - //delete _currScene; + if (_currScene) + removeScene(_currScene); + delete _currScene; _currScene = NULL; restoreColors(_savedState); @@ -1281,6 +1272,8 @@ void GrimEngine::restoreObjectStates(SaveGame *state) { void GrimEngine::restoreBitmaps(SaveGame *state) { state->beginSection('VBUF'); + killBitmaps(); + int32 size = state->readLESint32(); for (int32 i = 0; i < size; ++i) { int32 id = state->readLEUint32(); @@ -1304,6 +1297,8 @@ void GrimEngine::restoreBitmaps(SaveGame *state) { void GrimEngine::restoreFonts(SaveGame *state) { state->beginSection('FONT'); + killFonts(); + int32 size = state->readLESint32(); for (int32 i = 0; i < size; ++i) { int32 id = state->readLEUint32(); diff --git a/engines/grim/module.mk b/engines/grim/module.mk index 7ead1c8f55e..2e862eca9dc 100644 --- a/engines/grim/module.mk +++ b/engines/grim/module.mk @@ -42,6 +42,7 @@ MODULE_OBJS := \ actor.o \ bitmap.o \ costume.o \ + color.o \ colormap.o \ detection.o \ font.o \