From b2fa7e58a395b883e7c59ecb1f29f8fc6607885b Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 28 Oct 2010 00:26:25 +0000 Subject: SWORD25: Start to rename read/write methods of *PersistenceBlock classes All should be renamed to reduce risk of accidental incorrect use. svn-id: r53899 --- engines/sword25/gfx/animation.cpp | 16 ++++++++-------- engines/sword25/gfx/animationtemplate.cpp | 12 ++++++------ engines/sword25/gfx/staticbitmap.cpp | 4 ++-- engines/sword25/gfx/text.cpp | 8 ++++---- engines/sword25/input/inputengine.cpp | 8 ++++---- engines/sword25/kernel/inputpersistenceblock.cpp | 4 ++-- engines/sword25/kernel/inputpersistenceblock.h | 4 ++-- engines/sword25/kernel/outputpersistenceblock.cpp | 11 ++--------- engines/sword25/kernel/outputpersistenceblock.h | 5 ++--- engines/sword25/script/luascript.cpp | 4 ++-- 10 files changed, 34 insertions(+), 42 deletions(-) (limited to 'engines/sword25') diff --git a/engines/sword25/gfx/animation.cpp b/engines/sword25/gfx/animation.cpp index ed0f807234..0d3baae347 100644 --- a/engines/sword25/gfx/animation.cpp +++ b/engines/sword25/gfx/animation.cpp @@ -562,7 +562,7 @@ bool Animation::persist(OutputPersistenceBlock &writer) { if (_animationResourcePtr) { uint marker = 0; writer.write(marker); - writer.write(_animationResourcePtr->getFileName()); + writer.writeString(_animationResourcePtr->getFileName()); } else if (_animationTemplateHandle) { uint marker = 1; writer.write(marker); @@ -578,13 +578,13 @@ bool Animation::persist(OutputPersistenceBlock &writer) { // The following is only there to for compatibility with older saves // resp. the original engine. writer.write((uint)1); - writer.write(Common::String("LuaLoopPointCB")); + writer.writeString("LuaLoopPointCB"); writer.write(getHandle()); writer.write((uint)1); - writer.write(Common::String("LuaActionCB")); + writer.writeString("LuaActionCB"); writer.write(getHandle()); writer.write((uint)1); - writer.write(Common::String("LuaDeleteCB")); + writer.writeString("LuaDeleteCB"); writer.write(getHandle()); result &= RenderObject::persistChildren(writer); @@ -617,7 +617,7 @@ bool Animation::unpersist(InputPersistenceBlock &reader) { reader.read(marker); if (marker == 0) { Common::String resourceFilename; - reader.read(resourceFilename); + reader.readString(resourceFilename); initializeAnimationResource(resourceFilename); } else if (marker == 1) { reader.read(_animationTemplateHandle); @@ -639,7 +639,7 @@ bool Animation::unpersist(InputPersistenceBlock &reader) { // loop point callback reader.read(callbackCount); assert(callbackCount == 1); - reader.read(callbackFunctionName); + reader.readString(callbackFunctionName); assert(callbackFunctionName == "LuaLoopPointCB"); reader.read(callbackData); assert(callbackData == getHandle()); @@ -647,7 +647,7 @@ bool Animation::unpersist(InputPersistenceBlock &reader) { // loop point callback reader.read(callbackCount); assert(callbackCount == 1); - reader.read(callbackFunctionName); + reader.readString(callbackFunctionName); assert(callbackFunctionName == "LuaActionCB"); reader.read(callbackData); assert(callbackData == getHandle()); @@ -655,7 +655,7 @@ bool Animation::unpersist(InputPersistenceBlock &reader) { // loop point callback reader.read(callbackCount); assert(callbackCount == 1); - reader.read(callbackFunctionName); + reader.readString(callbackFunctionName); assert(callbackFunctionName == "LuaDeleteCB"); reader.read(callbackData); assert(callbackData == getHandle()); diff --git a/engines/sword25/gfx/animationtemplate.cpp b/engines/sword25/gfx/animationtemplate.cpp index 948dfbfa4d..4a060dbad9 100644 --- a/engines/sword25/gfx/animationtemplate.cpp +++ b/engines/sword25/gfx/animationtemplate.cpp @@ -195,13 +195,13 @@ bool AnimationTemplate::persist(OutputPersistenceBlock &writer) { writer.write(Iter->hotspotY); writer.write(Iter->flipV); writer.write(Iter->flipH); - writer.write(Iter->fileName); - writer.write(Iter->action); + writer.writeString(Iter->fileName); + writer.writeString(Iter->action); ++Iter; } // Restliche Member persistieren. - writer.write(_sourceAnimationPtr->getFileName()); + writer.writeString(_sourceAnimationPtr->getFileName()); writer.write(_valid); return Result; @@ -224,15 +224,15 @@ bool AnimationTemplate::unpersist(InputPersistenceBlock &reader) { reader.read(frame.hotspotY); reader.read(frame.flipV); reader.read(frame.flipH); - reader.read(frame.fileName); - reader.read(frame.action); + reader.readString(frame.fileName); + reader.readString(frame.action); _frames.push_back(frame); } // Die Animations-Resource wird für die gesamte Lebensdauer des Objektes gelockt Common::String sourceAnimation; - reader.read(sourceAnimation); + reader.readString(sourceAnimation); _sourceAnimationPtr = requestSourceAnimation(sourceAnimation); reader.read(_valid); diff --git a/engines/sword25/gfx/staticbitmap.cpp b/engines/sword25/gfx/staticbitmap.cpp index bbcadb11c6..3019fe0ac1 100644 --- a/engines/sword25/gfx/staticbitmap.cpp +++ b/engines/sword25/gfx/staticbitmap.cpp @@ -162,7 +162,7 @@ bool StaticBitmap::persist(OutputPersistenceBlock &writer) { bool result = true; result &= Bitmap::persist(writer); - writer.write(_resourceFilename); + writer.writeString(_resourceFilename); result &= RenderObject::persistChildren(writer); @@ -174,7 +174,7 @@ bool StaticBitmap::unpersist(InputPersistenceBlock &reader) { result &= Bitmap::unpersist(reader); Common::String resourceFilename; - reader.read(resourceFilename); + reader.readString(resourceFilename); result &= initBitmapResource(resourceFilename); result &= RenderObject::unpersistChildren(reader); diff --git a/engines/sword25/gfx/text.cpp b/engines/sword25/gfx/text.cpp index 55a87a41d6..b8e12ba570 100644 --- a/engines/sword25/gfx/text.cpp +++ b/engines/sword25/gfx/text.cpp @@ -313,8 +313,8 @@ bool Text::persist(OutputPersistenceBlock &writer) { result &= RenderObject::persist(writer); writer.write(_modulationColor); - writer.write(_font); - writer.write(_text); + writer.writeString(_font); + writer.writeString(_text); writer.write(_autoWrap); writer.write(_autoWrapThreshold); @@ -335,11 +335,11 @@ bool Text::unpersist(InputPersistenceBlock &reader) { // So wird das Layout automatisch aktualisiert und auch alle anderen notwendigen Methoden ausgeführt. Common::String font; - reader.read(font); + reader.readString(font); setFont(font); Common::String text; - reader.read(text); + reader.readString(text); setText(text); bool autoWrap; diff --git a/engines/sword25/input/inputengine.cpp b/engines/sword25/input/inputengine.cpp index 7c110a92bb..8dc98ba3fb 100644 --- a/engines/sword25/input/inputengine.cpp +++ b/engines/sword25/input/inputengine.cpp @@ -243,13 +243,13 @@ bool InputEngine::persist(OutputPersistenceBlock &writer) { // Note: We do this only for compatibility with older engines resp. // the original engine. writer.write((uint)1); - writer.write(Common::String("LuaCommandCB")); + writer.writeString("LuaCommandCB"); // Write out the number of command callbacks and their names. // Note: We do this only for compatibility with older engines resp. // the original engine. writer.write((uint)1); - writer.write(Common::String("LuaCharacterCB")); + writer.writeString("LuaCharacterCB"); return true; } @@ -264,7 +264,7 @@ bool InputEngine::unpersist(InputPersistenceBlock &reader) { reader.read(commandCallbackCount); assert(commandCallbackCount == 1); - reader.read(callbackFunctionName); + reader.readString(callbackFunctionName); assert(callbackFunctionName == "LuaCommandCB"); // Read number of character callbacks and their names. @@ -274,7 +274,7 @@ bool InputEngine::unpersist(InputPersistenceBlock &reader) { reader.read(characterCallbackCount); assert(characterCallbackCount == 1); - reader.read(callbackFunctionName); + reader.readString(callbackFunctionName); assert(callbackFunctionName == "LuaCharacterCB"); return reader.isGood(); diff --git a/engines/sword25/kernel/inputpersistenceblock.cpp b/engines/sword25/kernel/inputpersistenceblock.cpp index 132e08918d..652c2f362f 100644 --- a/engines/sword25/kernel/inputpersistenceblock.cpp +++ b/engines/sword25/kernel/inputpersistenceblock.cpp @@ -93,7 +93,7 @@ void InputPersistenceBlock::read(bool &value) { } } -void InputPersistenceBlock::read(Common::String &value) { +void InputPersistenceBlock::readString(Common::String &value) { value = ""; if (checkMarker(STRING_MARKER)) { @@ -107,7 +107,7 @@ void InputPersistenceBlock::read(Common::String &value) { } } -void InputPersistenceBlock::read(Common::Array &value) { +void InputPersistenceBlock::readByteArray(Common::Array &value) { if (checkMarker(BLOCK_MARKER)) { uint size; read(size); diff --git a/engines/sword25/kernel/inputpersistenceblock.h b/engines/sword25/kernel/inputpersistenceblock.h index a941d3cb5c..f6ab256460 100644 --- a/engines/sword25/kernel/inputpersistenceblock.h +++ b/engines/sword25/kernel/inputpersistenceblock.h @@ -57,8 +57,8 @@ public: void read(uint &value); void read(float &value); void read(bool &value); - void read(Common::String &value); - void read(Common::Array &value); + void readString(Common::String &value); + void readByteArray(Common::Array &value); bool isGood() const { return _errorState == NONE; diff --git a/engines/sword25/kernel/outputpersistenceblock.cpp b/engines/sword25/kernel/outputpersistenceblock.cpp index b81f3c1bbe..b1c3233b59 100644 --- a/engines/sword25/kernel/outputpersistenceblock.cpp +++ b/engines/sword25/kernel/outputpersistenceblock.cpp @@ -72,27 +72,20 @@ void OutputPersistenceBlock::write(bool value) { rawWrite(&uintBool, sizeof(uintBool)); } -void OutputPersistenceBlock::write(const Common::String &string) { +void OutputPersistenceBlock::writeString(const Common::String &string) { writeMarker(STRING_MARKER); write(string.size()); rawWrite(string.c_str(), string.size()); } -void OutputPersistenceBlock::write(Common::Array &value) { +void OutputPersistenceBlock::writeByteArray(Common::Array &value) { writeMarker(BLOCK_MARKER); write((uint)value.size()); rawWrite(&value[0], value.size()); } -void OutputPersistenceBlock::write(const void *bufferPtr, size_t size) { - writeMarker(BLOCK_MARKER); - - write((int)size); - rawWrite(bufferPtr, size); -} - void OutputPersistenceBlock::writeMarker(byte marker) { _data.push_back(marker); } diff --git a/engines/sword25/kernel/outputpersistenceblock.h b/engines/sword25/kernel/outputpersistenceblock.h index a7b0673f6f..71dbe68a52 100644 --- a/engines/sword25/kernel/outputpersistenceblock.h +++ b/engines/sword25/kernel/outputpersistenceblock.h @@ -48,9 +48,8 @@ public: void write(uint value); void write(float value); void write(bool value); - void write(const Common::String &string); - void write(Common::Array &value); - void write(const void *bufferPtr, size_t size); + void writeString(const Common::String &string); + void writeByteArray(Common::Array &value); const void *getData() const { return &_data[0]; diff --git a/engines/sword25/script/luascript.cpp b/engines/sword25/script/luascript.cpp index ad5fad1322..aa2bdb9e06 100644 --- a/engines/sword25/script/luascript.cpp +++ b/engines/sword25/script/luascript.cpp @@ -419,7 +419,7 @@ bool LuaScriptEngine::persist(OutputPersistenceBlock &writer) { pluto_persist(_state, chunkwriter, &chunkData); // Persistenzdaten in den Writer schreiben. - writer.write(chunkData); + writer.writeByteArray(chunkData); // Die beiden Tabellen vom Stack nehmen. lua_pop(_state, 2); @@ -516,7 +516,7 @@ bool LuaScriptEngine::unpersist(InputPersistenceBlock &reader) { // Persisted Lua data Common::Array chunkData; - reader.read(chunkData); + reader.readByteArray(chunkData); // Chunk-Reader initialisation. It is used with pluto_unpersist to restore read data ChunkreaderData cd; -- cgit v1.2.3