From 4f46928444acb1da4e7cd31ac816ad6c9e7c265d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 5 Apr 2016 20:15:14 -0400 Subject: TITANIC: Fix loading of game object bounds --- engines/titanic/core/game_object.cpp | 2 +- engines/titanic/support/simple_file.cpp | 15 +++++++++++++++ engines/titanic/support/simple_file.h | 10 ++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) (limited to 'engines/titanic') diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index 26b78247ba..510e455656 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -96,7 +96,7 @@ void CGameObject::load(SimpleFile *file) { // Deliberate fall-through case 1: - _bounds = file->readRect(); + _bounds = file->readBounds(); _field34 = file->readFloat(); _field38 = file->readFloat(); _field3C = file->readFloat(); diff --git a/engines/titanic/support/simple_file.cpp b/engines/titanic/support/simple_file.cpp index fccf6c5b4f..88d74a9f47 100644 --- a/engines/titanic/support/simple_file.cpp +++ b/engines/titanic/support/simple_file.cpp @@ -213,6 +213,16 @@ Rect SimpleFile::readRect() { return r; } +Rect SimpleFile::readBounds() { + Rect r; + r.left = readNumber(); + r.top = readNumber(); + r.setWidth(readNumber()); + r.setHeight(readNumber()); + + return r; +} + void SimpleFile::readBuffer(char *buffer, size_t count) { CString tempString = readString(); if (buffer) { @@ -309,6 +319,11 @@ void SimpleFile::writeRect(const Rect &r, int indent) { writePoint(Point(r.right, r.bottom), indent); } +void SimpleFile::writeBounds(const Rect &r, int indent) { + writePoint(Point(r.left, r.top), indent); + writePoint(Point(r.width(), r.height()), indent); +} + void SimpleFile::writeIndent(uint indent) { for (uint idx = 0; idx < indent; ++idx) write("\t", 1); diff --git a/engines/titanic/support/simple_file.h b/engines/titanic/support/simple_file.h index 0ba7699088..115e3805da 100644 --- a/engines/titanic/support/simple_file.h +++ b/engines/titanic/support/simple_file.h @@ -111,6 +111,11 @@ public: */ Rect readRect(); + /** + * Rect in a bounds + */ + Rect readBounds(); + /** * Read a string and copy it into an optionally passed buffer */ @@ -166,6 +171,11 @@ public: */ void writeRect(const Rect &r, int indent); + /** + * Write out a bounds line + */ + void writeBounds(const Rect &r, int indent); + /** * Write out a number of tabs to form an indent in the output */ -- cgit v1.2.3