diff options
-rw-r--r-- | engines/bladerunner/savefile.cpp | 14 | ||||
-rw-r--r-- | engines/bladerunner/savefile.h | 6 | ||||
-rw-r--r-- | engines/bladerunner/ui/kia_section_save.cpp | 2 |
3 files changed, 12 insertions, 10 deletions
diff --git a/engines/bladerunner/savefile.cpp b/engines/bladerunner/savefile.cpp index ed6217925b..b556b81756 100644 --- a/engines/bladerunner/savefile.cpp +++ b/engines/bladerunner/savefile.cpp @@ -182,10 +182,12 @@ void SaveFileWriteStream::writeBool(bool v) { writeUint32LE(v); } -void SaveFileWriteStream::writeStringSz(const Common::String &s, int sz) { - assert(s.size() < (uint)sz); - write(s.begin(), s.size()); - padBytes((uint)sz - s.size()); +void SaveFileWriteStream::writeStringSz(const Common::String &s, uint sz) { + uint32 sizeToWrite = MIN(sz, s.size()); + write(s.begin(), sizeToWrite); + if (sizeToWrite < sz) { + padBytes(sz - sizeToWrite); + } } void SaveFileWriteStream::writeVector2(const Vector2 &v) { @@ -238,10 +240,10 @@ bool SaveFileReadStream::readBool() { return readUint32LE(); } -Common::String SaveFileReadStream::readStringSz(int sz) { +Common::String SaveFileReadStream::readStringSz(uint sz) { char *buf = new char[sz]; read(buf, sz); - Common::String result = buf; + Common::String result(buf, sz); delete[] buf; return result; } diff --git a/engines/bladerunner/savefile.h b/engines/bladerunner/savefile.h index 32b1fc1d49..529be377b5 100644 --- a/engines/bladerunner/savefile.h +++ b/engines/bladerunner/savefile.h @@ -60,9 +60,9 @@ class SaveFileManager { private: static const uint32 kTag = MKTAG('B', 'R', 'S', 'V'); static const uint32 kVersion = 1; - static const uint32 kNameLength = 32; public: + static const uint32 kNameLength = 32; static const uint32 kThumbnailSize = 9600; // 80x60x16bpp static SaveStateList list(const Common::String &target); @@ -96,7 +96,7 @@ public: void writeInt(int v); void writeFloat(float v); void writeBool(bool v); - void writeStringSz(const Common::String &s, int sz); + void writeStringSz(const Common::String &s, uint sz); void writeVector2(const Vector2 &v); void writeVector3(const Vector3 &v); void writeRect(const Common::Rect &v); @@ -119,7 +119,7 @@ public: int readInt(); float readFloat(); bool readBool(); - Common::String readStringSz(int sz); + Common::String readStringSz(uint sz); Vector2 readVector2(); Vector3 readVector3(); Common::Rect readRect(); diff --git a/engines/bladerunner/ui/kia_section_save.cpp b/engines/bladerunner/ui/kia_section_save.cpp index 0dbd6033c1..f72254bafd 100644 --- a/engines/bladerunner/ui/kia_section_save.cpp +++ b/engines/bladerunner/ui/kia_section_save.cpp @@ -48,7 +48,7 @@ KIASectionSave::KIASectionSave(BladeRunnerEngine *vm) : KIASectionBase(vm) { _scrollBox = new UIScrollBox(_vm, scrollBoxCallback, this, 1024, 0, true, Common::Rect(155, 158, 461, 346), Common::Rect(506, 160, 506, 350)); _uiContainer->add(_scrollBox); - _inputBox = new UIInputBox(_vm, inputBoxCallback, this, Common::Rect(155, 367, 461, 376), 41, ""); + _inputBox = new UIInputBox(_vm, inputBoxCallback, this, Common::Rect(155, 367, 461, 376), SaveFileManager::kNameLength, ""); // original game had limit 41 characters _uiContainer->add(_inputBox); _inputBox->hide(); |