From 3b9ab4f5cf6a868300e49067ec116ca8b15903c8 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sat, 17 Sep 2011 12:02:15 -0400 Subject: COMMON: Add function to find the intersecting rectangle --- common/rect.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'common') diff --git a/common/rect.h b/common/rect.h index 768d1ebbb9..1106ec1714 100644 --- a/common/rect.h +++ b/common/rect.h @@ -169,6 +169,20 @@ struct Rect { return (left < r.right) && (r.left < right) && (top < r.bottom) && (r.top < bottom); } + /** + * Find the intersecting rectangle between this rectangle and the given rectangle + * + * @param r the intersecting rectangle + * + * @return the intersection of the rectangles or an empty rectangle if not intersecting + */ + Rect findIntersectingRect(const Rect &r) const { + if (!intersects(r)) + return Rect(); + + return Rect(MAX(r.left, left), MAX(r.top, top), MIN(r.right, right), MIN(r.bottom, bottom)); + } + /** * Extend this rectangle so that it contains r * -- cgit v1.2.3 From e90287f7f1063e9784239c5be558b7fb6cd3aa54 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sat, 17 Sep 2011 21:16:36 -0400 Subject: COMMON: Add numerator/denominator getters for Rational --- common/rational.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'common') diff --git a/common/rational.h b/common/rational.h index 45aa6a7a20..8270d2194e 100644 --- a/common/rational.h +++ b/common/rational.h @@ -80,6 +80,9 @@ public: double toDouble() const; frac_t toFrac() const; + int getNumerator() const { return _num; } + int getDenominator() const { return _denom; } + void debugPrint(int debuglevel = 0, const char *caption = "Rational:") const; private: -- cgit v1.2.3 From 7390d327f19df4d0da38ef6d989aa99bfd08b684 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Thu, 29 Sep 2011 16:58:22 -0400 Subject: COMMON: Ensure numTypes is set to 0 on close --- common/macresman.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'common') diff --git a/common/macresman.cpp b/common/macresman.cpp index c1cab8b96a..2b9c68ade9 100644 --- a/common/macresman.cpp +++ b/common/macresman.cpp @@ -69,6 +69,7 @@ void MacResManager::close() { delete[] _resLists; _resLists = 0; delete[] _resTypes; _resTypes = 0; delete _stream; _stream = 0; + _resMap.numTypes = 0; } bool MacResManager::hasDataFork() const { -- cgit v1.2.3 From 5dfa4333d1a566f064101ca505cd15c77e3c86c0 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sat, 7 Apr 2012 21:19:11 -0400 Subject: COMMON: Hopefully fix AppleDouble files with directories --- common/macresman.cpp | 22 +++++++++++++++++++--- common/macresman.h | 2 ++ 2 files changed, 21 insertions(+), 3 deletions(-) (limited to 'common') diff --git a/common/macresman.cpp b/common/macresman.cpp index 14bdfa7080..f2f020c6de 100644 --- a/common/macresman.cpp +++ b/common/macresman.cpp @@ -124,7 +124,7 @@ bool MacResManager::open(String filename) { File *file = new File(); // First, let's try to see if the Mac converted name exists - if (file->open("._" + filename) && loadFromAppleDouble(*file)) { + if (file->open(constructAppleDoubleName(filename)) && loadFromAppleDouble(*file)) { _baseFileName = filename; return true; } @@ -185,7 +185,7 @@ bool MacResManager::open(FSNode path, String filename) { #endif // First, let's try to see if the Mac converted name exists - FSNode fsNode = path.getChild("._" + filename); + FSNode fsNode = path.getChild(constructAppleDoubleName(filename)); if (fsNode.exists() && !fsNode.isDirectory()) { SeekableReadStream *stream = fsNode.createReadStream(); if (loadFromAppleDouble(*stream)) { @@ -253,7 +253,7 @@ bool MacResManager::exists(const String &filename) { return true; // Check if we have an AppleDouble file - if (tempFile.open("._" + filename) && tempFile.readUint32BE() == 0x00051607) + if (tempFile.open(constructAppleDoubleName(filename)) && tempFile.readUint32BE() == 0x00051607) return true; return false; @@ -574,4 +574,20 @@ void MacResManager::readMap() { } } +Common::String MacResManager::constructAppleDoubleName(Common::String name) { + // Insert "._" before the last portion of a path name + for (int i = name.size() - 1; i >= 0; i--) { + if (i == 0) { + name.insertChar('_', 0); + name.insertChar('.', 0); + } else if (name[i] == '/') { + name.insertChar('_', i + 1); + name.insertChar('.', i + 1); + break; + } + } + + return name; +} + } // End of namespace Common diff --git a/common/macresman.h b/common/macresman.h index 6820106925..f334405664 100644 --- a/common/macresman.h +++ b/common/macresman.h @@ -175,6 +175,8 @@ private: bool loadFromMacBinary(SeekableReadStream &stream); bool loadFromAppleDouble(SeekableReadStream &stream); + static Common::String constructAppleDoubleName(Common::String name); + enum { kResForkNone = 0, kResForkRaw, -- cgit v1.2.3 From f58d834cdaf4ddd741ccdcb0f9a7d0f2adcfa785 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Mon, 9 Apr 2012 11:18:55 -0400 Subject: COMMON: Add a KBD_META key state flag --- common/keyboard.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/keyboard.h b/common/keyboard.h index e6db086598..64c6cc4d01 100644 --- a/common/keyboard.h +++ b/common/keyboard.h @@ -224,12 +224,13 @@ enum { KBD_CTRL = 1 << 0, KBD_ALT = 1 << 1, KBD_SHIFT = 1 << 2, - KBD_NON_STICKY = (KBD_CTRL|KBD_ALT|KBD_SHIFT), + KBD_META = 1 << 3, + KBD_NON_STICKY = (KBD_CTRL|KBD_ALT|KBD_SHIFT|KBD_META), // Sticky modifier flags - KBD_NUM = 1 << 3, - KBD_CAPS = 1 << 4, - KBD_SCRL = 1 << 5, + KBD_NUM = 1 << 4, + KBD_CAPS = 1 << 5, + KBD_SCRL = 1 << 6, KBD_STICKY = (KBD_NUM|KBD_CAPS|KBD_SCRL) }; -- cgit v1.2.3 From 2f9b1b67b08f1b70cd95795aaf7816ca7f991649 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Fri, 31 Aug 2012 22:26:02 -0400 Subject: ALL: Mark off some things as used by Pegasus --- common/macresman.h | 1 + 1 file changed, 1 insertion(+) (limited to 'common') diff --git a/common/macresman.h b/common/macresman.h index f334405664..ed74da9cc6 100644 --- a/common/macresman.h +++ b/common/macresman.h @@ -25,6 +25,7 @@ * Macintosh resource fork manager used in engines: * - groovie * - mohawk + * - pegasus * - sci * - scumm */ -- cgit v1.2.3 From 89abab97e3124fa25eb4c7d3e8b38501747a8d17 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 26 Sep 2012 04:17:31 +0200 Subject: JANITORIAL: Remove trailing whitespaces. Powered by: git ls-files "*.cpp" "*.h" "*.m" "*.mm" | xargs sed -i -e 's/[ \t]*$//' --- common/array.h | 2 +- common/coroutines.cpp | 4 ++-- common/cosinetables.cpp | 2 +- common/gui_options.h | 2 +- common/quicktime.h | 2 +- common/savefile.h | 4 ++-- common/sinetables.cpp | 2 +- common/zlib.h | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) (limited to 'common') diff --git a/common/array.h b/common/array.h index a2c3023362..ca89523a0b 100644 --- a/common/array.h +++ b/common/array.h @@ -332,7 +332,7 @@ protected: // Copy a part of the new data to the position inside the // initialized space. copy(first, first + (_size - idx), pos); - + // Copy a part of the new data to the position inside the // uninitialized space. uninitialized_copy(first + (_size - idx), last, _storage + _size); diff --git a/common/coroutines.cpp b/common/coroutines.cpp index 7209ea3024..849b881177 100644 --- a/common/coroutines.cpp +++ b/common/coroutines.cpp @@ -717,12 +717,12 @@ void CoroutineScheduler::pulseEvent(uint32 pidEvent) { EVENT *evt = getEvent(pidEvent); if (!evt) return; - + // Set the event as signalled and pulsing evt->signalled = true; evt->pulsing = true; - // If there's an active process, and it's not the first in the queue, then reschedule all + // If there's an active process, and it's not the first in the queue, then reschedule all // the other prcoesses in the queue to run again this frame if (pCurrent && pCurrent != active->pNext) rescheduleAll(); diff --git a/common/cosinetables.cpp b/common/cosinetables.cpp index bf158e904f..fe8f454e14 100644 --- a/common/cosinetables.cpp +++ b/common/cosinetables.cpp @@ -36,7 +36,7 @@ CosineTable::CosineTable(int bitPrecision) { double freq = 2 * M_PI / m; _table = new float[m]; - // Table contains cos(2*pi*x/n) for 0<=x<=n/4, + // Table contains cos(2*pi*x/n) for 0<=x<=n/4, // followed by its reverse for (int i = 0; i <= m / 4; i++) _table[i] = cos(i * freq); diff --git a/common/gui_options.h b/common/gui_options.h index 9da19b1c3e..447fff43ed 100644 --- a/common/gui_options.h +++ b/common/gui_options.h @@ -55,7 +55,7 @@ #define GUIO_RENDERPC9821 "\037" #define GUIO_RENDERPC9801 "\040" -// Special GUIO flags for the AdvancedDetector's caching of game specific +// Special GUIO flags for the AdvancedDetector's caching of game specific // options. #define GUIO_GAMEOPTIONS1 "\041" #define GUIO_GAMEOPTIONS2 "\042" diff --git a/common/quicktime.h b/common/quicktime.h index 08ca35ad51..641718e13a 100644 --- a/common/quicktime.h +++ b/common/quicktime.h @@ -168,7 +168,7 @@ protected: Rational _scaleFactorX; Rational _scaleFactorY; Array _tracks; - + void init(); private: diff --git a/common/savefile.h b/common/savefile.h index da787289ee..19536da54f 100644 --- a/common/savefile.h +++ b/common/savefile.h @@ -109,12 +109,12 @@ public: * * Saved games are compressed by default, and engines are expected to * always write compressed saves. - * + * * A notable exception is if uncompressed files are needed for * compatibility with games not supported by ScummVM, such as character * exports from the Quest for Glory series. QfG5 is a 3D game and won't be * supported by ScummVM. - * + * * @param name the name of the savefile * @param compress toggles whether to compress the resulting save file * (default) or not. diff --git a/common/sinetables.cpp b/common/sinetables.cpp index a4467383cc..a6ec99469d 100644 --- a/common/sinetables.cpp +++ b/common/sinetables.cpp @@ -36,7 +36,7 @@ SineTable::SineTable(int bitPrecision) { double freq = 2 * M_PI / m; _table = new float[m]; - // Table contains sin(2*pi*x/n) for 0<=x<=n/4, + // Table contains sin(2*pi*x/n) for 0<=x<=n/4, // followed by its reverse for (int i = 0; i <= m / 4; i++) _table[i] = sin(i * freq); diff --git a/common/zlib.h b/common/zlib.h index b2d321d502..6a840f5fdc 100644 --- a/common/zlib.h +++ b/common/zlib.h @@ -114,7 +114,7 @@ bool inflateZlibInstallShield(byte *dst, uint dstLen, const byte *src, uint srcL * returned). * * @param toBeWrapped the stream to be wrapped (if it is in gzip-format) - * @param knownSize a supplied length of the compressed data (if not available directly) + * @param knownSize a supplied length of the compressed data (if not available directly) */ SeekableReadStream *wrapCompressedReadStream(SeekableReadStream *toBeWrapped, uint32 knownSize = 0); -- cgit v1.2.3 From efe2fe7e1ffcb423d0349ee2a508f8ec0d715642 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 9 Oct 2012 22:56:23 +0200 Subject: COMMON: Properly handle error indicator in MemoryWriteStream. Thanks to waltervn for noticing that MemoryWriteStream::write doesn't handle setting the error indicator properly. --- common/memstream.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/memstream.h b/common/memstream.h index 69fe6ec18e..497a178ab9 100644 --- a/common/memstream.h +++ b/common/memstream.h @@ -92,13 +92,17 @@ private: byte *_ptr; const uint32 _bufSize; uint32 _pos; + bool _err; public: - MemoryWriteStream(byte *buf, uint32 len) : _ptr(buf), _bufSize(len), _pos(0) {} + MemoryWriteStream(byte *buf, uint32 len) : _ptr(buf), _bufSize(len), _pos(0), _err(false) {} uint32 write(const void *dataPtr, uint32 dataSize) { // Write at most as many bytes as are still available... - if (dataSize > _bufSize - _pos) + if (dataSize > _bufSize - _pos) { dataSize = _bufSize - _pos; + // We couldn't write all the data => set error indicator + _err = true; + } memcpy(_ptr, dataPtr, dataSize); _ptr += dataSize; _pos += dataSize; @@ -107,6 +111,9 @@ public: uint32 pos() const { return _pos; } uint32 size() const { return _bufSize; } + + virtual bool err() const { return _err; } + virtual void clearErr() { _err = false; } }; /** -- cgit v1.2.3