From f21bfe1c41148368f30b0602a8e8820fbd543543 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 29 Apr 2012 11:01:40 +1000 Subject: TONY: Added resource update manager --- engines/tony/utils.cpp | 114 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 engines/tony/utils.cpp (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp new file mode 100644 index 0000000000..1368111a05 --- /dev/null +++ b/engines/tony/utils.cpp @@ -0,0 +1,114 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM 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 program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "tony/utils.h" +#include "mpal/lzo.h" + +namespace Tony { + +/****************************************************************************\ +* Resource Update +\****************************************************************************/ + +RMResUpdate::RMResUpdate() { + _infos = NULL; +} + +RMResUpdate::~RMResUpdate() { + if (_infos) { + delete[] _infos; + _infos = NULL; + } + + if (_hFile.isOpen()) + _hFile.close(); +} + +void RMResUpdate::Init(const Common::String &fileName) { + // Open the resource update file + if (!_hFile.open(fileName)) + // It doesn't exist, so exit immediately + return; + + uint8 version; + uint32 i; + + version = _hFile.readByte(); + _numUpd = _hFile.readUint32LE(); + + _infos = new ResUpdInfo[_numUpd]; + + // Load the index of the resources in the file + for (i=0; i<_numUpd; ++i) { + ResUpdInfo &info = _infos[i]; + + info.dwRes = _hFile.readUint32LE(); + info.offset = _hFile.readUint32LE(); + info.size = _hFile.readUint32LE(); + info.cmpSize = _hFile.readUint32LE(); + } +} + +const byte *RMResUpdate::QueryResource(uint32 dwRes) { + // If there isn't an update file, return NULL + if (!_hFile.isOpen()) + return NULL; + + uint32 i; + for (i=0; i < _numUpd; ++i) + if (_infos[i].dwRes == dwRes) + // Found the index + break; + + if (i==_numUpd) + // Couldn't find a matching resource, so return NULL + return NULL; + + const ResUpdInfo &info = _infos[i]; + byte *cmpBuf = new byte[info.cmpSize]; + uint32 dwRead; + + // Move to the correct offset and read in the compressed data + _hFile.seek(info.offset); + dwRead = _hFile.read(cmpBuf, info.cmpSize); + + if (info.cmpSize > dwRead) { + // Error occurred reading data, so return NULL + delete[] cmpBuf; + return NULL; + } + + // Allocate space for the output resource + byte *lpDestBuf = new byte[info.size]; + uint32 dwSize; + + // Decompress the data + MPAL::lzo1x_decompress(cmpBuf, info.cmpSize, lpDestBuf, &dwSize); + + // Delete buffer for compressed data + delete [] cmpBuf; + + // Return the resource + return lpDestBuf; +} + +} // End of namespace Tony -- cgit v1.2.3 From 118f5ca0102144b5c282f012def6c96c69052bc1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 29 Apr 2012 23:19:30 +1000 Subject: TONY: Implemented RMGameBoxes class and all dependent classes --- engines/tony/utils.cpp | 885 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 882 insertions(+), 3 deletions(-) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 1368111a05..76d168e27a 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -19,12 +19,889 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Loc.CPP.............. * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c Desc: Classi di gestione * + * z$$beu .ue=" $ "=e.. .zed$$c dei dati di una loca- * + * "#$e z$*" . `. ^*Nc e$"" zione................ * + * "$$". .r" ^4. .^$$" ..................... * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ #include "tony/utils.h" -#include "mpal/lzo.h" +#include "tony/tony.h" +#include "tony/mpal/lzo.h" namespace Tony { +/****************************************************************************\ +* RMString methods +\****************************************************************************/ + +/** + * Constructor + */ +RMString::RMString() { + m_string=NULL; + m_length=0; + m_realLength=0; +} + +/** + * Destructor + */ +RMString::~RMString() { + if (m_string != NULL) + delete[] m_string; +} + +/** + * Copy constructor + */ +RMString::RMString(const RMString &str) { + // Richiama l'overload su '=' per copiare + m_string = NULL; + m_length = 0; + m_realLength = 0; + *this = str; +} + +/** + * Constructor from a char * + */ +RMString::RMString(const char* str) { + // Use the overloaded '=' when copying + m_string = NULL; + m_length = 0; + m_realLength = 0; + *this = str; +} + +/** + * Constructor with a single passed character + */ +RMString::RMString(const int ch) { + // Use the overloaded '=' when copying + m_string = NULL; + m_length = 0; + m_realLength = 0; + *this = ch; +} + +/** + * Returns the length of the string + * @returns Length + */ +int RMString::Length() { + return m_length; +} + +/** + * Gets the character at the given index + * @param nIndex Position of the character to return + * @returns Character + */ +char RMString::GetAt(int nIndex) { + assert(nIndex < m_length); + return m_string[nIndex]; +} + +/** + * Sets the character at the given index + * @param nIndex Position of the character to change + * @param c Character + */ +void RMString::SetAt(int nIndex, char c) { + assert(nIndex < m_length); + m_string[nIndex] = c; +} + +/** + * Overloaded square brackets operator for accessing characters within the string + * @param nIndex Position of the charactre to reference + * @params Reference to the character + */ +char &RMString::operator[](int nIndex) { + assert(nIndex < m_length); + return m_string[nIndex]; +} + +/** + * Copies a string + * @param str String to copy + * @returns Refrence to our string + */ +const RMString &RMString::operator=(const RMString &str) { + // Set the new length + m_length = str.m_length; + + // If the source is empty, then destroy the current string buffer + if (m_length == 0) { + if (m_realLength > 0) { + delete[] m_string; + m_string = NULL; + m_realLength = 0; + } + } else { + // Resize if necessary + Resize(m_length + 1); + + // Copy the string + Common::copy(str.m_string, str.m_string + m_length + 1, m_string); + } + + return *this; +} + +/** + * Copies a char * string + * @param str String to copy + * @returns Refrence to our string + */ +const RMString& RMString::operator=(const char* str) { + // If the source is empty, then destroy the current string buffer + if (str == NULL) { + if (m_realLength > 0) { + delete[] m_string; + m_string = NULL; + m_realLength = m_length = 0; + } + } else { + // Calculate the new length + m_length = strlen(str); + + // Resize if necessary + Resize(m_length + 1); + + // Copy the string + Common::copy(str, str + m_length + 1, m_string); + } + + return *this; +} + +/** + * Forms a string from a passed character + * @param ch Character to copy + * @returns Refrence to our string + */ +const RMString& RMString::operator=(const int ch) { + if (ch=='\0') { + // Destroy the current string + if (m_realLength > 0) { + delete [] m_string; + m_string=NULL; + m_length=m_realLength=0; + } + } else { + // Resize if necessary + Resize(2); + + m_string[0] = ch; + m_string[1] = '\0'; + m_length = 1; + } + + return *this; +} + +/** + * Concatenate a string into the current one + * @param str String to concatenate + * @param size Length of the string + */ +void RMString::Connect(const char *str, int size) { + int nlen; + + if (size > 0) { + // Calculate the new lenght + nlen=m_length+size; + + // Resize + Resize(nlen + 1, true); + + // Linkage with '\0' + Common::copy(str, str + size + 1, m_string + m_length); + + // Save the new length + m_length = nlen; + } +} + +/** + * Concatenate a string + * @param str String to concatenate + * @returns Refrence to our string + */ +const RMString &RMString::operator+=(RMString &str) { + Connect(str,str.Length()); + return *this; +} + +/** + * Concatenate a string + * @param str String to concatenate + * @returns Refrence to our string + */ +const RMString &RMString::operator+=(const char *str) { + Connect(str,strlen(str)); + return *this; +} + +/** + * Concatenate a character + * @param ch Character to concatenate + * @returns Refrence to our string + */ +const RMString &RMString::operator+=(const int ch) { + char str[2]; + + // Create a simple string buffer to hold the single character + str[0] = ch; + str[1] = '\0'; + + Connect(str, 1); + return *this; +} + +/** + * Casts a string as char * + * @returns char * reference to string + */ +RMString::operator char*() const { + return m_string; +} + +/** + * Resize a string as necessary + * @param size New size necessary (in bytes) + * @param bMaintain If TRUE we must keep the original string, + if FALSE we can destroy. + */ +void RMString::Resize(int size, bool bMantain) { + if (m_realLength == 0) { + m_string = new char[size]; + m_realLength = size; + } else if (size > m_realLength) { + if (bMantain) { + char* app; + + app = new char[size]; + Common::copy(m_string, m_string + m_length + 1, app); + delete[] m_string; + m_string = app; + } else { + delete[] m_string; + m_string = new char[size]; + } + } +} + +/** + * Compacts the string to occupy less memory if possible. + */ +void RMString::Compact(void) { + if (m_realLength + 1 > m_length) { + char *app; + + app = new char[m_length + 1]; + Common::copy(m_string, m_string + m_length + 1, app); + + delete[] m_string; + m_string = app; + } +} + +/** + * Operator to concatenate two strings + */ +RMString operator+(const RMString &str1, const RMString &str2) { + RMString ret(str1); + + return (ret += str2); +} + +/** + * Operator to concatenate a character to a string + */ +RMString operator+(RMString &str, const int ch) { + RMString ret(str); + + return (ret += ch); +} + +RMString operator+(const int ch, RMString &str) { + RMString ret(ch); + + return (ret += str); +} + +/** + * Operator to concatenate a char * string to an RMString + */ +RMString operator+(RMString &str, const char *s) { + RMString ret(str); + + return (ret += s); +} + +RMString operator+(const char *s, RMString &str) { + RMString ret(s); + + return (ret+=str); +} + +/** + * Extracts a string from a data stream + * @param df data stream + * @param var String + */ +RMDataStream &operator>>(RMDataStream &df, RMString &var) { + uint8 len; + int i; + + df >> len; + var.Resize(len + 1); + var.m_length=len+1; + + for (i = 0; i < len; i++) + df >> var[i]; + + var[i] = '\0'; + var.m_length = len; + + return df; +} + +/** + * Formats a string + */ +void RMString::Format(char* str, ...) { + warning("TODO: Refactor RMString::Format if needed"); + /* + static char buf[2048]; + va_list argList; + + va_start(argList,str); + wvsprintf(buf,str,argList); + va_end(argList); + *this = buf; +*/ +} + +/****************************************************************************\ +* RMDataStream methods +\****************************************************************************/ + +/** + * Constructor + */ +RMDataStream::RMDataStream() { + m_length = 0; + m_pos = 0; + m_bError = false; +} + +/** + * Destructor + */ +RMDataStream::~RMDataStream() { + Close(); +} + +/** + * Close a stream + */ +void RMDataStream::Close(void) { + m_length = 0; + m_pos = 0; +} + +/** + * Takes the address of the buffer from which will be read the data. + * @param lpBuf Data buffer + * @param size Size of the buffer + * @remarks If the length of the buffer is not known, and cannot be + * specified, then EOF() and Seek() to end won't work. + */ +void RMDataStream::OpenBuffer(const byte *lpBuf, int size) { + m_length = size; + m_buf = lpBuf; + m_bError = false; + m_pos = 0; +} + +/** + * Returns the length of the stream + * @returns Stream length + */ +int RMDataStream::Length() { + return m_length; +} + +/** + * Determines if the end of the stream has been reached + * @returns TRUE if end of stream reached, FALSE if not + */ +bool RMDataStream::IsEOF() { + return (m_pos >= m_length); +} + +/** + * Extracts data from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream + */ +RMDataStream &operator>>(RMDataStream &df, char &var) { + df.Read(&var, 1); + return df; +} + +/** + * Extracts data from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream + */ +RMDataStream &operator>>(RMDataStream &df, uint8 &var) { + df.Read(&var, 1); + return df; +} + +/** + * Extracts data from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream + */ +RMDataStream &operator>>(RMDataStream &df, uint16 &var) { + uint16 v; + df.Read(&v, 2); + + var = FROM_LE_16(v); + return df; +} + +/** + * Extracts data from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream + */ +RMDataStream &operator>>(RMDataStream &df, int16 &var) { + uint16 v; + df.Read(&v, 2); + + var = (int16)FROM_LE_16(v); + return df; +} + +/** + * Extracts data from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream + */ +RMDataStream &operator>>(RMDataStream &df, int &var) { + uint32 v; + df.Read(&v, 4); + + var = (int)FROM_LE_32(v); + return df; +} + +/** + * Extracts data from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream + */ +RMDataStream &operator>>(RMDataStream &df, uint32 &var) { + uint32 v; + df.Read(&v, 4); + + var = FROM_LE_32(v); + return df; +} + +/** + * Reads a series of data from the stream in a buffer + * @param lpBuf Data buffer + * @param size Size of the buffer + * @returns TRUE if we have reached the end, FALSE if not + */ +bool RMDataStream::Read(void *lpBuf, int size) { + byte *dest = (byte *)lpBuf; + + if ((m_pos + size) > m_length) { + Common::copy(m_buf + m_pos, m_buf + m_pos + (m_length - m_pos), dest); + + return true; + } else { + Common::copy(m_buf + m_pos, m_buf + m_pos + size, dest); + + m_pos += size; + return false; + } +} + +/** + * Skips a number of bytes in the stream + * @param nBytres Number of bytes to skip + * @returns The stream + */ +RMDataStream &RMDataStream::operator+=(int nBytes) { + m_pos+=nBytes; + return *this; +} + +/** + * Seeks to a position within the stream + * @param nBytes Number of bytes from specified origin + * @param origin Origin to do offset from + * @returns The absolute current position in bytes + */ +int RMDataStream::Seek(int nBytes, RMDSPos origin) { + switch (origin) { + case CUR: + break; + + case START: + m_pos=0; + break; + + case END: + if (m_length == SIZENOTKNOWN) + return m_pos; + m_pos=m_length; + break; + } + + m_pos+=nBytes; + return m_pos; +} + +/** + * Returns the current position of the stream + * @returns The current position + */ +int RMDataStream::Pos() { + return m_pos; +} + +/** + * Check if an error occurred during reading the stream + * @returns TRUE if there was an error, false otherwise + */ +bool RMDataStream::IsError() { + return m_bError; +} + +/** + * Sets an error code for the stream + * @param code Error code + */ +void RMDataStream::SetError(int code) { + m_bError = true; + m_ecode = code; +} + +/** + * Returns the error code for the stream + * @returns Error code + */ +int RMDataStream::GetError() { + return m_ecode; +} + +/****************************************************************************\ +* RMPoint methods +\****************************************************************************/ + +/** + * Constructor + */ +RMPoint::RMPoint() { + x = y = 0; +} + +/** + * Copy constructor + */ +RMPoint::RMPoint(const RMPoint &p) { + x=p.x; + y=p.y; +} + +/** + * Constructor with integer parameters + */ +RMPoint::RMPoint(int x1, int y1) { + x = x1; + y = y1; +} + +/** + * Copy operator + */ +RMPoint &RMPoint::operator=(RMPoint p) { + x = p.x; + y = p.y; + + return *this; +} + +/** + * Offsets the point by another point + */ +void RMPoint::Offset(RMPoint p) { + x += p.x; + y += p.y; +} + +/** + * Offsets the point by a specified offset + */ +void RMPoint::Offset(int xOff, int yOff) { + x += xOff; + y += yOff; +} + +/** + * Sums together two points + */ +RMPoint operator+(RMPoint p1, RMPoint p2) { + RMPoint p(p1); + + return (p += p2); +} + +/** + * Subtracts two points + */ +RMPoint operator-(RMPoint p1, RMPoint p2) { + RMPoint p(p1); + + return (p -= p2); +} + +/** + * Sum (offset) of a point + */ +RMPoint &RMPoint::operator+=(RMPoint p) { + Offset(p); + return *this; +} + +/** + * Subtract (offset) of a point + */ +RMPoint& RMPoint::operator-=(RMPoint p) { + Offset(-p); + return *this; +} + +/** + * Inverts a point + */ +RMPoint RMPoint::operator-() { + RMPoint p; + + p.x = -x; + p.y = -y; + + return p; +} + +/** + * Equality operator + */ +bool RMPoint::operator==(RMPoint p) { + return ((x == p.x) && (y == p.y)); +} + +/** + * Not equal operator + */ +bool RMPoint::operator!=(RMPoint p) { + return ((x != p.x) || (y != p.y)); +} + +/** + * Reads a point from a stream + */ +RMDataStream &operator>>(RMDataStream &ds, RMPoint &p) { + ds >> p.x >> p.y; + return ds; +} + +/****************************************************************************\ +* RMRect methods +\****************************************************************************/ + +RMRect::RMRect() { + SetEmpty(); +} + +void RMRect::SetEmpty(void) { + x1 = y1 = x2 = y2 = 0; +} + +RMRect::RMRect(RMPoint p1, RMPoint p2) { + SetRect(p1, p2); +} + +RMRect::RMRect(int X1, int Y1, int X2, int Y2) { + SetRect(X1, Y1, X2, Y2); +} + +RMRect::RMRect(const RMRect &rc) { + CopyRect(rc); +} + +void RMRect::SetRect(RMPoint p1, RMPoint p2) { + x1 = p1.x; + y1 = p1.y; + x2 = p2.x; + y2 = p2.y; +} + +void RMRect::SetRect(int X1, int Y1, int X2, int Y2) { + x1 = X1; + y1 = Y1; + x2 = X2; + y2 = Y2; +} + +void RMRect::SetRect(const RMRect &rc) { + CopyRect(rc); +} + +void RMRect::CopyRect(const RMRect &rc) { + x1 = rc.x1; + y1 = rc.y1; + x2 = rc.x2; + y2 = rc.y2; +} + +RMPoint &RMRect::TopLeft() { + // FIXME: This seems very bad + return *((RMPoint *)this); +} + +RMPoint& RMRect::BottomRight() { + // FIXME: This seems very bad + return *((RMPoint*)this + 1); +} + +RMPoint RMRect::Center() { + return RMPoint((x2 - x1) / 2,(y2 - y1) / 2); +} + +int RMRect::Width() { + return x2 - x1; +} + +int RMRect::Height() { + return y2 - y1; +} + +int RMRect::Size() { + return Width() * Height(); +} + +bool RMRect::IsEmpty() { + return (x1 == 0 && y1 == 0 && x2 == 0 && y2 == 0); +} + +const RMRect& RMRect::operator=(const RMRect &rc) { + CopyRect(rc); + return *this; +} + +void RMRect::Offset(int xOff, int yOff) { + x1 += xOff; + y1 += yOff; + x2 += xOff; + y2 += yOff; +} + +void RMRect::Offset(RMPoint p) { + x1 += p.x; + y1 += p.y; + x2 += p.x; + y2 += p.y; +} + +const RMRect &RMRect::operator+=(RMPoint p) { + Offset(p); + return *this; +} + +const RMRect &RMRect::operator-=(RMPoint p) { + Offset(-p); + return *this; +} + +RMRect operator+(const RMRect &rc, RMPoint p) { + RMRect r(rc); + return (r += p); +} + +RMRect operator-(const RMRect& rc, RMPoint p) { + RMRect r(rc); + + return (r -= p); +} + +RMRect operator+(RMPoint p, const RMRect& rc) { + RMRect r(rc); + + return (r+=p); +} + +RMRect operator-(RMPoint p, const RMRect& rc) { + RMRect r(rc); + + return (r+=p); +} + +bool RMRect::operator==(const RMRect& rc) { + return ((x1 == rc.x1) && (y1 == rc.y1) && (x2 == rc.x2) && (y2 == rc.y2)); +} + +bool RMRect::operator!=(const RMRect& rc) { + return ((x1 != rc.x1) || (y1 != rc.y1) || (x2 != rc.x2) || (y2 != rc.y2)); +} + +void RMRect::NormalizeRect(void) { + SetRect(MIN(x1,x2), MIN(y1,y2), MAX(x1,x2), MAX(y1,y2)); +} + +RMDataStream &operator>>(RMDataStream &ds, RMRect &rc) { + ds >> rc.x1 >> rc.y1 >> rc.x2 >> rc.y2; + return ds; +} + + /****************************************************************************\ * Resource Update \****************************************************************************/ @@ -68,7 +945,7 @@ void RMResUpdate::Init(const Common::String &fileName) { } } -const byte *RMResUpdate::QueryResource(uint32 dwRes) { +HGLOBAL RMResUpdate::QueryResource(uint32 dwRes) { // If there isn't an update file, return NULL if (!_hFile.isOpen()) return NULL; @@ -98,7 +975,8 @@ const byte *RMResUpdate::QueryResource(uint32 dwRes) { } // Allocate space for the output resource - byte *lpDestBuf = new byte[info.size]; + HGLOBAL destBuf = GlobalAllocate(info.size); + byte *lpDestBuf = (byte *)GlobalLock(destBuf); uint32 dwSize; // Decompress the data @@ -108,6 +986,7 @@ const byte *RMResUpdate::QueryResource(uint32 dwRes) { delete [] cmpBuf; // Return the resource + GlobalUnlock(destBuf); return lpDestBuf; } -- cgit v1.2.3 From b0eef829728183b7ea170b30a33eca091bcc4574 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 30 Apr 2012 09:27:12 +1000 Subject: TONY: Added include files for graphics engine and all dependent classes --- engines/tony/utils.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 76d168e27a..48dcb9392a 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -28,14 +28,14 @@ * .z$* d$$$$$$$L ^*$c. * * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Loc.CPP.............. * + * ^$$. 4$$$$$$$$$F .$P" Module: Utils.CPP............ * * *$. '$$$$$$$$$ 4$P 4 * * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c Desc: Classi di gestione * - * z$$beu .ue=" $ "=e.. .zed$$c dei dati di una loca- * - * "#$e z$*" . `. ^*Nc e$"" zione................ * - * "$$". .r" ^4. .^$$" ..................... * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * * ^.@*"6L=\ebu^+C$"*b." * * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * -- cgit v1.2.3 From 68bcaa61b9eb1108028b3db072ade95431b9f14f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 30 Apr 2012 23:16:19 +1000 Subject: TONY: More header files and functionality added --- engines/tony/utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 48dcb9392a..360b7a6f32 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -980,7 +980,7 @@ HGLOBAL RMResUpdate::QueryResource(uint32 dwRes) { uint32 dwSize; // Decompress the data - MPAL::lzo1x_decompress(cmpBuf, info.cmpSize, lpDestBuf, &dwSize); + lzo1x_decompress(cmpBuf, info.cmpSize, lpDestBuf, &dwSize); // Delete buffer for compressed data delete [] cmpBuf; -- cgit v1.2.3 From bc2b9449869088be4f6c55ff03ccfa9a267a8c6a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 2 May 2012 00:23:41 +1000 Subject: TONY: Added code from Inventory.cpp --- engines/tony/utils.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 360b7a6f32..43a129b92a 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -816,19 +816,19 @@ RMPoint RMRect::Center() { return RMPoint((x2 - x1) / 2,(y2 - y1) / 2); } -int RMRect::Width() { +int RMRect::Width() const { return x2 - x1; } -int RMRect::Height() { +int RMRect::Height() const { return y2 - y1; } -int RMRect::Size() { +int RMRect::Size() const { return Width() * Height(); } -bool RMRect::IsEmpty() { +bool RMRect::IsEmpty() const { return (x1 == 0 && y1 == 0 && x2 == 0 && y2 == 0); } -- cgit v1.2.3 From a2982a0b20027f658c9b47266a8ddbec74a15878 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 3 May 2012 22:49:30 +1000 Subject: TONY: Engine is now compiling and linking again --- engines/tony/utils.cpp | 130 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 123 insertions(+), 7 deletions(-) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 43a129b92a..69ad5633d7 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -292,8 +292,8 @@ RMString::operator char*() const { /** * Resize a string as necessary * @param size New size necessary (in bytes) - * @param bMaintain If TRUE we must keep the original string, - if FALSE we can destroy. + * @param bMaintain If true we must keep the original string, + if false we can destroy. */ void RMString::Resize(int size, bool bMantain) { if (m_realLength == 0) { @@ -406,6 +406,122 @@ void RMString::Format(char* str, ...) { */ } +/****************************************************************************\ +* Metodi di RMFileStreamSlow +\****************************************************************************/ + +RMFileStreamSlow::RMFileStreamSlow() : RMDataStream() { + _stream = NULL; +} + +RMFileStreamSlow::~RMFileStreamSlow() { + Close(); +} + +void RMFileStreamSlow::Close() { + delete _stream; +} + +bool RMFileStreamSlow::OpenFile(Common::File &file) { + _stream = file.readStream(file.size()); + + m_length = _stream->pos(); + + return true; +} + + +bool RMFileStreamSlow::OpenFile(const char *lpFN) { + // Apre il file in lettura + Common::File f; + if (!f.open(lpFN)) + return false; + + m_length = f.size(); + _stream = f.readStream(f.size()); + + return true; +} + + +RMDataStream& RMFileStreamSlow::operator+=(int nBytes) { + Seek(nBytes); + return *this; +} + +int RMFileStreamSlow::Pos() { + return _stream->pos(); +} + +bool RMFileStreamSlow::IsEOF() { + return (Pos() >= m_length); +} + + +int RMFileStreamSlow::Seek(int nBytes, RMDSPos where) { + switch (where) { + case START: + return _stream->seek(nBytes); + + case END: + return _stream->seek(nBytes, SEEK_END); + + case CUR: + return _stream->seek(nBytes, SEEK_CUR); + + default: + return 0; + } +} + + +bool RMFileStreamSlow::Read(void *buf, int size) { + uint32 dwRead; + + dwRead = _stream->read(buf, size); + return ((int)dwRead == size); +} + + +RMFileStreamSlow &operator>>(RMFileStreamSlow &df, char &var) { + df.Read(&var, 1); + return df; +} + +RMFileStreamSlow &operator>>(RMFileStreamSlow &df, byte &var) { + df.Read(&var,1); + return df; +} + +RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint16 &var) { + uint16 v; + df.Read(&v, 2); + v = FROM_LE_16(v); + return df; +} + +RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int16 &var) { + uint16 v; + df.Read(&v, 2); + var = (int16)FROM_LE_16(v); + return df; +} + +RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int &var) { + int v; + df.Read(&v,4); + var = FROM_LE_32(v); + return df; +} + +RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint32 &var) { + uint32 v; + df.Read(&v, 4); + var = FROM_LE_32(v); + return df; +} + + /****************************************************************************\ * RMDataStream methods \****************************************************************************/ @@ -458,7 +574,7 @@ int RMDataStream::Length() { /** * Determines if the end of the stream has been reached - * @returns TRUE if end of stream reached, FALSE if not + * @returns true if end of stream reached, false if not */ bool RMDataStream::IsEOF() { return (m_pos >= m_length); @@ -546,7 +662,7 @@ RMDataStream &operator>>(RMDataStream &df, uint32 &var) { * Reads a series of data from the stream in a buffer * @param lpBuf Data buffer * @param size Size of the buffer - * @returns TRUE if we have reached the end, FALSE if not + * @returns true if we have reached the end, false if not */ bool RMDataStream::Read(void *lpBuf, int size) { byte *dest = (byte *)lpBuf; @@ -609,7 +725,7 @@ int RMDataStream::Pos() { /** * Check if an error occurred during reading the stream - * @returns TRUE if there was an error, false otherwise + * @returns true if there was an error, false otherwise */ bool RMDataStream::IsError() { return m_bError; @@ -714,7 +830,7 @@ RMPoint &RMPoint::operator+=(RMPoint p) { /** * Subtract (offset) of a point */ -RMPoint& RMPoint::operator-=(RMPoint p) { +RMPoint &RMPoint::operator-=(RMPoint p) { Offset(-p); return *this; } @@ -807,7 +923,7 @@ RMPoint &RMRect::TopLeft() { return *((RMPoint *)this); } -RMPoint& RMRect::BottomRight() { +RMPoint &RMRect::BottomRight() { // FIXME: This seems very bad return *((RMPoint*)this + 1); } -- cgit v1.2.3 From 5498f9a0b770ed8985ace1da232b505c650d70a7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 May 2012 22:03:03 +1000 Subject: TONY: Fix invalid casts and remove some unused variables --- engines/tony/utils.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 69ad5633d7..7a750c2975 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -393,17 +393,14 @@ RMDataStream &operator>>(RMDataStream &df, RMString &var) { /** * Formats a string */ -void RMString::Format(char* str, ...) { - warning("TODO: Refactor RMString::Format if needed"); - /* +void RMString::Format(const char *str, ...) { static char buf[2048]; va_list argList; - va_start(argList,str); - wvsprintf(buf,str,argList); + va_start(argList, str); + vsprintf(buf, str, argList); va_end(argList); *this = buf; -*/ } /****************************************************************************\ -- cgit v1.2.3 From 8a88ad861d68bd4c5a1a932d9da2518569ecc4ff Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 00:43:02 +1000 Subject: TONY: Converted object passing to use const reference where appropriate. This should cut down on the number of redunndant creations of temporary objects. --- engines/tony/utils.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 7a750c2975..a3998a01ab 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -109,7 +109,7 @@ RMString::RMString(const int ch) { * Returns the length of the string * @returns Length */ -int RMString::Length() { +int RMString::Length() const { return m_length; } @@ -785,7 +785,7 @@ RMPoint &RMPoint::operator=(RMPoint p) { /** * Offsets the point by another point */ -void RMPoint::Offset(RMPoint p) { +void RMPoint::Offset(const RMPoint &p) { x += p.x; y += p.y; } @@ -878,7 +878,7 @@ void RMRect::SetEmpty(void) { x1 = y1 = x2 = y2 = 0; } -RMRect::RMRect(RMPoint p1, RMPoint p2) { +RMRect::RMRect(const RMPoint &p1, const RMPoint &p2) { SetRect(p1, p2); } @@ -890,7 +890,7 @@ RMRect::RMRect(const RMRect &rc) { CopyRect(rc); } -void RMRect::SetRect(RMPoint p1, RMPoint p2) { +void RMRect::SetRect(const RMPoint &p1, const RMPoint &p2) { x1 = p1.x; y1 = p1.y; x2 = p2.x; @@ -957,7 +957,7 @@ void RMRect::Offset(int xOff, int yOff) { y2 += yOff; } -void RMRect::Offset(RMPoint p) { +void RMRect::Offset(const RMPoint &p) { x1 += p.x; y1 += p.y; x2 += p.x; -- cgit v1.2.3 From 099fe1e9e62ada666a312e08d7dca5cd2083de0b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 14 May 2012 07:43:50 +0200 Subject: TONY: Remove original header --- engines/tony/utils.cpp | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index a3998a01ab..d57640fee8 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Utils.CPP............ * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "tony/utils.h" #include "tony/tony.h" -- cgit v1.2.3 From 0450275c44c8c001d56cf37c78db6951ecaa4314 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 13:54:59 +1000 Subject: TONY: Converting Italian comments to English and formatting --- engines/tony/utils.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index d57640fee8..9aaffefceb 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -40,9 +40,9 @@ namespace Tony { * Constructor */ RMString::RMString() { - m_string=NULL; - m_length=0; - m_realLength=0; + m_string = NULL; + m_length = 0; + m_realLength = 0; } /** @@ -188,8 +188,8 @@ const RMString& RMString::operator=(const int ch) { // Destroy the current string if (m_realLength > 0) { delete [] m_string; - m_string=NULL; - m_length=m_realLength=0; + m_string = NULL; + m_length = m_realLength = 0; } } else { // Resize if necessary @@ -213,7 +213,7 @@ void RMString::Connect(const char *str, int size) { if (size > 0) { // Calculate the new lenght - nlen=m_length+size; + nlen = m_length+size; // Resize Resize(nlen + 1, true); @@ -242,7 +242,7 @@ const RMString &RMString::operator+=(RMString &str) { * @returns Refrence to our string */ const RMString &RMString::operator+=(const char *str) { - Connect(str,strlen(str)); + Connect(str, strlen(str)); return *this; } @@ -385,7 +385,7 @@ void RMString::Format(const char *str, ...) { } /****************************************************************************\ -* Metodi di RMFileStreamSlow +* RMFileStreamSlow Methods \****************************************************************************/ RMFileStreamSlow::RMFileStreamSlow() : RMDataStream() { @@ -410,7 +410,7 @@ bool RMFileStreamSlow::OpenFile(Common::File &file) { bool RMFileStreamSlow::OpenFile(const char *lpFN) { - // Apre il file in lettura + // Open file for reading Common::File f; if (!f.open(lpFN)) return false; @@ -679,13 +679,13 @@ int RMDataStream::Seek(int nBytes, RMDSPos origin) { break; case START: - m_pos=0; + m_pos = 0; break; case END: if (m_length == SIZENOTKNOWN) return m_pos; - m_pos=m_length; + m_pos = m_length; break; } @@ -741,8 +741,8 @@ RMPoint::RMPoint() { * Copy constructor */ RMPoint::RMPoint(const RMPoint &p) { - x=p.x; - y=p.y; + x = p.x; + y = p.y; } /** @@ -969,13 +969,13 @@ RMRect operator-(const RMRect& rc, RMPoint p) { RMRect operator+(RMPoint p, const RMRect& rc) { RMRect r(rc); - return (r+=p); + return (r += p); } RMRect operator-(RMPoint p, const RMRect& rc) { RMRect r(rc); - return (r+=p); + return (r += p); } bool RMRect::operator==(const RMRect& rc) { @@ -987,7 +987,7 @@ bool RMRect::operator!=(const RMRect& rc) { } void RMRect::NormalizeRect(void) { - SetRect(MIN(x1,x2), MIN(y1,y2), MAX(x1,x2), MAX(y1,y2)); + SetRect(MIN(x1, x2), MIN(y1, y2), MAX(x1, x2), MAX(y1, y2)); } RMDataStream &operator>>(RMDataStream &ds, RMRect &rc) { @@ -1029,7 +1029,7 @@ void RMResUpdate::Init(const Common::String &fileName) { _infos = new ResUpdInfo[_numUpd]; // Load the index of the resources in the file - for (i=0; i<_numUpd; ++i) { + for (i = 0; i < _numUpd; ++i) { ResUpdInfo &info = _infos[i]; info.dwRes = _hFile.readUint32LE(); @@ -1045,7 +1045,7 @@ HGLOBAL RMResUpdate::QueryResource(uint32 dwRes) { return NULL; uint32 i; - for (i=0; i < _numUpd; ++i) + for (i = 0; i < _numUpd; ++i) if (_infos[i].dwRes == dwRes) // Found the index break; -- cgit v1.2.3 From 94d3c8ebb29699a6c7a76c08986b984523761d63 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 21 May 2012 23:53:13 +0200 Subject: TONY: Some more code formatting --- engines/tony/utils.cpp | 188 ++++++++++++++++++++++++------------------------- 1 file changed, 94 insertions(+), 94 deletions(-) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 9aaffefceb..92b896b180 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -67,7 +67,7 @@ RMString::RMString(const RMString &str) { /** * Constructor from a char * */ -RMString::RMString(const char* str) { +RMString::RMString(const char *str) { // Use the overloaded '=' when copying m_string = NULL; m_length = 0; @@ -88,16 +88,16 @@ RMString::RMString(const int ch) { /** * Returns the length of the string - * @returns Length + * @returns Length */ int RMString::Length() const { - return m_length; + return m_length; } /** * Gets the character at the given index - * @param nIndex Position of the character to return - * @returns Character + * @param nIndex Position of the character to return + * @returns Character */ char RMString::GetAt(int nIndex) { assert(nIndex < m_length); @@ -106,8 +106,8 @@ char RMString::GetAt(int nIndex) { /** * Sets the character at the given index - * @param nIndex Position of the character to change - * @param c Character + * @param nIndex Position of the character to change + * @param c Character */ void RMString::SetAt(int nIndex, char c) { assert(nIndex < m_length); @@ -116,8 +116,8 @@ void RMString::SetAt(int nIndex, char c) { /** * Overloaded square brackets operator for accessing characters within the string - * @param nIndex Position of the charactre to reference - * @params Reference to the character + * @param nIndex Position of the charactre to reference + * @params Reference to the character */ char &RMString::operator[](int nIndex) { assert(nIndex < m_length); @@ -126,8 +126,8 @@ char &RMString::operator[](int nIndex) { /** * Copies a string - * @param str String to copy - * @returns Refrence to our string + * @param str String to copy + * @returns Refrence to our string */ const RMString &RMString::operator=(const RMString &str) { // Set the new length @@ -147,16 +147,16 @@ const RMString &RMString::operator=(const RMString &str) { // Copy the string Common::copy(str.m_string, str.m_string + m_length + 1, m_string); } - + return *this; } /** * Copies a char * string - * @param str String to copy - * @returns Refrence to our string + * @param str String to copy + * @returns Refrence to our string */ -const RMString& RMString::operator=(const char* str) { +const RMString &RMString::operator=(const char *str) { // If the source is empty, then destroy the current string buffer if (str == NULL) { if (m_realLength > 0) { @@ -180,11 +180,11 @@ const RMString& RMString::operator=(const char* str) { /** * Forms a string from a passed character - * @param ch Character to copy - * @returns Refrence to our string + * @param ch Character to copy + * @returns Refrence to our string */ -const RMString& RMString::operator=(const int ch) { - if (ch=='\0') { +const RMString &RMString::operator=(const int ch) { + if (ch == '\0') { // Destroy the current string if (m_realLength > 0) { delete [] m_string; @@ -203,17 +203,17 @@ const RMString& RMString::operator=(const int ch) { return *this; } -/** +/** * Concatenate a string into the current one - * @param str String to concatenate - * @param size Length of the string + * @param str String to concatenate + * @param size Length of the string */ void RMString::Connect(const char *str, int size) { int nlen; if (size > 0) { // Calculate the new lenght - nlen = m_length+size; + nlen = m_length + size; // Resize Resize(nlen + 1, true); @@ -228,18 +228,18 @@ void RMString::Connect(const char *str, int size) { /** * Concatenate a string - * @param str String to concatenate - * @returns Refrence to our string + * @param str String to concatenate + * @returns Refrence to our string */ const RMString &RMString::operator+=(RMString &str) { - Connect(str,str.Length()); + Connect(str, str.Length()); return *this; } /** * Concatenate a string - * @param str String to concatenate - * @returns Refrence to our string + * @param str String to concatenate + * @returns Refrence to our string */ const RMString &RMString::operator+=(const char *str) { Connect(str, strlen(str)); @@ -248,8 +248,8 @@ const RMString &RMString::operator+=(const char *str) { /** * Concatenate a character - * @param ch Character to concatenate - * @returns Refrence to our string + * @param ch Character to concatenate + * @returns Refrence to our string */ const RMString &RMString::operator+=(const int ch) { char str[2]; @@ -264,17 +264,17 @@ const RMString &RMString::operator+=(const int ch) { /** * Casts a string as char * - * @returns char * reference to string + * @returns char * reference to string */ -RMString::operator char*() const { +RMString::operator char *() const { return m_string; } /** * Resize a string as necessary - * @param size New size necessary (in bytes) - * @param bMaintain If true we must keep the original string, - if false we can destroy. + * @param size New size necessary (in bytes) + * @param bMaintain If true we must keep the original string, + if false we can destroy. */ void RMString::Resize(int size, bool bMantain) { if (m_realLength == 0) { @@ -282,7 +282,7 @@ void RMString::Resize(int size, bool bMantain) { m_realLength = size; } else if (size > m_realLength) { if (bMantain) { - char* app; + char *app; app = new char[size]; Common::copy(m_string, m_string + m_length + 1, app); @@ -346,13 +346,13 @@ RMString operator+(RMString &str, const char *s) { RMString operator+(const char *s, RMString &str) { RMString ret(s); - return (ret+=str); + return (ret += str); } /** * Extracts a string from a data stream - * @param df data stream - * @param var String + * @param df data stream + * @param var String */ RMDataStream &operator>>(RMDataStream &df, RMString &var) { uint8 len; @@ -360,14 +360,14 @@ RMDataStream &operator>>(RMDataStream &df, RMString &var) { df >> len; var.Resize(len + 1); - var.m_length=len+1; - + var.m_length = len + 1; + for (i = 0; i < len; i++) df >> var[i]; - var[i] = '\0'; + var[i] = '\0'; var.m_length = len; - + return df; } @@ -422,7 +422,7 @@ bool RMFileStreamSlow::OpenFile(const char *lpFN) { } -RMDataStream& RMFileStreamSlow::operator+=(int nBytes) { +RMDataStream &RMFileStreamSlow::operator+=(int nBytes) { Seek(nBytes); return *this; } @@ -440,7 +440,7 @@ int RMFileStreamSlow::Seek(int nBytes, RMDSPos where) { switch (where) { case START: return _stream->seek(nBytes); - + case END: return _stream->seek(nBytes, SEEK_END); @@ -467,7 +467,7 @@ RMFileStreamSlow &operator>>(RMFileStreamSlow &df, char &var) { } RMFileStreamSlow &operator>>(RMFileStreamSlow &df, byte &var) { - df.Read(&var,1); + df.Read(&var, 1); return df; } @@ -487,7 +487,7 @@ RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int16 &var) { RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int &var) { int v; - df.Read(&v,4); + df.Read(&v, 4); var = FROM_LE_32(v); return df; } @@ -530,10 +530,10 @@ void RMDataStream::Close(void) { /** * Takes the address of the buffer from which will be read the data. - * @param lpBuf Data buffer - * @param size Size of the buffer - * @remarks If the length of the buffer is not known, and cannot be - * specified, then EOF() and Seek() to end won't work. + * @param lpBuf Data buffer + * @param size Size of the buffer + * @remarks If the length of the buffer is not known, and cannot be + * specified, then EOF() and Seek() to end won't work. */ void RMDataStream::OpenBuffer(const byte *lpBuf, int size) { m_length = size; @@ -544,7 +544,7 @@ void RMDataStream::OpenBuffer(const byte *lpBuf, int size) { /** * Returns the length of the stream - * @returns Stream length + * @returns Stream length */ int RMDataStream::Length() { return m_length; @@ -552,7 +552,7 @@ int RMDataStream::Length() { /** * Determines if the end of the stream has been reached - * @returns true if end of stream reached, false if not + * @returns true if end of stream reached, false if not */ bool RMDataStream::IsEOF() { return (m_pos >= m_length); @@ -560,9 +560,9 @@ bool RMDataStream::IsEOF() { /** * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, char &var) { df.Read(&var, 1); @@ -571,9 +571,9 @@ RMDataStream &operator>>(RMDataStream &df, char &var) { /** * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, uint8 &var) { df.Read(&var, 1); @@ -582,9 +582,9 @@ RMDataStream &operator>>(RMDataStream &df, uint8 &var) { /** * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, uint16 &var) { uint16 v; @@ -596,9 +596,9 @@ RMDataStream &operator>>(RMDataStream &df, uint16 &var) { /** * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, int16 &var) { uint16 v; @@ -610,9 +610,9 @@ RMDataStream &operator>>(RMDataStream &df, int16 &var) { /** * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, int &var) { uint32 v; @@ -624,9 +624,9 @@ RMDataStream &operator>>(RMDataStream &df, int &var) { /** * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, uint32 &var) { uint32 v; @@ -638,9 +638,9 @@ RMDataStream &operator>>(RMDataStream &df, uint32 &var) { /** * Reads a series of data from the stream in a buffer - * @param lpBuf Data buffer - * @param size Size of the buffer - * @returns true if we have reached the end, false if not + * @param lpBuf Data buffer + * @param size Size of the buffer + * @returns true if we have reached the end, false if not */ bool RMDataStream::Read(void *lpBuf, int size) { byte *dest = (byte *)lpBuf; @@ -659,19 +659,19 @@ bool RMDataStream::Read(void *lpBuf, int size) { /** * Skips a number of bytes in the stream - * @param nBytres Number of bytes to skip - * @returns The stream + * @param nBytres Number of bytes to skip + * @returns The stream */ RMDataStream &RMDataStream::operator+=(int nBytes) { - m_pos+=nBytes; + m_pos += nBytes; return *this; } /** * Seeks to a position within the stream - * @param nBytes Number of bytes from specified origin - * @param origin Origin to do offset from - * @returns The absolute current position in bytes + * @param nBytes Number of bytes from specified origin + * @param origin Origin to do offset from + * @returns The absolute current position in bytes */ int RMDataStream::Seek(int nBytes, RMDSPos origin) { switch (origin) { @@ -689,13 +689,13 @@ int RMDataStream::Seek(int nBytes, RMDSPos origin) { break; } - m_pos+=nBytes; + m_pos += nBytes; return m_pos; } /** * Returns the current position of the stream - * @returns The current position + * @returns The current position */ int RMDataStream::Pos() { return m_pos; @@ -703,7 +703,7 @@ int RMDataStream::Pos() { /** * Check if an error occurred during reading the stream - * @returns true if there was an error, false otherwise + * @returns true if there was an error, false otherwise */ bool RMDataStream::IsError() { return m_bError; @@ -711,7 +711,7 @@ bool RMDataStream::IsError() { /** * Sets an error code for the stream - * @param code Error code + * @param code Error code */ void RMDataStream::SetError(int code) { m_bError = true; @@ -720,7 +720,7 @@ void RMDataStream::SetError(int code) { /** * Returns the error code for the stream - * @returns Error code + * @returns Error code */ int RMDataStream::GetError() { return m_ecode; @@ -903,11 +903,11 @@ RMPoint &RMRect::TopLeft() { RMPoint &RMRect::BottomRight() { // FIXME: This seems very bad - return *((RMPoint*)this + 1); + return *((RMPoint *)this + 1); } RMPoint RMRect::Center() { - return RMPoint((x2 - x1) / 2,(y2 - y1) / 2); + return RMPoint((x2 - x1) / 2, (y2 - y1) / 2); } int RMRect::Width() const { @@ -926,7 +926,7 @@ bool RMRect::IsEmpty() const { return (x1 == 0 && y1 == 0 && x2 == 0 && y2 == 0); } -const RMRect& RMRect::operator=(const RMRect &rc) { +const RMRect &RMRect::operator=(const RMRect &rc) { CopyRect(rc); return *this; } @@ -960,29 +960,29 @@ RMRect operator+(const RMRect &rc, RMPoint p) { return (r += p); } -RMRect operator-(const RMRect& rc, RMPoint p) { +RMRect operator-(const RMRect &rc, RMPoint p) { RMRect r(rc); return (r -= p); } -RMRect operator+(RMPoint p, const RMRect& rc) { +RMRect operator+(RMPoint p, const RMRect &rc) { RMRect r(rc); return (r += p); } -RMRect operator-(RMPoint p, const RMRect& rc) { +RMRect operator-(RMPoint p, const RMRect &rc) { RMRect r(rc); return (r += p); } -bool RMRect::operator==(const RMRect& rc) { +bool RMRect::operator==(const RMRect &rc) { return ((x1 == rc.x1) && (y1 == rc.y1) && (x2 == rc.x2) && (y2 == rc.y2)); } -bool RMRect::operator!=(const RMRect& rc) { +bool RMRect::operator!=(const RMRect &rc) { return ((x1 != rc.x1) || (y1 != rc.y1) || (x2 != rc.x2) || (y2 != rc.y2)); } @@ -1050,7 +1050,7 @@ HGLOBAL RMResUpdate::QueryResource(uint32 dwRes) { // Found the index break; - if (i==_numUpd) + if (i == _numUpd) // Couldn't find a matching resource, so return NULL return NULL; -- cgit v1.2.3 From f12ab3e521b01ed2b40e7d517753dd14bc6e6f0f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 7 Jun 2012 08:42:35 +0200 Subject: TONY: Rename variables and functions in utils.h --- engines/tony/utils.cpp | 338 ++++++++++++++++++++++++------------------------- 1 file changed, 169 insertions(+), 169 deletions(-) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 92b896b180..f11c9e6a2f 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -40,17 +40,17 @@ namespace Tony { * Constructor */ RMString::RMString() { - m_string = NULL; - m_length = 0; - m_realLength = 0; + _string = NULL; + _length = 0; + _realLength = 0; } /** * Destructor */ RMString::~RMString() { - if (m_string != NULL) - delete[] m_string; + if (_string != NULL) + delete[] _string; } /** @@ -58,9 +58,9 @@ RMString::~RMString() { */ RMString::RMString(const RMString &str) { // Richiama l'overload su '=' per copiare - m_string = NULL; - m_length = 0; - m_realLength = 0; + _string = NULL; + _length = 0; + _realLength = 0; *this = str; } @@ -69,9 +69,9 @@ RMString::RMString(const RMString &str) { */ RMString::RMString(const char *str) { // Use the overloaded '=' when copying - m_string = NULL; - m_length = 0; - m_realLength = 0; + _string = NULL; + _length = 0; + _realLength = 0; *this = str; } @@ -80,9 +80,9 @@ RMString::RMString(const char *str) { */ RMString::RMString(const int ch) { // Use the overloaded '=' when copying - m_string = NULL; - m_length = 0; - m_realLength = 0; + _string = NULL; + _length = 0; + _realLength = 0; *this = ch; } @@ -90,8 +90,8 @@ RMString::RMString(const int ch) { * Returns the length of the string * @returns Length */ -int RMString::Length() const { - return m_length; +int RMString::length() const { + return _length; } /** @@ -99,9 +99,9 @@ int RMString::Length() const { * @param nIndex Position of the character to return * @returns Character */ -char RMString::GetAt(int nIndex) { - assert(nIndex < m_length); - return m_string[nIndex]; +char RMString::getAt(int nIndex) { + assert(nIndex < _length); + return _string[nIndex]; } /** @@ -109,9 +109,9 @@ char RMString::GetAt(int nIndex) { * @param nIndex Position of the character to change * @param c Character */ -void RMString::SetAt(int nIndex, char c) { - assert(nIndex < m_length); - m_string[nIndex] = c; +void RMString::setAt(int nIndex, char c) { + assert(nIndex < _length); + _string[nIndex] = c; } /** @@ -120,8 +120,8 @@ void RMString::SetAt(int nIndex, char c) { * @params Reference to the character */ char &RMString::operator[](int nIndex) { - assert(nIndex < m_length); - return m_string[nIndex]; + assert(nIndex < _length); + return _string[nIndex]; } /** @@ -131,21 +131,21 @@ char &RMString::operator[](int nIndex) { */ const RMString &RMString::operator=(const RMString &str) { // Set the new length - m_length = str.m_length; + _length = str._length; // If the source is empty, then destroy the current string buffer - if (m_length == 0) { - if (m_realLength > 0) { - delete[] m_string; - m_string = NULL; - m_realLength = 0; + if (_length == 0) { + if (_realLength > 0) { + delete[] _string; + _string = NULL; + _realLength = 0; } } else { // Resize if necessary - Resize(m_length + 1); + resize(_length + 1); // Copy the string - Common::copy(str.m_string, str.m_string + m_length + 1, m_string); + Common::copy(str._string, str._string + _length + 1, _string); } return *this; @@ -159,20 +159,20 @@ const RMString &RMString::operator=(const RMString &str) { const RMString &RMString::operator=(const char *str) { // If the source is empty, then destroy the current string buffer if (str == NULL) { - if (m_realLength > 0) { - delete[] m_string; - m_string = NULL; - m_realLength = m_length = 0; + if (_realLength > 0) { + delete[] _string; + _string = NULL; + _realLength = _length = 0; } } else { // Calculate the new length - m_length = strlen(str); + _length = strlen(str); // Resize if necessary - Resize(m_length + 1); + resize(_length + 1); // Copy the string - Common::copy(str, str + m_length + 1, m_string); + Common::copy(str, str + _length + 1, _string); } return *this; @@ -186,18 +186,18 @@ const RMString &RMString::operator=(const char *str) { const RMString &RMString::operator=(const int ch) { if (ch == '\0') { // Destroy the current string - if (m_realLength > 0) { - delete [] m_string; - m_string = NULL; - m_length = m_realLength = 0; + if (_realLength > 0) { + delete [] _string; + _string = NULL; + _length = _realLength = 0; } } else { // Resize if necessary - Resize(2); + resize(2); - m_string[0] = ch; - m_string[1] = '\0'; - m_length = 1; + _string[0] = ch; + _string[1] = '\0'; + _length = 1; } return *this; @@ -208,21 +208,21 @@ const RMString &RMString::operator=(const int ch) { * @param str String to concatenate * @param size Length of the string */ -void RMString::Connect(const char *str, int size) { +void RMString::connect(const char *str, int size) { int nlen; if (size > 0) { // Calculate the new lenght - nlen = m_length + size; + nlen = _length + size; // Resize - Resize(nlen + 1, true); + resize(nlen + 1, true); // Linkage with '\0' - Common::copy(str, str + size + 1, m_string + m_length); + Common::copy(str, str + size + 1, _string + _length); // Save the new length - m_length = nlen; + _length = nlen; } } @@ -232,7 +232,7 @@ void RMString::Connect(const char *str, int size) { * @returns Refrence to our string */ const RMString &RMString::operator+=(RMString &str) { - Connect(str, str.Length()); + connect(str, str.length()); return *this; } @@ -242,7 +242,7 @@ const RMString &RMString::operator+=(RMString &str) { * @returns Refrence to our string */ const RMString &RMString::operator+=(const char *str) { - Connect(str, strlen(str)); + connect(str, strlen(str)); return *this; } @@ -258,7 +258,7 @@ const RMString &RMString::operator+=(const int ch) { str[0] = ch; str[1] = '\0'; - Connect(str, 1); + connect(str, 1); return *this; } @@ -267,7 +267,7 @@ const RMString &RMString::operator+=(const int ch) { * @returns char * reference to string */ RMString::operator char *() const { - return m_string; + return _string; } /** @@ -276,21 +276,21 @@ RMString::operator char *() const { * @param bMaintain If true we must keep the original string, if false we can destroy. */ -void RMString::Resize(int size, bool bMantain) { - if (m_realLength == 0) { - m_string = new char[size]; - m_realLength = size; - } else if (size > m_realLength) { +void RMString::resize(int size, bool bMantain) { + if (_realLength == 0) { + _string = new char[size]; + _realLength = size; + } else if (size > _realLength) { if (bMantain) { char *app; app = new char[size]; - Common::copy(m_string, m_string + m_length + 1, app); - delete[] m_string; - m_string = app; + Common::copy(_string, _string + _length + 1, app); + delete[] _string; + _string = app; } else { - delete[] m_string; - m_string = new char[size]; + delete[] _string; + _string = new char[size]; } } } @@ -298,15 +298,15 @@ void RMString::Resize(int size, bool bMantain) { /** * Compacts the string to occupy less memory if possible. */ -void RMString::Compact(void) { - if (m_realLength + 1 > m_length) { +void RMString::compact(void) { + if (_realLength + 1 > _length) { char *app; - app = new char[m_length + 1]; - Common::copy(m_string, m_string + m_length + 1, app); + app = new char[_length + 1]; + Common::copy(_string, _string + _length + 1, app); - delete[] m_string; - m_string = app; + delete[] _string; + _string = app; } } @@ -359,14 +359,14 @@ RMDataStream &operator>>(RMDataStream &df, RMString &var) { int i; df >> len; - var.Resize(len + 1); - var.m_length = len + 1; + var.resize(len + 1); + var._length = len + 1; for (i = 0; i < len; i++) df >> var[i]; var[i] = '\0'; - var.m_length = len; + var._length = len; return df; } @@ -374,7 +374,7 @@ RMDataStream &operator>>(RMDataStream &df, RMString &var) { /** * Formats a string */ -void RMString::Format(const char *str, ...) { +void RMString::format(const char *str, ...) { static char buf[2048]; va_list argList; @@ -393,29 +393,29 @@ RMFileStreamSlow::RMFileStreamSlow() : RMDataStream() { } RMFileStreamSlow::~RMFileStreamSlow() { - Close(); + close(); } -void RMFileStreamSlow::Close() { +void RMFileStreamSlow::close() { delete _stream; } -bool RMFileStreamSlow::OpenFile(Common::File &file) { +bool RMFileStreamSlow::openFile(Common::File &file) { _stream = file.readStream(file.size()); - m_length = _stream->pos(); + _length = _stream->pos(); return true; } -bool RMFileStreamSlow::OpenFile(const char *lpFN) { +bool RMFileStreamSlow::openFile(const char *lpFN) { // Open file for reading Common::File f; if (!f.open(lpFN)) return false; - m_length = f.size(); + _length = f.size(); _stream = f.readStream(f.size()); return true; @@ -423,20 +423,20 @@ bool RMFileStreamSlow::OpenFile(const char *lpFN) { RMDataStream &RMFileStreamSlow::operator+=(int nBytes) { - Seek(nBytes); + seek(nBytes); return *this; } -int RMFileStreamSlow::Pos() { +int RMFileStreamSlow::pos() { return _stream->pos(); } -bool RMFileStreamSlow::IsEOF() { - return (Pos() >= m_length); +bool RMFileStreamSlow::isEOF() { + return (pos() >= _length); } -int RMFileStreamSlow::Seek(int nBytes, RMDSPos where) { +int RMFileStreamSlow::seek(int nBytes, RMDSPos where) { switch (where) { case START: return _stream->seek(nBytes); @@ -453,7 +453,7 @@ int RMFileStreamSlow::Seek(int nBytes, RMDSPos where) { } -bool RMFileStreamSlow::Read(void *buf, int size) { +bool RMFileStreamSlow::read(void *buf, int size) { uint32 dwRead; dwRead = _stream->read(buf, size); @@ -462,39 +462,39 @@ bool RMFileStreamSlow::Read(void *buf, int size) { RMFileStreamSlow &operator>>(RMFileStreamSlow &df, char &var) { - df.Read(&var, 1); + df.read(&var, 1); return df; } RMFileStreamSlow &operator>>(RMFileStreamSlow &df, byte &var) { - df.Read(&var, 1); + df.read(&var, 1); return df; } RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint16 &var) { uint16 v; - df.Read(&v, 2); + df.read(&v, 2); v = FROM_LE_16(v); return df; } RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int16 &var) { uint16 v; - df.Read(&v, 2); + df.read(&v, 2); var = (int16)FROM_LE_16(v); return df; } RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int &var) { int v; - df.Read(&v, 4); + df.read(&v, 4); var = FROM_LE_32(v); return df; } RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint32 &var) { uint32 v; - df.Read(&v, 4); + df.read(&v, 4); var = FROM_LE_32(v); return df; } @@ -508,24 +508,24 @@ RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint32 &var) { * Constructor */ RMDataStream::RMDataStream() { - m_length = 0; - m_pos = 0; - m_bError = false; + _length = 0; + _pos = 0; + _bError = false; } /** * Destructor */ RMDataStream::~RMDataStream() { - Close(); + close(); } /** * Close a stream */ -void RMDataStream::Close(void) { - m_length = 0; - m_pos = 0; +void RMDataStream::close(void) { + _length = 0; + _pos = 0; } /** @@ -535,27 +535,27 @@ void RMDataStream::Close(void) { * @remarks If the length of the buffer is not known, and cannot be * specified, then EOF() and Seek() to end won't work. */ -void RMDataStream::OpenBuffer(const byte *lpBuf, int size) { - m_length = size; - m_buf = lpBuf; - m_bError = false; - m_pos = 0; +void RMDataStream::openBuffer(const byte *lpBuf, int size) { + _length = size; + _buf = lpBuf; + _bError = false; + _pos = 0; } /** * Returns the length of the stream * @returns Stream length */ -int RMDataStream::Length() { - return m_length; +int RMDataStream::length() { + return _length; } /** * Determines if the end of the stream has been reached * @returns true if end of stream reached, false if not */ -bool RMDataStream::IsEOF() { - return (m_pos >= m_length); +bool RMDataStream::isEOF() { + return (_pos >= _length); } /** @@ -565,7 +565,7 @@ bool RMDataStream::IsEOF() { * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, char &var) { - df.Read(&var, 1); + df.read(&var, 1); return df; } @@ -576,7 +576,7 @@ RMDataStream &operator>>(RMDataStream &df, char &var) { * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, uint8 &var) { - df.Read(&var, 1); + df.read(&var, 1); return df; } @@ -588,7 +588,7 @@ RMDataStream &operator>>(RMDataStream &df, uint8 &var) { */ RMDataStream &operator>>(RMDataStream &df, uint16 &var) { uint16 v; - df.Read(&v, 2); + df.read(&v, 2); var = FROM_LE_16(v); return df; @@ -602,7 +602,7 @@ RMDataStream &operator>>(RMDataStream &df, uint16 &var) { */ RMDataStream &operator>>(RMDataStream &df, int16 &var) { uint16 v; - df.Read(&v, 2); + df.read(&v, 2); var = (int16)FROM_LE_16(v); return df; @@ -616,7 +616,7 @@ RMDataStream &operator>>(RMDataStream &df, int16 &var) { */ RMDataStream &operator>>(RMDataStream &df, int &var) { uint32 v; - df.Read(&v, 4); + df.read(&v, 4); var = (int)FROM_LE_32(v); return df; @@ -630,7 +630,7 @@ RMDataStream &operator>>(RMDataStream &df, int &var) { */ RMDataStream &operator>>(RMDataStream &df, uint32 &var) { uint32 v; - df.Read(&v, 4); + df.read(&v, 4); var = FROM_LE_32(v); return df; @@ -642,17 +642,17 @@ RMDataStream &operator>>(RMDataStream &df, uint32 &var) { * @param size Size of the buffer * @returns true if we have reached the end, false if not */ -bool RMDataStream::Read(void *lpBuf, int size) { +bool RMDataStream::read(void *lpBuf, int size) { byte *dest = (byte *)lpBuf; - if ((m_pos + size) > m_length) { - Common::copy(m_buf + m_pos, m_buf + m_pos + (m_length - m_pos), dest); + if ((_pos + size) > _length) { + Common::copy(_buf + _pos, _buf + _pos + (_length - _pos), dest); return true; } else { - Common::copy(m_buf + m_pos, m_buf + m_pos + size, dest); + Common::copy(_buf + _pos, _buf + _pos + size, dest); - m_pos += size; + _pos += size; return false; } } @@ -663,7 +663,7 @@ bool RMDataStream::Read(void *lpBuf, int size) { * @returns The stream */ RMDataStream &RMDataStream::operator+=(int nBytes) { - m_pos += nBytes; + _pos += nBytes; return *this; } @@ -673,57 +673,57 @@ RMDataStream &RMDataStream::operator+=(int nBytes) { * @param origin Origin to do offset from * @returns The absolute current position in bytes */ -int RMDataStream::Seek(int nBytes, RMDSPos origin) { +int RMDataStream::seek(int nBytes, RMDSPos origin) { switch (origin) { case CUR: break; case START: - m_pos = 0; + _pos = 0; break; case END: - if (m_length == SIZENOTKNOWN) - return m_pos; - m_pos = m_length; + if (_length == SIZENOTKNOWN) + return _pos; + _pos = _length; break; } - m_pos += nBytes; - return m_pos; + _pos += nBytes; + return _pos; } /** * Returns the current position of the stream * @returns The current position */ -int RMDataStream::Pos() { - return m_pos; +int RMDataStream::pos() { + return _pos; } /** * Check if an error occurred during reading the stream * @returns true if there was an error, false otherwise */ -bool RMDataStream::IsError() { - return m_bError; +bool RMDataStream::isError() { + return _bError; } /** * Sets an error code for the stream * @param code Error code */ -void RMDataStream::SetError(int code) { - m_bError = true; - m_ecode = code; +void RMDataStream::setError(int code) { + _bError = true; + _ecode = code; } /** * Returns the error code for the stream * @returns Error code */ -int RMDataStream::GetError() { - return m_ecode; +int RMDataStream::getError() { + return _ecode; } /****************************************************************************\ @@ -766,7 +766,7 @@ RMPoint &RMPoint::operator=(RMPoint p) { /** * Offsets the point by another point */ -void RMPoint::Offset(const RMPoint &p) { +void RMPoint::offset(const RMPoint &p) { x += p.x; y += p.y; } @@ -774,7 +774,7 @@ void RMPoint::Offset(const RMPoint &p) { /** * Offsets the point by a specified offset */ -void RMPoint::Offset(int xOff, int yOff) { +void RMPoint::offset(int xOff, int yOff) { x += xOff; y += yOff; } @@ -801,7 +801,7 @@ RMPoint operator-(RMPoint p1, RMPoint p2) { * Sum (offset) of a point */ RMPoint &RMPoint::operator+=(RMPoint p) { - Offset(p); + offset(p); return *this; } @@ -809,7 +809,7 @@ RMPoint &RMPoint::operator+=(RMPoint p) { * Subtract (offset) of a point */ RMPoint &RMPoint::operator-=(RMPoint p) { - Offset(-p); + offset(-p); return *this; } @@ -852,93 +852,93 @@ RMDataStream &operator>>(RMDataStream &ds, RMPoint &p) { \****************************************************************************/ RMRect::RMRect() { - SetEmpty(); + setEmpty(); } -void RMRect::SetEmpty(void) { +void RMRect::setEmpty(void) { x1 = y1 = x2 = y2 = 0; } RMRect::RMRect(const RMPoint &p1, const RMPoint &p2) { - SetRect(p1, p2); + setRect(p1, p2); } RMRect::RMRect(int X1, int Y1, int X2, int Y2) { - SetRect(X1, Y1, X2, Y2); + setRect(X1, Y1, X2, Y2); } RMRect::RMRect(const RMRect &rc) { - CopyRect(rc); + copyRect(rc); } -void RMRect::SetRect(const RMPoint &p1, const RMPoint &p2) { +void RMRect::setRect(const RMPoint &p1, const RMPoint &p2) { x1 = p1.x; y1 = p1.y; x2 = p2.x; y2 = p2.y; } -void RMRect::SetRect(int X1, int Y1, int X2, int Y2) { +void RMRect::setRect(int X1, int Y1, int X2, int Y2) { x1 = X1; y1 = Y1; x2 = X2; y2 = Y2; } -void RMRect::SetRect(const RMRect &rc) { - CopyRect(rc); +void RMRect::setRect(const RMRect &rc) { + copyRect(rc); } -void RMRect::CopyRect(const RMRect &rc) { +void RMRect::copyRect(const RMRect &rc) { x1 = rc.x1; y1 = rc.y1; x2 = rc.x2; y2 = rc.y2; } -RMPoint &RMRect::TopLeft() { +RMPoint &RMRect::topLeft() { // FIXME: This seems very bad return *((RMPoint *)this); } -RMPoint &RMRect::BottomRight() { +RMPoint &RMRect::bottomRight() { // FIXME: This seems very bad return *((RMPoint *)this + 1); } -RMPoint RMRect::Center() { +RMPoint RMRect::center() { return RMPoint((x2 - x1) / 2, (y2 - y1) / 2); } -int RMRect::Width() const { +int RMRect::width() const { return x2 - x1; } -int RMRect::Height() const { +int RMRect::height() const { return y2 - y1; } -int RMRect::Size() const { - return Width() * Height(); +int RMRect::size() const { + return width() * height(); } -bool RMRect::IsEmpty() const { +bool RMRect::isEmpty() const { return (x1 == 0 && y1 == 0 && x2 == 0 && y2 == 0); } const RMRect &RMRect::operator=(const RMRect &rc) { - CopyRect(rc); + copyRect(rc); return *this; } -void RMRect::Offset(int xOff, int yOff) { +void RMRect::offset(int xOff, int yOff) { x1 += xOff; y1 += yOff; x2 += xOff; y2 += yOff; } -void RMRect::Offset(const RMPoint &p) { +void RMRect::offset(const RMPoint &p) { x1 += p.x; y1 += p.y; x2 += p.x; @@ -946,12 +946,12 @@ void RMRect::Offset(const RMPoint &p) { } const RMRect &RMRect::operator+=(RMPoint p) { - Offset(p); + offset(p); return *this; } const RMRect &RMRect::operator-=(RMPoint p) { - Offset(-p); + offset(-p); return *this; } @@ -986,8 +986,8 @@ bool RMRect::operator!=(const RMRect &rc) { return ((x1 != rc.x1) || (y1 != rc.y1) || (x2 != rc.x2) || (y2 != rc.y2)); } -void RMRect::NormalizeRect(void) { - SetRect(MIN(x1, x2), MIN(y1, y2), MAX(x1, x2), MAX(y1, y2)); +void RMRect::normalizeRect(void) { + setRect(MIN(x1, x2), MIN(y1, y2), MAX(x1, x2), MAX(y1, y2)); } RMDataStream &operator>>(RMDataStream &ds, RMRect &rc) { @@ -1014,7 +1014,7 @@ RMResUpdate::~RMResUpdate() { _hFile.close(); } -void RMResUpdate::Init(const Common::String &fileName) { +void RMResUpdate::init(const Common::String &fileName) { // Open the resource update file if (!_hFile.open(fileName)) // It doesn't exist, so exit immediately @@ -1039,7 +1039,7 @@ void RMResUpdate::Init(const Common::String &fileName) { } } -HGLOBAL RMResUpdate::QueryResource(uint32 dwRes) { +HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { // If there isn't an update file, return NULL if (!_hFile.isOpen()) return NULL; -- cgit v1.2.3 From cd15e483ed64274049142a2e6838962d794c3ff5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 7 Jun 2012 21:14:59 +0200 Subject: TONY: Some more renaming --- engines/tony/utils.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index f11c9e6a2f..98b23001c0 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -1069,8 +1069,8 @@ HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { } // Allocate space for the output resource - HGLOBAL destBuf = GlobalAllocate(info.size); - byte *lpDestBuf = (byte *)GlobalLock(destBuf); + HGLOBAL destBuf = globalAllocate(info.size); + byte *lpDestBuf = (byte *)globalLock(destBuf); uint32 dwSize; // Decompress the data @@ -1080,7 +1080,7 @@ HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { delete [] cmpBuf; // Return the resource - GlobalUnlock(destBuf); + globalUnlock(destBuf); return lpDestBuf; } -- cgit v1.2.3 From d4777379d23b70aa07feec3ef2e90fcf376f4117 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 8 Jun 2012 23:00:48 +1000 Subject: TONY: Refactored the memory manager to increase performance --- engines/tony/utils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 98b23001c0..fa100d681e 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -1069,7 +1069,7 @@ HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { } // Allocate space for the output resource - HGLOBAL destBuf = globalAllocate(info.size); + HGLOBAL destBuf = globalAllocate(0, info.size); byte *lpDestBuf = (byte *)globalLock(destBuf); uint32 dwSize; @@ -1081,7 +1081,7 @@ HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { // Return the resource globalUnlock(destBuf); - return lpDestBuf; + return destBuf; } } // End of namespace Tony -- cgit v1.2.3 From 02c8ccebcb20aa904dba3151d65a7b4fa67998fe Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 11 Jun 2012 20:24:25 +0200 Subject: TONY: Rename variables in utils.h --- engines/tony/utils.cpp | 112 ++++++++++++++++++++++++------------------------- 1 file changed, 56 insertions(+), 56 deletions(-) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index fa100d681e..6d790c0e68 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -734,31 +734,31 @@ int RMDataStream::getError() { * Constructor */ RMPoint::RMPoint() { - x = y = 0; + _x = _y = 0; } /** * Copy constructor */ RMPoint::RMPoint(const RMPoint &p) { - x = p.x; - y = p.y; + _x = p._x; + _y = p._y; } /** * Constructor with integer parameters */ RMPoint::RMPoint(int x1, int y1) { - x = x1; - y = y1; + _x = x1; + _y = y1; } /** * Copy operator */ RMPoint &RMPoint::operator=(RMPoint p) { - x = p.x; - y = p.y; + _x = p._x; + _y = p._y; return *this; } @@ -767,16 +767,16 @@ RMPoint &RMPoint::operator=(RMPoint p) { * Offsets the point by another point */ void RMPoint::offset(const RMPoint &p) { - x += p.x; - y += p.y; + _x += p._x; + _y += p._y; } /** * Offsets the point by a specified offset */ void RMPoint::offset(int xOff, int yOff) { - x += xOff; - y += yOff; + _x += xOff; + _y += yOff; } /** @@ -819,8 +819,8 @@ RMPoint &RMPoint::operator-=(RMPoint p) { RMPoint RMPoint::operator-() { RMPoint p; - p.x = -x; - p.y = -y; + p._x = -_x; + p._y = -_y; return p; } @@ -829,21 +829,21 @@ RMPoint RMPoint::operator-() { * Equality operator */ bool RMPoint::operator==(RMPoint p) { - return ((x == p.x) && (y == p.y)); + return ((_x == p._x) && (_y == p._y)); } /** * Not equal operator */ bool RMPoint::operator!=(RMPoint p) { - return ((x != p.x) || (y != p.y)); + return ((_x != p._x) || (_y != p._y)); } /** * Reads a point from a stream */ RMDataStream &operator>>(RMDataStream &ds, RMPoint &p) { - ds >> p.x >> p.y; + ds >> p._x >> p._y; return ds; } @@ -856,7 +856,7 @@ RMRect::RMRect() { } void RMRect::setEmpty(void) { - x1 = y1 = x2 = y2 = 0; + _x1 = _y1 = _x2 = _y2 = 0; } RMRect::RMRect(const RMPoint &p1, const RMPoint &p2) { @@ -872,17 +872,17 @@ RMRect::RMRect(const RMRect &rc) { } void RMRect::setRect(const RMPoint &p1, const RMPoint &p2) { - x1 = p1.x; - y1 = p1.y; - x2 = p2.x; - y2 = p2.y; + _x1 = p1._x; + _y1 = p1._y; + _x2 = p2._x; + _y2 = p2._y; } void RMRect::setRect(int X1, int Y1, int X2, int Y2) { - x1 = X1; - y1 = Y1; - x2 = X2; - y2 = Y2; + _x1 = X1; + _y1 = Y1; + _x2 = X2; + _y2 = Y2; } void RMRect::setRect(const RMRect &rc) { @@ -890,10 +890,10 @@ void RMRect::setRect(const RMRect &rc) { } void RMRect::copyRect(const RMRect &rc) { - x1 = rc.x1; - y1 = rc.y1; - x2 = rc.x2; - y2 = rc.y2; + _x1 = rc._x1; + _y1 = rc._y1; + _x2 = rc._x2; + _y2 = rc._y2; } RMPoint &RMRect::topLeft() { @@ -907,15 +907,15 @@ RMPoint &RMRect::bottomRight() { } RMPoint RMRect::center() { - return RMPoint((x2 - x1) / 2, (y2 - y1) / 2); + return RMPoint((_x2 - _x1) / 2, (_y2 - _y1) / 2); } int RMRect::width() const { - return x2 - x1; + return _x2 - _x1; } int RMRect::height() const { - return y2 - y1; + return _y2 - _y1; } int RMRect::size() const { @@ -923,7 +923,7 @@ int RMRect::size() const { } bool RMRect::isEmpty() const { - return (x1 == 0 && y1 == 0 && x2 == 0 && y2 == 0); + return (_x1 == 0 && _y1 == 0 && _x2 == 0 && _y2 == 0); } const RMRect &RMRect::operator=(const RMRect &rc) { @@ -932,17 +932,17 @@ const RMRect &RMRect::operator=(const RMRect &rc) { } void RMRect::offset(int xOff, int yOff) { - x1 += xOff; - y1 += yOff; - x2 += xOff; - y2 += yOff; + _x1 += xOff; + _y1 += yOff; + _x2 += xOff; + _y2 += yOff; } void RMRect::offset(const RMPoint &p) { - x1 += p.x; - y1 += p.y; - x2 += p.x; - y2 += p.y; + _x1 += p._x; + _y1 += p._y; + _x2 += p._x; + _y2 += p._y; } const RMRect &RMRect::operator+=(RMPoint p) { @@ -979,19 +979,19 @@ RMRect operator-(RMPoint p, const RMRect &rc) { } bool RMRect::operator==(const RMRect &rc) { - return ((x1 == rc.x1) && (y1 == rc.y1) && (x2 == rc.x2) && (y2 == rc.y2)); + return ((_x1 == rc._x1) && (_y1 == rc._y1) && (_x2 == rc._x2) && (_y2 == rc._y2)); } bool RMRect::operator!=(const RMRect &rc) { - return ((x1 != rc.x1) || (y1 != rc.y1) || (x2 != rc.x2) || (y2 != rc.y2)); + return ((_x1 != rc._x1) || (_y1 != rc._y1) || (_x2 != rc._x2) || (_y2 != rc._y2)); } void RMRect::normalizeRect(void) { - setRect(MIN(x1, x2), MIN(y1, y2), MAX(x1, x2), MAX(y1, y2)); + setRect(MIN(_x1, _x2), MIN(_y1, _y2), MAX(_x1, _x2), MAX(_y1, _y2)); } RMDataStream &operator>>(RMDataStream &ds, RMRect &rc) { - ds >> rc.x1 >> rc.y1 >> rc.x2 >> rc.y2; + ds >> rc._x1 >> rc._y1 >> rc._x2 >> rc._y2; return ds; } @@ -1032,10 +1032,10 @@ void RMResUpdate::init(const Common::String &fileName) { for (i = 0; i < _numUpd; ++i) { ResUpdInfo &info = _infos[i]; - info.dwRes = _hFile.readUint32LE(); - info.offset = _hFile.readUint32LE(); - info.size = _hFile.readUint32LE(); - info.cmpSize = _hFile.readUint32LE(); + info._dwRes = _hFile.readUint32LE(); + info._offset = _hFile.readUint32LE(); + info._size = _hFile.readUint32LE(); + info._cmpSize = _hFile.readUint32LE(); } } @@ -1046,7 +1046,7 @@ HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { uint32 i; for (i = 0; i < _numUpd; ++i) - if (_infos[i].dwRes == dwRes) + if (_infos[i]._dwRes == dwRes) // Found the index break; @@ -1055,26 +1055,26 @@ HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { return NULL; const ResUpdInfo &info = _infos[i]; - byte *cmpBuf = new byte[info.cmpSize]; + byte *cmpBuf = new byte[info._cmpSize]; uint32 dwRead; // Move to the correct offset and read in the compressed data - _hFile.seek(info.offset); - dwRead = _hFile.read(cmpBuf, info.cmpSize); + _hFile.seek(info._offset); + dwRead = _hFile.read(cmpBuf, info._cmpSize); - if (info.cmpSize > dwRead) { + if (info._cmpSize > dwRead) { // Error occurred reading data, so return NULL delete[] cmpBuf; return NULL; } // Allocate space for the output resource - HGLOBAL destBuf = globalAllocate(0, info.size); + HGLOBAL destBuf = globalAllocate(0, info._size); byte *lpDestBuf = (byte *)globalLock(destBuf); uint32 dwSize; // Decompress the data - lzo1x_decompress(cmpBuf, info.cmpSize, lpDestBuf, &dwSize); + lzo1x_decompress(cmpBuf, info._cmpSize, lpDestBuf, &dwSize); // Delete buffer for compressed data delete [] cmpBuf; -- cgit v1.2.3 From b8282316712c1969d9f7e8c1d80a673eeb4b2ced Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 12 Jun 2012 08:03:51 +0200 Subject: TONY: Translate some more comments into English --- engines/tony/utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 6d790c0e68..8e751a811a 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -57,7 +57,7 @@ RMString::~RMString() { * Copy constructor */ RMString::RMString(const RMString &str) { - // Richiama l'overload su '=' per copiare + // Use the overloaded '=' when copying _string = NULL; _length = 0; _realLength = 0; -- cgit v1.2.3 From 71aa08c7f0f00be2e2c9ca013aa7682d79b6796f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 15 Jun 2012 08:42:24 +0200 Subject: TONY: Silent more CppCheck warnings --- engines/tony/utils.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 8e751a811a..b6af8736bd 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -209,11 +209,9 @@ const RMString &RMString::operator=(const int ch) { * @param size Length of the string */ void RMString::connect(const char *str, int size) { - int nlen; - if (size > 0) { // Calculate the new lenght - nlen = _length + size; + int nlen = _length + size; // Resize resize(nlen + 1, true); @@ -511,6 +509,9 @@ RMDataStream::RMDataStream() { _length = 0; _pos = 0; _bError = false; + + _buf = NULL; + _ecode = 0; } /** @@ -1002,6 +1003,7 @@ RMDataStream &operator>>(RMDataStream &ds, RMRect &rc) { RMResUpdate::RMResUpdate() { _infos = NULL; + _numUpd = 0; } RMResUpdate::~RMResUpdate() { -- cgit v1.2.3 From cdbc4aa28b5c47392369879b209f9635ff431195 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Jun 2012 10:57:35 +1000 Subject: TONY: Initial commit of in progress dirty rect handling --- engines/tony/utils.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 8e751a811a..f9c2622eb2 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -922,6 +922,10 @@ int RMRect::size() const { return width() * height(); } +RMRect::operator Common::Rect() const { + return Common::Rect(_x1, _y1, _x2, _y2); +} + bool RMRect::isEmpty() const { return (_x1 == 0 && _y1 == 0 && _x2 == 0 && _y2 == 0); } -- cgit v1.2.3 From 6a7fa693ef0e68e08e45bc7b7c8397357deffa04 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 18 Jun 2012 07:58:19 +0200 Subject: TONY: Fix a typo in utils comments --- engines/tony/utils.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index b6af8736bd..6c36781f51 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -127,7 +127,7 @@ char &RMString::operator[](int nIndex) { /** * Copies a string * @param str String to copy - * @returns Refrence to our string + * @returns Reference to our string */ const RMString &RMString::operator=(const RMString &str) { // Set the new length @@ -154,7 +154,7 @@ const RMString &RMString::operator=(const RMString &str) { /** * Copies a char * string * @param str String to copy - * @returns Refrence to our string + * @returns Reference to our string */ const RMString &RMString::operator=(const char *str) { // If the source is empty, then destroy the current string buffer @@ -181,7 +181,7 @@ const RMString &RMString::operator=(const char *str) { /** * Forms a string from a passed character * @param ch Character to copy - * @returns Refrence to our string + * @returns Reference to our string */ const RMString &RMString::operator=(const int ch) { if (ch == '\0') { @@ -227,7 +227,7 @@ void RMString::connect(const char *str, int size) { /** * Concatenate a string * @param str String to concatenate - * @returns Refrence to our string + * @returns Reference to our string */ const RMString &RMString::operator+=(RMString &str) { connect(str, str.length()); @@ -237,7 +237,7 @@ const RMString &RMString::operator+=(RMString &str) { /** * Concatenate a string * @param str String to concatenate - * @returns Refrence to our string + * @returns Reference to our string */ const RMString &RMString::operator+=(const char *str) { connect(str, strlen(str)); @@ -247,7 +247,7 @@ const RMString &RMString::operator+=(const char *str) { /** * Concatenate a character * @param ch Character to concatenate - * @returns Refrence to our string + * @returns Reference to our string */ const RMString &RMString::operator+=(const int ch) { char str[2]; @@ -406,7 +406,6 @@ bool RMFileStreamSlow::openFile(Common::File &file) { return true; } - bool RMFileStreamSlow::openFile(const char *lpFN) { // Open file for reading Common::File f; @@ -419,7 +418,6 @@ bool RMFileStreamSlow::openFile(const char *lpFN) { return true; } - RMDataStream &RMFileStreamSlow::operator+=(int nBytes) { seek(nBytes); return *this; @@ -433,7 +431,6 @@ bool RMFileStreamSlow::isEOF() { return (pos() >= _length); } - int RMFileStreamSlow::seek(int nBytes, RMDSPos where) { switch (where) { case START: @@ -450,7 +447,6 @@ int RMFileStreamSlow::seek(int nBytes, RMDSPos where) { } } - bool RMFileStreamSlow::read(void *buf, int size) { uint32 dwRead; @@ -458,7 +454,6 @@ bool RMFileStreamSlow::read(void *buf, int size) { return ((int)dwRead == size); } - RMFileStreamSlow &operator>>(RMFileStreamSlow &df, char &var) { df.read(&var, 1); return df; @@ -497,7 +492,6 @@ RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint32 &var) { return df; } - /****************************************************************************\ * RMDataStream methods \****************************************************************************/ @@ -996,7 +990,6 @@ RMDataStream &operator>>(RMDataStream &ds, RMRect &rc) { return ds; } - /****************************************************************************\ * Resource Update \****************************************************************************/ -- cgit v1.2.3 From e8a6f61f8815fcf36e7a43383695c74b8925993f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 18 Jun 2012 08:24:33 +0200 Subject: TONY: Remove useless void in function declaration --- engines/tony/utils.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 6c36781f51..7661c600da 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -296,7 +296,7 @@ void RMString::resize(int size, bool bMantain) { /** * Compacts the string to occupy less memory if possible. */ -void RMString::compact(void) { +void RMString::compact() { if (_realLength + 1 > _length) { char *app; @@ -518,7 +518,7 @@ RMDataStream::~RMDataStream() { /** * Close a stream */ -void RMDataStream::close(void) { +void RMDataStream::close() { _length = 0; _pos = 0; } @@ -850,7 +850,7 @@ RMRect::RMRect() { setEmpty(); } -void RMRect::setEmpty(void) { +void RMRect::setEmpty() { _x1 = _y1 = _x2 = _y2 = 0; } @@ -981,7 +981,7 @@ bool RMRect::operator!=(const RMRect &rc) { return ((_x1 != rc._x1) || (_y1 != rc._y1) || (_x2 != rc._x2) || (_y2 != rc._y2)); } -void RMRect::normalizeRect(void) { +void RMRect::normalizeRect() { setRect(MIN(_x1, _x2), MIN(_y1, _y2), MAX(_x1, _x2), MAX(_y1, _y2)); } -- cgit v1.2.3 From 565bf7383a0000cf8564ac63da08a61778194254 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 18 Jun 2012 19:50:29 +1000 Subject: TONY: Refactored the RMRect topLeft/bottomRight properties into a cleaner implementation --- engines/tony/utils.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 7661c600da..647ef0ed82 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -842,11 +842,25 @@ RMDataStream &operator>>(RMDataStream &ds, RMPoint &p) { return ds; } +/****************************************************************************\ +* RMPointReference methods +\****************************************************************************/ + +RMPointReference &RMPointReference::operator=(const RMPoint &p) { + _x = p._x; _y = p._y; + return *this; +} + +RMPointReference &RMPointReference::operator-=(const RMPoint &p) { + _x -= p._x; _y -= p._y; + return *this; +} + /****************************************************************************\ * RMRect methods \****************************************************************************/ -RMRect::RMRect() { +RMRect::RMRect(): _topLeft(_x1, _y1), _bottomRight(_x2, _y2) { setEmpty(); } @@ -854,15 +868,15 @@ void RMRect::setEmpty() { _x1 = _y1 = _x2 = _y2 = 0; } -RMRect::RMRect(const RMPoint &p1, const RMPoint &p2) { +RMRect::RMRect(const RMPoint &p1, const RMPoint &p2): _topLeft(_x1, _y1), _bottomRight(_x2, _y2) { setRect(p1, p2); } -RMRect::RMRect(int X1, int Y1, int X2, int Y2) { +RMRect::RMRect(int X1, int Y1, int X2, int Y2): _topLeft(_x1, _y1), _bottomRight(_x2, _y2) { setRect(X1, Y1, X2, Y2); } -RMRect::RMRect(const RMRect &rc) { +RMRect::RMRect(const RMRect &rc): _topLeft(_x1, _y1), _bottomRight(_x2, _y2) { copyRect(rc); } @@ -891,16 +905,6 @@ void RMRect::copyRect(const RMRect &rc) { _y2 = rc._y2; } -RMPoint &RMRect::topLeft() { - // FIXME: This seems very bad - return *((RMPoint *)this); -} - -RMPoint &RMRect::bottomRight() { - // FIXME: This seems very bad - return *((RMPoint *)this + 1); -} - RMPoint RMRect::center() { return RMPoint((_x2 - _x1) / 2, (_y2 - _y1) / 2); } -- cgit v1.2.3 From b14a616f3f7f667946f617facd301369a0996582 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Sat, 25 Aug 2012 00:31:00 +0200 Subject: TONY: Get rid of RMString. --- engines/tony/utils.cpp | 342 +------------------------------------------------ 1 file changed, 6 insertions(+), 336 deletions(-) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 54a2209659..8dc1f5d615 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -32,356 +32,26 @@ namespace Tony { -/****************************************************************************\ -* RMString methods -\****************************************************************************/ - -/** - * Constructor - */ -RMString::RMString() { - _string = NULL; - _length = 0; - _realLength = 0; -} - -/** - * Destructor - */ -RMString::~RMString() { - if (_string != NULL) - delete[] _string; -} - -/** - * Copy constructor - */ -RMString::RMString(const RMString &str) { - // Use the overloaded '=' when copying - _string = NULL; - _length = 0; - _realLength = 0; - *this = str; -} - -/** - * Constructor from a char * - */ -RMString::RMString(const char *str) { - // Use the overloaded '=' when copying - _string = NULL; - _length = 0; - _realLength = 0; - *this = str; -} - -/** - * Constructor with a single passed character - */ -RMString::RMString(const int ch) { - // Use the overloaded '=' when copying - _string = NULL; - _length = 0; - _realLength = 0; - *this = ch; -} - -/** - * Returns the length of the string - * @returns Length - */ -int RMString::length() const { - return _length; -} - -/** - * Gets the character at the given index - * @param nIndex Position of the character to return - * @returns Character - */ -char RMString::getAt(int nIndex) { - assert(nIndex < _length); - return _string[nIndex]; -} - -/** - * Sets the character at the given index - * @param nIndex Position of the character to change - * @param c Character - */ -void RMString::setAt(int nIndex, char c) { - assert(nIndex < _length); - _string[nIndex] = c; -} - -/** - * Overloaded square brackets operator for accessing characters within the string - * @param nIndex Position of the charactre to reference - * @params Reference to the character - */ -char &RMString::operator[](int nIndex) { - assert(nIndex < _length); - return _string[nIndex]; -} - -/** - * Copies a string - * @param str String to copy - * @returns Reference to our string - */ -const RMString &RMString::operator=(const RMString &str) { - // Set the new length - _length = str._length; - - // If the source is empty, then destroy the current string buffer - if (_length == 0) { - if (_realLength > 0) { - delete[] _string; - _string = NULL; - _realLength = 0; - } - } else { - // Resize if necessary - resize(_length + 1); - - // Copy the string - Common::copy(str._string, str._string + _length + 1, _string); - } - - return *this; -} - -/** - * Copies a char * string - * @param str String to copy - * @returns Reference to our string - */ -const RMString &RMString::operator=(const char *str) { - // If the source is empty, then destroy the current string buffer - if (str == NULL) { - if (_realLength > 0) { - delete[] _string; - _string = NULL; - _realLength = _length = 0; - } - } else { - // Calculate the new length - _length = strlen(str); - - // Resize if necessary - resize(_length + 1); - - // Copy the string - Common::copy(str, str + _length + 1, _string); - } - - return *this; -} - -/** - * Forms a string from a passed character - * @param ch Character to copy - * @returns Reference to our string - */ -const RMString &RMString::operator=(const int ch) { - if (ch == '\0') { - // Destroy the current string - if (_realLength > 0) { - delete [] _string; - _string = NULL; - _length = _realLength = 0; - } - } else { - // Resize if necessary - resize(2); - - _string[0] = ch; - _string[1] = '\0'; - _length = 1; - } - - return *this; -} - -/** - * Concatenate a string into the current one - * @param str String to concatenate - * @param size Length of the string - */ -void RMString::connect(const char *str, int size) { - if (size > 0) { - // Calculate the new lenght - int nlen = _length + size; - - // Resize - resize(nlen + 1, true); - - // Linkage with '\0' - Common::copy(str, str + size + 1, _string + _length); - - // Save the new length - _length = nlen; - } -} - -/** - * Concatenate a string - * @param str String to concatenate - * @returns Reference to our string - */ -const RMString &RMString::operator+=(RMString &str) { - connect(str, str.length()); - return *this; -} - -/** - * Concatenate a string - * @param str String to concatenate - * @returns Reference to our string - */ -const RMString &RMString::operator+=(const char *str) { - connect(str, strlen(str)); - return *this; -} - -/** - * Concatenate a character - * @param ch Character to concatenate - * @returns Reference to our string - */ -const RMString &RMString::operator+=(const int ch) { - char str[2]; - - // Create a simple string buffer to hold the single character - str[0] = ch; - str[1] = '\0'; - - connect(str, 1); - return *this; -} - -/** - * Casts a string as char * - * @returns char * reference to string - */ -RMString::operator char *() const { - return _string; -} - -/** - * Resize a string as necessary - * @param size New size necessary (in bytes) - * @param bMaintain If true we must keep the original string, - if false we can destroy. - */ -void RMString::resize(int size, bool bMantain) { - if (_realLength == 0) { - _string = new char[size]; - _realLength = size; - } else if (size > _realLength) { - if (bMantain) { - char *app; - - app = new char[size]; - Common::copy(_string, _string + _length + 1, app); - delete[] _string; - _string = app; - } else { - delete[] _string; - _string = new char[size]; - } - } -} - -/** - * Compacts the string to occupy less memory if possible. - */ -void RMString::compact() { - if (_realLength + 1 > _length) { - char *app; - - app = new char[_length + 1]; - Common::copy(_string, _string + _length + 1, app); - - delete[] _string; - _string = app; - } -} - -/** - * Operator to concatenate two strings - */ -RMString operator+(const RMString &str1, const RMString &str2) { - RMString ret(str1); - - return (ret += str2); -} - -/** - * Operator to concatenate a character to a string - */ -RMString operator+(RMString &str, const int ch) { - RMString ret(str); - - return (ret += ch); -} - -RMString operator+(const int ch, RMString &str) { - RMString ret(ch); - - return (ret += str); -} - -/** - * Operator to concatenate a char * string to an RMString - */ -RMString operator+(RMString &str, const char *s) { - RMString ret(str); - - return (ret += s); -} - -RMString operator+(const char *s, RMString &str) { - RMString ret(s); - - return (ret += str); -} - /** * Extracts a string from a data stream * @param df data stream * @param var String */ -RMDataStream &operator>>(RMDataStream &df, RMString &var) { +RMDataStream &operator>>(RMDataStream &df, Common::String &var) { uint8 len; int i; df >> len; - var.resize(len + 1); - var._length = len + 1; - for (i = 0; i < len; i++) - df >> var[i]; - - var[i] = '\0'; - var._length = len; + for (i = 0; i < len; i++) { + char c; + df >> c; + var += c; + } return df; } -/** - * Formats a string - */ -void RMString::format(const char *str, ...) { - static char buf[2048]; - va_list argList; - - va_start(argList, str); - vsprintf(buf, str, argList); - va_end(argList); - *this = buf; -} - /****************************************************************************\ * RMFileStreamSlow Methods \****************************************************************************/ -- cgit v1.2.3 From 35fd91793b34b72624a89f2a76f45bc8e59020d2 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 28 Aug 2012 14:26:00 +0200 Subject: TONY: Get rid of RMDataStream. --- engines/tony/utils.cpp | 363 ++----------------------------------------------- 1 file changed, 13 insertions(+), 350 deletions(-) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 8dc1f5d615..a3f79decaf 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -35,360 +35,21 @@ namespace Tony { /** * Extracts a string from a data stream * @param df data stream - * @param var String */ -RMDataStream &operator>>(RMDataStream &df, Common::String &var) { +Common::String readString(Common::ReadStream &df) { + Common::String var; uint8 len; int i; - df >> len; + len = df.readByte(); for (i = 0; i < len; i++) { char c; - df >> c; + c = df.readByte(); var += c; } - return df; -} - -/****************************************************************************\ -* RMFileStreamSlow Methods -\****************************************************************************/ - -RMFileStreamSlow::RMFileStreamSlow() : RMDataStream() { - _stream = NULL; -} - -RMFileStreamSlow::~RMFileStreamSlow() { - close(); -} - -void RMFileStreamSlow::close() { - delete _stream; -} - -bool RMFileStreamSlow::openFile(Common::File &file) { - _stream = file.readStream(file.size()); - - _length = _stream->pos(); - - return true; -} - -bool RMFileStreamSlow::openFile(const char *lpFN) { - // Open file for reading - Common::File f; - if (!f.open(lpFN)) - return false; - - _length = f.size(); - _stream = f.readStream(f.size()); - - return true; -} - -RMDataStream &RMFileStreamSlow::operator+=(int nBytes) { - seek(nBytes); - return *this; -} - -int RMFileStreamSlow::pos() { - return _stream->pos(); -} - -bool RMFileStreamSlow::isEOF() { - return (pos() >= _length); -} - -int RMFileStreamSlow::seek(int nBytes, RMDSPos where) { - switch (where) { - case START: - return _stream->seek(nBytes); - - case END: - return _stream->seek(nBytes, SEEK_END); - - case CUR: - return _stream->seek(nBytes, SEEK_CUR); - - default: - return 0; - } -} - -bool RMFileStreamSlow::read(void *buf, int size) { - uint32 dwRead; - - dwRead = _stream->read(buf, size); - return ((int)dwRead == size); -} - -RMFileStreamSlow &operator>>(RMFileStreamSlow &df, char &var) { - df.read(&var, 1); - return df; -} - -RMFileStreamSlow &operator>>(RMFileStreamSlow &df, byte &var) { - df.read(&var, 1); - return df; -} - -RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint16 &var) { - uint16 v; - df.read(&v, 2); - v = FROM_LE_16(v); - return df; -} - -RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int16 &var) { - uint16 v; - df.read(&v, 2); - var = (int16)FROM_LE_16(v); - return df; -} - -RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int &var) { - int v; - df.read(&v, 4); - var = FROM_LE_32(v); - return df; -} - -RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint32 &var) { - uint32 v; - df.read(&v, 4); - var = FROM_LE_32(v); - return df; -} - -/****************************************************************************\ -* RMDataStream methods -\****************************************************************************/ - -/** - * Constructor - */ -RMDataStream::RMDataStream() { - _length = 0; - _pos = 0; - _bError = false; - - _buf = NULL; - _ecode = 0; -} - -/** - * Destructor - */ -RMDataStream::~RMDataStream() { - close(); -} - -/** - * Close a stream - */ -void RMDataStream::close() { - _length = 0; - _pos = 0; -} - -/** - * Takes the address of the buffer from which will be read the data. - * @param lpBuf Data buffer - * @param size Size of the buffer - * @remarks If the length of the buffer is not known, and cannot be - * specified, then EOF() and Seek() to end won't work. - */ -void RMDataStream::openBuffer(const byte *lpBuf, int size) { - _length = size; - _buf = lpBuf; - _bError = false; - _pos = 0; -} - -/** - * Returns the length of the stream - * @returns Stream length - */ -int RMDataStream::length() { - return _length; -} - -/** - * Determines if the end of the stream has been reached - * @returns true if end of stream reached, false if not - */ -bool RMDataStream::isEOF() { - return (_pos >= _length); -} - -/** - * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream - */ -RMDataStream &operator>>(RMDataStream &df, char &var) { - df.read(&var, 1); - return df; -} - -/** - * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream - */ -RMDataStream &operator>>(RMDataStream &df, uint8 &var) { - df.read(&var, 1); - return df; -} - -/** - * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream - */ -RMDataStream &operator>>(RMDataStream &df, uint16 &var) { - uint16 v; - df.read(&v, 2); - - var = FROM_LE_16(v); - return df; -} - -/** - * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream - */ -RMDataStream &operator>>(RMDataStream &df, int16 &var) { - uint16 v; - df.read(&v, 2); - - var = (int16)FROM_LE_16(v); - return df; -} - -/** - * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream - */ -RMDataStream &operator>>(RMDataStream &df, int &var) { - uint32 v; - df.read(&v, 4); - - var = (int)FROM_LE_32(v); - return df; -} - -/** - * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream - */ -RMDataStream &operator>>(RMDataStream &df, uint32 &var) { - uint32 v; - df.read(&v, 4); - - var = FROM_LE_32(v); - return df; -} - -/** - * Reads a series of data from the stream in a buffer - * @param lpBuf Data buffer - * @param size Size of the buffer - * @returns true if we have reached the end, false if not - */ -bool RMDataStream::read(void *lpBuf, int size) { - byte *dest = (byte *)lpBuf; - - if ((_pos + size) > _length) { - Common::copy(_buf + _pos, _buf + _pos + (_length - _pos), dest); - - return true; - } else { - Common::copy(_buf + _pos, _buf + _pos + size, dest); - - _pos += size; - return false; - } -} - -/** - * Skips a number of bytes in the stream - * @param nBytres Number of bytes to skip - * @returns The stream - */ -RMDataStream &RMDataStream::operator+=(int nBytes) { - _pos += nBytes; - return *this; -} - -/** - * Seeks to a position within the stream - * @param nBytes Number of bytes from specified origin - * @param origin Origin to do offset from - * @returns The absolute current position in bytes - */ -int RMDataStream::seek(int nBytes, RMDSPos origin) { - switch (origin) { - case CUR: - break; - - case START: - _pos = 0; - break; - - case END: - if (_length == SIZENOTKNOWN) - return _pos; - _pos = _length; - break; - } - - _pos += nBytes; - return _pos; -} - -/** - * Returns the current position of the stream - * @returns The current position - */ -int RMDataStream::pos() { - return _pos; -} - -/** - * Check if an error occurred during reading the stream - * @returns true if there was an error, false otherwise - */ -bool RMDataStream::isError() { - return _bError; -} - -/** - * Sets an error code for the stream - * @param code Error code - */ -void RMDataStream::setError(int code) { - _bError = true; - _ecode = code; -} - -/** - * Returns the error code for the stream - * @returns Error code - */ -int RMDataStream::getError() { - return _ecode; + return var; } /****************************************************************************\ @@ -507,9 +168,9 @@ bool RMPoint::operator!=(RMPoint p) { /** * Reads a point from a stream */ -RMDataStream &operator>>(RMDataStream &ds, RMPoint &p) { - ds >> p._x >> p._y; - return ds; +void RMPoint::readFromStream(Common::ReadStream &ds) { + _x = ds.readSint32LE(); + _y = ds.readSint32LE(); } /****************************************************************************\ @@ -663,9 +324,11 @@ void RMRect::normalizeRect() { setRect(MIN(_x1, _x2), MIN(_y1, _y2), MAX(_x1, _x2), MAX(_y1, _y2)); } -RMDataStream &operator>>(RMDataStream &ds, RMRect &rc) { - ds >> rc._x1 >> rc._y1 >> rc._x2 >> rc._y2; - return ds; +void RMRect::readFromStream(Common::ReadStream &ds) { + _x1 = ds.readSint32LE(); + _y1 = ds.readSint32LE(); + _x2 = ds.readSint32LE(); + _y2 = ds.readSint32LE(); } /****************************************************************************\ -- cgit v1.2.3 From d2b33ca4cce2794e7b4fcf3ccb3f00dc74fff68d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 28 Aug 2012 23:25:50 +0200 Subject: TONY: Janitorial - remove trailing spaces --- engines/tony/utils.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index a3f79decaf..70c33e71ee 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -177,13 +177,13 @@ void RMPoint::readFromStream(Common::ReadStream &ds) { * RMPointReference methods \****************************************************************************/ -RMPointReference &RMPointReference::operator=(const RMPoint &p) { - _x = p._x; _y = p._y; +RMPointReference &RMPointReference::operator=(const RMPoint &p) { + _x = p._x; _y = p._y; return *this; } RMPointReference &RMPointReference::operator-=(const RMPoint &p) { - _x -= p._x; _y -= p._y; + _x -= p._x; _y -= p._y; return *this; } -- cgit v1.2.3 From b12ccad9943c99ecfc4edc6f4a46e4d88db609cf Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 29 Aug 2012 00:30:07 +0200 Subject: TONY: Reduce scope of some variables --- engines/tony/utils.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 70c33e71ee..db83c2910b 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -38,12 +38,9 @@ namespace Tony { */ Common::String readString(Common::ReadStream &df) { Common::String var; - uint8 len; - int i; + uint8 len = df.readByte(); - len = df.readByte(); - - for (i = 0; i < len; i++) { + for (int i = 0; i < len; i++) { char c; c = df.readByte(); var += c; @@ -356,16 +353,14 @@ void RMResUpdate::init(const Common::String &fileName) { // It doesn't exist, so exit immediately return; - uint8 version; - uint32 i; + uint8 version = _hFile.readByte(); - version = _hFile.readByte(); _numUpd = _hFile.readUint32LE(); _infos = new ResUpdInfo[_numUpd]; // Load the index of the resources in the file - for (i = 0; i < _numUpd; ++i) { + for (uint32 i = 0; i < _numUpd; ++i) { ResUpdInfo &info = _infos[i]; info._dwRes = _hFile.readUint32LE(); -- cgit v1.2.3 From f2df769aab10e719cc4fba6cb71e1500eb3acae4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 1 Sep 2012 00:25:35 +0200 Subject: TONY: More renaming --- engines/tony/utils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index db83c2910b..99ba84ab19 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -370,7 +370,7 @@ void RMResUpdate::init(const Common::String &fileName) { } } -HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { +MpalHandle RMResUpdate::queryResource(uint32 dwRes) { // If there isn't an update file, return NULL if (!_hFile.isOpen()) return NULL; @@ -400,7 +400,7 @@ HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { } // Allocate space for the output resource - HGLOBAL destBuf = globalAllocate(0, info._size); + MpalHandle destBuf = globalAllocate(0, info._size); byte *lpDestBuf = (byte *)globalLock(destBuf); uint32 dwSize; -- cgit v1.2.3 From c737e6429866f18638a6b61103e4e1c7095407e6 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 2 Sep 2012 10:34:11 +0200 Subject: TONY: Move code from .h to .cpp files --- engines/tony/utils.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 99ba84ab19..3cc09a1454 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -86,6 +86,14 @@ RMPoint &RMPoint::operator=(RMPoint p) { return *this; } +/** + * Set a point + */ +void RMPoint::set(int x1, int y1) { + _x = x1; + _y = y1; +} + /** * Offsets the point by another point */ @@ -174,6 +182,9 @@ void RMPoint::readFromStream(Common::ReadStream &ds) { * RMPointReference methods \****************************************************************************/ +RMPointReference::RMPointReference(int &x, int &y): _x(x), _y(y) { +} + RMPointReference &RMPointReference::operator=(const RMPoint &p) { _x = p._x; _y = p._y; return *this; @@ -184,6 +195,10 @@ RMPointReference &RMPointReference::operator-=(const RMPoint &p) { return *this; } +RMPointReference::operator RMPoint() const { + return RMPoint(_x, _y); +} + /****************************************************************************\ * RMRect methods \****************************************************************************/ @@ -233,6 +248,14 @@ void RMRect::copyRect(const RMRect &rc) { _y2 = rc._y2; } +RMPointReference &RMRect::topLeft() { + return _topLeft; +} + +RMPointReference &RMRect::bottomRight() { + return _bottomRight; +} + RMPoint RMRect::center() { return RMPoint((_x2 - _x1) / 2, (_y2 - _y1) / 2); } @@ -328,6 +351,13 @@ void RMRect::readFromStream(Common::ReadStream &ds) { _y2 = ds.readSint32LE(); } +/** + * Check if RMPoint is in RMRect + */ +bool RMRect::ptInRect(const RMPoint &pt) { + return (pt._x >= _x1 && pt._x <= _x2 && pt._y >= _y1 && pt._y <= _y2); +} + /****************************************************************************\ * Resource Update \****************************************************************************/ -- cgit v1.2.3 From 25f4a3fb0838a8ed658e76eabd78f3ce2f5661e6 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 6 Sep 2012 00:23:59 +0200 Subject: TONY: Misc cleanup --- engines/tony/utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/tony/utils.cpp') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 3cc09a1454..81060146b7 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -383,7 +383,7 @@ void RMResUpdate::init(const Common::String &fileName) { // It doesn't exist, so exit immediately return; - uint8 version = _hFile.readByte(); + _hFile.readByte(); // Version, unused _numUpd = _hFile.readUint32LE(); -- cgit v1.2.3