From cff70f9fad6f6213e88c09faffabc5f92033d74a Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Mon, 21 Mar 2011 17:18:04 +0100 Subject: [PATCH] Cleanings. Mostly indent fixes. --- engines/grim/actor.cpp | 4 ++-- engines/grim/bitmap.cpp | 5 +++++ engines/grim/bitmap.h | 2 +- engines/grim/costume.cpp | 14 +++++++------- engines/grim/costume.h | 6 +++--- engines/grim/grim.h | 4 ++-- engines/grim/objectstate.h | 6 +++--- engines/grim/savegame.cpp | 38 ++++++++++++++++++------------------- engines/grim/savegame.h | 12 ++++++------ engines/grim/scene.cpp | 4 ++-- engines/grim/scene.h | 2 +- engines/grim/textobject.cpp | 4 ---- engines/grim/textobject.h | 4 ++-- engines/grim/walkplane.cpp | 12 ++---------- engines/grim/walkplane.h | 4 ++-- 15 files changed, 57 insertions(+), 64 deletions(-) diff --git a/engines/grim/actor.cpp b/engines/grim/actor.cpp index e56155b8380..d75277b816e 100644 --- a/engines/grim/actor.cpp +++ b/engines/grim/actor.cpp @@ -805,7 +805,7 @@ Costume *Actor::findCostume(const char *n) { for (Common::List::iterator i = _costumeStack.begin(); i != _costumeStack.end(); ++i) { if (strcasecmp((*i)->filename(), n) == 0) return *i; - } + } return NULL; } @@ -857,7 +857,7 @@ void Actor::update() { // _turning = false; } else { _pos += dir * walkAmt; - } + } _walkedCur = true; } diff --git a/engines/grim/bitmap.cpp b/engines/grim/bitmap.cpp index 67ecbea64a2..f014416f838 100644 --- a/engines/grim/bitmap.cpp +++ b/engines/grim/bitmap.cpp @@ -108,6 +108,11 @@ Bitmap::Bitmap(const char *data, int w, int h, const char *fname) : Object() { g_driver->createBitmap(this); } +Bitmap::Bitmap() : + Object() { + _data = NULL; +} + void Bitmap::draw() const { if (_currImage == 0) return; diff --git a/engines/grim/bitmap.h b/engines/grim/bitmap.h index 0d197cff412..289db615825 100644 --- a/engines/grim/bitmap.h +++ b/engines/grim/bitmap.h @@ -37,7 +37,7 @@ public: // Construct a bitmap from the given data. Bitmap(const char *filename, const char *data, int len); Bitmap(const char *data, int width, int height, const char *filename); - Bitmap() : Object() { _data = 0; } + Bitmap(); const char *filename() const { return _fname.c_str(); } diff --git a/engines/grim/costume.cpp b/engines/grim/costume.cpp index e0a89cba7e5..ec47bb935ec 100644 --- a/engines/grim/costume.cpp +++ b/engines/grim/costume.cpp @@ -589,9 +589,9 @@ public: void setKey(int val); void reset(); ~SoundComponent() { - // Stop the sound if it's in progress - reset(); - } + // Stop the sound if it's in progress + reset(); + } private: Common::String _soundName; @@ -637,9 +637,9 @@ void SoundComponent::reset() { } Costume::Costume(const char *fname, const char *data, int len, Costume *prevCost) : - Object() { + Object() { - load(fname, data, len, prevCost); + load(fname, data, len, prevCost); } void Costume::load(const char *filename, const char *data, int len, Costume *prevCost) { @@ -651,7 +651,7 @@ void Costume::load(const char *filename, const char *data, int len, Costume *pre _headPitch = 0; _lastTime = 0; _headZ = 0; - _prevCostume = prevCost; + _prevCostume = prevCost; TextSplitter ts(data, len); @@ -1113,7 +1113,7 @@ void Costume::moveHead() { if (v.isZero()) { return; } -// cout<<_lookAt.x()<<" "<<_lookAt.y()<<" "<<_lookAt.z()<<" "< TextListType; TextListType::const_iterator textsBegin() const { return _textObjects.begin(); diff --git a/engines/grim/objectstate.h b/engines/grim/objectstate.h index dd8bb834071..6c0c875b0ba 100644 --- a/engines/grim/objectstate.h +++ b/engines/grim/objectstate.h @@ -44,11 +44,11 @@ public: }; ObjectState(int setupID, ObjectState::Position pos, const char *bitmap, const char *zbitmap, bool visible); - ObjectState(); + ObjectState(); ~ObjectState(); - void saveState(SaveGame *savedState) const; - bool restoreState(SaveGame *savedState); + void saveState(SaveGame *savedState) const; + bool restoreState(SaveGame *savedState); int setupID() const { return _setupID; } Position pos() const { return _pos; } diff --git a/engines/grim/savegame.cpp b/engines/grim/savegame.cpp index ee4b6f8dc16..33524f49e64 100644 --- a/engines/grim/savegame.cpp +++ b/engines/grim/savegame.cpp @@ -232,19 +232,19 @@ void SaveGame::writeByte(byte data) { } void SaveGame::writeVector3d(const Graphics::Vector3d &vec) { - writeFloat(vec.x()); - writeFloat(vec.y()); - writeFloat(vec.z()); + writeFloat(vec.x()); + writeFloat(vec.y()); + writeFloat(vec.z()); } void SaveGame::writeColor(const Grim::Color &color) { - writeByte(color.red()); - writeByte(color.green()); - writeByte(color.blue()); + writeByte(color.red()); + writeByte(color.green()); + writeByte(color.blue()); } void SaveGame::writeFloat(float data) { - write(reinterpret_cast(&data), sizeof(float)); + write(reinterpret_cast(&data), sizeof(float)); } void SaveGame::writeCharString(const char *string) { @@ -258,25 +258,25 @@ void SaveGame::writeString(const Common::String &string) { } Graphics::Vector3d SaveGame::readVector3d() { - float x = readFloat(); - float y = readFloat(); - float z = readFloat(); - return Graphics::Vector3d(x, y, z); + float x = readFloat(); + float y = readFloat(); + float z = readFloat(); + return Graphics::Vector3d(x, y, z); } Grim::Color SaveGame::readColor() { - Color color; - color.red() = readByte(); - color.green() = readByte(); - color.blue() = readByte(); + Color color; + color.red() = readByte(); + color.green() = readByte(); + color.blue() = readByte(); - return color; + return color; } float SaveGame::readFloat() { - float f; - read(reinterpret_cast(&f), sizeof(float)); - return f; + float f; + read(reinterpret_cast(&f), sizeof(float)); + return f; } const char *SaveGame::readCharString() { diff --git a/engines/grim/savegame.h b/engines/grim/savegame.h index 61ce79d9b7c..6e046ed69f0 100644 --- a/engines/grim/savegame.h +++ b/engines/grim/savegame.h @@ -57,12 +57,12 @@ public: void writeCharString(const char *string); void writeString(const Common::String &string); - void writeVector3d(const Graphics::Vector3d &vec); - void writeColor(const Grim::Color &color); - void writeFloat(float data); - Graphics::Vector3d readVector3d(); - Grim::Color readColor(); - float readFloat(); + void writeVector3d(const Graphics::Vector3d &vec); + void writeColor(const Grim::Color &color); + void writeFloat(float data); + Graphics::Vector3d readVector3d(); + Grim::Color readColor(); + float readFloat(); const char *readCharString(); Common::String readString(); diff --git a/engines/grim/scene.cpp b/engines/grim/scene.cpp index 4b8d47a1818..54fd1e22027 100644 --- a/engines/grim/scene.cpp +++ b/engines/grim/scene.cpp @@ -107,9 +107,9 @@ Scene::Scene(const char *sceneName, const char *buf, int len) : for (int i = 0; i < _numSectors; i++) { _sectors[i] = new Sector(); _sectors[i]->load(ts); - } + } - ++s_id; + ++s_id; _id = s_id; } diff --git a/engines/grim/scene.h b/engines/grim/scene.h index a65d034f928..d1adb7526ee 100644 --- a/engines/grim/scene.h +++ b/engines/grim/scene.h @@ -41,7 +41,7 @@ public: ~Scene(); void saveState(SaveGame *savedState) const; - bool restoreState(SaveGame *savedState); + bool restoreState(SaveGame *savedState); int _minVolume; int _maxVolume; diff --git a/engines/grim/textobject.cpp b/engines/grim/textobject.cpp index da6e23c26b1..c187d3196d3 100644 --- a/engines/grim/textobject.cpp +++ b/engines/grim/textobject.cpp @@ -75,8 +75,6 @@ TextObject::~TextObject() { } void TextObject::saveState(SaveGame *state) const { -// state->writeLESint32(_created); - state->writeColor(_fgColor); state->writeLESint32(_x); @@ -96,8 +94,6 @@ void TextObject::saveState(SaveGame *state) const { } bool TextObject::restoreState(SaveGame *state) { -// _created = state->readLESint32(); - _fgColor = state->readColor(); _x = state->readLESint32(); diff --git a/engines/grim/textobject.h b/engines/grim/textobject.h index 4c9b976348b..248e8d87f2f 100644 --- a/engines/grim/textobject.h +++ b/engines/grim/textobject.h @@ -85,8 +85,8 @@ public: const char *name() const { return _textID; } void draw(); - void saveState(SaveGame *state) const; - bool restoreState(SaveGame *state); + void saveState(SaveGame *state) const; + bool restoreState(SaveGame *state); enum Justify { NONE, diff --git a/engines/grim/walkplane.cpp b/engines/grim/walkplane.cpp index 4c0584d6619..5c42bfd2e7c 100644 --- a/engines/grim/walkplane.cpp +++ b/engines/grim/walkplane.cpp @@ -39,10 +39,7 @@ void Sector::saveState(SaveGame *savedState) const { savedState->writeLESint32(_visible); savedState->writeFloat(_height); - const char *str = _name.c_str(); - int32 size = strlen(str); - savedState->writeLESint32(size); - savedState->write(str, size); + savedState->writeString(_name); for (int i = 0; i < _numVertices + 1; ++i) { savedState->writeVector3d(_vertices[i]); @@ -58,12 +55,7 @@ bool Sector::restoreState(SaveGame *savedState) { _visible = savedState->readLESint32(); _height = savedState->readFloat(); - int32 size = savedState->readLESint32(); - char *str = new char[size+1]; - savedState->read(str, size); - str[size]='\0'; - _name = str; - delete[] str; + _name = savedState->readString(); _vertices = new Graphics::Vector3d[_numVertices + 1]; for (int i = 0; i < _numVertices + 1; ++i) { diff --git a/engines/grim/walkplane.h b/engines/grim/walkplane.h index 7c9880f2ea6..2d3d43d3170 100644 --- a/engines/grim/walkplane.h +++ b/engines/grim/walkplane.h @@ -40,8 +40,8 @@ public: Sector() : _vertices(NULL) {} virtual ~Sector() { if (_vertices) delete[] _vertices; } - void saveState(SaveGame *savedState) const; - bool restoreState(SaveGame *savedState); + void saveState(SaveGame *savedState) const; + bool restoreState(SaveGame *savedState); void load(TextSplitter &ts);