diff options
author | Paul Gilbert | 2012-10-31 09:34:38 +1100 |
---|---|---|
committer | Paul Gilbert | 2012-10-31 09:34:38 +1100 |
commit | 798ddfaab500bb212f620cf095328eee5eb140a4 (patch) | |
tree | 55b5d0b90affd88063c04b7ff62fea1616b83e80 /common | |
parent | ef663f95a516d8fe47a245653d418c047361281a (diff) | |
parent | fdc80fd952120ecb8a4941edd4c2e404cdc5fa33 (diff) | |
download | scummvm-rg350-798ddfaab500bb212f620cf095328eee5eb140a4.tar.gz scummvm-rg350-798ddfaab500bb212f620cf095328eee5eb140a4.tar.bz2 scummvm-rg350-798ddfaab500bb212f620cf095328eee5eb140a4.zip |
Merge branch 'master' into hopkins
Diffstat (limited to 'common')
-rw-r--r-- | common/array.h | 2 | ||||
-rw-r--r-- | common/coroutines.cpp | 4 | ||||
-rw-r--r-- | common/cosinetables.cpp | 2 | ||||
-rw-r--r-- | common/gui_options.h | 2 | ||||
-rw-r--r-- | common/keyboard.h | 9 | ||||
-rw-r--r-- | common/macresman.cpp | 22 | ||||
-rw-r--r-- | common/macresman.h | 3 | ||||
-rw-r--r-- | common/memstream.h | 11 | ||||
-rw-r--r-- | common/quicktime.h | 2 | ||||
-rw-r--r-- | common/rational.h | 3 | ||||
-rw-r--r-- | common/rect.h | 14 | ||||
-rw-r--r-- | common/savefile.h | 4 | ||||
-rw-r--r-- | common/sinetables.cpp | 2 | ||||
-rw-r--r-- | common/zlib.h | 2 |
14 files changed, 63 insertions, 19 deletions
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/keyboard.h b/common/keyboard.h index f9e94e6656..3262a15c3f 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) }; 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..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 */ @@ -175,6 +176,8 @@ private: bool loadFromMacBinary(SeekableReadStream &stream); bool loadFromAppleDouble(SeekableReadStream &stream); + static Common::String constructAppleDoubleName(Common::String name); + enum { kResForkNone = 0, kResForkRaw, 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; } }; /** 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<Track *> _tracks; - + void init(); private: 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: diff --git a/common/rect.h b/common/rect.h index 2bd3affafe..8d1243f7e4 100644 --- a/common/rect.h +++ b/common/rect.h @@ -170,6 +170,20 @@ struct Rect { } /** + * 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 * * @param r the rectangle to extend by 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); |